@agimon-ai/po-cloudflare 0.0.2-alpha.2 → 0.0.2-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/README.md +4 -3
  2. package/dist/abort-signals-2GUraIGq.js +34 -0
  3. package/dist/agent-DZ-OKOHn.js +6850 -0
  4. package/dist/anthropic-messages-5ODquUB-.js +14317 -0
  5. package/dist/{apiContracts-CHOiCbS_.js → apiContracts-b33nSAAI.js} +18 -81
  6. package/dist/{approval-BMXqnTYd.js → approval-r3NnI1VC.js} +19 -3
  7. package/dist/{approvalPrompt-Bg1JrEEY.js → approvalPrompt-DWoXxu3S.js} +2 -2
  8. package/dist/artifactFiles-DLCReI0-.js +1 -0
  9. package/dist/assets/assets/{CodeEditorView-BnyZHaYM.js → CodeEditorView-XeNS0L9M.js} +2 -2
  10. package/dist/assets/assets/{abnfDiagram-WEYOIA3C-muME0eCj.js → abnfDiagram-WEYOIA3C-B6ZW0nkR.js} +2 -2
  11. package/dist/assets/assets/{architecture-WOLXFQ4H-DMnhK1WH.js → architecture-WOLXFQ4H-bVR64sHO.js} +1 -1
  12. package/dist/assets/assets/{architectureDiagram-ZHVYKT53-DKn7XGP7.js → architectureDiagram-ZHVYKT53-D7tZz3io.js} +2 -2
  13. package/dist/assets/assets/{blockDiagram-RJAE7QA3-DtDctXZg.js → blockDiagram-RJAE7QA3-DdwScfiX.js} +2 -2
  14. package/dist/assets/assets/{c4Diagram-XDPPPE54-23pGLJeP.js → c4Diagram-XDPPPE54-DgSxZJCV.js} +2 -2
  15. package/dist/assets/assets/channel-TPcVvp_3.js +2 -0
  16. package/dist/assets/assets/{chunk-2E7WHVMD-BZ2nGNPa.js → chunk-2E7WHVMD-D5TXC2SM.js} +2 -2
  17. package/dist/assets/assets/{chunk-4EMNKR2T-Dui1SYFi.js → chunk-4EMNKR2T-BWhOSvo1.js} +2 -2
  18. package/dist/assets/assets/{chunk-55XCU76K-CUB92Evl.js → chunk-55XCU76K-HkkBzLtZ.js} +2 -2
  19. package/dist/assets/assets/{chunk-7S6XSTFO-CVayPHfE.js → chunk-7S6XSTFO-CBnjycLU.js} +2 -2
  20. package/dist/assets/assets/{chunk-AQDTSKZB---wakYqY.js → chunk-AQDTSKZB-75lIIq8T.js} +2 -2
  21. package/dist/assets/assets/{chunk-DSNLSHJZ-DfbdohUR.js → chunk-DSNLSHJZ-D8PpnXMk.js} +2 -2
  22. package/dist/assets/assets/{chunk-HAGFOTED-Dr4KRh-b.js → chunk-HAGFOTED-CXRS2NIN.js} +2 -2
  23. package/dist/assets/assets/{chunk-HNE4Q36P-D06cR91Z.js → chunk-HNE4Q36P-BocUqS94.js} +2 -2
  24. package/dist/assets/assets/{chunk-NQOKRVIF-Ca4gLeDb.js → chunk-NQOKRVIF-CHf_ogYT.js} +2 -2
  25. package/dist/assets/assets/{chunk-UHW7PFBP-DmL638jN.js → chunk-UHW7PFBP-DrW1PaIv.js} +2 -2
  26. package/dist/assets/assets/{chunk-VQ5W62QI-pkxSW5Zj.js → chunk-VQ5W62QI-CLoA7bFm.js} +2 -2
  27. package/dist/assets/assets/{chunk-WQQL4CDK-Dcc8hV4U.js → chunk-WQQL4CDK-BmBsrj9I.js} +2 -2
  28. package/dist/assets/assets/chunk-XXDRQBXY-iFE4Tl8c.js +2 -0
  29. package/dist/assets/assets/{chunk-YZO67HFG-B_HKcFrw.js → chunk-YZO67HFG-DShE_cgv.js} +2 -2
  30. package/dist/assets/assets/{chunk-ZAUX2LTX-DAzZUysS.js → chunk-ZAUX2LTX-B3oLvSXy.js} +2 -2
  31. package/dist/assets/assets/{chunk-ZCHMQSOR-DAVgjymL.js → chunk-ZCHMQSOR-B14vKK7C.js} +2 -2
  32. package/dist/assets/assets/{classDiagram-v2-4MYWR3UA-Fsw8TGPu.js → classDiagram-v2-4MYWR3UA-Da8elIW2.js} +2 -2
  33. package/dist/assets/assets/{cose-bilkent-JH36ORCC-CgUbISYV.js → cose-bilkent-JH36ORCC-Du4tGtiJ.js} +2 -2
  34. package/dist/assets/assets/{cynefin-EF2NZ3EQ-D1LxAU2x.js → cynefin-EF2NZ3EQ-Cyj6i_WI.js} +1 -1
  35. package/dist/assets/assets/{cynefinDiagram-WF24UDRP-D54I1jil.js → cynefinDiagram-WF24UDRP-DFWXwO7A.js} +2 -2
  36. package/dist/assets/assets/{dagre-NK4GIZVX-DC7zL16U.js → dagre-NK4GIZVX-C1wB_cf-.js} +2 -2
  37. package/dist/assets/assets/{diagram-CBK3MWTC-DB0ptUdz.js → diagram-CBK3MWTC-MYCOBYl6.js} +2 -2
  38. package/dist/assets/assets/{diagram-I5XIIV2D-CozSftPJ.js → diagram-I5XIIV2D-BFYbKUFf.js} +2 -2
  39. package/dist/assets/assets/{diagram-ODIL2UCW-g3WOEWDS.js → diagram-ODIL2UCW-6siqTpv_.js} +2 -2
  40. package/dist/assets/assets/{diagram-PFBEJUXE-CFxGeOYi.js → diagram-PFBEJUXE-CaBr9CoB.js} +2 -2
  41. package/dist/assets/assets/{diagram-RJA3I4VV-BQBsLche.js → diagram-RJA3I4VV-DAvmuDpc.js} +2 -2
  42. package/dist/assets/assets/{diagram-TYUNFSNR-DrjpW2yq.js → diagram-TYUNFSNR-CJnhgCpo.js} +2 -2
  43. package/dist/assets/assets/{dist-DjL8d1jZ.js → dist-BQ4W1R18.js} +2 -2
  44. package/dist/assets/assets/{dist-DvgCCshF.js → dist-BnzFckPF.js} +2 -2
  45. package/dist/assets/assets/{dist-gfbb4ygy.js → dist-CFtBpcYL.js} +2 -2
  46. package/dist/assets/assets/{dist-BabjcJ3j.js → dist-CIQX1z4W.js} +2 -2
  47. package/dist/assets/assets/{dist-XIZum9n5.js → dist-ChHYoe9_.js} +2 -2
  48. package/dist/assets/assets/{dist-1-mhYUBH.js → dist-DKxZO8d9.js} +2 -2
  49. package/dist/assets/assets/{dist-h6SOnP8-.js → dist-DL6z28wl.js} +2 -2
  50. package/dist/assets/assets/{dist-B3JXhDWV.js → dist-DNyn1p9Z.js} +2 -2
  51. package/dist/assets/assets/{dist-Izr2SB3q.js → dist-qYlLXIa8.js} +2 -2
  52. package/dist/assets/assets/{ebnfDiagram-V4P3TTPT-BZS_aAve.js → ebnfDiagram-V4P3TTPT-AUcqDTM3.js} +2 -2
  53. package/dist/assets/assets/{elk-QONTBCTQ-B2ksVmMA.js → elk-QONTBCTQ-aA10PEHJ.js} +2 -2
  54. package/dist/assets/assets/{erDiagram-KYQIGQAA-7P6zF-Z-.js → erDiagram-KYQIGQAA-hhYiqA-x.js} +2 -2
  55. package/dist/assets/assets/{eventmodeling-K75KTNOO-RoGQoRq-.js → eventmodeling-K75KTNOO-BQZqbRo5.js} +1 -1
  56. package/dist/assets/assets/flowDiagram-IUGLLWBU-BuyysPYC.js +1 -0
  57. package/dist/assets/assets/{ganttDiagram-R7GPNTJY-CTOlRy7M.js → ganttDiagram-R7GPNTJY-CLON1GpW.js} +2 -2
  58. package/dist/assets/assets/{gitGraph-VSP46ZUC-CPqytIt0.js → gitGraph-VSP46ZUC-DbmvNwR2.js} +1 -1
  59. package/dist/assets/assets/{gitGraphDiagram-PDYL7XHY-BffLxuxg.js → gitGraphDiagram-PDYL7XHY-DJVO0WlL.js} +2 -2
  60. package/dist/assets/assets/index-BiTVAj5E.js +155 -0
  61. package/dist/assets/assets/index-CBNQEGK3.css +1 -0
  62. package/dist/assets/assets/{info-OHQRW6UA-BI8RK0Ow.js → info-OHQRW6UA-CAt3Nt3g.js} +1 -1
  63. package/dist/assets/assets/{infoDiagram-MVDRKAX5-DUIst1FB.js → infoDiagram-MVDRKAX5-DTuqH-Zb.js} +2 -2
  64. package/dist/assets/assets/{ishikawaDiagram-HPEHV2GE-CA17Eho5.js → ishikawaDiagram-HPEHV2GE-BnWvdonT.js} +2 -2
  65. package/dist/assets/assets/{journeyDiagram-BOSHW7O7-CNri5Ap9.js → journeyDiagram-BOSHW7O7-Btxtcgvl.js} +2 -2
  66. package/dist/assets/assets/{kanban-definition-FNSA4HC5-DnXna7jO.js → kanban-definition-FNSA4HC5-q7ek9o_H.js} +2 -2
  67. package/dist/assets/assets/{line-BsXJZn93.js → line-B7yLilmC.js} +2 -2
  68. package/dist/assets/assets/{linear-BHYaD5T0.js → linear-y8aSKEli.js} +2 -2
  69. package/dist/assets/assets/{mermaid-parser.core-B64Eo-8a.js → mermaid-parser.core-B4rH50nD.js} +4 -4
  70. package/dist/assets/assets/{mermaid.core-Zw9qmTzg.js → mermaid.core-DnRVHTjE.js} +5 -5
  71. package/dist/assets/assets/{mindmap-definition-6OY57UG3-E5qz4KNc.js → mindmap-definition-6OY57UG3-DT9Afs2v.js} +2 -2
  72. package/dist/assets/assets/{packet-JDAUHWVQ-DgfizTr3.js → packet-JDAUHWVQ-CnqNbu4p.js} +1 -1
  73. package/dist/assets/assets/{pegDiagram-ECIUJNBX-D0WK_agM.js → pegDiagram-ECIUJNBX-cvxdBBFq.js} +2 -2
  74. package/dist/assets/assets/{pie-XZMESJXO-PJR1sXD4.js → pie-XZMESJXO-etXMNsaL.js} +1 -1
  75. package/dist/assets/assets/{pieDiagram-GNMPY74T-CPuU-NTs.js → pieDiagram-GNMPY74T-CBN-R3_j.js} +2 -2
  76. package/dist/assets/assets/{quadrantDiagram-D57K4MC3-5C9yjM1b.js → quadrantDiagram-D57K4MC3-C5jjVPIH.js} +2 -2
  77. package/dist/assets/assets/{radar-ABXABTNO-BspdXgl0.js → radar-ABXABTNO-CAMd_mrV.js} +1 -1
  78. package/dist/assets/assets/{railroad-I3PHUGI6-Ct0a6hLD.js → railroad-I3PHUGI6-DIs3auoe.js} +1 -1
  79. package/dist/assets/assets/{railroad-abnf-LNEFI6M7-fduYB4SA.js → railroad-abnf-LNEFI6M7-CJXr1qWy.js} +1 -1
  80. package/dist/assets/assets/{railroad-ebnf-DWYD2UWJ-CTQa8Sww.js → railroad-ebnf-DWYD2UWJ-DfwtykqI.js} +1 -1
  81. package/dist/assets/assets/{railroad-peg-JR7BVNR7-DatoH3GJ.js → railroad-peg-JR7BVNR7-B8beAhTs.js} +1 -1
  82. package/dist/assets/assets/{railroadDiagram-Y72NRBL7-C8sWN8l2.js → railroadDiagram-Y72NRBL7-BDcQE-EL.js} +2 -2
  83. package/dist/assets/assets/{requirementDiagram-EQYSW5RA-CqRz4RcT.js → requirementDiagram-EQYSW5RA-KJ4-QjZM.js} +2 -2
  84. package/dist/assets/assets/{sankeyDiagram-SY24JHO5-bdiuKKlX.js → sankeyDiagram-SY24JHO5-VjIB-Ybr.js} +2 -2
  85. package/dist/assets/assets/{sequenceDiagram-BLEHNHQU-Zy-8I0Hy.js → sequenceDiagram-BLEHNHQU-MfMuWq1M.js} +2 -2
  86. package/dist/assets/assets/{src-gihY33R9.js → src-BAxIj8GJ.js} +2 -2
  87. package/dist/assets/assets/{stateDiagram-v2-A6IESKWZ-DXQERPvz.js → stateDiagram-v2-A6IESKWZ-mHwLRRCY.js} +2 -2
  88. package/dist/assets/assets/{swimlanes-B3ENRKFQ-1gjZQElg.js → swimlanes-B3ENRKFQ-PArlYoqV.js} +2 -2
  89. package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-The09-5S.js +9 -0
  90. package/dist/assets/assets/{timeline-definition-JXYKGLGB-CTeYEw-9.js → timeline-definition-JXYKGLGB-B2nKiNFU.js} +2 -2
  91. package/dist/assets/assets/{treeView-D4JQ5SDB-DD-EsLLT.js → treeView-D4JQ5SDB-gU23_RuI.js} +1 -1
  92. package/dist/assets/assets/{treemap-SAJKECNS-BLdFeS5J.js → treemap-SAJKECNS-CiqoMvZa.js} +1 -1
  93. package/dist/assets/assets/{usecaseDiagram-WPOLBNNX-C1GikSSP.js → usecaseDiagram-WPOLBNNX-DpeoWpMK.js} +2 -2
  94. package/dist/assets/assets/{vennDiagram-Q3Y3IDCW-B1FoA3g8.js → vennDiagram-Q3Y3IDCW-C31iGKvM.js} +2 -2
  95. package/dist/assets/assets/{wardley-7MLQ67FV-BrHb5Bjf.js → wardley-7MLQ67FV-CIzHhzNw.js} +1 -1
  96. package/dist/assets/assets/{wardleyDiagram-IVAIDKWA-CmPLD1X4.js → wardleyDiagram-IVAIDKWA-DIIkoezc.js} +2 -2
  97. package/dist/assets/assets/{webpack-BYWDFj_R.js → webpack-RFseiMZW.js} +2 -2
  98. package/dist/assets/assets/{xychartDiagram-4URNHDU4-DR5pfEjl.js → xychartDiagram-4URNHDU4-QiHL91kC.js} +2 -2
  99. package/dist/assets/bundle-asset-policy.json +1 -1
  100. package/dist/assets/index.html +2 -2
  101. package/dist/assets/plugins/assets/base-CKKRZ7-h.css +2 -0
  102. package/dist/assets/plugins/assets/browserCaptureWorklet-Droj0fW0-Droj0fW0.js +13 -0
  103. package/dist/assets/plugins/assets/ibm-plex-sans-cyrillic-ext-wght-normal-d45eAU9y.woff2 +0 -0
  104. package/dist/assets/plugins/assets/ibm-plex-sans-cyrillic-wght-normal-BAAhND-U.woff2 +0 -0
  105. package/dist/assets/plugins/assets/ibm-plex-sans-greek-wght-normal-CmyJS8uq.woff2 +0 -0
  106. package/dist/assets/plugins/assets/ibm-plex-sans-latin-ext-wght-normal-CIII54If.woff2 +0 -0
  107. package/dist/assets/plugins/assets/ibm-plex-sans-latin-wght-normal-IvpUvPa2.woff2 +0 -0
  108. package/dist/assets/plugins/assets/ibm-plex-sans-vietnamese-wght-normal-Dg1JeJN0.woff2 +0 -0
  109. package/dist/assets/plugins/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
  110. package/dist/assets/plugins/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  111. package/dist/assets/plugins/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  112. package/dist/assets/plugins/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  113. package/dist/assets/plugins/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  114. package/dist/assets/plugins/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  115. package/dist/assets/plugins/assets/sileroVadWorker-D894njUe-DjN_BMWf.mjs +110 -0
  116. package/dist/assets/plugins/assets/silero_vad_v6.2.1-SjbCxFXk-SjbCxFXk.onnx +0 -0
  117. package/dist/assets/plugins/chunks/po-web-runtime-BJDT6Lbw.js +1 -0
  118. package/dist/assets/plugins/compositions.json +1 -0
  119. package/dist/assets/plugins/slots/approval.293d9a00-BXIhaPlQ.js +2 -0
  120. package/dist/assets/plugins/slots/artifacts.24567664-ZzR0gbvy.js +1 -0
  121. package/dist/assets/plugins/slots/author.0998a880-DAbA-7rb.js +93 -0
  122. package/dist/assets/plugins/slots/autocompact.dd97d013-IVq4Z6qm.js +1 -0
  123. package/dist/assets/plugins/slots/builtin-tools.36d7400b-CpCLjRRN.js +7 -0
  124. package/dist/assets/plugins/slots/codemode.8eaee717-VWt9PqsU.js +10 -0
  125. package/dist/assets/plugins/slots/domain.5e95fc37-5PIUBqDe.js +1 -0
  126. package/dist/assets/plugins/slots/edit.385c9aa9-DNAjPNG5.js +7 -0
  127. package/dist/assets/plugins/slots/files.daf34ed8-CQaTz0i1.js +2 -0
  128. package/dist/assets/plugins/slots/goal.77ec9930-B8EkarBq.js +1 -0
  129. package/dist/assets/plugins/slots/grep.02052cdc-CIRhO2gY.js +1 -0
  130. package/dist/assets/plugins/slots/help.ecd4c0f9-naMF9NN1.js +3 -0
  131. package/dist/assets/plugins/slots/log.a86eb6d0-D5__rAZJ.js +4 -0
  132. package/dist/assets/plugins/slots/mcp.974af249-DPNHn9XH.js +109 -0
  133. package/dist/assets/plugins/slots/plan.bafb8f68-C5GEpybF.js +3 -0
  134. package/dist/assets/plugins/slots/profile.48851a1d-yX6tzV3x.js +1 -0
  135. package/dist/assets/plugins/slots/prompts.723d7748-B7zpPeoF.js +3 -0
  136. package/dist/assets/plugins/slots/read.46bf6536-Cw5Z5z5T.js +1 -0
  137. package/dist/assets/plugins/slots/runner.53e9bd76-CiQR_FPX.js +8 -0
  138. package/dist/assets/plugins/slots/skill.086701a4-CL6h_F-x.js +4 -0
  139. package/dist/assets/plugins/slots/vault.ac9935c8-DKERQYg4.js +1 -0
  140. package/dist/assets/plugins/slots/voice.e85ca7f9-DEgb-U9m.js +1 -0
  141. package/dist/assets/pwa/pwa.js +12 -12
  142. package/dist/assets/pwa/sw.js +4 -4
  143. package/dist/{atomicJson-BJfPFSYF.js → atomicJson-C_7F2zD1.js} +2 -3
  144. package/dist/azure-openai-config-COZUaRzM.js +55 -0
  145. package/dist/azure-openai-responses-Cs4k2HOd.js +183 -0
  146. package/dist/{backgroundWork-CeFrbRnj.js → backgroundWork-B1mPDYlf.js} +1 -1
  147. package/dist/browser-BWf8OMfl.js +3 -0
  148. package/dist/childSession-Cf2-kH4O.js +22 -0
  149. package/dist/classifier-shared-IhSH9hhh.js +106 -0
  150. package/dist/cloudflare-workers-ai-system-one-BNnc8MuH.js +52 -0
  151. package/dist/{codemode-DbPu0yJN.js → codemode-DQFmrosw.js} +5 -2
  152. package/dist/contracts-DD3f1Lpn.js +19 -0
  153. package/dist/diagnostics-1lYFeSJe.js +131 -0
  154. package/dist/{server-D3PQk1Gt.js → dist-B-vqs6tA.js} +1 -546
  155. package/dist/dist-Dvx5mlIR.js +50 -0
  156. package/dist/env-api-keys-Bow6MJe2.js +32 -0
  157. package/dist/error-body-CJk7jMUh.js +102 -0
  158. package/dist/esm-BKJy3O9-.js +1553 -0
  159. package/dist/exports-B0WMEXCP.js +34 -0
  160. package/dist/{remoteMcp-CMqZldeA.js → exports-D09VsUk-.js} +1153 -175
  161. package/dist/{exports-BNZz2DNU.js → exports-nV43ShA7.js} +25 -9
  162. package/dist/{extensionFile-CXOa5G4C.js → extensionFile-DNM4xsje.js} +26 -2
  163. package/dist/github-copilot-headers-D1RedfLn.js +22 -0
  164. package/dist/google-generative-ai-DXTILNT0.js +328 -0
  165. package/dist/google-shared-e4JDCTVP.js +19588 -0
  166. package/dist/google-vertex-a1lzvJfq.js +374 -0
  167. package/dist/{domains-BNjGTOPj.js → harnessState-Dwrk3lfv.js} +175 -16
  168. package/dist/{harnessStore-BT706Ly6.js → harnessStore-Z7yDLO45.js} +4 -5
  169. package/dist/hash-Dt6RIbkn.js +16 -0
  170. package/dist/headers-CwtEVQvr.js +17 -0
  171. package/dist/help-w6vVEZGL.js +101 -0
  172. package/dist/hubChannel-Cm-sxOvU.js +21 -0
  173. package/dist/hubRevisions-58pU2dW5.js +363 -0
  174. package/dist/identity-BgfHobJH.js +165 -0
  175. package/dist/index.edge-COJJ_Dv2.js +937 -0
  176. package/dist/index.edge-ChYa2LU4.js +14 -0
  177. package/dist/index.edge-ClLTmPFz.js +191 -0
  178. package/dist/index.edge-DyYmurS7.js +62 -0
  179. package/dist/index.edge-K0w5auwG.js +56 -0
  180. package/dist/index.edge-Xa5LLtxz.js +67 -0
  181. package/dist/iso-BPQViXM8.js +10 -0
  182. package/dist/{layeredConfig-DPQAnlXD.js → layeredConfig-CUkYUs1f.js} +193 -15
  183. package/dist/{majorModes-DbCfLZH3.js → majorModes-BB0PXgFn.js} +4 -14
  184. package/dist/majorModes-C7vtBs4D.js +1 -0
  185. package/dist/{mcpProjection-BsP0IEnb.js → mcpProjection-BtKzB6oK.js} +2 -2
  186. package/dist/migrations-5gbLIQIc.js +32 -0
  187. package/dist/mistral-conversations-CLwhVDjA.js +689 -0
  188. package/dist/modeDefinition-C3Zbrw48.js +44 -0
  189. package/dist/models-Chzm15vC.js +1511 -0
  190. package/dist/narration-CpRurWLO.js +127 -0
  191. package/dist/node-BT4GsJQp.js +2479 -0
  192. package/dist/node-DytJOfYf.js +23 -0
  193. package/dist/notification-kckG3leF.js +102 -0
  194. package/dist/openai-codex-responses-DRMONxDE.js +1210 -0
  195. package/dist/openai-completions-CcNhAv8l.js +984 -0
  196. package/dist/openai-decisions-BsFjaAGw.js +142 -0
  197. package/dist/openai-kPrtlgjl.js +17357 -0
  198. package/dist/openai-prompt-cache-Bc6qNWt0.js +8 -0
  199. package/dist/openai-responses-C5Gp2UOV.js +281 -0
  200. package/dist/openai-responses-shared-BbSi-wBR.js +661 -0
  201. package/dist/openrouter-cost-CvC52g3b.js +30 -0
  202. package/dist/openrouter-images-BoHl8g8p.js +124 -0
  203. package/dist/{hubChannel-BHQyzcOo.js → packageApi-t1oCjNDU.js} +4 -41
  204. package/dist/photon_rs_bg.wasm +0 -0
  205. package/dist/pi-messages-BXfrZLC7.js +312 -0
  206. package/dist/piConfig-DQzlbPY4.js +126 -0
  207. package/dist/piSettings-Cf1QofNe.js +1 -0
  208. package/dist/platform-BIEiM4TG.js +113 -0
  209. package/dist/pluginContributions-Be9EnCAW.js +16 -0
  210. package/dist/pluginProtocol-BqXXyI4z.js +80 -0
  211. package/dist/{protocol-Xpm_mCNN.js → protocol-DDL8geoS.js} +2 -2
  212. package/dist/provider-env-CxhHUFiF.js +38 -0
  213. package/dist/provider-retry-BUoezuw8.js +79 -0
  214. package/dist/sanitize-unicode-C3Ec8oL6.js +26 -0
  215. package/dist/sealedChannel-BeWNTWys.js +27 -0
  216. package/dist/server-AbXyhXlY.js +217 -0
  217. package/dist/server-B6dqQoh2.js +1518 -0
  218. package/dist/server-BIHo9TFu.js +505 -0
  219. package/dist/{server-BZh1ZXz_.js → server-BJ7DNzCp.js} +8 -19
  220. package/dist/server-BO-j_GbD.js +15106 -0
  221. package/dist/{server-D4W7EdJY.js → server-BQzAiMns.js} +16 -16
  222. package/dist/server-BR7SZtj7.js +3125 -0
  223. package/dist/{server-BE6VqEiA.js → server-BT2ORK83.js} +20 -12
  224. package/dist/server-BbSHYRnY.js +295 -0
  225. package/dist/server-BqoKlEGk.js +1806 -0
  226. package/dist/{server-tvgQ99rv.js → server-Busl0pQI.js} +370 -120
  227. package/dist/server-CIHM4jqu.js +1116 -0
  228. package/dist/server-CgWSSdvd.js +576 -0
  229. package/dist/{server-Dpgh8PDh.js → server-Co_UWKrR.js} +14 -5
  230. package/dist/{server-BAAL9-NA.js → server-CuEPb7u-.js} +3 -10
  231. package/dist/{server-Dt4y1rZD.js → server-D40q2Jpx.js} +47 -27
  232. package/dist/server-DCyf2Asb.js +679 -0
  233. package/dist/server-DH7PfLln.js +148 -0
  234. package/dist/server-DJ8bc89M.js +934 -0
  235. package/dist/server-DYdp0W9v.js +489 -0
  236. package/dist/server-DsdPEYGu.js +639 -0
  237. package/dist/server-DymH4Ucq.js +189 -0
  238. package/dist/server-IqECnUrb.js +834 -0
  239. package/dist/{server-36iuA3MI.js → server-KBgW77zh.js} +3 -3
  240. package/dist/server-RW_9R3R3.js +1522 -0
  241. package/dist/server-aUit8j6r.js +1028 -0
  242. package/dist/{server-DJAanjoI.js → server-gifRriZK.js} +491 -103
  243. package/dist/server-nkUlqnAL.js +2658 -0
  244. package/dist/server-oxyEbv1a.js +1256 -0
  245. package/dist/{server-D8ndq0wL.js → server-ub3s16Mc.js} +11 -9
  246. package/dist/{build-2gFaVEfG.js → serverPlugin-CELT6P0Q.js} +3946 -3
  247. package/dist/{sessionConfig-rBQgzXlT.js → sessionConfig-RQGvfm6E.js} +550 -760
  248. package/dist/simple-options-CFzI5Pd_.js +156 -0
  249. package/dist/streaming-json-BWTHTwz-.js +858 -0
  250. package/dist/system-one-shared-CiIrx29d.js +132 -0
  251. package/dist/{notification-D76PSL7r.js → telemetry-Csv1ZxAn.js} +1 -92
  252. package/dist/transform-messages-D77af7Bx.js +356 -0
  253. package/dist/truncate-M3KbFyVj.js +89 -0
  254. package/dist/{server-A-_GFpPr.js → type-ASYnCGVW.js} +10 -1031
  255. package/dist/typesafe-system-one-DGxeggJh.js +37 -0
  256. package/dist/uuid-B0QJx6Kr.js +31 -0
  257. package/dist/{validation-D77NZBrx.js → validation-BJxVSAwx.js} +8 -3
  258. package/dist/{value-Djvc2foV.js → value-_W31So3B.js} +1 -1
  259. package/dist/vaultSettings-Di3n5YIg.js +328 -0
  260. package/dist/voiceTools-RMn4HvWo.js +246 -0
  261. package/dist/web-DCP7ELJj.js +3 -0
  262. package/dist/worker.js +95288 -49863
  263. package/dist/workflow-B7qx0Vv9.js +79 -0
  264. package/package.json +37 -22
  265. package/wrangler.jsonc +4 -2
  266. package/dist/assets/assets/channel-CMrEzemr.js +0 -2
  267. package/dist/assets/assets/chunk-XXDRQBXY-CFf0S6bN.js +0 -2
  268. package/dist/assets/assets/flowDiagram-IUGLLWBU-BhGbWVf0.js +0 -1
  269. package/dist/assets/assets/index-Bx_K4Joy.js +0 -155
  270. package/dist/assets/assets/index-DZM68mTk.css +0 -1
  271. package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-q91tR8ri.js +0 -9
  272. package/dist/contextProjection-DVP2Vc5j.js +0 -188
  273. package/dist/harnessState-gmzJcPGt.js +0 -88
  274. package/dist/harnessStore-BiH9vSuD.js +0 -1
  275. package/dist/index.edge-BgSx_gRO.js +0 -45
  276. package/dist/majorModes-BvWNqoHt.js +0 -1
  277. package/dist/piSettings-B6fsgIBA.js +0 -1
  278. package/dist/platform-B4AAgwJ0.js +0 -16
  279. package/dist/platformFiles-C_bXo4Ig.js +0 -39
  280. package/dist/server-BZaPPoQp.js +0 -592
  281. package/dist/server-D75MWDhB.js +0 -118
  282. package/dist/server-r358hzQg.js +0 -280
  283. package/dist/serverPlugin-BOI6c6s5.js +0 -3393
@@ -1,28 +1,22 @@
1
- import { a as piAgentDirectory, c as nodeHost, et as Service, f as getOrThrow, ot as BACKGROUND_CONTEXT, s as createSerialRunner } from "./serverPlugin-BOI6c6s5.js";
2
- import { A as Integer, G as _Object_, M as Boolean, Q as _Array_, _ as Union, k as Literal, q as Optional, x as Number$1, y as String$1 } from "./build-2gFaVEfG.js";
3
- import { i as writeFileAtomic, t as readTextIfExists } from "./platformFiles-C_bXo4Ig.js";
4
- import "./approvalPrompt-Bg1JrEEY.js";
5
- import { c as PROFILE_ICON_MIME_TYPES, n as PO_CONFIG_TRANSITION_ENTRY_TYPE, t as PO_CONFIG_ENTRY_TYPE } from "./contextProjection-DVP2Vc5j.js";
6
- import "./platform-B4AAgwJ0.js";
7
- import { n as writePrivateAtomicJsonAsync, t as createDirectoryWithMode } from "./atomicJson-BJfPFSYF.js";
8
- import { a as globalPoConfigPath, c as repositoryPoConfigPath, d as parse, f as parseDocument, l as configScopeOf, t as readPoConfigSourcesAsync, u as parsePoConfig } from "./layeredConfig-DPQAnlXD.js";
9
- import "./piSettings-B6fsgIBA.js";
10
- import { i as defaultDomainsForMajorMode, s as readPoConfig } from "./domains-BNjGTOPj.js";
11
- import { r as loadMajorModesConfig } from "./majorModes-DbCfLZH3.js";
12
- import { t as loadHarnessStateAsync } from "./harnessStore-BT706Ly6.js";
1
+ import { G as Null, Hn as BACKGROUND_CONTEXT, S as PO_CONFIG_SERVICE, Sn as getOrThrow, V as String$1, ar as defineServiceContract, gn as createSerialRunner, ht as Optional, pt as _Object_, vn as nodeHost, x as Service, z as Union } from "./serverPlugin-CELT6P0Q.js";
2
+ import { s as readTextIfExists, u as writeFileAtomic } from "./platform-BIEiM4TG.js";
3
+ import { t as createDirectoryWithMode } from "./atomicJson-C_7F2zD1.js";
4
+ import { S as isMap, _ as parse, c as globalPoConfigPath, f as repositoryPoConfigPath, h as parsePoConfig, m as configScopeOf, n as poConfigCandidates, s as globalPoConfigDirectory, t as readPoConfigSourcesAsync, v as parseDocument, w as isSeq, x as YAMLMap, y as stringify } from "./layeredConfig-CUkYUs1f.js";
5
+ import { d as readPoConfigLayers, o as defaultDomainsForMajorMode, r as loadDomainsAsync, u as readPoConfig } from "./harnessState-Dwrk3lfv.js";
6
+ import { n as defineApiRoutes, t as apiResponse } from "./hubRevisions-58pU2dW5.js";
7
+ import "./web-DCP7ELJj.js";
8
+ import { n as savePiImageSettingsAsync, r as DEFAULT_IMAGE_MAX_DIMENSION, t as readPiImageSettings } from "./piConfig-DQzlbPY4.js";
9
+ import { r as MODES_FILE, t as readMajorModesConfig } from "./majorModes-BB0PXgFn.js";
10
+ import { t as loadHarnessStateAsync } from "./harnessStore-Z7yDLO45.js";
13
11
  import path from "node:path";
14
12
  import { Buffer as Buffer$1 } from "node:buffer";
15
13
  //#region ../../foundations/po-config/src/services/config/sync.edge.ts
16
- function nodeOnly$2(name, asyncName) {
14
+ function nodeOnly(name, asyncName) {
17
15
  throw new Error(`${name} is Node-only; use ${asyncName} with a PoPlatform on the edge.`);
18
16
  }
19
17
  /** @deprecated Node-only sync shim; use readPoConfig. Removed in M2. */
20
18
  function loadPoConfig(_repoRoot, _homeDirectory, _environment) {
21
- return nodeOnly$2("loadPoConfig", "readPoConfig");
22
- }
23
- /** @deprecated Node-only sync shim; use readPoConfigLayers. Removed in M2. */
24
- function loadPoConfigLayers(_repoRoot, _homeDirectory, _environment) {
25
- return nodeOnly$2("loadPoConfigLayers", "readPoConfigLayers");
19
+ return nodeOnly("loadPoConfig", "readPoConfig");
26
20
  }
27
21
  //#endregion
28
22
  //#region ../../foundations/po-config/src/services/configWriter/core.ts
@@ -138,379 +132,12 @@ async function writePoConfigValuesAsync(fs, filePath, edits, context, options =
138
132
  });
139
133
  }
140
134
  //#endregion
141
- //#region ../../foundations/po-config/src/services/domains/sync.edge.ts
142
- function nodeOnly$1(name, asyncName) {
143
- throw new Error(`${name} is Node-only; use ${asyncName} with a PoPlatform on the edge.`);
144
- }
145
- /** @deprecated Node-only sync shim; use loadDomainsAsync. Removed in M2. */
146
- function loadDomains(_repoRoot, _homeDirectory) {
147
- return nodeOnly$1("loadDomains", "loadDomainsAsync");
148
- }
149
- //#endregion
150
135
  //#region ../../foundations/po-config/src/constants/settings.ts
151
136
  const SELECTION_KEYS = {
152
137
  majorMode: ["selection", "majorMode"],
153
138
  domains: ["selection", "domains"],
154
139
  profile: ["selection", "profile"]
155
140
  };
156
- /** Identity with inference, so a route table keeps its literal types. */
157
- function defineApiRoutes(routes) {
158
- return routes;
159
- }
160
- //#endregion
161
- //#region ../../../node_modules/.pnpm/@tanstack+store@0.11.2/node_modules/@tanstack/store/dist/alien.js
162
- /* @__NO_SIDE_EFFECTS__ */
163
- function createReactiveSystem({ update, notify, unwatched }) {
164
- return {
165
- link,
166
- unlink,
167
- propagate,
168
- checkDirty,
169
- shallowPropagate
170
- };
171
- function link(dep, sub, version) {
172
- const prevDep = sub.depsTail;
173
- if (prevDep !== void 0 && prevDep.dep === dep) return;
174
- const nextDep = prevDep !== void 0 ? prevDep.nextDep : sub.deps;
175
- if (nextDep !== void 0 && nextDep.dep === dep) {
176
- nextDep.version = version;
177
- sub.depsTail = nextDep;
178
- return;
179
- }
180
- const prevSub = dep.subsTail;
181
- if (prevSub !== void 0 && prevSub.version === version && prevSub.sub === sub) return;
182
- const newLink = sub.depsTail = dep.subsTail = {
183
- version,
184
- dep,
185
- sub,
186
- prevDep,
187
- nextDep,
188
- prevSub,
189
- nextSub: void 0
190
- };
191
- if (nextDep !== void 0) nextDep.prevDep = newLink;
192
- if (prevDep !== void 0) prevDep.nextDep = newLink;
193
- else sub.deps = newLink;
194
- if (prevSub !== void 0) prevSub.nextSub = newLink;
195
- else dep.subs = newLink;
196
- }
197
- function unlink(link, sub = link.sub) {
198
- const dep = link.dep;
199
- const prevDep = link.prevDep;
200
- const nextDep = link.nextDep;
201
- const nextSub = link.nextSub;
202
- const prevSub = link.prevSub;
203
- if (nextDep !== void 0) nextDep.prevDep = prevDep;
204
- else sub.depsTail = prevDep;
205
- if (prevDep !== void 0) prevDep.nextDep = nextDep;
206
- else sub.deps = nextDep;
207
- if (nextSub !== void 0) nextSub.prevSub = prevSub;
208
- else dep.subsTail = prevSub;
209
- if (prevSub !== void 0) prevSub.nextSub = nextSub;
210
- else if ((dep.subs = nextSub) === void 0) unwatched(dep);
211
- return nextDep;
212
- }
213
- function propagate(link) {
214
- let next = link.nextSub;
215
- let stack;
216
- top: do {
217
- const sub = link.sub;
218
- let flags = sub.flags;
219
- if (!(flags & 60)) sub.flags = flags | 32;
220
- else if (!(flags & 12)) flags = 0;
221
- else if (!(flags & 4)) sub.flags = flags & -9 | 32;
222
- else if (!(flags & 48) && isValidLink(link, sub)) {
223
- sub.flags = flags | 40;
224
- flags &= 1;
225
- } else flags = 0;
226
- if (flags & 2) notify(sub);
227
- if (flags & 1) {
228
- const subSubs = sub.subs;
229
- if (subSubs !== void 0) {
230
- const nextSub = (link = subSubs).nextSub;
231
- if (nextSub !== void 0) {
232
- stack = {
233
- value: next,
234
- prev: stack
235
- };
236
- next = nextSub;
237
- }
238
- continue;
239
- }
240
- }
241
- if ((link = next) !== void 0) {
242
- next = link.nextSub;
243
- continue;
244
- }
245
- while (stack !== void 0) {
246
- link = stack.value;
247
- stack = stack.prev;
248
- if (link !== void 0) {
249
- next = link.nextSub;
250
- continue top;
251
- }
252
- }
253
- break;
254
- } while (true);
255
- }
256
- function checkDirty(link, sub) {
257
- let stack;
258
- let checkDepth = 0;
259
- let dirty = false;
260
- top: do {
261
- const dep = link.dep;
262
- const flags = dep.flags;
263
- if (sub.flags & 16) dirty = true;
264
- else if ((flags & 17) === 17) {
265
- if (update(dep)) {
266
- const subs = dep.subs;
267
- if (subs.nextSub !== void 0) shallowPropagate(subs);
268
- dirty = true;
269
- }
270
- } else if ((flags & 33) === 33) {
271
- if (link.nextSub !== void 0 || link.prevSub !== void 0) stack = {
272
- value: link,
273
- prev: stack
274
- };
275
- link = dep.deps;
276
- sub = dep;
277
- ++checkDepth;
278
- continue;
279
- }
280
- if (!dirty) {
281
- const nextDep = link.nextDep;
282
- if (nextDep !== void 0) {
283
- link = nextDep;
284
- continue;
285
- }
286
- }
287
- while (checkDepth--) {
288
- const firstSub = sub.subs;
289
- const hasMultipleSubs = firstSub.nextSub !== void 0;
290
- if (hasMultipleSubs) {
291
- link = stack.value;
292
- stack = stack.prev;
293
- } else link = firstSub;
294
- if (dirty) {
295
- if (update(sub)) {
296
- if (hasMultipleSubs) shallowPropagate(firstSub);
297
- sub = link.sub;
298
- continue;
299
- }
300
- dirty = false;
301
- } else sub.flags &= -33;
302
- sub = link.sub;
303
- const nextDep = link.nextDep;
304
- if (nextDep !== void 0) {
305
- link = nextDep;
306
- continue top;
307
- }
308
- }
309
- return dirty;
310
- } while (true);
311
- }
312
- function shallowPropagate(link) {
313
- do {
314
- const sub = link.sub;
315
- const flags = sub.flags;
316
- if ((flags & 48) === 32) {
317
- sub.flags = flags | 16;
318
- if ((flags & 6) === 2) notify(sub);
319
- }
320
- } while ((link = link.nextSub) !== void 0);
321
- }
322
- function isValidLink(checkLink, sub) {
323
- let link = sub.depsTail;
324
- while (link !== void 0) {
325
- if (link === checkLink) return true;
326
- link = link.prevDep;
327
- }
328
- return false;
329
- }
330
- }
331
- //#endregion
332
- //#region ../../../node_modules/.pnpm/@tanstack+store@0.11.2/node_modules/@tanstack/store/dist/atom.js
333
- function toObserver(nextHandler, errorHandler, completionHandler) {
334
- const isObserver = typeof nextHandler === "object";
335
- const self = isObserver ? nextHandler : void 0;
336
- return {
337
- next: (isObserver ? nextHandler.next : nextHandler)?.bind(self),
338
- error: (isObserver ? nextHandler.error : errorHandler)?.bind(self),
339
- complete: (isObserver ? nextHandler.complete : completionHandler)?.bind(self)
340
- };
341
- }
342
- const queuedEffects = [];
343
- let cycle = 0;
344
- const { link, unlink, propagate, checkDirty, shallowPropagate } = /* @__PURE__ */ createReactiveSystem({
345
- update(atom) {
346
- return atom._update();
347
- },
348
- notify(effect) {
349
- queuedEffects[queuedEffectsLength++] = effect;
350
- effect.flags &= -3;
351
- },
352
- unwatched(atom) {
353
- if (atom.depsTail !== void 0) {
354
- atom.depsTail = void 0;
355
- atom.flags = 17;
356
- purgeDeps(atom);
357
- }
358
- }
359
- });
360
- let notifyIndex = 0;
361
- let queuedEffectsLength = 0;
362
- let activeSub;
363
- function purgeDeps(sub) {
364
- const depsTail = sub.depsTail;
365
- let dep = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
366
- while (dep !== void 0) dep = unlink(dep, sub);
367
- }
368
- function flush() {
369
- while (notifyIndex < queuedEffectsLength) {
370
- const effect = queuedEffects[notifyIndex];
371
- queuedEffects[notifyIndex++] = void 0;
372
- effect.notify();
373
- }
374
- notifyIndex = 0;
375
- queuedEffectsLength = 0;
376
- }
377
- function createAtom(valueOrFn, options) {
378
- const isComputed = typeof valueOrFn === "function";
379
- const getter = valueOrFn;
380
- const atom = {
381
- _snapshot: isComputed ? void 0 : valueOrFn,
382
- subs: void 0,
383
- subsTail: void 0,
384
- deps: void 0,
385
- depsTail: void 0,
386
- flags: isComputed ? 0 : 1,
387
- get() {
388
- if (activeSub !== void 0) link(atom, activeSub, cycle);
389
- return atom._snapshot;
390
- },
391
- subscribe(observerOrFn) {
392
- const obs = toObserver(observerOrFn);
393
- const observed = { current: false };
394
- const e = effect(() => {
395
- atom.get();
396
- if (!observed.current) observed.current = true;
397
- else {
398
- activeSub = void 0;
399
- obs.next?.(atom._snapshot);
400
- }
401
- });
402
- return { unsubscribe: () => {
403
- e.stop();
404
- } };
405
- },
406
- _update(getValue) {
407
- const prevSub = activeSub;
408
- const compare = options?.compare ?? Object.is;
409
- if (isComputed) {
410
- activeSub = atom;
411
- ++cycle;
412
- atom.depsTail = void 0;
413
- } else if (getValue === void 0) return false;
414
- if (isComputed) atom.flags = 5;
415
- try {
416
- const oldValue = atom._snapshot;
417
- const newValue = typeof getValue === "function" ? getValue(oldValue) : getValue === void 0 && isComputed ? getter(oldValue) : getValue;
418
- if (oldValue === void 0 || !compare(oldValue, newValue)) {
419
- atom._snapshot = newValue;
420
- return true;
421
- }
422
- return false;
423
- } finally {
424
- activeSub = prevSub;
425
- if (isComputed) atom.flags &= -5;
426
- purgeDeps(atom);
427
- }
428
- }
429
- };
430
- if (isComputed) {
431
- atom.flags = 17;
432
- atom.get = function() {
433
- const flags = atom.flags;
434
- if (flags & 16 || flags & 32 && checkDirty(atom.deps, atom)) {
435
- if (atom._update()) {
436
- const subs = atom.subs;
437
- if (subs !== void 0) shallowPropagate(subs);
438
- }
439
- } else if (flags & 32) atom.flags = flags & -33;
440
- if (activeSub !== void 0) link(atom, activeSub, cycle);
441
- return atom._snapshot;
442
- };
443
- } else atom.set = function(valueOrFn) {
444
- if (atom._update(valueOrFn)) {
445
- const subs = atom.subs;
446
- if (subs !== void 0) {
447
- propagate(subs);
448
- shallowPropagate(subs);
449
- flush();
450
- }
451
- }
452
- };
453
- return atom;
454
- }
455
- function effect(fn) {
456
- const run = () => {
457
- const prevSub = activeSub;
458
- activeSub = effectObj;
459
- ++cycle;
460
- effectObj.depsTail = void 0;
461
- effectObj.flags = 6;
462
- try {
463
- return fn();
464
- } finally {
465
- activeSub = prevSub;
466
- effectObj.flags &= -5;
467
- purgeDeps(effectObj);
468
- }
469
- };
470
- const effectObj = {
471
- deps: void 0,
472
- depsTail: void 0,
473
- subs: void 0,
474
- subsTail: void 0,
475
- flags: 6,
476
- notify() {
477
- const flags = this.flags;
478
- if (flags & 16 || flags & 32 && checkDirty(this.deps, this)) run();
479
- else this.flags = 2;
480
- },
481
- stop() {
482
- this.flags = 0;
483
- this.depsTail = void 0;
484
- purgeDeps(this);
485
- }
486
- };
487
- run();
488
- return effectObj;
489
- }
490
- //#endregion
491
- //#region ../../../node_modules/.pnpm/@tanstack+store@0.11.2/node_modules/@tanstack/store/dist/store.js
492
- var Store = class {
493
- constructor(valueOrFn, actionsFactory) {
494
- this.atom = createAtom(valueOrFn);
495
- this.get = this.get.bind(this);
496
- this.setState = this.setState.bind(this);
497
- this.subscribe = this.subscribe.bind(this);
498
- if (actionsFactory) this.actions = actionsFactory(this);
499
- }
500
- setState(updater) {
501
- this.atom.set(updater);
502
- }
503
- get state() {
504
- return this.atom.get();
505
- }
506
- get() {
507
- return this.state;
508
- }
509
- subscribe(observerOrFn) {
510
- return this.atom.subscribe(toObserver(observerOrFn));
511
- }
512
- };
513
- new Store({});
514
141
  //#endregion
515
142
  //#region ../../foundations/po-config/src/types/apiRoutes.ts
516
143
  /**
@@ -533,161 +160,102 @@ var apiRoutes_default = defineApiRoutes({
533
160
  path: "/",
534
161
  /** Repeatable. The page also sends `repoRoot`, which the mount ignores: it serves one repository. */
535
162
  query: ["key"],
536
- response: void 0
163
+ response: /* @__PURE__ */ apiResponse()
537
164
  },
538
165
  value: {
539
166
  method: "PUT",
540
167
  path: "/value",
541
- response: void 0
168
+ response: /* @__PURE__ */ apiResponse()
542
169
  },
543
170
  repositories: {
544
171
  method: "GET",
545
172
  path: "/repositories",
546
- response: void 0
173
+ response: /* @__PURE__ */ apiResponse()
547
174
  },
548
175
  /** The workspace this mount was bound to; a global mount has none and answers 404. */
549
176
  repository: {
550
177
  method: "GET",
551
178
  path: "/repository",
552
- response: void 0
179
+ response: /* @__PURE__ */ apiResponse()
553
180
  },
554
181
  selection: {
555
182
  method: "PUT",
556
183
  path: "/repository/selection",
557
- response: void 0
184
+ response: /* @__PURE__ */ apiResponse()
558
185
  },
559
186
  /** Pi's own image limits, served by the global mount only. */
560
187
  images: {
561
188
  method: "GET",
562
189
  path: "/images",
563
- response: void 0
190
+ response: /* @__PURE__ */ apiResponse()
564
191
  },
565
192
  /** The same path as `images`; the method is the whole of the difference. */
566
193
  saveImages: {
567
194
  method: "PUT",
568
195
  path: "/images",
569
- response: void 0
196
+ response: /* @__PURE__ */ apiResponse()
197
+ },
198
+ /** Your major modes from `~/.po/modes.yaml`, served by the global mount only. */
199
+ presets: {
200
+ method: "GET",
201
+ path: "/presets",
202
+ response: /* @__PURE__ */ apiResponse()
203
+ },
204
+ /** Sets `defaultMajorMode`; the method is the whole of the difference. */
205
+ savePresets: {
206
+ method: "PUT",
207
+ path: "/presets",
208
+ response: /* @__PURE__ */ apiResponse()
570
209
  }
571
210
  });
572
211
  //#endregion
573
- //#region ../../foundations/po-config/src/services/imageSettings/index.ts
574
- const IMAGE_SETTINGS_KEY = "images";
575
- const IMAGE_AUTO_RESIZE_KEY = "autoResize";
576
- const IMAGE_MAX_DIMENSION_KEY = "maxDimension";
577
- /** Pi's own cap, from its resize core; also the largest value worth writing. */
578
- const DEFAULT_IMAGE_MAX_DIMENSION = 2e3;
579
- function clampImageMaxDimension(value) {
580
- const rounded = Math.round(value);
581
- if (rounded < 256) return 256;
582
- if (rounded > 2e3) return DEFAULT_IMAGE_MAX_DIMENSION;
583
- return rounded;
584
- }
585
- function isRecord$3(value) {
586
- return typeof value === "object" && value !== null && !Array.isArray(value);
587
- }
588
- /** Resolves the effective limits, defaulting anything absent or unusable. */
589
- function parsePiImageSettings(config) {
590
- const images = config[IMAGE_SETTINGS_KEY];
591
- if (!isRecord$3(images)) return {
592
- autoResize: true,
593
- maxDimension: DEFAULT_IMAGE_MAX_DIMENSION
594
- };
595
- const autoResize = images[IMAGE_AUTO_RESIZE_KEY];
596
- const maxDimension = images[IMAGE_MAX_DIMENSION_KEY];
597
- return {
598
- autoResize: typeof autoResize === "boolean" ? autoResize : true,
599
- maxDimension: typeof maxDimension === "number" && Number.isFinite(maxDimension) ? clampImageMaxDimension(maxDimension) : DEFAULT_IMAGE_MAX_DIMENSION
600
- };
212
+ //#region ../../foundations/po-config/src/services/presets/index.ts
213
+ const io = BACKGROUND_CONTEXT;
214
+ function packageName(entry) {
215
+ return typeof entry === "string" ? entry : entry.name;
601
216
  }
602
217
  /**
603
- * Folds a change into the `images` object of a settings document, leaving every
604
- * other key of that document, and of `images` itself, as it was.
218
+ * Settings > Presets: the major modes in `~/.po/modes.yaml`. Read with the home as the root, so
219
+ * the page shows your presets, never one repository's.
605
220
  */
606
- function applyPiImageSettings(config, update) {
607
- const existing = config[IMAGE_SETTINGS_KEY];
608
- const images = isRecord$3(existing) ? { ...existing } : {};
609
- if (update.autoResize !== void 0) images[IMAGE_AUTO_RESIZE_KEY] = update.autoResize;
610
- if (update.maxDimension !== void 0) images[IMAGE_MAX_DIMENSION_KEY] = clampImageMaxDimension(update.maxDimension);
221
+ async function readPresetsView(fs, homeDirectory, environment) {
222
+ const config = await readMajorModesConfig(fs, homeDirectory, io, {
223
+ homeDirectory,
224
+ environment
225
+ });
611
226
  return {
612
- ...config,
613
- [IMAGE_SETTINGS_KEY]: images
227
+ defaultPreset: config.defaultMajorMode,
228
+ presets: Object.entries(config.majorMode).map(([name, mode]) => ({
229
+ name,
230
+ description: mode.description,
231
+ layers: mode.layers.map((layer) => ({
232
+ name: layer,
233
+ packages: (config.layers[layer]?.packages ?? []).map(packageName)
234
+ }))
235
+ })),
236
+ alwaysIncluded: (config.default?.packages ?? []).map(packageName)
614
237
  };
615
238
  }
616
- //#endregion
617
- //#region ../../foundations/po-config/src/services/piConfig/core.ts
618
- const SETTINGS_FILE_NAME = "settings.json";
619
- const CONFIG_DIR_NAME = ".pi";
620
- /** An explicit home other than the real one is isolated from the process environment. */
621
- function defaultAgentDirectory(homeDirectory) {
622
- return piAgentDirectory(homeDirectory === nodeHost.homeDirectory() ? process.env : {}, homeDirectory);
623
- }
624
- function isObject(value) {
625
- return typeof value === "object" && value !== null && !Array.isArray(value);
626
- }
627
- function mergeConfig(base, override) {
628
- const result = { ...base };
629
- for (const [key, value] of Object.entries(override)) {
630
- const current = result[key];
631
- result[key] = isObject(current) && isObject(value) ? mergeConfig(current, value) : value;
632
- }
633
- return result;
634
- }
635
- /** Parses one settings file; `undefined` text means the file is missing. */
636
- function configFromText(text, filePath) {
637
- if (text === void 0) return {};
638
- let parsed;
239
+ /**
240
+ * Sets `defaultMajorMode` in `~/.po/modes.yaml`, keeping the file's comments. Answers an error
241
+ * string, rather than writing, when the name is not one of your presets or the file is not YAML;
242
+ * a result the loader refuses is put back as it was.
243
+ */
244
+ async function writeDefaultPreset(fs, homeDirectory, environment, name) {
245
+ if (!(await readPresetsView(fs, homeDirectory, environment)).presets.some((preset) => preset.name === name)) return { error: `There is no preset named ${name}.` };
246
+ const file = path.join(globalPoConfigDirectory(homeDirectory), MODES_FILE);
247
+ const text = await readTextIfExists(fs, file, io);
248
+ const document = parseDocument(text ?? "");
249
+ if (document.errors.length > 0 || !isMap(document.contents)) return { error: `Your ${MODES_FILE} could not be read as YAML.` };
250
+ document.set("defaultMajorMode", name);
251
+ await writeFileAtomic(fs, file, document.toString(), io);
639
252
  try {
640
- parsed = JSON.parse(text);
253
+ return await readPresetsView(fs, homeDirectory, environment);
641
254
  } catch (error) {
642
- throw new Error(`Could not parse Pi settings at ${filePath}`, { cause: error });
255
+ if (text === void 0) getOrThrow(await fs.remove(file, { force: true }, io));
256
+ else await writeFileAtomic(fs, file, text, io);
257
+ return { error: `Po left ${MODES_FILE} as it was: ${error instanceof Error ? error.message : String(error)}` };
643
258
  }
644
- if (!isObject(parsed)) throw new Error(`Pi settings at ${filePath} must be a JSON object`);
645
- return parsed;
646
- }
647
- /**
648
- * Where the image limits are read from and written to.
649
- *
650
- * The user layer only. Pi merges a trusted project settings.json over it, but
651
- * these limits describe one machine's tolerance for image payloads rather than
652
- * one repository's, and the cockpit page that writes them has no repository
653
- * scope to offer. The legacy user path is still read, because a machine that
654
- * has not been migrated still answers from it.
655
- */
656
- function userSettingsPaths(homeDirectory) {
657
- return {
658
- legacy: path.join(homeDirectory, CONFIG_DIR_NAME, SETTINGS_FILE_NAME),
659
- canonical: path.join(defaultAgentDirectory(homeDirectory), SETTINGS_FILE_NAME)
660
- };
661
- }
662
- //#endregion
663
- //#region ../../foundations/po-config/src/services/piConfig/index.ts
664
- /** Image settings saves in this process are queued per file, so none reads a stale document. */
665
- const imageSettingsWrites = createSerialRunner();
666
- async function readConfig(fs, filePath, context) {
667
- return configFromText(await readTextIfExists(fs, filePath, context), filePath);
668
- }
669
- async function readConfigPaths(fs, paths, context) {
670
- return (await Promise.all(paths.map((filePath) => readConfig(fs, filePath, context)))).reduce(mergeConfig, {});
671
- }
672
- async function readPiImageSettings(fs, context, homeDirectory = nodeHost.homeDirectory()) {
673
- const paths = userSettingsPaths(homeDirectory);
674
- return parsePiImageSettings(await readConfigPaths(fs, [paths.legacy, paths.canonical], context));
675
- }
676
- /**
677
- * Writes the changed keys back and reports the limits that now apply.
678
- *
679
- * Read-modify-write on Pi's own file, so a save races a concurrent Pi settings
680
- * save rather than merging with it. Pi writes only the fields its UI touched,
681
- * as this does, which keeps the window to the one setting being changed on
682
- * both sides at once. Saves from this process are queued.
683
- */
684
- async function savePiImageSettingsAsync(fs, update, context, homeDirectory = nodeHost.homeDirectory()) {
685
- const paths = userSettingsPaths(homeDirectory);
686
- await imageSettingsWrites.forKey(path.resolve(paths.canonical))(async () => {
687
- const current = await readConfig(fs, paths.canonical, context);
688
- await writePrivateAtomicJsonAsync(fs, paths.canonical, applyPiImageSettings(current, update), context);
689
- });
690
- return readPiImageSettings(fs, context, homeDirectory);
691
259
  }
692
260
  //#endregion
693
261
  //#region ../../foundations/po-config/src/services/personaFrontMatter/index.ts
@@ -769,6 +337,66 @@ function parsePersonaFrontMatter(content) {
769
337
  };
770
338
  }
771
339
  //#endregion
340
+ //#region ../../core/po-core/src/schemas/profileIdentity.ts
341
+ /**
342
+ * The custom session entry the runtime journals when the active profile's
343
+ * persona identity changes.
344
+ *
345
+ * A profile has always been prompt text only, so a cockpit had nothing to show
346
+ * for it beyond the profile name already published as footer status. This entry
347
+ * carries the persona's display name and avatar so the transcript can attribute
348
+ * each assistant message to the persona that produced it.
349
+ *
350
+ * It rides Pi's `entry_appended` frames on the road the agent-model projection
351
+ * already uses, so any RPC client sees the change live and on replay without a
352
+ * new protocol.
353
+ *
354
+ * Unlike the minor-mode, context, and agent-model projections, this entry is
355
+ * NOT a projection: it is transcript, positioned in journal order. A cockpit
356
+ * folding it must keep every occurrence rather than collapsing to the latest
357
+ * one, because a message written before a switch keeps the identity it was
358
+ * written under. Collapsing would rewrite history.
359
+ */
360
+ const PO_PROFILE_IDENTITY_ENTRY_TYPE = "po-profile-identity";
361
+ /**
362
+ * Ceiling on the encoded icon, counted on the finished `data:` URL rather than
363
+ * the file, so one number bounds both the journal entry and the transport.
364
+ *
365
+ * An avatar renders at 32 CSS pixels. This much room is already generous, and
366
+ * the cap exists because the entry is replayed with the transcript: an oversize
367
+ * icon is dropped and the persona keeps its name, never failing a profile load.
368
+ */
369
+ const PROFILE_ICON_MAX_DATA_URL_LENGTH = 262144;
370
+ const MAX_PROFILE_NAME_LENGTH = 128;
371
+ /**
372
+ * Image types allowed for a persona icon.
373
+ *
374
+ * Deliberately narrower than the cockpit's general media catalog: `image/svg+xml`
375
+ * is excluded because an SVG rendered same-origin executes script, and the icon
376
+ * path comes from user-authored persona front-matter. Do not reconcile this list
377
+ * with the broader media type map.
378
+ */
379
+ const PROFILE_ICON_MIME_TYPES = [
380
+ "image/png",
381
+ "image/jpeg",
382
+ "image/gif",
383
+ "image/webp"
384
+ ];
385
+ _Object_({
386
+ profile: Union([String$1({
387
+ minLength: 1,
388
+ maxLength: MAX_PROFILE_NAME_LENGTH
389
+ }), Null()]),
390
+ name: Optional(String$1({
391
+ minLength: 1,
392
+ maxLength: MAX_PROFILE_NAME_LENGTH
393
+ })),
394
+ icon: Optional(String$1({
395
+ minLength: 1,
396
+ maxLength: PROFILE_ICON_MAX_DATA_URL_LENGTH
397
+ }))
398
+ }, { additionalProperties: false });
399
+ //#endregion
772
400
  //#region ../../foundations/po-config/src/services/personaIcon/core.ts
773
401
  /**
774
402
  * Pure half of persona icon loading: confinement and image sniffing. The
@@ -856,6 +484,27 @@ async function readPersonaIconAsync(fs, personaPath, iconRelative, context) {
856
484
  }
857
485
  }
858
486
  //#endregion
487
+ //#region ../../core/po-core/src/schemas/personTimeZone.ts
488
+ const PO_PERSON_TIME_ZONE_SERVICE = "po/person-time-zone";
489
+ defineServiceContract(PO_PERSON_TIME_ZONE_SERVICE, { scope: "session" });
490
+ function readPoPersonTimeZone(context) {
491
+ return context.get(PO_PERSON_TIME_ZONE_SERVICE);
492
+ }
493
+ /** True for a zone name this runtime's Intl accepts, such as `Australia/Sydney`. */
494
+ function isTimeZone(value) {
495
+ if (typeof value !== "string" || value.length === 0 || value.length > 64) return false;
496
+ try {
497
+ new Intl.DateTimeFormat("en", { timeZone: value });
498
+ return true;
499
+ } catch {
500
+ return false;
501
+ }
502
+ }
503
+ /** The system prompt line. It names no clock time, so it stays stable and the prompt cache holds. */
504
+ function personTimeZoneLine(zone) {
505
+ return zone === void 0 ? "Person's timezone: unknown. Ask the person before acting on a clock time or date; never assume the server's zone." : `Person's timezone: ${zone.timeZone} (from their ${zone.source}). Read and write dates and clock times in this zone unless the person names another.`;
506
+ }
507
+ //#endregion
859
508
  //#region ../../foundations/po-config/src/services/profileBinding/index.ts
860
509
  const BINDING_KEYS = /* @__PURE__ */ new Set([
861
510
  "provider",
@@ -869,18 +518,35 @@ const SECRET_KEYS = /* @__PURE__ */ new Set([
869
518
  "credentialId",
870
519
  "field",
871
520
  "purposes",
872
- "allowedOrigins"
521
+ "allowedOrigins",
522
+ "allowedTargets"
523
+ ]);
524
+ const VAULT_SECRET_KEYS = /* @__PURE__ */ new Set([
525
+ "vault",
526
+ "purposes",
527
+ "allowedOrigins",
528
+ "allowedTargets"
873
529
  ]);
874
530
  const BROWSER_KEYS = /* @__PURE__ */ new Set([
875
531
  "profileName",
876
532
  "allowedOrigins",
877
533
  "mode",
878
- "proxySecret"
534
+ "proxySecret",
535
+ "geoip",
536
+ "timezone",
537
+ "locale",
538
+ "fingerprint"
539
+ ]);
540
+ const FINGERPRINT_KEYS = /* @__PURE__ */ new Set([
541
+ "platform",
542
+ "seed",
543
+ "required"
879
544
  ]);
880
545
  const PURPOSES = /* @__PURE__ */ new Set([
881
546
  "browser",
882
547
  "proxy",
883
- "env"
548
+ "env",
549
+ "input"
884
550
  ]);
885
551
  const BROWSER_MODES = /* @__PURE__ */ new Set([
886
552
  "playwright",
@@ -890,6 +556,26 @@ const BROWSER_MODES = /* @__PURE__ */ new Set([
890
556
  const ALIAS_PATTERN = /^[A-Z][A-Z0-9_]{0,63}$/;
891
557
  const FIELD_PATTERN = /^(?:[A-Za-z][A-Za-z0-9_.-]{0,63}|profileSecret:[A-Z][A-Z0-9_]{0,63})$/;
892
558
  const BROWSER_PROFILE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
559
+ /** Browser-level defaults only. Every alias still requires its own exact recipient origins. */
560
+ const PROFILE_SOCIAL_BROWSER_ORIGINS = Object.freeze([
561
+ "https://x.com",
562
+ "https://www.x.com",
563
+ "https://twitter.com",
564
+ "https://www.twitter.com",
565
+ "https://reddit.com",
566
+ "https://www.reddit.com",
567
+ "https://linkedin.com",
568
+ "https://www.linkedin.com",
569
+ "https://facebook.com",
570
+ "https://www.facebook.com",
571
+ "https://instagram.com",
572
+ "https://www.instagram.com",
573
+ "https://tiktok.com",
574
+ "https://www.tiktok.com",
575
+ "https://youtube.com",
576
+ "https://www.youtube.com",
577
+ "https://accounts.google.com"
578
+ ]);
893
579
  function record(value, location, keys) {
894
580
  if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${location} must be a mapping`);
895
581
  if (keys && Object.keys(value).some((key) => !keys.has(key))) throw new Error(`${location} contains unsupported metadata`);
@@ -916,21 +602,118 @@ function origins(value, location) {
916
602
  }
917
603
  function purposes(value, location) {
918
604
  if (value === void 0) return Object.freeze(["browser"]);
919
- if (!Array.isArray(value) || value.length === 0 || value.some((entry) => typeof entry !== "string" || !PURPOSES.has(entry)) || new Set(value).size !== value.length) throw new Error(`${location} must list distinct purposes: browser, proxy or env`);
605
+ if (!Array.isArray(value) || value.length === 0 || value.some((entry) => typeof entry !== "string" || !PURPOSES.has(entry)) || new Set(value).size !== value.length) throw new Error(`${location} must list distinct purposes: browser, proxy, env or input`);
920
606
  return Object.freeze([...value]);
921
607
  }
608
+ function timezone(value, location) {
609
+ try {
610
+ if (typeof value === "string" && value.length <= 64) {
611
+ new Intl.DateTimeFormat("en-US", { timeZone: value });
612
+ return value;
613
+ }
614
+ } catch {}
615
+ throw new Error(`${location} must be an IANA timezone`);
616
+ }
617
+ function locale(value, location) {
618
+ try {
619
+ if (typeof value === "string" && value.length <= 35 && Intl.getCanonicalLocales(value).length === 1) return value;
620
+ } catch {}
621
+ throw new Error(`${location} must be a BCP 47 locale`);
622
+ }
623
+ function fingerprint(value, location) {
624
+ const entry = record(value, location, FINGERPRINT_KEYS);
625
+ if (entry.platform !== void 0 && entry.platform !== "windows" && entry.platform !== "macos") throw new Error(`${location}.platform must be windows or macos`);
626
+ if (entry.seed !== void 0 && (typeof entry.seed !== "number" || !Number.isInteger(entry.seed) || entry.seed < 1e4 || entry.seed > 99999)) throw new Error(`${location}.seed must be an integer from 10000 to 99999`);
627
+ if (entry.required !== void 0 && typeof entry.required !== "boolean") throw new Error(`${location}.required must be a boolean`);
628
+ return Object.freeze({
629
+ ...entry.platform === void 0 ? {} : { platform: entry.platform },
630
+ ...entry.seed === void 0 ? {} : { seed: entry.seed },
631
+ ...entry.required === void 0 ? {} : { required: entry.required }
632
+ });
633
+ }
922
634
  function browser(value, location) {
923
635
  const entry = record(value, location, BROWSER_KEYS);
924
636
  if (typeof entry.profileName !== "string" || !BROWSER_PROFILE_PATTERN.test(entry.profileName)) throw new Error(`${location}.profileName must be a safe browser profile name`);
925
637
  if (entry.mode !== void 0 && (typeof entry.mode !== "string" || !BROWSER_MODES.has(entry.mode))) throw new Error(`${location}.mode must be playwright, extension or stealth`);
926
638
  if (entry.proxySecret !== void 0 && (typeof entry.proxySecret !== "string" || !ALIAS_PATTERN.test(entry.proxySecret))) throw new Error(`${location}.proxySecret must be an uppercase alias name`);
639
+ if (entry.geoip !== void 0 && typeof entry.geoip !== "boolean") throw new Error(`${location}.geoip must be a boolean`);
640
+ const pinned = entry.fingerprint === void 0 ? void 0 : fingerprint(entry.fingerprint, `${location}.fingerprint`);
641
+ if (pinned?.required && entry.mode !== void 0 && entry.mode !== "playwright") throw new Error(`${location}.fingerprint.required needs playwright mode`);
927
642
  return Object.freeze({
928
643
  profileName: entry.profileName,
929
- allowedOrigins: origins(entry.allowedOrigins, `${location}.allowedOrigins`),
644
+ allowedOrigins: Object.freeze([.../* @__PURE__ */ new Set([...origins(entry.allowedOrigins, `${location}.allowedOrigins`), ...PROFILE_SOCIAL_BROWSER_ORIGINS])]),
930
645
  ...entry.mode === void 0 ? {} : { mode: entry.mode },
931
- ...entry.proxySecret === void 0 ? {} : { proxySecret: entry.proxySecret }
646
+ ...entry.proxySecret === void 0 ? {} : { proxySecret: entry.proxySecret },
647
+ ...entry.geoip === void 0 ? {} : { geoip: entry.geoip },
648
+ ...entry.timezone === void 0 ? {} : { timezone: timezone(entry.timezone, `${location}.timezone`) },
649
+ ...entry.locale === void 0 ? {} : { locale: locale(entry.locale, `${location}.locale`) },
650
+ ...pinned === void 0 ? {} : { fingerprint: pinned }
932
651
  });
933
652
  }
653
+ function targets(value, forInput, location) {
654
+ if (value === void 0) {
655
+ if (forInput) throw new Error(`${location} requires explicit input targets`);
656
+ return;
657
+ }
658
+ if (!forInput) throw new Error(`${location} requires the input purpose`);
659
+ const entries = record(value, location);
660
+ if (Object.keys(entries).length === 0) throw new Error(`${location} requires explicit input targets`);
661
+ const result = Object.create(null);
662
+ for (const [surface, list] of Object.entries(entries)) {
663
+ if (!/^[a-z][a-z0-9-]{0,63}$/.test(surface) || [
664
+ "browser",
665
+ "env",
666
+ "proxy",
667
+ "constructor",
668
+ "prototype"
669
+ ].includes(surface) || !Array.isArray(list) || list.length === 0 || list.some((entry) => typeof entry !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_.-]{0,255}$/.test(entry))) throw new Error(`${location} must map surfaces to exact application identifiers`);
670
+ result[surface] = Object.freeze([...new Set(list)]);
671
+ }
672
+ return Object.freeze(result);
673
+ }
674
+ function delivery(secret, location) {
675
+ const secretPurposes = purposes(secret.purposes, `${location}.purposes`);
676
+ const forBrowser = secretPurposes.includes("browser");
677
+ const emptyOrigins = Array.isArray(secret.allowedOrigins) && secret.allowedOrigins.length === 0;
678
+ if (!forBrowser && secret.allowedOrigins !== void 0 && !emptyOrigins) throw new Error(`${location}.allowedOrigins requires the browser purpose`);
679
+ const allowedTargets = targets(secret.allowedTargets, secretPurposes.includes("input"), `${location}.allowedTargets`);
680
+ return {
681
+ purposes: secretPurposes,
682
+ allowedOrigins: forBrowser ? origins(secret.allowedOrigins, `${location}.allowedOrigins`) : Object.freeze([]),
683
+ ...allowedTargets === void 0 ? {} : { allowedTargets }
684
+ };
685
+ }
686
+ /** Explicit vault aliases only. Templates never name a namespace or key themselves. */
687
+ function parseProfileVaultSecrets(value, location = "Profile secrets") {
688
+ const result = Object.create(null);
689
+ for (const [alias, valueEntry] of Object.entries(record(value, location))) {
690
+ if (!ALIAS_PATTERN.test(alias)) throw new Error(`${location} requires uppercase alias names`);
691
+ const secret = record(valueEntry, location, VAULT_SECRET_KEYS);
692
+ const vault = record(secret.vault, `${location}.vault`, /* @__PURE__ */ new Set([
693
+ "namespace",
694
+ "key",
695
+ "field"
696
+ ]));
697
+ if (typeof vault.namespace !== "string" || !/^[a-z][a-z0-9.-]{0,63}$/.test(vault.namespace) || typeof vault.key !== "string" || vault.key.length < 1 || vault.key.length > 512 || /\p{Cc}/u.test(vault.key)) throw new Error(`${location}.vault requires a valid namespace and key`);
698
+ const field = vault.field === void 0 ? void 0 : reference(vault.field, `${location}.vault.field`);
699
+ if (field !== void 0 && ([
700
+ "__proto__",
701
+ "prototype",
702
+ "constructor"
703
+ ].includes(field) || !FIELD_PATTERN.test(field))) throw new Error(`${location}.vault.field must be an own string field name`);
704
+ const scope = delivery(secret, location);
705
+ if (scope.purposes.some((purpose) => purpose !== "browser" && purpose !== "input")) throw new Error(`${location} vault aliases support browser and input purposes only`);
706
+ result[alias] = Object.freeze({
707
+ vault: Object.freeze({
708
+ namespace: vault.namespace,
709
+ key: vault.key,
710
+ ...field === void 0 ? {} : { field }
711
+ }),
712
+ ...scope
713
+ });
714
+ }
715
+ return Object.freeze(result);
716
+ }
934
717
  /** Validates and deeply freezes a detached metadata snapshot. No provider SDK or secret is loaded. */
935
718
  function parseProfileBinding(value, location = "Profile integration") {
936
719
  const entry = record(value, location, BINDING_KEYS);
@@ -940,15 +723,10 @@ function parseProfileBinding(value, location = "Profile integration") {
940
723
  if (!ALIAS_PATTERN.test(alias)) throw new Error(`${location}.secrets requires uppercase alias names`);
941
724
  const secret = record(value, `${location}.secrets.${alias}`, SECRET_KEYS);
942
725
  if (typeof secret.field !== "string" || !FIELD_PATTERN.test(secret.field)) throw new Error(`${location}.secrets.${alias}.field must be a credential field name`);
943
- const secretPurposes = purposes(secret.purposes, `${location}.secrets.${alias}.purposes`);
944
- const forBrowser = secretPurposes.includes("browser");
945
- const emptyOrigins = Array.isArray(secret.allowedOrigins) && secret.allowedOrigins.length === 0;
946
- if (!forBrowser && secret.allowedOrigins !== void 0 && !emptyOrigins) throw new Error(`${location}.secrets.${alias}.allowedOrigins requires the browser purpose`);
947
726
  secrets[alias] = Object.freeze({
948
727
  credentialId: reference(secret.credentialId, `${location}.secrets.${alias}.credentialId`),
949
728
  field: secret.field,
950
- purposes: secretPurposes,
951
- allowedOrigins: forBrowser ? origins(secret.allowedOrigins, `${location}.secrets.${alias}.allowedOrigins`) : Object.freeze([])
729
+ ...delivery(secret, `${location}.secrets.${alias}`)
952
730
  });
953
731
  }
954
732
  const browserBinding = entry.browser === void 0 ? void 0 : browser(entry.browser, `${location}.browser`);
@@ -976,7 +754,9 @@ const PERSONA_IDENTITY_FILE = "profile.md";
976
754
  const PROFILE_KEYS = /* @__PURE__ */ new Set([
977
755
  "persona",
978
756
  "env",
979
- "integration"
757
+ "integration",
758
+ "secrets",
759
+ "timezone"
980
760
  ]);
981
761
  const PROFILE_CATALOG_KEYS = /* @__PURE__ */ new Set([
982
762
  "roots",
@@ -986,7 +766,9 @@ const PROFILE_CATALOG_KEYS = /* @__PURE__ */ new Set([
986
766
  const SIDECAR_KEYS = /* @__PURE__ */ new Set([
987
767
  "version",
988
768
  "env",
989
- "integration"
769
+ "integration",
770
+ "secrets",
771
+ "timezone"
990
772
  ]);
991
773
  const SIDECAR_VERSION = 1;
992
774
  const SIDECAR_MAX_BYTES = 65536;
@@ -1008,11 +790,17 @@ function parseEnvironment(name, value) {
1008
790
  const environment = {};
1009
791
  for (const [key, entry] of Object.entries(value)) {
1010
792
  if (typeof entry !== "string") throw new Error(`Profile "${name}" env.${key} must be a string`);
1011
- if (entry.includes("${secret.") || entry.includes("${secrets.")) throw new Error(`Profile "${name}" env cannot contain secret aliases`);
793
+ if (/\$\{\s*secrets?\b|\{\{\s*secrets?\b/.test(entry)) throw new Error(`Profile "${name}" env cannot contain secret aliases`);
1012
794
  environment[key] = entry;
1013
795
  }
1014
796
  return environment;
1015
797
  }
798
+ /** The profile's own zone, spread into the profile only when declared. */
799
+ function parseTimezone(name, value) {
800
+ if (value === void 0) return {};
801
+ if (!isTimeZone(value)) throw new Error(`Profile "${name}" timezone must be an IANA zone such as Australia/Sydney`);
802
+ return { timezone: value };
803
+ }
1016
804
  /** Strict v1 sidecar parse. YAML errors are reported generically so source text never reaches a diagnostic. */
1017
805
  function parseProfileSidecar(name, text) {
1018
806
  if (Buffer.byteLength(text) > SIDECAR_MAX_BYTES) throw new Error(`Profile "${name}" ${PROFILE_SIDECAR_FILE} is too large`);
@@ -1023,11 +811,13 @@ function parseProfileSidecar(name, text) {
1023
811
  throw new Error(`Profile "${name}" ${PROFILE_SIDECAR_FILE} is not valid YAML`);
1024
812
  }
1025
813
  if (!isRecord$1(document)) throw new Error(`Profile "${name}" ${PROFILE_SIDECAR_FILE} must be a mapping`);
1026
- if (Object.keys(document).some((key) => !SIDECAR_KEYS.has(key))) throw new Error(`Profile "${name}" ${PROFILE_SIDECAR_FILE} may only set version, env and integration`);
814
+ if (Object.keys(document).some((key) => !SIDECAR_KEYS.has(key))) throw new Error(`Profile "${name}" ${PROFILE_SIDECAR_FILE} may only set version, env, integration, secrets and timezone`);
1027
815
  if (document.version !== SIDECAR_VERSION) throw new Error(`Profile "${name}" ${PROFILE_SIDECAR_FILE} must declare version: ${SIDECAR_VERSION}`);
1028
816
  return {
1029
817
  env: parseEnvironment(name, document.env),
1030
- ...document.integration === void 0 ? {} : { integration: parseProfileBinding(document.integration, `Profile "${name}" integration`) }
818
+ ...document.secrets === void 0 ? {} : { secrets: parseProfileVaultSecrets(document.secrets) },
819
+ ...document.integration === void 0 ? {} : { integration: parseProfileBinding(document.integration, `Profile "${name}" integration`) },
820
+ ...parseTimezone(name, document.timezone)
1031
821
  };
1032
822
  }
1033
823
  function sidecarDiagnostic(filePath, profile, error) {
@@ -1069,13 +859,45 @@ function parseProfileLayer(source) {
1069
859
  };
1070
860
  }
1071
861
  /**
862
+ * The profiles.yaml text that also lists `root` in `profiles.roots`, or undefined when it already does.
863
+ * Comments and every other key are kept, a flat-form file moves under `entries`, and `defaultProfile` is never set.
864
+ */
865
+ function withProfileRoot(text, filePath, baseDirectory, root) {
866
+ const document = parseDocument(text);
867
+ if (document.errors.length > 0) throw new Error(`${filePath} is not valid YAML`);
868
+ const current = document.toJS();
869
+ if (current === null || current === void 0) return stringify({ [PROFILES_ROOT_KEY]: { roots: [root] } });
870
+ if (parseProfileLayer({
871
+ filePath,
872
+ baseDirectory,
873
+ document: current
874
+ }).roots.includes(path.resolve(baseDirectory, root))) return void 0;
875
+ const profiles = document.get(PROFILES_ROOT_KEY, true);
876
+ if (!isMap(profiles)) throw new Error(`${filePath} must contain a profiles mapping`);
877
+ const roots = profiles.get("roots", true);
878
+ if (isSeq(roots)) roots.add(document.createNode(root));
879
+ else if (profiles.has("entries") || profiles.items.length === 0) profiles.set("roots", document.createNode([root]));
880
+ else {
881
+ const catalog = new YAMLMap();
882
+ catalog.set("roots", document.createNode([root]));
883
+ catalog.set("entries", profiles);
884
+ document.set(PROFILES_ROOT_KEY, catalog);
885
+ }
886
+ const output = document.toString();
887
+ parseProfileLayer({
888
+ filePath,
889
+ baseDirectory,
890
+ document: parse(output)
891
+ });
892
+ return output;
893
+ }
894
+ /**
1072
895
  * Shape checks for one explicit entry. The caller checks the persona on disk,
1073
896
  * then `profileFromDraft` parses env and integration, keeping the error order.
1074
897
  */
1075
898
  function draftProfileEntry(personaRoot, configuredRoots, name, value) {
1076
899
  if (!isRecord$1(value)) throw new Error(`Profile "${name}" must be a mapping`);
1077
- const unsupported = Object.keys(value).filter((key) => !PROFILE_KEYS.has(key));
1078
- if (unsupported.length > 0) throw new Error(`Profile "${name}" may only set persona, env and integration; unsupported: ${unsupported.join(", ")}`);
900
+ if (Object.keys(value).filter((key) => !PROFILE_KEYS.has(key)).length > 0) throw new Error(`Profile "${name}" may only set persona, env, integration, secrets or timezone; unsupported metadata`);
1079
901
  if (typeof value.persona !== "string" || value.persona.trim().length === 0) throw new Error(`Profile "${name}" must set a persona`);
1080
902
  if (path.isAbsolute(value.persona)) throw new Error(`Profile "${name}" persona must be relative to the config that declares it`);
1081
903
  const persona = value.persona;
@@ -1110,7 +932,9 @@ function profileFromDraft(draft, personaRoot, presentation) {
1110
932
  persona: draft.persona,
1111
933
  personaRoot,
1112
934
  env: parseEnvironment(name, value.env),
935
+ ...value.secrets === void 0 ? {} : { secrets: parseProfileVaultSecrets(value.secrets) },
1113
936
  ...value.integration === void 0 ? {} : { integration: parseProfileBinding(value.integration, `Profile "${name}" integration`) },
937
+ ...parseTimezone(name, value.timezone),
1114
938
  ...presentation
1115
939
  };
1116
940
  }
@@ -1170,7 +994,9 @@ function inlineProfile(input) {
1170
994
  persona: source,
1171
995
  personaRoot: "",
1172
996
  env: parseEnvironment(name, input.env),
997
+ ...input.secrets === void 0 ? {} : { secrets: parseProfileVaultSecrets(input.secrets) },
1173
998
  ...input.integration === void 0 ? {} : { integration: parseProfileBinding(input.integration, `Profile "${name}" integration`) },
999
+ ...parseTimezone(name, input.timezone),
1174
1000
  ...presentation,
1175
1001
  ...Object.keys(identity).length === 0 ? {} : { identity },
1176
1002
  personaPrompt
@@ -1180,19 +1006,6 @@ function sortProfiles(byName) {
1180
1006
  return [...byName.values()].sort((left, right) => left.name.localeCompare(right.name));
1181
1007
  }
1182
1008
  //#endregion
1183
- //#region ../../foundations/po-config/src/services/profiles/sync.edge.ts
1184
- function nodeOnly(name, asyncName) {
1185
- throw new Error(`${name} is Node-only; use ${asyncName} with a PoPlatform on the edge.`);
1186
- }
1187
- /** @deprecated Node-only sync shim; use loadProfilesAsync. Removed in M2. */
1188
- function loadProfiles(_repoRoot, _homeDirectory) {
1189
- return nodeOnly("loadProfiles", "loadProfilesAsync");
1190
- }
1191
- /** @deprecated Node-only sync shim; use buildPersonaPromptAsync. Removed in M2. */
1192
- function buildPersonaPrompt(_personaRoot, _personaDirectory) {
1193
- return nodeOnly("buildPersonaPrompt", "buildPersonaPromptAsync");
1194
- }
1195
- //#endregion
1196
1009
  //#region ../../foundations/po-config/src/services/profiles/index.ts
1197
1010
  /** Profile reads over a FileSystem; the Node shims in `./sync` give the same answers from node:fs. */
1198
1011
  const realPath = async (fs, target, context) => getOrThrow(await fs.canonicalPath(target, context));
@@ -1322,8 +1135,41 @@ async function profilesFromLayers(fs, layers, context, diagnostics = []) {
1322
1135
  async function loadProfilesAsync(fs, repoRoot, context, homeDirectory = nodeHost.homeDirectory()) {
1323
1136
  return profilesFromLayers(fs, await readProfileLayers(fs, repoRoot, context, homeDirectory), context);
1324
1137
  }
1138
+ /** Thrown when `~/.po/profiles.yaml` changed between planning and committing a root. */
1139
+ var ProfileCatalogChangedError = class extends Error {
1140
+ constructor(filePath) {
1141
+ super(`${filePath} changed while it was being updated`);
1142
+ this.name = "ProfileCatalogChangedError";
1143
+ }
1144
+ };
1145
+ const profileCatalogWrites = createSerialRunner();
1146
+ /** Reads the personal profiles.yaml and computes the text that lists `root`. Throws when the file is invalid. */
1147
+ async function planGlobalProfileRootAsync(fs, homeDirectory, root, context) {
1148
+ const [candidate] = poConfigCandidates(PROFILES_FILE, homeDirectory, homeDirectory);
1149
+ if (!candidate) throw new Error("No personal profiles.yaml location");
1150
+ const before = await readTextIfExists(fs, candidate.filePath, context);
1151
+ return {
1152
+ filePath: candidate.filePath,
1153
+ before,
1154
+ next: withProfileRoot(before ?? "", candidate.filePath, candidate.baseDirectory, root)
1155
+ };
1156
+ }
1157
+ /** Writes a plan unless the file changed since it was read, which throws ProfileCatalogChangedError. */
1158
+ async function commitGlobalProfileRootAsync(fs, plan, context) {
1159
+ await profileCatalogWrites.forKey(path.resolve(plan.filePath))(async () => {
1160
+ if (await readTextIfExists(fs, plan.filePath, context) !== plan.before) throw new ProfileCatalogChangedError(plan.filePath);
1161
+ if (plan.next !== void 0) await writeFileAtomic(fs, plan.filePath, plan.next, context);
1162
+ });
1163
+ }
1325
1164
  //#endregion
1326
1165
  //#region ../../foundations/po-config/src/services/settings/index.ts
1166
+ /** The mount's admitted home and environment, so no reader falls back to the host's. */
1167
+ function readOptions(homeDirectory, environment) {
1168
+ return {
1169
+ ...homeDirectory === void 0 ? {} : { homeDirectory },
1170
+ environment
1171
+ };
1172
+ }
1327
1173
  function isRecord(value) {
1328
1174
  return typeof value === "object" && value !== null && !Array.isArray(value);
1329
1175
  }
@@ -1376,12 +1222,13 @@ function configuredSelectionValue(layers, key, effective) {
1376
1222
  origin
1377
1223
  };
1378
1224
  }
1379
- function repositorySettingsView(repository, homeDirectory, environment) {
1225
+ async function repositorySettingsView(fs, repository, homeDirectory, environment, io) {
1380
1226
  const repoRoot = repository.path;
1381
- const layers = loadPoConfigLayers(repoRoot, homeDirectory, environment);
1382
- const modes = loadMajorModesConfig(repoRoot, homeDirectory, environment);
1383
- const domains = loadDomains(repoRoot, homeDirectory);
1384
- const profiles = loadProfiles(repoRoot, homeDirectory);
1227
+ const options = readOptions(homeDirectory, environment);
1228
+ const layers = await readPoConfigLayers(fs, repoRoot, io, options);
1229
+ const modes = await readMajorModesConfig(fs, repoRoot, io, options);
1230
+ const domains = await loadDomainsAsync(fs, repoRoot, io, homeDirectory);
1231
+ const profiles = await loadProfilesAsync(fs, repoRoot, io, homeDirectory);
1385
1232
  const configured = layers.effective.selection;
1386
1233
  const effectiveMajorMode = configured?.majorMode ?? modes.defaultMajorMode;
1387
1234
  const effectiveDomains = configured?.domains ?? defaultDomainsForMajorMode(effectiveMajorMode, {}, domains.defaultDomains);
@@ -1460,9 +1307,9 @@ function selectionEdits(changes) {
1460
1307
  ...value === null ? {} : { value }
1461
1308
  }));
1462
1309
  }
1463
- function configView(context, keys) {
1310
+ async function configView(fs, context, keys, io) {
1464
1311
  const root = context.scope === "workspace" ? context.workspaceRoot : void 0;
1465
- const layers = loadPoConfigLayers(root, context.homeDirectory, context.environment ?? {});
1312
+ const layers = await readPoConfigLayers(fs, root, io, readOptions(context.homeDirectory, context.environment ?? {}));
1466
1313
  const values = {};
1467
1314
  for (const key of keys) {
1468
1315
  const keyPath = key.split(".");
@@ -1486,7 +1333,7 @@ function configView(context, keys) {
1486
1333
  //#region ../../foundations/po-config/src/services/settingsApi/index.ts
1487
1334
  /**
1488
1335
  * Config handlers are bound to their mount. Request paths cannot choose a different repository.
1489
- * Writes and image settings go through the host's FileSystem.
1336
+ * Reads, writes and image settings all go through the host's FileSystem.
1490
1337
  */
1491
1338
  const createSettingsApi = (fs) => ({
1492
1339
  basePath: "settings",
@@ -1520,9 +1367,9 @@ const createSettingsApi = (fs) => ({
1520
1367
  */
1521
1368
  const addresses = (route) => url.pathname === route.path && request.method === route.method;
1522
1369
  const currentRepository = repository();
1523
- if (addresses(apiRoutes_default.config)) return Response.json(configView(context, url.searchParams.getAll("key")));
1370
+ if (addresses(apiRoutes_default.config)) return Response.json(await configView(fs, context, url.searchParams.getAll("key"), io));
1524
1371
  if (addresses(apiRoutes_default.repositories)) return Response.json({ repositories: context.repositories?.() ?? [] });
1525
- if (addresses(apiRoutes_default.repository)) return currentRepository ? Response.json(repositorySettingsView(currentRepository, homeDirectory, environment)) : Response.json({ error: "Choose a workspace." }, { status: 404 });
1372
+ if (addresses(apiRoutes_default.repository)) return currentRepository ? Response.json(await repositorySettingsView(fs, currentRepository, homeDirectory, environment, io)) : Response.json({ error: "Choose a workspace." }, { status: 404 });
1526
1373
  if (url.pathname === apiRoutes_default.images.path && context.scope === "global") {
1527
1374
  if (request.method === apiRoutes_default.images.method) return Response.json(await imageView());
1528
1375
  if (request.method === apiRoutes_default.saveImages.method) {
@@ -1536,11 +1383,23 @@ const createSettingsApi = (fs) => ({
1536
1383
  return Response.json(await imageView());
1537
1384
  }
1538
1385
  }
1386
+ if (url.pathname === apiRoutes_default.presets.path && context.scope === "global") {
1387
+ if (!homeDirectory) return Response.json({ error: "Po has no home directory here." }, { status: 503 });
1388
+ if (request.method === apiRoutes_default.presets.method) return Response.json(await readPresetsView(fs, homeDirectory, environment));
1389
+ if (request.method === apiRoutes_default.savePresets.method) {
1390
+ const body = await request.json();
1391
+ if (!isRecord(body) || typeof body.defaultPreset !== "string" || !body.defaultPreset.trim()) return Response.json({ error: "Choose a preset." }, { status: 400 });
1392
+ const result = await writeDefaultPreset(fs, homeDirectory, environment, body.defaultPreset.trim());
1393
+ if ("error" in result) return Response.json(result, { status: 422 });
1394
+ context.configurationChanged?.();
1395
+ return Response.json(result);
1396
+ }
1397
+ }
1539
1398
  if (addresses(apiRoutes_default.selection)) {
1540
1399
  const body = parseSelectionWrite(await request.json());
1541
1400
  if (!body) return Response.json({ error: "A selection write needs typed changes and a file hash." }, { status: 400 });
1542
1401
  if (!currentRepository || body.repositoryId !== currentRepository.id) return Response.json({ error: "Workspace not found in this mount." }, { status: 404 });
1543
- const before = repositorySettingsView(currentRepository, homeDirectory, environment);
1402
+ const before = await repositorySettingsView(fs, currentRepository, homeDirectory, environment, io);
1544
1403
  if (before.hash !== body.expectedHash) return Response.json({
1545
1404
  error: "The repository config changed since it was read.",
1546
1405
  hash: before.hash
@@ -1549,7 +1408,7 @@ const createSettingsApi = (fs) => ({
1549
1408
  if (invalid) return Response.json({ error: invalid }, { status: 422 });
1550
1409
  await writePoConfigValuesAsync(fs, repositoryPoConfigPath(currentRepository.path), selectionEdits(body.changes), io, { scope: "repository" });
1551
1410
  context.configurationChanged?.();
1552
- return Response.json(repositorySettingsView(currentRepository, homeDirectory, environment));
1411
+ return Response.json(await repositorySettingsView(fs, currentRepository, homeDirectory, environment, io));
1553
1412
  }
1554
1413
  if (addresses(apiRoutes_default.value)) {
1555
1414
  const body = parseWrite(await request.json());
@@ -1560,7 +1419,7 @@ const createSettingsApi = (fs) => ({
1560
1419
  const allowed = configScopeOf(edit.keyPath);
1561
1420
  return allowed !== "both" && allowed !== scope;
1562
1421
  })) return Response.json({ error: "This key cannot be set at this scope." }, { status: 409 });
1563
- const before = configView(context, []);
1422
+ const before = await configView(fs, context, [], io);
1564
1423
  if (before.hashes[scope] !== body.expectedHash) return Response.json({
1565
1424
  error: "The config changed since it was read.",
1566
1425
  hash: before.hashes[scope]
@@ -1570,7 +1429,7 @@ const createSettingsApi = (fs) => ({
1570
1429
  ...value === null ? {} : { value }
1571
1430
  })), io, { scope });
1572
1431
  context.configurationChanged?.();
1573
- return Response.json(configView(context, body.edits.map((edit) => edit.keyPath.join("."))));
1432
+ return Response.json(await configView(fs, context, body.edits.map((edit) => edit.keyPath.join(".")), io));
1574
1433
  }
1575
1434
  return Response.json({ error: "Configuration route not found." }, { status: 404 });
1576
1435
  };
@@ -1595,218 +1454,149 @@ const createSettingsApi = (fs) => ({
1595
1454
  }
1596
1455
  });
1597
1456
  //#endregion
1598
- //#region ../../core/po-core/src/schemas/config.ts
1599
- /**
1600
- * Configuration surfaces, contributed by every extension that owns settings.
1601
- *
1602
- * Po settings live in one YAML file but are owned by many extensions, and for
1603
- * a long time the only way to change any of them was to edit that file by hand.
1604
- * The one exception, an editor-command prompt, asked for a value with no way to
1605
- * see what a valid one looked like.
1606
- *
1607
- * So configuration is published rather than centralised: an extension describes
1608
- * its own fields, one renderer draws them all, and the extension still performs
1609
- * every write. Nothing here knows what a voice model or an editor command is.
1610
- *
1611
- * Deliberately the same shape as the mode and footer contracts next door, since
1612
- * the problem is the same one: several extensions sharing one surface. The UI
1613
- * hub invokes an owner's registered action directly, because unlike a status
1614
- * strip this surface is written to as well as read.
1615
- */
1616
- /** Canonical Cordis key for the session-owned Po configuration service. */
1617
- const PO_CONFIG_SERVICE = "po/config";
1618
- /** Matches the leader contract's source rule: package names, addressable and spoof-checkable. */
1619
- const ConfigSourceSchema = String$1({
1620
- minLength: 1,
1621
- maxLength: 128,
1622
- pattern: "^[A-Za-z0-9@][A-Za-z0-9@/._:-]*$"
1623
- });
1624
- const ConfigIdSchema = String$1({
1625
- minLength: 1,
1626
- maxLength: 128,
1627
- pattern: "^[a-z0-9][a-z0-9._:-]*$"
1628
- });
1629
- /**
1630
- * How ready a value is to be used, as opposed to whether it is merely set.
1631
- * `blocked` covers a choice that needs something else first, such as a model
1632
- * whose engine is not installed.
1633
- */
1634
- const ConfigStatusSchema = Union([
1635
- Literal("ready"),
1636
- Literal("available"),
1637
- Literal("blocked")
1638
- ]);
1639
- const ConfigFieldKindSchema = Union([
1640
- Literal("text"),
1641
- Literal("enum"),
1642
- Literal("choice"),
1643
- Literal("info")
1644
- ]);
1645
- /**
1646
- * A key the renderer offers on the focused field, sent back verbatim as an
1647
- * action. Owners use this for confirmations, so the pending question survives a
1648
- * panel that is closed and reopened.
1649
- */
1650
- const ConfigActionSchema = _Object_({
1651
- key: String$1({
1652
- minLength: 1,
1653
- maxLength: 1
1654
- }),
1655
- label: String$1({
1656
- minLength: 1,
1657
- maxLength: 24
1658
- }),
1659
- action: ConfigIdSchema
1660
- }, { additionalProperties: false });
1661
- const ConfigChoiceSchema = _Object_({
1662
- id: String$1({
1663
- minLength: 1,
1664
- maxLength: 256
1665
- }),
1666
- label: String$1({
1667
- minLength: 1,
1668
- maxLength: 96
1669
- }),
1670
- /** Right-aligned by the renderer. Sizes, ids, anything narrow. */
1671
- detail: Optional(String$1({
1672
- minLength: 1,
1673
- maxLength: 96
1674
- })),
1675
- /** Groups entries under a heading the cursor skips over. */
1676
- group: Optional(String$1({
1677
- minLength: 1,
1678
- maxLength: 48
1679
- })),
1680
- status: Optional(ConfigStatusSchema),
1681
- statusText: Optional(String$1({
1682
- minLength: 1,
1683
- maxLength: 96
1684
- })),
1685
- /**
1686
- * What enter does on this entry. Carrying it per-entry is what lets one list
1687
- * hold both an installed model that only needs selecting and an absent one
1688
- * that needs fetching, without the renderer knowing the difference.
1689
- */
1690
- action: Optional(ConfigIdSchema)
1691
- }, { additionalProperties: false });
1692
- /**
1693
- * One line of a multi-step operation.
1694
- *
1695
- * Published as a list rather than a single "current step" string so the panel can
1696
- * show what already ran alongside what is left. During an install that is the
1697
- * difference between "something is happening" and knowing a package manager
1698
- * already finished and a download is now underway.
1699
- */
1700
- const ConfigStepSchema = _Object_({
1701
- label: String$1({
1702
- minLength: 1,
1703
- maxLength: 96
1704
- }),
1705
- state: Union([
1706
- Literal("pending"),
1707
- Literal("satisfied"),
1708
- Literal("running"),
1709
- Literal("done"),
1710
- Literal("failed")
1711
- ]),
1712
- detail: Optional(String$1({
1713
- minLength: 1,
1714
- maxLength: 160
1715
- }))
1716
- }, { additionalProperties: false });
1717
- const ConfigProgressSchema = _Object_({
1718
- label: String$1({
1719
- minLength: 1,
1720
- maxLength: 96
1721
- }),
1722
- /** 0 to 1. Omitted when the work has no measurable total. */
1723
- ratio: Optional(Number$1({
1724
- minimum: 0,
1725
- maximum: 1
1726
- }))
1727
- }, { additionalProperties: false });
1728
- const ConfigFieldSchema = _Object_({
1729
- id: ConfigIdSchema,
1730
- label: String$1({
1731
- minLength: 1,
1732
- maxLength: 48
1733
- }),
1734
- kind: ConfigFieldKindSchema,
1735
- /** Absent means unset; the renderer shows `placeholder` instead. */
1736
- value: Optional(String$1({
1737
- minLength: 1,
1738
- maxLength: 4096
1739
- })),
1740
- placeholder: Optional(String$1({
1741
- minLength: 1,
1742
- maxLength: 96
1743
- })),
1744
- /** One line of help for the focused field. */
1745
- detail: Optional(String$1({
1746
- minLength: 1,
1747
- maxLength: 240
1748
- })),
1749
- /** The config key this writes, shown under the focused field so the file stays legible. */
1750
- keyPath: Optional(String$1({
1751
- minLength: 1,
1752
- maxLength: 128
1753
- })),
1754
- status: Optional(ConfigStatusSchema),
1755
- /** Doubles as the error line: a rejected edit comes back as the old value plus this. */
1756
- statusText: Optional(String$1({
1757
- minLength: 1,
1758
- maxLength: 240
1759
- })),
1760
- choices: Optional(_Array_(ConfigChoiceSchema, { maxItems: 128 })),
1761
- actions: Optional(_Array_(ConfigActionSchema, { maxItems: 4 })),
1762
- /** Work is running; the renderer dims the field and offers abort. */
1763
- busy: Optional(Boolean()),
1764
- progress: Optional(ConfigProgressSchema),
1765
- steps: Optional(_Array_(ConfigStepSchema, { maxItems: 24 })),
1766
- /**
1767
- * The tail of a running command's terminal output.
1768
- *
1769
- * A tail rather than the whole scrollback: the field is a few rows of a
1770
- * shared pane, and what matters is the question a package manager just
1771
- * asked, not what it printed a minute ago.
1772
- */
1773
- output: Optional(_Array_(String$1({ maxLength: 512 }), { maxItems: 64 })),
1774
- /**
1775
- * The command is waiting on the user. The renderer offers a line to type
1776
- * into, which comes back as an owner-defined action carrying the text.
1777
- */
1778
- awaitingInput: Optional(Boolean())
1779
- }, { additionalProperties: false });
1780
- const ConfigSectionSchema = _Object_({
1781
- id: ConfigIdSchema,
1782
- title: String$1({
1783
- minLength: 1,
1784
- maxLength: 32
1785
- }),
1786
- detail: Optional(String$1({
1787
- minLength: 1,
1788
- maxLength: 96
1789
- })),
1790
- order: Integer({
1791
- minimum: 0,
1792
- maximum: 1e3
1793
- }),
1794
- /** Section-wide state: readiness, or why a write failed. */
1795
- notice: Optional(String$1({
1796
- minLength: 1,
1797
- maxLength: 240
1798
- })),
1799
- noticeLevel: Optional(Union([Literal("info"), Literal("error")])),
1800
- fields: _Array_(ConfigFieldSchema, { maxItems: 64 })
1801
- }, { additionalProperties: false });
1802
- const ConfigSourceRefSchema = _Object_({
1803
- source: ConfigSourceSchema,
1804
- generation: String$1({ minLength: 1 })
1805
- }, { additionalProperties: false });
1806
- _Object_({
1807
- ...ConfigSourceRefSchema.properties,
1808
- sections: _Array_(ConfigSectionSchema, { maxItems: 32 })
1809
- }, { additionalProperties: false });
1457
+ //#region ../../core/po-core/src/services/toolCost/index.ts
1458
+ /** Mirrors the wire shape MCP advertises, so both estimates stay comparable. */
1459
+ function schemaPayload(entry) {
1460
+ return JSON.stringify({
1461
+ name: entry.name,
1462
+ ...entry.description === void 0 ? {} : { description: entry.description },
1463
+ ...entry.parameters === void 0 ? {} : { parameters: entry.parameters }
1464
+ });
1465
+ }
1466
+ function promptPayload(entry) {
1467
+ return [entry.promptSnippet ?? "", ...entry.promptGuidelines ?? []].filter(Boolean).join("\n");
1468
+ }
1469
+ function tokensForTool(entry, countTokens) {
1470
+ const schemaTokens = countTokens(schemaPayload(entry));
1471
+ const prompt = promptPayload(entry);
1472
+ const promptTokens = prompt.length === 0 ? 0 : countTokens(prompt);
1473
+ return {
1474
+ schemaTokens,
1475
+ promptTokens,
1476
+ totalTokens: schemaTokens + promptTokens
1477
+ };
1478
+ }
1479
+ /** Journal entry the cockpit reads; mirrored by CONTEXT_ENTRY_TYPE in po-web. */
1480
+ const PO_CONTEXT_ENTRY_TYPE = "po-context";
1481
+ /** Session selection and transition journal identities, not transport channels. */
1482
+ const PO_CONFIG_ENTRY_TYPE = "po:config:v1";
1483
+ const PO_CONFIG_TRANSITION_ENTRY_TYPE = "po:transition:v1";
1484
+ /** The tokenizer these counts came from, so a reader can judge them. */
1485
+ const CONTEXT_PROJECTION_ESTIMATOR = "gpt-tokenizer";
1486
+ /** Everything the runtime could not attribute lands here rather than vanishing. */
1487
+ const CORE_GROUP = "core";
1488
+ /** Pi's own tools have no package; the runtime itself is the owner. */
1489
+ const CORE_OWNER = "pi";
1490
+ const KIND_ORDER = {
1491
+ major: 0,
1492
+ minor: 1,
1493
+ domain: 2,
1494
+ shared: 3,
1495
+ core: 4
1496
+ };
1497
+ const SOURCE_ORDER = {
1498
+ extension: 0,
1499
+ mcp: 1,
1500
+ plugin: 2,
1501
+ core: 3
1502
+ };
1503
+ /** Reads only replayable selection fields, accepting legacy projections without a request marker. */
1504
+ function readProjectedSelection(data) {
1505
+ if (typeof data !== "object" || data === null || Array.isArray(data) || !("selection" in data)) return void 0;
1506
+ const selection = data.selection;
1507
+ if (typeof selection !== "object" || selection === null || Array.isArray(selection)) return void 0;
1508
+ if (!("majorMode" in selection) || typeof selection.majorMode !== "string") return void 0;
1509
+ if (!("domains" in selection) || !Array.isArray(selection.domains) || !selection.domains.every((domain) => typeof domain === "string")) return void 0;
1510
+ const profile = "profile" in selection ? selection.profile : void 0;
1511
+ if (profile !== void 0 && typeof profile !== "string") return void 0;
1512
+ const requestedProfile = "requestedProfile" in selection ? selection.requestedProfile : void 0;
1513
+ return {
1514
+ majorMode: selection.majorMode,
1515
+ domains: [...selection.domains],
1516
+ profile,
1517
+ ...typeof requestedProfile === "string" || requestedProfile === null ? { requestedProfile } : {}
1518
+ };
1519
+ }
1520
+ function skillSource(group) {
1521
+ if (group === "plugins") return "plugin";
1522
+ if (group === "extensions") return "extension";
1523
+ return "core";
1524
+ }
1525
+ function byRow(left, right) {
1526
+ return SOURCE_ORDER[left.source] - SOURCE_ORDER[right.source] || left.name.localeCompare(right.name);
1527
+ }
1528
+ function projectContext(input) {
1529
+ const buckets = /* @__PURE__ */ new Map();
1530
+ const declare = (id, label, kind) => {
1531
+ if (!buckets.has(id)) buckets.set(id, {
1532
+ kind,
1533
+ label,
1534
+ items: []
1535
+ });
1536
+ };
1537
+ if (input.majorMode) declare(input.majorMode, input.majorMode, "major");
1538
+ for (const group of input.groups) declare(group.id, group.label, group.kind);
1539
+ for (const domain of input.domains) declare(domain, domain, "domain");
1540
+ const place = (owner, item, conditional) => {
1541
+ const attributed = conditional ?? input.attribution[owner];
1542
+ const id = attributed?.mode ?? CORE_GROUP;
1543
+ const kind = attributed?.kind ?? "core";
1544
+ declare(id, attributed && "label" in attributed ? attributed.label ?? id : id, kind);
1545
+ buckets.get(id)?.items.push(item);
1546
+ };
1547
+ for (const source of input.sources) {
1548
+ const owner = source.kind === "extension" ? source.packageName ?? source.key : source.kind === "mcp" ? source.key.slice(4) : CORE_OWNER;
1549
+ for (const tool of source.tools) {
1550
+ const cost = tokensForTool(tool, input.countTokens);
1551
+ const item = {
1552
+ name: tool.name,
1553
+ itemKind: "tool",
1554
+ source: source.kind === "core" ? "core" : source.kind,
1555
+ owner,
1556
+ tokens: cost.totalTokens,
1557
+ active: tool.active
1558
+ };
1559
+ if (source.kind === "core") {
1560
+ declare(CORE_GROUP, CORE_GROUP, "core");
1561
+ buckets.get(CORE_GROUP)?.items.push(item);
1562
+ } else place(owner, item, tool.contextAttribution);
1563
+ }
1564
+ }
1565
+ for (const skill of input.skills) place(skill.owner, {
1566
+ name: skill.name,
1567
+ itemKind: "skill",
1568
+ source: skillSource(skill.group),
1569
+ owner: skill.owner,
1570
+ tokens: skill.promptTokens ?? 0,
1571
+ active: true
1572
+ }, skill.contextAttribution);
1573
+ const groups = [...buckets.entries()].map(([id, bucket]) => {
1574
+ const items = [...bucket.items].sort(byRow);
1575
+ return {
1576
+ id,
1577
+ label: bucket.label,
1578
+ kind: bucket.kind,
1579
+ items,
1580
+ tokens: items.reduce((total, item) => total + (item.active ? item.tokens : 0), 0),
1581
+ inactiveTokens: items.reduce((total, item) => total + (item.active ? 0 : item.tokens), 0)
1582
+ };
1583
+ }).sort((left, right) => KIND_ORDER[left.kind] - KIND_ORDER[right.kind] || left.label.localeCompare(right.label));
1584
+ return {
1585
+ version: 1,
1586
+ revision: input.revision,
1587
+ selection: {
1588
+ majorMode: input.majorMode,
1589
+ domains: [...input.domains],
1590
+ ...input.profile === void 0 ? {} : { profile: input.profile },
1591
+ ...input.requestedProfile === void 0 ? {} : { requestedProfile: input.requestedProfile }
1592
+ },
1593
+ groups,
1594
+ totalTokens: groups.reduce((total, group) => total + group.tokens, 0),
1595
+ inactiveTokens: groups.reduce((total, group) => total + group.inactiveTokens, 0),
1596
+ ...input.systemPrompt === void 0 ? {} : { systemPrompt: input.systemPrompt },
1597
+ estimator: CONTEXT_PROJECTION_ESTIMATOR
1598
+ };
1599
+ }
1810
1600
  //#endregion
1811
1601
  //#region ../../foundations/po-config/src/services/poConfigService/index.ts
1812
1602
  function deepFreeze$1(value) {
@@ -1958,4 +1748,4 @@ function providePoConfigContext(ctx, context, generation = `po-config:${crypto.r
1958
1748
  return new PoConfigService(ctx, deepFreeze(context), loadPoConfig, generation);
1959
1749
  }
1960
1750
  //#endregion
1961
- export { loadProfilesAsync as a, inlineProfile as c, createSettingsApi as i, parseProfileBinding as l, providePoConfigContext as n, buildPersonaPrompt as o, PO_CONFIG_SERVICE as r, loadProfiles as s, createNativePoConfigContext as t };
1751
+ export { loadPoConfig as S, personTimeZoneLine as _, readProjectedSelection as a, PROFILE_ICON_MAX_DATA_URL_LENGTH as b, ProfileCatalogChangedError as c, planGlobalProfileRootAsync as d, inlineProfile as f, isTimeZone as g, PO_PERSON_TIME_ZONE_SERVICE as h, projectContext as i, commitGlobalProfileRootAsync as l, parseProfileVaultSecrets as m, providePoConfigContext as n, tokensForTool as o, parseProfileBinding as p, PO_CONTEXT_ENTRY_TYPE as r, createSettingsApi as s, createNativePoConfigContext as t, loadProfilesAsync as u, readPoPersonTimeZone as v, PROFILE_ICON_MIME_TYPES as x, PO_PROFILE_IDENTITY_ENTRY_TYPE as y };