@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.
Files changed (283) hide show
  1. package/README.md +4 -3
  2. package/dist/abort-signals-2GUraIGq.js +34 -0
  3. package/dist/agent-DZ-OKOHn.js +6850 -0
  4. package/dist/anthropic-messages-5ODquUB-.js +14317 -0
  5. package/dist/{apiContracts-CHOiCbS_.js → apiContracts-b33nSAAI.js} +18 -81
  6. package/dist/{approval-BMXqnTYd.js → approval-r3NnI1VC.js} +19 -3
  7. package/dist/{approvalPrompt-Bg1JrEEY.js → approvalPrompt-DWoXxu3S.js} +2 -2
  8. package/dist/artifactFiles-DLCReI0-.js +1 -0
  9. package/dist/assets/assets/{CodeEditorView-BnyZHaYM.js → CodeEditorView-XeNS0L9M.js} +2 -2
  10. package/dist/assets/assets/{abnfDiagram-WEYOIA3C-muME0eCj.js → abnfDiagram-WEYOIA3C-B6ZW0nkR.js} +2 -2
  11. package/dist/assets/assets/{architecture-WOLXFQ4H-DMnhK1WH.js → architecture-WOLXFQ4H-bVR64sHO.js} +1 -1
  12. package/dist/assets/assets/{architectureDiagram-ZHVYKT53-DKn7XGP7.js → architectureDiagram-ZHVYKT53-D7tZz3io.js} +2 -2
  13. package/dist/assets/assets/{blockDiagram-RJAE7QA3-DtDctXZg.js → blockDiagram-RJAE7QA3-DdwScfiX.js} +2 -2
  14. package/dist/assets/assets/{c4Diagram-XDPPPE54-23pGLJeP.js → c4Diagram-XDPPPE54-DgSxZJCV.js} +2 -2
  15. package/dist/assets/assets/channel-TPcVvp_3.js +2 -0
  16. package/dist/assets/assets/{chunk-2E7WHVMD-BZ2nGNPa.js → chunk-2E7WHVMD-D5TXC2SM.js} +2 -2
  17. package/dist/assets/assets/{chunk-4EMNKR2T-Dui1SYFi.js → chunk-4EMNKR2T-BWhOSvo1.js} +2 -2
  18. package/dist/assets/assets/{chunk-55XCU76K-CUB92Evl.js → chunk-55XCU76K-HkkBzLtZ.js} +2 -2
  19. package/dist/assets/assets/{chunk-7S6XSTFO-CVayPHfE.js → chunk-7S6XSTFO-CBnjycLU.js} +2 -2
  20. package/dist/assets/assets/{chunk-AQDTSKZB---wakYqY.js → chunk-AQDTSKZB-75lIIq8T.js} +2 -2
  21. package/dist/assets/assets/{chunk-DSNLSHJZ-DfbdohUR.js → chunk-DSNLSHJZ-D8PpnXMk.js} +2 -2
  22. package/dist/assets/assets/{chunk-HAGFOTED-Dr4KRh-b.js → chunk-HAGFOTED-CXRS2NIN.js} +2 -2
  23. package/dist/assets/assets/{chunk-HNE4Q36P-D06cR91Z.js → chunk-HNE4Q36P-BocUqS94.js} +2 -2
  24. package/dist/assets/assets/{chunk-NQOKRVIF-Ca4gLeDb.js → chunk-NQOKRVIF-CHf_ogYT.js} +2 -2
  25. package/dist/assets/assets/{chunk-UHW7PFBP-DmL638jN.js → chunk-UHW7PFBP-DrW1PaIv.js} +2 -2
  26. package/dist/assets/assets/{chunk-VQ5W62QI-pkxSW5Zj.js → chunk-VQ5W62QI-CLoA7bFm.js} +2 -2
  27. package/dist/assets/assets/{chunk-WQQL4CDK-Dcc8hV4U.js → chunk-WQQL4CDK-BmBsrj9I.js} +2 -2
  28. package/dist/assets/assets/chunk-XXDRQBXY-iFE4Tl8c.js +2 -0
  29. package/dist/assets/assets/{chunk-YZO67HFG-B_HKcFrw.js → chunk-YZO67HFG-DShE_cgv.js} +2 -2
  30. package/dist/assets/assets/{chunk-ZAUX2LTX-DAzZUysS.js → chunk-ZAUX2LTX-B3oLvSXy.js} +2 -2
  31. package/dist/assets/assets/{chunk-ZCHMQSOR-DAVgjymL.js → chunk-ZCHMQSOR-B14vKK7C.js} +2 -2
  32. package/dist/assets/assets/{classDiagram-v2-4MYWR3UA-Fsw8TGPu.js → classDiagram-v2-4MYWR3UA-Da8elIW2.js} +2 -2
  33. package/dist/assets/assets/{cose-bilkent-JH36ORCC-CgUbISYV.js → cose-bilkent-JH36ORCC-Du4tGtiJ.js} +2 -2
  34. package/dist/assets/assets/{cynefin-EF2NZ3EQ-D1LxAU2x.js → cynefin-EF2NZ3EQ-Cyj6i_WI.js} +1 -1
  35. package/dist/assets/assets/{cynefinDiagram-WF24UDRP-D54I1jil.js → cynefinDiagram-WF24UDRP-DFWXwO7A.js} +2 -2
  36. package/dist/assets/assets/{dagre-NK4GIZVX-DC7zL16U.js → dagre-NK4GIZVX-C1wB_cf-.js} +2 -2
  37. package/dist/assets/assets/{diagram-CBK3MWTC-DB0ptUdz.js → diagram-CBK3MWTC-MYCOBYl6.js} +2 -2
  38. package/dist/assets/assets/{diagram-I5XIIV2D-CozSftPJ.js → diagram-I5XIIV2D-BFYbKUFf.js} +2 -2
  39. package/dist/assets/assets/{diagram-ODIL2UCW-g3WOEWDS.js → diagram-ODIL2UCW-6siqTpv_.js} +2 -2
  40. package/dist/assets/assets/{diagram-PFBEJUXE-CFxGeOYi.js → diagram-PFBEJUXE-CaBr9CoB.js} +2 -2
  41. package/dist/assets/assets/{diagram-RJA3I4VV-BQBsLche.js → diagram-RJA3I4VV-DAvmuDpc.js} +2 -2
  42. package/dist/assets/assets/{diagram-TYUNFSNR-DrjpW2yq.js → diagram-TYUNFSNR-CJnhgCpo.js} +2 -2
  43. package/dist/assets/assets/{dist-DjL8d1jZ.js → dist-BQ4W1R18.js} +2 -2
  44. package/dist/assets/assets/{dist-DvgCCshF.js → dist-BnzFckPF.js} +2 -2
  45. package/dist/assets/assets/{dist-gfbb4ygy.js → dist-CFtBpcYL.js} +2 -2
  46. package/dist/assets/assets/{dist-BabjcJ3j.js → dist-CIQX1z4W.js} +2 -2
  47. package/dist/assets/assets/{dist-XIZum9n5.js → dist-ChHYoe9_.js} +2 -2
  48. package/dist/assets/assets/{dist-1-mhYUBH.js → dist-DKxZO8d9.js} +2 -2
  49. package/dist/assets/assets/{dist-h6SOnP8-.js → dist-DL6z28wl.js} +2 -2
  50. package/dist/assets/assets/{dist-B3JXhDWV.js → dist-DNyn1p9Z.js} +2 -2
  51. package/dist/assets/assets/{dist-Izr2SB3q.js → dist-qYlLXIa8.js} +2 -2
  52. package/dist/assets/assets/{ebnfDiagram-V4P3TTPT-BZS_aAve.js → ebnfDiagram-V4P3TTPT-AUcqDTM3.js} +2 -2
  53. package/dist/assets/assets/{elk-QONTBCTQ-B2ksVmMA.js → elk-QONTBCTQ-aA10PEHJ.js} +2 -2
  54. package/dist/assets/assets/{erDiagram-KYQIGQAA-7P6zF-Z-.js → erDiagram-KYQIGQAA-hhYiqA-x.js} +2 -2
  55. package/dist/assets/assets/{eventmodeling-K75KTNOO-RoGQoRq-.js → eventmodeling-K75KTNOO-BQZqbRo5.js} +1 -1
  56. package/dist/assets/assets/flowDiagram-IUGLLWBU-BuyysPYC.js +1 -0
  57. package/dist/assets/assets/{ganttDiagram-R7GPNTJY-CTOlRy7M.js → ganttDiagram-R7GPNTJY-CLON1GpW.js} +2 -2
  58. package/dist/assets/assets/{gitGraph-VSP46ZUC-CPqytIt0.js → gitGraph-VSP46ZUC-DbmvNwR2.js} +1 -1
  59. package/dist/assets/assets/{gitGraphDiagram-PDYL7XHY-BffLxuxg.js → gitGraphDiagram-PDYL7XHY-DJVO0WlL.js} +2 -2
  60. package/dist/assets/assets/index-BiTVAj5E.js +155 -0
  61. package/dist/assets/assets/index-CBNQEGK3.css +1 -0
  62. package/dist/assets/assets/{info-OHQRW6UA-BI8RK0Ow.js → info-OHQRW6UA-CAt3Nt3g.js} +1 -1
  63. package/dist/assets/assets/{infoDiagram-MVDRKAX5-DUIst1FB.js → infoDiagram-MVDRKAX5-DTuqH-Zb.js} +2 -2
  64. package/dist/assets/assets/{ishikawaDiagram-HPEHV2GE-CA17Eho5.js → ishikawaDiagram-HPEHV2GE-BnWvdonT.js} +2 -2
  65. package/dist/assets/assets/{journeyDiagram-BOSHW7O7-CNri5Ap9.js → journeyDiagram-BOSHW7O7-Btxtcgvl.js} +2 -2
  66. package/dist/assets/assets/{kanban-definition-FNSA4HC5-DnXna7jO.js → kanban-definition-FNSA4HC5-q7ek9o_H.js} +2 -2
  67. package/dist/assets/assets/{line-BsXJZn93.js → line-B7yLilmC.js} +2 -2
  68. package/dist/assets/assets/{linear-BHYaD5T0.js → linear-y8aSKEli.js} +2 -2
  69. package/dist/assets/assets/{mermaid-parser.core-B64Eo-8a.js → mermaid-parser.core-B4rH50nD.js} +4 -4
  70. package/dist/assets/assets/{mermaid.core-Zw9qmTzg.js → mermaid.core-DnRVHTjE.js} +5 -5
  71. package/dist/assets/assets/{mindmap-definition-6OY57UG3-E5qz4KNc.js → mindmap-definition-6OY57UG3-DT9Afs2v.js} +2 -2
  72. package/dist/assets/assets/{packet-JDAUHWVQ-DgfizTr3.js → packet-JDAUHWVQ-CnqNbu4p.js} +1 -1
  73. package/dist/assets/assets/{pegDiagram-ECIUJNBX-D0WK_agM.js → pegDiagram-ECIUJNBX-cvxdBBFq.js} +2 -2
  74. package/dist/assets/assets/{pie-XZMESJXO-PJR1sXD4.js → pie-XZMESJXO-etXMNsaL.js} +1 -1
  75. package/dist/assets/assets/{pieDiagram-GNMPY74T-CPuU-NTs.js → pieDiagram-GNMPY74T-CBN-R3_j.js} +2 -2
  76. package/dist/assets/assets/{quadrantDiagram-D57K4MC3-5C9yjM1b.js → quadrantDiagram-D57K4MC3-C5jjVPIH.js} +2 -2
  77. package/dist/assets/assets/{radar-ABXABTNO-BspdXgl0.js → radar-ABXABTNO-CAMd_mrV.js} +1 -1
  78. package/dist/assets/assets/{railroad-I3PHUGI6-Ct0a6hLD.js → railroad-I3PHUGI6-DIs3auoe.js} +1 -1
  79. package/dist/assets/assets/{railroad-abnf-LNEFI6M7-fduYB4SA.js → railroad-abnf-LNEFI6M7-CJXr1qWy.js} +1 -1
  80. package/dist/assets/assets/{railroad-ebnf-DWYD2UWJ-CTQa8Sww.js → railroad-ebnf-DWYD2UWJ-DfwtykqI.js} +1 -1
  81. package/dist/assets/assets/{railroad-peg-JR7BVNR7-DatoH3GJ.js → railroad-peg-JR7BVNR7-B8beAhTs.js} +1 -1
  82. package/dist/assets/assets/{railroadDiagram-Y72NRBL7-C8sWN8l2.js → railroadDiagram-Y72NRBL7-BDcQE-EL.js} +2 -2
  83. package/dist/assets/assets/{requirementDiagram-EQYSW5RA-CqRz4RcT.js → requirementDiagram-EQYSW5RA-KJ4-QjZM.js} +2 -2
  84. package/dist/assets/assets/{sankeyDiagram-SY24JHO5-bdiuKKlX.js → sankeyDiagram-SY24JHO5-VjIB-Ybr.js} +2 -2
  85. package/dist/assets/assets/{sequenceDiagram-BLEHNHQU-Zy-8I0Hy.js → sequenceDiagram-BLEHNHQU-MfMuWq1M.js} +2 -2
  86. package/dist/assets/assets/{src-gihY33R9.js → src-BAxIj8GJ.js} +2 -2
  87. package/dist/assets/assets/{stateDiagram-v2-A6IESKWZ-DXQERPvz.js → stateDiagram-v2-A6IESKWZ-mHwLRRCY.js} +2 -2
  88. package/dist/assets/assets/{swimlanes-B3ENRKFQ-1gjZQElg.js → swimlanes-B3ENRKFQ-PArlYoqV.js} +2 -2
  89. package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-The09-5S.js +9 -0
  90. package/dist/assets/assets/{timeline-definition-JXYKGLGB-CTeYEw-9.js → timeline-definition-JXYKGLGB-B2nKiNFU.js} +2 -2
  91. package/dist/assets/assets/{treeView-D4JQ5SDB-DD-EsLLT.js → treeView-D4JQ5SDB-gU23_RuI.js} +1 -1
  92. package/dist/assets/assets/{treemap-SAJKECNS-BLdFeS5J.js → treemap-SAJKECNS-CiqoMvZa.js} +1 -1
  93. package/dist/assets/assets/{usecaseDiagram-WPOLBNNX-C1GikSSP.js → usecaseDiagram-WPOLBNNX-DpeoWpMK.js} +2 -2
  94. package/dist/assets/assets/{vennDiagram-Q3Y3IDCW-B1FoA3g8.js → vennDiagram-Q3Y3IDCW-C31iGKvM.js} +2 -2
  95. package/dist/assets/assets/{wardley-7MLQ67FV-BrHb5Bjf.js → wardley-7MLQ67FV-CIzHhzNw.js} +1 -1
  96. package/dist/assets/assets/{wardleyDiagram-IVAIDKWA-CmPLD1X4.js → wardleyDiagram-IVAIDKWA-DIIkoezc.js} +2 -2
  97. package/dist/assets/assets/{webpack-BYWDFj_R.js → webpack-RFseiMZW.js} +2 -2
  98. package/dist/assets/assets/{xychartDiagram-4URNHDU4-DR5pfEjl.js → xychartDiagram-4URNHDU4-QiHL91kC.js} +2 -2
  99. package/dist/assets/bundle-asset-policy.json +1 -1
  100. package/dist/assets/index.html +2 -2
  101. package/dist/assets/plugins/assets/base-CKKRZ7-h.css +2 -0
  102. package/dist/assets/plugins/assets/browserCaptureWorklet-Droj0fW0-Droj0fW0.js +13 -0
  103. package/dist/assets/plugins/assets/ibm-plex-sans-cyrillic-ext-wght-normal-d45eAU9y.woff2 +0 -0
  104. package/dist/assets/plugins/assets/ibm-plex-sans-cyrillic-wght-normal-BAAhND-U.woff2 +0 -0
  105. package/dist/assets/plugins/assets/ibm-plex-sans-greek-wght-normal-CmyJS8uq.woff2 +0 -0
  106. package/dist/assets/plugins/assets/ibm-plex-sans-latin-ext-wght-normal-CIII54If.woff2 +0 -0
  107. package/dist/assets/plugins/assets/ibm-plex-sans-latin-wght-normal-IvpUvPa2.woff2 +0 -0
  108. package/dist/assets/plugins/assets/ibm-plex-sans-vietnamese-wght-normal-Dg1JeJN0.woff2 +0 -0
  109. package/dist/assets/plugins/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
  110. package/dist/assets/plugins/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  111. package/dist/assets/plugins/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  112. package/dist/assets/plugins/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  113. package/dist/assets/plugins/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  114. package/dist/assets/plugins/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  115. package/dist/assets/plugins/assets/sileroVadWorker-D894njUe-DjN_BMWf.mjs +110 -0
  116. package/dist/assets/plugins/assets/silero_vad_v6.2.1-SjbCxFXk-SjbCxFXk.onnx +0 -0
  117. package/dist/assets/plugins/chunks/po-web-runtime-BJDT6Lbw.js +1 -0
  118. package/dist/assets/plugins/compositions.json +1 -0
  119. package/dist/assets/plugins/slots/approval.293d9a00-BXIhaPlQ.js +2 -0
  120. package/dist/assets/plugins/slots/artifacts.24567664-ZzR0gbvy.js +1 -0
  121. package/dist/assets/plugins/slots/author.0998a880-DAbA-7rb.js +93 -0
  122. package/dist/assets/plugins/slots/autocompact.dd97d013-IVq4Z6qm.js +1 -0
  123. package/dist/assets/plugins/slots/builtin-tools.36d7400b-CpCLjRRN.js +7 -0
  124. package/dist/assets/plugins/slots/codemode.8eaee717-VWt9PqsU.js +10 -0
  125. package/dist/assets/plugins/slots/domain.5e95fc37-5PIUBqDe.js +1 -0
  126. package/dist/assets/plugins/slots/edit.385c9aa9-DNAjPNG5.js +7 -0
  127. package/dist/assets/plugins/slots/files.daf34ed8-CQaTz0i1.js +2 -0
  128. package/dist/assets/plugins/slots/goal.77ec9930-B8EkarBq.js +1 -0
  129. package/dist/assets/plugins/slots/grep.02052cdc-CIRhO2gY.js +1 -0
  130. package/dist/assets/plugins/slots/help.ecd4c0f9-naMF9NN1.js +3 -0
  131. package/dist/assets/plugins/slots/log.a86eb6d0-D5__rAZJ.js +4 -0
  132. package/dist/assets/plugins/slots/mcp.974af249-DPNHn9XH.js +109 -0
  133. package/dist/assets/plugins/slots/plan.bafb8f68-C5GEpybF.js +3 -0
  134. package/dist/assets/plugins/slots/profile.48851a1d-yX6tzV3x.js +1 -0
  135. package/dist/assets/plugins/slots/prompts.723d7748-B7zpPeoF.js +3 -0
  136. package/dist/assets/plugins/slots/read.46bf6536-Cw5Z5z5T.js +1 -0
  137. package/dist/assets/plugins/slots/runner.53e9bd76-CiQR_FPX.js +8 -0
  138. package/dist/assets/plugins/slots/skill.086701a4-CL6h_F-x.js +4 -0
  139. package/dist/assets/plugins/slots/vault.ac9935c8-DKERQYg4.js +1 -0
  140. package/dist/assets/plugins/slots/voice.e85ca7f9-DEgb-U9m.js +1 -0
  141. package/dist/assets/pwa/pwa.js +12 -12
  142. package/dist/assets/pwa/sw.js +4 -4
  143. package/dist/{atomicJson-BJfPFSYF.js → atomicJson-C_7F2zD1.js} +2 -3
  144. package/dist/azure-openai-config-COZUaRzM.js +55 -0
  145. package/dist/azure-openai-responses-Cs4k2HOd.js +183 -0
  146. package/dist/{backgroundWork-CeFrbRnj.js → backgroundWork-B1mPDYlf.js} +1 -1
  147. package/dist/browser-BWf8OMfl.js +3 -0
  148. package/dist/childSession-Cf2-kH4O.js +22 -0
  149. package/dist/classifier-shared-IhSH9hhh.js +106 -0
  150. package/dist/cloudflare-workers-ai-system-one-BNnc8MuH.js +52 -0
  151. package/dist/{codemode-DbPu0yJN.js → codemode-DQFmrosw.js} +5 -2
  152. package/dist/contracts-DD3f1Lpn.js +19 -0
  153. package/dist/diagnostics-1lYFeSJe.js +131 -0
  154. package/dist/{server-D3PQk1Gt.js → dist-B-vqs6tA.js} +1 -546
  155. package/dist/dist-Dvx5mlIR.js +50 -0
  156. package/dist/env-api-keys-Bow6MJe2.js +32 -0
  157. package/dist/error-body-CJk7jMUh.js +102 -0
  158. package/dist/esm-BKJy3O9-.js +1553 -0
  159. package/dist/exports-B0WMEXCP.js +34 -0
  160. package/dist/{remoteMcp-CMqZldeA.js → exports-D09VsUk-.js} +1153 -175
  161. package/dist/{exports-BNZz2DNU.js → exports-nV43ShA7.js} +25 -9
  162. package/dist/{extensionFile-CXOa5G4C.js → extensionFile-DNM4xsje.js} +26 -2
  163. package/dist/github-copilot-headers-D1RedfLn.js +22 -0
  164. package/dist/google-generative-ai-DXTILNT0.js +328 -0
  165. package/dist/google-shared-e4JDCTVP.js +19588 -0
  166. package/dist/google-vertex-a1lzvJfq.js +374 -0
  167. package/dist/{domains-BNjGTOPj.js → harnessState-Dwrk3lfv.js} +175 -16
  168. package/dist/{harnessStore-BT706Ly6.js → harnessStore-Z7yDLO45.js} +4 -5
  169. package/dist/hash-Dt6RIbkn.js +16 -0
  170. package/dist/headers-CwtEVQvr.js +17 -0
  171. package/dist/help-w6vVEZGL.js +101 -0
  172. package/dist/hubChannel-Cm-sxOvU.js +21 -0
  173. package/dist/hubRevisions-58pU2dW5.js +363 -0
  174. package/dist/identity-BgfHobJH.js +165 -0
  175. package/dist/index.edge-COJJ_Dv2.js +937 -0
  176. package/dist/index.edge-ChYa2LU4.js +14 -0
  177. package/dist/index.edge-ClLTmPFz.js +191 -0
  178. package/dist/index.edge-DyYmurS7.js +62 -0
  179. package/dist/index.edge-K0w5auwG.js +56 -0
  180. package/dist/index.edge-Xa5LLtxz.js +67 -0
  181. package/dist/iso-BPQViXM8.js +10 -0
  182. package/dist/{layeredConfig-DPQAnlXD.js → layeredConfig-CUkYUs1f.js} +193 -15
  183. package/dist/{majorModes-DbCfLZH3.js → majorModes-BB0PXgFn.js} +4 -14
  184. package/dist/majorModes-C7vtBs4D.js +1 -0
  185. package/dist/{mcpProjection-BsP0IEnb.js → mcpProjection-BtKzB6oK.js} +2 -2
  186. package/dist/migrations-5gbLIQIc.js +32 -0
  187. package/dist/mistral-conversations-CLwhVDjA.js +689 -0
  188. package/dist/modeDefinition-C3Zbrw48.js +44 -0
  189. package/dist/models-Chzm15vC.js +1511 -0
  190. package/dist/narration-CpRurWLO.js +127 -0
  191. package/dist/node-BT4GsJQp.js +2479 -0
  192. package/dist/node-DytJOfYf.js +23 -0
  193. package/dist/notification-kckG3leF.js +102 -0
  194. package/dist/openai-codex-responses-DRMONxDE.js +1210 -0
  195. package/dist/openai-completions-CcNhAv8l.js +984 -0
  196. package/dist/openai-decisions-BsFjaAGw.js +142 -0
  197. package/dist/openai-kPrtlgjl.js +17357 -0
  198. package/dist/openai-prompt-cache-Bc6qNWt0.js +8 -0
  199. package/dist/openai-responses-C5Gp2UOV.js +281 -0
  200. package/dist/openai-responses-shared-BbSi-wBR.js +661 -0
  201. package/dist/openrouter-cost-CvC52g3b.js +30 -0
  202. package/dist/openrouter-images-BoHl8g8p.js +124 -0
  203. package/dist/{hubChannel-BHQyzcOo.js → packageApi-t1oCjNDU.js} +4 -41
  204. package/dist/photon_rs_bg.wasm +0 -0
  205. package/dist/pi-messages-BXfrZLC7.js +312 -0
  206. package/dist/piConfig-DQzlbPY4.js +126 -0
  207. package/dist/piSettings-Cf1QofNe.js +1 -0
  208. package/dist/platform-BIEiM4TG.js +113 -0
  209. package/dist/pluginContributions-Be9EnCAW.js +16 -0
  210. package/dist/pluginProtocol-BqXXyI4z.js +80 -0
  211. package/dist/{protocol-Xpm_mCNN.js → protocol-DDL8geoS.js} +2 -2
  212. package/dist/provider-env-CxhHUFiF.js +38 -0
  213. package/dist/provider-retry-BUoezuw8.js +79 -0
  214. package/dist/sanitize-unicode-C3Ec8oL6.js +26 -0
  215. package/dist/sealedChannel-BeWNTWys.js +27 -0
  216. package/dist/server-AbXyhXlY.js +217 -0
  217. package/dist/server-B6dqQoh2.js +1518 -0
  218. package/dist/server-BIHo9TFu.js +505 -0
  219. package/dist/{server-BZh1ZXz_.js → server-BJ7DNzCp.js} +8 -19
  220. package/dist/server-BO-j_GbD.js +15106 -0
  221. package/dist/{server-D4W7EdJY.js → server-BQzAiMns.js} +16 -16
  222. package/dist/server-BR7SZtj7.js +3125 -0
  223. package/dist/{server-BE6VqEiA.js → server-BT2ORK83.js} +20 -12
  224. package/dist/server-BbSHYRnY.js +295 -0
  225. package/dist/server-BqoKlEGk.js +1806 -0
  226. package/dist/{server-tvgQ99rv.js → server-Busl0pQI.js} +370 -120
  227. package/dist/server-CIHM4jqu.js +1116 -0
  228. package/dist/server-CgWSSdvd.js +576 -0
  229. package/dist/{server-Dpgh8PDh.js → server-Co_UWKrR.js} +14 -5
  230. package/dist/{server-BAAL9-NA.js → server-CuEPb7u-.js} +3 -10
  231. package/dist/{server-Dt4y1rZD.js → server-D40q2Jpx.js} +47 -27
  232. package/dist/server-DCyf2Asb.js +679 -0
  233. package/dist/server-DH7PfLln.js +148 -0
  234. package/dist/server-DJ8bc89M.js +934 -0
  235. package/dist/server-DYdp0W9v.js +489 -0
  236. package/dist/server-DsdPEYGu.js +639 -0
  237. package/dist/server-DymH4Ucq.js +189 -0
  238. package/dist/server-IqECnUrb.js +834 -0
  239. package/dist/{server-36iuA3MI.js → server-KBgW77zh.js} +3 -3
  240. package/dist/server-RW_9R3R3.js +1522 -0
  241. package/dist/server-aUit8j6r.js +1028 -0
  242. package/dist/{server-DJAanjoI.js → server-gifRriZK.js} +491 -103
  243. package/dist/server-nkUlqnAL.js +2658 -0
  244. package/dist/server-oxyEbv1a.js +1256 -0
  245. package/dist/{server-D8ndq0wL.js → server-ub3s16Mc.js} +11 -9
  246. package/dist/{build-2gFaVEfG.js → serverPlugin-CELT6P0Q.js} +3946 -3
  247. package/dist/{sessionConfig-rBQgzXlT.js → sessionConfig-RQGvfm6E.js} +550 -760
  248. package/dist/simple-options-CFzI5Pd_.js +156 -0
  249. package/dist/streaming-json-BWTHTwz-.js +858 -0
  250. package/dist/system-one-shared-CiIrx29d.js +132 -0
  251. package/dist/{notification-D76PSL7r.js → telemetry-Csv1ZxAn.js} +1 -92
  252. package/dist/transform-messages-D77af7Bx.js +356 -0
  253. package/dist/truncate-M3KbFyVj.js +89 -0
  254. package/dist/{server-A-_GFpPr.js → type-ASYnCGVW.js} +10 -1031
  255. package/dist/typesafe-system-one-DGxeggJh.js +37 -0
  256. package/dist/uuid-B0QJx6Kr.js +31 -0
  257. package/dist/{validation-D77NZBrx.js → validation-BJxVSAwx.js} +8 -3
  258. package/dist/{value-Djvc2foV.js → value-_W31So3B.js} +1 -1
  259. package/dist/vaultSettings-Di3n5YIg.js +328 -0
  260. package/dist/voiceTools-RMn4HvWo.js +246 -0
  261. package/dist/web-DCP7ELJj.js +3 -0
  262. package/dist/worker.js +95288 -49863
  263. package/dist/workflow-B7qx0Vv9.js +79 -0
  264. package/package.json +37 -22
  265. package/wrangler.jsonc +4 -2
  266. package/dist/assets/assets/channel-CMrEzemr.js +0 -2
  267. package/dist/assets/assets/chunk-XXDRQBXY-CFf0S6bN.js +0 -2
  268. package/dist/assets/assets/flowDiagram-IUGLLWBU-BhGbWVf0.js +0 -1
  269. package/dist/assets/assets/index-Bx_K4Joy.js +0 -155
  270. package/dist/assets/assets/index-DZM68mTk.css +0 -1
  271. package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-q91tR8ri.js +0 -9
  272. package/dist/contextProjection-DVP2Vc5j.js +0 -188
  273. package/dist/harnessState-gmzJcPGt.js +0 -88
  274. package/dist/harnessStore-BiH9vSuD.js +0 -1
  275. package/dist/index.edge-BgSx_gRO.js +0 -45
  276. package/dist/majorModes-BvWNqoHt.js +0 -1
  277. package/dist/piSettings-B6fsgIBA.js +0 -1
  278. package/dist/platform-B4AAgwJ0.js +0 -16
  279. package/dist/platformFiles-C_bXo4Ig.js +0 -39
  280. package/dist/server-BZaPPoQp.js +0 -592
  281. package/dist/server-D75MWDhB.js +0 -118
  282. package/dist/server-r358hzQg.js +0 -280
  283. package/dist/serverPlugin-BOI6c6s5.js +0 -3393
@@ -0,0 +1,937 @@
1
+ import photonWasm from "./photon_rs_bg.wasm";
2
+ //#region ../../../node_modules/.pnpm/@silvia-odwyer+photon@0.3.3/node_modules/@silvia-odwyer/photon/photon_rs.js
3
+ let wasm;
4
+ function debugString(val) {
5
+ const type = typeof val;
6
+ if (type == "number" || type == "boolean" || val == null) return `${val}`;
7
+ if (type == "string") return `"${val}"`;
8
+ if (type == "symbol") {
9
+ const description = val.description;
10
+ if (description == null) return "Symbol";
11
+ else return `Symbol(${description})`;
12
+ }
13
+ if (type == "function") {
14
+ const name = val.name;
15
+ if (typeof name == "string" && name.length > 0) return `Function(${name})`;
16
+ else return "Function";
17
+ }
18
+ if (Array.isArray(val)) {
19
+ const length = val.length;
20
+ let debug = "[";
21
+ if (length > 0) debug += debugString(val[0]);
22
+ for (let i = 1; i < length; i++) debug += ", " + debugString(val[i]);
23
+ debug += "]";
24
+ return debug;
25
+ }
26
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
27
+ let className;
28
+ if (builtInMatches.length > 1) className = builtInMatches[1];
29
+ else return toString.call(val);
30
+ if (className == "Object") try {
31
+ return "Object(" + JSON.stringify(val) + ")";
32
+ } catch (_) {
33
+ return "Object";
34
+ }
35
+ if (val instanceof Error) return `${val.name}: ${val.message}\n${val.stack}`;
36
+ return className;
37
+ }
38
+ let WASM_VECTOR_LEN = 0;
39
+ let cachedUint8ArrayMemory0 = null;
40
+ function getUint8ArrayMemory0() {
41
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
42
+ return cachedUint8ArrayMemory0;
43
+ }
44
+ const cachedTextEncoder = typeof TextEncoder !== "undefined" ? new TextEncoder("utf-8") : { encode: () => {
45
+ throw Error("TextEncoder not available");
46
+ } };
47
+ const encodeString = typeof cachedTextEncoder.encodeInto === "function" ? function(arg, view) {
48
+ return cachedTextEncoder.encodeInto(arg, view);
49
+ } : function(arg, view) {
50
+ const buf = cachedTextEncoder.encode(arg);
51
+ view.set(buf);
52
+ return {
53
+ read: arg.length,
54
+ written: buf.length
55
+ };
56
+ };
57
+ function passStringToWasm0(arg, malloc, realloc) {
58
+ if (realloc === void 0) {
59
+ const buf = cachedTextEncoder.encode(arg);
60
+ const ptr = malloc(buf.length, 1) >>> 0;
61
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
62
+ WASM_VECTOR_LEN = buf.length;
63
+ return ptr;
64
+ }
65
+ let len = arg.length;
66
+ let ptr = malloc(len, 1) >>> 0;
67
+ const mem = getUint8ArrayMemory0();
68
+ let offset = 0;
69
+ for (; offset < len; offset++) {
70
+ const code = arg.charCodeAt(offset);
71
+ if (code > 127) break;
72
+ mem[ptr + offset] = code;
73
+ }
74
+ if (offset !== len) {
75
+ if (offset !== 0) arg = arg.slice(offset);
76
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
77
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
78
+ const ret = encodeString(arg, view);
79
+ offset += ret.written;
80
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
81
+ }
82
+ WASM_VECTOR_LEN = offset;
83
+ return ptr;
84
+ }
85
+ let cachedDataViewMemory0 = null;
86
+ function getDataViewMemory0() {
87
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
88
+ return cachedDataViewMemory0;
89
+ }
90
+ const cachedTextDecoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf-8", {
91
+ ignoreBOM: true,
92
+ fatal: true
93
+ }) : { decode: () => {
94
+ throw Error("TextDecoder not available");
95
+ } };
96
+ if (typeof TextDecoder !== "undefined") cachedTextDecoder.decode();
97
+ function getStringFromWasm0(ptr, len) {
98
+ ptr = ptr >>> 0;
99
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
100
+ }
101
+ function _assertClass(instance, klass) {
102
+ if (!(instance instanceof klass)) throw new Error(`expected instance of ${klass.name}`);
103
+ return instance.ptr;
104
+ }
105
+ /**
106
+ * Flip an image horizontally.
107
+ *
108
+ * # Arguments
109
+ * * `img` - A PhotonImage.
110
+ *
111
+ * # Example
112
+ *
113
+ * ```no_run
114
+ * // For example, to flip an image horizontally:
115
+ * use photon_rs::native::open_image;
116
+ * use photon_rs::transform::fliph;
117
+ *
118
+ * let mut img = open_image("img.jpg").expect("File should open");
119
+ * fliph(&mut img);
120
+ * ```
121
+ * @param {PhotonImage} photon_image
122
+ */
123
+ function fliph(photon_image) {
124
+ _assertClass(photon_image, PhotonImage);
125
+ wasm.fliph(photon_image.__wbg_ptr);
126
+ }
127
+ /**
128
+ * Flip an image vertically.
129
+ *
130
+ * # Arguments
131
+ * * `img` - A PhotonImage.
132
+ *
133
+ * # Example
134
+ *
135
+ * ```no_run
136
+ * // For example, to flip an image vertically:
137
+ * use photon_rs::native::open_image;
138
+ * use photon_rs::transform::flipv;
139
+ *
140
+ * let mut img = open_image("img.jpg").expect("File should open");
141
+ * flipv(&mut img);
142
+ * ```
143
+ * @param {PhotonImage} photon_image
144
+ */
145
+ function flipv(photon_image) {
146
+ _assertClass(photon_image, PhotonImage);
147
+ wasm.flipv(photon_image.__wbg_ptr);
148
+ }
149
+ /**
150
+ * Resize an image.
151
+ *
152
+ * # Arguments
153
+ * * `img` - A PhotonImage.
154
+ * * `width` - New width.
155
+ * * `height` - New height.
156
+ * * `sampling_filter` - Nearest = 1, Triangle = 2, CatmullRom = 3, Gaussian = 4, Lanczos3 = 5
157
+ * @param {PhotonImage} photon_img
158
+ * @param {number} width
159
+ * @param {number} height
160
+ * @param {SamplingFilter} sampling_filter
161
+ * @returns {PhotonImage}
162
+ */
163
+ function resize(photon_img, width, height, sampling_filter) {
164
+ _assertClass(photon_img, PhotonImage);
165
+ const ret = wasm.resize(photon_img.__wbg_ptr, width, height, sampling_filter);
166
+ return PhotonImage.__wrap(ret);
167
+ }
168
+ function passArray8ToWasm0(arg, malloc) {
169
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
170
+ getUint8ArrayMemory0().set(arg, ptr / 1);
171
+ WASM_VECTOR_LEN = arg.length;
172
+ return ptr;
173
+ }
174
+ function getArrayU8FromWasm0(ptr, len) {
175
+ ptr = ptr >>> 0;
176
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
177
+ }
178
+ function isLikeNone(x) {
179
+ return x === void 0 || x === null;
180
+ }
181
+ function addToExternrefTable0(obj) {
182
+ const idx = wasm.__externref_table_alloc();
183
+ wasm.__wbindgen_export_2.set(idx, obj);
184
+ return idx;
185
+ }
186
+ function handleError(f, args) {
187
+ try {
188
+ return f.apply(this, args);
189
+ } catch (e) {
190
+ const idx = addToExternrefTable0(e);
191
+ wasm.__wbindgen_exn_store(idx);
192
+ }
193
+ }
194
+ let cachedUint8ClampedArrayMemory0 = null;
195
+ function getUint8ClampedArrayMemory0() {
196
+ if (cachedUint8ClampedArrayMemory0 === null || cachedUint8ClampedArrayMemory0.byteLength === 0) cachedUint8ClampedArrayMemory0 = new Uint8ClampedArray(wasm.memory.buffer);
197
+ return cachedUint8ClampedArrayMemory0;
198
+ }
199
+ function getClampedArrayU8FromWasm0(ptr, len) {
200
+ ptr = ptr >>> 0;
201
+ return getUint8ClampedArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
202
+ }
203
+ const SamplingFilter = Object.freeze({
204
+ Nearest: 1,
205
+ "1": "Nearest",
206
+ Triangle: 2,
207
+ "2": "Triangle",
208
+ CatmullRom: 3,
209
+ "3": "CatmullRom",
210
+ Gaussian: 4,
211
+ "4": "Gaussian",
212
+ Lanczos3: 5,
213
+ "5": "Lanczos3"
214
+ });
215
+ const PhotonImageFinalization = typeof FinalizationRegistry === "undefined" ? {
216
+ register: () => {},
217
+ unregister: () => {}
218
+ } : new FinalizationRegistry((ptr) => wasm.__wbg_photonimage_free(ptr >>> 0, 1));
219
+ /**
220
+ * Provides the image's height, width, and contains the image's raw pixels.
221
+ * For use when communicating between JS and WASM, and also natively.
222
+ */
223
+ var PhotonImage = class PhotonImage {
224
+ static __wrap(ptr) {
225
+ ptr = ptr >>> 0;
226
+ const obj = Object.create(PhotonImage.prototype);
227
+ obj.__wbg_ptr = ptr;
228
+ PhotonImageFinalization.register(obj, obj.__wbg_ptr, obj);
229
+ return obj;
230
+ }
231
+ __destroy_into_raw() {
232
+ const ptr = this.__wbg_ptr;
233
+ this.__wbg_ptr = 0;
234
+ PhotonImageFinalization.unregister(this);
235
+ return ptr;
236
+ }
237
+ free() {
238
+ const ptr = this.__destroy_into_raw();
239
+ wasm.__wbg_photonimage_free(ptr, 0);
240
+ }
241
+ /**
242
+ * Create a new PhotonImage from a Vec of u8s, which represent raw pixels.
243
+ * @param {Uint8Array} raw_pixels
244
+ * @param {number} width
245
+ * @param {number} height
246
+ */
247
+ constructor(raw_pixels, width, height) {
248
+ const ptr0 = passArray8ToWasm0(raw_pixels, wasm.__wbindgen_malloc);
249
+ const len0 = WASM_VECTOR_LEN;
250
+ const ret = wasm.photonimage_new(ptr0, len0, width, height);
251
+ this.__wbg_ptr = ret >>> 0;
252
+ PhotonImageFinalization.register(this, this.__wbg_ptr, this);
253
+ return this;
254
+ }
255
+ /**
256
+ * Create a new PhotonImage from a base64 string.
257
+ * @param {string} base64
258
+ * @returns {PhotonImage}
259
+ */
260
+ static new_from_base64(base64) {
261
+ const ptr0 = passStringToWasm0(base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
262
+ const len0 = WASM_VECTOR_LEN;
263
+ const ret = wasm.base64_to_image(ptr0, len0);
264
+ return PhotonImage.__wrap(ret);
265
+ }
266
+ /**
267
+ * Create a new PhotonImage from a byteslice.
268
+ * @param {Uint8Array} vec
269
+ * @returns {PhotonImage}
270
+ */
271
+ static new_from_byteslice(vec) {
272
+ const ptr0 = passArray8ToWasm0(vec, wasm.__wbindgen_malloc);
273
+ const len0 = WASM_VECTOR_LEN;
274
+ const ret = wasm.photonimage_new_from_byteslice(ptr0, len0);
275
+ return PhotonImage.__wrap(ret);
276
+ }
277
+ /**
278
+ * Create a new PhotonImage from a Blob/File.
279
+ * @param {Blob} blob
280
+ * @returns {PhotonImage}
281
+ */
282
+ static new_from_blob(blob) {
283
+ const ret = wasm.photonimage_new_from_blob(blob);
284
+ return PhotonImage.__wrap(ret);
285
+ }
286
+ /**
287
+ * Create a new PhotonImage from a HTMLImageElement
288
+ * @param {HTMLImageElement} image
289
+ * @returns {PhotonImage}
290
+ */
291
+ static new_from_image(image) {
292
+ const ret = wasm.photonimage_new_from_image(image);
293
+ return PhotonImage.__wrap(ret);
294
+ }
295
+ /**
296
+ * Get the width of the PhotonImage.
297
+ * @returns {number}
298
+ */
299
+ get_width() {
300
+ return wasm.photonimage_get_width(this.__wbg_ptr) >>> 0;
301
+ }
302
+ /**
303
+ * Get the PhotonImage's pixels as a Vec of u8s.
304
+ * @returns {Uint8Array}
305
+ */
306
+ get_raw_pixels() {
307
+ const ret = wasm.photonimage_get_raw_pixels(this.__wbg_ptr);
308
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
309
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
310
+ return v1;
311
+ }
312
+ /**
313
+ * Get the height of the PhotonImage.
314
+ * @returns {number}
315
+ */
316
+ get_height() {
317
+ return wasm.photonimage_get_height(this.__wbg_ptr) >>> 0;
318
+ }
319
+ /**
320
+ * Convert the PhotonImage to base64.
321
+ * @returns {string}
322
+ */
323
+ get_base64() {
324
+ let deferred1_0;
325
+ let deferred1_1;
326
+ try {
327
+ const ret = wasm.photonimage_get_base64(this.__wbg_ptr);
328
+ deferred1_0 = ret[0];
329
+ deferred1_1 = ret[1];
330
+ return getStringFromWasm0(ret[0], ret[1]);
331
+ } finally {
332
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
333
+ }
334
+ }
335
+ /**
336
+ * Convert the PhotonImage to raw bytes. Returns PNG.
337
+ * @returns {Uint8Array}
338
+ */
339
+ get_bytes() {
340
+ const ret = wasm.photonimage_get_bytes(this.__wbg_ptr);
341
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
342
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
343
+ return v1;
344
+ }
345
+ /**
346
+ * Convert the PhotonImage to raw bytes. Returns a JPEG.
347
+ * @param {number} quality
348
+ * @returns {Uint8Array}
349
+ */
350
+ get_bytes_jpeg(quality) {
351
+ const ret = wasm.photonimage_get_bytes_jpeg(this.__wbg_ptr, quality);
352
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
353
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
354
+ return v1;
355
+ }
356
+ /**
357
+ * Convert the PhotonImage to raw bytes. Returns a WEBP.
358
+ * @returns {Uint8Array}
359
+ */
360
+ get_bytes_webp() {
361
+ const ret = wasm.photonimage_get_bytes_webp(this.__wbg_ptr);
362
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
363
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
364
+ return v1;
365
+ }
366
+ /**
367
+ * Convert the PhotonImage's raw pixels to JS-compatible ImageData.
368
+ * @returns {ImageData}
369
+ */
370
+ get_image_data() {
371
+ return wasm.photonimage_get_image_data(this.__wbg_ptr);
372
+ }
373
+ /**
374
+ * Convert ImageData to raw pixels, and update the PhotonImage's raw pixels to this.
375
+ * @param {ImageData} img_data
376
+ */
377
+ set_imgdata(img_data) {
378
+ wasm.photonimage_set_imgdata(this.__wbg_ptr, img_data);
379
+ }
380
+ /**
381
+ * Calculates estimated filesize and returns number of bytes
382
+ * @returns {bigint}
383
+ */
384
+ get_estimated_filesize() {
385
+ const ret = wasm.photonimage_get_estimated_filesize(this.__wbg_ptr);
386
+ return BigInt.asUintN(64, ret);
387
+ }
388
+ };
389
+ typeof FinalizationRegistry === "undefined" || new FinalizationRegistry((ptr) => wasm.__wbg_rgb_free(ptr >>> 0, 1));
390
+ typeof FinalizationRegistry === "undefined" || new FinalizationRegistry((ptr) => wasm.__wbg_rgba_free(ptr >>> 0, 1));
391
+ async function __wbg_load(module, imports) {
392
+ if (typeof Response === "function" && module instanceof Response) {
393
+ if (typeof WebAssembly.instantiateStreaming === "function") try {
394
+ return await WebAssembly.instantiateStreaming(module, imports);
395
+ } catch (e) {
396
+ if (module.headers.get("Content-Type") != "application/wasm") console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
397
+ else throw e;
398
+ }
399
+ const bytes = await module.arrayBuffer();
400
+ return await WebAssembly.instantiate(bytes, imports);
401
+ } else {
402
+ const instance = await WebAssembly.instantiate(module, imports);
403
+ if (instance instanceof WebAssembly.Instance) return {
404
+ instance,
405
+ module
406
+ };
407
+ else return instance;
408
+ }
409
+ }
410
+ function __wbg_get_imports() {
411
+ const imports = {};
412
+ imports.wbg = {};
413
+ imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
414
+ return /* @__PURE__ */ new Error();
415
+ };
416
+ imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
417
+ const ret = arg1.stack;
418
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
419
+ const len1 = WASM_VECTOR_LEN;
420
+ getDataViewMemory0().setInt32(arg0 + 4, len1, true);
421
+ getDataViewMemory0().setInt32(arg0 + 0, ptr1, true);
422
+ };
423
+ imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
424
+ let deferred0_0;
425
+ let deferred0_1;
426
+ try {
427
+ deferred0_0 = arg0;
428
+ deferred0_1 = arg1;
429
+ console.error(getStringFromWasm0(arg0, arg1));
430
+ } finally {
431
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
432
+ }
433
+ };
434
+ imports.wbg.__wbg_instanceof_Window_c4b70662a0d2c5ec = function(arg0) {
435
+ let result;
436
+ try {
437
+ result = arg0 instanceof Window;
438
+ } catch (_) {
439
+ result = false;
440
+ }
441
+ return result;
442
+ };
443
+ imports.wbg.__wbg_document_e5c1786dea6542e4 = function(arg0) {
444
+ const ret = arg0.document;
445
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
446
+ };
447
+ imports.wbg.__wbg_body_e70ae6abd01ae584 = function(arg0) {
448
+ const ret = arg0.body;
449
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
450
+ };
451
+ imports.wbg.__wbg_createElement_5d4c76f218b78145 = function() {
452
+ return handleError(function(arg0, arg1, arg2) {
453
+ return arg0.createElement(getStringFromWasm0(arg1, arg2));
454
+ }, arguments);
455
+ };
456
+ imports.wbg.__wbg_width_4c6f0048d64cf86b = function(arg0) {
457
+ return arg0.width;
458
+ };
459
+ imports.wbg.__wbg_height_21f0d3fd8f753394 = function(arg0) {
460
+ return arg0.height;
461
+ };
462
+ imports.wbg.__wbg_width_79e0847ed5883b03 = function(arg0) {
463
+ return arg0.width;
464
+ };
465
+ imports.wbg.__wbg_height_e4e4e4779f8feac0 = function(arg0) {
466
+ return arg0.height;
467
+ };
468
+ imports.wbg.__wbg_data_fda507064d127f5b = function(arg0, arg1) {
469
+ const ret = arg1.data;
470
+ const ptr1 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc);
471
+ const len1 = WASM_VECTOR_LEN;
472
+ getDataViewMemory0().setInt32(arg0 + 4, len1, true);
473
+ getDataViewMemory0().setInt32(arg0 + 0, ptr1, true);
474
+ };
475
+ imports.wbg.__wbg_newwithu8clampedarrayandsh_1fddccb3a94a5e05 = function() {
476
+ return handleError(function(arg0, arg1, arg2, arg3) {
477
+ return new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0, arg3 >>> 0);
478
+ }, arguments);
479
+ };
480
+ imports.wbg.__wbg_instanceof_CanvasRenderingContext2d_3abbe7ec7af32cae = function(arg0) {
481
+ let result;
482
+ try {
483
+ result = arg0 instanceof CanvasRenderingContext2D;
484
+ } catch (_) {
485
+ result = false;
486
+ }
487
+ return result;
488
+ };
489
+ imports.wbg.__wbg_drawImage_fede06db74e39a60 = function() {
490
+ return handleError(function(arg0, arg1, arg2, arg3) {
491
+ arg0.drawImage(arg1, arg2, arg3);
492
+ }, arguments);
493
+ };
494
+ imports.wbg.__wbg_drawImage_f395c8e43c79a909 = function() {
495
+ return handleError(function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
496
+ arg0.drawImage(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
497
+ }, arguments);
498
+ };
499
+ imports.wbg.__wbg_getImageData_5e1c242046e6b59e = function() {
500
+ return handleError(function(arg0, arg1, arg2, arg3, arg4) {
501
+ return arg0.getImageData(arg1, arg2, arg3, arg4);
502
+ }, arguments);
503
+ };
504
+ imports.wbg.__wbg_putImageData_a8b3e177ee06d521 = function() {
505
+ return handleError(function(arg0, arg1, arg2, arg3) {
506
+ arg0.putImageData(arg1, arg2, arg3);
507
+ }, arguments);
508
+ };
509
+ imports.wbg.__wbg_instanceof_HtmlCanvasElement_25d964a0dde6717e = function(arg0) {
510
+ let result;
511
+ try {
512
+ result = arg0 instanceof HTMLCanvasElement;
513
+ } catch (_) {
514
+ result = false;
515
+ }
516
+ return result;
517
+ };
518
+ imports.wbg.__wbg_width_dc225e55343b745e = function(arg0) {
519
+ return arg0.width;
520
+ };
521
+ imports.wbg.__wbg_setwidth_488780db69b08846 = function(arg0, arg1) {
522
+ arg0.width = arg1 >>> 0;
523
+ };
524
+ imports.wbg.__wbg_height_3a8bec2f3fe71b26 = function(arg0) {
525
+ return arg0.height;
526
+ };
527
+ imports.wbg.__wbg_setheight_1761808c18403921 = function(arg0, arg1) {
528
+ arg0.height = arg1 >>> 0;
529
+ };
530
+ imports.wbg.__wbg_getContext_fc99dbd3a9a7e318 = function() {
531
+ return handleError(function(arg0, arg1, arg2) {
532
+ const ret = arg0.getContext(getStringFromWasm0(arg1, arg2));
533
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
534
+ }, arguments);
535
+ };
536
+ imports.wbg.__wbg_settextContent_f82a86a8df347e1c = function(arg0, arg1, arg2) {
537
+ arg0.textContent = arg1 === 0 ? void 0 : getStringFromWasm0(arg1, arg2);
538
+ };
539
+ imports.wbg.__wbg_appendChild_fa3b00dade9fc4cf = function() {
540
+ return handleError(function(arg0, arg1) {
541
+ return arg0.appendChild(arg1);
542
+ }, arguments);
543
+ };
544
+ imports.wbg.__wbg_newnoargs_e643855c6572a4a8 = function(arg0, arg1) {
545
+ return new Function(getStringFromWasm0(arg0, arg1));
546
+ };
547
+ imports.wbg.__wbg_call_f96b398515635514 = function() {
548
+ return handleError(function(arg0, arg1) {
549
+ return arg0.call(arg1);
550
+ }, arguments);
551
+ };
552
+ imports.wbg.__wbg_self_b9aad7f1c618bfaf = function() {
553
+ return handleError(function() {
554
+ return self.self;
555
+ }, arguments);
556
+ };
557
+ imports.wbg.__wbg_window_55e469842c98b086 = function() {
558
+ return handleError(function() {
559
+ return window.window;
560
+ }, arguments);
561
+ };
562
+ imports.wbg.__wbg_globalThis_d0957e302752547e = function() {
563
+ return handleError(function() {
564
+ return globalThis.globalThis;
565
+ }, arguments);
566
+ };
567
+ imports.wbg.__wbg_global_ae2f87312b8987fb = function() {
568
+ return handleError(function() {
569
+ return global.global;
570
+ }, arguments);
571
+ };
572
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
573
+ return arg0 === void 0;
574
+ };
575
+ imports.wbg.__wbg_buffer_fcbfb6d88b2732e9 = function(arg0) {
576
+ return arg0.buffer;
577
+ };
578
+ imports.wbg.__wbg_new_bc5d9aad3f9ac80e = function(arg0) {
579
+ return new Uint8Array(arg0);
580
+ };
581
+ imports.wbg.__wbg_set_4b3aa8445ac1e91c = function(arg0, arg1, arg2) {
582
+ arg0.set(arg1, arg2 >>> 0);
583
+ };
584
+ imports.wbg.__wbg_length_d9c4ded7e708c6a1 = function(arg0) {
585
+ return arg0.length;
586
+ };
587
+ imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
588
+ const ptr1 = passStringToWasm0(debugString(arg1), wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
589
+ const len1 = WASM_VECTOR_LEN;
590
+ getDataViewMemory0().setInt32(arg0 + 4, len1, true);
591
+ getDataViewMemory0().setInt32(arg0 + 0, ptr1, true);
592
+ };
593
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
594
+ throw new Error(getStringFromWasm0(arg0, arg1));
595
+ };
596
+ imports.wbg.__wbindgen_memory = function() {
597
+ return wasm.memory;
598
+ };
599
+ imports.wbg.__wbindgen_init_externref_table = function() {
600
+ const table = wasm.__wbindgen_export_2;
601
+ const offset = table.grow(4);
602
+ table.set(0, void 0);
603
+ table.set(offset + 0, void 0);
604
+ table.set(offset + 1, null);
605
+ table.set(offset + 2, true);
606
+ table.set(offset + 3, false);
607
+ };
608
+ return imports;
609
+ }
610
+ function __wbg_finalize_init(instance, module) {
611
+ wasm = instance.exports;
612
+ __wbg_init.__wbindgen_wasm_module = module;
613
+ cachedDataViewMemory0 = null;
614
+ cachedUint8ArrayMemory0 = null;
615
+ cachedUint8ClampedArrayMemory0 = null;
616
+ wasm.__wbindgen_start();
617
+ return wasm;
618
+ }
619
+ function initSync(module) {
620
+ if (wasm !== void 0) return wasm;
621
+ if (typeof module !== "undefined") {
622
+ if (Object.getPrototypeOf(module) === Object.prototype) ({module} = module);
623
+ else console.warn("using deprecated parameters for `initSync()`; pass a single object instead");
624
+ }
625
+ const imports = __wbg_get_imports();
626
+ if (!(module instanceof WebAssembly.Module)) module = new WebAssembly.Module(module);
627
+ return __wbg_finalize_init(new WebAssembly.Instance(module, imports), module);
628
+ }
629
+ async function __wbg_init(module_or_path) {
630
+ if (wasm !== void 0) return wasm;
631
+ if (typeof module_or_path !== "undefined") {
632
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) ({module_or_path} = module_or_path);
633
+ else console.warn("using deprecated parameters for the initialization function; pass a single object instead");
634
+ }
635
+ if (typeof module_or_path === "undefined") module_or_path = new URL("photon_rs_bg.wasm", import.meta.url);
636
+ const imports = __wbg_get_imports();
637
+ if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) module_or_path = fetch(module_or_path);
638
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
639
+ return __wbg_finalize_init(instance, module);
640
+ }
641
+ //#endregion
642
+ //#region ../../../node_modules/.pnpm/@earendil-works+pi-durable@1.5.0_patch_hash=0f5e595daa4c370af407284d99d6dba48a9e21f56aa_fbb51180c4b193ec70152883060baa79/node_modules/@earendil-works/pi-durable/dist/tools/image-processor.js
643
+ /** Formats every provider takes inline; others, such as BMP, need converting. */
644
+ const INLINE_IMAGE_TYPES = /* @__PURE__ */ new Set([
645
+ "image/png",
646
+ "image/jpeg",
647
+ "image/gif",
648
+ "image/webp"
649
+ ]);
650
+ /**
651
+ * Standard base64 of `bytes`. `btoa` takes a binary string, built 8 KiB at a time: a single `String.fromCharCode`
652
+ * call with megabytes of arguments overflows the stack.
653
+ */
654
+ function toBase64(bytes) {
655
+ const parts = [];
656
+ for (let i = 0; i < bytes.length; i += 8192) parts.push(String.fromCharCode.apply(null, bytes.subarray(i, i + 8192)));
657
+ return btoa(parts.join(""));
658
+ }
659
+ /** The length of the base64 of `byteLength` bytes. */
660
+ function base64Length(byteLength) {
661
+ return Math.ceil(byteLength / 3) * 4;
662
+ }
663
+ //#endregion
664
+ //#region ../../../node_modules/.pnpm/@earendil-works+pi-durable@1.5.0_patch_hash=0f5e595daa4c370af407284d99d6dba48a9e21f56aa_fbb51180c4b193ec70152883060baa79/node_modules/@earendil-works/pi-durable/dist/images/exif.js
665
+ /** The EXIF orientation of a JPEG or WebP, 1 to 8; 1 when absent or unreadable. */
666
+ function exifOrientation(bytes) {
667
+ const tiff = tiffStart(bytes);
668
+ if (tiff < 0 || tiff + 8 > bytes.length) return 1;
669
+ const little = bytes[tiff] === 73 && bytes[tiff + 1] === 73;
670
+ const u16 = (at) => little ? bytes[at] | bytes[at + 1] << 8 : bytes[at] << 8 | bytes[at + 1];
671
+ const u32 = (at) => little ? (bytes[at] | bytes[at + 1] << 8 | bytes[at + 2] << 16 | bytes[at + 3] << 24) >>> 0 : (bytes[at] << 24 | bytes[at + 1] << 16 | bytes[at + 2] << 8 | bytes[at + 3]) >>> 0;
672
+ const directory = tiff + u32(tiff + 4);
673
+ if (directory + 2 > bytes.length) return 1;
674
+ const entries = u16(directory);
675
+ for (let index = 0; index < entries; index++) {
676
+ const entry = directory + 2 + index * 12;
677
+ if (entry + 12 > bytes.length) return 1;
678
+ if (u16(entry) === 274) {
679
+ const value = u16(entry + 8);
680
+ return value >= 1 && value <= 8 ? value : 1;
681
+ }
682
+ }
683
+ return 1;
684
+ }
685
+ /** Where the TIFF header of a JPEG's APP1 or a WebP's EXIF chunk starts; -1 when there is none. */
686
+ function tiffStart(bytes) {
687
+ if (bytes[0] === 255 && bytes[1] === 216) {
688
+ for (let offset = 2; offset + 4 <= bytes.length;) {
689
+ if (bytes[offset] !== 255) return -1;
690
+ const marker = bytes[offset + 1];
691
+ if (marker === 255) {
692
+ offset++;
693
+ continue;
694
+ }
695
+ if (marker === 225 && isExifHeader(bytes, offset + 4)) return offset + 10;
696
+ offset += 2 + (bytes[offset + 2] << 8 | bytes[offset + 3]);
697
+ }
698
+ return -1;
699
+ }
700
+ if (ascii(bytes, 0, "RIFF") && ascii(bytes, 8, "WEBP")) for (let offset = 12; offset + 8 <= bytes.length;) {
701
+ const size = (bytes[offset + 4] | bytes[offset + 5] << 8 | bytes[offset + 6] << 16 | bytes[offset + 7] << 24) >>> 0;
702
+ if (ascii(bytes, offset, "EXIF")) return isExifHeader(bytes, offset + 8) ? offset + 14 : offset + 8;
703
+ offset += 8 + size + size % 2;
704
+ }
705
+ return -1;
706
+ }
707
+ function isExifHeader(bytes, offset) {
708
+ return ascii(bytes, offset, "Exif") && bytes[offset + 4] === 0 && bytes[offset + 5] === 0;
709
+ }
710
+ function ascii(bytes, offset, text) {
711
+ for (let index = 0; index < text.length; index++) if (bytes[offset + index] !== text.charCodeAt(index)) return false;
712
+ return true;
713
+ }
714
+ //#endregion
715
+ //#region ../../../node_modules/.pnpm/@earendil-works+pi-durable@1.5.0_patch_hash=0f5e595daa4c370af407284d99d6dba48a9e21f56aa_fbb51180c4b193ec70152883060baa79/node_modules/@earendil-works/pi-durable/dist/images/index.js
716
+ /** JPEG qualities tried in order. */
717
+ const JPEG_QUALITIES = [
718
+ 80,
719
+ 70,
720
+ 55,
721
+ 40
722
+ ];
723
+ /**
724
+ * An `ImageProcessor` on Photon (Rust compiled to WebAssembly), for `createCodingTools({ images })`. `wasm` is
725
+ * Photon's `photon_rs_bg.wasm` as bytes or as a compiled module: `@earendil-works/pi-durable/images/node` reads it from
726
+ * the installed package, `@earendil-works/pi-durable/images/cloudflare` imports it as a Workers module. Elsewhere, such
727
+ * as a browser, fetch the file and pass its bytes. Photon loads once per process; later calls reuse the first `wasm`.
728
+ *
729
+ * An image already upright, in a format providers take inline, and within the limits is returned as it is, once it
730
+ * decodes. Otherwise it is turned upright by its EXIF orientation, scaled to the
731
+ * maximum width and height, and encoded as PNG or JPEG at falling qualities (JPEG first for JPEG sources), then at
732
+ * smaller dimensions, 3/4 at a time, until the base64 fits. Formats providers do not take inline (BMP) become PNG.
733
+ *
734
+ * The work runs on the calling thread: about a second and a half for a 12-megapixel photo. Decoding takes the image's
735
+ * RGBA size in WebAssembly memory, which does not shrink again; leave the processor out on memory-constrained hosts.
736
+ */
737
+ function createPhotonImages(wasm) {
738
+ initSync({ module: wasm });
739
+ return { prepare: async (bytes, mimeType, limits) => prepare(bytes, mimeType, limits) };
740
+ }
741
+ function prepare(bytes, mimeType, limits) {
742
+ const orientation = exifOrientation(bytes);
743
+ const inline = INLINE_IMAGE_TYPES.has(mimeType);
744
+ let image;
745
+ try {
746
+ image = PhotonImage.new_from_byteslice(bytes);
747
+ if (inline && orientation === 1 && image.get_width() <= limits.maxWidth && image.get_height() <= limits.maxHeight && base64Length(bytes.byteLength) <= limits.maxBytes) return {
748
+ data: toBase64(bytes),
749
+ mimeType
750
+ };
751
+ if (orientation >= 5) {
752
+ const upright = transposed(image, orientation);
753
+ image.free();
754
+ image = void 0;
755
+ image = new PhotonImage(upright.pixels, upright.width, upright.height);
756
+ } else if (orientation !== 1) {
757
+ if (orientation !== 4) fliph(image);
758
+ if (orientation !== 2) flipv(image);
759
+ }
760
+ const width = image.get_width();
761
+ const height = image.get_height();
762
+ const scale = Math.min(1, limits.maxWidth / width, limits.maxHeight / height);
763
+ let target = {
764
+ width: Math.max(1, Math.round(width * scale)),
765
+ height: Math.max(1, Math.round(height * scale))
766
+ };
767
+ for (;;) {
768
+ const encoded = encodeWithin(image, target, limits.maxBytes, mimeType === "image/jpeg");
769
+ if (encoded !== void 0) {
770
+ const resized = target.width === width && target.height === height ? {} : { resized: {
771
+ from: {
772
+ width,
773
+ height
774
+ },
775
+ to: target
776
+ } };
777
+ const converted = encoded.mimeType === mimeType ? {} : { convertedFrom: mimeType };
778
+ return {
779
+ ...encoded,
780
+ ...converted,
781
+ ...resized
782
+ };
783
+ }
784
+ if (target.width === 1 && target.height === 1) return void 0;
785
+ target = {
786
+ width: Math.max(1, Math.floor(target.width * .75)),
787
+ height: Math.max(1, Math.floor(target.height * .75))
788
+ };
789
+ }
790
+ } catch {
791
+ return;
792
+ } finally {
793
+ image?.free();
794
+ }
795
+ }
796
+ /**
797
+ * `image` at `size` in the first encoding whose base64 fits `maxBytes`: PNG, then JPEG at falling qualities, or the
798
+ * JPEG qualities first when `jpegFirst`; `undefined` if none fits.
799
+ */
800
+ function encodeWithin(image, size, maxBytes, jpegFirst) {
801
+ const same = size.width === image.get_width() && size.height === image.get_height();
802
+ const scaled = same ? image : resize(image, size.width, size.height, SamplingFilter.Lanczos3);
803
+ try {
804
+ const png = {
805
+ mimeType: "image/png",
806
+ encode: () => scaled.get_bytes()
807
+ };
808
+ const jpegs = JPEG_QUALITIES.map((quality) => ({
809
+ mimeType: "image/jpeg",
810
+ encode: () => scaled.get_bytes_jpeg(quality)
811
+ }));
812
+ for (const candidate of jpegFirst ? [...jpegs, png] : [png, ...jpegs]) {
813
+ const bytes = candidate.encode();
814
+ if (base64Length(bytes.byteLength) <= maxBytes) return {
815
+ data: toBase64(bytes),
816
+ mimeType: candidate.mimeType
817
+ };
818
+ }
819
+ return;
820
+ } finally {
821
+ if (!same) scaled.free();
822
+ }
823
+ }
824
+ /**
825
+ * The RGBA pixels of `image` turned upright for EXIF `orientation` 5 to 8, the orientations that swap width and
826
+ * height. Photon's own `rotate` drops pixels at right angles, so the pixels are moved here.
827
+ */
828
+ function transposed(image, orientation) {
829
+ const width = image.get_width();
830
+ const height = image.get_height();
831
+ const source = image.get_raw_pixels();
832
+ const pixels = new Uint8Array(source.length);
833
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
834
+ const outX = orientation === 5 || orientation === 8 ? y : height - 1 - y;
835
+ const outY = orientation === 5 || orientation === 6 ? x : width - 1 - x;
836
+ pixels.set(source.subarray((y * width + x) * 4, (y * width + x) * 4 + 4), (outY * height + outX) * 4);
837
+ }
838
+ return {
839
+ pixels,
840
+ width: height,
841
+ height: width
842
+ };
843
+ }
844
+ //#endregion
845
+ //#region ../../../node_modules/.pnpm/@earendil-works+pi-durable@1.5.0_patch_hash=0f5e595daa4c370af407284d99d6dba48a9e21f56aa_fbb51180c4b193ec70152883060baa79/node_modules/@earendil-works/pi-durable/dist/images/cloudflare.js
846
+ /** `createPhotonImages()` for Cloudflare Workers and Durable Objects, built with Wrangler. */
847
+ function createCloudflarePhotonImages() {
848
+ return createPhotonImages(photonWasm);
849
+ }
850
+ //#endregion
851
+ //#region ../../core/po-core/src/services/providerImages/fitter.ts
852
+ /**
853
+ * Pi's own cap. Providers reject the whole request when one image is larger than their
854
+ * many-image limit (Anthropic: 2000px), so one oversized attachment breaks every later turn.
855
+ */
856
+ const MAX_DIMENSION = 2e3;
857
+ /** Bytes of base64, Pi's default: headroom below Anthropic's 5 MB image limit. */
858
+ const MAX_IMAGE_BYTES = 4718592;
859
+ /**
860
+ * Fits every image in a provider request with `resize`. Runs on the request, not on entry, so
861
+ * images already stored in history (user attachments, tool results) are fixed too. An image that
862
+ * cannot be resized (no image backend, undecodable) is kept as it is, as Pi does.
863
+ *
864
+ * ponytail: the cache lives as long as the session and holds one copy of each image it saw.
865
+ * Resize on admission instead if image-heavy sessions show memory pressure.
866
+ */
867
+ function createImageFitter(resize) {
868
+ const fitted = /* @__PURE__ */ new Map();
869
+ const fit = (image) => {
870
+ let result = fitted.get(image.data);
871
+ if (!result) {
872
+ result = resize(image).then((resized) => resized ?? image, () => image);
873
+ fitted.set(image.data, result);
874
+ }
875
+ return result;
876
+ };
877
+ return async (messages) => Promise.all(messages.map(async (message) => {
878
+ if (message.role !== "user" && message.role !== "toolResult" || typeof message.content === "string") return message;
879
+ if (!message.content.some((part) => part.type === "image")) return message;
880
+ const content = await Promise.all(message.content.map((part) => part.type === "image" ? fit(part) : Promise.resolve(part)));
881
+ return content.every((part, index) => part === message.content[index]) ? message : {
882
+ ...message,
883
+ content
884
+ };
885
+ }));
886
+ }
887
+ //#endregion
888
+ //#region ../../core/po-core/src/services/providerImages/index.edge.ts
889
+ const LIMITS = {
890
+ maxWidth: MAX_DIMENSION,
891
+ maxHeight: MAX_DIMENSION,
892
+ maxBytes: MAX_IMAGE_BYTES
893
+ };
894
+ /** Photon loads once per isolate, on the first image, so sessions without images pay nothing. */
895
+ let photon;
896
+ /** Fits an inline image with the isolate's Photon instance, without Node workers or filesystem access. */
897
+ async function resizeImage(inputBytes, mimeType, options) {
898
+ photon ??= createCloudflarePhotonImages();
899
+ const prepared = await photon.prepare(inputBytes, mimeType, {
900
+ maxWidth: options?.maxWidth ?? 2e3,
901
+ maxHeight: options?.maxHeight ?? 2e3,
902
+ maxBytes: options?.maxBytes ?? 4718592
903
+ });
904
+ if (!prepared) return null;
905
+ const { resized } = prepared;
906
+ return {
907
+ data: prepared.data,
908
+ mimeType: prepared.mimeType,
909
+ originalWidth: resized?.from.width ?? 0,
910
+ originalHeight: resized?.from.height ?? 0,
911
+ width: resized?.to.width ?? 0,
912
+ height: resized?.to.height ?? 0,
913
+ wasResized: resized !== void 0
914
+ };
915
+ }
916
+ function formatDimensionNote(result) {
917
+ if (!result.wasResized) return void 0;
918
+ const scale = result.originalWidth / result.width;
919
+ return `[Image: original ${result.originalWidth}x${result.originalHeight}, displayed at ${result.width}x${result.height}. Multiply coordinates by ${scale.toFixed(2)} to map to original image.]`;
920
+ }
921
+ /**
922
+ * The edge form: Pi's resizer needs worker threads and reads its wasm from disk, so the Worker
923
+ * resizes with pi-durable's Photon build, whose wasm ships next to the bundle.
924
+ */
925
+ function createProviderImageFitter() {
926
+ return createImageFitter(async (image) => {
927
+ photon ??= createCloudflarePhotonImages();
928
+ const prepared = await photon.prepare(Buffer.from(image.data, "base64"), image.mimeType, LIMITS);
929
+ return prepared && prepared.data !== image.data ? {
930
+ type: "image",
931
+ data: prepared.data,
932
+ mimeType: prepared.mimeType
933
+ } : void 0;
934
+ });
935
+ }
936
+ //#endregion
937
+ export { formatDimensionNote as n, resizeImage as r, createProviderImageFitter as t };