@agimon-ai/po-cloudflare 0.0.2-alpha.20 → 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 (222) hide show
  1. package/dist/{agent-DTjnYFAN.js → agent-DZ-OKOHn.js} +1 -1
  2. package/dist/{apiContracts-DepyzMNr.js → apiContracts-b33nSAAI.js} +4 -80
  3. package/dist/{approval-Biq3NCWj.js → approval-r3NnI1VC.js} +2 -2
  4. package/dist/{approvalPrompt-DoHlIPkU.js → approvalPrompt-DWoXxu3S.js} +2 -2
  5. package/dist/artifactFiles-DLCReI0-.js +1 -0
  6. package/dist/assets/assets/{CodeEditorView-BU8DeV_G.js → CodeEditorView-XeNS0L9M.js} +2 -2
  7. package/dist/assets/assets/{abnfDiagram-WEYOIA3C-BkzARjqu.js → abnfDiagram-WEYOIA3C-B6ZW0nkR.js} +2 -2
  8. package/dist/assets/assets/{architecture-WOLXFQ4H-B_dgnlXa.js → architecture-WOLXFQ4H-bVR64sHO.js} +1 -1
  9. package/dist/assets/assets/{architectureDiagram-ZHVYKT53-DMGAifk0.js → architectureDiagram-ZHVYKT53-D7tZz3io.js} +2 -2
  10. package/dist/assets/assets/{blockDiagram-RJAE7QA3-DwTSK4lj.js → blockDiagram-RJAE7QA3-DdwScfiX.js} +2 -2
  11. package/dist/assets/assets/{c4Diagram-XDPPPE54-IRaOcC_u.js → c4Diagram-XDPPPE54-DgSxZJCV.js} +2 -2
  12. package/dist/assets/assets/channel-TPcVvp_3.js +2 -0
  13. package/dist/assets/assets/{chunk-2E7WHVMD-BvS46crW.js → chunk-2E7WHVMD-D5TXC2SM.js} +2 -2
  14. package/dist/assets/assets/{chunk-4EMNKR2T--n96Xbj0.js → chunk-4EMNKR2T-BWhOSvo1.js} +2 -2
  15. package/dist/assets/assets/{chunk-55XCU76K-D3h_hFRi.js → chunk-55XCU76K-HkkBzLtZ.js} +2 -2
  16. package/dist/assets/assets/{chunk-7S6XSTFO-Cj18feJl.js → chunk-7S6XSTFO-CBnjycLU.js} +2 -2
  17. package/dist/assets/assets/{chunk-AQDTSKZB-DXsT43bg.js → chunk-AQDTSKZB-75lIIq8T.js} +2 -2
  18. package/dist/assets/assets/{chunk-DSNLSHJZ-Br7dX7yf.js → chunk-DSNLSHJZ-D8PpnXMk.js} +2 -2
  19. package/dist/assets/assets/{chunk-HAGFOTED-BcozAtPo.js → chunk-HAGFOTED-CXRS2NIN.js} +2 -2
  20. package/dist/assets/assets/{chunk-HNE4Q36P-B8kgXgRq.js → chunk-HNE4Q36P-BocUqS94.js} +2 -2
  21. package/dist/assets/assets/{chunk-NQOKRVIF-Dn7UnsqE.js → chunk-NQOKRVIF-CHf_ogYT.js} +2 -2
  22. package/dist/assets/assets/{chunk-UHW7PFBP-BSJot0vi.js → chunk-UHW7PFBP-DrW1PaIv.js} +2 -2
  23. package/dist/assets/assets/{chunk-VQ5W62QI-Cpf1EfZK.js → chunk-VQ5W62QI-CLoA7bFm.js} +2 -2
  24. package/dist/assets/assets/{chunk-WQQL4CDK-Dnc36uZR.js → chunk-WQQL4CDK-BmBsrj9I.js} +2 -2
  25. package/dist/assets/assets/chunk-XXDRQBXY-iFE4Tl8c.js +2 -0
  26. package/dist/assets/assets/{chunk-YZO67HFG-BV8_A7x3.js → chunk-YZO67HFG-DShE_cgv.js} +2 -2
  27. package/dist/assets/assets/{chunk-ZAUX2LTX-C4Ne_31B.js → chunk-ZAUX2LTX-B3oLvSXy.js} +2 -2
  28. package/dist/assets/assets/{chunk-ZCHMQSOR-Dq9ModsA.js → chunk-ZCHMQSOR-B14vKK7C.js} +2 -2
  29. package/dist/assets/assets/{classDiagram-v2-4MYWR3UA-1BWEjXP9.js → classDiagram-v2-4MYWR3UA-Da8elIW2.js} +2 -2
  30. package/dist/assets/assets/{cose-bilkent-JH36ORCC-DREkvC_x.js → cose-bilkent-JH36ORCC-Du4tGtiJ.js} +2 -2
  31. package/dist/assets/assets/{cynefin-EF2NZ3EQ-CWziP8nx.js → cynefin-EF2NZ3EQ-Cyj6i_WI.js} +1 -1
  32. package/dist/assets/assets/{cynefinDiagram-WF24UDRP-DOoYmcvz.js → cynefinDiagram-WF24UDRP-DFWXwO7A.js} +2 -2
  33. package/dist/assets/assets/{dagre-NK4GIZVX-OoAtEico.js → dagre-NK4GIZVX-C1wB_cf-.js} +2 -2
  34. package/dist/assets/assets/{diagram-CBK3MWTC-B-pl2-iR.js → diagram-CBK3MWTC-MYCOBYl6.js} +2 -2
  35. package/dist/assets/assets/{diagram-I5XIIV2D-uKzNJSZ2.js → diagram-I5XIIV2D-BFYbKUFf.js} +2 -2
  36. package/dist/assets/assets/{diagram-ODIL2UCW-CEXY_Tzu.js → diagram-ODIL2UCW-6siqTpv_.js} +2 -2
  37. package/dist/assets/assets/{diagram-PFBEJUXE-MKlRQo-g.js → diagram-PFBEJUXE-CaBr9CoB.js} +2 -2
  38. package/dist/assets/assets/{diagram-RJA3I4VV-c2qlCEVs.js → diagram-RJA3I4VV-DAvmuDpc.js} +2 -2
  39. package/dist/assets/assets/{diagram-TYUNFSNR-DTdqLA6J.js → diagram-TYUNFSNR-CJnhgCpo.js} +2 -2
  40. package/dist/assets/assets/{dist-qZHwVT1x.js → dist-BQ4W1R18.js} +2 -2
  41. package/dist/assets/assets/{dist-DvZCwSZ8.js → dist-BnzFckPF.js} +2 -2
  42. package/dist/assets/assets/{dist-DCKskbBE.js → dist-CFtBpcYL.js} +2 -2
  43. package/dist/assets/assets/{dist-mQUN8X3n.js → dist-CIQX1z4W.js} +2 -2
  44. package/dist/assets/assets/{dist-D9lacOpq.js → dist-ChHYoe9_.js} +2 -2
  45. package/dist/assets/assets/{dist-BzTxJnSR.js → dist-DKxZO8d9.js} +2 -2
  46. package/dist/assets/assets/{dist-DCc8tQ7G.js → dist-DL6z28wl.js} +2 -2
  47. package/dist/assets/assets/{dist-4TUOlkyl.js → dist-DNyn1p9Z.js} +2 -2
  48. package/dist/assets/assets/{dist-DXlts_H5.js → dist-qYlLXIa8.js} +2 -2
  49. package/dist/assets/assets/{ebnfDiagram-V4P3TTPT-C89wxfCd.js → ebnfDiagram-V4P3TTPT-AUcqDTM3.js} +2 -2
  50. package/dist/assets/assets/{elk-QONTBCTQ-BMBgLOae.js → elk-QONTBCTQ-aA10PEHJ.js} +2 -2
  51. package/dist/assets/assets/{erDiagram-KYQIGQAA-Bb04CRa4.js → erDiagram-KYQIGQAA-hhYiqA-x.js} +2 -2
  52. package/dist/assets/assets/{eventmodeling-K75KTNOO-DSyNf2MV.js → eventmodeling-K75KTNOO-BQZqbRo5.js} +1 -1
  53. package/dist/assets/assets/flowDiagram-IUGLLWBU-BuyysPYC.js +1 -0
  54. package/dist/assets/assets/{ganttDiagram-R7GPNTJY-sB7-pF_t.js → ganttDiagram-R7GPNTJY-CLON1GpW.js} +2 -2
  55. package/dist/assets/assets/{gitGraph-VSP46ZUC-pWPBCmdT.js → gitGraph-VSP46ZUC-DbmvNwR2.js} +1 -1
  56. package/dist/assets/assets/{gitGraphDiagram-PDYL7XHY-DronDRed.js → gitGraphDiagram-PDYL7XHY-DJVO0WlL.js} +2 -2
  57. package/dist/assets/assets/index-BiTVAj5E.js +155 -0
  58. package/dist/assets/assets/{info-OHQRW6UA-B375mT1i.js → info-OHQRW6UA-CAt3Nt3g.js} +1 -1
  59. package/dist/assets/assets/{infoDiagram-MVDRKAX5-9Hw3wWP7.js → infoDiagram-MVDRKAX5-DTuqH-Zb.js} +2 -2
  60. package/dist/assets/assets/{ishikawaDiagram-HPEHV2GE-CdPAuupk.js → ishikawaDiagram-HPEHV2GE-BnWvdonT.js} +2 -2
  61. package/dist/assets/assets/{journeyDiagram-BOSHW7O7-hqmaHM9u.js → journeyDiagram-BOSHW7O7-Btxtcgvl.js} +2 -2
  62. package/dist/assets/assets/{kanban-definition-FNSA4HC5-BdOHplX4.js → kanban-definition-FNSA4HC5-q7ek9o_H.js} +2 -2
  63. package/dist/assets/assets/{line-BCSC3Bu2.js → line-B7yLilmC.js} +2 -2
  64. package/dist/assets/assets/{linear-D5ddQU3r.js → linear-y8aSKEli.js} +2 -2
  65. package/dist/assets/assets/{mermaid-parser.core-BaSUi_Ph.js → mermaid-parser.core-B4rH50nD.js} +4 -4
  66. package/dist/assets/assets/{mermaid.core-CUUsU9Ou.js → mermaid.core-DnRVHTjE.js} +5 -5
  67. package/dist/assets/assets/{mindmap-definition-6OY57UG3-BtVkhvIZ.js → mindmap-definition-6OY57UG3-DT9Afs2v.js} +2 -2
  68. package/dist/assets/assets/{packet-JDAUHWVQ-CQ3OUDwI.js → packet-JDAUHWVQ-CnqNbu4p.js} +1 -1
  69. package/dist/assets/assets/{pegDiagram-ECIUJNBX-DDnq-Kn3.js → pegDiagram-ECIUJNBX-cvxdBBFq.js} +2 -2
  70. package/dist/assets/assets/{pie-XZMESJXO-BvOFTkQB.js → pie-XZMESJXO-etXMNsaL.js} +1 -1
  71. package/dist/assets/assets/{pieDiagram-GNMPY74T-Bdwhl9jD.js → pieDiagram-GNMPY74T-CBN-R3_j.js} +2 -2
  72. package/dist/assets/assets/{quadrantDiagram-D57K4MC3-GHKoDEeT.js → quadrantDiagram-D57K4MC3-C5jjVPIH.js} +2 -2
  73. package/dist/assets/assets/{radar-ABXABTNO-Yk9rKkKW.js → radar-ABXABTNO-CAMd_mrV.js} +1 -1
  74. package/dist/assets/assets/{railroad-I3PHUGI6-Crr2QEwm.js → railroad-I3PHUGI6-DIs3auoe.js} +1 -1
  75. package/dist/assets/assets/{railroad-abnf-LNEFI6M7-CLrgwBog.js → railroad-abnf-LNEFI6M7-CJXr1qWy.js} +1 -1
  76. package/dist/assets/assets/{railroad-ebnf-DWYD2UWJ-zWReI6MC.js → railroad-ebnf-DWYD2UWJ-DfwtykqI.js} +1 -1
  77. package/dist/assets/assets/{railroad-peg-JR7BVNR7-CnVnlaHi.js → railroad-peg-JR7BVNR7-B8beAhTs.js} +1 -1
  78. package/dist/assets/assets/{railroadDiagram-Y72NRBL7-MJ68mMla.js → railroadDiagram-Y72NRBL7-BDcQE-EL.js} +2 -2
  79. package/dist/assets/assets/{requirementDiagram-EQYSW5RA-BYb-mTCH.js → requirementDiagram-EQYSW5RA-KJ4-QjZM.js} +2 -2
  80. package/dist/assets/assets/{sankeyDiagram-SY24JHO5-DzONJsqQ.js → sankeyDiagram-SY24JHO5-VjIB-Ybr.js} +2 -2
  81. package/dist/assets/assets/{sequenceDiagram-BLEHNHQU-0vav9YWV.js → sequenceDiagram-BLEHNHQU-MfMuWq1M.js} +2 -2
  82. package/dist/assets/assets/{src-DZJUnjaM.js → src-BAxIj8GJ.js} +2 -2
  83. package/dist/assets/assets/{stateDiagram-v2-A6IESKWZ-B0M8THPh.js → stateDiagram-v2-A6IESKWZ-mHwLRRCY.js} +2 -2
  84. package/dist/assets/assets/{swimlanes-B3ENRKFQ-5YJZCHIB.js → swimlanes-B3ENRKFQ-PArlYoqV.js} +2 -2
  85. package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-The09-5S.js +9 -0
  86. package/dist/assets/assets/{timeline-definition-JXYKGLGB-us1LwUHo.js → timeline-definition-JXYKGLGB-B2nKiNFU.js} +2 -2
  87. package/dist/assets/assets/{treeView-D4JQ5SDB-BSLlcDre.js → treeView-D4JQ5SDB-gU23_RuI.js} +1 -1
  88. package/dist/assets/assets/{treemap-SAJKECNS-DZ2SwLmk.js → treemap-SAJKECNS-CiqoMvZa.js} +1 -1
  89. package/dist/assets/assets/{usecaseDiagram-WPOLBNNX-BrmvO_6k.js → usecaseDiagram-WPOLBNNX-DpeoWpMK.js} +2 -2
  90. package/dist/assets/assets/{vennDiagram-Q3Y3IDCW-FKXSeKp5.js → vennDiagram-Q3Y3IDCW-C31iGKvM.js} +2 -2
  91. package/dist/assets/assets/{wardley-7MLQ67FV-DZ_vIMp2.js → wardley-7MLQ67FV-CIzHhzNw.js} +1 -1
  92. package/dist/assets/assets/{wardleyDiagram-IVAIDKWA-CfLYNckm.js → wardleyDiagram-IVAIDKWA-DIIkoezc.js} +2 -2
  93. package/dist/assets/assets/{webpack-CiS_BB3R.js → webpack-RFseiMZW.js} +2 -2
  94. package/dist/assets/assets/{xychartDiagram-4URNHDU4-DBucwhQh.js → xychartDiagram-4URNHDU4-QiHL91kC.js} +2 -2
  95. package/dist/assets/bundle-asset-policy.json +1 -1
  96. package/dist/assets/index.html +1 -1
  97. package/dist/assets/plugins/assets/base-CKKRZ7-h.css +2 -0
  98. package/dist/assets/plugins/assets/browserCaptureWorklet-Droj0fW0-Droj0fW0.js +13 -0
  99. package/dist/assets/plugins/assets/sileroVadWorker-D894njUe-DjN_BMWf.mjs +110 -0
  100. package/dist/assets/plugins/assets/silero_vad_v6.2.1-SjbCxFXk-SjbCxFXk.onnx +0 -0
  101. package/dist/assets/plugins/chunks/po-web-runtime-BJDT6Lbw.js +1 -0
  102. package/dist/assets/plugins/compositions.json +1 -1
  103. package/dist/assets/plugins/slots/approval.293d9a00-BXIhaPlQ.js +2 -0
  104. package/dist/assets/plugins/slots/artifacts.24567664-ZzR0gbvy.js +1 -0
  105. package/dist/assets/plugins/slots/author.0998a880-DAbA-7rb.js +93 -0
  106. package/dist/assets/plugins/slots/{autocompact.ec8f713f-B3KTYwW1.js → autocompact.dd97d013-IVq4Z6qm.js} +1 -1
  107. package/dist/assets/plugins/slots/builtin-tools.36d7400b-CpCLjRRN.js +7 -0
  108. package/dist/assets/plugins/slots/codemode.8eaee717-VWt9PqsU.js +10 -0
  109. package/dist/assets/plugins/slots/domain.5e95fc37-5PIUBqDe.js +1 -0
  110. package/dist/assets/plugins/slots/edit.385c9aa9-DNAjPNG5.js +7 -0
  111. package/dist/assets/plugins/slots/files.daf34ed8-CQaTz0i1.js +2 -0
  112. package/dist/assets/plugins/slots/goal.77ec9930-B8EkarBq.js +1 -0
  113. package/dist/assets/plugins/slots/grep.02052cdc-CIRhO2gY.js +1 -0
  114. package/dist/assets/plugins/slots/help.ecd4c0f9-naMF9NN1.js +3 -0
  115. package/dist/assets/plugins/slots/log.a86eb6d0-D5__rAZJ.js +4 -0
  116. package/dist/assets/plugins/slots/{mcp.ea8b6aa2-D0CkHnIw.js → mcp.974af249-DPNHn9XH.js} +10 -10
  117. package/dist/assets/plugins/slots/plan.bafb8f68-C5GEpybF.js +3 -0
  118. package/dist/assets/plugins/slots/{profile.63bc3ae6-BSY3iYfJ.js → profile.48851a1d-yX6tzV3x.js} +1 -1
  119. package/dist/assets/plugins/slots/prompts.723d7748-B7zpPeoF.js +3 -0
  120. package/dist/assets/plugins/slots/read.46bf6536-Cw5Z5z5T.js +1 -0
  121. package/dist/assets/plugins/slots/runner.53e9bd76-CiQR_FPX.js +8 -0
  122. package/dist/assets/plugins/slots/skill.086701a4-CL6h_F-x.js +4 -0
  123. package/dist/assets/plugins/slots/vault.ac9935c8-DKERQYg4.js +1 -0
  124. package/dist/assets/plugins/slots/voice.e85ca7f9-DEgb-U9m.js +1 -0
  125. package/dist/{atomicJson-DCIsEywH.js → atomicJson-C_7F2zD1.js} +2 -3
  126. package/dist/{backgroundWork-Bswjs1av.js → backgroundWork-B1mPDYlf.js} +1 -1
  127. package/dist/{codemode-CgVosRtU.js → codemode-DQFmrosw.js} +1 -1
  128. package/dist/{contracts-CylyLZC8.js → contracts-DD3f1Lpn.js} +1 -1
  129. package/dist/exports-B0WMEXCP.js +34 -0
  130. package/dist/{exports-DERO0cQf.js → exports-D09VsUk-.js} +6 -7
  131. package/dist/{exports-C_dclnKs.js → exports-nV43ShA7.js} +10 -9
  132. package/dist/{extensionFile-Ds7RCpnb.js → extensionFile-DNM4xsje.js} +16 -2
  133. package/dist/{domains-BqChtBLN.js → harnessState-Dwrk3lfv.js} +90 -5
  134. package/dist/{harnessStore-BectazJQ.js → harnessStore-Z7yDLO45.js} +4 -5
  135. package/dist/{help-Dpm82qDr.js → help-w6vVEZGL.js} +15 -5
  136. package/dist/hubChannel-Cm-sxOvU.js +21 -0
  137. package/dist/{index.edge-b0z7PQ6b.js → index.edge-DyYmurS7.js} +14 -2
  138. package/dist/{index.edge-B0D_Lgbx.js → index.edge-K0w5auwG.js} +2 -2
  139. package/dist/{index.edge-BLmsRNW8.js → index.edge-Xa5LLtxz.js} +13 -3
  140. package/dist/{layeredConfig-pQGjhAks.js → layeredConfig-CUkYUs1f.js} +74 -5
  141. package/dist/{majorModes-BrL4EtzH.js → majorModes-BB0PXgFn.js} +3 -4
  142. package/dist/majorModes-C7vtBs4D.js +1 -0
  143. package/dist/{mcpProjection-pbPBBuvs.js → mcpProjection-BtKzB6oK.js} +2 -2
  144. package/dist/modeDefinition-C3Zbrw48.js +44 -0
  145. package/dist/narration-CpRurWLO.js +127 -0
  146. package/dist/{notification-CINsJWDL.js → notification-kckG3leF.js} +2 -2
  147. package/dist/{hubChannel-COvmdWGO.js → packageApi-t1oCjNDU.js} +2 -22
  148. package/dist/{piConfig-BDUpA6w0.js → piConfig-DQzlbPY4.js} +4 -5
  149. package/dist/piSettings-Cf1QofNe.js +1 -0
  150. package/dist/platform-BIEiM4TG.js +113 -0
  151. package/dist/pluginProtocol-BqXXyI4z.js +80 -0
  152. package/dist/{protocol-B6LbEIe6.js → protocol-DDL8geoS.js} +2 -2
  153. package/dist/{server-DRcCuj6P.js → server-AbXyhXlY.js} +4 -4
  154. package/dist/{server-Re1VNk9s.js → server-B6dqQoh2.js} +7 -6
  155. package/dist/{server-cStfn1Yv.js → server-BIHo9TFu.js} +4 -4
  156. package/dist/{server-1O3JEYO0.js → server-BJ7DNzCp.js} +7 -7
  157. package/dist/server-BO-j_GbD.js +15106 -0
  158. package/dist/{server-Cgym-G0a.js → server-BQzAiMns.js} +11 -11
  159. package/dist/server-BR7SZtj7.js +3125 -0
  160. package/dist/{server-DL6UyXfJ.js → server-BT2ORK83.js} +9 -8
  161. package/dist/{server-CzJjYgVk.js → server-BbSHYRnY.js} +3 -3
  162. package/dist/{server-DFCXmDed.js → server-BqoKlEGk.js} +8 -8
  163. package/dist/{server-BXFDsLgm.js → server-Busl0pQI.js} +8 -9
  164. package/dist/server-CIHM4jqu.js +1116 -0
  165. package/dist/{server-DhkR6ugd.js → server-CgWSSdvd.js} +6 -7
  166. package/dist/{server-B8P-UkxF.js → server-Co_UWKrR.js} +5 -5
  167. package/dist/{server-Bt6Zsqo8.js → server-CuEPb7u-.js} +2 -2
  168. package/dist/{server-V8W5mcGu.js → server-D40q2Jpx.js} +47 -27
  169. package/dist/{server-OerXqXJT.js → server-DCyf2Asb.js} +3 -4
  170. package/dist/{server-CCwwnpH0.js → server-DH7PfLln.js} +5 -5
  171. package/dist/{server-_0288DYR.js → server-DJ8bc89M.js} +3 -4
  172. package/dist/{server-GIQIpf33.js → server-DYdp0W9v.js} +7 -7
  173. package/dist/{server-B2G-c0hg.js → server-DsdPEYGu.js} +5 -5
  174. package/dist/{server-Dgn4el5K.js → server-DymH4Ucq.js} +4 -5
  175. package/dist/{server-pY027myK.js → server-IqECnUrb.js} +13 -236
  176. package/dist/{server-Ci_BGVwd.js → server-KBgW77zh.js} +3 -3
  177. package/dist/server-RW_9R3R3.js +1522 -0
  178. package/dist/server-aUit8j6r.js +1028 -0
  179. package/dist/{server-Ci3ls6LL.js → server-gifRriZK.js} +10 -11
  180. package/dist/{server-BR9yl54i.js → server-nkUlqnAL.js} +10 -10
  181. package/dist/server-oxyEbv1a.js +1256 -0
  182. package/dist/{server-DPTp6GXS.js → server-ub3s16Mc.js} +4 -4
  183. package/dist/{serverPlugin-OOfjB8tm.js → serverPlugin-CELT6P0Q.js} +12 -3
  184. package/dist/{sessionConfig-DfwcUKO2.js → sessionConfig-RQGvfm6E.js} +9 -10
  185. package/dist/{server-CyYesT-G.js → type-ASYnCGVW.js} +9 -1031
  186. package/dist/{validation-DuOGOKEi.js → validation-BJxVSAwx.js} +8 -3
  187. package/dist/{value-DyVsxCwZ.js → value-_W31So3B.js} +1 -1
  188. package/dist/{vaultSettings-BFCRCBM3.js → vaultSettings-Di3n5YIg.js} +1 -1
  189. package/dist/voiceTools-RMn4HvWo.js +246 -0
  190. package/dist/web-DCP7ELJj.js +3 -0
  191. package/dist/worker.js +345 -244
  192. package/dist/{workflow-BgwWq0nq.js → workflow-B7qx0Vv9.js} +1 -1
  193. package/package.json +37 -32
  194. package/wrangler.jsonc +2 -0
  195. package/dist/assets/assets/channel-BXwM62E-.js +0 -2
  196. package/dist/assets/assets/chunk-XXDRQBXY-C9Ka5KSI.js +0 -2
  197. package/dist/assets/assets/flowDiagram-IUGLLWBU-DXuTqLUd.js +0 -1
  198. package/dist/assets/assets/index-DdAdCxGc.js +0 -155
  199. package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-aJTRXiIU.js +0 -9
  200. package/dist/assets/plugins/assets/base-C3j1WCCq.css +0 -2
  201. package/dist/assets/plugins/chunks/po-web-runtime-Czm_C4SJ.js +0 -1
  202. package/dist/assets/plugins/slots/approval.3e4ea6e4-CqQk6XG_.js +0 -2
  203. package/dist/assets/plugins/slots/artifacts.84980c32-DQlO5IFk.js +0 -1
  204. package/dist/assets/plugins/slots/builtin-tools.16ef5e25-CZRYQVIP.js +0 -7
  205. package/dist/assets/plugins/slots/codemode.5f359b9c-Bzl_K_vt.js +0 -10
  206. package/dist/assets/plugins/slots/domain.832848c8-CvnpuKCY.js +0 -1
  207. package/dist/assets/plugins/slots/edit.7c802139-kaxIknZ-.js +0 -7
  208. package/dist/assets/plugins/slots/files.364f16c9-wuB8gcQA.js +0 -2
  209. package/dist/assets/plugins/slots/grep.d8bf9f57-3FnU8p-d.js +0 -1
  210. package/dist/assets/plugins/slots/log.07fd59a4-C0PXQ0O1.js +0 -4
  211. package/dist/assets/plugins/slots/prompts.9d9b47cc-xdCkNkoA.js +0 -3
  212. package/dist/assets/plugins/slots/read.926c024f-qqaxVlEX.js +0 -1
  213. package/dist/assets/plugins/slots/runner.5393fa6c-DfO2Z9HG.js +0 -8
  214. package/dist/assets/plugins/slots/skill.56c1cc07-CL_n-l4h.js +0 -4
  215. package/dist/assets/plugins/slots/vault.587549ba-DbG3F_on.js +0 -1
  216. package/dist/harnessState-gmzJcPGt.js +0 -88
  217. package/dist/harnessStore-C0Zwvny8.js +0 -1
  218. package/dist/majorModes-WXt22_km.js +0 -1
  219. package/dist/piSettings-tdui0CZI.js +0 -1
  220. package/dist/platform-yhQXrrM_.js +0 -16
  221. package/dist/platformFiles-DB3Cw1l_.js +0 -64
  222. package/dist/web-cN41ySs9.js +0 -3
@@ -0,0 +1 @@
1
+ import{$n as e,An as t,Cn as n,Cr as r,En as i,H as a,I as o,Mt as s,Nt as c,Ot as l,Pt as u,Qn as d,Rn as f,Sn as p,Tn as m,Tt as h,Un as g,Xn as _,a as v,at as y,bn as b,br as x,c as ee,ct as S,et as C,fr as w,h as T,jn as E,jt as te,kn as ne,l as re,m as ie,mr as ae,n as D,o as O,ot as k,s as A,st as j,tn as oe,tr as M,u as se,un as N,wn as P,xn as F,zt as I}from"../chunks/po-web-runtime-BJDT6Lbw.js";var ce=/^[A-Za-z0-9@][A-Za-z0-9@/._:-]*$/u,L=`domains`,R=`newDomain`,z={view:{method:`GET`,path:`/view`,response:void 0},toggle:{method:`POST`,path:`/toggle`,response:void 0},addToDomain:{method:`POST`,path:`/domain-plugins`,response:void 0},removeFromDomain:{method:`DELETE`,path:`/domain-plugins`,response:void 0},createDomain:{method:`POST`,path:`/domains`,response:void 0},deleteDomain:{method:`DELETE`,path:`/domains`,response:void 0},deletePlugin:{method:`DELETE`,path:`/plugins`,response:void 0},previewUpload:{method:`POST`,path:`/uploads/preview`,response:void 0},installUpload:{method:`POST`,path:`/uploads`,query:[L,R],response:void 0}};M(z,{scopes:[`session`],basePath:`domains`,transport:(e,t)=>D.fetch(e,t),sessionAddress:r});var B=M(z,{scopes:[`global`,`workspace`,`session`],basePath:`plugin-settings`,transport:(e,t)=>D.fetch(e,t),sessionAddress:r}),le={"content-type":`application/json`},V={"content-type":`application/zip`};async function ue(e,t){let n;try{n=await e.json()}catch{n=void 0}return e.ok?{value:n}:{error:typeof n==`object`&&n&&`error`in n&&typeof n.error==`string`?n.error:t}}async function H(e,t,n,r){try{return await ue(await e(t,n),r)}catch(e){return{error:e instanceof Error?e.message:r}}}async function de(e){return await H(e,B.global.view.url(),{},`Your plugins could not be read.`)}async function U(e,t,n){let r=B.global[t];return await H(e,r.url(),{method:r.spec.method,headers:le,body:JSON.stringify(n)},`The change could not be saved.`)}async function fe(e,t){let n=B.global.previewUpload;return await H(e,n.url(),{method:n.spec.method,headers:V,body:t},`Po could not read the archive.`)}async function pe(e,t,n,r){let i=B.global.installUpload;return await H(e,i.url({query:{...n.length>0?{[L]:n.join(`,`)}:{},...r?{[R]:r}:{}}}),{method:i.spec.method,headers:V,body:t},`The plugin could not be added.`)}var W=`standalone plugins`;function G(e,t){return`${String(e)} ${t}${e===1?``:`s`}`}function me(e){switch(e.origin.kind){case`uploaded`:return`Uploaded`;case`marketplace`:return`From ${e.origin.marketplace}`;case`folder`:return e.origin.path;case`remote`:return`From ${e.origin.source}`}}function K({label:e,children:n}){return A(ne,{children:[O(f,{asChild:!0,children:O(I,{variant:`ghost`,size:`icon`,"aria-label":e,children:O(d,{"aria-hidden":!0,className:`size-4`})})}),O(t,{align:`end`,children:n})]})}var q=5;function J({label:e,names:t}){let[n,r]=T(0),i=Math.ceil(t.length/q),a=n*q,o=t.slice(a,a+q);return A(v,{children:[o.map((e,t)=>A(re,{children:[t>0?`, `:``,O(`span`,{className:`font-mono whitespace-nowrap`,children:e})]},e)),i>1?A(`span`,{className:`ml-2 inline-flex items-center gap-1 align-middle whitespace-nowrap`,children:[O(I,{variant:`ghost`,size:`icon`,"aria-label":`Previous ${e}`,disabled:n===0,onClick:()=>r(n-1),children:O(N,{"aria-hidden":!0,className:`size-3.5 rotate-180`})}),O(`span`,{className:`tabular-nums`,children:`${String(a+1)}-${String(a+o.length)} of ${String(t.length)}`}),O(I,{variant:`ghost`,size:`icon`,"aria-label":`Next ${e}`,disabled:n===i-1,onClick:()=>r(n+1),children:O(N,{"aria-hidden":!0,className:`size-3.5`})})]}):null]})}function Y({plugin:e}){return A(v,{children:[O(k,{children:e.skills.length>0?A(v,{children:[`Skills: `,O(J,{label:`skills of ${e.name}`,names:e.skills})]}):`No skills`}),A(k,{children:[e.mcpServers.length>0?A(v,{children:[`MCP servers: `,O(J,{label:`MCP servers of ${e.name}`,names:e.mcpServers})]}):`No MCP servers`,e.hooks>0?`. ${G(e.hooks,`hook`)}, which Po does not run`:``]})]})}function X({plugin:e,domain:t,onToggle:n,onRemoveFromDomain:r,onDeletePlugin:i}){let a=`plugin-switch-${e.name}`,o=e.domains.filter(e=>e!==t);return O(y,{asChild:!0,className:`items-start`,children:A(`li`,{children:[A(j,{children:[A(S,{className:`flex items-baseline gap-2 first-letter:normal-case`,children:[O(`label`,{htmlFor:a,className:`font-mono`,children:e.name}),e.version?O(`span`,{className:`font-mono text-sm font-normal text-po-dim`,children:e.version}):null]}),e.description?O(k,{children:e.description}):null,e.missing?A(k,{children:[`Not downloaded yet, so its skills and servers are unknown. Run `,O(`span`,{className:`font-mono`,children:`po sync`}),` `,`to fetch it.`]}):O(Y,{plugin:e}),A(k,{children:[me(e),`.`,o.length>0?A(v,{children:[` `,`Also in `,O(`span`,{className:`font-mono`,children:o.join(`, `)}),`.`]}):null,e.enabled?e.domains.length===0?` On, so it loads in every session.`:null:` Off, so nothing from it loads.`]})]}),A(`div`,{className:`flex shrink-0 items-center gap-2`,children:[O(l,{id:a,checked:e.enabled,onCheckedChange:t=>n(e.name,t)}),t?O(I,{variant:`outline`,size:`sm`,onClick:()=>r(e.name,t),children:`Remove from ${t}`}):null,e.deletable?O(K,{label:`More for ${e.name}`,children:O(E,{variant:`destructive`,onSelect:()=>i(e.name),children:`Delete plugin`})}):null]})]})})}function Z({title:e,children:t}){return O(C,{asChild:!0,children:O(`ul`,{children:O(y,{asChild:!0,children:O(`li`,{children:A(j,{children:[O(S,{children:e}),O(k,{children:t})]})})})})})}function he({status:e,onRetry:t}){return e.kind===`error`?O(C,{asChild:!0,children:O(`ul`,{children:O(y,{asChild:!0,role:`alert`,children:A(`li`,{children:[A(j,{children:[O(S,{children:`Po couldn't read your plugins just now`}),O(k,{children:e.error})]}),O(I,{variant:`outline`,size:`sm`,onClick:t,children:`Try again`})]})})})}):O(Z,{title:`Reading your plugins`,children:`This takes a moment.`})}function Q({title:e,detail:t,actions:n}){return A(`div`,{className:`flex items-start justify-between gap-3`,children:[A(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[O(`h3`,{className:`text-lg font-semibold text-po-hi`,children:e}),O(`p`,{className:`text-sm text-po-dim`,children:t})]}),n?O(`div`,{className:`flex shrink-0 items-center gap-1`,children:n}):null]})}function ge({status:e,domains:t,plugins:n,selected:r,onSelect:i,onUpload:a,onRetry:l,onNewDomain:d,onAddPlugins:f,onDeleteDomain:p,notice:m,...h}){let g=e.kind===`ready`,_=n.filter(e=>e.domains.length===0);return A(`div`,{className:`flex flex-col gap-6`,children:[A(`div`,{className:`flex items-center justify-between gap-3`,children:[O(`span`,{className:`text-sm text-po-dim tabular-nums`,children:g&&n.length>0?G(n.length,`plugin`):``}),A(I,{variant:`primary`,size:`sm`,onClick:a,disabled:!g,children:[O(o,{"aria-hidden":!0,className:`size-3.5`}),`Upload plugin`]})]}),m?O(`p`,{role:`alert`,className:`text-sm text-po-red`,children:m}):null,g?A(te,{orientation:`vertical`,value:r,onValueChange:i,className:`flex items-start gap-6`,children:[A(`div`,{className:`flex w-44 shrink-0 flex-col gap-2`,children:[O(`span`,{className:`px-2 text-sm font-semibold text-po-dim`,children:`Domains`}),A(c,{"aria-label":`Plugin groups`,className:`flex-col items-stretch`,children:[t.map(e=>A(u,{value:e.name,className:`justify-between font-mono`,children:[e.name,O(`span`,{className:`font-sans text-sm tabular-nums`,children:n.filter(t=>t.domains.includes(e.name)).length})]},e.name)),A(u,{value:W,className:`mt-3 justify-between`,children:[`Standalone`,O(`span`,{className:`text-sm tabular-nums`,children:_.length})]})]}),A(I,{variant:`ghost`,size:`sm`,className:`justify-start`,onClick:d,children:[O(o,{"aria-hidden":!0,className:`size-3.5`}),`New domain`]})]}),t.map(e=>{let t=n.filter(t=>t.domains.includes(e.name));return A(s,{value:e.name,className:`flex min-w-0 flex-col gap-4`,children:[O(Q,{title:O(`span`,{className:`font-mono`,children:e.name}),detail:`${e.description?`${e.description.replace(/[.!?]\s*$/u,``)}. `:``}These plugins load only in sessions that pick ${e.name}.`,actions:A(v,{children:[A(I,{variant:`primary`,size:`sm`,onClick:()=>f(e.name),children:[O(o,{"aria-hidden":!0,className:`size-3.5`}),`Add plugins`]}),O(K,{label:`More for domain ${e.name}`,children:O(E,{variant:`destructive`,onSelect:()=>p(e.name),children:`Delete domain`})})]})}),t.length>0?O(C,{asChild:!0,children:O(`ul`,{"aria-label":`Plugins in ${e.name}`,children:t.map(t=>O(X,{plugin:t,domain:e.name,...h},t.name))})}):O(Z,{title:`No plugins in ${e.name} yet`,children:`Add plugins you already have, or upload a new one.`})]},e.name)}),A(s,{value:W,className:`flex min-w-0 flex-col gap-4`,children:[O(Q,{title:`Standalone`,detail:`Plugins in no domain. Switch one on to load it in every session, or add it to a domain to load it only there.`}),_.length>0?O(C,{asChild:!0,children:O(`ul`,{"aria-label":`Standalone plugins`,children:_.map(e=>O(X,{plugin:e,...h},e.name))})}):O(Z,{title:n.length===0?`No plugins yet`:`Every plugin is in a domain`,children:n.length===0?`Upload a zipped Codex or Claude Code plugin folder to start.`:`A plugin you take out of its last domain shows here, switched off.`})]})]}):O(he,{status:e,onRetry:l})]})}function _e({open:t,domain:r,candidates:a,selected:o,onOpenChange:s,onToggle:c,onSubmit:l}){return O(b,{open:t,onOpenChange:s,children:A(p,{width:`md`,"aria-describedby":`add-plugins-description`,children:[O(m,{dismissible:!0,closeLabel:`Close`,children:A(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[A(i,{children:[`Add plugins to `,O(`span`,{className:`font-mono`,children:r})]}),A(n,{id:`add-plugins-description`,children:[`Sessions that pick `,r,` get the plugins you tick. A plugin can be in more than one domain.`]})]})}),A(`form`,{className:`flex min-h-0 flex-col`,onSubmit:e=>{e.preventDefault(),l()},children:[O(F,{className:`gap-4 px-4 py-4 sm:px-5 sm:py-5`,children:a.length>0?O(`ul`,{className:`flex flex-col gap-4`,children:a.map(t=>{let n=`add-plugin-${t.name}`;return A(`li`,{className:`flex items-start gap-2.5`,children:[O(oe,{id:n,className:`mt-0.5`,checked:o.includes(t.name),onCheckedChange:e=>c(t.name,e===!0)}),A(`div`,{className:`flex min-w-0 flex-col items-start gap-0.5`,children:[A(e,{htmlFor:n,className:`flex items-baseline gap-2 font-normal`,children:[O(`span`,{className:`font-mono text-base text-po-text`,children:t.name}),t.version?O(`span`,{className:`font-mono text-sm text-po-dim`,children:t.version}):null]}),t.description?O(`span`,{className:`text-sm text-po-dim`,children:t.description}):null,O(Y,{plugin:t}),O(`span`,{className:`text-sm text-po-dim`,children:t.domains.length>0?A(v,{children:[`Already in `,O(`span`,{className:`font-mono`,children:t.domains.join(`, `)}),`.`]}):`Standalone now, so it loads in every session. Once added it loads only where a domain that has it is picked.`})]})]},t.name)})}):A(`p`,{className:`text-sm text-po-dim`,children:[`Every plugin is already in `,r,`. Upload a new one to add more.`]})}),A(P,{variant:`bar`,children:[O(`span`,{className:`text-sm text-po-dim`,children:`Changes apply to new sessions.`}),A(`div`,{className:`flex shrink-0 items-center gap-2 py-1.5`,children:[O(I,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>s(!1),children:`Cancel`}),O(I,{type:`submit`,variant:`primary`,size:`sm`,disabled:o.length===0,children:o.length>1?`Add ${String(o.length)} plugins`:`Add plugin`})]})]})]})]})})}function ve({open:t,name:r,description:a,nameError:o,onOpenChange:s,onNameChange:c,onDescriptionChange:l,onSubmit:u}){return O(b,{open:t,onOpenChange:s,children:A(p,{width:`sm`,"aria-describedby":`new-domain-description`,children:[O(m,{dismissible:!0,closeLabel:`Close`,children:A(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[O(i,{children:`New domain`}),O(n,{id:`new-domain-description`,children:`A session that picks this domain loads its plugins. You add plugins next.`})]})}),A(`form`,{className:`flex min-h-0 flex-col`,onSubmit:e=>{e.preventDefault(),u()},children:[A(F,{className:`gap-4 px-4 py-4 sm:px-5 sm:py-5`,children:[A(`div`,{className:`flex flex-col gap-1.5`,children:[O(e,{htmlFor:`new-domain-name`,children:`Name`}),O(_,{id:`new-domain-name`,className:`font-mono`,value:r,placeholder:`writing`,required:!0,"aria-invalid":o!==void 0,"aria-describedby":`new-domain-name-hint`,onChange:e=>c(e.target.value)}),O(`p`,{id:`new-domain-name-hint`,className:o?`text-sm text-po-red`:`text-sm text-po-dim`,children:o??`Letters, numbers, dots, dashes or underscores, with no spaces.`})]}),A(`div`,{className:`flex flex-col gap-1.5`,children:[O(e,{htmlFor:`new-domain-description-input`,children:`Description`}),O(_,{id:`new-domain-description-input`,value:a,placeholder:`Drafting and editing long-form text`,"aria-describedby":`new-domain-description-hint`,onChange:e=>l(e.target.value)}),O(`p`,{id:`new-domain-description-hint`,className:`text-sm text-po-dim`,children:`Optional. Shown when someone picks a domain for a session.`})]})]}),O(P,{variant:`bar`,className:`justify-end`,children:A(`div`,{className:`flex shrink-0 items-center gap-2 py-1.5`,children:[O(I,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>s(!1),children:`Cancel`}),O(I,{type:`submit`,variant:`primary`,size:`sm`,disabled:r.trim()===``||o!==void 0,children:`Create domain`})]})})]})]})})}function ye({domains:t,selected:n,newDomain:r,newDomainError:i,onToggle:a,onNewDomainChange:o}){return A(`fieldset`,{className:`flex flex-col gap-3`,children:[O(`legend`,{className:`mb-1 text-base font-semibold text-po-hi`,children:`Domains`}),O(`p`,{className:`-mt-2 text-sm text-po-dim`,children:`Leave every domain unchecked to keep it standalone: it then loads in every session.`}),t.length>0?O(`ul`,{className:`flex flex-col gap-2`,children:t.map(t=>{let r=`domain-picker-${t.name}`;return A(`li`,{className:`flex items-start gap-2.5`,children:[O(oe,{id:r,className:`mt-0.5`,checked:n.includes(t.name),onCheckedChange:e=>a(t.name,e===!0)}),A(e,{htmlFor:r,className:`flex min-w-0 flex-col items-start gap-0.5 font-normal`,children:[O(`span`,{className:`font-mono text-base text-po-text`,children:t.name}),t.description?O(`span`,{className:`text-sm text-po-dim`,children:t.description}):null]})]},t.name)})}):O(`p`,{className:`text-sm text-po-dim`,children:`No domains yet. Name one below, or leave it standalone.`}),A(`div`,{className:`flex flex-col gap-1.5`,children:[O(e,{htmlFor:`domain-picker-new`,children:`New domain`}),O(_,{id:`domain-picker-new`,className:`font-mono`,value:r,placeholder:`writing`,"aria-invalid":i!==void 0,"aria-describedby":`domain-picker-new-hint`,onChange:e=>o(e.target.value)}),O(`p`,{id:`domain-picker-new-hint`,className:i?`text-sm text-po-red`:`text-sm text-po-dim`,children:i??`Optional. Letters, numbers, dots, dashes or underscores, with no spaces.`})]})]})}var be=`.zip,application/zip`;function xe(e,t){return`${String(e)} ${t}${e===1?``:`s`}`}function Se({onFile:e}){return A(`label`,{htmlFor:`upload-plugin-file`,className:`flex cursor-pointer flex-col items-center gap-2 rounded-lg border border-dashed border-po-border bg-po-deep px-6 py-8 text-center hover:border-po-green/50 focus-within:border-po-green`,onDragOver:e=>e.preventDefault(),onDrop:t=>{t.preventDefault();let n=t.dataTransfer.files[0];n&&e(n)},children:[O(g,{"aria-hidden":!0,className:`size-6 text-po-dim`}),O(`span`,{className:`text-base font-semibold text-po-hi`,children:`Drop a .zip here, or choose a file`}),O(`span`,{className:`max-w-md text-sm text-po-dim`,children:`A Codex or Claude Code plugin folder, zipped. Po keeps its skills and MCP servers.`}),O(`input`,{id:`upload-plugin-file`,type:`file`,accept:be,className:`sr-only`,onChange:t=>{let n=t.target.files?.[0];n&&e(n)}})]})}function $({title:e,names:t,empty:n}){return A(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[A(`span`,{className:`text-sm font-semibold text-po-hi`,children:[e,` `,O(`span`,{className:`font-normal text-po-dim tabular-nums`,children:t.length})]}),t.length>0?O(`ul`,{className:`flex flex-col gap-1`,children:t.map(e=>O(`li`,{className:`truncate font-mono text-sm text-po-text`,children:e},e))}):O(`span`,{className:`text-sm text-po-dim`,children:n})]})}function Ce({plugin:e}){return A(`section`,{"aria-label":`Plugin contents`,className:`flex flex-col gap-3 rounded-lg border border-po-border p-3`,children:[A(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[A(`span`,{className:`flex items-baseline gap-2`,children:[O(`span`,{className:`font-mono text-base font-semibold text-po-hi`,children:e.name}),e.version?O(`span`,{className:`font-mono text-sm text-po-dim`,children:e.version}):null]}),e.description?O(`span`,{className:`text-sm text-po-dim`,children:e.description}):null]}),A(`div`,{className:`grid grid-cols-2 gap-4`,children:[O($,{title:`Skills`,names:e.skills,empty:`None`}),O($,{title:`MCP servers`,names:e.mcpServers,empty:`None`})]}),e.hooks>0?A(`p`,{className:`text-sm text-po-dim`,children:[`It also declares `,xe(e.hooks,`hook`),`. Po does not run hooks, so they stay unused.`]}):null]})}function we({open:e,step:t,domains:r,onOpenChange:a,onFile:o,onToggleDomain:s,onNewDomainChange:c,onChooseAgain:l,onSubmit:u}){return O(b,{open:e,onOpenChange:a,children:A(p,{width:`lg`,"aria-describedby":`upload-plugin-description`,children:[O(m,{dismissible:!0,closeLabel:`Close upload`,children:A(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[O(i,{children:`Upload a plugin`}),O(n,{id:`upload-plugin-description`,children:`Po reads it first, so you can see what it brings before adding it.`})]})}),A(`form`,{className:`flex min-h-0 flex-col`,onSubmit:e=>{e.preventDefault(),u()},children:[A(F,{className:`gap-4 px-4 py-4 sm:px-5 sm:py-5`,children:[t.kind===`choose`?O(Se,{onFile:o}):null,t.kind===`reading`?A(`div`,{className:`flex items-center gap-2 rounded-lg border border-po-border px-3 py-6 text-sm text-po-dim`,children:[O(h,{className:`size-4`}),A(`span`,{children:[`Reading `,O(`span`,{className:`font-mono text-po-text`,children:t.fileName})]})]}):null,t.kind===`invalid`?A(`div`,{role:`alert`,className:`flex flex-col gap-1 rounded-lg border border-po-edge-red bg-po-tint-red p-3`,children:[A(`span`,{className:`text-base font-semibold text-po-red`,children:[`Po can't add `,O(`span`,{className:`font-mono`,children:t.fileName})]}),O(`span`,{className:`text-sm text-po-text`,children:t.reason})]}):null,t.kind===`preview`?A(v,{children:[O(Ce,{plugin:t.plugin}),O(ye,{domains:r,selected:t.selected,newDomain:t.newDomain,newDomainError:t.newDomainError,onToggle:s,onNewDomainChange:c})]}):null]}),A(P,{variant:`bar`,children:[O(`span`,{className:`min-w-0 truncate text-sm text-po-dim`,children:t.kind===`preview`?A(v,{children:[`Saved to `,O(`span`,{className:`font-mono`,children:t.destination})]}):`Nothing is saved until you add it.`}),A(`div`,{className:`flex shrink-0 items-center gap-2 py-1.5`,children:[O(I,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>a(!1),children:`Cancel`}),t.kind===`invalid`?O(I,{type:`button`,variant:`outline`,size:`sm`,onClick:l,children:`Choose another file`}):O(I,{type:`submit`,variant:`primary`,size:`sm`,disabled:t.kind!==`preview`,loading:t.kind===`preview`&&t.submitting===!0,loadingLabel:`Adding the plugin`,children:`Add plugin`})]})]})]})]})})}var Te={domains:[],plugins:[]};function Ee(e,t){let n=e.trim();if(n){if(!ce.test(n))return`Use letters, numbers, dots, dashes or underscores, with no spaces.`;if(t.domains.some(e=>e.name===n))return`A domain named ${n} already exists.`}}function De({request:e,requestWithStepUp:t}){let[n,r]=T({kind:`loading`}),[i,a]=T(Te),[o,s]=T(W),[c,l]=T(),[u,d]=T(),[f,p]=T(),[m,h]=T({open:!1,step:{kind:`choose`}}),g=ie(void 0),_=ee(async()=>{let t=await de(e);`error`in t?r({kind:`error`,error:t.error}):(a(t.value),r({kind:`ready`}),s(e=>e!==`standalone plugins`||t.value.domains.length===0?e:t.value.domains[0].name))},[e]);se(()=>{_()},[_]);let y=e=>`error`in e?(l(e.error),!1):(a(e.value),l(void 0),!0),b=async(e,n)=>y(await U(t,e,n)),x=async e=>{if(e.size>6291456){h({open:!0,step:{kind:`invalid`,fileName:e.name,reason:`The archive is larger than 6 MB.`}});return}g.current=e,h({open:!0,step:{kind:`reading`,fileName:e.name}});let n=await fe(t,e);h({open:!0,step:`error`in n?{kind:`invalid`,fileName:e.name,reason:n.error}:{kind:`preview`,fileName:e.name,plugin:n.value.plugin,destination:n.value.destination,selected:o===`standalone plugins`?[]:[o],newDomain:``}})},S=e=>h(t=>t.step.kind===`preview`?{...t,step:e(t.step)}:t),C=async()=>{let{step:e}=m,n=g.current;if(e.kind!==`preview`||!n||e.newDomainError||e.submitting)return;S(e=>({...e,submitting:!0}));let r=e.newDomain.trim()||void 0,i=await pe(t,n,e.selected,r);`error`in i?h({open:!0,step:{kind:`invalid`,fileName:e.fileName,reason:i.error}}):(y(i),g.current=void 0,h({open:!1,step:{kind:`choose`}}),s(e.selected[0]??r??`standalone plugins`))},w=async()=>{if(!f)return;let e=f.name.trim(),n=await U(t,`createDomain`,{name:e,...f.description.trim()?{description:f.description.trim()}:{}});`error`in n?p({...f,error:n.error}):(y(n),p(void 0),s(e))},E=u?.domain??``;return A(v,{children:[O(ge,{status:n,domains:i.domains,plugins:i.plugins,selected:o,notice:c,onSelect:s,onRetry:()=>{r({kind:`loading`}),_()},onUpload:()=>{g.current=void 0,h({open:!0,step:{kind:`choose`}})},onNewDomain:()=>p({name:``,description:``}),onToggle:(e,t)=>void b(`toggle`,{plugin:e,enabled:t}),onAddPlugins:e=>d({domain:e,selected:[]}),onRemoveFromDomain:(e,t)=>void b(`removeFromDomain`,{domain:t,plugin:e}),onDeletePlugin:e=>{window.confirm(`Delete ${e}? Po removes its folder from ~/.po/plugins.`)&&b(`deletePlugin`,{plugin:e})},onDeleteDomain:e=>{window.confirm(`Delete the domain ${e}? Its plugins stay installed.`)&&b(`deleteDomain`,{name:e}).then(e=>{e&&s(W)})}}),O(_e,{open:u!==void 0,domain:E,candidates:i.plugins.filter(e=>!e.domains.includes(E)),selected:u?.selected??[],onOpenChange:e=>{e||d(void 0)},onToggle:(e,t)=>d(n=>n&&{...n,selected:t?[...n.selected,e]:n.selected.filter(t=>t!==e)}),onSubmit:()=>{u&&u.selected.length!==0&&b(`addToDomain`,{domain:u.domain,plugins:u.selected}).then(e=>{e&&d(void 0)})}}),O(ve,{open:f!==void 0,name:f?.name??``,description:f?.description??``,nameError:f?f.error??Ee(f.name,i):void 0,onOpenChange:e=>{e||p(void 0)},onNameChange:e=>p(t=>t&&{...t,name:e,error:void 0}),onDescriptionChange:e=>p(t=>t&&{...t,description:e}),onSubmit:()=>void w()}),O(we,{open:m.open,step:m.step,domains:i.domains,onOpenChange:e=>{e||h({open:!1,step:{kind:`choose`}})},onFile:e=>void x(e),onToggleDomain:(e,t)=>S(n=>({...n,selected:t?[...n.selected,e]:n.selected.filter(t=>t!==e)})),onNewDomainChange:e=>S(t=>{let n=Ee(e,i);return{...t,newDomain:e,...n?{newDomainError:n}:{newDomainError:void 0}}}),onChooseAgain:()=>h({open:!0,step:{kind:`choose`}}),onSubmit:()=>void C()})]})}var Oe=ae({label:`Plugins`,detail:`Codex and Claude Code plugins: their skills and MCP servers. Put one in a domain to load it where that domain is picked, or switch it on standalone to load it everywhere.`,icon:a,order:0,menuGroup:`general`,component:De}),ke=w({name:`domains`,command:`domains`,statusKey:`po-domain`,emptyLabel:`no domains`,multi:!0,order:20}),Ae=(e,t)=>t===void 0?void 0:{...e,...t},je=x({id:`domain`,global:{get settingsPanels(){return[Ae({id:`plugins`},Oe)]}},session:{get selectionAxes(){return[Ae({name:`domains`},ke)]}}});export{je as webPlugin};
@@ -0,0 +1,7 @@
1
+ import{Bt as e,C as t,E as n,T as r,_r as i,a,br as o,cn as s,dn as c,kt as l,o as u,s as d,w as f}from"../chunks/po-web-runtime-BJDT6Lbw.js";var p=/^([+\- ])( *\d*) (.*)$/u,m=` `;function h(e){let t=Array.isArray(e.edits)?e.edits.length:0;return{path:typeof e.path==`string`?e.path:``,ranges:`${t} ${t===1?`range`:`ranges`}`}}function g(e){return e===`+`||e===`-`?e:m}function _(e){return e.split(`
2
+ `).map(e=>{let t=e.replaceAll(` `,` `),n=p.exec(t);return n?{marker:g(n[1]),lineNumber:(n[2]??``).trim(),content:n[3]??``}:{marker:m,lineNumber:``,content:t}})}function v(e){let t=e?.details;if(typeof t!=`object`||!t)return;let n=t.diff;if(typeof n!=`string`||n.length===0)return;let r=_(n);return{rows:r,gutter:r.reduce((e,t)=>Math.max(e,t.lineNumber.length),1)}}function y(e,t){let n=(e===null?t:e.content.flatMap(e=>{let t=typeof e==`object`&&e?e:{};return t.type===`text`&&typeof t.text==`string`?[t.text]:[]}).join(`
3
+ `)).replaceAll(` `,` `).replaceAll(`\r
4
+ `,`
5
+ `).split(`
6
+ `);for(;n.at(-1)===``;)n.pop();return n}var b={"+":`bg-po-tint-green text-po-green`,"-":`bg-po-tint-red text-po-red`," ":`text-po-dim`};function x({rows:e,gutter:t,path:n}){let r=c(e.map(e=>e.content).join(`
7
+ `),{path:n});return u(a,{children:e.map((e,n)=>d(`span`,{className:`flex gap-2 ${b[e.marker]}`,children:[u(`span`,{className:`shrink-0 text-right text-po-faint`,style:{width:`${String(t)}ch`},children:e.lineNumber}),u(`span`,{className:`w-2 shrink-0`,children:e.marker===` `?``:e.marker}),u(l,{spans:r?.[n],text:e.content,className:`min-w-0 whitespace-pre-wrap break-words`})]},`${String(n)}-${e.lineNumber}`))})}function S({args:i,result:o,output:c,running:l,isError:p,fileTabFor:m,openTransientTab:g}){let _=h(i),b=o===null||p?void 0:v(o),S=m(_.path);return u(t,{tone:s({running:l,isError:p}),expandable:!0,children:({expanded:t})=>d(a,{children:[u(r,{title:`edit`,children:d(`span`,{"data-testid":`tool-call-edit`,className:`flex min-w-0 flex-1 items-center gap-2`,children:[u(e,{path:_.path,...S===void 0?{}:{onOpen:()=>g(S)}}),d(`span`,{className:`shrink-0 text-po-faint`,children:[`· `,_.ranges]})]})}),t?p?d(f,{"data-testid":`tool-result-edit`,className:`flex flex-col`,children:[u(n,{tone:`error`,children:`failed`}),y(o,c).map((e,t)=>u(`span`,{className:`whitespace-pre-wrap break-words text-po-red`,children:e},`${String(t)}-${e}`))]}):b===void 0?l?u(f,{"data-testid":`tool-result-edit`,children:u(n,{tone:`running`,children:`running`})}):null:u(f,{"data-testid":`tool-result-edit`,className:`flex flex-col font-mono`,children:u(x,{rows:b.rows,gutter:b.gutter,path:_.path})}):null]})})}var C=i({message:S}),w=(e,t)=>t===void 0?void 0:{...e,...t},T=o({id:`edit`,session:{get toolRenderers(){return[w({tools:[`edit`]},C)]}}});export{T as webPlugin};
@@ -0,0 +1,2 @@
1
+ import{$t as e,An as t,Cn as n,Cr as r,Dn as i,En as a,Ft as o,G as ee,Kt as s,Qn as c,Rn as l,S as u,Sn as d,Tn as f,Yt as p,a as te,an as ne,b as re,bn as m,br as ie,c as ae,en as h,h as g,i as oe,ir as _,jn as v,kn as se,m as ce,mn as y,n as b,o as x,or as S,pr as C,s as w,tr as T,tt as le,u as E,wn as D,xn as O,zt as k}from"../chunks/po-web-runtime-BJDT6Lbw.js";var ue=`file_edits`;function A(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function j(e){return A(e)&&typeof e.path==`string`&&typeof e.relPath==`string`&&typeof e.tool==`string`&&typeof e.at==`number`&&typeof e.count==`number`}function M(e){return!A(e)||!Array.isArray(e.items)?null:{items:e.items.filter(j)}}var N=C({items:[],detail:{},loading:[],errors:{},comments:[]}),P=N.channel({channel:ue,parse:M,reduce:(e,{items:t})=>({...e,items:t})});function de(e,t){N.update(e,e=>e.loading.includes(t)?e:{...e,loading:[...e.loading,t],errors:I(e.errors,t)})}function fe(e,t){N.update(e,e=>({...e,detail:{...e.detail,[t.path]:t},loading:e.loading.filter(e=>e!==t.path),errors:I(e.errors,t.path)}))}function F(e,t,n){N.update(e,e=>({...e,loading:e.loading.filter(e=>e!==t),errors:{...e.errors,[t]:n}}))}function pe(e,t){N.update(e,e=>({...e,comments:[...e.comments,t]}))}function me(e,t){N.update(e,e=>({...e,comments:e.comments.filter(e=>e.id!==t)}))}function he(e,t){N.update(e,e=>({...e,comments:e.comments.filter(e=>e.path!==t)}))}function I(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}var L=_(P),R=T({detail:{method:`GET`,path:`/detail`,query:[`path`],response:void 0},preview:{method:`GET`,path:`/preview`,query:[`path`],response:void 0},save:{method:`PUT`,path:`/content`,response:void 0},remove:{method:`DELETE`,path:`/content`,query:[`path`]},file:{method:`GET`,path:`/file`,raw:!0,query:[`path`],host:!0}},{scopes:[`session`],basePath:`file-edits`,transport:(e,t)=>b.fetch(e,t),sessionAddress:r}),z=`path`,B=`The session is unreachable.`;function V(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function H(e,t){return R.session(e).file.url({query:{[z]:t}})}function U(e){return e.status===0?B:e.error===``?`The session answered ${e.status}.`:e.error}async function ge(e,t){let n=await R.session(e).detail({query:{[z]:t}});return n.ok?V(n.data)?{ok:!0,detail:n.data}:{ok:!1,error:`The session answered with no detail.`}:{ok:!1,error:U(n)}}async function W(e,t){let n=await R.session(e).preview({query:{[z]:t}});return n.ok?V(n.data)?{ok:!0,preview:n.data}:{ok:!1,error:`The session answered with no file.`}:{ok:!1,error:U(n)}}async function _e(e,t,n,r){let i=await R.session(e).save({body:{path:t,expectedHash:n,content:r}});if(i.status===409){let e=i.ok?void 0:i.data,t=V(e)&&typeof e.hash==`string`?e.hash:void 0;return{ok:!1,stale:!0,error:i.ok?`The file changed since it was opened.`:U(i),...t===void 0?{}:{hash:t}}}return i.ok?{ok:!0,hash:V(i.data)&&typeof i.data.hash==`string`?i.data.hash:``}:{ok:!1,stale:!1,error:U(i)}}async function ve(e,t){let n=await R.session(e).remove({query:{[z]:t}});return n.ok?{ok:!0}:{ok:!1,error:U(n)}}function G(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function K(e){let t=e.replaceAll(/[^a-zA-Z0-9]+/gu,`-`).replace(/^-|-$/gu,``);return`files-file-${G(e)}-${t.slice(-40)}`}var q={edit:`edit`,write:`write`,bash:`command`,user:`you`};function ye(e,t){if(h(e)!==`download`)return`media`;if(t)return`unavailable`;let n=e.toLowerCase();return n.endsWith(`.md`)||n.endsWith(`.markdown`)?`markdown`:n.endsWith(`.html`)||n.endsWith(`.htm`)?`html`:p(e)===void 0?`text`:`code`}function be(e,t){try{e({type:`follow_up`,message:s(t)});return}catch(e){return e instanceof Error?e.message:String(e)}}function xe({relPath:e,open:t,onConfirm:r,onCancel:i}){return x(m,{open:t,onOpenChange:e=>{e||i()},children:w(d,{width:`sm`,"data-testid":`files-delete-dialog`,"aria-describedby":void 0,children:[x(f,{children:x(a,{children:`delete file`})}),w(O,{children:[w(n,{children:[`this removes `,x(`span`,{className:`font-semibold text-po-hi`,children:e}),` from disk. the session keeps its record of the change, but the file itself is gone.`]}),w(D,{children:[x(k,{variant:`outline`,size:`md`,"data-testid":`files-delete-cancel`,autoFocus:!0,onClick:i,children:`cancel`}),x(k,{variant:`danger`,size:`md`,"data-testid":`files-delete-confirm`,onClick:r,children:`delete`})]})]})]})})}function Se({src:e,path:t,"data-testid":n}){let[r,i]=g();E(()=>{if(e===``)return;let t=new AbortController,n;return(async()=>{let r=await b.fetch(e,{signal:t.signal,cache:`no-store`});if(!r.ok)throw Error(`Media could not be loaded (${r.status}).`);let a=await r.blob();t.signal.aborted||(n=URL.createObjectURL(a),i({source:e,url:n,contentType:(r.headers.get(`content-type`)??a.type).split(`;`,1)[0]?.trim().toLowerCase()??``}))})().catch(n=>{t.signal.aborted||i({source:e,error:n instanceof Error?n.message:String(n)})}),()=>{t.abort(),n!==void 0&&URL.revokeObjectURL(n)}},[e]);let a=r?.source===e?r:void 0;return a?.url===void 0?x(`p`,{role:a?.error?`alert`:`status`,children:a?.error??`Loading media...`}):x(u,{src:a.url,path:t,contentType:a.contentType,"data-testid":n})}async function Ce(e,t,n){if(e===null)throw Error(`The session is unavailable.`);let r=t.slice(0,t.lastIndexOf(`/`)+1),i=n.startsWith(`/`)?n:`${r}${n}`,a=await b.fetch(H(e,i),{cache:`no-store`});if(!a.ok)throw Error(`Image could not be loaded (${a.status}).`);let o=URL.createObjectURL(await a.blob());return{url:o,dispose:()=>URL.revokeObjectURL(o),path:i}}function we(e){let t=new Date(e.at).toLocaleTimeString(),n=e.hunks===void 0?``:` +${e.additions} -${e.removals}`;return`${t} · ${q[e.tool]??e.tool}${n}`}function Te(n){let{filePath:r,relPath:a,sessionId:s,sendSessionFrame:u,closeTransientTab:d}=n,f=oe(N.store,e=>N.select(e,s)),p=f.detail[r],m=f.errors[r],ie=f.loading.includes(r),h=f.comments.filter(e=>e.path===r),[_,b]=g(`preview`),[S,C]=g(void 0),[T,D]=g(void 0),[O,ue]=g(void 0),[A,j]=g(!1),[M,P]=g(void 0),[I,L]=g(!1),[R,z]=g(void 0),B=ce(void 0),V=f.items.find(e=>e.path===r)?.count??0;E(()=>{if(s===null)return;let e=!1;return de(s,r),ge(s,r).then(t=>{e||(t.ok?(fe(s,t.detail),D(void 0),P(void 0)):F(s,r,t.error))}),()=>{e=!0}},[s,r,V]);let U=p?.working,W=a===`..`||a.startsWith(`../`)||a.startsWith(`/`),G=T??U?.content??``,q=ye(a,U?.unavailable===!0),Te=ae(e=>Ce(s,a,e),[s,a]),J=s===null?``:H(s,a),Y=e=>{C(e)},X=()=>{let e=B.current;e!==void 0&&e.text.trim()!==``&&Y({snippet:e.text,startLine:e.startLine,endLine:e.endLine})},Z=e=>{s!==null&&S!==void 0&&(pe(s,{id:`${r}:${S.side??`new`}:${S.startLine??0}:${h.length}:${e.length}`,path:r,relPath:a,...S.side===void 0?{}:{side:S.side},...S.startLine===void 0?{}:{startLine:S.startLine},...S.endLine===void 0?{}:{endLine:S.endLine},snippet:S.snippet,body:e}),C(void 0))},Ee=()=>{if(s===null||h.length===0)return;let e=be(e=>u(s,e),h);z(e),e===void 0&&he(s,r)},Q=async()=>{if(s===null)return;L(!1);let e=await ve(s,r);e.ok?d(K(r)):F(s,r,e.error)},$=async()=>{if(s===null||U===void 0||T===void 0)return;j(!0);let e=await _e(s,r,U.hash,T);if(j(!1),e.ok){P(`saved`),D(void 0),de(s,r);let e=await ge(s,r);e.ok?fe(s,e.detail):F(s,r,e.error)}else P(e.error)};return w(`div`,{"data-testid":`files-file-panel`,className:`flex min-h-0 flex-1 flex-col`,children:[w(`header`,{className:`flex shrink-0 items-center gap-2 border-b border-po-border px-4 py-2`,children:[x(o,{path:a,"data-testid":`files-breadcrumb`,className:`min-w-0 flex-1`}),_===`edit`?x(le,{tone:`neutral`,"data-testid":`files-editing`,className:`shrink-0 `,children:`editing`}):null,p===void 0?null:w(`span`,{className:`shrink-0 text-sm text-po-dim`,children:[`+`,p.cumulative.additions,` -`,p.cumulative.removals]}),x(`nav`,{className:`flex shrink-0 items-center gap-1`,children:[`preview`,`diff`].map(e=>x(k,{variant:_===e?`outline`:`ghost`,size:`xs`,"data-testid":`files-view-${e}`,onClick:()=>b(e),className:``,children:e},e))}),w(se,{children:[x(l,{asChild:!0,children:x(k,{variant:`ghost`,size:`icon`,"data-testid":`files-menu`,title:`file actions`,className:`shrink-0 text-po-faint hover:text-po-hi`,children:x(c,{className:`h-3 w-3`})})}),w(t,{"data-testid":`files-menu-list`,children:[x(v,{"data-testid":`files-edit`,disabled:W||U?.unavailable===!0,onSelect:()=>b(`edit`),children:`edit`}),x(v,{variant:`destructive`,"data-testid":`files-delete`,disabled:W||U?.unavailable===!0,onSelect:()=>L(!0),children:`delete`}),x(v,{"data-testid":`files-close`,onSelect:()=>d(K(r)),children:`close`})]})]})]}),x(xe,{relPath:a,open:I,onConfirm:()=>void Q(),onCancel:()=>L(!1)}),ie&&p===void 0?x(`p`,{"data-testid":`files-loading`,className:`px-4 py-3 text-sm text-po-dim`,children:`reading this file's history…`}):null,m===void 0?null:x(`p`,{"data-testid":`files-error`,className:`px-4 py-3 text-sm text-po-red`,children:m}),x(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:p===void 0?null:_===`diff`?w(`div`,{className:`flex flex-col`,children:[p.cumulative.note===void 0?null:x(`p`,{"data-testid":`files-cumulative-note`,className:`px-4 py-2 text-sm text-po-yellow`,children:p.cumulative.note}),p.cumulative.hunks===void 0?null:x(i,{hunks:p.cumulative.hunks,testId:`files-cumulative-diff`,onSelect:e=>Y(e)}),w(`section`,{className:`mt-2 border-t border-po-border`,children:[w(`h2`,{className:`px-4 py-2 text-lg font-semibold text-po-hi `,children:[p.versions.length,` `,p.versions.length===1?`change`:`changes`,` this session`]}),p.versions.map(e=>w(`article`,{"data-testid":`files-version-${e.index}`,children:[x(k,{variant:`ghost`,size:`card`,"data-testid":`files-version-toggle-${e.index}`,onClick:()=>ue(O===e.index?void 0:e.index),className:`w-full gap-2 rounded-none px-4 py-1.5 hover:bg-po-panel`,children:w(`span`,{className:`flex w-full min-w-0 items-center gap-2`,children:[w(`span`,{className:`shrink-0 text-sm text-po-dim`,children:[`#`,e.index]}),x(`span`,{className:`min-w-0 flex-1 truncate text-left text-base text-po-text`,children:we(e)}),e.origin===`scan`?x(le,{tone:`neutral`,className:`shrink-0 `,children:`no baseline`}):null,x(`span`,{className:`shrink-0 text-sm text-po-dim`,children:O===e.index?`▾`:`▸`})]})}),O===e.index?e.hunks===void 0?x(`p`,{className:`px-4 py-1.5 text-sm text-po-dim`,children:e.note??`nothing to show`}):x(i,{hunks:e.hunks,testId:`files-version-diff-${e.index}`,onSelect:e=>Y(e)}):null]},e.index))]})]}):_===`edit`?x(`div`,{className:`flex h-full flex-col gap-2 p-3`,children:U?.unavailable===!0?x(`p`,{"data-testid":`files-source-unavailable`,className:`text-sm text-po-dim`,children:U.reason??`this file cannot be shown`}):w(te,{children:[x(`div`,{className:`min-h-[24rem] flex-1`,onMouseUp:X,onKeyUp:e=>{e.shiftKey&&X()},children:x(y,{"data-testid":`files-source`,value:G,path:a,onChange:D,onSelect:e=>{B.current=e},className:`h-full rounded border border-po-border`})}),w(`div`,{className:`flex shrink-0 items-center gap-2`,children:[x(k,{variant:`outline`,size:`xs`,"data-testid":`files-save`,loading:A,disabled:T===void 0||A,onClick:()=>void $(),className:``,children:`save to disk`}),T===void 0?null:x(k,{variant:`ghost`,size:`xs`,"data-testid":`files-revert`,onClick:()=>D(void 0),className:``,children:`discard edits`}),M===void 0?null:x(`span`,{"data-testid":`files-save-note`,className:M===`saved`?`text-sm text-po-green`:`text-sm text-po-red`,children:M})]})]})}):w(`div`,{"data-testid":`files-preview`,"data-mode":q,className:q===`code`?`flex h-full flex-col gap-2 p-4 text-base text-po-text`:`flex flex-col gap-2 p-4 text-base text-po-text`,onMouseUp:()=>{if(q===`code`){X();return}let e=globalThis.getSelection?.()?.toString()??``;e.trim()!==``&&Y({snippet:e})},children:[q===`unavailable`?x(`p`,{"data-testid":`files-preview-unavailable`,className:`text-sm text-po-dim`,children:U?.reason??`this file cannot be shown`}):null,q===`media`||q===`unavailable`?x(Se,{src:J,path:a,"data-testid":`files-preview-media`}):q===`markdown`?x(re,{text:G,loadImage:Te,documentPath:a,renderMediaReview:e(n)}):q===`html`?x(`iframe`,{"data-testid":`files-preview-html`,title:a,sandbox:``,srcDoc:G,className:`h-[36rem] w-full rounded border border-po-border bg-po-deep`}):q===`code`?x(y,{"data-testid":`files-preview-code`,value:G,path:a,readOnly:!0,onSelect:e=>{B.current=e},className:`min-h-[24rem] flex-1 rounded border border-po-border`}):x(`pre`,{"data-testid":`files-preview-text`,className:`whitespace-pre-wrap break-words font-mono text-sm leading-normal text-po-text`,children:G})]})}),S===void 0?null:x(ee,{testIdPrefix:`files-comment`,snippet:S.snippet,...S.side===void 0?{}:{side:S.side},...S.startLine===void 0?{}:{startLine:S.startLine},...S.endLine===void 0?{}:{endLine:S.endLine},onSubmit:Z,onCancel:()=>C(void 0)}),h.length===0?null:w(`footer`,{"data-testid":`files-review`,className:`shrink-0 border-t border-po-border px-3 py-2`,children:[w(`div`,{className:`flex items-center gap-2 pb-1`,children:[w(`span`,{className:`flex-1 text-base font-semibold text-po-hi`,children:[h.length,` `,h.length===1?`comment`:`comments`]}),x(k,{variant:`outline`,size:`xs`,"data-testid":`files-send-review`,onClick:Ee,className:``,children:`send review`})]}),R===void 0?null:w(`p`,{role:`alert`,"data-testid":`files-review-error`,className:`pb-1 text-sm text-po-red`,children:[`review not sent: `,R]}),h.map(e=>w(`div`,{"data-testid":`files-review-comment`,className:`flex items-start gap-2 py-0.5`,children:[x(`span`,{className:`shrink-0 text-sm text-po-dim`,children:ne(e)}),x(`span`,{className:`min-w-0 flex-1 truncate text-base text-po-text`,children:e.body}),x(k,{variant:`ghost`,size:`xs`,"data-testid":`files-review-remove`,onClick:()=>{s!==null&&me(s,e.id)},className:`shrink-0 `,children:`remove`})]},e.id))]})]})}function J(e,t){return{id:K(e),label:t.split(`/`).at(-1)??t,panel:n=>x(Te,{...n,filePath:e,relPath:t})}}function Y(t){let{filePath:n,sessionId:r,closeTransientTab:i}=t,[a,ee]=g(void 0);E(()=>{if(r===null)return;let e=!1;return W(r,n).then(t=>{e||ee(t.ok?{sessionId:r,path:n,preview:t.preview}:{sessionId:r,path:n,error:t.error})}),()=>{e=!0}},[r,n]);let s=a?.path===n&&a.sessionId===r?a:void 0,c=s?.preview,l=s?.error,u=c?.relPath??n,d=c?.working,f=d?.content??``,p=ye(u,d?.unavailable===!0),te=ae(e=>Ce(r,u,e),[r,u]),ne=r===null?``:H(r,u);return w(`div`,{"data-testid":`files-preview-panel`,className:`flex min-h-0 flex-1 flex-col`,children:[w(`header`,{className:`flex shrink-0 items-center gap-2 border-b border-po-border px-4 py-2`,children:[x(o,{path:u,"data-testid":`files-preview-breadcrumb`,className:`min-w-0 flex-1`}),x(`span`,{className:`shrink-0 text-sm text-po-dim`,children:`unchanged`}),x(k,{variant:`ghost`,size:`xs`,"data-testid":`files-preview-close`,onClick:()=>i(X(n)),className:`shrink-0 `,children:`close`})]}),l===void 0?null:x(`p`,{"data-testid":`files-preview-error`,className:`px-4 py-3 text-sm text-po-red`,children:l}),c===void 0&&l===void 0?x(`p`,{"data-testid":`files-preview-loading`,className:`px-4 py-3 text-sm text-po-dim`,children:`reading this file…`}):null,c===void 0?null:x(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:w(`div`,{"data-testid":`files-preview`,"data-mode":p,className:`flex h-full flex-col gap-2 p-4 text-base text-po-text`,children:[p===`unavailable`?x(`p`,{"data-testid":`files-preview-unavailable`,className:`text-sm text-po-dim`,children:d?.reason??`this file cannot be shown`}):null,p===`media`||p===`unavailable`?x(Se,{src:ne,path:u,"data-testid":`files-preview-media`}):p===`markdown`?x(re,{text:f,loadImage:te,documentPath:u,renderMediaReview:e(t)}):p===`html`?x(`iframe`,{"data-testid":`files-preview-html`,title:u,sandbox:``,srcDoc:f,className:`h-[36rem] w-full rounded border border-po-border bg-po-deep`}):p===`code`?x(y,{"data-testid":`files-preview-code`,value:f,path:u,readOnly:!0,className:`min-h-[24rem] flex-1 rounded border border-po-border`}):x(`pre`,{"data-testid":`files-preview-text`,className:`whitespace-pre-wrap break-words font-mono text-sm leading-normal text-po-text`,children:f})]})})]})}function X(e){return`${K(e)}-preview`}function Z(e){return{id:X(e),label:e.split(`/`).at(-1)??e,panel:t=>x(Y,{...t,filePath:e})}}var Ee=/:\d+(?::\d+)?$/;function Q(e){return N.select(N.store.state,e).items}function $(e,t){let n=t.trim().replace(Ee,``);if(n!==``)return Q(e).find(e=>e.relPath===n||e.path===n)}var De=S({subscribe(e){let t=N.store.subscribe(e);return()=>t.unsubscribe()},fingerprint:e=>Q(e).map(e=>e.relPath).join(`
2
+ `),resolve:(e,t)=>{let n=$(e,t);return n===void 0?void 0:J(n.path,n.relPath)},openPath:(e,t)=>{let n=$(e,t);if(n!==void 0)return J(n.path,n.relPath);let r=t.trim();return r===``||r.startsWith(`artifact:`)?void 0:Z(r)}}),Oe=(e,t)=>t===void 0?void 0:{...e,...t},ke=ie({id:`files`,session:{get channels(){return[Oe({channel:`file_edits`},L)]},get fileLinks(){return De}}});export{ke as webPlugin};
@@ -0,0 +1 @@
1
+ import{$n as e,An as t,C as n,Cn as r,En as i,O as a,Qn as o,Rn as s,Rt as c,Sn as l,T as u,Tn as d,Xn as ee,_r as f,a as p,bn as m,br as h,cn as g,h as _,jn as v,kn as y,lr as b,nr as te,o as x,s as S,sr as C,ur as ne,w,wn as T,xn as E,zt as D}from"../chunks/po-web-runtime-BJDT6Lbw.js";var O=`po-goal-current`,re=` · `,ie=/\[[0-9;]*m/gu;function ae(e){if(e===void 0)return;let t=e.replace(ie,``).trim(),n=t.indexOf(re);if(n===-1)return;let r=t.slice(n+3).trim();return r===``?void 0:{state:t.slice(0,n).trim(),objective:r}}var k=te({keys:`g e`,statusKey:O,marksBackgroundWork:!1,hideWhenEmpty:!0,order:35}),A=`/goal clear`,j=/\s+/gu,M=/^\d+(?:\.\d+)?[km]?$/iu;function N(e){let t=e.trim().replaceAll(j,` `);return t===``||t.length>4e3?void 0:t}function P(e){let t=e.indexOf(`/`);return t===-1?``:e.slice(t+1).trim()}function F(e,t){let n=N(e);if(n===void 0)return;let r=t.trim();return r===``?`/goal edit ${n}`:M.test(r)?`/goal edit --tokens ${r} ${n}`:void 0}function I({objective:t,budgetHint:n,open:a,onSubmit:o,onCancel:s}){let[u,f]=_(t),[p,h]=_(``),g=F(u,p),v=()=>{f(t),h(``),s()};return x(m,{open:a,onOpenChange:e=>{e||v()},children:S(l,{width:`sm`,"data-testid":`goal-edit-dialog`,"aria-describedby":void 0,children:[x(d,{children:x(i,{children:`edit goal`})}),S(E,{children:[x(r,{children:`this replaces the objective the agent is working to. it takes effect on the next turn.`}),S(`div`,{className:`flex flex-col gap-1`,children:[x(e,{htmlFor:`goal-edit-objective`,children:`objective`}),x(c,{id:`goal-edit-objective`,"data-testid":`goal-edit-objective`,value:u,rows:3,spellCheck:!1,onChange:e=>f(e.target.value)})]}),S(`div`,{className:`flex flex-col gap-1`,children:[x(e,{htmlFor:`goal-edit-budget`,children:`token budget`}),x(ee,{id:`goal-edit-budget`,"data-testid":`goal-edit-budget`,value:p,placeholder:n===``?`none; leave blank to keep it that way`:`${n}; blank keeps it`,onChange:e=>h(e.target.value)})]}),x(`p`,{"data-testid":`goal-edit-preview`,className:`truncate font-mono text-sm text-po-dim`,children:g??`nothing to send`}),S(T,{children:[x(D,{variant:`outline`,size:`md`,"data-testid":`goal-edit-cancel`,onClick:v,children:`cancel`}),x(D,{variant:`primary`,size:`md`,"data-testid":`goal-edit-save`,disabled:g===void 0,onClick:()=>{g!==void 0&&(o(g),h(``))},children:`save`})]})]})]})})}function L({objective:e,open:t,onConfirm:n,onCancel:a}){return x(m,{open:t,onOpenChange:e=>{e||a()},children:S(l,{width:`sm`,"data-testid":`goal-remove-dialog`,"aria-describedby":void 0,children:[x(d,{children:x(i,{children:`remove goal`})}),S(E,{children:[S(r,{children:[`this ends `,x(`span`,{className:`font-semibold text-po-hi`,children:e}),` and stops the current turn. it is archived to this repository's goal history, where it can be restarted.`]}),S(T,{children:[x(D,{variant:`outline`,size:`md`,"data-testid":`goal-remove-cancel`,autoFocus:!0,onClick:a,children:`cancel`}),x(D,{variant:`danger`,size:`md`,"data-testid":`goal-remove-confirm`,onClick:n,children:`remove`})]})]})]})})}function R({sessionId:e,statuses:n,sendSessionFrame:r}){let[i,a]=_(`view`),c=ae(n[O]);if(c===void 0)return x(`p`,{"data-testid":`activity-goal-unavailable`,className:`px-1 text-sm text-po-dim`,children:`goal status unavailable`});let l=t=>{e!==null&&r(e,{type:`prompt`,message:t})};return S(`div`,{"data-testid":`activity-goal-row`,className:`flex flex-col gap-0.5`,children:[S(`div`,{className:`flex min-w-0 items-start gap-1.5 px-1`,children:[S(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[x(`span`,{"data-testid":`activity-goal-objective`,className:`text-base font-semibold text-po-hi`,children:c.objective}),x(`span`,{"data-testid":`activity-goal-state`,className:`text-sm tabular-nums text-po-dim`,children:c.state})]}),S(y,{open:i===`menu`,onOpenChange:e=>a(t=>e?`menu`:t===`menu`?`view`:t),children:[x(s,{asChild:!0,children:x(D,{variant:`ghost`,size:`icon`,"data-testid":`activity-goal-menu`,title:`goal actions`,disabled:e===null,className:`shrink-0 text-po-faint hover:bg-po-deep hover:text-po-hi data-[state=open]:bg-po-deep data-[state=open]:text-po-hi`,children:x(o,{className:`h-3 w-3`})})}),S(t,{"data-testid":`activity-goal-menu-list`,children:[x(v,{"data-testid":`activity-goal-edit`,onSelect:()=>a(`edit`),children:`edit`}),x(v,{variant:`destructive`,"data-testid":`activity-goal-remove`,onSelect:()=>a(`confirm`),children:`remove`})]})]})]}),i===`edit`?x(I,{open:!0,objective:c.objective,budgetHint:P(c.state),onSubmit:e=>{l(e),a(`view`)},onCancel:()=>a(`view`)}):null,x(L,{objective:c.objective,open:i===`confirm`,onConfirm:()=>{l(A),a(`view`)},onCancel:()=>a(`view`)})]})}var z=C({component:R}),B=C({slot:`help.guides`,id:`Goal`,order:30,data:{version:1,label:`Goal`,guides:[{id:`about`,question:`What is a goal?`,order:0,answer:`A goal keeps one objective active across agent turns. An independent check reviews the transcript and verification evidence when the session is idle.`},{id:`budget`,question:`How do I set a goal or token budget?`,order:1,answer:`Send /goal followed by your objective. For a budget, use /goal --tokens 100k followed by the objective. Budgets also accept values such as 1.5m.`,keywords:[`limit`,`tokens`]}]}}),V=b({path:[{key:`g`,label:`goal`,detail:`session objective`},{key:`g`,label:`current`,detail:`the goal being worked`}],command:`goal status`}),H=b({path:[{key:`g`,label:`goal`,detail:`session objective`},{key:`e`,label:`toggle`,detail:`start a session goal or end the current one`}],command:`minor goal`}),U=ne({keys:`g e`,statusKey:`goal`,order:40}),W=[`goal_complete`,`goal_blocked`],G=72;function K(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function q(e){let t=``;for(let n of e){let e=n.codePointAt(0)??0;t+=e<=31||e===127?` `:n}return t.replace(/\s+/gu,` `).trim()}function J(e,t){let n=e[t];return typeof n==`string`&&q(n)||void 0}function Y(e){if(e)return e.length>G?`${e.slice(0,69)}…`:e}function X(e,t,n={}){return{text:e,tone:t,...n}}function oe(e){return e?q(e.content.flatMap(e=>{let t=K(e);return t?.type===`text`&&typeof t.text==`string`?[t.text]:[]}).join(` `)):``}function se(e,t){if(e===`goal_complete`){let e=Y(J(t,`summary`));return{action:`complete`,...e?{detail:e}:{},metadata:[]}}let n=Y(J(t,`reason`)),r=t.repeated_turns,i=typeof r==`number`&&Number.isFinite(r)?[`${r} ${r===1?`turn`:`turns`}`]:[];return{action:`blocked`,...n?{detail:n}:{},metadata:i}}function Z(e,t,n,r){if(r.isPartial)return[X(`◐ recording the goal outcome`,`warning`)];let i=oe(n),a=r.isError||K(n?.details)?.error===!0?[X(`✗ ${i||`${e} refused`}`,`error`)]:[X(`✓ ${i||(e===`goal_complete`?`goal complete`:`goal blocked`)}`,`success`)];if(!r.expanded)return a;let o=e===`goal_complete`?[[`goal_id`,`goal`],[`summary`,`summary`]]:[[`goal_id`,`goal`],[`reason`,`reason`],[`evidence`,`evidence`]];for(let[e,n]of o){let r=J(t,e);r&&a.push(X(`${n} ${r}`,`text`))}return a}function ce({toolName:e,args:t,result:r,running:i,isError:o}){let s=se(e,t),c=Z(e,t,r,{expanded:!1,isError:o,isPartial:i}),l=Z(e,t,r,{expanded:!0,isError:o,isPartial:i});return x(n,{tone:g({running:i,isError:o}),expandable:l.length>c.length,children:({expanded:t})=>S(p,{children:[x(u,{title:e,children:S(`span`,{"data-testid":`tool-call-${e}`,className:`flex min-w-0 flex-1 items-center gap-2`,children:[x(`span`,{className:`font-semibold text-po-hi`,children:s.action}),s.detail?x(`span`,{className:`min-w-0 truncate text-po-dim`,children:s.detail}):null,s.metadata.map(e=>S(`span`,{className:`shrink-0 text-po-dim`,children:[`· `,e]},e))]})}),(t?l:c).length>0?x(w,{"data-testid":`tool-result-${e}`,children:x(a,{lines:t?l:c})}):null]})})}var le=f({tools:[...W],message:ce}),Q=(e,t)=>t===void 0?void 0:{...e,...t},$=h({id:`goal`,session:{get activityGroups(){return[Q({name:`goal`},k)]},get fills(){return[Q({slot:`activity.goal`,id:`goal`},z),Q({slot:`help.guides`,id:`goal`},B)]},get leaderBindings(){return[Q({id:`goal.show`},V),Q({id:`goal.toggle`},H)]},get minorModes(){return[Q({name:`goal`},U)]},get toolRenderers(){return[Q({tools:[`goal`]},le)]}}});export{$ as webPlugin};
@@ -0,0 +1 @@
1
+ import{C as e,E as t,Kn as n,T as r,Zt as i,_r as a,a as o,br as s,cn as c,in as l,o as u,s as d,w as f}from"../chunks/po-web-runtime-BJDT6Lbw.js";function p(e){let t=typeof e.limit==`number`&&Number.isFinite(e.limit)?e.limit:void 0;return{pattern:typeof e.pattern==`string`?e.pattern:``,details:[typeof e.path==`string`&&e.path.length>0?e.path:`.`,typeof e.glob==`string`?e.glob:void 0,e.ignoreCase===!0?`ignore case`:void 0,t===void 0?void 0:`${t} matches`].filter(e=>e!==void 0&&e.length>0)}}function m({args:a,result:s,output:m,running:h,isError:g}){let _=p(a),v=s===null||g?null:i(s,m,`grep`,!0);return u(e,{tone:c({running:h,isError:g}),expandable:!0,defaultExpanded:!1,children:({expanded:e})=>d(o,{children:[u(r,{title:`grep`,children:d(`span`,{"data-testid":`tool-call-grep`,className:`flex min-w-0 flex-1 items-center gap-2`,children:[u(`span`,{className:`truncate text-po-text`,children:_.pattern}),_.details.length>0?d(`span`,{className:`shrink-0 text-po-faint`,children:[`· `,_.details.join(` · `)]}):null]})}),e?g?d(f,{"data-testid":`tool-result-grep`,className:`flex flex-col`,children:[u(t,{tone:`error`,children:`failed`}),l(s,m).map((e,t)=>u(`span`,{className:`whitespace-pre-wrap break-words text-po-red`,children:e},`${String(t)}-${e}`))]}):v===null?h?u(f,{"data-testid":`tool-result-grep`,children:u(t,{tone:`running`,children:`running`})}):null:v.shown.length===0&&v.notice===void 0?null:d(f,{"data-testid":`tool-result-grep`,className:`flex flex-col gap-1`,children:[u(n,{lines:v.shown,gutter:v.gutter}),v.notice===void 0?null:u(`span`,{className:`text-po-faint`,children:v.notice})]}):null]})})}var h=a({message:m}),g=(e,t)=>t===void 0?void 0:{...e,...t},_=s({id:`grep`,session:{get toolRenderers(){return[g({tools:[`grep`]},h)]}}});export{_ as webPlugin};
@@ -0,0 +1,3 @@
1
+ import{Bn as e,C as t,Cr as n,E as r,Jn as i,O as a,Qt as o,Sr as s,T as c,Xn as l,_ as u,_r as d,a as f,ar as p,br as m,cn as h,gr as g,h as _,ln as v,lr as y,m as b,n as x,o as S,p as ee,q as C,qt as w,s as T,sr as E,tr as D,tt as O,u as k,ur as A,vn as te,vt as ne,w as j,zt as M}from"../chunks/po-web-runtime-BJDT6Lbw.js";var N=D({simulation:{method:`GET`,path:`/simulation`,response:void 0},setSimulation:{method:`PUT`,path:`/simulation`,response:void 0},services:{method:`GET`,path:`/services`,response:void 0},slots:{method:`GET`,path:`/slots`,response:void 0}},{scopes:[`global`,`workspace`,`session`],basePath:`brain`,transport:(e,t)=>x.fetch(e,t),sessionAddress:n}),P=`po/codemode`,F=new Set([`po/server-scope`,`po/server-host`,`po/headless-host`,`po/global-services`]);function I(e,t){let n=new Set([...t.values()].flatMap(e=>[e.source,e.target]));return{nodes:[...e.values()].filter(e=>n.has(e.id)).sort((e,t)=>e.id.localeCompare(t.id)),links:[...t.values()].sort((e,t)=>`${e.source}\0${e.target}`.localeCompare(`${t.source}\0${t.target}`))}}function L(e){let t=new Map(e.consumers.flatMap(e=>e.owner.kind===`package`&&e.owner.packageName?[[e.id,{name:e.owner.packageName,origin:e.owner.origin}]]:[])),n=new Map(e.services.map(e=>[e.id,e])),r=e.edges.flatMap(e=>{let r=t.get(e.consumer),i=e.service===null?void 0:n.get(e.service);return r&&i&&!F.has(i.name)?[{plugin:r,service:i}]:[]}),i=new Set(r.filter(e=>e.service.name===P).map(e=>e.plugin.name)),a=new Set(r.filter(e=>i.has(e.plugin.name)).map(e=>e.service.name)),o=new Map,s=new Map;for(let{plugin:e,service:t}of r){if(!t.public&&!a.has(t.name))continue;let n=`service:${t.name}`,r=o.get(n);(!r||t.description&&r.detail.endsWith(`No description.`))&&o.set(n,{id:n,label:t.name,role:a.has(t.name)?`codemode`:`public`,detail:`${t.public?`Public`:`Private`} service${a.has(t.name)?`, callable from code mode`:``}. Provided by ${t.owner.packageName??t.owner.kind}. ${t.description??`No description.`}`});let c=`plugin:${e.name}`;o.set(c,{id:c,label:e.name,role:e.origin===`personal`?`personal`:`plugin`,detail:`Plugin${i.has(e.name)?` that contributes to code mode`:``}.`}),s.set(`${c}\0${n}`,{source:c,target:n,label:`consumes`})}return I(o,s)}function R(e,t,n={}){let r=new Map(Object.values(n).map(e=>[e.slot,e.description])),i=new Map,a=new Map,o=(e,t)=>{let n=`slot:${e}`;return(!i.has(n)||t)&&i.set(n,{id:n,label:e,role:`slot`,detail:`Slot. ${t??r.get(e)??`No description.`}`}),n};for(let n of e){let e=t===`web`?n.web:n.native;if(!e||!n.owner.packageName)continue;let r=`plugin:${n.owner.packageName}`;i.set(r,{id:r,label:n.owner.packageName,role:n.owner.origin===`personal`?`personal`:`plugin`,detail:`Plugin with a ${t} half.`});for(let t of e.slots){let e=o(t.name,t.description);a.set(`${r}\0${e}`,{source:r,target:e,label:`declares`})}for(let t of e.fills){if(t.slot===null)continue;let e=o(t.slot);a.set(`${r}\0${e}`,{source:r,target:e,label:`fills`})}}return I(i,a)}function re(e,t,n){return t===`backend`?L(e):R(t===`web`?e.clientPackages??e.packages:e.packages,t,n)}function ie(e,t){let n=new Set([e]);for(let r of t)r.source===e&&n.add(r.target),r.target===e&&n.add(r.source);return n}function ae(e){return e.map((e,t)=>{let n=12*Math.sqrt(t+.5),r=t*2.399963229728653;return{id:e,x:Math.cos(r)*n,y:Math.sin(r)*n,vx:0,vy:0}})}function z(e,t,n){if(e.length>400)throw Error(`Brain simulation node limit exceeded.`);let r=Math.max(0,Math.min(n,32))/(1e3/60),i=e.map(e=>({...e,vx:e.vx*.8**r,vy:e.vy*.8**r})),a=new Map(e.map((e,t)=>[e.id,t]));for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++){let a=e[t].x-e[n].x||(e[t].y===e[n].y?.5:0),o=e[t].y-e[n].y,s=Math.max(1,Math.hypot(a,o)),c=Math.min(4,1400/s**2)*r;i[t].vx+=a/s*c,i[t].vy+=o/s*c,i[n].vx-=a/s*c,i[n].vy-=o/s*c}for(let n of t){let t=a.get(n.source),o=a.get(n.target);if(t===void 0||o===void 0||t===o)continue;let s=e[o].x-e[t].x,c=e[o].y-e[t].y,l=Math.max(1,Math.hypot(s,c)),u=(l-70)*.01*r;i[t].vx+=s/l*u,i[t].vy+=c/l*u,i[o].vx-=s/l*u,i[o].vy-=c/l*u}for(let e of i)e.vx=Math.max(-8,Math.min(8,e.vx-e.x*.004*r)),e.vy=Math.max(-8,Math.min(8,e.vy-e.y*.004*r)),e.x+=e.vx*r,e.y+=e.vy*r;return i}function oe(e,t,n=300){let r=[...e];for(let e=0;e<n;e++)r=z(r,t,1e3/60);return r}var se=[{id:`backend`,label:`Backend`},{id:`web`,label:`Web`},{id:`native`,label:`Native`}],B={public:`var(--po-green)`,codemode:`var(--po-blue)`,plugin:`var(--po-text)`,personal:`var(--po-magenta)`,slot:`var(--po-cyan)`},V={public:`Public service`,codemode:`Code-mode service`,plugin:`Plugin`,personal:`Your plugin`,slot:`Slot`},ce={backend:`No public or code-mode services are consumed in this scope yet.`,web:`No web slots or fills are published in this scope yet.`,native:`No native slot metadata yet. Packages publish it on their next build.`},le=12,H=420;function ue(e){if(e.length===0)return{x:-100,y:-100,w:200,h:200};let t=e.map(e=>e.x),n=e.map(e=>e.y),r=Math.max(H,Math.max(...t)-Math.min(...t)+80),i=Math.max(H,Math.max(...n)-Math.min(...n)+80);return{x:(Math.max(...t)+Math.min(...t)-r)/2,y:(Math.max(...n)+Math.min(...n)-i)/2,w:r,h:i}}function U({services:e,state:t=`populated`,initialSelection:n,initialGraph:r=`backend`,simulation:i}){let[a,o]=_(r),[c,l]=_(n),[u,d]=_(),f=ee(()=>{let t=re(e,a,s),n=new Map;for(let e of t.links)for(let t of[e.source,e.target])n.set(t,(n.get(t)??0)+1);let r=new Set([...t.nodes].sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0)).slice(0,le).map(e=>e.id)),i=t.nodes.length>400,o=ae(t.nodes.map(e=>e.id)),c=i?o:oe(o,t.links);return{...t,degree:n,hubs:r,tooLarge:i,seed:o,settled:c,home:ue(c)}},[a,e]),[p,m]=_(),[h,g]=_(!1),v=i?.enabled===!0;k(()=>{if(!v||t!==`populated`||f.tooLarge){m(void 0);return}let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),n=f.seed,r=0,i=!1,a=()=>{i||(n=z(n,f.links,1e3/60),m({model:f,points:n}),n.some(e=>Math.abs(e.vx)+Math.abs(e.vy)>.02)&&(r=requestAnimationFrame(a)))},o=()=>{cancelAnimationFrame(r),g(e.matches),e.matches?m(void 0):(n=f.seed,r=requestAnimationFrame(a))};return e.addEventListener(`change`,o),o(),()=>{i=!0,cancelAnimationFrame(r),e.removeEventListener(`change`,o)}},[f,v,t]);let y=v&&p?.model===f?p.points:f.settled,x=new Map(y.map(e=>[e.id,e])),[C,w]=_(),E=C?.model===f?C.box:f.home,D=b(null),O=b(void 0),A=(e,t=E.x+E.w/2,n=E.y+E.h/2)=>{let r=Math.min(f.home.w*4,Math.max(f.home.w/12,E.w*e)),i=r/E.w;w({model:f,box:{x:t-(t-E.x)*i,y:n-(n-E.y)*i,w:r,h:E.h*i}})},te=(e,t)=>{let n=D.current?.getScreenCTM()?.inverse();if(!D.current||!n)return{x:E.x+E.w/2,y:E.y+E.h/2};let r=new DOMPoint(e,t).matrixTransform(n);return{x:r.x,y:r.y}},ne=t===`populated`&&f.nodes.length>0,j=b(()=>{});j.current=e=>{e.preventDefault();let t=te(e.clientX,e.clientY);A(Math.exp(e.deltaY*.0015),t.x,t.y)},k(()=>{let e=D.current;if(!e)return;let t=e=>j.current(e);return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[ne]);let N=()=>{O.current=void 0},P=e=>{e.currentTarget.setPointerCapture(e.pointerId),O.current={x:e.clientX,y:e.clientY,box:E}},F=e=>{let t=O.current,n=D.current?.getBoundingClientRect();if(!t||!n?.width)return;let r=Math.max(t.box.w/n.width,t.box.h/n.height);w({model:f,box:{...t.box,x:t.box.x-(e.clientX-t.x)*r,y:t.box.y-(e.clientY-t.y)*r}})},I=f.nodes.some(e=>e.id===c)?c:void 0,L=u??I,R=L?ie(L,f.links):void 0,H=f.home.w/E.w,U=E.w*.017,W=new Map(f.nodes.map(e=>[e.id,e])),G=I?W.get(I):void 0,K=G?f.links.filter(e=>e.source===G.id||e.target===G.id).map(e=>({link:e,other:W.get(e.source===G.id?e.target:e.source)})).sort((e,t)=>e.other.label.localeCompare(t.other.label)):[];return T(`section`,{className:`break-words bg-po-bg p-4 font-sans text-base text-po-text`,children:[T(`header`,{className:`mb-4 flex flex-wrap items-center justify-between gap-3`,children:[T(`div`,{children:[S(`h1`,{className:`text-2xl font-semibold text-po-hi`,children:`Brain`}),S(`p`,{className:`text-sm text-po-dim`,children:`What this scope can reach, and which plugins lean on it.`})]}),T(`div`,{className:`flex flex-wrap gap-2`,children:[S(`div`,{className:`flex gap-1 rounded-lg border border-po-border p-1`,role:`group`,"aria-label":`Graph`,children:se.map(e=>S(M,{size:`xs`,variant:a===e.id?`subtle`:`ghost`,"aria-pressed":a===e.id,onClick:()=>o(e.id),children:e.label},e.id))}),i&&T(M,{size:`xs`,variant:`outline`,"aria-label":`Physics simulation`,"aria-pressed":v,"aria-disabled":i.pending||void 0,"aria-busy":i.pending,className:`aria-disabled:pointer-events-none aria-disabled:opacity-40`,disabled:t!==`populated`||!v&&f.tooLarge,onClick:()=>{i.pending||i.onChange(!v)},children:[`Motion `,v?`on`:`off`]})]})]}),i?.error&&S(`p`,{role:`alert`,className:`mb-3 text-sm text-po-red`,children:i.error}),i&&(f.tooLarge||v&&h)&&S(`p`,{role:`status`,className:`mb-3 text-sm text-po-dim`,children:f.tooLarge?`Layout is paused above 400 nodes.`:`Motion is paused for your reduced-motion preference.`}),t!==`populated`||f.nodes.length===0?S(`p`,{role:t===`error`?`alert`:`status`,className:`py-12 text-po-text`,children:t===`loading`?`Reading the Brain snapshot…`:t===`error`?`The Brain snapshot could not be read. Your session is unchanged.`:ce[a]}):T(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-[minmax(0,1fr)_320px]`,children:[T(`div`,{className:`relative overflow-hidden rounded-lg border border-po-border bg-po-panel`,children:[T(`svg`,{ref:D,viewBox:`${E.x} ${E.y} ${E.w} ${E.h}`,className:`block h-[min(70vh,640px)] w-full cursor-grab touch-none select-none active:cursor-grabbing`,"aria-hidden":`true`,onPointerDown:P,onPointerMove:F,onPointerUp:N,onPointerCancel:N,children:[f.links.map(e=>{let t=x.get(e.source),n=x.get(e.target);if(!t||!n)return null;let r=L!==void 0&&(e.source===L||e.target===L);return S(`line`,{x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:r?B[W.get(L).role]:`var(--po-dim)`,strokeDasharray:e.label===`declares`?`4 3`:void 0,strokeOpacity:r?.9:L?.06:.22,strokeWidth:r?1.5:1,vectorEffect:`non-scaling-stroke`},`${e.source}\0${e.target}`)}),f.nodes.map(e=>{let t=x.get(e.id),n=3+Math.sqrt(f.degree.get(e.id)??0)*1.6,r=R?.has(e.id)??!0,i=e.id===L||(R?.has(e.id)??!1)||f.hubs.has(e.id)||H>=2;return T(`g`,{className:`cursor-pointer`,opacity:r?1:.15,onPointerDown:e=>e.stopPropagation(),onPointerEnter:()=>d(e.id),onPointerLeave:()=>d(void 0),onClick:()=>l(e.id),children:[e.id===I&&S(`circle`,{cx:t.x,cy:t.y,r:n+4,fill:`none`,stroke:B[e.role],strokeOpacity:`0.5`,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`}),S(`circle`,{cx:t.x,cy:t.y,r:n,fill:B[e.role]}),i&&S(`text`,{x:t.x,y:t.y+n+U*1.1,textAnchor:`middle`,fontSize:U,className:`fill-po-text`,paintOrder:`stroke`,stroke:`var(--po-panel)`,strokeWidth:U*.25,children:e.label})]},e.id)})]}),T(`div`,{className:`absolute right-2 bottom-2 flex gap-1`,children:[S(M,{size:`xs`,variant:`outline`,"aria-label":`Zoom in`,onClick:()=>A(1/1.4),children:`+`}),S(M,{size:`xs`,variant:`outline`,"aria-label":`Zoom out`,onClick:()=>A(1.4),children:`−`}),S(M,{size:`xs`,variant:`outline`,onClick:()=>w(void 0),children:`Fit`})]}),S(`p`,{className:`pointer-events-none absolute top-2 left-3 flex flex-wrap gap-x-3 text-xs text-po-dim`,children:(a===`backend`?[`public`,`codemode`,`plugin`,`personal`]:[`slot`,`plugin`,`personal`]).map(e=>T(`span`,{className:`flex items-center gap-1`,children:[S(`svg`,{viewBox:`0 0 8 8`,className:`size-2`,"aria-hidden":`true`,children:S(`circle`,{cx:`4`,cy:`4`,r:`4`,fill:B[e]})}),V[e]]},e))})]}),T(`aside`,{className:`flex min-w-0 flex-col gap-3`,"aria-label":`Selection`,children:[G?T(`div`,{className:`rounded-lg border border-po-border p-3`,children:[S(`p`,{className:`text-sm text-po-dim`,children:V[G.role]}),S(`h2`,{className:`break-all font-mono text-base font-semibold text-po-hi`,children:G.label}),S(`p`,{className:`mt-1 text-sm`,children:G.detail}),T(`h3`,{className:`mt-3 text-sm text-po-dim`,children:[`Connected (`,K.length,`)`]}),S(`ul`,{className:`mt-1 max-h-72 overflow-y-auto`,children:K.map(({link:e,other:t})=>S(`li`,{children:T(M,{size:`xs`,variant:`ghost`,className:`h-auto w-full justify-start whitespace-normal break-all py-1 text-left`,onClick:()=>l(t.id),children:[S(`span`,{className:`font-mono`,children:t.label}),S(`span`,{className:`text-po-dim`,children:e.label})]})},t.id))})]}):S(`p`,{className:`rounded-lg border border-dashed border-po-border p-3 text-sm text-po-dim`,children:`Pick a node to see what it connects to. Scroll to zoom, drag to move around.`}),T(`details`,{className:`rounded-lg border border-po-border p-3`,children:[T(`summary`,{className:`cursor-pointer text-sm text-po-dim`,children:[`All nodes (`,f.nodes.length,`)`]}),S(`ul`,{className:`mt-2 max-h-72 overflow-y-auto`,children:f.nodes.map(e=>S(`li`,{children:S(M,{size:`xs`,variant:`ghost`,"aria-pressed":I===e.id,className:`h-auto w-full justify-start whitespace-normal break-all py-1 text-left font-mono`,onClick:()=>l(e.id),children:e.label})},e.id))})]}),a===`backend`&&e.diagnostics.length>0&&T(`details`,{className:`rounded-lg border border-po-border p-3`,children:[T(`summary`,{className:`cursor-pointer text-sm text-po-dim`,children:[`Coverage notes (`,e.diagnostics.length,`)`]}),e.diagnostics.map(e=>S(`p`,{className:`mt-2 text-sm text-po-dim`,children:e},e))]})]})]})]})}var W={scope:{id:`pending`,level:`global`},scopes:[],packages:[],services:[],consumers:[],edges:[],diagnostics:[]};function G({sessionId:e,workspaceId:t}){let n=e?`session:${e}`:t?`workspace:${t}`:`global`,r=!!(e||t),i=ee(()=>e?N.session(e):t?N.workspace(t):N.global,[e,t]),[a,o]=_(0),[s,c]=_(),[l,u]=_(),d=b(void 0);k(()=>{let e=new AbortController;return d.current=e,r?(u({target:n,pending:!0}),i.simulation({signal:e.signal}).then(t=>{if(!e.signal.aborted){if(!t.ok||typeof t.data?.enabled!=`boolean`)throw Error(`Simulation unavailable.`);u({target:n,enabled:t.data.enabled,pending:!1})}}).catch(()=>{e.signal.aborted||u({target:n,pending:!1,error:`Simulation could not be read. Refresh to try again.`})})):u(void 0),c(e=>e?.target===n?{...e,state:`loading`}:void 0),i.services({signal:e.signal}).then(t=>{if(!t.ok)throw Error(`Brain snapshot unavailable.`);e.signal.aborted||c({target:n,services:t.data,state:t.data.services.length+t.data.consumers.length+t.data.packages.length?`populated`:`empty`})}).catch(()=>{e.signal.aborted||c({target:n,services:W,state:`error`})}),()=>{e.abort(),d.current===e&&(d.current=void 0)}},[i,r,n,a]);let f=s?.target===n?s:void 0,p=f?.state??`loading`,m=l?.target===n?l:void 0;async function h(e){let t=d.current;if(r&&t&&!t.signal.aborted&&m&&m.enabled!==void 0&&!m.pending){u({...m,pending:!0,error:void 0});try{let r=await i.setSimulation({body:{enabled:e},signal:t.signal});if(t.signal.aborted)return;if(!r.ok||typeof r.data?.enabled!=`boolean`)throw Error(`Simulation unavailable.`);u({target:n,enabled:r.data.enabled,pending:!1})}catch{t.signal.aborted||u({...m,pending:!1,error:`Simulation could not be changed. Your graph is unchanged.`})}}}return T(`div`,{children:[T(`div`,{className:`flex items-center justify-between gap-3 bg-po-bg px-4 pt-4`,children:[T(`p`,{className:`text-sm text-po-dim`,children:[e?`Session`:t?`Workspace`:`Global`,` snapshot`]}),S(M,{size:`xs`,variant:`outline`,disabled:p===`loading`||m?.pending,onClick:()=>o(e=>e+1),children:`Refresh`})]}),S(U,{services:f?.services??W,state:p,simulation:r?{enabled:m?.enabled??!1,pending:m?.pending!==!1||m.enabled===void 0,error:m?.error,onChange:h}:void 0},n)]})}var K=E({slot:`page`,id:`brain`,component:G}),de=e=>typeof e==`object`&&!!e&&!Array.isArray(e),q=(e,t)=>{if(typeof e!=`string`)return null;let n=e.trim();return n.length>0&&n.length<=t?n:null};function fe(e){if(!de(e)||e.version!==1)return null;let t=q(e.label,80);if(!t||!Array.isArray(e.guides)||e.guides.length>64)return null;let n=[],r=new Set;for(let t of e.guides){if(!de(t))return null;let e=q(t.id,80),i=q(t.question,240),a=q(t.answer,4e3);if(!e||!i||!a||r.has(e)||t.order!==void 0&&(typeof t.order!=`number`||!Number.isFinite(t.order)))return null;let o;if(t.keywords!==void 0){if(!Array.isArray(t.keywords)||t.keywords.length>16)return null;o=[];for(let e of t.keywords){let t=q(e,64);if(!t)return null;o.push(t)}}r.add(e),n.push({id:e,question:i,answer:a,...o===void 0?{}:{keywords:o},...t.order===void 0?{}:{order:t.order}})}return{version:1,label:t,guides:n}}var pe={slot:`help.guides`,description:`Contribute a labelled set of searchable plain-text questions and answers to the Help panel.`,parse:fe};function me(e,t){let n=t.toLowerCase().trim().split(/\s+/).filter(Boolean);return e.flatMap(e=>{let t=e.data.guides.filter(t=>{let r=[e.data.label,t.question,t.answer,...t.keywords??[]].join(` `).toLowerCase();return n.every(e=>r.includes(e))}).sort((e,t)=>(e.order??0)-(t.order??0)||e.question.localeCompare(t.question));return t.length?[{...e,data:{...e.data,guides:t}}]:[]})}function he(e){return S(ge,{fills:e.slotData(pe)},e.sessionId)}function ge({fills:t,initialQuery:n=``,initialExpanded:r}){let[i,a]=_(n),o=me(t,i),s=t.some(e=>e.data.guides.length);return T(`div`,{className:`flex h-full min-h-0 w-full flex-col bg-po-rail text-po-text font-sans`,children:[S(`div`,{className:`border-b border-po-border-soft p-3`,children:S(l,{"aria-label":`Search help`,placeholder:`Search help`,type:`search`,value:i,onChange:e=>a(e.target.value),className:`w-full placeholder:text-po-dim`})}),S(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:o.length===0?S(e,{title:s?`No matching guides`:`No help guides yet`,description:s?`Try a different word or a package name.`:`Guides from this session’s plugins will appear here.`}):S(`div`,{className:`flex flex-col gap-5`,children:o.map(e=>T(`section`,{children:[S(`h2`,{className:`mb-1 text-lg font-semibold text-po-hi break-words`,children:e.data.label}),S(u,{type:`single`,collapsible:!0,defaultValue:r?.[0]===e.pluginId&&r[1]===e.id?r[2]:void 0,children:e.data.guides.map(e=>T(v,{value:e.id,children:[S(te,{className:`text-base font-medium leading-relaxed break-words`,children:e.question}),S(ne,{className:`whitespace-pre-wrap break-words text-base leading-relaxed text-po-text`,children:e.answer})]},e.id))})]},JSON.stringify([e.pluginId,e.id])))})})]})}var _e=p({id:`help`,label:`Help`,icon:i,order:50,requiredMinorMode:`help`,panel:he});function ve({openTransientTab:e}){return S(M,{variant:`outline`,size:`xs`,"data-testid":`activity-explore-brain`,onClick:()=>e({id:`help-brain-map`,label:`Brain`,panel:G}),children:`Explore`})}var ye=E({slot:`activity-promo`,id:`brain-explore`,component:ve}),be=E({slot:`help.guides`,id:`Help`,order:0,data:{version:1,label:`Help`,guides:[{id:`about`,question:`What does Help mode do?`,order:0,answer:`Help adds package guidance and read-only diagnostics for your setup. It does not change configuration or grant extra permissions.`,keywords:[`setup`,`diagnostics`]},{id:`toggle`,question:`How do I turn Help on or off?`,order:1,answer:`Use the minor-mode menu, or send /minor help. Help is additive: other tools and modes keep their existing rules.`}]}}),xe=y({path:[{key:`h`,label:`help`,detail:`package docs and logs`},{key:`e`,label:`toggle`,detail:`load or hide package Help`}],command:`minor help`}),Se=A({keys:`h e`,order:10}),Ce=g(pe),we=new Set([`inactive`,`activating`,`active`,`degraded`]),J=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Y=e=>typeof e==`number`&&Number.isInteger(e)&&e>=0?e:void 0,X=e=>typeof e==`string`&&e.trim()!==``?e.trim():void 0,Z=e=>Array.isArray(e)?e.filter(J):[];function Q(e){return e.split(`
2
+ `).filter(e=>e.trim()!==``)}function Te(e){return Z(e).flatMap(e=>{let t=X(e.name);if(t===void 0)return[];let n=X(e.source),r=X(e.reason);return[{name:t,active:e.active===!0,...n?{source:n}:{},...r?{reason:r}:{}}]})}function Ee(e){let t=X(e.activation);if(t===void 0||!we.has(t))return null;let n=J(e.counts)?e.counts:{},r=Y(n.tools);return{kind:`status`,activation:t,skillCount:Y(n.skills)??null,...r===void 0?{}:{toolCount:r},skills:Te(e.skills),tools:Te(e.tools),diagnostics:Z(e.diagnostics).flatMap(e=>{let t=X(e.code);if(t===void 0)return[];let n=X(e.source);return[{code:t,...n?{source:n}:{}}]}),packages:Z(e.packages).flatMap(e=>{let t=X(e.packageName);if(t===void 0)return[];let n={scope:X(e.scope),stage:X(e.stage),reason:X(e.reason)},r=X(e.previous);return[{packageName:t,...Object.fromEntries(Object.entries(n).filter(([,e])=>e!==void 0)),...r&&r!==`none`?{previous:r}:{}}]}),truncated:e.truncated===!0}}function De(e){let t=X(e.status);if(t!==`checks-passed`&&t!==`issues-found`)return null;let n=J(e.appliedSelection)?e.appliedSelection:{},r=X(n.majorMode),i=X(n.profile),a=X(e.limitations);return{kind:`setup`,passed:t===`checks-passed`,...r?{majorMode:r}:{},domains:Array.isArray(n.domains)?n.domains.flatMap(e=>X(e)??[]):[],...i?{profile:i}:{},checks:Z(e.checks).flatMap(e=>{let t=X(e.area);if(t===void 0)return[];let n=Y(e.problemCount),r=X(e.guidance);return[{area:t,passed:e.status===`passed`,...n===void 0?{}:{problemCount:n},...r?{guidance:r}:{}}]}),skipped:Array.isArray(e.skipped)?e.skipped.flatMap(e=>X(e)??[]):[],...a?{limitations:a}:{}}}function Oe(e){let t;try{t=JSON.parse(e)}catch{return{kind:`text`,lines:Q(e)}}if(J(t)){let e=Ee(t)??De(t);if(e!==null)return e}return{kind:`text`,lines:Q(e)}}var ke=(e,t)=>`${String(e)} ${t}${e===1?``:`s`}`;function Ae(e){if(e.kind===`setup`){if(e.passed)return`Checks passed`;let t=e.checks.filter(e=>!e.passed).length;return t>0?`${ke(t,`area`)} failed`:`Issues found`}return{inactive:`Help off`,activating:`Help activating`,active:`Help active`,degraded:`Help degraded`}[e.activation]}function je(e){if(e.kind===`setup`){let t=e.checks.filter(e=>!e.passed).length;return[{label:`Checks passed`,value:`${String(e.checks.length-t)}/${String(e.checks.length)}`,tone:`text`},{label:`Failed`,value:String(t),tone:t>0?`error`:`text`},...e.skipped.length>0?[{label:`Skipped`,value:String(e.skipped.length),tone:`warning`}]:[]]}return e.activation===`inactive`?[]:[{label:`Skills`,value:e.skillCount===null?`pending`:String(e.skillCount),tone:`text`},...e.toolCount===void 0?[]:[{label:`Tools`,value:String(e.toolCount),tone:`text`}],...e.diagnostics.length>0?[{label:`Diagnostics`,value:String(e.diagnostics.length),tone:`warning`}]:[],...e.packages.length>0?[{label:`Failed packages`,value:String(e.packages.length),tone:`error`}]:[]]}function Me(e){if(e.activation===`inactive`)return`Help mode is off in this session.`;if(e.activation===`activating`)return`Skills are counted once the session is ready.`}function Ne(e){return e.kind===`setup`?e.checks.length>0||e.skipped.length>0||e.limitations!==void 0:e.skills.length>0||e.tools.length>0||e.diagnostics.length>0||e.packages.length>0||e.truncated}var Pe=`Help diagnostics`,Fe={text:`truncate text-lg font-semibold tabular-nums text-po-hi`,warning:`truncate text-lg font-semibold tabular-nums text-po-yellow`,error:`truncate text-lg font-semibold tabular-nums text-po-red`};function Ie({toolName:e,output:n,running:i,isError:o}){let s=h({running:i,isError:o}),l=i||o?null:Oe(n);if(l!==null&&l.kind!==`text`)return S(Le,{toolName:e,tone:s,view:l});let u=l?.lines??Q(n);if(o)return T(t,{tone:s,children:[S(c,{title:e,children:S(`span`,{className:`min-w-0 truncate text-po-faint`,children:Pe})}),u.length>0?S(j,{children:S(`p`,{className:`whitespace-pre-wrap break-words text-po-red`,children:u.join(`
3
+ `)})}):null]});let d=u.map(e=>({text:e,tone:`text`}));return S(t,{tone:s,expandable:d.length>12,children:({expanded:t})=>{let n=w(d,12,t);return T(f,{children:[S(c,{title:e,children:S(`span`,{className:`min-w-0 truncate text-po-faint`,children:Pe})}),n.shown.length>0||i?T(j,{children:[S(a,{lines:n.shown}),n.hidden>0?T(r,{expands:!0,children:[n.hidden,` more lines`]}):null,i?S(r,{tone:`running`,children:`Inspecting this session`}):null]}):null]})}})}function Le({toolName:e,tone:n,view:r}){let i=je(r),a=r.kind===`status`?Me(r):void 0;return S(t,{tone:n,expandable:Ne(r),children:({expanded:t})=>T(f,{children:[S(c,{title:e,children:S(`span`,{"data-testid":`tool-call-${e}`,className:`max-w-[70%] shrink-0 truncate text-po-text`,children:Ae(r)})}),T(j,{"data-testid":`tool-result-${e}`,className:`flex flex-col gap-4`,children:[a===void 0?null:S(`p`,{className:`text-sm text-po-dim`,children:a}),i.length>0?S(`dl`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:i.map(e=>T(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[S(`dt`,{className:`truncate text-sm text-po-dim`,children:e.label}),S(`dd`,{className:Fe[e.tone],children:e.value})]},e.label))}):null,t?r.kind===`status`?S(Re,{view:r}):S(Be,{view:r}):null]})]})})}function Re({view:e}){return T(f,{children:[e.packages.length>0?T(`section`,{className:`flex flex-col gap-2`,children:[S(C,{children:`Failed packages`}),e.packages.map((e,t)=>T(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[T(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[S(`span`,{className:`min-w-0 shrink truncate font-mono text-sm text-po-text`,children:e.packageName}),e.stage===void 0?null:T(`span`,{className:`min-w-0 flex-1 truncate text-right text-sm text-po-faint`,children:[e.stage,e.scope===void 0?``:` · ${e.scope}`]})]}),e.reason===void 0?null:S(`p`,{className:`break-words text-sm text-po-red`,children:e.reason}),e.previous===void 0?null:T(`p`,{className:`text-sm text-po-faint`,children:[`Previous build `,e.previous]})]},`${e.packageName}-${String(t)}`))]}):null,e.diagnostics.length>0?T(`section`,{className:`flex flex-col gap-2`,children:[S(C,{children:`Diagnostics`}),e.diagnostics.map((e,t)=>T(`div`,{className:`flex min-w-0 items-center gap-2`,children:[S(O,{tone:`yellow`,size:`xs`,className:`shrink-0 font-mono`,children:e.code}),e.source===void 0?null:S(`span`,{className:`min-w-0 flex-1 truncate text-right font-mono text-sm text-po-dim`,children:e.source})]},`${e.code}-${String(t)}`))]}):null,S(ze,{label:`Skills`,rows:e.skills}),S(ze,{label:`Tools`,rows:e.tools}),e.truncated?S(`p`,{className:`text-sm text-po-faint`,children:`The tool capped its lists; more exist.`}):null]})}function ze({label:e,rows:t}){if(t.length===0)return null;let n=t.slice(0,10);return T(`section`,{className:`flex flex-col gap-2`,children:[S(C,{children:e}),S(`ul`,{className:`grid grid-cols-1 gap-x-6 gap-y-1 sm:grid-cols-2`,children:n.map((e,t)=>T(`li`,{className:`flex min-w-0 items-center gap-2`,children:[S(`span`,{className:e.active?`min-w-0 shrink truncate font-mono text-sm text-po-text`:`min-w-0 shrink truncate font-mono text-sm text-po-dim`,children:e.name}),e.active?null:S(O,{size:`xs`,className:`shrink-0`,children:e.reason??`inactive`}),e.source===void 0?null:S(`span`,{className:`min-w-0 flex-1 truncate text-right text-sm text-po-faint`,children:e.source})]},`${e.name}-${String(t)}`))}),t.length>n.length?T(`p`,{className:`text-sm text-po-faint`,children:[`and `,t.length-n.length,` more`]}):null]})}function Be({view:e}){let t=[...e.majorMode===void 0?[]:[`mode ${e.majorMode}`],...e.domains.map(e=>`domain ${e}`),...e.profile===void 0?[]:[`profile ${e.profile}`]];return T(f,{children:[t.length>0?T(`section`,{className:`flex flex-col gap-2`,children:[S(C,{children:`Selection`}),S(`div`,{className:`flex flex-wrap items-center gap-2`,children:t.map(e=>S(O,{size:`xs`,children:e},e))})]}):null,e.checks.length>0?T(`section`,{className:`flex flex-col gap-2`,children:[S(C,{children:`Checks`}),S(`ul`,{className:`grid grid-cols-1 gap-x-6 gap-y-2 sm:grid-cols-2`,children:e.checks.map(e=>T(`li`,{className:`flex min-w-0 flex-col gap-0.5`,children:[T(`div`,{className:`flex min-w-0 items-center gap-2`,children:[S(`span`,{className:`min-w-0 flex-1 truncate font-mono text-sm text-po-text`,children:e.area}),e.passed?S(o,{"aria-label":`passed`,className:`size-3.5 shrink-0 text-po-green`}):S(`span`,{className:`shrink-0 text-sm text-po-red`,children:e.problemCount===void 0?`failed`:`${String(e.problemCount)} problem${e.problemCount===1?``:`s`}`})]}),!e.passed&&e.guidance!==void 0?T(`span`,{className:`truncate text-sm text-po-faint`,children:[`Guide: `,e.guidance]}):null]},e.area))})]}):null,e.skipped.length>0?T(`section`,{className:`flex flex-col gap-2`,children:[S(C,{children:`Skipped`}),e.skipped.map(e=>S(`p`,{className:`text-sm text-po-yellow`,children:e},e))]}):null,e.limitations===void 0?null:S(`p`,{className:`text-sm text-po-faint`,children:e.limitations})]})}var Ve=d({tools:[`help_status`,`diagnose_setup`],message:Ie}),$=(e,t)=>t===void 0?void 0:{...e,...t},He=m({id:`help`,global:{get fills(){return[$({slot:`page`,id:`brain`},K)]}},session:{get dockFaces(){return[$({id:`help`},_e)]},get fills(){return[$({slot:`activity-promo`,id:`brain`},ye),$({slot:`help.guides`,id:`help`},be)]},get leaderBindings(){return[$({id:`help.toggle`},xe)]},get minorModes(){return[$({name:`help`},Se)]},get slots(){return[$({slot:`help.guides`},Ce)]},get toolRenderers(){return[$({tools:[`help_status`]},Ve)]}}});export{He as webPlugin};
@@ -0,0 +1,4 @@
1
+ import{Bn as e,C as t,Cr as n,E as r,Et as i,J as a,O as o,Q as s,T as c,Tt as l,X as u,Y as d,Z as f,_r as p,a as m,br as h,cn as g,d as _,er as v,h as y,m as b,mr as x,n as S,o as C,q as w,qt as ee,rr as te,s as T,tr as ne,tt as re,u as E,w as D,yn as ie,zt as O}from"../chunks/po-web-runtime-BJDT6Lbw.js";var ae=[`session`,`agent`,`model`,`provider`],oe=[`day`,`week`,`month`,`all`],k={dimension:`dimension`,period:`period`,focus:`focus`};function A(e){return`unavailable`in e}function se(e){return`unavailable`in e}var ce=te({metrics:{method:`GET`,path:`/metrics`,query:[k.dimension,k.period,k.focus],response:v()},issues:{method:`GET`,path:`/issues`,query:[k.focus],response:v()},ingestLogs:{method:`POST`,path:`/v1/logs`,response:v()}}),j=ne(ce,{scopes:[`global`,`workspace`,`session`],basePath:`log`,transport:(e,t)=>S.fetch(e,t),sessionAddress:n}),le=`The cockpit hub is unreachable.`,M=`This cockpit is running a bundle without the log package API, so there are no metrics to read.`,ue={unavailable:`no-api`,detail:M};function de(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function N(e,t){if(e.status===0)return{error:t?.aborted===!0?``:le};let n=`The hub answered ${String(e.status)}.`;return e.data===void 0?e.ok?{noApi:!0}:{error:n}:de(e.data)?e.ok?{body:e.data}:{error:e.error===``?n:e.error}:{error:`The hub returned a response the cockpit could not read.`}}async function fe(e,t,n,r){let i=N(await j.global.metrics({query:{[k.dimension]:e,[k.period]:t,[k.focus]:n===``?void 0:n},...r===void 0?{}:{signal:r}}),r);if(`error`in i)return{error:i.error};if(`noApi`in i)return{report:ue};let a=i.body;return!A(a)&&!Array.isArray(a.groups)?{error:`The hub returned a report the cockpit could not read.`}:{report:a}}async function pe(e,t,n={}){let r=N(await j.global.issues({query:{[k.focus]:e===``?void 0:e,...n},...t===void 0?{}:{signal:t}}),t);return`error`in r?{error:r.error}:`noApi`in r?{issues:{unavailable:`no-api`,detail:M}}:{issues:r.body}}function P(e,t){return!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0?0:Math.min(1,e/t)}function F(e){return e.reduce((e,t)=>Number.isFinite(t)&&t>e?t:e,0)}function I(e){return Number.isFinite(e)?e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Math.round(e)):`Not reported`}var L=5;function me({groups:e,totalTokens:t,focus:n,onFocus:r}){let[i,a]=y(!1),o=[...e].sort((e,t)=>t.totalTokens-e.totalTokens||e.key.localeCompare(t.key)),s=i?o:o.slice(0,L),c=t??F(e.map(e=>e.totalTokens));return T(`div`,{className:`flex flex-col gap-3`,children:[e.length===0?C(`p`,{className:`rounded-md border border-dashed border-po-border p-5 text-sm text-po-dim`,children:`No grouped usage was recorded for this selection.`}):null,C(`ul`,{className:`flex flex-col gap-1`,"data-testid":`metrics-group-bars`,children:s.map(e=>{let i=n===e.key,a=e.key===`unknown`||e.key===``,o=r!==void 0&&!a,s=P(e.totalTokens,c)*100,l=T(m,{children:[T(`span`,{className:`flex items-start justify-between gap-3`,children:[C(`span`,{className:`min-w-0 break-all text-left font-medium text-po-hi`,title:e.key,children:a?`Unattributed`:e.key}),C(`span`,{className:`shrink-0 text-right font-semibold tabular-nums text-po-hi`,title:String(e.totalTokens),children:I(e.totalTokens)})]}),C(`span`,{"aria-hidden":`true`,className:`mt-2 block h-1.5 overflow-hidden rounded-full bg-po-border`,children:C(`span`,{className:`block h-full rounded-full ${a?`bg-po-yellow`:`bg-po-blue`}`,style:{width:`${s}%`}})}),T(`span`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-sm text-po-dim`,children:[C(`span`,{children:t!==void 0&&c>0?`${s.toFixed(1)}% of total`:`Relative token volume`}),T(`span`,{className:e.issueCount>0||e.failed?`text-po-yellow`:`text-po-dim`,children:[e.failed?`Failed · `:``,I(e.issueCount),` `,e.issueCount===1?`issue`:`issues`]})]})]});return C(`li`,{children:o?C(`button`,{type:`button`,onClick:()=>r?.(i?``:e.key),"aria-pressed":i,"aria-label":`Filter to ${e.key}`,"data-testid":`metrics-group-${e.key}`,className:`block w-full rounded-md p-3 text-base hover:bg-po-tint-blue focus-visible:outline focus-visible:outline-1 focus-visible:outline-po-blue ${i?`bg-po-tint-blue`:``}`,children:l}):C(`div`,{className:`rounded-md p-3 text-base`,children:l})},e.key)})}),e.length>L?C(O,{variant:`ghost`,size:`sm`,onClick:()=>a(!i),"aria-expanded":i,children:i?`Show top 5`:`Show all ${e.length} returned groups`}):null]})}var R=[{key:`totalTokens`,label:`Total`},{key:`inputTokens`,label:`Input`},{key:`outputTokens`,label:`Output`}],z=600,B=160,he=48;function ge({buckets:e,bucketUnit:t,onShorterPeriod:n}){let[r,i]=y(`totalTokens`),[a,o]=y(``),s=e.find(e=>e.label===a)??e.at(-1),c=F(e.map(e=>e[r])),l=t?`${t} `:``,u=z/Math.max(1,e.length),d=Math.min(he,u*.65);return e.length===0?C(`p`,{className:`rounded-md border border-dashed border-po-border p-5 text-sm text-po-dim`,"data-testid":`metrics-timeline-chart`,children:`No timeline buckets were recorded for this selection.`}):e.length===1&&s!==void 0?C(`div`,{className:`flex flex-col gap-4`,"data-testid":`metrics-timeline-chart`,children:T(`div`,{className:`rounded-md border border-po-border bg-po-deep p-5`,children:[C(`p`,{className:`text-sm text-po-dim`,children:s.label}),T(`p`,{className:`mt-2 text-lg font-semibold tabular-nums text-po-blue`,title:String(s.totalTokens),children:[I(s.totalTokens),` tokens`]}),T(`p`,{className:`mt-3 text-sm leading-relaxed text-po-dim`,children:[`Only one `,l,`bucket was recorded. There is not enough history to show a trend.`]}),C(`p`,{className:`mt-2 text-sm text-po-dim`,children:`For more detail, pick a shorter period when one is available.`}),n===void 0?null:C(O,{variant:`ghost`,size:`sm`,className:`mt-3`,onClick:n,children:`View hourly detail`})]})}):T(`div`,{className:`flex flex-col gap-3`,"data-testid":`metrics-timeline-chart`,children:[T(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[C(`div`,{className:`flex gap-1`,role:`group`,"aria-label":`Timeline token counter`,children:R.map(e=>C(O,{size:`sm`,variant:r===e.key?`primary`:`ghost`,"aria-pressed":r===e.key,onClick:()=>i(e.key),children:e.label},e.key))}),T(`span`,{className:`text-sm text-po-dim`,children:[e.length,` recorded `,l,`buckets`]})]}),T(`div`,{className:`flex gap-3`,children:[T(`div`,{"aria-hidden":`true`,className:`flex w-12 shrink-0 flex-col justify-between text-right text-sm tabular-nums text-po-dim`,children:[C(`span`,{children:I(c)}),C(`span`,{children:I(c/2)}),C(`span`,{children:`0`})]}),T(`svg`,{viewBox:`0 0 ${z} ${B}`,preserveAspectRatio:`none`,className:`h-40 min-w-0 flex-1 overflow-visible`,role:`group`,"aria-label":`tokens per bucket, peak ${I(c)}`,children:[[0,B/2,B].map(e=>C(`line`,{x1:`0`,x2:z,y1:e,y2:e,className:`text-po-border`,stroke:`currentColor`,vectorEffect:`non-scaling-stroke`},e)),e.map((e,t)=>{let n=P(e[r],c)*B,i=`${e.label}: ${I(e[r])} ${R.find(e=>e.key===r)?.label.toLowerCase()} tokens`;return T(`g`,{children:[C(`rect`,{x:t*u+(u-d)/2,y:B-n,width:d,height:n,rx:`2`,fill:`currentColor`,className:s?.label===e.label?`text-po-cyan`:`text-po-blue`}),C(`rect`,{x:t*u,y:`0`,width:u,height:B,fill:`transparent`,tabIndex:0,role:`button`,"aria-label":i,"aria-pressed":s?.label===e.label,onMouseEnter:()=>o(e.label),onFocus:()=>o(e.label),onClick:()=>o(e.label),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),o(e.label))},className:`cursor-pointer focus-visible:outline focus-visible:outline-1 focus-visible:outline-po-cyan`,children:C(`title`,{children:i})})]},e.label)})]})]}),T(`div`,{className:`ml-15 flex justify-between gap-3 text-sm text-po-dim`,children:[C(`span`,{children:e[0]?.label}),C(`span`,{className:`text-right`,children:e.at(-1)?.label})]}),T(`div`,{className:`flex flex-wrap justify-between gap-2 rounded-md bg-po-deep px-3 py-2 text-sm tabular-nums`,"aria-live":`polite`,"aria-atomic":`true`,children:[C(`span`,{className:`text-po-dim`,children:s?.label}),T(`span`,{className:`text-po-hi`,children:[I(s?.[r]??NaN),` `,R.find(e=>e.key===r)?.label.toLowerCase(),` tokens`]})]}),c===0?T(`p`,{className:`text-sm text-po-dim`,children:[`Recorded buckets contain zero `,R.find(e=>e.key===r)?.label.toLowerCase(),` tokens.`]}):null,T(`details`,{className:`text-sm text-po-dim`,children:[C(`summary`,{className:`cursor-pointer rounded-sm focus-visible:outline focus-visible:outline-1 focus-visible:outline-po-blue`,children:`View exact bucket values`}),C(`div`,{className:`mt-3 overflow-x-auto`,children:T(`table`,{className:`w-full text-right tabular-nums`,children:[C(`caption`,{className:`sr-only`,children:`Independent token counters by recorded bucket`}),C(`thead`,{children:T(`tr`,{children:[C(`th`,{scope:`col`,className:`py-2 text-left`,children:`Bucket`}),C(`th`,{scope:`col`,className:`pl-3`,children:`Total`}),C(`th`,{scope:`col`,className:`pl-3`,children:`Input`}),C(`th`,{scope:`col`,className:`pl-3`,children:`Output`})]})}),C(`tbody`,{children:e.map(e=>T(`tr`,{className:`border-t border-po-border`,children:[C(`th`,{scope:`row`,className:`py-2 text-left font-normal`,children:e.label}),R.map(t=>C(`td`,{className:`pl-3`,children:Number.isFinite(e[t.key])?e[t.key].toLocaleString(`en-US`):`Not reported`},t.key))]},e.label))})]})})]})]})}function _e(e){return`${e.fingerprint===``?`${e.category}|${e.message}`:e.fingerprint}|${e.detail}`}function ve(e){let t=new Map;for(let n of e){let e=_e(n),r=t.get(e);r===void 0?t.set(e,{key:e,occurrences:n.occurrenceCount,category:n.category,detail:n.detail,tool:n.tool,errorType:n.errorType,agentName:n.agentName,model:n.model,statusCode:n.statusCode,lastSeen:n.timestamp,members:[n]}):(r.occurrences+=n.occurrenceCount,r.members.push(n),n.timestamp>r.lastSeen&&(r.lastSeen=n.timestamp),r.tool??=n.tool,r.errorType??=n.errorType,r.agentName??=n.agentName,r.model??=n.model,r.statusCode??=n.statusCode)}return[...t.values()].sort((e,t)=>t.occurrences-e.occurrences||e.detail.localeCompare(t.detail))}function V(e){return Object.entries(e).sort(([,e],[,t])=>t-e)}function ye(e){return e.errorType===null?e.tool===null?e.category:`${e.tool} failed`:e.errorType}function be({group:e,max:t,tools:n}){let[r,i]=y(!1),a=`${(P(e.occurrences,t)*100).toFixed(2)}%`,o=n.find(t=>t.name===e.tool)?.calls;return T(`li`,{className:`flex flex-col rounded-md border border-po-border`,children:[T(`div`,{className:`relative`,children:[C(`span`,{"aria-hidden":`true`,className:`absolute bottom-0 left-0 h-1 rounded-xs bg-po-yellow/40`,style:{width:a}}),T(`button`,{type:`button`,onClick:()=>i(!r),"aria-expanded":r,"data-testid":`metrics-issue-${e.key}`,className:`relative flex min-h-10 w-full flex-wrap items-start gap-3 rounded-md p-3 text-left text-base hover:bg-po-tint-blue focus-visible:outline focus-visible:outline-1 focus-visible:outline-po-blue`,children:[C(`span`,{className:`w-8 shrink-0 text-right font-semibold text-po-yellow`,children:e.occurrences}),C(`span`,{className:`w-24 shrink-0 break-words font-medium text-po-hi`,children:ye(e)}),C(`span`,{className:`min-w-40 flex-1 break-words text-po-dim`,children:e.detail}),o===void 0?null:T(`span`,{className:`shrink-0 text-po-dim`,children:[o,` token samples`]})]})]}),r?T(`div`,{className:`flex flex-col gap-1 px-3 py-3 text-base`,"data-testid":`metrics-issue-body-${e.key}`,children:[T(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-sm text-po-dim`,children:[T(`span`,{children:[`category `,e.category]}),e.tool===null?null:T(`span`,{children:[`tool `,e.tool]}),e.errorType===null?null:T(`span`,{children:[`error `,e.errorType]}),e.statusCode===null?null:T(`span`,{children:[`status `,e.statusCode]}),e.agentName===null?null:T(`span`,{children:[`agent `,e.agentName]}),e.model===null?null:T(`span`,{children:[`model `,e.model]}),T(`span`,{children:[`last seen `,e.lastSeen]})]}),C(`span`,{className:`break-words text-po-dim`,children:e.detail}),C(`ul`,{className:`flex flex-col gap-1 text-sm text-po-dim`,children:e.members.map((e,t)=>T(`li`,{className:`flex flex-wrap gap-x-2`,children:[C(`span`,{children:e.timestamp}),C(`span`,{children:e.level}),T(`span`,{children:[e.occurrenceCount,`×`]}),C(`span`,{className:`min-w-0 truncate`,children:e.message})]},`${e.timestamp}-${String(t)}`))})]}):null]})}function xe({view:e,tools:t,summaryCount:n}){let r=ve(e.samples),i=r[0]?.occurrences??0,a=new Map(t.map(e=>[e.name,e.calls]));return T(`div`,{className:`flex flex-col gap-3`,children:[n!==void 0&&n!==e.totalIssues?T(`p`,{className:`rounded-md border border-po-edge-yellow bg-po-tint-yellow p-3 text-sm leading-relaxed text-po-yellow`,role:`status`,"data-testid":`metrics-issue-count-mismatch`,children:[`The summary reports `,n,` `,n===1?`issue`:`issues`,`; incident analysis returned`,` `,e.totalIssues,`. The counts differ, so these details should not be treated as a complete explanation of the summary.`]}):null,T(`span`,{className:`text-sm text-po-dim`,children:[C(`span`,{className:`text-po-hi`,children:e.totalIssues}),` occurrences of`,` `,C(`span`,{className:`text-po-hi`,children:r.length}),` distinct problems in the returned samples, most frequent first`]}),r.length===0?C(`p`,{className:`rounded-md border border-dashed border-po-border p-4 text-sm text-po-dim`,children:e.totalIssues===0?`No issues were detected in the returned analysis. This does not establish coverage of unrecorded activity.`:`The analysis counted issues but returned no incident samples.`}):C(`ul`,{className:`flex flex-col gap-2`,"data-testid":`metrics-issue-groups`,children:r.map(e=>C(be,{group:e,max:i,tools:t},e.key))}),Object.keys(e.byTool).length===0?null:T(`div`,{className:`flex flex-col gap-2 overflow-x-auto`,children:[C(`h4`,{className:`text-base font-semibold text-po-hi`,children:`Failures by tool`}),T(`table`,{className:`w-full text-sm`,"data-testid":`metrics-issues-tools`,children:[C(`thead`,{children:T(`tr`,{className:`text-sm text-po-dim`,children:[C(`th`,{scope:`col`,className:`py-2 text-left font-normal`,children:`Tool`}),C(`th`,{scope:`col`,className:`text-right font-normal`,children:`Failures`}),C(`th`,{scope:`col`,className:`text-right font-normal`,children:`Attribution context`})]})}),C(`tbody`,{children:V(e.byTool).map(([e,t])=>{let n=a.get(e);return T(`tr`,{className:`border-b border-po-border/40`,children:[C(`td`,{className:`min-w-0 break-all py-2 text-po-dim`,children:e}),C(`td`,{className:`w-16 py-2 text-right text-po-red`,children:t}),C(`td`,{className:`w-28 py-2 text-right text-po-dim`,children:n===void 0?`no token samples`:`${String(n)} token samples`})]},e)})})]})]}),T(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-sm text-po-dim`,children:[C(`span`,{className:`text-sm font-semibold text-po-dim`,children:`by category`}),V(e.byCategory).map(([e,t])=>T(`span`,{children:[e,` `,C(`span`,{className:`text-po-hi`,children:t})]},e))]})]})}function Se({tools:e,focus:t,count:n,startTime:r,endTime:i,broaderScope:a=!1}){let[o,s]=y(),[c,u]=y(``),[d,f]=y(!1),[p,m]=y(!1),h=b(void 0),g=_();return E(()=>(h.current?.abort(),s(void 0),u(``),f(!1),m(!1),()=>h.current?.abort()),[t,r,i]),T(`section`,{className:`flex min-w-0 flex-col gap-3 rounded-lg border border-po-border bg-po-panel p-4`,"data-testid":`metrics-issues`,children:[T(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[T(`div`,{children:[T(`h3`,{className:`text-lg font-semibold text-po-hi`,children:[`Issues to investigate`,n===void 0?``:` · ${n} ${n===1?`issue`:`issues`}`]}),C(`p`,{className:`mt-1 text-sm text-po-dim`,children:`Inspect recurring failures and the evidence behind them.`})]}),T(`div`,{className:`flex items-center gap-2`,children:[d?C(l,{label:`Reading issue details`}):null,C(O,{variant:`outline`,size:`md`,disabled:d,onClick:()=>{h.current?.abort();let e=new AbortController;h.current=e,m(!0),f(!0),u(``),s(void 0),pe(t,e.signal,{startTime:r,endTime:i}).then(t=>{e.signal.aborted||(f(!1),`error`in t?u(t.error||`Issue details could not be loaded.`):se(t.issues)?u(t.issues.detail):s(t.issues))}).catch(t=>{e.signal.aborted||(f(!1),u(t instanceof Error?t.message:`Issue details could not be loaded.`))})},"aria-expanded":p,"aria-controls":g,"data-testid":p?`metrics-issues-reload`:`metrics-issues-open`,children:p?`Reload details`:`Inspect issues`}),p?C(O,{variant:`ghost`,size:`md`,onClick:()=>{h.current?.abort(),f(!1),m(!1)},"aria-controls":g,children:`Hide`}):null]})]}),T(`p`,{className:`text-sm leading-relaxed text-po-dim`,children:[`Details are loaded on demand.`,` `,r===void 0?i===void 0?`This hub did not report a time window; details cover all available history.`:`Details cover available history up to report time; no start bound was supplied.`:`Details use the report’s recorded time window.`,` `,a?`LogSink cannot filter issue details by model, provider or agent, so this analysis covers all groups in that window.`:t===void 0?`Analysis covers all groups.`:`Filtered to this session.`]}),T(`div`,{id:g,hidden:!p,"aria-busy":d,children:[c===``?null:C(`p`,{role:`alert`,className:`rounded-md border border-po-edge-yellow bg-po-tint-yellow p-3 text-sm text-po-yellow`,"data-testid":`metrics-issues-message`,children:c}),d?C(`p`,{role:`status`,className:`py-3 text-sm text-po-dim`,children:`Reading recorded incidents...`}):null,o===void 0?null:C(xe,{view:o,tools:a?[]:e,summaryCount:a?void 0:n})]})]})}function Ce({totals:e}){let t=[{label:`Total tokens`,value:e.totalTokens,detail:`Provider-reported total`,color:`text-po-blue`},{label:`Input tokens`,value:e.inputTokens,detail:`Reported input counter`,color:`text-po-hi`},{label:`Output tokens`,value:e.outputTokens,detail:`Reported output counter`,color:`text-po-hi`},{label:`Recorded issues`,value:e.issueCount,detail:`Detected in this selection`,color:e.issueCount>0?`text-po-yellow`:`text-po-hi`}];return C(`dl`,{className:`grid grid-cols-2 gap-3 @3xl:grid-cols-4`,"data-testid":`metrics-summary`,children:t.map(e=>T(`div`,{className:`min-w-0 rounded-lg border border-po-border bg-po-panel p-4`,children:[C(`dt`,{className:`text-sm text-po-dim`,children:e.label}),C(`dd`,{className:`mt-2 text-lg font-semibold tabular-nums ${e.color}`,title:Number.isFinite(e.value)?e.value.toLocaleString(`en-US`):`Not reported`,children:I(e.value)}),C(`dd`,{className:`mt-1 text-sm text-po-dim`,children:e.detail})]},e.label))})}function we({tools:e}){let[t,n]=y(`p90TotalTokens`),r=[...e].sort((e,n)=>n[t]-e[t]||e.name.localeCompare(n.name));return T(`section`,{className:`flex min-w-0 flex-col gap-4 rounded-lg border border-po-border bg-po-panel p-4`,"aria-label":`Tool token samples`,children:[T(`div`,{children:[C(`h3`,{className:`text-lg font-semibold text-po-hi`,children:`Tool token samples`}),C(`p`,{className:`mt-1 text-sm text-po-dim`,children:`Which tools participate in token-heavy turns?`})]}),r.length===0?T(`div`,{className:`flex flex-1 flex-col justify-center gap-2 rounded-md border border-dashed border-po-border p-5`,"data-testid":`metrics-tools-empty`,children:[C(`p`,{className:`text-base font-semibold text-po-hi`,children:`No token-attributed tool calls`}),C(`p`,{className:`text-sm leading-relaxed text-po-dim`,children:`Tool execution logs may exist, but this selection has no samples that connect tools to model usage. This does not mean no tools ran.`})]}):T(m,{children:[T(`div`,{className:`flex flex-wrap gap-1`,role:`group`,"aria-label":`Rank tool samples by`,children:[C(O,{size:`sm`,variant:t===`p90TotalTokens`?`primary`:`ghost`,"aria-pressed":t===`p90TotalTokens`,onClick:()=>n(`p90TotalTokens`),children:`P90 turn tokens`}),C(O,{size:`sm`,variant:t===`calls`?`primary`:`ghost`,"aria-pressed":t===`calls`,onClick:()=>n(`calls`),children:`Sampled calls`})]}),C(`div`,{className:`overflow-x-auto`,children:T(`table`,{className:`w-full text-base tabular-nums`,"data-testid":`metrics-tools`,children:[T(`caption`,{className:`sr-only`,children:[`Tools ranked by `,t===`calls`?`sampled calls`:`90th percentile whole-turn tokens`]}),C(`thead`,{children:T(`tr`,{className:`border-b border-po-border text-sm text-po-dim`,children:[C(`th`,{scope:`col`,className:`pb-2 text-left font-normal`,children:`Tool`}),C(`th`,{scope:`col`,className:`pb-2 pl-3 text-right font-normal`,children:`Sampled calls`}),C(`th`,{scope:`col`,className:`pb-2 pl-3 text-right font-normal`,children:`P90 turn tokens`})]})}),C(`tbody`,{children:r.map(e=>T(`tr`,{className:`border-b border-po-border/40`,children:[C(`th`,{scope:`row`,className:`max-w-48 break-all py-3 text-left font-normal text-po-hi`,children:e.name}),C(`td`,{className:`py-3 pl-3 text-right text-po-dim`,children:I(e.calls)}),C(`td`,{className:`py-3 pl-3 text-right text-po-blue`,title:String(e.p90TotalTokens),children:I(e.p90TotalTokens)})]},e.name))})]})})]}),T(`details`,{className:`text-sm leading-relaxed text-po-dim`,children:[C(`summary`,{className:`cursor-pointer rounded-sm focus-visible:outline focus-visible:outline-1 focus-visible:outline-po-blue`,children:`How these samples are counted`}),C(`p`,{className:`mt-2`,children:`This view includes only calls with recorded token attribution; external MCP calls remain in the logs. P90 is the 90th percentile of the whole turn, not each tool's own consumption. Several tools may share a turn, so do not add these values together.`})]})]})}var H={session:`session`,agent:`agent`,model:`model`,provider:`provider`},U={session:`Session ids are hashed before export. Select a row to filter usage, not to open a session.`};function Te({report:e,onFocus:t,onPeriodChange:n}){let r=H[e.dimension],i=e.groups.filter(e=>e.key===`unknown`||e.key===``).reduce((e,t)=>e+t.totalTokens,0),a=[{name:`Cache reads`,value:e.totals.cachedTokens},{name:`Reasoning tokens`,value:e.totals.reasoningTokens},{name:`Usage events`,value:e.totals.usageEventCount},{name:`Log and span records`,value:e.totals.totalRecords}],o=new Date(e.generatedAt);return T(`div`,{className:`@container flex w-full min-w-0 flex-col gap-4`,"data-testid":`metrics-report`,children:[C(Ce,{totals:e.totals}),T(`div`,{className:`grid min-w-0 grid-cols-1 gap-4 @3xl:grid-cols-3`,children:[T(`section`,{className:`flex min-w-0 flex-col gap-4 rounded-lg border border-po-border bg-po-panel p-4 @3xl:col-span-2`,"aria-label":`Usage over time`,children:[T(`div`,{children:[C(`h3`,{className:`text-lg font-semibold text-po-hi`,children:`Usage over time`}),C(`p`,{className:`mt-1 text-sm text-po-dim`,children:`Recorded tokens, not estimated spend.`})]}),C(ge,{buckets:e.timeline,bucketUnit:e.bucketUnit,onShorterPeriod:e.period===`day`||n===void 0?void 0:()=>n(`day`)})]}),T(`section`,{className:`flex min-w-0 flex-col gap-4 rounded-lg border border-po-border bg-po-panel p-4`,"aria-label":`Reported counters`,children:[C(`h3`,{className:`text-lg font-semibold text-po-hi`,children:`Reported counters`}),C(`dl`,{className:`flex flex-col gap-3`,children:a.map(e=>T(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1 border-b border-po-border/40 pb-3`,children:[C(`dt`,{className:`text-sm text-po-dim`,children:e.name}),C(`dd`,{className:`text-base font-semibold tabular-nums text-po-hi`,title:e.value===void 0?`Not reported`:String(e.value),children:I(e.value??NaN)})]},e.name))}),C(`p`,{className:`text-sm leading-relaxed text-po-dim`,children:`Monetary cost is not included in this metrics report.`}),T(`details`,{className:`text-sm leading-relaxed text-po-dim`,children:[C(`summary`,{className:`cursor-pointer rounded-sm focus-visible:outline focus-visible:outline-1 focus-visible:outline-po-blue`,children:`Why the counters may not add up`}),C(`p`,{className:`mt-2`,children:`The total is reported by providers. Input, output, cache reads and reasoning are independent counters and may overlap or be incomplete. They are not a breakdown and may not sum to the total. A gap is not evidence of cache traffic. Missing fields say Not reported; a recorded zero stays zero.`})]})]})]}),T(`div`,{className:`grid min-w-0 grid-cols-1 items-start gap-4 @3xl:grid-cols-2`,children:[T(`section`,{className:`flex min-w-0 flex-col gap-3 rounded-lg border border-po-border bg-po-panel p-4`,"aria-label":`Tokens by ${r}`,children:[T(`div`,{children:[T(`h3`,{className:`text-lg font-semibold text-po-hi`,children:[`Tokens by `,r]}),C(`p`,{className:`mt-1 text-sm text-po-dim`,children:`Largest recorded consumers. Select a named row to filter.`})]}),i>0?T(`div`,{className:`rounded-md border border-po-edge-yellow bg-po-tint-yellow p-3`,"data-testid":`metrics-attribution-notice`,children:[T(`p`,{className:`text-sm font-semibold text-po-yellow`,children:[r.charAt(0).toUpperCase()+r.slice(1),` attribution missing`]}),T(`p`,{className:`mt-1 text-sm leading-relaxed text-po-dim`,children:[I(i),` tokens have no `,r,` recorded. They are included in the total, but cannot be assigned to a named `,r,`.`]})]}):null,U[e.dimension]===void 0?null:C(`p`,{className:`text-sm leading-relaxed text-po-dim`,children:U[e.dimension]}),C(me,{groups:e.groups,totalTokens:e.totals.totalTokens,focus:e.focus,onFocus:t},`${e.dimension}:${e.focus??``}`),T(`p`,{className:`text-sm text-po-dim`,children:[`Showing `,e.groups.length,` of `,I(e.totals.groupCount),` `,r,` groups. Bars show share of the reported total.`]}),e.totals.failedGroups>0?T(`p`,{className:`text-sm text-po-yellow`,children:[e.totals.failedGroups,` of `,e.totals.groupCount,` `,r,`s failed`]}):null]}),C(we,{tools:e.tools})]}),C(Se,{tools:e.tools,focus:e.dimension===`session`?e.focus:void 0,count:e.totals.issueCount,startTime:e.startTime,endTime:e.endTime,broaderScope:e.focus!==void 0&&e.dimension!==`session`},`${e.generatedAt}:${e.dimension}:${e.focus??``}`),T(`footer`,{className:`flex flex-wrap justify-between gap-2 border-t border-po-border pt-3 text-sm text-po-dim`,"data-testid":`metrics-provenance`,children:[T(`span`,{children:[`Source: LogSink ·`,` `,e.transport===`http`?`HTTP`:e.transport===`worker`?`database worker`:`transport not reported`]}),T(`span`,{title:e.generatedAt,children:[`Report generated `,Number.isNaN(o.getTime())?e.generatedAt:o.toLocaleString()]})]})]})}var Ee={"no-sink":`no log sink`,"no-data":`nothing recorded yet`,"no-api":`metrics not installed`,"query-error":`metrics could not be loaded`};function De({response:t}){return C(e,{title:Ee[t.unavailable],description:t.detail,"data-testid":`metrics-empty`})}function Oe({requested:e,applied:t,dimension:n,onClear:r}){return e===``?null:t===void 0?T(`span`,{className:`rounded-md border border-po-edge-yellow bg-po-tint-yellow p-3 text-sm text-po-yellow`,"data-testid":`metrics-focus-refused`,children:[`this log sink does not support narrowing by `,H[n],`, so the numbers below are still everything`,C(O,{variant:`ghost`,size:`md`,className:`ml-2`,onClick:r,children:`clear`})]}):T(`span`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-po-border bg-po-panel p-3 text-sm text-po-dim`,"data-testid":`metrics-focus`,children:[`narrowed to `,C(`span`,{className:`min-w-0 break-all text-po-hi`,children:t}),C(O,{variant:`ghost`,size:`md`,className:`ml-2`,onClick:r,children:`clear`})]})}function ke(){return T(`div`,{className:`flex flex-col gap-4`,role:`status`,"aria-live":`polite`,"data-testid":`metrics-loading`,children:[C(`span`,{className:`text-sm text-po-dim`,children:`Loading recorded metrics...`}),C(`div`,{"aria-hidden":`true`,className:`grid grid-cols-2 gap-3 @3xl:grid-cols-4`,children:[0,1,2,3].map(e=>C(`div`,{className:`h-24 animate-pulse rounded-lg border border-po-border bg-po-panel motion-reduce:animate-none`},e))}),C(`div`,{"aria-hidden":`true`,className:`h-48 animate-pulse rounded-lg border border-po-border bg-po-panel motion-reduce:animate-none`})]})}var Ae={day:`Past day`,week:`Past week`,month:`Past month`,all:`All history`};function je(e){let[t,n]=y(`model`),[r,i]=y(`week`),[o,c]=y(``),[l,p]=y(0),[h,g]=y(),_=JSON.stringify([t,r,o,l]);E(()=>{let e=new AbortController;return fe(t,r,o,e.signal).then(t=>{e.signal.aborted||g({key:_,result:t})}).catch(t=>{e.signal.aborted||g({key:_,result:{error:t instanceof Error?t.message:`Metrics could not be loaded.`}})}),()=>e.abort()},[t,r,o,_]);let v=h?.key===_?h.result:void 0,b=v===void 0,x=v!==void 0&&`report`in v?v.report:void 0,S=x===void 0||A(x)?void 0:x,w=v!==void 0&&`error`in v?v.error:``;return T(`div`,{className:`@container flex w-full min-w-0 flex-col gap-4`,"data-testid":`metrics-panel`,"aria-busy":b,children:[T(`div`,{className:`flex min-w-0 flex-wrap items-end gap-3 rounded-lg border border-po-border bg-po-panel p-3`,children:[T(`div`,{className:`flex flex-col gap-2`,children:[C(`span`,{className:`text-base font-medium text-po-text`,children:`Group by`}),T(a,{value:t,onValueChange:e=>{c(``),n(e)},children:[C(f,{"aria-label":`Group metrics by`,"data-testid":`metrics-dimension`,className:`w-40 `,children:C(s,{})}),C(d,{children:ae.map(e=>C(u,{value:e,children:H[e]},e))})]})]}),T(`div`,{className:`flex flex-col gap-2`,children:[C(`span`,{className:`text-base font-medium text-po-text`,children:`Period`}),T(a,{value:r,onValueChange:e=>i(e),children:[C(f,{"aria-label":`Metrics period`,"data-testid":`metrics-period`,className:`w-40 `,children:C(s,{})}),C(d,{children:oe.map(e=>C(u,{value:e,children:Ae[e]},e))})]})]}),C(O,{variant:`outline`,size:`md`,className:`ml-auto`,onClick:()=>p(e=>e+1),disabled:b,"data-testid":`metrics-refresh`,children:b?`Loading...`:`Refresh`})]}),b?C(ke,{}):null,w===``?null:T(`p`,{role:`alert`,className:`rounded-lg border border-po-edge-red bg-po-tint-red p-4 text-sm text-po-red`,"data-testid":`metrics-error`,children:[w,` Use Refresh to try again.`]}),x!==void 0&&A(x)?C(De,{response:x}):null,S===void 0?null:T(m,{children:[C(Oe,{requested:o,applied:S.focus,dimension:S.dimension,onClear:()=>c(``)}),C(Te,{report:S,onFocus:c,onPeriodChange:i})]})]})}var Me=x({label:`metrics`,detail:`recorded usage, token attribution and issues`,icon:ie,component:je});function Ne(e){return e.split(`
2
+ `).filter(Boolean)}var Pe=new Set([`tool_failure`,`infrastructure_failure`,`api_error`,`api_retries_exhausted`,`log_error`]),Fe=/[^.]*empty data[^.]*\.?/i,W=e=>typeof e==`object`&&!!e&&!Array.isArray(e),G=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0?e:void 0,K=e=>typeof e==`string`&&e.trim()!==``?e.trim():void 0;function Ie(e){return W(e)?Object.entries(e).flatMap(([e,t])=>{let n=G(t);return n!==void 0&&n>0&&e.trim()!==``?[{key:e,label:e.replaceAll(`_`,` `),count:n,failure:Pe.has(e)}]:[]}).sort((e,t)=>t.count-e.count):[]}function Le(e){return Array.isArray(e)?e.flatMap(e=>{if(!W(e))return[];let t=K(e.name);return t===void 0?[]:[{name:t,invocations:G(e.invocations),p90TurnTokens:G(e.p90TurnTokens)}]}):[]}function Re(e){let t;try{t=JSON.parse(e)}catch{return null}if(!W(t))return null;let n=W(t.usage)?t.usage:{},r={scope:K(t.scope),period:K(t.period),evidence:K(t.evidence),code:K(t.code),capturedRecords:G(t.capturedRecords),capturedIssues:G(t.capturedIssues),categories:Ie(t.issuesByCategory),inputTokens:G(n.inputTokens),outputTokens:G(n.outputTokens),tokenCoveragePercent:G(n.tokenCoveragePercent),tools:Le(t.tools),limitReached:typeof t.limitReached==`boolean`?t.limitReached:void 0,captureCompleteness:K(t.captureCompleteness),limitations:K(t.limitations)};return Object.values(r).some(e=>Array.isArray(e)?e.length>0:e!==void 0)?r:null}function q(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Math.round(e))}var J=e=>e.replaceAll(/[-_]/g,` `);function ze(e){let t=[e.scope,e.period].flatMap(e=>e?[J(e)]:[]).join(` · `),n=e.capturedIssues,r=e.evidence===`unavailable`?`Telemetry unavailable`:e.evidence===`empty`?`Nothing captured`:n===void 0?`Captured agent evidence`:n===0?`No issues`:`${String(n)} ${n===1?`issue`:`issues`}`;return t===``?{primary:r}:{primary:r,context:t}}function Be(e){let t=[];if(e.capturedRecords!==void 0&&t.push({label:`Records`,value:e.capturedRecords.toLocaleString(`en-US`),failure:!1}),e.capturedIssues!==void 0){let n=e.capturedIssues>0&&e.categories.some(e=>e.failure);t.push({label:`Issues`,value:e.capturedIssues.toLocaleString(`en-US`),failure:n})}if(e.inputTokens!==void 0||e.outputTokens!==void 0){let n=e=>e===void 0?`?`:q(e);t.push({label:`Tokens in / out`,value:`${n(e.inputTokens)} / ${n(e.outputTokens)}`,failure:!1})}return e.tokenCoveragePercent!==void 0&&t.push({label:`Token coverage`,value:`${String(e.tokenCoveragePercent)}%`,failure:!1}),t}function Ve(e){let t=[e.captureCompleteness?`Capture completeness: ${J(e.captureCompleteness)}.`:void 0,e.limitations].filter(e=>e!==void 0);return t.length>0?t.join(` `):void 0}function He(e){return e.limitations?.match(Fe)?.[0].trim()??`Empty data is not proof of a healthy run.`}var Y=`Captured agent evidence`;function Ue({toolName:e,output:n,running:i,isError:a}){let s=g({running:i,isError:a}),l=i||a?null:Re(n);if(l)return C(We,{toolName:e,tone:s,report:l});let u=Ne(n);if(a)return T(t,{tone:s,children:[C(c,{title:e,children:C(`span`,{className:`min-w-0 truncate text-po-faint`,children:Y})}),u.length>0?C(D,{children:C(`p`,{className:`whitespace-pre-wrap break-words text-po-red`,children:u.join(`
3
+ `)})}):null]});let d=u.map(e=>({text:e,tone:`text`}));return C(t,{tone:s,expandable:d.length>12,children:({expanded:t})=>{let n=ee(d,12,t);return T(m,{children:[C(c,{title:e,children:C(`span`,{className:`min-w-0 truncate text-po-faint`,children:Y})}),n.shown.length>0||i?T(D,{children:[C(o,{lines:n.shown}),n.hidden>0?T(r,{expands:!0,children:[n.hidden,` more lines`]}):null,i?C(r,{tone:`running`,children:`Reading session telemetry`}):null]}):null]})}})}function We({toolName:e,tone:n,report:r}){let a=ze(r),o=Be(r),s=Ve(r),l=r.evidence===`empty`,u=r.evidence===`unavailable`,d=He(r),f=l&&s===d?void 0:s,p=l||u?f!==void 0:r.categories.length>0||r.tools.length>0||s!==void 0;return C(t,{tone:u?`neutral`:n,expandable:p,children:({expanded:t})=>T(m,{children:[T(c,{title:e,children:[C(`span`,{className:`max-w-[60%] shrink-0 truncate text-po-text`,children:a.primary}),a.context?T(`span`,{className:`min-w-0 truncate text-po-faint`,children:[`· `,a.context]}):null]}),T(D,{className:`flex flex-col gap-4`,children:[u?T(`div`,{className:`flex flex-wrap items-center gap-2`,children:[C(`span`,{className:`text-po-dim`,children:`The session's telemetry could not be read.`}),r.code?C(i,{size:`xs`,className:`font-mono`,children:r.code}):null]}):l?T(`div`,{className:`flex flex-col gap-1`,children:[C(`p`,{className:`text-po-text`,children:`No records were captured in this window.`}),C(`p`,{className:`text-sm text-po-dim`,children:d})]}):o.length>0?C(`dl`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:o.map(e=>T(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[C(`dt`,{className:`truncate text-sm text-po-dim`,children:e.label}),C(`dd`,{className:e.failure?`truncate text-lg font-semibold tabular-nums text-po-red`:`truncate text-lg font-semibold tabular-nums text-po-hi`,children:e.value})]},e.label))}):null,t&&!l&&!u&&r.categories.length>0?T(`section`,{className:`flex flex-col gap-2`,children:[C(w,{children:`Issues by category`}),C(`div`,{className:`flex flex-wrap gap-2`,children:r.categories.map(e=>T(re,{tone:e.failure?`red`:`neutral`,children:[C(`span`,{children:e.label}),C(`span`,{className:`font-semibold tabular-nums`,children:e.count})]},e.key))})]}):null,t&&!l&&!u&&r.tools.length>0?T(`section`,{className:`flex flex-col gap-2`,children:[C(w,{children:`Tools`}),T(`table`,{className:`w-full text-base`,children:[C(`thead`,{children:T(`tr`,{className:`text-sm text-po-dim`,children:[C(`th`,{className:`w-full pb-1 text-left font-normal`,children:`Name`}),C(`th`,{className:`whitespace-nowrap pb-1 pl-4 text-right font-normal`,children:`Calls`}),C(`th`,{className:`whitespace-nowrap pb-1 pl-4 text-right font-normal`,children:`p90 turn tokens`})]})}),C(`tbody`,{children:r.tools.map(e=>T(`tr`,{className:`border-t border-po-border-soft`,children:[C(`td`,{className:`max-w-0 truncate py-1 font-mono text-po-text`,children:e.name}),C(`td`,{className:`whitespace-nowrap py-1 pl-4 text-right tabular-nums text-po-text`,children:e.invocations===void 0?`?`:e.invocations.toLocaleString(`en-US`)}),C(`td`,{className:`whitespace-nowrap py-1 pl-4 text-right tabular-nums text-po-text`,children:e.p90TurnTokens===void 0?`?`:q(e.p90TurnTokens)})]},e.name))})]}),r.limitReached?T(`p`,{className:`text-sm text-po-dim`,children:[`Showing the first `,r.tools.length,` tools.`]}):null]}):null,t&&f?C(`p`,{className:`text-sm text-po-faint`,children:f}):null]})]})})}var Ge=p({tools:[`diagnose_agent`],message:Ue}),Ke=[`logsink_status`,`logsink_search`,`logsink_agent_issues`,`logsink_trace`,`logsink_stats`,`logsink_services`,`logsink_metrics`];function X(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function Z(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function qe(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=100}function Q(e){return typeof e==`string`&&/^\d{4}-\d{2}-\d{2}T/.test(e)&&Number.isFinite(Date.parse(e))}function Je(e){let t=X(e);if(!(!t||t.kind!==`session`&&t.kind!==`history`)&&(t.sessionId===void 0||typeof t.sessionId==`string`)&&(t.startTime===void 0||Q(t.startTime))&&(t.endTime===void 0||Q(t.endTime))&&(t.kind!==`history`||Q(t.startTime)&&Q(t.endTime))&&!(Q(t.startTime)&&Q(t.endTime)&&Date.parse(t.startTime)>Date.parse(t.endTime)))return[t.kind===`session`?`This session`:`History`,t.startTime,t.endTime,t.kind===`history`?t.sessionId:void 0].filter(Boolean).join(` · `)}function Ye(e){return Ke.some(t=>t===e)}function Xe({toolName:e,args:t,result:n,output:r,running:i,isError:a}){let o=n?.details;if(o==null)try{o=JSON.parse(r)}catch{o=void 0}let s=X(o),c=Je(s?.scope),l=t.scope===`history`?[`Requested history`,t.startTime,t.endTime,t.sessionId].filter(e=>typeof e==`string`).join(` · `):`This session`,u=o===void 0?r:JSON.stringify(o,null,2),d={scope:c??l,evidence:u};if(i)return{...d,scope:l,state:`running`,heading:`Reading captured agent evidence`,note:`Only retained records are inspected.`};if(a)return{...d,state:`query-error`,heading:`Log query could not be completed.`,note:`No collector changes were made.`};let f={...d,state:`unavailable`,heading:`Log summary is unavailable.`,note:`Inspect the retained evidence for details.`},p=X(s?.data);if(!c||!p)return f;let m={...d,state:`populated`,heading:``},h={...d,state:`empty`,heading:`No captured records in this window.`,note:`This does not establish that the run was healthy.`};switch(e){case`logsink_status`:return p.available===!1&&p.reason===`missing-database`?{...d,state:`missing`,heading:`No retained log database is available.`,note:`No collector changes were made.`}:p.available===!0?{...m,heading:`Retained log database is available.`,note:`This does not establish that the collector is capturing now.`}:f;case`logsink_search`:return!Z(p.count)||!Z(p.total)||typeof p.truncated!=`boolean`||!Array.isArray(p.results)?f:{...p.total===0?h:m,heading:p.total===0?h.heading:`Captured log records`,summary:`${p.count} returned · ${p.total} records`,note:p.truncated?`Results are truncated.`:p.total===0?h.note:void 0};case`logsink_agent_issues`:{if(!Z(p.matchingLogs)||!Z(p.uniqueIncidents)||!Z(p.scanned)||!qe(p.coveragePercent)||typeof p.truncated!=`boolean`||!Array.isArray(p.issues))return f;let e=X(p.byTool);return!e||!Object.values(e).every(Z)?f:{...p.matchingLogs===0?h:m,heading:p.matchingLogs===0?`No captured agent issues in this window.`:`Captured agent issues`,summary:`${p.matchingLogs} records · ${p.uniqueIncidents} incidents`,coverage:`Coverage ${p.coveragePercent}% · ${p.scanned} scanned${p.truncated?` · Scan truncated`:``}`,tools:Object.entries(e).map(([e,t])=>({name:e,count:t})),note:p.matchingLogs===0?h.note:`Repeated events may describe one incident.`}}case`logsink_trace`:return!Z(p.count)||typeof p.truncated!=`boolean`||!Array.isArray(p.timeline)?f:{...p.count===0?h:m,heading:p.count===0?h.heading:`Captured trace timeline`,summary:`${p.count} entries`,note:p.truncated?`Timeline is truncated.`:p.count===0?h.note:void 0};case`logsink_stats`:return!Z(p.totalEntries)||!Array.isArray(p.statistics)||!p.statistics.every(e=>{let t=X(e);return Z(t?.count)&&typeof t?.service==`string`&&typeof t?.level==`string`})?f:{...p.totalEntries===0?h:m,heading:p.totalEntries===0?h.heading:`Retained entry statistics`,summary:`${p.totalEntries} entries · ${p.statistics.length} group${p.statistics.length===1?``:`s`}`,tools:p.statistics.map(e=>{let t=e;return{name:[t.service,t.level].filter(Boolean).join(` · `),count:t.count}})};case`logsink_services`:return!Z(p.count)||typeof p.truncated!=`boolean`||!Array.isArray(p.services)||!p.services.every(e=>typeof e==`string`)?f:{...p.count===0?h:m,heading:p.count===0?h.heading:`Services with retained records`,summary:`${p.count} service${p.count===1?``:`s`}`,note:p.truncated?`Service list is truncated.`:p.count===0?h.note:void 0};case`logsink_metrics`:{let e=X(p.totals);return!e||!Z(e.totalRecords)||!Z(e.totalTokens)||!Z(e.issueCount)||!qe(e.tokenCoveragePercent)?f:{...e.totalRecords===0?h:m,heading:e.totalRecords===0?h.heading:`Captured usage and issues`,summary:`${e.totalRecords} records · ${e.totalTokens} tokens · ${e.issueCount} issues`,coverage:`Token coverage ${e.tokenCoveragePercent}%`,note:`${e.totalRecords===0?`${h.note} `:``}Tool turn costs are not exclusive per-tool token shares.`}}default:return f}}function Ze({toolName:e,running:n,isError:i,fixture:a,defaultExpanded:s=!1}){let l=a.state===`missing`,u=a.state===`unavailable`,d=a.evidence.split(`
4
+ `).map(e=>({text:e,tone:`text`}));return C(t,{tone:l||u?`neutral`:g({running:n,isError:i}),expandable:a.evidence.length>0,defaultExpanded:s,children:({expanded:t})=>T(m,{children:[C(c,{title:e,badge:i?`Query failed`:l?`No data`:void 0,children:C(`span`,{className:`truncate text-po-dim max-sm:hidden`,children:a.scope})}),T(D,{className:`flex flex-col gap-3`,children:[C(`p`,{className:`break-words text-sm text-po-dim sm:hidden`,children:a.scope}),T(`div`,{className:`flex flex-col gap-1`,children:[C(`p`,{className:`text-base font-semibold text-po-hi`,children:a.heading}),a.summary?C(`p`,{className:`text-base text-po-text`,children:a.summary}):null,a.coverage?C(`p`,{className:`text-sm text-po-dim`,children:a.coverage}):null]}),a.tools?C(`div`,{className:`flex flex-col gap-2 border-t border-po-border-soft pt-3`,children:a.tools.map(e=>T(`p`,{className:`flex flex-wrap items-center gap-4 text-base`,children:[C(`span`,{className:`font-mono text-po-text`,children:e.name}),T(`span`,{className:`text-po-dim`,children:[e.count,` occurrences`]})]},e.name))}):null,a.note?C(`p`,{className:`text-sm text-po-dim`,children:a.note}):null,n?C(r,{tone:`running`,children:`Reading telemetry`}):null,a.evidence?T(`div`,{className:`flex flex-col gap-3 border-t border-po-border-soft pt-3`,children:[C(r,{expands:!0,glyph:t?`⌄`:`›`,className:`text-sm text-po-dim`,children:t?`Hide evidence`:`Show evidence`}),t?C(o,{lines:d}):null]}):null]})]})})}function Qe(e){return C(Ze,{...e,fixture:Xe(e)})}var $e=p({tools:[`logsink_status`,`logsink_search`,`logsink_agent_issues`,`logsink_trace`,`logsink_stats`,`logsink_services`,`logsink_metrics`],matches:Ye,message:Qe}),$=(e,t)=>t===void 0?void 0:{...e,...t},et=h({id:`log`,global:{get settingsPanels(){return[$({id:`metrics`},Me)]}},session:{get toolRenderers(){return[$({tools:[`diagnose_agent`]},Ge),$({tools:[`logsink`]},$e)]}}});export{et as webPlugin};