@agimon-ai/po-cloudflare 0.0.2-alpha.7 → 0.0.2-alpha.71
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.
- package/README.md +64 -241
- package/container/Dockerfile +27 -0
- package/dist/{BrowserWebSocketTransport-C2SC2VeJ.js → BrowserWebSocketTransport-B4heNdrp.js} +1 -1
- package/dist/{NodeWebSocketTransport-CKilJesa.js → NodeWebSocketTransport-BCiOXUEz.js} +2 -2
- package/dist/{abort-signals-Bkmp_euQ.js → abort-signals-C8CttjsR.js} +1 -1
- package/dist/agent-CEqvgRl6.js +3878 -0
- package/dist/{anthropic-messages-CkYm8M3V.js → anthropic-messages-DCLLLNuM.js} +292 -64
- package/dist/apiContracts-DaOpUHnu.js +1719 -0
- package/dist/{approval-CQ3ZuoTy.js → approval-DXPV7Vm5.js} +15 -2
- package/dist/{approvalPrompt-CylV3C84.js → approvalPrompt-CBaxjb_g.js} +1 -2
- package/dist/approvalSession-C9bg7tPo.js +132 -0
- package/dist/artifactFiles-5KwXIxYf.js +1 -0
- package/dist/artifactsApi-bg2wMYWg.js +200 -0
- package/dist/assets/assets/{CodeEditorView-D4q94XH-.js → CodeEditorView-CfrVwzvL.js} +2 -2
- package/dist/assets/assets/{abnfDiagram-WEYOIA3C-C85p4OYZ.js → abnfDiagram-WEYOIA3C-B80H4Cm4.js} +2 -2
- package/dist/assets/assets/{architecture-WOLXFQ4H-Bt_NOdwE.js → architecture-WOLXFQ4H-Dr4hXaql.js} +1 -1
- package/dist/assets/assets/{architectureDiagram-ZHVYKT53-DzH1GKMm.js → architectureDiagram-ZHVYKT53-DWyt7oXu.js} +2 -2
- package/dist/assets/assets/{blockDiagram-RJAE7QA3-BmWU34j3.js → blockDiagram-RJAE7QA3-OxNTLdmi.js} +2 -2
- package/dist/assets/assets/{c4Diagram-XDPPPE54-BpGOdOuo.js → c4Diagram-XDPPPE54-B4YtcH0s.js} +2 -2
- package/dist/assets/assets/channel-bXj00dGj.js +2 -0
- package/dist/assets/assets/{chunk-2E7WHVMD-AycP1cXU.js → chunk-2E7WHVMD-CD6FFMOX.js} +2 -2
- package/dist/assets/assets/{chunk-4EMNKR2T-DX-DrZzc.js → chunk-4EMNKR2T-CEIoX5oo.js} +2 -2
- package/dist/assets/assets/{chunk-55XCU76K-BdwnLWzI.js → chunk-55XCU76K-CD3t0IJi.js} +2 -2
- package/dist/assets/assets/{chunk-7S6XSTFO-D-RBAwAn.js → chunk-7S6XSTFO-Cyt75UCF.js} +2 -2
- package/dist/assets/assets/{chunk-AQDTSKZB-CCxNNhKs.js → chunk-AQDTSKZB-DRtqYBj9.js} +2 -2
- package/dist/assets/assets/{chunk-DSNLSHJZ-D2hGwWm1.js → chunk-DSNLSHJZ-C8Fx2F8s.js} +2 -2
- package/dist/assets/assets/{chunk-HAGFOTED-BPi-cqGh.js → chunk-HAGFOTED-wOLWRRnd.js} +2 -2
- package/dist/assets/assets/{chunk-HNE4Q36P-D-r1ChHT.js → chunk-HNE4Q36P-CurJg4Hf.js} +2 -2
- package/dist/assets/assets/{chunk-NQOKRVIF-RgmZCAdn.js → chunk-NQOKRVIF-Dzcc5nOG.js} +2 -2
- package/dist/assets/assets/{chunk-UHW7PFBP-B-Hul-rZ.js → chunk-UHW7PFBP-B_ULFf2h.js} +2 -2
- package/dist/assets/assets/{chunk-VQ5W62QI-D1zlXCt8.js → chunk-VQ5W62QI-DH0VY4_p.js} +2 -2
- package/dist/assets/assets/{chunk-WQQL4CDK-CtjIbVJn.js → chunk-WQQL4CDK-DNxfLyXM.js} +2 -2
- package/dist/assets/assets/chunk-XXDRQBXY-B2bMWgN9.js +2 -0
- package/dist/assets/assets/{chunk-YZO67HFG-BQOgXG99.js → chunk-YZO67HFG-COuMUh9U.js} +2 -2
- package/dist/assets/assets/{chunk-ZAUX2LTX-CsDDxmqv.js → chunk-ZAUX2LTX-BJrCnubF.js} +2 -2
- package/dist/assets/assets/{chunk-ZCHMQSOR-deyEYMjx.js → chunk-ZCHMQSOR-D1lFKPtk.js} +2 -2
- package/dist/assets/assets/{classDiagram-v2-4MYWR3UA-DVJHeFlq.js → classDiagram-v2-4MYWR3UA-DfZIbyVL.js} +2 -2
- package/dist/assets/assets/{cose-bilkent-JH36ORCC-ipcN28Fw.js → cose-bilkent-JH36ORCC-CpGhv9_S.js} +2 -2
- package/dist/assets/assets/{cynefin-EF2NZ3EQ-s9ZkPF55.js → cynefin-EF2NZ3EQ-Cxdc6nQl.js} +1 -1
- package/dist/assets/assets/{cynefinDiagram-WF24UDRP-Ksr2qjsS.js → cynefinDiagram-WF24UDRP-qoj0w3lp.js} +2 -2
- package/dist/assets/assets/{dagre-NK4GIZVX-2_Wl-XEW.js → dagre-NK4GIZVX-DL6QbNDS.js} +2 -2
- package/dist/assets/assets/{diagram-CBK3MWTC-C7PeyT7l.js → diagram-CBK3MWTC-CJB3jq1_.js} +2 -2
- package/dist/assets/assets/{diagram-I5XIIV2D-DPYzeKdj.js → diagram-I5XIIV2D-4cPOxCxF.js} +2 -2
- package/dist/assets/assets/{diagram-ODIL2UCW-DHw1cAmn.js → diagram-ODIL2UCW-BG3-jAxE.js} +2 -2
- package/dist/assets/assets/{diagram-PFBEJUXE-C2wA8i-1.js → diagram-PFBEJUXE-Bx8dFaXj.js} +2 -2
- package/dist/assets/assets/{diagram-RJA3I4VV-tM3moCIs.js → diagram-RJA3I4VV-CUUHND91.js} +2 -2
- package/dist/assets/assets/{diagram-TYUNFSNR-CInyJxF7.js → diagram-TYUNFSNR-BDMoN-kr.js} +2 -2
- package/dist/assets/assets/{dist-BDqjNLTC.js → dist-5AxNm-uy.js} +2 -2
- package/dist/assets/assets/{dist-hpZIQBl4.js → dist-9_Rmyj2I.js} +2 -2
- package/dist/assets/assets/{dist-DSLprmec.js → dist-BE3CLKv4.js} +2 -2
- package/dist/assets/assets/{dist-BASEd5LC.js → dist-BfNCu-7x.js} +2 -2
- package/dist/assets/assets/{dist-BuYBvf4F.js → dist-BjI0b36Z.js} +2 -2
- package/dist/assets/assets/{dist-DUS0U_ge.js → dist-CM7b5P9a.js} +2 -2
- package/dist/assets/assets/{dist-CeOy6PjJ.js → dist-Ccxb9U1G.js} +2 -2
- package/dist/assets/assets/{dist-ChXoRSS6.js → dist-CjCWP21A.js} +2 -2
- package/dist/assets/assets/{dist-07dRlnp1.js → dist-DSTAktnR.js} +2 -2
- package/dist/assets/assets/{ebnfDiagram-V4P3TTPT-4nZgqaSt.js → ebnfDiagram-V4P3TTPT-BivOMXZb.js} +2 -2
- package/dist/assets/assets/{elk-QONTBCTQ-nFh54c1Q.js → elk-QONTBCTQ-CrJ1Qpy_.js} +2 -2
- package/dist/assets/assets/{erDiagram-KYQIGQAA-CIQ0_IgZ.js → erDiagram-KYQIGQAA-w9Bqp4sV.js} +2 -2
- package/dist/assets/assets/{eventmodeling-K75KTNOO-Cw4BlbYP.js → eventmodeling-K75KTNOO-CBjFM3kV.js} +1 -1
- package/dist/assets/assets/flowDiagram-IUGLLWBU-C6Fnfgm0.js +1 -0
- package/dist/assets/assets/{ganttDiagram-R7GPNTJY-C97qoUpX.js → ganttDiagram-R7GPNTJY-CsWtGaqD.js} +2 -2
- package/dist/assets/assets/{gitGraph-VSP46ZUC-B8HWVkEX.js → gitGraph-VSP46ZUC-DsBSV9_h.js} +1 -1
- package/dist/assets/assets/{gitGraphDiagram-PDYL7XHY-B4Js56_8.js → gitGraphDiagram-PDYL7XHY-D5GxuYHW.js} +2 -2
- package/dist/assets/assets/index-CNDyKUDF.css +1 -0
- package/dist/assets/assets/index-DWDYnZsq.js +256 -0
- package/dist/assets/assets/{info-OHQRW6UA-A4qythhA.js → info-OHQRW6UA-C7x5dSJu.js} +1 -1
- package/dist/assets/assets/{infoDiagram-MVDRKAX5-BSNwG9yI.js → infoDiagram-MVDRKAX5-CwpI-uAa.js} +2 -2
- package/dist/assets/assets/{ishikawaDiagram-HPEHV2GE-D4gU-3RA.js → ishikawaDiagram-HPEHV2GE-DAa7J5G6.js} +2 -2
- package/dist/assets/assets/{journeyDiagram-BOSHW7O7-CxxDrw7o.js → journeyDiagram-BOSHW7O7-BmiZnxE_.js} +2 -2
- package/dist/assets/assets/{kanban-definition-FNSA4HC5-DUxQv3v0.js → kanban-definition-FNSA4HC5-DUR_mA3L.js} +2 -2
- package/dist/assets/assets/{line-BKODXUmk.js → line-DHY49wSg.js} +2 -2
- package/dist/assets/assets/{linear-Cm5uyUun.js → linear-pTo-a9xT.js} +2 -2
- package/dist/assets/assets/{mermaid-parser.core-CYst2kCg.js → mermaid-parser.core-DMg3hN3T.js} +4 -4
- package/dist/assets/assets/{mermaid.core-B4Qq8SMa.js → mermaid.core-DKtPCltA.js} +5 -5
- package/dist/assets/assets/{mindmap-definition-6OY57UG3-CZFvUTIM.js → mindmap-definition-6OY57UG3-DwTkFbnV.js} +2 -2
- package/dist/assets/assets/{packet-JDAUHWVQ-DZMlaiuy.js → packet-JDAUHWVQ-Tu9TrQ1x.js} +1 -1
- package/dist/assets/assets/{pegDiagram-ECIUJNBX-BjM668dT.js → pegDiagram-ECIUJNBX-B7My4tsz.js} +2 -2
- package/dist/assets/assets/{pie-XZMESJXO-CmpJ6vb8.js → pie-XZMESJXO-QPQm5Gdx.js} +1 -1
- package/dist/assets/assets/{pieDiagram-GNMPY74T-BCA9DCDe.js → pieDiagram-GNMPY74T-Bv-zAD_z.js} +2 -2
- package/dist/assets/assets/{quadrantDiagram-D57K4MC3-CUnpC-Rl.js → quadrantDiagram-D57K4MC3-HTjoGQPd.js} +2 -2
- package/dist/assets/assets/{radar-ABXABTNO-C9x42-KP.js → radar-ABXABTNO-LDBlEoFo.js} +1 -1
- package/dist/assets/assets/{railroad-I3PHUGI6-CLvHKrsC.js → railroad-I3PHUGI6-Dy3_ymgZ.js} +1 -1
- package/dist/assets/assets/{railroad-abnf-LNEFI6M7-B0LGF3gx.js → railroad-abnf-LNEFI6M7-QLVvYs6e.js} +1 -1
- package/dist/assets/assets/{railroad-ebnf-DWYD2UWJ-SKnYapAj.js → railroad-ebnf-DWYD2UWJ-CFRlv9a8.js} +1 -1
- package/dist/assets/assets/{railroad-peg-JR7BVNR7-wsUpPloN.js → railroad-peg-JR7BVNR7-BOlq3d9c.js} +1 -1
- package/dist/assets/assets/{railroadDiagram-Y72NRBL7-BYJtosKO.js → railroadDiagram-Y72NRBL7-Chg32HoU.js} +2 -2
- package/dist/assets/assets/{requirementDiagram-EQYSW5RA-YYdoWMnl.js → requirementDiagram-EQYSW5RA-VenIs_eg.js} +2 -2
- package/dist/assets/assets/{sankeyDiagram-SY24JHO5-DtZyCTdM.js → sankeyDiagram-SY24JHO5-BdByqMKF.js} +2 -2
- package/dist/assets/assets/{sequenceDiagram-BLEHNHQU-BPE8f413.js → sequenceDiagram-BLEHNHQU-D3Do4GJE.js} +2 -2
- package/dist/assets/assets/{src-BNTOLq2G.js → src-DmfN-DA-.js} +2 -2
- package/dist/assets/assets/{stateDiagram-v2-A6IESKWZ-9f8Ow4Fl.js → stateDiagram-v2-A6IESKWZ-CZkRbPlf.js} +2 -2
- package/dist/assets/assets/{swimlanes-B3ENRKFQ-DdAEbxGp.js → swimlanes-B3ENRKFQ-DRTdF9AF.js} +2 -2
- package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-BYr_4JUb.js +9 -0
- package/dist/assets/assets/{timeline-definition-JXYKGLGB-DJNGd2mU.js → timeline-definition-JXYKGLGB-BVcuws_M.js} +2 -2
- package/dist/assets/assets/{treeView-D4JQ5SDB-BHONoCCw.js → treeView-D4JQ5SDB-BLtOJGqO.js} +1 -1
- package/dist/assets/assets/{treemap-SAJKECNS-pOaYkxq7.js → treemap-SAJKECNS-Dn3BWJ4v.js} +1 -1
- package/dist/assets/assets/{usecaseDiagram-WPOLBNNX-C3eDYL9v.js → usecaseDiagram-WPOLBNNX-CBExIKDY.js} +2 -2
- package/dist/assets/assets/{vennDiagram-Q3Y3IDCW-CJi1xfsR.js → vennDiagram-Q3Y3IDCW-C6FIx2L4.js} +2 -2
- package/dist/assets/assets/{wardley-7MLQ67FV-CEy4w7Ir.js → wardley-7MLQ67FV-Cjj2xSBp.js} +1 -1
- package/dist/assets/assets/{wardleyDiagram-IVAIDKWA-DfdLMMpN.js → wardleyDiagram-IVAIDKWA-sQPCBCFK.js} +2 -2
- package/dist/assets/assets/{webpack-v8XGbQTa.js → webpack-DDCA0aDL.js} +2 -2
- package/dist/assets/assets/{xychartDiagram-4URNHDU4-Aw-Ix4uC.js → xychartDiagram-4URNHDU4-bZ4rifSw.js} +2 -2
- package/dist/assets/bundle-asset-policy.json +1 -1
- package/dist/assets/index.html +8 -2
- package/dist/assets/mascot/cta-provider.png +0 -0
- package/dist/assets/mascot/cta-sign-in.png +0 -0
- package/dist/assets/plugins/assets/base-GzIOAd-t.css +2 -0
- package/dist/assets/plugins/assets/browserCaptureWorklet-Droj0fW0-Droj0fW0.js +13 -0
- package/dist/assets/plugins/assets/day-bottom-left-5um-x02r-5um-x02r.webp +0 -0
- package/dist/assets/plugins/assets/day-grain-CvEuNhlI-CvEuNhlI.webp +0 -0
- package/dist/assets/plugins/assets/day-right-C9W-XtjV-C9W-XtjV.webp +0 -0
- package/dist/assets/plugins/assets/day-top-left-B544Eq9J-B544Eq9J.webp +0 -0
- package/dist/assets/plugins/assets/night-bottom-left-N03ST5Uz-N03ST5Uz.webp +0 -0
- package/dist/assets/plugins/assets/night-grain-BY9q-tNN-BY9q-tNN.webp +0 -0
- package/dist/assets/plugins/assets/night-right-C6Denrqj-C6Denrqj.webp +0 -0
- package/dist/assets/plugins/assets/night-top-left-KOou6UxY-KOou6UxY.webp +0 -0
- package/dist/assets/plugins/assets/sileroVadWorker-D894njUe-DjN_BMWf.mjs +110 -0
- package/dist/assets/plugins/assets/silero_vad_v6.2.1-SjbCxFXk-SjbCxFXk.onnx +0 -0
- package/dist/assets/plugins/chunks/po-web-runtime-D8FIos2q.js +1 -0
- package/dist/assets/plugins/chunks/schemas-DVQ8BvvP.js +55 -0
- package/dist/assets/plugins/compositions.json +1 -1
- package/dist/assets/plugins/slots/approval.09e72f36-DxS_uibk.js +2 -0
- package/dist/assets/plugins/slots/artifacts.50b639bb-Cp37TAkd.js +1 -0
- package/dist/assets/plugins/slots/author.ea449ace-Ds9Y-tjN.js +93 -0
- package/dist/assets/plugins/slots/autocompact.6f428144-CDZpN7I7.js +1 -0
- package/dist/assets/plugins/slots/backdrop-bamboo.6e4c928d-qbifuMc6.js +1 -0
- package/dist/assets/plugins/slots/browse.fa1f1a50-CVYvo1M5.js +1 -0
- package/dist/assets/plugins/slots/builtin-tools.75108f21-Cq1ljoL-.js +7 -0
- package/dist/assets/plugins/slots/calendar.d8b70190-BBjpOs1v.js +2 -0
- package/dist/assets/plugins/slots/codemode.c58fb583-DOR6OR7R.js +11 -0
- package/dist/assets/plugins/slots/domain.753f9f92-CJrXxig9.js +1 -0
- package/dist/assets/plugins/slots/edit.804fec90-BFF7_xN9.js +7 -0
- package/dist/assets/plugins/slots/files.66ffc636-CzOlZrRm.js +2 -0
- package/dist/assets/plugins/slots/goal.45dffa01-BtQBp3sw.js +1 -0
- package/dist/assets/plugins/slots/grep.98262cff-9bUDfjyT.js +1 -0
- package/dist/assets/plugins/slots/help.5fbd20f7-B4-y6gYK.js +3 -0
- package/dist/assets/plugins/slots/log.cb964209-BRPa3cVs.js +4 -0
- package/dist/assets/plugins/slots/mcp.82cc1ff5-CFtzPkPC.js +55 -0
- package/dist/assets/plugins/slots/plan.3852ba52-CH59Ff49.js +3 -0
- package/dist/assets/plugins/slots/profile.ab16dcec-0e9fWWyE.js +1 -0
- package/dist/assets/plugins/slots/prompts.ae48c07a-BTqYnBX5.js +38 -0
- package/dist/assets/plugins/slots/read.4560591a-C7fMXDEH.js +1 -0
- package/dist/assets/plugins/slots/runner.6e494d59-CqrpqhW9.js +9 -0
- package/dist/assets/plugins/slots/scaffold.d87a6ee0-9qY5gkYW.js +1 -0
- package/dist/assets/plugins/slots/session-mcp.2be84084-Cf0cqopp.js +2 -0
- package/dist/assets/plugins/slots/sessions.6f47cb4c-B1_eqPJQ.js +1 -0
- package/dist/assets/plugins/slots/skill.62a0a1b3-D-SKX8iw.js +4 -0
- package/dist/assets/plugins/slots/space.65a27e5a-fbLHc-DX.js +1 -0
- package/dist/assets/plugins/slots/subagents.8bb9992c-Cm_YMEnn.js +7 -0
- package/dist/assets/plugins/slots/template-advanced.59f3f98a-L0WOM4JT.js +1 -0
- package/dist/assets/plugins/slots/template-desktop.0f0b8491-By9BZlaL.js +7 -0
- package/dist/assets/plugins/slots/template-elegant.0e3b0acf-El05x7HK.js +1 -0
- package/dist/assets/plugins/slots/vault.3cbfcdc3-DpU_65Wy.js +1 -0
- package/dist/assets/plugins/slots/voice.a952113d-CvcuL__m.js +1 -0
- package/dist/assets/plugins/slots/web-search.65013836-NVh9fdvE.js +1 -0
- package/dist/assets/plugins/slots/workflows.cbc5c5c0-OLKSY9PE.js +16 -0
- package/dist/assets/pwa/pwa.js +12 -12
- package/dist/assets/pwa/sw.js +58 -4
- package/dist/{atomicJson-wczZBXQP.js → atomicJson-XYtxz032.js} +2 -3
- package/dist/{azure-openai-config-DHMgdIa-.js → azure-openai-config-S-quxzTC.js} +2 -2
- package/dist/{azure-openai-responses-CTgRdQ4m.js → azure-openai-responses-DdpV5zh7.js} +13 -13
- package/dist/backgroundWork-Bv0ib_lY.js +49 -0
- package/dist/{layeredConfig-xmTHGrw8.js → browser-DwY5dXHX.js} +21 -983
- package/dist/{browser-EJ5_ffnN.js → browser-IsHIcvFg.js} +1 -1
- package/dist/browser-ks_k-6KA.js +36 -0
- package/dist/calendarSetup-CI3AACVo.js +3892 -0
- package/dist/childProcess-Cv8rJuUf.js +32 -0
- package/dist/childSession-BrDCrNtL.js +25 -0
- package/dist/{classifier-shared-jXm-plIK.js → classifier-shared-DFprgrML.js} +5 -5
- package/dist/{cloudflare-workers-ai-system-one-B0wH6HU5.js → cloudflare-workers-ai-system-one-B0MD19yZ.js} +3 -3
- package/dist/{codemode-CFVDmyGm.js → codemode-LpcMFMYM.js} +1 -1
- package/dist/coerce-DM9YrILC.js +13 -0
- package/dist/config-DeWkdjj7.js +1372 -0
- package/dist/contextContributions-C1bsEJef.js +13 -0
- package/dist/contracts-CW8o6Xyi.js +19 -0
- package/dist/contracts-WRa9e98H.js +40 -0
- package/dist/cordisHost-_-jtkneB.js +25 -0
- package/dist/delegation-B2rBgv8A.js +100 -0
- package/dist/{diagnostics-DPTP-yrt.js → diagnostics-BY5LXbHJ.js} +2 -2
- package/dist/{dist-BVBi6VMV.js → dist-B2ArMqge.js} +1 -1
- package/dist/{server-Cg07O2W6.js → dist-C6IqjC-m.js} +1 -546
- package/dist/{dist-PDDFdqDX.js → dist-CDz5dYMj.js} +1 -1
- package/dist/{dist-Dvx5mlIR.js → dist-kgi2Ix1y.js} +16 -3
- package/dist/{emscripten-module.cloudflare-D4Bc9Ykz.js → emscripten-module.cloudflare-B4fhfquU.js} +1 -1
- package/dist/{env-api-keys-CAnjjnsR.js → env-api-keys-BgCPpU9t.js} +1 -1
- package/dist/{error-body-DQZRsyL5.js → error-body-CeumezyR.js} +26 -4
- package/dist/esm-BKJy3O9-.js +1553 -0
- package/dist/{remoteMcp-DqE2xFWS.js → exports-BEEgtkya.js} +1588 -714
- package/dist/{exports-LjvSY7Y6.js → exports-CBp_9dVk.js} +47 -28
- package/dist/exports-CRjRvvX0.js +34 -0
- package/dist/exports-Cg0wxflf.js +1 -0
- package/dist/exports-Ct56PRB9.js +46 -0
- package/dist/extensionFile-B940JOEn.js +121 -0
- package/dist/{factory-Cs8iaUtc.js → factory-BU0cZY0I.js} +1 -1
- package/dist/{github-copilot-headers-DpQQAh-s.js → github-copilot-headers-Cq9pnpl2.js} +1 -1
- package/dist/{google-generative-ai-BTTOo5RQ.js → google-generative-ai-DmbUlCGv.js} +9 -9
- package/dist/{google-shared-S7bqOccz.js → google-shared-Diz2uk39.js} +6 -6
- package/dist/{google-vertex-BcMU_DMb.js → google-vertex-CGCpI9Po.js} +10 -10
- package/dist/{domains-B6Ae4swm.js → harnessState-Df--jB5z.js} +162 -42
- package/dist/{harnessStore-Ccbia9_u.js → harnessStore-DInwiLYb.js} +4 -5
- package/dist/{hash-B3RRpLS2.js → hash-IQBoLxOB.js} +1 -1
- package/dist/{headers-BEuxFxDI.js → headers-Dkgiqogr.js} +1 -1
- package/dist/help-C9UGKetC.js +100 -0
- package/dist/home-kwZFHqOx.js +60 -0
- package/dist/http-BekstF5S.js +64 -0
- package/dist/hubChannel-Dldv3EEb.js +32 -0
- package/dist/hubRevisions-BPoC6quI.js +364 -0
- package/dist/{identity-BIeAyilV.js → identity-BzB1N-Sn.js} +3 -3
- package/dist/index.edge-BiVQ9LoZ.js +198 -0
- package/dist/index.edge-CSGx6QOL.js +56 -0
- package/dist/index.edge-ClLTmPFz.js +191 -0
- package/dist/index.edge-CzoLWbyl.js +238 -0
- package/dist/index.edge-D1biKw71.js +946 -0
- package/dist/index.edge-D2RirEwK.js +14 -0
- package/dist/iso-BGFmgtky.js +27 -0
- package/dist/{kysely-adapter-D51abb3q.js → kysely-adapter-D8KUrWxm.js} +1 -1
- package/dist/liquid.browser-1BcykmIN.js +4596 -0
- package/dist/manualTranscription-DN56fzgj.js +96 -0
- package/dist/{mcpProjection-BXiECnW0.js → mcpProjection-D2U50Pel.js} +1 -2
- package/dist/meta-CVgfTHQP.js +1030 -0
- package/dist/migrations-DJBPDwSR.js +32 -0
- package/dist/{mistral-conversations-DN8VSERk.js → mistral-conversations-Bv_m1MRF.js} +12 -12
- package/dist/modeDefinition-Di95_IiU.js +44 -0
- package/dist/{models-D6d73jcW.js → models-D50yN8Ag.js} +41 -46
- package/dist/{node-UuMT2C3q.js → node-B4kSjHeD.js} +2 -2
- package/dist/{node-DytJOfYf.js → node-CBLSc-YH.js} +1 -1
- package/dist/notification-DjxbNoMR.js +143 -0
- package/dist/{openai-bt3ZRBZv.js → openai-D6Q-l6hT.js} +187 -187
- package/dist/{openai-codex-responses-cL36x0ml.js → openai-codex-responses-BnoiTqYV.js} +21 -25
- package/dist/{openai-completions-BWsTNYyT.js → openai-completions-C68qs5rI.js} +26 -19
- package/dist/{openai-decisions-Dfn_KgQd.js → openai-decisions-BSxU_aoV.js} +3 -3
- package/dist/{openai-responses-aa0LoyCJ.js → openai-responses-D6hXen-k.js} +17 -15
- package/dist/{openai-responses-shared-H-jH5SlM.js → openai-responses-shared-BD8K7FAC.js} +7 -7
- package/dist/{openrouter-cost-D99Qqcs6.js → openrouter-cost-BPam8wyW.js} +1 -1
- package/dist/{openrouter-images-BpwVpALC.js → openrouter-images-DylXiHy7.js} +7 -7
- package/dist/{hubChannel-Dn5NMpvu.js → packageApi-DYkaxP59.js} +33 -42
- package/dist/photon_rs_bg.wasm +0 -0
- package/dist/{pi-messages-BHAIkYBj.js → pi-messages-DaIlYYlO.js} +6 -6
- package/dist/piConfig-5tRPD0ov.js +126 -0
- package/dist/piSettings-ekBG5OeF.js +1 -0
- package/dist/platform-CQahdzpG.js +138 -0
- package/dist/pluginCatalog-BAALyedS.js +30 -0
- package/dist/pluginContributions-Be9EnCAW.js +16 -0
- package/dist/pluginProtocol-7_gVUeM9.js +1 -0
- package/dist/pluginProtocol-DVIfJnav.js +135 -0
- package/dist/portableConfig-0tnk9anb.js +49 -0
- package/dist/presetConfig-n-oiNd3h.js +541 -0
- package/dist/profileSources-D1rymC97.js +537 -0
- package/dist/{protocol-DUeE0Q8z.js → protocol-Cri0GpZR.js} +1 -2
- package/dist/{provider-env-DgfpjgTa.js → provider-env-DJb40UF7.js} +2 -2
- package/dist/{provider-retry-ChD-K2Gv.js → provider-retry-jpvs7ixx.js} +1 -1
- package/dist/{puppeteer-cloudflare-B-GHrPGO.js → puppeteer-cloudflare-D4l8smMS.js} +3 -3
- package/dist/{server-BWJmxCrm.js → readiness-Ydw5zrKy.js} +4 -169
- package/dist/{rolldown-runtime-B-lAHAz2.js → rolldown-runtime-DbVrKiKs.js} +1 -1
- package/dist/{sanitize-unicode-Dl4ROF7y.js → sanitize-unicode-B1ZFaEtf.js} +1 -1
- package/dist/scaffoldRegistry-CeFe3Pf0.js +1240 -0
- package/dist/{schemas-Vj8-rCR4.js → schemas-D2dRon18.js} +1901 -53
- package/dist/server-AKM07WcM.js +466 -0
- package/dist/server-B0tM5Ygf.js +1300 -0
- package/dist/server-B8-vStCx.js +1116 -0
- package/dist/server-BAbdiL38.js +15108 -0
- package/dist/server-BCZ_R3kX.js +3326 -0
- package/dist/server-BGKAeB3M.js +492 -0
- package/dist/server-BIQhg1jS.js +26985 -0
- package/dist/server-BcPD_6a2.js +1533 -0
- package/dist/server-BeoA0QB-.js +580 -0
- package/dist/server-BsgvOpBF.js +24 -0
- package/dist/server-BtnOqSB5.js +156 -0
- package/dist/server-C-HBjWRo.js +2800 -0
- package/dist/{server-CWg0m_wq.js → server-C0Lt6nTt.js} +269 -1062
- package/dist/server-C8NPfG1H.js +148 -0
- package/dist/server-CKkaxOc0.js +978 -0
- package/dist/server-CMaWF5UA.js +1379 -0
- package/dist/server-CQPI6jIa.js +295 -0
- package/dist/{server-BhYE7Vqk.js → server-CQmb0lYL.js} +114 -176
- package/dist/server-CWR34Vx6.js +1884 -0
- package/dist/server-CZiAy2v5.js +641 -0
- package/dist/server-Cjtr0oVJ.js +584 -0
- package/dist/server-CkJQJ3Oo.js +571 -0
- package/dist/server-ClQQGtsI.js +679 -0
- package/dist/server-Cy2FhGBm.js +1744 -0
- package/dist/server-D8yEblCB.js +24 -0
- package/dist/server-DF0YIUeI.js +9603 -0
- package/dist/server-DRFESCq1.js +1527 -0
- package/dist/{server-zkcrP99W.js → server-Df1defzp.js} +89 -87
- package/dist/server-DgZd_TuT.js +189 -0
- package/dist/server-Dkc9Kth2.js +1830 -0
- package/dist/server-DlRePYOB.js +343 -0
- package/dist/{server-BpPEzRes.js → server-_HZm8wEC.js} +654 -745
- package/dist/{server-yABhJa2K.js → server-_jWkMESg.js} +60 -39
- package/dist/server-lgV6liTt.js +140 -0
- package/dist/server-nHPXbRDA.js +742 -0
- package/dist/server-p7qANgrf.js +877 -0
- package/dist/server-vhmQi3co.js +112 -0
- package/dist/{server-SA0dsIJ2.js → server-w1aKMZOs.js} +3 -10
- package/dist/serverPlugin-4nI5J6Zt.js +39622 -0
- package/dist/session-resources-BvR3cwiH.js +10 -0
- package/dist/{sessionConfig-DgnPcGBu.js → sessionConfig-UMlgu98q.js} +926 -844
- package/dist/{simple-options-DWrW31_K.js → simple-options-Cp5p46f9.js} +13 -6
- package/dist/space-C3Wnli1l.js +92 -0
- package/dist/sse-XlzXs1es.js +151 -0
- package/dist/{streaming-json-t4rzNHEp.js → streaming-json-CZyrX_Ux.js} +6 -6
- package/dist/{system-one-shared-DLVLdzYL.js → system-one-shared-Du6bka0h.js} +3 -3
- package/dist/{notification-valMY1zH.js → telemetry-CrTcxeA5.js} +2 -93
- package/dist/{transform-messages-CjTSwW9q.js → transform-messages-CBj9g2mx.js} +3 -16
- package/dist/truncate-M3KbFyVj.js +89 -0
- package/dist/{server-BXjfQYeU.js → type-DppaYz6F.js} +955 -1187
- package/dist/type-yokaDI_F.js +7 -0
- package/dist/{typesafe-system-one-DBVcjcUQ.js → typesafe-system-one-C7YFgvrX.js} +3 -3
- package/dist/{uuid-mkNGilLv.js → uuid-BVI0BZsx.js} +1 -1
- package/dist/{validation-BLnxgJU_.js → validation-QWuk6kwJ.js} +79 -74
- package/dist/vaultSettings-Bq8wkbDv.js +292 -0
- package/dist/voiceTools-BdJyfzwB.js +246 -0
- package/dist/web-B2sdV-F2.js +4 -0
- package/dist/worker.js +97821 -72579
- package/dist/workflow-DTCt4n6k.js +171 -0
- package/dist/workflowServices-RlswfHWp.js +300 -0
- package/package.json +55 -25
- package/wrangler.jsonc +16 -3
- package/dist/apiContracts-sG5b90Qa.js +0 -4451
- package/dist/assets/assets/channel-BOT7In0s.js +0 -2
- package/dist/assets/assets/chunk-XXDRQBXY-Dp9-QbR6.js +0 -2
- package/dist/assets/assets/flowDiagram-IUGLLWBU-B9D9uWwn.js +0 -1
- package/dist/assets/assets/index-BlPEYpuN.css +0 -1
- package/dist/assets/assets/index-DS9w_Q1B.js +0 -155
- package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-CyUKtW7v.js +0 -9
- package/dist/assets/plugins/assets/base-DyDpY0zD.css +0 -2
- package/dist/assets/plugins/chunks/po-web-runtime-4JiBsb_c.js +0 -1
- package/dist/assets/plugins/slots/approval.09e72f36-DwFz-UMh.js +0 -2
- package/dist/assets/plugins/slots/artifacts.50b639bb-CUtFC806.js +0 -1
- package/dist/assets/plugins/slots/builtin-tools.75108f21-B69GLfY_.js +0 -7
- package/dist/assets/plugins/slots/codemode.c58fb583-C0Gmb7_s.js +0 -9
- package/dist/assets/plugins/slots/domain.753f9f92-BTBYRLkE.js +0 -1
- package/dist/assets/plugins/slots/mcp.82cc1ff5-Ecacjn0a.js +0 -109
- package/dist/assets/plugins/slots/profile.ab16dcec-DIVXNHmh.js +0 -1
- package/dist/assets/plugins/slots/skill.62a0a1b3-BNr7DmPH.js +0 -4
- package/dist/backgroundWork-CSpsJ-Rg.js +0 -25
- package/dist/contextProjection-DDIQRgN4.js +0 -188
- package/dist/extensionFile-CacKVegY.js +0 -409
- package/dist/harnessState-gmzJcPGt.js +0 -88
- package/dist/harnessStore-Ch6hdYYe.js +0 -1
- package/dist/index.edge-BgSx_gRO.js +0 -45
- package/dist/majorModes-CCnwAjfF.js +0 -333
- package/dist/majorModes-DNQbxkpt.js +0 -1
- package/dist/piSettings-B6fsgIBA.js +0 -1
- package/dist/platform-Bs2_X_dK.js +0 -16
- package/dist/platformFiles-CCGujP9o.js +0 -39
- package/dist/server-5hLs7M43.js +0 -656
- package/dist/server-B3iqBHOP.js +0 -118
- package/dist/server-Dv0EKLwc.js +0 -108
- package/dist/server-Y5A21sJf.js +0 -591
- package/dist/server-a1K226XK.js +0 -279
- package/dist/serverPlugin-DUc4gGep.js +0 -7279
- package/dist/value-Bd477RDX.js +0 -2247
|
@@ -0,0 +1,1372 @@
|
|
|
1
|
+
import { $t as Boolean$1, Jt as String$1, an as _Array_, c as poHomeDirectory, d as nodeHost, rn as _Object_ } from "./serverPlugin-4nI5J6Zt.js";
|
|
2
|
+
import { f as readTextIfExists } from "./platform-CQahdzpG.js";
|
|
3
|
+
import "./piSettings-ekBG5OeF.js";
|
|
4
|
+
import { t as parse } from "./browser-DwY5dXHX.js";
|
|
5
|
+
import "./notification-DjxbNoMR.js";
|
|
6
|
+
import "./protocol-Cri0GpZR.js";
|
|
7
|
+
import { t as isPortableConfigKey } from "./portableConfig-0tnk9anb.js";
|
|
8
|
+
import { createHash } from "node:crypto";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
//#region ../../core/po-core/src/schemas/askUser.ts
|
|
11
|
+
const MAX_QUESTIONS = 3;
|
|
12
|
+
const MAX_OPTIONS = 16;
|
|
13
|
+
const MAX_TEXT_LENGTH = 4096;
|
|
14
|
+
const AskUserPromptOptionSchema = _Object_({
|
|
15
|
+
label: String$1({
|
|
16
|
+
minLength: 1,
|
|
17
|
+
maxLength: MAX_TEXT_LENGTH
|
|
18
|
+
}),
|
|
19
|
+
description: String$1({ maxLength: MAX_TEXT_LENGTH }),
|
|
20
|
+
hasPreview: Boolean$1()
|
|
21
|
+
}, { additionalProperties: false });
|
|
22
|
+
const AskUserPromptQuestionSchema = _Object_({
|
|
23
|
+
question: String$1({
|
|
24
|
+
minLength: 1,
|
|
25
|
+
maxLength: MAX_TEXT_LENGTH
|
|
26
|
+
}),
|
|
27
|
+
header: String$1({
|
|
28
|
+
minLength: 1,
|
|
29
|
+
maxLength: MAX_TEXT_LENGTH
|
|
30
|
+
}),
|
|
31
|
+
multiSelect: Boolean$1(),
|
|
32
|
+
options: _Array_(AskUserPromptOptionSchema, { maxItems: MAX_OPTIONS })
|
|
33
|
+
}, { additionalProperties: false });
|
|
34
|
+
_Object_({ questions: _Array_(AskUserPromptQuestionSchema, {
|
|
35
|
+
minItems: 1,
|
|
36
|
+
maxItems: MAX_QUESTIONS
|
|
37
|
+
}) }, { additionalProperties: false });
|
|
38
|
+
_Object_({ active: Boolean$1() }, { additionalProperties: false });
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region ../../foundations/po-config/src/services/configPolicy/index.ts
|
|
41
|
+
const DEFAULT_PROJECT_TRUST = "ask";
|
|
42
|
+
const DEFAULT_VOICE_MODE = "legacy";
|
|
43
|
+
const DEFAULT_VOICE_ENGINE = "auto";
|
|
44
|
+
const DEFAULT_VOICE_LANGUAGE = "auto";
|
|
45
|
+
const DEFAULT_RECORDER_DEVICE = "none:default";
|
|
46
|
+
const ROOT_KEYS = [
|
|
47
|
+
"modes",
|
|
48
|
+
"computerUse",
|
|
49
|
+
"desktopEnvironment",
|
|
50
|
+
"profileMemory",
|
|
51
|
+
"subagents",
|
|
52
|
+
"projectTrust",
|
|
53
|
+
"workspaces",
|
|
54
|
+
"editor",
|
|
55
|
+
"browse",
|
|
56
|
+
"ios",
|
|
57
|
+
"voice",
|
|
58
|
+
"selection",
|
|
59
|
+
"web",
|
|
60
|
+
"native"
|
|
61
|
+
];
|
|
62
|
+
const WORKSPACE_KEYS = ["name", "instructions"];
|
|
63
|
+
const BROWSE_KEYS = ["engine", "fallback"];
|
|
64
|
+
const PO_BROWSE_ENGINES = ["cloak", "chrome-for-testing"];
|
|
65
|
+
const PO_BROWSE_FALLBACKS = ["none", "chrome-for-testing"];
|
|
66
|
+
const IOS_KEYS = [
|
|
67
|
+
"pool",
|
|
68
|
+
"helperPath",
|
|
69
|
+
"device"
|
|
70
|
+
];
|
|
71
|
+
const IOS_POOL_KEYS = [
|
|
72
|
+
"minBooted",
|
|
73
|
+
"maxBooted",
|
|
74
|
+
"maxDevices",
|
|
75
|
+
"idleShutdownMinutes",
|
|
76
|
+
"waitTimeoutSeconds",
|
|
77
|
+
"deviceType",
|
|
78
|
+
"runtime"
|
|
79
|
+
];
|
|
80
|
+
const IOS_DEVICE_KEYS = ["developmentTeam", "availability"];
|
|
81
|
+
const SELECTION_KEYS = [
|
|
82
|
+
"preset",
|
|
83
|
+
"domains",
|
|
84
|
+
"profile"
|
|
85
|
+
];
|
|
86
|
+
const MODE_KEYS = ["planning", "autocompact"];
|
|
87
|
+
const PLANNING_KEYS = [
|
|
88
|
+
"main",
|
|
89
|
+
"subagents",
|
|
90
|
+
"plansDirectory"
|
|
91
|
+
];
|
|
92
|
+
const AGENT_KEYS = ["model", "thinking"];
|
|
93
|
+
const AUTOCOMPACT_KEYS = [
|
|
94
|
+
"enabled",
|
|
95
|
+
"model",
|
|
96
|
+
"thinking",
|
|
97
|
+
"thresholds",
|
|
98
|
+
"overrides"
|
|
99
|
+
];
|
|
100
|
+
const AUTOCOMPACT_THRESHOLD_KEYS = [
|
|
101
|
+
"pass1",
|
|
102
|
+
"pass2",
|
|
103
|
+
"pass3"
|
|
104
|
+
];
|
|
105
|
+
const AUTOCOMPACT_OVERRIDE_KEYS = ["model", "tokens"];
|
|
106
|
+
const COMPUTER_USE_KEYS = ["enabled"];
|
|
107
|
+
const DESKTOP_ENVIRONMENT_KEYS = [
|
|
108
|
+
"inherit",
|
|
109
|
+
"exclude",
|
|
110
|
+
"includeOnly",
|
|
111
|
+
"set"
|
|
112
|
+
];
|
|
113
|
+
const ENVIRONMENT_VARIABLE_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/u;
|
|
114
|
+
const PROFILE_MEMORY_KEYS = ["automatic"];
|
|
115
|
+
const SUBAGENTS_KEYS = [
|
|
116
|
+
"model",
|
|
117
|
+
"thinking",
|
|
118
|
+
"fallbackModels",
|
|
119
|
+
"excludeTools",
|
|
120
|
+
"agents"
|
|
121
|
+
];
|
|
122
|
+
/** A pass that fires below this is noise; one above it never fires before Pi compacts natively. */
|
|
123
|
+
const MIN_AUTOCOMPACT_RATIO = .05;
|
|
124
|
+
const MAX_AUTOCOMPACT_RATIO = .99;
|
|
125
|
+
/**
|
|
126
|
+
* A checkpoint at zero tokens fires before the session has said anything. There is
|
|
127
|
+
* deliberately no ceiling: the package takes the lower of the ratio and the token
|
|
128
|
+
* value, so one larger than the window is inert rather than dangerous.
|
|
129
|
+
*/
|
|
130
|
+
const MIN_AUTOCOMPACT_TOKENS = 1;
|
|
131
|
+
const EDITOR_KEYS = ["command"];
|
|
132
|
+
const VOICE_KEYS = [
|
|
133
|
+
"mode",
|
|
134
|
+
"engine",
|
|
135
|
+
"language",
|
|
136
|
+
"recorder",
|
|
137
|
+
"adapters",
|
|
138
|
+
"autoCapture",
|
|
139
|
+
"live"
|
|
140
|
+
];
|
|
141
|
+
/** `orchestrator` configured the removed Voice conversation; it stays accepted so older files still load, and is ignored. */
|
|
142
|
+
const VOICE_LIVE_KEYS = [
|
|
143
|
+
"voice",
|
|
144
|
+
"model",
|
|
145
|
+
"orchestrator"
|
|
146
|
+
];
|
|
147
|
+
const LIVE_MODEL_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]*$/u;
|
|
148
|
+
const MAX_LIVE_MODEL_LENGTH = 64;
|
|
149
|
+
const RECORDER_KEYS = ["binary", "device"];
|
|
150
|
+
const WHISPER_CPP_ENGINE = "whisper-cpp";
|
|
151
|
+
const OPENAI_WHISPER_ENGINE = "openai-whisper";
|
|
152
|
+
const MLX_WHISPER_ENGINE = "mlx-whisper";
|
|
153
|
+
const MACOS_SAY_TTS_ENGINE = "macos-say";
|
|
154
|
+
const ADAPTERS_KEYS = [
|
|
155
|
+
WHISPER_CPP_ENGINE,
|
|
156
|
+
OPENAI_WHISPER_ENGINE,
|
|
157
|
+
MLX_WHISPER_ENGINE
|
|
158
|
+
];
|
|
159
|
+
const ADAPTER_KEYS = ["binary", "model"];
|
|
160
|
+
const MODEL_KEYS = ["path", "id"];
|
|
161
|
+
const AUTO_CAPTURE_KEYS = [
|
|
162
|
+
"model",
|
|
163
|
+
"startPhrases",
|
|
164
|
+
"stopPhrases",
|
|
165
|
+
"composeOpenPhrases",
|
|
166
|
+
"composeSendPhrases",
|
|
167
|
+
"composeCancelPhrases",
|
|
168
|
+
"utteranceIdleMs",
|
|
169
|
+
"composeUtteranceIdleMs",
|
|
170
|
+
"composeNudgeMs",
|
|
171
|
+
"transcriptionTimeoutMs",
|
|
172
|
+
"tts"
|
|
173
|
+
];
|
|
174
|
+
const TTS_KEYS = [
|
|
175
|
+
"engine",
|
|
176
|
+
"voice",
|
|
177
|
+
"rate"
|
|
178
|
+
];
|
|
179
|
+
const DEFAULT_UTTERANCE_IDLE_MS = 3e3;
|
|
180
|
+
const MIN_UTTERANCE_IDLE_MS = 1500;
|
|
181
|
+
const MAX_UTTERANCE_IDLE_MS = 1e4;
|
|
182
|
+
/**
|
|
183
|
+
* The endpoint window used while a composition draft is collecting.
|
|
184
|
+
*
|
|
185
|
+
* Shorter than `utteranceIdleMs` on purpose. A turn produces exactly one transcript, so
|
|
186
|
+
* with the ordinary ~3 s window a short command spoken after a brief pause arrives glued
|
|
187
|
+
* to the end of the preceding sentence and can never be read as a command. Roughly twice
|
|
188
|
+
* the VAD's own 600 ms trailing-silence window: long enough that ordinary speech rhythm
|
|
189
|
+
* does not split a sentence, short enough that a deliberate pause does. Over-splitting is
|
|
190
|
+
* harmless here and only here, because draft segments are joined back together with a
|
|
191
|
+
* space.
|
|
192
|
+
*/
|
|
193
|
+
const DEFAULT_COMPOSE_UTTERANCE_IDLE_MS = 1200;
|
|
194
|
+
const MIN_COMPOSE_UTTERANCE_IDLE_MS = 800;
|
|
195
|
+
const MAX_COMPOSE_UTTERANCE_IDLE_MS = 3e3;
|
|
196
|
+
/** Silence before Voice reminds the user a draft is still open. `0` disables it. */
|
|
197
|
+
const DEFAULT_COMPOSE_NUDGE_MS = 1e4;
|
|
198
|
+
const MIN_COMPOSE_NUDGE_MS = 5e3;
|
|
199
|
+
const MAX_COMPOSE_NUDGE_MS = 6e4;
|
|
200
|
+
/**
|
|
201
|
+
* Defaults kept as lists so the phrases that shipped first keep working.
|
|
202
|
+
*
|
|
203
|
+
* `hey po` and `that's it` read as speech; `po prompt` and `po send` are what
|
|
204
|
+
* existing users have in their fingers. Dropping the originals would break them for no
|
|
205
|
+
* gain, and the cost of carrying both is two extra comparisons per command candidate.
|
|
206
|
+
*/
|
|
207
|
+
const DEFAULT_COMPOSE_OPEN_PHRASES = ["hey po", "po prompt"];
|
|
208
|
+
const DEFAULT_COMPOSE_SEND_PHRASES = ["that's it", "po send"];
|
|
209
|
+
const DEFAULT_COMPOSE_CANCEL_PHRASES = ["po cancel", "scratch that"];
|
|
210
|
+
const DEFAULT_TRANSCRIPTION_TIMEOUT_MS = 12e4;
|
|
211
|
+
const MIN_TRANSCRIPTION_TIMEOUT_MS = 1e3;
|
|
212
|
+
const MAX_TRANSCRIPTION_TIMEOUT_MS = 12e4;
|
|
213
|
+
const MAX_CONTROL_PHRASES = 16;
|
|
214
|
+
const MAX_CONTROL_PHRASE_LENGTH = 64;
|
|
215
|
+
const MAX_TTS_VOICE_LENGTH = 64;
|
|
216
|
+
const MIN_TTS_RATE = 80;
|
|
217
|
+
const MAX_TTS_RATE = 500;
|
|
218
|
+
const MODEL_REFERENCE_PATTERN = /^[^/\s]+\/[^/\s]+(?:\/[^/\s]+)*$/u;
|
|
219
|
+
const PHRASE_PUNCTUATION_PATTERN = /[\p{P}\p{S}]+/gu;
|
|
220
|
+
/**
|
|
221
|
+
* The accepted values, in the order a picker should offer them.
|
|
222
|
+
*
|
|
223
|
+
* Exported because the config UI has to offer exactly what the parser accepts,
|
|
224
|
+
* and a second hand-written list in the contributing package would drift. The
|
|
225
|
+
* validating Sets below are built from these for the same reason.
|
|
226
|
+
*/
|
|
227
|
+
const PO_PLANNING_THINKING_LEVELS = [
|
|
228
|
+
"off",
|
|
229
|
+
"minimal",
|
|
230
|
+
"low",
|
|
231
|
+
"medium",
|
|
232
|
+
"high",
|
|
233
|
+
"xhigh",
|
|
234
|
+
"max"
|
|
235
|
+
];
|
|
236
|
+
const PO_VOICE_MODES = [DEFAULT_VOICE_MODE, "live"];
|
|
237
|
+
const PO_VOICE_ENGINES = [
|
|
238
|
+
DEFAULT_VOICE_ENGINE,
|
|
239
|
+
WHISPER_CPP_ENGINE,
|
|
240
|
+
OPENAI_WHISPER_ENGINE,
|
|
241
|
+
MLX_WHISPER_ENGINE
|
|
242
|
+
];
|
|
243
|
+
const PO_VOICE_TTS_ENGINES = [MACOS_SAY_TTS_ENGINE];
|
|
244
|
+
/** Codex realtime V3 voices, from `codex-rs/protocol/src/protocol.rs` `RealtimeVoicesList::builtin()`. */
|
|
245
|
+
const PO_VOICE_LIVE_VOICES = [
|
|
246
|
+
"juniper",
|
|
247
|
+
"maple",
|
|
248
|
+
"spruce",
|
|
249
|
+
"ember",
|
|
250
|
+
"vale",
|
|
251
|
+
"breeze",
|
|
252
|
+
"arbor",
|
|
253
|
+
"sol",
|
|
254
|
+
"cove",
|
|
255
|
+
"aube",
|
|
256
|
+
"bubbie",
|
|
257
|
+
"haetsal",
|
|
258
|
+
"hanul",
|
|
259
|
+
"himari",
|
|
260
|
+
"leher",
|
|
261
|
+
"miko",
|
|
262
|
+
"neer",
|
|
263
|
+
"porto",
|
|
264
|
+
"rindo",
|
|
265
|
+
"rio",
|
|
266
|
+
"rivage",
|
|
267
|
+
"selva",
|
|
268
|
+
"sonna",
|
|
269
|
+
"tinta",
|
|
270
|
+
"viola"
|
|
271
|
+
];
|
|
272
|
+
const THINKING_VALUES = new Set(PO_PLANNING_THINKING_LEVELS);
|
|
273
|
+
const TRUST_VALUES = /* @__PURE__ */ new Set([
|
|
274
|
+
"ask",
|
|
275
|
+
"always",
|
|
276
|
+
"never"
|
|
277
|
+
]);
|
|
278
|
+
const VOICE_MODE_VALUES = new Set(PO_VOICE_MODES);
|
|
279
|
+
const ENGINE_VALUES = new Set(PO_VOICE_ENGINES);
|
|
280
|
+
const TTS_ENGINE_VALUES = new Set(PO_VOICE_TTS_ENGINES);
|
|
281
|
+
function isObject(value) {
|
|
282
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Where a lenient parse collects unknown keys instead of throwing.
|
|
286
|
+
*
|
|
287
|
+
* Module scope rather than a parameter threaded through the twelve nested
|
|
288
|
+
* parsers: `assertKeys` is the only reader, parsing is synchronous end to end,
|
|
289
|
+
* and `parsePoConfig` owns the whole window in a try/finally. Threading would
|
|
290
|
+
* touch every parser to change behaviour in one of them.
|
|
291
|
+
*/
|
|
292
|
+
let unknownKeySink;
|
|
293
|
+
function assertKeys(value, allowed, location, filePath) {
|
|
294
|
+
const unknown = Object.keys(value).filter((key) => !allowed.includes(key));
|
|
295
|
+
if (unknown.length === 0) return;
|
|
296
|
+
if (unknownKeySink !== void 0) {
|
|
297
|
+
for (const key of unknown) unknownKeySink.push({
|
|
298
|
+
filePath,
|
|
299
|
+
path: location === "root" ? key : `${location}.${key}`,
|
|
300
|
+
message: `unsupported ${location} field`
|
|
301
|
+
});
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
throw new Error(`Po config at ${filePath} has unsupported ${location} field(s): ${unknown.join(", ")}`);
|
|
305
|
+
}
|
|
306
|
+
function optionalString(value, location, filePath) {
|
|
307
|
+
if (value === void 0) return void 0;
|
|
308
|
+
if (typeof value !== "string" || value.trim().length === 0) throw new Error(`Po config at ${filePath} requires ${location} to be a non-empty string`);
|
|
309
|
+
return value.trim();
|
|
310
|
+
}
|
|
311
|
+
function hasControlCharacters(value) {
|
|
312
|
+
for (const character of value) {
|
|
313
|
+
const codePoint = character.codePointAt(0);
|
|
314
|
+
if (codePoint !== void 0 && (codePoint <= 31 || codePoint === 127)) return true;
|
|
315
|
+
}
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
function boundedOptionalString(value, location, filePath, maximumLength) {
|
|
319
|
+
const text = optionalString(value, location, filePath);
|
|
320
|
+
if (!text) return void 0;
|
|
321
|
+
if (text.length > maximumLength) throw new Error(`Po config at ${filePath} requires ${location} to be at most ${maximumLength} characters`);
|
|
322
|
+
if (hasControlCharacters(text)) throw new Error(`Po config at ${filePath} does not allow control characters in ${location}`);
|
|
323
|
+
return text;
|
|
324
|
+
}
|
|
325
|
+
function parseModelReference(value, filePath) {
|
|
326
|
+
const location = "voice.autoCapture.model";
|
|
327
|
+
const model = optionalString(value, location, filePath);
|
|
328
|
+
if (!model || !MODEL_REFERENCE_PATTERN.test(model)) throw new Error(`Po config at ${filePath} requires ${location} in provider/model-id form`);
|
|
329
|
+
return model;
|
|
330
|
+
}
|
|
331
|
+
function normalizeControlPhrase(value) {
|
|
332
|
+
return value.normalize("NFKC").toLocaleLowerCase("en-US").replace(PHRASE_PUNCTUATION_PATTERN, " ").replace(/\s+/gu, " ").trim();
|
|
333
|
+
}
|
|
334
|
+
function parseControlPhrases(value, location, filePath) {
|
|
335
|
+
if (value === void 0) return void 0;
|
|
336
|
+
if (!Array.isArray(value) || value.some((phrase) => typeof phrase !== "string")) throw new Error(`Po config at ${filePath} requires ${location} to be an array of strings`);
|
|
337
|
+
if (value.length > MAX_CONTROL_PHRASES) throw new Error(`Po config at ${filePath} requires ${location} to contain at most ${MAX_CONTROL_PHRASES} phrases`);
|
|
338
|
+
const phrases = value.map((phrase) => phrase.trim());
|
|
339
|
+
const normalized = /* @__PURE__ */ new Set();
|
|
340
|
+
for (const phrase of phrases) {
|
|
341
|
+
if (phrase.length === 0) throw new Error(`Po config at ${filePath} requires ${location} to contain non-empty strings`);
|
|
342
|
+
if (phrase.length > MAX_CONTROL_PHRASE_LENGTH) throw new Error(`Po config at ${filePath} requires ${location} phrases to be at most ${MAX_CONTROL_PHRASE_LENGTH} characters`);
|
|
343
|
+
if (hasControlCharacters(phrase)) throw new Error(`Po config at ${filePath} does not allow control characters in ${location}`);
|
|
344
|
+
const key = normalizeControlPhrase(phrase);
|
|
345
|
+
if (!key) throw new Error(`Po config at ${filePath} requires ${location} to contain words`);
|
|
346
|
+
if (normalized.has(key)) throw new Error(`Po config at ${filePath} does not allow normalized duplicates in ${location}`);
|
|
347
|
+
normalized.add(key);
|
|
348
|
+
}
|
|
349
|
+
return phrases;
|
|
350
|
+
}
|
|
351
|
+
function parseBoundedInteger(value, location, filePath, minimum, maximum) {
|
|
352
|
+
if (value === void 0) return void 0;
|
|
353
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < minimum || value > maximum) throw new Error(`Po config at ${filePath} requires ${location} to be an integer from ${minimum} to ${maximum}`);
|
|
354
|
+
return value;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Rejects a phrase claimed by two control roles at once.
|
|
358
|
+
*
|
|
359
|
+
* Composition commands are adjudicated before stop phrases and before leading
|
|
360
|
+
* start-phrase removal, so a phrase shared with a later role is not ambiguous, it is
|
|
361
|
+
* silently unreachable. Without a screen there is nothing to show which role won.
|
|
362
|
+
*/
|
|
363
|
+
function assertDisjointPhrases(left, right, leftName, rightName, filePath) {
|
|
364
|
+
const keys = new Set((left ?? []).map(normalizeControlPhrase));
|
|
365
|
+
if ((right ?? []).some((phrase) => keys.has(normalizeControlPhrase(phrase)))) throw new Error(`Po config at ${filePath} does not allow a phrase in both ${leftName} and ${rightName}`);
|
|
366
|
+
}
|
|
367
|
+
function parseTtsConfig(value, filePath) {
|
|
368
|
+
const location = "voice.autoCapture.tts";
|
|
369
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires ${location} to be an object`);
|
|
370
|
+
assertKeys(value, TTS_KEYS, location, filePath);
|
|
371
|
+
if (typeof value.engine !== "string" || !TTS_ENGINE_VALUES.has(value.engine)) throw new Error(`Po config at ${filePath} requires ${location}.engine to be one of: ${[...TTS_ENGINE_VALUES].join(", ")}`);
|
|
372
|
+
const voice = boundedOptionalString(value.voice, `${location}.voice`, filePath, MAX_TTS_VOICE_LENGTH);
|
|
373
|
+
const rate = value.rate;
|
|
374
|
+
if (rate !== void 0 && (typeof rate !== "number" || !Number.isInteger(rate) || rate < MIN_TTS_RATE || rate > MAX_TTS_RATE)) throw new Error(`Po config at ${filePath} requires ${location}.rate to be an integer from ${MIN_TTS_RATE} to ${MAX_TTS_RATE}`);
|
|
375
|
+
return {
|
|
376
|
+
engine: value.engine,
|
|
377
|
+
...voice ? { voice } : {},
|
|
378
|
+
...rate === void 0 ? {} : { rate }
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
function parseAutoCapture(value, filePath) {
|
|
382
|
+
if (value === void 0) return void 0;
|
|
383
|
+
const location = "voice.autoCapture";
|
|
384
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires ${location} to be an object`);
|
|
385
|
+
assertKeys(value, AUTO_CAPTURE_KEYS, location, filePath);
|
|
386
|
+
const startPhrases = parseControlPhrases(value.startPhrases, `${location}.startPhrases`, filePath);
|
|
387
|
+
const stopPhrases = parseControlPhrases(value.stopPhrases, `${location}.stopPhrases`, filePath);
|
|
388
|
+
const composeOpenPhrases = parseControlPhrases(value.composeOpenPhrases, `${location}.composeOpenPhrases`, filePath);
|
|
389
|
+
const composeSendPhrases = parseControlPhrases(value.composeSendPhrases, `${location}.composeSendPhrases`, filePath);
|
|
390
|
+
const composeCancelPhrases = parseControlPhrases(value.composeCancelPhrases, `${location}.composeCancelPhrases`, filePath);
|
|
391
|
+
const utteranceIdleMs = parseBoundedInteger(value.utteranceIdleMs, `${location}.utteranceIdleMs`, filePath, MIN_UTTERANCE_IDLE_MS, MAX_UTTERANCE_IDLE_MS);
|
|
392
|
+
const composeUtteranceIdleMs = parseBoundedInteger(value.composeUtteranceIdleMs, `${location}.composeUtteranceIdleMs`, filePath, MIN_COMPOSE_UTTERANCE_IDLE_MS, MAX_COMPOSE_UTTERANCE_IDLE_MS);
|
|
393
|
+
const composeNudgeMs = value.composeNudgeMs === 0 ? 0 : parseBoundedInteger(value.composeNudgeMs, `${location}.composeNudgeMs`, filePath, MIN_COMPOSE_NUDGE_MS, MAX_COMPOSE_NUDGE_MS);
|
|
394
|
+
const transcriptionTimeoutMs = parseBoundedInteger(value.transcriptionTimeoutMs, `${location}.transcriptionTimeoutMs`, filePath, MIN_TRANSCRIPTION_TIMEOUT_MS, MAX_TRANSCRIPTION_TIMEOUT_MS);
|
|
395
|
+
assertDisjointPhrases(startPhrases, stopPhrases, "startPhrases", "stopPhrases", filePath);
|
|
396
|
+
assertDisjointPhrases(composeSendPhrases, composeCancelPhrases, "composeSendPhrases", "composeCancelPhrases", filePath);
|
|
397
|
+
assertDisjointPhrases(composeOpenPhrases, composeSendPhrases, "composeOpenPhrases", "composeSendPhrases", filePath);
|
|
398
|
+
assertDisjointPhrases(composeOpenPhrases, composeCancelPhrases, "composeOpenPhrases", "composeCancelPhrases", filePath);
|
|
399
|
+
assertDisjointPhrases(stopPhrases, composeSendPhrases, "stopPhrases", "composeSendPhrases", filePath);
|
|
400
|
+
assertDisjointPhrases(stopPhrases, composeCancelPhrases, "stopPhrases", "composeCancelPhrases", filePath);
|
|
401
|
+
return {
|
|
402
|
+
model: parseModelReference(value.model, filePath),
|
|
403
|
+
...startPhrases ? { startPhrases } : {},
|
|
404
|
+
...stopPhrases ? { stopPhrases } : {},
|
|
405
|
+
...composeOpenPhrases ? { composeOpenPhrases } : {},
|
|
406
|
+
...composeSendPhrases ? { composeSendPhrases } : {},
|
|
407
|
+
...composeCancelPhrases ? { composeCancelPhrases } : {},
|
|
408
|
+
...utteranceIdleMs === void 0 ? {} : { utteranceIdleMs },
|
|
409
|
+
...composeUtteranceIdleMs === void 0 ? {} : { composeUtteranceIdleMs },
|
|
410
|
+
...composeNudgeMs === void 0 ? {} : { composeNudgeMs },
|
|
411
|
+
...transcriptionTimeoutMs === void 0 ? {} : { transcriptionTimeoutMs },
|
|
412
|
+
tts: parseTtsConfig(value.tts, filePath)
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
function parseThinking(value, location, filePath) {
|
|
416
|
+
if (value === void 0) return void 0;
|
|
417
|
+
if (typeof value !== "string" || !THINKING_VALUES.has(value)) throw new Error(`Po config at ${filePath} requires ${location}.thinking to be one of: ${[...THINKING_VALUES].join(", ")}`);
|
|
418
|
+
return value;
|
|
419
|
+
}
|
|
420
|
+
function parseAgent(value, location, filePath) {
|
|
421
|
+
if (value === void 0) return void 0;
|
|
422
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires ${location} to be an object`);
|
|
423
|
+
assertKeys(value, AGENT_KEYS, location, filePath);
|
|
424
|
+
const thinking = parseThinking(value.thinking, location, filePath);
|
|
425
|
+
const model = optionalString(value.model, `${location}.model`, filePath);
|
|
426
|
+
return {
|
|
427
|
+
...model ? { model } : {},
|
|
428
|
+
...thinking ? { thinking } : {}
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* A flag the cockpit can write.
|
|
433
|
+
*
|
|
434
|
+
* The settings page writes strings and nothing else, so `'true'` has to mean
|
|
435
|
+
* what a hand-edited `true` means. Anything else is rejected rather than
|
|
436
|
+
* treated as false, because a typo that silently disables a feature is the
|
|
437
|
+
* worst reading of it.
|
|
438
|
+
*/
|
|
439
|
+
function parseFlexibleBoolean(value, location, filePath) {
|
|
440
|
+
if (value === void 0) return void 0;
|
|
441
|
+
if (typeof value === "boolean") return value;
|
|
442
|
+
if (value === "true") return true;
|
|
443
|
+
if (value === "false") return false;
|
|
444
|
+
throw new Error(`Po config at ${filePath} requires ${location} to be true or false`);
|
|
445
|
+
}
|
|
446
|
+
/** Same story as the flag: a number, or the string form the settings page writes. */
|
|
447
|
+
function parseFlexibleRatio(value, location, filePath) {
|
|
448
|
+
if (value === void 0) return void 0;
|
|
449
|
+
const ratio = typeof value === "string" ? Number(value.trim()) : value;
|
|
450
|
+
if (typeof ratio !== "number" || !Number.isFinite(ratio) || ratio < MIN_AUTOCOMPACT_RATIO || ratio > MAX_AUTOCOMPACT_RATIO) throw new Error(`Po config at ${filePath} requires ${location} to be a number from ${MIN_AUTOCOMPACT_RATIO} to ${MAX_AUTOCOMPACT_RATIO}`);
|
|
451
|
+
return ratio;
|
|
452
|
+
}
|
|
453
|
+
function parseAutocompactThresholds(value, location, filePath) {
|
|
454
|
+
if (value === void 0) return void 0;
|
|
455
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires ${location} to be an object`);
|
|
456
|
+
assertKeys(value, AUTOCOMPACT_THRESHOLD_KEYS, location, filePath);
|
|
457
|
+
const pass1 = parseFlexibleRatio(value.pass1, `${location}.pass1`, filePath);
|
|
458
|
+
const pass2 = parseFlexibleRatio(value.pass2, `${location}.pass2`, filePath);
|
|
459
|
+
const pass3 = parseFlexibleRatio(value.pass3, `${location}.pass3`, filePath);
|
|
460
|
+
return {
|
|
461
|
+
...pass1 === void 0 ? {} : { pass1 },
|
|
462
|
+
...pass2 === void 0 ? {} : { pass2 },
|
|
463
|
+
...pass3 === void 0 ? {} : { pass3 }
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
/** Absolute token counts, unlike the ratios, are only ever written by hand, so no string form is accepted. */
|
|
467
|
+
function parseAutocompactTokenCount(value, location, filePath) {
|
|
468
|
+
if (value === void 0) return void 0;
|
|
469
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < MIN_AUTOCOMPACT_TOKENS) throw new Error(`Po config at ${filePath} requires ${location} to be an integer of at least ${MIN_AUTOCOMPACT_TOKENS}`);
|
|
470
|
+
return value;
|
|
471
|
+
}
|
|
472
|
+
function parseAutocompactOverrideEntry(value, location, filePath) {
|
|
473
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires ${location} to be an object`);
|
|
474
|
+
assertKeys(value, AUTOCOMPACT_OVERRIDE_KEYS, location, filePath);
|
|
475
|
+
const model = optionalString(value.model, `${location}.model`, filePath);
|
|
476
|
+
if (!model) throw new Error(`Po config at ${filePath} requires ${location}.model`);
|
|
477
|
+
if (!isObject(value.tokens)) throw new Error(`Po config at ${filePath} requires ${location}.tokens to be an object`);
|
|
478
|
+
assertKeys(value.tokens, AUTOCOMPACT_THRESHOLD_KEYS, `${location}.tokens`, filePath);
|
|
479
|
+
const pass1 = parseAutocompactTokenCount(value.tokens.pass1, `${location}.tokens.pass1`, filePath);
|
|
480
|
+
const pass2 = parseAutocompactTokenCount(value.tokens.pass2, `${location}.tokens.pass2`, filePath);
|
|
481
|
+
const pass3 = parseAutocompactTokenCount(value.tokens.pass3, `${location}.tokens.pass3`, filePath);
|
|
482
|
+
if (pass1 === void 0 && pass2 === void 0 && pass3 === void 0) throw new Error(`Po config at ${filePath} requires one of ${location}.tokens.pass1, pass2, or pass3`);
|
|
483
|
+
return {
|
|
484
|
+
model,
|
|
485
|
+
tokens: {
|
|
486
|
+
...pass1 === void 0 ? {} : { pass1 },
|
|
487
|
+
...pass2 === void 0 ? {} : { pass2 },
|
|
488
|
+
...pass3 === void 0 ? {} : { pass3 }
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
function parseAutocompactOverrides(value, location, filePath) {
|
|
493
|
+
if (value === void 0) return void 0;
|
|
494
|
+
if (!Array.isArray(value)) throw new Error(`Po config at ${filePath} requires ${location} to be a list`);
|
|
495
|
+
return value.map((entry, index) => parseAutocompactOverrideEntry(entry, `${location}[${index}]`, filePath));
|
|
496
|
+
}
|
|
497
|
+
function parseAutocompactModeConfig(value, filePath, location = "modes.autocompact") {
|
|
498
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires ${location} to be an object`);
|
|
499
|
+
assertKeys(value, AUTOCOMPACT_KEYS, location, filePath);
|
|
500
|
+
const enabled = parseFlexibleBoolean(value.enabled, `${location}.enabled`, filePath);
|
|
501
|
+
const model = optionalString(value.model, `${location}.model`, filePath);
|
|
502
|
+
const thinking = parseThinking(value.thinking, location, filePath);
|
|
503
|
+
const thresholds = parseAutocompactThresholds(value.thresholds, `${location}.thresholds`, filePath);
|
|
504
|
+
const overrides = parseAutocompactOverrides(value.overrides, `${location}.overrides`, filePath);
|
|
505
|
+
return {
|
|
506
|
+
...enabled === void 0 ? {} : { enabled },
|
|
507
|
+
...model ? { model } : {},
|
|
508
|
+
...thinking ? { thinking } : {},
|
|
509
|
+
...thresholds ? { thresholds } : {},
|
|
510
|
+
...overrides ? { overrides } : {}
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
function parsePlanningModeConfig(value, filePath, location = "modes.planning") {
|
|
514
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires ${location} to be an object`);
|
|
515
|
+
assertKeys(value, PLANNING_KEYS, location, filePath);
|
|
516
|
+
return {
|
|
517
|
+
main: parseAgent(value.main, `${location}.main`, filePath),
|
|
518
|
+
subagents: parseAgent(value.subagents, `${location}.subagents`, filePath),
|
|
519
|
+
plansDirectory: optionalString(value.plansDirectory, `${location}.plansDirectory`, filePath)
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
function parseModel(value, location, filePath, allowId) {
|
|
523
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires ${location} to be an object`);
|
|
524
|
+
assertKeys(value, MODEL_KEYS, location, filePath);
|
|
525
|
+
const modelPath = optionalString(value.path, `${location}.path`, filePath);
|
|
526
|
+
const id = optionalString(value.id, `${location}.id`, filePath);
|
|
527
|
+
if (Boolean(modelPath) === Boolean(id)) throw new Error(`Po config at ${filePath} requires exactly one of ${location}.path or ${location}.id`);
|
|
528
|
+
if (id && !allowId) throw new Error(`Po config at ${filePath} does not support ${location}.id for whisper-cpp`);
|
|
529
|
+
return {
|
|
530
|
+
...modelPath ? { path: modelPath } : {},
|
|
531
|
+
...id ? { id } : {}
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
function parseAdapter(value, location, filePath, allowId) {
|
|
535
|
+
if (value === void 0) return void 0;
|
|
536
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires ${location} to be an object`);
|
|
537
|
+
assertKeys(value, ADAPTER_KEYS, location, filePath);
|
|
538
|
+
const binary = optionalString(value.binary, `${location}.binary`, filePath);
|
|
539
|
+
return {
|
|
540
|
+
...binary ? { binary } : {},
|
|
541
|
+
model: parseModel(value.model, `${location}.model`, filePath, allowId)
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
function parseVoice(value, filePath) {
|
|
545
|
+
if (value === void 0) return void 0;
|
|
546
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires voice to be an object`);
|
|
547
|
+
assertKeys(value, VOICE_KEYS, "voice", filePath);
|
|
548
|
+
const result = {};
|
|
549
|
+
if (value.mode !== void 0) {
|
|
550
|
+
if (typeof value.mode !== "string" || !VOICE_MODE_VALUES.has(value.mode)) throw new Error(`Po config at ${filePath} requires voice.mode to be one of: ${[...VOICE_MODE_VALUES].join(", ")}`);
|
|
551
|
+
result.mode = value.mode;
|
|
552
|
+
}
|
|
553
|
+
if (value.engine !== void 0) {
|
|
554
|
+
if (typeof value.engine !== "string" || !ENGINE_VALUES.has(value.engine)) throw new Error(`Po config at ${filePath} requires voice.engine to be one of: ${[...ENGINE_VALUES].join(", ")}`);
|
|
555
|
+
result.engine = value.engine;
|
|
556
|
+
}
|
|
557
|
+
const language = optionalString(value.language, "voice.language", filePath);
|
|
558
|
+
if (language) result.language = language;
|
|
559
|
+
if (value.recorder !== void 0) {
|
|
560
|
+
if (!isObject(value.recorder)) throw new Error(`Po config at ${filePath} requires voice.recorder to be an object`);
|
|
561
|
+
assertKeys(value.recorder, RECORDER_KEYS, "voice.recorder", filePath);
|
|
562
|
+
result.recorder = {};
|
|
563
|
+
const binary = optionalString(value.recorder.binary, "voice.recorder.binary", filePath);
|
|
564
|
+
const device = optionalString(value.recorder.device, "voice.recorder.device", filePath);
|
|
565
|
+
if (binary) result.recorder.binary = binary;
|
|
566
|
+
if (device) result.recorder.device = device;
|
|
567
|
+
}
|
|
568
|
+
if (value.adapters !== void 0) {
|
|
569
|
+
if (!isObject(value.adapters)) throw new Error(`Po config at ${filePath} requires voice.adapters to be an object`);
|
|
570
|
+
assertKeys(value.adapters, ADAPTERS_KEYS, "voice.adapters", filePath);
|
|
571
|
+
result.adapters = {
|
|
572
|
+
[WHISPER_CPP_ENGINE]: parseAdapter(value.adapters[WHISPER_CPP_ENGINE], `voice.adapters.${WHISPER_CPP_ENGINE}`, filePath, false),
|
|
573
|
+
[OPENAI_WHISPER_ENGINE]: parseAdapter(value.adapters[OPENAI_WHISPER_ENGINE], `voice.adapters.${OPENAI_WHISPER_ENGINE}`, filePath, true),
|
|
574
|
+
[MLX_WHISPER_ENGINE]: parseAdapter(value.adapters[MLX_WHISPER_ENGINE], `voice.adapters.${MLX_WHISPER_ENGINE}`, filePath, true)
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
const autoCapture = parseAutoCapture(value.autoCapture, filePath);
|
|
578
|
+
if (autoCapture) result.autoCapture = autoCapture;
|
|
579
|
+
const live = parseVoiceLive(value.live, filePath);
|
|
580
|
+
if (live) result.live = live;
|
|
581
|
+
return result;
|
|
582
|
+
}
|
|
583
|
+
function parseVoiceLive(value, filePath) {
|
|
584
|
+
if (value === void 0) return void 0;
|
|
585
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires voice.live to be an object`);
|
|
586
|
+
assertKeys(value, VOICE_LIVE_KEYS, "voice.live", filePath);
|
|
587
|
+
const result = {};
|
|
588
|
+
if (value.voice !== void 0) {
|
|
589
|
+
if (typeof value.voice !== "string" || !PO_VOICE_LIVE_VOICES.includes(value.voice)) throw new Error(`Po config at ${filePath} requires voice.live.voice to be one of: ${PO_VOICE_LIVE_VOICES.join(", ")}`);
|
|
590
|
+
result.voice = value.voice;
|
|
591
|
+
}
|
|
592
|
+
if (value.model !== void 0) {
|
|
593
|
+
if (typeof value.model !== "string" || value.model.length > MAX_LIVE_MODEL_LENGTH || !LIVE_MODEL_PATTERN.test(value.model)) throw new Error(`Po config at ${filePath} requires voice.live.model to be a model id of at most ${MAX_LIVE_MODEL_LENGTH} letters, digits, dots, colons, underscores or dashes`);
|
|
594
|
+
result.model = value.model;
|
|
595
|
+
}
|
|
596
|
+
return result;
|
|
597
|
+
}
|
|
598
|
+
function parseSelection(value, filePath) {
|
|
599
|
+
if (value === void 0) return void 0;
|
|
600
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires selection to be an object`);
|
|
601
|
+
if (Object.hasOwn(value, "majorMode")) throw new Error(`Po config at ${filePath}: selection.majorMode was renamed to selection.preset.`);
|
|
602
|
+
assertKeys(value, SELECTION_KEYS, "selection", filePath);
|
|
603
|
+
const domains = value.domains;
|
|
604
|
+
if (domains !== void 0 && (!Array.isArray(domains) || domains.some((name) => typeof name !== "string"))) throw new Error(`Po config at ${filePath} requires selection.domains to be an array of strings`);
|
|
605
|
+
return {
|
|
606
|
+
preset: optionalString(value.preset, "selection.preset", filePath),
|
|
607
|
+
domains,
|
|
608
|
+
profile: optionalString(value.profile, "selection.profile", filePath)
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
function parseEditor(value, filePath) {
|
|
612
|
+
if (value === void 0) return void 0;
|
|
613
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires editor to be an object`);
|
|
614
|
+
assertKeys(value, EDITOR_KEYS, "editor", filePath);
|
|
615
|
+
return { command: optionalString(value.command, "editor.command", filePath) };
|
|
616
|
+
}
|
|
617
|
+
function parseBrowse(value, filePath) {
|
|
618
|
+
if (value === void 0) return void 0;
|
|
619
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires browse to be an object`);
|
|
620
|
+
assertKeys(value, BROWSE_KEYS, "browse", filePath);
|
|
621
|
+
const pick = (key, allowed) => {
|
|
622
|
+
const raw = value[key];
|
|
623
|
+
if (raw === void 0) return void 0;
|
|
624
|
+
if (typeof raw !== "string" || !allowed.includes(raw)) throw new Error(`Po config at ${filePath} requires browse.${key} to be one of: ${allowed.join(", ")}`);
|
|
625
|
+
return raw;
|
|
626
|
+
};
|
|
627
|
+
const engine = pick("engine", PO_BROWSE_ENGINES);
|
|
628
|
+
const fallback = pick("fallback", PO_BROWSE_FALLBACKS);
|
|
629
|
+
return {
|
|
630
|
+
...engine ? { engine } : {},
|
|
631
|
+
...fallback ? { fallback } : {}
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
function parseMinimumInteger(value, location, filePath, minimum) {
|
|
635
|
+
if (value === void 0) return void 0;
|
|
636
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < minimum) throw new Error(`Po config at ${filePath} requires ${location} to be an integer of at least ${minimum}`);
|
|
637
|
+
return value;
|
|
638
|
+
}
|
|
639
|
+
function parseIosPool(value, filePath) {
|
|
640
|
+
if (value === void 0) return void 0;
|
|
641
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires ios.pool to be an object`);
|
|
642
|
+
assertKeys(value, IOS_POOL_KEYS, "ios.pool", filePath);
|
|
643
|
+
const pool = {};
|
|
644
|
+
const integer = (key, minimum) => {
|
|
645
|
+
const parsed = parseMinimumInteger(value[key], `ios.pool.${key}`, filePath, minimum);
|
|
646
|
+
if (parsed !== void 0) pool[key] = parsed;
|
|
647
|
+
};
|
|
648
|
+
integer("minBooted", 0);
|
|
649
|
+
integer("maxBooted", 1);
|
|
650
|
+
integer("maxDevices", 1);
|
|
651
|
+
integer("idleShutdownMinutes", 1);
|
|
652
|
+
integer("waitTimeoutSeconds", 0);
|
|
653
|
+
const deviceType = optionalString(value.deviceType, "ios.pool.deviceType", filePath);
|
|
654
|
+
if (deviceType !== void 0) pool.deviceType = deviceType;
|
|
655
|
+
const runtime = optionalString(value.runtime, "ios.pool.runtime", filePath);
|
|
656
|
+
if (runtime !== void 0) pool.runtime = runtime;
|
|
657
|
+
if (pool.minBooted !== void 0 && pool.maxBooted !== void 0 && pool.minBooted > pool.maxBooted) throw new Error(`Po config at ${filePath} requires ios.pool.minBooted to be at most ios.pool.maxBooted`);
|
|
658
|
+
if (pool.maxBooted !== void 0 && pool.maxDevices !== void 0 && pool.maxBooted > pool.maxDevices) throw new Error(`Po config at ${filePath} requires ios.pool.maxBooted to be at most ios.pool.maxDevices`);
|
|
659
|
+
if (pool.minBooted !== void 0 && pool.maxDevices !== void 0 && pool.minBooted > pool.maxDevices) throw new Error(`Po config at ${filePath} requires ios.pool.minBooted to be at most ios.pool.maxDevices`);
|
|
660
|
+
return pool;
|
|
661
|
+
}
|
|
662
|
+
function parseIos(value, filePath) {
|
|
663
|
+
if (value === void 0) return void 0;
|
|
664
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires ios to be an object`);
|
|
665
|
+
assertKeys(value, IOS_KEYS, "ios", filePath);
|
|
666
|
+
const result = {};
|
|
667
|
+
const pool = parseIosPool(value.pool, filePath);
|
|
668
|
+
if (pool) result.pool = pool;
|
|
669
|
+
const helperPath = optionalString(value.helperPath, "ios.helperPath", filePath);
|
|
670
|
+
if (helperPath !== void 0) result.helperPath = helperPath;
|
|
671
|
+
if (value.device !== void 0) {
|
|
672
|
+
if (!isObject(value.device)) throw new Error(`Po config at ${filePath} requires ios.device to be an object`);
|
|
673
|
+
assertKeys(value.device, IOS_DEVICE_KEYS, "ios.device", filePath);
|
|
674
|
+
const developmentTeam = optionalString(value.device.developmentTeam, "ios.device.developmentTeam", filePath);
|
|
675
|
+
if (developmentTeam !== void 0 && !/^[A-Z0-9]{10}$/.test(developmentTeam)) throw new Error(`Po config at ${filePath} requires ios.device.developmentTeam to be 10 uppercase letters or digits`);
|
|
676
|
+
result.device = developmentTeam === void 0 ? {} : { developmentTeam };
|
|
677
|
+
if (value.device.availability !== void 0) {
|
|
678
|
+
const availability = value.device.availability;
|
|
679
|
+
if (!isObject(availability) || Object.entries(availability).some(([udid, state]) => !/^[a-fA-F0-9]{8}-[a-fA-F0-9]{16}$|^[a-fA-F0-9]{40}$/.test(udid) || state !== "available" && state !== "excluded")) throw new Error(`Po config at ${filePath} requires ios.device.availability to map hardware UDIDs to available or excluded`);
|
|
680
|
+
result.device.availability = { ...availability };
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
return result;
|
|
684
|
+
}
|
|
685
|
+
const KEBAB_ID = "[a-z][a-z0-9]*(?:-[a-z0-9]+)*";
|
|
686
|
+
const TEMPLATE_ID = new RegExp(`^${KEBAB_ID}$`);
|
|
687
|
+
/** A background is `none` or the `<pluginId>/<fillId>` of an installed `backdrop` fill. */
|
|
688
|
+
const BACKDROP_CHOICE = new RegExp(`^(?:none|${KEBAB_ID}/${KEBAB_ID})$`);
|
|
689
|
+
/** `web` and `native` each choose a template, so both read the same `{ template }` shape; `web` also chooses a background. */
|
|
690
|
+
function parseTemplateChoice(value, root, filePath) {
|
|
691
|
+
if (value === void 0) return void 0;
|
|
692
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires ${root} to be an object`);
|
|
693
|
+
assertKeys(value, root === "web" ? ["template", "backdrop"] : ["template"], root, filePath);
|
|
694
|
+
const choice = {};
|
|
695
|
+
if (value.template !== void 0) {
|
|
696
|
+
const template = optionalString(value.template, `${root}.template`, filePath);
|
|
697
|
+
if (!template || template.length > 160 || !TEMPLATE_ID.test(template)) throw new Error(`Po config at ${filePath} requires ${root}.template to be a kebab-case template identifier`);
|
|
698
|
+
choice.template = template;
|
|
699
|
+
}
|
|
700
|
+
if (value.backdrop !== void 0) {
|
|
701
|
+
const backdrop = optionalString(value.backdrop, `${root}.backdrop`, filePath);
|
|
702
|
+
if (!backdrop || backdrop.length > 160 || !BACKDROP_CHOICE.test(backdrop)) throw new Error(`Po config at ${filePath} requires ${root}.backdrop to be none or <pluginId>/<fillId>`);
|
|
703
|
+
choice.backdrop = backdrop;
|
|
704
|
+
}
|
|
705
|
+
return choice;
|
|
706
|
+
}
|
|
707
|
+
function parseComputerUse(value, filePath) {
|
|
708
|
+
if (value === void 0) return void 0;
|
|
709
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires computerUse to be an object`);
|
|
710
|
+
assertKeys(value, COMPUTER_USE_KEYS, "computerUse", filePath);
|
|
711
|
+
const enabled = parseFlexibleBoolean(value.enabled, "computerUse.enabled", filePath);
|
|
712
|
+
return enabled === void 0 ? {} : { enabled };
|
|
713
|
+
}
|
|
714
|
+
function parseProfileMemory(value, filePath) {
|
|
715
|
+
if (value === void 0) return void 0;
|
|
716
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires profileMemory to be an object`);
|
|
717
|
+
assertKeys(value, PROFILE_MEMORY_KEYS, "profileMemory", filePath);
|
|
718
|
+
const automatic = parseFlexibleBoolean(value.automatic, "profileMemory.automatic", filePath);
|
|
719
|
+
return automatic === void 0 ? {} : { automatic };
|
|
720
|
+
}
|
|
721
|
+
/** A list, or the comma-separated text the settings page writes for one. */
|
|
722
|
+
function parseFlexibleList(value, location, filePath) {
|
|
723
|
+
if (value === void 0) return void 0;
|
|
724
|
+
const entries = typeof value === "string" ? value.split(",") : value;
|
|
725
|
+
if (!Array.isArray(entries) || entries.some((entry) => typeof entry !== "string")) throw new Error(`Po config at ${filePath} requires ${location} to be a list of strings`);
|
|
726
|
+
return [...new Set(entries.map((entry) => entry.trim()).filter(Boolean))];
|
|
727
|
+
}
|
|
728
|
+
/** An agent's runtime name: its file's `name`, qualified by its package with a dot. */
|
|
729
|
+
const SUBAGENT_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u;
|
|
730
|
+
function parseSubagentAgents(value, filePath) {
|
|
731
|
+
if (value === void 0) return void 0;
|
|
732
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires subagents.agents to be an object`);
|
|
733
|
+
const agents = {};
|
|
734
|
+
for (const [name, entry] of Object.entries(value)) {
|
|
735
|
+
if (!SUBAGENT_NAME.test(name)) throw new Error(`Po config at ${filePath} has an invalid agent name in subagents.agents: ${name}`);
|
|
736
|
+
const agent = parseAgent(entry, `subagents.agents.${name}`, filePath);
|
|
737
|
+
if (agent && Object.keys(agent).length > 0) agents[name] = agent;
|
|
738
|
+
}
|
|
739
|
+
return Object.keys(agents).length > 0 ? agents : void 0;
|
|
740
|
+
}
|
|
741
|
+
function parseSubagents(value, filePath) {
|
|
742
|
+
if (value === void 0) return void 0;
|
|
743
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires subagents to be an object`);
|
|
744
|
+
assertKeys(value, SUBAGENTS_KEYS, "subagents", filePath);
|
|
745
|
+
const model = optionalString(value.model, "subagents.model", filePath);
|
|
746
|
+
const thinking = parseThinking(value.thinking, "subagents", filePath);
|
|
747
|
+
const fallbackModels = parseFlexibleList(value.fallbackModels, "subagents.fallbackModels", filePath);
|
|
748
|
+
const excludeTools = parseFlexibleList(value.excludeTools, "subagents.excludeTools", filePath);
|
|
749
|
+
const agents = parseSubagentAgents(value.agents, filePath);
|
|
750
|
+
return {
|
|
751
|
+
...model ? { model } : {},
|
|
752
|
+
...thinking ? { thinking } : {},
|
|
753
|
+
...fallbackModels ? { fallbackModels } : {},
|
|
754
|
+
...excludeTools ? { excludeTools } : {},
|
|
755
|
+
...agents ? { agents } : {}
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
function parseDesktopEnvironment(value, filePath) {
|
|
759
|
+
if (value === void 0) return void 0;
|
|
760
|
+
if (!isObject(value)) throw new Error(`Po config at ${filePath} requires desktopEnvironment to be an object`);
|
|
761
|
+
assertKeys(value, DESKTOP_ENVIRONMENT_KEYS, "desktopEnvironment", filePath);
|
|
762
|
+
if (value.inherit !== void 0 && value.inherit !== "all" && value.inherit !== "core") throw new Error(`Po config at ${filePath} desktopEnvironment.inherit must be all or core`);
|
|
763
|
+
const exclude = parseFlexibleList(value.exclude, "desktopEnvironment.exclude", filePath);
|
|
764
|
+
const includeOnly = parseFlexibleList(value.includeOnly, "desktopEnvironment.includeOnly", filePath);
|
|
765
|
+
if (value.set !== void 0 && (!isObject(value.set) || Object.entries(value.set).some(([name, entry]) => !ENVIRONMENT_VARIABLE_NAME.test(name) || typeof entry !== "string"))) throw new Error(`Po config at ${filePath} requires desktopEnvironment.set to map variable names to strings`);
|
|
766
|
+
return {
|
|
767
|
+
...value.inherit === void 0 ? {} : { inherit: value.inherit },
|
|
768
|
+
...exclude ? { exclude } : {},
|
|
769
|
+
...includeOnly ? { includeOnly } : {},
|
|
770
|
+
...value.set === void 0 ? {} : { set: { ...value.set } }
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
function parsePoConfig(content, filePath, options) {
|
|
774
|
+
if (options?.lenient !== true) return parseStrict(content, filePath);
|
|
775
|
+
const diagnostics = [];
|
|
776
|
+
const previous = unknownKeySink;
|
|
777
|
+
unknownKeySink = diagnostics;
|
|
778
|
+
try {
|
|
779
|
+
return {
|
|
780
|
+
config: parseStrict(content, filePath),
|
|
781
|
+
diagnostics
|
|
782
|
+
};
|
|
783
|
+
} finally {
|
|
784
|
+
unknownKeySink = previous;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
function parseWorkspaces(value, filePath) {
|
|
788
|
+
if (value === void 0) return void 0;
|
|
789
|
+
if (!Array.isArray(value)) throw new Error(`Po config at ${filePath} requires workspaces to be a list`);
|
|
790
|
+
const names = /* @__PURE__ */ new Set();
|
|
791
|
+
return value.map((entry, index) => {
|
|
792
|
+
const location = `workspaces[${index}]`;
|
|
793
|
+
if (!isObject(entry)) throw new Error(`Po config at ${filePath} requires ${location} to be an object`);
|
|
794
|
+
assertKeys(entry, WORKSPACE_KEYS, location, filePath);
|
|
795
|
+
const name = optionalString(entry.name, `${location}.name`, filePath);
|
|
796
|
+
if (!name) throw new Error(`Po config at ${filePath} requires ${location}.name to be a non-empty string`);
|
|
797
|
+
if (entry.instructions !== void 0 && typeof entry.instructions !== "string") throw new Error(`Po config at ${filePath} requires ${location}.instructions to be a string`);
|
|
798
|
+
const key = name.toLowerCase();
|
|
799
|
+
if (names.has(key)) throw new Error(`Po config at ${filePath} has duplicate ${location}.name: ${name}`);
|
|
800
|
+
names.add(key);
|
|
801
|
+
return {
|
|
802
|
+
name,
|
|
803
|
+
...entry.instructions === void 0 ? {} : { instructions: entry.instructions }
|
|
804
|
+
};
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
function parseStrict(content, filePath) {
|
|
808
|
+
let parsed;
|
|
809
|
+
try {
|
|
810
|
+
parsed = parse(content) ?? {};
|
|
811
|
+
} catch (error) {
|
|
812
|
+
throw new Error(`Could not parse Po config at ${filePath}`, { cause: error });
|
|
813
|
+
}
|
|
814
|
+
if (!isObject(parsed)) throw new Error(`Po config at ${filePath} must be a YAML object`);
|
|
815
|
+
assertKeys(parsed, ROOT_KEYS, "root", filePath);
|
|
816
|
+
let modes;
|
|
817
|
+
if (parsed.modes !== void 0) {
|
|
818
|
+
if (!isObject(parsed.modes)) throw new Error(`Po config at ${filePath} requires modes to be an object`);
|
|
819
|
+
assertKeys(parsed.modes, MODE_KEYS, "modes", filePath);
|
|
820
|
+
modes = {
|
|
821
|
+
...parsed.modes.planning === void 0 ? {} : { planning: parsePlanningModeConfig(parsed.modes.planning, filePath) },
|
|
822
|
+
...parsed.modes.autocompact === void 0 ? {} : { autocompact: parseAutocompactModeConfig(parsed.modes.autocompact, filePath) }
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
const trust = parsed.projectTrust === void 0 ? DEFAULT_PROJECT_TRUST : parsed.projectTrust;
|
|
826
|
+
if (typeof trust !== "string" || !TRUST_VALUES.has(trust)) throw new Error(`Po config at ${filePath} projectTrust must be ask, always, or never`);
|
|
827
|
+
return {
|
|
828
|
+
modes,
|
|
829
|
+
computerUse: parseComputerUse(parsed.computerUse, filePath),
|
|
830
|
+
desktopEnvironment: parseDesktopEnvironment(parsed.desktopEnvironment, filePath),
|
|
831
|
+
profileMemory: parseProfileMemory(parsed.profileMemory, filePath),
|
|
832
|
+
subagents: parseSubagents(parsed.subagents, filePath),
|
|
833
|
+
projectTrust: trust,
|
|
834
|
+
workspaces: parseWorkspaces(parsed.workspaces, filePath),
|
|
835
|
+
editor: parseEditor(parsed.editor, filePath),
|
|
836
|
+
browse: parseBrowse(parsed.browse, filePath),
|
|
837
|
+
ios: parseIos(parsed.ios, filePath),
|
|
838
|
+
voice: parseVoice(parsed.voice, filePath),
|
|
839
|
+
selection: parseSelection(parsed.selection, filePath),
|
|
840
|
+
web: parseTemplateChoice(parsed.web, "web", filePath),
|
|
841
|
+
native: parseTemplateChoice(parsed.native, "native", filePath)
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
function mergeAgent(globalValue, repositoryValue) {
|
|
845
|
+
return globalValue || repositoryValue ? {
|
|
846
|
+
...globalValue,
|
|
847
|
+
...repositoryValue
|
|
848
|
+
} : void 0;
|
|
849
|
+
}
|
|
850
|
+
function mergeSubagents(globalValue, repositoryValue) {
|
|
851
|
+
if (!globalValue && !repositoryValue) return void 0;
|
|
852
|
+
const names = /* @__PURE__ */ new Set([...Object.keys(globalValue?.agents ?? {}), ...Object.keys(repositoryValue?.agents ?? {})]);
|
|
853
|
+
const agents = Object.fromEntries([...names].map((name) => [name, mergeAgent(globalValue?.agents?.[name], repositoryValue?.agents?.[name])]));
|
|
854
|
+
return {
|
|
855
|
+
...globalValue,
|
|
856
|
+
...repositoryValue,
|
|
857
|
+
...names.size > 0 ? { agents } : {}
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
function mergePoConfigs(globalConfig, repositoryConfig) {
|
|
861
|
+
if (repositoryConfig.voice?.mode) throw new Error("Repository Po config voice.mode is global-only; configure it in ~/.po/config.yaml");
|
|
862
|
+
if (repositoryConfig.voice?.autoCapture) throw new Error("Repository Po config voice.autoCapture is global-only; configure it in ~/.po/config.yaml");
|
|
863
|
+
if (repositoryConfig.voice?.live) throw new Error("Repository Po config voice.live is global-only; configure it in ~/.po/config.yaml");
|
|
864
|
+
if (repositoryConfig.computerUse) throw new Error("Repository Po config computerUse is global-only; configure it in ~/.po/config.yaml");
|
|
865
|
+
if (repositoryConfig.desktopEnvironment) throw new Error("Repository Po config desktopEnvironment is global-only; configure it in ~/.po/config.yaml");
|
|
866
|
+
if (repositoryConfig.browse) throw new Error("Repository Po config browse is global-only; configure it in ~/.po/config.yaml");
|
|
867
|
+
if (repositoryConfig.ios) throw new Error("Repository Po config ios is global-only; configure it in ~/.po/config.yaml");
|
|
868
|
+
if (repositoryConfig.profileMemory) throw new Error("Repository Po config profileMemory is global-only; configure it in ~/.po/config.yaml");
|
|
869
|
+
const globalPlanning = globalConfig.modes?.planning;
|
|
870
|
+
const repositoryPlanning = repositoryConfig.modes?.planning;
|
|
871
|
+
const planning = globalPlanning || repositoryPlanning ? {
|
|
872
|
+
main: mergeAgent(globalPlanning?.main, repositoryPlanning?.main),
|
|
873
|
+
subagents: mergeAgent(globalPlanning?.subagents, repositoryPlanning?.subagents),
|
|
874
|
+
plansDirectory: repositoryPlanning?.plansDirectory ?? globalPlanning?.plansDirectory
|
|
875
|
+
} : void 0;
|
|
876
|
+
const globalAutocompact = globalConfig.modes?.autocompact;
|
|
877
|
+
const repositoryAutocompact = repositoryConfig.modes?.autocompact;
|
|
878
|
+
const autocompact = globalAutocompact || repositoryAutocompact ? {
|
|
879
|
+
...globalAutocompact,
|
|
880
|
+
...repositoryAutocompact,
|
|
881
|
+
...globalAutocompact?.thresholds || repositoryAutocompact?.thresholds ? { thresholds: {
|
|
882
|
+
...globalAutocompact?.thresholds,
|
|
883
|
+
...repositoryAutocompact?.thresholds
|
|
884
|
+
} } : {}
|
|
885
|
+
} : void 0;
|
|
886
|
+
const voice = mergeVoice(globalConfig.voice, repositoryConfig.voice);
|
|
887
|
+
return {
|
|
888
|
+
modes: planning || autocompact ? {
|
|
889
|
+
...planning ? { planning } : {},
|
|
890
|
+
...autocompact ? { autocompact } : {}
|
|
891
|
+
} : void 0,
|
|
892
|
+
computerUse: globalConfig.computerUse,
|
|
893
|
+
desktopEnvironment: globalConfig.desktopEnvironment,
|
|
894
|
+
profileMemory: globalConfig.profileMemory,
|
|
895
|
+
subagents: mergeSubagents(globalConfig.subagents, repositoryConfig.subagents),
|
|
896
|
+
projectTrust: repositoryConfig.projectTrust,
|
|
897
|
+
workspaces: repositoryConfig.workspaces,
|
|
898
|
+
editor: globalConfig.editor,
|
|
899
|
+
browse: globalConfig.browse,
|
|
900
|
+
ios: globalConfig.ios,
|
|
901
|
+
voice,
|
|
902
|
+
web: globalConfig.web || repositoryConfig.web ? {
|
|
903
|
+
template: repositoryConfig.web?.template ?? globalConfig.web?.template,
|
|
904
|
+
backdrop: repositoryConfig.web?.backdrop ?? globalConfig.web?.backdrop
|
|
905
|
+
} : void 0,
|
|
906
|
+
native: globalConfig.native || repositoryConfig.native ? { template: repositoryConfig.native?.template ?? globalConfig.native?.template } : void 0,
|
|
907
|
+
selection: globalConfig.selection || repositoryConfig.selection ? {
|
|
908
|
+
...globalConfig.selection,
|
|
909
|
+
...repositoryConfig.selection
|
|
910
|
+
} : void 0
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
function mergeAdapter(globalValue, repositoryValue) {
|
|
914
|
+
if (!globalValue && !repositoryValue) return void 0;
|
|
915
|
+
return {
|
|
916
|
+
...globalValue,
|
|
917
|
+
...repositoryValue,
|
|
918
|
+
model: repositoryValue?.model ?? globalValue.model
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
function mergeVoice(globalValue, repositoryValue) {
|
|
922
|
+
if (!globalValue && !repositoryValue) return void 0;
|
|
923
|
+
return {
|
|
924
|
+
...globalValue,
|
|
925
|
+
...repositoryValue,
|
|
926
|
+
...globalValue?.mode ? { mode: globalValue.mode } : {},
|
|
927
|
+
recorder: globalValue?.recorder || repositoryValue?.recorder ? {
|
|
928
|
+
...globalValue?.recorder,
|
|
929
|
+
...repositoryValue?.recorder
|
|
930
|
+
} : void 0,
|
|
931
|
+
adapters: globalValue?.adapters || repositoryValue?.adapters ? {
|
|
932
|
+
[WHISPER_CPP_ENGINE]: mergeAdapter(globalValue?.adapters?.[WHISPER_CPP_ENGINE], repositoryValue?.adapters?.[WHISPER_CPP_ENGINE]),
|
|
933
|
+
[OPENAI_WHISPER_ENGINE]: mergeAdapter(globalValue?.adapters?.[OPENAI_WHISPER_ENGINE], repositoryValue?.adapters?.[OPENAI_WHISPER_ENGINE]),
|
|
934
|
+
[MLX_WHISPER_ENGINE]: mergeAdapter(globalValue?.adapters?.[MLX_WHISPER_ENGINE], repositoryValue?.adapters?.[MLX_WHISPER_ENGINE])
|
|
935
|
+
} : void 0,
|
|
936
|
+
...globalValue?.autoCapture ? { autoCapture: globalValue.autoCapture } : {}
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Resolves voice settings, optionally shadowed by the active profile's override.
|
|
941
|
+
*
|
|
942
|
+
* The override is per field, so a persona that sets only `rate` keeps the voice
|
|
943
|
+
* from config.yaml. `engine` is deliberately not overridable: it selects the
|
|
944
|
+
* synthesiser binary, which is a machine-level fact rather than a persona's.
|
|
945
|
+
*
|
|
946
|
+
* The result is read once when autonomous voice activates, because
|
|
947
|
+
* `VoiceNarrationPlayback.config` is assigned in `activate()` and has no setter.
|
|
948
|
+
* That is sufficient today only because every profile switch reloads the
|
|
949
|
+
* session, which deactivates and reactivates voice. A future in-place profile
|
|
950
|
+
* switch would leave the spoken voice stale until the next activation.
|
|
951
|
+
*/
|
|
952
|
+
function resolveVoiceConfig(config, ttsOverride) {
|
|
953
|
+
return {
|
|
954
|
+
mode: config.mode ?? DEFAULT_VOICE_MODE,
|
|
955
|
+
engine: config.engine ?? DEFAULT_VOICE_ENGINE,
|
|
956
|
+
language: config.language ?? DEFAULT_VOICE_LANGUAGE,
|
|
957
|
+
recorder: {
|
|
958
|
+
...config.recorder,
|
|
959
|
+
device: config.recorder?.device ?? DEFAULT_RECORDER_DEVICE
|
|
960
|
+
},
|
|
961
|
+
adapters: config.adapters ?? {},
|
|
962
|
+
...config.autoCapture ? { autoCapture: {
|
|
963
|
+
...config.autoCapture,
|
|
964
|
+
startPhrases: [...config.autoCapture.startPhrases ?? []],
|
|
965
|
+
stopPhrases: [...config.autoCapture.stopPhrases ?? []],
|
|
966
|
+
composeOpenPhrases: [...config.autoCapture.composeOpenPhrases ?? DEFAULT_COMPOSE_OPEN_PHRASES],
|
|
967
|
+
composeSendPhrases: [...config.autoCapture.composeSendPhrases ?? DEFAULT_COMPOSE_SEND_PHRASES],
|
|
968
|
+
composeCancelPhrases: [...config.autoCapture.composeCancelPhrases ?? DEFAULT_COMPOSE_CANCEL_PHRASES],
|
|
969
|
+
utteranceIdleMs: config.autoCapture.utteranceIdleMs ?? DEFAULT_UTTERANCE_IDLE_MS,
|
|
970
|
+
composeUtteranceIdleMs: config.autoCapture.composeUtteranceIdleMs ?? DEFAULT_COMPOSE_UTTERANCE_IDLE_MS,
|
|
971
|
+
composeNudgeMs: config.autoCapture.composeNudgeMs ?? DEFAULT_COMPOSE_NUDGE_MS,
|
|
972
|
+
transcriptionTimeoutMs: config.autoCapture.transcriptionTimeoutMs ?? DEFAULT_TRANSCRIPTION_TIMEOUT_MS,
|
|
973
|
+
tts: {
|
|
974
|
+
...config.autoCapture.tts,
|
|
975
|
+
...ttsOverride?.voice === void 0 ? {} : { voice: ttsOverride.voice },
|
|
976
|
+
...ttsOverride?.rate === void 0 ? {} : { rate: ttsOverride.rate }
|
|
977
|
+
}
|
|
978
|
+
} } : {}
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
/** Root keys the merge reads from one side only. */
|
|
982
|
+
const GLOBAL_ONLY_ROOTS = [
|
|
983
|
+
"computerUse",
|
|
984
|
+
"desktopEnvironment",
|
|
985
|
+
"profileMemory",
|
|
986
|
+
"editor",
|
|
987
|
+
"browse",
|
|
988
|
+
"ios"
|
|
989
|
+
];
|
|
990
|
+
const REPOSITORY_ONLY_ROOTS = ["projectTrust", "workspaces"];
|
|
991
|
+
/** Nested exceptions; a repository declaration of any of them throws in the merge. */
|
|
992
|
+
const GLOBAL_ONLY_PATHS = [
|
|
993
|
+
["voice", "mode"],
|
|
994
|
+
["voice", "autoCapture"],
|
|
995
|
+
["voice", "live"]
|
|
996
|
+
];
|
|
997
|
+
function startsWith(keyPath, prefix) {
|
|
998
|
+
return prefix.length <= keyPath.length && prefix.every((segment, index) => keyPath[index] === segment);
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* The scopes a key path accepts. An unknown root answers `both` rather than
|
|
1002
|
+
* throwing: the parser is what rejects unsupported keys, and it reports them
|
|
1003
|
+
* far better than a scope lookup could.
|
|
1004
|
+
*/
|
|
1005
|
+
function configScopeOf(keyPath) {
|
|
1006
|
+
if (keyPath.length === 0) return "both";
|
|
1007
|
+
if (GLOBAL_ONLY_PATHS.some((prefix) => startsWith(keyPath, prefix))) return "host";
|
|
1008
|
+
const root = keyPath[0];
|
|
1009
|
+
if (GLOBAL_ONLY_ROOTS.includes(root)) return "host";
|
|
1010
|
+
if (REPOSITORY_ONLY_ROOTS.includes(root)) return "repository";
|
|
1011
|
+
return "both";
|
|
1012
|
+
}
|
|
1013
|
+
function portableSubset(value, prefix) {
|
|
1014
|
+
const result = {};
|
|
1015
|
+
for (const [key, child] of Object.entries(value)) {
|
|
1016
|
+
const keyPath = [...prefix, key];
|
|
1017
|
+
if (isPlainRecord(child) && Object.keys(child).length > 0) {
|
|
1018
|
+
const nested = portableSubset(child, keyPath);
|
|
1019
|
+
if (Object.keys(nested).length > 0) result[key] = nested;
|
|
1020
|
+
} else if (isPortableConfigKey(keyPath)) result[key] = child;
|
|
1021
|
+
}
|
|
1022
|
+
return result;
|
|
1023
|
+
}
|
|
1024
|
+
function mergeRecords(base, override) {
|
|
1025
|
+
const result = { ...base };
|
|
1026
|
+
for (const [key, value] of Object.entries(override)) {
|
|
1027
|
+
const current = result[key];
|
|
1028
|
+
result[key] = isPlainRecord(current) && isPlainRecord(value) ? mergeRecords(current, value) : value;
|
|
1029
|
+
}
|
|
1030
|
+
return result;
|
|
1031
|
+
}
|
|
1032
|
+
/**
|
|
1033
|
+
* The host document with the global tier beneath it: only portable global keys come through and the
|
|
1034
|
+
* host wins every conflict. Both inputs are raw parsed YAML; parse the result like a host file.
|
|
1035
|
+
*/
|
|
1036
|
+
function mergeGlobalConfigLayer(globalDocument, hostDocument) {
|
|
1037
|
+
const host = isPlainRecord(hostDocument) ? hostDocument : {};
|
|
1038
|
+
if (!isPlainRecord(globalDocument)) return host;
|
|
1039
|
+
return mergeRecords(portableSubset(globalDocument, []), host);
|
|
1040
|
+
}
|
|
1041
|
+
const KEY_SEPARATOR = ".";
|
|
1042
|
+
function isPlainRecord(value) {
|
|
1043
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* Every key path a parsed document actually sets, as dotted strings.
|
|
1047
|
+
*
|
|
1048
|
+
* A settings surface needs to tell "this file set this key" from "this file is
|
|
1049
|
+
* silent about it", and the parsed `PoConfig` cannot answer: an absent file
|
|
1050
|
+
* reads as `{ projectTrust: 'ask' }` and `parsePoConfig` always returns all
|
|
1051
|
+
* known root keys, some undefined. So the question is asked of the raw document
|
|
1052
|
+
* instead, before any defaulting has happened.
|
|
1053
|
+
*
|
|
1054
|
+
* Leaves only. A list is a leaf because it is replaced whole, and an empty
|
|
1055
|
+
* record sets nothing.
|
|
1056
|
+
*/
|
|
1057
|
+
function configLeafKeys(value, prefix = []) {
|
|
1058
|
+
if (!isPlainRecord(value)) return prefix.length > 0 ? [prefix.join(KEY_SEPARATOR)] : [];
|
|
1059
|
+
const keys = Object.keys(value);
|
|
1060
|
+
if (keys.length === 0) return prefix.length > 0 ? [prefix.join(KEY_SEPARATOR)] : [];
|
|
1061
|
+
return keys.flatMap((key) => configLeafKeys(value[key], [...prefix, key]));
|
|
1062
|
+
}
|
|
1063
|
+
/** The value a key path points at, or undefined when any step is missing. */
|
|
1064
|
+
function valueAtKeyPath(value, keyPath) {
|
|
1065
|
+
let current = value;
|
|
1066
|
+
for (const segment of keyPath) {
|
|
1067
|
+
if (!isPlainRecord(current)) return void 0;
|
|
1068
|
+
current = current[segment];
|
|
1069
|
+
}
|
|
1070
|
+
return current;
|
|
1071
|
+
}
|
|
1072
|
+
//#endregion
|
|
1073
|
+
//#region ../../foundations/po-config/src/services/config/core.ts
|
|
1074
|
+
/**
|
|
1075
|
+
* Paths and pure parse/merge steps for the two Po config files. The readers
|
|
1076
|
+
* in `read.ts` (async, over a FileSystem) and `sync.ts` (Node-only shims) only
|
|
1077
|
+
* fetch file text and hand it here, so both produce identical results.
|
|
1078
|
+
*/
|
|
1079
|
+
const PO_DIR$1 = ".po";
|
|
1080
|
+
const CONFIG_FILE = "config.yaml";
|
|
1081
|
+
const PLANS_DIR = "plans";
|
|
1082
|
+
/** Runtime callers pass admitted environment; omission retains the legacy host lookup. */
|
|
1083
|
+
function globalPoConfigDirectory(homeDirectory = nodeHost.homeDirectory(), environment) {
|
|
1084
|
+
return poHomeDirectory(homeDirectory, environment);
|
|
1085
|
+
}
|
|
1086
|
+
function globalPoConfigPath(homeDirectory = nodeHost.homeDirectory(), environment) {
|
|
1087
|
+
return path.join(globalPoConfigDirectory(homeDirectory, environment), CONFIG_FILE);
|
|
1088
|
+
}
|
|
1089
|
+
/** The global settings of each person who granted them to this host, as the issuer last answered. Written by the host only. */
|
|
1090
|
+
function globalSettingsCachePath(homeDirectory, environment) {
|
|
1091
|
+
return path.join(globalPoConfigDirectory(homeDirectory, environment), "global-settings.yaml");
|
|
1092
|
+
}
|
|
1093
|
+
function globalSettingsOwnerPath(homeDirectory, environment) {
|
|
1094
|
+
return path.join(globalPoConfigDirectory(homeDirectory, environment), "web", "hub-trust.json");
|
|
1095
|
+
}
|
|
1096
|
+
/** The host's owner, who is the member of every session that names no starter. */
|
|
1097
|
+
function globalSettingsOwner(text) {
|
|
1098
|
+
try {
|
|
1099
|
+
const state = JSON.parse(text ?? "null");
|
|
1100
|
+
const owner = state?.owner;
|
|
1101
|
+
if (!owner || typeof owner.issuer !== "string" || !owner.issuer || typeof owner.subject !== "string" || !owner.subject || typeof state?.ownerNetworkId !== "string" || !state.ownerNetworkId || !state.issuers?.some((pin) => pin.issuer === owner.issuer)) return void 0;
|
|
1102
|
+
return {
|
|
1103
|
+
issuer: owner.issuer,
|
|
1104
|
+
subject: owner.subject,
|
|
1105
|
+
org: state.ownerNetworkId
|
|
1106
|
+
};
|
|
1107
|
+
} catch {
|
|
1108
|
+
return;
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
function parsedYaml(text) {
|
|
1112
|
+
try {
|
|
1113
|
+
return {
|
|
1114
|
+
ok: true,
|
|
1115
|
+
value: parse(text)
|
|
1116
|
+
};
|
|
1117
|
+
} catch {
|
|
1118
|
+
return { ok: false };
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
/** The session variable naming the person who started a session. The host sets it, from a verified caller only. */
|
|
1122
|
+
const SESSION_MEMBER_ENVIRONMENT = "PO_SESSION_MEMBER";
|
|
1123
|
+
function isGlobalSettingsBinding(value) {
|
|
1124
|
+
const binding = value;
|
|
1125
|
+
return typeof binding === "object" && binding !== null && typeof binding.issuer === "string" && !!binding.issuer && typeof binding.org === "string" && !!binding.org && typeof binding.subject === "string" && !!binding.subject;
|
|
1126
|
+
}
|
|
1127
|
+
function sameGlobalSettingsBinding(left, right) {
|
|
1128
|
+
return left.issuer === right.issuer && left.org === right.org && left.subject === right.subject;
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Whose global settings a read applies: the session's starter when the environment names one, else the
|
|
1132
|
+
* host's owner. A starter that cannot be read applies nobody's, never the owner's.
|
|
1133
|
+
*/
|
|
1134
|
+
function globalSettingsMember(environment, ownerText) {
|
|
1135
|
+
const starter = environment?.[SESSION_MEMBER_ENVIRONMENT];
|
|
1136
|
+
if (starter === void 0) return globalSettingsOwner(ownerText);
|
|
1137
|
+
const parsed = parsedYaml(starter);
|
|
1138
|
+
if (!parsed.ok || !isGlobalSettingsBinding(parsed.value)) return void 0;
|
|
1139
|
+
const { issuer, org, subject } = parsed.value;
|
|
1140
|
+
return {
|
|
1141
|
+
issuer,
|
|
1142
|
+
org,
|
|
1143
|
+
subject
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
/** The well-formed records of a cache file. An unreadable file holds none. */
|
|
1147
|
+
function globalSettingsRecords(cacheText) {
|
|
1148
|
+
const cached = parsedYaml(cacheText ?? "");
|
|
1149
|
+
if (!cached.ok || !cached.value || typeof cached.value !== "object") return [];
|
|
1150
|
+
const { members } = cached.value;
|
|
1151
|
+
return (Array.isArray(members) ? members : [cached.value]).filter((record) => !!record && isGlobalSettingsBinding(record.binding) && typeof record.yaml === "string");
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* The host file's text with one person's cached global layer beneath it. A missing or unreadable cache, or a
|
|
1155
|
+
* host file that does not parse, leaves the host text untouched so its own errors still surface.
|
|
1156
|
+
*/
|
|
1157
|
+
function withGlobalLayer(cacheText, hostText, binding) {
|
|
1158
|
+
if (cacheText === void 0 || !binding) return hostText;
|
|
1159
|
+
const host = parsedYaml(hostText ?? "");
|
|
1160
|
+
const record = globalSettingsRecords(cacheText).find((entry) => sameGlobalSettingsBinding(entry.binding, binding));
|
|
1161
|
+
if (!host.ok || !record) return hostText;
|
|
1162
|
+
const settings = parsedYaml(record.yaml);
|
|
1163
|
+
if (!settings.ok) return hostText;
|
|
1164
|
+
return JSON.stringify(mergeGlobalConfigLayer(settings.value, host.value));
|
|
1165
|
+
}
|
|
1166
|
+
function resolvePlanningPlansDirectory(configured, repoRoot, homeDirectory = nodeHost.homeDirectory()) {
|
|
1167
|
+
if (!configured) return path.join(globalPoConfigDirectory(homeDirectory), PLANS_DIR);
|
|
1168
|
+
if (configured === "~") return homeDirectory;
|
|
1169
|
+
if (configured.startsWith("~/")) return path.resolve(homeDirectory, configured.slice(2));
|
|
1170
|
+
if (configured.startsWith("~")) throw new Error("Po planning plansDirectory supports only '~' or '~/' home aliases");
|
|
1171
|
+
return path.isAbsolute(configured) ? path.normalize(configured) : path.resolve(repoRoot, configured);
|
|
1172
|
+
}
|
|
1173
|
+
function repositoryPoConfigPath(repoRoot) {
|
|
1174
|
+
return path.join(repoRoot, PO_DIR$1, CONFIG_FILE);
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* True when a repository's `.po` folder is Po's home itself, as it is for a
|
|
1178
|
+
* session rooted at home. That folder is already the global layer; reading it
|
|
1179
|
+
* again as the repository layer would apply global-only keys at repository scope.
|
|
1180
|
+
*/
|
|
1181
|
+
function isGlobalPoConfigRoot(repoRoot, homeDirectory = nodeHost.homeDirectory(), environment) {
|
|
1182
|
+
return path.resolve(repoRoot, PO_DIR$1) === path.resolve(globalPoConfigDirectory(homeDirectory, environment));
|
|
1183
|
+
}
|
|
1184
|
+
function repositoryConfigFor(repoRoot, homeDirectory, environment) {
|
|
1185
|
+
return isGlobalPoConfigRoot(repoRoot, homeDirectory, environment) ? void 0 : repositoryPoConfigPath(repoRoot);
|
|
1186
|
+
}
|
|
1187
|
+
/** The config a missing file stands for. */
|
|
1188
|
+
function defaultPoConfig() {
|
|
1189
|
+
return { projectTrust: "ask" };
|
|
1190
|
+
}
|
|
1191
|
+
/** Parses one file's text strictly; `undefined` text means the file is absent. */
|
|
1192
|
+
function configFromText(text, filePath) {
|
|
1193
|
+
return text === void 0 ? defaultPoConfig() : parsePoConfig(text, filePath);
|
|
1194
|
+
}
|
|
1195
|
+
/** Process-local distribution defaults never grant native authority or modify user files. */
|
|
1196
|
+
function distributionDefaults(config, environment) {
|
|
1197
|
+
if (environment.PO_DISTRIBUTION !== "desktop") return config;
|
|
1198
|
+
return {
|
|
1199
|
+
...config,
|
|
1200
|
+
computerUse: {
|
|
1201
|
+
...config.computerUse,
|
|
1202
|
+
enabled: config.computerUse?.enabled ?? true
|
|
1203
|
+
}
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
/** Merges the global and repository files, then applies distribution defaults. */
|
|
1207
|
+
function mergeConfigLayers(globalConfig, repositoryConfig, environment) {
|
|
1208
|
+
return distributionDefaults(mergePoConfigs(globalConfig, repositoryConfig), environment);
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* One config file as a layer: what it is, what it sets, and the bytes it held.
|
|
1212
|
+
* A file that does not exist is a layer that sets nothing, which is a normal
|
|
1213
|
+
* state rather than an error.
|
|
1214
|
+
*/
|
|
1215
|
+
function layerFromText(filePath, text) {
|
|
1216
|
+
if (text === void 0) return {
|
|
1217
|
+
filePath,
|
|
1218
|
+
exists: false,
|
|
1219
|
+
hash: "",
|
|
1220
|
+
keys: []
|
|
1221
|
+
};
|
|
1222
|
+
const document = parse(text) ?? {};
|
|
1223
|
+
return {
|
|
1224
|
+
filePath,
|
|
1225
|
+
exists: true,
|
|
1226
|
+
hash: createHash("sha256").update(text, "utf8").digest("hex"),
|
|
1227
|
+
keys: configLeafKeys(document)
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
function absentRepositoryLayer() {
|
|
1231
|
+
return {
|
|
1232
|
+
filePath: "",
|
|
1233
|
+
exists: false,
|
|
1234
|
+
hash: "",
|
|
1235
|
+
keys: []
|
|
1236
|
+
};
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* The two config files kept apart, with the merge alongside them.
|
|
1240
|
+
*
|
|
1241
|
+
* The origin answer respects the merge's own per-field rules rather than simply
|
|
1242
|
+
* preferring the repository: `editor` is read from the global side whatever the
|
|
1243
|
+
* repository says, and `projectTrust` from the repository side whatever the
|
|
1244
|
+
* global one says. Reporting a file as the source of a value the merge discards
|
|
1245
|
+
* is the exact confusion this exists to remove.
|
|
1246
|
+
*/
|
|
1247
|
+
function composeConfigLayers(globalLayer, repositoryLayer, effective) {
|
|
1248
|
+
const sets = (layer, keyPath) => {
|
|
1249
|
+
const dotted = keyPath.join(".");
|
|
1250
|
+
return layer.keys.some((key) => key === dotted || key.startsWith(`${dotted}.`));
|
|
1251
|
+
};
|
|
1252
|
+
return {
|
|
1253
|
+
globalFile: globalLayer,
|
|
1254
|
+
repositoryFile: repositoryLayer,
|
|
1255
|
+
effective,
|
|
1256
|
+
originOf(keyPath) {
|
|
1257
|
+
const scope = configScopeOf(keyPath);
|
|
1258
|
+
if (scope !== "host" && sets(repositoryLayer, keyPath)) return "repository";
|
|
1259
|
+
if (scope !== "repository" && sets(globalLayer, keyPath)) return "host";
|
|
1260
|
+
return "default";
|
|
1261
|
+
},
|
|
1262
|
+
valueAt: (keyPath) => valueAtKeyPath(effective, keyPath)
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* The global and repository locations of one named `.po` document, lowest
|
|
1267
|
+
* precedence first.
|
|
1268
|
+
*/
|
|
1269
|
+
function poConfigCandidates(fileName, repoRoot, homeDirectory) {
|
|
1270
|
+
const globalDirectory = globalPoConfigDirectory(homeDirectory);
|
|
1271
|
+
const globalCandidate = {
|
|
1272
|
+
filePath: path.join(globalDirectory, fileName),
|
|
1273
|
+
baseDirectory: globalDirectory
|
|
1274
|
+
};
|
|
1275
|
+
if (isGlobalPoConfigRoot(repoRoot, homeDirectory)) return [globalCandidate];
|
|
1276
|
+
return [globalCandidate, {
|
|
1277
|
+
filePath: path.join(repoRoot, ".po", fileName),
|
|
1278
|
+
baseDirectory: repoRoot
|
|
1279
|
+
}];
|
|
1280
|
+
}
|
|
1281
|
+
/** Retired file names, keyed by the file that replaced them in the same directory. */
|
|
1282
|
+
const RETIRED_CONFIG_SIBLING = { "presets.yaml": "modes.yaml" };
|
|
1283
|
+
/** The retired file that would sit beside `filePath`, for a name that replaced one. */
|
|
1284
|
+
function retiredConfigSibling(filePath) {
|
|
1285
|
+
const retired = RETIRED_CONFIG_SIBLING[path.basename(filePath)];
|
|
1286
|
+
return retired === void 0 ? void 0 : path.join(path.dirname(filePath), retired);
|
|
1287
|
+
}
|
|
1288
|
+
/** The error for a retired file found beside its replacement's location. */
|
|
1289
|
+
function retiredConfigError(retiredPath) {
|
|
1290
|
+
return /* @__PURE__ */ new Error(`${retiredPath} was renamed to presets.yaml. Rename the file and its keys (majorMode to preset, defaultMajorMode to defaultPreset). If Po already created a presets.yaml next to it, replace that file.`);
|
|
1291
|
+
}
|
|
1292
|
+
/**
|
|
1293
|
+
* Parses one candidate's text into a source, or undefined when the file is
|
|
1294
|
+
* absent (`undefined` text) or empty. An empty file parses to null and is
|
|
1295
|
+
* treated as an absent one, so a seeded placeholder never has to be deleted to
|
|
1296
|
+
* get out of the way.
|
|
1297
|
+
*/
|
|
1298
|
+
function sourceFromText(candidate, text) {
|
|
1299
|
+
if (text === void 0) return void 0;
|
|
1300
|
+
const document = parse(text);
|
|
1301
|
+
if (document === null || document === void 0) return void 0;
|
|
1302
|
+
return {
|
|
1303
|
+
...candidate,
|
|
1304
|
+
text,
|
|
1305
|
+
document
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
//#endregion
|
|
1309
|
+
//#region ../../foundations/po-config/src/services/layeredConfig/index.ts
|
|
1310
|
+
/**
|
|
1311
|
+
* Reads one named `.po` document from the global and repository config
|
|
1312
|
+
* directories over a FileSystem, lowest precedence first.
|
|
1313
|
+
*
|
|
1314
|
+
* A missing or empty file contributes nothing, so either location on its own is
|
|
1315
|
+
* a complete configuration, and a host with neither (a fresh edge filesystem)
|
|
1316
|
+
* reads no sources, as an empty Node home does. Documents are deliberately
|
|
1317
|
+
* returned unmerged: merging is by name, and only the caller knows what a name
|
|
1318
|
+
* means in its own document, so each one folds the sources itself with the
|
|
1319
|
+
* repository last.
|
|
1320
|
+
*/
|
|
1321
|
+
async function readPoConfigSourcesAsync(fs, fileName, repoRoot, context, homeDirectory) {
|
|
1322
|
+
const sources = [];
|
|
1323
|
+
for (const candidate of poConfigCandidates(fileName, repoRoot, homeDirectory)) {
|
|
1324
|
+
const retired = retiredConfigSibling(candidate.filePath);
|
|
1325
|
+
if (retired !== void 0 && await readTextIfExists(fs, retired, context) !== void 0) throw retiredConfigError(retired);
|
|
1326
|
+
const source = sourceFromText(candidate, await readTextIfExists(fs, candidate.filePath, context));
|
|
1327
|
+
if (source) sources.push(source);
|
|
1328
|
+
}
|
|
1329
|
+
return sources;
|
|
1330
|
+
}
|
|
1331
|
+
//#endregion
|
|
1332
|
+
//#region ../../foundations/po-config/src/services/config/index.ts
|
|
1333
|
+
function resolved(options) {
|
|
1334
|
+
return {
|
|
1335
|
+
homeDirectory: options.homeDirectory ?? nodeHost.homeDirectory(),
|
|
1336
|
+
environment: options.environment ?? process.env
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
const readText = (fs, filePath, context) => filePath === void 0 ? Promise.resolve(void 0) : readTextIfExists(fs, filePath, context);
|
|
1340
|
+
/**
|
|
1341
|
+
* Loads the merged global and repository config over a FileSystem. A missing
|
|
1342
|
+
* file contributes the defaults, so a host with neither file, such as a fresh
|
|
1343
|
+
* Durable Object filesystem, reads the same config as an empty Node home.
|
|
1344
|
+
* One person's cached global settings sit beneath the host file, portable keys only: the session starter's
|
|
1345
|
+
* when the environment names one, else the host owner's.
|
|
1346
|
+
*/
|
|
1347
|
+
async function readPoConfig(fs, repoRoot, context, options = {}) {
|
|
1348
|
+
const { homeDirectory, environment } = resolved(options);
|
|
1349
|
+
const globalPath = globalPoConfigPath(homeDirectory, environment);
|
|
1350
|
+
const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);
|
|
1351
|
+
const hostText = await readText(fs, globalPath, context);
|
|
1352
|
+
return mergeConfigLayers(configFromText(withGlobalLayer(await readText(fs, globalSettingsCachePath(homeDirectory, environment), context), hostText, globalSettingsMember(environment, await readText(fs, globalSettingsOwnerPath(homeDirectory, environment), context))), globalPath), repositoryPath === void 0 ? defaultPoConfig() : configFromText(await readText(fs, repositoryPath, context), repositoryPath), environment);
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* The two config files kept apart, with the merge alongside them.
|
|
1356
|
+
*
|
|
1357
|
+
* `repoRoot` is optional because the global file is complete on its own: a
|
|
1358
|
+
* settings surface with no repository in view still has settings to show.
|
|
1359
|
+
*/
|
|
1360
|
+
async function readPoConfigLayers(fs, repoRoot, context, options = {}) {
|
|
1361
|
+
const { homeDirectory, environment } = resolved(options);
|
|
1362
|
+
const globalPath = globalPoConfigPath(homeDirectory, environment);
|
|
1363
|
+
const repositoryPath = repoRoot === void 0 ? void 0 : repositoryConfigFor(repoRoot, homeDirectory, environment);
|
|
1364
|
+
const globalText = await readText(fs, globalPath, context);
|
|
1365
|
+
const repositoryText = await readText(fs, repositoryPath, context);
|
|
1366
|
+
const globalLayer = layerFromText(globalPath, globalText);
|
|
1367
|
+
const repositoryLayer = repositoryPath === void 0 ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText);
|
|
1368
|
+
const repositoryConfig = repositoryPath === void 0 ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);
|
|
1369
|
+
return composeConfigLayers(globalLayer, repositoryLayer, mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment));
|
|
1370
|
+
}
|
|
1371
|
+
//#endregion
|
|
1372
|
+
export { retiredConfigError as a, globalPoConfigPath as c, PO_PLANNING_THINKING_LEVELS as d, configScopeOf as f, poConfigCandidates as i, repositoryPoConfigPath as l, resolveVoiceConfig as m, readPoConfigLayers as n, retiredConfigSibling as o, parsePoConfig as p, readPoConfigSourcesAsync as r, globalPoConfigDirectory as s, readPoConfig as t, resolvePlanningPlansDirectory as u };
|