@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,1240 @@
|
|
|
1
|
+
import { n as __exportAll } from "./rolldown-runtime-DbVrKiKs.js";
|
|
2
|
+
import { _t as BACKGROUND_CONTEXT, h as getOrThrow, sn as defineServiceContract } from "./serverPlugin-4nI5J6Zt.js";
|
|
3
|
+
import "./platform-CQahdzpG.js";
|
|
4
|
+
import { $ as _length, At as isPlainObject, Ct as _trim, Dt as prettifyError, F as string, G as _endsWith, J as _includes, K as _gt, L as unknown, M as record, N as schemas_exports, P as strictObject, St as _toUpperCase, Tt as globalRegistry, _t as _regex, at as _mime, bt as _startsWith, ct as _multipleOf, dt as _nonpositive, et as _lowercase, ft as _normalize, gt as _property, h as boolean, ht as _properties, it as _maxSize, k as object, kt as assignProp, lt as _negative, m as array, mt as _positive, nt as _lte, ot as _minLength, pt as _overwrite, q as _gte, rt as _maxLength, st as _minSize, tt as _lt, u as _enum, ut as _nonnegative, vt as _size, wt as _uppercase, xt as _toLowerCase, yt as _slugify } from "./schemas-D2dRon18.js";
|
|
5
|
+
import { r as iso_exports } from "./iso-BGFmgtky.js";
|
|
6
|
+
import { n as parseDocument, t as parse } from "./browser-DwY5dXHX.js";
|
|
7
|
+
import { t as Liquid } from "./liquid.browser-1BcykmIN.js";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
//#region ../../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/checks.js
|
|
10
|
+
var checks_exports = /* @__PURE__ */ __exportAll({
|
|
11
|
+
endsWith: () => _endsWith,
|
|
12
|
+
gt: () => _gt,
|
|
13
|
+
gte: () => _gte,
|
|
14
|
+
includes: () => _includes,
|
|
15
|
+
length: () => _length,
|
|
16
|
+
lowercase: () => _lowercase,
|
|
17
|
+
lt: () => _lt,
|
|
18
|
+
lte: () => _lte,
|
|
19
|
+
maxLength: () => _maxLength,
|
|
20
|
+
maxSize: () => _maxSize,
|
|
21
|
+
mime: () => _mime,
|
|
22
|
+
minLength: () => _minLength,
|
|
23
|
+
minSize: () => _minSize,
|
|
24
|
+
multipleOf: () => _multipleOf,
|
|
25
|
+
negative: () => _negative,
|
|
26
|
+
nonnegative: () => _nonnegative,
|
|
27
|
+
nonpositive: () => _nonpositive,
|
|
28
|
+
normalize: () => _normalize,
|
|
29
|
+
overwrite: () => _overwrite,
|
|
30
|
+
positive: () => _positive,
|
|
31
|
+
properties: () => _properties,
|
|
32
|
+
property: () => _property,
|
|
33
|
+
regex: () => _regex,
|
|
34
|
+
size: () => _size,
|
|
35
|
+
slugify: () => _slugify,
|
|
36
|
+
startsWith: () => _startsWith,
|
|
37
|
+
toLowerCase: () => _toLowerCase,
|
|
38
|
+
toUpperCase: () => _toUpperCase,
|
|
39
|
+
trim: () => _trim,
|
|
40
|
+
uppercase: () => _uppercase
|
|
41
|
+
});
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region ../../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/from-json-schema.js
|
|
44
|
+
const z = {
|
|
45
|
+
...schemas_exports,
|
|
46
|
+
...checks_exports,
|
|
47
|
+
iso: iso_exports
|
|
48
|
+
};
|
|
49
|
+
const RECOGNIZED_KEYS = /*@__PURE__*/ new Set([
|
|
50
|
+
"$schema",
|
|
51
|
+
"$ref",
|
|
52
|
+
"$defs",
|
|
53
|
+
"definitions",
|
|
54
|
+
"$id",
|
|
55
|
+
"id",
|
|
56
|
+
"$comment",
|
|
57
|
+
"$anchor",
|
|
58
|
+
"$vocabulary",
|
|
59
|
+
"$dynamicRef",
|
|
60
|
+
"$dynamicAnchor",
|
|
61
|
+
"type",
|
|
62
|
+
"enum",
|
|
63
|
+
"const",
|
|
64
|
+
"anyOf",
|
|
65
|
+
"oneOf",
|
|
66
|
+
"allOf",
|
|
67
|
+
"not",
|
|
68
|
+
"properties",
|
|
69
|
+
"required",
|
|
70
|
+
"additionalProperties",
|
|
71
|
+
"patternProperties",
|
|
72
|
+
"propertyNames",
|
|
73
|
+
"minProperties",
|
|
74
|
+
"maxProperties",
|
|
75
|
+
"items",
|
|
76
|
+
"prefixItems",
|
|
77
|
+
"additionalItems",
|
|
78
|
+
"minItems",
|
|
79
|
+
"maxItems",
|
|
80
|
+
"uniqueItems",
|
|
81
|
+
"contains",
|
|
82
|
+
"minContains",
|
|
83
|
+
"maxContains",
|
|
84
|
+
"minLength",
|
|
85
|
+
"maxLength",
|
|
86
|
+
"pattern",
|
|
87
|
+
"format",
|
|
88
|
+
"minimum",
|
|
89
|
+
"maximum",
|
|
90
|
+
"exclusiveMinimum",
|
|
91
|
+
"exclusiveMaximum",
|
|
92
|
+
"multipleOf",
|
|
93
|
+
"description",
|
|
94
|
+
"default",
|
|
95
|
+
"contentEncoding",
|
|
96
|
+
"contentMediaType",
|
|
97
|
+
"contentSchema",
|
|
98
|
+
"unevaluatedItems",
|
|
99
|
+
"unevaluatedProperties",
|
|
100
|
+
"if",
|
|
101
|
+
"then",
|
|
102
|
+
"else",
|
|
103
|
+
"dependentSchemas",
|
|
104
|
+
"dependentRequired",
|
|
105
|
+
"nullable",
|
|
106
|
+
"readOnly"
|
|
107
|
+
]);
|
|
108
|
+
function detectVersion(schema, defaultTarget) {
|
|
109
|
+
const $schema = schema.$schema;
|
|
110
|
+
if ($schema === "https://json-schema.org/draft/2020-12/schema") return "draft-2020-12";
|
|
111
|
+
if ($schema === "http://json-schema.org/draft-07/schema#") return "draft-7";
|
|
112
|
+
if ($schema === "http://json-schema.org/draft-04/schema#") return "draft-4";
|
|
113
|
+
return defaultTarget ?? "draft-2020-12";
|
|
114
|
+
}
|
|
115
|
+
function applyMinItems(items, minItems) {
|
|
116
|
+
return items.map((item, index) => index < minItems ? item : item.optional());
|
|
117
|
+
}
|
|
118
|
+
function decodeJSONPointerSegment(segment) {
|
|
119
|
+
return segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
120
|
+
}
|
|
121
|
+
function resolveRef(ref, ctx) {
|
|
122
|
+
if (!ref.startsWith("#")) throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
123
|
+
const path = ref.slice(1).split("/").filter(Boolean);
|
|
124
|
+
if (path.length === 0) return ctx.rootSchema;
|
|
125
|
+
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
126
|
+
if (path[0] === defsKey) {
|
|
127
|
+
const key = path[1] === void 0 ? void 0 : decodeJSONPointerSegment(path[1]);
|
|
128
|
+
if (!key || !ctx.defs[key]) throw new Error(`Reference not found: ${ref}`);
|
|
129
|
+
return ctx.defs[key];
|
|
130
|
+
}
|
|
131
|
+
throw new Error(`Reference not found: ${ref}`);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Enforces the keywords that constrain an object's own keys — `propertyNames`,
|
|
135
|
+
* `minProperties`, `maxProperties` — before `objectSchema` runs. The guard has
|
|
136
|
+
* to see the raw input: an object parse drops `__proto__` and can add keys from
|
|
137
|
+
* a property `default`, so its output is not the set of names the instance
|
|
138
|
+
* actually carried.
|
|
139
|
+
*/
|
|
140
|
+
function checkObjectGuards(objectSchema, guards) {
|
|
141
|
+
return z.transform((value) => value).check((payload) => {
|
|
142
|
+
const value = payload.value;
|
|
143
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return;
|
|
144
|
+
const keys = Object.getOwnPropertyNames(value);
|
|
145
|
+
if (guards.minProperties !== void 0 && keys.length < guards.minProperties) payload.issues.push({
|
|
146
|
+
origin: "object",
|
|
147
|
+
code: "too_small",
|
|
148
|
+
minimum: guards.minProperties,
|
|
149
|
+
inclusive: true,
|
|
150
|
+
message: `Too small: expected object to have >=${guards.minProperties} properties`,
|
|
151
|
+
input: value,
|
|
152
|
+
inst: objectSchema,
|
|
153
|
+
continue: true
|
|
154
|
+
});
|
|
155
|
+
if (guards.maxProperties !== void 0 && keys.length > guards.maxProperties) payload.issues.push({
|
|
156
|
+
origin: "object",
|
|
157
|
+
code: "too_big",
|
|
158
|
+
maximum: guards.maxProperties,
|
|
159
|
+
inclusive: true,
|
|
160
|
+
message: `Too big: expected object to have <=${guards.maxProperties} properties`,
|
|
161
|
+
input: value,
|
|
162
|
+
inst: objectSchema,
|
|
163
|
+
continue: true
|
|
164
|
+
});
|
|
165
|
+
if (guards.keySchema) for (const key of keys) {
|
|
166
|
+
const result = guards.keySchema.safeParse(key);
|
|
167
|
+
if (result.success) continue;
|
|
168
|
+
payload.issues.push({
|
|
169
|
+
code: "invalid_key",
|
|
170
|
+
origin: "record",
|
|
171
|
+
issues: result.error.issues,
|
|
172
|
+
input: key,
|
|
173
|
+
path: [key],
|
|
174
|
+
continue: true
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}).pipe(objectSchema);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* An injective string for JSON data: two values share a key exactly when `uniqueItems` calls them
|
|
181
|
+
* equal, so duplicate detection is a Map lookup rather than a pairwise walk. Strings and keys are
|
|
182
|
+
* length-prefixed so no value can spell another one. `null` means "never equal to anything" — a
|
|
183
|
+
* cycle or a NaN, neither of which JSON can express.
|
|
184
|
+
*/
|
|
185
|
+
function canonicalKey(value, seen) {
|
|
186
|
+
if (value === null) return "z";
|
|
187
|
+
const type = typeof value;
|
|
188
|
+
if (type !== "object") {
|
|
189
|
+
if (type === "number" && Number.isNaN(value)) return null;
|
|
190
|
+
const raw = String(value);
|
|
191
|
+
return `${type[0]}${raw.length}:${raw}`;
|
|
192
|
+
}
|
|
193
|
+
if (seen.has(value)) return null;
|
|
194
|
+
seen.add(value);
|
|
195
|
+
try {
|
|
196
|
+
if (Array.isArray(value)) {
|
|
197
|
+
const parts = [];
|
|
198
|
+
for (const item of value) {
|
|
199
|
+
const key = canonicalKey(item, seen);
|
|
200
|
+
if (key === null) return null;
|
|
201
|
+
parts.push(key);
|
|
202
|
+
}
|
|
203
|
+
return `a${parts.length}:[${parts.join(",")}]`;
|
|
204
|
+
}
|
|
205
|
+
const keys = Object.keys(value).sort();
|
|
206
|
+
const parts = [];
|
|
207
|
+
for (const k of keys) {
|
|
208
|
+
const key = canonicalKey(value[k], seen);
|
|
209
|
+
if (key === null) return null;
|
|
210
|
+
parts.push(`${k.length}:${k}=${key}`);
|
|
211
|
+
}
|
|
212
|
+
return `o${parts.length}:{${parts.join(",")}}`;
|
|
213
|
+
} finally {
|
|
214
|
+
seen.delete(value);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const SCHEMA_KEYWORDS = /*@__PURE__*/ new Set([
|
|
218
|
+
"items",
|
|
219
|
+
"prefixItems",
|
|
220
|
+
"additionalItems",
|
|
221
|
+
"additionalProperties",
|
|
222
|
+
"contains",
|
|
223
|
+
"propertyNames",
|
|
224
|
+
"not",
|
|
225
|
+
"if",
|
|
226
|
+
"then",
|
|
227
|
+
"else",
|
|
228
|
+
"allOf",
|
|
229
|
+
"anyOf",
|
|
230
|
+
"oneOf",
|
|
231
|
+
"unevaluatedItems",
|
|
232
|
+
"unevaluatedProperties",
|
|
233
|
+
"contentSchema"
|
|
234
|
+
]);
|
|
235
|
+
const SCHEMA_MAP_KEYWORDS = /*@__PURE__*/ new Set([
|
|
236
|
+
"properties",
|
|
237
|
+
"patternProperties",
|
|
238
|
+
"dependentSchemas",
|
|
239
|
+
"dependencies",
|
|
240
|
+
"$defs",
|
|
241
|
+
"definitions"
|
|
242
|
+
]);
|
|
243
|
+
/**
|
|
244
|
+
* True when a subschema holds a `$ref` anywhere a schema can appear. Only those positions are
|
|
245
|
+
* walked: `$ref` under `default` or an `x-` annotation is instance data with an ordinary key, and
|
|
246
|
+
* reading it as a reference would drop a constraint that resolves perfectly well.
|
|
247
|
+
*/
|
|
248
|
+
function containsRef(value) {
|
|
249
|
+
if (typeof value !== "object" || value === null) return false;
|
|
250
|
+
if (Array.isArray(value)) return value.some(containsRef);
|
|
251
|
+
if (typeof value.$ref === "string") return true;
|
|
252
|
+
return Object.entries(value).some(([key, sub]) => {
|
|
253
|
+
if (SCHEMA_KEYWORDS.has(key)) return containsRef(sub);
|
|
254
|
+
if (!SCHEMA_MAP_KEYWORDS.has(key) || typeof sub !== "object" || sub === null) return false;
|
|
255
|
+
return Object.values(sub).some(containsRef);
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
function plural(n) {
|
|
259
|
+
return n === 1 ? "element" : "elements";
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Enforces `uniqueItems` and the `contains` family before `arraySchema` runs, for the same reason
|
|
263
|
+
* `checkObjectGuards` runs pre-pipe: an item parse can apply a nested `default`, so the parsed
|
|
264
|
+
* array is not the instance the keywords are defined over. A guard issue aborts the pipe, so
|
|
265
|
+
* `minItems`/`maxItems` are not also reported on the same parse — instance correctness is worth
|
|
266
|
+
* more than co-reporting two issues.
|
|
267
|
+
*/
|
|
268
|
+
function checkArrayGuards(arraySchema, guards) {
|
|
269
|
+
return z.transform((value) => value).check((payload) => {
|
|
270
|
+
const items = payload.value;
|
|
271
|
+
if (!Array.isArray(items)) return;
|
|
272
|
+
if (guards.uniqueItems === true) {
|
|
273
|
+
const firstSeen = /* @__PURE__ */ new Map();
|
|
274
|
+
for (let i = 0; i < items.length; i++) {
|
|
275
|
+
const key = canonicalKey(items[i], /* @__PURE__ */ new Set());
|
|
276
|
+
if (key === null) continue;
|
|
277
|
+
const first = firstSeen.get(key);
|
|
278
|
+
if (first === void 0) {
|
|
279
|
+
firstSeen.set(key, i);
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
payload.issues.push({
|
|
283
|
+
code: "custom",
|
|
284
|
+
message: `Array items must be unique: element at index ${i} duplicates the one at index ${first}`,
|
|
285
|
+
input: items,
|
|
286
|
+
path: [i],
|
|
287
|
+
continue: true
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (guards.containsSchema) {
|
|
292
|
+
const minContains = guards.minContains ?? 1;
|
|
293
|
+
const ceiling = guards.maxContains !== void 0 ? guards.maxContains + 1 : Number.POSITIVE_INFINITY;
|
|
294
|
+
let matches = 0;
|
|
295
|
+
for (const item of items) if (guards.containsSchema.safeParse(item).success && ++matches >= ceiling) break;
|
|
296
|
+
if (matches < minContains) payload.issues.push({
|
|
297
|
+
code: "custom",
|
|
298
|
+
message: `Array must contain at least ${minContains} matching ${plural(minContains)}; found ${matches}`,
|
|
299
|
+
input: items,
|
|
300
|
+
continue: true
|
|
301
|
+
});
|
|
302
|
+
if (guards.maxContains !== void 0 && matches > guards.maxContains) payload.issues.push({
|
|
303
|
+
code: "custom",
|
|
304
|
+
message: `Array must contain at most ${guards.maxContains} matching ${plural(guards.maxContains)}`,
|
|
305
|
+
input: items,
|
|
306
|
+
continue: true
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}).pipe(arraySchema);
|
|
310
|
+
}
|
|
311
|
+
function getTupleRest(restSchema, ctx) {
|
|
312
|
+
if (restSchema === false) return;
|
|
313
|
+
if (restSchema === void 0 || restSchema === true) return z.any();
|
|
314
|
+
return convertSchema(restSchema, ctx);
|
|
315
|
+
}
|
|
316
|
+
const fullTime = /^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;
|
|
317
|
+
function convertBaseSchema(schema, ctx) {
|
|
318
|
+
if (schema.not !== void 0) {
|
|
319
|
+
if (typeof schema.not === "object" && Object.keys(schema.not).length === 0) return z.never();
|
|
320
|
+
throw new Error("not is not supported in Zod (except { not: {} } for never)");
|
|
321
|
+
}
|
|
322
|
+
if (schema.unevaluatedItems !== void 0) throw new Error("unevaluatedItems is not supported");
|
|
323
|
+
if (schema.unevaluatedProperties !== void 0) throw new Error("unevaluatedProperties is not supported");
|
|
324
|
+
if (schema.if !== void 0 || schema.then !== void 0 || schema.else !== void 0) throw new Error("Conditional schemas (if/then/else) are not supported");
|
|
325
|
+
if (schema.dependentSchemas !== void 0 || schema.dependentRequired !== void 0) throw new Error("dependentSchemas and dependentRequired are not supported");
|
|
326
|
+
if (schema.$ref) {
|
|
327
|
+
const refPath = schema.$ref;
|
|
328
|
+
if (ctx.refs.has(refPath)) return ctx.refs.get(refPath);
|
|
329
|
+
if (ctx.processing.has(refPath)) return z.lazy(() => {
|
|
330
|
+
if (!ctx.refs.has(refPath)) throw new Error(`Circular reference not resolved: ${refPath}`);
|
|
331
|
+
return ctx.refs.get(refPath);
|
|
332
|
+
});
|
|
333
|
+
ctx.processing.add(refPath);
|
|
334
|
+
const zodSchema = convertSchema(resolveRef(refPath, ctx), ctx);
|
|
335
|
+
ctx.refs.set(refPath, zodSchema);
|
|
336
|
+
ctx.processing.delete(refPath);
|
|
337
|
+
return zodSchema;
|
|
338
|
+
}
|
|
339
|
+
if (schema.enum !== void 0) {
|
|
340
|
+
const enumValues = schema.enum;
|
|
341
|
+
if (ctx.version === "openapi-3.0" && schema.nullable === true && enumValues.length === 1 && enumValues[0] === null) return z.null();
|
|
342
|
+
if (enumValues.length === 0) return z.never();
|
|
343
|
+
if (enumValues.length === 1) return z.literal(enumValues[0]);
|
|
344
|
+
if (enumValues.every((v) => typeof v === "string")) return z.enum(enumValues);
|
|
345
|
+
const literalSchemas = enumValues.map((v) => z.literal(v));
|
|
346
|
+
if (literalSchemas.length < 2) return literalSchemas[0];
|
|
347
|
+
return z.union([
|
|
348
|
+
literalSchemas[0],
|
|
349
|
+
literalSchemas[1],
|
|
350
|
+
...literalSchemas.slice(2)
|
|
351
|
+
]);
|
|
352
|
+
}
|
|
353
|
+
if (schema.const !== void 0) return z.literal(schema.const);
|
|
354
|
+
const type = schema.type;
|
|
355
|
+
if (Array.isArray(type)) {
|
|
356
|
+
const typeSchemas = type.map((t) => {
|
|
357
|
+
return convertBaseSchema({
|
|
358
|
+
...schema,
|
|
359
|
+
type: t
|
|
360
|
+
}, ctx);
|
|
361
|
+
});
|
|
362
|
+
if (typeSchemas.length === 0) return z.never();
|
|
363
|
+
if (typeSchemas.length === 1) return typeSchemas[0];
|
|
364
|
+
return z.union(typeSchemas);
|
|
365
|
+
}
|
|
366
|
+
if (!type) return z.any();
|
|
367
|
+
let zodSchema;
|
|
368
|
+
switch (type) {
|
|
369
|
+
case "string": {
|
|
370
|
+
let stringSchema = z.string();
|
|
371
|
+
if (schema.format) {
|
|
372
|
+
const format = schema.format;
|
|
373
|
+
if (format === "email") stringSchema = stringSchema.check(z.email());
|
|
374
|
+
else if (format === "uri" || format === "uri-reference") stringSchema = stringSchema.check(z.url());
|
|
375
|
+
else if (format === "uuid" || format === "guid") stringSchema = stringSchema.check(z.uuid());
|
|
376
|
+
else if (format === "date-time") stringSchema = stringSchema.check(z.iso.datetime({ offset: true }));
|
|
377
|
+
else if (format === "date") stringSchema = stringSchema.check(z.iso.date());
|
|
378
|
+
else if (format === "time") stringSchema = stringSchema.check(z.regex(fullTime));
|
|
379
|
+
else if (format === "duration") stringSchema = stringSchema.check(z.iso.duration());
|
|
380
|
+
else if (format === "hostname") stringSchema = stringSchema.check(z.hostname());
|
|
381
|
+
else if (format === "ipv4") stringSchema = stringSchema.check(z.ipv4());
|
|
382
|
+
else if (format === "ipv6") stringSchema = stringSchema.check(z.ipv6());
|
|
383
|
+
else if (format === "mac") stringSchema = stringSchema.check(z.mac());
|
|
384
|
+
else if (format === "cidr") stringSchema = stringSchema.check(z.cidrv4());
|
|
385
|
+
else if (format === "cidr-v6") stringSchema = stringSchema.check(z.cidrv6());
|
|
386
|
+
else if (format === "base64") stringSchema = stringSchema.check(z.base64());
|
|
387
|
+
else if (format === "base64url") stringSchema = stringSchema.check(z.base64url());
|
|
388
|
+
else if (format === "e164") stringSchema = stringSchema.check(z.e164());
|
|
389
|
+
else if (format === "credit_card") stringSchema = stringSchema.check(z.creditCard());
|
|
390
|
+
else if (format === "iban") stringSchema = stringSchema.check(z.iban());
|
|
391
|
+
else if (format === "jwt") stringSchema = stringSchema.check(z.jwt());
|
|
392
|
+
else if (format === "emoji") stringSchema = stringSchema.check(z.emoji());
|
|
393
|
+
else if (format === "nanoid") stringSchema = stringSchema.check(z.nanoid());
|
|
394
|
+
else if (format === "cuid") stringSchema = stringSchema.check(z.cuid());
|
|
395
|
+
else if (format === "cuid2") stringSchema = stringSchema.check(z.cuid2());
|
|
396
|
+
else if (format === "ulid") stringSchema = stringSchema.check(z.ulid());
|
|
397
|
+
else if (format === "xid") stringSchema = stringSchema.check(z.xid());
|
|
398
|
+
else if (format === "ksuid") stringSchema = stringSchema.check(z.ksuid());
|
|
399
|
+
}
|
|
400
|
+
if (typeof schema.minLength === "number") stringSchema = stringSchema.min(schema.minLength);
|
|
401
|
+
if (typeof schema.maxLength === "number") stringSchema = stringSchema.max(schema.maxLength);
|
|
402
|
+
if (schema.pattern) stringSchema = stringSchema.regex(new RegExp(schema.pattern));
|
|
403
|
+
zodSchema = stringSchema;
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
case "number":
|
|
407
|
+
case "integer": {
|
|
408
|
+
let numberSchema = type === "integer" ? z.number().int() : z.number();
|
|
409
|
+
if (typeof schema.minimum === "number" && schema.exclusiveMinimum !== true) numberSchema = numberSchema.min(schema.minimum);
|
|
410
|
+
if (typeof schema.maximum === "number" && schema.exclusiveMaximum !== true) numberSchema = numberSchema.max(schema.maximum);
|
|
411
|
+
if (typeof schema.exclusiveMinimum === "number") numberSchema = numberSchema.gt(schema.exclusiveMinimum);
|
|
412
|
+
else if (schema.exclusiveMinimum === true && typeof schema.minimum === "number") numberSchema = numberSchema.gt(schema.minimum);
|
|
413
|
+
if (typeof schema.exclusiveMaximum === "number") numberSchema = numberSchema.lt(schema.exclusiveMaximum);
|
|
414
|
+
else if (schema.exclusiveMaximum === true && typeof schema.maximum === "number") numberSchema = numberSchema.lt(schema.maximum);
|
|
415
|
+
if (typeof schema.multipleOf === "number") numberSchema = numberSchema.multipleOf(schema.multipleOf);
|
|
416
|
+
zodSchema = numberSchema;
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
419
|
+
case "boolean":
|
|
420
|
+
zodSchema = z.boolean();
|
|
421
|
+
break;
|
|
422
|
+
case "null":
|
|
423
|
+
zodSchema = z.null();
|
|
424
|
+
break;
|
|
425
|
+
case "object": {
|
|
426
|
+
const shape = {};
|
|
427
|
+
const properties = schema.properties || {};
|
|
428
|
+
const requiredSet = new Set(schema.required || []);
|
|
429
|
+
const additionalSchema = typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : void 0;
|
|
430
|
+
for (const [key, propSchema] of Object.entries(properties)) {
|
|
431
|
+
const propZodSchema = convertSchema(propSchema, ctx);
|
|
432
|
+
assignProp(shape, key, requiredSet.has(key) ? propZodSchema : propZodSchema.optional());
|
|
433
|
+
}
|
|
434
|
+
if (schema.patternProperties) {
|
|
435
|
+
const patternProps = schema.patternProperties;
|
|
436
|
+
const patternKeys = Object.keys(patternProps);
|
|
437
|
+
const looseRecords = [];
|
|
438
|
+
for (const pattern of patternKeys) {
|
|
439
|
+
const patternValue = convertSchema(patternProps[pattern], ctx);
|
|
440
|
+
const keySchema = z.string().regex(new RegExp(pattern));
|
|
441
|
+
looseRecords.push(z.looseRecord(keySchema, patternValue));
|
|
442
|
+
}
|
|
443
|
+
const schemasToIntersect = [];
|
|
444
|
+
if (Object.keys(shape).length > 0) schemasToIntersect.push(z.object(shape).passthrough());
|
|
445
|
+
schemasToIntersect.push(...looseRecords);
|
|
446
|
+
if (schemasToIntersect.length === 0) zodSchema = z.object({}).passthrough();
|
|
447
|
+
else if (schemasToIntersect.length === 1) zodSchema = schemasToIntersect[0];
|
|
448
|
+
else {
|
|
449
|
+
let result = z.intersection(schemasToIntersect[0], schemasToIntersect[1]);
|
|
450
|
+
for (let i = 2; i < schemasToIntersect.length; i++) result = z.intersection(result, schemasToIntersect[i]);
|
|
451
|
+
zodSchema = result;
|
|
452
|
+
}
|
|
453
|
+
if (schema.additionalProperties === false) {
|
|
454
|
+
const propertyKeys = Object.keys(shape);
|
|
455
|
+
const patterns = patternKeys.map((p) => new RegExp(p));
|
|
456
|
+
const basePatternSchema = zodSchema;
|
|
457
|
+
zodSchema = zodSchema.check((payload) => {
|
|
458
|
+
if (!isPlainObject(payload.value)) return;
|
|
459
|
+
const unrecognized = [];
|
|
460
|
+
for (const key of Object.keys(payload.value)) {
|
|
461
|
+
if (propertyKeys.includes(key)) continue;
|
|
462
|
+
if (patterns.some((regex) => regex.test(key))) continue;
|
|
463
|
+
unrecognized.push(key);
|
|
464
|
+
}
|
|
465
|
+
if (unrecognized.length) payload.issues.push({
|
|
466
|
+
code: "unrecognized_keys",
|
|
467
|
+
keys: unrecognized,
|
|
468
|
+
input: payload.value,
|
|
469
|
+
inst: basePatternSchema
|
|
470
|
+
});
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
} else {
|
|
474
|
+
const objectSchema = z.object(shape);
|
|
475
|
+
if (schema.additionalProperties === false) zodSchema = objectSchema.strict();
|
|
476
|
+
else if (additionalSchema) zodSchema = objectSchema.catchall(additionalSchema);
|
|
477
|
+
else zodSchema = objectSchema.passthrough();
|
|
478
|
+
}
|
|
479
|
+
const hasKeyGuard = schema.propertyNames !== void 0 && schema.propertyNames !== true;
|
|
480
|
+
const minProperties = typeof schema.minProperties === "number" ? schema.minProperties : void 0;
|
|
481
|
+
const maxProperties = typeof schema.maxProperties === "number" ? schema.maxProperties : void 0;
|
|
482
|
+
if (hasKeyGuard || minProperties !== void 0 || maxProperties !== void 0) {
|
|
483
|
+
let keySchema;
|
|
484
|
+
if (hasKeyGuard) keySchema = convertSchema(typeof schema.propertyNames === "object" && schema.propertyNames.type === void 0 ? {
|
|
485
|
+
type: "string",
|
|
486
|
+
...schema.propertyNames
|
|
487
|
+
} : schema.propertyNames, ctx);
|
|
488
|
+
zodSchema = checkObjectGuards(zodSchema, {
|
|
489
|
+
keySchema,
|
|
490
|
+
minProperties,
|
|
491
|
+
maxProperties
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
case "array": {
|
|
497
|
+
const prefixItems = schema.prefixItems;
|
|
498
|
+
const items = schema.items;
|
|
499
|
+
if (prefixItems && Array.isArray(prefixItems)) {
|
|
500
|
+
const minItems = typeof schema.minItems === "number" ? schema.minItems : 0;
|
|
501
|
+
const positionalItems = applyMinItems(prefixItems.map((item) => convertSchema(item, ctx)), minItems);
|
|
502
|
+
const rest = !Array.isArray(items) ? getTupleRest(items, ctx) : void 0;
|
|
503
|
+
const tupleSchema = z.tuple(positionalItems);
|
|
504
|
+
zodSchema = rest ? tupleSchema.rest(rest) : tupleSchema;
|
|
505
|
+
if (typeof schema.minItems === "number") zodSchema = zodSchema.check(z.minLength(schema.minItems));
|
|
506
|
+
if (typeof schema.maxItems === "number") zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
|
|
507
|
+
} else if (Array.isArray(items)) {
|
|
508
|
+
const minItems = typeof schema.minItems === "number" ? schema.minItems : 0;
|
|
509
|
+
const positionalItems = applyMinItems(items.map((item) => convertSchema(item, ctx)), minItems);
|
|
510
|
+
const rest = getTupleRest(schema.additionalItems, ctx);
|
|
511
|
+
const tupleSchema = z.tuple(positionalItems);
|
|
512
|
+
zodSchema = rest ? tupleSchema.rest(rest) : tupleSchema;
|
|
513
|
+
if (typeof schema.minItems === "number") zodSchema = zodSchema.check(z.minLength(schema.minItems));
|
|
514
|
+
if (typeof schema.maxItems === "number") zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
|
|
515
|
+
} else if (items !== void 0) {
|
|
516
|
+
const element = convertSchema(items, ctx);
|
|
517
|
+
let arraySchema = z.array(element);
|
|
518
|
+
if (typeof schema.minItems === "number") arraySchema = arraySchema.min(schema.minItems);
|
|
519
|
+
if (typeof schema.maxItems === "number") arraySchema = arraySchema.max(schema.maxItems);
|
|
520
|
+
zodSchema = arraySchema;
|
|
521
|
+
} else zodSchema = z.array(z.any());
|
|
522
|
+
if (schema.uniqueItems === true || schema.contains !== void 0) zodSchema = checkArrayGuards(zodSchema, {
|
|
523
|
+
uniqueItems: schema.uniqueItems === true,
|
|
524
|
+
containsSchema: schema.contains !== void 0 ? convertSchema(schema.contains, ctx) : void 0,
|
|
525
|
+
minContains: typeof schema.minContains === "number" ? schema.minContains : void 0,
|
|
526
|
+
maxContains: typeof schema.maxContains === "number" ? schema.maxContains : void 0
|
|
527
|
+
});
|
|
528
|
+
break;
|
|
529
|
+
}
|
|
530
|
+
default: throw new Error(`Unsupported type: ${type}`);
|
|
531
|
+
}
|
|
532
|
+
return zodSchema;
|
|
533
|
+
}
|
|
534
|
+
function convertSchema(schema, ctx) {
|
|
535
|
+
if (typeof schema === "boolean") return schema ? z.any() : z.never();
|
|
536
|
+
let baseSchema = convertBaseSchema(schema, ctx);
|
|
537
|
+
const hasExplicitType = schema.type || schema.enum !== void 0 || schema.const !== void 0;
|
|
538
|
+
if (schema.anyOf && Array.isArray(schema.anyOf)) {
|
|
539
|
+
const options = schema.anyOf.map((s) => convertSchema(s, ctx));
|
|
540
|
+
const anyOfUnion = z.union(options);
|
|
541
|
+
baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
|
|
542
|
+
}
|
|
543
|
+
if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
544
|
+
const options = schema.oneOf.map((s) => convertSchema(s, ctx));
|
|
545
|
+
const oneOfUnion = z.xor(options);
|
|
546
|
+
baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
|
|
547
|
+
}
|
|
548
|
+
if (schema.allOf && Array.isArray(schema.allOf)) {
|
|
549
|
+
if (schema.allOf.length === 0) baseSchema = hasExplicitType ? baseSchema : z.any();
|
|
550
|
+
else {
|
|
551
|
+
let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
|
|
552
|
+
const startIdx = hasExplicitType ? 0 : 1;
|
|
553
|
+
for (let i = startIdx; i < schema.allOf.length; i++) result = z.intersection(result, convertSchema(schema.allOf[i], ctx));
|
|
554
|
+
baseSchema = result;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
if (schema.nullable === true && ctx.version === "openapi-3.0") baseSchema = z.nullable(baseSchema);
|
|
558
|
+
if (schema.readOnly === true) baseSchema = z.readonly(baseSchema);
|
|
559
|
+
if (schema.default !== void 0) baseSchema = baseSchema.default(schema.default);
|
|
560
|
+
const extraMeta = {};
|
|
561
|
+
for (const key of [
|
|
562
|
+
"$id",
|
|
563
|
+
"id",
|
|
564
|
+
"$comment",
|
|
565
|
+
"$anchor",
|
|
566
|
+
"$vocabulary",
|
|
567
|
+
"$dynamicRef",
|
|
568
|
+
"$dynamicAnchor"
|
|
569
|
+
]) if (key in schema) extraMeta[key] = schema[key];
|
|
570
|
+
for (const key of [
|
|
571
|
+
"contentEncoding",
|
|
572
|
+
"contentMediaType",
|
|
573
|
+
"contentSchema"
|
|
574
|
+
]) if (key in schema) extraMeta[key] = schema[key];
|
|
575
|
+
if (schema.type === "object" && schema.$ref === void 0) {
|
|
576
|
+
if (schema.propertyNames !== void 0 && !containsRef(schema.propertyNames)) extraMeta.propertyNames = schema.propertyNames;
|
|
577
|
+
for (const key of ["minProperties", "maxProperties"]) if (schema[key] !== void 0) extraMeta[key] = schema[key];
|
|
578
|
+
}
|
|
579
|
+
if (schema.type === "array" && schema.$ref === void 0) {
|
|
580
|
+
if (schema.contains !== void 0 && !containsRef(schema.contains)) extraMeta.contains = schema.contains;
|
|
581
|
+
for (const key of [
|
|
582
|
+
"uniqueItems",
|
|
583
|
+
"minContains",
|
|
584
|
+
"maxContains"
|
|
585
|
+
]) if (schema[key] !== void 0) extraMeta[key] = schema[key];
|
|
586
|
+
}
|
|
587
|
+
for (const key of Object.keys(schema)) if (!RECOGNIZED_KEYS.has(key)) assignProp(extraMeta, key, schema[key]);
|
|
588
|
+
if (Object.keys(extraMeta).length > 0) ctx.registry.add(baseSchema, extraMeta);
|
|
589
|
+
if (schema.description) baseSchema = baseSchema.describe(schema.description);
|
|
590
|
+
return baseSchema;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Converts a JSON Schema to a Zod schema. This function should be considered semi-experimental. It's behavior is liable to change. */
|
|
594
|
+
function fromJSONSchema(schema, params) {
|
|
595
|
+
if (typeof schema === "boolean") return schema ? z.any() : z.never();
|
|
596
|
+
let normalized;
|
|
597
|
+
try {
|
|
598
|
+
normalized = JSON.parse(JSON.stringify(schema));
|
|
599
|
+
} catch {
|
|
600
|
+
throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
|
|
601
|
+
}
|
|
602
|
+
const ctx = {
|
|
603
|
+
version: detectVersion(normalized, params?.defaultTarget),
|
|
604
|
+
defs: normalized.$defs || normalized.definitions || {},
|
|
605
|
+
refs: /* @__PURE__ */ new Map(),
|
|
606
|
+
processing: /* @__PURE__ */ new Set(),
|
|
607
|
+
rootSchema: normalized,
|
|
608
|
+
registry: params?.registry ?? globalRegistry
|
|
609
|
+
};
|
|
610
|
+
return convertSchema(normalized, ctx);
|
|
611
|
+
}
|
|
612
|
+
//#endregion
|
|
613
|
+
//#region ../../default/po-scaffold/src/constants/scaffold.ts
|
|
614
|
+
const SCAFFOLD_SOURCE = "@agimon-ai/po-scaffold";
|
|
615
|
+
/** The bundled Po plugin template, relative to the package root. */
|
|
616
|
+
const SCAFFOLD_TEMPLATE_ROOT = "templates/po-extension";
|
|
617
|
+
const SCAFFOLD_BUILTIN_SET_ID = "po-extension";
|
|
618
|
+
/** The host-scope registry other packages register template sets into. */
|
|
619
|
+
const PO_SCAFFOLD_SERVICE = "po/scaffold";
|
|
620
|
+
/** Bound by hosts where sets belong to orgs and people; see `ScaffoldTenancy`. */
|
|
621
|
+
const PO_SCAFFOLD_TENANCY_SERVICE = "po/scaffold-tenancy";
|
|
622
|
+
/** User sets live in `<po home>/scaffolds/<id>` and `<workspace>/.po/scaffolds/<id>`. */
|
|
623
|
+
const SCAFFOLD_USER_DIRECTORY = "scaffolds";
|
|
624
|
+
const SCAFFOLD_WORKSPACE_DIRECTORY = ".po/scaffolds";
|
|
625
|
+
/** `{ "disabled": [id], "enabled": [id] }` beside the sets: what the person turned off, or back on in one repository. */
|
|
626
|
+
const SCAFFOLD_SETTINGS_FILE = "settings.json";
|
|
627
|
+
const SCAFFOLD_SKILL_NAME = "codemode-how-to-scaffold";
|
|
628
|
+
const SCAFFOLD_SKILL_FILE = `src/prompts/${SCAFFOLD_SKILL_NAME}/SKILL.md`;
|
|
629
|
+
const SCAFFOLD_SKILL_DESCRIPTION = "Create projects, documents and other files from template sets through the scaffold namespace, including Po plugin packages and their features. Use before hand-writing anything a template set covers.";
|
|
630
|
+
const SCAFFOLD_AUTHOR_SKILL_NAME = "codemode-how-to-scaffold-author";
|
|
631
|
+
const SCAFFOLD_AUTHOR_SKILL_FILE = `src/prompts/${SCAFFOLD_AUTHOR_SKILL_NAME}/SKILL.md`;
|
|
632
|
+
const SCAFFOLD_AUTHOR_SKILL_DESCRIPTION = "Save or remove host, personal and workspace template sets through the scaffoldAuthor namespace, in Help mode and with the person approving each change. Use when the person asks Po to define a reusable template.";
|
|
633
|
+
//#endregion
|
|
634
|
+
//#region ../../default/po-scaffold/src/schemas/contracts.ts
|
|
635
|
+
const SCAFFOLD_REGISTRY_CONTRACT = defineServiceContract(PO_SCAFFOLD_SERVICE, { scope: "host" });
|
|
636
|
+
/** Bound by a hosted service so sets belong to orgs and people; a computer binds nothing. */
|
|
637
|
+
const SCAFFOLD_TENANCY_CONTRACT = defineServiceContract(PO_SCAFFOLD_TENANCY_SERVICE, {
|
|
638
|
+
scope: "host",
|
|
639
|
+
description: "Resolves a verified person's org and personal template set folders."
|
|
640
|
+
});
|
|
641
|
+
//#endregion
|
|
642
|
+
//#region ../../default/po-scaffold/src/schemas/scaffoldInputs.ts
|
|
643
|
+
const variables = record(string(), unknown()).default({});
|
|
644
|
+
const name = string().min(1).max(200);
|
|
645
|
+
const relativePath = string().min(1).max(200);
|
|
646
|
+
/** kebab-case, so a set id is also a safe folder name. */
|
|
647
|
+
const scaffoldSetId = string().max(64).regex(/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/u, "Use kebab-case, such as weekly-report.");
|
|
648
|
+
const set = scaffoldSetId.optional();
|
|
649
|
+
const scaffoldCreateSchema = strictObject({
|
|
650
|
+
set,
|
|
651
|
+
boilerplate: name,
|
|
652
|
+
variables,
|
|
653
|
+
targetFolder: relativePath.optional()
|
|
654
|
+
});
|
|
655
|
+
const scaffoldAddSchema = strictObject({
|
|
656
|
+
set,
|
|
657
|
+
feature: name,
|
|
658
|
+
projectPath: relativePath,
|
|
659
|
+
variables
|
|
660
|
+
});
|
|
661
|
+
const scaffoldSetScopeSchema = _enum([
|
|
662
|
+
"host",
|
|
663
|
+
"personal",
|
|
664
|
+
"workspace"
|
|
665
|
+
]);
|
|
666
|
+
/** Bounded so one draft cannot fill a disk: 200 files of at most 256 KiB, 2 MiB in all. */
|
|
667
|
+
const scaffoldSetDraftSchema = strictObject({
|
|
668
|
+
scope: scaffoldSetScopeSchema,
|
|
669
|
+
id: scaffoldSetId,
|
|
670
|
+
label: string().trim().min(1).max(80),
|
|
671
|
+
description: string().trim().max(400),
|
|
672
|
+
files: record(relativePath, string().max(262144)).refine((files) => Object.keys(files).length <= 200, "A set holds at most 200 files.").refine((files) => Object.values(files).reduce((total, text) => total + text.length, 0) <= 2097152, "A set holds at most 2 MiB of text.").refine((files) => "scaffold.yaml" in files, "A set needs a scaffold.yaml.")
|
|
673
|
+
}).refine((draft) => !("settings.json" in draft.files), "settings.json is reserved.");
|
|
674
|
+
/** A Settings toggle: turn one set on or off for agents, at the mount's scope unless it names another it offers. */
|
|
675
|
+
const scaffoldSetToggleSchema = strictObject({
|
|
676
|
+
id: scaffoldSetId,
|
|
677
|
+
enabled: boolean(),
|
|
678
|
+
scope: scaffoldSetScopeSchema.optional()
|
|
679
|
+
});
|
|
680
|
+
/**
|
|
681
|
+
* A scaffolds folder's settings.json. `enabled` turns back on a set a level
|
|
682
|
+
* below turned off: a person's own over their org, a repository over both.
|
|
683
|
+
*/
|
|
684
|
+
const scaffoldSettingsSchema = object({
|
|
685
|
+
disabled: array(string()).default([]),
|
|
686
|
+
enabled: array(string()).default([])
|
|
687
|
+
});
|
|
688
|
+
const scaffoldSetRefSchema = strictObject({
|
|
689
|
+
scope: scaffoldSetScopeSchema,
|
|
690
|
+
id: scaffoldSetId
|
|
691
|
+
});
|
|
692
|
+
const templateDefinition = object({
|
|
693
|
+
name,
|
|
694
|
+
description: string().default(""),
|
|
695
|
+
targetFolder: string().optional(),
|
|
696
|
+
/** Liquid for the new project's folder below targetFolder; boilerplates only. */
|
|
697
|
+
folder: string().optional(),
|
|
698
|
+
variables_schema: record(string(), unknown()).default({
|
|
699
|
+
type: "object",
|
|
700
|
+
properties: {},
|
|
701
|
+
additionalProperties: false
|
|
702
|
+
}),
|
|
703
|
+
includes: array(string()).default([]),
|
|
704
|
+
instruction: string().default("")
|
|
705
|
+
});
|
|
706
|
+
/** A template set's scaffold.yaml, with the defaults the engine relies on. */
|
|
707
|
+
const scaffoldConfigSchema = object({
|
|
708
|
+
label: string().optional(),
|
|
709
|
+
description: string().optional(),
|
|
710
|
+
boilerplate: array(templateDefinition).default([]),
|
|
711
|
+
features: array(templateDefinition).default([])
|
|
712
|
+
});
|
|
713
|
+
/** Validates `variables` against a template's declared JSON Schema and applies its defaults. */
|
|
714
|
+
function parseScaffoldVariables(template, jsonSchema, value) {
|
|
715
|
+
const parsed = fromJSONSchema(jsonSchema).safeParse(value);
|
|
716
|
+
if (!parsed.success) throw new Error(`Invalid variables for ${template}:\n${prettifyError(parsed.error)}`);
|
|
717
|
+
return parsed.data;
|
|
718
|
+
}
|
|
719
|
+
//#endregion
|
|
720
|
+
//#region ../../default/po-scaffold/src/services/scaffoldTemplates/index.ts
|
|
721
|
+
/** Splits camel case and any separator, so every case filter agrees on the words. */
|
|
722
|
+
function words(value) {
|
|
723
|
+
return String(value).replace(/([a-z0-9])([A-Z])/gu, "$1 $2").split(/[^a-zA-Z0-9]+/u).filter(Boolean).map((word) => word.toLowerCase());
|
|
724
|
+
}
|
|
725
|
+
const capitalize = (word) => word.charAt(0).toUpperCase() + word.slice(1);
|
|
726
|
+
function createLiquid() {
|
|
727
|
+
const liquid = new Liquid({
|
|
728
|
+
strictFilters: true,
|
|
729
|
+
strictVariables: true
|
|
730
|
+
});
|
|
731
|
+
liquid.registerFilter("camelCase", (value) => words(value).map((word, index) => index === 0 ? word : capitalize(word)).join(""));
|
|
732
|
+
liquid.registerFilter("pascalCase", (value) => words(value).map(capitalize).join(""));
|
|
733
|
+
liquid.registerFilter("kebabCase", (value) => words(value).join("-"));
|
|
734
|
+
liquid.registerFilter("snakeCase", (value) => words(value).join("_"));
|
|
735
|
+
liquid.registerFilter("upperCase", (value) => words(value).join("_").toUpperCase());
|
|
736
|
+
liquid.registerFilter("upper", (value) => String(value).toUpperCase());
|
|
737
|
+
return liquid;
|
|
738
|
+
}
|
|
739
|
+
/** A workspace-relative POSIX path that cannot leave the checkout. */
|
|
740
|
+
function safeRelative(value, label) {
|
|
741
|
+
const normalized = path.posix.normalize(value.replaceAll("\\", "/")).replace(/\/+$/u, "");
|
|
742
|
+
if (normalized === "." || normalized.startsWith("/") || /^[a-z]:/iu.test(normalized) || normalized === ".." || normalized.startsWith("../") || normalized.includes("\0")) throw new Error(`${label} "${value}" must be a relative path inside the workspace.`);
|
|
743
|
+
return normalized;
|
|
744
|
+
}
|
|
745
|
+
/** A folder inside the workspace, where `.` is the workspace root itself; files may not be `.`. */
|
|
746
|
+
function safeFolder(value, label) {
|
|
747
|
+
return path.posix.normalize(value.replaceAll("\\", "/")) === "." ? "." : safeRelative(value, label);
|
|
748
|
+
}
|
|
749
|
+
/** `src->target?key=value&key=value`, as scaffold.yaml declares an include. */
|
|
750
|
+
function parseInclude(entry) {
|
|
751
|
+
const [pathPart = "", query] = entry.split("?");
|
|
752
|
+
const conditions = {};
|
|
753
|
+
for (const pair of query?.split("&") ?? []) {
|
|
754
|
+
const [key, value] = pair.split("=");
|
|
755
|
+
if (key && value) conditions[key.trim()] = value.trim();
|
|
756
|
+
}
|
|
757
|
+
const [source = "", target = source] = pathPart.split("->").map((part) => part.trim());
|
|
758
|
+
return {
|
|
759
|
+
source,
|
|
760
|
+
target,
|
|
761
|
+
conditions
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
/** Every template file a parsed scaffold.yaml includes, relative to the set root. */
|
|
765
|
+
function scaffoldIncludeSources(config) {
|
|
766
|
+
const definitions = [...config.boilerplate, ...config.features];
|
|
767
|
+
return [...new Set(definitions.flatMap((definition) => definition.includes.map((entry) => parseInclude(entry).source)))];
|
|
768
|
+
}
|
|
769
|
+
function toTemplate(kind, definition) {
|
|
770
|
+
return {
|
|
771
|
+
name: definition.name,
|
|
772
|
+
kind,
|
|
773
|
+
description: definition.description,
|
|
774
|
+
...definition.targetFolder === void 0 ? {} : { targetFolder: definition.targetFolder },
|
|
775
|
+
variablesSchema: definition.variables_schema
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
/** Parses a set's scaffold.yaml text; throws when it is missing or malformed. */
|
|
779
|
+
function parseScaffoldConfig(text, source) {
|
|
780
|
+
if (text === "") throw new Error(`${source} has no scaffold.yaml.`);
|
|
781
|
+
const parsed = scaffoldConfigSchema.safeParse(parse(text));
|
|
782
|
+
if (!parsed.success) throw new Error(`${source} has an invalid scaffold.yaml: ${parsed.error.message}`);
|
|
783
|
+
return parsed.data;
|
|
784
|
+
}
|
|
785
|
+
/** The boilerplates and features a parsed scaffold.yaml declares. */
|
|
786
|
+
function listScaffoldTemplates(config) {
|
|
787
|
+
return [...config.boilerplate.map((definition) => toTemplate("boilerplate", definition)), ...config.features.map((definition) => toTemplate("feature", definition))];
|
|
788
|
+
}
|
|
789
|
+
function createScaffoldTemplates({ workspaceRoot, fs, readTemplate, write: customWrite, setName = "This template set" }) {
|
|
790
|
+
const liquid = createLiquid();
|
|
791
|
+
let config;
|
|
792
|
+
const loadConfig = () => {
|
|
793
|
+
config ??= readTemplate("scaffold.yaml").then((text) => parseScaffoldConfig(text, setName));
|
|
794
|
+
return config;
|
|
795
|
+
};
|
|
796
|
+
const absolute = (relative) => path.join(workspaceRoot, relative);
|
|
797
|
+
const exists = async (relative) => getOrThrow(await fs.exists(absolute(relative), BACKGROUND_CONTEXT));
|
|
798
|
+
const find = async (kind, name) => {
|
|
799
|
+
const loaded = await loadConfig();
|
|
800
|
+
const definitions = kind === "boilerplate" ? loaded.boilerplate : loaded.features;
|
|
801
|
+
const definition = definitions.find((candidate) => candidate.name === name);
|
|
802
|
+
if (definition) return definition;
|
|
803
|
+
const names = definitions.map((candidate) => candidate.name).join(", ");
|
|
804
|
+
throw new Error(`Unknown ${kind} "${name}". Available: ${names}.`);
|
|
805
|
+
};
|
|
806
|
+
const parseVariables = (definition, variables) => parseScaffoldVariables(definition.name, definition.variables_schema, variables);
|
|
807
|
+
const resolveFiles = async (definition, projectPath, variables) => {
|
|
808
|
+
const files = [];
|
|
809
|
+
for (const entry of definition.includes) {
|
|
810
|
+
const { source, target, conditions } = parseInclude(entry);
|
|
811
|
+
if (Object.entries(conditions).some(([key, value]) => String(variables[key]) !== value)) continue;
|
|
812
|
+
const rendered = safeRelative(await liquid.parseAndRender(target, variables), `Include target of ${source}`);
|
|
813
|
+
files.push({
|
|
814
|
+
source: safeRelative(source, "Include source"),
|
|
815
|
+
target: path.posix.join(projectPath, rendered)
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
return files;
|
|
819
|
+
};
|
|
820
|
+
const planCreate = async (input) => {
|
|
821
|
+
const definition = await find("boilerplate", input.boilerplate);
|
|
822
|
+
const variables = parseVariables(definition, input.variables);
|
|
823
|
+
const parent = safeFolder(input.targetFolder ?? definition.targetFolder ?? ".", "targetFolder");
|
|
824
|
+
const folderTemplate = definition.folder ?? (typeof variables.packageName === "string" ? "{{ packageName }}" : void 0);
|
|
825
|
+
const folder = folderTemplate === void 0 ? void 0 : safeRelative(await liquid.parseAndRender(folderTemplate, variables), "folder");
|
|
826
|
+
const projectPath = folder === void 0 ? parent : path.posix.join(parent, folder);
|
|
827
|
+
return {
|
|
828
|
+
operation: "create",
|
|
829
|
+
projectPath,
|
|
830
|
+
ownFolder: folder !== void 0,
|
|
831
|
+
variables,
|
|
832
|
+
files: await resolveFiles(definition, projectPath, variables),
|
|
833
|
+
instruction: await liquid.parseAndRender(definition.instruction, variables)
|
|
834
|
+
};
|
|
835
|
+
};
|
|
836
|
+
const planAdd = async (input) => {
|
|
837
|
+
const definition = await find("feature", input.feature);
|
|
838
|
+
const variables = parseVariables(definition, input.variables);
|
|
839
|
+
const projectPath = safeFolder(input.projectPath, "projectPath");
|
|
840
|
+
return {
|
|
841
|
+
operation: "add",
|
|
842
|
+
projectPath,
|
|
843
|
+
variables,
|
|
844
|
+
files: await resolveFiles(definition, projectPath, variables),
|
|
845
|
+
instruction: await liquid.parseAndRender(definition.instruction, variables)
|
|
846
|
+
};
|
|
847
|
+
};
|
|
848
|
+
const preview = async (plan, signal) => {
|
|
849
|
+
const existingFiles = [];
|
|
850
|
+
for (const file of plan.files) {
|
|
851
|
+
signal.throwIfAborted();
|
|
852
|
+
if (await exists(file.target)) existingFiles.push(file.target);
|
|
853
|
+
}
|
|
854
|
+
return {
|
|
855
|
+
operation: plan.operation,
|
|
856
|
+
projectPath: plan.projectPath,
|
|
857
|
+
files: plan.files.map((file) => file.target),
|
|
858
|
+
existingFiles,
|
|
859
|
+
instruction: plan.instruction
|
|
860
|
+
};
|
|
861
|
+
};
|
|
862
|
+
const renderFile = async (source, variables) => {
|
|
863
|
+
const liquidText = await readTemplate(`${source}.liquid`);
|
|
864
|
+
const text = liquidText === "" ? await readTemplate(source) : liquidText;
|
|
865
|
+
if (text === "") throw new Error(`${setName} has no template file ${source}.`);
|
|
866
|
+
return liquid.parseAndRender(text, variables);
|
|
867
|
+
};
|
|
868
|
+
const write = async (plan, signal) => {
|
|
869
|
+
const skippedFiles = [];
|
|
870
|
+
const pending = [];
|
|
871
|
+
for (const file of plan.files) {
|
|
872
|
+
signal.throwIfAborted();
|
|
873
|
+
if (await exists(file.target)) skippedFiles.push(file.target);
|
|
874
|
+
else pending.push({
|
|
875
|
+
path: file.target,
|
|
876
|
+
content: await renderFile(file.source, plan.variables)
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
if (customWrite) {
|
|
880
|
+
signal.throwIfAborted();
|
|
881
|
+
const createdFiles = await customWrite({
|
|
882
|
+
operation: plan.operation,
|
|
883
|
+
workspaceRoot,
|
|
884
|
+
projectPath: plan.projectPath,
|
|
885
|
+
files: pending
|
|
886
|
+
}, signal);
|
|
887
|
+
return {
|
|
888
|
+
projectPath: plan.projectPath,
|
|
889
|
+
createdFiles: [...createdFiles],
|
|
890
|
+
skippedFiles,
|
|
891
|
+
instruction: plan.instruction
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
const createdFiles = [];
|
|
895
|
+
try {
|
|
896
|
+
for (const file of pending) {
|
|
897
|
+
signal.throwIfAborted();
|
|
898
|
+
getOrThrow(await fs.createDir(path.dirname(absolute(file.path)), { recursive: true }, BACKGROUND_CONTEXT));
|
|
899
|
+
getOrThrow(await fs.writeFile(absolute(file.path), file.content, BACKGROUND_CONTEXT));
|
|
900
|
+
createdFiles.push(file.path);
|
|
901
|
+
}
|
|
902
|
+
} catch (error) {
|
|
903
|
+
const written = createdFiles.length === 0 ? "nothing" : createdFiles.join(", ");
|
|
904
|
+
throw new Error(`Scaffold stopped after writing ${written}. Inspect those files before retrying.`, { cause: error });
|
|
905
|
+
}
|
|
906
|
+
return {
|
|
907
|
+
projectPath: plan.projectPath,
|
|
908
|
+
createdFiles,
|
|
909
|
+
skippedFiles,
|
|
910
|
+
instruction: plan.instruction
|
|
911
|
+
};
|
|
912
|
+
};
|
|
913
|
+
return {
|
|
914
|
+
async list() {
|
|
915
|
+
return listScaffoldTemplates(await loadConfig());
|
|
916
|
+
},
|
|
917
|
+
async preview(input, signal) {
|
|
918
|
+
return preview(await planCreate(input), signal);
|
|
919
|
+
},
|
|
920
|
+
async previewFeature(input, signal) {
|
|
921
|
+
return preview(await planAdd(input), signal);
|
|
922
|
+
},
|
|
923
|
+
async create(input, signal) {
|
|
924
|
+
const plan = await planCreate(input);
|
|
925
|
+
if (plan.ownFolder && await exists(plan.projectPath)) throw new Error(`${plan.projectPath} already exists. Choose other variables or another targetFolder.`);
|
|
926
|
+
if (!plan.ownFolder) {
|
|
927
|
+
const { existingFiles } = await preview(plan, signal);
|
|
928
|
+
if (existingFiles.length > 0) throw new Error(`${existingFiles.join(", ")} already exist. Nothing was written.`);
|
|
929
|
+
}
|
|
930
|
+
return write(plan, signal);
|
|
931
|
+
},
|
|
932
|
+
async add(input, signal) {
|
|
933
|
+
const plan = await planAdd(input);
|
|
934
|
+
if (!await exists(plan.projectPath)) throw new Error(`${plan.projectPath} does not exist. Create it first with scaffold.create.`);
|
|
935
|
+
return write(plan, signal);
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
//#endregion
|
|
940
|
+
//#region ../../default/po-scaffold/src/services/scaffoldLibrary/index.ts
|
|
941
|
+
const MAX_LISTED_FILES = 200;
|
|
942
|
+
const MAX_LISTED_DIRECTORIES = 100;
|
|
943
|
+
/** Lowest first: each level's choice replaces the ones before it. */
|
|
944
|
+
const SCOPES = [
|
|
945
|
+
"host",
|
|
946
|
+
"personal",
|
|
947
|
+
"workspace"
|
|
948
|
+
];
|
|
949
|
+
const SCOPE_NAMES = {
|
|
950
|
+
host: "Host",
|
|
951
|
+
personal: "Personal",
|
|
952
|
+
workspace: "Workspace"
|
|
953
|
+
};
|
|
954
|
+
const message = (error) => error instanceof Error ? error.message : String(error);
|
|
955
|
+
/** Text of a file, or `''` when it does not exist; other failures throw. */
|
|
956
|
+
async function readText(fs, file) {
|
|
957
|
+
const result = await fs.readTextFile(file, BACKGROUND_CONTEXT);
|
|
958
|
+
if (result.ok) return result.value;
|
|
959
|
+
if (result.error.code === "not_found") return "";
|
|
960
|
+
throw result.error;
|
|
961
|
+
}
|
|
962
|
+
async function exists(fs, target) {
|
|
963
|
+
return getOrThrow(await fs.exists(target, BACKGROUND_CONTEXT));
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Regular files below a set folder, relative and sorted. Symlinks are left out,
|
|
967
|
+
* so a set read through this list cannot reach outside its folder. Bounded so a
|
|
968
|
+
* stray folder cannot stall a listing.
|
|
969
|
+
*/
|
|
970
|
+
async function listFiles(fs, root) {
|
|
971
|
+
const files = [];
|
|
972
|
+
const pending = [""];
|
|
973
|
+
let directories = 0;
|
|
974
|
+
while (pending.length > 0 && files.length < MAX_LISTED_FILES && directories < MAX_LISTED_DIRECTORIES) {
|
|
975
|
+
const relative = pending.shift();
|
|
976
|
+
directories += 1;
|
|
977
|
+
for (const entry of getOrThrow(await fs.listDir(path.join(root, relative), BACKGROUND_CONTEXT))) {
|
|
978
|
+
const child = relative === "" ? entry.name : `${relative}/${entry.name}`;
|
|
979
|
+
if (entry.kind === "directory") pending.push(child);
|
|
980
|
+
else if (entry.kind === "file") files.push(child);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
return files.slice(0, MAX_LISTED_FILES).sort();
|
|
984
|
+
}
|
|
985
|
+
/** Whether agents may use a set, folding the levels lowest first: an off turns it off, an on turns it back on. */
|
|
986
|
+
const choice = (levels, id) => levels.reduce((on, level) => !level.disabled.has(id) && (level.enabled.has(id) || on), true);
|
|
987
|
+
/**
|
|
988
|
+
* Template sets from every source, and the host, personal and workspace folders
|
|
989
|
+
* the person owns. Works through the injected filesystem only, so it runs on the
|
|
990
|
+
* edge too.
|
|
991
|
+
*/
|
|
992
|
+
function createScaffoldLibrary({ fs, packaged, directories = async () => ({}), workspaceRoot }) {
|
|
993
|
+
const workspaceDirectory = workspaceRoot && path.join(workspaceRoot, ".po/scaffolds");
|
|
994
|
+
const directoryOf = (folders, scope) => scope === "workspace" ? workspaceDirectory : folders[scope];
|
|
995
|
+
const requireDirectory = (folders, scope) => {
|
|
996
|
+
const directory = directoryOf(folders, scope);
|
|
997
|
+
if (!directory) throw new Error(`${SCOPE_NAMES[scope]} template sets are unavailable here.`);
|
|
998
|
+
return directory;
|
|
999
|
+
};
|
|
1000
|
+
const readSettings = async (directory) => {
|
|
1001
|
+
if (!directory) return {
|
|
1002
|
+
disabled: /* @__PURE__ */ new Set(),
|
|
1003
|
+
enabled: /* @__PURE__ */ new Set()
|
|
1004
|
+
};
|
|
1005
|
+
const text = await readText(fs, path.join(directory, SCAFFOLD_SETTINGS_FILE));
|
|
1006
|
+
if (text === "") return {
|
|
1007
|
+
disabled: /* @__PURE__ */ new Set(),
|
|
1008
|
+
enabled: /* @__PURE__ */ new Set()
|
|
1009
|
+
};
|
|
1010
|
+
try {
|
|
1011
|
+
const settings = scaffoldSettingsSchema.parse(JSON.parse(text));
|
|
1012
|
+
return {
|
|
1013
|
+
disabled: new Set(settings.disabled),
|
|
1014
|
+
enabled: new Set(settings.enabled)
|
|
1015
|
+
};
|
|
1016
|
+
} catch (error) {
|
|
1017
|
+
throw new Error(`${path.join(directory, SCAFFOLD_SETTINGS_FILE)} is not valid settings: ${message(error)}`, { cause: error });
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
/** Every level's settings, in `SCOPES` order. */
|
|
1021
|
+
const allSettings = (folders) => Promise.all(SCOPES.map((scope) => readSettings(directoryOf(folders, scope))));
|
|
1022
|
+
const folderSource = (root, files, id, label, description) => ({
|
|
1023
|
+
id,
|
|
1024
|
+
label,
|
|
1025
|
+
description,
|
|
1026
|
+
readTemplate: async (file) => {
|
|
1027
|
+
const relative = safeRelative(file, "Template file");
|
|
1028
|
+
return files.includes(relative) ? readText(fs, path.join(root, relative)) : "";
|
|
1029
|
+
}
|
|
1030
|
+
});
|
|
1031
|
+
const userSets = async (folders, scope, signal) => {
|
|
1032
|
+
const directory = directoryOf(folders, scope);
|
|
1033
|
+
if (!directory || !await exists(fs, directory)) return [];
|
|
1034
|
+
const candidates = [];
|
|
1035
|
+
for (const entry of getOrThrow(await fs.listDir(directory, BACKGROUND_CONTEXT))) {
|
|
1036
|
+
signal.throwIfAborted();
|
|
1037
|
+
if (entry.kind !== "directory" || !scaffoldSetId.safeParse(entry.name).success) continue;
|
|
1038
|
+
const root = path.join(directory, entry.name);
|
|
1039
|
+
const where = scope === "workspace" ? `${SCAFFOLD_WORKSPACE_DIRECTORY}/${entry.name}` : root;
|
|
1040
|
+
const files = await listFiles(fs, root);
|
|
1041
|
+
try {
|
|
1042
|
+
const config = parseScaffoldConfig(files.includes("scaffold.yaml") ? await readText(fs, path.join(root, "scaffold.yaml")) : "", where);
|
|
1043
|
+
candidates.push({
|
|
1044
|
+
source: folderSource(root, files, entry.name, config.label ?? entry.name, config.description ?? ""),
|
|
1045
|
+
origin: scope,
|
|
1046
|
+
path: where,
|
|
1047
|
+
files,
|
|
1048
|
+
templates: listScaffoldTemplates(config)
|
|
1049
|
+
});
|
|
1050
|
+
} catch (error) {
|
|
1051
|
+
candidates.push({
|
|
1052
|
+
source: folderSource(root, files, entry.name, entry.name, ""),
|
|
1053
|
+
origin: scope,
|
|
1054
|
+
path: where,
|
|
1055
|
+
files,
|
|
1056
|
+
templates: [],
|
|
1057
|
+
error: message(error)
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
return candidates;
|
|
1062
|
+
};
|
|
1063
|
+
const resolve = async (signal) => {
|
|
1064
|
+
const folders = await directories(signal);
|
|
1065
|
+
const levels = await allSettings(folders);
|
|
1066
|
+
const personal = folders.personal !== void 0;
|
|
1067
|
+
const ordered = [];
|
|
1068
|
+
for (const set of packaged()) {
|
|
1069
|
+
signal.throwIfAborted();
|
|
1070
|
+
try {
|
|
1071
|
+
const config = parseScaffoldConfig(await set.source.readTemplate("scaffold.yaml"), set.source.label);
|
|
1072
|
+
ordered.push({
|
|
1073
|
+
...set,
|
|
1074
|
+
templates: listScaffoldTemplates(config)
|
|
1075
|
+
});
|
|
1076
|
+
} catch (error) {
|
|
1077
|
+
ordered.push({
|
|
1078
|
+
...set,
|
|
1079
|
+
templates: [],
|
|
1080
|
+
error: message(error)
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
for (const scope of SCOPES) ordered.push(...await userSets(folders, scope, signal));
|
|
1085
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
1086
|
+
for (const candidate of ordered) {
|
|
1087
|
+
const replaced = resolved.get(candidate.source.id);
|
|
1088
|
+
const id = candidate.source.id;
|
|
1089
|
+
const view = {
|
|
1090
|
+
id,
|
|
1091
|
+
label: candidate.source.label,
|
|
1092
|
+
description: candidate.source.description,
|
|
1093
|
+
origin: candidate.origin,
|
|
1094
|
+
...candidate.owner === void 0 ? {} : { owner: candidate.owner },
|
|
1095
|
+
...candidate.path === void 0 ? {} : { path: candidate.path },
|
|
1096
|
+
enabled: choice(levels, id),
|
|
1097
|
+
...personal ? { hostEnabled: choice(levels.slice(0, 1), id) } : {},
|
|
1098
|
+
...replaced ? { overrides: replaced.view.origin } : {},
|
|
1099
|
+
templates: candidate.templates,
|
|
1100
|
+
...candidate.files === void 0 ? {} : { files: candidate.files },
|
|
1101
|
+
...candidate.error === void 0 ? {} : { error: candidate.error }
|
|
1102
|
+
};
|
|
1103
|
+
resolved.set(id, {
|
|
1104
|
+
candidate,
|
|
1105
|
+
view
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
return resolved;
|
|
1109
|
+
};
|
|
1110
|
+
const writeSettings = async (directory, settings) => {
|
|
1111
|
+
getOrThrow(await fs.createDir(directory, { recursive: true }, BACKGROUND_CONTEXT));
|
|
1112
|
+
const content = `${JSON.stringify({
|
|
1113
|
+
disabled: [...settings.disabled].sort(),
|
|
1114
|
+
enabled: [...settings.enabled].sort()
|
|
1115
|
+
}, null, 2)}\n`;
|
|
1116
|
+
getOrThrow(await fs.writeFile(path.join(directory, SCAFFOLD_SETTINGS_FILE), content, BACKGROUND_CONTEXT));
|
|
1117
|
+
};
|
|
1118
|
+
return {
|
|
1119
|
+
async list(signal) {
|
|
1120
|
+
return [...(await resolve(signal)).values()].map(({ view }) => view);
|
|
1121
|
+
},
|
|
1122
|
+
async open(id, signal) {
|
|
1123
|
+
const found = (await resolve(signal)).get(id);
|
|
1124
|
+
if (!found) throw new Error(`Unknown template set "${id}".`);
|
|
1125
|
+
if (found.view.error) throw new Error(found.view.error);
|
|
1126
|
+
if (!found.view.enabled) throw new Error(`Template set "${id}" is turned off in Settings.`);
|
|
1127
|
+
return {
|
|
1128
|
+
view: found.view,
|
|
1129
|
+
source: found.candidate.source
|
|
1130
|
+
};
|
|
1131
|
+
},
|
|
1132
|
+
async save(input, signal) {
|
|
1133
|
+
const draft = scaffoldSetDraftSchema.parse(input);
|
|
1134
|
+
const directory = requireDirectory(await directories(signal), draft.scope);
|
|
1135
|
+
const files = /* @__PURE__ */ new Map();
|
|
1136
|
+
for (const [file, content] of Object.entries(draft.files)) files.set(safeRelative(file, "Set file"), content);
|
|
1137
|
+
const config = parseScaffoldConfig(files.get("scaffold.yaml") ?? "", `Set ${draft.id}`);
|
|
1138
|
+
if (listScaffoldTemplates(config).length === 0) throw new Error("scaffold.yaml declares no boilerplate or feature.");
|
|
1139
|
+
const missing = scaffoldIncludeSources(config).filter((file) => !files.has(file) && !files.has(`${file}.liquid`));
|
|
1140
|
+
if (missing.length > 0) throw new Error(`scaffold.yaml includes files the set does not have: ${missing.join(", ")}.`);
|
|
1141
|
+
const document = parseDocument(files.get("scaffold.yaml"));
|
|
1142
|
+
document.set("label", draft.label);
|
|
1143
|
+
document.set("description", draft.description);
|
|
1144
|
+
files.set("scaffold.yaml", document.toString());
|
|
1145
|
+
const target = path.join(directory, draft.id);
|
|
1146
|
+
const staging = path.join(directory, `.${draft.id}.staging-${crypto.randomUUID()}`);
|
|
1147
|
+
try {
|
|
1148
|
+
for (const [file, content] of files) {
|
|
1149
|
+
signal.throwIfAborted();
|
|
1150
|
+
getOrThrow(await fs.createDir(path.dirname(path.join(staging, file)), { recursive: true }, BACKGROUND_CONTEXT));
|
|
1151
|
+
getOrThrow(await fs.writeFile(path.join(staging, file), content, BACKGROUND_CONTEXT));
|
|
1152
|
+
}
|
|
1153
|
+
signal.throwIfAborted();
|
|
1154
|
+
if (await exists(fs, target)) {
|
|
1155
|
+
const previous = path.join(directory, `.${draft.id}.previous-${crypto.randomUUID()}`);
|
|
1156
|
+
getOrThrow(await fs.renameFile(target, previous, BACKGROUND_CONTEXT));
|
|
1157
|
+
const swapped = await fs.renameFile(staging, target, BACKGROUND_CONTEXT);
|
|
1158
|
+
if (!swapped.ok) {
|
|
1159
|
+
getOrThrow(await fs.renameFile(previous, target, BACKGROUND_CONTEXT));
|
|
1160
|
+
throw swapped.error;
|
|
1161
|
+
}
|
|
1162
|
+
await fs.remove(previous, {
|
|
1163
|
+
recursive: true,
|
|
1164
|
+
force: true
|
|
1165
|
+
}, BACKGROUND_CONTEXT);
|
|
1166
|
+
} else getOrThrow(await fs.renameFile(staging, target, BACKGROUND_CONTEXT));
|
|
1167
|
+
} catch (error) {
|
|
1168
|
+
await fs.remove(staging, {
|
|
1169
|
+
recursive: true,
|
|
1170
|
+
force: true
|
|
1171
|
+
}, BACKGROUND_CONTEXT);
|
|
1172
|
+
throw error;
|
|
1173
|
+
}
|
|
1174
|
+
const saved = (await resolve(signal)).get(draft.id)?.view;
|
|
1175
|
+
if (!saved) throw new Error(`Template set "${draft.id}" was saved but could not be read back.`);
|
|
1176
|
+
return saved;
|
|
1177
|
+
},
|
|
1178
|
+
async readFiles({ scope, id }, signal) {
|
|
1179
|
+
const root = path.join(requireDirectory(await directories(signal), scope), scaffoldSetId.parse(id));
|
|
1180
|
+
if (!await exists(fs, root)) throw new Error(`There is no ${scope} template set "${id}".`);
|
|
1181
|
+
const files = {};
|
|
1182
|
+
for (const file of await listFiles(fs, root)) {
|
|
1183
|
+
signal.throwIfAborted();
|
|
1184
|
+
files[file] = await readText(fs, path.join(root, file));
|
|
1185
|
+
}
|
|
1186
|
+
return files;
|
|
1187
|
+
},
|
|
1188
|
+
async remove({ scope, id }, signal) {
|
|
1189
|
+
const target = path.join(requireDirectory(await directories(signal), scope), scaffoldSetId.parse(id));
|
|
1190
|
+
signal.throwIfAborted();
|
|
1191
|
+
if (!await exists(fs, target)) throw new Error(`There is no ${scope} template set "${id}".`);
|
|
1192
|
+
getOrThrow(await fs.remove(target, { recursive: true }, BACKGROUND_CONTEXT));
|
|
1193
|
+
},
|
|
1194
|
+
async scopes(signal) {
|
|
1195
|
+
const folders = await directories(signal);
|
|
1196
|
+
return SCOPES.filter((scope) => directoryOf(folders, scope) !== void 0);
|
|
1197
|
+
},
|
|
1198
|
+
async setEnabled({ scope, id, enabled }, signal) {
|
|
1199
|
+
scaffoldSetId.parse(id);
|
|
1200
|
+
const folders = await directories(signal);
|
|
1201
|
+
const directory = requireDirectory(folders, scope);
|
|
1202
|
+
const levels = await allSettings(folders);
|
|
1203
|
+
signal.throwIfAborted();
|
|
1204
|
+
const at = SCOPES.indexOf(scope);
|
|
1205
|
+
const settings = levels[at];
|
|
1206
|
+
settings.disabled.delete(id);
|
|
1207
|
+
settings.enabled.delete(id);
|
|
1208
|
+
if (!enabled) settings.disabled.add(id);
|
|
1209
|
+
else if (!choice(levels.slice(0, at), id)) settings.enabled.add(id);
|
|
1210
|
+
await writeSettings(directory, settings);
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
//#endregion
|
|
1215
|
+
//#region ../../default/po-scaffold/src/services/scaffoldRegistry/index.ts
|
|
1216
|
+
/** The host's registry of package-contributed template sets, in registration order. */
|
|
1217
|
+
function createScaffoldRegistry() {
|
|
1218
|
+
const sets = /* @__PURE__ */ new Map();
|
|
1219
|
+
return {
|
|
1220
|
+
register(source, owner) {
|
|
1221
|
+
scaffoldSetId.parse(source.id);
|
|
1222
|
+
if (sets.has(source.id)) throw new Error(`Template set "${source.id}" is already registered.`);
|
|
1223
|
+
const entry = {
|
|
1224
|
+
source,
|
|
1225
|
+
owner
|
|
1226
|
+
};
|
|
1227
|
+
sets.set(source.id, entry);
|
|
1228
|
+
return { dispose: () => {
|
|
1229
|
+
if (sets.get(source.id) === entry) sets.delete(source.id);
|
|
1230
|
+
} };
|
|
1231
|
+
},
|
|
1232
|
+
list: () => [...sets.values()]
|
|
1233
|
+
};
|
|
1234
|
+
}
|
|
1235
|
+
/** Absent when po-scaffold is not selected at this host. */
|
|
1236
|
+
function readPoScaffold(context) {
|
|
1237
|
+
return context.get(PO_SCAFFOLD_SERVICE);
|
|
1238
|
+
}
|
|
1239
|
+
//#endregion
|
|
1240
|
+
export { SCAFFOLD_USER_DIRECTORY as S, SCAFFOLD_SKILL_DESCRIPTION as _, scaffoldAddSchema as a, SCAFFOLD_SOURCE as b, scaffoldSetRefSchema as c, SCAFFOLD_REGISTRY_CONTRACT as d, SCAFFOLD_TENANCY_CONTRACT as f, SCAFFOLD_BUILTIN_SET_ID as g, SCAFFOLD_AUTHOR_SKILL_NAME as h, createScaffoldTemplates as i, scaffoldSetScopeSchema as l, SCAFFOLD_AUTHOR_SKILL_FILE as m, readPoScaffold as n, scaffoldCreateSchema as o, SCAFFOLD_AUTHOR_SKILL_DESCRIPTION as p, createScaffoldLibrary as r, scaffoldSetDraftSchema as s, createScaffoldRegistry as t, scaffoldSetToggleSchema as u, SCAFFOLD_SKILL_FILE as v, SCAFFOLD_TEMPLATE_ROOT as x, SCAFFOLD_SKILL_NAME as y };
|