@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,1116 @@
1
+ import { Hn as BACKGROUND_CONTEXT, Qn as readPoFs, S as PO_CONFIG_SERVICE, Sn as getOrThrow, V as String$1, _n as fileMutationRunner, ht as Optional, pt as _Object_, v as composeServerProviderOverrides } from "./serverPlugin-CELT6P0Q.js";
2
+ import { a as pathExists, i as FileTooLargeError, l as removePath, o as readBoundedFile, u as writeFileAtomic } from "./platform-BIEiM4TG.js";
3
+ import { p as resolvePlanningPlansDirectory } from "./layeredConfig-CUkYUs1f.js";
4
+ import "./sessionConfig-RQGvfm6E.js";
5
+ import "./exports-nV43ShA7.js";
6
+ import { c as defineRoot, h as defineServerPlugin, l as defineRoute, m as defineToolRestriction, n as composeRootInjects, t as composeRootHooks, u as defineRoutedContribution } from "./extensionFile-DNM4xsje.js";
7
+ import { n as readPackageResource } from "./index.edge-DyYmurS7.js";
8
+ import { t as Hono } from "./dist-B-vqs6tA.js";
9
+ import { t as defineMinorMode } from "./modeDefinition-C3Zbrw48.js";
10
+ import { t as serverMinorModes } from "./exports-B0WMEXCP.js";
11
+ import { a as PO_VOICE_AUTO_MODE_ID } from "./voiceTools-RMn4HvWo.js";
12
+ import { createHash } from "node:crypto";
13
+ import path from "node:path";
14
+ import { Buffer as Buffer$1 } from "node:buffer";
15
+ //#region ../../minor/po-plan/src/schemas/mcpTools.ts
16
+ const markdown = String$1({ minLength: 1 });
17
+ _Object_({ markdown }, { additionalProperties: false });
18
+ const writePlanParameters = _Object_({ markdown: Optional(markdown) }, { additionalProperties: false });
19
+ //#endregion
20
+ //#region ../../minor/po-plan/src/services/mcpTools/index.ts
21
+ const PLAN_MCP_TOOLS_SERVICE = "po/plan-mcp-tools";
22
+ function mountMcpTools(tools) {
23
+ return (context) => {
24
+ context.plugin((providerContext) => {
25
+ providerContext.provide(PLAN_MCP_TOOLS_SERVICE, {
26
+ get: (name) => tools.find((tool) => tool.name === name),
27
+ names: () => tools.map((tool) => tool.name)
28
+ });
29
+ });
30
+ };
31
+ }
32
+ //#endregion
33
+ //#region ../../minor/po-plan/src/services/planPointer/index.edge.ts
34
+ /** Session ids remain part of the path: a DO may also host child sessions. */
35
+ var PlanPointerService = class {
36
+ fileSystem;
37
+ constructor(options = {}) {
38
+ if (!options.fileSystem) throw new Error("Plan pointers require the session filesystem.");
39
+ this.fileSystem = options.fileSystem;
40
+ }
41
+ directory() {
42
+ return "/.po/plan";
43
+ }
44
+ pathFor(sessionId) {
45
+ return path.join(this.directory(), `${createHash("sha256").update(sessionId).digest("hex")}.json`);
46
+ }
47
+ async read(sessionId) {
48
+ let parsed;
49
+ try {
50
+ const bytes = await readBoundedFile(this.fileSystem, this.pathFor(sessionId), 16384, BACKGROUND_CONTEXT);
51
+ parsed = JSON.parse(Buffer$1.from(bytes).toString("utf8"));
52
+ } catch {
53
+ return;
54
+ }
55
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return void 0;
56
+ const { path: planPath, title, writtenAt, planId } = parsed;
57
+ if (typeof planPath !== "string" || !path.isAbsolute(planPath)) return void 0;
58
+ if (typeof title !== "string" || typeof writtenAt !== "string") return void 0;
59
+ return {
60
+ path: planPath,
61
+ title,
62
+ writtenAt,
63
+ ...typeof planId === "string" ? { planId } : {}
64
+ };
65
+ }
66
+ async write(sessionId, record) {
67
+ const content = JSON.stringify(record);
68
+ if (Buffer$1.byteLength(content, "utf8") > 16384) throw new Error("The plan pointer is too large.");
69
+ await writeFileAtomic(this.fileSystem, this.pathFor(sessionId), content, BACKGROUND_CONTEXT);
70
+ }
71
+ async clear(sessionId) {
72
+ await removePath(this.fileSystem, this.pathFor(sessionId), BACKGROUND_CONTEXT);
73
+ }
74
+ };
75
+ //#endregion
76
+ //#region ../../minor/po-plan/src/types/apiRoutes.ts
77
+ /**
78
+ * This package's routes, as data.
79
+ *
80
+ * No scope and no base path. The build reads both off
81
+ * `src/extensions/workspaces/sessions/(backend)/api/plans/`, so the mount is
82
+ * stated once, by the folder that creates it. The paths used to be written
83
+ * here as helpers, again in the contract, and again inside every URL the page
84
+ * built, and the copies were free to disagree.
85
+ *
86
+ * This is the one file the routes, the Hono app and the browser all read, so a
87
+ * path cannot move on one side alone.
88
+ *
89
+ * Neither route takes a query or a path parameter: a session has one current
90
+ * plan, so `current` answers it and `save` takes the manual write back.
91
+ */
92
+ const routes = {
93
+ current: {
94
+ method: "GET",
95
+ path: "/current",
96
+ response: void 0
97
+ },
98
+ save: {
99
+ method: "PUT",
100
+ path: "/content",
101
+ response: void 0
102
+ }
103
+ };
104
+ //#endregion
105
+ //#region ../../minor/po-plan/src/types/planApi.ts
106
+ /**
107
+ * The wire vocabulary this package's API shares with whatever calls it.
108
+ *
109
+ * It lives under src/types because that is the one server root a browser
110
+ * bundle may read: the routes answer with these shapes and the cockpit plugin
111
+ * reads them, so neither half can drift from the other. The paths themselves
112
+ * are not here; they are declared once in `./apiRoutes`, which the Hono app
113
+ * and the generated client both read.
114
+ *
115
+ * Two routes, and neither takes a path. A session has one current plan, so
116
+ * `current` answers it and `content` takes the manual save back; the file they
117
+ * act on is the one write_plan recorded, never one the page named. That is
118
+ * also why there is nothing to escape here: a reader cannot address a second
119
+ * file through these URLs.
120
+ */
121
+ /** Where a host mounts this package's API; the segment after /api/plugins/. */
122
+ const API_BASE_PATH = "plans";
123
+ /**
124
+ * Footer status key the session publishes once a plan exists, which is what
125
+ * makes the cockpit's activity group appear at all. It outlives plan mode: the
126
+ * plan is most worth reading while the agent implements it.
127
+ */
128
+ const PLAN_STATUS_KEY = "po-plan-document";
129
+ /** The selector contract shared by complete_plan and its cockpit composer prompt. */
130
+ const PLAN_REVIEW_TITLE = "Plan complete. What would you like to do?";
131
+ const EXIT_PLAN_MODE_CHOICE = "Exit plan mode and start implementation";
132
+ const CONTINUE_PLANNING_CHOICE = "Continue planning";
133
+ const EXIT_PLAN_DECISION = "exit";
134
+ const CONTINUE_PLAN_DECISION = "continue";
135
+ /**
136
+ * The label the reader sees paired with the decision the tool acts on. A headless
137
+ * client answers with `value`, so a server plugin never has to recognise the wording; Pi's
138
+ * own `ui.select` carries labels only, so its half maps the label back itself.
139
+ */
140
+ const PLAN_REVIEW_CHOICES = [{
141
+ label: EXIT_PLAN_MODE_CHOICE,
142
+ value: EXIT_PLAN_DECISION
143
+ }, {
144
+ label: CONTINUE_PLANNING_CHOICE,
145
+ value: CONTINUE_PLAN_DECISION
146
+ }];
147
+ PLAN_REVIEW_CHOICES.map((choice) => choice.label);
148
+ /** Between the plan's title and the stamp that marks a rewrite. */
149
+ const STATUS_SEPARATOR = " · ";
150
+ /** The status line the session publishes; the stamp changes on every write. */
151
+ function formatPlanStatus(title, stamp) {
152
+ return `${title}${STATUS_SEPARATOR}${stamp}`;
153
+ }
154
+ //#endregion
155
+ //#region ../../minor/po-plan/src/services/planFiles/index.edge.ts
156
+ const MAX_PLAN_BYTES$1 = 1048576;
157
+ function storage(fileSystem) {
158
+ if (!fileSystem) throw new Error("Plan files require the session filesystem.");
159
+ return fileSystem;
160
+ }
161
+ async function writeNewPlanFile(directory, filename, content, fileSystem) {
162
+ const fs = storage(fileSystem);
163
+ const planPath = path.join(directory, filename);
164
+ if (Buffer$1.byteLength(content, "utf8") > MAX_PLAN_BYTES$1) throw new Error(`The plan is larger than ${MAX_PLAN_BYTES$1} bytes.`);
165
+ return await fileMutationRunner.forKey(planPath)(async () => {
166
+ if (await pathExists(fs, planPath, BACKGROUND_CONTEXT)) throw new Error("The plan file already exists.");
167
+ await writeFileAtomic(fs, planPath, content, BACKGROUND_CONTEXT);
168
+ return planPath;
169
+ });
170
+ }
171
+ async function readPlanText(planPath, fileSystem) {
172
+ return Buffer$1.from(await readBoundedFile(storage(fileSystem), planPath, MAX_PLAN_BYTES$1, BACKGROUND_CONTEXT)).toString("utf8");
173
+ }
174
+ async function readPlanBytes(planPath, maxBytes, fileSystem) {
175
+ try {
176
+ return Buffer$1.from(await readBoundedFile(storage(fileSystem), planPath, maxBytes, BACKGROUND_CONTEXT));
177
+ } catch (error) {
178
+ if (error instanceof FileTooLargeError) return Buffer$1.alloc(maxBytes + 1);
179
+ throw error;
180
+ }
181
+ }
182
+ async function overwritePlanFile(planPath, content, expectedHash, maxBytes, fileSystem) {
183
+ const fs = storage(fileSystem);
184
+ if (Buffer$1.byteLength(content, "utf8") > maxBytes) throw new Error(`The plan is larger than ${maxBytes} bytes.`);
185
+ return await fileMutationRunner.forKey(planPath)(async () => {
186
+ if (getOrThrow(await fs.fileInfo(planPath, BACKGROUND_CONTEXT)).kind !== "file") return void 0;
187
+ const raw = await readPlanBytes(planPath, maxBytes, fs);
188
+ if (raw.length > maxBytes) return void 0;
189
+ const hash = createHash("sha256").update(raw.toString("utf8"), "utf8").digest("hex");
190
+ if (hash !== expectedHash) return {
191
+ written: false,
192
+ hash
193
+ };
194
+ await writeFileAtomic(fs, planPath, content, BACKGROUND_CONTEXT);
195
+ return {
196
+ written: true,
197
+ hash: createHash("sha256").update(content, "utf8").digest("hex")
198
+ };
199
+ });
200
+ }
201
+ //#endregion
202
+ //#region ../../minor/po-plan/src/services/planApi/index.ts
203
+ /**
204
+ * This package's HTTP surface: the session's current plan, and the manual save.
205
+ *
206
+ * Each path comes from the route table the browser reads, so a route the page
207
+ * calls and the route this serves cannot be spelled apart. Both are relative
208
+ * to the mount its host gives it, so nothing here repeats where it was mounted. The host is one session's own server, which is what
209
+ * makes the session id available without the page supplying it.
210
+ *
211
+ * Neither route takes a path. A session has exactly one current plan, and the
212
+ * file both routes act on is the one the pointer names, so a page can address
213
+ * the plan and nothing else; there is no traversal question to answer because
214
+ * there is no path to traverse.
215
+ *
216
+ * The save refuses unless the reader proves they were looking at the content
217
+ * that is still on disk. The agent may rewrite the plan while a tab is open,
218
+ * and silently discarding whichever side finished second is the one outcome
219
+ * worth ruling out.
220
+ */
221
+ /** Past this, the plan is reported rather than carried. */
222
+ const MAX_PLAN_BYTES = 1048576;
223
+ const NO_PLAN = "This session has not written a plan yet.";
224
+ const STALE_SAVE = "The plan changed since it was opened.";
225
+ const NOT_A_FILE = "The plan file is no longer a regular file, so it was not written.";
226
+ function hashOf(content) {
227
+ return createHash("sha256").update(content, "utf8").digest("hex");
228
+ }
229
+ /** Reads the plan as the source view will show it, or says why it cannot. */
230
+ async function readPlan(planPath, fileSystem) {
231
+ let raw;
232
+ try {
233
+ raw = await readPlanBytes(planPath, MAX_PLAN_BYTES, fileSystem);
234
+ } catch {
235
+ return {
236
+ content: "",
237
+ hash: "",
238
+ unavailable: true,
239
+ reason: "the plan file no longer exists"
240
+ };
241
+ }
242
+ if (raw.byteLength > 1048576) return {
243
+ content: "",
244
+ hash: "",
245
+ unavailable: true,
246
+ reason: `the plan is larger than ${MAX_PLAN_BYTES} bytes`
247
+ };
248
+ const content = raw.toString("utf8");
249
+ return {
250
+ content,
251
+ hash: hashOf(content),
252
+ unavailable: false
253
+ };
254
+ }
255
+ function createPlanApi(options = {}) {
256
+ const app = new Hono();
257
+ const pointers = options.pointers ?? new PlanPointerService({ fileSystem: options.fileSystem });
258
+ const pointerFor = () => options.sessionId === void 0 ? void 0 : pointers.read(options.sessionId);
259
+ app.get(routes.current.path, async (context) => {
260
+ const pointer = await pointerFor();
261
+ if (pointer === void 0) return context.json({ error: NO_PLAN }, 404);
262
+ const view = {
263
+ path: pointer.path,
264
+ title: pointer.title,
265
+ writtenAt: pointer.writtenAt,
266
+ ...pointer.planId === void 0 ? {} : { planId: pointer.planId },
267
+ ...await readPlan(pointer.path, options.fileSystem)
268
+ };
269
+ return context.json(view);
270
+ });
271
+ app.put(routes.save.path, async (context) => {
272
+ let request;
273
+ try {
274
+ request = await context.req.json();
275
+ } catch {
276
+ return context.json({ error: "The save body is not JSON." }, 400);
277
+ }
278
+ if (typeof request !== "object" || request === null || Array.isArray(request) || !("content" in request) || typeof request.content !== "string" || !("expectedHash" in request) || typeof request.expectedHash !== "string") return context.json({ error: "A save carries the content to write and the hash it was read at." }, 400);
279
+ const pointer = await pointerFor();
280
+ if (pointer === void 0) return context.json({ error: NO_PLAN }, 404);
281
+ if (Buffer.byteLength(request.content, "utf8") > 1048576) return context.json({ error: `The plan is larger than ${MAX_PLAN_BYTES} bytes.` }, 413);
282
+ try {
283
+ const saved = await overwritePlanFile(pointer.path, request.content, request.expectedHash, MAX_PLAN_BYTES, options.fileSystem);
284
+ if (saved === void 0) return context.json({ error: NOT_A_FILE }, 409);
285
+ if (!saved.written) return context.json({
286
+ error: STALE_SAVE,
287
+ hash: saved.hash
288
+ }, 409);
289
+ return context.json({ hash: saved.hash });
290
+ } catch {
291
+ return context.json({ error: NOT_A_FILE }, 409);
292
+ }
293
+ });
294
+ return app;
295
+ }
296
+ /** The named export a host imports from this package's built entry. */
297
+ function createPlanServerApi(fileSystem) {
298
+ return {
299
+ basePath: API_BASE_PATH,
300
+ start(context) {
301
+ const app = createPlanApi({
302
+ ...context.sessionId === void 0 ? {} : { sessionId: context.sessionId },
303
+ pointers: new PlanPointerService({
304
+ env: context.environment ?? {},
305
+ homeDirectory: context.homeDirectory,
306
+ fileSystem
307
+ }),
308
+ fileSystem
309
+ });
310
+ return {
311
+ fetch: (request) => app.fetch(request),
312
+ close: () => void 0
313
+ };
314
+ }
315
+ };
316
+ }
317
+ const api = createPlanServerApi();
318
+ //#endregion
319
+ //#region ../../minor/po-plan/src/services/prompts/index.ts
320
+ const EVIDENCE_FIELDS = [
321
+ "issue",
322
+ "expectedBehavior",
323
+ "reproductionAttempt",
324
+ "actualBehavior",
325
+ "logs",
326
+ "correlatedTraceEvidence",
327
+ "processOutput",
328
+ "browserConsoleEvidence",
329
+ "correlationIds",
330
+ "timestamps",
331
+ "verifiedFacts",
332
+ "hypotheses",
333
+ "unavailableEvidence"
334
+ ];
335
+ function evidenceLines(packet) {
336
+ return EVIDENCE_FIELDS.flatMap((field) => {
337
+ const value = packet[field];
338
+ if (Array.isArray(value) && value.length === 0) return [];
339
+ if (typeof value === "string" && value.length === 0) return [];
340
+ return `${field}: ${Array.isArray(value) ? value.join(" | ") : value}`;
341
+ }).join("\n");
342
+ }
343
+ /** The review protocol sentences that exist only because a host's tools support them. */
344
+ function reviewProtocolLines(capabilities) {
345
+ return [
346
+ ...capabilities.completePlanTakesDecision ? ["In an interactive text session, call complete_plan without a decision and it opens the exit-or-continue selector."] : [],
347
+ ...capabilities.narratesReview ? ["Under autonomous voice, complete_plan displays and narrates the choices without opening a blocking dialog, then ends the turn."] : [],
348
+ ...capabilities.completePlanTakesDecision ? ["Interpret the user's next ordinary message and call complete_plan again with decision \"exit\" or \"continue\"."] : []
349
+ ];
350
+ }
351
+ /**
352
+ * The host-independent plan mode block, pushed ahead of the flavor block.
353
+ *
354
+ * Both the Pi extension and the server plugin append this. It lives here so the cockpit and the
355
+ * terminal cannot drift into giving the agent different instructions for the same mode. The two
356
+ * hosts may differ only through {@link PlanHostCapabilities}, so every other sentence is shared
357
+ * by construction.
358
+ */
359
+ function buildPlanModeBasePrompt(plansDirectory, capabilities) {
360
+ const review = reviewProtocolLines(capabilities);
361
+ return `[PLAN MODE ACTIVE]\nYou are in repository read-only plan mode. The dedicated write_plan tool may write one unique Markdown plan file under ${plansDirectory}.\n\nExplore the codebase and produce a concrete implementation plan. For every plan, first call subagent with action "agents", cluster the exploration by independent domain, subsystem, or integration boundary, and create a provisional task graph with the task tool. Select specialized agents by matching their names and descriptions to each cluster. Assign every unblocked delegated task through the task tool, and use a one-shot inlineAgent with a focused systemPrompt when no discovered specialist fits. Treat the initial graph as provisional, not as a fixed contract. After findings arrive, review the entire graph at least once and perform one to three review passes in total. In each pass, use the evidence to add, rewrite, delete, cancel, reassign, or change blockedBy relationships for tasks when warranted. Do not keep following tasks that new information has made stale. Stop revising early when the graph is stable, or after the third pass.\n\nEvery plan must end with a delegated planning-draft stage blocked by all exploration and decision tasks. A single-boundary plan gets one planning draft. A complex plan spanning multiple subsystems, domains, packages, apps, or integration boundaries gets two planning drafts concurrently. Use three concurrent drafts instead when the work is cross-layer, migration-sensitive, security-sensitive, or similarly high risk. Assign each draft through the task tool to the discovered "planner" agent with context "fork" so it receives the conversation and gathered evidence. If the planner agent is unavailable, assign the same draft task through the task tool with a focused inlineAgent. All children receive read, Bash, grep, find, ls, and configured MCP tools with artifacts disabled. Bash and MCP tools are for read-only inspection and must not modify files, external systems, or repository state. Po Team runs asynchronously, so do not poll. After launch, continue non-overlapping exploration or end your turn; completion notifications wake the parent session.\n\nAfter all planning drafts complete, the main agent must compare the candidates, pick the strongest draft, cross-check it against the gathered evidence and the other drafts, resolve conflicts and gaps, and ask the user only for product decisions. A child produces the draft, but the main agent owns and synthesizes the final plan. The edit and write tools are withheld while plan mode is active; do not modify files or repository state except through write_plan. Start the final plan with a meaningful Markdown H1 because write_plan derives the filename from it. Present the complete plan as visible Markdown in chat, then call write_plan with no arguments. After write_plan succeeds, clear the completed durable task graph and call complete_plan so the user can review the plan and choose whether to begin implementation or continue planning. Do not exit plan mode without explicit approval.${review.length === 0 ? "" : `\n\n${review.join("\n")}`}`;
362
+ }
363
+ /** Normal planning adds only the flavor-specific brief to the shared planning workflow. */
364
+ function buildNormalPlanningPrompt() {
365
+ return `[PLAN MODE ACTIVE: NORMAL]\nStandard planning: follow the plan mode brief above using the read-only tools directly.`;
366
+ }
367
+ function buildDebugPlanningPrompt(plansDirectory, evidence) {
368
+ return `[PLAN MODE ACTIVE: DEBUG]\nYou are in repository read-only adaptive debug planning. The dedicated write_plan tool may write one unique Markdown plan file under ${plansDirectory}.\n\n${evidence ? `A bounded debug evidence packet is recorded below. Cite its verified facts when making source findings. Keep verified facts and hypotheses distinct. Do not claim a verified root cause when reproduction or supporting evidence is unavailable.\n\n[DEBUG EVIDENCE]\n${evidenceLines(evidence)}` : "No structured debug evidence packet is recorded yet. First understand the reported issue, then gather only the evidence relevant to it. Recording evidence is optional and must not block source exploration, delegation, writing a plan, or completing a plan."}\n\nUse the exact read-only tools available for the issue. Bash is available for repository inspection, but commands must not modify files or repository state. Treat unavailable evidence as unavailable, never invent its contents, and keep verified facts separate from hypotheses. ${evidence ? "The final plan must separate verified facts from hypotheses and must not present an unsupported root cause as verified." : "You may call record_debug_evidence when structured notes would help, but continue investigating without it when it is not relevant."}`;
369
+ }
370
+ function buildCodeReviewPlanningPrompt(plansDirectory) {
371
+ return `[PLAN MODE ACTIVE: CODE REVIEW]\nYou are in repository read-only code review planning. The dedicated write_plan tool may write one unique Markdown review and remediation plan under ${plansDirectory}.\n\nReview the user-specified change, commit range, or files. When no target is specified, inspect git status and the staged and unstaged diffs; ask for the review target when there are no changes to review. Trace changed behavior through callers, contracts, and relevant tests. Focus on concrete bugs, regressions, security risks, error handling, and missing regression coverage rather than unrelated cleanup or style preferences.\n\nPresent actionable findings in severity order with file and line references, the affected scenario, supporting evidence, and a minimal proposed fix. Keep verified behavior separate from source-based inferences and clearly state which checks were not run. Do not invent findings; explicitly report when no actionable issues are found and note remaining risks or test gaps. Turn supported findings into a scoped remediation plan with validation steps. Do not implement fixes or modify repository state during review. Present the final review plan, save it with write_plan, and use complete_plan for explicit approval before implementation.`;
372
+ }
373
+ function buildFlavorPlanningPrompt(flavor, plansDirectory, evidence) {
374
+ if (flavor === "debug") return buildDebugPlanningPrompt(plansDirectory, evidence);
375
+ if (flavor === "code-review") return buildCodeReviewPlanningPrompt(plansDirectory);
376
+ return buildNormalPlanningPrompt();
377
+ }
378
+ //#endregion
379
+ //#region ../../minor/po-plan/src/services/optionalTeamServices/index.ts
380
+ const PO_SUBAGENT_POLICY_SERVICE = "po/subagent-policy";
381
+ function readPoSubagentPolicyService(ctx) {
382
+ return ctx.get(PO_SUBAGENT_POLICY_SERVICE);
383
+ }
384
+ //#endregion
385
+ //#region ../../minor/po-plan/src/services/planServerSession/index.ts
386
+ const PLAN_ARTIFACT_SERVICE = "po/artifacts";
387
+ const RECORD_DEBUG_EVIDENCE_TOOL = "record_debug_evidence";
388
+ const WRITE_PLAN_TOOL = "write_plan";
389
+ const COMPLETE_PLAN_TOOL = "complete_plan";
390
+ const PLAN_MODE_ID = "plan";
391
+ const PLAN_MODEL_SNAPSHOT = "plan-server-model-snapshot";
392
+ const PLAN_FLAVOR_SNAPSHOT = "plan-server-flavor";
393
+ const PLAN_DEBUG_EVIDENCE = "plan-debug-evidence";
394
+ const PLAN_DOCUMENT = "plan-document";
395
+ /** This host supports UI review without narrated decisions. */
396
+ const PLAN_SERVER_CAPABILITIES = {
397
+ completePlanTakesDecision: false,
398
+ narratesReview: false
399
+ };
400
+ const PLAN_SUBAGENT_POLICY = {
401
+ owner: "@agimon-ai/po-plan",
402
+ allowMcpTools: true,
403
+ denyExtensions: false
404
+ };
405
+ function serverPlanSubagentPolicy(host) {
406
+ return (context) => {
407
+ context.inject([PO_SUBAGENT_POLICY_SERVICE], (child) => {
408
+ const service = readPoSubagentPolicyService(child);
409
+ if (!service) return void 0;
410
+ let handle;
411
+ const sync = () => {
412
+ if (modeSelected(host)) {
413
+ if (handle) handle.update(PLAN_SUBAGENT_POLICY);
414
+ else handle = service.register(PLAN_SUBAGENT_POLICY);
415
+ } else {
416
+ handle?.dispose();
417
+ handle = void 0;
418
+ }
419
+ };
420
+ sync();
421
+ child.effect(() => host.subscribeSelection(sync));
422
+ return () => handle?.dispose();
423
+ });
424
+ };
425
+ }
426
+ function modeSelected(host) {
427
+ return (host.context.selection.state?.["minor-mode"] ?? []).includes(PLAN_MODE_ID);
428
+ }
429
+ function output(value, isError = false) {
430
+ return {
431
+ content: [{
432
+ type: "text",
433
+ text: typeof value === "string" ? value : JSON.stringify(value, null, 2)
434
+ }],
435
+ details: value,
436
+ ...isError ? { isError: true } : {}
437
+ };
438
+ }
439
+ function createPlanServerSession(host, options) {
440
+ let flavor = "normal";
441
+ let debugEvidence;
442
+ let modeOwner;
443
+ const selected = () => modeSelected(host);
444
+ let configService;
445
+ let artifactStorage;
446
+ const planningConfig = () => configService?.getSnapshot().settings.modes?.planning;
447
+ const plansDirectory = async () => {
448
+ const root = await artifactStorage?.rootForSession(host.context.sessionId, host.context.environment);
449
+ if (root !== void 0) return path.join(root, "plans");
450
+ if (options.homeDirectory === void 0) throw new Error("Po needs a home directory to choose the plans folder.");
451
+ return resolvePlanningPlansDirectory(planningConfig()?.plansDirectory, host.context.repoRoot, options.homeDirectory);
452
+ };
453
+ const pointers = new PlanPointerService({
454
+ env: host.context.environment,
455
+ homeDirectory: options.homeDirectory,
456
+ fileSystem: options.fileSystem
457
+ });
458
+ /**
459
+ * The activity group's line, and the pointer its panel reads.
460
+ *
461
+ * A cockpit drives this server plugin and never the Pi runtime, so both were written
462
+ * only on the Pi side: the group never appeared, and when it did its panel
463
+ * had no pointer to answer from.
464
+ */
465
+ const announcePlanDocument = async (filePath, title, writtenAt) => {
466
+ const status = formatPlanStatus(title, planStampOf(writtenAt));
467
+ try {
468
+ await pointers.write(host.context.sessionId, {
469
+ path: filePath,
470
+ title,
471
+ writtenAt
472
+ });
473
+ host.context.client.setStatus(PLAN_STATUS_KEY, status);
474
+ } catch (error) {
475
+ const reason = error instanceof Error ? error.message : String(error);
476
+ host.context.client.setStatus(PLAN_STATUS_KEY, `${status} (plan panel not updated: ${reason})`);
477
+ }
478
+ };
479
+ const modeState = () => {
480
+ const active = selected();
481
+ return {
482
+ activation: active ? "active" : "inactive",
483
+ condition: "ready",
484
+ ...active ? {
485
+ detail: `${flavor} - read only`,
486
+ modelContextVariant: flavor
487
+ } : {},
488
+ actions: [{
489
+ id: "activate",
490
+ enabled: true
491
+ }, {
492
+ id: "deactivate",
493
+ enabled: active,
494
+ ...active ? {} : { disabledReason: "Plan mode is inactive." }
495
+ }]
496
+ };
497
+ };
498
+ const publishMode = () => modeOwner?.publish();
499
+ const restoreModel = async (snapshots) => {
500
+ const session = host.context.session;
501
+ const data = snapshots ? snapshots.get(PLAN_MODEL_SNAPSHOT) : await latestEntry(PLAN_MODEL_SNAPSHOT);
502
+ if (data === void 0 || data === null) return;
503
+ if (typeof data !== "object" || !("thinkingLevel" in data) || ![
504
+ "off",
505
+ "minimal",
506
+ "low",
507
+ "medium",
508
+ "high",
509
+ "xhigh",
510
+ "max"
511
+ ].includes(String(data.thinkingLevel))) throw new Error("The saved planning model settings are invalid.");
512
+ if (!session.setModelSettings) throw new Error("This session cannot restore its model settings.");
513
+ await session.setModelSettings(data);
514
+ await session.appendCustomEntry(PLAN_MODEL_SNAPSHOT, null);
515
+ };
516
+ const selectPlan = async (enabled, nextFlavor = flavor) => {
517
+ const wasEnabled = selected();
518
+ const session = host.context.session;
519
+ if (enabled && !wasEnabled) {
520
+ const config = planningConfig()?.main;
521
+ if (config?.model || config?.thinking) {
522
+ if (!session.readModelSettings || !session.setModelSettings) throw new Error("This session cannot apply planning model settings.");
523
+ const previous = await session.readModelSettings();
524
+ const settings = {};
525
+ if (config.model) {
526
+ const separator = config.model.indexOf("/");
527
+ const provider = separator > 0 ? config.model.slice(0, separator) : previous.model?.provider;
528
+ if (!provider) throw new Error("The planning model needs a provider.");
529
+ settings.model = {
530
+ provider,
531
+ id: separator > 0 ? config.model.slice(separator + 1) : config.model
532
+ };
533
+ }
534
+ if (config.thinking) settings.thinkingLevel = config.thinking;
535
+ await session.appendCustomEntry(PLAN_MODEL_SNAPSHOT, previous);
536
+ try {
537
+ await session.setModelSettings(settings);
538
+ } catch (error) {
539
+ await session.setModelSettings(previous);
540
+ await session.appendCustomEntry(PLAN_MODEL_SNAPSHOT, null);
541
+ throw error;
542
+ }
543
+ }
544
+ } else if (!enabled && wasEnabled) await restoreModel();
545
+ const modes = (host.context.selection.state?.["minor-mode"] ?? []).filter((mode) => mode !== PLAN_MODE_ID);
546
+ await host.changeSelection({
547
+ axis: "state",
548
+ key: "minor-mode",
549
+ values: enabled ? [...modes, PLAN_MODE_ID] : modes
550
+ });
551
+ flavor = nextFlavor;
552
+ await session.appendCustomEntry(PLAN_FLAVOR_SNAPSHOT, enabled ? { flavor } : null);
553
+ publishMode();
554
+ };
555
+ /** Newest value for a custom entry type, or undefined when none was recorded. */
556
+ const latestEntry = async (customType) => {
557
+ const snapshot = await host.context.session.customSnapshot?.(customType);
558
+ return snapshot?.available ? snapshot.entry?.data : void 0;
559
+ };
560
+ const restorePlanState = async () => {
561
+ const wanted = /* @__PURE__ */ new Set([
562
+ PLAN_FLAVOR_SNAPSHOT,
563
+ PLAN_DEBUG_EVIDENCE,
564
+ ...!selected() ? [PLAN_MODEL_SNAPSHOT] : []
565
+ ]);
566
+ const snapshots = /* @__PURE__ */ new Map();
567
+ for (const type of wanted) snapshots.set(type, await latestEntry(type));
568
+ const saved = snapshots.get(PLAN_FLAVOR_SNAPSHOT);
569
+ if (saved !== void 0 && saved !== null && typeof saved === "object" && "flavor" in saved) {
570
+ const candidate = String(saved.flavor);
571
+ if (candidate === "fable") flavor = "normal";
572
+ else if (candidate === "normal" || candidate === "debug" || candidate === "code-review") flavor = candidate;
573
+ }
574
+ const evidence = snapshots.get(PLAN_DEBUG_EVIDENCE);
575
+ if (evidence === void 0 || evidence === null) return snapshots;
576
+ try {
577
+ debugEvidence = parseDebugEvidencePacket(evidence);
578
+ } catch {
579
+ debugEvidence = void 0;
580
+ }
581
+ return snapshots;
582
+ };
583
+ modeOwner = defineMinorMode({
584
+ descriptor: {
585
+ source: "@agimon-ai/po-plan",
586
+ id: PLAN_MODE_ID,
587
+ label: "Plan",
588
+ description: "Read-only planning with normal, debug, and code review flavors.",
589
+ order: 40,
590
+ actions: [{
591
+ id: "activate",
592
+ label: "Activate",
593
+ description: "Activate plan mode or switch its planning flavor.",
594
+ contexts: ["headless"],
595
+ parameters: [{
596
+ name: "flavor",
597
+ label: "Flavor",
598
+ kind: "enum",
599
+ required: true,
600
+ choices: [
601
+ {
602
+ value: "normal",
603
+ label: "Normal"
604
+ },
605
+ {
606
+ value: "debug",
607
+ label: "Debug"
608
+ },
609
+ {
610
+ value: "code-review",
611
+ label: "Code Review"
612
+ }
613
+ ]
614
+ }]
615
+ }, {
616
+ id: "deactivate",
617
+ label: "Deactivate",
618
+ description: "Exit plan mode and restore the previous agent configuration.",
619
+ contexts: ["headless"],
620
+ parameters: []
621
+ }]
622
+ },
623
+ state: () => modeState(),
624
+ async handleAction(_runtime, actionId, argumentsValue, { signal }) {
625
+ signal.throwIfAborted();
626
+ if (actionId === "activate") {
627
+ const nextFlavor = argumentsValue.flavor;
628
+ if (nextFlavor !== "normal" && nextFlavor !== "debug" && nextFlavor !== "code-review") throw new Error("A valid plan flavor is required.");
629
+ await selectPlan(true, nextFlavor);
630
+ return { message: `Plan mode is active with the ${nextFlavor} flavor.` };
631
+ }
632
+ if (actionId === "deactivate") {
633
+ await selectPlan(false);
634
+ return { message: "Plan mode deactivated." };
635
+ }
636
+ throw new Error(`Unknown plan mode action: ${actionId}`);
637
+ }
638
+ }).createOwner(void 0);
639
+ return {
640
+ services: [
641
+ serverMinorModes([modeOwner]),
642
+ serverPlanSubagentPolicy(host),
643
+ (context) => {
644
+ context.inject([PO_CONFIG_SERVICE], (child) => {
645
+ const service = child.get(PO_CONFIG_SERVICE);
646
+ configService = service;
647
+ return () => {
648
+ if (configService === service) configService = void 0;
649
+ };
650
+ });
651
+ context.inject([PLAN_ARTIFACT_SERVICE], (child) => {
652
+ const storage = child.get(PLAN_ARTIFACT_SERVICE);
653
+ artifactStorage = storage;
654
+ return () => {
655
+ if (artifactStorage === storage) artifactStorage = void 0;
656
+ };
657
+ });
658
+ }
659
+ ],
660
+ resources: [{
661
+ when: {
662
+ state: { "minor-mode": PLAN_MODE_ID },
663
+ attribution: {
664
+ kind: "minor",
665
+ mode: PLAN_MODE_ID
666
+ }
667
+ },
668
+ name: "po-use-plan",
669
+ kind: "skill",
670
+ read: () => readPackageResource("bundle:///po-plan/src/services/planServerSession/index.ts", "src/prompts/po-use-plan/SKILL.md")
671
+ }],
672
+ tools: [
673
+ {
674
+ when: {
675
+ state: { "minor-mode": PLAN_MODE_ID },
676
+ attribution: {
677
+ kind: "minor",
678
+ mode: PLAN_MODE_ID
679
+ }
680
+ },
681
+ name: RECORD_DEBUG_EVIDENCE_TOOL,
682
+ label: "Record Debug Evidence",
683
+ description: "Record bounded debug evidence as optional planning context.",
684
+ parameters: {
685
+ type: "object",
686
+ properties: {
687
+ issue: { type: "string" },
688
+ expectedBehavior: { type: "string" },
689
+ reproductionAttempt: { type: "string" },
690
+ actualBehavior: { type: "string" },
691
+ logs: {
692
+ type: "array",
693
+ items: { type: "string" }
694
+ },
695
+ correlatedTraceEvidence: {
696
+ type: "array",
697
+ items: { type: "string" }
698
+ },
699
+ processOutput: {
700
+ type: "array",
701
+ items: { type: "string" }
702
+ },
703
+ browserConsoleEvidence: {
704
+ type: "array",
705
+ items: { type: "string" }
706
+ },
707
+ correlationIds: {
708
+ type: "array",
709
+ items: { type: "string" }
710
+ },
711
+ timestamps: {
712
+ type: "array",
713
+ items: { type: "string" }
714
+ },
715
+ verifiedFacts: {
716
+ type: "array",
717
+ items: { type: "string" }
718
+ },
719
+ hypotheses: {
720
+ type: "array",
721
+ items: { type: "string" }
722
+ },
723
+ unavailableEvidence: {
724
+ type: "array",
725
+ items: { type: "string" }
726
+ }
727
+ },
728
+ required: ["issue"],
729
+ additionalProperties: false
730
+ },
731
+ executionMode: "serial",
732
+ async execute(_toolCallId, parameters) {
733
+ try {
734
+ const parsedEvidence = parseDebugEvidencePacket(parameters);
735
+ await host.context.session.appendCustomEntry(PLAN_DEBUG_EVIDENCE, parsedEvidence);
736
+ debugEvidence = parsedEvidence;
737
+ return output({ recorded: true });
738
+ } catch (error) {
739
+ return output(error instanceof Error ? error.message : String(error), true);
740
+ }
741
+ }
742
+ },
743
+ {
744
+ when: {
745
+ state: { "minor-mode": PLAN_MODE_ID },
746
+ attribution: {
747
+ kind: "minor",
748
+ mode: PLAN_MODE_ID
749
+ }
750
+ },
751
+ name: WRITE_PLAN_TOOL,
752
+ label: "Write Plan",
753
+ mainAgentOnly: true,
754
+ description: "Save the supplied Markdown plan, or the plan already presented in the local session.",
755
+ parameters: writePlanParameters,
756
+ executionMode: "serial",
757
+ async execute(toolCallId, parameters, signal) {
758
+ try {
759
+ signal?.throwIfAborted();
760
+ let content = typeof parameters === "object" && parameters !== null && "markdown" in parameters ? parameters.markdown : void 0;
761
+ if (content !== void 0 && typeof content !== "string") throw new Error("Plan Markdown must be a string.");
762
+ if (content === void 0) for await (const entry of host.context.session.entriesNewestFirst({ type: "message" })) {
763
+ const message = entry.message;
764
+ if (message?.role !== "assistant" || !Array.isArray(message.content)) continue;
765
+ if (!message.content.some((block) => {
766
+ if (!block || typeof block !== "object") return false;
767
+ const call = block;
768
+ return call.type === "toolCall" && call.id === toolCallId && call.name === WRITE_PLAN_TOOL;
769
+ })) continue;
770
+ content = visiblePlanForToolCall([entry], toolCallId);
771
+ break;
772
+ }
773
+ if (content === void 0) {
774
+ if (host.context.selection.state?.["minor-mode"]?.includes("voice-auto")) throw new Error("Supply Markdown to write_plan during autonomous Voice; UI input is unavailable.");
775
+ const requested = await host.context.client.request({
776
+ kind: "input",
777
+ title: "Implementation plan",
778
+ multiline: true
779
+ }, signal);
780
+ content = typeof requested === "string" ? requested : "";
781
+ }
782
+ if (typeof content !== "string" || !content.trim()) throw new Error("No implementation plan content was supplied.");
783
+ const directory = await plansDirectory();
784
+ const title = planTitleOf(content);
785
+ const writtenAt = (/* @__PURE__ */ new Date()).toISOString();
786
+ const filePath = await writeNewPlanFile(directory, `${planTitleSlug(content)}-${Date.now()}.md`, `${content.trim()}\n`, options.fileSystem);
787
+ await host.context.session.appendCustomEntry(PLAN_DOCUMENT, {
788
+ path: filePath,
789
+ content: content.trim(),
790
+ title,
791
+ writtenAt
792
+ });
793
+ await announcePlanDocument(filePath, title, writtenAt);
794
+ await selectPlan(true);
795
+ const saved = {
796
+ path: filePath,
797
+ written: true
798
+ };
799
+ return {
800
+ ...output(saved),
801
+ structuredContent: saved
802
+ };
803
+ } catch (error) {
804
+ return output(error instanceof Error ? error.message : String(error), true);
805
+ }
806
+ }
807
+ },
808
+ {
809
+ when: {
810
+ state: { "minor-mode": PLAN_MODE_ID },
811
+ attribution: {
812
+ kind: "minor",
813
+ mode: PLAN_MODE_ID
814
+ }
815
+ },
816
+ name: COMPLETE_PLAN_TOOL,
817
+ label: "Complete Plan",
818
+ mainAgentOnly: true,
819
+ description: "Request exit-or-continue approval in the local Po UI. Requires the user to interact there; this is not a ChatGPT approval dialog.",
820
+ parameters: {
821
+ type: "object",
822
+ properties: {},
823
+ additionalProperties: false
824
+ },
825
+ executionMode: "serial",
826
+ async execute(_toolCallId, _parameters, signal) {
827
+ try {
828
+ if (host.context.selection.state?.["minor-mode"]?.includes("voice-auto")) throw new Error("UI plan review is unavailable during autonomous Voice. Wait for explicit user direction.");
829
+ const exited = await host.context.client.request({
830
+ kind: "select",
831
+ title: PLAN_REVIEW_TITLE,
832
+ options: PLAN_REVIEW_CHOICES.map((choice) => ({ ...choice }))
833
+ }, signal) === EXIT_PLAN_DECISION;
834
+ await host.context.session.appendCustomEntry("plan-review", { decision: exited ? EXIT_PLAN_DECISION : CONTINUE_PLAN_DECISION });
835
+ await selectPlan(!exited);
836
+ return {
837
+ content: [{
838
+ type: "text",
839
+ text: exited ? planExitText(hasTaskTracking(host)) : PLAN_CONTINUE_TEXT
840
+ }],
841
+ details: { exited }
842
+ };
843
+ } catch (error) {
844
+ return output(error instanceof Error ? error.message : String(error), true);
845
+ }
846
+ }
847
+ }
848
+ ],
849
+ hooks: [
850
+ {
851
+ when: {
852
+ state: { "minor-mode": PLAN_MODE_ID },
853
+ attribution: {
854
+ kind: "minor",
855
+ mode: PLAN_MODE_ID
856
+ }
857
+ },
858
+ event: "before_agent_start",
859
+ async handle(event) {
860
+ const prompt = typeof event.systemPrompt === "string" ? event.systemPrompt : "";
861
+ const directory = await plansDirectory();
862
+ const sections = [buildPlanModeBasePrompt(directory, PLAN_SERVER_CAPABILITIES), buildFlavorPlanningPrompt(flavor, directory, debugEvidence)];
863
+ const saved = await latestEntry(PLAN_DOCUMENT);
864
+ if (saved !== void 0 && saved !== null && typeof saved === "object" && "path" in saved) {
865
+ const document = saved;
866
+ let content = document.content ?? "";
867
+ try {
868
+ content = await readPlanText(document.path, options.fileSystem);
869
+ } catch {
870
+ content = document.content ?? "";
871
+ }
872
+ if (content.trim()) sections.push(`[CURRENT PLAN]\nSource: ${document.path}\n\n${content}`);
873
+ }
874
+ return { systemPrompt: `${prompt}\n\n${sections.join("\n\n")}`.trim() };
875
+ }
876
+ },
877
+ {
878
+ event: "session_start",
879
+ async handle() {
880
+ const snapshots = await restorePlanState();
881
+ publishMode();
882
+ const pointer = await pointers.read(host.context.sessionId);
883
+ if (pointer) host.context.client.setStatus(PLAN_STATUS_KEY, formatPlanStatus(pointer.title, planStampOf(pointer.writtenAt)));
884
+ if (!selected()) await restoreModel(snapshots);
885
+ }
886
+ },
887
+ {
888
+ event: "context",
889
+ async handle(event) {
890
+ if (!Array.isArray(event.messages)) return;
891
+ return { messages: event.messages.filter((message) => message.customType !== PLAN_MODE_CONTEXT) };
892
+ }
893
+ }
894
+ ]
895
+ };
896
+ }
897
+ const DEFAULT_PLAN_TITLE = "implementation-plan";
898
+ const PLAN_TITLE_MAX_LENGTH = 64;
899
+ const DEBUG_EVIDENCE_MAX_BYTES = 32768;
900
+ const DEBUG_EVIDENCE_MAX_TEXT_BYTES = 4096;
901
+ const DEBUG_EVIDENCE_MAX_ITEMS = 32;
902
+ const PLAN_MODE_CONTEXT = "agent-harness-plan-mode-context";
903
+ const PLAN_EXIT_APPROVED_TEXT = "The user approved exiting plan mode. Full tool access is restored. Begin implementing the approved plan.";
904
+ const PLAN_CONTINUE_TEXT = "The user chose to continue planning. Remain read-only and refine the plan.";
905
+ const PLAN_EXIT_TASK_TRACKING_TEXT = "Track implementation progress with po-task: create one task per plan step (the `tasks` code-mode namespace, or the `task` tool without code mode), mark each in progress when you start it and done when it is verified.";
906
+ /** po-task registers the `task` tool and its code-mode guide; either one means the session can track tasks. */
907
+ function hasTaskTracking(host) {
908
+ return host.inspectCapabilities().capabilities.some((capability) => capability.kind === "tool" && capability.name === "task" || capability.kind === "skill" && capability.name === "codemode-how-to-task");
909
+ }
910
+ function planExitText(taskTracking) {
911
+ return taskTracking ? `${PLAN_EXIT_APPROVED_TEXT} ${PLAN_EXIT_TASK_TRACKING_TEXT}` : PLAN_EXIT_APPROVED_TEXT;
912
+ }
913
+ /** The plan's own heading, as the status line and the pointer record word it. */
914
+ function planTitleOf(markdown) {
915
+ return markdown.match(/^#\s+(.+?)\s*$/m)?.[1] ?? DEFAULT_PLAN_TITLE;
916
+ }
917
+ function planTitleSlug(markdown) {
918
+ return planTitleOf(markdown).normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, PLAN_TITLE_MAX_LENGTH) || DEFAULT_PLAN_TITLE;
919
+ }
920
+ /**
921
+ * How the status line words when a plan was written. A malformed timestamp is
922
+ * shown as it came rather than as an invalid date: the stamp's other job is to
923
+ * change on a rewrite, and it can still do that.
924
+ */
925
+ function planStampOf(writtenAt) {
926
+ const at = new Date(writtenAt);
927
+ return Number.isNaN(at.getTime()) ? writtenAt : at.toLocaleTimeString();
928
+ }
929
+ function visiblePlanForToolCall(entries, toolCallId) {
930
+ for (let index = entries.length - 1; index >= 0; index -= 1) {
931
+ const entry = entries[index];
932
+ if (!entry || typeof entry !== "object") continue;
933
+ const candidate = entry;
934
+ if (candidate.type !== "message" || candidate.message?.role !== "assistant") continue;
935
+ if (!Array.isArray(candidate.message.content)) continue;
936
+ const toolIndex = candidate.message.content.findIndex((block) => {
937
+ if (!block || typeof block !== "object") return false;
938
+ const content = block;
939
+ return content.type === "toolCall" && content.id === toolCallId && content.name === WRITE_PLAN_TOOL;
940
+ });
941
+ if (toolIndex < 0) continue;
942
+ return candidate.message.content.slice(0, toolIndex).flatMap((block) => {
943
+ if (!block || typeof block !== "object") return [];
944
+ const content = block;
945
+ return content.type === "text" && typeof content.text === "string" ? [content.text] : [];
946
+ }).join("\n\n").trim() || void 0;
947
+ }
948
+ }
949
+ function isRecord(value) {
950
+ return typeof value === "object" && value !== null && !Array.isArray(value);
951
+ }
952
+ function isString(value) {
953
+ return typeof value === "string";
954
+ }
955
+ function boundedDebugText(value, field, required) {
956
+ if (!isString(value)) throw new Error(`${field} must be a string.`);
957
+ const text = value.trim();
958
+ if (required && !text) throw new Error(`${field} must not be empty.`);
959
+ if (Buffer$1.byteLength(text, "utf8") > DEBUG_EVIDENCE_MAX_TEXT_BYTES) throw new Error(`${field} exceeds the bounded debug evidence limit.`);
960
+ return text;
961
+ }
962
+ function boundedDebugList(value, field) {
963
+ if (!Array.isArray(value) || value.length > DEBUG_EVIDENCE_MAX_ITEMS) throw new Error(`${field} must be a bounded string array.`);
964
+ return value.map((item, index) => boundedDebugText(item, `${field}[${index}]`, false));
965
+ }
966
+ function optionalDebugText(value, field) {
967
+ return value === void 0 ? "" : boundedDebugText(value, field, false);
968
+ }
969
+ function optionalDebugList(value, field) {
970
+ return value === void 0 ? [] : boundedDebugList(value, field);
971
+ }
972
+ function assertExactObjectKeys(value, keys, field) {
973
+ const allowed = new Set(keys);
974
+ const unexpected = Object.keys(value).find((key) => !allowed.has(key));
975
+ if (unexpected) throw new Error(`${field} contains unsupported field '${unexpected}'.`);
976
+ }
977
+ function parseDebugEvidencePacket(value) {
978
+ if (!isRecord(value)) throw new Error("Debug evidence must be an object.");
979
+ assertExactObjectKeys(value, [
980
+ "issue",
981
+ "expectedBehavior",
982
+ "reproductionAttempt",
983
+ "actualBehavior",
984
+ "logs",
985
+ "correlatedTraceEvidence",
986
+ "processOutput",
987
+ "browserConsoleEvidence",
988
+ "correlationIds",
989
+ "timestamps",
990
+ "verifiedFacts",
991
+ "hypotheses",
992
+ "unavailableEvidence"
993
+ ], "Debug evidence");
994
+ const packet = {
995
+ issue: boundedDebugText(value.issue, "issue", true),
996
+ expectedBehavior: optionalDebugText(value.expectedBehavior, "expectedBehavior"),
997
+ reproductionAttempt: optionalDebugText(value.reproductionAttempt, "reproductionAttempt"),
998
+ actualBehavior: optionalDebugText(value.actualBehavior, "actualBehavior"),
999
+ logs: optionalDebugList(value.logs, "logs"),
1000
+ correlatedTraceEvidence: optionalDebugList(value.correlatedTraceEvidence, "correlatedTraceEvidence"),
1001
+ processOutput: optionalDebugList(value.processOutput, "processOutput"),
1002
+ browserConsoleEvidence: optionalDebugList(value.browserConsoleEvidence, "browserConsoleEvidence"),
1003
+ correlationIds: optionalDebugList(value.correlationIds, "correlationIds"),
1004
+ timestamps: optionalDebugList(value.timestamps, "timestamps"),
1005
+ verifiedFacts: optionalDebugList(value.verifiedFacts, "verifiedFacts"),
1006
+ hypotheses: optionalDebugList(value.hypotheses, "hypotheses"),
1007
+ unavailableEvidence: optionalDebugList(value.unavailableEvidence, "unavailableEvidence")
1008
+ };
1009
+ if (Buffer$1.byteLength(JSON.stringify(packet), "utf8") > DEBUG_EVIDENCE_MAX_BYTES) throw new Error("Debug evidence exceeds the bounded packet size.");
1010
+ return packet;
1011
+ }
1012
+ //#endregion
1013
+ //#region ../../minor/po-plan/src/extensions/workspaces/sessions/(backend)/root.server.ts
1014
+ var root_server_default = defineRoot(({ agent, host, context }) => {
1015
+ const fileSystem = readPoFs(context);
1016
+ const value = {
1017
+ api: [fileSystem ? createPlanServerApi(fileSystem) : api],
1018
+ ...agent ? createPlanServerSession(agent, {
1019
+ homeDirectory: host.context.homeDirectory ?? host.context.environment?.HOME,
1020
+ fileSystem
1021
+ }) : {}
1022
+ };
1023
+ return {
1024
+ value,
1025
+ services: [...value.services ?? [], ...value.tools?.length ? [mountMcpTools(value.tools)] : []]
1026
+ };
1027
+ });
1028
+ //#endregion
1029
+ //#region ../../minor/po-plan/src/extensions/workspaces/sessions/(backend)/api/plans/route.server.ts
1030
+ var route_server_default = defineRoute((context) => context.root.api[0]);
1031
+ //#endregion
1032
+ //#region ../../minor/po-plan/src/extensions/workspaces/sessions/(backend)/hook/beforeAgentStart.server.ts
1033
+ var beforeAgentStart_server_default = defineRoutedContribution((context) => context.root.hooks?.[0], { cardinality: "optional" });
1034
+ //#endregion
1035
+ //#region ../../minor/po-plan/src/extensions/workspaces/sessions/(backend)/hook/context.server.ts
1036
+ var context_server_default = defineRoutedContribution((context) => context.root.hooks?.[2], { cardinality: "optional" });
1037
+ //#endregion
1038
+ //#region ../../minor/po-plan/src/extensions/workspaces/sessions/(backend)/hook/sessionStart.server.ts
1039
+ var sessionStart_server_default = defineRoutedContribution((context) => context.root.hooks?.[1], { cardinality: "optional" });
1040
+ //#endregion
1041
+ //#region ../../minor/po-plan/src/extensions/workspaces/sessions/(backend)/resource/poUsePlan.server.ts
1042
+ var poUsePlan_server_default = defineRoutedContribution((context) => context.root.resources?.[0], { cardinality: "optional" });
1043
+ //#endregion
1044
+ //#region ../../minor/po-plan/src/extensions/workspaces/sessions/(backend)/tool-restriction/plan.server.ts
1045
+ var plan_server_default = defineToolRestriction({
1046
+ when: { state: { "minor-mode": PO_VOICE_AUTO_MODE_ID } },
1047
+ excludedTools: ["complete_plan"]
1048
+ });
1049
+ //#endregion
1050
+ //#region ../../minor/po-plan/src/extensions/workspaces/sessions/(backend)/tool-restriction/planReadOnly.server.ts
1051
+ var planReadOnly_server_default = defineToolRestriction({
1052
+ when: { state: { "minor-mode": "plan" } },
1053
+ excludedTools: ["edit", "write"]
1054
+ });
1055
+ //#endregion
1056
+ //#region ../../minor/po-plan/src/extensions/workspaces/sessions/(backend)/tool/completePlan.server.ts
1057
+ var completePlan_server_default = defineRoutedContribution((context) => context.root.tools?.[2], { cardinality: "optional" });
1058
+ //#endregion
1059
+ //#region ../../minor/po-plan/src/extensions/workspaces/sessions/(backend)/tool/recordDebugEvidence.server.ts
1060
+ var recordDebugEvidence_server_default = defineRoutedContribution((context) => context.root.tools?.[0], { cardinality: "optional" });
1061
+ //#endregion
1062
+ //#region ../../minor/po-plan/src/extensions/workspaces/sessions/(backend)/tool/writePlan.server.ts
1063
+ var writePlan_server_default = defineRoutedContribution((context) => context.root.tools?.[1], { cardinality: "optional" });
1064
+ //#endregion
1065
+ //#region ../../minor/po-plan/generated/server.ts
1066
+ const at = (value, context) => typeof value === "function" ? value(context) : value;
1067
+ /* v8 ignore next -- generated normalization branch */
1068
+ const defined = (values) => values.filter((value) => value !== void 0);
1069
+ const via = (identity, value) => value === void 0 ? void 0 : {
1070
+ ...identity,
1071
+ ...value
1072
+ };
1073
+ const serverPlugin = defineServerPlugin({
1074
+ name: "@agimon-ai/po-plan",
1075
+ providerOverrides: composeServerProviderOverrides(root_server_default),
1076
+ injects: composeRootInjects({ session: [root_server_default] }),
1077
+ session: async (context) => {
1078
+ const scopeSession = await context.scopeRoot("session", root_server_default, context);
1079
+ const contextSession = {
1080
+ ...context,
1081
+ root: scopeSession.value
1082
+ };
1083
+ return {
1084
+ ...composeRootHooks(scopeSession),
1085
+ get api() {
1086
+ return [at(route_server_default, contextSession)];
1087
+ },
1088
+ get hooks() {
1089
+ return defined([
1090
+ via({ event: "before_agent_start" }, at(beforeAgentStart_server_default, contextSession)),
1091
+ via({ event: "context" }, at(context_server_default, contextSession)),
1092
+ via({ event: "session_start" }, at(sessionStart_server_default, contextSession))
1093
+ ]);
1094
+ },
1095
+ get resources() {
1096
+ return defined([at(poUsePlan_server_default, contextSession)]);
1097
+ },
1098
+ get toolRestrictions() {
1099
+ return [at(plan_server_default, contextSession), at(planReadOnly_server_default, contextSession)];
1100
+ },
1101
+ get tools() {
1102
+ return defined([
1103
+ via({ name: "complete_plan" }, at(completePlan_server_default, contextSession)),
1104
+ via({ name: "record_debug_evidence" }, at(recordDebugEvidence_server_default, contextSession)),
1105
+ via({ name: "write_plan" }, at(writePlan_server_default, contextSession))
1106
+ ]);
1107
+ },
1108
+ services: [...scopeSession.services ?? []],
1109
+ get activities() {
1110
+ return [...scopeSession.activities ?? []];
1111
+ }
1112
+ };
1113
+ }
1114
+ });
1115
+ //#endregion
1116
+ export { serverPlugin as default, serverPlugin };