@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,934 @@
1
+ import { G as Null, Hn as BACKGROUND_CONTEXT, Jn as PO_FS_SERVICE, Sn as getOrThrow, V as String$1, Wn as withAbortSignal, bt as _Array_, ht as Optional, pt as _Object_, tr as requirePoFs, z as Union } from "./serverPlugin-CELT6P0Q.js";
2
+ import { i as FileTooLargeError, o as readBoundedFile } from "./platform-BIEiM4TG.js";
3
+ import { f as defineServerTool, h as defineServerPlugin } from "./extensionFile-DNM4xsje.js";
4
+ import { a as decodeUtf8, d as normalizeToLf, i as computeFileTag, m as stripBom, n as resolveInputPath, o as displayPath, s as applyHashlineEdits, u as normalizeFileTag } from "./index.edge-ClLTmPFz.js";
5
+ import { posix } from "node:path";
6
+ //#region ../../default/po-edit/src/schemas/editTool.ts
7
+ const HashlineRangeSchema = _Object_({
8
+ from: String$1({ description: "One inclusive starting anchor, for example 5#abc. Do not paste multiple lines." }),
9
+ to: String$1({ description: "One inclusive ending anchor, for example 8#def. Do not paste multiple lines." }),
10
+ content: Optional(Union([String$1({ description: "Replacement content. Empty content deletes the selected lines." }), Null({ description: "Delete the selected lines." })]))
11
+ });
12
+ const EditParamsSchema = _Object_({
13
+ path: String$1({ description: "Path to the file returned by a compatible hashline read or grep tool." }),
14
+ hash: String$1({ description: "Eight-character exact-byte file tag returned by read or grep." }),
15
+ edits: _Array_(HashlineRangeSchema, {
16
+ minItems: 1,
17
+ description: "Non-overlapping inclusive ranges from the same original snapshot."
18
+ })
19
+ });
20
+ //#endregion
21
+ //#region ../../../node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/base.js
22
+ var Diff = class {
23
+ diff(oldStr, newStr, options = {}) {
24
+ let callback;
25
+ if (typeof options === "function") {
26
+ callback = options;
27
+ options = {};
28
+ } else if ("callback" in options) callback = options.callback;
29
+ const oldString = this.castInput(oldStr, options);
30
+ const newString = this.castInput(newStr, options);
31
+ const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
32
+ const newTokens = this.removeEmpty(this.tokenize(newString, options));
33
+ return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
34
+ }
35
+ diffWithOptionsObj(oldTokens, newTokens, options, callback) {
36
+ var _a;
37
+ const done = (value) => {
38
+ value = this.postProcess(value, options);
39
+ if (callback) {
40
+ setTimeout(function() {
41
+ callback(value);
42
+ }, 0);
43
+ return;
44
+ } else return value;
45
+ };
46
+ const newLen = newTokens.length, oldLen = oldTokens.length;
47
+ let editLength = 1;
48
+ let maxEditLength = newLen + oldLen;
49
+ if (options.maxEditLength != null) maxEditLength = Math.min(maxEditLength, options.maxEditLength);
50
+ const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
51
+ const abortAfterTimestamp = Date.now() + maxExecutionTime;
52
+ const bestPath = [{
53
+ oldPos: -1,
54
+ lastComponent: void 0
55
+ }];
56
+ let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
57
+ if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
58
+ let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
59
+ const execEditLength = () => {
60
+ for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
61
+ let basePath;
62
+ const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
63
+ if (removePath) bestPath[diagonalPath - 1] = void 0;
64
+ let canAdd = false;
65
+ if (addPath) {
66
+ const addPathNewPos = addPath.oldPos - diagonalPath;
67
+ canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
68
+ }
69
+ const canRemove = removePath && removePath.oldPos + 1 < oldLen;
70
+ if (!canAdd && !canRemove) {
71
+ bestPath[diagonalPath] = void 0;
72
+ continue;
73
+ }
74
+ if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) basePath = this.addToPath(addPath, true, false, 0, options);
75
+ else basePath = this.addToPath(removePath, false, true, 1, options);
76
+ newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
77
+ if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
78
+ else {
79
+ bestPath[diagonalPath] = basePath;
80
+ if (basePath.oldPos + 1 >= oldLen) maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
81
+ if (newPos + 1 >= newLen) minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
82
+ }
83
+ }
84
+ editLength++;
85
+ };
86
+ if (callback) (function exec() {
87
+ setTimeout(function() {
88
+ if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) return callback(void 0);
89
+ if (!execEditLength()) exec();
90
+ }, 0);
91
+ })();
92
+ else while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
93
+ const ret = execEditLength();
94
+ if (ret) return ret;
95
+ }
96
+ }
97
+ addToPath(path, added, removed, oldPosInc, options) {
98
+ const last = path.lastComponent;
99
+ if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) return {
100
+ oldPos: path.oldPos + oldPosInc,
101
+ lastComponent: {
102
+ count: last.count + 1,
103
+ added,
104
+ removed,
105
+ previousComponent: last.previousComponent
106
+ }
107
+ };
108
+ else return {
109
+ oldPos: path.oldPos + oldPosInc,
110
+ lastComponent: {
111
+ count: 1,
112
+ added,
113
+ removed,
114
+ previousComponent: last
115
+ }
116
+ };
117
+ }
118
+ extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
119
+ const newLen = newTokens.length, oldLen = oldTokens.length;
120
+ let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
121
+ while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
122
+ newPos++;
123
+ oldPos++;
124
+ commonCount++;
125
+ if (options.oneChangePerToken) basePath.lastComponent = {
126
+ count: 1,
127
+ previousComponent: basePath.lastComponent,
128
+ added: false,
129
+ removed: false
130
+ };
131
+ }
132
+ if (commonCount && !options.oneChangePerToken) basePath.lastComponent = {
133
+ count: commonCount,
134
+ previousComponent: basePath.lastComponent,
135
+ added: false,
136
+ removed: false
137
+ };
138
+ basePath.oldPos = oldPos;
139
+ return newPos;
140
+ }
141
+ equals(left, right, options) {
142
+ if (options.comparator) return options.comparator(left, right);
143
+ else return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
144
+ }
145
+ removeEmpty(array) {
146
+ const ret = [];
147
+ for (let i = 0; i < array.length; i++) if (array[i]) ret.push(array[i]);
148
+ return ret;
149
+ }
150
+ castInput(value, options) {
151
+ return value;
152
+ }
153
+ tokenize(value, options) {
154
+ return Array.from(value);
155
+ }
156
+ join(chars) {
157
+ return chars.join("");
158
+ }
159
+ postProcess(changeObjects, options) {
160
+ return changeObjects;
161
+ }
162
+ get useLongestToken() {
163
+ return false;
164
+ }
165
+ buildValues(lastComponent, newTokens, oldTokens) {
166
+ const components = [];
167
+ let nextComponent;
168
+ while (lastComponent) {
169
+ components.push(lastComponent);
170
+ nextComponent = lastComponent.previousComponent;
171
+ delete lastComponent.previousComponent;
172
+ lastComponent = nextComponent;
173
+ }
174
+ components.reverse();
175
+ const componentLen = components.length;
176
+ let componentPos = 0, newPos = 0, oldPos = 0;
177
+ for (; componentPos < componentLen; componentPos++) {
178
+ const component = components[componentPos];
179
+ if (!component.removed) {
180
+ if (!component.added && this.useLongestToken) {
181
+ let value = newTokens.slice(newPos, newPos + component.count);
182
+ value = value.map(function(value, i) {
183
+ const oldValue = oldTokens[oldPos + i];
184
+ return oldValue.length > value.length ? oldValue : value;
185
+ });
186
+ component.value = this.join(value);
187
+ } else component.value = this.join(newTokens.slice(newPos, newPos + component.count));
188
+ newPos += component.count;
189
+ if (!component.added) oldPos += component.count;
190
+ } else {
191
+ component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
192
+ oldPos += component.count;
193
+ }
194
+ }
195
+ return components;
196
+ }
197
+ };
198
+ //#endregion
199
+ //#region ../../../node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/character.js
200
+ var CharacterDiff = class extends Diff {};
201
+ new CharacterDiff();
202
+ //#endregion
203
+ //#region ../../../node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/util/string.js
204
+ function longestCommonPrefix(str1, str2) {
205
+ let i = 0;
206
+ for (; i < str1.length && i < str2.length; i++) if (str1[i] != str2[i]) return str1.slice(0, i);
207
+ return str1.slice(0, i);
208
+ }
209
+ function longestCommonSuffix(str1, str2) {
210
+ let i;
211
+ if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) return "";
212
+ for (i = 0; i < str1.length && i < str2.length; i++) if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) return str1.slice(-i);
213
+ return str1.slice(-i);
214
+ }
215
+ function replacePrefix(string, oldPrefix, newPrefix) {
216
+ if (string.slice(0, oldPrefix.length) != oldPrefix) throw Error(`string ${JSON.stringify(string)} doesn't start with prefix ${JSON.stringify(oldPrefix)}; this is a bug`);
217
+ return newPrefix + string.slice(oldPrefix.length);
218
+ }
219
+ function replaceSuffix(string, oldSuffix, newSuffix) {
220
+ if (!oldSuffix) return string + newSuffix;
221
+ if (string.slice(-oldSuffix.length) != oldSuffix) throw Error(`string ${JSON.stringify(string)} doesn't end with suffix ${JSON.stringify(oldSuffix)}; this is a bug`);
222
+ return string.slice(0, -oldSuffix.length) + newSuffix;
223
+ }
224
+ function removePrefix(string, oldPrefix) {
225
+ return replacePrefix(string, oldPrefix, "");
226
+ }
227
+ function removeSuffix(string, oldSuffix) {
228
+ return replaceSuffix(string, oldSuffix, "");
229
+ }
230
+ function maximumOverlap(string1, string2) {
231
+ return string2.slice(0, overlapCount(string1, string2));
232
+ }
233
+ function overlapCount(a, b) {
234
+ let startA = 0;
235
+ if (a.length > b.length) startA = a.length - b.length;
236
+ let endB = b.length;
237
+ if (a.length < b.length) endB = a.length;
238
+ const map = Array(endB);
239
+ let k = 0;
240
+ map[0] = 0;
241
+ for (let j = 1; j < endB; j++) {
242
+ if (b[j] == b[k]) map[j] = map[k];
243
+ else map[j] = k;
244
+ while (k > 0 && b[j] != b[k]) k = map[k];
245
+ if (b[j] == b[k]) k++;
246
+ }
247
+ k = 0;
248
+ for (let i = startA; i < a.length; i++) {
249
+ while (k > 0 && a[i] != b[k]) k = map[k];
250
+ if (a[i] == b[k]) k++;
251
+ }
252
+ return k;
253
+ }
254
+ /**
255
+ * Split a string into segments using a word segmenter, merging consecutive
256
+ * segments if they are both whitespace segments. Whitespace segments can
257
+ * appear adjacent to one another for two reasons:
258
+ * - newlines always get their own segment
259
+ * - where a diacritic is attached to a whitespace character in the text, the
260
+ * segment ends after the diacritic, so e.g. " \u0300 " becomes two segments.
261
+ * This function therefore runs the segmenter's .segment() method and then
262
+ * merges consecutive segments of whitespace into a single part.
263
+ */
264
+ function segment(string, segmenter) {
265
+ const parts = [];
266
+ for (const segmentObj of Array.from(segmenter.segment(string))) {
267
+ const segment = segmentObj.segment;
268
+ if (parts.length && /\s/.test(parts[parts.length - 1]) && /\s/.test(segment)) parts[parts.length - 1] += segment;
269
+ else parts.push(segment);
270
+ }
271
+ return parts;
272
+ }
273
+ function trailingWs(string, segmenter) {
274
+ if (segmenter) return leadingAndTrailingWs(string, segmenter)[1];
275
+ let i;
276
+ for (i = string.length - 1; i >= 0; i--) if (!string[i].match(/\s/)) break;
277
+ return string.substring(i + 1);
278
+ }
279
+ function leadingWs(string, segmenter) {
280
+ if (segmenter) return leadingAndTrailingWs(string, segmenter)[0];
281
+ const match = string.match(/^\s*/);
282
+ return match ? match[0] : "";
283
+ }
284
+ function leadingAndTrailingWs(string, segmenter) {
285
+ if (!segmenter) return [leadingWs(string), trailingWs(string)];
286
+ if (segmenter.resolvedOptions().granularity != "word") throw new Error("The segmenter passed must have a granularity of \"word\"");
287
+ const segments = segment(string, segmenter);
288
+ const firstSeg = segments[0];
289
+ const lastSeg = segments[segments.length - 1];
290
+ return [/\s/.test(firstSeg) ? firstSeg : "", /\s/.test(lastSeg) ? lastSeg : ""];
291
+ }
292
+ //#endregion
293
+ //#region ../../../node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/word.js
294
+ const extendedWordChars = "a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
295
+ const tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\s+|[^${extendedWordChars}]`, "ug");
296
+ var WordDiff = class extends Diff {
297
+ equals(left, right, options) {
298
+ if (options.ignoreCase) {
299
+ left = left.toLowerCase();
300
+ right = right.toLowerCase();
301
+ }
302
+ return left.trim() === right.trim();
303
+ }
304
+ tokenize(value, options = {}) {
305
+ let parts;
306
+ if (options.intlSegmenter) {
307
+ const segmenter = options.intlSegmenter;
308
+ if (segmenter.resolvedOptions().granularity != "word") throw new Error("The segmenter passed must have a granularity of \"word\"");
309
+ parts = segment(value, segmenter);
310
+ } else parts = value.match(tokenizeIncludingWhitespace) || [];
311
+ const tokens = [];
312
+ let prevPart = null;
313
+ parts.forEach((part) => {
314
+ if (/\s/.test(part)) {
315
+ if (prevPart == null) tokens.push(part);
316
+ else tokens.push(tokens.pop() + part);
317
+ } else if (prevPart != null && /\s/.test(prevPart)) {
318
+ if (tokens[tokens.length - 1] == prevPart) tokens.push(tokens.pop() + part);
319
+ else tokens.push(prevPart + part);
320
+ } else tokens.push(part);
321
+ prevPart = part;
322
+ });
323
+ return tokens;
324
+ }
325
+ join(tokens) {
326
+ return tokens.map((token, i) => {
327
+ if (i == 0) return token;
328
+ else return token.replace(/^\s+/, "");
329
+ }).join("");
330
+ }
331
+ postProcess(changes, options) {
332
+ if (!changes || options.oneChangePerToken) return changes;
333
+ let lastKeep = null;
334
+ let insertion = null;
335
+ let deletion = null;
336
+ changes.forEach((change) => {
337
+ if (change.added) insertion = change;
338
+ else if (change.removed) deletion = change;
339
+ else {
340
+ if (insertion || deletion) dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change, options.intlSegmenter);
341
+ lastKeep = change;
342
+ insertion = null;
343
+ deletion = null;
344
+ }
345
+ });
346
+ if (insertion || deletion) dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null, options.intlSegmenter);
347
+ return changes;
348
+ }
349
+ };
350
+ new WordDiff();
351
+ function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep, segmenter) {
352
+ if (deletion && insertion) {
353
+ const [oldWsPrefix, oldWsSuffix] = leadingAndTrailingWs(deletion.value, segmenter);
354
+ const [newWsPrefix, newWsSuffix] = leadingAndTrailingWs(insertion.value, segmenter);
355
+ if (startKeep) {
356
+ const commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
357
+ startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
358
+ deletion.value = removePrefix(deletion.value, commonWsPrefix);
359
+ insertion.value = removePrefix(insertion.value, commonWsPrefix);
360
+ }
361
+ if (endKeep) {
362
+ const commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);
363
+ endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);
364
+ deletion.value = removeSuffix(deletion.value, commonWsSuffix);
365
+ insertion.value = removeSuffix(insertion.value, commonWsSuffix);
366
+ }
367
+ } else if (insertion) {
368
+ if (startKeep) {
369
+ const ws = leadingWs(insertion.value, segmenter);
370
+ insertion.value = insertion.value.substring(ws.length);
371
+ }
372
+ if (endKeep) {
373
+ const ws = leadingWs(endKeep.value, segmenter);
374
+ endKeep.value = endKeep.value.substring(ws.length);
375
+ }
376
+ } else if (startKeep && endKeep) {
377
+ const newWsFull = leadingWs(endKeep.value, segmenter), [delWsStart, delWsEnd] = leadingAndTrailingWs(deletion.value, segmenter);
378
+ const newWsStart = longestCommonPrefix(newWsFull, delWsStart);
379
+ deletion.value = removePrefix(deletion.value, newWsStart);
380
+ const newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
381
+ deletion.value = removeSuffix(deletion.value, newWsEnd);
382
+ endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
383
+ startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
384
+ } else if (endKeep) {
385
+ const endKeepWsPrefix = leadingWs(endKeep.value, segmenter);
386
+ const overlap = maximumOverlap(trailingWs(deletion.value, segmenter), endKeepWsPrefix);
387
+ deletion.value = removeSuffix(deletion.value, overlap);
388
+ } else if (startKeep) {
389
+ const overlap = maximumOverlap(trailingWs(startKeep.value, segmenter), leadingWs(deletion.value, segmenter));
390
+ deletion.value = removePrefix(deletion.value, overlap);
391
+ }
392
+ }
393
+ var WordsWithSpaceDiff = class extends Diff {
394
+ tokenize(value) {
395
+ const regex = new RegExp(`(\\r?\\n)|[${extendedWordChars}]+|[^\\S\\n\\r]+|[^${extendedWordChars}]`, "ug");
396
+ return value.match(regex) || [];
397
+ }
398
+ };
399
+ new WordsWithSpaceDiff();
400
+ //#endregion
401
+ //#region ../../../node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/line.js
402
+ var LineDiff = class extends Diff {
403
+ constructor() {
404
+ super(...arguments);
405
+ this.tokenize = tokenize;
406
+ }
407
+ equals(left, right, options) {
408
+ if (options.ignoreWhitespace) {
409
+ if (!options.newlineIsToken || !left.includes("\n")) left = left.trim();
410
+ if (!options.newlineIsToken || !right.includes("\n")) right = right.trim();
411
+ } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
412
+ if (left.endsWith("\n")) left = left.slice(0, -1);
413
+ if (right.endsWith("\n")) right = right.slice(0, -1);
414
+ }
415
+ return super.equals(left, right, options);
416
+ }
417
+ };
418
+ const lineDiff = new LineDiff();
419
+ function diffLines(oldStr, newStr, options) {
420
+ return lineDiff.diff(oldStr, newStr, options);
421
+ }
422
+ function tokenize(value, options) {
423
+ if (options.stripTrailingCr) value = value.replace(/\r\n/g, "\n");
424
+ const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
425
+ if (!linesAndNewlines[linesAndNewlines.length - 1]) linesAndNewlines.pop();
426
+ for (let i = 0; i < linesAndNewlines.length; i++) {
427
+ const line = linesAndNewlines[i];
428
+ if (i % 2 && !options.newlineIsToken) retLines[retLines.length - 1] += line;
429
+ else retLines.push(line);
430
+ }
431
+ return retLines;
432
+ }
433
+ //#endregion
434
+ //#region ../../../node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/sentence.js
435
+ function isSentenceEndPunct(char) {
436
+ return char == "." || char == "!" || char == "?";
437
+ }
438
+ var SentenceDiff = class extends Diff {
439
+ tokenize(value) {
440
+ var _a;
441
+ const result = [];
442
+ let tokenStartI = 0;
443
+ for (let i = 0; i < value.length; i++) {
444
+ if (i == value.length - 1) {
445
+ result.push(value.slice(tokenStartI));
446
+ break;
447
+ }
448
+ if (isSentenceEndPunct(value[i]) && value[i + 1].match(/\s/)) {
449
+ result.push(value.slice(tokenStartI, i + 1));
450
+ i = tokenStartI = i + 1;
451
+ while ((_a = value[i + 1]) === null || _a === void 0 ? void 0 : _a.match(/\s/)) i++;
452
+ result.push(value.slice(tokenStartI, i + 1));
453
+ tokenStartI = i + 1;
454
+ }
455
+ }
456
+ return result;
457
+ }
458
+ };
459
+ new SentenceDiff();
460
+ //#endregion
461
+ //#region ../../../node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/css.js
462
+ var CssDiff = class extends Diff {
463
+ tokenize(value) {
464
+ return value.split(/([{}:;,]|\s+)/);
465
+ }
466
+ };
467
+ new CssDiff();
468
+ //#endregion
469
+ //#region ../../../node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/json.js
470
+ var JsonDiff = class extends Diff {
471
+ constructor() {
472
+ super(...arguments);
473
+ this.tokenize = tokenize;
474
+ }
475
+ get useLongestToken() {
476
+ return true;
477
+ }
478
+ castInput(value, options) {
479
+ const { undefinedReplacement, stringifyReplacer = (k, v) => typeof v === "undefined" ? undefinedReplacement : v } = options;
480
+ return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, " ");
481
+ }
482
+ equals(left, right, options) {
483
+ return super.equals(left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"), options);
484
+ }
485
+ };
486
+ new JsonDiff();
487
+ function canonicalize(obj, stack, replacementStack, replacer, key) {
488
+ stack = stack || [];
489
+ replacementStack = replacementStack || [];
490
+ if (replacer) obj = replacer(key === void 0 ? "" : key, obj);
491
+ let i = 0;
492
+ for (; i < stack.length; i += 1) if (stack[i] === obj) return replacementStack[i];
493
+ let canonicalizedObj;
494
+ if ("[object Array]" === Object.prototype.toString.call(obj)) {
495
+ stack.push(obj);
496
+ canonicalizedObj = new Array(obj.length);
497
+ replacementStack.push(canonicalizedObj);
498
+ for (i = 0; i < obj.length; i += 1) canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));
499
+ stack.pop();
500
+ replacementStack.pop();
501
+ return canonicalizedObj;
502
+ }
503
+ if (obj && obj.toJSON) obj = obj.toJSON();
504
+ if (typeof obj === "object" && obj !== null) {
505
+ stack.push(obj);
506
+ canonicalizedObj = {};
507
+ replacementStack.push(canonicalizedObj);
508
+ const sortedKeys = [];
509
+ let key;
510
+ for (key in obj)
511
+ /* istanbul ignore else */
512
+ if (Object.prototype.hasOwnProperty.call(obj, key)) sortedKeys.push(key);
513
+ sortedKeys.sort();
514
+ for (i = 0; i < sortedKeys.length; i += 1) {
515
+ key = sortedKeys[i];
516
+ canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack, replacer, key);
517
+ }
518
+ stack.pop();
519
+ replacementStack.pop();
520
+ } else canonicalizedObj = obj;
521
+ return canonicalizedObj;
522
+ }
523
+ //#endregion
524
+ //#region ../../../node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/array.js
525
+ var ArrayDiff = class extends Diff {
526
+ tokenize(value) {
527
+ return value.slice();
528
+ }
529
+ join(value) {
530
+ return value;
531
+ }
532
+ removeEmpty(value) {
533
+ return value;
534
+ }
535
+ };
536
+ new ArrayDiff();
537
+ //#endregion
538
+ //#region ../../../node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/patch/create.js
539
+ const INCLUDE_HEADERS = {
540
+ includeIndex: true,
541
+ includeUnderline: true,
542
+ includeFileHeaders: true
543
+ };
544
+ const FILE_HEADERS_ONLY = {
545
+ includeIndex: false,
546
+ includeUnderline: false,
547
+ includeFileHeaders: true
548
+ };
549
+ function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
550
+ let optionsObj;
551
+ if (!options) optionsObj = {};
552
+ else if (typeof options === "function") optionsObj = { callback: options };
553
+ else optionsObj = options;
554
+ if (typeof optionsObj.context === "undefined") optionsObj.context = 4;
555
+ const context = optionsObj.context;
556
+ if (optionsObj.newlineIsToken) throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
557
+ if (!optionsObj.callback) return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));
558
+ else {
559
+ const { callback } = optionsObj;
560
+ diffLines(oldStr, newStr, Object.assign(Object.assign({}, optionsObj), { callback: (diff) => {
561
+ const patch = diffLinesResultToPatch(diff);
562
+ callback(patch);
563
+ } }));
564
+ }
565
+ function diffLinesResultToPatch(diff) {
566
+ if (!diff) return;
567
+ diff.push({
568
+ value: "",
569
+ lines: []
570
+ });
571
+ function contextLines(lines) {
572
+ return lines.map(function(entry) {
573
+ return " " + entry;
574
+ });
575
+ }
576
+ const hunks = [];
577
+ let oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
578
+ for (let i = 0; i < diff.length; i++) {
579
+ const current = diff[i], lines = current.lines || splitLines(current.value);
580
+ current.lines = lines;
581
+ if (current.added || current.removed) {
582
+ if (!oldRangeStart) {
583
+ const prev = diff[i - 1];
584
+ oldRangeStart = oldLine;
585
+ newRangeStart = newLine;
586
+ if (prev) {
587
+ curRange = context > 0 ? contextLines(prev.lines.slice(-context)) : [];
588
+ oldRangeStart -= curRange.length;
589
+ newRangeStart -= curRange.length;
590
+ }
591
+ }
592
+ for (const line of lines) curRange.push((current.added ? "+" : "-") + line);
593
+ if (current.added) newLine += lines.length;
594
+ else oldLine += lines.length;
595
+ } else {
596
+ if (oldRangeStart) {
597
+ if (lines.length <= context * 2 && i < diff.length - 2) for (const line of contextLines(lines)) curRange.push(line);
598
+ else {
599
+ const contextSize = Math.min(lines.length, context);
600
+ for (const line of contextLines(lines.slice(0, contextSize))) curRange.push(line);
601
+ const hunk = {
602
+ oldStart: oldRangeStart,
603
+ oldLines: oldLine - oldRangeStart + contextSize,
604
+ newStart: newRangeStart,
605
+ newLines: newLine - newRangeStart + contextSize,
606
+ lines: curRange
607
+ };
608
+ hunks.push(hunk);
609
+ oldRangeStart = 0;
610
+ newRangeStart = 0;
611
+ curRange = [];
612
+ }
613
+ }
614
+ oldLine += lines.length;
615
+ newLine += lines.length;
616
+ }
617
+ }
618
+ for (const hunk of hunks) for (let i = 0; i < hunk.lines.length; i++) if (hunk.lines[i].endsWith("\n")) hunk.lines[i] = hunk.lines[i].slice(0, -1);
619
+ else {
620
+ hunk.lines.splice(i + 1, 0, "\");
621
+ i++;
622
+ }
623
+ return {
624
+ oldFileName,
625
+ newFileName,
626
+ oldHeader,
627
+ newHeader,
628
+ hunks
629
+ };
630
+ }
631
+ }
632
+ /**
633
+ * creates a unified diff patch.
634
+ * @param patch either a single structured patch object (as returned by `structuredPatch`) or an array of them (as returned by `parsePatch`)
635
+ */
636
+ function formatPatch(patch, headerOptions) {
637
+ if (!headerOptions) headerOptions = INCLUDE_HEADERS;
638
+ if (Array.isArray(patch)) {
639
+ if (patch.length > 1 && !headerOptions.includeFileHeaders) throw new Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");
640
+ return patch.map((p) => formatPatch(p, headerOptions)).join("\n");
641
+ }
642
+ const ret = [];
643
+ if (headerOptions.includeIndex && patch.oldFileName == patch.newFileName) ret.push("Index: " + patch.oldFileName);
644
+ if (headerOptions.includeUnderline) ret.push("===================================================================");
645
+ if (headerOptions.includeFileHeaders) {
646
+ ret.push("--- " + patch.oldFileName + (typeof patch.oldHeader === "undefined" ? "" : " " + patch.oldHeader));
647
+ ret.push("+++ " + patch.newFileName + (typeof patch.newHeader === "undefined" ? "" : " " + patch.newHeader));
648
+ }
649
+ for (let i = 0; i < patch.hunks.length; i++) {
650
+ const hunk = patch.hunks[i];
651
+ if (hunk.oldLines === 0) hunk.oldStart -= 1;
652
+ if (hunk.newLines === 0) hunk.newStart -= 1;
653
+ ret.push("@@ -" + hunk.oldStart + "," + hunk.oldLines + " +" + hunk.newStart + "," + hunk.newLines + " @@");
654
+ for (const line of hunk.lines) ret.push(line);
655
+ }
656
+ return ret.join("\n") + "\n";
657
+ }
658
+ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
659
+ if (typeof options === "function") options = { callback: options };
660
+ if (!(options === null || options === void 0 ? void 0 : options.callback)) {
661
+ const patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
662
+ if (!patchObj) return;
663
+ return formatPatch(patchObj, options === null || options === void 0 ? void 0 : options.headerOptions);
664
+ } else {
665
+ const { callback } = options;
666
+ structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, Object.assign(Object.assign({}, options), { callback: (patchObj) => {
667
+ if (!patchObj) callback(void 0);
668
+ else callback(formatPatch(patchObj, options.headerOptions));
669
+ } }));
670
+ }
671
+ }
672
+ /**
673
+ * Split `text` into an array of lines, including the trailing newline character (where present)
674
+ */
675
+ function splitLines(text) {
676
+ const hasTrailingNl = text.endsWith("\n");
677
+ const result = text.split("\n").map((line) => line + "\n");
678
+ if (hasTrailingNl) result.pop();
679
+ else result.push(result.pop().slice(0, -1));
680
+ return result;
681
+ }
682
+ //#endregion
683
+ //#region ../../default/po-edit/src/services/editHost/index.edge.ts
684
+ /** A unified patch with file headers only, as Pi writes it. */
685
+ function generateUnifiedPatch(path, oldContent, newContent, contextLines = 4) {
686
+ return createTwoFilesPatch(path, path, oldContent, newContent, void 0, void 0, {
687
+ context: contextLines,
688
+ headerOptions: FILE_HEADERS_ONLY
689
+ });
690
+ }
691
+ /**
692
+ * A display diff with line numbers and `contextLines` unchanged lines around each change, and the first changed line
693
+ * of the new file.
694
+ */
695
+ function generateDiffString(oldContent, newContent, contextLines = 4) {
696
+ const parts = diffLines(oldContent, newContent);
697
+ const output = [];
698
+ const width = String(Math.max(oldContent.split("\n").length, newContent.split("\n").length)).length;
699
+ const number = (value) => String(value).padStart(width, " ");
700
+ let oldLineNumber = 1;
701
+ let newLineNumber = 1;
702
+ let lastWasChange = false;
703
+ let firstChangedLine;
704
+ const show = (rows) => {
705
+ for (const row of rows) {
706
+ output.push(` ${number(oldLineNumber)} ${row}`);
707
+ oldLineNumber += 1;
708
+ newLineNumber += 1;
709
+ }
710
+ };
711
+ const skip = (count) => {
712
+ if (count <= 0) return;
713
+ output.push(` ${"".padStart(width, " ")} ...`);
714
+ oldLineNumber += count;
715
+ newLineNumber += count;
716
+ };
717
+ for (const [index, part] of parts.entries()) {
718
+ const rows = part.value.split("\n");
719
+ if (rows[rows.length - 1] === "") rows.pop();
720
+ if (part.added || part.removed) {
721
+ firstChangedLine ??= newLineNumber;
722
+ for (const row of rows) if (part.added) {
723
+ output.push(`+${number(newLineNumber)} ${row}`);
724
+ newLineNumber += 1;
725
+ } else {
726
+ output.push(`-${number(oldLineNumber)} ${row}`);
727
+ oldLineNumber += 1;
728
+ }
729
+ lastWasChange = true;
730
+ continue;
731
+ }
732
+ const next = parts[index + 1];
733
+ const nextIsChange = next !== void 0 && Boolean(next.added || next.removed);
734
+ if (lastWasChange && nextIsChange) {
735
+ if (rows.length <= contextLines * 2) show(rows);
736
+ else {
737
+ show(rows.slice(0, contextLines));
738
+ skip(rows.length - contextLines * 2);
739
+ show(rows.slice(rows.length - contextLines));
740
+ }
741
+ } else if (lastWasChange) {
742
+ show(rows.slice(0, contextLines));
743
+ skip(rows.length - Math.min(contextLines, rows.length));
744
+ } else if (nextIsChange) {
745
+ const skipped = Math.max(0, rows.length - contextLines);
746
+ skip(skipped);
747
+ show(rows.slice(skipped));
748
+ } else {
749
+ oldLineNumber += rows.length;
750
+ newLineNumber += rows.length;
751
+ }
752
+ lastWasChange = false;
753
+ }
754
+ return {
755
+ diff: output.join("\n"),
756
+ firstChangedLine
757
+ };
758
+ }
759
+ const queues = /* @__PURE__ */ new Map();
760
+ /**
761
+ * Serialize mutations of one file, in call order. A Worker isolate hosts many Durable Objects, each with its own file
762
+ * namespace, so the key is the namespace id and the resolved path. There are no links to resolve.
763
+ */
764
+ async function withFileMutationQueue(filesystem, filePath, run) {
765
+ const key = `${filesystem.id}\0${posix.resolve(filePath)}`;
766
+ const previous = queues.get(key) ?? Promise.resolve();
767
+ let release = () => void 0;
768
+ const current = new Promise((resolve) => {
769
+ release = resolve;
770
+ });
771
+ const chained = previous.then(() => current);
772
+ queues.set(key, chained);
773
+ await previous;
774
+ try {
775
+ return await run();
776
+ } finally {
777
+ release();
778
+ if (queues.get(key) === chained) queues.delete(key);
779
+ }
780
+ }
781
+ //#endregion
782
+ //#region ../../default/po-edit/src/services/editTool/index.ts
783
+ function createHeadlessEditTool(filesystem) {
784
+ return {
785
+ name: "edit",
786
+ label: "edit",
787
+ description: "Edit one file using its exact snapshot hash and inclusive anchors such as 5#abc from read or grep. Each from and to value must contain one anchor, not a pasted block. All ranges refer to the original snapshot. Empty or omitted content deletes a range. Files over 8 MiB are refused.",
788
+ promptSnippet: "Edit files with snapshot-bound hashline ranges",
789
+ promptGuidelines: ["Copy path, hash, and anchors from the latest compatible read or grep result. Re-read after every successful edit.", "Pass one anchor such as 5#abc in each from and to value. Do not paste tagged lines or multiline blocks."],
790
+ parameters: EditParamsSchema,
791
+ executionMode: "parallel",
792
+ execute: (_toolCallId, params, signal, _onUpdate, context) => executeHashlineEdit(params, context.cwd, signal, typeof filesystem === "function" ? filesystem() : filesystem)
793
+ };
794
+ }
795
+ function assertNotAborted(signal) {
796
+ if (signal?.aborted) throw new Error("Operation aborted");
797
+ }
798
+ async function executeHashlineEdit(params, cwd, signal, filesystem) {
799
+ const absolutePath = resolveInputPath(params.path, cwd);
800
+ const context = signal ? withAbortSignal(signal, BACKGROUND_CONTEXT) : BACKGROUND_CONTEXT;
801
+ const readSnapshot = async () => {
802
+ try {
803
+ return Buffer.from(await readBoundedFile(filesystem, absolutePath, 8388608, context));
804
+ } catch (error) {
805
+ if (error instanceof FileTooLargeError) throw new Error("File is over 8 MiB, hashline edit refuses; use runner log tools for logs.", { cause: error });
806
+ throw error;
807
+ }
808
+ };
809
+ const expectedHash = normalizeFileTag(params.hash);
810
+ return withFileMutationQueue(filesystem, absolutePath, async () => {
811
+ assertNotAborted(signal);
812
+ getOrThrow(await filesystem.fileInfo(absolutePath, context));
813
+ const beforeBytes = await readSnapshot();
814
+ assertNotAborted(signal);
815
+ const actualHash = computeFileTag(beforeBytes);
816
+ if (actualHash !== expectedHash) throw new Error(`Stale file hash ${expectedHash}. Current hash is ${actualHash}. Re-read the file and retry.`);
817
+ const hasBom = beforeBytes.subarray(0, 3).equals(Buffer.from([
818
+ 239,
819
+ 187,
820
+ 191
821
+ ]));
822
+ const decoded = decodeUtf8(beforeBytes, params.path);
823
+ const withoutBom = stripBom(decoded);
824
+ const before = normalizeToLf(withoutBom);
825
+ const applied = applyHashlineEdits(before, params.edits);
826
+ const editedText = restoreOriginalLineEndings(withoutBom, applied.edits);
827
+ if (normalizeToLf(editedText) !== applied.content) throw new Error("Could not preserve the file line endings safely. The file was not changed.");
828
+ const diff = generateDiffString(before, applied.content);
829
+ const patch = generateUnifiedPatch(displayPath(absolutePath, cwd), before, applied.content);
830
+ const details = {
831
+ diff: diff.diff,
832
+ patch,
833
+ firstChangedLine: diff.firstChangedLine
834
+ };
835
+ assertNotAborted(signal);
836
+ if (!(await readSnapshot()).equals(beforeBytes)) throw new Error("The file changed while the edit was being prepared. Re-read it and retry.");
837
+ assertNotAborted(signal);
838
+ if (applied.content !== before) {
839
+ const output = Buffer.from(`${hasBom ? "" : ""}${editedText}`, "utf8");
840
+ getOrThrow(await filesystem.writeFile(absolutePath, output, BACKGROUND_CONTEXT));
841
+ }
842
+ const count = applied.edits.length;
843
+ const noun = count === 1 ? "range" : "ranges";
844
+ return {
845
+ content: [{
846
+ type: "text",
847
+ text: `${applied.content === before ? `No changes needed in ${params.path}.` : `Edited ${params.path} (${count} ${noun}).`} Re-read before editing it again.`
848
+ }],
849
+ details
850
+ };
851
+ });
852
+ }
853
+ function restoreOriginalLineEndings(original, edits) {
854
+ const tokens = tokenizeLines(original);
855
+ const defaultEnding = tokens.find((token) => token.ending !== "")?.ending ?? "\n";
856
+ for (const edit of [...edits].reverse()) {
857
+ const start = edit.from.line - 1;
858
+ const count = edit.to.line - edit.from.line + 1;
859
+ const removed = tokens.slice(start, start + count);
860
+ const inheritedEnding = removed.at(-1)?.ending ?? "";
861
+ const internalEnding = removed.find((token) => token.ending !== "")?.ending ?? defaultEnding;
862
+ const lines = replacementLines(edit.content);
863
+ if (lines.length === 0 && removed.at(-1)?.ending === "" && start > 0) {
864
+ const previous = tokens[start - 1];
865
+ if (previous) tokens[start - 1] = {
866
+ ...previous,
867
+ ending: ""
868
+ };
869
+ }
870
+ const replacements = lines.map((text, index) => ({
871
+ text,
872
+ ending: index === lines.length - 1 ? inheritedEnding : internalEnding
873
+ }));
874
+ tokens.splice(start, count, ...replacements);
875
+ }
876
+ return tokens.map((token) => `${token.text}${token.ending}`).join("");
877
+ }
878
+ function tokenizeLines(content) {
879
+ const tokens = [];
880
+ let start = 0;
881
+ for (let index = 0; index < content.length; index += 1) {
882
+ const character = content[index];
883
+ if (character !== "\r" && character !== "\n") continue;
884
+ const ending = character === "\r" && content[index + 1] === "\n" ? "\r\n" : character;
885
+ tokens.push({
886
+ text: content.slice(start, index),
887
+ ending
888
+ });
889
+ if (ending === "\r\n") index += 1;
890
+ start = index + 1;
891
+ }
892
+ tokens.push({
893
+ text: content.slice(start),
894
+ ending: ""
895
+ });
896
+ return tokens;
897
+ }
898
+ function replacementLines(content) {
899
+ if (content === null || content === "") return [];
900
+ const normalized = normalizeToLf(content);
901
+ const trimmed = normalized.endsWith("\n") ? normalized.slice(0, -1) : normalized;
902
+ return trimmed === "" ? [] : trimmed.split("\n");
903
+ }
904
+ //#endregion
905
+ //#region ../../default/po-edit/src/extensions/workspaces/sessions/(backend)/tool/edit.server.ts
906
+ var edit_server_default = defineServerTool(({ context }) => {
907
+ let filesystem;
908
+ context.inject([PO_FS_SERVICE], (scoped) => {
909
+ const bound = requirePoFs(scoped);
910
+ filesystem = bound;
911
+ return () => {
912
+ if (filesystem === bound) filesystem = void 0;
913
+ };
914
+ });
915
+ return createHeadlessEditTool(() => {
916
+ if (!filesystem) throw new Error("Edit filesystem service is unavailable.");
917
+ return filesystem;
918
+ });
919
+ });
920
+ //#endregion
921
+ //#region ../../default/po-edit/generated/server.ts
922
+ const at = (value, context) => typeof value === "function" ? value(context) : value;
923
+ const via = (identity, value) => value === void 0 ? void 0 : {
924
+ ...identity,
925
+ ...value
926
+ };
927
+ const serverPlugin = defineServerPlugin({
928
+ name: "@agimon-ai/po-edit",
929
+ session: (context) => ({ get tools() {
930
+ return [via({ name: "edit" }, at(edit_server_default, context))];
931
+ } })
932
+ });
933
+ //#endregion
934
+ export { serverPlugin as default, serverPlugin };