@kabmo-labs/kabmo 0.32.0 → 0.33.0
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/dist/client/index.html +1 -1
- package/dist/client/index.js +537 -530
- package/dist/client/static/js/{CsvGrid-amafmq3z.js → CsvGrid-fncjbg6j.js} +2 -2
- package/dist/client/static/js/{DocxView-851ps9t0.js → DocxView-c9v2vr3r.js} +5 -5
- package/dist/client/static/js/{DrawioView-kw1vy3r2.js → DrawioView-vxjksm12.js} +2 -2
- package/dist/client/static/js/ImageView-a3g5k226.js +1 -0
- package/dist/client/static/js/LayoutWrapper-hnjfwsjh.js +2 -0
- package/dist/client/static/js/Modal-qtftcp2t.js +38 -0
- package/dist/client/static/js/{PdfView-f5jkm0rs.js → PdfView-ksaes53y.js} +1 -1
- package/dist/client/static/js/SessionsView-30vcr95v.js +1 -0
- package/dist/client/static/js/{SheetView-23zxy30b.js → SheetView-vc484scg.js} +23 -23
- package/dist/client/static/js/{SvgPreview-c341y50e.js → SvgPreview-tph89jet.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-2dc3mpk6.js → abnfDiagram-O67JEVCF-xbar278c.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-tavtgb8a.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-7jmrr5ja.js → architectureDiagram-NJMV4G6O-s171n2z6.js} +3 -3
- package/dist/client/static/js/{astro-sjtf954j.js → astro-80bs6hvg.js} +1 -1
- package/dist/client/static/js/bash-b3rwyg5p.js +1 -0
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-jrk2m0ea.js → blockDiagram-BEXU5L5S-gzx6rv9n.js} +3 -3
- package/dist/client/static/js/c-wkgxb1t1.js +1 -0
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-48cyncjd.js → c4Diagram-YGBWAQC7-7f00skch.js} +2 -2
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-gm7jt1cd.js → classDiagram-v2-NBCMYWYE-j79v95nc.js} +4 -4
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-g0g3z0xp.js → cose-bilkent-JH36ORCC-5fkn7ee5.js} +1 -1
- package/dist/client/static/js/cpp-y0t6mynx.js +1 -0
- package/dist/client/static/js/css-6vj0d308.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-cdh3n2z2.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-6vjde6am.js → cynefinDiagram-VND7K2PF-cfs1yvrd.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-q6k8bx1j.js → dagre-6A5THRUB-44bgc48p.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-87cmze2n.js → diagram-22UHCM2B-a4g4x83k.js} +19 -19
- package/dist/client/static/js/{diagram-3UASUU5V-1ejbr2p4.js → diagram-3UASUU5V-gm4rg5na.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-vaw1r6k2.js → diagram-ATOU4E4O-a95y41vk.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-gxm9zv7d.js → diagram-CDSNMT55-t3j93mmc.js} +5 -5
- package/dist/client/static/js/{diagram-MLGK6HIB-x010xswm.js → diagram-MLGK6HIB-c2wdez02.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-qtcq7e6c.js → diagram-MPIPVDR6-gya9jhs5.js} +2 -2
- package/dist/client/static/js/{dockerfile-k5xbramm.js → dockerfile-a7q6174s.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-nwwbasfh.js → ebnfDiagram-ZINNZB2B-jjhkza6t.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-xcp7thax.js → elk-276RUBZZ-f7re45mw.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-xj1tp716.js → erDiagram-OPXOYQCR-tpm9g5te.js} +6 -6
- package/dist/client/static/js/{erlang-rz1g9mxy.js → erlang-qt876zrq.js} +1 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-as97tpyp.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-ggm06d12.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-f7q96bea.js → ganttDiagram-FUAMR5RP-fz43n12d.js} +4 -4
- package/dist/client/static/js/gitGraph-4MIJSDKK-eqz7p9ng.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-1rydkyq9.js → gitGraphDiagram-X574FWY7-f61hgbn6.js} +9 -9
- package/dist/client/static/js/graphql-n43pd5fs.js +1 -0
- package/dist/client/static/js/{index-0g25yrc0.js → index-03h3bkcf.js} +1 -1
- package/dist/client/static/js/{index-8m3q2zpb.js → index-0e40xskg.js} +1 -1
- package/dist/client/static/js/{index-w5131mtt.js → index-0n5wwe60.js} +2 -2
- package/dist/client/static/js/{index-ynqnbvn2.js → index-0tf0arsp.js} +3 -3
- package/dist/client/static/js/{index-0a1ekhqf.js → index-14vndmcr.js} +2 -2
- package/dist/client/static/js/index-1a0zkj8h.js +2 -0
- package/dist/client/static/js/{index-zca66d5d.js → index-1xqs14fr.js} +3 -3
- package/dist/client/static/js/{index-73xfkyea.js → index-1y9r4frb.js} +2 -2
- package/dist/client/static/js/{index-0n9c85ke.js → index-2svnq5gg.js} +2 -2
- package/dist/client/static/js/{index-pe9j88d4.js → index-2x5f66t6.js} +2 -2
- package/dist/client/static/js/{index-ggaqh9rt.js → index-354mqqra.js} +2 -2
- package/dist/client/static/js/{index-2t2tnc3x.js → index-3rcjx70v.js} +1 -1
- package/dist/client/static/js/{index-9nbxb421.js → index-3zc1b0dv.js} +2 -2
- package/dist/client/static/js/{index-14wppnkx.js → index-5tgq7aqx.js} +2 -2
- package/dist/client/static/js/{index-vrbcj11n.js → index-76zb4m0n.js} +2 -2
- package/dist/client/static/js/{index-x64kqgen.js → index-7y6rpsrp.js} +2 -2
- package/dist/client/static/js/{index-2n5wy1sh.js → index-8239j2v1.js} +1 -1
- package/dist/client/static/js/{index-pkyrkkbt.js → index-9fjt5anh.js} +2 -2
- package/dist/client/static/js/{index-m6wwc5h6.js → index-9t82sx0w.js} +2 -2
- package/dist/client/static/js/{index-hkq0y3pn.js → index-9y3gjdj7.js} +2 -2
- package/dist/client/static/js/{index-hyry1n8x.js → index-ahv9y42z.js} +2 -2
- package/dist/client/static/js/{index-f519m6s3.js → index-ajs3jj6j.js} +1 -1
- package/dist/client/static/js/index-apvkd37e.js +4 -0
- package/dist/client/static/js/index-at6bhjyf.js +1 -0
- package/dist/client/static/js/index-bkye8mz4.js +2 -0
- package/dist/client/static/js/{index-e7a3fkvv.js → index-d495kfm0.js} +1 -1
- package/dist/client/static/js/{index-hhm62nfj.js → index-dbe6afkf.js} +2 -2
- package/dist/client/static/js/{index-c20a46ww.js → index-djmg1d7h.js} +2 -2
- package/dist/client/static/js/{index-fc2j6bq2.js → index-e4p4cd3r.js} +2 -2
- package/dist/client/static/js/{index-f63y3mjj.js → index-eyzeya95.js} +5 -5
- package/dist/client/static/js/{index-123e8tqq.js → index-gcs49f3p.js} +1 -1
- package/dist/client/static/js/{index-c8jzx6b0.js → index-gs6f0qwa.js} +2 -2
- package/dist/client/static/js/{index-6sdctwv2.js → index-hf52f59k.js} +2 -2
- package/dist/client/static/js/{index-3anc30zh.js → index-j0r5hj0j.js} +2 -2
- package/dist/client/static/js/{index-31jrebvn.js → index-js7t1vb1.js} +18 -18
- package/dist/client/static/js/{index-xa7nrnda.js → index-km2zb6wk.js} +2 -2
- package/dist/client/static/js/{index-yvcpdk5f.js → index-m73za75e.js} +1 -1
- package/dist/client/static/js/{index-e6rar25v.js → index-pbe4yed4.js} +2 -2
- package/dist/client/static/js/{index-xpf2ra60.js → index-pxv2nw9w.js} +1 -1
- package/dist/client/static/js/{index-deex10rz.js → index-q2w6s8n7.js} +5 -5
- package/dist/client/static/js/{index-22jaxtz1.js → index-qckv9nte.js} +2 -2
- package/dist/client/static/js/{index-e26rd868.js → index-qsm2z36d.js} +2 -2
- package/dist/client/static/js/{index-5zd1jx9r.js → index-rg8jpbsw.js} +2 -2
- package/dist/client/static/js/{index-gvwqjpcr.js → index-rytaa8ca.js} +2 -2
- package/dist/client/static/js/{index-fmxn1rzs.js → index-sdtye3jy.js} +2 -2
- package/dist/client/static/js/index-sffjtm5w.js +12 -0
- package/dist/client/static/js/{index-tr8754r0.js → index-trm9x02n.js} +45 -45
- package/dist/client/static/js/{index-cwaz6geq.js → index-vtbbfwx0.js} +2 -2
- package/dist/client/static/js/{index-vmvcse63.js → index-vw4brsdx.js} +1 -1
- package/dist/client/static/js/{index-qmh0h87h.js → index-vw5k8csz.js} +55 -55
- package/dist/client/static/js/{index-52bgxh6f.js → index-w0fwb80e.js} +1 -1
- package/dist/client/static/js/{index-s9vp6p70.js → index-x07kp3jz.js} +2 -2
- package/dist/client/static/js/{index-8a3tmm1h.js → index-xj9649ac.js} +7 -7
- package/dist/client/static/js/{index-w4re5r8w.js → index-ypx3qmhq.js} +2 -2
- package/dist/client/static/js/{index-y139vc12.js → index-zt75xpq0.js} +193 -193
- package/dist/client/static/js/{index-nsrnyqcm.js → index-zvfvqvn9.js} +2 -2
- package/dist/client/static/js/info-A6RAGUB7-4pkzh1qx.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-ptg07tp2.js → infoDiagram-VRGFBTTK-1qj804sn.js} +1 -1
- package/dist/client/static/js/ini-j5dyq6gm.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-bdk2dkf5.js → ishikawaDiagram-OU5B5YK6-4j4qsnzw.js} +3 -3
- package/dist/client/static/js/java-g4dgwbfd.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-kez0ha4c.js → journeyDiagram-ZHPQQLJL-j0brnfft.js} +4 -4
- package/dist/client/static/js/json-j5q8nt57.js +1 -0
- package/dist/client/static/js/jsx-7t5ecz9s.js +1 -0
- package/dist/client/static/js/{julia-nmr85k8z.js → julia-4ghmfy3e.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-dhzp3qg5.js → kanban-definition-PNTS6WVX-qqc22br0.js} +3 -3
- package/dist/client/static/js/lua-1g6w30de.js +1 -0
- package/dist/client/static/js/markdown-afx21x8c.js +1 -0
- package/dist/client/static/js/{mermaid.core-h7wttbss.js → mermaid.core-vv3wbe65.js} +7 -7
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-tq5dd1em.js → mindmap-definition-NLK3R4M7-y5b2z8zp.js} +4 -4
- package/dist/client/static/js/one-dark-pro-hm3f56n1.js +1 -0
- package/dist/client/static/js/one-light-xrz49rct.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-yg71sp88.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-e5hrdfzv.js → pegDiagram-GJSIUBJH-0be07mqs.js} +1 -1
- package/dist/client/static/js/{perl-prxcva8r.js → perl-sd00t4b4.js} +1 -1
- package/dist/client/static/js/{php-m9kcctzs.js → php-2zfyqa61.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-89wd6np0.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-axvbvnz8.js → pieDiagram-5QR66LMP-544w86jk.js} +2 -2
- package/dist/client/static/js/properties-thd83wey.js +1 -0
- package/dist/client/static/js/python-264ns4xw.js +1 -0
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-wtn28cfm.js → quadrantDiagram-O4NWA36T-p09e7z5s.js} +4 -4
- package/dist/client/static/js/r-qw82kkv9.js +1 -0
- package/dist/client/static/js/radar-RG4KPBEZ-avn0b8r9.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-de27xv5w.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-rg4zzj7x.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-d84fhj8v.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-dvf8xrmc.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-avjkq945.js → railroadDiagram-XR7U4H2S-de830ed2.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-bntx7r6q.js → requirementDiagram-PLB6GJNP-b47d74p1.js} +4 -4
- package/dist/client/static/js/{ruby-t06c0e7g.js → ruby-v9qaqhby.js} +1 -1
- package/dist/client/static/js/{rust-6gqjxyf0.js → rust-fkt0qyrs.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-ps8nkdm2.js → sankeyDiagram-IPEJSGJF-6ezc2fpj.js} +5 -5
- package/dist/client/static/js/{sass-gsbyn3wh.js → sass-9bxped7y.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-3ckf1q6z.js → sequenceDiagram-PO4LG4MO-by5zqj6w.js} +18 -18
- package/dist/client/static/js/{sizeCapture-INFHLROL-akvcr1x7.js → sizeCapture-INFHLROL-q85r06j6.js} +1 -1
- package/dist/client/static/js/sql-g8wcshpc.js +1 -0
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-c82914fz.js → stateDiagram-v2-GCMORJYK-ep5pyexs.js} +3 -3
- package/dist/client/static/js/{svelte-j54gfrvq.js → svelte-mwtx07d9.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-scgdefh4.js → swimlanes-2SLR337P-95fcqkh8.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-xs2en5dv.js +8 -0
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-z2ha1rhq.js → timeline-definition-EJHVYXUP-461e615g.js} +2 -2
- package/dist/client/static/js/treeView-Q6P3EWNA-mham0bh6.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-mxrxax86.js +1 -0
- package/dist/client/static/js/tsx-nm94hed6.js +1 -0
- package/dist/client/static/js/typescript-0s2t05jj.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-3wdmrfmk.js → usecaseDiagram-POWQR4AR-ftqfnvhg.js} +38 -38
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-7m5tatzv.js → vennDiagram-UO4OBE2U-7t96h6ez.js} +7 -7
- package/dist/client/static/js/{vue-y8bb5f3h.js → vue-j8vb9d7r.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-8vrvh9p3.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-55ps9s4z.js → wardleyDiagram-VNRHLVJA-0de8w8c6.js} +4 -4
- package/dist/client/static/js/xml-dz51p1m3.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-8bsjtm4t.js → xychartDiagram-PMCCYNJV-dez9phkf.js} +5 -5
- package/dist/client/static/js/yaml-2cfkd30t.js +1 -0
- package/package.json +1 -1
- package/src/client/components/common/context-usage-button/McpSection.test.tsx +98 -0
- package/src/client/components/common/context-usage-button/McpSection.tsx +12 -5
- package/src/client/components/common/context-usage-button/SessionStats.tsx +80 -0
- package/src/client/components/common/context-usage-button/index.test.tsx +26 -0
- package/src/client/components/common/context-usage-button/index.tsx +36 -28
- package/src/client/components/common/harness-glyph/brands.ts +8 -0
- package/src/client/components/common/session-actions-menu/index.tsx +6 -1
- package/src/client/components/layout/session-sidebar/SessionsView.tsx +20 -33
- package/src/client/components/mobile/LayoutWrapper.tsx +28 -29
- package/src/client/components/mobile/mobile-right-sidebar/FullDiff.tsx +9 -2
- package/src/client/components/mobile/worktree-session.ts +4 -1
- package/src/client/components/settings/apply-side-effects.test.ts +11 -0
- package/src/client/components/settings/apply-side-effects.ts +7 -0
- package/src/client/components/settings/categories/ChatSettings.test.tsx +1 -1
- package/src/client/components/settings/categories/ChatSettings.tsx +2 -0
- package/src/client/components/settings/categories/NotificationSettings.tsx +1 -1
- package/src/client/components/settings/categories/chat-settings/ChangedFilesSection.tsx +79 -0
- package/src/client/components/settings/categories/chat-settings/groups.ts +4 -3
- package/src/client/components/workspace/chat-timeline/ChangedFilesSummary.tsx +101 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +16 -15
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +33 -1
- package/src/client/components/workspace/chat-timeline/RunFooter.tsx +21 -1
- package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +13 -0
- package/src/client/components/workspace/chat-timeline/fork-preview.test.tsx +11 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +1 -1
- package/src/client/components/workspace/diff-panel/Toolbar.tsx +17 -51
- package/src/client/components/workspace/diff-panel/index.tsx +23 -4
- package/src/client/components/workspace/diff-panel/toolbar-git-actions.tsx +94 -0
- package/src/client/components/workspace/editor/Body.tsx +2 -0
- package/src/client/data/settings/omp-schema.json +73 -3
- package/src/client/hooks/chat/btw/mode.ts +5 -1
- package/src/client/hooks/chat/omp/session-sidebar-controller.ts +9 -3
- package/src/client/hooks/chat/timeline/changed-files-setting.test.ts +31 -0
- package/src/client/hooks/chat/timeline/changed-files-setting.ts +60 -0
- package/src/client/hooks/chat/timeline/new-chat.ts +4 -1
- package/src/client/hooks/chat/timeline/pending-dispatch.ts +6 -10
- package/src/client/hooks/chat/timeline/session-changes.ts +51 -0
- package/src/client/hooks/chat/waiting/dispatch.ts +4 -1
- package/src/client/hooks/ui/notification-events.test.ts +3 -0
- package/src/client/hooks/ui/notification-events.ts +3 -1
- package/src/client/hooks/ui/notification-sound.ts +13 -6
- package/src/client/hooks/ui/ui-sounds.test.ts +15 -0
- package/src/client/hooks/workspace/batch-delete-run.ts +5 -1
- package/src/client/hooks/workspace/diff-file.ts +11 -4
- package/src/client/hooks/workspace/file-tabs.ts +13 -4
- package/src/client/hooks/workspace/journal-diff.ts +97 -0
- package/src/client/hooks/workspace/session-delete.ts +5 -1
- package/src/client/lib/notifications/native-banner-sound.test.ts +93 -0
- package/src/client/lib/notifications/native-banner-sound.ts +46 -0
- package/src/client/lib/notifications/os.test.ts +14 -5
- package/src/client/lib/notifications/os.ts +8 -0
- package/src/client/lib/router/branch-params.test.ts +62 -0
- package/src/client/lib/router/branch-params.ts +48 -0
- package/src/server/lib/assets/shell-settings.server.test.ts +35 -0
- package/src/server/lib/assets/shell-settings.server.ts +33 -0
- package/src/server/lib/harness/launch-table.ts +10 -0
- package/src/server/lib/omp/session/changes.test.ts +138 -0
- package/src/server/lib/omp/session/changes.ts +220 -0
- package/src/server/lib/omp/session/session-discovery.test.ts +4 -4
- package/src/server/lib/omp/session/sidebar-activity.server.test.ts +6 -2
- package/src/server/lib/omp/session/subagent-presence-scan.ts +54 -0
- package/src/server/lib/omp/session/subagent-presence-store.test.ts +1 -1
- package/src/server/lib/omp/session/subagent-presence.test.ts +115 -0
- package/src/server/lib/omp/session/subagent-presence.ts +12 -3
- package/src/server/lib/omp/session/telemetry/compute.ts +68 -0
- package/src/server/lib/omp/session/telemetry.test.ts +81 -0
- package/src/server/lib/realtime/topics/peer-relay.server.test.ts +1 -11
- package/src/server/plugins/ssr.ts +20 -8
- package/src/server/routes/sessions/changes.test.ts +90 -0
- package/src/server/routes/sessions/changes.ts +55 -0
- package/src/server/routes/sessions/index.ts +6 -0
- package/src/shared/lib/chat/duration.ts +34 -0
- package/src/shared/lib/chat/timeline/changed-files.test.ts +121 -0
- package/src/shared/lib/chat/timeline/changed-files.ts +71 -0
- package/src/shared/lib/chat/timeline/fork-anchor.test.ts +3 -0
- package/src/shared/lib/format/duration.test.ts +31 -0
- package/src/shared/lib/format/duration.ts +27 -0
- package/src/shared/lib/fs/unified-diff.test.ts +53 -0
- package/src/shared/lib/fs/unified-diff.ts +127 -0
- package/src/shared/lib/harness/brand-color.ts +3 -0
- package/src/shared/lib/harness/catalog.test.ts +13 -0
- package/src/shared/lib/harness/catalog.ts +8 -1
- package/src/shared/lib/harness/fork.ts +4 -2
- package/src/shared/lib/harness/mcp-facts.ts +3 -0
- package/src/shared/lib/harness/provider-facts.ts +14 -0
- package/src/shared/lib/harness/updates.ts +5 -0
- package/src/shared/lib/icons/tint-hues.generated.ts +27 -27
- package/src/shared/lib/omp/config/schema.test.ts +4 -2
- package/src/shared/lib/settings/defaults.ts +1 -0
- package/src/shared/lib/workspace/file-tab-id.ts +9 -0
- package/src/shared/types/context.ts +18 -0
- package/src/shared/types/fs.ts +21 -0
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/omp/session.ts +6 -0
- package/src/shared/types/session-changes.ts +58 -0
- package/src/shared/types/settings/state.ts +8 -0
- package/src/test-support/peer-harness.ts +13 -5
- package/dist/client/static/js/ImageView-ksx9bbct.js +0 -1
- package/dist/client/static/js/LayoutWrapper-9ftz050x.js +0 -2
- package/dist/client/static/js/Modal-f8x3j3be.js +0 -38
- package/dist/client/static/js/SessionsView-wzdf1cp6.js +0 -1
- package/dist/client/static/js/architecture-7GRP2DOG-4wsd6vk0.js +0 -1
- package/dist/client/static/js/bash-h6pkqvth.js +0 -1
- package/dist/client/static/js/c-thbdzmwv.js +0 -1
- package/dist/client/static/js/cpp-r1za1kke.js +0 -1
- package/dist/client/static/js/css-qsv4vvke.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-eycwde8c.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-srqbnmey.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-yj98317w.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-5jcrvn94.js +0 -1
- package/dist/client/static/js/graphql-275pg7ya.js +0 -1
- package/dist/client/static/js/index-b08zd4eq.js +0 -1
- package/dist/client/static/js/index-g0pkzanm.js +0 -2
- package/dist/client/static/js/index-ga2xdef3.js +0 -2
- package/dist/client/static/js/index-r416e9dt.js +0 -12
- package/dist/client/static/js/index-xzfsaqyz.js +0 -4
- package/dist/client/static/js/info-A6RAGUB7-mbt0ryx5.js +0 -1
- package/dist/client/static/js/ini-jqdrx98c.js +0 -1
- package/dist/client/static/js/java-70zqqrkr.js +0 -1
- package/dist/client/static/js/json-kxk8gfet.js +0 -1
- package/dist/client/static/js/jsx-h1035eqk.js +0 -1
- package/dist/client/static/js/lua-j2356waf.js +0 -1
- package/dist/client/static/js/markdown-ffw6rgk6.js +0 -1
- package/dist/client/static/js/one-dark-pro-8acf6cn2.js +0 -1
- package/dist/client/static/js/one-light-ysc1knem.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-a5yw789s.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-x0y4v4r2.js +0 -1
- package/dist/client/static/js/properties-55mrarxr.js +0 -1
- package/dist/client/static/js/python-dhypc3j4.js +0 -1
- package/dist/client/static/js/r-6b8dt1wp.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-trrc3ta1.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-dxgvx21w.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-rbgkd8sk.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-exgw7j47.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-28tpamzk.js +0 -1
- package/dist/client/static/js/sql-9dq913c8.js +0 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-0x2ashav.js +0 -8
- package/dist/client/static/js/treeView-Q6P3EWNA-1a00b6kc.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-2q4f2f7m.js +0 -1
- package/dist/client/static/js/tsx-wh5xgm7f.js +0 -1
- package/dist/client/static/js/typescript-ge85req5.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-x9v91the.js +0 -1
- package/dist/client/static/js/xml-7bgz40qa.js +0 -1
- package/dist/client/static/js/yaml-4ht9416k.js +0 -1
- package/src/client/components/layout/session-sidebar/new-session-context.test.ts +0 -55
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import{d,n,i,o,u,a,an,ua,Do,CA,e,w,s,li,B,ne,ze,La,En,An,m,qn,Fe,Wt,U,D,Qs,Kt,da,In,pa,Vt,xt,hr,f,I,se,ma,Hi,Or,Ki,ie,ft,Oa,he,Be,wt,Ge,Tt,tt,fe,De,$a,pe,ui,fa,$r,Ur,Xt,Yt,Aa,Ji,Ro,ga,Gr,Tn,Fo,Y,pi,ba,C,ct,F,mi,fi,lr,cr,Hn,Dt,Ie,jr,Oo,y,DA,zo,hp,$l,bp,QA,Wn,Zi,yp,W,NA,At,qr,ut,zl,va,Kn,le,nt,Uo,J,Qn,Nf,_e,Ve,ge,Ps,qo,sn,JA,ZA,Cp,Ep,XA,Bp,eg,Ip,_p,hi,tg,ng,Sp,Rf,Tp,ee,$t,zt,Me,no,Mp,og,sg,lg,cg,ug,dg,pg,Wl,mg,Lp,Pp,fg,Op,Ag,Kl,Nu,Hr,Vl,$p,yi,ro,Wr,ki,zp,Ru,Up,Lf,hg,bg,Pf,Gp,gt,Et,Us,yg,Of,Nn,Ho,Ua,Yl,qp,Wo,ht,wi,Hp,$f,kg,zf,Fu,Wp,Zl,xg,Kr,Xl,wg,Cg,Kp,Vp,Uf,Yp,Eg,Jp,Zp,Xp,je,ec,Ko,tc,Vo,js,nc,rc,ac,em}from"./index-y139vc12.js";import{yt,td,nd,rd,Oc,ad,id,al,Uc,is,il,uo}from"./index-g0pkzanm.js";import{Zr,ru,ys,vs,au,iu}from"./index-w5131mtt.js";import{sl,Ia,rA,aA,ll,iA,oA,bs}from"./index-w4re5r8w.js";var Vd={name:"sliders-vertical",size:24,node:[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]],aliases:["sliders"]},Mo=s(Vd);var Yd={name:"square-check-big",size:24,node:[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],aliases:["check-square"]},Eo=s(Yd);var Jd={name:"arrow-down-to-line",size:24,node:[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]},Je=s(Jd);var Xd={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]},Lo=s(Xd);var Qd={name:"bell-ring",size:24,node:[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]]},jo=s(Qd);var Zd={name:"calendar-range",size:24,node:[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M16 2v3",key:"otl347"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M17 13h-6",key:"1qbiup"}],["path",{d:"M13 17H7",key:"1x38vv"}],["path",{d:"M7 13h.01",key:"1vezk1"}],["path",{d:"M17 17h.01",key:"1sd3ek"}]]},$o=s(Zd);var oc={name:"cloud",size:24,node:[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]},Bo=s(oc);var ic={name:"compass",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]]},Ft=s(ic);var sc={name:"dice-5",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 16h.01",key:"18s6g9"}],["path",{d:"M16 16h.01",key:"1f9h7w"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]},_o=s(sc);var lc={name:"dollar-sign",size:24,node:[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]},Go=s(lc);var dc={name:"folder-git",size:24,node:[["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M14 13h3",key:"1dgedf"}],["path",{d:"M7 13h3",key:"1pygq7"}]]},Yo=s(dc);var cc={name:"folder-input",size:24,node:[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]},Jo=s(cc);var pc={name:"hammer",size:24,node:[["path",{d:"m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9",key:"1hayfq"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"15ts47"}]]},Xo=s(pc);var uc={name:"image",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]},Qo=s(uc);var mc={name:"key",size:24,node:[["path",{d:"m2 21 9.6-9.6",key:"9l79m3"}],["path",{d:"m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19",key:"fw8biw"}],["circle",{cx:"15.5",cy:"7.5",r:"5.5",key:"4wxmhb"}]]},lt=s(mc);var gc={name:"library",size:24,node:[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]},Zo=s(gc);var bc={name:"log-out",size:24,node:[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]},jt=s(bc);var fc={name:"log-in",size:24,node:[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]]},er=s(fc);var hc={name:"moon",size:24,node:[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]},Bt=s(hc);var vc={name:"pipette",size:24,node:[["path",{d:"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12",key:"1y3wsu"}],["path",{d:"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z",key:"110lr1"}],["path",{d:"m2 22 .414-.414",key:"jhxm08"}]]},tr=s(vc);var xc={name:"power",size:24,node:[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]},nr=s(xc);var kc={name:"store",size:24,node:[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]]},rt=s(kc);var yc={name:"sun",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]},_t=s(yc);var wc={name:"volume-2",size:24,node:[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]},Pn=s(wc);var Sc={name:"volume-x",size:24,node:[["path",{d:"M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z",key:"1p7khw"}],["path",{d:"m16.5 14.5 5-5",key:"cul3yw"}],["path",{d:"m16.5 9.5 5 5",key:"1akey5"}]]},or=s(Sc);var Nc={name:"waypoints",size:24,node:[["path",{d:"m10.586 5.414-5.172 5.172",key:"4mc350"}],["path",{d:"m18.586 13.414-5.172 5.172",key:"8c96vv"}],["path",{d:"M6 12h12",key:"8npq4p"}],["circle",{cx:"12",cy:"20",r:"2",key:"144qzu"}],["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}],["circle",{cx:"20",cy:"12",r:"2",key:"1xzzfp"}],["circle",{cx:"4",cy:"12",r:"2",key:"1hvhnz"}]]},Cn=s(Nc);function rr(t,r,l){let c={},b=typeof l==="function"?Object.keys(r):Object.keys(l);for(let p of b)if(r[p]!==t[p])c[p]=r[p];return c}var ir={theme:Ps,editorFont:Nu,editorTheme:Vl,autoSessionTitle:!0,soundAlerts:!0,chatCompletionSound:!0,notifyDesktopEnabled:!0,notifyMobileEnabled:!0,notifyOnFinish:!1,notifyOnAsk:!1,notifyOnError:!1,goalAuditEnabled:!0,goalAuditModel:"",goalDefaultBudget:null,chatWidthMode:Mp,toolRenderStyle:lg,sidebarStyle:rA,composerStyle:pg,surfaceStyle:Pp,iconStyle:Ep,followUpBehavior:"queue",keybindingSend:"Enter",keybindingNewLine:"Shift + Enter",keybindingSteering:"Ctrl / Cmd + Enter"};function ar(){let[t,r]=n(!1),l=a(async()=>{r(!0);try{let c=await fetch("/api/omp/reload-engine",{method:"POST"}),b=await c.json().catch(()=>null);if(!c.ok||!b?.success)return{ok:!1,message:b?.error??`Reload failed (HTTP ${c.status})`};yi(),Wr();let p=b.utility??0,g=b.prewarmed??0;return{ok:!0,message:p+g===0?"No standby omp processes were running — the next command starts the current build.":`Reloaded omp engine — ${p} utility, ${g} prewarmed process${p+g===1?"":"es"} recycled.`}}catch(c){return{ok:!1,message:c instanceof Error?c.message:"Failed to reload the omp engine."}}finally{r(!1)}},[]);return{isReloading:t,reload:l}}function sr(t={}){let{restart:r}=t,[l,c]=n(!1),b=a(async()=>{c(!0);try{let p=await Ru(r),g=await fetch("/api/console/restart",{method:"POST"}),h=await g.json().catch(()=>null);if(!g.ok||!h?.success)return{ok:!1,message:h?.error??`Restart failed (HTTP ${g.status})`};if(!h.restarting)return{ok:!1,message:h.message??"This instance cannot be restarted from the console."};let v=await Up(p,r);if(v==="restarted")return window.location.reload(),{ok:!0,message:h.message??"Restarting — this page reloads on its own."};if(v==="timeout")return{ok:!1,message:`The server did not come back within ${Math.round((r?.timeoutMs??zp)/1000)} seconds — reload this page once it is up.`};return{ok:!1,message:"The restart was cancelled."}}catch(p){return{ok:!1,message:p instanceof Error?p.message:"Failed to restart Kabmo."}}finally{c(!1)}},[r]);return{isRestarting:l,restart:b}}function dr(t,r){if(typeof document<"u"&&r.theme)Tp(r.theme);if(typeof window<"u"&&r.editorFont!==t.editorFont)window.dispatchEvent(new CustomEvent(Gp,{detail:r.editorFont}));if(typeof window<"u"&&r.editorTheme!==t.editorTheme)window.dispatchEvent(new CustomEvent(td,{detail:r.editorTheme}));if(r.chatWidthMode!==t.chatWidthMode)Lf(r.chatWidthMode);if(r.toolRenderStyle!==t.toolRenderStyle)hg(r.toolRenderStyle);if(r.sidebarStyle!==t.sidebarStyle)oA(r.sidebarStyle);if(r.composerStyle!==t.composerStyle)bg(r.composerStyle);if(r.surfaceStyle!==t.surfaceStyle)Pf(r.surfaceStyle);if(r.iconStyle!==t.iconStyle)Rf(r.iconStyle)}var pr=["KABMO","WORKSPACE","OMP","HARNESSES"];var ur=[{id:"appearance",label:"Appearance",icon:ga,section:"KABMO",description:"Custom themes, typography scale, and layout density."},{id:"chats",label:"Chats",icon:Xt,section:"KABMO",description:"Chat width, composer style, tool call rendering, session titles, and goal mode."},{id:"keyboard",label:"Keyboard",icon:fa,section:"KABMO",description:"Every command shortcut, the composer Enter keys, and chord conflicts."},{id:"notifications",label:"Notifications",icon:pa,section:"KABMO",description:"Completion sound, separate Desktop and Mobile delivery switches, and the finished, waiting-for-you and failed run triggers."},{id:"usage",label:"Usage",icon:li,section:"KABMO",description:"Build minutes quota, storage, and general usage."},{id:"token-usage",label:"Token Usage",icon:Ki,section:"KABMO",description:"Token telemetry, cache, and cost breakdown."},{id:"panel-plugins",label:"Plugins Kabmo",icon:pi,section:"KABMO",description:"Plugins installed into Kabmo: panels, background services, and the MCP servers they register."},{id:"projects",label:"Projects",icon:Yo,section:"WORKSPACE",description:"Workspace directories, roots, and ignored paths."},{id:"omp",label:"OMP Engine",icon:Oa,section:"OMP",description:"Live agent state and native omp config keys."},{id:"providers",label:"Providers",icon:Bo,section:"OMP",description:"AI model engines, endpoints, and credentials."},{id:"agents",label:"Agents",icon:xt,section:"OMP",description:"Autonomous agent persona, self-healing, and reasoning."},{id:"behavior",label:"Behavior",icon:Mo,section:"OMP",description:"Native AGENTS.md and RULES.md: global instructions, permission gates, and safety filters."},{id:"commands",label:"Commands",icon:Ie,section:"OMP",description:"Slash command macros and terminal shortcuts."},{id:"mcp",label:"MCP",icon:hr,section:"OMP",description:"Model Context Protocol servers and dynamic tools."},{id:"plugins",label:"Plugins",icon:Fo,section:"OMP",description:"Installed omp plugins, marketplaces, features, and plugin settings."},{id:"skills",label:"Skills",icon:Zo,section:"OMP",description:"Manage downloaded skills and scripts."},{id:"skills-catalog",label:"Skills Catalog",icon:Vt,section:"OMP",description:"Browse and install new skills."},...Of().map((t)=>({id:t.id,label:t.label,icon:Cn,section:"HARNESSES",...t.harness?{harness:t.harness}:{},description:t.description}))];function mr(t){let r=Of(t&&t.length>0?t:void 0).map((c)=>({id:c.id,label:c.label,icon:Cn,section:"HARNESSES",...c.harness?{harness:c.harness}:{},description:c.description}));return[...ur.filter((c)=>c.section!=="HARNESSES"),...r]}function Rn({activeCategory:t,onSelectCategory:r,searchQuery:l,onSearchChange:c,onReloadOmp:b,isReloading:p,onRestartKabmo:g,isRestarting:h,disabledHarnesses:v=[],categories:k=ur,className:x=""}){let A=k.filter((N)=>{if(N.harness&&v.includes(N.harness))return!1;if(!l.trim())return!0;let M=l.toLowerCase();return N.label.toLowerCase().includes(M)||N.section.toLowerCase().includes(M)||N.description.toLowerCase().includes(M)});return e("div",{className:`flex flex-col h-full bg-canvas border-r border-ink/10 text-ink select-none ${x}`,children:[e("div",{className:"p-3 border-b border-ink/10 flex-shrink-0",children:e("div",{className:"relative flex items-center",children:[e(F,{size:14,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",placeholder:"Search settings",value:l,onChange:(N)=>c(N.currentTarget.value),className:"w-full bg-paper border border-ink/15 rounded-lg pl-8 pr-7 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors"}),l&&e("button",{type:"button",onClick:()=>c(""),className:"absolute right-2 text-ink/40 hover:text-ink p-0.5",children:e(y,{size:12})})]})}),e("div",{className:"flex-1 scrollbar-overlay-container p-2 space-y-4",children:A.length===0?e("div",{className:"text-center py-8 text-xs text-ink/50 italic",children:"No matching settings found"}):pr.map((N)=>{let M=A.filter((P)=>P.section===N);if(M.length===0)return null;return e("div",{className:"space-y-1",children:[e("div",{className:"px-2.5 py-1 text-[10px] font-bold text-ink/40 tracking-wider font-mono uppercase",children:N}),e("div",{className:"space-y-0.5",children:M.map((P)=>{let E=P.icon,S=t===P.id;return e("button",{type:"button",onClick:()=>r(P.id),className:`w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-xs transition-all text-left ${S?"bg-ink/10 font-semibold text-ink shadow-2xs":"text-ink/75 hover:bg-ink/5 hover:text-ink"}`,children:[e("div",{className:"flex items-center space-x-2.5 truncate",children:[P.harness?e("span",{className:"flex w-[14px] shrink-0 items-center justify-center",children:e(gt,{harness:P.harness,size:14})}):e(E,{size:14,className:S?"text-ink":"text-ink/60"}),e("span",{className:"truncate",children:P.label})]}),P.badge&&e("span",{className:"px-1.5 py-0.2 text-[10px] font-mono font-medium rounded border border-warning/30 bg-warning/15 text-warning",children:P.badge})]},P.id)})})]},N)})}),e("div",{className:"p-2 border-t border-ink/10 flex-shrink-0 bg-canvas flex items-center gap-0.5",children:[e("button",{type:"button",onClick:b,disabled:p||h,title:"Recycle the standby omp processes so the next command uses the installed binary","aria-label":"Reload OMP",className:"shrink-0 flex items-center space-x-1 px-1 py-1.5 text-[11px] text-ink/75 hover:text-ink hover:bg-ink/5 rounded-lg transition-colors font-medium cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed",children:[e(C,{size:12,className:`shrink-0 ${p?"animate-spin text-warning":"text-ink/60"}`}),e("span",{className:"whitespace-nowrap",children:p?"Reloading…":"Reload OMP"})]}),e("button",{type:"button",onClick:g,disabled:p||h,title:"Stop and start this Kabmo instance","aria-label":"Restart Kabmo",className:"flex-1 min-w-0 flex items-center space-x-1 px-1 py-1.5 text-[11px] text-ink/75 hover:text-ink hover:bg-ink/5 rounded-lg transition-colors font-medium cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed",children:[e(nr,{size:12,className:`shrink-0 ${h?"animate-pulse text-warning":"text-ink/60"}`}),e("span",{className:"truncate",children:h?"Restarting…":"Restart Kabmo"})]})]})]})}function gr({theme:t,selected:r,onSelect:l}){return e("button",{type:"button",onClick:()=>l(t.id),"aria-pressed":r,className:`group flex w-full flex-col gap-2.5 rounded-lg border p-2.5 text-left transition-all cursor-pointer ${r?"border-ink bg-ink/5 ring-1 ring-ink/20":"border-ink/20 bg-paper hover:border-ink/40 hover:bg-ink/5"}`,children:[e("div",{className:"flex items-center gap-2",children:[e("span",{className:"truncate font-semibold text-ink",title:t.name,children:t.name}),e("span",{className:"shrink-0 rounded-full border border-ink/15 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:t.variant}),r&&e(f,{size:14,className:"ml-auto shrink-0 text-ink"})]}),e("div",{className:"flex items-center gap-1",children:ZA.map((c)=>e("span",{title:`${c.label} · ${t[c.key]}`,style:{backgroundColor:t[c.key]},className:"h-5 flex-1 rounded-[3px] border border-ink/10"},c.key))})]})}var Pc=[{id:"all",label:"All"},{id:"light",label:"Light"},{id:"dark",label:"Dark"}];function Cc(t){return t==="all"?qo:qo.filter((r)=>r.variant===t)}function br({selectedId:t,onSelect:r}){let[l,c]=n("all"),b=u(()=>Cc(l),[l]);return e("div",{className:"space-y-3 pb-6",children:[e("div",{className:"flex items-center gap-1.5",children:[Pc.map((p)=>e("button",{type:"button",onClick:()=>c(p.id),className:`rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors cursor-pointer ${l===p.id?"border-ink bg-ink text-paper":"border-ink/20 bg-paper text-ink/70 hover:border-ink/40 hover:text-ink"}`,children:[p.id==="light"&&e(_t,{size:11,className:"mr-1 inline align-[-1px]"}),p.id==="dark"&&e(Bt,{size:11,className:"mr-1 inline align-[-1px]"}),p.label]},p.id)),e("span",{className:"ml-auto font-mono text-[11px] text-ink/50",children:[b.length," themes"]})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2 lg:grid-cols-3",children:b.map((p)=>e(gr,{theme:p,selected:p.id===t,onSelect:r},p.id))})]})}function it({width:t,active:r=!1,trailing:l=!1}){return e("span",{className:"flex h-[9px] items-center gap-1 px-1",children:[e("span",{className:`h-[5px] w-[5px] shrink-0 rounded-full ${r?"bg-ink":"bg-ink/25"}`}),e("span",{className:`h-[3px] rounded-full ${r?"bg-ink/70":"bg-ink/25"}`,style:{width:`${t}%`}}),l&&e("span",{className:"ml-auto h-[3px] w-[6px] rounded-full bg-ink/20"})]})}function Tc(){return e("span",{className:"flex h-full flex-col gap-1 rounded-md border border-ink/10 bg-paper p-1","aria-hidden":"true",children:[e("span",{className:"flex items-center gap-0.5",children:[e("span",{className:"h-[7px] w-[30%] rounded-sm bg-ink/80"}),e("span",{className:"h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"}),e("span",{className:"h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"}),e("span",{className:"ml-auto h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"}),e("span",{className:"h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"})]}),e("span",{className:"flex h-[7px] items-center gap-1 px-1",children:e("span",{className:"h-[3px] w-[45%] rounded-full bg-ink/45"})}),e(it,{width:62,trailing:!0}),e(it,{width:50,active:!0,trailing:!0}),e(it,{width:44,trailing:!0}),e(it,{width:56,trailing:!0})]})}function Ic(){return e("span",{className:"flex h-full flex-col gap-1 rounded-md border border-ink/10 bg-paper p-1","aria-hidden":"true",children:[e("span",{className:"flex h-[7px] items-center rounded-sm bg-ink/5 px-1",children:e("span",{className:"h-[3px] w-[38%] rounded-full bg-ink/30"})}),e("span",{className:"flex items-center gap-0.5",children:[e("span",{className:"h-[6px] w-[16%] rounded-full bg-ink/80"}),e("span",{className:"h-[6px] w-[22%] rounded-full border border-ink/20"}),e("span",{className:"h-[6px] w-[12%] rounded-full border border-ink/20"})]}),e("span",{className:"flex h-[9px] items-center gap-1 px-1",children:[e("span",{className:"h-[5px] w-[5px] shrink-0 rounded-full bg-ink/50"}),e("span",{className:"h-[3px] w-[40%] rounded-full bg-ink/45"}),e("span",{className:"ml-auto h-[3px] w-[5px] rounded-full bg-ink/20"})]}),e(it,{width:62,active:!0,trailing:!0}),e(it,{width:50,trailing:!0}),e(it,{width:44,trailing:!0})]})}var Ac={classic:Tc,modern:Ic};function fr({settings:t,onUpdate:r}){let l=ll(t.sidebarStyle);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Session sidebar"}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:"How the left column draws its workspaces and chats. Both styles list the same workspaces and offer the same actions; the choice applies to desktop and phone, and takes effect immediately."})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",role:"group","aria-label":"Session sidebar style",children:aA.map((c)=>{let b=iA[c],p=c===l,g=Ac[c];return e("button",{type:"button",onClick:()=>r({sidebarStyle:c}),"aria-pressed":p,"aria-label":`${b.label} sidebar — ${b.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${p?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[86px]",children:e(g,{})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:b.label}),e("span",{className:"font-mono text-[10px] text-ink/40",children:b.caption}),p&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:b.description})]},c)})})]})}function vr({backdropFilter:t,reducedTransparency:r}){let l=[];if(!t)l.push("no-backdrop-filter");if(r)l.push("reduced-transparency");return l}var xr={"no-backdrop-filter":"This engine reports no backdrop blur, so the frost falls back to opaque panels here — the window keeps the glass colours but loses the blur.","reduced-transparency":"Your system asks apps to reduce transparency, so the frost is switched off. Turn that system setting off to see the glass material."};var kr="(prefers-reduced-transparency: reduce)";function Rc(){if(typeof CSS>"u"||typeof CSS.supports!=="function")return!1;return CSS.supports("backdrop-filter","blur(1px)")||CSS.supports("-webkit-backdrop-filter","blur(1px)")}function yr(){let[t,r]=n(()=>typeof window>"u"?!1:window.matchMedia(kr).matches);return i(()=>{let l=window.matchMedia(kr),c=()=>r(l.matches);return c(),l.addEventListener("change",c),()=>l.removeEventListener("change",c)},[]),vr({backdropFilter:Rc(),reducedTransparency:t})}function wr(){return e("span",{className:"flex h-full flex-col gap-1 p-1",children:[e("span",{className:"flex items-center gap-1",children:[e("span",{className:"h-[3px] w-[38%] rounded-full bg-ink/40"}),e("span",{className:"ml-auto h-[6px] w-[10%] rounded-[2px] border border-ink/20"})]}),e("span",{className:"h-[2px] w-full rounded-full bg-ink/15"}),e("span",{className:"flex items-center gap-1",children:[e("span",{className:"h-[3px] w-[52%] rounded-full bg-ink/30"}),e("span",{className:"h-[3px] w-[18%] rounded-full bg-ink/15"})]}),e("span",{className:"flex items-center gap-1",children:[e("span",{className:"h-[3px] w-[44%] rounded-full bg-ink/30"}),e("span",{className:"h-[3px] w-[22%] rounded-full bg-ink/15"})]})]})}function Mc(){return e("span",{className:"block h-full rounded-md border border-ink/15 bg-paper","aria-hidden":"true",children:[e("span",{className:"block h-[13px] rounded-t-[5px] border-b border-ink/10 bg-paper",children:e("span",{className:"mx-1 mt-[4px] block h-[3px] w-[40%] rounded-full bg-ink/35"})}),e(wr,{})]})}function Ec(){return e("span",{className:"relative block h-full overflow-hidden rounded-md border border-ink/15 bg-canvas","aria-hidden":"true",children:[e("span",{className:"pointer-events-none absolute inset-0",children:[e("span",{className:"absolute -left-2 top-2 h-[70%] w-[55%] rounded-full bg-info/40 blur-md"}),e("span",{className:"absolute -right-2 -top-2 h-[60%] w-[50%] rounded-full bg-meta/35 blur-md"}),e("span",{className:"absolute -bottom-2 right-3 h-[45%] w-[45%] rounded-full bg-success/30 blur-md"})]}),e("span",{className:"relative block h-[13px] border-b border-ink/10 bg-paper/40",children:e("span",{className:"mx-1 mt-[4px] block h-[3px] w-[40%] rounded-full bg-ink/40"})}),e("span",{className:"relative block h-[calc(100%-13px)] bg-paper/50",children:e(wr,{})})]})}var Lc={classic:Mc,glass:Ec};function Dc(){let t=yr();if(t.length===0)return null;return e("ul",{className:"space-y-1 rounded-lg border border-ink/15 bg-ink/[0.03] p-2.5","aria-live":"polite",children:t.map((r)=>e("li",{className:"flex gap-1.5 text-[11px] leading-relaxed text-ink/60",children:[e("span",{"aria-hidden":"true",className:"mt-[5px] h-1 w-1 shrink-0 rounded-full bg-ink/40"}),e("span",{children:xr[r]})]},r))})}function Sr({settings:t,onUpdate:r}){let l=Op(t.surfaceStyle);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Surfaces"}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:"What the windows are made of. Both styles draw the same panels, rows and dialogs; the frost is one blur pass per window, and it follows the palette — there is no separate glass colour to tune."})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",role:"group","aria-label":"Surface style",children:fg.map((c)=>{let b=Ag[c],p=c===l,g=Lc[c];return e("button",{type:"button",onClick:()=>r({surfaceStyle:c}),"aria-pressed":p,"aria-label":`${b.label} surfaces — ${b.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${p?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[78px]",children:e(g,{})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:b.label}),e("span",{className:"font-mono text-[10px] text-ink/40",children:b.caption}),p&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:b.description})]},c)})}),l==="glass"&&e(Dc,{})]})}function Fc(t){return sn(t).paper}function Mn({name:t,Icon:r,colored:l,paper:c}){let b=tg(t),p=!l?void 0:b?_p[b]:hi(ng(t),"light",c);return e(r,{size:13,strokeWidth:2,style:p?{color:p}:void 0,"aria-hidden":"true"})}function Nr({name:t,base:r,colored:l}){let c=l?r:void 0;return e("span",{className:"flex h-5 w-5 items-center justify-center rounded-[5px] border border-ink/10",style:c?{backgroundColor:`${c}22`,color:c}:void 0,title:t,"aria-hidden":"true",children:e("span",{className:`block h-2 w-2 rounded-full ${l?"":"bg-ink/60"}`,style:c?{backgroundColor:c}:void 0})})}function Pr({colored:t,paper:r}){return e("span",{className:"flex h-full items-center gap-1.5 rounded-md border border-ink/10 bg-canvas/60 px-2",children:[e(Mn,{name:"Trash2",Icon:U,colored:t,paper:r}),e(Mn,{name:"Check",Icon:f,colored:t,paper:r}),e(Mn,{name:"Sparkles",Icon:Fe,colored:t,paper:r}),e("span",{className:"mx-0.5 h-4 w-px bg-ink/10"}),e(Nr,{name:"claude",base:Ip.claude.light,colored:t}),e(Nr,{name:"Typescript",base:Sp.Typescript.light,colored:t})]})}function Cr({settings:t,onUpdate:r}){let l=Bp(t.iconStyle),c=Fc(t.theme),b={monochrome:()=>e(Pr,{colored:!1,paper:c}),color:()=>e(Pr,{colored:!0,paper:c})};return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Icons"}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:"Every icon: toolbar and panel glyphs, provider logos and file-type marks. Full colour gives each glyph its own hue and keeps the palette’s red, green, amber and blue for signals; a colour that would disappear on the active theme falls back to the ink. A control that sets its own colour keeps it."})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",role:"group","aria-label":"Icon style",children:XA.map((p)=>{let g=eg[p],h=p===l,v=b[p];return e("button",{type:"button",onClick:()=>r({iconStyle:p}),"aria-pressed":h,"aria-label":`${g.label} icons — ${g.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${h?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[42px]",children:e(v,{})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:g.label}),e("span",{className:"font-mono text-[10px] text-ink/40",children:g.caption}),h&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:g.description})]},p)})})]})}function Tr({settings:t,onUpdate:r}){let l=t.editorFont||Kl[0].id;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80 flex items-center gap-2",children:[e(jr,{size:16,className:"text-ink/60"}),"Editor Font"]}),e("p",{className:"text-[11px] text-ink/60 mt-1",children:"Typeface for the code editor and its line numbers, in both the desktop panel and the phone's full-screen editor. Only Fira Code ships with the app; the others are used when your device has them, and fall back to Fira Code when it does not."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:Kl.map((c)=>{let b=l===c.id;return e("button",{type:"button",onClick:()=>r({editorFont:c.id}),"aria-pressed":b,className:`flex items-center justify-between gap-3 rounded-lg border px-3 py-2 text-left transition-colors ${b?"border-ink/40 bg-ink/5":"border-ink/12 hover:bg-ink/5"}`,children:[e("span",{className:"min-w-0",children:[e("span",{className:"block truncate text-xs text-ink",style:{fontFamily:`"${c.id}", monospace`},children:"const greet = () => 'hi'"}),e("span",{className:"mt-0.5 flex items-center gap-1.5 text-[10px] text-ink/50",children:[e("span",{children:c.label}),c.bundled&&e("span",{className:"rounded bg-ink/8 px-1 py-px text-[10px] uppercase tracking-wide",children:"Bundled"})]})]}),b&&e(f,{size:14,className:"text-ink flex-shrink-0"})]},c.id)})})]})}var jc=[{id:"all",label:"All"},{id:"light",label:"Light"},{id:"dark",label:"Dark"}];function $c(t){return`"${Kl.find((l)=>l.id===t)?.id??Kl[0].id}", monospace`}function Bc({theme:t,face:r}){return e("span",{className:"block overflow-hidden rounded border border-ink/10",style:{backgroundColor:t.bg,color:t.fg},children:e("span",{className:"block px-1.5 py-1 font-mono text-[10px] leading-[1.4]",style:{fontFamily:r},children:[e("span",{style:{color:t.keyword},children:"const"})," ",e("span",{children:"answer"})," ",e("span",{style:{color:t.keyword},children:"="})," ",e("span",{style:{color:t.string},children:"42"}),e("span",{children:";"}),e("span",{className:"block truncate",style:{color:t.comment},children:["// ",t.label]})]})})}function Ir({settings:t,onUpdate:r}){let l=t.editorTheme||Hr,[c,b]=n("all"),p=$c(t.editorFont),g=u(()=>c==="all"?$p:$p.filter((h)=>h.variant===c),[c]);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80 flex items-center gap-2",children:[e(ga,{size:16,className:"text-ink/60"}),"Editor Theme"]}),e("p",{className:"text-[11px] text-ink/60 mt-1",children:["Colours for the code editor only — the console around it keeps the theme above. ",e("strong",{children:"Auto"})," ","follows the app palette; any other choice paints the editor's own surface, gutter, selection and syntax, and applies to every open editor without a reload."]})]}),e("div",{className:"flex items-center gap-1.5",children:[jc.map((h)=>e("button",{type:"button",onClick:()=>b(h.id),className:`rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors cursor-pointer ${c===h.id?"border-ink bg-ink text-paper":"border-ink/20 bg-paper text-ink/70 hover:border-ink/40 hover:text-ink"}`,children:[h.id==="light"&&e(_t,{size:11,className:"mr-1 inline align-[-1px]"}),h.id==="dark"&&e(Bt,{size:11,className:"mr-1 inline align-[-1px]"}),h.label]},h.id)),e("span",{className:"ml-auto font-mono text-[11px] text-ink/50",children:c==="all"?`${g.length} themes`:`${g.length} shown`})]}),e("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:[e("button",{type:"button",onClick:()=>r({editorTheme:Hr}),"aria-pressed":l===Hr,className:`flex w-full flex-col gap-2 rounded-lg border p-2 text-left transition-colors cursor-pointer ${l===Hr?"border-ink bg-ink/5 ring-1 ring-ink/20":"border-ink/20 bg-paper hover:border-ink/40 hover:bg-ink/5"}`,children:[e("span",{className:"flex items-center gap-2",children:[e("span",{className:"truncate font-semibold text-ink",children:"Auto"}),e("span",{className:"shrink-0 rounded-full border border-ink/15 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:"app palette"}),l===Hr&&e(f,{size:14,className:"ml-auto shrink-0 text-ink"})]}),e("span",{className:"flex h-8 items-center justify-center rounded border border-dashed border-ink/20 text-[10px] text-ink/50",children:"Follows the theme above"})]}),g.map((h)=>{let v=l===h.id;return e("button",{type:"button",onClick:()=>r({editorTheme:h.id}),"aria-pressed":v,className:`flex w-full flex-col gap-2 rounded-lg border p-2 text-left transition-colors cursor-pointer ${v?"border-ink bg-ink/5 ring-1 ring-ink/20":"border-ink/20 bg-paper hover:border-ink/40 hover:bg-ink/5"}`,children:[e("span",{className:"flex items-center gap-2",children:[e("span",{className:"truncate font-semibold text-ink",title:h.label,children:h.label}),e("span",{className:"shrink-0 rounded-full border border-ink/15 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:h.variant}),v&&e(f,{size:14,className:"ml-auto shrink-0 text-ink"})]}),e(Bc,{theme:h,face:p})]},h.id)})]})]})}function Ar({settings:t,onUpdate:r}){let l=W("editorIndentWidth"),c=typeof l==="number"&&rd.includes(l)?l:Oc.width,b=(p)=>{if(p===c)return;let g={...ad(),width:p};qr({editorIndentWidth:p,editorInsertSpaces:!0}),r((h)=>({...h})),window.dispatchEvent(new CustomEvent(nd,{detail:g}))};return e("section",{className:"space-y-3",children:e("div",{className:"flex items-center justify-between gap-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Editor indentation"}),e("p",{className:"text-[11px] text-ink/50 mt-0.5",children:"One level, in spaces. Enter, Tab and the auto-indent rules all use it."})]}),e("div",{className:"flex items-center gap-1",role:"group","aria-label":"Indentation width",children:rd.map((p)=>e("button",{type:"button",onClick:()=>b(p),"aria-pressed":p===c,"aria-label":`${p} spaces`,className:`px-2.5 py-1 rounded border text-[11px] font-mono transition-colors cursor-pointer ${p===c?"border-ink/40 bg-ink/10 text-ink":"border-ink/15 text-ink/60 hover:bg-ink/5 hover:text-ink"}`,children:p},p))})]})})}function Rr({label:t,hint:r,checked:l,onChange:c}){return e("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[e("span",{className:"min-w-0",children:[e("span",{className:"block text-xs text-ink",children:t}),e("span",{className:"block text-[11px] text-ink/50 mt-0.5",children:r})]}),e("input",{type:"checkbox",checked:l,onChange:(b)=>c(b.currentTarget.checked),"aria-label":t,className:`${ge} mt-0.5 accent-ink flex-shrink-0`})]})}function Mr({settings:t,onUpdate:r}){let l=Uc(),c=W("editorAutoCloseBrackets"),b=W("editorAutocomplete"),p=(g)=>{let h={...Uc(),...g};qr(g),r((v)=>({...v})),window.dispatchEvent(new CustomEvent(id,{detail:h}))};return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Editor typing"}),e("p",{className:"text-[11px] text-ink/50 mt-0.5",children:"Both change what typing does, which is why they are switches rather than always-on."})]}),e("div",{className:"space-y-2.5 rounded-lg border border-ink/10 p-3",children:[e(Rr,{label:"Auto-close brackets",hint:"Typing ( or { inserts the matching closer, and typing it again steps over it.",checked:typeof c==="boolean"?c:al.autoCloseBrackets,onChange:(g)=>p({editorAutoCloseBrackets:g})}),e(Rr,{label:"Suggest words from the file",hint:`Offers identifiers already near the caret (${l.autocomplete?"on":"off"}). Words only — this is not a language server.`,checked:typeof b==="boolean"?b:al.autocomplete,onChange:(g)=>p({editorAutocomplete:g})})]})]})}function Er({label:t,hint:r,checked:l,onChange:c}){return e("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[e("span",{className:"min-w-0",children:[e("span",{className:"block text-xs text-ink",children:t}),e("span",{className:"block text-[11px] text-ink/50 mt-0.5",children:r})]}),e("input",{type:"checkbox",checked:l,onChange:(b)=>c(b.target.checked),className:`${ge} mt-0.5 shrink-0 accent-ink`})]})}function Lr({settings:t,onUpdate:r}){let l=W("editorBlame"),c=W("editorBlameInline"),b=uo(),p=(g)=>{let h={...uo(),...g};qr(g),r((v)=>({...v})),window.dispatchEvent(new CustomEvent(is,{detail:h}))};return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Line blame"}),e("p",{className:"text-[11px] text-ink/50 mt-0.5",children:"Who last touched a line, and which commit. Read from git, so it needs a committed file."})]}),e("div",{className:"space-y-2.5 rounded-lg border border-ink/10 p-3",children:[e(Er,{label:"Show blame on hover",hint:"Hover a line number — or the label, when it is on — to see the author, the commit and the line's own history.",checked:typeof l==="boolean"?l:il.enabled,onChange:(g)=>p({editorBlame:g})}),e(Er,{label:"Show the label in the editor",hint:`Puts “author · age” at the end of each block. It costs horizontal room, so it is off on a narrow panel by default (${b.inline?"on":"off"}).`,checked:typeof c==="boolean"?c:il.inline,onChange:(g)=>p({editorBlameInline:g})})]})]})}function Dr({settings:t,onUpdate:r}){return e("div",{className:"w-full space-y-8 text-xs text-ink pb-3",children:[e("section",{className:"space-y-4",children:[e("div",{className:"flex items-center space-x-2 border-b border-ink/10 pb-2",children:[e(ga,{size:16,className:"text-ink/60"}),e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80",children:"Theme Preferences"})]}),e(br,{selectedId:t.theme,onSelect:(l)=>r({theme:JA(l)})})]}),e("section",{className:"space-y-4",children:[e("div",{className:"flex items-center space-x-2 border-b border-ink/10 pb-2",children:[e(qn,{size:16,className:"text-ink/60"}),e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80",children:"Layout"})]}),e(fr,{settings:t,onUpdate:r}),e(Sr,{settings:t,onUpdate:r}),e(Cr,{settings:t,onUpdate:r})]}),e(Tr,{settings:t,onUpdate:r}),e(Ir,{settings:t,onUpdate:r}),e(Ar,{settings:t,onUpdate:r}),e(Mr,{settings:t,onUpdate:r}),e(Lr,{settings:t,onUpdate:r})]})}function ke(){let[t,r]=n("list"),l=a(()=>r("detail"),[]),c=a(()=>r("list"),[]);return{pane:t,openDetail:l,back:c}}function ye({pane:t,onBack:r,list:l,detail:c,listLabel:b,className:p=""}){return e("div",{className:`flex-1 flex flex-col md:flex-row h-full w-full min-w-0 overflow-hidden bg-paper text-ink ${p}`,children:[e("div",{className:`${t==="list"?"flex":"hidden"} md:flex flex-1 md:flex-none md:w-auto min-h-0 min-w-0 flex-col`,children:l}),e("div",{className:`${t==="detail"?"flex":"hidden"} md:flex flex-1 min-h-0 min-w-0 flex-col`,children:[e("div",{className:"md:hidden flex items-center px-2 py-1 border-b border-ink/10 bg-canvas flex-shrink-0",children:e("button",{type:"button",onClick:r,"aria-label":`Back to ${b}`,className:"flex items-center gap-1 -ml-0.5 pl-0.5 pr-2 py-1 rounded-lg text-ink hover:bg-ink/5 active:bg-ink/10 transition-colors cursor-pointer",children:[e(ma,{size:18}),e("span",{className:"text-xs font-semibold truncate",children:b})]})}),c]})]})}function Fr({groups:t,activeGroupId:r,onSelectGroup:l}){return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0 select-none",children:[e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex items-center justify-between",children:e("span",{className:"text-xs font-semibold text-ink",children:[t.length," group",t.length===1?"":"s"]})}),e("div",{className:"flex-1 scrollbar-overlay-container p-1.5 text-xs",children:e("div",{className:"space-y-0.5",children:t.map((c)=>{let b=c.id===r,p=c.icon;return e("button",{type:"button",onClick:()=>l(c.id),"aria-current":b?"true":void 0,className:`w-full text-left px-2.5 py-2 rounded-lg transition-colors cursor-pointer flex flex-col gap-0.5 ${b?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e("span",{className:"flex items-center gap-1.5 min-w-0",children:[e("span",{"aria-hidden":!0,className:`w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0 ${b?"bg-ink/10 text-ink":"bg-ink/5 text-ink/70"}`,children:e(p,{size:12})}),e("span",{className:"font-semibold text-xs text-ink truncate",children:c.label})]}),e("span",{className:"text-[11px] text-ink/60 line-clamp-1 leading-snug pl-[26px]",children:c.hint})]},c.id)})})})]})}var St=[{id:"layout",label:"Layout",hint:"Chat width and composer shape",description:"How wide the conversation is drawn, and the shape of the box you type into.",icon:qn,sections:["width","composer"]},{id:"transcript",label:"Transcript",hint:"Tool calls and follow-up dispatch",description:"How a tool call is drawn, and what happens to a prompt sent while the agent is still running.",icon:$r,sections:["tool-calls","follow-up"]},{id:"sessions",label:"Sessions",hint:"Titles and goal mode",description:"How a session gets its name, and the defaults a new goal starts with.",icon:Xt,sections:["titles","goal"]}];var _c={compact:"60%",wide:"85%",full:"100%"};function Br({settings:t,onUpdate:r}){let l=t.chatWidthMode;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Chat Width"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"How wide the conversation is drawn. The composer follows the transcript, and no mode hides a panel."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",role:"group","aria-label":"Chat width",children:og.map((c)=>{let b=sg[c],p=l===c;return e("div",{onClick:()=>r({chatWidthMode:c}),role:"button",tabIndex:0,"aria-pressed":p,onKeyDown:(g)=>{if(g.key==="Enter"||g.key===" ")g.preventDefault(),r({chatWidthMode:c})},className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${p?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("span",{className:"font-semibold text-xs text-ink",children:b.label}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${p?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:p&&e(f,{size:10,strokeWidth:3})})]}),e("div",{"aria-hidden":!0,className:"h-1.5 rounded-full bg-ink/10 mb-2.5 overflow-hidden",children:e("div",{className:`h-full rounded-full ${p?"bg-ink":"bg-ink/35"}`,style:{width:_c[c]}})}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:b.description})]})},c)})}),e("p",{className:"text-[10px] text-ink/45 font-mono",children:"On a phone the column already fills the screen, so the mode has no visible effect."})]})}function _r({active:t=!1}){return e("span",{className:`h-[6px] w-[16px] rounded-sm border ${t?"border-ink/40 bg-ink/15":"border-ink/20 bg-ink/5"}`})}function Kc({hero:t=!1}){return e("span",{className:`flex flex-col gap-[3px] rounded-md border border-ink/15 bg-paper px-1.5 py-1 ${t?"flex-1 justify-center":""}`,children:[e("span",{className:"h-[2.5px] w-[72%] rounded-full bg-ink/25"}),e("span",{className:"h-[2.5px] w-[54%] rounded-full bg-ink/20"}),e("span",{className:"h-[2.5px] w-[30%] rounded-full bg-ink/15"})]})}function zc({rail:t=!1}){if(t)return e("span",{className:"flex items-center gap-1 border-t border-ink/10 px-1 pt-1 font-mono",children:[e("span",{className:"h-[2.5px] w-[14px] rounded-full bg-ink/30"}),e("span",{className:"h-[2.5px] w-[9px] rounded-full bg-ink/20"}),e("span",{className:"h-[2.5px] w-[11px] rounded-full bg-ink/20"}),e("span",{className:"ml-auto h-[7px] w-[7px] rounded-sm bg-ink/80"})]});return e("span",{className:"flex items-center gap-1 px-1",children:[e("span",{className:"h-[6px] w-[20px] rounded-sm bg-ink/15"}),e("span",{className:"h-[6px] w-[10px] rounded-sm bg-ink/10"}),e("span",{className:"ml-auto h-[7px] w-[7px] rounded-full border border-ink/25"}),e("span",{className:"h-[7px] w-[7px] rounded-sm bg-ink/80"})]})}var Hc={classic:"rounded-md bg-paper border-ink/10",calm:"rounded-lg bg-paper border-ink/10",console:"rounded-sm bg-paper border-ink/10",stage:"rounded-md bg-paper border-ink/15",glass:"rounded-xl border-ink/15 bg-gradient-to-b from-ink/[0.06] to-transparent"};function Wc({style:t}){let r=Lp({style:t,hero:t==="stage"});return e("span",{className:`flex h-full flex-col gap-1 border p-1 ${Hc[t]}`,"aria-hidden":"true",children:r.wire.map((l,c)=>l==="draft"?e(Kc,{hero:t==="stage"},c):l==="chip"?e("span",{className:"flex items-center gap-1 px-1",children:[e(_r,{active:t!=="calm"}),e(_r,{})]},c):e(zc,{rail:r.toolbarTone==="rail"},c))})}function zr({settings:t,onUpdate:r}){let l=Wl(t.composerStyle);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Composer"}),e("p",{className:"mt-0.5 text-[11px] text-ink/60",children:"The shape of the box you type into. Every style offers the same controls — attachments, plan and goal, access mode, model, thinking, voice, send — and only their order and frame change. Applies to desktop and phone, and takes effect immediately."})]}),e("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",role:"group","aria-label":"Composer style",children:dg.map((c)=>{let b=mg[c],p=c===l;return e("button",{type:"button",onClick:()=>r({composerStyle:c}),"aria-pressed":p,"aria-label":`${b.label} composer — ${b.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${p?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[92px]",children:e(Wc,{style:c})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:b.label}),p&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:b.description})]},c)})})]})}function Gc({mode:t}){if(t==="card")return e("div",{"aria-hidden":!0,className:"space-y-1 rounded-md border border-ink/15 bg-paper px-2 py-1.5",children:[e("div",{className:"flex items-center gap-1",children:[e("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/50"}),e("span",{className:"h-1 w-10 rounded-full bg-ink/35"}),e("span",{className:"ml-auto h-1 w-5 rounded-full bg-ink/20"})]}),e("div",{className:"h-1 w-16 rounded-full bg-ink/15"})]});if(t==="compact")return e("div",{"aria-hidden":!0,className:"space-y-1.5 rounded-md border border-transparent px-1 py-1",children:[0,1].map((r)=>e("div",{className:"flex items-center gap-1",children:[e("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/40"}),e("span",{className:"h-1 w-8 rounded-full bg-ink/30"}),e("span",{className:"ml-auto h-1 w-6 rounded-full bg-ink/15"})]},r))});if(t==="trace")return e("div",{"aria-hidden":!0,className:"relative ml-1 pl-3 py-1",children:[e("span",{className:"absolute left-[3px] top-1 bottom-1 w-px bg-ink/20"}),[0,1,2].map((r)=>e("div",{className:"flex items-center gap-1 py-0.5",children:[e("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/40"}),e("span",{className:"h-1 w-10 rounded-full bg-ink/25"})]},r))]});if(t==="tui")return e("div",{"aria-hidden":!0,className:"space-y-1 px-1 py-1 font-mono",children:[0,1].map((r)=>e("div",{className:"flex items-baseline gap-1",children:[e("span",{className:"text-[6px] text-success",children:"✔"}),e("span",{className:"h-1 w-3 rounded-full bg-info/70"}),e("span",{className:"h-1 w-6 rounded-full bg-meta/70"}),e("span",{className:"ml-auto h-1 w-2 rounded-full bg-ink/25"})]},r))});return e("div",{"aria-hidden":!0,className:"space-y-1.5 px-1 py-1",children:[e("div",{className:"h-1 w-20 rounded-full bg-ink/25"}),e("div",{className:"h-1 w-14 rounded-full bg-ink/15"})]})}function Vr({settings:t,onUpdate:r}){let l=t.toolRenderStyle;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Tool Calls"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"How a tool call is drawn in the transcript. Every style shows the same outcome, facts and body."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:cg.map((c)=>{let b=ug[c],p=l===c;return e("div",{onClick:()=>r({toolRenderStyle:c}),role:"button",tabIndex:0,"aria-pressed":p,onKeyDown:(g)=>{if(g.key==="Enter"||g.key===" ")g.preventDefault(),r({toolRenderStyle:c})},className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${p?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("span",{className:"font-semibold text-xs text-ink",children:b.label}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${p?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:p&&e(f,{size:10,strokeWidth:3})})]}),e("div",{className:"mb-2.5 h-12 rounded-md bg-canvas/50 px-1 py-1",children:e(Gc,{mode:c})}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:b.description})]})},c)})}),e("p",{className:"text-[10px] text-ink/45 font-mono",children:"The style is global: it applies to every session, and the composer keeps its own frame."})]})}function Yr({settings:t,onUpdate:r}){return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Follow-up Dispatch"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"Choose how new user prompts are handled while the AI agent is actively executing."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e("div",{onClick:()=>r({followUpBehavior:"queue"}),role:"button",tabIndex:0,onKeyDown:(l)=>l.key==="Enter"&&r({followUpBehavior:"queue"}),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${t.followUpBehavior==="queue"?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${t.followUpBehavior==="queue"?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e($r,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:"Queue Mode"})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:"Sequential"})]}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:"Messages wait in an execution queue and run in succession once current inference completes."})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50 text-[10px]",children:"Recommended for batch operations"}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${t.followUpBehavior==="queue"?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:t.followUpBehavior==="queue"&&e(f,{size:10,strokeWidth:3})})]})]}),e("div",{onClick:()=>r({followUpBehavior:"steering"}),role:"button",tabIndex:0,onKeyDown:(l)=>l.key==="Enter"&&r({followUpBehavior:"steering"}),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${t.followUpBehavior==="steering"?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${t.followUpBehavior==="steering"?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(Ft,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:"Steering Mode"})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:"Intervention"})]}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:"Immediately redirects current agent trajectory and focuses runtime resources onto the new instruction."})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50 text-[10px]",children:"Recommended for active debugging"}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${t.followUpBehavior==="steering"?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:t.followUpBehavior==="steering"&&e(f,{size:10,strokeWidth:3})})]})]})]})]})}var qc=[{enabled:!0,label:"Generate Automatically",badge:"Default",icon:Fe,description:`As soon as your first message lands, the session is named from it using omp's own tiny title model — retried once when the run ends if that first attempt came back empty. Sessions stop showing "New Session - <timestamp>" in the sidebar.`,note:"One small model call per session"},{enabled:!1,label:"Manual Only",badge:"Opt-out",icon:jr,description:"Sessions keep their timestamp placeholder until you rename them from the sidebar. Choose this when every title should be deliberate, or to avoid the extra model call.",note:"No background model calls"}];function Jr({settings:t,onUpdate:r}){let l=t.autoSessionTitle??!0;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Session Titles"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"How a session gets its display name. A name you set yourself is never replaced."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:qc.map(({enabled:c,label:b,badge:p,icon:g,description:h,note:v})=>{let k=l===c,x=()=>r({autoSessionTitle:c});return e("div",{onClick:x,role:"button",tabIndex:0,onKeyDown:(A)=>A.key==="Enter"&&x(),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${k?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${k?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(g,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:b})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:p})]}),e("p",{className:"text-[11px] text-ink/70 leading-relaxed",children:h})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50",children:v}),k&&e("span",{className:"flex items-center gap-1 text-ink font-medium",children:[e(f,{size:12})," Active"]})]})]},b)})})]})}var Vc="flex w-full min-w-0 items-center justify-between gap-2 rounded-md border border-ink/20 bg-paper px-2 py-1.5 text-left font-mono text-[11px] text-ink transition-colors hover:border-ink/40 focus:border-ink/50 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50";function Le({value:t,options:r,placeholder:l,ariaLabel:c,onChange:b,disabled:p,className:g,searchable:h=!0}){let[v,k]=n(null),[x,A]=n(""),[N,M]=n(0),P=o(null),E=o(null),S=o([]),R=o(`search-select-${Math.random().toString(36).slice(2,9)}`).current,T=r.find((G)=>G.value===t),O=v!==null,L=u(()=>{let G=x.trim();if(!G)return r;return r.filter((j)=>Wo(`${j.label} ${j.value} ${j.hint??""}`,G))},[r,x]),_=u(()=>{let G=[];for(let j of L){let H=j.group??"",X=G.find((oe)=>oe.name===H);if(X)X.rows.push(j);else G.push({name:H,rows:[j]})}return G},[L]),K=(G=!1)=>{if(k(null),A(""),G)P.current?.focus()},V=()=>{if(p||!P.current)return;let G=Math.max(0,r.findIndex((j)=>j.value===t));A(""),M(G),k($t(P.current))},z=(G)=>{if(G!==t)b(G);K(!0)};i(()=>{M(0)},[x]),i(()=>{if(!O)return;S.current[N]?.scrollIntoView({block:"nearest"})},[O,N]),i(()=>{if(O)E.current?.focus()},[O]);let q=(G)=>{if(G.key==="ArrowDown")G.preventDefault(),M((j)=>Math.max(0,Math.min(L.length-1,j+1)));else if(G.key==="ArrowUp")G.preventDefault(),M((j)=>Math.max(0,j-1));else if(G.key==="Home")G.preventDefault(),M(0);else if(G.key==="End")G.preventDefault(),M(Math.max(0,L.length-1));else if(G.key==="Enter"){G.preventDefault();let j=L[N];if(j)z(j.value)}};return e(d,{children:[e("button",{ref:P,type:"button",role:"combobox","aria-label":c,"aria-haspopup":"listbox","aria-expanded":O,"aria-controls":O?R:void 0,disabled:p,title:T?.label??l,onClick:()=>O?K():V(),onKeyDown:(G)=>{if(G.key==="ArrowDown"||G.key==="Enter"||G.key===" ")G.preventDefault(),V()},className:`${Vc} ${g??""}`,children:[e("span",{className:`truncate ${T?"":"text-ink/40"}`,children:T?.label??(t?`${t} (not listed)`:l)}),e(I,{size:12,className:`flex-shrink-0 text-ink/40 transition-transform ${O?"rotate-180":""}`})]}),e(zt,{anchor:v,align:"start",className:"w-72 max-w-[calc(100vw-2rem)] rounded-md border border-ink/15 bg-paper py-1 text-xs shadow-lg",...{"aria-label":c},onClose:()=>K(!0),children:e("div",{onKeyDown:q,children:[h&&e("div",{className:"flex items-center gap-1.5 border-b border-ink/10 px-2 py-1.5",children:[e(F,{size:11,className:"flex-shrink-0 text-ink/40"}),e("input",{ref:E,type:"text",value:x,"aria-label":`Search ${c}`,placeholder:"Search…",onInput:(G)=>A(G.currentTarget.value),className:"w-full min-w-0 bg-transparent text-xs text-ink outline-none placeholder:text-ink/35"})]}),e("div",{id:R,role:"listbox","aria-label":c,className:"max-h-56 overflow-y-auto py-1",children:[e("button",{type:"button",role:"option","aria-selected":t==="",ref:(G)=>{S.current[0]=G},onClick:()=>z(""),onMouseEnter:()=>M(0),className:`flex w-full items-center justify-between gap-2 px-3 py-1.5 text-left ${t===""?"text-ink":"text-ink/60"} hover:bg-ink/5`,children:[e("span",{className:"truncate italic",children:l}),t===""&&e(f,{size:11,className:"flex-shrink-0"})]}),t!==""&&!T&&e("button",{type:"button",role:"option","aria-selected":!0,onClick:()=>z(t),className:"flex w-full items-center justify-between gap-2 px-3 py-1.5 text-left text-ink",children:[e("span",{className:"truncate",children:[t," (not listed)"]}),e(f,{size:11,className:"flex-shrink-0"})]}),L.length===0?e("div",{className:"px-3 py-2 italic text-ink/40",children:["No match for “",x.trim(),"”"]}):_.map((G)=>e("div",{children:[G.name&&e("div",{className:"px-3 pb-0.5 pt-2 text-[9px] font-semibold uppercase tracking-wider text-ink/35",children:G.name}),G.rows.map((j)=>{let H=L.indexOf(j),X=j.value===t;return e("button",{type:"button",role:"option","aria-selected":X,ref:(oe)=>{S.current[H+1]=oe},onClick:()=>z(j.value),onMouseEnter:()=>M(H),title:j.hint??j.value,className:`flex w-full items-start justify-between gap-2 px-3 py-1.5 text-left transition-colors ${H===N?"bg-ink/5":""} ${X?"font-medium text-ink":"text-ink/75"}`,children:[e("span",{className:"min-w-0",children:[e("span",{className:"block truncate",children:j.label}),j.hint&&e("span",{className:"block truncate font-mono text-[10px] text-ink/40",children:j.hint})]}),X&&e(f,{size:11,className:"mt-0.5 flex-shrink-0"})]},j.value)})]},G.name||"__flat"))]})]})})]})}var Yc=[{enabled:!0,label:"Independent auditor",badge:"Default",description:"After every finished turn a separate model reads the objective and the agent's own report and decides: keep going, done, or needs you. Without it nothing advances a goal on its own.",note:"One extra model call per turn"},{enabled:!1,label:"Manual only",badge:"Opt-out",description:"Goals still exist — objective, pause, resume and the token budget all work — but the loop never continues by itself. Use it when a goal should only ever run the turns you ask for.",note:"No background model calls"}];function Xr({settings:t,onUpdate:r}){let l=Yl(),[c,b]=n([]),[p,g]=n(!0),h=t.goalAuditEnabled??!0,v=t.goalAuditModel??"",k=t.goalDefaultBudget??null,[x,A]=n(k===null?"":String(k));i(()=>{A(k===null?"":String(k))},[k]);let N=()=>{let M=qp(x);if(A(M===null?"":String(M)),M!==k)r({goalDefaultBudget:M})};return i(()=>{let M=!0;return ro().then((P)=>{if(!M)return;b(Array.isArray(P.modelList)?P.modelList.map((E)=>({id:E.id,name:E.name,provider:E.provider})):[])}).catch(()=>{}).finally(()=>{if(M)g(!1)}),()=>{M=!1}},[]),e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Goal Mode"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"A goal keeps a session working toward one objective until it is done, out of budget, or the auditor says it needs you."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Yc.map(({enabled:M,label:P,badge:E,description:S,note:R})=>{let T=h===M,O=()=>r({goalAuditEnabled:M});return e("div",{onClick:O,role:"button",tabIndex:0,onKeyDown:(L)=>L.key==="Enter"&&O(),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${T?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${T?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(fi,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:P})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:E})]}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:S})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50 text-[10px]",children:R}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${T?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:T&&e(f,{size:10,strokeWidth:3})})]})]},P)})}),h&&e("div",{className:"rounded-lg border border-ink/15 bg-paper p-3.5 space-y-3",children:e("div",{children:[e("label",{className:"mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:"Auditor model"}),e(Le,{ariaLabel:"Auditor model",value:v,onChange:(M)=>r({goalAuditModel:M}),disabled:p,placeholder:"Session model (default)",className:"w-full py-1.5 text-[11.5px]",options:c.map((M)=>({value:`${M.provider}/${M.id}`,label:M.name,hint:`${M.provider}/${M.id}`,group:Ho(M.provider,l)}))}),e("p",{className:"mt-1 text-[10.5px] text-ink/45",children:"The audit is a classification, not a task: it runs with thinking off, one small call per turn."})]})}),e("div",{className:"rounded-lg border border-ink/15 bg-paper p-3.5",children:[e("label",{className:"mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:[e(Ki,{size:11})," Default token budget"]}),e("div",{className:"flex items-center gap-2",children:[e("input",{value:x,onChange:(M)=>A(M.currentTarget.value),onBlur:N,onKeyDown:(M)=>{if(M.key==="Enter")N()},placeholder:"none: the turn ceiling is then the only stop",inputMode:"numeric","aria-label":"Default goal token budget",className:"w-56 rounded border border-ink/15 bg-paper px-2 py-1.5 font-mono text-[11.5px] outline-none focus:border-ink"}),e("span",{className:"text-[10.5px] text-ink/45",children:"New goals start with this budget; a goal you set explicitly keeps its own."})]})]}),e("div",{className:"flex items-start gap-2 rounded-lg border border-ink/10 bg-canvas/40 p-3 text-[11px] text-ink/60",children:[e(Dt,{size:12,className:"mt-0.5 shrink-0"}),e("span",{children:"The objective is set per goal from the composer's target button. The auditor judges progress from the objective and the agent's own report only — write an objective that says what finished looks like."})]})]})}var Jc={width:Br,composer:zr,"tool-calls":Vr,"follow-up":Yr,titles:Jr,goal:Xr};function Qr({settings:t,onUpdate:r}){let l=ke(),[c,b]=n(St[0].id),p=St.find((g)=>g.id===c)??St[0];return e(ye,{pane:l.pane,onBack:l.back,listLabel:"Chat settings",list:e(Fr,{groups:St,activeGroupId:p.id,onSelectGroup:(g)=>{b(g),l.openDetail()}}),detail:e("div",{className:"flex-1 h-full overflow-hidden flex flex-col text-xs text-ink",children:[e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex-shrink-0",children:[e("span",{className:"text-xs font-semibold text-ink/75",children:p.label}),e("p",{className:"text-[11px] text-ink/60 leading-snug mt-0.5",children:p.description})]}),e("div",{className:"flex-1 overflow-y-auto scrollbar-overlay-container p-3.5 space-y-7 pb-6",children:p.sections.map((g)=>{let h=Jc[g];return e(h,{settings:t,onUpdate:r},g)})})]})})}function ei(t){let r=new Map;for(let c of t){let b=kg(c.chord),p=r.get(b);if(p)p.push(c);else r.set(b,[c])}let l=[];for(let c of r.values())for(let b=0;b<c.length;b+=1)for(let p=b+1;p<c.length;p+=1){let g=c[b],h=c[p];if(g.command===h.command)continue;l.push({chord:g.chord,a:g,b:h,certain:!g.when||!h.when||g.when===h.when})}return l}var Xc={Shift:!0,Control:!0,Alt:!0,Meta:!0,OS:!0,Super:!0,Hyper:!0,CapsLock:!0,Fn:!0},Qc={ShiftLeft:!0,ShiftRight:!0,ControlLeft:!0,ControlRight:!0,AltLeft:!0,AltRight:!0,MetaLeft:!0,MetaRight:!0,OSLeft:!0,OSRight:!0,CapsLock:!0};function ti(t){return Xc[t.key]===!0||Qc[t.code]===!0}function ni({chord:t,onCommit:r}){let[l,c]=n(!1),[b,p]=n([]),g=o(null);i(()=>{if(l)g.current?.focus()},[l]);let h=()=>{c(!1),p([])},v=(x)=>{if(!l)return;if(x.preventDefault(),x.stopPropagation(),x.key==="Escape"){h();return}if(x.key==="Backspace"||x.key==="Delete"){if(b.length===0)r(null),h();else p([]);return}if(x.key==="Enter"&&b.length===1){r($f(b)),h();return}if(ti(x))return;let A=Hp(x);if(b.length===0){p([A]);return}r($f([b[0],A])),h()},k=l?b.length>0?`${wi(b,ht())} …`:"Press keys…":t||"Unassigned";return e("button",{ref:g,type:"button",onClick:()=>{c(!0),p([])},onBlur:()=>{if(l)h()},onKeyDown:v,"aria-label":l?"Recording shortcut, press keys":`Shortcut ${t||"unassigned"}, click to change`,className:`min-w-[7rem] px-2 py-1 rounded-md border text-[11px] font-mono transition-colors ${l?"border-ink/60 bg-ink/5 text-ink":"border-ink/20 text-ink/70 hover:border-ink/40 hover:text-ink"}`,children:k})}function oi(){let{commands:t,chords:r,rules:l}=Zl(),[c,b]=n(()=>Wp()),[p,g]=n(""),h=u(()=>ei(l),[l]),v=ht(),k=(P)=>t.find((E)=>E.id===P)?.title??P,x=(P,E)=>{let S={...c,[P]:E};b(S),Fu(S),zf(S)},A=(P)=>{let E={...c};delete E[P],b(E),Fu(E),zf(E)},N=p.trim().toLowerCase(),M=t.filter((P)=>!N||P.title.toLowerCase().includes(N)||(r.get(P.id)??"").toLowerCase().includes(N)).sort((P,E)=>P.category.localeCompare(E.category)||P.title.localeCompare(E.title));return e("section",{className:"space-y-3",children:[e("div",{className:"flex items-center justify-between gap-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Shortcuts"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"Click a chord to record a new one. Two strokes are allowed; Enter keeps a single stroke."})]}),e("div",{className:"flex items-center gap-2 px-2.5 py-1.5 border border-ink/15 rounded-md bg-canvas",children:[e(F,{size:13,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:p,onInput:(P)=>g(P.currentTarget.value),placeholder:"Filter","aria-label":"Filter shortcuts",className:"w-32 bg-transparent text-xs text-ink focus:outline-none placeholder-ink/40"})]})]}),h.length>0?e("div",{className:"border border-ink/15 rounded-lg p-3 space-y-1.5 bg-ink/[0.02]",children:[e("p",{className:"text-[11px] font-semibold text-ink/75",children:[h.length," chord ",h.length===1?"conflict":"conflicts"]}),h.map((P)=>e("p",{className:"text-[11px] text-ink/60",children:[e("span",{className:"font-mono text-ink/80",children:wi(P.chord,v)})," ","— ",k(P.a.command)," and ",k(P.b.command),P.certain?"":" (may not overlap)"]},`${P.a.command}-${P.b.command}`))]}):null,e("div",{className:"bg-paper border border-ink/15 rounded-lg divide-y divide-ink/10 shadow-xs overflow-hidden",children:M.length===0?e("p",{className:"px-3 py-4 text-center text-xs text-ink/50",children:"No command matches that filter."}):M.map((P)=>{let E=c[P.id]!==void 0;return e("div",{className:"px-3 py-2 flex items-center justify-between gap-3",children:[e("div",{className:"min-w-0",children:[e("div",{className:"text-xs font-medium text-ink truncate",children:P.title}),e("div",{className:"text-[10px] text-ink/45",children:[P.category,P.pluginId?` · ${P.pluginId}`:"",E?" · custom":""]})]}),e("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e(ni,{chord:r.get(P.id)??"",onCommit:(S)=>x(P.id,S)}),E?e("button",{type:"button",onClick:()=>A(P.id),title:"Reset to default","aria-label":`Reset ${P.title} to its default shortcut`,className:"p-1 rounded text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors",children:e(ct,{size:12})}):null]})]},P.id)})})]})}function ri({settings:t,onUpdate:r}){let l=["Enter","Shift + Enter","Ctrl / Cmd + Enter"],c=(p,g)=>{r((h)=>{let v={[p]:g},k=["keybindingSend","keybindingNewLine","keybindingSteering"].filter((x)=>x!==p);for(let x of k)if(h[x]===g)v[x]=h[p];return{...h,...v}})},b=[{id:"keybindingSend",label:"Send Message",desc:"Submit prompt and initiate agent reasoning",icon:ft,value:t.keybindingSend||"Enter"},{id:"keybindingNewLine",label:"Line Break",desc:"Insert newline inside input box without dispatching",icon:Wt,value:t.keybindingNewLine||"Shift + Enter"},{id:"keybindingSteering",label:"Steering Intervention",desc:"Send prompt with steering interruption priority",icon:Ft,value:t.keybindingSteering||"Ctrl / Cmd + Enter"}];return e("section",{className:"space-y-3",children:[e("div",{className:"flex items-center justify-between",children:[e("div",{className:"flex items-center gap-2",children:[e(fa,{size:15,className:"text-ink/70"}),e("h4",{className:"text-sm font-semibold text-ink",children:"Keyboard Shortcuts"})]}),e("span",{className:"text-[10px] text-ink/50 font-mono",children:"Auto-conflict resolution"})]}),e("div",{className:"bg-paper border border-ink/15 rounded-lg divide-y divide-ink/10 shadow-xs overflow-hidden",children:b.map((p)=>e("div",{className:"p-3.5 flex flex-col sm:flex-row sm:items-center justify-between gap-3 hover:bg-ink/[0.015] transition-colors",children:[e("div",{className:"flex items-start gap-3",children:[e("div",{className:"w-7 h-7 rounded-md bg-ink/5 flex items-center justify-center text-ink/70 flex-shrink-0 mt-0.5",children:e(p.icon,{size:14})}),e("div",{children:[e("div",{className:"font-semibold text-xs text-ink",children:p.label}),e("div",{className:"text-[11px] text-ink/60 mt-0.5",children:p.desc})]})]}),e("div",{className:"flex items-center gap-2 self-end sm:self-center",children:e("select",{value:p.value,onChange:(g)=>c(p.id,g.currentTarget.value),className:"bg-paper border border-ink/20 rounded-md px-2.5 py-1.5 outline-none focus:border-ink text-[11px] font-medium text-ink cursor-pointer hover:border-ink/40 transition-colors",children:l.map((g)=>e("option",{value:g,children:g},g))})})]},p.id))})]})}function ii({settings:t,onUpdate:r}){return e("div",{className:"flex-1 h-full overflow-y-auto scrollbar-overlay-container p-4 md:p-6 space-y-8 pb-8",children:[e(oi,{}),e(ri,{settings:t,onUpdate:r})]})}function ai({projects:t,selectedProjectId:r,onSelectProject:l,onAddProject:c,onTogglePin:b,isAdding:p=!1,folderFacts:g=[],loadError:h=null}){let v=new Map(g.map((k)=>[k.id,k.totalSessions]));return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0",children:[e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex items-center justify-between",children:[e("span",{className:"text-xs font-semibold text-ink",children:[t.length," project",t.length===1?"":"s"]}),e("button",{type:"button",onClick:c,disabled:p,"aria-label":"Add project",title:"Add project",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:e(Y,{size:15,strokeWidth:2.2})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-1.5 space-y-0.5",children:[h&&e("p",{className:"px-2 py-2 text-[11px] text-error",title:h,children:["Projects could not be read: ",h]}),!h&&t.length===0&&e("div",{className:"px-2 py-3 space-y-1.5",children:[e("p",{className:"text-[11.5px] text-ink/60",children:"No projects yet."}),e("button",{type:"button",onClick:c,className:"text-[11px] font-medium text-ink underline underline-offset-2 hover:no-underline cursor-pointer",children:"Add the first one"})]}),t.map((k)=>{let x=k.id===r,A=Kr(k.icon),N=k.folderId===void 0?void 0:v.get(k.folderId);return e("div",{className:`group flex items-center rounded-md transition-colors ${x?"bg-ink/10 shadow-2xs":"hover:bg-ink/5"}`,children:[e("button",{type:"button",onClick:()=>l(k.id),"aria-current":x?"true":void 0,className:"flex-1 min-w-0 flex items-center gap-2 px-2.5 py-1.5 text-left cursor-pointer",children:[k.customIconUrl?e("img",{src:k.customIconUrl,alt:"",className:"w-3.5 h-3.5 rounded-xs object-contain flex-shrink-0",referrerPolicy:"no-referrer"}):e(A,{size:14,className:"flex-shrink-0",style:{color:k.accentColor||"currentColor"}}),e("span",{className:`text-[11.5px] truncate flex-1 ${x?"font-medium text-ink":"text-ink/80"}`,children:k.name}),typeof N==="number"&&N>0&&e("span",{className:"shrink-0 font-mono text-[10px] text-ink/40",children:N})]}),e("button",{type:"button",onClick:()=>b(k),"aria-label":k.isPinned?`Unpin ${k.name}`:`Pin ${k.name}`,title:k.isPinned?"Unpin (stop sorting first)":"Pin (sort first in the sidebar)",className:`shrink-0 mr-1 p-1 rounded transition-colors cursor-pointer ${k.isPinned?"text-ink/70 hover:text-ink hover:bg-ink/10":"text-ink/30 hover:text-ink/70 hover:bg-ink/10 opacity-0 group-hover:opacity-100 focus-visible:opacity-100"}`,children:k.isPinned?e(Ia,{size:12}):e(sl,{size:12})})]},k.id)})]})]})}function si({project:t,canDelete:r,isDeleting:l=!1,onDelete:c}){return e("div",{className:"flex items-start justify-between gap-4 pb-4 border-b border-ink/10",children:[e("div",{className:"min-w-0 flex-1",children:[e("h2",{className:"text-xl font-bold tracking-tight text-ink truncate",children:t.name}),e("p",{className:"text-[11px] font-mono text-ink/50 truncate mt-0.5 select-all",children:t.path||"Not bound to a directory"})]}),r&&e("button",{type:"button",onClick:c,disabled:l,title:"Delete this project",className:"inline-flex items-center gap-1.5 shrink-0 px-2.5 py-1.5 text-[11px] font-medium text-ink/50 hover:text-error hover:bg-error/10 rounded-md transition-colors cursor-pointer disabled:opacity-50",children:[e(U,{size:13}),e("span",{children:"Delete"})]})]})}function di({name:t,disabled:r=!1,onCommit:l}){let[c,b]=n(t);return i(()=>{b(t)},[t]),e("div",{className:"space-y-2",children:[e("label",{htmlFor:"project-name-input",className:"block text-xs font-semibold text-ink",children:"Project name"}),e("input",{id:"project-name-input",type:"text",value:c,disabled:r,onChange:(g)=>b(g.currentTarget.value),onBlur:()=>{let g=c.trim();if(!g){b(t);return}if(g===t)return;l(g)},onKeyDown:(g)=>{if(g.key==="Enter")g.preventDefault(),g.currentTarget.blur();if(g.key==="Escape")b(t),g.currentTarget.blur()},placeholder:"Enter project name…",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-xs font-medium text-ink outline-none focus:border-ink/60 transition-colors shadow-2xs disabled:opacity-60"}),e("p",{className:"text-[11px] text-ink/50",children:"Names are unique: the sidebar identifies a project by it."})]})}function ci({path:t,disabled:r=!1,onCommit:l,onReveal:c,isRevealing:b=!1}){let[p,g]=n(t),[h,v]=n(!1);i(()=>{g(t)},[t]);let k=(x)=>{let A=x.trim();if(A===t)return;l(A)};return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("label",{htmlFor:"project-path-input",className:"block text-xs font-semibold text-ink",children:"Project directory"}),e("div",{className:"flex items-center gap-1",children:[e("button",{type:"button",onClick:()=>v(!0),disabled:r,className:"inline-flex items-center gap-1 px-2 py-1 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink transition-colors cursor-pointer disabled:opacity-50",children:[e(Tn,{size:11}),e("span",{children:"Browse…"})]}),e("button",{type:"button",onClick:c,disabled:r||!t||b,title:t?"Reveal in the file manager":"This project is not bound to a directory",className:"inline-flex items-center gap-1 px-2 py-1 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink transition-colors cursor-pointer disabled:opacity-40",children:[e(Tt,{size:11}),e("span",{children:"Reveal"})]})]})]}),e("input",{id:"project-path-input",type:"text",value:p,disabled:r,onChange:(x)=>g(x.currentTarget.value),onBlur:()=>k(p),onKeyDown:(x)=>{if(x.key==="Enter")x.preventDefault(),x.currentTarget.blur();if(x.key==="Escape")g(t),x.currentTarget.blur()},placeholder:"~ or /absolute/path, or leave empty for an unbound grouping",spellcheck:!1,className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-[11.5px] font-mono text-ink outline-none focus:border-ink/60 transition-colors shadow-2xs disabled:opacity-60"}),e("p",{className:"text-[11px] text-ink/50",children:t?"Sessions found under this directory appear in the project. One directory can belong to one project.":"Not bound to a directory: this project groups chats only and discovers no sessions."}),h&&e(bs,{initialPath:t||void 0,onSelect:(x)=>{v(!1),g(x),k(x)},onClose:()=>v(!1)})]})}function gi({model:t,models:r,onSelectModel:l,disabled:c=!1}){let[b,p]=n(!1),[g,h]=n(""),v=o(null);le(v,()=>p(!1));let k=Cg(t,r)??"Inherit Kabmo’s default",x=u(()=>{let N=g.trim().toLowerCase();if(!N)return r;return r.filter((M)=>M.name.toLowerCase().includes(N)||M.id.toLowerCase().includes(N)||M.provider.toLowerCase().includes(N))},[r,g]),A=(N)=>{l(N),p(!1),h("")};return e("div",{className:"space-y-2.5",children:[e("div",{className:"flex items-center gap-1.5",children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Defaults for new chats"}),e("span",{className:"inline-flex text-ink/40 hover:text-ink/70 transition-colors cursor-help",title:"The model a chat started in this project uses until you pick another one in the composer.",children:e(pe,{size:12})})]}),e("div",{className:"flex items-center justify-between gap-4 p-3 bg-paper border border-ink/15 rounded-lg",children:[e("div",{className:"min-w-0",children:[e("div",{className:"text-xs font-medium text-ink",children:"Project model"}),e("div",{className:"text-[11px] text-ink/50",children:r.length===0?"No model catalog yet — connect a provider first.":"Applied when the project starts a chat."})]}),e("div",{className:"relative shrink-0",ref:v,children:[e("button",{type:"button",onClick:()=>p((N)=>!N),disabled:c,className:"flex items-center gap-2 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs max-w-[248px] disabled:opacity-50",children:[e(Fe,{size:13,className:"text-ink/70 shrink-0"}),e("span",{className:"truncate",children:k}),e(I,{size:13,className:"text-ink/50 shrink-0"})]}),b&&e("div",{className:"glass-popover absolute right-0 mt-1 w-[288px] bg-paper border border-ink/15 rounded-lg shadow-xl z-50 overflow-hidden",children:[e("div",{className:"flex items-center gap-1.5 px-2.5 py-2 border-b border-ink/10",children:[e(F,{size:12,className:"text-ink/40 shrink-0"}),e("input",{autoFocus:!0,value:g,onInput:(N)=>h(N.currentTarget.value),placeholder:"Search models…",className:"flex-1 bg-transparent text-xs text-ink outline-none placeholder:text-ink/35"})]}),e("div",{className:"max-h-64 scrollbar-overlay-container py-1",children:[e("button",{type:"button",onClick:()=>A(Xl),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 text-left text-xs hover:bg-ink/5 transition-colors cursor-pointer",children:[e("span",{className:t===Xl?"font-semibold text-ink":"text-ink/80",children:"Inherit Kabmo’s default"}),t===Xl&&e(f,{size:13,className:"text-ink"})]}),x.length===0?e("p",{className:"px-3 py-2 text-[11px] text-ink/50",children:r.length===0?"The catalog is empty.":`No model matches “${g.trim()}”.`}):x.map((N)=>{let M=wg({provider:N.provider,modelId:N.id}),P=t===M;return e("button",{type:"button",onClick:()=>A(M),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 text-left hover:bg-ink/5 transition-colors cursor-pointer",children:[e("span",{className:"min-w-0 flex flex-col",children:[e("span",{className:`truncate text-xs ${P?"font-semibold text-ink":"text-ink/85"}`,children:N.name}),e("span",{className:"truncate text-[10.5px] text-ink/45",children:N.provider})]}),P&&e(f,{size:13,className:"text-ink shrink-0"})]},M)})]}),t!==Xl&&e("button",{type:"button",onClick:()=>A(Xl),className:"w-full flex items-center gap-1.5 px-3 py-2 border-t border-ink/10 text-[11px] text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:[e(y,{size:11}),e("span",{children:"Clear the project model"})]})]})]})]})]})}function bi({accentColor:t,onSelectColor:r,options:l=Uf,disabled:c=!1}){let b=l.length>0?l:Uf,p=t.trim().toLowerCase(),g=b.some((E)=>E.value!==""&&E.value.toLowerCase()===p),h=p!==""&&!g,v=Vp(p)??Kp,[k,x]=n(v);i(()=>x(v),[v]);let A=(E)=>{let S=Vp(E);if(S===null){x(v);return}if(x(S),S!==p)r(S)},N=o(null),M=o(null),P=o({commit:A,clear:()=>r("")});return P.current={commit:A,clear:()=>r("")},i(()=>{let E=N.current,S=M.current;if(!E||!S)return;let R=(_)=>x(_.target.value.toLowerCase()),T=(_)=>P.current.commit(_.target.value),O=()=>{let _=S.value.trim();if(_==="")P.current.clear();else P.current.commit(_)},L=(_)=>{if(_.key==="Enter")_.preventDefault(),O();if(_.key==="Escape")x(v)};return E.addEventListener("input",R),E.addEventListener("change",T),S.addEventListener("blur",O),S.addEventListener("keydown",L),()=>{E.removeEventListener("input",R),E.removeEventListener("change",T),S.removeEventListener("blur",O),S.removeEventListener("keydown",L)}},[v]),e("div",{className:"space-y-2.5",children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Accent colour"}),e("div",{className:"flex flex-wrap items-center gap-2.5",children:b.map((E)=>{let S=p===E.value.toLowerCase();if(E.value==="")return e("button",{type:"button",onClick:()=>r(""),disabled:c,"aria-label":"No accent colour","aria-pressed":S,title:"No accent colour",className:`w-7 h-7 rounded-full border flex items-center justify-center transition-all cursor-pointer disabled:opacity-50 ${S?"border-ink bg-ink/10 ring-2 ring-ink/30 ring-offset-2 ring-offset-paper":"border-ink/25 bg-paper hover:border-ink/50 text-ink/60"}`,children:e(y,{size:12,strokeWidth:2.2})},"none");return e("button",{type:"button",onClick:()=>r(E.value),disabled:c,"aria-label":E.label,"aria-pressed":S,title:E.label,style:{backgroundColor:E.bgHex},className:`w-7 h-7 rounded-full transition-all cursor-pointer shadow-2xs disabled:opacity-50 ${S?"ring-2 ring-ink ring-offset-2 ring-offset-paper scale-105":"hover:scale-105 opacity-90 hover:opacity-100"}`},E.value)})}),e("div",{className:"flex items-center gap-2 pt-0.5",children:[e("label",{title:"Pick a custom accent colour",className:`relative w-7 h-7 shrink-0 rounded-full border overflow-hidden cursor-pointer transition-all ${h?"ring-2 ring-ink ring-offset-2 ring-offset-paper":"border-ink/25 hover:border-ink/50"} ${c?"opacity-50 pointer-events-none":""}`,children:[e("span",{"aria-hidden":"true",className:"absolute inset-0",style:{backgroundColor:k}}),e(tr,{size:12,strokeWidth:2.2,"aria-hidden":"true",className:"absolute inset-0 m-auto text-white/90 mix-blend-difference pointer-events-none"}),e("input",{ref:N,type:"color",value:Vp(k)??Kp,disabled:c,"aria-label":"Custom accent colour",className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer"})]}),e("input",{ref:M,type:"text",value:k,disabled:c,spellcheck:!1,"aria-label":"Custom accent colour hex",placeholder:Kp,onInput:(E)=>x(E.currentTarget.value),className:"w-[86px] bg-paper border border-ink/20 rounded-md px-2 py-1 text-[11px] font-mono text-ink outline-none focus:border-ink/60 transition-colors disabled:opacity-50"}),e("span",{className:"text-[11px] text-ink/45",children:h?"Custom accent":"Pick any colour"})]})]})}var On=128,Zc=700000;async function ep(t){let r=Promise.withResolvers(),l=new FileReader;l.onload=(M)=>{let P=M.target?.result;if(typeof P==="string"&&P)r.resolve(P);else r.reject(Error("That file could not be read as an image."))},l.onerror=()=>r.reject(Error("That file could not be read as an image.")),l.readAsDataURL(t);let c=await r.promise;if(t.type==="image/svg+xml")return c;let b=Promise.withResolvers(),p=new Image;p.onload=()=>b.resolve(p),p.onerror=()=>b.reject(Error("That file is not an image Kabmo can read.")),p.src=c;let g=await b.promise,h=Math.min(1,On/Math.max(g.naturalWidth,g.naturalHeight)),v=Math.max(1,Math.round(g.naturalWidth*h)),k=Math.max(1,Math.round(g.naturalHeight*h)),x=document.createElement("canvas");x.width=v,x.height=k;let A=x.getContext("2d");if(!A)return c;A.drawImage(g,0,0,v,k);let N=x.toDataURL("image/png");return N.length>0&&N.length<c.length?N:c}function vi({currentIcon:t,customIconUrl:r,projectName:l,onSelectIcon:c,onSetCustomIcon:b,disabled:p=!1}){let g=o(null),[h,v]=n(!1),[k,x]=n(!1),[A,N]=n(null),M=async(S)=>{let R=S.currentTarget.files?.[0];if(S.currentTarget.value="",!R)return;N(null),x(!0);try{let T=await ep(R);if(T.length>Zc){N("That image is too detailed to store as a mark — try a PNG or SVG.");return}b(T)}catch(T){N(T instanceof Error?T.message:String(T))}finally{x(!1)}},P=()=>{let R=`https://api.dicebear.com/7.x/identicon/svg?seed=${l.toLowerCase().replace(/[^a-z0-9]/g,"")||"project"}&radius=50&size=${On}`;N(null),v(!0);let T=new Image;T.onload=()=>{v(!1),b(R)},T.onerror=()=>{v(!1),N("The generated icon could not be loaded — check your connection.")},T.src=R},E=p||k||h;return e("div",{className:"space-y-3",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Project icon"}),r&&e("button",{type:"button",onClick:()=>b(void 0),disabled:E,className:"text-[11px] text-ink/50 hover:text-error transition-colors cursor-pointer disabled:opacity-50",children:"Use a standard icon"})]}),e("div",{className:"flex flex-wrap gap-1.5",children:xg.map((S)=>{let R=!r&&t===S.id,T=S.icon;return e("button",{type:"button",onClick:()=>c(S.id),disabled:E,"aria-label":S.label,"aria-pressed":R,title:S.label,className:`w-7 h-7 rounded-md flex items-center justify-center transition-all cursor-pointer disabled:opacity-50 ${R?"border border-ink/40 bg-ink/5 text-ink shadow-2xs":"border border-transparent text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:e(T,{size:14,strokeWidth:1.8})},S.id)})}),e("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[e("input",{type:"file",ref:g,onChange:(S)=>void M(S),accept:"image/png,image/jpeg,image/svg+xml,image/webp,image/gif",className:"hidden"}),e("button",{type:"button",onClick:()=>g.current?.click(),disabled:E,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs disabled:opacity-50",children:[k?e(m,{size:13,className:"animate-spin text-ink/60"}):e(Oo,{size:13,className:"text-ink/60"}),e("span",{children:k?"Reading…":"Upload image"})]}),e("button",{type:"button",onClick:P,disabled:E,title:"Generate a stable identicon from the project name",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs disabled:opacity-50",children:[h?e(m,{size:13,className:"animate-spin text-ink/60"}):e(_o,{size:13,className:"text-ink/60"}),e("span",{children:h?"Generating…":"Generate mark"})]}),r&&e("div",{className:"flex items-center gap-2 ml-1 pl-2 border-l border-ink/10",children:[e("img",{src:r,alt:"Current custom icon",className:"w-5 h-5 rounded-xs object-contain border border-ink/15",referrerPolicy:"no-referrer"}),e("span",{className:"text-[11px] text-ink/60",children:"Custom icon in use"}),e("button",{type:"button",onClick:()=>b(void 0),disabled:E,"aria-label":"Remove the custom icon",className:"p-0.5 rounded text-ink/40 hover:text-error transition-colors cursor-pointer disabled:opacity-50",children:e(y,{size:12})})]})]}),e("p",{className:"text-[11px] text-ink/50",children:["Any image works — it is scaled down to a ",On,"px mark. PNG, JPEG, WebP, GIF or SVG."]}),A&&e("p",{className:"text-[11px] text-error",children:A})]})}function xi({project:t,canDelete:r,isDeleting:l=!1,isRevealing:c=!1,models:b,accentColorOptions:p,onUpdateField:g,onUpdateFields:h,onReveal:v,onDeleteProject:k}){return e("div",{className:"p-6 md:p-8 space-y-7",children:[e(si,{project:t,canDelete:r,isDeleting:l,onDelete:k}),e(di,{name:t.name,onCommit:(x)=>g("name",x)}),e(ci,{path:t.path,onCommit:(x)=>g("path",x),onReveal:v,isRevealing:c}),e(gi,{model:t.model,models:b,onSelectModel:(x)=>g("model",x)}),e(bi,{accentColor:t.accentColor,onSelectColor:(x)=>g("accentColor",x),...p&&p.length>0?{options:p}:{}}),e(vi,{currentIcon:t.icon,customIconUrl:t.customIconUrl,projectName:t.name,onSelectIcon:(x)=>h({icon:x,customIconUrl:void 0}),onSetCustomIcon:(x)=>h({customIconUrl:x,icon:x===void 0?"default":"custom"})})]})}function tp(t){return(t.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??"").toLowerCase()}function np({isSaving:t,onClose:r,onSubmit:l}){let[c,b]=n(""),[p,g]=n(""),[h,v]=n(!1),[k,x]=n(!0),[A,N]=n(null),M=(E)=>{if(g(E),k||!c.trim())b(tp(E)),x(!0)},P=async()=>{let E=c.trim();if(!E){N("Enter a project name.");return}N(null);try{await l({name:E,path:p.trim()}),r()}catch(S){N(S instanceof Error?S.message:String(S))}};return e(d,{children:e(J,{onClose:t?()=>{}:r,ariaLabel:"Add project",maxWidthClass:"max-w-[480px]",header:e("div",{className:"min-w-0",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Add project"}),e("p",{className:"text-[11px] text-ink/50",children:"A name, and the directory its chats run in."})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-5 py-3.5 border-t border-ink/10",children:[e("button",{type:"button",onClick:r,disabled:t,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:"Cancel"}),e("button",{type:"button",onClick:()=>void P(),disabled:t,className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 inline-flex items-center gap-1.5",children:[t&&e(m,{size:13,className:"animate-spin"}),e("span",{children:t?"Adding…":"Add project"})]})]}),children:[e("div",{className:"px-5 py-4 space-y-4",children:[e("div",{className:"space-y-1.5",children:[e("label",{htmlFor:"add-project-name",className:"block text-xs font-semibold text-ink",children:"Name"}),e("input",{id:"add-project-name",type:"text",value:c,onInput:(E)=>{b(E.currentTarget.value),x(!1)},placeholder:"e.g. kabmo",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-xs text-ink outline-none focus:border-ink/60 transition-colors"}),e("p",{className:"text-[11px] text-ink/50",children:"Unique: the sidebar identifies a workspace by it."})]}),e("div",{className:"space-y-1.5",children:[e("label",{htmlFor:"add-project-path",className:"block text-xs font-semibold text-ink",children:["Directory ",e("span",{className:"text-ink/40 font-normal",children:"(optional)"})]}),e("div",{className:"flex items-center gap-2",children:[e("input",{id:"add-project-path",type:"text",value:p,onInput:(E)=>g(E.currentTarget.value),placeholder:"~ or /absolute/path",spellcheck:!1,className:"flex-1 min-w-0 bg-paper border border-ink/20 rounded-md px-3 py-2 text-[11.5px] font-mono text-ink outline-none focus:border-ink/60 transition-colors"}),e("button",{type:"button",onClick:()=>v(!0),className:"shrink-0 inline-flex items-center gap-1 px-2.5 py-2 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink transition-colors cursor-pointer",children:[e(Tt,{size:12}),e("span",{children:"Browse…"})]})]}),e("p",{className:"text-[11px] text-ink/50",children:"Sessions under this directory are listed in the project. Leave it empty for a grouping with no directory behind it."})]}),A&&e("p",{className:"text-[11px] text-error",children:A})]}),h&&e(bs,{initialPath:p||void 0,onSelect:(E)=>{M(E),v(!1)},onClose:()=>v(!1)})]})})}function Si({isOpen:t,isSaving:r,onClose:l,onSubmit:c}){if(!t)return null;return e(np,{isSaving:r,onClose:l,onSubmit:c})}function Ni({project:t,isDeleting:r,error:l,onClose:c,onConfirm:b}){if(i(()=>{let p=(g)=>{if(g.key!=="Escape"||r)return;g.preventDefault(),c()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[c,r]),!t)return null;return e(J,{onClose:r?()=>{}:c,zClass:"z-[70]",maxWidthClass:"max-w-[440px]",ariaLabel:"Delete project",header:e("div",{className:"flex items-center gap-3 min-w-0",children:[e(U,{size:16,className:"text-error shrink-0"}),e("div",{className:"min-w-0",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Delete project?"}),e("p",{className:"text-[11px] text-ink/50 truncate",children:t.name})]})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-5 py-3.5 border-t border-ink/10",children:[e("button",{type:"button",onClick:c,disabled:r,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:"Cancel"}),e("button",{type:"button",onClick:b,disabled:r,className:"px-3.5 py-1.5 rounded-md bg-error text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:[r?e(m,{size:13,className:"animate-spin"}):e(U,{size:13}),e("span",{children:r?"Deleting…":"Delete project"})]})]}),children:e("div",{className:"px-5 py-4 space-y-3",children:[e("ul",{className:"text-[11.5px] leading-relaxed text-ink/70 space-y-1.5",children:[e("li",{children:"The workspace is unregistered from Kabmo — its place in the sidebar, its chats' grouping and its settings go."}),e("li",{children:t.path?"The directory itself is NOT deleted; a tombstone keeps omp discovery from re-adding it on the next boot.":"It has no directory, so nothing on disk is touched."}),e("li",{children:"Chat transcripts stay on disk under ~/.omp/agent/sessions."})]}),l&&e("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md border border-error/30 bg-error/5 text-[11px] text-ink/75",children:[e(D,{size:13,className:"mt-0.5 shrink-0 text-error"}),e("span",{children:l})]})]})})}var Ln="worktreeDirectory",Dn="worktreeCarryIgnored";function Pi(t){if(t.missing)return"folder is missing — its chats still open";let r=t.detached?`detached @ ${t.head.slice(0,7)||"unknown"}`:`${t.branch} checked out here`,l=t.sessions===1?"1 chat":`${t.sessions} chats`,c=t.dirty===0?"clean":`${t.dirty} changed`;return`${r} · ${l} · ${c}`}function Ci(t){return!t.detached&&Boolean(t.branch)&&t.aheadOfStart===0}function Un(t){if(t.isPrimary)return"The main checkout cannot be removed.";if(t.dirty>0)return`${t.dirty} uncommitted file${t.dirty===1?"":"s"} here would be lost.`;return null}function Ti({root:t,folderId:r,onReport:l}){let{worktrees:c,base:b,loading:p,error:g,isRepo:h,refresh:v}=Yp({root:t,folderId:r},Boolean(t)),[k,x]=n(()=>{let S=W(Ln);return typeof S==="string"?S:""}),[A,N]=n(()=>W(Dn)!==!1),[M,P]=n(null);if(!t)return e("p",{className:"text-xs text-ink/50",children:"Bind this workspace to a repository to manage its worktrees."});let E=c.filter((S)=>!S.isPrimary);return e("div",{className:"flex flex-col gap-4",children:[e("section",{className:"flex flex-col gap-1",children:[e("h3",{className:"text-xs font-semibold text-ink",children:"Worktrees"}),p&&e("p",{className:"text-[11px] text-ink/50",children:"Reading worktrees…"}),g&&e("p",{className:"text-[11px] text-error",title:g,children:["Worktrees could not be read: ",g]}),!p&&!g&&h===!1&&e("p",{className:"text-[11px] text-ink/50",children:"Worktrees need a Git repository."}),!p&&!g&&h!==!1&&E.length===0&&e("p",{className:"text-[11px] text-ink/50",children:"No worktrees yet."}),E.map((S)=>e("div",{className:"group flex items-center gap-2 rounded-md px-1 py-1.5 hover:bg-ink/5",children:[e("div",{className:"min-w-0 flex-1",children:[e("p",{className:"truncate text-xs text-ink",children:S.branch||"detached"}),e("p",{className:"truncate text-[10.5px] text-ink/50",title:S.path,children:Pi(S)})]}),e("button",{type:"button",disabled:M===S.path||Un(S)!==null,"aria-label":`Remove worktree ${S.branch||S.path}`,title:Un(S)??"Remove worktree",onClick:()=>{P(S.path),Eg({root:t,folderId:r},S.path,{deleteBranch:Ci(S)}).then((R)=>(l(R.branchDeleted?`Removed ${S.branch} and its branch`:`Removed ${S.branch}${R.branchKept?" (branch kept)":""}`,"success"),v())).catch((R)=>l(R instanceof Error?R.message:String(R),"error")).finally(()=>P(null))},className:"shrink-0 rounded px-2 py-1 text-[11px] text-ink/60 hover:bg-error/10 hover:text-error disabled:opacity-40",children:"Remove"})]},S.path))]}),e("label",{className:"flex flex-col gap-1",children:[e("span",{className:"text-xs font-semibold text-ink",children:"Worktree location"}),e("input",{value:k,onChange:(S)=>x(S.currentTarget.value),onBlur:()=>At(Ln,k.trim()),placeholder:b,className:"h-8 rounded-md border border-ink/15 bg-paper px-2 text-xs text-ink outline-none focus:border-ink/40"}),e("span",{className:"text-[10.5px] text-ink/50",children:["Where new worktrees are created. Relative paths are resolved against the project; ~ is your home directory. Empty uses ",b,"."]})]}),e("label",{className:"flex items-start gap-2",children:[e("input",{type:"checkbox",checked:A,onChange:(S)=>{let R=S.currentTarget.checked;N(R),At(Dn,R)},className:`${ge} mt-0.5`}),e("span",{className:"flex flex-col gap-0.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:"Copy ignored files into new worktrees"}),e("span",{className:"text-[10.5px] text-ink/50",children:"A new worktree gets the project's ignored build folders (node_modules, .venv, target) copied in, so it works without reinstalling."})]})]})]})}var op={full:"flex h-full w-full items-center justify-center text-xs text-ink/40",fill:"flex-1 flex items-center justify-center text-xs text-ink/40"},Ce=({variant:t="full",children:r})=>e("div",{className:op[t],children:r});var Ht="";function Ii(t){if(!w(t))return!1;return typeof t.id==="string"&&typeof t.name==="string"&&typeof t.path==="string"}function rp(t){if(!w(t))return!1;return typeof t.label==="string"&&typeof t.value==="string"&&typeof t.bgHex==="string"}function ip(t,r){return t.some((c)=>c.id===r.id)?t.map((c)=>c.id===r.id?r:c):[...t,r]}function Ai(t){let[r,l]=n([]),[c,b]=n([]),[p,g]=n(Ht),[h,v]=n(!0),[k,x]=n(null),[A,N]=n(!1),[M,P]=n(!1),E=o(t);E.current=t;let S=a((j)=>{if(!w(j))return;let H=Array.isArray(j.projects)?j.projects.filter(Ii):null;if(H)l(H),g((X)=>H.some((oe)=>oe.id===X)?X:H[0]?.id??Ht);if(Array.isArray(j.accentColorOptions))b(j.accentColorOptions.filter(rp))},[]),R=a(async()=>{try{let j=await fetch("/api/settings/projects"),H=await j.json();if(!j.ok){let X=w(H)&&typeof H.error==="string"?H.error:`HTTP ${j.status}`;x(X);return}x(null),S(H)}catch(j){x(j instanceof Error?j.message:String(j))}},[S]);i(()=>{let j=!0;return(async()=>{if(await R(),j)v(!1)})(),()=>{j=!1}},[R]);let T=je().folders,O=u(()=>T.map((j)=>`${j.id}:${j.name}:${j.model??""}:${j.icon??""}:${j.accentColor??""}:${j.project_path??""}:${j.isPinned?1:0}`).join("|"),[T]);i(()=>{if(!O)return;R()},[O,R]);let L=a(async(j,H)=>{if(j.folderId===void 0)return E.current("This project has no workspace row to save to."),!1;let X=r;l((te)=>te.map((Z)=>Z.id===j.id?{...Z,...H}:Z));let oe={folderId:j.folderId};for(let[te,Z]of Object.entries(H))oe[te]=Z===void 0?null:Z;try{let te=await fetch("/api/settings/projects",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:oe})}),Z=await te.json().catch(()=>null);if(!te.ok){let re=w(Z)&&typeof Z.error==="string"?Z.error:`HTTP ${te.status}`;throw Error(re)}let Q=w(Z)&&Ii(Z.project)?Z.project:null;if(Q)l((re)=>ip(re,Q));return!0}catch(te){return l(X),E.current(te instanceof Error?te.message:String(te)),!1}},[r]),_=a((j,H,X)=>L(j,{[H]:X}),[L]),K=a((j,H)=>L(j,H),[L]),V=a(async(j)=>{N(!0);try{let H=await fetch("/api/folders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j.name,path:j.path})}),X=await H.json().catch(()=>null),oe=w(X)?X.folder:null,te=w(oe)&&typeof oe.id==="number"?oe.id:null;if(!H.ok||!w(X)||X.success!==!0||te===null){let Z=w(X)&&typeof X.error==="string"?X.error:`HTTP ${H.status}`;throw Error(Z)}await R(),g(`folder-${te}`)}catch(H){throw E.current(H instanceof Error?H.message:String(H)),H}finally{N(!1)}},[R]),z=a(async(j)=>{P(!0);try{let H=await fetch(`/api/settings/projects?id=${encodeURIComponent(j.id)}`,{method:"DELETE"}),X=await H.json().catch(()=>null);if(!H.ok||!w(X)||X.success!==!0){let oe=w(X)&&typeof X.error==="string"?X.error:`HTTP ${H.status}`;throw Error(oe)}l((oe)=>{let te=oe.filter((Z)=>Z.id!==j.id);return g((Z)=>Z===j.id?te[0]?.id??Ht:Z),te})}catch(H){throw E.current(H instanceof Error?H.message:String(H)),H}finally{P(!1)}},[]),q=Ua((j)=>Array.isArray(j.modelList)&&j.modelList.length>0?j.modelList.map((H)=>({provider:H.provider,id:H.id,name:H.name||H.id})):void 0)??[],G=r.find((j)=>j.id===p)??r[0]??null;return{projects:r,selected:G,selectedId:G?.id??Ht,select:g,accentColorOptions:c,models:q,isLoading:h,loadError:k,refresh:R,updateField:_,updateFields:K,isAdding:A,addProject:V,isDeleting:M,deleteProject:z,onError:t}}function Ri(){let t=ke(),{pushToast:r}=Ve(),[l,c]=n(!1),[b,p]=n(null),[g,h]=n(null),[v,k]=n(null),x=Ai((E)=>r(E,"error",{duration:7000})),{folders:A}=je(),N=async(E)=>{if(!E.path||E.folderId===void 0){r("This project is not bound to a directory.","error");return}k(E.id);try{let S=await fetch(`/api/folders/${E.folderId}/open`,{method:"POST"}),R=await S.json().catch(()=>null);if(!S.ok){let T=R&&typeof R==="object"&&"error"in R&&typeof R.error==="string"?R.error:`HTTP ${S.status}`;throw Error(T)}}catch(S){r(S instanceof Error?S.message:String(S),"error")}finally{k(null)}},M=async()=>{if(!b)return;h(null);try{await x.deleteProject(b),p(null),t.back()}catch(E){h(E instanceof Error?E.message:String(E))}};if(x.isLoading)return e(Ce,{children:"Loading projects…"});let P=x.selected;return e("div",{className:"w-full h-full flex flex-col overflow-hidden bg-paper text-ink",children:[e(ye,{pane:t.pane,onBack:t.back,listLabel:"Projects",list:e(ai,{projects:x.projects,selectedProjectId:P?.id??"",onSelectProject:(E)=>{x.select(E),t.openDetail()},onAddProject:()=>c(!0),onTogglePin:(E)=>{x.updateField(E,"isPinned",!E.isPinned)},isAdding:x.isAdding,folderFacts:A,loadError:x.loadError}),detail:P?e("div",{className:"flex-1 min-h-0 scrollbar-overlay-container flex flex-col",children:[e(xi,{project:P,canDelete:x.projects.length>1,isDeleting:x.isDeleting&&b?.id===P.id,isRevealing:v===P.id,models:x.models,accentColorOptions:x.accentColorOptions,onUpdateField:(E,S)=>{x.updateField(P,E,S)},onUpdateFields:(E)=>{x.updateFields(P,E)},onReveal:()=>void N(P),onDeleteProject:()=>{h(null),p(P)}}),e("div",{className:"border-t border-ink/10 px-6 md:px-8 py-4",children:e(Ti,{root:P.path||null,folderId:P.folderId??null,onReport:(E,S)=>r(E,S??"success",{duration:6000})})})]}):e("div",{className:"flex-1 flex items-center justify-center px-6 text-center",children:e("div",{className:"space-y-2",children:[e("p",{className:"text-xs text-ink/60",children:"No project selected."}),e("button",{type:"button",onClick:()=>c(!0),className:"text-[11px] font-medium text-ink underline underline-offset-2 hover:no-underline cursor-pointer",children:"Add a project"})]})})}),e(Si,{isOpen:l,isSaving:x.isAdding,onClose:()=>c(!1),onSubmit:async(E)=>{await x.addProject(E),t.openDetail()}}),e(Ni,{project:b,isDeleting:x.isDeleting,error:g,onClose:()=>{p(null),h(null)},onConfirm:()=>void M()})]})}function Mi(t){return t!==void 0&&(t.status==="connected"||Boolean(t.baseUrl))}function Ei(t){return t.filter((r)=>r.slug.trim().length>0&&Mi(r)).map((r)=>r.slug)}function Oi(t,r){let l=new Map;for(let p of t){let g=p.slug.trim().toLowerCase();if(g)l.set(g,p)}let c=new Set,b=[];for(let p of r){let g=p.slug.trim().toLowerCase();if(c.has(g))continue;if(!p.bundled&&Mi(l.get(g)))continue;c.add(g),b.push(p)}return b}function Li(t){let r=[];for(let l of t){let c=r.find((b)=>b.group===l.group);if(c)c.options.push(l);else r.push({group:l.group,options:[l]})}return r}var Di="/api/settings/providers";async function Ui(t){let r=await fetch(Di,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json();if(!r.ok)throw Error(l?.error||`Providers request failed (HTTP ${r.status})`);return Wr(),Array.isArray(l.providers)?l.providers:null}function Fi(t){return Ui({providers:t})}function ji(t,r){return Ui(r?{enableProvider:t}:{disableProvider:t})}async function $i(t,r){try{let l=await fetch("/api/settings/provider-entry",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:t,...r})}),c=await l.json();if(!l.ok)return{ok:!1,error:c.error??c.reason??`HTTP ${l.status}`};return Wr(),{...c,ok:!0}}catch(l){return{ok:!1,error:l instanceof Error?l.message:"Network error while saving the provider"}}}async function Bi(t,r){try{let l=await fetch("/api/provider-icon",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:t,baseUrl:r})}),c=await l.json();if(!l.ok)return{ok:!1,error:c.error??`HTTP ${l.status}`};return c}catch(l){return{ok:!1,error:l instanceof Error?l.message:"Network error while fetching the icon"}}}async function _i(t){try{let r=await fetch("/api/settings/providers/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{slug:t}:{})}),l=await r.json();if(!r.ok)return{ok:!1,added:0,removed:0,changed:[],error:l.error??`HTTP ${r.status}`};return Wr(),l}catch(r){return{ok:!1,added:0,removed:0,changed:[],error:r instanceof Error?r.message:"Network error while refreshing models"}}}async function zi(t){try{let r=await fetch(`${Di}?id=${encodeURIComponent(t)}`,{method:"DELETE"}),l=await r.json();if(!r.ok)return{ok:!1,error:l?.error||`Delete failed (HTTP ${r.status})`};return Wr(),{...l,ok:!0}}catch(r){return{ok:!1,error:r instanceof Error?r.message:"Network error while deleting the provider"}}}function Wi(t,r){if(t.modelSource==="discovery")return{text:`${t.name} registered — omp discovers its models on each run.`,tone:"success"};if(t.modelSource==="override")return{text:`${t.name} endpoint registered — omp keeps its own model list for this provider.`,tone:"success"};if(r.fetchedCount>0)return{text:`Fetched ${r.fetchedCount} new model${r.fetchedCount===1?"":"s"} from the provider.`,tone:"success"};if(r.fetchedCount===-1)return{text:r.ompNote?`Provider registered, but models could not be listed: ${r.ompNote}`:"Auto-fetch models failed — provider added with default models.",tone:"warning"};return{text:`${t.name} registered — no new models to add.`,tone:"success"}}function Gi(t){let r=(l)=>l===1?"":"s";if(t.addedCount>0&&t.removedCount>0)return{text:`Fetched ${t.addedCount} new model${r(t.addedCount)} and removed ${t.removedCount} the provider no longer serves.`,tone:"success"};if(t.addedCount>0)return{text:`Fetched ${t.addedCount} new model${r(t.addedCount)} from the provider.`,tone:"success"};if(t.removedCount>0)return{text:`Removed ${t.removedCount} model${r(t.removedCount)} the provider no longer serves.`,tone:"success"};return{text:"Models refreshed — the list already matches the provider.",tone:"success"}}function qi(t){if(!t.omp)return null;if(t.omp.written){let r=[];if(t.omp.addedCount>0)r.push(`${t.omp.addedCount} new model${t.omp.addedCount===1?"":"s"} registered`);if(t.omp.backfilledCount>0)r.push(`${t.omp.backfilledCount} model${t.omp.backfilledCount===1?"":"s"} enriched`);if((t.omp.removedCount??0)>0)r.push(`${t.omp.removedCount} model${t.omp.removedCount===1?"":"s"} removed`);return{text:`omp models.yml updated${r.length>0?`: ${r.join(", ")}`:""}.`,tone:"success"}}if(t.omp.reason)return{text:`omp models.yml not updated: ${t.omp.reason}`,tone:"warning"};return null}function Vi(t,r){let l=(c)=>c===1?"":"s";if(r.added>0||r.removed>0){let c=[];if(r.added>0)c.push(`${r.added} new model${l(r.added)}`);if(r.removed>0)c.push(`${r.removed} model${l(r.removed)} gone`);return{text:`${t}: ${c.join(", ")} after omp re-ran discovery.`,tone:"success"}}return{text:`${t}: omp re-ran discovery — this provider's list is unchanged.`,tone:"success"}}async function dt(){try{let r=await(await fetch("/api/settings/providers")).json();if(!Array.isArray(r?.providers))return null;return{providers:r.providers,...r.presetProviders?{presetProviders:r.presetProviders}:{},...typeof r.catalogError==="string"?{catalogError:r.catalogError}:{}}}catch(t){return console.error("Failed to load providers from API:",t),null}}async function Yi(t,r,l){let c={provider:t,modelId:r};if("maxTokens"in l)c.maxTokens=l.maxTokens??null;if("reasoningEffort"in l)c.reasoningEffort=l.reasoningEffort??null;if(Object.keys(c).length===2)return{ok:!0,written:!1};try{let b=await fetch("/api/settings/model-override",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),p=await b.json();if(!b.ok)return{ok:!1,error:p.error||"Failed to save the model configuration."};return{ok:!0,written:p.written,reason:p.reason}}catch(b){return console.error("Failed to save model override:",b),{ok:!1,error:"Failed to save the model configuration."}}}function Xi(t){let{providers:r,selectedProvider:l,isDeletingProvider:c,pushToast:b,setProviders:p,setSelectedProviderId:g,setIsAddModalOpen:h,setIsDeleteModalOpen:v,setIsDeletingProvider:k,openLogin:x,openEntryEditor:A,onAddModalClose:N}=t,M=async(K)=>{p(K);try{let V=await Fi(K);if(V)p(V)}catch(V){console.error("Failed to save providers via API:",V),b("Failed to save provider settings.","error")}},P=async()=>{let K=await dt();if(K)p(K.providers);return K?.providers??[]},E=async(K,V)=>{try{let z=await ji(K,V);if(z)p(z);return z}catch(z){return console.error("Failed to update provider connection:",z),b("Failed to update the provider connection.","error"),null}};return{handleAddProvider:async(K,V)=>{let z=K.slug.trim().toLowerCase(),q=r.filter((X)=>X.slug.trim().toLowerCase()!==z);await M([...q,K]);let j=(await E(K.slug,!0))?.find((X)=>X.slug.trim().toLowerCase()===z);g(j?.id||K.id),h(!1),N?.();let H=Wi(K,V);b(H.text,H.tone)},handleConnect:(K)=>{if(!l)return;if(K==="login")x();else A()},handleEntrySaved:async(K)=>{if(!l)return;b(K.length>0?`${l.name}: updated ${K.join(", ")} in models.yml.`:`${l.name}: nothing to change.`,"success"),await P()},handleOmpAuthSuccess:async()=>{if(!l)return;let K=l.slug;b(`${l.name} signed in — omp stored the credential.`,"success");let z=(await P()).find((q)=>q.slug===K);if(z)g(z.id)},handleToggleProviderDisabled:async()=>{if(!l)return;let K=l,V=K.disabled!==!0;if(!await E(K.slug,!V))return;b(V?`${K.name} disabled — it no longer appears in the model list.`:`${K.name} enabled — its models are offered again.`,"success")},handleDeleteProvider:async(K)=>{let V=K??l;if(!V||c)return;k(!0);try{let z=await zi(V.id);if(!z.ok){b(z.error||"Failed to delete the provider.","error");return}v(!1);let q=z.providers??[];if(l?.id===V.id)g(q[0]?.id??"");if(p(q),z.warning)b(`${V.name} removed from Kabmo, but models.yml cleanup failed: ${z.warning}`,"warning");else if(z.removedFromOmp){let G=z.modelsRemoved??0;b(`${V.name} deleted from models.yml${G>0?` with its ${G} model${G===1?"":"s"}`:""}.`,"success")}else b(`${V.name} removed from Kabmo.`,"success")}finally{k(!1)}},persistProviders:M,reloadProviders:P}}async function Gt(t){try{let r=await fetch("/api/settings/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json();if(!r.ok)return{ok:!1,error:l?.error||`Request failed (HTTP ${r.status})`};return l}catch(r){return{ok:!1,error:r instanceof Error?r.message:"Network error while fetching models"}}}async function Qi(t){try{let r=await fetch("/api/settings/provider-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json();if(!r.ok)return{...l,success:!1,written:!1,error:l?.error||l?.reason};return Wr(),l}catch(r){return{success:!1,written:!1,error:r instanceof Error?r.message:"Network error while adding the model"}}}function ea(t,r){let l=new Map(t.map((h)=>[h.id,h])),c=new Set,b=[],p=[];for(let h of r){if(!h.id||c.has(h.id))continue;c.add(h.id);let v=l.get(h.id);if(!v){let k={...h};p.push(k),b.push(k);continue}b.push({...h,isVisible:v.isVisible!==!1,...v.temperature!==void 0?{temperature:v.temperature}:{},...v.maxTokens!==void 0?{maxTokens:v.maxTokens}:{},...v.topP!==void 0?{topP:v.topP}:{},...v.reasoningEffort!==void 0?{reasoningEffort:v.reasoningEffort}:{}})}let g=t.filter((h)=>!c.has(h.id)).map((h)=>h.id);return{models:b,added:p,addedCount:p.length,removed:g,removedCount:g.length}}async function ta(t,r){try{await Promise.all(r.map((l)=>fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"addModel",model:{id:l.id,name:l.name,provider:t,contextWindow:l.contextWindow?.split(" ")[0]||"128K",thinkingLevel:"Default",capabilities:["Tool calling","Reasoning"],inputFormats:["text"],outputFormats:["text"]}})}))),Wr()}catch(l){console.error("Failed to sync provider models to catalog:",l)}}var ap=/^model-\d+-(?:1|2)$/;function sp(t){return`${t.name} ${t.slug} ${t.baseUrl||""}`.toLowerCase().includes("kenari")}function na(t,r){if(!sp(t))return r;return r.filter((l)=>{let c=l.name.trim().toLowerCase(),b=c==="kenari default model"||c==="kenari fast / flash";return!(ap.test(l.id)&&b)})}function oa(t){let{providers:r,selectedProvider:l,isFetchingModels:c,pushToast:b,setProviders:p,setIsFetchingModels:g,persistProviders:h,reloadProviders:v}=t,k=async()=>{if(!l||c)return;let S=l;g(!0);try{let R=await _i(S.slug);if(!R.ok){b(R.error||"omp could not refresh the model catalog.","error");return}if(R.providers)p(R.providers);let T=Vi(S.name,R);b(T.text,T.tone)}finally{g(!1)}},x=async()=>{if(!l||c)return;let S=l;if(!S.baseUrl){b("This provider has no endpoint to import from — use “refresh” instead.","error");return}g(!0);try{let R=await Gt({baseUrl:S.baseUrl,apiKey:S.apiKey,providerSlug:S.slug,persistToOmp:!0,replaceModels:!0,...S.api?{api:S.api}:{},...S.auth?{auth:S.auth}:{}});if(!R.ok||!R.models){b(R.error||"Failed to fetch models from the provider.","error");return}if(R.omp?.written)Wr();let T=na(S,S.models),O=S.models.length-T.length,{added:L,addedCount:_,removedCount:K}=ea(T,R.models),V=K+O,z=Gi({addedCount:_,removedCount:V});b(z.text,z.tone);let q=qi(R);if(q)b(q.text,q.tone);if(_>0)ta(S.name,L);await v()}finally{g(!1)}},A=(S)=>{if(!l)return;h(r.map((R)=>R.id===l.id?{...R,models:S(R.models)}:R))};return{handleRefreshModels:k,handleFetchModels:x,handleHideAll:()=>A((S)=>S.map((R)=>({...R,isVisible:!1}))),handleShowAll:()=>A((S)=>S.map((R)=>({...R,isVisible:!0}))),handleToggleModelVisibility:(S)=>A((R)=>R.map((T)=>T.id===S?{...T,isVisible:!T.isVisible}:T)),handleSaveModelConfig:async(S,R)=>{if(!l)return;let T=l;A((L)=>L.map((_)=>_.id===S?{..._,...R}:_));let O=await Yi(T.slug,S,R);if(!O.ok){b(O.error||"Failed to save the model configuration.","error");return}if(O.written)Wr();else if(O.reason)b(O.reason,"error")}}}function ra({autoOpenAdd:t=!1,onAddModalClose:r}={}){let[l,c]=n([]),[b,p]=n([]),[g,h]=n(""),[v,k]=n(null),[x,A]=n(!0),[N,M]=n(!1),[P,E]=n(!1),[S,R]=n(!1),{pushToast:T}=Ve(),[O,L]=n(t),[_,K]=n(!1),[V,z]=n(!1),[q,G]=n(!1),[j,H]=n(!1),[X,oe]=n(!1),[te,Z]=n(!1),[Q,re]=n(null),[ue,ve]=n(null);i(()=>{if(t)L(!0)},[t]),i(()=>{let ae=!0;return dt().then((me)=>{if(!ae)return;if(A(!1),!me)return;c(me.providers),p(me.presetProviders??[]),k(me.catalogError??null);let $e=me.providers.filter((Ye)=>Ye.status==="connected");h($e[0]?.id??me.providers[0]?.id??"")}),()=>{ae=!1}},[]),i(()=>{let ae=null,me=ki(()=>{if(ae)clearTimeout(ae);ae=setTimeout(()=>{ae=null,dt().then(($e)=>{if($e)c($e.providers)})},400)});return()=>{if(me(),ae)clearTimeout(ae)}},[]);let Ne=u(()=>Oi(l,b),[l,b]),ce=u(()=>Ei(l),[l]),be=l.find((ae)=>ae.id===g)??l[0],Pe=Xi({providers:l,selectedProvider:be,isDeletingProvider:j,pushToast:T,setProviders:c,setSelectedProviderId:h,setIsAddModalOpen:L,setIsDeleteModalOpen:z,setIsDeletingProvider:H,openLogin:()=>Z(!0),openEntryEditor:()=>oe(!0),...r?{onAddModalClose:r}:{}}),xe=oa({providers:l,selectedProvider:be,isFetchingModels:P,pushToast:T,setProviders:c,setIsFetchingModels:E,persistProviders:Pe.persistProviders,reloadProviders:Pe.reloadProviders});return{providers:l,availablePresetProviders:Ne,existingSlugs:ce,selectedProvider:be,catalogError:v,isLoading:x,isRefreshingList:N,handleRefreshList:async()=>{if(N)return;M(!0);try{let ae=await dt();if(!ae){T("Could not read the provider list — omp may still be starting.","error");return}c(ae.providers),p(ae.presetProviders??[]),k(ae.catalogError??null),h(($e)=>ae.providers.some((Ye)=>Ye.id===$e)?$e:ae.providers.find((Ye)=>Ye.status==="connected")?.id??ae.providers[0]?.id??"");let me=ae.providers.length;T(`Provider list refreshed — ${me} provider${me===1?"":"s"}.`,"success")}finally{M(!1)}},isFetchingModels:P,isRefreshingIcon:S,handleRefreshIcon:async()=>{let ae=be;if(!ae||S)return;if(!ae.baseUrl){T("This provider has no endpoint, so there is no site to read an icon from.","error");return}R(!0);try{let me=await Bi(ae.slug,ae.baseUrl);if(!me.ok){T(me.error||"No usable icon on that host or its base domain — keeping the current mark.","error");return}let Ye=(await Pe.reloadProviders()).find((qd)=>qd.slug===ae.slug);if(Ye)h(Ye.id);T(`${ae.name}: icon updated from ${ae.baseUrl}.`,"success")}finally{R(!1)}},pushToast:T,isAddModelModalOpen:_,setIsAddModelModalOpen:K,handleModelAdded:async(ae)=>{T(`${ae} registered in models.yml.`,"success"),await Pe.reloadProviders()},handleSignedOut:async(ae)=>{G(!1),T(ae,"success"),await Pe.reloadProviders()},isDeleteModalOpen:V,setIsDeleteModalOpen:z,isLogoutModalOpen:q,setIsLogoutModalOpen:G,isDeletingProvider:j,isAddModalOpen:O,setIsAddModalOpen:L,isEntryModalOpen:X,setIsEntryModalOpen:oe,isLoginModalOpen:te,setIsLoginModalOpen:Z,configModel:Q,setConfigModel:re,capabilitiesModel:ue,setCapabilitiesModel:ve,setSelectedProviderId:h,...Pe,...xe}}function lp(t){if(t.disabled===!0)return"disabled";if(t.status==="connected")return"connected";return"signed-out"}var dp=[{id:"connected",label:"Signed in"},{id:"signed-out",label:"Not signed in",hint:"omp knows these providers; pick one to sign in or add its key."},{id:"disabled",label:"Disabled",hint:"Hidden from the model picker."}];function ia(t,r=""){let l=r.trim().toLowerCase(),c=l?t.filter((p)=>p.name.toLowerCase().includes(l)||p.slug.toLowerCase().includes(l)||p.models.some((g)=>g.id.toLowerCase().includes(l))):t,b=new Map;for(let p of c){let g=lp(p),h=b.get(g);if(h)h.push(p);else b.set(g,[p])}return dp.flatMap((p)=>{let g=b.get(p.id);if(!g||g.length===0)return[];return[{...p,providers:[...g].sort((h,v)=>h.name.localeCompare(v.name))}]})}function Fn(t){return t.inModelsYml===!0||t.inOverlay===!0}function aa(t){if(t.disabled===!0)return"Disabled — hidden from the model picker";if(t.status==="connected")switch(t.credentialOrigin){case"models.yml":return"Signed in — key stored in models.yml";case"login":return"Signed in — OAuth credential stored by omp";case"api-key":return"Signed in — API key stored by omp";case"environment":return"Signed in — credential comes from the environment";default:return"Signed in"}return t.oauth===!0?"Not signed in — pick this row to sign in with OAuth":"Not signed in — no credential omp can resolve"}function sa({providers:t,selectedProviderId:r,onSelectProvider:l,onOpenAddModal:c,onRefresh:b,isRefreshing:p,isLoading:g,catalogError:h}){let[v,k]=n(""),x=o(null),A=ia(t,v);return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0",children:[e("div",{className:"px-3 pt-3 pb-2 flex items-center justify-between gap-2",children:[e("span",{className:"text-[10px] font-semibold tracking-wider text-ink/50 uppercase",children:g?"Loading…":`${t.length} provider${t.length===1?"":"s"}`}),e("div",{className:"flex items-center gap-0.5",children:[e("button",{type:"button",onClick:b,disabled:p||g,title:"Refresh the provider list","aria-label":"Refresh the provider list",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:e(C,{size:14,strokeWidth:2.2,className:p?"animate-spin":""})}),e("button",{type:"button",onClick:c,title:"Add provider","aria-label":"Add provider",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:e(Y,{size:15,strokeWidth:2.2})})]})]}),e("div",{className:"px-3 pb-2",children:e("div",{className:"relative flex items-center",children:[e(F,{size:12,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{ref:x,type:"text",value:v,onChange:(N)=>k(N.currentTarget.value),placeholder:"Filter providers or models…","aria-label":"Filter providers",className:"w-full bg-paper border border-ink/15 rounded-md pl-7 pr-7 py-1.5 text-[11px] text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors"}),v&&e("button",{type:"button",onClick:()=>{k(""),x.current?.focus()},title:"Clear the filter","aria-label":"Clear the filter",className:"absolute right-1.5 p-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:e(y,{size:11})})]})}),h&&e("p",{className:"mx-3 mb-2 px-2 py-1.5 rounded border border-amber-500/30 bg-amber-500/10 text-[10px] leading-relaxed text-ink/70",children:["Model catalog unavailable: ",h]}),e("div",{className:"flex-1 scrollbar-overlay-container px-1.5 pb-3",children:g?e("div",{className:"flex flex-col items-center justify-center gap-2 py-10 text-[11px] text-ink/45",role:"status","aria-live":"polite",children:[e(m,{size:16,className:"animate-spin"}),e("span",{children:"Reading providers…"})]}):A.length===0?e("div",{className:"px-2.5 py-4 text-[11px] leading-relaxed text-ink/50",children:v?`No provider or model matches “${v}”.`:"No providers detected yet. Use the plus button above to register one."}):A.map((N)=>e("div",{className:"pt-1.5 first:pt-0",children:[e("div",{className:"px-2 pb-1",children:[e("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-[10px] font-semibold tracking-wider text-ink/45 uppercase",children:N.label}),e("span",{className:"text-[10px] font-mono text-ink/35",children:N.providers.length})]}),N.hint&&e("p",{className:"text-[10px] leading-snug text-ink/40 mt-0.5",children:N.hint})]}),e("div",{className:"space-y-0.5",children:N.providers.map((M)=>{let P=M.id===r;return e("button",{type:"button",onClick:()=>l(M.id),"aria-current":P?"true":void 0,title:aa(M),className:`w-full flex items-center gap-2 pl-1.5 pr-2 py-1 rounded-md text-left transition-colors cursor-pointer ${P?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e(Me,{provider:M,size:22}),e("span",{className:"flex-1 min-w-0 text-[12px] truncate",children:M.name}),e("span",{className:"w-8 shrink-0 text-right text-[10px] font-mono tabular-nums text-ink/45",children:M.models.length})]},M.id)})})]},N.id))})]})}function la({provider:t,onRefreshIcon:r,isRefreshingIcon:l=!1}){return e("div",{className:"flex items-start gap-3 pb-4",children:[e(Me,{provider:t,size:30,className:"mt-0.5"}),e("div",{className:"min-w-0 flex flex-1 flex-col gap-0.5",children:[e("h2",{className:"text-xl font-bold leading-tight tracking-tight text-ink truncate",children:t.name}),e("p",{className:"text-xs font-mono text-ink/50 truncate",children:t.slug})]}),r&&e("button",{type:"button",onClick:r,disabled:l,title:t.baseUrl?`Refetch the icon from ${t.baseUrl}`:"This provider has no endpoint to read an icon from","aria-label":"Refresh provider icon",className:"shrink-0 p-1.5 rounded-md border border-ink/15 text-ink/50 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:e(C,{size:12,className:l?"animate-spin":""})})]})}function ca(t){switch(t){case"models.yml":return"models.yml key";case"login":return"OAuth login";case"api-key":return"stored API key";case"environment":return"environment variable";default:return"no credential"}}function ha(t){return t==="login"||t==="api-key"}function xa(t){let r=t.oauth===!0&&t.auth!=="none"&&t.credentialOrigin!=="models.yml",l=t.inModelsYml===!0;if(r||l)return{login:r,edit:l};return{login:!1,edit:!1,reason:"omp discovers this provider itself — its models come from its own endpoint, so there is no login flow and no entry to edit."}}function ka({provider:t,onConnect:r,onToggleDisabled:l,onDelete:c,onSignOut:b}){let[p,g]=n(!1),h=t.status==="connected",v=t.disabled===!0,k=t.credentialOrigin,x=ha(k),A=xa(t);return e("div",{className:"space-y-6",children:[e("div",{className:"space-y-3",children:[e("div",{className:"text-xs font-semibold text-ink",children:"Authentication"}),e("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[e("div",{className:"flex items-center gap-2 min-w-0",children:[v?e(d,{children:[e(In,{size:15,className:"text-ink/50 flex-shrink-0",strokeWidth:2.4}),e("span",{className:"text-xs font-medium text-ink/70",children:"Disabled"})]}):h?e(d,{children:[e(f,{size:15,className:"text-success flex-shrink-0",strokeWidth:2.4}),e("span",{className:"text-xs font-medium text-ink",children:"Connected"})]}):e(d,{children:[e(B,{size:15,className:"text-warning flex-shrink-0",strokeWidth:2.4}),e("span",{className:"text-xs font-medium text-ink/80",children:"Not signed in"})]}),e("span",{className:"text-[11px] text-ink/55 font-mono px-1.5 py-0.5 rounded bg-ink/5 border border-ink/10",children:ca(k)}),e("div",{className:"relative inline-block cursor-help ml-0.5",onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),children:[e(pe,{size:13,className:"text-ink/40 hover:text-ink/70 transition-colors"}),p&&e("div",{className:"absolute left-4 top-1/2 -translate-y-1/2 bg-ink text-canvas text-[10px] rounded px-2.5 py-1.5 shadow-xl w-64 z-50 pointer-events-none leading-relaxed",children:v?"Disabled in omp’s config.yml — none of its models appear in the chat model list. The credential is untouched.":h?"omp can resolve a credential for this provider, so its models are offered in the chat picker.":"omp knows this provider but has no credential for it. Connect to sign in or supply a key."})]})]}),e("div",{className:"flex flex-wrap items-center gap-2",children:[e("button",{type:"button",onClick:l,title:v?"Offer this provider in the model list again":"Hide this provider and its models from the model list",className:"px-3 py-1.5 rounded-md bg-ink/5 hover:bg-ink/10 text-ink text-xs font-medium transition-colors cursor-pointer border border-ink/10",children:v?"enable":"disable"}),A.login&&e("button",{type:"button",onClick:()=>r("login"),title:"Sign in to this provider through omp",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer",children:[e(er,{size:12}),e("span",{children:h&&k==="login"?"sign in again":"sign in"})]}),A.edit&&e("button",{type:"button",onClick:()=>r("edit"),title:"Edit this provider’s endpoint, credential and dialect in models.yml",className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors cursor-pointer border ${A.login?"bg-ink/5 hover:bg-ink/10 text-ink border-ink/15":"bg-ink text-canvas hover:opacity-90 border-ink"}`,children:[e(Tn,{size:12}),e("span",{children:"edit"})]}),!A.login&&!A.edit&&e("button",{type:"button",disabled:!0,title:A.reason,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium opacity-40 cursor-not-allowed",children:[e(ui,{size:12}),e("span",{children:"connect"})]}),x&&e("button",{type:"button",onClick:b,title:"Remove the credential omp stored for this provider",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-ink/5 hover:bg-ink/10 text-ink text-xs font-medium transition-colors cursor-pointer border border-ink/10",children:[e(jt,{size:12}),e("span",{children:"sign out"})]}),e("button",{type:"button",onClick:c,disabled:!Fn(t),title:Fn(t)?t.inModelsYml?"Remove this provider’s models.yml entry":"Remove this provider’s Kabmo settings row":"Nothing to delete: omp discovered this provider from its endpoint. Use disable to hide it.",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-error/10 hover:bg-error/20 text-error text-xs font-medium transition-colors cursor-pointer border border-error/30 disabled:opacity-40 disabled:cursor-not-allowed",children:[e(U,{size:12}),e("span",{children:"delete"})]})]})]})]}),e("div",{className:"border-b border-ink/10"}),e("div",{className:"space-y-3",children:[e("div",{className:"text-xs font-semibold text-ink",children:"Connection details"}),e("div",{className:"flex items-center justify-between gap-4",children:[e("div",{className:"text-xs text-ink/70 min-w-0",children:["Configured in:"," ",e("span",{className:"font-mono text-ink font-medium break-all",children:t.configuredIn})]}),e("span",{className:"text-[11px] text-ink/40 italic shrink-0",children:v?"hidden":h?"active":"inactive"})]}),(t.api||t.auth||t.discovery||t.transport)&&e("div",{className:"flex flex-wrap items-center gap-1.5 pt-0.5",children:[t.api&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"Wire API omp uses for this provider",children:t.api}),t.auth&&t.auth!=="apiKey"&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"Auth mode from models.yml",children:["auth: ",t.auth]}),t.discovery&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"omp lists this provider's models live",children:["discovery: ",t.discovery]}),t.transport&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"Requests are routed through the auth gateway",children:["transport: ",t.transport]}),t.headers&&Object.keys(t.headers).length>0&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:Object.entries(t.headers).map(([N,M])=>`${N}: ${M}`).join(`
|
|
2
|
-
`),children:[Object.keys(t.headers).length," header",Object.keys(t.headers).length===1?"":"s"]})]})]}),e("div",{className:"border-b border-ink/10"})]})}var qt=["openai-completions","openai-responses","openai-codex-responses","azure-openai-responses","anthropic-messages","bedrock-converse-stream","google-generative-ai","google-gemini-cli","google-vertex","openrouter-decisions","openai-decisions","workers-ai-systemone","typesafe"],Jt={"openai-completions":"[OI] Chat Completions — the default for gateways and local servers","openai-responses":"[OI] Responses API — newer [OI]-shaped endpoints","openai-codex-responses":"[OC] Responses — Codex-style endpoints","azure-openai-responses":"Azure [OI] Responses — api-key header, api-version query","anthropic-messages":"Anthropic Messages — Claude-shaped proxies (x-api-key)","bedrock-converse-stream":"Amazon Bedrock Converse — AWS credential chain","google-generative-ai":"Google Generative AI — Gemini API (x-goog-api-key)","google-gemini-cli":"Google Gemini CLI — OAuth-backed Gemini route","google-vertex":"Google Vertex AI — service-account / ADC route","openrouter-decisions":"OpenRouter decisions — judge role only","openai-decisions":"[OI] decisions — judge role only","workers-ai-systemone":"Workers AI System One — judge role only",typesafe:"Typesafe System One — judge role only"},at=["minimal","low","medium","high","xhigh","max"];var Nt=[{value:"apiKey",label:"API key",hint:"omp requires a key for this provider"},{value:"none",label:"No auth (keyless)",hint:"Local server that needs no credential"},{value:"oauth",label:"OAuth",hint:"Claude-Code-style proxy expecting the cloaked request shape"}];var jn=["chat","tiny","image","tts","stt","search","judge","embedding","rerank","video"],st={chat:"Chat",tiny:"Tiny",image:"Image",tts:"Speech",stt:"Transcribe",search:"Search",judge:"Judge",embedding:"Embedding",rerank:"Rerank",video:"Video"};function pt(t){return typeof t==="string"&&jn.includes(t)?t:"chat"}var mt=[{value:"openai-models-list",label:"OpenAI /v1/models",hint:"Any OpenAI-compatible endpoint"},{value:"ollama",label:"Ollama",hint:"Native Ollama /api/tags + /api/show"},{value:"llama.cpp",label:"llama.cpp",hint:"llama.cpp server model endpoints"},{value:"lm-studio",label:"LM Studio",hint:"LM Studio /v1/models + native metadata"},{value:"litellm",label:"LiteLLM proxy",hint:"LiteLLM proxy with rich model metadata"},{value:"proxy",label:"New-API / One-API proxy",hint:"Wire api read per model from the proxy"},{value:"apple-foundation-models",label:"Apple Foundation Models",hint:"On-device model (Apple silicon only)"}];function ya(t){if(/anthropic\./i.test(t))return"anthropic-messages";if(/generativelanguage\.googleapis\.com/i.test(t))return"google-generative-ai";if(/openai\.azure\.com/i.test(t))return"azure-openai-responses";if(/openrouter\.ai/i.test(t))return"openai-completions";return"openai-completions"}function wa(t){if(t.discovery||t.modelSource==="discovery")return"omp discovers this provider’s models live — they appear in the chat model picker, not here.";if(t.modelSource==="override")return t.auth==="none"?"Endpoint override — omp keeps its own model list for this provider. Use “fetch models” to add specific ids.":"Endpoint override — omp keeps its own model list for this provider. It still needs a credential: use “connect” to supply one, or “fetch models” to add specific ids.";if(t.auth==="none")return"No models registered yet. This server is keyless, so use “fetch models” to list what it serves.";return}function Sa(t){if(t.discovery!==void 0||t.modelSource==="discovery")return"omp lists this provider’s models itself — importing would freeze a snapshot beside that live list. Use “refresh”.";if(!t.baseUrl)return"This provider has no endpoint Kabmo can probe — omp owns its URL. Use “refresh” instead.";return}function Na({models:t,emptyReason:r,onToggleModelVisibility:l,onHideAll:c,onShowAll:b,onRefreshModels:p,onImportModels:g,onAddModel:h,fetchBlockReason:v,isFetchingModels:k,onOpenModelConfig:x,onOpenModelCapabilities:A}){let[N,M]=n(""),[P,E]=n("all"),S=u(()=>{let L=new Map;for(let _ of t){let K=pt(_.kind);L.set(K,(L.get(K)??0)+1)}return L},[t]),R=u(()=>[...S.entries()].sort((L,_)=>_[1]-L[1]),[S]),T=t.filter((L)=>{if(P!=="all"&&pt(L.kind)!==P)return!1;if(!N.trim())return!0;let _=N.trim().toLowerCase();return L.id.toLowerCase().includes(_)||L.name.toLowerCase().includes(_)}),O=t.filter((L)=>!L.isVisible).length;return e("div",{className:"space-y-3.5",children:[e("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[e("div",{className:"text-xs font-semibold text-ink",children:["Models ",e("span",{className:"font-normal text-ink/60",children:["(",t.length,")"]}),O>0&&e("span",{className:"font-normal text-ink/40",children:[" · ",O," hidden"]})]}),e("div",{className:"flex flex-wrap items-center gap-2",children:[e("button",{type:"button",onClick:p,disabled:k,title:"Ask omp to re-run model discovery for every provider",className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded bg-ink text-canvas text-[11px] font-medium hover:opacity-90 transition-opacity cursor-pointer border border-ink disabled:opacity-40 disabled:cursor-not-allowed",children:[e(C,{size:12,className:k?"animate-spin":""}),e("span",{children:k?"refreshing…":"refresh"})]}),g&&e("button",{type:"button",onClick:g,disabled:Boolean(v)||k,title:v??"List this endpoint’s models and register them in models.yml",className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded bg-ink/5 hover:bg-ink/10 text-[11px] font-medium text-ink/80 hover:text-ink transition-colors cursor-pointer border border-ink/10 disabled:opacity-40 disabled:cursor-not-allowed",children:[e(he,{size:12}),e("span",{children:"import"})]}),e("button",{type:"button",onClick:h,title:"Register a model by hand",className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded bg-ink/5 hover:bg-ink/10 text-[11px] font-medium text-ink/80 hover:text-ink transition-colors cursor-pointer border border-ink/10",children:[e(Y,{size:12}),e("span",{children:"add model"})]}),e("button",{type:"button",onClick:c,disabled:t.length===0,title:"Hide every model from the chat picker",className:"px-2.5 py-1 rounded bg-ink/5 hover:bg-ink/10 text-[11px] font-medium text-ink/80 hover:text-ink transition-colors cursor-pointer border border-ink/10 disabled:opacity-40 disabled:cursor-not-allowed",children:"hide all"}),e("button",{type:"button",onClick:b,disabled:O===0,title:"Show every model in the chat picker",className:"px-2.5 py-1 rounded bg-ink/5 hover:bg-ink/10 text-[11px] font-medium text-ink/80 hover:text-ink transition-colors cursor-pointer border border-ink/10 disabled:opacity-40 disabled:cursor-not-allowed",children:"show all"})]})]}),e("div",{className:"flex flex-wrap items-center gap-1.5",children:[e("button",{type:"button",onClick:()=>E("all"),"aria-pressed":P==="all",className:`px-2 py-0.5 rounded text-[11px] font-medium transition-colors cursor-pointer border ${P==="all"?"border-ink/40 bg-ink/10 text-ink":"border-ink/10 text-ink/60 hover:text-ink hover:border-ink/25"}`,children:["All ",e("span",{className:"font-mono text-ink/45",children:t.length})]}),R.map(([L,_])=>e("button",{type:"button",onClick:()=>E(L),"aria-pressed":P===L,className:`px-2 py-0.5 rounded text-[11px] font-medium transition-colors cursor-pointer border ${P===L?"border-ink/40 bg-ink/10 text-ink":"border-ink/10 text-ink/60 hover:text-ink hover:border-ink/25"}`,children:[st[L]," ",e("span",{className:"font-mono text-ink/45",children:_})]},L))]}),e("div",{className:"relative flex items-center",children:[e(F,{size:14,className:"absolute left-3 text-ink/40 pointer-events-none"}),e("input",{type:"text",value:N,onChange:(L)=>M(L.currentTarget.value),placeholder:"Filter models by id or name…","aria-label":"Filter models",className:"w-full bg-paper border border-ink/15 rounded-lg pl-9 pr-9 py-2 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors shadow-2xs"}),N&&e("button",{type:"button",onClick:()=>M(""),title:"Clear the filter","aria-label":"Clear the model filter",className:"absolute right-2 p-1 rounded text-ink/40 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:e(y,{size:12})})]}),e("div",{className:"space-y-1 pt-1",children:T.length===0?e("div",{className:"py-8 text-center text-xs text-ink/40",children:N||P!=="all"?"No model matches this filter.":r||"No models registered for this provider yet."}):T.map((L)=>{let _=pt(L.kind);return e("div",{className:`flex items-center justify-between gap-3 px-3 py-2 rounded-lg hover:bg-ink/5 transition-colors group ${!L.isVisible?"opacity-50":""}`,children:[e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-1.5 min-w-0",children:[e("span",{className:`text-xs font-medium truncate ${L.isVisible?"text-ink":"text-ink/60 line-through decoration-ink/40"}`,title:L.id,children:L.name}),_!=="chat"&&e("span",{className:"shrink-0 px-1 py-0 rounded border border-ink/15 text-[10px] font-mono uppercase tracking-wide text-ink/55",children:st[_]})]}),L.name!==L.id&&e("span",{className:"text-[10px] font-mono text-ink/40 truncate block",children:L.id})]}),e("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[(L.priceInput!==void 0||L.priceOutput!==void 0)&&e("span",{title:`$${L.priceInput??"?"} in / $${L.priceOutput??"?"} out per 1M tokens${L.pricingStatus&&L.pricingStatus!=="exact"?` (${L.pricingStatus})`:""}`,className:"text-[11px] font-mono px-2 py-0.5 rounded bg-ink/5 text-ink/70 border border-ink/10",children:[Nf(L.priceInput)," / ",Nf(L.priceOutput)]}),L.contextWindow&&e("span",{className:"text-[11px] font-mono px-2 py-0.5 rounded bg-ink/5 text-ink/70 border border-ink/10",children:ec(L.contextWindow)}),e("button",{type:"button",onClick:()=>A(L),title:"What this model declares: tools, vision, reasoning","aria-label":`Capabilities of ${L.name}`,className:"p-1 rounded text-ink/50 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:e(lr,{size:13,strokeWidth:1.8})}),e("button",{type:"button",onClick:()=>x(L),title:"Per-model overrides omp honours (max output, reasoning level)","aria-label":`Configure ${L.name}`,className:"p-1 rounded text-ink/50 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:e(mi,{size:13,strokeWidth:1.8})}),L.hasVision&&e("span",{title:"Accepts image input",className:"p-1 text-ink/60","aria-label":"Accepts image input",children:e(Qo,{size:13,strokeWidth:1.8})}),e("button",{type:"button",onClick:()=>l(L.id),title:L.isVisible?"Hide model from chat picker":"Show model in chat picker","aria-label":L.isVisible?`Hide ${L.name}`:`Show ${L.name}`,"aria-pressed":L.isVisible,className:`p-1 rounded transition-colors cursor-pointer ${L.isVisible?"text-ink/60 hover:text-ink hover:bg-ink/10":"text-ink/30 hover:text-ink/70 hover:bg-ink/10"}`,children:L.isVisible?e(Ge,{size:14,strokeWidth:1.8}):e(wt,{size:14,strokeWidth:1.8})})]})]},L.id)})})]})}var Pa=[{value:"fetch",label:"Fetch now",hint:"List the endpoint here and write the ids into models.yml"},{value:"discovery",label:"Let omp discover",hint:"omp lists the models live on every run"},{value:"override",label:"Endpoint only",hint:"Keep omp’s own model list, change only the URL"}],$n="w-full text-xs py-2 px-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors cursor-pointer";function Ca({api:t,onApiChange:r,auth:l,onAuthChange:c,source:b,onSourceChange:p,discovery:g,onDiscoveryChange:h}){return e(d,{children:[e("div",{className:"grid grid-cols-2 gap-3",children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Wire API"}),e("select",{value:t,onChange:(v)=>r(v.currentTarget.value),className:$n,children:qt.map((v)=>e("option",{value:v,children:v},v))})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Auth"}),e("select",{value:l,onChange:(v)=>c(v.currentTarget.value),className:$n,children:Nt.map((v)=>e("option",{value:v.value,children:v.label},v.value))})]})]}),e("p",{className:"text-[10px] text-ink/40 leading-relaxed -mt-1",children:[Jt[t]," · ",Nt.find((v)=>v.value===l)?.hint]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Model source"}),e("div",{className:"grid grid-cols-3 gap-2",children:Pa.map((v)=>{let k=b===v.value;return e("button",{type:"button",onClick:()=>p(v.value),className:`px-2 py-1.5 rounded-lg border text-[11px] transition-colors cursor-pointer ${k?"border-ink/50 bg-ink/5 font-semibold text-ink":"border-ink/15 hover:border-ink/30 text-ink/70"}`,children:v.label},v.value)})}),e("p",{className:"text-[10px] text-ink/40 mt-1 leading-relaxed",children:Pa.find((v)=>v.value===b)?.hint})]}),b==="discovery"&&e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Discovery protocol"}),e("select",{value:g,onChange:(v)=>h(v.currentTarget.value),className:$n,children:mt.map((v)=>e("option",{value:v.value,children:v.label},v.value))}),e("p",{className:"text-[10px] text-ink/40 mt-1",children:mt.find((v)=>v.value===g)?.hint})]})]})}function Ta({presets:t,selectedPresetId:r,onSelectPreset:l}){let[c,b]=n({}),p=Li(t);if(t.length===0)return e("p",{className:"px-2 py-3 text-xs text-ink/50",children:"Every known provider is already configured."});return e("div",{className:"max-h-52 scrollbar-overlay-container pr-1 space-y-2",children:p.map((g)=>{let h=c[g.group]===!0;return e("div",{children:[e("button",{type:"button",onClick:()=>b((v)=>({...v,[g.group]:!h})),className:"w-full flex items-center gap-1.5 px-0.5 py-1 text-[10px] font-semibold tracking-wider text-ink/50 uppercase hover:text-ink/80 transition-colors cursor-pointer",children:[e(I,{size:11,className:`transition-transform ${h?"-rotate-90":""}`}),e("span",{children:g.group}),e("span",{className:"text-ink/30 normal-case tracking-normal",children:g.options.length})]}),!h&&e("div",{className:"grid grid-cols-2 gap-2 pt-1",children:g.options.map((v)=>{let k=v.id===r;return e("button",{type:"button",onClick:()=>l(v),title:v.defaultUrl,className:`flex items-center gap-2 p-2 rounded-lg border text-left text-xs transition-colors cursor-pointer ${k?"border-ink/50 bg-ink/5 font-semibold text-ink shadow-2xs":"border-ink/15 hover:border-ink/30 text-ink/70"}`,children:[e(Me,{provider:{icon:v.icon,slug:v.slug,name:v.name},size:18}),e("span",{className:"truncate flex-1",children:v.name}),k&&e(f,{size:12,className:"shrink-0 text-ink"})]},v.id)})})]},g.group)})})}var cp=/^[a-z0-9][a-z0-9._-]{0,63}$/;function Ra(t){return{api:t?.api??ya(t?.defaultUrl??""),auth:t?.auth??"apiKey",discovery:t?.discovery??"openai-models-list",source:t?.discovery?"discovery":t?.bundled?"override":"fetch"}}function Ma({isOpen:t,onClose:r,onAddProvider:l,presets:c,existingSlugs:b}){let p=c,g=p[0],h=Ra(g),[v,k]=n(g?.id||"openai"),[x,A]=n(g?.name||"OpenAI"),[N,M]=n(g?.defaultUrl||"https://api.openai.com/v1"),[P,E]=n(""),[S,R]=n(h.api),[T,O]=n(h.auth),[L,_]=n(h.source),[K,V]=n(h.discovery),[z,q]=n(!1),G=(ce)=>{let be=Ra(ce);k(ce.id),A(ce.name),M(ce.defaultUrl),R(be.api),O(be.auth),V(be.discovery),_(be.source)};if(i(()=>{if(!p.find((be)=>be.id===v)&&p[0])G(p[0])},[p,v]),!t)return null;let j=p.find((ce)=>ce.id===v),H=x.trim(),X=(H&&j&&H===j.name?j.slug:H.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")).toLowerCase(),oe=new Set(b.map((ce)=>ce.trim().toLowerCase())),te=j?.bundled===!0,Z=!X?"Enter a provider name to derive an id.":!cp.test(X)?"The derived id must start with a letter or digit.":oe.has(X)&&!te?`"${X}" is already registered in models.yml — connecting it would overwrite that provider. Pick another name.`:"",Q=T==="apiKey",re=Q&&L==="fetch",ue=re&&!P.trim()?'Enter the API key, or set Auth to "No auth" for a keyless local server.':"",ve=Boolean(H)&&!Z&&!ue&&!z;return e(J,{onClose:r,header:e("div",{className:"flex items-center gap-2",children:[e(An,{size:16,className:"text-ink/70"}),e("h3",{className:"text-sm font-semibold text-ink",children:"Add Model Provider"})]}),form:{onSubmit:async(ce)=>{if(ce.preventDefault(),!ve)return;q(!0);try{let be=Date.now(),Pe=N.trim(),xe=P.trim(),We={id:`provider-${be}`,name:H,slug:X,icon:j?.icon||"custom",status:"connected",configuredIn:"auth credentials",credentialSource:"models.yml",baseUrl:Pe,...xe?{apiKey:xe}:{},api:S,...T!=="apiKey"?{auth:T}:{},...L==="discovery"?{discovery:K}:{},modelSource:L,models:[]},Ae=await Gt({baseUrl:Pe,apiKey:xe||void 0,providerSlug:We.slug,persistToOmp:!0,api:S,auth:T,...L==="discovery"?{discovery:K}:{},...L==="override"?{registerOnly:!0}:{}});if(Ae.ok&&Ae.models)We.models=Ae.models,l(We,{fetchedCount:Ae.models.length,ompNote:Ae.omp?.reason});else l(We,{fetchedCount:-1,ompNote:Ae.omp?.written?void 0:Ae.error});r()}finally{q(!1)}},className:"p-5 space-y-4"},maxWidthClass:"max-w-lg",footer:e("div",{className:"pt-2 flex items-center justify-end gap-2 border-t border-ink/10",children:[e("button",{type:"button",onClick:r,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"submit",disabled:!ve,className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:z?e(d,{children:[e(La,{size:14,className:"animate-pulse"}),e("span",{children:L==="fetch"?"Fetching models...":"Registering..."})]}):e(d,{children:[e(f,{size:14}),e("span",{children:"Connect Provider"})]})})]}),children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1.5",children:"Provider Preset"}),e(Ta,{presets:p,selectedPresetId:v,onSelectPreset:G})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Display Name"}),e("input",{type:"text",required:!0,value:x,onChange:(ce)=>A(ce.currentTarget.value),placeholder:"e.g. My Provider",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60"}),X&&e("p",{className:"text-[10px] text-ink/40 mt-1 font-mono",children:["models.yml id: ",X]}),Z&&e("p",{className:"text-[11px] text-error mt-1",children:Z})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"API Base URL"}),e("div",{className:"relative flex items-center",children:[e(De,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",required:!0,value:N,onChange:(ce)=>M(ce.currentTarget.value),placeholder:"https://api.domain.com/v1",className:"w-full bg-paper border border-ink/20 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]})]}),e(Ca,{api:S,onApiChange:R,auth:T,onAuthChange:O,source:L,onSourceChange:_,discovery:K,onDiscoveryChange:V}),Q&&e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:["API Key (stored securely)",!re&&e("span",{className:"font-normal text-ink/40",children:" (optional)"})]}),e("div",{className:"relative flex items-center",children:[e(lt,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"password",value:P,onChange:(ce)=>E(ce.currentTarget.value),placeholder:"sk-••••••••••••••••",className:"w-full bg-paper border border-ink/20 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]}),ue&&e("p",{className:"text-[11px] text-error mt-1",children:ue}),e("p",{className:"text-[10px] text-ink/40 mt-1",children:[re?"May name an environment variable (e.g. ":"Leave empty to keep using the provider’s existing credential. May name an environment variable (e.g. ",e("span",{className:"font-mono",children:"MY_KEY"}),") or run a command with a leading"," ",e("span",{className:"font-mono",children:"!"}),"."]})]})]})}var Qt="w-full text-xs py-2 px-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors",pp={"openai-models-list":!0,"lm-studio":!0,proxy:!0};function Ea({discovery:t,onDiscoveryChange:r,headers:l,onHeadersChange:c}){let b=(v)=>r({...t,...v}),p=t.type==="openai-models-list",g=pp[t.type]===!0,h=(v,k)=>{c(l.map((x,A)=>A===v?{...x,...k}:x))};return e(d,{children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:["Discovery ",e("span",{className:"font-normal text-ink/40",children:"(optional)"})]}),e("select",{value:t.type,onChange:(v)=>b({type:v.currentTarget.value}),className:Qt,children:[e("option",{value:"",children:"Use the registered model list"}),mt.map((v)=>e("option",{value:v.value,children:v.label},v.value))]}),e("p",{className:"text-[10px] text-ink/40 mt-1 leading-relaxed",children:t.type?mt.find((v)=>v.value===t.type)?.hint:"With discovery set, omp lists this provider’s models live and importing here would freeze a snapshot beside that list."})]}),t.type&&e("div",{className:"space-y-2 pl-3 border-l-2 border-ink/10",children:[e("div",{children:[e("label",{className:"block text-[11px] font-medium text-ink/70 mb-1",children:["Timeout ",e("span",{className:"font-normal text-ink/40",children:"(ms, optional)"})]}),e("input",{type:"text",inputMode:"numeric",value:t.timeoutMs,onChange:(v)=>b({timeoutMs:v.currentTarget.value}),placeholder:"omp default",className:`${Qt} font-mono`})]}),p&&e("label",{className:"flex items-start gap-2 text-[11px] text-ink/70",children:[e("input",{type:"checkbox",checked:t.injectV1===!0,onChange:(v)=>b({injectV1:v.currentTarget.checked}),className:`${ge} mt-0.5`}),e("span",{children:["Skip the forced ",e("span",{className:"font-mono",children:"/v1"})," prefix — for a gateway rooted at a versioned path."]})]}),g&&e("label",{className:"flex items-start gap-2 text-[11px] text-ink/70",children:[e("input",{type:"checkbox",checked:t.advertisedReasoning===!0,onChange:(v)=>b({advertisedReasoning:v.currentTarget.checked}),className:`${ge} mt-0.5`}),e("span",{children:"Trust the reasoning ladder the endpoint advertises in its model rows."})]})]}),e("div",{children:[e("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e("label",{className:"block text-xs font-semibold text-ink",children:["Request headers ",e("span",{className:"font-normal text-ink/40",children:"(optional)"})]}),e("button",{type:"button",onClick:()=>c([...l,{key:"",value:""}]),className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:[e(Y,{size:11}),e("span",{children:"add"})]})]}),l.length===0?e("p",{className:"text-[10px] text-ink/40 leading-relaxed",children:"Sent with every request to this provider — the place for a gateway’s routing or version header."}):e("div",{className:"space-y-1.5",children:l.map((v,k)=>e("div",{className:"flex items-center gap-1.5",children:[e("input",{type:"text",value:v.key,onChange:(x)=>h(k,{key:x.currentTarget.value}),placeholder:"Header-Name","aria-label":`Header ${k+1} name`,className:`${Qt} font-mono`}),e("input",{type:"text",value:v.value,onChange:(x)=>h(k,{value:x.currentTarget.value}),placeholder:"value","aria-label":`Header ${k+1} value`,className:`${Qt} font-mono`}),e("button",{type:"button",onClick:()=>c(l.filter((x,A)=>A!==k)),title:"Remove this header","aria-label":`Remove header ${k+1}`,className:"shrink-0 p-1.5 rounded text-ink/40 hover:text-error hover:bg-error/10 transition-colors cursor-pointer",children:e(y,{size:12})})]},k))})]})]})}var Zt="w-full text-xs py-2 px-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors",up="sk-••••••••••••••••••••••••";function Da({isOpen:t,provider:r,onClose:l,onSaved:c}){let[b,p]=n(r.baseUrl??""),[g,h]=n(""),[v,k]=n(r.api??""),[x,A]=n(r.auth??"apiKey"),[N,M]=n({type:r.discovery??"",timeoutMs:"",injectV1:void 0,advertisedReasoning:void 0}),[P,E]=n(Object.entries(r.headers??{}).map(([q,G])=>({key:q,value:G}))),[S,R]=n(!1),[T,O]=n(null);if(i(()=>{if(!t)return;p(r.baseUrl??""),h(""),k(r.api??""),A(r.auth??"apiKey"),M({type:r.discovery??"",timeoutMs:"",injectV1:void 0,advertisedReasoning:void 0}),E(Object.entries(r.headers??{}).map(([q,G])=>({key:q,value:G}))),O(null)},[t,r.id,r.baseUrl,r.api,r.auth,r.discovery]),!t)return null;let L=r.credentialOrigin==="models.yml"||r.credentialOrigin==="api-key",_=x!=="apiKey",K=!_&&!g.trim()&&!L?'omp needs a credential for a keyed provider — enter the key, or switch Auth to "No auth".':"",V=!S&&!K,z=async(q)=>{if(q.preventDefault(),!V)return;R(!0),O(null);let G={},j=b.trim();if(j!==(r.baseUrl??""))G.baseUrl=j||null;if(g.trim())G.apiKey=g.trim();if(v&&v!==r.api)G.api=v;if(x!==(r.auth??"apiKey"))G.auth=x;if(N.type!==(r.discovery??""))G.discovery=N.type?{type:N.type,...N.timeoutMs.trim()&&Number(N.timeoutMs)>0?{timeoutMs:Number(N.timeoutMs)}:{},...N.injectV1!==void 0?{injectV1:N.injectV1}:{},...N.advertisedReasoning!==void 0?{advertisedReasoning:N.advertisedReasoning}:{}}:null;let H=Object.fromEntries(P.filter((Z)=>Z.key.trim()).map((Z)=>[Z.key.trim(),Z.value.trim()])),X=r.headers??{};if(JSON.stringify(H)!==JSON.stringify(X))G.headers=Object.keys(H).length>0?H:null;if(Object.keys(G).length===0){R(!1),l();return}let te=await $i(r.slug,G);if(R(!1),!te.ok){O(te.error??"Could not write the provider entry.");return}c(te.changed??[]),l()};return e(J,{onClose:l,header:e("div",{className:"flex items-center gap-2.5",children:[e(Me,{provider:r,size:26}),e("div",{children:[e("h3",{className:"text-sm font-semibold text-ink",children:"Edit connection"}),e("p",{className:"text-[11px] text-ink/50 font-mono",children:["models.yml · ",r.slug]})]})]}),form:{onSubmit:z,className:"p-5 space-y-4"},footer:e("div",{className:"pt-3 flex items-center justify-end gap-2 border-t border-ink/10",children:[e("button",{type:"button",onClick:l,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"submit",disabled:!V,className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-40 flex items-center gap-1.5",children:[e(yt,{size:13}),e("span",{children:S?"Saving…":"Save to models.yml"})]})]}),children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Endpoint URL"}),e("div",{className:"relative flex items-center",children:[e(De,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",value:b,onChange:(q)=>p(q.currentTarget.value),placeholder:"https://api.example.com/v1",className:`${Zt} pl-8 font-mono`})]})]}),_?e("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md bg-ink/5 border border-ink/10 text-[11px] text-ink/60",children:[e(pe,{size:13,className:"mt-0.5 flex-shrink-0 text-ink/50"}),e("span",{children:["Registered with ",e("span",{className:"font-mono",children:["auth: ",x]})," — omp sends no API key for this provider. Switch Auth to “API key” if the endpoint starts requiring one."]})]}):e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:["API key",L&&e("span",{className:"font-normal text-ink/40",children:" (stored; leave empty to keep it)"})]}),e("div",{className:"relative flex items-center",children:[e(lt,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",value:g,onChange:(q)=>h(q.currentTarget.value),placeholder:L?up:"sk-…",autoComplete:"off",spellcheck:!1,className:`${Zt} pl-8 font-mono`})]}),K&&e("p",{className:"text-[11px] text-error mt-1",children:K}),e("p",{className:"text-[10px] text-ink/40 mt-1 leading-relaxed",children:["A literal key, or ",e("span",{className:"font-mono",children:"!command"})," to have omp run a command for it — both are stored in ",e("span",{className:"font-mono",children:"models.yml"}),"."]})]}),e("div",{className:"grid grid-cols-2 gap-3",children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Wire API"}),e("select",{value:v,onChange:(q)=>k(q.currentTarget.value),className:Zt,children:[e("option",{value:"",children:"Inherit omp's setting"}),qt.map((q)=>e("option",{value:q,children:q},q))]})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Auth"}),e("select",{value:x,onChange:(q)=>A(q.currentTarget.value),className:Zt,children:Nt.map((q)=>e("option",{value:q.value,children:q.label},q.value))})]})]}),v&&e("p",{className:"text-[10px] text-ink/40 leading-relaxed -mt-2",children:Jt[v]}),e(Ea,{discovery:N,onDiscoveryChange:M,headers:P,onHeadersChange:E}),T&&e("div",{className:"flex items-start gap-2 text-[11px] text-error",children:[e(B,{size:13,className:"mt-0.5 shrink-0"}),e("span",{className:"select-text",children:T})]})]})}var Fa={status:"connecting",authUrl:null,launchUrl:null,instructions:null,prompt:null,notices:[],error:null};function Ba(t){if(!t)return null;return/^(.*\bcode:?\s+)([A-Za-z0-9][A-Za-z0-9-]{3,})\s*$/s.exec(t.trim())?.[2]??null}function ja(t){let r=t.replace(/^\[|\]$/g,"");return r==="localhost"||r==="127.0.0.1"||r==="::1"||r.endsWith(".localhost")}function Bn(t){if(!t)return!1;let r;try{r=new URL(t)}catch{return!1}if(r.protocol!=="http:"&&r.protocol!=="https:")return!0;if(!ja(r.hostname))return!0;return typeof window<"u"&&ja(window.location.hostname)}function _a({isOpen:t,providerId:r,onAuthenticated:l}){let[c,b]=n(Fa),[p,g]=n(""),h=o(null),v=o(l);v.current=l,i(()=>{if(!t)return;b(Fa),g("");let x=new AbortController,A=null,N=(M)=>{if(!A)return;fetch("/api/omp/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...M,type:"extension_ui_response",loginId:A}),signal:x.signal}).catch(()=>{})};return h.current=N,fetch("/api/omp/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:r}),signal:x.signal}).then(async(M)=>{if(!M.ok){let R=await M.json().catch(()=>null),T=R&&typeof R.error==="string"?R.error:`HTTP ${M.status}`;throw Error(T)}if(!M.body)throw Error("Streaming is not supported by this browser");let P=M.body.getReader(),E=new TextDecoder,S="";for(;;){let{done:R,value:T}=await P.read();if(R)break;S+=E.decode(T,{stream:!0});let O=S.split(`
|
|
3
|
-
|
|
4
|
-
`);S=O.pop()??"";for(let L of O){let _=L.split(`
|
|
5
|
-
`).find((z)=>z.startsWith("data: "));if(!_)continue;let K;try{K=JSON.parse(_.slice(6))}catch{continue}let V=K.type;if(V==="login_started"&&typeof K.loginId==="string"){A=K.loginId;continue}if(V==="extension_ui_request"){let z={id:typeof K.id==="string"?K.id:"",...typeof K.method==="string"?{method:K.method}:{},...typeof K.title==="string"?{title:K.title}:{},...typeof K.message==="string"?{message:K.message}:{},...typeof K.url==="string"?{url:K.url}:{},...typeof K.launchUrl==="string"?{launchUrl:K.launchUrl}:{},...typeof K.instructions==="string"?{instructions:K.instructions}:{},...typeof K.placeholder==="string"?{placeholder:K.placeholder}:{},...typeof K.secret==="boolean"?{secret:K.secret}:{}},q=z.method;if(q==="open_url"){let G=z.url??null;b((H)=>({...H,status:"waiting",authUrl:G,launchUrl:z.launchUrl??null,instructions:z.instructions??null}));let j=z.launchUrl??G;if(Bn(j))window.open(j,"_blank","noopener");continue}if(q==="input"&&z.secret!==!0){b((G)=>({...G,status:"waiting",prompt:z}));continue}if(q==="notify"){let G=typeof z.title==="string"?z.title:"";b((j)=>({...j,status:"waiting",notices:G?[...j.notices,G]:j.notices})),N({id:z.id,accepted:!0});continue}N({id:z.id,cancelled:!0});continue}if(V==="login_result"){let z=K.success===!0;if(b((q)=>({...q,status:z?"success":"failed",error:z?null:typeof K.error==="string"?K.error:"Login failed"})),z)v.current();x.abort();return}}}}).catch((M)=>{if(x.signal.aborted)return;b((P)=>({...P,status:"failed",error:M instanceof Error?M.message:String(M)}))}),()=>{x.abort(),h.current=null}},[t,r]);let k=a((x)=>{let A=c.prompt;if(!A)return;h.current?.(x?{id:A.id,cancelled:!0}:{id:A.id,value:p}),b((N)=>({...N,prompt:null,status:"waiting",notices:x?N.notices:[...N.notices,"Sent to omp — waiting for the provider…"]})),g("")},[c.prompt,p]);return{state:c,inputValue:p,setInputValue:g,submitInput:k}}function Ka({isOpen:t,provider:r,onClose:l,onAuthenticated:c}){let{state:b,inputValue:p,setInputValue:g,submitInput:h}=_a({isOpen:t,providerId:r.slug,onAuthenticated:c});if(!t)return null;let v=Ba(b.instructions),k=Bn(b.launchUrl??b.authUrl),x=b.launchUrl??b.authUrl,A=(N)=>{navigator.clipboard?.writeText(N).catch(()=>{})};return e(J,{onClose:l,header:e("div",{className:"flex items-center gap-2.5",children:[e(Me,{provider:r,size:26}),e("div",{children:[e("h3",{className:"text-sm font-semibold text-ink",children:["Sign in to ",r.name]}),e("p",{className:"text-[11px] text-ink/50 font-mono",children:r.slug})]})]}),footer:e("div",{className:"px-5 py-3 border-t border-ink/10 flex items-center justify-between gap-3",children:[e("span",{className:"text-[11px] text-ink/45",children:b.status==="success"?"omp stored the credential — its models appear in the chat picker.":"The browser step runs on omp’s side; this dialog follows it."}),e("button",{type:"button",onClick:l,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:b.status==="success"?"Done":"Close"})]}),children:e("div",{className:"p-5 space-y-4",children:[b.status==="connecting"&&!b.prompt&&e("div",{className:"flex items-center gap-2.5 text-xs text-ink/70",children:[e(m,{size:14,className:"animate-spin"}),"Starting the login flow…"]}),b.authUrl&&e("div",{className:"space-y-2",children:[e("div",{className:"text-xs font-semibold text-ink",children:"Authorization URL"}),e("p",{className:"text-[11px] text-ink/55 leading-relaxed",children:k?"Finish the sign-in in the browser tab that opened. If it did not open, use the link below.":"This URL belongs to the machine running omp. Open it there, or copy it into a browser on that machine."}),e("div",{className:"flex items-start gap-2",children:[e("code",{className:"flex-1 min-w-0 text-[11px] font-mono break-all bg-ink/5 border border-ink/10 rounded-md px-2.5 py-2 text-ink/80 select-text",children:b.authUrl}),e("div",{className:"flex flex-col gap-1 shrink-0",children:[e("button",{type:"button",onClick:()=>A(b.authUrl),title:"Copy the authorization URL","aria-label":"Copy the authorization URL",className:"p-1.5 rounded-md border border-ink/15 text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:e(ie,{size:13})}),k&&x&&e("button",{type:"button",onClick:()=>window.open(x,"_blank","noopener"),title:"Open the authorization URL","aria-label":"Open the authorization URL",className:"p-1.5 rounded-md border border-ink/15 text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:e(Be,{size:13})})]})]})]}),v&&e("div",{className:"rounded-lg border border-ink/15 bg-ink/5 px-3 py-2.5 space-y-1.5",children:[e("div",{className:"text-[11px] font-semibold text-ink",children:"Device code"}),e("div",{className:"flex items-center gap-2",children:[e("code",{className:"text-sm font-mono font-semibold tracking-[0.12em] text-ink select-text",children:v}),e("button",{type:"button",onClick:()=>A(v),title:"Copy the device code","aria-label":"Copy the device code",className:"p-1 rounded text-ink/50 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:e(ie,{size:12})})]}),e("p",{className:"text-[10px] text-ink/50 leading-relaxed select-text",children:b.instructions})]}),!v&&b.instructions&&e("p",{className:"text-[11px] text-ink/60 leading-relaxed select-text",children:b.instructions}),b.prompt&&e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center gap-2 text-xs font-semibold text-ink",children:[e(lt,{size:13,className:"text-ink/50"}),b.prompt.title??b.prompt.message??"Authorization code"]}),e("input",{type:"text",autoFocus:!0,value:p,onChange:(N)=>g(N.currentTarget.value),onKeyDown:(N)=>N.key==="Enter"&&h(!1),placeholder:b.prompt.placeholder??"Paste the code or the full redirect URL",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"}),e("div",{className:"flex justify-end gap-2",children:[e("button",{type:"button",onClick:()=>h(!0),className:"px-3 py-1.5 rounded-md border border-ink/20 text-xs text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>h(!1),disabled:!p.trim(),className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-40",children:"Submit"})]})]}),b.notices.length>0&&e("ul",{className:"space-y-1",children:b.notices.map((N,M)=>e("li",{className:"flex items-start gap-2 text-[11px] text-ink/60",children:[e(m,{size:12,className:"mt-0.5 shrink-0 animate-spin"}),e("span",{className:"select-text",children:N})]},`${M}-${N}`))}),b.status==="success"&&e("div",{className:"flex items-center gap-2 text-xs text-success font-medium",children:[e(ne,{size:14})," Signed in. omp stored the credential."]}),b.status==="failed"&&e("div",{className:"flex items-start gap-2 text-xs text-error font-medium",children:[e(B,{size:14,className:"mt-0.5 shrink-0"}),e("span",{className:"select-text",children:b.error??"Login failed"})]})]})})}var mp=["minimal","low","medium","high","xhigh","max"];function za({isOpen:t,model:r,onClose:l,onSaveModelConfig:c}){let[b,p]=n(r?.maxTokens?String(r.maxTokens):""),[g,h]=n(r?.reasoningEffort??"");if(!t||!r)return null;let v=(k)=>{k.preventDefault();let x=Number.parseInt(b,10);c(r.id,{maxTokens:Number.isFinite(x)&&x>0?x:void 0,reasoningEffort:g||void 0}),l()};return e(J,{onClose:l,header:e("div",{className:"flex items-center gap-2",children:[e(mi,{size:16,className:"text-ink/70"}),e("div",{children:[e("h3",{className:"text-sm font-semibold text-ink",children:"Model Configuration"}),e("p",{className:"text-[11px] text-ink/50 truncate max-w-[280px]",children:r.name})]})]}),form:{onSubmit:v,className:"p-5 space-y-4"},footer:e("div",{className:"pt-2 flex items-center justify-end gap-2 border-t border-ink/10",children:[e("button",{type:"button",onClick:l,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"submit",className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer flex items-center gap-1.5",children:[e(f,{size:14}),e("span",{children:"Save Parameters"})]})]}),children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Max Output Tokens"}),e("input",{type:"number",min:1,step:1024,value:b,placeholder:"Catalog default",onChange:(k)=>p(k.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"}),e("p",{className:"text-[10px] text-ink/40 mt-0.5",children:"Written to models.yml as this model's output cap. Empty uses the catalog value."})]}),r.hasReasoning&&e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1.5",children:"Default Reasoning Effort"}),e("div",{className:"grid grid-cols-3 gap-2",children:[e("button",{type:"button",onClick:()=>h(""),className:`py-1.5 rounded-md text-xs font-medium border text-center transition-colors cursor-pointer ${g===""?"border-ink/50 bg-ink/10 text-ink":"border-ink/15 text-ink/60 hover:border-ink/30"}`,children:"Auto"}),mp.map((k)=>e("button",{type:"button",onClick:()=>h(k),className:`py-1.5 rounded-md text-xs font-medium border text-center transition-colors cursor-pointer capitalize ${g===k?"border-ink/50 bg-ink/10 text-ink":"border-ink/15 text-ink/60 hover:border-ink/30"}`,children:k},k))]}),e("p",{className:"text-[10px] text-ink/40 mt-0.5",children:"The level omp starts this model at. Auto leaves the choice to the chat composer."})]}),e("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md bg-ink/5 border border-ink/10 text-[11px] text-ink/60",children:e("span",{children:["Sampling temperature and Top P are global omp settings, not per-model — change them in ",e("span",{className:"font-medium text-ink",children:"Settings → OMP Engine"}),"."]})})]})}function Ha({isOpen:t,model:r,onClose:l}){if(!t||!r)return null;let c=pt(r.kind),b=r.thinkingEfforts??[],p=[{title:"Tool & function calling",desc:"The model can emit tool calls the agent executes (file edits, shell, search).",value:r.hasTools,icon:Ie},{title:"Image input",desc:"Accepts screenshots, diagrams and image attachments on the wire.",value:r.hasVision,icon:Ge},{title:"Reasoning",desc:"Produces thinking blocks before its answer.",value:r.hasReasoning,reported:r.hasReasoning===void 0,icon:Oa,...b.length>0?{detail:`Levels: ${b.join(" · ")}${r.thinkingMode?` (${r.thinkingMode})`:""}`}:{}},{title:"Catalog kind",desc:"Which role omp resolves this model for.",value:void 0,badge:!1,icon:lr,detail:`${st[c]} (${c})`}];return e(J,{onClose:l,header:e("div",{className:"flex items-center gap-2",children:[e(lr,{size:16,className:"text-ink/70"}),e("div",{className:"min-w-0",children:[e("h3",{className:"text-sm font-semibold text-ink",children:"Model capabilities"}),e("p",{className:"text-[11px] text-ink/50 font-mono truncate max-w-[280px]",children:r.id})]})]}),footer:e("div",{className:"px-5 py-3 border-t border-ink/10 flex items-center justify-between gap-3",children:[e("span",{className:"text-[11px] text-ink/45",children:"Read from omp’s own model record — “not reported” means the catalog says nothing, which is not the same as “no”."}),e("button",{type:"button",onClick:l,className:"px-4 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer",children:"Close"})]}),children:e("div",{className:"p-5 space-y-3",children:p.map((g)=>{let h=g.icon;return e("div",{className:"flex items-start gap-3 p-2.5 rounded-lg bg-ink/5 border border-ink/10",children:[e("div",{className:"p-1.5 rounded bg-ink/10 text-ink mt-0.5",children:e(h,{size:14})}),e("div",{className:"flex-1 min-w-0",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-xs font-semibold text-ink",children:g.title}),g.value===void 0?g.badge===!1?null:g.reported?e("span",{className:"text-[10px] text-ink/35 font-medium uppercase tracking-wider",title:"omp’s catalog reports nothing for this field",children:"not reported"}):null:g.value?e("span",{className:"inline-flex items-center gap-1 text-[10px] text-success font-semibold uppercase tracking-wider",children:[e(f,{size:11,strokeWidth:2.5}),"Yes"]}):e("span",{className:"inline-flex items-center gap-1 text-[10px] text-ink/40 font-medium uppercase tracking-wider",children:[e(Yt,{size:11,strokeWidth:2.5}),"No"]})]}),e("p",{className:"text-[11px] text-ink/60 mt-0.5 leading-relaxed",children:g.desc}),g.detail&&e("p",{className:"text-[10px] font-mono text-ink/50 mt-1 select-text",children:g.detail})]})]},g.title)})})})}function Wa({selected:t,onToggle:r,onSelectAll:l,onClear:c}){let b=t.length===at.length;return e("div",{children:[e("div",{className:"flex items-center justify-between mb-1.5",children:[e("label",{className:"block text-xs font-semibold text-ink",children:"Reasoning levels"}),e("div",{className:"flex items-center gap-2 text-[10px]",children:[e("button",{type:"button",onClick:l,disabled:b,className:"text-ink/50 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:"all"}),e("span",{className:"text-ink/20",children:"·"}),e("button",{type:"button",onClick:c,disabled:t.length===0,className:"text-ink/50 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:"none"})]})]}),e("div",{className:"grid grid-cols-3 gap-2",children:at.map((p)=>{let g=t.includes(p);return e("button",{type:"button",onClick:()=>r(p),"aria-pressed":g,className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg border text-left text-[11px] transition-colors cursor-pointer ${g?"border-ink/50 bg-ink/5 font-semibold text-ink":"border-ink/15 hover:border-ink/30 text-ink/70"}`,children:[e("span",{className:`w-3 h-3 rounded-[3px] border flex items-center justify-center shrink-0 ${g?"border-ink bg-ink text-canvas":"border-ink/30"}`,children:g&&e(f,{size:9,strokeWidth:3})}),e("span",{className:"truncate",children:p})]},p)})}),e("p",{className:"text-[10px] text-ink/40 mt-1",children:t.length===0?"No ladder declared — omp keeps its own default levels for this model.":`Only these levels will be offered: ${at.filter((p)=>t.includes(p)).join(", ")}.`})]})}function en({value:t,onChange:r,label:l,hint:c}){return e("div",{children:[e("label",{className:"block text-[11px] font-medium text-ink/70 mb-1",title:c,children:l}),e("div",{className:"relative flex items-center",children:[e(Go,{size:12,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",inputMode:"decimal",value:t,onChange:(b)=>r(b.currentTarget.value),placeholder:"0",className:"w-full bg-paper border border-ink/20 rounded-md pl-7 pr-2 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]})]})}function Ga({costInput:t,costOutput:r,costCacheRead:l,costCacheWrite:c,onCostInputChange:b,onCostOutputChange:p,onCostCacheReadChange:g,onCostCacheWriteChange:h,error:v}){return e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1.5",children:["Price ",e("span",{className:"font-normal text-ink/40",children:"(USD per 1M tokens, optional)"})]}),e("div",{className:"grid grid-cols-2 gap-3",children:[e(en,{value:t,onChange:b,label:"Input",hint:"Uncached prompt tokens"}),e(en,{value:r,onChange:p,label:"Output",hint:"Generated tokens"}),e(en,{value:l,onChange:g,label:"Cache read",hint:"Prompt tokens served from the provider's cache — usually a fraction of the input rate"}),e(en,{value:c,onChange:h,label:"Cache write",hint:"Prompt tokens written into the provider's cache"})]}),v&&e("p",{className:"text-[11px] text-error mt-1",children:v}),e("p",{className:"text-[10px] text-ink/40 mt-1",children:"Used for omp's cost accounting. Input and output decide whether a price is written at all; the cache rates fall back to 0, which bills cached turns at the full input rate."})]})}function qa({isOpen:t,provider:r,onClose:l,onAdded:c,onError:b}){let[p,g]=n(""),[h,v]=n(""),[k,x]=n(""),[A,N]=n(""),[M,P]=n(""),[E,S]=n(""),[R,T]=n(""),[O,L]=n(""),[_,K]=n("chat"),[V,z]=n(!1),[q,G]=n(!1),[j,H]=n([]),[X,oe]=n(!1);if(!t)return null;let te=p.trim(),Z=r.models.some((de)=>de.id===te),Q=!te?"Enter the model id exactly as the provider expects it.":Z?`"${te}" is already registered under this provider.`:"",re=(de,Te)=>de.trim()&&!(Number(de)>0)?`${Te} must be a positive number of tokens.`:"",ue=re(k,"Context window")||re(A,"Max output"),ve=(de)=>de.trim()&&!(Number(de)>=0)?"Prices must be zero or more USD per 1M tokens.":"",Ne=ve(M)||ve(E)||ve(R)||ve(O),ce=Boolean(M.trim())!==Boolean(E.trim())?"Enter both input and output price, or neither.":(R.trim()||O.trim())&&!M.trim()?"A cache rate needs the input and output price too.":"",be=!V&&j.length>0?"Turn on Reasoning to declare its levels.":"",Pe=Boolean(te)&&!Q&&!ue&&!Ne&&!ce&&!be&&!X,xe=(de)=>{let Te=Number(de);return de.trim()&&Number.isFinite(Te)?Te:void 0},We=(de)=>{H((Te)=>Te.includes(de)?Te.filter((ae)=>ae!==de):at.filter((ae)=>ae===de||Te.includes(ae)))},Ae=async(de)=>{if(de.preventDefault(),!Pe)return;oe(!0);try{let Te={provider:r.slug,id:te,...h.trim()?{name:h.trim()}:{},...xe(k)!==void 0?{contextWindow:xe(k)}:{},...xe(A)!==void 0?{maxTokens:xe(A)}:{},..._!=="chat"?{kind:_}:{},...V?{reasoning:!0}:{},...V&&j.length>0?{efforts:j}:{},...q?{imageInput:!0}:{},...M.trim()&&E.trim()?{costInput:xe(M),costOutput:xe(E),...xe(R)!==void 0?{costCacheRead:xe(R)}:{},...xe(O)!==void 0?{costCacheWrite:xe(O)}:{}}:{},...r.baseUrl?{baseUrl:r.baseUrl}:{},...r.apiKey?{apiKey:r.apiKey}:{},...r.auth?{auth:r.auth}:{}},ae=await Qi(Te);if(!ae.success){b(ae.error||ae.reason||`Could not register ${te}.`);return}c(te),l()}finally{oe(!1)}};return e(J,{onClose:l,header:e("div",{className:"flex items-center gap-2",children:[e(Y,{size:16,className:"text-ink/70"}),e("div",{children:[e("h3",{className:"text-sm font-semibold text-ink",children:"Add Model"}),e("p",{className:"text-[11px] text-ink/50 font-mono truncate max-w-[280px]",children:r.slug})]})]}),form:{onSubmit:Ae,className:"p-5 space-y-4"},footer:e("div",{className:"pt-2 flex items-center justify-end gap-2 border-t border-ink/10",children:[e("button",{type:"button",onClick:l,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"submit",disabled:!Pe,className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:X?e(d,{children:[e(An,{size:14,className:"animate-pulse"}),e("span",{children:"Registering..."})]}):e(d,{children:[e(f,{size:14}),e("span",{children:"Add Model"})]})})]}),children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Model ID"}),e("div",{className:"relative flex items-center",children:[e($a,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",required:!0,autoFocus:!0,value:p,onChange:(de)=>g(de.currentTarget.value),placeholder:"e.g. claude-sonnet-5 or my-deployment",className:"w-full bg-paper border border-ink/20 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]}),Q&&e("p",{className:"text-[11px] text-error mt-1",children:Q}),e("p",{className:"text-[10px] text-ink/40 mt-1",children:"Sent to the provider verbatim — this is the id omp puts on the wire."})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:["Display Name ",e("span",{className:"font-normal text-ink/40",children:"(optional)"})]}),e("input",{type:"text",value:h,onChange:(de)=>v(de.currentTarget.value),placeholder:"Shown in the chat model picker",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60"})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Kind"}),e("select",{value:_,onChange:(de)=>K(de.currentTarget.value),className:"w-full text-xs py-2 px-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors cursor-pointer",children:jn.map((de)=>e("option",{value:de,children:st[de]},de))}),e("p",{className:"text-[10px] text-ink/40 mt-1",children:"Chat is omp’s default. A non-chat kind keeps this model out of the chat picker."})]}),e("div",{className:"grid grid-cols-2 gap-3",children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:["Context window ",e("span",{className:"font-normal text-ink/40",children:"(tokens)"})]}),e("input",{type:"text",inputMode:"numeric",value:k,onChange:(de)=>x(de.currentTarget.value),placeholder:"200000",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:["Max output ",e("span",{className:"font-normal text-ink/40",children:"(tokens)"})]}),e("input",{type:"text",inputMode:"numeric",value:A,onChange:(de)=>N(de.currentTarget.value),placeholder:"8192",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]})]}),ue&&e("p",{className:"text-[11px] text-error -mt-2",children:ue}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1.5",children:"Capabilities"}),e("div",{className:"grid grid-cols-2 gap-2",children:[e("button",{type:"button",onClick:()=>z((de)=>!de),"aria-pressed":V,className:`flex items-center gap-2 px-2.5 py-2 rounded-lg border text-left text-[11px] transition-colors cursor-pointer ${V?"border-ink/50 bg-ink/5 font-semibold text-ink":"border-ink/15 hover:border-ink/30 text-ink/70"}`,children:[e(Fe,{size:13,className:"shrink-0"}),e("span",{className:"truncate",children:"Reasoning"})]}),e("button",{type:"button",onClick:()=>G((de)=>!de),"aria-pressed":q,className:`flex items-center gap-2 px-2.5 py-2 rounded-lg border text-left text-[11px] transition-colors cursor-pointer ${q?"border-ink/50 bg-ink/5 font-semibold text-ink":"border-ink/15 hover:border-ink/30 text-ink/70"}`,children:[e(De,{size:13,className:"shrink-0"}),e("span",{className:"truncate",children:"Vision"})]})]}),e("p",{className:"text-[10px] text-ink/40 mt-1",children:"Leave both off when unsure — omp still serves the model; only its declared abilities change."})]}),V&&e(Wa,{selected:j,onToggle:We,onSelectAll:()=>H([...at]),onClear:()=>H([])}),be&&e("p",{className:"text-[11px] text-error -mt-2",children:be}),e(Ga,{costInput:M,costOutput:E,costCacheRead:R,costCacheWrite:O,onCostInputChange:P,onCostOutputChange:S,onCostCacheReadChange:T,onCostCacheWriteChange:L,error:Ne||ce})]})}function Va({isOpen:t,provider:r,isDeleting:l,onClose:c,onConfirm:b}){if(i(()=>{let k=(x)=>{if(x.key!=="Escape"||l)return;x.preventDefault(),c()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[c,l]),!t||!r)return null;let p=r.models.length,g=r.inModelsYml===!0,h=!g,v=r.credentialOrigin==="environment";return e("div",{className:"fixed inset-0 z-[70] flex items-center justify-center modal-scrim backdrop-blur-[2px] p-4",onClick:l?void 0:c,role:"dialog","aria-modal":"true","aria-label":"Confirm provider deletion",children:e("div",{className:"glass-overlay bg-paper border border-ink/20 rounded-xl shadow-2xl w-[min(94vw,460px)] max-h-full overflow-y-auto scrollbar-overlay-container text-ink",onClick:(k)=>k.stopPropagation(),children:[e("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-ink/10",children:[e(U,{size:16,className:"text-error shrink-0"}),e("div",{className:"min-w-0",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Delete provider?"}),e("p",{className:"text-[11px] text-ink/50 truncate",children:e("span",{className:"font-mono",children:r.slug})})]})]}),e("div",{className:"px-5 py-4 space-y-3",children:[e("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg bg-ink/5 border border-ink/10",children:[e(Me,{provider:r,size:26}),e("span",{className:"text-xs font-medium text-ink truncate",children:r.name})]}),e("ul",{className:"text-[11.5px] leading-relaxed text-ink/70 space-y-1.5",children:[g?e(d,{children:[e("li",{children:["Its entry is removed from"," ",e("span",{className:"font-mono text-ink",children:"~/.omp/agent/models.yml"}),p>0?`, along with its ${p} registered model${p===1?"":"s"}.`:"."]}),e("li",{children:"The endpoint and API key stored on that entry are removed with it. They are shown masked here, so you would need to enter them again."})]}):e(d,{children:[e("li",{children:"Kabmo’s own settings row for this provider is removed (per-model visibility and sampling choices). omp keeps the provider itself."}),e("li",{children:["The provider and its models stay available to the chat picker — use"," ",e("span",{className:"text-ink",children:"disable"})," to hide them instead."]})]}),v&&e("li",{className:"text-ink/60",children:"Its credential comes from an environment variable, which this cannot remove."}),r.credentialSource==="omp-auth"&&e("li",{className:"text-ink/60",children:["Your omp login for ",e("span",{className:"font-mono",children:r.slug})," is NOT touched — only the entry above. The provider stays available through that login."]})]}),e("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md border border-error/30 bg-error/5 text-[11px] text-ink/75",children:[e(D,{size:13,className:"mt-0.5 shrink-0 text-error"}),e("span",{children:h?"Only Kabmo’s stored preferences go — nothing in omp’s own configuration changes.":"This cannot be undone from the UI. Re-adding the provider starts from an empty endpoint and key."})]})]}),e("div",{className:"flex items-center justify-end gap-2 px-5 py-3.5 border-t border-ink/10",children:[e("button",{type:"button",onClick:c,disabled:l,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:"Cancel"}),e("button",{type:"button",onClick:b,disabled:l,className:"px-3.5 py-1.5 rounded-md bg-error text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:l?e(d,{children:[e(m,{size:13,className:"animate-spin"}),e("span",{children:"Deleting..."})]}):e(d,{children:[e(U,{size:13}),e("span",{children:"Delete provider"})]})})]})]})})}function _n(t){return t&&typeof t==="object"?t:null}async function Ya(t){try{let r=await fetch("/api/settings/providers/logout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:t})}),l=_n(await r.json().catch(()=>null));if(!r.ok){let p=l&&typeof l.error==="string"?l.error:`HTTP ${r.status}`;return{accounts:[],error:p}}let c=l?.accounts;if(!Array.isArray(c))return{accounts:[]};let b=[];for(let p of c){let g=_n(p);if(!g||typeof g.credentialId!=="number")continue;b.push({credentialId:g.credentialId,label:typeof g.label==="string"?g.label:`credential ${g.credentialId}`,...g.active===!0?{active:!0}:{}})}return{accounts:b}}catch(r){return{accounts:[],error:r instanceof Error?r.message:String(r)}}}async function Ja(t,r){try{let l=await fetch("/api/settings/providers/logout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:t,credentialId:r})}),c=_n(await l.json().catch(()=>null));if(!l.ok)return{error:c&&typeof c.error==="string"?c.error:`HTTP ${l.status}`};return{...c&&typeof c.remainingSource==="string"?{remainingSource:c.remainingSource}:{}}}catch(l){return{error:l instanceof Error?l.message:String(l)}}}function Xa({isOpen:t,provider:r,onClose:l,onSignedOut:c}){let[b,p]=n(null),[g,h]=n(null),[v,k]=n(null);if(i(()=>{if(!t||!r)return;let A=!1;return p(null),k(null),Ya(r.slug).then((N)=>{if(A)return;if(N.error){k(N.error),p([]);return}p(N.accounts)}),()=>{A=!0}},[t,r]),i(()=>{let A=(N)=>{if(N.key!=="Escape"||g!==null)return;N.preventDefault(),l()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[l,g]),!t||!r)return null;let x=async(A)=>{h(A),k(null);let N=await Ja(r.slug,A);if(h(null),N.error){k(N.error);return}c(N.remainingSource?`Signed out of ${r.name}. It still authenticates via ${N.remainingSource}.`:`Signed out of ${r.name} — its stored credential is gone.`)};return e("div",{className:"fixed inset-0 z-[70] flex items-center justify-center modal-scrim backdrop-blur-[2px] p-4",onClick:g!==null?void 0:l,role:"dialog","aria-modal":"true","aria-label":"Confirm sign out",children:e("div",{className:"glass-overlay bg-paper border border-ink/20 rounded-xl shadow-2xl w-[min(94vw,480px)] max-h-full overflow-y-auto scrollbar-overlay-container text-ink",onClick:(A)=>A.stopPropagation(),children:[e("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-ink/10",children:[e(jt,{size:16,className:"text-error shrink-0"}),e("div",{className:"min-w-0",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Sign out?"}),e("p",{className:"text-[11px] text-ink/50 truncate",children:e("span",{className:"font-mono",children:r.slug})})]})]}),e("div",{className:"px-5 py-4 space-y-3",children:[e("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg bg-ink/5 border border-ink/10",children:[e(Me,{provider:r,size:26}),e("span",{className:"text-xs font-medium text-ink truncate",children:r.name})]}),v&&e("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md border border-error/30 bg-error/5 text-[11px] text-ink/80",children:[e(D,{size:13,className:"mt-0.5 shrink-0 text-error"}),e("span",{children:v})]}),b===null?e("div",{className:"flex items-center gap-2 py-3 text-[11.5px] text-ink/55",children:[e(m,{size:13,className:"animate-spin"}),e("span",{children:"Reading stored credentials…"})]}):b.length===0?e("p",{className:"text-[11.5px] leading-relaxed text-ink/70",children:["omp holds no removable credential for this provider — its authentication comes from somewhere this dialog cannot touch (an API key in"," ",e("span",{className:"font-mono text-ink",children:"models.yml"}),", or the environment). Use ",e("span",{className:"font-medium text-ink",children:"disable"})," to hide it instead."]}):e(d,{children:[e("p",{className:"text-[11.5px] leading-relaxed text-ink/70",children:["This removes the stored credential. The provider disappears from the model list until you sign in again — different from"," ",e("span",{className:"font-medium text-ink",children:"disable"}),", which only hides it and leaves the credential in place."]}),e("div",{className:"space-y-1.5",children:b.map((A)=>e("div",{className:"flex items-center justify-between gap-3 px-3 py-2 rounded-md border border-ink/15 bg-paper",children:[e("div",{className:"min-w-0",children:[e("div",{className:"text-[11.5px] text-ink truncate",children:A.label}),A.active&&e("div",{className:"text-[10px] text-ink/45",children:"in use"})]}),e("button",{type:"button",onClick:()=>void x(A.credentialId),disabled:g!==null,className:"shrink-0 px-2.5 py-1 rounded-md bg-error/10 hover:bg-error/20 text-error text-[11px] font-medium border border-error/30 transition-colors cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:g===A.credentialId?e(d,{children:[e(m,{size:11,className:"animate-spin"}),e("span",{children:"removing…"})]}):e("span",{children:"sign out"})})]},A.credentialId))}),e("p",{className:"text-[11px] text-ink/55",children:["A ",e("span",{className:"font-mono",children:"models.yml"})," entry for this provider is not touched — use ",e("span",{className:"font-medium text-ink",children:"delete"})," for that."]})]})]}),e("div",{className:"flex items-center justify-end gap-2 px-5 py-3.5 border-t border-ink/10",children:e("button",{type:"button",onClick:l,disabled:g!==null,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:"Close"})})]})})}function Qa({autoOpenAdd:t=!1,onAddModalClose:r}){let l=ke(),{providers:c,availablePresetProviders:b,existingSlugs:p,selectedProvider:g,catalogError:h,isLoading:v,isRefreshingList:k,handleRefreshList:x,isFetchingModels:A,isRefreshingIcon:N,handleRefreshIcon:M,pushToast:P,isAddModelModalOpen:E,setIsAddModelModalOpen:S,handleModelAdded:R,handleSignedOut:T,isDeleteModalOpen:O,setIsDeleteModalOpen:L,isLogoutModalOpen:_,setIsLogoutModalOpen:K,isDeletingProvider:V,isAddModalOpen:z,setIsAddModalOpen:q,isEntryModalOpen:G,setIsEntryModalOpen:j,isLoginModalOpen:H,setIsLoginModalOpen:X,configModel:oe,setConfigModel:te,capabilitiesModel:Z,setCapabilitiesModel:Q,setSelectedProviderId:re,handleAddProvider:ue,handleConnect:ve,handleEntrySaved:Ne,handleRefreshModels:ce,handleFetchModels:be,handleOmpAuthSuccess:Pe,handleToggleProviderDisabled:xe,handleDeleteProvider:We,handleHideAll:Ae,handleShowAll:de,handleToggleModelVisibility:Te,handleSaveModelConfig:ae}=ra({autoOpenAdd:t,onAddModalClose:r});return e("div",{className:"w-full h-full flex flex-col overflow-hidden bg-paper text-ink",children:[e(ye,{pane:z?"detail":l.pane,onBack:l.back,listLabel:"Providers",list:e(sa,{providers:c,selectedProviderId:g?.id??"",onSelectProvider:(me)=>{re(me),l.openDetail()},onOpenAddModal:()=>q(!0),onRefresh:()=>void x(),isRefreshing:k,isLoading:v,...h?{catalogError:h}:{}}),detail:e("div",{className:"flex-1 scrollbar-overlay-container p-6 md:p-8 space-y-6",children:g?e(d,{children:[e(la,{provider:g,onRefreshIcon:()=>void M(),isRefreshingIcon:N}),e(ka,{provider:g,onConnect:ve,onToggleDisabled:xe,onDelete:()=>L(!0),onSignOut:()=>K(!0)}),e(Na,{models:g.models,emptyReason:wa(g),onToggleModelVisibility:Te,onHideAll:Ae,onShowAll:de,onRefreshModels:ce,onImportModels:be,onAddModel:()=>S(!0),fetchBlockReason:Sa(g),isFetchingModels:A,onOpenModelConfig:(me)=>te(me),onOpenModelCapabilities:(me)=>Q(me)})]}):v?e("div",{className:"py-12 text-center text-xs text-ink/40",children:"Reading omp’s provider registry…"}):e("div",{className:"py-12 text-center text-xs text-ink/40 space-y-2",children:[e("p",{children:"omp reports no providers yet."}),e("p",{className:"text-[11px] text-ink/35",children:"Sign in to a provider from the list, or add one with the plus button."})]})})}),e(Ma,{isOpen:z,onClose:()=>{q(!1),r?.()},onAddProvider:async(me,$e)=>{await ue(me,$e),l.openDetail()},presets:b,existingSlugs:p}),g&&e(Da,{isOpen:G,provider:g,onClose:()=>j(!1),onSaved:(me)=>void Ne(me)},g.id),g&&e(Ka,{isOpen:H,provider:g,onClose:()=>X(!1),onAuthenticated:()=>void Pe()}),g&&e(qa,{isOpen:E,provider:g,onClose:()=>S(!1),onAdded:(me)=>void R(me),onError:(me)=>P(me,"error")}),e(Xa,{isOpen:_,provider:g??null,onClose:()=>K(!1),onSignedOut:(me)=>void T(me)}),e(Va,{isOpen:O,provider:g??null,isDeleting:V,onClose:()=>L(!1),onConfirm:()=>void We()}),e(za,{isOpen:!!oe,model:oe,onClose:()=>te(null),onSaveModelConfig:ae}),e(Ha,{isOpen:!!Z,model:Z,onClose:()=>Q(null)})]})}var Za=(t)=>t.value??t.id,gp=(t,r)=>t.find((l)=>l.id===r||Za(l)===r)?.name??r,Xe=({selectedProject:t,onChangeProject:r,options:l=[],getTriggerLabel:c=gp,variant:b="default"})=>{let[p,g]=n(!1),h=o(null);le(h,()=>g(!1));let v=c(l,t),k=l.map((x)=>{let A=Za(x),N=t===A;return e("button",{type:"button",onClick:()=>{r(A),g(!1)},className:b==="compact"?`w-full text-left px-3 py-1.5 text-xs flex items-center justify-between hover:bg-ink/5 transition-colors cursor-pointer ${N?"text-ink font-semibold bg-ink/5":"text-ink/70"}`:`w-full px-3 py-1.5 text-left text-xs flex items-center justify-between hover:bg-ink/5 transition-colors cursor-pointer ${N?"font-semibold text-ink bg-ink/5":"text-ink/80"}`,children:b==="compact"?e(d,{children:[e("span",{className:"truncate",children:x.label}),N&&e(f,{size:12,className:"text-ink flex-shrink-0"})]}):e("div",{className:"flex items-center gap-2 truncate",children:[e(tt,{size:13,className:"text-ink/60"}),e("span",{className:"truncate",children:x.name})]})},x.id)});if(l.length===0)return e("div",{className:b==="compact"?"p-2.5 border-b border-ink/10":"p-3 border-b border-ink/10",children:e("div",{className:"flex items-center gap-2 px-2.5 py-1.5 rounded-lg border border-dashed border-ink/15 text-[11px] text-ink/50",children:[e(tt,{size:13,className:"text-ink/40 flex-shrink-0"}),e("span",{className:"truncate",children:"No projects yet. Add one in Settings, Projects"})]})});if(b==="compact")return e("div",{className:"p-2.5 border-b border-ink/10 relative",ref:h,children:[e("button",{type:"button",onClick:()=>g(!p),className:"w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper text-xs text-ink transition-colors cursor-pointer",children:[e("div",{className:"flex items-center gap-2 truncate",children:[e(tt,{size:14,className:"text-ink/60 flex-shrink-0"}),e("span",{className:"truncate font-medium",children:v})]}),e(I,{size:14,className:"text-ink/50 flex-shrink-0"})]}),p&&e(d,{children:[e("div",{className:"fixed inset-0 z-20",onClick:()=>g(!1)}),e("div",{className:"glass-popover absolute left-2.5 right-2.5 top-12 z-30 bg-paper border border-ink/15 rounded-lg shadow-lg py-1 animate-in fade-in zoom-in-95 duration-100",children:k})]})]});return e("div",{className:"p-3 border-b border-ink/10 relative",ref:h,children:[e("button",{type:"button",onClick:()=>g(!p),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs",children:[e("div",{className:"flex items-center gap-2 truncate",children:[e(tt,{size:14,className:"text-ink/60 flex-shrink-0"}),e("span",{className:"truncate",children:v})]}),e(I,{size:14,className:"text-ink/50 flex-shrink-0"})]}),p&&e("div",{className:"glass-popover absolute top-12 left-3 right-3 bg-paper border border-ink/20 rounded-lg shadow-lg z-30 py-1 divide-y divide-ink/5 animate-in fade-in zoom-in-95 duration-100",children:k})]})};var tn=({items:t,selectedId:r,onSelect:l,onAddNew:c,addTitle:b,builtInLabel:p,customLabel:g,formatName:h,nameClassName:v,renderIcon:k,selectedProject:x,onChangeProject:A,projectOptions:N,loadError:M,onRetry:P})=>{let E=t.filter((T)=>T.isBuiltIn),S=t.filter((T)=>!T.isBuiltIn),R=(T)=>{let O=T.id===r;return e("button",{type:"button",onClick:()=>l(T.id),className:`w-full text-left px-2.5 py-2 rounded-lg transition-colors cursor-pointer flex flex-col gap-0.5 group ${O?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e("div",{className:"flex items-center justify-between gap-1.5",children:[e("div",{className:"flex items-center gap-1.5 min-w-0",children:[k(Boolean(T.isBuiltIn)),e("span",{className:v,children:h(T.name)})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:T.scope})]}),e("p",{className:"text-[11px] text-ink/60 line-clamp-1 leading-snug pl-5",children:T.description})]},T.id)};return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0 select-none",children:[e(Xe,{selectedProject:x,onChangeProject:A,...N?{options:N}:{}}),e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex items-center justify-between",children:[e("span",{className:"text-xs font-semibold text-ink",children:["Total ",t.length]}),e("button",{type:"button",onClick:c,title:b,className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:e(Y,{size:15,strokeWidth:2.2})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-1.5 space-y-3 text-xs",children:[M&&e("div",{className:"mx-1 rounded-lg border border-error/30 bg-error/5 px-2.5 py-2 text-[11px] leading-snug text-error",children:[e("div",{className:"font-semibold",children:"Could not read the list"}),e("div",{className:"mt-0.5 break-words text-error/80",children:M}),P&&e("button",{type:"button",onClick:P,className:"mt-1.5 rounded border border-error/40 px-2 py-0.5 font-medium hover:bg-error/10 cursor-pointer",children:"Retry"})]}),e("div",{children:[e("div",{className:"px-2.5 pt-1.5 pb-1 text-[10px] font-bold text-ink/50 uppercase tracking-wider",children:p}),e("div",{className:"space-y-0.5",children:E.map(R)})]}),e("div",{children:[e("div",{className:"px-2.5 pt-1.5 pb-1 text-[10px] font-bold text-ink/50 uppercase tracking-wider flex items-center justify-between",children:[e("span",{children:g}),e("span",{className:"text-[10px] font-normal",children:S.length})]}),e("div",{className:"space-y-0.5",children:S.map(R)})]})]})]})};var es=({agents:t,selectedAgentId:r,onSelectAgent:l,onAddNewAgent:c,selectedProject:b,onChangeProject:p,projectOptions:g,loadError:h,onRetry:v})=>e(tn,{items:t,selectedId:r,onSelect:l,onAddNew:c,addTitle:"Create new agent",builtInLabel:"Project scope (read-only)",customLabel:"Your agent files",formatName:(k)=>k,nameClassName:"font-semibold text-xs text-ink truncate",selectedProject:b,onChangeProject:p,...g?{projectOptions:g}:{},...h?{loadError:h}:{},...v?{onRetry:v}:{},renderIcon:(k)=>e("div",{className:"relative",children:[e(xt,{className:`w-3.5 h-3.5 ${k?"text-ink/80":"text-ink/60"} flex-shrink-0`}),k&&e("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 rounded-full bg-ink"})]})});var fp=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;function Pt(t){let r=t.trim();if(!r)return"An agent needs a name — it becomes the definition’s file name.";if(!fp.test(r))return"Use letters, numbers, dots, dashes or underscores, starting with a letter or number.";return null}var vp=2000;function Qe(){let[t,r]=n(!1),[l,c]=n(!1),[b,p]=n(null),g=o(void 0),h=a(()=>p(null),[]),v=a(async(k)=>{r(!0),p(null),clearTimeout(g.current),c(!1);try{let x=await k();if(!x.ok)return p(x.error??"The server refused the write."),!1;return c(!0),g.current=setTimeout(()=>c(!1),vp),!0}catch(x){return p(x instanceof Error?x.message:String(x)),!1}finally{r(!1)}},[]);return{saving:t,saved:l,error:b,dismissError:h,run:v}}var xp="Not selected";function ts({value:t,disabled:r,onChange:l}){let c=Ua((p)=>{if(!Array.isArray(p.modelList)||p.modelList.length===0)return;return p.modelList.map((g)=>({selector:`${g.provider}/${g.id}`,provider:g.provider,name:g.name||g.id}))})??[],b=c.some((p)=>p.selector===t);return e(Le,{ariaLabel:"Override model",value:t,placeholder:xp,onChange:l,disabled:r,className:"w-full rounded-lg py-2 pl-2 pr-3 text-xs hover:border-ink/40 focus:border-ink disabled:opacity-60",options:[...t&&!b?[{value:t,label:`${t} (not in catalog)`}]:[],...c.map((p)=>({value:p.selector,label:p.name,hint:p.selector,group:p.provider}))]})}var ns=["off","minimal","low","medium","high","xhigh","max","auto"],zn="";function os(){return{id:"new-agent",name:"new-agent",description:"",scope:"user",thinkingLevel:"",systemPrompt:"",isBuiltIn:!1}}var Gn=({agent:t,isNew:r=!1,previousFileName:l=null,onSave:c,onDelete:b})=>{let[p,g]=n(t),[h,v]=n((t.tools??[]).join(", ")),[k,x]=n(!1),[A,N]=n(!1),M=Qe(),P=t.sourceRoot==="project";i(()=>{g(t),v((t.tools??[]).join(", ")),N(!1)},[t]);let E=(()=>{if(P)return null;let O=Pt(p.name);if(O)return O;if(!p.systemPrompt.trim())return"A system prompt is required — an empty agent does nothing.";return null})(),S=p.name!==t.name||p.description!==t.description||(p.model??"")!==(t.model??"")||(p.thinkingLevel??"")!==(t.thinkingLevel??"")||(p.spawns??"")!==(t.spawns??"")||h!==(t.tools??[]).join(", ")||p.systemPrompt!==t.systemPrompt,R=(O)=>{if(O.preventDefault(),P||E||M.saving)return;let _=h.trim()!==(t.tools??[]).join(", ")?h.split(",").map((K)=>K.trim()).filter(Boolean):void 0;M.run(()=>c({...p,name:p.name.trim(),tools:_},l))},T=()=>{if(!b)return;M.run(async()=>{let O=await b(t);if(!O.ok)N(!1);return O})};return e("form",{onSubmit:R,className:"flex-1 flex flex-col h-full scrollbar-overlay-container bg-paper text-ink p-6 md:p-8 space-y-6",children:[P&&e("div",{className:"rounded-lg border border-ink/15 bg-ink/5 px-3 py-2 text-[11px] leading-relaxed text-ink/70",children:["This agent is defined by the workspace at"," ",e("span",{className:"font-mono text-ink/80",children:t.filePath}),". It is listed here and stays read-only: that ",e("span",{className:"font-mono",children:".omp/agents"})," directory belongs to the project."]}),e("div",{className:"space-y-3",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("h2",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:"Identity & Role"}),t.fileName&&e("span",{className:"truncate font-mono text-[10px] text-ink/40",title:t.filePath,children:[t.sourceRoot==="project"?".omp/agents":"~/.omp/agent/agents","/",t.fileName,".md"]})]}),e("div",{children:[e("label",{className:"mb-1.5 block text-xs font-semibold text-ink/80",children:"Agent name"}),e("input",{type:"text",value:p.name,onInput:(O)=>g({...p,name:O.currentTarget.value}),required:!0,placeholder:"agent-name",disabled:P||M.saving,"aria-invalid":Pt(p.name)?!0:void 0,className:"w-full rounded-lg border border-ink/20 bg-paper px-3 py-2 font-mono text-xs text-ink transition-colors hover:border-ink/40 focus:border-ink focus:outline-none disabled:opacity-60"}),e("p",{className:"mt-1 text-[10px] text-ink/45",children:"The file name omp loads it from — letters, numbers, dots, dashes, underscores."})]}),e("div",{children:[e("label",{className:"mb-1.5 block text-xs font-semibold text-ink/80",children:"Description"}),e("textarea",{value:p.description,onInput:(O)=>g({...p,description:O.currentTarget.value}),placeholder:"What does this agent do? Shown when omp lists it.",rows:2,disabled:P||M.saving,className:"w-full rounded-lg border border-ink/20 bg-paper p-3 text-xs text-ink transition-colors hover:border-ink/40 focus:border-ink focus:outline-none placeholder:text-ink/35 disabled:opacity-60"}),e("p",{className:"mt-1 text-[10px] text-ink/45",children:"Required by omp: a definition without a description is not loaded at all."})]})]}),e("div",{className:"border-t border-ink/10"}),e("div",{className:"space-y-3",children:[e("h2",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:"Model & Capabilities"}),e("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[e("div",{children:[e("div",{className:"mb-1.5 flex items-center gap-1",children:[e("label",{className:"text-xs font-semibold text-ink/80",children:"Model"}),e("span",{title:"A provider/model selector from the live catalog. Leave it unselected to inherit the session model.",children:e(pe,{className:"h-3.5 w-3.5 text-ink/40"})})]}),e(ts,{value:p.model??"",disabled:P||M.saving,onChange:(O)=>g({...p,model:O||void 0})})]}),e("div",{children:[e("div",{className:"mb-1.5 flex items-center gap-1",children:[e("label",{className:"text-xs font-semibold text-ink/80",children:"Thinking level"}),e("span",{title:"An omp thinking selector. “inherit” leaves the level to the session.",children:e(pe,{className:"h-3.5 w-3.5 text-ink/40"})})]}),e("select",{"aria-label":"Thinking level",value:p.thinkingLevel??zn,onChange:(O)=>g({...p,thinkingLevel:O.currentTarget.value||void 0}),disabled:P||M.saving,className:"w-full cursor-pointer rounded-lg border border-ink/20 bg-paper py-2 pl-2 pr-3 font-mono text-xs text-ink transition-colors hover:border-ink/40 focus:border-ink focus:outline-none disabled:opacity-60",children:[e("option",{value:zn,children:"inherit (session level)"}),ns.map((O)=>e("option",{value:O,children:O},O))]})]}),e("div",{children:[e("div",{className:"mb-1.5 flex items-center gap-1",children:[e("label",{className:"text-xs font-semibold text-ink/80",children:"Tools"}),e("span",{title:"Comma-separated tool names. Empty means omp's default set for this kind of agent.",children:e(pe,{className:"h-3.5 w-3.5 text-ink/40"})})]}),e("input",{type:"text",value:h,onInput:(O)=>v(O.currentTarget.value),placeholder:"read, grep, glob, edit",disabled:P||M.saving,className:"w-full rounded-lg border border-ink/20 bg-paper px-3 py-2 font-mono text-xs text-ink transition-colors hover:border-ink/40 focus:border-ink focus:outline-none placeholder:text-ink/35 disabled:opacity-60"})]}),e("div",{children:[e("div",{className:"mb-1.5 flex items-center gap-1",children:[e("label",{className:"text-xs font-semibold text-ink/80",children:"Spawns"}),e("span",{title:"Which agents this one may delegate to: * for any, or a comma-separated list.",children:e(pe,{className:"h-3.5 w-3.5 text-ink/40"})})]}),e("input",{type:"text",value:p.spawns??"",onInput:(O)=>g({...p,spawns:O.currentTarget.value||void 0}),placeholder:"*",disabled:P||M.saving,className:"w-full rounded-lg border border-ink/20 bg-paper px-3 py-2 font-mono text-xs text-ink transition-colors hover:border-ink/40 focus:border-ink focus:outline-none placeholder:text-ink/35 disabled:opacity-60"})]})]})]}),e("div",{className:"border-t border-ink/10"}),e("div",{className:"flex flex-1 flex-col space-y-2",children:[e("div",{className:"flex items-center justify-between",children:[e("label",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:"System prompt"}),e("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(p.systemPrompt).then(()=>{x(!0),setTimeout(()=>x(!1),1800)}).catch((O)=>console.error("Failed to copy the system prompt:",O))},className:"flex items-center gap-1.5 text-xs text-ink/60 transition-colors hover:text-ink cursor-pointer",children:[k?e(f,{className:"h-3.5 w-3.5 text-ink"}):e(ie,{className:"h-3.5 w-3.5"}),e("span",{children:k?"Copied":"Copy"})]})]}),e("textarea",{value:p.systemPrompt,onInput:(O)=>g({...p,systemPrompt:O.currentTarget.value}),rows:7,disabled:P||M.saving,placeholder:"You are an expert coding assistant…","aria-invalid":E&&!Pt(p.name)?!0:void 0,className:`min-h-[140px] w-full flex-1 rounded-lg border bg-ink/5 p-3 font-mono text-xs leading-relaxed text-ink transition-colors hover:border-ink/40 focus:border-ink focus:outline-none disabled:opacity-60 ${E&&!Pt(p.name)?"border-error":"border-ink/20"}`})]}),M.error&&e("div",{className:"flex items-start gap-1.5 rounded-lg border border-error/30 bg-error/5 px-3 py-2 text-[11px] text-error",children:[e(B,{className:"mt-px h-3.5 w-3.5 flex-shrink-0"}),e("span",{className:"flex-1 break-words",children:M.error}),e("button",{type:"button",onClick:M.dismissError,className:"cursor-pointer text-error/60 hover:text-error","aria-label":"Dismiss error",children:"×"})]}),e("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-ink/10 pt-3",children:[e("div",{className:"flex items-center gap-2",children:!P&&!r&&b&&(A?e(d,{children:[e("span",{className:"text-[11px] text-ink/70",children:["Delete “",t.name,"”? The file is removed."]}),e("button",{type:"button",onClick:T,disabled:M.saving,className:"rounded-lg border border-error/40 px-2.5 py-1 text-xs font-medium text-error transition-colors hover:bg-error/10 cursor-pointer disabled:opacity-50",children:"Delete"}),e("button",{type:"button",onClick:()=>N(!1),className:"px-2 py-1 text-xs text-ink/50 transition-colors hover:text-ink cursor-pointer",children:"Cancel"})]}):e("button",{type:"button",onClick:()=>N(!0),className:"flex items-center gap-1.5 rounded-lg border border-ink/20 px-3.5 py-2 text-xs font-medium text-ink/70 transition-colors hover:border-error hover:text-error cursor-pointer",children:[e(U,{className:"h-3.5 w-3.5"}),"Delete agent"]}))}),e("div",{className:"flex items-center gap-3",children:[M.saved&&e("span",{className:"flex items-center gap-1 text-xs font-medium text-ink",children:[e(f,{className:"h-3.5 w-3.5"})," Saved to the agent file"]}),E&&!M.saved&&e("span",{className:"max-w-[16rem] text-right text-[11px] leading-snug text-error",children:E}),!P&&e("button",{type:"submit",disabled:M.saving||Boolean(E)||!r&&!S,title:!r&&!S?"Nothing changed yet":void 0,className:"flex items-center gap-1.5 rounded-lg bg-ink px-4 py-2 text-xs font-medium text-paper shadow-xs transition-colors hover:bg-ink/90 cursor-pointer disabled:cursor-not-allowed disabled:opacity-40",children:[M.saving?e(m,{className:"h-3.5 w-3.5 animate-spin"}):e(yt,{className:"h-3.5 w-3.5"}),r?"Create agent":"Save agent"]})]})]})]})};function rs(t){if(typeof t!=="object"||t===null||!("agents"in t))return null;return Array.isArray(t.agents)?t.agents:null}function as(t){if(typeof t!=="object"||t===null||!("error"in t))return;return typeof t.error==="string"?t.error:void 0}function ss(t){let[r,l]=n([]),[c,b]=n(null),[p,g]=n(!0),[h,v]=n(null),[k,x]=n(0);i(()=>{let S=!0;return g(!0),fetch(`/api/settings/agents${t}`).then(async(R)=>{let T=await R.json().catch(()=>null);if(!R.ok)throw Error(as(T)??`GET /api/settings/agents answered ${R.status}`);return T}).then((R)=>{if(!S)return;let T=rs(R)??[];l(T),v(null),b((O)=>T.some((L)=>L.id===O)?O:T[0]?.id??null)}).catch((R)=>{if(!S)return;console.error("Failed to load agents:",R),v(R instanceof Error?R.message:String(R))}).finally(()=>{if(S)g(!1)}),()=>{S=!1}},[t,k]);let A=a(()=>x((S)=>S+1),[]),N=a((S)=>b(S),[]),M=a(async(S)=>{try{let R=await fetch("/api/settings/agents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S)}),T=await R.json().catch(()=>null),O=as(T)??(R.ok?void 0:`The write answered ${R.status}`);if(O)return{ok:!1,error:O};let L=rs(T);if(L){l(L);let _=S.fileName,K=typeof _==="string"?L.find((V)=>V.fileName===_):void 0;if(K)b(K.id)}return{ok:!0}}catch(R){return{ok:!1,error:R instanceof Error?R.message:String(R)}}},[]),P=a((S,R)=>{let T=S.name.trim();return M({type:"write",fileName:T,name:S.name,description:S.description,...S.model?{model:S.model}:{},...S.thinkingLevel?{thinkingLevel:S.thinkingLevel}:{},...S.tools?{tools:S.tools}:{},...S.spawns?{spawns:S.spawns}:{},systemPrompt:S.systemPrompt,...R&&R!==T?{previousFileName:R}:{}})},[M]),E=a(async(S)=>{if(!S.fileName)return{ok:!1,error:"This agent has no definition file to delete."};let R=await M({type:"delete",fileName:S.fileName});if(R.ok)b((T)=>T===S.id?null:T),l((T)=>T.filter((O)=>O.id!==S.id));return R},[M]);return{agents:r,selectedId:c,selected:r.find((S)=>S.id===c),isLoading:p,loadError:h,reload:A,select:N,save:P,remove:E}}var qe="global",ls={id:qe,name:"global",label:"User (all projects)",value:""};function Ze(){let[t,r]=n([ls]);i(()=>{let g=!0;return fetch("/api/settings/projects").then((h)=>h.json()).then((h)=>{if(!g)return;let v=(h.projects??[]).filter((k)=>typeof k.path==="string"&&k.path).map((k)=>({id:k.id,name:k.name,label:k.name,value:k.path}));r([...v,ls])}).catch((h)=>console.error("Failed to load workspace folders:",h)),()=>{g=!1}},[]);let l=(g)=>(t.find((k)=>k.id===g||k.value===g)?.value??"")||null;return{options:t,rootFor:l,queryFor:(g)=>{let h=l(g);return h?`?root=${encodeURIComponent(h)}`:"?scope=user"},scopeBodyFor:(g)=>{let h=l(g);return h?{root:h}:{scope:"user"}},isWorkspace:(g)=>l(g)!==null}}var ds=()=>{let t=ke(),r=Ze(),[l,c]=n(qe),[b,p]=n(!1),g=r.queryFor(l),{agents:h,selectedId:v,selected:k,isLoading:x,loadError:A,reload:N,select:M,save:P,remove:E}=ss(g);if(x)return e(Ce,{children:"Reading omp’s agent definitions…"});return e("div",{className:"flex h-full w-full overflow-hidden bg-paper",children:e(ye,{pane:t.pane,onBack:t.back,listLabel:"Agents",list:e(es,{agents:h,selectedAgentId:b?null:v,onSelectAgent:(S)=>{p(!1),M(S),t.openDetail()},onAddNewAgent:()=>{p(!0),t.openDetail()},selectedProject:l,onChangeProject:c,projectOptions:r.options,...A?{loadError:A,onRetry:N}:{}}),detail:e("div",{className:"flex-1 h-full overflow-hidden flex flex-col",children:b?e(Gn,{agent:os(),isNew:!0,onSave:(S)=>P(S)}):k?e(Gn,{agent:k,onSave:(S)=>P(S,k.fileName),onDelete:async(S)=>{let R=await E(S);if(R.ok)t.back();return R}},k.id):e("div",{className:"flex-1 flex items-center justify-center px-6 text-center text-xs text-ink/40",children:r.isWorkspace(l)?"No agents in this project. Create one, or pick Global.":"Select an agent or click + to create one."})})})})};var kp={agents:{title:"Global AGENTS.md",badge:"context file",tooltip:"User context file omp loads when a session starts (~/.omp/agent/AGENTS.md, relocated by PI_CODING_AGENT_DIR). It shadows every other user-level context file, so it is the place for long-lived global rules. Recognizable permission directives are also mirrored into config.yml tools.approval. Saving empty content removes the file.",placeholder:"Type instructions in <mandatory_rules> tags..."},rules:{title:"Global RULES.md",badge:"sticky rule",tooltip:"User sticky rule (~/.omp/agent/RULES.md). Its whole body is re-sent on every request and re-read when a session starts or after /clear and /new, so it keeps its hold in long conversations — keep it to a few hard requirements. Saving empty content removes the file.",placeholder:"One hard requirement per line, e.g. Never commit or push unless asked."}},cs=({kind:t,content:r,filePath:l,exists:c,isMock:b,onSave:p,onReset:g})=>{let[h,v]=n(r),[k,x]=n(!1),[A,N]=n(!1),[M,P]=n(!1),[E,S]=n(null),[R,T]=n(null),O=o(null);i(()=>{v(r)},[r]);let L=kp[t],K=h.split(`
|
|
6
|
-
`).length,V=h.length,z=Math.round(V/4),q=b?"Demo preset — MOCK=true, nothing is written to disk":l?`${l}${c?"":" · not created yet"}`:"Native path unavailable",G=async(te)=>{N(!0),S(null),T(null);try{let Z=await te();if(Z.error){S(Z.error);return}T(Z.note??null),P(!0),setTimeout(()=>P(!1),2000)}finally{N(!1)}},j=()=>{navigator.clipboard.writeText(h).then(()=>{x(!0),setTimeout(()=>x(!1),2000)}).catch((te)=>{S(`The clipboard refused the copy: ${te instanceof Error?te.message:String(te)}`)})},H=()=>{G(()=>p(h))},X=async()=>{if(!g)return;if(!window.confirm(`Replace ${l??"the stored content"} with the shipped default rules?`))return;await G(g)},oe=(te)=>{v((Z)=>`${Z.trim()}
|
|
7
|
-
|
|
8
|
-
${te}
|
|
9
|
-
`)};return e("div",{className:"flex-1 flex flex-col h-full bg-paper text-ink p-6 md:p-8 overflow-hidden",children:[e("div",{className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-2 pb-4 border-b border-ink/10",children:[e("div",{className:"flex items-center gap-2 min-w-0",children:[e("h2",{className:"text-sm font-bold tracking-tight text-ink flex items-center gap-2",children:[e("span",{className:"truncate",children:L.title}),e("span",{className:"text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded border border-ink/15 text-ink/50 font-medium flex-shrink-0",children:L.badge})]}),e("div",{className:"group relative flex-shrink-0",children:[e(pe,{className:"w-4 h-4 text-ink/40 cursor-help"}),e("div",{className:"absolute left-0 top-6 hidden group-hover:block w-80 max-w-[80vw] p-2.5 rounded-lg bg-ink text-paper text-xs shadow-lg z-20 leading-relaxed pointer-events-none",children:L.tooltip})]})]}),e("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e("button",{type:"button",onClick:j,title:"Copy to clipboard",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg border border-ink/20 hover:border-ink/40 hover:bg-ink/5 text-ink transition-colors cursor-pointer",children:[k?e(f,{className:"w-3.5 h-3.5 text-ink"}):e(ie,{className:"w-3.5 h-3.5"}),e("span",{children:k?"Copied":"Copy"})]}),g&&e("button",{type:"button",onClick:X,disabled:A,title:"Reset to default rules",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg border border-ink/20 hover:border-ink/40 hover:bg-ink/5 text-ink transition-colors cursor-pointer disabled:opacity-50",children:[e(ct,{className:"w-3.5 h-3.5"}),e("span",{children:"Reset"})]}),e("button",{type:"button",onClick:H,disabled:A,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-medium rounded-lg bg-ink text-paper hover:bg-ink/90 transition-colors shadow-xs cursor-pointer disabled:opacity-50",children:[M?e(f,{className:"w-3.5 h-3.5"}):e(yt,{className:"w-3.5 h-3.5"}),e("span",{children:A?"Saving…":M?"Saved":"Save Changes"})]})]})]}),(E||R)&&e("div",{className:`pt-3 text-xs font-mono break-words ${E?"text-error":"text-ink/60"}`,children:E??R}),e("div",{className:"py-3 flex items-center gap-2 overflow-x-auto text-xs border-b border-ink/10",children:[e("span",{className:"text-ink/50 uppercase tracking-wider text-[10px] font-bold whitespace-nowrap",children:"Quick Insert:"}),e("button",{type:"button",onClick:()=>oe(`<mandatory_rules>
|
|
10
|
-
ALWAY USE CODEGRAPH (codegraph_codegraph_explore) TOOL MCP FIRST BEFORE OTHER TOOL BUILT-IN.
|
|
11
|
-
</mandatory_rules>`),className:"px-2.5 py-1 text-xs font-mono rounded-md bg-ink/5 hover:bg-ink/10 border border-ink/15 whitespace-nowrap transition-colors flex items-center gap-1.5 text-ink cursor-pointer",children:[e(Or,{className:"w-3.5 h-3.5 text-ink/60"}),"+ CodeGraph Rule"]}),e("button",{type:"button",onClick:()=>oe(`<mandatory_rules>
|
|
12
|
-
IF SUBAGENT NOT DEFINE MODELID, DELEGATE TASK USING INHERIT WITH PARENT MODELID.
|
|
13
|
-
</mandatory_rules>`),className:"px-2.5 py-1 text-xs font-mono rounded-md bg-ink/5 hover:bg-ink/10 border border-ink/15 whitespace-nowrap transition-colors flex items-center gap-1.5 text-ink cursor-pointer",children:[e(fi,{className:"w-3.5 h-3.5 text-ink/60"}),"+ Model Inheritance"]}),e("button",{type:"button",onClick:()=>oe(`<mandatory_rules>
|
|
14
|
-
WHEN COMMIT, ALWAYS USE CONVENTIONAL COMMIT. JANGAN COMMIT SAMPAI AKU MINTA.
|
|
15
|
-
</mandatory_rules>`),className:"px-2.5 py-1 text-xs font-mono rounded-md bg-ink/5 hover:bg-ink/10 border border-ink/15 whitespace-nowrap transition-colors flex items-center gap-1.5 text-ink cursor-pointer",children:[e(fi,{className:"w-3.5 h-3.5 text-ink/60"}),"+ Conventional Commit Guard"]})]}),e("div",{className:"flex-1 min-h-0 mt-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-ink/5 overflow-hidden flex flex-col font-mono text-xs focus-within:border-ink transition-colors",children:[e("div",{className:"flex-1 flex overflow-hidden",children:[e("div",{ref:O,"aria-hidden":"true",className:"w-10 py-3 pr-2 select-none text-right font-mono text-xs text-ink/30 border-r border-ink/10 bg-ink/[0.02] overflow-hidden leading-relaxed",children:Array.from({length:Math.max(K,12)}).map((te,Z)=>e("div",{children:Z+1},Z))}),e("textarea",{value:h,onInput:(te)=>v(te.currentTarget.value),onScroll:(te)=>{if(O.current)O.current.scrollTop=te.currentTarget.scrollTop},spellcheck:!1,"aria-label":`${L.title} content`,className:"flex-1 p-3 bg-transparent text-ink font-mono text-xs leading-relaxed resize-none focus:outline-none overflow-y-auto",placeholder:L.placeholder})]}),e("div",{className:"p-2.5 border-t border-ink/10 bg-paper flex items-center justify-between gap-4 text-xs font-mono text-ink/60",children:[e("div",{className:"flex items-center gap-4 shrink-0",children:[e("span",{children:[K," lines"]}),e("span",{children:[V," chars"]}),e("span",{children:["~",z," tokens"]})]}),e("div",{className:"flex items-center gap-2 min-w-0",children:[e("span",{className:`w-2 h-2 rounded-full shrink-0 ${c&&!b?"bg-ink/60":"bg-ink/25"}`}),e("span",{className:"truncate",title:q,children:q})]})]})]})]})};function Vn(t){let[r,l]=n(""),[c,b]=n(null),[p,g]=n(!1),[h,v]=n(!1),[k,x]=n(!0),[A,N]=n(null),M=a((E)=>{if(typeof E.rules==="string")l(E.rules);b(typeof E.path==="string"?E.path:null),g(E.exists===!0),v(E.isMock===!0)},[]);i(()=>{let E=!0;return N(null),fetch(`/api/settings/behavior?file=${t}`).then((S)=>S.json()).then((S)=>{if(!E)return;if(S.error){N(S.error);return}M(S)}).catch((S)=>{if(E)N(S instanceof Error?S.message:String(S))}).finally(()=>{if(E)x(!1)}),()=>{E=!1}},[M,t]);let P=a(async(E)=>{try{let R=await(await fetch("/api/settings/behavior",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...E,file:t})})).json();if(R.error)return{error:R.error};if(M(R),R.nativeError)return{note:`Saved, but the approval mapping was skipped: ${R.nativeError}`};if(R.nativeSynced)return{note:"Saved — recognized permission gates were mirrored into config.yml tools.approval."};return{}}catch(S){return{error:S instanceof Error?S.message:String(S)}}},[M,t]);return{content:r,filePath:c,exists:p,isMock:h,isLoading:k,error:A,save:(E)=>P({rules:E}),reset:()=>P({action:"reset"})}}var Yn=[{kind:"agents",label:"AGENTS.md",hint:"context file"},{kind:"rules",label:"RULES.md",hint:"sticky rule"}],ps=()=>{let[t,r]=n("agents"),l=Vn("agents"),c=Vn("rules"),b=t==="agents"?l:c,p=Yn.find((g)=>g.kind===t)??Yn[0];return e("div",{className:"h-full w-full overflow-hidden flex flex-col bg-paper",children:[e("div",{className:"flex items-center gap-1.5 px-6 md:px-8 pt-5",children:Yn.map((g)=>e("button",{type:"button",onClick:()=>r(g.kind),className:`px-3 py-1.5 text-xs font-mono rounded-lg border transition-colors cursor-pointer ${g.kind===t?"border-ink bg-ink text-paper":"border-ink/20 text-ink/60 hover:border-ink/40 hover:bg-ink/5"}`,children:[g.label,e("span",{className:"ml-2 opacity-60",children:g.hint})]},g.kind))}),b.error&&e("div",{className:"mx-6 md:mx-8 mt-3 px-3 py-2 text-xs font-mono text-error bg-error/5 border border-error/30 rounded-lg",children:["Failed to load ",b.filePath??p.label,": ",b.error]}),b.isLoading?e(Ce,{variant:"fill",children:["Loading ",p.label," from ",b.filePath??"the preset store","..."]}):e(cs,{kind:t,content:b.content,filePath:b.filePath,exists:b.exists,isMock:b.isMock,onSave:b.save,onReset:t==="agents"?b.reset:void 0},t)]})};var us=({commands:t,selectedCommandId:r,onSelectCommand:l,onAddNewCommand:c,selectedProject:b,onChangeProject:p,projectOptions:g,loadError:h,onRetry:v})=>e(tn,{items:t,selectedId:r,onSelect:l,onAddNew:c,addTitle:"Create new command",builtInLabel:"Built-in Commands",customLabel:"Command Files",formatName:(k)=>`/${k}`,nameClassName:"font-mono font-semibold text-xs text-ink truncate",selectedProject:b,onChangeProject:p,...g?{projectOptions:g}:{},...h?{loadError:h}:{},...v?{onRetry:v}:{},renderIcon:(k)=>e(Ie,{className:`w-3.5 h-3.5 ${k?"text-ink/70":"text-ink/60"} flex-shrink-0`})});var Jn=({command:t,isNew:r=!1,onSave:l,onDelete:c,projectScopeDisabled:b=!1})=>{let[p,g]=n(t),[h,v]=n(!1),[k,x]=n(!0),[A,N]=n(!1),M=Qe(),P=!r&&t.source!=null&&t.managed!==!0;i(()=>{g(t),N(!1)},[t]);let E=P||M.saving,S=(K)=>{if(K.preventDefault(),P||M.saving)return;M.run(()=>l(p))},R=()=>{if(!c)return;M.run(()=>c(p.id))},T=()=>{navigator.clipboard.writeText(p.template).then(()=>{v(!0),setTimeout(()=>v(!1),1800)}).catch((K)=>console.error("Failed to copy the command template:",K))},O=(K)=>{g((V)=>({...V,template:V.template?`${V.template} ${K}`:K}))},L=p.template.split(`
|
|
16
|
-
`),_=Math.max(L.length,6);return e("form",{onSubmit:S,className:"flex-1 flex flex-col h-full scrollbar-overlay-container bg-paper text-ink p-6 md:p-8 space-y-6",children:[P&&e("div",{className:"rounded-lg border border-ink/15 bg-ink/5 px-3 py-2 text-[11px] text-ink/70 leading-relaxed",children:p.filePath?e(d,{children:["This command is provided by ",e("span",{className:"font-mono text-ink/80",children:p.source})," and is read-only here. Edit ",e("span",{className:"font-mono text-ink/80",children:p.filePath})," at its source, or create a command of your own under ",e("span",{className:"font-mono text-ink/80",children:"~/.omp/agent/commands"}),"."]}):e(d,{children:["This is a ",e("span",{className:"font-mono text-ink/80",children:p.source??"live"})," command built into the agent, not a file. It cannot be edited or deleted here — create a command with another name to extend it."]})}),e("div",{className:"space-y-3",children:[e("div",{className:"flex items-center justify-between",children:[e("h2",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:"Identity"}),P&&e("span",{className:"text-[10px] font-mono px-2 py-0.5 rounded-md bg-ink/5 border border-ink/10 text-ink/60",children:[p.source??"live"," · read-only"]})]}),e("div",{className:"flex items-center gap-3",children:[e("div",{className:"flex-1",children:[e("label",{className:"block text-xs font-semibold text-ink/80 mb-1.5",children:"Command Name"}),e("div",{className:"flex items-center border border-ink/20 hover:border-ink/40 focus-within:border-ink rounded-lg bg-paper transition-colors",children:[e("span",{className:"px-3 py-2 font-mono text-xs text-ink/40 border-r border-ink/15 select-none",children:"/"}),e("input",{type:"text",value:p.name,onChange:(K)=>g({...p,name:K.currentTarget.value.replace(/^\/+/,"")}),required:!0,placeholder:"command-name",disabled:E,className:"w-full text-xs font-mono px-3 py-2 bg-transparent focus:outline-none disabled:opacity-60 text-ink"})]})]}),e("div",{className:"w-40",children:[e("label",{className:"block text-xs font-semibold text-ink/80 mb-1.5",children:"Scope"}),e("select",{value:p.scope,onChange:(K)=>g({...p,scope:K.currentTarget.value}),disabled:E||b,title:b?"Select a workspace folder to write a project command":void 0,className:"w-full text-xs py-2 px-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink disabled:opacity-60 text-ink transition-colors cursor-pointer",children:[e("option",{value:"user",children:"user"}),!b&&e("option",{value:"project",children:"project"})]})]})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink/80 mb-1.5",children:"Description"}),e("textarea",{value:p.description,onChange:(K)=>g({...p,description:K.currentTarget.value}),disabled:E,placeholder:"What does this command do?",rows:2,className:"w-full text-xs p-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink placeholder:text-ink/35 text-ink transition-colors disabled:opacity-60"})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink/80 mb-1.5",children:"Argument Hint"}),e("input",{type:"text",value:p.inputHint??"",onChange:(K)=>g({...p,inputHint:K.currentTarget.value}),disabled:E,placeholder:"[on|off|status]",className:"w-full text-xs font-mono p-2.5 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink placeholder:text-ink/35 text-ink transition-colors disabled:opacity-60"}),e("p",{className:"text-[11px] text-ink/60 mt-1",children:["Shown as ghost text after ",e("span",{className:"font-mono",children:["/",p.name||"name"]})," in the composer."]})]})]}),e("div",{className:"border-t border-ink/10"}),e("div",{className:"space-y-2 flex-1 flex flex-col",children:[e("div",{className:"flex items-center justify-between",children:[e("div",{children:[e("label",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:"Command Template"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:["Use ",e("code",{className:"text-ink font-semibold font-mono",children:"$ARGUMENTS"}),", ",e("code",{className:"text-ink font-semibold font-mono",children:"!`shell`"}),", or ",e("code",{className:"text-ink font-semibold font-mono",children:"@filename"}),"."]})]}),e("div",{className:"flex items-center gap-2",children:[e("button",{type:"button",onClick:()=>x(!k),title:k?"Hide line numbers":"Show line numbers",className:"p-1 rounded-md text-ink/50 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:k?e(Ge,{size:15}):e(wt,{size:15})}),e("button",{type:"button",onClick:T,className:"flex items-center gap-1.5 text-xs text-ink/60 hover:text-ink transition-colors cursor-pointer",children:[h?e(f,{className:"w-3.5 h-3.5 text-ink"}):e(ie,{className:"w-3.5 h-3.5"}),e("span",{children:h?"Copied":"Copy"})]})]})]}),e("div",{className:"flex items-center gap-2 py-1",children:[e("button",{type:"button",onClick:()=>O("$ARGUMENTS"),disabled:E,className:"px-2.5 py-1 text-xs font-mono rounded-md bg-ink/5 hover:bg-ink/10 border border-ink/15 text-ink transition-colors cursor-pointer disabled:opacity-50",children:"+$ARGUMENTS"}),e("button",{type:"button",onClick:()=>O("!`bun test`"),disabled:E,className:"px-2.5 py-1 text-xs font-mono rounded-md bg-ink/5 hover:bg-ink/10 border border-ink/15 text-ink transition-colors cursor-pointer disabled:opacity-50",children:"+!shell"}),e("button",{type:"button",onClick:()=>O("@src/App.tsx"),disabled:E,className:"px-2.5 py-1 text-xs font-mono rounded-md bg-ink/5 hover:bg-ink/10 border border-ink/15 text-ink transition-colors cursor-pointer disabled:opacity-50",children:"+@filename"})]}),e("div",{className:"flex rounded-lg border border-ink/20 hover:border-ink/40 bg-ink/5 overflow-hidden flex-1 min-h-[140px] font-mono text-xs focus-within:border-ink transition-colors",children:[k&&e("div",{className:"w-10 py-3 pr-2 select-none text-right text-xs text-ink/30 border-r border-ink/10 bg-ink/[0.02] overflow-hidden leading-relaxed",children:Array.from({length:_}).map((K,V)=>e("div",{children:V+1},V))}),e("textarea",{value:p.template,onChange:(K)=>g({...p,template:K.currentTarget.value}),rows:Math.max(_,7),disabled:E,spellcheck:!1,placeholder:"Enter command template instructions...",className:"flex-1 p-3 bg-transparent text-ink resize-none focus:outline-none leading-relaxed disabled:opacity-60"})]})]}),M.error&&e("div",{className:"flex items-start gap-1.5 rounded-lg border border-error/30 bg-error/5 px-3 py-2 text-[11px] text-error",children:[e(B,{className:"mt-px h-3.5 w-3.5 flex-shrink-0"}),e("span",{className:"flex-1 break-words",children:M.error}),e("button",{type:"button",onClick:M.dismissError,className:"cursor-pointer text-error/60 hover:text-error","aria-label":"Dismiss error",children:"×"})]}),e("div",{className:"pt-3 border-t border-ink/10 flex flex-wrap items-center justify-between gap-3",children:[e("div",{className:"flex items-center gap-2",children:!P&&!r&&c&&(A?e(d,{children:[e("span",{className:"text-[11px] text-ink/70",children:["Delete “/",p.name,"”? Its file is removed."]}),e("button",{type:"button",onClick:R,disabled:M.saving,className:"px-2.5 py-1 rounded-lg border border-error/40 text-error text-xs font-medium hover:bg-error/10 transition-colors cursor-pointer disabled:opacity-50",children:"Delete"}),e("button",{type:"button",onClick:()=>N(!1),className:"px-2 py-1 text-xs text-ink/50 hover:text-ink cursor-pointer",children:"Cancel"})]}):e("button",{type:"button",onClick:()=>N(!0),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-lg border border-ink/20 hover:border-error hover:text-error text-ink/70 text-xs font-medium transition-colors cursor-pointer",children:[e(U,{className:"w-3.5 h-3.5"}),"Delete Command"]}))}),e("div",{className:"flex items-center gap-3",children:[M.saved&&e("span",{className:"flex items-center gap-1 text-xs text-ink font-medium",children:[e(f,{className:"w-3.5 h-3.5"}),"Saved"]}),!P&&e("button",{type:"submit",disabled:M.saving,className:"flex items-center gap-1.5 px-4 py-2 rounded-lg bg-ink text-paper text-xs font-medium hover:bg-ink/90 transition-colors shadow-xs cursor-pointer disabled:opacity-50 disabled:cursor-progress",children:[M.saving?e(m,{className:"w-3.5 h-3.5 animate-spin"}):e(yt,{className:"w-3.5 h-3.5"}),r?"Create Command":"Save Command"]})]})]})]})};function wp(t){return(r)=>{let l=r?.[t];return Array.isArray(l)?l:null}}function Xn(t){if(typeof t!=="object"||t===null||!("error"in t))return null;let r=t.error;return typeof r==="string"&&r.trim()?r:null}function bt(t){let{endpoint:r,listKey:l,query:c,messages:b,cacheKey:p}=t,[g,h]=n([]),[v,k]=n(null),[x,A]=n(!1),[N,M]=n(!0),[P,E]=n(null),[S,R]=n(0),T=t.readList??wp(l);i(()=>{let q=!0;return M(!0),fetch(`${r}${c??""}`).then(async(G)=>{let j=await G.json().catch(()=>null);if(!G.ok)throw Error(Xn(j)??`GET ${r} answered ${G.status}`);return j}).then((G)=>{if(!q)return;let j=T(G)??[];h(j),E(null),k((H)=>t.resolveOnLoad?t.resolveOnLoad(H,j):j.length>0?j[0].id:null)}).catch((G)=>{if(!q)return;console.error(b.load,G),E(G instanceof Error?G.message:String(G))}).finally(()=>{if(q)M(!1)}),()=>{q=!1}},[r,c,S]);let O=t.fallbackToFirst===!1?g.find((q)=>q.id===v):g.find((q)=>q.id===v)??g[0],L=a(()=>R((q)=>q+1),[]);return{items:g,selectedId:v,selected:O,isCreatingNew:x,isLoading:N,loadError:P,reload:L,select:(q)=>{A(!1),k(q)},startCreate:()=>{A(!0),k(null)},save:async(q)=>{let G=x?t.buildNew(q):t.buildUpdate(q,O,v),j=t.buildBody?t.buildBody(G):{[t.bodyKey]:G};try{let H=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(j)}),X=await H.json().catch(()=>null),oe=Xn(X)??(H.ok?null:`POST ${r} answered ${H.status}`);if(oe)return console.error(b.save,oe),{ok:!1,error:oe};let te=T(X);if(te)h(te);else if(!t.serverListOnly)h((Q)=>Q.some((ue)=>ue.id===G.id)?Q.map((ue)=>ue.id===G.id?G:ue):[...Q,G]);let Z=t.resolveOnSave?t.resolveOnSave(G,te):G.id;if(Z!==void 0)k(Z);if(A(!1),p)yi(p);return{ok:!0}}catch(H){return console.error(b.save,H),{ok:!1,error:H instanceof Error?H.message:String(H)}}},remove:async(q)=>{let G=t.buildDeleteQuery?t.buildDeleteQuery(q):`?id=${encodeURIComponent(q)}`;try{let j=await fetch(`${r}${G}`,{method:"DELETE"}),H=await j.json().catch(()=>null),X=Xn(H)??(j.ok?null:`DELETE ${r} answered ${j.status}`);if(X)return console.error(b.delete,X),{ok:!1,error:X};if(p)yi(p);if(t.deleteFromResponse){let oe=T(H)??g.filter((te)=>te.id!==q);if(h(oe),v===q)k(oe[0]?.id??null)}else{let te=await(await fetch(`${r}${c??""}`)).json().catch(()=>null),Z=T(te)??[];if(h(Z),v===q)k(Z[0]?.id||null)}return{ok:!0}}catch(j){return console.error(b.delete,j),{ok:!1,error:j instanceof Error?j.message:String(j)}}}}}var ms=()=>{let t=ke(),r=Ze(),[l,c]=n(qe),b=o(null),p=r.queryFor(l),g=r.isWorkspace(l),{items:h,selectedId:v,selected:k,isCreatingNew:x,isLoading:A,loadError:N,reload:M,select:P,startCreate:E,save:S,remove:R}=bt({endpoint:"/api/settings/commands",query:p,listKey:"commands",bodyKey:"command",messages:{load:"Failed to load commands from API:",save:"Failed to save command via API:",delete:"Failed to delete command via API:"},cacheKey:"command",buildBody:(O)=>({command:O,...r.scopeBodyFor(l),...b.current?{previousName:b.current}:{}}),buildDeleteQuery:(O)=>`?id=${encodeURIComponent(O)}&${p.slice(1)}`,buildNew:(O)=>({...O,id:`cmd-${Date.now()}`,isBuiltIn:!1,scope:g?"project":"user"}),buildUpdate:(O)=>O}),T={id:`new-${Date.now()}`,name:"new-command",description:"",scope:g?"project":"user",template:"Execute task: $ARGUMENTS",isBuiltIn:!1};if(A)return e(Ce,{children:"Loading commands…"});return e("div",{className:"flex h-full w-full overflow-hidden bg-paper",children:e(ye,{pane:t.pane,onBack:t.back,listLabel:"Commands",list:e(us,{commands:h,selectedCommandId:x?null:v,onSelectCommand:(O)=>{b.current=h.find((L)=>L.id===O)?.name??null,P(O),t.openDetail()},onAddNewCommand:()=>{b.current=null,E(),t.openDetail()},selectedProject:l,onChangeProject:c,projectOptions:r.options,...N?{loadError:N,onRetry:M}:{}}),detail:e("div",{className:"flex-1 h-full overflow-hidden flex flex-col",children:x?e(Jn,{command:T,isNew:!0,onSave:S,projectScopeDisabled:!g}):k?e(Jn,{command:k,isNew:!1,onSave:S,onDelete:R,projectScopeDisabled:!g},k.id):e("div",{className:"flex-1 flex items-center justify-center text-xs font-mono text-ink/40",children:"Select a command or click + to create one"})})})})};var gs=({servers:t,projects:r,selectedServerId:l,onSelectServer:c,onAddNewServer:b,selectedProject:p,onChangeProject:g,loadError:h,onRetry:v})=>{let k=r.find((x)=>x.path===p)?.name??"Global (all projects)";return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0 select-none",children:[e(Xe,{selectedProject:p,onChangeProject:g,options:r.map((x)=>({id:x.id,name:x.name,label:x.name,value:x.path})),getTriggerLabel:()=>k}),e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex items-center justify-between",children:[e("span",{className:"text-xs font-semibold text-ink",children:["Total ",t.length]}),e("button",{type:"button",onClick:b,title:"Add MCP Server",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:e(Y,{size:15,strokeWidth:2.2})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-1.5 space-y-3 text-xs",children:[h&&e("div",{className:"mx-1 rounded-lg border border-error/30 bg-error/5 px-2.5 py-2 text-[11px] leading-snug text-error",children:[e("div",{className:"font-semibold",children:"Could not read the list"}),e("div",{className:"mt-0.5 break-words text-error/80",children:h}),v&&e("button",{type:"button",onClick:v,className:"mt-1.5 rounded border border-error/40 px-2 py-0.5 font-medium hover:bg-error/10 cursor-pointer",children:"Retry"})]}),e("div",{children:[e("div",{className:"px-2.5 pt-1.5 pb-1 text-[10px] font-bold text-ink/50 uppercase tracking-wider flex items-center justify-between",children:[e("span",{children:"User Servers"}),e("span",{className:"text-[10px] font-normal",children:t.length})]}),e("div",{className:"space-y-0.5",children:t.map((x)=>{let A=x.id===l,N=x.transport==="stdio",M=N?x.commandArgs.join(" "):x.linkUrl||"No URL configured";return e("button",{type:"button",onClick:()=>c(x.id),className:`w-full text-left px-2.5 py-2 rounded-lg transition-colors cursor-pointer flex flex-col gap-0.5 group ${A?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e("div",{className:"flex items-center justify-between gap-1.5",children:[e("div",{className:"flex items-center gap-2 min-w-0",children:[e("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${x.enabled?"bg-ink":"bg-ink/20"}`,title:x.enabled?"Enabled":"Disabled"}),e("span",{className:"font-semibold text-xs text-ink truncate",children:x.name})]}),e("div",{className:"flex items-center gap-1 text-ink/40",children:N?e(Ie,{className:"w-3.5 h-3.5"}):e(De,{className:"w-3.5 h-3.5"})})]}),e("p",{className:"text-[11px] font-mono text-ink/60 line-clamp-1 leading-snug pl-4",children:M})]},x.id)})})]})]})]})};function fs({server:t}){let[r,l]=n(!1),[c,b]=n(null);return e("div",{className:"flex items-center gap-2 min-w-0",children:[e("button",{type:"button",onClick:async()=>{l(!0),b(null);try{let h=await(await fetch("/api/settings/mcp-test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({server:t})})).json();b(h)}catch(g){b({ok:!1,transport:t.transport,durationMs:0,error:g instanceof Error?g.message:"Request failed"})}finally{l(!1)}},disabled:r,className:"flex items-center gap-1.5 px-3.5 py-2 rounded-lg border border-ink/20 hover:border-ink/40 text-xs font-medium text-ink hover:bg-ink/5 transition-colors disabled:opacity-50 cursor-pointer",children:[e(Qs,{className:`w-3.5 h-3.5 ${r?"animate-spin":""}`}),r?"Testing...":"Test Connection"]}),c&&!r&&(c.ok?e("span",{className:"flex items-center gap-1.5 text-xs text-ink font-medium min-w-0",children:[e(f,{className:"w-3.5 h-3.5 shrink-0"}),e("span",{className:"truncate",children:[c.serverInfo?.name??t.name,c.serverInfo?.version?` v${c.serverInfo.version}`:""]}),c.protocolVersion&&e("span",{className:"text-ink/50 shrink-0",children:["· ",c.protocolVersion]}),typeof c.toolCount==="number"&&e("span",{className:"text-ink/50 shrink-0",children:["· ",c.toolCount," tools"]}),e("span",{className:"text-ink/50 shrink-0",children:["· ",c.durationMs,"ms"]})]}):e("span",{className:"flex items-center gap-1 text-xs text-error font-medium min-w-0",title:c.error??"Connection failed",children:[e(B,{className:"w-3.5 h-3.5 shrink-0"}),e("span",{className:"truncate max-w-[280px]",children:c.error??"Connection failed"})]}))]})}function Zn({title:t,description:r,addLabel:l,emptyLabel:c,keyPlaceholder:b,valuePlaceholder:p,rows:g,onAdd:h,onUpdate:v,onRemove:k}){return e("div",{className:"space-y-3",children:[e("div",{className:"flex items-center justify-between gap-3",children:[e("div",{children:[e("h3",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:t}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:r})]}),e("button",{type:"button",onClick:h,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg border border-ink/20 hover:border-ink/40 hover:bg-ink/5 text-ink transition-colors cursor-pointer",children:[e(Y,{className:"w-3.5 h-3.5"}),e("span",{children:l})]})]}),g.length===0?e("div",{className:"p-4 rounded-lg border border-dashed border-ink/20 text-center text-xs text-ink/50",children:c}):e("div",{className:"space-y-2",children:g.map((x)=>e("div",{className:"flex items-center gap-2",children:[e("input",{type:"text",value:x.key,onChange:(A)=>v(x.id,A.currentTarget.value,x.value),placeholder:b,"aria-label":`${t} name`,className:"w-1/3 text-xs font-mono px-3 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors"}),e("input",{type:"text",value:x.value,onChange:(A)=>v(x.id,x.key,A.currentTarget.value),placeholder:p,"aria-label":`Value for ${x.key||"the entry"}`,className:"flex-1 text-xs font-mono px-3 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors"}),e("button",{type:"button",onClick:()=>k(x.id),"aria-label":`Remove ${x.key||"the entry"}`,title:"Remove",className:"p-1.5 text-ink/40 hover:text-error transition-colors rounded-md cursor-pointer",children:e(U,{className:"w-4 h-4"})})]},x.id))})]})}var Np=[{value:"stdio",label:"Command",icon:Ie},{value:"http",label:"HTTP",icon:De},{value:"sse",label:"SSE",icon:ba}];function hs({transport:t,onTransportChange:r,commandText:l,onCommandTextChange:c,linkUrl:b,onLinkUrlChange:p}){return e("div",{className:"space-y-3",children:[e("div",{children:[e("h3",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:"How to reach it"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"Paste the command that starts it, or the link to a hosted server."})]}),e("div",{className:"inline-flex rounded-lg border border-ink/20 p-0.5 bg-ink/5",children:Np.map(({value:g,label:h,icon:v})=>e("button",{type:"button",onClick:()=>r(g),"aria-pressed":t===g,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md transition-colors cursor-pointer ${t===g?"bg-paper text-ink shadow-2xs font-semibold":"text-ink/60 hover:text-ink"}`,children:[e(v,{className:"w-3.5 h-3.5"}),h]},g))}),t==="stdio"?e("div",{children:[e("textarea",{value:l,onChange:(g)=>c(g.currentTarget.value),rows:4,placeholder:`bunx
|
|
17
|
-
@modelcontextprotocol/server-postgres
|
|
18
|
-
postgresql://user:pass@host/db`,className:"w-full text-xs font-mono p-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-ink/5 focus:outline-none focus:border-ink resize-none leading-relaxed text-ink transition-colors"}),e("p",{className:"text-[11px] text-ink/50 mt-1",children:"Runs on this machine. Paste a whole command and it is split into one argument per line."})]}):e("div",{children:[e("input",{type:"url",value:b,onChange:(g)=>p(g.currentTarget.value),placeholder:t==="sse"?"https://example.com/sse":"https://needmcp.com/mcp",className:"w-full text-xs font-mono px-3 py-2 rounded-lg border border-ink/20 hover:border-ink/40 bg-ink/5 focus:outline-none focus:border-ink text-ink transition-colors"}),e("p",{className:"text-[11px] text-ink/50 mt-1",children:t==="sse"?"Legacy SSE endpoint. Prefer HTTP unless the server only speaks SSE.":"Streamable HTTP endpoint. Add headers below when it needs a token."})]})]})}var we="w-full text-xs font-mono px-3 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors";function Se({label:t,children:r}){return e("label",{className:"block space-y-1",children:[e("span",{className:"block text-[11px] font-medium text-ink/70",children:t}),r]})}function xs({server:t,onChange:r}){let{auth:l,oauth:c}=t,b=(g)=>{r({auth:{...l??{type:"oauth"},...g}})},p=(g)=>{r({oauth:{...c??{},...g}})};return e("details",{className:"rounded-lg border border-ink/15 bg-ink/[0.02]",children:[e("summary",{className:"cursor-pointer select-none px-3 py-2 text-xs font-semibold text-ink",children:["Advanced",e("span",{className:"ml-2 font-normal text-ink/50",children:"timeout, working directory, credentials"})]}),e("div",{className:"px-3 pb-3 space-y-3",children:[e("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e(Se,{label:"Timeout (ms)",children:e("input",{type:"number",min:0,value:t.timeout??"",onChange:(g)=>{let h=g.currentTarget.value;r({timeout:h===""?void 0:Number(h)})},placeholder:"30000",className:we})}),e(Se,{label:"Request id format",children:e("select",{value:t.requestIdFormat??"",onChange:(g)=>{let h=g.currentTarget.value;r({requestIdFormat:h==="string"||h==="number"?h:void 0})},className:`${we} cursor-pointer`,children:[e("option",{value:"",children:"Default (number)"}),e("option",{value:"number",children:"number"}),e("option",{value:"string",children:"string"})]})}),t.transport==="stdio"&&e(Se,{label:"Working directory",children:e("input",{type:"text",value:t.cwd??"",onChange:(g)=>r({cwd:g.currentTarget.value||void 0}),placeholder:"/path/to/project",className:we})}),e("label",{className:"flex items-center gap-2 pt-5 text-xs text-ink cursor-pointer select-none",children:[e("input",{type:"checkbox",checked:t.instructions!==!1,onChange:(g)=>r({instructions:g.currentTarget.checked}),className:`${ge} w-4 h-4 cursor-pointer`}),"Include the server’s instructions in the prompt"]})]}),e("div",{className:"border-t border-ink/10 pt-3 space-y-3",children:[e(Se,{label:"Auth strategy",children:e("select",{value:l?.type??"",onChange:(g)=>{let h=g.currentTarget.value;if(h!=="oauth"&&h!=="apikey"){r({auth:void 0});return}b({type:h})},className:`${we} cursor-pointer`,children:[e("option",{value:"",children:"None"}),e("option",{value:"oauth",children:"OAuth"}),e("option",{value:"apikey",children:"API key"})]})}),l&&e("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e(Se,{label:"Credential id",children:e("input",{type:"text",value:l.credentialId??"",onChange:(g)=>b({credentialId:g.currentTarget.value}),className:we})}),e(Se,{label:"Token URL",children:e("input",{type:"text",value:l.tokenUrl??"",onChange:(g)=>b({tokenUrl:g.currentTarget.value}),className:we})}),e(Se,{label:"Client id",children:e("input",{type:"text",value:l.clientId??"",onChange:(g)=>b({clientId:g.currentTarget.value}),className:we})}),e(Se,{label:"Client secret",children:e("input",{type:"password",value:l.clientSecret??"",onChange:(g)=>b({clientSecret:g.currentTarget.value}),className:we})}),e(Se,{label:"Resource",children:e("input",{type:"text",value:l.resource??"",onChange:(g)=>b({resource:g.currentTarget.value}),className:we})})]})]}),e("div",{className:"border-t border-ink/10 pt-3 space-y-3",children:[e("p",{className:"text-[11px] font-medium text-ink/70",children:"OAuth client (used by reauth)"}),e("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e(Se,{label:"Client id",children:e("input",{type:"text",value:c?.clientId??"",onChange:(g)=>p({clientId:g.currentTarget.value}),className:we})}),e(Se,{label:"Client secret",children:e("input",{type:"password",value:c?.clientSecret??"",onChange:(g)=>p({clientSecret:g.currentTarget.value}),className:we})}),e(Se,{label:"Scope",children:e("input",{type:"text",value:c?.scope??"",onChange:(g)=>p({scope:g.currentTarget.value}),className:we})}),e(Se,{label:"Redirect URI",children:e("input",{type:"text",value:c?.redirectUri??"",onChange:(g)=>p({redirectUri:g.currentTarget.value}),className:we})}),e(Se,{label:"Callback port",children:e("input",{type:"number",min:1,max:65535,value:c?.callbackPort??"",onChange:(g)=>{let h=g.currentTarget.value;p({callbackPort:h===""?void 0:Number(h)})},className:we})}),e(Se,{label:"Callback path",children:e("input",{type:"text",value:c?.callbackPath??"",onChange:(g)=>p({callbackPath:g.currentTarget.value}),className:we})}),e(Se,{label:"Prompt",children:e("input",{type:"text",value:c?.prompt??"",onChange:(g)=>p({prompt:g.currentTarget.value}),placeholder:"consent",className:we})})]})]})]})]})}function eo(t){return t.split(`
|
|
19
|
-
`).map((r)=>r.trim()).filter(Boolean)}function ks(t,r){return[...t,{id:`${r}-${Date.now()}-${t.length}`,key:"",value:""}]}var to=({server:t,isNew:r=!1,onSave:l,onDelete:c,onOpenImportModal:b})=>{let[p,g]=n(t),[h,v]=n(""),[k,x]=n(!1),A=Qe();i(()=>{g(t),v(t.commandArgs.join(`
|
|
20
|
-
`)),x(!1)},[t]);let N=(()=>{if(!p.name.trim())return"A server needs a name — omp keys its config by it.";if(p.transport==="stdio"&&eo(h).length===0)return"Paste the command that starts the server, one argument per line.";if(p.transport!=="stdio"&&!(p.linkUrl??"").trim())return"Paste the server’s MCP endpoint URL.";return null})(),M=(T)=>{if(T.preventDefault(),N||A.saving)return;let O={...p,name:p.name.trim(),commandArgs:eo(h)};A.run(()=>l(O))},P=()=>{if(!c)return;A.run(async()=>{let T=await c(p.id);if(!T.ok)x(!1);return T})},E=(T,O,L,_)=>{g((K)=>({...K,[T]:K[T].map((V)=>V.id===O?{...V,key:L,value:_}:V)}))},S=(T,O)=>{g((L)=>({...L,[T]:L[T].filter((_)=>_.id!==O)}))},R={...p,commandArgs:eo(h)};return e("form",{onSubmit:M,className:"flex-1 flex flex-col h-full scrollbar-overlay-container bg-paper text-ink p-6 md:p-8 space-y-6",children:[e("div",{className:"flex items-center justify-between pb-4 border-b border-ink/10",children:[e("div",{children:e("h2",{className:"text-sm font-bold tracking-tight text-ink",children:r?"Configure a new MCP server":`Edit MCP Server: ${p.name}`})}),e("button",{type:"button",onClick:b,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg border border-ink/20 hover:border-ink/40 hover:bg-ink/5 transition-colors cursor-pointer",children:[e(Or,{className:"w-3.5 h-3.5 text-ink/70"}),e("span",{children:"Import from JSON snippet"})]})]}),e("div",{className:"space-y-4",children:[e("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink/80 mb-1.5",children:"Server Name"}),e("input",{type:"text",value:p.name,onChange:(T)=>g({...p,name:T.currentTarget.value}),required:!0,placeholder:"new-mcp-server",className:"w-full text-xs font-mono px-3 py-2 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors"})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink/80 mb-1.5",children:"Scope"}),e("select",{value:p.scope,onChange:(T)=>g({...p,scope:T.currentTarget.value}),className:"w-full text-xs py-2 px-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink cursor-pointer text-ink transition-colors",children:[e("option",{value:"every-project",children:"Available in every project"}),e("option",{value:"this-project",children:"This project only"})]})]})]}),e("div",{className:"flex items-center gap-2 pt-1",children:[e("input",{type:"checkbox",id:"enable-mcp",checked:p.enabled,onChange:(T)=>g({...p,enabled:T.currentTarget.checked}),className:`${ge} w-4 h-4 cursor-pointer`}),e("label",{htmlFor:"enable-mcp",className:"text-xs font-medium text-ink cursor-pointer select-none",children:"Enable Server"})]})]}),e("div",{className:"border-t border-ink/10"}),e(hs,{transport:p.transport,onTransportChange:(T)=>g({...p,transport:T}),commandText:h,onCommandTextChange:v,linkUrl:p.linkUrl??"",onLinkUrlChange:(T)=>g({...p,linkUrl:T})}),e("div",{className:"border-t border-ink/10"}),p.transport==="stdio"?e(Zn,{title:"Environment Variables",description:"Values the server needs, such as an API key.",addLabel:"Add variable",emptyLabel:"No environment variables configured.",keyPlaceholder:"KEY",valuePlaceholder:"VALUE",rows:p.envVars,onAdd:()=>g((T)=>({...T,envVars:ks(T.envVars,"env")})),onUpdate:(T,O,L)=>E("envVars",T,O,L),onRemove:(T)=>S("envVars",T)}):e(Zn,{title:"Request Headers",description:"Sent with every request — an Authorization header, for example.",addLabel:"Add header",emptyLabel:"No request headers configured.",keyPlaceholder:"Authorization",valuePlaceholder:"Bearer …",rows:p.headers,onAdd:()=>g((T)=>({...T,headers:ks(T.headers,"header")})),onUpdate:(T,O,L)=>E("headers",T,O,L),onRemove:(T)=>S("headers",T)}),e(xs,{server:p,onChange:(T)=>g((O)=>({...O,...T}))}),N&&e("div",{className:"rounded-lg border border-error/30 bg-error/5 px-3 py-2 text-[11px] text-error",children:N}),A.error&&e("div",{className:"flex items-start gap-1.5 rounded-lg border border-error/30 bg-error/5 px-3 py-2 text-[11px] text-error",children:[e(B,{className:"mt-px h-3.5 w-3.5 flex-shrink-0"}),e("span",{className:"flex-1 break-words",children:A.error}),e("button",{type:"button",onClick:A.dismissError,className:"cursor-pointer text-error/60 hover:text-error","aria-label":"Dismiss error",children:"×"})]}),e("div",{className:"pt-3 border-t border-ink/10 flex flex-wrap items-center justify-between gap-3",children:[e("div",{className:"flex items-center gap-2",children:[!r&&c&&(k?e(d,{children:[e("span",{className:"text-[11px] text-ink/70",children:["Delete “",p.name,"”?"]}),e("button",{type:"button",onClick:P,disabled:A.saving,className:"px-2.5 py-1 rounded-lg border border-error/40 text-error text-xs font-medium hover:bg-error/10 transition-colors cursor-pointer disabled:opacity-50",children:"Delete"}),e("button",{type:"button",onClick:()=>x(!1),className:"px-2 py-1 text-xs text-ink/50 hover:text-ink cursor-pointer",children:"Cancel"})]}):e("button",{type:"button",onClick:()=>x(!0),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-lg border border-ink/20 hover:border-error hover:text-error text-ink/70 text-xs font-medium transition-colors cursor-pointer",children:[e(U,{className:"w-3.5 h-3.5"}),"Delete"]})),e(fs,{server:R})]}),e("div",{className:"flex items-center gap-3",children:[A.saved&&e("span",{className:"flex items-center gap-1 text-xs text-ink font-medium",children:[e(f,{className:"w-3.5 h-3.5"}),"Saved"]}),e("button",{type:"submit",disabled:A.saving||Boolean(N),className:"flex items-center gap-1.5 px-4 py-2 rounded-lg bg-ink text-paper text-xs font-medium hover:bg-ink/90 transition-colors shadow-xs cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:[A.saving?e(m,{className:"w-3.5 h-3.5 animate-spin"}):e(yt,{className:"w-3.5 h-3.5"}),r?"Create Server":"Save Changes"]})]})]})]})};function ws(t,r){if(!w(t))return[];return Object.entries(t).map(([l,c],b)=>({id:`${r}-${b}`,key:l,value:typeof c==="string"?c:String(c)}))}function Ap(t){return Array.isArray(t)?t.map(String):[]}function Ss(t,r,l){let c=typeof r.url==="string"?r.url:typeof r.httpUrl==="string"?r.httpUrl:void 0,b=typeof r.type==="string"?r.type:"",p=b==="sse"?"sse":b==="http"||b==="remote"||c&&b!=="stdio"&&b!=="local"?"http":"stdio",g=Array.isArray(r.command)?r.command.map(String):typeof r.command==="string"?[r.command,...Ap(r.args)]:[],h={id:`import-${l}-${t}`,name:t,scope:"every-project",enabled:r.enabled!==!1,transport:p,commandArgs:p==="stdio"?g:[c??""],...p==="stdio"?{}:{linkUrl:c??""},envVars:ws(r.env??r.environment,`env-${l}`),headers:ws(r.headers,`header-${l}`),status:"active"};if(typeof r.cwd==="string")h.cwd=r.cwd;if(typeof r.timeout==="number")h.timeout=r.timeout;if(typeof r.instructions==="boolean")h.instructions=r.instructions;if(w(r.auth))h.auth=r.auth;if(w(r.oauth))h.oauth=r.oauth;return h}function Rp(t){for(let r of["mcpServers","servers","mcp"]){let l=t[r];if(w(l))return l}return null}function Ns(t){let r;try{r=JSON.parse(t)}catch{throw Error("That is not valid JSON.")}if(!w(r))throw Error("Paste a JSON object, not a list or a bare value.");let l=Rp(r);if(l){let b=Object.entries(l).filter((p)=>w(p[1]));if(b.length===0)throw Error("No server definitions found in that snippet.");return b.map(([p,g],h)=>Ss(p,g,h))}if(typeof r.command!=="string"&&typeof r.url!=="string"&&typeof r.httpUrl!=="string")throw Error("No server definitions found in that snippet.");let c=typeof r.name==="string"&&r.name?r.name:"imported-mcp-server";return[Ss(c,r,0)]}var Dp=`{
|
|
21
|
-
"mcpServers": {
|
|
22
|
-
"postgres-db": {
|
|
23
|
-
"command": "bunx",
|
|
24
|
-
"args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://user:pass@localhost:5432/db"],
|
|
25
|
-
"env": {
|
|
26
|
-
"DEBUG": "1"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}`,Cs=({isOpen:t,onClose:r,onImport:l})=>{let[c,b]=n(Dp),[p,g]=n(null),[h,v]=n(!1);if(!t)return null;let k=async()=>{g(null);let x;try{x=Ns(c)}catch(A){g(A instanceof Error?A.message:"Invalid JSON format");return}v(!0);try{let A=await l(x);if(A.ok)r();else g(A.error??"The server refused the import.")}finally{v(!1)}};return e("div",{className:"fixed inset-0 modal-scrim backdrop-blur-[2px] z-50 flex items-center justify-center p-4 animate-in fade-in duration-150",children:e("div",{className:"glass-overlay w-full max-w-lg rounded-lg border border-ink/20 bg-paper text-ink p-5 shadow-2xl space-y-4 max-h-full overflow-y-auto scrollbar-overlay-container",children:[e("div",{className:"flex items-center justify-between pb-3 border-b border-ink/10",children:[e("div",{className:"flex items-center gap-2",children:[e(Or,{className:"w-4 h-4 text-ink/70"}),e("h2",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:"Import MCP Servers from JSON"})]}),e("button",{type:"button",onClick:r,className:"p-1 rounded-md text-ink/50 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:e(y,{className:"w-4 h-4"})})]}),e("p",{className:"text-xs text-ink/70 leading-relaxed",children:"Paste a configuration block from omp, Claude, VS Code, Cursor, Gemini, or OpenCode. Every server in the snippet is imported."}),e("textarea",{value:c,onChange:(x)=>{b(x.currentTarget.value),g(null)},rows:10,className:"w-full text-xs font-mono p-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-ink/5 focus:outline-none focus:border-ink resize-none leading-relaxed text-ink transition-colors",placeholder:"Paste JSON snippet here..."}),p&&e("div",{className:"flex items-center gap-2 text-xs text-error p-2.5 rounded-lg bg-error/10 border border-error/20",children:[e(B,{className:"w-4 h-4 flex-shrink-0"}),e("span",{className:"font-medium",children:p})]}),e("div",{className:"pt-3 border-t border-ink/10 flex items-center justify-end gap-2",children:[e("button",{type:"button",onClick:r,className:"px-3.5 py-2 rounded-lg border border-ink/20 hover:border-ink/40 text-xs font-medium text-ink/80 hover:text-ink transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>void k(),disabled:h,className:"flex items-center gap-1.5 px-4 py-2 rounded-lg bg-ink text-paper text-xs font-medium hover:bg-ink/90 transition-colors shadow-xs cursor-pointer disabled:opacity-50 disabled:cursor-progress",children:[h&&e(m,{className:"w-3.5 h-3.5 animate-spin"}),h?"Importing…":"Import Servers"]})]})]})})};var Fp={id:"global",name:"Global (all projects)",path:""},Ts=()=>{let t=ke(),{folders:r}=je(),l=u(()=>{let _=r.flatMap((K)=>K.project_path?[{id:String(K.id),name:K.name,path:K.project_path}]:[]);return[Fp,..._]},[r]),[c,b]=n(!1),[p,g]=n(""),h=p?`?project=${encodeURIComponent(p)}`:"",{items:v,selectedId:k,selected:x,isCreatingNew:A,isLoading:N,loadError:M,reload:P,select:E,startCreate:S,save:R,remove:T}=bt({endpoint:"/api/settings/mcp",listKey:"servers",bodyKey:"server",query:h,messages:{load:"Failed to load MCP servers from API:",save:"Failed to save MCP server via API:",delete:"Failed to delete MCP server via API:"},serverListOnly:!0,deleteFromResponse:!0,buildNew:(_)=>({..._,id:`mcp-${Date.now()}`}),buildUpdate:(_)=>_,buildBody:(_)=>p?{server:_,projectPath:p}:{server:_},buildDeleteQuery:(_)=>{let K=new URLSearchParams({id:_});if(p)K.set("projectPath",p);return`?${K.toString()}`},readList:(_)=>Array.isArray(_?.servers)?_.servers:null,resolveOnLoad:(_,K)=>_&&K.some((V)=>V.id===_)?_:K[0]?.id??null,resolveOnSave:(_,K)=>{if(!K)return;return K.find((z)=>z.name.toLowerCase()===_.name.toLowerCase())?.id??_.id}}),O=async(_)=>{for(let K of _){let V=await R(K);if(!V.ok)return V}return{ok:!0}},L={id:`new-${Date.now()}`,name:"new-mcp-server",scope:"every-project",enabled:!0,transport:"stdio",commandArgs:["bunx","@modelcontextprotocol/server-everything"],envVars:[],headers:[],status:"active"};if(N)return e(Ce,{children:"Loading MCP servers from database..."});return e("div",{className:"flex h-full w-full overflow-hidden bg-paper",children:[e(ye,{pane:t.pane,onBack:t.back,listLabel:"MCP Servers",list:e(gs,{servers:v,projects:l,selectedServerId:A?null:k,onSelectServer:(_)=>{E(_),t.openDetail()},onAddNewServer:()=>{S(),t.openDetail()},selectedProject:p,onChangeProject:g,...M?{loadError:M,onRetry:P}:{}}),detail:e("div",{className:"flex-1 h-full overflow-hidden flex flex-col",children:A?e(to,{server:L,isNew:!0,onSave:R,onOpenImportModal:()=>b(!0)}):x?e(to,{server:x,isNew:!1,onSave:R,onDelete:T,onOpenImportModal:()=>b(!0)},x.id):e("div",{className:"flex-1 flex items-center justify-center text-xs font-mono text-ink/40",children:"Select an MCP server or click + to configure one"})})}),e(Cs,{isOpen:c,onClose:()=>b(!1),onImport:O})]})};var Ct={command:"",env:"",provider:"",model:"",thinking:"",mode:""};function Is(t){let r=t.indexOf("/");return r<=0?"":t.slice(0,r)}function As(t,r){if(t.model&&r.some((l)=>l.value===t.model))return t.model;if(t.provider){let l=r.find((c)=>Is(c.value)===t.provider);if(l)return l.value}return null}function Rs(t){let r=new Set,l=[];for(let c of t){let b=Is(c.value);if(!b||r.has(b))continue;r.add(b),l.push(b)}return l}function Ms(t){return Object.values(t).some((r)=>r.trim()!=="")}var Es={"omp-rpc":{registry:{kind:"yaml-providers",file:".omp/agent/models.yml",pointer:"providers",writable:!0,baseUrlField:"baseUrl",apiKeyField:"apiKey",dialectField:"api",modelsField:"models"},createsChoice:!0,importFrom:["opencode","codex","pi","kimi","qwen"],summary:"omp keeps providers in models.yml. Providers added here are added, not substituted."},"omp-acp":{registry:{kind:"yaml-providers",file:".omp/agent/models.yml",pointer:"providers",writable:!0,baseUrlField:"baseUrl",apiKeyField:"apiKey",dialectField:"api",modelsField:"models"},createsChoice:!0,importFrom:["opencode","codex","pi","kimi","qwen"],summary:"The same models.yml omp over RPC uses — one registry, whichever transport runs the chat."},opencode:{registry:{kind:"json-provider",file:".config/opencode/opencode.json",pointer:"provider",writable:!0,baseUrlField:"options.baseURL",apiKeyField:"options.apiKey",dialectField:"npm",modelsField:"models"},createsChoice:!0,importFrom:["omp-rpc","codex","pi","kimi","qwen"],summary:"opencode reads providers from opencode.json, with an npm SDK per provider and a model map. Added beside the vendored ones."},codex:{registry:{kind:"toml-model-providers",file:".codex/config.toml",pointer:"model_providers",writable:!0,baseUrlField:"base_url",apiKeyField:"env_key",dialectField:"wire_api",modelsField:null,bundledIds:["openai","ollama","lmstudio","amazon-bedrock","amazon-bedrock-runtime","gcp"]},createsChoice:!0,importFrom:["omp-rpc","opencode","pi","kimi"],summary:"codex defines providers in config.toml under [model_providers.<id>]; model_provider selects the active one."},pi:{registry:{kind:"json-providers",file:".pi/agent/models.json",pointer:"providers",writable:!0,baseUrlField:"baseUrl",apiKeyField:"apiKey",dialectField:"api",modelsField:"models"},createsChoice:!0,importFrom:["omp-rpc","opencode","codex"],summary:"pi reads providers from models.json; each needs a baseUrl and an api."},kimi:{registry:{kind:"toml-providers",file:".kimi-code/config.toml",pointer:"providers",writable:!0,baseUrlField:"base_url",apiKeyField:"api_key",dialectField:"type",modelsField:"models",modelsAreRows:!0},createsChoice:!0,importFrom:["omp-rpc","opencode","pi","qwen"],summary:"kimi-code reads [providers.<id>] and [models.<alias>] from config.toml; `type` names the wire protocol and nothing serves until a model alias exists."},qwen:{registry:{kind:"json-model-providers",file:".qwen/settings.json",pointer:"modelProviders",writable:!0,baseUrlField:"baseUrl",apiKeyField:"envKey",modelsField:null,bundledIds:["qwen-oauth"]},createsChoice:!0,importFrom:["omp-rpc","opencode"],summary:"qwen lists model routes under modelProviders, grouped by protocol; credentials stay in the environment."},"command-code":{registry:{kind:"agent-managed",file:".commandcode/providers.json",pointer:"providers",writable:!1,baseUrlField:null,apiKeyField:null,modelsField:null},createsChoice:!0,importFrom:[],summary:"Command Code adds providers with `cmd /connect`, which writes its own providers.json. The models it publishes then appear in Kabmo."},minimax:{registry:{kind:"agent-managed",file:null,pointer:"mcode BYOK",writable:!1,baseUrlField:null,apiKeyField:null,modelsField:null},createsChoice:!0,importFrom:[],summary:"MiniMax stores BYOK providers itself; add one with `mcode`, and Kabmo will see the models it publishes."},jcode:{registry:{kind:"agent-managed",file:".jcode/config.toml",pointer:"providers",writable:!1,baseUrlField:null,apiKeyField:null,modelsField:null},createsChoice:!0,importFrom:[],summary:"jcode keeps providers in ~/.jcode/config.toml, written by its setup wizard and settings menu; Kabmo shows the models it publishes but does not edit that file."},grok:{registry:{kind:"agent-managed",file:".grok/config.toml",pointer:"model",writable:!1,baseUrlField:null,apiKeyField:null,modelsField:null},createsChoice:!0,importFrom:[],summary:"Grok takes custom models as [model.<name>] tables in ~/.grok/config.toml (model, base_url, api_key or env_key, context_window). Kabmo does not write that file; xAI models still need `grok login`."},claude:{registry:{kind:"env",file:null,pointer:"environment",writable:!0,baseUrlField:null,apiKeyField:null,modelsField:null},env:{baseUrl:"ANTHROPIC_BASE_URL",apiKey:"ANTHROPIC_AUTH_TOKEN",model:"ANTHROPIC_MODEL",modelAliases:[{family:"opus",env:"ANTHROPIC_DEFAULT_OPUS_MODEL"},{family:"sonnet",env:"ANTHROPIC_DEFAULT_SONNET_MODEL"},{family:"haiku",env:"ANTHROPIC_DEFAULT_HAIKU_MODEL"},{family:"fable",env:"ANTHROPIC_DEFAULT_FABLE_MODEL"}]},envProtocol:"anthropic-messages",createsChoice:!1,importFrom:["omp-rpc","opencode","codex","pi","kimi","qwen"],summary:"Claude Code has no provider registry: ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN point every request at one endpoint. Setting them REPLACES Anthropic."},antigravity:{registry:{kind:"env",file:null,pointer:"environment",writable:!0,baseUrlField:null,apiKeyField:null,modelsField:null},env:{baseUrl:"GOOGLE_GEMINI_BASE_URL",apiKey:"GEMINI_API_KEY"},envProtocol:"google-genai",createsChoice:!1,importFrom:["omp-rpc","opencode","codex","pi","kimi","qwen"],summary:"Antigravity reads GEMINI_API_KEY and GOOGLE_GEMINI_BASE_URL, and only when modelProvider is `gemini`. It REPLACES the signed-in account."},dsh:{registry:{kind:"none",file:null,pointer:"—",writable:!1,baseUrlField:null,apiKeyField:null,modelsField:null},createsChoice:!1,importFrom:[],summary:"No provider registry Kabmo can write; the launch command and env are the whole surface."},cursor:{registry:{kind:"none",file:null,pointer:"—",writable:!1,baseUrlField:null,apiKeyField:null,modelsField:null},createsChoice:!1,importFrom:[],summary:"Signed in with its own auth flow; no provider registry to edit."},zcode:{registry:{kind:"zcode-provider-rules",file:".zcode/v2/provider_config.json",pointer:"config.providerConfigRules.providerRules",writable:!0,baseUrlField:"config.api.baseUrl",apiKeyField:"config.access.apiKey",dialectField:"config.api.type",modelsField:"config.personalModelIds",modelsAreRows:!0},createsChoice:!0,importFrom:["omp-rpc","opencode","codex","pi","kimi","qwen"],summary:"ZCode keeps user-added providers in ~/.zcode/v2/provider_config.json (3.12+), as provider rules plus one model rule per id. Kabmo merges one provider into that file and leaves the app’s legacy config.json untouched. Chats still need a ZCode runtime: the desktop app, or `zcode-app-cli` on PATH (`ZCODE_BIN` for a custom install)."}};function Os(t){return(t?Es[t]:void 0)??{registry:{kind:"none",file:null,pointer:"—",writable:!1,baseUrlField:null,apiKeyField:null,modelsField:null},createsChoice:!1,importFrom:[],summary:"This build knows nothing about providers for that harness."}}function jp(t){let r=new Set,l=[];for(let c of t){let b=c.value.indexOf("/");if(b<=0)continue;let p=c.value.slice(0,b);if(r.has(p))continue;r.add(p),l.push(p)}return l}function Qp(t){let r=Os(t);if(r.env){let{env:l}=r,c=[l.baseUrl,l.apiKey,l.model].filter(Boolean).join(", "),b=l.modelAliases??[],p=b.map((g)=>g.env).join(", ");return{hint:b.length>0?`The variables that point this agent at one endpoint: ${c}. A picker alias still resolves to the vendor's model id unless ${p} pins it to an id this endpoint serves; unpinned aliases answer 400. Setting them REPLACES its own provider.`:`The variables that point this agent at one endpoint: ${c}. Setting them REPLACES its own provider.`,placeholder:[`${l.baseUrl}=https://…`,`${l.apiKey}=…`,...l.model?[`${l.model}=…`]:[],...b[0]?[`${b[0].env}=…`]:[]].join(`
|
|
31
|
-
`),notes:["This agent has no provider registry — a provider here is an endpoint and a key, nothing else.",...b.length>0?["A picker alias with no default-model variable keeps the vendor’s model id; a custom endpoint answers that id with 400."]:[]]}}if(r.registry.kind==="none")return{hint:"One KEY=VALUE per line. Nothing else configures a provider for this agent.",placeholder:"KEY=VALUE",notes:["No provider registry and no provider variables: the launch line and this box are the whole surface."]};if(r.registry.kind==="agent-managed")return{hint:"One KEY=VALUE per line. Providers themselves are managed by the agent’s own command.",placeholder:"KEY=VALUE",notes:["The provider registry belongs to the agent — add providers with its own command."]};return{hint:`Credentials this agent reads from the environment. Its providers live in ${r.registry.file??"its own config"}.`,placeholder:"KEY=VALUE",notes:[`Providers are edited in ${r.registry.file??"the agent’s own config"}, not here.`]}}function eu(t){let r=t?.trim()??"";if(!r)return{placeholder:"the agent’s own command",hint:"Empty runs the launch line this build’s table gives the agent."};let[l,...c]=r.split(/\s+/),b=l.split("/").pop()||l;return{placeholder:r,hint:`Empty runs the built-in line (${r}). Quoted paths survive: ${[`/Users/me/bin/${b}`,...c].join(" ")}`}}function Ls(t,r,l={}){let c=r?.models??[],b=jp(c),p=Qp(t),g=b.length>0,h=Boolean(l.provider?.trim()),v=eu(l.launchCommand);return{showProvider:g||h,showModel:!0,showThinking:Boolean(r?.thinking?.length),showMode:Boolean(r?.modes?.length),modelsAreSelectors:g,envHint:p.hint,envPlaceholder:p.placeholder,launchPlaceholder:v.placeholder,launchHint:v.hint,notes:p.notes}}function vt({label:t,hint:r,children:l}){return e("label",{className:"flex flex-col gap-1",children:[e("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:t}),l,e("span",{className:"text-[10px] leading-relaxed text-ink/40",children:r})]})}var et="w-full rounded-md border border-ink/20 bg-paper px-2 py-1.5 font-mono text-[11px] text-ink outline-none transition-colors placeholder:text-ink/30 focus:border-ink/50";function Ds({summary:t,config:r,onSave:l}){let[c,b]=n(r),[p,g]=n(!1),[h,v]=n(null),k=t.probe?.models??[],x=Ls(t.id,t.probe??void 0,{...c.provider?{provider:c.provider}:{},...t.command?{launchCommand:t.command}:{}}),A=Rs(k),N=c.provider?k.filter((S)=>S.value.startsWith(`${c.provider}/`)):k,M=As(c,k),P=(S)=>b((R)=>({...R,...S})),E=async()=>{g(!0);try{v(await l(c))}finally{g(!1)}};return e("div",{className:"mt-3 space-y-3 border-t border-ink/10 pt-3",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:"Configuration"}),e("div",{className:"flex items-center gap-1.5",children:[Ms(c)&&e("button",{type:"button",onClick:()=>b({...Ct}),className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-ink/15 px-2 py-1 text-[11px] text-ink/60 transition-colors hover:border-ink/35 hover:text-ink",children:[e(ct,{size:11})," Reset"]}),e("button",{type:"button",onClick:()=>void E(),disabled:p,className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-ink/20 px-2 py-1 text-[11px] text-ink/75 transition-colors hover:border-ink/40 hover:text-ink disabled:cursor-not-allowed disabled:opacity-50",children:[p?e(m,{size:11,className:"animate-spin"}):e(yt,{size:11})," Save"]})]})]}),x.notes.length>0&&e("ul",{className:"space-y-0.5",children:x.notes.map((S)=>e("li",{className:"text-[10px] leading-relaxed text-ink/45",children:S},S))}),e("div",{className:"grid gap-3 sm:grid-cols-2",children:[e(vt,{label:"Launch command",hint:x.launchHint,children:e("input",{type:"text",value:c.command,placeholder:x.launchPlaceholder,onInput:(S)=>P({command:S.currentTarget.value}),className:et})}),x.showProvider&&e(vt,{label:"Provider",hint:A.length>0?`Published by this agent: ${A.slice(0,4).join(", ")}${A.length>4?"…":""}`:"Not known yet — probe the harness to list its providers",children:A.length>0?e(Le,{value:c.provider,onChange:(S)=>P({provider:S,model:""}),placeholder:"Agent default",ariaLabel:"Provider",className:et,options:A.map((S)=>({value:S,label:S}))}):e("input",{type:"text",value:c.provider,placeholder:"command-code",onInput:(S)=>P({provider:S.currentTarget.value}),className:et})}),e(vt,{label:"Default model",hint:c.model?"Applied after session/new":M?`Falls back to ${M}`:"Empty leaves the agent on its own default",children:N.length>0?e(Le,{value:c.model,onChange:(S)=>P({model:S}),placeholder:"Agent default",ariaLabel:"Default model",className:et,options:N.map((S)=>({value:S.value,label:S.name||S.value,hint:S.value}))}):e("input",{type:"text",value:c.model,placeholder:x.modelsAreSelectors?"provider/model":"model name the agent accepts",onInput:(S)=>P({model:S.currentTarget.value}),className:et})}),x.showThinking&&e(vt,{label:"Default thinking",hint:`This agent publishes ${t.probe?.thinking.length??0} levels`,children:e(Le,{value:c.thinking,onChange:(S)=>P({thinking:S}),placeholder:"Agent default",ariaLabel:"Default thinking",className:et,options:(t.probe?.thinking??[]).map((S)=>({value:S.value,label:S.name||S.value}))})})]}),e("div",{className:"grid gap-3 sm:grid-cols-2",children:[x.showMode&&e(vt,{label:"Default mode",hint:`This agent publishes ${t.probe?.modes.length??0} modes`,children:e(Le,{value:c.mode,onChange:(S)=>P({mode:S}),placeholder:"Agent default",ariaLabel:"Default mode",className:et,options:(t.probe?.modes??[]).map((S)=>({value:S.value,label:S.name||S.value}))})}),e(vt,{label:"Environment",hint:x.envHint,children:e("textarea",{value:c.env,rows:3,placeholder:x.envPlaceholder,onInput:(S)=>P({env:S.currentTarget.value}),className:`${et} resize-y`})})]}),h&&e("div",{className:"rounded-lg border border-ink/15 bg-ink/[0.04] p-2 text-[11px] text-ink/75",children:h})]})}var It={"openai-chat":"OpenAI Chat Completions","openai-responses":"OpenAI Responses","anthropic-messages":"Anthropic Messages","google-genai":"Google Gemini","vertex-ai":"Google Vertex AI"};var nn="w-full rounded-md border border-ink/20 bg-paper px-2 py-1.5 font-mono text-[11px] text-ink outline-none transition-colors placeholder:text-ink/30 focus:border-ink/50";function Fs({support:t,onSave:r}){let[l,c]=n(""),[b,p]=n(""),[g,h]=n(""),[v,k]=n({}),[x,A]=n(!1),[N,M]=n(null),P=t.env;if(!P)return null;let E=P.modelAliases??[],S=async()=>{A(!0);try{let R=[l.trim()?`${P.baseUrl}=${l.trim()}`:"",b.trim()?`${P.apiKey}=${b.trim()}`:"",P.model&&g.trim()?`${P.model}=${g.trim()}`:"",...E.map((O)=>{let L=v[O.env]?.trim();return L?`${O.env}=${L}`:""})].filter(Boolean).join(`
|
|
32
|
-
`),T=await r(R);if(M(T),!T)c(""),p(""),h(""),k({})}finally{A(!1)}};return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-start gap-1.5 rounded-md border border-ink/15 bg-ink/[0.03] p-2 text-[10px] leading-relaxed text-ink/65",children:[e(B,{size:11,className:"mt-0.5 shrink-0"}),e("span",{children:["These point ",e("strong",{className:"font-semibold text-ink",children:"every"})," request at one endpoint — they replace this agent's own provider, they do not add beside it."]})]}),e("label",{className:"flex flex-col gap-1",children:[e("span",{className:"font-mono text-[10px] text-ink/50",children:P.baseUrl}),e("input",{type:"text",value:l,placeholder:"https://api.example.com",onInput:(R)=>c(R.currentTarget.value),className:nn})]}),e("label",{className:"flex flex-col gap-1",children:[e("span",{className:"font-mono text-[10px] text-ink/50",children:P.apiKey}),e("input",{type:"password",value:b,autoComplete:"off",placeholder:"sk-…",onInput:(R)=>p(R.currentTarget.value),className:nn})]}),P.model&&e("label",{className:"flex flex-col gap-1",children:[e("span",{className:"font-mono text-[10px] text-ink/50",children:P.model}),e("input",{type:"text",value:g,placeholder:"claude-sonnet-5",onInput:(R)=>h(R.currentTarget.value),className:nn})]}),E.length>0&&e("div",{className:"space-y-1.5 rounded-md border border-ink/15 bg-ink/[0.03] p-2",children:[e("div",{className:"text-[10px] leading-relaxed text-ink/60",children:["Each picker alias resolves to a model id the vendor ships unless it is pinned here. Leave an alias blank when the endpoint serves that family's vendor id; fill it when the endpoint has its own ids — otherwise that pick sends"," ",e("span",{className:"font-mono",children:"400 model not found"}),"."]}),E.map((R)=>e("label",{className:"flex flex-col gap-1",children:[e("span",{className:"font-mono text-[10px] text-ink/50",children:R.env}),e("input",{type:"text",value:v[R.env]??"",placeholder:`the endpoint's ${R.family} model id`,onInput:(T)=>k((O)=>({...O,[R.env]:T.currentTarget.value})),className:nn})]},R.env))]}),e("button",{type:"button",onClick:()=>void S(),disabled:x||!l.trim()&&!b.trim(),className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-ink/20 px-2 py-1 text-[11px] text-ink/75 transition-colors hover:border-ink/40 hover:text-ink disabled:cursor-not-allowed disabled:opacity-50",children:[x?e(m,{size:11,className:"animate-spin"}):e(f,{size:11})," Save to environment"]}),N&&e("div",{className:"rounded-md border border-ink/15 bg-ink/[0.04] p-2 text-[11px] text-ink/75",children:N})]})}function oo(t,r){let l=t.protocol?It[t.protocol]:t.dialect??"unknown dialect";if(r.protocols.length===0)return`${l} — this agent takes no providers`;return`${l} · this agent takes ${r.protocols.map((c)=>It[c]).join(" · ")}`}function tu({entry:t,support:r,onImport:l,busy:c}){return e("div",{className:"flex items-center justify-between gap-2 border-b border-ink/5 py-1.5 last:border-0",children:[e("div",{className:"min-w-0",children:[e("div",{className:"truncate text-[11px] font-medium text-ink",children:[t.name,e("span",{className:"ml-1.5 font-mono text-[9px] uppercase tracking-wider text-ink/35",children:t.source})]}),e("div",{className:"truncate font-mono text-[10px] text-ink/45",children:[t.id,t.models.length>0?` · ${t.models.length} models`:" · no models listed",t.baseUrl?` · ${t.baseUrl}`:""]}),e("div",{className:"truncate text-[10px] text-ink/40",children:oo(t,r)})]}),e("div",{className:"flex shrink-0 items-center gap-1.5",children:[e("span",{className:"text-[10px] text-ink/40",children:t.hasKey?"key stored":"no key"}),e("button",{type:"button",onClick:l,disabled:c,title:"Probes the endpoint, picks a protocol this agent speaks, and copies the credential from the source",className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-ink/20 px-2 py-0.5 text-[10px] text-ink/70 transition-colors hover:border-ink/40 hover:text-ink disabled:cursor-not-allowed disabled:opacity-50",children:[c?e(m,{size:10,className:"animate-spin"}):e(he,{size:10})," Import"]})]})]})}function io({support:t,onImport:r}){let[l,c]=n(null),[b,p]=n(null),g=t.importable;if(g.length===0)return null;return e("div",{className:"mt-3 space-y-1 border-t border-ink/10 pt-3",children:[e("div",{className:"flex items-center justify-between",children:[e("span",{className:"text-[10px] font-medium text-ink/50",children:"Import from another harness"}),e("span",{className:"text-[10px] text-ink/35",children:[g.length," custom"]})]}),g.map((h)=>e(tu,{entry:h,support:t,busy:l===h.id,onImport:()=>{c(h.id),r(h.id,h).then((v)=>p({id:h.id,result:v})).finally(()=>c(null))}},`${h.source}:${h.id}`)),b&&e("div",{className:"mt-1 space-y-0.5",children:[e("p",{className:`text-[10px] ${b.result.problem?"text-ink/70":"text-ink/55"}`,children:b.result.problem?b.result.problem:`Copied ${b.id} into ${t.fileLabel} — restart the agent so it re-reads the file.`}),b.result.detail&&e("p",{className:"font-mono text-[9px] leading-relaxed text-ink/40",children:b.result.detail})]}),e("p",{className:"text-[10px] text-ink/35",children:"Only providers you registered yourself can be copied; a provider the agent ships is its own."})]})}function $s({support:t}){let r=t.configured;return e("div",{className:"space-y-1",children:[e("div",{className:"flex items-center justify-between",children:[e("span",{className:"text-[10px] font-medium text-ink/50",children:"In this agent's registry"}),e("span",{className:"text-[10px] text-ink/35",children:[r.length," custom"]})]}),r.length===0?e("p",{className:"text-[10px] text-ink/40",children:"No provider of your own yet. Add one below, or copy one from another harness."}):r.map((l)=>e("div",{className:"flex items-center justify-between gap-2 border-b border-ink/5 py-1.5 last:border-0",children:[e("div",{className:"min-w-0",children:[e("div",{className:"truncate text-[11px] font-medium text-ink",children:l.name}),e("div",{className:"truncate font-mono text-[10px] text-ink/45",children:[l.id,l.models.length>0?` · ${l.models.length} models`:" · no models listed",l.baseUrl?` · ${l.baseUrl}`:""]}),e("div",{className:"truncate text-[10px] text-ink/40",children:oo(l,t)})]}),e("span",{className:"shrink-0 text-[10px] text-ink/40",children:l.hasKey?"key stored":"no key"})]},l.id))]})}function Bs({support:t}){return e("div",{className:"space-y-1",children:[e("div",{className:"text-[10px] font-medium text-ink/50",children:"Import from another harness"}),t.importable.map((r)=>e("div",{className:"border-b border-ink/5 py-1.5 last:border-0",children:[e("div",{className:"truncate text-[11px] font-medium text-ink",children:[r.name,e("span",{className:"ml-1.5 font-mono text-[9px] uppercase tracking-wider text-ink/35",children:r.source})]}),e("div",{className:"truncate font-mono text-[10px] text-ink/45",children:[r.id,r.models.length>0?` · ${r.models.length} models`:" · no models listed",r.baseUrl?` · ${r.baseUrl}`:""]}),e("div",{className:"truncate text-[10px] text-ink/40",children:oo(r,t)}),e("div",{className:"text-[10px] text-ink/35",children:r.hasKey?"key stored":"no key"})]},`${r.source}:${r.id}`)),e("p",{className:"text-[10px] text-ink/40",children:"This file has no writer in this build; the rows show what the sources hold."})]})}var nu=/^[a-z0-9][a-z0-9._:-]{0,63}$/;function _s(t){return t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64)}function Ks(t){if(!t.trim())return"Enter a provider name to derive an id.";if(!nu.test(t))return"The id must start with a letter or digit, and hold only a-z, 0-9, dot, underscore, colon or dash.";return null}var on="w-full rounded-md border border-ink/20 bg-paper px-2 py-1.5 font-mono text-[11px] text-ink outline-none transition-colors placeholder:text-ink/30 focus:border-ink/50";function ou(t){let r=new Set,l=[];for(let c of t.split(/[\n,]+/)){let b=c.trim();if(!b||r.has(b))continue;r.add(b),l.push(b)}return l}function ao({support:t,onAdd:r}){let[l,c]=n(!1),[b,p]=n(""),[g,h]=n(""),[v,k]=n(""),[x,A]=n(""),[N,M]=n(!1),[P,E]=n(null),S=_s(b),R=b.trim()?Ks(S):null,T=t.level==="full",O=Boolean(b.trim())&&!R&&!N&&(!T||Boolean(g.trim())),L=async()=>{M(!0);try{let _=await r({name:b.trim(),baseUrl:g.trim(),apiKey:v.trim(),...x.trim()?{models:ou(x)}:{}});if(E(_),!_.problem)p(""),h(""),k(""),A("")}finally{M(!1)}};if(!l)return e("div",{className:"mt-2",children:[e("button",{type:"button",onClick:()=>c(!0),className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-ink/20 px-2 py-1 text-[11px] text-ink/70 transition-colors hover:border-ink/40 hover:text-ink",children:[e(Y,{size:11})," Add provider"]}),P?.problem&&e("p",{className:"mt-1 text-[10px] text-ink/70",children:P.problem}),P&&!P.problem&&e("p",{className:"mt-1 text-[10px] text-ink/55",children:P.detail??"Added."})]});return e("div",{className:"mt-2 space-y-2 rounded-md border border-ink/15 bg-ink/[0.02] p-2",children:[e("div",{className:"flex items-center justify-between",children:[e("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:"Add provider"}),e("span",{className:"font-mono text-[9px] text-ink/35",children:t.protocols.length>0?"protocol measured on save":"no provider slot here"})]}),e("label",{className:"flex flex-col gap-1",children:[e("span",{className:"text-[10px] text-ink/50",children:"Name"}),e("input",{type:"text",value:b,placeholder:"My Gateway",onInput:(_)=>p(_.currentTarget.value),className:on}),S&&e("span",{className:"font-mono text-[9px] text-ink/35",children:["id: ",S,R?"":` · ${t.pointer??"registry"}`]}),R&&e("span",{className:"text-[10px] text-ink/70",children:R})]}),e("label",{className:"flex flex-col gap-1",children:[e("span",{className:"text-[10px] text-ink/50",children:"Base URL"}),e("input",{type:"text",value:g,placeholder:"https://gateway.example/v1",onInput:(_)=>h(_.currentTarget.value),className:on}),t.level==="environment"&&t.env&&e("span",{className:"font-mono text-[9px] text-ink/35",children:["becomes ",t.env.baseUrl," — host root, the agent appends its own path"]})]}),e("label",{className:"flex flex-col gap-1",children:[e("span",{className:"text-[10px] text-ink/50",children:"API key"}),e("input",{type:"password",value:v,autoComplete:"off",placeholder:"sk-…",onInput:(_)=>k(_.currentTarget.value),className:on}),t.credentialLabel&&e("span",{className:"font-mono text-[9px] text-ink/35",children:["stored as ",t.credentialLabel]})]}),t.level==="full"&&e("label",{className:"flex flex-col gap-1",children:[e("span",{className:"text-[10px] text-ink/50",children:"Models"}),e("input",{type:"text",value:x,placeholder:"model-id, another-id",onInput:(_)=>A(_.currentTarget.value),className:on}),e("span",{className:"text-[9px] text-ink/35",children:"Comma separated. Leave it empty only for an endpoint OVERRIDE of a provider the agent already ships — measured: a provider with no models and no discovery serves nothing."})]}),e("div",{className:"flex items-center gap-2",children:[e("button",{type:"button",onClick:()=>void L(),disabled:!O,className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-ink/20 px-2 py-1 text-[11px] text-ink/75 transition-colors hover:border-ink/40 hover:text-ink disabled:cursor-not-allowed disabled:opacity-50",children:[N?e(m,{size:11,className:"animate-spin"}):e(f,{size:11})," Add"]}),e("button",{type:"button",onClick:()=>{c(!1),E(null)},className:"cursor-pointer text-[11px] text-ink/45 hover:text-ink",children:"Cancel"})]}),P&&e("div",{className:"space-y-0.5",children:[e("p",{className:`text-[10px] ${P.problem?"text-ink/70":"text-ink/55"}`,children:P.problem??"Added."}),P.detail&&e("p",{className:"font-mono text-[9px] leading-relaxed text-ink/40",children:P.detail})]})]})}function zs({support:t,onSaveEnv:r,onImport:l,onAddProvider:c}){if(t.level==="configurable")return e("div",{className:"mt-3 space-y-2 border-t border-ink/10 pt-3",children:[e("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:"Providers"}),e("p",{className:"text-[11px] leading-relaxed text-ink/55",children:t.summary}),e("p",{className:"text-[10px] text-ink/40",children:"Use the launch command and environment fields above — that is this agent's whole surface."})]});if(t.level==="environment")return e("div",{className:"mt-3 space-y-2 border-t border-ink/10 pt-3",children:[e("div",{className:"flex items-center justify-between",children:[e("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:"Provider"}),e("span",{className:"font-mono text-[10px] text-ink/40",children:t.fileLabel})]}),e("p",{className:"text-[11px] leading-relaxed text-ink/55",children:t.summary}),r&&e(Fs,{support:t,onSave:r}),c&&e(ao,{support:t,onAdd:c}),l&&e(io,{support:t,onImport:l})]});return e(su,{support:t,onImport:l,onAddProvider:c})}function su({support:t,onImport:r,onAddProvider:l}){return e("div",{className:"mt-3 space-y-2 border-t border-ink/10 pt-3",children:[e("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:"Providers"}),e("span",{className:"font-mono text-[10px] text-ink/40",title:t.file||void 0,children:[t.fileLabel,t.pointer?` · ${t.pointer}`:""]})]}),e("p",{className:"text-[11px] leading-relaxed text-ink/55",children:t.summary}),e("div",{className:"flex flex-wrap gap-1",children:t.protocols.map((c)=>e("span",{className:"rounded border border-ink/15 px-1.5 py-0.5 font-mono text-[9px] text-ink/50",children:It[c]},c))}),t.configured.length>0&&e($s,{support:t}),l&&e(ao,{support:t,onAdd:l}),t.importable.length===0?e("p",{className:"text-[10px] text-ink/40",children:"Nothing to import yet — the other agents' registries hold no provider you registered yourself."}):e("div",{children:r?e(io,{support:t,onImport:r}):e(Bs,{support:t})})]})}function Ke({label:t,value:r,detail:l}){return e("div",{className:"flex items-start justify-between gap-3 border-b border-ink/5 py-1.5 last:border-0",children:[e("div",{className:"min-w-0",children:[e("div",{className:"text-ink/70",children:t}),l&&e("div",{className:"truncate text-[10px] text-ink/40",title:l,children:l})]}),e("span",{className:"shrink-0 font-mono text-[11px]",children:r===null?e("span",{className:"text-ink/35",children:"—"}):r?e("span",{className:"inline-flex items-center gap-1 text-ink/80",children:[e(f,{size:11})," yes"]}):e("span",{className:"inline-flex items-center gap-1 text-ink/40",children:[e(y,{size:11})," no"]})})]})}function Hs({summary:t,onProbe:r,install:l,config:c,onSaveConfig:b,providerSupport:p,onImportProvider:g,onAddProvider:h,onSetEnabled:v,busy:k=!1}){let[x,A]=n(!1),[N,M]=n(t.probe?.capabilities.blocked??null),P=t.probe?.capabilities,E=Ko(N?{...t,probe:t.probe&&{...t.probe,capabilities:{...t.probe.capabilities,blocked:N}}}:t),S=E.state!=="ready"&&E.state!=="unprobed",R=async()=>{A(!0);try{let T=await r(t.id);M(T)}finally{A(!1)}};return e("section",{className:"rounded-xl border border-ink/10 bg-paper",children:[e("header",{className:"flex items-center justify-between gap-3 border-b border-ink/10 px-4 py-3",children:[e("div",{className:"flex min-w-0 items-center gap-2",children:[e(gt,{harness:t.id,size:18}),e("div",{className:"min-w-0",children:[e("div",{className:"truncate text-sm font-medium text-ink",children:t.label}),e("div",{className:"text-[11px] text-ink/45",children:[t.transport==="rpc"?"Native RPC (always available)":"ACP over stdio",P?.agentVersion?` · ${P.agentVersion}`:""]})]})]}),e("div",{className:"flex shrink-0 items-center gap-2",children:[e("span",{className:"inline-flex items-center gap-1 text-[11px] text-ink/60",title:E.detail??void 0,children:[e(lu,{state:E.state}),E.label]}),e("button",{type:"button",onClick:()=>void R(),disabled:x||k||!t.canLaunch||t.builtIn,title:t.builtIn?"Nothing to probe: Kabmo runs this transport itself":!t.canLaunch?E.detail??"Not installed":"Spawn this harness once and read what it reports",className:"cursor-pointer rounded-md border border-ink/20 px-2 py-1 text-[11px] text-ink/70 transition-colors hover:border-ink/40 hover:text-ink disabled:cursor-not-allowed disabled:opacity-50",children:x?e(m,{size:12,className:"animate-spin"}):"Check status"}),v&&!t.builtIn&&e("button",{type:"button",role:"switch","aria-checked":t.enabled,"aria-label":`${t.enabled?"Disable":"Enable"} ${t.label}`,disabled:x||k,onClick:()=>v(!t.enabled),title:t.enabled?"Turn off — hides this page and removes the agent from the model picker":"Turn on — probes it once and adds its settings page",className:`relative h-4 w-8 shrink-0 rounded-full transition-colors disabled:opacity-40 ${t.enabled?"bg-ink/70":"bg-ink/20"}`,children:e("span",{className:`absolute top-0.5 h-3 w-3 rounded-full bg-canvas transition-all ${t.enabled?"left-[18px]":"left-0.5"}`})})]})]}),e("div",{className:"px-4 py-3 text-xs",children:[e("div",{className:`mb-3 rounded-lg border p-2.5 text-[11px] ${S?"border-ink/15 bg-ink/[0.04] text-ink/75":"border-ink/10 bg-ink/[0.02] text-ink/55"}`,children:[e("div",{className:S?"font-medium text-ink":"",children:E.detail}),E.state==="not-installed"&&l&&e("div",{className:"mt-1 font-mono text-[10px] text-ink/50",children:l})]}),t.note&&e("p",{className:"mb-3 text-[11px] leading-relaxed text-ink/45",children:t.note}),e("div",{className:"grid gap-x-6 sm:grid-cols-2",children:[e("div",{children:[e("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink/40",children:"Session"}),e(Ke,{label:"Load / resume history",value:P?P.loadSession||P.resumeSession:null}),e(Ke,{label:"List sessions",value:P?P.listSessions:null}),e(Ke,{label:"Fork",value:P?P.forkSession:null}),e(Ke,{label:"Delete",value:P?P.deleteSession:null})]}),e("div",{children:[e("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink/40",children:"Composer"}),e(Ke,{label:"Models offered",value:P?P.configModel>0:null,detail:P&&P.configModel>0?`${P.configModel} entries`:void 0}),e(Ke,{label:"Thinking levels",value:P?P.configThinking>0:null,detail:P&&P.configThinking>0?`${P.configThinking} levels`:void 0}),e(Ke,{label:"Mode selector",value:P?P.configMode>0:null,detail:P&&P.modeValues.length>0?P.modeValues.join(" · "):void 0}),e(Ke,{label:"Mid-turn steering",value:P?P.steerMode!==null:null,detail:P?.steerMode==="follow-up"?"queue only":void 0})]})]}),b&&!t.builtIn&&e(Ds,{summary:t,config:c??{...Ct},onSave:(T)=>b(t.id,T)}),p&&!t.builtIn&&e(zs,{support:p,...b?{onSaveEnv:(T)=>b(t.id,{...c??Ct,env:T})}:{},...g?{onImport:(T,O)=>g(t.id,T,O)}:{},...h?{onAddProvider:(T)=>h(t.id,T)}:{}}),e("div",{className:"mt-1 grid gap-x-6 sm:grid-cols-2",children:[e(Ke,{label:"Usage / cost reported",value:P?P.hasUsage:null,detail:P&&!P.hasUsage?"usage panel shows “not reported”":void 0}),e(Ke,{label:"Plan updates",value:P?P.hasPlan:null})]})]})]})}function lu({state:t}){if(t==="ready")return e("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 rounded-full bg-success"});if(t==="not-installed")return e(Ji,{size:12,className:"text-ink/55"});if(t==="needs-setup")return e(B,{size:12,className:"text-ink/60"});return e(Hi,{size:12,className:"text-ink/40"})}function du({state:t}){if(t==="ready")return e(f,{size:11,className:"text-ink/70"});if(t==="not-installed")return e(Ji,{size:11,className:"text-ink/50"});if(t==="needs-setup")return e(B,{size:11,className:"text-ink/55"});return e(Hi,{size:11,className:"text-ink/35"})}function cu(t){let r=t.probe;if(!r)return"not probed";let l=Math.max(0,Math.round((Date.now()-r.probedAt)/60000)),c=l<1?"just now":l<60?`${l}m ago`:`${Math.round(l/60)}h ago`;return r.stale?`checked ${c} · re-check for a current version`:`checked ${c}`}function Ws({harnesses:t,busy:r,onSetEnabled:l,onOpen:c,onProbe:b}){return e("ul",{className:"divide-y divide-ink/10 rounded-xl border border-ink/10 bg-paper",children:t.map((p)=>{let g=Ko(p),h=r===p.id;return e("li",{className:"flex items-center gap-3 px-3 py-2.5",children:[e("span",{className:p.enabled?"":"opacity-40",children:e(gt,{harness:p.id,size:Et.compact})}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:`truncate text-xs font-medium ${p.enabled?"text-ink":"text-ink/45"}`,children:p.label}),e("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-ink/45",children:[e("span",{className:"inline-flex items-center gap-1",title:g.detail??void 0,children:[e(du,{state:g.state}),g.label]}),p.enabled&&e("span",{className:"text-ink/35",children:p.canLaunch?cu(p):g.detail})]})]}),p.enabled&&e("button",{type:"button",disabled:h||!p.canLaunch,onClick:()=>b(p.id),title:p.canLaunch?"Spawn this agent once and read what it reports":g.detail??"Not installed",className:"shrink-0 cursor-pointer rounded-md border border-ink/15 px-2 py-1 text-[10px] text-ink/60 transition-colors hover:border-ink/35 hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:h?e(m,{size:10,className:"animate-spin"}):"Check"}),p.enabled&&e("button",{type:"button",onClick:()=>c(p.id),title:`Open ${p.label} settings`,"aria-label":`Open ${p.label} settings`,className:"shrink-0 cursor-pointer rounded p-1 text-ink/40 transition-colors hover:text-ink",children:e(Lo,{size:12})}),e("button",{type:"button",role:"switch","aria-checked":p.enabled,"aria-label":`${p.enabled?"Disable":"Enable"} ${p.label}`,disabled:h,onClick:()=>l(p.id,!p.enabled),title:p.enabled?"Turn off — hides its settings page and removes it from the model picker":"Turn on — probes it once and adds its settings page",className:`relative h-4 w-8 shrink-0 rounded-full transition-colors disabled:opacity-40 ${p.enabled?"bg-ink/70":"bg-ink/20"}`,children:h?e(m,{size:9,className:"absolute inset-0 m-auto animate-spin text-canvas"}):e("span",{className:`absolute top-0.5 h-3 w-3 rounded-full bg-canvas transition-all ${p.enabled?"left-[18px]":"left-0.5"}`})})]},p.id)})})}function Gs({value:t,onChange:r,placeholder:l}){return e("div",{className:"relative flex min-w-[14rem] flex-1 items-center",children:[e(F,{size:13,className:"pointer-events-none absolute left-2.5 text-ink/40"}),e("input",{type:"text",value:t,onChange:(c)=>r(c.currentTarget.value),placeholder:l,className:"w-full rounded-md border border-ink/20 bg-paper py-1.5 pl-7 pr-7 text-xs text-ink outline-none transition-colors placeholder:text-ink/35 focus:border-ink/50"}),t&&e("button",{type:"button",onClick:()=>r(""),title:"Clear search","aria-label":"Clear search",className:"absolute right-1.5 cursor-pointer rounded p-0.5 text-ink/40 transition-colors hover:text-ink",children:e(y,{size:12})})]})}function Rt({message:t,onDismiss:r,dismissLabel:l="Dismiss message"}){return e("div",{className:"flex items-start gap-2 rounded-lg border border-ink/15 bg-ink/[0.03] p-3 text-[11px] text-ink/70",children:[e(B,{size:13,className:"mt-0.5 shrink-0"}),e("span",{className:"min-w-0 flex-1",children:t}),r&&e("button",{type:"button",onClick:r,title:l,"aria-label":l,className:"-m-0.5 shrink-0 cursor-pointer rounded p-0.5 text-ink/40 transition-colors hover:text-ink",children:e(y,{size:12})})]})}var qs={id:"",label:"",command:"",env:"",initial:""};function Vs({harnesses:t,onChanged:r}){let[l,c]=n(qs),[b,p]=n(!1),[g,h]=n(null),v=t.filter((N)=>N.custom),k=(N)=>(M)=>{let P=M.currentTarget.value;c((E)=>({...E,[N]:P}))},x=async(N)=>{N.preventDefault(),p(!0),h(null);try{let M=await fetch("/api/harness",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({customHarness:l})}),P=await M.json();if(!M.ok){h(P.error??`Could not add this harness (HTTP ${M.status})`);return}c(qs),r()}catch(M){h(M instanceof Error?M.message:"Could not add this harness")}finally{p(!1)}},A=async(N)=>{p(!0),h(null);try{let M=await fetch("/api/harness",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({removeHarness:N})}),P=await M.json();if(!M.ok){h(P.error??`Could not remove this harness (HTTP ${M.status})`);return}r()}catch(M){h(M instanceof Error?M.message:"Could not remove this harness")}finally{p(!1)}};return e("section",{className:"space-y-3 rounded-xl border border-ink/10 p-4",children:[e("header",{children:[e("h3",{className:"text-sm font-semibold text-ink",children:"Add an ACP harness"}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:"Any agent that speaks the Agent Client Protocol over stdio. Kabmo runs the command you type, so only add a program you trust."})]}),g&&e(Rt,{message:g,onDismiss:()=>h(null),dismissLabel:"Dismiss this message"}),e("form",{onSubmit:x,className:"grid gap-2 sm:grid-cols-2",children:[e("label",{className:"text-[11px] text-ink/60",children:["id",e("input",{value:l.id,onInput:k("id"),placeholder:"my-agent",required:!0,pattern:"[a-z0-9][a-z0-9-]{0,31}",className:"mt-1 w-full rounded-md border border-ink/20 bg-paper px-2 py-1.5 text-xs text-ink outline-none focus:border-ink/50"})]}),e("label",{className:"text-[11px] text-ink/60",children:["label",e("input",{value:l.label,onInput:k("label"),placeholder:"My Agent",className:"mt-1 w-full rounded-md border border-ink/20 bg-paper px-2 py-1.5 text-xs text-ink outline-none focus:border-ink/50"})]}),e("label",{className:"text-[11px] text-ink/60 sm:col-span-2",children:["command",e("input",{value:l.command,onInput:k("command"),placeholder:"npx -y my-agent acp",required:!0,className:"mt-1 w-full rounded-md border border-ink/20 bg-paper px-2 py-1.5 font-mono text-xs text-ink outline-none focus:border-ink/50"})]}),e("label",{className:"text-[11px] text-ink/60 sm:col-span-2",children:["env (one KEY=VALUE per line)",e("textarea",{value:l.env,onInput:k("env"),rows:2,className:"mt-1 w-full rounded-md border border-ink/20 bg-paper px-2 py-1.5 font-mono text-xs text-ink outline-none focus:border-ink/50"})]}),e("label",{className:"text-[11px] text-ink/60",children:["initial (optional)",e("input",{value:l.initial,onInput:k("initial"),maxLength:2,placeholder:"M",className:"mt-1 w-full rounded-md border border-ink/20 bg-paper px-2 py-1.5 text-xs text-ink outline-none focus:border-ink/50"})]}),e("div",{className:"flex items-end",children:e("button",{type:"submit",disabled:b,className:"inline-flex cursor-pointer items-center gap-1.5 rounded-md border border-ink/20 px-2.5 py-1.5 text-[11px] text-ink/70 transition-colors hover:border-ink/40 hover:text-ink disabled:cursor-not-allowed disabled:opacity-50",children:[e(Y,{size:12})," Add harness"]})})]}),v.length>0&&e("ul",{className:"divide-y divide-ink/10 border-t border-ink/10 pt-2",children:v.map((N)=>e("li",{className:"flex items-center justify-between gap-3 py-1.5",children:[e("span",{className:"min-w-0 truncate text-xs text-ink",children:[N.label," ",e("span",{className:"text-ink/40",children:["(",N.id,")"]})]}),e("button",{type:"button",disabled:b,onClick:()=>void A(N.id),title:`Remove ${N.label}`,"aria-label":`Remove ${N.label}`,className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-ink/20 px-2 py-1 text-[11px] text-ink/60 transition-colors hover:border-ink/40 hover:text-ink disabled:cursor-not-allowed disabled:opacity-50",children:[e(U,{size:11})," Remove"]})]},N.id))})]})}function so({only:t}={}){let{harnesses:r,configs:l,providerSupport:c,isLoading:b,error:p,reload:g,probe:h,saveConfig:v,importProvider:k,addProvider:x,setEnabled:A}=Nn(),[N,M]=n(""),[P,E]=n(null),[S,R]=n(null),[T,O]=n(null),L=u(()=>r.filter((j)=>!j.builtIn),[r]),_=u(()=>{if(t)return L.filter((H)=>H.id===t);let j=N.trim().toLowerCase();if(!j)return L;return L.filter((H)=>H.label.toLowerCase().includes(j)||H.id.includes(j)||(H.note??"").toLowerCase().includes(j))},[L,N,t]),K=L.filter((j)=>j.enabled).length,V=L.filter((j)=>j.enabled&&j.probe&&!j.probe.capabilities.blocked).length,z=async(j,H)=>{E(j),R(null);try{R(await A(j,H))}finally{E(null)}},q=async(j)=>{E(j),R(null);try{R(await h(j))}finally{E(null)}},G=(j)=>{window.dispatchEvent(new CustomEvent("omp:open-settings",{detail:{category:Us(j)}}))};return e("div",{className:"space-y-4",children:[e("header",{className:"flex flex-wrap items-start justify-between gap-3",children:[e("div",{children:[e("h2",{className:"text-base font-semibold text-ink",children:t?r.find((j)=>j.id===t)?.label??t:"All Harnesses"}),e("p",{className:"mt-0.5 text-xs text-ink/50",children:t?"Providers, launch command, and the defaults a new chat on this agent starts on.":"Switch on the agents you run. An agent that is off keeps no settings page and no tab in the model picker; switching one on probes it once."})]}),e("button",{type:"button",onClick:g,disabled:b,"aria-busy":b,className:"inline-flex cursor-pointer items-center gap-1.5 rounded-md border border-ink/20 px-2.5 py-1.5 text-[11px] text-ink/70 transition-colors hover:border-ink/40 hover:text-ink disabled:opacity-50",children:[e(C,{size:12,className:b?"animate-spin":void 0})," Reload catalog"]})]}),!t&&e("div",{className:"flex flex-wrap items-center gap-3",children:[e(Gs,{value:N,onChange:M,placeholder:"Search harnesses"}),e("span",{className:"text-[11px] text-ink/45",children:[K,"/",L.length," on · ",V," probed ready"]})]}),p&&p!==T&&e(Rt,{message:p,onDismiss:()=>O(p),dismissLabel:"Dismiss the catalog error"}),S&&e(Rt,{message:S,onDismiss:()=>R(null),dismissLabel:"Dismiss this message"}),b&&r.length===0?e("div",{className:"rounded-xl border border-ink/10 p-6 text-center text-xs text-ink/40",children:"Reading the harness catalog…"}):t?e("div",{className:"space-y-3",children:[_.map((j)=>e(Hs,{summary:j,onProbe:h,install:j.install,config:l[j.id],onSaveConfig:v,onSetEnabled:(H)=>void z(j.id,H),busy:P===j.id,...c[j.id]?{providerSupport:c[j.id]}:{},onImportProvider:k,onAddProvider:x},j.id)),_.length===0&&e("div",{className:"rounded-xl border border-ink/10 p-6 text-center text-xs text-ink/40",children:["This build does not list a harness named “",t,"”."]})]}):_.length===0?e("div",{className:"rounded-xl border border-ink/10 p-6 text-center text-xs text-ink/40",children:["No harness matches “",N,"”."]}):e(d,{children:[e(Ws,{harnesses:_,busy:P,onSetEnabled:(j,H)=>void z(j,H),onOpen:G,onProbe:(j)=>void q(j)}),e(Vs,{harnesses:r,onChanged:g})]})]})}function rn(t){let r=t.source??"";if(r.startsWith("native:"))return"omp";if(r.startsWith("agents:"))return"agents";if(r.startsWith("claude-plugins:"))return"claude";if(r.startsWith("claude:"))return"claude";if(r.startsWith("codex:"))return"codex";if(r.startsWith("github:"))return"github";if(r.startsWith("opencode:"))return"opencode";if(r.startsWith("skillshare:"))return"skillshare";return r.split(":")[0]||"other"}function ln(t){if(t.source?.startsWith("skillshare:"))return"user";if(t.source?.endsWith(":project"))return"project";if(t.source?.endsWith(":user"))return"user";return t.location}var Ys=[{id:"all",label:"All"},{id:"managed",label:"Managed"},{id:"read-only",label:"Read-only"},{id:"hidden",label:"Hidden"}];function Js(t,r,l){let c=r.trim().toLowerCase();return t.filter((b)=>{if(l==="managed"&&b.managed!==!0)return!1;if(l==="read-only"&&b.managed===!0)return!1;if(l==="hidden"&&b.hidden!==!0)return!1;if(!c)return!0;return`${b.name} ${b.description} ${b.source??""}`.toLowerCase().includes(c)})}function Xs(t){return{all:t.length,managed:t.filter((r)=>r.managed===!0).length,"read-only":t.filter((r)=>r.managed!==!0).length,hidden:t.filter((r)=>r.hidden===!0).length}}function Zs({skills:t,selectedSkillId:r,isCreatingNew:l,onSelectSkill:c,onAddNewSkill:b,onImportFromGit:p,onOpenCatalog:g,selectedProject:h,onSelectProject:v,projectOptions:k,loadError:x,onRetry:A}){let[N,M]=n({}),[P,E]=n(""),[S,R]=n("all"),T=Js(t,P,S),O=Xs(t),L={},_=[];for(let z of T)if(z.group)(L[z.group]??=[]).push(z);else _.push(z);let K=(z)=>{M((q)=>({...q,[z]:!q[z]}))},V=(z)=>{let q=!l&&r===z.id;return e("button",{type:"button",onClick:()=>c(z.id),className:`w-full text-left px-2 py-1.5 rounded-lg transition-colors cursor-pointer ${q?"bg-ink/10 text-ink shadow-2xs":"text-ink/75 hover:bg-ink/5 hover:text-ink"}`,children:[e("div",{className:"flex items-center gap-1.5 min-w-0",children:[e("span",{className:"truncate text-xs font-medium",children:z.name}),z.hidden?e(wt,{size:11,className:"text-ink/40 flex-shrink-0",title:"Hidden from the model"}):null,z.managed!==!0?e(Ur,{size:10,className:"text-ink/35 flex-shrink-0",title:"Read-only"}):null]}),e("div",{className:"flex items-center gap-1.5 text-[10px] text-ink/45 mt-0.5",children:[e("span",{className:"font-mono px-1 rounded bg-ink/5 flex-shrink-0",children:rn(z)}),e("span",{className:"truncate",children:ln(z)})]})]},z.id)};return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0",children:[e(Xe,{variant:"compact",selectedProject:h,onChangeProject:v,...k?{options:k}:{},getTriggerLabel:(z,q)=>z.find((G)=>G.id===q||G.value===q)?.label||q}),e("div",{className:"px-3 pt-2.5 pb-2 space-y-2 border-b border-ink/10",children:[e("div",{className:"relative",children:[e(F,{size:13,className:"absolute left-2 top-1.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",value:P,onInput:(z)=>E(z.currentTarget.value),placeholder:"Filter skills…",className:"w-full pl-7 pr-2 py-1 rounded-md border border-ink/20 bg-paper focus:outline-none focus:border-ink text-[11px] text-ink transition-colors"})]}),e("div",{className:"flex flex-wrap gap-1",children:Ys.map((z)=>e("button",{type:"button",onClick:()=>R(z.id),className:`px-1.5 py-0.5 rounded-md text-[10px] font-medium transition-colors cursor-pointer ${S===z.id?"bg-ink text-paper":"text-ink/60 hover:bg-ink/5 hover:text-ink"}`,children:[z.label," ",O[z.id]]},z.id))}),e("button",{type:"button",onClick:b,className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 rounded-lg bg-ink text-paper text-[11px] font-medium hover:bg-ink/90 transition-colors cursor-pointer",children:[e(Y,{size:13}),e("span",{children:"New skill"})]})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-1.5 space-y-2",children:[x?e("div",{className:"mx-1 rounded-lg border border-error/30 bg-error/5 px-2.5 py-2 text-[11px] leading-snug text-error",children:[e("div",{className:"font-semibold",children:"Could not read the skills"}),e("div",{className:"mt-0.5 break-words text-error/80",children:x}),A?e("button",{type:"button",onClick:A,className:"mt-1.5 rounded border border-error/40 px-2 py-0.5 font-medium hover:bg-error/10 cursor-pointer",children:"Retry"}):null]}):null,l?e("div",{className:"px-2.5 py-1.5 rounded-lg bg-ink/10 text-ink font-medium text-xs",children:"new-skill"}):null,T.length===0?e("div",{className:"px-2.5 py-6 text-center space-y-1",children:[e("p",{className:"text-[11px] text-ink/60",children:t.length===0?"No skills in this scope.":"Nothing matches that filter."}),t.length===0?e("p",{className:"text-[10px] text-ink/45",children:["Create one with ",e("span",{className:"font-semibold",children:"New skill"}),", import a repository, or browse the catalog."]}):null]}):null,Object.entries(L).map(([z,q])=>{let G=!!N[z];return e("div",{className:"space-y-0.5",children:[e("button",{type:"button",onClick:()=>K(z),className:"w-full flex items-center justify-between px-2 py-1 rounded-md text-ink/80 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:[e("div",{className:"flex items-center gap-1.5 truncate",children:[G?e(se,{size:13,className:"text-ink/60"}):e(I,{size:13,className:"text-ink/60"}),e("span",{className:"truncate text-[11px] font-bold uppercase tracking-tight text-ink/90",children:z})]}),e("span",{className:"text-[10px] font-mono text-ink/50 px-1.5 rounded bg-ink/5",children:q.length})]}),!G?e("div",{className:"pl-3 space-y-0.5 border-l border-ink/10 ml-2.5",children:q.map(V)}):null]},z)}),_.length>0?e("div",{className:"space-y-0.5 pt-1",children:_.map(V)}):null]}),e("div",{className:"p-2 border-t border-ink/10 space-y-1",children:[e("button",{type:"button",onClick:p,className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Import from Git"}),e("button",{type:"button",onClick:g,className:"w-full px-2 py-1.5 rounded-lg text-[11px] font-medium text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Browse the catalog"})]})]})}function dn(t){if(!t?.startsWith("skillshare:"))return null;let r=t.slice(11),l=r.lastIndexOf("@");return l>0?r.slice(0,l):r}function lo({children:t,title:r}){return e("span",{title:r,className:"px-1.5 py-0.5 rounded-md border border-ink/15 bg-ink/[0.03] text-[10px] font-mono text-ink/65 whitespace-nowrap",children:t})}function el({skill:t,isCreatingNew:r,name:l,locationLabel:c,dirty:b,validationError:p,readOnly:g,hidden:h,isReloading:v,confirmingDelete:k,onReload:x,onOpenCatalog:A,onHiddenChange:N,onRequestDelete:M,onConfirmDelete:P,onCancelDelete:E,onUninstallRegistry:S,onSave:R,saving:T=!1,saved:O=!1,writeError:L=null,onDismissWriteError:_}){let[K,V]=n(!1),z=r?"New skill":t?.name??l,q=t?dn(t.source):null;return e("div",{className:"space-y-3",children:[e("div",{className:"flex items-start justify-between gap-3 pb-3 border-b border-ink/10",children:[e("div",{className:"min-w-0",children:[e("div",{className:"flex items-center gap-2 flex-wrap",children:[e("h2",{className:"text-sm font-bold tracking-tight text-ink truncate",children:z}),!r&&t?e(d,{children:[e(lo,{title:t.source,children:rn(t)}),e(lo,{children:ln(t)}),g?e("span",{className:"flex items-center gap-1 text-[10px] text-ink/55",children:[e(Ur,{size:10}),"read-only"]}):null,h?e(lo,{children:"hidden"}):null]}):null,b?e("span",{className:"flex items-center gap-1 text-[10px] font-semibold text-ink/70",children:[e("span",{className:"w-1.5 h-1.5 rounded-full bg-ink"}),"unsaved"]}):null]}),e("p",{className:"text-[11px] text-ink/55 mt-0.5 truncate",children:r?`A new skill written to ${c}`:t?.description||`No description · ${c}`})]}),e("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[x?e("button",{type:"button",onClick:x,disabled:v,title:"Re-discover skills in the running agents",className:"flex items-center gap-1 px-2 py-1 rounded-lg border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink hover:bg-ink/5 disabled:opacity-50 transition-colors cursor-pointer",children:[e(C,{size:12,className:v?"animate-spin text-ink/70":"text-ink/70"}),e("span",{className:"hidden sm:inline",children:"Reload"})]}):null,A?e("button",{type:"button",onClick:A,className:"flex items-center gap-1 px-2 py-1 rounded-lg border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:[e(Fe,{size:12,className:"text-ink/70"}),e("span",{className:"hidden sm:inline",children:"Catalog"})]}):null]})]}),g?e("div",{className:"rounded-lg border border-ink/15 bg-ink/[0.03] px-3 py-2 text-[11px] text-ink/70 leading-relaxed",children:["Provided by ",e("span",{className:"font-mono text-ink/85",children:t?.source}),", so Kabmo cannot edit it. The file is ",e("span",{className:"font-mono text-ink/85 break-all",children:t?.filePath}),"."," ",q?"Uninstall it here to remove the package from omp, or edit it at its source.":"Edit it at its source, or import a copy into ~/.omp/agent/skills to own it here."]}):null,e("label",{className:"flex items-start gap-2 cursor-pointer select-none",children:[e("input",{type:"checkbox",checked:h,disabled:g,onChange:(G)=>N(G.currentTarget.checked),className:`${ge} mt-0.5 accent-ink cursor-pointer disabled:cursor-not-allowed`}),e("span",{className:"text-[11px] text-ink/75 leading-relaxed",children:[e("span",{className:"inline-flex items-center gap-1",children:["Hide from the model's skill listing",h?e(wt,{size:11,className:"text-ink/45"}):e(Ge,{size:11,className:"text-ink/45"})]}),e("span",{className:"block text-[10px] text-ink/45",children:["Still runnable via ",e("span",{className:"font-mono",children:["/skill:",l||"name"]}),"."]})]})]}),p?e("p",{className:"text-[11px] text-error leading-relaxed",children:p}):null,L?e("div",{className:"flex items-start gap-1.5 rounded-lg border border-error/30 bg-error/5 px-2.5 py-2 text-[11px] text-error",children:[e(B,{size:12,className:"mt-px flex-shrink-0"}),e("span",{className:"flex-1 break-words",children:L}),_?e("button",{type:"button",onClick:_,className:"cursor-pointer text-error/60 hover:text-error","aria-label":"Dismiss error",children:"×"}):null]}):null,e("div",{className:"flex items-center justify-between gap-2",children:[!r&&t&&!g?k?e("div",{className:"flex items-center gap-1.5",children:[e("button",{type:"button",onClick:P,className:"px-2 py-1.5 rounded-lg bg-error/15 border border-error/40 text-error text-[11px] font-semibold hover:bg-error/25 transition-colors cursor-pointer",children:"Delete permanently"}),e("button",{type:"button",onClick:E,className:"px-2 py-1.5 rounded-lg border border-ink/20 text-[11px] font-medium text-ink/70 hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"})]}):e("button",{type:"button",onClick:M,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg border border-ink/20 hover:border-error hover:text-error text-ink/70 text-[11px] font-medium transition-colors cursor-pointer",children:[e(U,{size:12}),e("span",{children:"Delete"})]}):q&&S?K?e("div",{className:"flex items-center gap-1.5",children:[e("button",{type:"button",onClick:()=>{V(!1),S(q)},className:"px-2 py-1.5 rounded-lg bg-error/15 border border-error/40 text-error text-[11px] font-semibold hover:bg-error/25 transition-colors cursor-pointer",children:"Uninstall package"}),e("button",{type:"button",onClick:()=>V(!1),className:"px-2 py-1.5 rounded-lg border border-ink/20 text-[11px] font-medium text-ink/70 hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"})]}):e("button",{type:"button",onClick:()=>V(!0),disabled:T,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg border border-ink/20 hover:border-error hover:text-error text-ink/70 text-[11px] font-medium transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:[e(U,{size:12}),e("span",{children:"Uninstall"})]}):e("div",{}),!g?e("button",{type:"button",onClick:R,disabled:T||Boolean(p)||!b&&!r,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-ink text-paper text-[11px] font-medium hover:bg-ink/90 disabled:opacity-40 transition-colors cursor-pointer disabled:cursor-not-allowed",children:[T?e(m,{size:12,className:"animate-spin"}):e(yt,{size:12}),e("span",{children:T?"Saving…":r?"Create skill":"Save changes"})]}):null]}),O?e("p",{className:"flex items-center gap-1 text-[10px] text-ink/60",children:[e(f,{size:10}),"Saved"]}):!g&&!b&&!r?e("p",{className:"flex items-center gap-1 text-[10px] text-ink/40",children:[e(f,{size:10}),"Nothing to write"]}):null]})}var pu=10,uu=24;function tl({value:t,onChange:r,readOnly:l,showLineNumbers:c,onToggleLineNumbers:b}){let p=t.split(`
|
|
33
|
-
`).length,g=Math.max(pu,Math.min(p+1,uu)),h=t.length;return e("div",{className:"space-y-1.5",children:[e("div",{className:"flex items-center justify-between",children:[e("div",{className:"flex items-baseline gap-2",children:[e("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-ink",children:"Instructions"}),e("span",{className:"text-[10px] text-ink/45 font-mono",children:[p," line",p===1?"":"s"," · ",h," chars"]})]}),e("button",{type:"button",onClick:b,title:c?"Hide line numbers":"Show line numbers","aria-label":c?"Hide line numbers":"Show line numbers",className:"p-1 rounded-md text-ink/50 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:c?e(Ge,{size:14}):e(wt,{size:14})})]}),e("div",{className:"rounded-lg border border-ink/20 hover:border-ink/40 bg-ink/[0.02] overflow-hidden flex font-mono text-[11px] leading-5 focus-within:border-ink transition-colors",children:[c?e("div",{"aria-hidden":"true",className:"w-9 flex-shrink-0 py-2 pr-1.5 select-none text-right font-mono text-[11px] leading-5 text-ink/30 border-r border-ink/10 overflow-hidden",children:Array.from({length:g},(v,k)=>e("div",{children:k+1},k))}):null,e("textarea",{value:t,onInput:(v)=>r(v.currentTarget.value),readOnly:l,spellcheck:!1,rows:g,style:{height:`${g*1.25}rem`},className:"flex-1 px-2.5 py-2 bg-transparent text-ink font-mono text-[11px] leading-5 resize-none focus:outline-none overflow-auto disabled:opacity-60 read-only:opacity-70",placeholder:`---
|
|
34
|
-
description: "What this skill does"
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
Instructions…`})]}),e("p",{className:"text-[10px] text-ink/40 leading-relaxed",children:["The body of ",e("span",{className:"font-mono",children:"SKILL.md"}),". The pane writes the frontmatter",l?"":" (name, description, hidden) — do not repeat those keys here","."]})]})}function co(t){let r=/^---\r?\n[\s\S]*?\r?\n---\r?\n?/.exec(t);return(r?t.slice(r[0].length):t).replace(/^\r?\n/,"")}function nl({skill:t,isCreatingNew:r,onSave:l,onDelete:c,onUninstallRegistry:b,onOpenCatalog:p,onReload:g,isReloading:h=!1,projectScopeDisabled:v=!1,defaultLocation:k="user"}){let[x,A]=n(""),[N,M]=n(""),[P,E]=n("user"),[S,R]=n(""),[T,O]=n(!1),[L,_]=n(!0),[K,V]=n(!1),[z,q]=n(0),G=Qe(),j=!r&&t!=null&&t.managed!==!0,H=P==="project"?"Project / .omp/skills":"User / omp agent";i(()=>{if(V(!1),r||!t){A(""),M(""),E(k),R(""),O(!1);return}A(t.name),M(t.description),E(t.location),R(co(t.instructions)),O(t.hidden===!0)},[t,r,k]);let X=u(()=>{if(r)return x.trim().length>0||N.trim().length>0||S.trim().length>0;if(!t)return!1;return x!==t.name||N!==t.description||P!==t.location||T!==(t.hidden===!0)||S!==co(t.instructions)},[r,t,x,N,P,T,S]),oe=u(()=>{if(j)return null;let re=x.trim();if(!re)return"A skill needs a name — it becomes the directory name and the /skill:<name> command.";if(/[\\/]/.test(re))return"A skill name cannot contain a path separator.";if(!N.trim())return"A description is required: omp does not load a SKILL.md without one, so this skill would never run.";return null},[x,N,j]),te=()=>{if(j||oe||G.saving)return;G.run(async()=>{let re=await l({name:x.trim(),description:N.trim(),location:P,locationLabel:H,instructions:co(S),hidden:T});if(re.ok)q(Date.now());return re})},Z=()=>{if(!t||!c)return;G.run(async()=>{let re=await c(t.id);if(!re.ok)V(!1);return re})};return e("div",{className:"flex-1 flex flex-col h-full scrollbar-overlay-container bg-paper text-ink p-5 md:p-6 space-y-4",children:[e(el,{skill:t,isCreatingNew:r,name:x,locationLabel:H,dirty:X,validationError:oe,readOnly:j,hidden:T,isReloading:h,confirmingDelete:K,...g?{onReload:g}:{},...p?{onOpenCatalog:p}:{},...b?{onUninstallRegistry:(re)=>{if(!b)return;G.run(()=>b(re))}}:{},onHiddenChange:O,onRequestDelete:()=>V(!0),onCancelDelete:()=>V(!1),onConfirmDelete:()=>{V(!1),Z()},onSave:te,saving:G.saving,saved:G.saved,writeError:G.error,onDismissWriteError:G.dismissError}),!j?e("div",{className:"space-y-3",children:[e("div",{children:[e("div",{className:"flex items-center gap-1.5 mb-1",children:[e("label",{htmlFor:"skill-name",className:"text-[11px] font-semibold text-ink/80",children:"Name"}),e("span",{className:"group relative",children:[e(pe,{size:11,className:"text-ink/35 cursor-help"}),e("span",{className:"absolute left-0 top-4 hidden group-hover:block w-60 p-2 rounded-lg bg-ink text-paper text-[10px] shadow-lg z-20 pointer-events-none leading-relaxed",children:["Unique identifier and execution scope. A project skill is written under"," ",e("span",{className:"font-mono",children:"<workspace>/.omp/skills"}),"."]})]})]}),e("input",{id:"skill-name",type:"text",value:x,onInput:(re)=>A(re.currentTarget.value),placeholder:"skill-name",className:"w-full px-2.5 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-xs font-mono text-ink transition-colors"})]}),e("div",{children:[e("label",{htmlFor:"skill-description",className:"block text-[11px] font-semibold text-ink/80 mb-1",children:["Description ",e("span",{className:"text-error",children:"*"})]}),e("textarea",{id:"skill-description",rows:2,value:N,onInput:(re)=>M(re.currentTarget.value),placeholder:"When should the agent use this skill?",className:"w-full px-2.5 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-xs text-ink transition-colors resize-none leading-relaxed"})]}),e("div",{className:"flex items-center gap-2",children:[e("span",{className:"text-[11px] font-semibold text-ink/80",children:"Scope"}),["user","project"].map((re)=>{let ue=re==="project"&&v;return e("button",{type:"button",disabled:ue,title:ue?"Select a workspace folder to write a project skill":void 0,onClick:()=>E(re),className:`px-2 py-0.5 rounded-md text-[10px] font-medium transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed ${P===re?"bg-ink text-paper":"border border-ink/20 text-ink/70 hover:bg-ink/5"}`,children:re==="user"?"User":"Project"},re)}),e("span",{className:"text-[10px] text-ink/45 font-mono truncate",children:H})]})]}):null,e(tl,{value:S,onChange:R,readOnly:j,showLineNumbers:L,onToggleLineNumbers:()=>_(!L)}),z>0&&!X&&!G.error?e("p",{className:"text-[10px] text-ink/40",children:["Last saved ",new Date(z).toLocaleTimeString()," — omp sessions were told to reload their skills."]}):null]})}function ol({onNavigateToCatalog:t}){let r=ke(),l=Ze(),[c,b]=n(qe),[p,g]=n(!1),h=l.queryFor(c),v=l.isWorkspace(c),{items:k,selectedId:x,selected:A,isCreatingNew:N,isLoading:M,loadError:P,reload:E,select:S,startCreate:R,save:T,remove:O}=bt({endpoint:"/api/settings/skills",query:h,listKey:"skills",bodyKey:"skill",messages:{load:"Failed to load skills from API:",save:"Failed to save skill via API:",delete:"Failed to delete skill via API:"},cacheKey:"command",fallbackToFirst:!1,buildBody:(K)=>({skill:K,...l.scopeBodyFor(c)}),buildDeleteQuery:(K)=>`?id=${encodeURIComponent(K)}&${h.slice(1)}`,buildNew:(K)=>({id:`skill-${Date.now()}`,name:K.name||"new-skill",description:K.description||"",location:K.location||(v?"project":"user"),locationLabel:K.locationLabel||(v?"Project / .omp/skills":"User / omp agent"),instructions:K.instructions||"",hidden:K.hidden===!0,project:"omp"}),buildUpdate:(K,V,z)=>({...V||{id:z||`skill-${Date.now()}`},...K})}),L=()=>{g(!0),fetch("/api/settings/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"reload",...l.scopeBodyFor(c)})}).catch((K)=>console.error("Failed to reload skills:",K)).finally(()=>g(!1))},_=async(K)=>{try{let V=await fetch("/api/settings/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"uninstall_registry_skill",package:K,...l.scopeBodyFor(c)})}),z=await V.json().catch(()=>({}));if(!V.ok||z.error)return{ok:!1,error:z.error||`Request failed (${V.status})`};return await E(),{ok:!0}}catch(V){return{ok:!1,error:V instanceof Error?V.message:String(V)}}};if(M)return e(Ce,{children:"Loading skills…"});return e("div",{className:"flex-1 flex flex-col h-full w-full overflow-hidden bg-paper",children:e(ye,{pane:r.pane,onBack:r.back,listLabel:"Skills",list:e(Zs,{skills:k,selectedSkillId:x,isCreatingNew:N,onSelectSkill:(K)=>{S(K),r.openDetail()},onAddNewSkill:()=>{R(),r.openDetail()},onImportFromGit:()=>t?.("git"),onOpenCatalog:()=>t?.("browse"),selectedProject:c,onSelectProject:b,projectOptions:l.options,...P?{loadError:P,onRetry:E}:{}}),detail:e(nl,{skill:A??null,isCreatingNew:N,onSave:T,onDelete:O,onUninstallRegistry:_,onOpenCatalog:()=>t?.("browse"),onReload:L,isReloading:p,projectScopeDisabled:!v,defaultLocation:v?"project":"user"})})})}function kt(t){return`${t.id}::${t.scope}`}function rl({plugins:t,marketplaces:r,catalogCount:l,view:c,onSelectView:b,selectedPluginKey:p,onSelectPlugin:g,selectedProject:h,onSelectProject:v,projectOptions:k,isWorkspaceScope:x,busy:A,error:N,onClearError:M,onInstall:P,onRefresh:E}){let[S,R]=n(""),[T,O]=n(!1),L=t.filter((_)=>_.enabled).length;return e("div",{className:"w-full md:w-72 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0",children:[e(Xe,{variant:"compact",selectedProject:h,onChangeProject:v,...k?{options:k}:{},getTriggerLabel:(_,K)=>_.find((V)=>V.id===K||V.value===K)?.label||K}),e("div",{className:"px-3 pt-2.5",children:e("div",{className:"flex items-center gap-1 p-0.5 rounded-lg bg-ink/5 border border-ink/10",children:[{id:"installed",label:"Installed",count:t.length},{id:"marketplaces",label:"Marketplaces",count:r.length}].map((_)=>e("button",{type:"button",onClick:()=>b(_.id),"aria-pressed":c===_.id,className:`flex-1 flex items-center justify-center gap-1 px-2 py-1 rounded-md text-[11px] font-medium transition-colors cursor-pointer ${c===_.id?"bg-paper text-ink shadow-2xs":"text-ink/60 hover:text-ink"}`,children:[e("span",{className:"truncate",children:_.label}),e("span",{className:"font-mono text-[10px] text-ink/50",children:_.count})]},_.id))})}),e("div",{className:"px-3.5 py-2.5 flex items-center justify-between",children:[e("span",{className:"text-xs font-semibold text-ink",children:c==="installed"?`${L}/${t.length} enabled`:`${l} available`}),e("button",{type:"button",disabled:T,"aria-busy":T,onClick:async()=>{O(!0);try{await E()}finally{O(!1)}},title:"Re-read omp's plugin registries",className:"p-1 rounded-md text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:e(C,{size:14,className:A||T?"animate-spin":void 0})})]}),c==="installed"&&e("form",{className:"px-3 pb-2.5",onSubmit:(_)=>{_.preventDefault();let K=S.trim();if(!K)return;P(K),R("")},children:[e("div",{className:"flex items-center gap-1.5",children:[e("input",{type:"text",value:S,onInput:(_)=>R(_.currentTarget.value),placeholder:"name@marketplace, npm, git, or ./path",spellcheck:!1,className:"flex-1 min-w-0 px-2.5 py-1.5 rounded-lg border border-ink/15 bg-paper focus:outline-none focus:border-ink/40 text-[11px] font-mono text-ink placeholder-ink/40 transition-colors"}),e("button",{type:"submit",disabled:!S.trim()||A!==null,title:x?"Install into this workspace":"Install for all projects",className:"p-1.5 rounded-lg border border-ink/20 text-ink/70 hover:text-ink hover:border-ink/40 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:e(Je,{size:14})})]}),e("p",{className:"mt-1 text-[10px] text-ink/45 leading-snug",children:x?"Installs into this workspace (.omp/plugins)":"Installs for all projects (~/.omp/plugins)"})]}),A&&e("div",{className:"mx-3 mb-2 px-2.5 py-1.5 rounded-lg border border-ink/15 bg-ink/5 text-[11px] text-ink/70 truncate",children:[A,"…"]}),N&&e("div",{className:"mx-3 mb-2 flex items-start gap-1.5 px-2.5 py-1.5 rounded-lg border border-error/30 bg-error/5 text-[11px] text-error leading-snug",children:[e(B,{size:13,className:"mt-0.5 flex-shrink-0"}),e("span",{className:"flex-1 break-words",children:N}),e("button",{type:"button",onClick:M,"aria-label":"Dismiss",className:"cursor-pointer",children:e(y,{size:12})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-1.5 space-y-0.5",children:c==="marketplaces"?e(mu,{marketplaces:r}):t.length===0?e("p",{className:"px-2.5 py-6 text-[11px] text-ink/50 leading-relaxed text-center",children:"No plugins installed in this scope. Install one above, or browse a marketplace."}):t.map((_)=>e(gu,{plugin:_,isSelected:kt(_)===p,onSelect:()=>g(kt(_))},kt(_)))})]})}function mu({marketplaces:t}){if(t.length===0)return e("p",{className:"px-2.5 py-6 text-[11px] text-ink/50 leading-relaxed text-center",children:"No marketplaces configured. Add one from the marketplace pane."});return e(d,{children:t.map((r)=>e("div",{className:"px-2.5 py-2 rounded-lg text-xs",children:[e("div",{className:"flex items-center gap-1.5 min-w-0",children:[e(rt,{size:13,className:"text-ink/50 flex-shrink-0"}),e("span",{className:"truncate font-medium text-ink",children:r.name})]}),e("p",{className:"mt-0.5 pl-5 text-[10px] font-mono text-ink/50 truncate",children:r.sourceUri}),e("p",{className:"pl-5 text-[10px] text-ink/45",children:r.error?e("span",{className:"text-error",children:r.error}):`${r.pluginCount??0} plugins`})]},r.name))})}function gu({plugin:t,isSelected:r,onSelect:l}){return e("button",{type:"button",onClick:l,className:`w-full text-left px-2.5 py-2 rounded-lg transition-colors cursor-pointer ${r?"bg-ink/10 text-ink shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e("div",{className:"flex items-center justify-between gap-1.5",children:[e("div",{className:"flex items-center gap-1.5 min-w-0",children:[t.kind==="marketplace"?e(rt,{size:13,className:"text-ink/50 flex-shrink-0"}):e(Ro,{size:13,className:"text-ink/50 flex-shrink-0"}),e("span",{className:"truncate text-xs font-medium",children:t.name}),t.enabled&&e(f,{size:11,className:"text-success flex-shrink-0"})]}),e("span",{className:"text-[10px] font-mono text-ink/45 flex-shrink-0",children:t.version||"–"})]}),e("div",{className:"flex items-center gap-1.5 mt-0.5 pl-[19px]",children:[e("span",{className:"text-[10px] font-mono uppercase text-ink/50",children:t.scope}),t.shadowedBy&&e("span",{className:"text-[10px] text-ink/45",children:"shadowed"}),t.updateAvailable&&e("span",{className:"text-[10px] px-1 rounded border border-warning/30 bg-warning/15 text-warning",children:t.updateAvailable}),!t.enabled&&e("span",{className:"text-[10px] text-ink/45",children:"disabled"})]})]})}function dl({plugin:t,disabled:r,onSave:l,onDelete:c}){return e("section",{className:"space-y-2 pt-2 border-t border-ink/10",children:[e("div",{children:[e("h3",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:"Settings"}),e("p",{className:"text-[11px] text-ink/50 mt-0.5",children:"Stored in omp-plugins.lock.json and read by the plugin at load time."})]}),e("div",{className:"rounded-lg border border-ink/10 divide-y divide-ink/5",children:t.settings.map((b)=>e(bu,{spec:b,plugin:t,disabled:r,onSave:l,onDelete:c},b.key))})]})}function bu({spec:t,plugin:r,disabled:l,onSave:c,onDelete:b}){let p=r.settingValues?.[t.key],g=r.secretSet?.includes(t.key)===!0,h=fu(t,p,g),[v,k]=n(h),[x,A]=n(!0);i(()=>k(h),[h]);let N=p!==void 0||g,M=v!==h;return e("div",{className:"px-3 py-2",children:[e("div",{className:"flex items-start gap-2",children:[e("button",{type:"button",onClick:()=>A((P)=>!P),"aria-expanded":x,"aria-label":x?`Collapse ${t.key}`:`Expand ${t.key}`,className:"mt-0.5 p-0.5 rounded text-ink/40 hover:text-ink cursor-pointer",children:x?e(I,{size:13}):e(se,{size:13})}),e("div",{className:"flex-1 min-w-0",children:[e("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-medium text-ink font-mono truncate",children:t.key}),e("span",{className:"text-[10px] font-mono text-ink/40",children:t.type}),t.secret&&e(ui,{size:11,className:"text-ink/40"}),N&&e(f,{size:11,className:"text-success"})]}),t.description&&e("p",{className:"text-[11px] text-ink/60 leading-snug mt-0.5",children:t.description})]})]}),x&&e("div",{className:"mt-2 pl-6 space-y-1.5",children:[e(hu,{spec:t,value:v,isSecretSet:g,disabled:l,onChange:k}),e("div",{className:"flex items-center gap-2 flex-wrap",children:[e("button",{type:"button",disabled:l||!M,onClick:()=>c(r,t.key,v),className:"px-2.5 py-1 rounded-md bg-ink text-paper text-[11px] font-medium hover:bg-ink/90 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:"Save"}),N&&e("button",{type:"button",disabled:l,onClick:()=>b(r,t.key),title:"Remove the stored value; omp falls back to its default",className:"px-2.5 py-1 rounded-md border border-ink/20 text-[11px] text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-40",children:"Clear"}),t.env&&e("span",{className:"text-[10px] font-mono text-ink/40",children:["env: ",t.env]}),t.min!==void 0&&t.max!==void 0&&e("span",{className:"text-[10px] text-ink/40",children:[t.min,"–",t.max]})]}),g&&e("p",{className:"text-[10px] text-ink/45 leading-snug",children:"A value is stored. omp holds it on disk and never returns it, so it can be replaced or cleared but not shown."})]})]})}function fu(t,r,l){if(t.secret&&l)return"";if(r!==void 0&&r!==null)return String(r);return t.default===void 0?"":String(t.default)}function hu({spec:t,value:r,isSecretSet:l,disabled:c,onChange:b}){if(t.type==="boolean")return e("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[e("input",{type:"checkbox",checked:r==="true",disabled:c,onChange:(g)=>b(g.currentTarget.checked?"true":"false"),className:`${ge} accent-ink cursor-pointer`}),e("span",{className:"text-[11px] text-ink/70",children:r==="true"?"true":"false"})]});if(t.type==="enum"&&t.values?.length)return e("select",{value:r,disabled:c,onChange:(g)=>b(g.currentTarget.value),className:"w-full px-2.5 py-1.5 rounded-lg border border-ink/15 bg-paper focus:outline-none focus:border-ink/40 text-[11px] text-ink transition-colors disabled:opacity-60 cursor-pointer",children:[!t.values.includes(r)&&e("option",{value:r,children:r||"(unset)"}),t.values.map((g)=>e("option",{value:g,children:g},g))]});return e("input",{type:t.type==="number"?"number":t.secret?"password":"text",value:r,disabled:c,spellcheck:!1,placeholder:t.secret&&l?"stored — type a new value to replace":void 0,onInput:(g)=>b(g.currentTarget.value),className:"w-full px-2.5 py-1.5 rounded-lg border border-ink/15 bg-paper focus:outline-none focus:border-ink/40 text-[11px] text-ink transition-colors disabled:opacity-60 font-mono"})}function cl({plugin:t,busy:r,onToggleEnabled:l,onUpgrade:c,onUninstall:b,onSaveFeatures:p,onSaveSetting:g,onDeleteSetting:h}){let[v,k]=n(!1);if(i(()=>k(!1),[t?.id,t?.scope]),!t)return e("div",{className:"flex-1 flex flex-col h-full items-center justify-center px-8 text-center bg-paper",children:e("p",{className:"text-xs text-ink/50 leading-relaxed max-w-sm",children:["Select a plugin to see its manifest, features and settings. Plugins are installed through"," ",e("span",{className:"font-mono text-ink/70",children:"omp plugin"}),", so omp loads exactly what this panel lists."]})});let x=r!==null,A=t.scope==="project"?"this workspace":"all projects";return e("div",{className:"flex-1 flex flex-col h-full scrollbar-overlay-container bg-paper text-ink p-6 md:p-8 space-y-6",children:[e("div",{className:"flex items-start justify-between gap-4 pb-4 border-b border-ink/10",children:[e("div",{className:"min-w-0",children:[e("h2",{className:"text-sm font-bold tracking-tight text-ink truncate",children:t.name}),e("p",{className:"text-xs text-ink/60 mt-0.5 truncate",children:[t.version||"no version"," · ",t.scope==="project"?"project scope":"user scope",t.marketplace?` · ${t.marketplace}`:""]}),t.description&&e("p",{className:"text-xs text-ink/70 mt-2 leading-relaxed",children:t.description}),t.homepage&&e("a",{href:t.homepage,target:"_blank",rel:"noreferrer noopener",className:"mt-1 inline-flex items-center gap-1 text-[11px] text-ink/60 hover:text-ink underline decoration-ink/30",children:[e(Be,{size:11})," ",t.homepage]})]}),e("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e("button",{type:"button",disabled:x,"aria-pressed":t.enabled,onClick:()=>l(t,!t.enabled),className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer disabled:opacity-50 ${t.enabled?"border-ink/20 text-ink/70 hover:bg-ink/5":"border-ink bg-ink text-paper hover:bg-ink/90"}`,children:t.enabled?"Disable":"Enable"}),t.updateAvailable&&e("button",{type:"button",disabled:x,onClick:()=>c(t),className:"px-3 py-1.5 rounded-lg border border-amber-500/40 text-xs font-medium text-ink hover:bg-amber-500/10 transition-colors cursor-pointer disabled:opacity-50",children:["Upgrade to ",t.updateAvailable]})]})]}),t.shadowedBy==="project"&&e("div",{className:"rounded-lg border border-ink/15 bg-ink/5 px-3 py-2 text-[11px] text-ink/70 leading-relaxed",children:"A project install of this plugin in this workspace takes precedence, so this user copy is not the one loading right now. Disabling or removing it leaves the project copy in place."}),t.installPath&&e("section",{className:"space-y-1",children:[e("h3",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:"Install location"}),e("p",{className:"text-[11px] font-mono text-ink/70 break-all",children:t.installPath})]}),t.features.length>0?e(vu,{features:t.features,selected:t.enabledFeatures,disabled:x,note:t.featuresNote,onSave:(N)=>p(t,N)}):e("section",{className:"space-y-1",children:[e("h3",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:"Features"}),e("p",{className:"text-[11px] text-ink/50 leading-relaxed",children:"This plugin declares no optional features. It loads its whole content (skills, commands, hooks, MCP servers) whenever it is enabled."})]}),t.settings.length>0&&e(dl,{plugin:t,disabled:x,onSave:g,onDelete:h}),e("div",{className:"pt-4 border-t border-ink/10 flex items-center justify-between gap-3",children:[e("p",{className:"text-[11px] text-ink/50 leading-snug max-w-sm",children:["Uninstalling removes the plugin and its stored settings from ",A,"."]}),v?e("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e("button",{type:"button",disabled:x,onClick:()=>b(t),className:"px-3.5 py-2 rounded-lg border border-error text-error text-xs font-medium hover:bg-error/5 transition-colors cursor-pointer disabled:opacity-50",children:"Confirm remove"}),e("button",{type:"button",onClick:()=>k(!1),className:"px-3 py-2 rounded-lg text-xs text-ink/60 hover:text-ink cursor-pointer",children:"Cancel"})]}):e("button",{type:"button",onClick:()=>k(!0),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-lg border border-ink/20 hover:border-error hover:text-error text-ink/70 text-xs font-medium transition-colors cursor-pointer flex-shrink-0",children:[e(U,{size:14}),e("span",{children:"Uninstall"})]})]})]})}function vu({features:t,selected:r,disabled:l,note:c,onSave:b}){let p=r??t.filter((k)=>k.isDefault).map((k)=>k.name),[g,h]=n(p);i(()=>h(p),[r,t]);let v=g.length!==p.length||g.some((k)=>!p.includes(k));return e("section",{className:"space-y-2 pt-2 border-t border-ink/10",children:[e("div",{className:"flex items-center justify-between gap-3",children:[e("div",{children:[e("h3",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:"Features"}),e("p",{className:"text-[11px] text-ink/50 mt-0.5",children:r===null?"Using omp’s defaults (the features marked default).":"Explicit selection stored in omp-plugins.lock.json."})]}),!c&&e("div",{className:"flex items-center gap-2",children:[r!==null&&e("button",{type:"button",disabled:l,onClick:()=>b([]),title:"Clear the explicit selection so omp uses its defaults",className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-ink/20 text-[11px] text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:[e(ct,{size:12})," Defaults"]}),e("button",{type:"button",disabled:l||!v,onClick:()=>b(g),className:"px-3 py-1.5 rounded-lg bg-ink text-paper text-[11px] font-medium hover:bg-ink/90 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:"Save features"})]})]}),c&&e("div",{className:"rounded-lg border border-ink/15 bg-ink/5 px-3 py-2 text-[11px] text-ink/70 leading-relaxed",children:c}),e("div",{className:"rounded-lg border border-ink/10 divide-y divide-ink/5",children:t.map((k)=>e("label",{className:`flex items-start gap-2 px-3 py-2 select-none ${c?"":"cursor-pointer"}`,children:[e("input",{type:"checkbox",checked:g.includes(k.name),disabled:l||Boolean(c),onChange:(x)=>h((A)=>x.currentTarget.checked?[...A,k.name]:A.filter((N)=>N!==k.name)),className:`${ge} mt-0.5 accent-ink cursor-pointer disabled:opacity-60`}),e("span",{className:"min-w-0",children:[e("span",{className:"text-xs font-medium text-ink font-mono",children:k.name}),k.isDefault&&e("span",{className:"ml-1.5 text-[10px] text-ink/45",children:"default"}),k.description&&e("span",{className:"block text-[11px] text-ink/60 leading-snug",children:k.description})]})]},k.name))})]})}function pl({marketplaces:t,catalog:r,plugins:l,busy:c,error:b,onClearError:p,workspace:g,run:h}){let[v,k]=n(""),[x,A]=n(""),[N,M]=n(""),[P,E]=n(null),S=c!==null,R=u(()=>new Set(l.map((O)=>O.id)),[l]),T=u(()=>{let O=x.trim().toLowerCase();return r.filter((L)=>{if(N&&L.marketplace!==N)return!1;if(!O)return!0;return L.name.toLowerCase().includes(O)||L.description.toLowerCase().includes(O)||(L.category??"").toLowerCase().includes(O)})},[r,N,x]);return e("div",{className:"flex-1 flex flex-col h-full scrollbar-overlay-container bg-paper text-ink p-6 md:p-8 space-y-6",children:[e("div",{className:"pb-4 border-b border-ink/10",children:[e("h2",{className:"text-sm font-bold tracking-tight text-ink",children:"Marketplaces"}),e("p",{className:"text-xs text-ink/60 mt-0.5 leading-relaxed",children:["A marketplace is a git repository (or local directory) publishing a catalog at"," ",e("span",{className:"font-mono text-ink/70",children:".omp-plugin/marketplace.json"}),". Adding one clones it and lets its plugins install by ",e("span",{className:"font-mono text-ink/70",children:"name@marketplace"}),"."]})]}),b&&e("div",{className:"flex items-start gap-1.5 px-3 py-2 rounded-lg border border-error/30 bg-error/5 text-[11px] text-error leading-snug",children:[e(B,{size:13,className:"mt-0.5 flex-shrink-0"}),e("span",{className:"flex-1 break-words",children:b}),e("button",{type:"button",onClick:p,"aria-label":"Dismiss",className:"cursor-pointer",children:e(y,{size:12})})]}),e("form",{className:"flex items-center gap-2",onSubmit:(O)=>{O.preventDefault();let L=v.trim();if(!L)return;h(`Adding ${L}`,{type:"add_marketplace",source:L}),k("")},children:[e("input",{type:"text",value:v,onInput:(O)=>k(O.currentTarget.value),placeholder:"owner/repo, https://…, git@…, or ./path",spellcheck:!1,className:"flex-1 min-w-0 px-3 py-2 rounded-lg border border-ink/15 bg-paper focus:outline-none focus:border-ink/40 text-xs font-mono text-ink placeholder-ink/40 transition-colors"}),e("button",{type:"submit",disabled:!v.trim()||S,className:"flex items-center gap-1.5 px-3.5 py-2 rounded-lg bg-ink text-paper text-xs font-medium hover:bg-ink/90 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:[e(Y,{size:14})," Add"]})]}),e("section",{className:"space-y-2",children:[e("h3",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:"Configured"}),t.length===0?e("p",{className:"text-[11px] text-ink/50 leading-relaxed",children:["No marketplaces configured. Add one above — for example"," ",e("span",{className:"font-mono text-ink/70",children:"anthropics/claude-plugins-official"}),", which omp itself documents as the starting catalog."]}):e("div",{className:"rounded-lg border border-ink/10 divide-y divide-ink/5",children:t.map((O)=>{let L=c===`Updating ${O.name}`;return e("div",{className:"flex items-center gap-3 px-3 py-2.5",children:[e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-medium text-ink truncate",children:O.name}),e("span",{className:"text-[10px] font-mono uppercase text-ink/45",children:O.sourceType})]}),e("p",{className:"text-[11px] font-mono text-ink/50 truncate",children:O.sourceUri}),e("p",{className:"text-[10px] text-ink/45",children:O.error?e("span",{className:"text-error",children:O.error}):`${O.pluginCount??0} plugins · updated ${ku(O.updatedAt)}`})]}),e("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e("button",{type:"button",disabled:S,onClick:()=>void h(`Updating ${O.name}`,{type:"update_marketplace",name:O.name}),title:"Re-fetch this catalog",className:"p-1.5 rounded-lg border border-ink/20 text-ink/60 hover:text-ink hover:border-ink/40 transition-colors cursor-pointer disabled:opacity-40",children:e(C,{size:13,className:L?"animate-spin":void 0,"aria-hidden":"true"})}),P===O.name?e(d,{children:[e("button",{type:"button",disabled:S,onClick:()=>{h(`Removing ${O.name}`,{type:"remove_marketplace",name:O.name}),E(null)},className:"px-2 py-1 rounded-lg border border-error text-error text-[11px] font-medium hover:bg-error/5 transition-colors cursor-pointer disabled:opacity-40",children:"Confirm"}),e("button",{type:"button",onClick:()=>E(null),className:"px-1.5 py-1 rounded-lg text-[11px] text-ink/60 hover:text-ink cursor-pointer",children:"Cancel"})]}):e("button",{type:"button",disabled:S,onClick:()=>E(O.name),title:"Remove this marketplace (installed plugins stay)",className:"p-1.5 rounded-lg border border-ink/20 text-ink/60 hover:border-error hover:text-error transition-colors cursor-pointer disabled:opacity-40",children:e(U,{size:13})})]})]},O.name)})})]}),r.length>0&&e("section",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e("h3",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:["Available plugins",e("span",{className:"ml-1.5 font-mono text-[10px] text-ink/45",children:[T.length,"/",r.length]})]}),e("div",{className:"flex items-center gap-2",children:[e("select",{value:N,onChange:(O)=>M(O.currentTarget.value),className:"px-2 py-1 rounded-lg border border-ink/15 bg-paper text-[11px] text-ink cursor-pointer focus:outline-none focus:border-ink/40",children:[e("option",{value:"",children:"All marketplaces"}),t.map((O)=>e("option",{value:O.name,children:O.name},O.name))]}),e("div",{className:"relative flex items-center",children:[e(F,{size:12,className:"absolute left-2 text-ink/40 pointer-events-none"}),e("input",{type:"text",value:x,onInput:(O)=>A(O.currentTarget.value),placeholder:"Filter",className:"w-40 pl-6 pr-2 py-1 rounded-lg border border-ink/15 bg-paper text-[11px] text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40"})]})]})]}),e("div",{className:"rounded-lg border border-ink/10 divide-y divide-ink/5 max-h-[420px] overflow-y-auto scrollbar-overlay-container",children:T.length===0?e("p",{className:"px-3 py-6 text-[11px] text-ink/50 text-center",children:"No plugin matches this filter."}):T.map((O)=>e(xu,{item:O,installed:R.has(`${O.name}@${O.marketplace}`),disabled:S,workspace:g,run:h},`${O.marketplace}::${O.name}`))})]})]})}function xu({item:t,installed:r,disabled:l,workspace:c,run:b}){let p=`${t.name}@${t.marketplace}`;return e("div",{className:"flex items-start gap-3 px-3 py-2.5",children:[e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-medium text-ink font-mono truncate",children:t.name}),t.category&&e("span",{className:"text-[10px] px-1 rounded bg-ink/5 text-ink/50 border border-ink/10",children:t.category}),t.version&&e("span",{className:"text-[10px] font-mono text-ink/45",children:t.version})]}),e("p",{className:"text-[11px] text-ink/60 leading-snug mt-0.5 line-clamp-2",children:t.description}),e("p",{className:"text-[10px] font-mono text-ink/40",children:t.marketplace})]}),r?e("span",{className:"text-[10px] text-ink/45 flex-shrink-0 mt-0.5",children:"installed"}):e("button",{type:"button",disabled:l,onClick:()=>void b(`Installing ${p}`,{type:"install",spec:p,...c?{root:c}:{scope:"user"}}),className:"flex items-center gap-1 px-2.5 py-1 rounded-lg border border-ink/20 text-[11px] text-ink/70 hover:text-ink hover:border-ink/40 transition-colors cursor-pointer flex-shrink-0 disabled:opacity-40",children:[e(he,{size:12})," Install"]})]})}function ku(t){if(!t)return"unknown";let r=new Date(t);if(Number.isNaN(r.getTime()))return"unknown";return r.toLocaleDateString()}function ul(t){let[r,l]=n({plugins:[],marketplaces:[],catalog:[]}),[c,b]=n(!0),[p,g]=n(null),[h,v]=n(null),k=a(async()=>{try{let M=await(await fetch(`/api/settings/plugins${t}`)).json();if(l({plugins:Array.isArray(M?.plugins)?M.plugins:[],marketplaces:Array.isArray(M?.marketplaces)?M.marketplaces:[],catalog:Array.isArray(M?.catalog)?M.catalog:[]}),M?.error)v(String(M.error))}catch(N){v(N instanceof Error?N.message:String(N))}finally{b(!1)}},[t]);i(()=>{b(!0),k().catch(console.error)},[k]);let x=a(async(N,M)=>{g(N),v(null);try{let P=await fetch(`/api/settings/plugins${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M)}),E=await P.json();if(!E?.success)return v(typeof E?.error==="string"?E.error:`Request failed (${P.status})`),!1;if(Array.isArray(E.plugins))l({plugins:E.plugins,marketplaces:Array.isArray(E.marketplaces)?E.marketplaces:[],catalog:Array.isArray(E.catalog)?E.catalog:[]});return!0}catch(P){return v(P instanceof Error?P.message:String(P)),!1}finally{g(null)}},[t]),A=a(()=>v(null),[]);return{...r,isLoading:c,busy:p,error:h,refresh:k,run:x,clearError:A}}function ml(t,r){if(t.kind!=="marketplace")return{};if(t.scope==="project"&&r)return{scope:"project",root:r};return{scope:"user"}}function gl(){let t=ke(),r=Ze(),[l,c]=n(qe),[b,p]=n("installed"),[g,h]=n(null),v=r.rootFor(l),k=ul(r.queryFor(l)),x=k.plugins.find((N)=>kt(N)===g)??null;if(k.isLoading)return e(Ce,{children:"Loading plugins…"});let A=(N)=>ml(N,v);return e("div",{className:"flex-1 flex flex-col h-full w-full overflow-hidden bg-paper",children:e(ye,{pane:t.pane,onBack:t.back,listLabel:"Plugins",list:e(rl,{plugins:k.plugins,marketplaces:k.marketplaces,catalogCount:k.catalog.length,view:b,onSelectView:(N)=>{p(N),t.openDetail()},selectedPluginKey:g,onSelectPlugin:(N)=>{h(N),t.openDetail()},selectedProject:l,onSelectProject:(N)=>{c(N),h(null)},projectOptions:r.options,isWorkspaceScope:v!==null,busy:k.busy,error:k.error,onClearError:k.clearError,onInstall:(N)=>{k.run(`Installing ${N}`,{type:"install",spec:N,...cn(v)})},onRefresh:()=>k.refresh()}),detail:b==="marketplaces"?e(pl,{marketplaces:k.marketplaces,catalog:k.catalog,plugins:k.plugins,busy:k.busy,error:k.error,onClearError:k.clearError,workspace:v,run:k.run}):e(cl,{plugin:x,busy:k.busy,onToggleEnabled:(N,M)=>{k.run(`${M?"Enabling":"Disabling"} ${N.name}`,{type:"set_enabled",id:N.id,enabled:M,...A(N)})},onUpgrade:(N)=>{k.run(`Upgrading ${N.name}`,{type:"upgrade",id:N.id,...A(N)})},onUninstall:(N)=>{k.run(`Uninstalling ${N.name}`,{type:"uninstall",id:N.id,...A(N)})},onSaveFeatures:(N,M)=>{k.run(`Saving features for ${N.name}`,{type:"set_features",packageName:N.packageName,pluginScope:N.scope,features:M,...cn(v)})},onSaveSetting:(N,M,P)=>{k.run(`Saving ${M}`,{type:"set_setting",packageName:N.packageName,key:M,value:P,...cn(v)})},onDeleteSetting:(N,M)=>{k.run(`Clearing ${M}`,{type:"delete_setting",packageName:N.packageName,key:M,...cn(v)})}})})})}function cn(t){return t?{root:t}:{scope:"user"}}function po(t,r){if(t.origin==="local")return null;if(t.origin==="git"){if(r?.updateAvailable!==!0)return null;let c=t.latestVersion??r.latestVersion;return c?{version:c}:{}}let l=t.latestVersion;if(!l||!tc(l,t.version))return null;return{version:l}}function pn(t,r){return t.filter((l)=>po(l,r[l.pluginId])!==null).length}function bl({busy:t,onInstall:r,onClearError:l}){let[c,b]=n(""),[p,g]=n(null),h=async(k)=>{k.preventDefault();let x=c.trim();if(!x)return;if(!/^(https?:\/\/\S+|ssh:\/\/\S+|git@[^:/\s]+:\S+|file:\/\/\S+)$/i.test(x)&&!/^[/~]\S*$/.test(x)){g("Expected an https, ssh, git@ or local path.");return}if(g(null),l(),await r(x))b("")},v=p;return e("form",{onSubmit:h,className:"border border-ink/15 rounded p-3 space-y-2",children:[e("div",{className:"flex items-center gap-2",children:[e(he,{size:14,className:"text-ink/50 flex-shrink-0"}),e("span",{className:"text-xs font-semibold text-ink",children:"Install from a git URL"})]}),e("p",{className:"text-[11px] text-ink/50",children:["A Bun package whose ",e("span",{className:"font-mono",children:"package.json"})," carries a"," ",e("span",{className:"font-mono",children:"kabmo"})," key, or a plain directory with a"," ",e("span",{className:"font-mono",children:"kabmo.json"}),". It is cloned, built, and registered automatically."]}),e("div",{className:"flex items-center gap-2",children:[e("input",{type:"text",value:c,onChange:(k)=>{b(k.currentTarget.value),g(null)},placeholder:"https://github.com/you/my-panel.git",disabled:t,className:"flex-1 bg-paper border border-ink/15 rounded px-2.5 py-1.5 text-xs font-mono text-ink placeholder-ink/35 focus:outline-none focus:border-ink/40 disabled:opacity-50"}),e("button",{type:"submit",disabled:t||!c.trim(),className:"flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded border border-ink/15 hover:bg-ink/5 disabled:opacity-40 disabled:hover:bg-transparent flex-shrink-0",children:[t?e(m,{size:13,className:"animate-spin"}):e(he,{size:13}),t?"Cloning…":"Install"]})]}),v?e("p",{className:"text-[11px] text-error",children:v}):null]})}function fl({pluginId:t,disabled:r,onRemove:l}){let[c,b]=n(!1);if(!c)return e("button",{type:"button",onClick:()=>b(!0),disabled:r,title:`Remove ${t} from disk`,"aria-label":`Remove ${t}`,className:"p-1 rounded text-ink/40 hover:text-error hover:bg-error/10 disabled:opacity-40 flex-shrink-0",children:e(U,{size:13})});return e("span",{className:"flex items-center gap-1 flex-shrink-0",children:[e("button",{type:"button",onClick:()=>{b(!1),l(t)},className:"px-1.5 py-0.5 text-[10px] rounded bg-error/15 text-error border border-error/30 hover:bg-error/25",children:"Delete files"}),e("button",{type:"button",onClick:()=>b(!1),className:"px-1.5 py-0.5 text-[10px] rounded border border-ink/15 hover:bg-ink/5",children:"Cancel"})]})}function un({pluginId:t,name:r,readmeUrl:l,onClose:c}){let[b,p]=n(null),[g,h]=n(null);return i(()=>{let v=!1;return fetch(l,{credentials:"same-origin"}).then(async(k)=>{if(!k.ok){let x=await k.json().catch(()=>null);throw Error(x?.error??`Could not read the README (${k.status})`)}return k.text()}).then((k)=>{if(!v)p(k)},(k)=>{if(!v)h(k instanceof Error?k.message:String(k))}),()=>{v=!0}},[l]),e(J,{onClose:c,maxWidthClass:"max-w-3xl",header:e("div",{className:"flex items-center gap-2 min-w-0",children:[e(Vt,{size:15,className:"text-ink/50 flex-shrink-0"}),e("span",{className:"text-sm font-medium text-ink truncate",children:r}),e("span",{className:"text-[11px] text-ink/45 font-mono truncate",children:t})]}),children:e("div",{className:"px-5 py-4",children:g?e("div",{className:"flex items-start gap-2 text-error",children:[e(D,{size:14,className:"flex-shrink-0 mt-0.5"}),e("p",{className:"text-xs",children:g})]}):b===null?e("div",{className:"flex items-center gap-2 text-ink/50",children:[e(m,{size:14,className:"animate-spin"}),e("span",{className:"text-xs",children:"Reading README…"})]}):e(ee,{content:b,document:!0,className:"text-xs"})})})}function mn({version:t,latest:r}){let l=Boolean(r&&t&&tc(r,t));if(!t)return e("span",{className:"text-[10px] font-mono text-ink/40",children:"unversioned"});if(!l)return e("span",{className:"text-[10px] font-mono text-ink/50",title:`Installed version ${t}`,children:["v",t]});return e("span",{className:"flex items-center gap-1 text-[10px] font-mono",title:`Installed ${t}, available ${r}`,children:[e("span",{className:"text-ink/45",children:["v",t]}),e("span",{className:"text-ink/30",children:"→"}),e("span",{className:"px-1 rounded bg-warning/15 text-warning border border-warning/25",children:["v",r]})]})}function gn({author:t}){if(!t)return e("span",{className:"text-[10px] text-ink/40",children:"author unknown"});let r=`by ${t.name}`;if(!t.url)return e("span",{className:"text-[10px] text-ink/50 truncate",title:t.email?`${t.name} <${t.email}>`:r,children:r});return e("a",{href:t.url,target:"_blank",rel:"noreferrer noopener",className:"flex items-center gap-0.5 text-[10px] text-ink/50 hover:text-ink truncate",title:t.url,children:[r,e(Be,{size:9,className:"flex-shrink-0"})]})}var yu={bundled:{label:"Bundled",detail:"Installed from Kabmo’s own store, and kept current by Kabmo’s update.",Icon:rt},git:{label:"Git",detail:"A git clone you own. Update it from its remote, or turn on automatic updates above.",Icon:fe},local:{label:"Local",detail:"A directory in the marketplace. Nothing updates it — edit the files and rebuild.",Icon:Jo}};function hl({origin:t}){let r=yu[t];return e("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-ink/5 border border-ink/10 text-[10px] text-ink/55",title:r.detail,children:[e(r.Icon,{size:10,className:"flex-shrink-0"}),r.label]})}function mo({item:t,declared:r}){return e("span",{className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] ${r?"border border-dashed border-ink/25 text-ink/45":"bg-ink/10 text-ink/65"}`,title:r?`${t.detail} (declared by the manifest — its bundle has not registered it)`:t.detail,children:[t.label,t.count>1?e("span",{className:"font-mono text-ink/50",children:["×",t.count]}):null,t.title?e("span",{className:"text-ink/40 truncate max-w-[9rem]",children:["· ",t.title]}):null]})}function vl({items:t,declared:r}){if(t.length===0)return null;return e("div",{className:"flex flex-wrap items-center gap-1",children:t.map((l)=>e(mo,{item:l,declared:r},l.key))})}function xl({label:t,children:r}){return e("span",{className:"flex items-baseline gap-1 min-w-0",children:[e("span",{className:"text-[10px] uppercase tracking-wide text-ink/35 flex-shrink-0",children:t}),e("span",{className:"text-[10px] text-ink/60 truncate min-w-0",children:r})]})}var go=["rightPanel","panel","headerPanel","settingsSection"];var wu={rightPanel:{label:"Panel view",detail:"A view with its own button — it rides the left dock or the right column.",kind:"panel"},panel:{label:"Editor takeover",detail:"A full-height view that owns the editor column.",kind:"panel"},headerPanel:{label:"Header button",detail:"A control in the top navbar — a readout, a dropdown, or a button that opens a panel.",kind:"panel"},settingsSection:{label:"Settings section",detail:"A block inside this plugin’s own settings pane.",kind:"panel"}},Su={messageAction:{label:"Message actions",detail:"Buttons on every chat message row.",kind:"row"},commandPaletteAction:{label:"Command palette",detail:"Commands added to the composer’s `/` popup.",kind:"row"},command:{label:"Commands",detail:"Commands added to the app palette and keymap.",kind:"row"},fileOpener:{label:"File openers",detail:"Handlers that open a file in its own viewer instead of the editor.",kind:"row"},sourceCodeRenderer:{label:"Source renderers",detail:"Alternate renderers for a source file.",kind:"row"},diffRenderer:{label:"Diff renderers",detail:"Alternate renderers for a diff.",kind:"row"},timelineRenderer:{label:"Timeline renderers",detail:"Alternate renderers for the chat timeline.",kind:"row"},composerAction:{label:"Composer buttons",detail:"Buttons in the composer’s toolbar.",kind:"row"},composerBanner:{label:"Composer banners",detail:"A strip drawn above the composer’s input.",kind:"row"},providerIcon:{label:"Provider icons",detail:"Marks for a model provider.",kind:"row"},pendingInteraction:{label:"Pending interactions",detail:"A dialog the agent can block on.",kind:"row"},messageDirective:{label:"Message directives",detail:"A fenced-block name this plugin renders.",kind:"row"},contentScript:{label:"Content scripts",detail:"Code that runs while the plugin is enabled and draws nothing.",kind:"row"}};function bo(t){return wu[t]}function kl(t){return Su[t]}var Pu={live:!1,panels:[],rows:[]};function bn(t){let r=$l().slots.get(t);if(!r)return Pu;let l=[];for(let b of go){if(!r.components[b])continue;let p=bo(b),g=r.titles[b];l.push({key:b,label:p.label,detail:p.detail,kind:"panel",count:1,...g?{title:g}:{}})}let c=[];for(let b of DA){let p=zo(b).filter((h)=>h.pluginId===t).length;if(p===0)continue;let g=kl(b);c.push({key:b,label:g.label,detail:g.detail,kind:"row",count:p})}return{live:!0,panels:l,rows:c}}function yl(t){let[r,l]=n(()=>bn(t));return i(()=>{l(bn(t));let c=bp(()=>l(bn(t))),b=hp(()=>l(bn(t)));return()=>{c(),b()}},[t]),r}function fo(t){if(!t||t.length===0)return[];let r=new Set(t);return go.filter((l)=>r.has(l)).map((l)=>{let c=bo(l);return{key:l,label:c.label,detail:c.detail,kind:"panel",count:1}})}function wl(t,r){let l=[...t.panels,...t.rows];if(l.length>0)return{items:l,fromDeclaration:!1};let c=fo(r);return{items:c,fromDeclaration:c.length>0}}function Sl({entries:t,busy:r,onInstall:l,onInstallUrl:c}){let[b,p]=n(null);if(t.length===0)return null;return e("section",{children:[e("header",{className:"flex items-center gap-2 mb-2",children:[e(rt,{size:14,className:"text-ink/50 flex-shrink-0"}),e("h3",{className:"text-sm font-medium text-ink",children:"Available"}),e("span",{className:"ml-auto text-[11px] text-ink/50",children:[t.length," plugin",t.length===1?"":"s"]})]}),e("div",{className:"grid gap-3 [grid-template-columns:repeat(auto-fill,minmax(240px,1fr))]",children:t.map((g)=>{let h=r==="install"||r===`install:${g.pluginId}`,v=fo(g.slots);return e("article",{className:"flex flex-col gap-2 border border-ink/10 rounded-lg p-3 bg-paper hover:border-ink/20 transition-colors",children:[e("div",{className:"flex items-start gap-2.5",children:[e(Vo,{name:g.name,iconUrl:g.iconUrl,color:g.color}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"text-xs font-medium text-ink truncate",title:g.name,children:g.name}),e("div",{className:"flex items-center gap-1.5 min-w-0",children:[g.pluginId===g.name?null:e("span",{className:"text-[11px] text-ink/45 font-mono truncate",title:g.pluginId,children:g.pluginId}),e(mn,{version:g.version})]})]})]}),e("div",{className:"flex items-center gap-2 flex-wrap",children:[e("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-ink/5 border border-ink/10 text-[10px] text-ink/55",title:g.origin==="git"?"Listed in marketplace.json as a git repository — installing clones it.":"Shipped inside Kabmo’s own store.",children:g.origin==="git"?"Git":"Bundled"}),e(gn,{author:g.author})]}),g.description?e("p",{className:"text-[11px] text-ink/60 leading-relaxed line-clamp-3",children:g.description}):null,e(vl,{items:v,declared:!0}),g.origin==="git"&&g.url?e("p",{className:"text-[10px] font-mono text-ink/40 truncate",title:g.url,children:g.url}):null,e("div",{className:"mt-auto flex items-center gap-1.5 pt-1",children:[g.readmeUrl?e("button",{type:"button",onClick:()=>p(g),title:`Read ${g.name}'s README`,"aria-label":`Read ${g.name}'s README`,className:"flex items-center gap-1.5 px-2 py-1 text-[11px] rounded border border-ink/15 hover:bg-ink/5 text-ink/70",children:[e(Vt,{size:12}),"README"]}):null,e("button",{type:"button",disabled:r!==null,onClick:()=>{if(g.origin==="git"&&g.url)c(g.url);else l(g.pluginId)},className:"ml-auto flex items-center gap-1 px-2.5 py-1 rounded-lg border border-ink/20 text-[11px] text-ink/70 hover:text-ink hover:border-ink/40 transition-colors disabled:opacity-40",children:[h?e(m,{size:12,className:"animate-spin"}):e(he,{size:12}),"Install"]})]})]},`${g.origin}:${g.pluginId}`)})}),b?.readmeUrl?e(un,{pluginId:b.pluginId,name:b.name,readmeUrl:b.readmeUrl,onClose:()=>p(null)}):null]})}function ho(t){return t?t.slice(0,7):"?"}function Nl({status:t,origin:r,busy:l,pluginId:c,onUpdate:b,latestVersion:p}){let g=l===`update:${c}`;if(!t)return e("p",{className:"text-[10px] text-ink/40 font-mono truncate",title:r,children:["git · ",r," · not checked"]});if(t.error)return e("p",{className:"text-[10px] text-warning truncate",title:`${r} — ${t.error}`,children:["git · could not reach ",r]});if(!t.updateAvailable)return e("p",{className:"text-[10px] text-ink/40 font-mono truncate",title:`${r} @ ${t.current??"?"}`,children:["git · ",ho(t.current)," · up to date"]});let h=p??t.latestVersion;return e("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-[10px] text-ink/50 font-mono truncate",title:`${r}
|
|
38
|
-
${t.current} → ${t.latest}`,children:[ho(t.current)," → ",ho(t.latest)]}),h?e("span",{className:"text-[10px] text-warning font-mono flex-shrink-0",children:["v",h]}):null,e("button",{type:"button",onClick:()=>void b(c),disabled:l!==null,title:`Update from ${r} — fetches the remote's commit and rebuilds the plugin`,className:"ml-auto flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded border border-ink/25 text-ink hover:bg-ink/5 disabled:opacity-40 flex-shrink-0",children:[g?e(m,{size:11,className:"animate-spin"}):e(Je,{size:11}),"Update"]})]})}var fn={left:"left dock",right:"right column",editor:"editor column"},Cu={left:"Left",right:"Right",editor:"Editor"},Tu={left:qn,right:Gr,editor:En};function Pl({name:t,pluginId:r,slot:l,dock:c}){let b=zl(l);if(b.length<2)return null;let p=ua(r,l),g=va(p,c);return e("span",{className:"flex items-center gap-0.5 flex-shrink-0","data-placement-for":p,children:b.map((h)=>{let v=Tu[h],k=h===g;return e("button",{type:"button",disabled:k,onClick:()=>c.setSide(p,h),title:k?`${t} is on the ${fn[h]}`:`Move ${t} to the ${fn[h]}`,"aria-label":k?`${t} is on the ${fn[h]}`:`Move ${t} to the ${fn[h]}`,"aria-pressed":k,className:`flex items-center gap-0.5 px-1 py-0.5 rounded border text-[10px] transition-colors ${k?"border-ink/30 bg-ink/10 text-ink/50 cursor-default":"border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink cursor-pointer"}`,children:[e(v,{size:10}),Cu[h]]},h)})})}function Cl({plugin:t,entry:r,failure:l,iconUrl:c,readmeUrl:b,busy:p,gitStatus:g,dock:h,onReadme:v,onSettings:k,onBuild:x,onRemove:A,onSetEnabled:N,onUpdate:M}){let P=Do(t.pluginId),E=p===`enable:${P}`||p===`disable:${P}`,S=yl(t.pluginId),R=wl(S,t.slots),T=po(t,g);return e("article",{className:`flex flex-col gap-2 border rounded-lg p-3 transition-colors ${t.enabled?"border-ink/10 bg-paper":"border-ink/10 bg-ink/[0.02]"}`,children:[e("header",{className:"flex items-start gap-2.5",children:[e("div",{className:t.enabled?"":"opacity-50",children:e(Vo,{name:t.name,iconUrl:c,color:t.color})}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-1.5 min-w-0",children:[e("span",{className:"text-xs font-medium text-ink truncate",title:t.name,children:t.name}),!t.built?e("span",{className:"text-[10px] px-1 rounded bg-warning/15 text-warning border border-warning/25 flex-shrink-0",children:"not built"}):null]}),e("div",{className:"flex items-center gap-1.5 min-w-0",children:[e("span",{className:"text-[11px] text-ink/45 font-mono truncate",title:t.pluginId,children:t.pluginId}),e(mn,{version:t.version,latest:t.latestVersion})]})]}),e("button",{type:"button",role:"switch","aria-checked":t.enabled,"aria-label":`${t.enabled?"Disable":"Enable"} ${t.name}`,disabled:p!==null,onClick:()=>void N(P,!t.enabled),title:t.enabled?"Disable — keep the files, remove its buttons":"Enable this plugin",className:`relative w-8 h-4 rounded-full transition-colors flex-shrink-0 mt-0.5 disabled:opacity-40 ${t.enabled?"bg-ink/70":"bg-ink/20"}`,children:E?e(m,{size:9,className:"absolute inset-0 m-auto animate-spin text-canvas"}):e("span",{className:`absolute top-0.5 w-3 h-3 rounded-full bg-canvas transition-all ${t.enabled?"left-[18px]":"left-0.5"}`})})]}),t.description?e("p",{className:"text-[11px] text-ink/60 leading-relaxed line-clamp-2",children:t.description}):null,e("div",{className:"flex items-center gap-2 flex-wrap",children:[e(hl,{origin:t.origin}),e(gn,{author:t.author}),t.settingsCount?e(xl,{label:"settings",children:t.settingsCount}):null,t.homepage?e("a",{href:t.homepage,target:"_blank",rel:"noreferrer noopener",className:"ml-auto text-[10px] text-ink/45 hover:text-ink truncate max-w-[10rem]",title:t.homepage,children:Iu(t.homepage)}):null]}),!t.enabled?e("p",{className:"text-[11px] text-ink/45",children:["Disabled — contributes nothing while the switch is off.",R.fromDeclaration?" The slots below are what its manifest declares.":""]}):l?e("p",{className:"text-[11px] text-error leading-snug",children:["Bundle failed to load — ",l]}):!r?e("p",{className:"text-[11px] text-ink/45",children:"Loading bundle…"}):R.items.length===0?e("p",{className:"text-[11px] text-ink/45",children:"Loaded, but registers nothing: no panel, no button, no hook."}):null,R.items.length>0?e("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:R.items.map((O)=>e("span",{className:"flex items-center gap-1",children:[e(mo,{item:O,declared:R.fromDeclaration}),!R.fromDeclaration&&CA(O.key)?e(Pl,{name:O.title??t.name,pluginId:t.pluginId,slot:O.key,dock:h}):null]},O.key))}):null,!t.built?e("p",{className:"text-[11px] text-warning",children:["Not built",t.reason?` — ${t.reason}`:"",". The bundle will 404 until it is built."]}):null,t.gitOrigin?e(Nl,{status:g,origin:t.gitOrigin,busy:p,pluginId:t.pluginId,onUpdate:M,latestVersion:t.latestVersion}):null,e("footer",{className:"mt-auto flex items-center gap-1.5 pt-1",children:[!t.built?e("button",{type:"button",onClick:()=>void x(t.pluginId),disabled:p!==null,title:t.reason?`Rebuild — ${t.reason}`:"Rebuild this plugin",className:"flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded border border-warning/40 text-warning hover:bg-warning/10 disabled:opacity-40",children:[p===`build:${t.pluginId}`?e(m,{size:11,className:"animate-spin"}):e(Xo,{size:11}),"Rebuild"]}):null,T&&!t.gitOrigin?e("button",{type:"button",onClick:()=>void M(t.pluginId),disabled:p!==null,title:T.version?`Apply the store's copy of v${T.version} — your edited files are left untouched, and the update is refused if they conflict`:"Apply the store's copy — your edited files are left untouched, and the update is refused if they conflict",className:"flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded border border-warning/50 text-warning hover:bg-warning/10 disabled:opacity-40",children:[p===`update:${t.pluginId}`?e(m,{size:11,className:"animate-spin"}):e(Je,{size:11}),"Update"]}):null,e("span",{className:"ml-auto flex items-center gap-1",children:[t.settingsCount?e("button",{type:"button",onClick:k,title:`Configure ${t.name}`,"aria-label":`Configure ${t.name}`,className:"p-1 rounded text-ink/40 hover:text-ink hover:bg-ink/5 flex-shrink-0",children:e(lr,{size:13})}):null,b?e("button",{type:"button",onClick:v,title:`Read ${t.name}'s README`,"aria-label":`Read ${t.name}'s README`,className:"p-1 rounded text-ink/40 hover:text-ink hover:bg-ink/5 flex-shrink-0",children:e(Vt,{size:13})}):null,e(fl,{pluginId:t.pluginId,disabled:p!==null,onRemove:A})]})]})]})}function Iu(t){try{return new URL(t).host.replace(/^www\./,"")}catch{return t}}var Tl="••••••••";function Rl({pluginId:t,name:r,onClose:l}){let[c,b]=n(null),[p,g]=n({}),[h,v]=n(null),[k,x]=n(!1),[A,N]=n(!1);i(()=>{let S=!1;return fetch(`/api/panels/settings/${encodeURIComponent(t)}`,{credentials:"same-origin"}).then(async(R)=>{if(!R.ok)throw Error(await Il(R));return await R.json()}).then((R)=>{if(S)return;b(R),g(Al(R.definitions,R.values))},(R)=>{if(!S)v(R instanceof Error?R.message:String(R))}),()=>{S=!0}},[t]);let M=c?Object.entries(c.definitions):[];function P(S,R){g((T)=>({...T,[S]:R})),N(!1)}async function E(S){if(S.preventDefault(),!c)return;v(null),N(!1);let R={};for(let[T,O]of Object.entries(c.definitions)){let L=p[T];if(O.type==="boolean"){R[T]=L===!0;continue}let _=String(L??"");if(O.secret&&!_)continue;if(O.type==="number"){let K=Number(_.trim());if(_.trim()===""||!Number.isFinite(K)){v(`${O.label} needs a number.`);return}R[T]=K;continue}R[T]=_}x(!0);try{let T=await fetch(`/api/panels/settings/${encodeURIComponent(t)}`,{method:"PUT",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({values:R})});if(!T.ok)throw Error(await Il(T));let O=await T.json();b(O),g(Al(O.definitions,O.values)),N(!0)}catch(T){v(T instanceof Error?T.message:String(T))}finally{x(!1)}}return e(J,{onClose:l,maxWidthClass:"max-w-lg",header:e("div",{className:"flex items-center gap-2 min-w-0",children:[e(lr,{size:15,className:"text-ink/50 flex-shrink-0"}),e("span",{className:"text-sm font-medium text-ink truncate",children:r}),e("span",{className:"text-[11px] text-ink/45 font-mono truncate",children:t})]}),form:{onSubmit:E,className:"px-5 py-4 space-y-4"},footer:e("div",{className:"flex items-center gap-2",children:[h?e("span",{className:"flex items-start gap-1.5 text-error min-w-0",children:[e(D,{size:13,className:"flex-shrink-0 mt-0.5"}),e("span",{className:"text-[11px] leading-snug",children:h})]}):A?e("span",{className:"text-[11px] text-success",children:"Saved"}):null,e("button",{type:"submit",disabled:k||!c,className:"ml-auto px-3 py-1.5 rounded-md bg-ink text-paper text-[11px] font-medium hover:bg-ink/90 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:k?"Saving…":"Save"})]}),children:!c?h?null:e("div",{className:"flex items-center gap-2 text-ink/50",children:[e(m,{size:14,className:"animate-spin"}),e("span",{className:"text-xs",children:"Reading settings…"})]}):M.length===0?e("p",{className:"text-xs text-ink/50",children:"This plugin declares no settings."}):M.map(([S,R])=>e(Au,{name:S,definition:R,value:p[S],stored:R.secret===!0&&c.values[S]===Tl,onChange:(T)=>P(S,T)},S))})}function Au({name:t,definition:r,value:l,stored:c,onChange:b}){return e("div",{className:"space-y-1",children:[e("label",{className:"block text-xs font-medium text-ink",for:`plugin-setting-${t}`,children:r.label}),r.description?e("p",{className:"text-[11px] text-ink/50 leading-snug",children:r.description}):null,r.type==="boolean"?e("label",{className:"flex items-center gap-2 cursor-pointer select-none pt-0.5",children:[e("input",{id:`plugin-setting-${t}`,type:"checkbox",checked:l===!0,onChange:(g)=>b(g.currentTarget.checked),className:`${ge} accent-ink cursor-pointer`}),e("span",{className:"text-[11px] text-ink/70",children:l===!0?"on":"off"})]}):e("input",{id:`plugin-setting-${t}`,type:r.type==="number"?"number":r.secret?"password":"text",value:typeof l==="string"?l:"",spellcheck:!1,autocomplete:"off",placeholder:c?"stored — type a new value to replace":void 0,onInput:(g)=>b(g.currentTarget.value),className:"w-full px-2.5 py-1.5 rounded-lg border border-ink/15 bg-paper focus:outline-none focus:border-ink/40 text-xs text-ink transition-colors font-mono"})]})}async function Il(t){return(await t.json().catch(()=>null))?.error??`The settings request failed (${t.status})`}function Al(t,r){let l={};for(let[c,b]of Object.entries(t)){if(b.type==="boolean"){l[c]=r[c]===!0;continue}l[c]=b.secret?"":String(r[c]??"")}return l}function Ml({plugins:t,slots:r,failures:l,iconUrls:c,readmeUrls:b,busy:p,dock:g,onBuild:h,onRemove:v,onSetEnabled:k,gitStatus:x,onUpdate:A}){let[N,M]=n(null),[P,E]=n(null),S=t.filter((T)=>T.enabled).length,R=pn(t,x);return e("section",{children:[e("header",{className:"flex items-center gap-2 mb-2",children:[e("h3",{className:"text-sm font-medium text-ink",children:"Installed"}),e("span",{className:"text-[11px] text-ink/45",children:[S,"/",t.length," enabled"]}),R>0?e("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-warning/15 text-warning border border-warning/25",children:[R," update",R===1?"":"s"," available"]}):null]}),e("div",{className:"grid gap-3 [grid-template-columns:repeat(auto-fill,minmax(260px,1fr))]",children:t.map((T)=>e(Cl,{plugin:T,entry:r.get(T.pluginId),failure:l.get(T.pluginId),iconUrl:c.get(T.pluginId),readmeUrl:b.get(T.pluginId),busy:p,gitStatus:x[T.pluginId],dock:g,onReadme:()=>M(T),onSettings:()=>E(T),onBuild:h,onRemove:v,onSetEnabled:k,onUpdate:A},T.pluginId))}),N&&b.get(N.pluginId)?e(un,{pluginId:N.pluginId,name:N.name,readmeUrl:b.get(N.pluginId),onClose:()=>M(null)}):null,P?e(Rl,{pluginId:P.pluginId,name:P.name,onClose:()=>E(null)}):null]})}function El({disabled:t,busy:r,onSetEnabled:l}){let c=new Set(t);return e("section",{children:[e("header",{className:"flex items-center gap-2 mb-2",children:[e("h3",{className:"text-sm font-medium text-ink",children:"Built-in"}),e("span",{className:"ml-auto text-[11px] text-ink/50",children:[no.length-no.filter((b)=>c.has(b.id)).length," of"," ",no.length," on"]})]}),e("p",{className:"text-[11px] text-ink/50 mb-2",children:"The views Kabmo ships. Switch one off to put it away — its code stays in the app, so this is reversible at any time and needs no reinstall."}),e("div",{className:"grid gap-2 [grid-template-columns:repeat(auto-fill,minmax(200px,1fr))]",children:no.map((b)=>{let p=!c.has(b.id),g=r===`enable:${b.id}`||r===`disable:${b.id}`;return e("div",{className:`flex items-center gap-2.5 border border-ink/10 rounded-lg px-2.5 py-2 transition-colors ${p?"bg-paper":"bg-ink/[0.02]"}`,children:[e(js,{className:`flex-shrink-0 ${p?"text-ink/70":"text-ink/30"}`,panelId:b.id,builtin:!0,icon:b.icon,name:b.title,size:an,idle:!p}),e("span",{className:"min-w-0 flex-1",children:[e("span",{className:`block text-xs truncate ${p?"text-ink":"text-ink/45"}`,title:b.title,children:b.title}),e("span",{className:"block text-[10px] font-mono text-ink/40 truncate",children:b.id})]}),e("button",{type:"button",role:"switch","aria-checked":p,"aria-label":`${p?"Disable":"Enable"} ${b.title}`,disabled:r!==null,onClick:()=>void l(b.id,!p),title:p?"Switch off — remove its button":"Switch on",className:`relative w-8 h-4 rounded-full transition-colors flex-shrink-0 disabled:opacity-40 ${p?"bg-ink/70":"bg-ink/20"}`,children:g?e(m,{size:9,className:"absolute inset-0 m-auto animate-spin text-canvas"}):e("span",{className:`absolute top-0.5 w-3 h-3 rounded-full bg-canvas transition-all ${p?"left-[18px]":"left-0.5"}`})})]},b.id)})})]})}var Mu={left:"Left dock",right:"Right column",editor:"Editor column"},hn={left:"left dock",right:"right column",editor:"editor column"},Eu={left:qn,right:Gr,editor:En};function Ou({name:t,destinations:r,current:l,onMove:c}){if(r.length<2)return null;return e("span",{className:"flex items-center gap-1 flex-shrink-0",children:r.map((b)=>{let p=Eu[b],g=b===l;return e("button",{type:"button",disabled:g,onClick:()=>c(b),title:g?`${t} is on the ${hn[b]}`:`Move ${t} to the ${hn[b]}`,"aria-label":g?`${t} is on the ${hn[b]}`:`Move ${t} to the ${hn[b]}`,"aria-pressed":g,className:`flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded border flex-shrink-0 transition-colors ${g?"border-ink/30 bg-ink/10 text-ink/50 cursor-default":"border-ink/25 text-ink/80 hover:bg-ink/5 cursor-pointer"}`,children:[e(p,{size:11}),b==="left"?"Left":b==="right"?"Right":"Editor"]},b)})})}function Ol({dock:t,plugins:r,slots:l}){let c=[];for(let p of r){let g=l.get(p.pluginId);if(!p.enabled||!g)continue;for(let h of["rightPanel","panel"]){if(!g.components[h])continue;let v=ua(p.pluginId,h);c.push({plugin:p,key:v,slot:h,side:va(v,t),title:g.titles[h]??p.name})}}let b=r.filter((p)=>p.enabled&&!l.get(p.pluginId)).length;return e("section",{children:[e("header",{className:"flex items-center gap-2 mb-2",children:[e("h3",{className:"text-sm font-medium text-ink",children:"Panel placement"}),e("span",{className:"ml-auto text-[11px] text-ink/50",children:t.enabled?`${t.panels.length} on the rail`:"rail off"})]}),e("p",{className:"text-[11px] text-ink/50 mb-2",children:"The left column always holds the session list. Turn its rail on to add views beside it — a panel placed there gets its own button and its own width, and leaves the right column. Each contributed panel is placed on its own: a plugin that ships two panels gets two rows."}),!t.enabled?e("p",{className:"text-[11px] text-ink/45 mb-2",children:"The rail is off. Placing a panel on the left turns it on, and you can switch it back off here at any time."}):null,e("div",{className:"flex items-center gap-2.5 border border-ink/10 rounded-lg px-2.5 py-2 mb-2",children:[e("span",{className:"min-w-0 flex-1",children:[e("span",{className:"block text-xs text-ink",children:"Show the left activity bar"}),e("span",{className:"block text-[10px] text-ink/40",children:"Off by default. With it off the column shows only its active view."})]}),e("button",{type:"button",role:"switch","aria-checked":t.enabled,"aria-label":t.enabled?"Hide the left activity bar":"Show the left activity bar",onClick:()=>t.setEnabled(!t.enabled),className:`relative w-8 h-4 rounded-full transition-colors flex-shrink-0 ${t.enabled?"bg-ink/70":"bg-ink/20"}`,children:e("span",{className:`absolute top-0.5 w-3 h-3 rounded-full bg-canvas transition-all ${t.enabled?"left-[18px]":"left-0.5"}`})})]}),c.length===0?e("p",{className:"text-[11px] text-ink/45",children:b>0?`Loading ${b} plugin ${b===1?"bundle":"bundles"}…`:"No installed plugin contributes a panel yet. Install one from the store above and it appears here."}):e("div",{className:"grid gap-2 [grid-template-columns:repeat(auto-fill,minmax(240px,1fr))]",children:[e("div",{className:"flex flex-col gap-1.5 border border-ink/10 rounded-lg px-2.5 py-2 bg-ink/[0.02]",children:[e("span",{className:"min-w-0",children:[e("span",{className:"block text-xs text-ink",children:"Sessions"}),e("span",{className:"block text-[10px] text-ink/40",children:"The dock's own view, always here."})]}),e("span",{className:"text-[10px] font-mono text-ink/40 self-start",children:ut})]}),c.map(({plugin:p,key:g,slot:h,side:v,title:k})=>{let x=zl(h);return e("div",{className:"flex flex-col gap-1.5 border border-ink/10 rounded-lg px-2.5 py-2",children:[e("span",{className:"min-w-0",children:[e("span",{className:"block text-xs text-ink",title:`${k} — ${p.name}`,children:[k,e("span",{className:"text-ink/40",children:[" · ",p.name]})]}),e("span",{className:"block text-[10px] text-ink/40",children:[Mu[v],h==="panel"?" · takeover":" · view",v==="left"&&!t.enabled?" · rail off":""]})]}),x.length>1?e(Ou,{name:k,destinations:x,current:v,onMove:(A)=>t.setSide(g,A)}):e("span",{className:"flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded border border-ink/10 text-ink/50 self-start",title:`${k} draws the editor column — its slot has no other destination`,children:[e(Kt,{size:11,className:"opacity-40"}),"Fixed"]})]},g)})]}),b>0&&c.length>0?e("p",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-ink/45",children:[e(m,{size:11,className:"animate-spin"}),b," plugin ",b===1?"bundle is":"bundles are"," still loading."]}):null,e("p",{className:"mt-2 flex items-start gap-1.5 text-[11px] text-ink/40",children:[e(da,{size:11,className:"mt-0.5 flex-shrink-0 opacity-60"}),e("span",{children:"A takeover draws the editor column whole, so its switch is the editor panel's own rail (Files · your panels). A view rides a rail and gets one button on the column it is placed on."})]})]})}function Ll({autoUpdate:t,busy:r,gitCount:l,updateCount:c,onSetAutoUpdate:b,onCheckUpdates:p,onUpdateAll:g,onRefresh:h}){let v=r==="check_updates",k=r==="update_all",[x,A]=n(!1),N=async()=>{A(!0);try{await h()}finally{A(!1)}};return e("div",{className:"flex flex-wrap items-center gap-2",children:[e("button",{type:"button",role:"checkbox","aria-checked":t,disabled:r!==null,onClick:()=>void b(!t),title:t?"Stop updating git-installed plugins automatically":"Fetch and apply the remote’s latest commit for every git-installed plugin, hourly",className:"flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded border border-ink/15 hover:bg-ink/5 disabled:opacity-50",children:[t?e(Eo,{size:13}):e(Hn,{size:13}),"Auto-update git plugins"]}),e("button",{type:"button",onClick:()=>void p(),disabled:r!==null||l===0,title:l===0?"No git-installed plugins to check":"Ask each git-installed plugin’s remote whether a newer commit exists",className:"flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded border border-ink/15 hover:bg-ink/5 disabled:opacity-50",children:[e(C,{size:13,className:v?"animate-spin":""}),"Check for updates"]}),e("button",{type:"button",onClick:()=>void g(),disabled:r!==null||c===0,title:c===0?"No updates to apply — press Check for updates to ask the git plugins’ remotes":`Apply ${c} update${c===1?"":"s"} — a plugin with local edits is refused and reported, never overwritten`,className:"flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded border border-warning/50 text-warning hover:bg-warning/10 disabled:opacity-50",children:[k?e(m,{size:13,className:"animate-spin"}):e(Je,{size:13}),"Update all",c>0?` (${c})`:""]}),e("button",{type:"button",onClick:()=>void N(),disabled:r!==null||x,"aria-busy":x,className:"flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded border border-ink/15 hover:bg-ink/5 disabled:opacity-50",title:"Re-read the marketplace from disk",children:[e(C,{size:13,className:x?"animate-spin":void 0}),"Refresh"]}),e("span",{className:"text-[11px] text-ink/45",children:t?"Git plugins are updated from their remote about once an hour, with no confirmation.":"Off — updates are applied only when you press Update."})]})}var Lu=5;function Dl({blocked:t,busy:r,onForceSync:l}){let c=Object.entries(t);if(c.length===0)return null;return e("div",{className:"space-y-2",children:c.map(([b,p])=>{let g=p.changed.slice(0,Lu),h=p.changed.length-g.length;return e("div",{className:"border border-warning/40 rounded p-3 space-y-1.5",children:[e("div",{className:"flex items-center gap-2 text-warning",children:[e(D,{size:14,className:"flex-shrink-0"}),e("span",{className:"text-xs",children:[e("span",{className:"font-medium",children:b})," has local changes — its bundled update is paused"]})]}),e("p",{className:"text-[11px] text-ink/60",children:["Kabmo installed this plugin, and ",p.changed.length," of its files no longer match what it wrote. Your files are left as they are."]}),e("ul",{className:"text-[10px] font-mono text-ink/50 space-y-0.5",children:[g.map((v)=>e("li",{className:"truncate",title:v,children:v},v)),h>0?e("li",{children:["… and ",h," more"]}):null]}),e("div",{className:"flex items-center gap-2 pt-0.5",children:[e("button",{type:"button",disabled:r!==null,onClick:()=>void l(b),title:`Replace ${p.changed.length} changed file(s) with the copy Kabmo ships — your edits are lost`,className:"flex items-center gap-1.5 px-2 py-1 text-[11px] rounded border border-warning/50 text-warning hover:bg-warning/10 disabled:opacity-50",children:[r===`force_sync:${b}`?e(m,{size:12,className:"animate-spin"}):e(ct,{size:12}),"Replace my changes with the store's copy"]}),e("span",{className:"text-[11px] text-ink/45",children:"This discards the files listed above."})]})]},b)})})}function Du({error:t,busy:r,onForget:l}){let c=t.source;return e("div",{className:"border border-error/30 rounded p-3",children:[e("div",{className:"flex items-center gap-2 text-error",children:[e(D,{size:14,className:"flex-shrink-0"}),e("span",{className:"text-xs",children:"Rejected"})]}),e("div",{className:"mt-1 text-[11px] font-mono text-ink/50 break-all",children:t.dir}),e("div",{className:"mt-1 text-xs text-ink/70",children:t.reason}),c?e("div",{className:"mt-2 flex items-center gap-2",children:[e("button",{type:"button",disabled:r,onClick:()=>void l(c),className:"flex items-center gap-1.5 px-2 py-1 text-[11px] rounded border border-error/40 text-error hover:bg-error/10 disabled:opacity-50",title:`Drop the catalog entry "${c}" — the directory it names is already gone`,children:[e(U,{size:12}),"Forget this entry"]}),e("span",{className:"text-[11px] text-ink/45",children:"Removes the record from marketplace.json. No files are touched."})]}):null]})}function Ul(){let{panels:t,errors:r,plugins:l,catalog:c,disabledPanels:b,gitStatus:p,autoUpdate:g,syncBlocked:h,ready:v}=Wn(),{slots:k,failures:x}=Zi(),A=yp(),N=Kn(),M=c.filter((O)=>!O.installed),P=new Map(x.map((O)=>[O.pluginId,O.reason])),E=new Map(t.map((O)=>[O.pluginId,O.iconUrl])),S=new Map(t.map((O)=>[O.pluginId,O.readmeUrl])),R=l.filter((O)=>O.gitOrigin).length,T=pn(l,p);return e("div",{className:"space-y-4",children:[e("div",{className:"flex items-start justify-between gap-3",children:e("p",{className:"text-xs text-ink/60 max-w-xl",children:["Panels bundled with Kabmo, plus the ones you install from a git URL — typed here or listed in"," ",e("span",{className:"font-mono text-ink/70",children:"marketplace.json"}),". A plugin is local code Kabmo loads into this page and renders in its own tree, so it looks and behaves like the rest of the app — treat it the way you would a VS Code extension."]})}),e(Ll,{autoUpdate:g,busy:A.busy,gitCount:R,updateCount:T,onSetAutoUpdate:A.setAutoUpdate,onCheckUpdates:A.checkUpdates,onUpdateAll:A.updateAll,onRefresh:QA}),A.error?e("div",{className:"flex items-start gap-1.5 px-3 py-2 rounded-lg border border-error/30 bg-error/5 text-[11px] text-error leading-snug",children:[e(D,{size:13,className:"mt-0.5 flex-shrink-0"}),e("span",{className:"flex-1 break-words",children:A.error}),e("button",{type:"button",onClick:A.clearError,"aria-label":"Dismiss",className:"cursor-pointer",children:e(y,{size:12})})]}):null,e(bl,{busy:A.busy==="install",onInstall:A.install,onClearError:A.clearError}),!v?e("p",{className:"text-xs text-ink/50",children:"Reading…"}):null,e(El,{disabled:b,busy:A.busy,onSetEnabled:A.setEnabled}),e(Ol,{dock:N,plugins:l,slots:k}),v&&M.length===0&&l.length===0&&r.length===0?e("div",{className:"text-xs text-ink/60 space-y-1.5",children:[e("p",{children:"No panel plugins installed."}),e("p",{className:"font-mono text-[11px] text-ink/45 leading-relaxed",children:["~/.kabmo/marketplace/marketplace.json",e("br",{}),"~/.kabmo/marketplace/plugins/<plugin>/package.json"]})]}):null,e(Sl,{entries:M,busy:A.busy,onInstall:A.installBundled,onInstallUrl:A.install}),e(Dl,{blocked:h,busy:A.busy,onForceSync:A.forceSync}),l.length>0?e(Ml,{plugins:l,slots:k,failures:P,iconUrls:E,readmeUrls:S,busy:A.busy,dock:N,onBuild:A.build,onRemove:A.remove,onSetEnabled:A.setEnabled,gitStatus:p,onUpdate:A.update}):null,r.map((O)=>e(Du,{error:O,busy:A.busy!==null,onForget:A.forget},O.dir+O.reason))]})}function Fl(){return e("div",{className:"flex-1 min-h-0 overflow-auto p-6 md:p-8",children:e("div",{className:"max-w-3xl",children:e(Ul,{})})})}async function vn(t){let r=await fetch("/api/settings/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json().catch(()=>({}));if(!r.ok||l.error)throw Error(l.error||`Request failed (${r.status})`);return l}function jl(){let[t,r]=n([]),[l,c]=n([]),[b,p]=n([]),g=a((N)=>{if(N.catalogSources)r(N.catalogSources);if(N.catalogSkills)c(N.catalogSkills);if(N.skills)p(N.skills)},[]),h=a(async()=>{let N=await fetch("/api/settings/skills");g(await N.json())},[g]),v=a(async(N)=>{let M=N.trim();if(!M)return await h(),[];let E=(await vn({type:"search_catalog",q:M})).catalogSkills??[];return c(E),E},[h]),k=a(async(N,M)=>{let P=await vn({type:"add_source",repo:N,...M?{name:M}:{}});g(P);let E=P.catalogSources?.at(-1);if(!E)throw Error("The server stored the source but did not return it");return E},[g]),x=a(async(N)=>{g(await vn({type:"remove_source",id:N}))},[g]),A=a(async(N)=>{let M=await vn({type:"scan_source",id:N});if(M.catalogSources)r(M.catalogSources);return{skills:M.skills??[],notes:M.notes??[]}},[]);return i(()=>{h().catch(console.error)},[h]),{sources:t,catalogSkills:l,userSkills:b,setSources:r,setUserSkills:p,reload:h,search:v,addSource:k,removeSource:x,scanSource:A}}var Bl={inspecting:!1,installing:!1,repo:null,url:"",skills:[],notes:[],selected:[],overwrite:!1,error:null,result:null};async function _l(t){let r=await fetch("/api/settings/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json().catch(()=>({}));if(!r.ok||l.error)throw Error(l.error||`Request failed (${r.status})`);return l}function Hl(){let[t,r]=n(Bl),l=a(async(v)=>{let k=v.trim();if(!k){r((x)=>({...x,error:"Paste a repository URL first."}));return}r((x)=>({...x,inspecting:!0,error:null,result:null,url:k}));try{let x=await _l({type:"inspect_git_repo",url:k}),A=x.skills.filter((N)=>N.loadable&&!N.installed);r((N)=>({...N,inspecting:!1,repo:x.repo,url:k,skills:x.skills,notes:x.notes??[],selected:A.map((M)=>M.path)}))}catch(x){r((A)=>({...A,inspecting:!1,skills:[],selected:[],repo:null,error:x instanceof Error?x.message:String(x)}))}},[]),c=a((v)=>{r((k)=>({...k,selected:k.selected.includes(v)?k.selected.filter((x)=>x!==v):[...k.selected,v]}))},[]),b=a((v)=>{r((k)=>({...k,selected:v?k.skills.filter((x)=>x.loadable&&!x.installed).map((x)=>x.path):[]}))},[]),p=a((v)=>{r((k)=>({...k,overwrite:v}))},[]),g=a(async()=>{if(t.selected.length===0||!t.url)return null;r((v)=>({...v,installing:!0,error:null,result:null}));try{let v=await _l({type:"install_git_skills",url:t.url,paths:t.selected,overwrite:t.overwrite});return r((k)=>({...k,installing:!1,result:v})),v}catch(v){return r((k)=>({...k,installing:!1,error:v instanceof Error?v.message:String(v)})),null}},[t.selected,t.url,t.overwrite]),h=a(()=>r(Bl),[]);return{...t,inspect:l,toggle:c,toggleAll:b,setOverwrite:p,install:g,reset:h}}function Uu(t){if(t>=1e6)return`${(t/1e6).toFixed(1)}M`;if(t>=1000)return`${Math.round(t/1000)}K`;return String(t)}function Gl({skill:t,installed:r,busy:l,onInstallToggle:c}){return e("div",{className:"p-4 rounded-xl border border-ink/15 hover:border-ink/30 bg-paper transition-colors flex flex-col sm:flex-row sm:items-start justify-between gap-3",children:[e("div",{className:"space-y-1.5 flex-1 min-w-0",children:[e("div",{className:"flex items-center gap-2 min-w-0",children:[e("span",{className:"text-xs font-bold text-ink tracking-tight font-mono truncate",children:t.name}),t.installs?e("span",{className:"text-[10px] text-ink/45 font-mono flex-shrink-0",children:[Uu(t.installs)," weekly"]}):null]}),t.description?e("p",{className:"text-xs text-ink/75 leading-relaxed line-clamp-2",children:t.description}):null,e("div",{className:"text-[11px] text-ink/50 font-mono truncate pt-1",children:t.repoTag})]}),e("div",{className:"flex items-center gap-2 flex-shrink-0 self-end sm:self-center",children:[t.githubUrl?e("a",{href:t.githubUrl,target:"_blank",rel:"noreferrer",className:"p-1.5 rounded-lg text-ink/50 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",title:"Open the repository","aria-label":`Open the repository for ${t.name}`,children:e(Be,{size:14})}):null,e("button",{type:"button",onClick:()=>c(t),disabled:l,className:`px-3 py-1.5 rounded-lg text-xs font-medium transition-colors flex items-center gap-1.5 cursor-pointer disabled:cursor-default disabled:opacity-60 ${r?"border border-ink/20 text-ink/80 hover:border-error hover:text-error hover:bg-error/5":"bg-ink text-paper hover:bg-ink/90 shadow-xs"}`,children:l?e(d,{children:[e(m,{size:12,className:"animate-spin"}),e("span",{children:r?"Removing…":"Installing…"})]}):r?e(d,{children:[e(f,{size:12}),e("span",{children:"Installed"})]}):e(d,{children:[e(he,{size:12}),e("span",{children:"Install"})]})})]})]})}function ju(t){if(t.skillCount===null)return"Not scanned";let r=`${t.skillCount} skill${t.skillCount===1?"":"s"}`;if(!t.scannedAt)return r;let l=Math.floor((Date.now()-t.scannedAt)/60000);if(l<1)return`${r} · just scanned`;if(l<60)return`${r} · scanned ${l}m ago`;let c=Math.floor(l/60);if(c<24)return`${r} · scanned ${c}h ago`;return`${r} · scanned ${Math.floor(c/24)}d ago`}function ql({sources:t,onScan:r,onImportFrom:l,onRemove:c,onAdd:b,scanningId:p,busy:g}){return e("div",{className:"space-y-3",children:[e("div",{className:"flex items-start justify-between gap-3",children:[e("p",{className:"text-xs text-ink/60 leading-relaxed max-w-xl",children:"A source is a git repository. Kabmo clones it only when you scan or import, so adding one costs nothing until you use it."}),e("button",{type:"button",onClick:b,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer flex-shrink-0",children:[e(Y,{size:13}),e("span",{children:"Add source"})]})]}),e("div",{className:"rounded-xl border border-ink/15 divide-y divide-ink/10 overflow-hidden",children:t.length===0?e("p",{className:"p-6 text-xs text-ink/60 text-center",children:["No sources yet. Add a repository, or paste one into ",e("span",{className:"font-semibold",children:"From Git"}),"."]}):t.map((h)=>{let v=p===h.id;return e("div",{className:"p-3.5 flex flex-col sm:flex-row sm:items-center gap-3 bg-paper",children:[e("div",{className:"flex-1 min-w-0",children:[e("div",{className:"flex items-center gap-2 min-w-0",children:[e("span",{className:"text-xs font-bold text-ink truncate",children:h.name}),h.isCustom?e("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-ink/8 text-ink/60 flex-shrink-0",children:"custom"}):null]}),e("div",{className:"flex items-center gap-1.5 mt-0.5 text-[11px] text-ink/55 font-mono truncate",children:[e(fe,{size:11,className:"flex-shrink-0"}),e("span",{className:"truncate",children:h.repo})]}),e("div",{className:"text-[11px] text-ink/50 mt-0.5",children:ju(h)})]}),e("div",{className:"flex items-center gap-1.5 flex-shrink-0 self-end sm:self-center",children:[e("button",{type:"button",onClick:()=>r(h.id),disabled:g||v,className:"flex items-center gap-1 px-2 py-1 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink hover:bg-ink/5 disabled:opacity-50 transition-colors cursor-pointer",children:[v?e(m,{size:12,className:"animate-spin"}):e(C,{size:12}),e("span",{children:v?"Scanning…":"Scan"})]}),e("button",{type:"button",onClick:()=>l(h.repo),disabled:g,className:"px-2 py-1 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink hover:bg-ink/5 disabled:opacity-50 transition-colors cursor-pointer",children:"Import"}),e("button",{type:"button",onClick:()=>c(h.id),disabled:g,title:`Remove ${h.name} from the source list`,"aria-label":`Remove ${h.name}`,className:"p-1 rounded-md text-ink/40 hover:text-error hover:bg-error/10 disabled:opacity-40 transition-colors cursor-pointer",children:e(U,{size:13})})]})]},h.id)})})]})}function $u({label:t,children:r}){return e("div",{className:"space-y-1",children:[e("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-ink/60",children:t}),r]})}function Jl({controller:t,onInstalled:r}){let[l,c]=n(t.url),{skills:b,selected:p,overwrite:g}=t;i(()=>{if(t.url)c(t.url)},[t.url]);let h=b.filter((v)=>v.loadable&&!v.installed);return e("div",{className:"space-y-4",children:[e("div",{className:"space-y-2",children:[e($u,{label:"Repository",children:e("div",{className:"flex items-center gap-2",children:[e("div",{className:"relative flex-1",children:[e(fe,{size:14,className:"absolute left-3 top-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",value:l,onInput:(v)=>c(v.currentTarget.value),onKeyDown:(v)=>{if(v.key==="Enter")t.inspect(l)},placeholder:"https://github.com/owner/repo · owner/repo · a local path",className:"w-full pl-9 pr-3 py-2 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-xs font-mono text-ink transition-colors"})]}),e("button",{type:"button",onClick:()=>void t.inspect(l),disabled:t.inspecting||!l.trim(),className:"flex items-center gap-1.5 px-3 py-2 rounded-lg border border-ink/20 hover:border-ink/40 text-xs font-medium text-ink hover:bg-ink/5 disabled:opacity-50 transition-colors cursor-pointer flex-shrink-0",children:[t.inspecting?e(m,{size:13,className:"animate-spin"}):e(F,{size:13}),e("span",{children:t.inspecting?"Cloning…":"Inspect"})]})]})}),e("p",{className:"text-[11px] text-ink/50 leading-relaxed",children:"Kabmo clones the repository into a temporary directory, reads every SKILL.md, and removes the clone when it is done. Nothing is written to your skills until you press Install."})]}),t.error?e("div",{className:"flex items-start gap-2 rounded-lg border border-error/40 bg-error/5 px-3 py-2 text-[11px] text-error",children:[e(B,{size:13,className:"mt-0.5 flex-shrink-0"}),e("span",{className:"leading-relaxed",children:t.error})]}):null,b.length>0?e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between",children:[e("span",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:[t.repo," · ",b.length," SKILL.md"]}),e("div",{className:"flex items-center gap-2 text-[11px]",children:[e("button",{type:"button",onClick:()=>t.toggleAll(!0),className:"text-ink/60 hover:text-ink cursor-pointer",children:"Select all"}),e("span",{className:"text-ink/25",children:"·"}),e("button",{type:"button",onClick:()=>t.toggleAll(!1),className:"text-ink/60 hover:text-ink cursor-pointer",children:"None"})]})]}),e("div",{className:"rounded-xl border border-ink/15 divide-y divide-ink/10 max-h-72 overflow-auto scrollbar-overlay-container",children:b.map((v)=>{let k=p.includes(v.path),x=!v.loadable?"no description — omp will not load it":v.installed?"already installed":"";return e("label",{className:`flex items-start gap-2.5 p-3 transition-colors ${x?"opacity-55":"cursor-pointer hover:bg-ink/[0.03]"}`,children:[e("input",{type:"checkbox",checked:k,disabled:Boolean(x),onChange:()=>t.toggle(v.path),className:`${ge} mt-0.5 accent-ink cursor-pointer disabled:cursor-not-allowed`}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-2 min-w-0",children:[e("span",{className:"text-xs font-semibold font-mono text-ink truncate",children:v.name}),x?e("span",{className:"text-[10px] text-ink/50 flex-shrink-0",children:x}):null]}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed line-clamp-2",children:v.description||"No description in the frontmatter."}),e("div",{className:"text-[10px] text-ink/40 font-mono truncate mt-0.5",children:[v.path,"/SKILL.md"]})]})]},v.path)})}),t.notes.length>0?e("ul",{className:"text-[11px] text-ink/55 space-y-0.5 list-disc list-inside",children:t.notes.map((v)=>e("li",{children:v},v))}):null,e("div",{className:"rounded-lg border border-ink/15 p-3 space-y-2.5",children:[e("p",{className:"text-[11px] text-ink/55 leading-relaxed",children:["Installs into ",e("span",{className:"font-mono text-ink/75",children:"~/.omp/agent/skills"})," (or the selected workspace's ",e("span",{className:"font-mono text-ink/75",children:".omp/skills"}),"), so omp loads the skill and the Skills pane can edit it."]}),e("label",{className:"flex items-start gap-2 cursor-pointer select-none",children:[e("input",{type:"checkbox",checked:g,onChange:(v)=>t.setOverwrite(v.currentTarget.checked),className:`${ge} mt-0.5 accent-ink cursor-pointer`}),e("span",{className:"text-[11px] text-ink/70 leading-relaxed",children:["Replace skills that already have the same name",e("span",{className:"block text-[10px] text-ink/45",children:"Off by default: an existing directory may hold your own edits."})]})]})]})]}):null,t.result?e("div",{className:"rounded-lg border border-ink/20 bg-ink/[0.03] p-3 space-y-1.5",children:[e("div",{className:"flex items-center gap-1.5 text-xs font-semibold text-ink",children:[e(f,{size:13}),e("span",{children:[t.result.installed.length," installed",t.result.skipped.length>0?` · ${t.result.skipped.length} skipped`:""]})]}),t.result.installed.length>0?e("div",{className:"text-[11px] text-ink/70 font-mono",children:t.result.installed.join(", ")}):null,e("ul",{className:"text-[11px] text-ink/60 space-y-0.5",children:t.result.skipped.map((v)=>e("li",{children:[e("span",{className:"font-mono text-ink/80",children:v.name})," — ",v.reason]},`${v.name}-${v.reason}`))})]}):null,b.length>0?e("div",{className:"flex items-center justify-between pt-1",children:[e("span",{className:"text-[11px] text-ink/55",children:[p.length," of ",h.length," installable selected"]}),e("button",{type:"button",onClick:async()=>{let v=await t.install();if(v&&v.installed.length>0)r()},disabled:p.length===0||t.installing,className:"flex items-center gap-1.5 px-3.5 py-2 rounded-lg bg-ink text-paper text-xs font-medium hover:bg-ink/90 disabled:opacity-40 transition-colors cursor-pointer",children:[t.installing?e(m,{size:13,className:"animate-spin"}):null,e("span",{children:t.installing?"Installing…":`Install ${p.length} skill${p.length===1?"":"s"}`})]})]}):null]})}var Bu=[{id:"browse",label:"Browse"},{id:"git",label:"From Git"},{id:"sources",label:"Sources"}],_u=300;function Ql({initialTab:t="browse"}={}){let r=jl(),l=Hl(),[c,b]=n(t),[p,g]=n(""),[h,v]=n(!1),[k,x]=n(!1),[A,N]=n(null),[M,P]=n(null),[E,S]=n(!1),R=o(void 0),T=new Set(r.userSkills.map((j)=>dn(j.source)).filter((j)=>j!==null)),{pushToast:O}=Ve();i(()=>()=>clearTimeout(R.current),[]);let L=(j)=>{if(g(j),clearTimeout(R.current),!j.trim()){r.search("").catch(console.error);return}R.current=setTimeout(()=>{v(!0),r.search(j).catch((H)=>O(H instanceof Error?H.message:String(H),"error")).finally(()=>v(!1))},_u)},_=async(j)=>{let H=T.has(j.repoTag);N(j.id);try{let X=await fetch("/api/settings/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"install_toggle",skill:j,install:!H})}),oe=await X.json();if(!X.ok||oe?.error)throw Error(oe?.error||`Request failed (${X.status})`);if(Array.isArray(oe?.skills))r.setUserSkills(oe.skills);yi("command"),O(H?`Uninstalled "${j.name}"`:`Installed "${j.name}"`,"success")}catch(X){O(X instanceof Error?X.message:String(X),"error")}finally{N(null)}},K=()=>{x(!0),(p.trim()?r.search(p):r.reload()).then(()=>O("Catalog refreshed","success")).catch((H)=>O(H instanceof Error?H.message:String(H),"error")).finally(()=>x(!1))},V=(j)=>{P(j),r.scanSource(j).then(({skills:H})=>O(`Found ${H.filter((X)=>X.loadable).length} loadable skill(s)`,"success")).catch((H)=>O(H instanceof Error?H.message:String(H),"error")).finally(()=>P(null))},z=()=>{b("git"),l.reset()},q=(j)=>{S(!0),r.removeSource(j).then(()=>O("Source removed","success")).catch((H)=>O(H instanceof Error?H.message:String(H),"error")).finally(()=>S(!1))},G=(j)=>{b("git"),l.inspect(j)};return e("div",{className:"flex-1 flex flex-col h-full w-full overflow-hidden bg-paper text-ink",children:[e("div",{className:"flex-shrink-0 px-6 md:px-8 pt-5",children:e("div",{className:"flex items-center gap-1 border-b border-ink/10",children:Bu.map((j)=>e("button",{type:"button",onClick:()=>b(j.id),className:`px-3 py-2 -mb-px text-xs font-semibold border-b-2 transition-colors cursor-pointer ${c===j.id?"border-ink text-ink":"border-transparent text-ink/55 hover:text-ink hover:border-ink/25"}`,children:j.label},j.id))})}),e("div",{className:"flex-1 min-h-0 overflow-auto scrollbar-overlay-container px-6 md:px-8 py-5 space-y-5",children:[c==="browse"?e(d,{children:[e("div",{className:"relative",children:[h?e(m,{size:15,className:"absolute left-3 top-2.5 text-ink/40 animate-spin"}):e(F,{size:15,className:"absolute left-3 top-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",value:p,onInput:(j)=>L(j.currentTarget.value),placeholder:"Search the Skillshare registry…",className:"w-full pl-9 pr-9 py-2 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-xs text-ink transition-colors"}),p?e("button",{type:"button",onClick:()=>L(""),"aria-label":"Clear the search",className:"absolute right-2 top-1.5 p-1 rounded-md text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:e(y,{size:13})}):null]}),e("div",{className:"flex items-center justify-between",children:[e("span",{className:"text-[11px] text-ink/55",children:p.trim()?`${r.catalogSkills.length} skill(s) for “${p.trim()}”`:"Search the registry to list skills"}),e("button",{type:"button",onClick:K,disabled:k,title:"Re-read the catalog",className:"flex items-center gap-1 p-1 rounded-md text-ink/50 hover:text-ink hover:bg-ink/5 disabled:opacity-50 transition-colors cursor-pointer",children:[e(C,{size:13,className:k?"animate-spin":""}),e("span",{className:"text-[11px]",children:"Refresh"})]})]}),e("div",{className:"space-y-3",children:r.catalogSkills.length===0?e("div",{className:"text-center py-10 border border-dashed border-ink/15 rounded-xl space-y-1",children:[e("p",{className:"text-xs text-ink/60",children:p.trim()?"No skills match that query.":"No skills listed yet."}),e("p",{className:"text-[11px] text-ink/45",children:[p.trim()?"Try another query, or install straight from a repository in ":"Type a query to search the Skillshare registry, or install from a repository in ",e("span",{className:"font-semibold",children:"From Git"}),"."]})]}):r.catalogSkills.map((j)=>e(Gl,{skill:j,installed:T.has(j.repoTag),busy:A===j.id,onInstallToggle:_},j.id))})]}):null,c==="git"?e(Jl,{controller:l,onInstalled:()=>{r.reload().catch(console.error),yi("command"),O("Skills installed — omp sessions were reloaded","success")}}):null,c==="sources"?e(ql,{sources:r.sources,onScan:V,onImportFrom:G,onRemove:q,onAdd:z,scanningId:M,busy:E||M!==null}):null]})]})}function ed({category:t}){return e("div",{className:"space-y-6 text-ink flex flex-col items-center justify-center py-16",children:[e("div",{className:"text-sm font-semibold capitalize",children:[t.replace("-"," ")," Settings"]}),e("div",{className:"text-xs text-ink/60 text-center max-w-sm mt-2",children:"This settings category is currently under construction and will be available soon."})]})}var od={source:"@oh-my-pi/pi-coding-agent 10 tabs / 615 settings",tabs:[{id:"appearance",label:"Appearance",groups:["Theme","Composer","Status Line","Images","Display"]},{id:"model",label:"Model",groups:["Prompt","Prewalk","Vision","Thinking","Sampling","Retry & Fallback","Advisor"]},{id:"interaction",label:"Interaction",groups:["Startup & Updates","Git","Input","Magic Keywords","Notifications","Power","Agent","Approvals","Skills","Speech","Collab","Stream"]},{id:"context",label:"Context",groups:["General","Compaction","Experimental","Rules (TTSR)"]},{id:"memory",label:"Memory",groups:["General","Sharpshooter","Auto-Learn","Mnemopi","Hindsight"]},{id:"files",label:"Files",groups:["Editing","Reading","Read Summaries","LSP"]},{id:"shell",label:"Shell",groups:["Bash","Eval & Runtimes"]},{id:"tools",label:"Tools",groups:["Output Limits","Available Tools","Todos","Grep & Browser","Find","Computer","Execution","GitHub","Discovery & MCP","Developer","Extensions","IDA Pro"]},{id:"tasks",label:"Tasks",groups:["Isolation","Subagents","Modes","Commands & Skills"]},{id:"providers",label:"Providers",groups:["Services","Fireworks","Tiny Model","Protocol","Timeouts","Privacy"]}],entries:{modelRoleStorage:{type:"enum",default:"global",values:["global","project"],ui:{tab:"model",group:"Prompt",label:"Model Role Storage",description:"Where model selector role assignments are saved",options:[{value:"global",label:"Global",description:"Save role models in the active profile config (current behavior)"},{value:"project",label:"Per-project",description:"Save project role models in .omp/config.yml; missing project roles use global defaults"}]}},autoResume:{type:"boolean",default:!1,ui:{tab:"interaction",group:"Startup & Updates",label:"Auto Resume",description:"Automatically resume the most recent session in the current directory. If its model cannot be restored and model fallback is disabled, interactive startup warns and starts a new session without the saved history"}},"git.enabled":{type:"boolean",default:!0,ui:{tab:"interaction",group:"Git",label:"Enable Git Integration",description:"Show git branch, status, and PR information in the TUI and watch repository metadata."}},"theme.dark":{type:"string",default:"titanium",ui:{tab:"appearance",group:"Theme",label:"Dark Theme",description:"Theme used when the terminal has a dark background",options:"runtime"}},"theme.light":{type:"string",default:"light",ui:{tab:"appearance",group:"Theme",label:"Light Theme",description:"Theme used when the terminal has a light background",options:"runtime"}},symbolPreset:{type:"enum",default:"unicode",values:["unicode","nerd","ascii"],ui:{tab:"appearance",group:"Theme",label:"Symbol Preset",description:"Glyph set for icons and symbols (Unicode, Nerd Font, or ASCII)",options:[{value:"unicode",label:"Unicode",description:"Standard symbols (default)"},{value:"nerd",label:"Nerd Font",description:"Requires a Nerd Font, or a Glyph Protocol terminal (icons ship in-band)"},{value:"ascii",label:"ASCII",description:"Maximum compatibility"}]}},colorBlindMode:{type:"boolean",default:!1,ui:{tab:"appearance",group:"Theme",label:"Color-Blind Mode",description:"Use blue instead of green for diff additions"}},"composer.shape":{type:"string",default:"band",ui:{tab:"appearance",group:"Composer",label:"Composer Shape",description:"Visual layout of the input editor and status line",options:"runtime"}},"composer.tokenRate":{type:"boolean",default:!1,ui:{tab:"appearance",group:"Composer",label:"Generation Rate",description:"Show a live generation tok/s readout: on the working row next to the session title, or in the native composer bar right after the thinking level, where the last reading stays between turns. Estimated from streamed deltas and corrected by the provider's billed output count as each message completes."}},"statusLine.preset":{type:"enum",default:"default",values:["default","minimal","compact","full","nerd","ascii","custom"],ui:{tab:"appearance",group:"Status Line",label:"Status Line Preset",description:"Pre-built status line configurations",options:[{value:"default",label:"Default",description:"Model, path, git, context, tokens, cost"},{value:"minimal",label:"Minimal",description:"Path and git only"},{value:"compact",label:"Compact",description:"Model, git, cost, context"},{value:"full",label:"Full",description:"All segments including time"},{value:"nerd",label:"Nerd",description:"Maximum info with Nerd Font icons"},{value:"ascii",label:"ASCII",description:"No special characters"},{value:"custom",label:"Custom",description:"User-defined segments"}]}},"statusLine.separator":{type:"enum",default:"powerline-thin",values:["powerline","powerline-thin","slash","pipe","block","none","ascii"],ui:{tab:"appearance",group:"Status Line",label:"Status Line Separator",description:"Style of separators between segments",options:[{value:"powerline",label:"Powerline",description:"Solid arrows (Nerd Font)"},{value:"powerline-thin",label:"Thin chevron",description:"Thin arrows (Nerd Font)"},{value:"slash",label:"Slash",description:"Forward slashes"},{value:"pipe",label:"Pipe",description:"Vertical pipes"},{value:"block",label:"Block",description:"Solid blocks"},{value:"none",label:"None",description:"Space only"},{value:"ascii",label:"ASCII",description:"Greater-than signs"}]}},"statusLine.contextLine":{type:"enum",default:"embedded",values:["off","percentage","annotated","embedded"],ui:{tab:"appearance",group:"Status Line",label:"Context-Reactive Line",description:"How the line between the left and right segments reflects context usage (box composer only)",options:[{value:"off",label:"Off",description:"Solid accent line, no context feedback"},{value:"percentage",label:"Percentage",description:"Used portion in accent color, remainder dimmed"},{value:"annotated",label:"Annotated",description:"Percentage plus ticks at the speculative and auto-compaction boundaries"},{value:"embedded",label:"Embedded",description:"Annotated line with the context percentage and window embedded in the gauge"}]}},"statusLine.sessionAccent":{type:"boolean",default:!0,ui:{tab:"appearance",group:"Status Line",label:"Session Accent",description:"Use the session name color for the editor border and status line gap"}},"statusLine.transparent":{type:"boolean",default:!1,ui:{tab:"appearance",group:"Status Line",label:"Transparent Status Line",description:"Use the terminal's default background for the status line instead of the theme's `statusLineBg`. Powerline end caps are dropped because they need a contrasting fill to bridge into the surrounding terminal."}},"statusLine.compactThinkingLevel":{type:"boolean",default:!0,ui:{tab:"appearance",group:"Status Line",label:"Compact Thinking Level",description:"Show the thinking level as a single icon on the model name instead of a separate ` · <level>` suffix; in Tern's composer, as the model chip's icon instead of a separate chip (click the icon to cycle it)."}},"statusLine.showHookStatus":{type:"boolean",default:!0,ui:{tab:"appearance",group:"Status Line",label:"Show Hook Status",description:"Display hook status messages below the status line"}},"terminal.showImages":{type:"boolean",default:!0,ui:{tab:"appearance",group:"Images",label:"Show Inline Images",description:"Render images inline in the terminal",condition:"hasImageProtocol"}},"images.autoResize":{type:"boolean",default:!0,ui:{tab:"appearance",group:"Images",label:"Auto-Resize Images",description:"Resize large images to 2000x2000 max for better model compatibility"}},"images.blockImages":{type:"boolean",default:!1,ui:{tab:"appearance",group:"Images",label:"Block Images",description:"Prevent images from being sent to LLM providers"}},"tui.resizeScrollback":{type:"enum",default:"rebuild",values:["append","rebuild","preserve"],ui:{tab:"appearance",group:"Display",label:"Resize Scrollback",description:"How a settled terminal resize refreshes transcript rows retained in terminal scrollback",options:[{value:"append",label:"Append",description:"Replay the transcript at the new width below retained history"},{value:"rebuild",label:"Rebuild",description:"Erase all terminal scrollback, then replay one current-width transcript"},{value:"preserve",label:"Preserve",description:"Repaint only the viewport and keep history wrapped at its old width"}]}},"tui.completeScrollback":{type:"boolean",default:!1,ui:{tab:"appearance",group:"Display",label:"Complete Scrollback",description:"Send transcript rows pushed off screen by a growing HUD or dialog straight to scrollback; when it shrinks, blank rows sit between the transcript and the input until new output fills them"}},"terminal.showProgress":{type:"boolean",default:!1,ui:{tab:"appearance",group:"Display",label:"Native Terminal Progress",description:"Emit OSC 9;4 indeterminate progress while the agent or context maintenance is running (always on in Tern)"}},"terminal.programStatus":{type:"boolean",default:!0,ui:{tab:"appearance",group:"Display",label:"Program Status (OSC 7501)",description:"Report whether the agent is working, waiting on you, done, or failed over OSC 7501, for terminal tab indicators and agent inboxes"}},"tui.textSizing":{type:"boolean",default:!1,ui:{tab:"appearance",group:"Display",label:"Large Headings (Kitty)",description:"Render Markdown H1 headings at 2x scale using Kitty's OSC 66 text-sizing protocol. Only takes effect on Kitty terminals; ignored everywhere else. Off by default."}},"tui.colorfulMarkdown":{type:"boolean",default:!0,ui:{tab:"appearance",group:"Display",label:"Colorful Markdown",description:"Color headings by level, bold and italic text, inline code, and table headers from the theme's ANSI palette. Off uses one heading color and plain bold/italic."}},"tui.renderMermaid":{type:"boolean",default:!0,ui:{tab:"appearance",group:"Display",label:"Render Mermaid Diagrams",description:"Render Mermaid fenced code blocks as ASCII diagrams"}},"tui.renderSvg":{type:"boolean",default:!0,ui:{tab:"appearance",group:"Display",label:"Render SVG Figures",description:"Invite the agent to draw diagrams and charts as SVG, rendered inline as images on terminals that show graphics"}},"tui.autoGraph":{type:"enum",default:"auto",values:["auto","smart","always","off"],ui:{tab:"appearance",group:"Display",label:"Auto-Graph Tables",description:"Draw a chart under numeric tables in the agent's answers, in your theme's colors, on terminals that show graphics",options:[{value:"auto",label:"Auto",description:"Smart when the judge role resolves to a native TypeSafe jev model, else Always"},{value:"smart",label:"Smart",description:"The judge model refines each chart: kind, columns, row names and grouping, scales, which way is better, and its title"},{value:"always",label:"Always",description:"Chart every table that reads as numeric, using the built-in best guess"},{value:"off",label:"Off",description:"Leave tables as tables"}]}},"tui.reactions":{type:"boolean",default:!0,ui:{tab:"appearance",group:"Display",label:"Agent Reactions",description:"Invite the agent to react to your message with an emoji badge on its bubble"}},"tui.codexResetFireworks":{type:"boolean",default:!1,ui:{tab:"appearance",group:"Display",label:"Codex Reset Fireworks",description:"Celebrate unscheduled Codex weekly usage resets and newly banked saved resets with a top-third fireworks overlay that remains until Esc"}},"tui.titleState":{type:"boolean",default:!0,ui:{tab:"appearance",group:"Display",label:"Terminal Title Run State",description:"Show the agent run state in the terminal title's separator — an animated spinner while working (a static ':' under WSL), '>' when it's your turn, '!' when the agent is waiting on you"}},"tui.titleSpinner":{type:"enum",default:"braille",values:["braille","pulse","dots","line"],ui:{tab:"appearance",group:"Display",label:"Terminal Title Spinner",description:"Glyph set for the working-state spinner in the terminal title — braille sweep, filling moon, single-dot cycle, or ASCII-safe line",options:[{value:"braille",label:"Braille",description:"Classic ⠋⠙⠹ sweep (default)"},{value:"pulse",label:"Pulse",description:"Moon filling ○◑● then emptying"},{value:"dots",label:"Dots",description:"Single braille dots cycling"},{value:"line",label:"Line",description:"ASCII - \\ | / for fonts without braille coverage"}]}},"tui.spinnerInterval":{type:"number",ui:{tab:"appearance",group:"Display",label:"Spinner Interval (ms)",description:"Milliseconds between frames of every spinner, the terminal title included; 0 shows static glyphs. Unset follows Motion",options:[{value:"0",label:"Static",description:"No animation"},{value:"80",label:"80 ms",description:"12.5 frames/s"},{value:"250",label:"250 ms",description:"4 frames/s"},{value:"1000",label:"1 s",description:"1 frame/s"}]}},"tui.maxFps":{type:"number",default:30,ui:{tab:"appearance",group:"Display",label:"Max Frames Per Second",description:"Ceiling on how often the TUI repaints, streaming text included. Keystroke echo keeps 30 fps, so the pane you type in stays responsive",options:[{value:"30",label:"30 fps",description:"Default"},{value:"15",label:"15 fps"},{value:"4",label:"4 fps",description:"Quiet, for many panes"},{value:"1",label:"1 fps",description:"Minimum"}]}},"tui.hyperlinks":{type:"enum",default:"auto",values:["off","auto","always"],ui:{tab:"appearance",group:"Display",label:"Terminal Hyperlinks",description:"Wrap paths and URLs in OSC 8 hyperlinks for terminal-native click-to-open (auto: detect support; off: never; always: unconditional)"}},"tui.mouse":{type:"boolean",default:!1,ui:{tab:"appearance",group:"Display",label:"Mouse Click-to-Focus",description:"Capture mouse clicks in the main session so live subagent cards and HUD rows focus on click, with a hover highlight on the target, and clicks on extension-owned links reach their extension (the link-hint key picks them without the mouse). Native text selection becomes Shift+drag while on, and mouse capture stops wheel scrolling — the terminal reports wheel ticks to omp instead — so scroll with the terminal's keyboard scrollback keys, or turn this off"}},"tui.tight":{type:"boolean",default:!1,ui:{tab:"appearance",group:"Display",label:"Tight Layout",description:"Remove the 1-character horizontal padding from the left and right of the terminal output"}},"display.shimmer":{type:"enum",default:"classic",values:["classic","kitt","disabled"],ui:{tab:"appearance",group:"Display",label:"Shimmer",description:"Animation style for working/loading messages; off under reduced or no Motion",options:[{value:"classic",label:"Classic",description:"Soft cosine wave sweeping across the text"},{value:"kitt",label:"KITT Scanner",description:"Knight Rider 1982 red light bouncing left-right"},{value:"disabled",label:"Disabled",description:"No animation; static muted text"}]}},"tui.motion":{type:"enum",default:"full",values:["full","reduced","none"],ui:{tab:"appearance",group:"Display",label:"Motion",description:"One switch over spinners, shimmer, and decorative blink/fade. Streaming text is unaffected (see Max Frames Per Second). A spinner interval you set still wins",options:[{value:"full",label:"Full",description:"Every animation at its own setting (default)"},{value:"reduced",label:"Reduced",description:"Spinners at 250 ms, no shimmer, no blink/fade"},{value:"none",label:"None",description:"Static spinners and title, no shimmer, no blink/fade"}]}},"display.pinnedAgents":{type:"enum",default:"collapsed",values:["off","collapsed","full"],ui:{tab:"appearance",group:"Display",label:"Pinned Agents",description:"Pinned live-agent jump list above the editor (off hides it; collapsed shows a few rows with an expander; full lists all)",options:[{value:"off",label:"Off",description:"Hide the pinned jump list"},{value:"collapsed",label:"Collapsed",description:"Show a few rows with an expander"},{value:"full",label:"Full",description:"Always list every live agent"}]}},"display.subagentLivePreview":{type:"boolean",default:!1,ui:{tab:"appearance",group:"Display",label:"Subagent Live Preview",description:"Show each pinned subagent's current (or most recent) tool call beneath its row"}},"display.smoothStreaming":{type:"boolean",default:!0,ui:{tab:"appearance",group:"Display",label:"Smooth Streaming",description:"Reveal assistant text and streamed tool input smoothly while chunks arrive (Tern types assistant text out itself)"}},"display.hideToolActivity":{type:"boolean",default:!1,ui:{tab:"appearance",group:"Display",label:"Hide Tool Activity",description:"Hide model-initiated tool calls and results from the transcript"}},"display.showTokenUsage":{type:"boolean",default:!1,ui:{tab:"appearance",group:"Display",label:"Show Token Usage",description:"Show per-turn token usage on assistant messages"}},"display.showTurnTime":{type:"boolean",default:!1,ui:{tab:"appearance",group:"Display",label:"Show Turn Time",description:"Show the total prompt-to-yield time (including tool calls) on assistant message usage rows"}},"display.cacheMissMarker":{type:"boolean",default:!1,ui:{tab:"appearance",group:"Display",label:"Cache Miss Marker",description:"Show a divider after an assistant turn whose request lost (missed) the prompt cache"}},"display.shellVisualization":{type:"boolean",default:!0,ui:{tab:"appearance",group:"Display",label:"Shell Visualization",description:"Show bash commands as an interactive execution visualization instead of plain shell commands"}},"display.advisorCollapsedLines":{type:"number",default:0,ui:{tab:"appearance",group:"Display",label:"Advisor Collapsed Lines",description:"Maximum note lines a collapsed advisor card shows below its header (0 keeps the full preview; expand with the tool-output toggle)",options:[{value:"0",label:"No limit",description:"Default."},{value:"1",label:"1 line"},{value:"2",label:"2 lines"},{value:"3",label:"3 lines"},{value:"5",label:"5 lines"}]}},"display.collapseCompacted":{type:"boolean",default:!0,ui:{tab:"appearance",group:"Display",label:"Collapse Compacted History",description:"Collapse pre-compaction history behind the summary divider on the live transcript; disable to keep the full transcript inline with dividers at each compaction point"}},showHardwareCursor:{type:"boolean",default:!0,ui:{tab:"appearance",group:"Display",label:"Show Hardware Cursor",description:"Show terminal cursor for IME support"}},"tui.imeSafeCursor":{type:"boolean",default:!1,ui:{tab:"appearance",group:"Display",label:"IME-Safe Prompt Layout",description:"Move the prompt's bottom border to a separate row so macOS IME preedit cannot displace it"}},steeringMode:{type:"enum",default:"one-at-a-time",values:["all","one-at-a-time"],ui:{tab:"interaction",group:"Input",label:"Steering Mode",description:"How to process queued messages while agent is working"}},followUpMode:{type:"enum",default:"one-at-a-time",values:["all","one-at-a-time"],ui:{tab:"interaction",group:"Input",label:"Follow-Up Mode",description:"How to drain follow-up messages after a turn completes"}},interruptMode:{type:"enum",default:"immediate",values:["immediate","wait"],ui:{tab:"interaction",group:"Input",label:"Interrupt Mode",description:"When steering messages interrupt tool execution"}},"btw.inject":{type:"boolean",default:!1,ui:{tab:"interaction",group:"Input",label:"/btw Steering Inject",description:"When you ask /btw for a steering prompt, it drafts one in <inject> tags, highlighted in the answer; Alt+I (app.btw.inject) sends it to the main session"}},"tui.vimMode":{type:"boolean",default:!1,ui:{tab:"interaction",group:"Input",label:"Vim Editing Mode",description:"Modal prompt editing. Esc leaves Insert mode; Normal mode has hjkl, 0, $, ^, w, b, e, gg, G, counts, x/D/C, dd/yy, p and u; operators take motions or text objects (diw, ca(, dap); v/V start a Visual selection that y copies and d deletes"}},"tui.vimModeDisplay":{type:"enum",default:"text",values:["text","icon","none"],ui:{tab:"interaction",group:"Input",label:"Vim Mode Indicator",description:"How the current Vim mode appears in the status line",condition:"vimModeEnabled",options:[{value:"text",label:"Text",description:"Full mode name — NORMAL, INSERT, VISUAL, V-LINE, REPLACE"},{value:"icon",label:"Icon",description:"Single compact glyph per mode"},{value:"none",label:"Hidden",description:"Do not show the mode in the status line"}]}},"loop.mode":{type:"enum",default:"prompt",values:["prompt","compact","reset"],ui:{tab:"interaction",group:"Input",label:"Loop Mode",description:"What happens between /loop iterations before re-submitting the prompt",options:[{value:"prompt",label:"Prompt",description:"Re-submit the prompt as a follow-up message (current behavior)"},{value:"compact",label:"Compact",description:"Compact the session context, then re-submit the prompt"},{value:"reset",label:"Reset",description:"Start a new session, then re-submit the prompt"}]}},"loop.conditionTimeoutMs":{type:"number",default:30000,ui:{tab:"interaction",group:"Input",label:"Loop Condition Timeout (ms)",description:"Max wait for a `/loop --while` / `--until` condition command before treating it as broken and stopping the loop. Set to 0 to wait indefinitely",options:[{value:"0",label:"Unlimited"},{value:"10000",label:"10 seconds"},{value:"30000",label:"30 seconds"},{value:"120000",label:"2 minutes"}]}},"composer.recallClearedDrafts":{type:"boolean",default:!0,ui:{tab:"interaction",group:"Input",label:"Recall Cleared Drafts",description:"Keep drafts cleared with Ctrl+C in local Up/Down history until exit; disabling affects future clears"}},doubleEscapeAction:{type:"enum",default:"rewind",values:["rewind","tree","none"],ui:{tab:"interaction",group:"Input",label:"Double-Escape Action",description:"What pressing Esc twice with an empty editor does: open the transcript rewind selector, open the session tree, or nothing"}},"input.bareExitOnEmptySession":{type:"boolean",default:!0,ui:{tab:"interaction",group:"Input",label:"Bare Exit on Empty Session",description:"Submitting exactly `exit`, `quit`, or `q` (any case) before the first message quits instead of prompting the model"}},"input.bareSlashCommands":{type:"boolean",default:!1,ui:{tab:"interaction",group:"Input",label:"Bare Slash Commands",description:"Submitting exactly a command name without the leading `/` (e.g. `model`, `compact`) runs that slash command; once the session has messages, press Enter twice to confirm"}},treeFilterMode:{type:"enum",default:"default",values:["default","no-tools","user-only","labeled-only","all"],ui:{tab:"interaction",group:"Input",label:"Session Tree Filter",description:"Default filter mode when opening the session tree"}},autocompleteMaxVisible:{type:"number",default:10,ui:{tab:"interaction",group:"Input",label:"Autocomplete Items",description:"Max visible items in autocomplete dropdown (3-20)",options:[{value:"3",label:"3 items"},{value:"5",label:"5 items"},{value:"7",label:"7 items"},{value:"10",label:"10 items"},{value:"15",label:"15 items"},{value:"20",label:"20 items"}]}},"spelling.typoDetection":{type:"boolean",default:!0,ui:{tab:"interaction",group:"Input",label:"Typo Detection (macOS)",description:"Mark misspelled prompt words with the active macOS dictionaries",condition:"macOS"}},"spelling.autocomplete":{type:"enum",default:"auto",values:["off","auto","ngram","smollm","apple"],ui:{tab:"interaction",group:"Input",label:"Word Autocomplete",description:"Show predicted word completions as inline hints: Tab accepts with a space, Right without",options:[{value:"off",label:"Off",description:"No word completion"},{value:"auto",label:"Auto",description:"N-gram (nothing to download)"},{value:"ngram",label:"N-gram",description:"Learns your vocabulary from prompt history"},{value:"smollm",label:"SmolLM",description:"Small on-device language model blended with N-gram (downloads weights on first use)"},{value:"apple",label:"Apple",description:"macOS dictionary completions"}]}},"composer.predictions":{type:"boolean",default:!1,ui:{tab:"interaction",group:"Input",label:"Composer Predictions",description:"After a completed turn, ask the active model to predict your next message and show it as ghost text in the empty composer; Tab or Right inserts it without sending. Extra usage: every completed turn sends one more billed request over the whole conversation (counted in /stats)"}},"composer.predictionAlternatives":{type:"boolean",default:!1,ui:{tab:"interaction",group:"Input",label:"Prediction Alternatives",description:"Ask for up to four distinct predictions instead of one, most likely first. The ghost text shows the first one your draft matches; after inserting one, press Tab again to pick another. The same single request returns a few more output tokens",condition:"composerPredictionsEnabled"}},"spelling.autocorrect":{type:"boolean",default:!1,ui:{tab:"interaction",group:"Input",label:"Autocorrect (macOS)",description:"Apply confident macOS spelling corrections after completed words",condition:"macOS"}},emojiAutocomplete:{type:"boolean",default:!0,ui:{tab:"interaction",group:"Input",label:"Emoji Autocomplete",description:"Suggest emojis from `:name:` shortcodes and expand text emoticons like `:D` or `:-)`"}},"paste.largeMenuThreshold":{type:"number",default:100,ui:{tab:"interaction",group:"Input",label:"Large Paste Menu",description:"When a paste reaches this many lines, offer a menu to wrap it in a code block, wrap it in XML tags, or save it to a file. 0 disables the menu (large pastes still collapse to a [Paste] marker).",options:[{value:"0",label:"Off"},{value:"100",label:"100 lines"},{value:"250",label:"250 lines"},{value:"500",label:"500 lines"},{value:"1000",label:"1000 lines"}]}},"startup.quiet":{type:"boolean",default:!1,ui:{tab:"interaction",group:"Startup & Updates",label:"Quiet Startup",description:"Skip welcome screen and startup status messages"}},"startup.showSplash":{type:"boolean",default:!1,ui:{tab:"interaction",group:"Startup & Updates",label:"Show Startup Splash",description:"Show the full animated setup splash on normal interactive startup without rerunning setup. Quiet Startup still suppresses it."}},"startup.setupWizard":{type:"boolean",default:!0,ui:{tab:"interaction",group:"Startup & Updates",label:"Setup Wizard",description:"Show newly added onboarding steps once per setup version"}},"startup.checkUpdate":{type:"boolean",default:!0,ui:{tab:"interaction",group:"Startup & Updates",label:"Check for Updates",description:"Check for omp updates on startup"}},"update.channel":{type:"enum",default:"stable",values:["stable","canary"],ui:{tab:"interaction",group:"Startup & Updates",label:"Update Channel",description:"Update channel used by omp update and the startup update check",options:[{value:"stable",label:"Stable"},{value:"canary",label:"Canary"}]}},"update.auto":{type:"boolean",default:!1,ui:{tab:"interaction",group:"Startup & Updates",label:"Auto Update",description:"Install omp updates in the background on startup; the next launch runs the new version"}},"marketplace.autoUpdate":{type:"enum",default:"notify",values:["off","notify","auto"],ui:{tab:"interaction",group:"Startup & Updates",label:"Marketplace Auto-Update",description:"Check for plugin updates on startup",options:[{value:"off",label:"Off",description:"Don't check for plugin updates"},{value:"notify",label:"Notify",description:"Check on startup and notify when updates are available"},{value:"auto",label:"Auto",description:"Check on startup and auto-install updates"}]}},"startup.changelogMode":{type:"enum",default:"summary",values:["summary","expanded","hidden"],ui:{tab:"interaction",group:"Startup & Updates",label:"Startup Changelog",description:"Choose whether update notes start as a summary, full details, or stay hidden",options:[{value:"summary",label:"Summary",description:"Show release and change counts with a /changelog hint"},{value:"expanded",label:"Expanded",description:"Show the recent release notes in full"},{value:"hidden",label:"Hidden",description:"Do not show release notes on startup"}]}},"magicKeywords.enabled":{type:"boolean",default:!0,ui:{tab:"interaction",group:"Magic Keywords",label:"Magic Keywords",description:"Enable hidden notices for standalone ultrathink, chillax, orchestrate, workflowz, jevify keywords"}},"magicKeywords.ultrathink":{type:"boolean",default:!0,ui:{tab:"interaction",group:"Magic Keywords",label:"Ultrathink Keyword",description:"Let standalone ultrathink request maximum automatic thinking and append its hidden notice"}},"magicKeywords.chillax":{type:"boolean",default:!0,ui:{tab:"interaction",group:"Magic Keywords",label:"Chillax Keyword",description:"Let standalone chillax drop thinking to the model's lowest effort (models with per-message effort, even mid-turn) and append its hidden notice"}},"magicKeywords.orchestrate":{type:"boolean",default:!0,ui:{tab:"interaction",group:"Magic Keywords",label:"Orchestrate Keyword",description:"Let standalone orchestrate append its hidden multi-agent orchestration notice"}},"magicKeywords.workflow":{type:"boolean",default:!0,ui:{tab:"interaction",group:"Magic Keywords",label:"Workflow Keyword",description:"Let standalone workflowz append its hidden eval workflow notice"}},"magicKeywords.jevify":{type:"boolean",default:!0,ui:{tab:"interaction",group:"Magic Keywords",label:"Jevify Keyword",description:"Let standalone jevify append its hidden bulk-judge classification notice"}},"completion.notify":{type:"enum",default:"on",values:["on","off"],ui:{tab:"interaction",group:"Notifications",label:"Completion Notification",description:"Notify when the agent finishes a turn"}},"error.notify":{type:"enum",default:"off",values:["on","off"],ui:{tab:"interaction",group:"Notifications",label:"Error Notification",description:"Notify when the agent stops with an error"}},"ask.timeout":{type:"number",default:0,ui:{tab:"interaction",group:"Notifications",label:"Ask Timeout",description:"Submit an ask form's current values (your preselected answers) after this many seconds (0 disables). Also bounds cfg:// approval prompts; an unanswered approval denies the write instead of auto-submitting",options:[{value:"0",label:"Disabled"},{value:"15",label:"15 seconds"},{value:"30",label:"30 seconds"},{value:"60",label:"60 seconds"},{value:"120",label:"120 seconds"}]}},"ask.notify":{type:"enum",default:"on",values:["on","off"],ui:{tab:"interaction",group:"Notifications",label:"Ask Notification",description:"Notify when the ask tool is waiting for input"}},"recap.enabled":{type:"boolean",default:!0,ui:{tab:"interaction",group:"Notifications",label:"Idle Recap",description:"Generate a brief LLM recap of where things stand after the terminal has been idle"}},"recap.idleSeconds":{type:"number",default:240,ui:{tab:"interaction",group:"Notifications",label:"Idle Recap Delay",description:"Seconds to wait while idle before showing the recap",options:[{value:"60",label:"1 minute"},{value:"120",label:"2 minutes"},{value:"240",label:"4 minutes"},{value:"300",label:"5 minutes"},{value:"600",label:"10 minutes"}]}},"session.worktreeScope":{type:"enum",default:"repo",values:["directory","repo"],ui:{tab:"interaction",group:"Startup & Updates",label:"Resume Worktree Scope",description:"Choose whether the resume picker's current folder includes sessions from other repository worktrees",options:[{value:"directory",label:"This Directory",description:"Only sessions saved for this directory"},{value:"repo",label:"Repository Worktrees",description:"Also include sessions from sibling worktrees"}]}},"power.sleepPrevention":{type:"enum",default:"idle",values:["off","idle","display","system"],ui:{tab:"interaction",group:"Power",label:"Sleep Prevention",description:"Prevent the system sleeping while the agent is running a turn; an idle session, including one waiting on background jobs, does not hold it. Each level is cumulative — it adds the flags of all lower levels.",options:[{value:"off",label:"Off",description:"Do not prevent any sleep"},{value:"idle",label:"Prevent Idle Sleep",description:"Keep the system awake while the agent is running a turn (macOS `caffeinate -i`)"},{value:"display",label:"Prevent Display Sleep",description:"Also keep the display from idle-sleeping (macOS `caffeinate -i -d`)"},{value:"system",label:"Prevent System Sleep",description:"Also block all system sleep on AC and declare the user active (macOS `caffeinate -i -d -s -u`)"}]}},"prewalk.enabled":{type:"boolean",default:!1,ui:{tab:"model",group:"Prewalk",label:"Enable Prewalk",description:"Start on the active model, then switch to a fast/cheap model (default the 'smol' role) at the first edit/write after the plan nudge's todo list exists — the strong model plans, commits the todos, and starts the implementation before handing off. Overridable per session with --prewalk / --no-prewalk."}},"prewalk.from":{type:"string",default:"@default",ui:{tab:"model",group:"Prewalk",label:"Prewalk planning model",description:"Model or role (default '@default') that /prewalk restart returns to for planning."}},"prewalk.into":{type:"string",default:"@smol",ui:{tab:"model",group:"Prewalk",label:"Prewalk target",description:"Model or role (default '@smol') that prewalk hands off to at the first edit/write: /prewalk, /prewalk restart, Enable Prewalk, and --prewalk. Auto-prewalk uses its own target."}},"prewalk.auto":{type:"enum",default:"off",values:["off","suggest","on"],ui:{tab:"model",group:"Prewalk",label:"Auto Prewalk",description:"Ask the native judge resolved through the 'judge' role whether each new top-level user task front-loads its hard reasoning. Needs a native judge; without one nothing is classified. Independent of Enable Prewalk.",options:[{value:"off",label:"Off",description:"Never classify prompts for prewalk"},{value:"suggest",label:"Suggest",description:"Classify each task and report the decision without arming prewalk"},{value:"on",label:"On",description:"For confidently front-loaded tasks, arm a handoff from the active model to the auto target; the next task starts back on the planning model"}]}},"prewalk.autoTarget":{type:"string",default:"@smol",ui:{tab:"model",group:"Prewalk",label:"Auto-prewalk target",description:"Model or role (default '@smol') auto-prewalk hands off to at the first edit/write."}},"providers.maxInFlightRequests":{type:"record",default:{},ui:{tab:"providers",group:"Services",label:"Max In-Flight Requests",description:'Maximum concurrent LLM requests per provider id (for example "openai" or "anthropic"), shared across local OMP processes with this config root. Omitted providers are unlimited.'}},"images.describeForTextModels":{type:"boolean",default:!0,ui:{tab:"model",group:"Vision",label:"Describe Images for Text Models",description:"When an image is attached to a model without vision support, save it under local:// and inject a description from a vision-capable model instead of dropping it"}},defaultThinkingLevel:{type:"enum",default:"high",values:["minimal","low","medium","high","xhigh","max","auto"],ui:{tab:"model",group:"Thinking",label:"Thinking Level",description:"Reasoning depth for thinking-capable models",options:[{value:"auto",label:"auto",description:"Auto-detect per prompt"},{value:"minimal",label:"min",description:"Very brief reasoning (~1k tokens)"},{value:"low",label:"low",description:"Light reasoning (~2k tokens)"},{value:"medium",label:"medium",description:"Moderate reasoning (~8k tokens)"},{value:"high",label:"high",description:"Deep reasoning (~16k tokens)"},{value:"xhigh",label:"xhigh",description:"Extended reasoning (~32k tokens)"},{value:"max",label:"max",description:"Maximum reasoning the model supports"}]}},hideThinkingBlock:{type:"boolean",default:!1,ui:{tab:"model",group:"Thinking",label:"Hide Thinking Blocks",description:"Hide thinking blocks in assistant responses"}},expandThinkingBlocks:{type:"boolean",default:!1,ui:{tab:"model",group:"Thinking",label:"Expand Thinking Blocks",description:"Keep finished thinking blocks expanded instead of collapsing them when the turn ends",condition:"nativeRendering"}},proseOnlyThinking:{type:"boolean",default:!0,ui:{tab:"model",group:"Thinking",label:"Prose Only Thinking",description:"Omit code blocks from thinking summaries and replace them with an ellipsis"}},omitThinking:{type:"boolean",default:!1,ui:{tab:"model",group:"Thinking",label:"Omit Thinking summaries",description:"Instruct upstream providers to completely omit thinking summaries from responses (where supported)"}},externalThinking:{type:"boolean",default:!1,ui:{tab:"model",group:"Thinking",label:"External Thinking",description:"Private scratchpad; not shown to user. Disables supported GPT, Claude, and Gemini reasoning",warning:"At your own risk: providers have flagged this request shape as abuse, up to account-level enforcement"}},"model.loopGuard.enabled":{type:"boolean",default:!0,ui:{tab:"model",group:"Thinking",label:"Loop Guard",description:"Enable automatic stream loop detection for model reasoning and prose"}},"model.loopGuard.checkAssistantContent":{type:"boolean",default:!0,ui:{tab:"model",group:"Thinking",label:"Loop Guard Scan Prose",description:"Apply loop guard to assistant prose messages in addition to thinking logs"}},"model.loopGuard.toolCallReminder":{type:"boolean",default:!0,ui:{tab:"model",group:"Thinking",label:"Loop Guard Tool-Call Reminder",description:"When a Gemini reasoning stream emits many consecutive planning headers without calling a tool, interrupt it and inject a reminder to issue a tool call (requires Loop Guard)"}},"model.toolCallLoopGuard.enabled":{type:"boolean",default:!0,ui:{tab:"model",group:"Thinking",label:"Tool-Call Loop Guard",description:"Detect consecutive identical tool calls across turns and inject a corrective steer"}},"model.toolCallLoopGuard.threshold":{type:"number",default:5,ui:{tab:"model",group:"Thinking",label:"Tool-Call Loop Threshold",description:"Consecutive identical tool calls required before the corrective steer is injected"}},"model.toolCallLoopGuard.exemptTools":{type:"array",default:["wait"],ui:{tab:"model",group:"Thinking",label:"Tool-Call Loop Exempt Tools",description:"Tool names, or xd:// device names of write dispatches (for example mcp__peers_wait), that may repeat consecutively without triggering the cross-turn loop guard"}},inlineToolDescriptors:{type:"enum",default:"auto",values:["auto","on","off"],ui:{tab:"model",group:"Prompt",label:"Inline Tool Descriptors",description:"Render full tool descriptors in the system prompt and strip top-level/nested descriptions from provider tool schemas so descriptor text is sent once. Auto enables this for Gemini models and disables it otherwise",options:[{value:"auto",label:"Auto",description:"Inline descriptors for Gemini models; keep them in tool schemas otherwise"},{value:"on",label:"On",description:"Always inline descriptors in the system prompt"},{value:"off",label:"Off",description:"Keep descriptors in provider tool schemas only"}]}},includeModelInPrompt:{type:"boolean",default:!0,ui:{tab:"model",group:"Prompt",label:"Include Model in Prompt",description:"Surface the active model identifier in the system prompt so the agent knows which model it is"}},includeWorkspaceTree:{type:"boolean",default:!1,ui:{tab:"model",group:"Prompt",label:"Include Workspace Tree",description:"Render the workspace directory tree in the system prompt. WARNING: This can bust prompt caching across sessions when files are modified."}},encourageEdits:{type:"boolean",default:!0,ui:{tab:"model",group:"Prompt",label:"Encourage Edits",description:"Require the edit tool for file edits and forbid sed/perl/python edits"}},skillful:{type:"boolean",default:!0,ui:{tab:"model",group:"Prompt",label:"List Skills in Prompt",description:"List available skills in the system prompt; disable to save context and toggle per-session with /skillful"}},personality:{type:"enum",default:"default",values:["default","friendly","pragmatic","none"],ui:{tab:"model",group:"Prompt",label:"Personality",description:"Communication style rendered into the system prompt's personality block",options:[{value:"default",label:"Default",description:"Terse, evidence-first engineer; dense, action-oriented replies"},{value:"friendly",label:"Friendly",description:"Warm, encouraging collaborator focused on momentum and morale"},{value:"pragmatic",label:"Pragmatic",description:"Direct, efficient engineer focused on clarity and rigor"},{value:"none",label:"None",description:"Omit the personality block entirely"}]}},temperature:{type:"number",default:-1,ui:{tab:"model",group:"Sampling",label:"Temperature",description:"Sampling temperature (0 = deterministic, 1 = creative, -1 = provider default)",options:[{value:"-1",label:"Default",description:"Use provider default"},{value:"0",label:"0",description:"Deterministic"},{value:"0.2",label:"0.2",description:"Focused"},{value:"0.5",label:"0.5",description:"Balanced"},{value:"0.7",label:"0.7",description:"Creative"},{value:"1",label:"1",description:"Maximum variety"}]}},topP:{type:"number",default:-1,ui:{tab:"model",group:"Sampling",label:"Top P",description:"Nucleus sampling cutoff (0-1, -1 = provider default)",options:[{value:"-1",label:"Default",description:"Use provider default"},{value:"0.1",label:"0.1",description:"Very focused"},{value:"0.3",label:"0.3",description:"Focused"},{value:"0.5",label:"0.5",description:"Balanced"},{value:"0.9",label:"0.9",description:"Broad"},{value:"1",label:"1",description:"No nucleus filtering"}]}},topK:{type:"number",default:-1,ui:{tab:"model",group:"Sampling",label:"Top K",description:"Sample from top-K tokens (-1 = provider default)",options:[{value:"-1",label:"Default",description:"Use provider default"},{value:"1",label:"1",description:"Greedy top token"},{value:"20",label:"20",description:"Focused"},{value:"40",label:"40",description:"Balanced"},{value:"100",label:"100",description:"Broad"}]}},minP:{type:"number",default:-1,ui:{tab:"model",group:"Sampling",label:"Min P",description:"Minimum probability threshold (0-1, -1 = provider default)",options:[{value:"-1",label:"Default",description:"Use provider default"},{value:"0.01",label:"0.01",description:"Very permissive"},{value:"0.05",label:"0.05",description:"Balanced"},{value:"0.1",label:"0.1",description:"Strict"}]}},presencePenalty:{type:"number",default:-1,ui:{tab:"model",group:"Sampling",label:"Presence Penalty",description:"Penalty for introducing already-present tokens (-1 = provider default)",options:[{value:"-1",label:"Default",description:"Use provider default"},{value:"0",label:"0",description:"No penalty"},{value:"0.5",label:"0.5",description:"Mild novelty"},{value:"1",label:"1",description:"Encourage novelty"},{value:"2",label:"2",description:"Strong novelty"}]}},repetitionPenalty:{type:"number",default:-1,ui:{tab:"model",group:"Sampling",label:"Repetition Penalty",description:"Penalty for repeated tokens (-1 = provider default)",options:[{value:"-1",label:"Default",description:"Use provider default"},{value:"0.8",label:"0.8",description:"Allow repetition"},{value:"1",label:"1",description:"No penalty"},{value:"1.1",label:"1.1",description:"Mild penalty"},{value:"1.2",label:"1.2",description:"Balanced"},{value:"1.5",label:"1.5",description:"Strong penalty"}]}},textVerbosity:{type:"enum",default:"low",values:["low","medium","high"],ui:{tab:"model",group:"Sampling",label:"Text Verbosity",description:"OpenAI Responses and Codex response verbosity (low, medium, or high)",options:[{value:"low",label:"Low",description:"Prefer concise responses (default)"},{value:"medium",label:"Medium",description:"Balance brevity and detail"},{value:"high",label:"High",description:"Prefer detailed responses"}]}},"tier.openai":{type:"enum",default:"none",values:["none","auto","default","flex","scale","priority","ultrafast"],ui:{tab:"model",group:"Sampling",label:"Service Tier — OpenAI",description:"Processing tier for OpenAI / OpenAI-Codex requests, and OpenAI-family models routed via OpenRouter (none = omit). Sent as `service_tier`.",options:[{value:"none",label:"None",description:"Omit service_tier (standard processing)"},{value:"auto",label:"Auto",description:"Provider default tier selection"},{value:"default",label:"Default",description:"Standard priority processing"},{value:"flex",label:"Flex",description:"Lower cost, higher latency when available"},{value:"scale",label:"Scale",description:"Scale Tier credits when available"},{value:"priority",label:"Priority",description:"Faster, higher cost (premium request)"},{value:"ultrafast",label:"Ultrafast",description:"Lowest-latency serving; OpenAI API preview access, or Codex and relay models that advertise it"}]}},"tier.anthropic":{type:"enum",default:"none",values:["none","priority"],ui:{tab:"model",group:"Sampling",label:"Service Tier — Anthropic",description:'Processing tier for Claude requests. `priority` realizes fast mode (`speed: "fast"`) on supported direct Anthropic models; ignored on Bedrock/Vertex Claude and via OpenRouter.',options:[{value:"none",label:"None",description:"Standard processing"},{value:"priority",label:"Priority",description:'Fast mode (`speed: "fast"`) on supported direct Claude models; ignored on Bedrock/Vertex'}]}},"tier.google":{type:"enum",default:"none",values:["none","flex","priority"],ui:{tab:"model",group:"Sampling",label:"Service Tier — Google",description:"Processing tier for Gemini (Google AI Studio + Vertex) requests, and Google-family models routed via OpenRouter (none = omit). Sent as the top-level `serviceTier` field.",options:[{value:"none",label:"None",description:"Standard processing"},{value:"flex",label:"Flex",description:"Lower cost, higher latency (Gemini API + Vertex)"},{value:"priority",label:"Priority",description:"Faster, higher reliability (Gemini API + Vertex)"}]}},"tier.subagent":{type:"enum",default:"inherit",values:["inherit","none","auto","default","flex","scale","priority","ultrafast"],ui:{tab:"model",group:"Sampling",label:"Service Tier — Subagent",description:"Service Tier for spawned task/eval subagents. Inherit = match the main agent's live per-family tiers (tracks /fast); pick a value to apply it to whichever family the subagent's model belongs to.",options:[{value:"inherit",label:"Inherit",description:"Match the main agent's live per-family tiers"},{value:"none",label:"None",description:"Standard processing"},{value:"auto",label:"Auto",description:"Provider default tier selection (OpenAI family)"},{value:"default",label:"Default",description:"Standard priority processing (OpenAI family)"},{value:"flex",label:"Flex",description:"Flexible capacity tier (OpenAI/Google families)"},{value:"scale",label:"Scale",description:"Scale Tier credits (OpenAI family)"},{value:"priority",label:"Priority",description:"Priority on every supported family of the spawned model"},{value:"ultrafast",label:"Ultrafast",description:"Ultrafast serving (OpenAI family, where available)"}]}},"tier.advisor":{type:"enum",default:"none",values:["inherit","none","auto","default","flex","scale","priority","ultrafast"],ui:{tab:"model",group:"Sampling",label:"Service Tier — Advisor",description:"Service Tier for the advisor model. None = standard processing; Inherit = match the main agent's live per-family tiers; pick a value to apply it to the advisor model's family.",options:[{value:"inherit",label:"Inherit",description:"Match the main agent's live per-family tiers"},{value:"none",label:"None",description:"Standard processing"},{value:"auto",label:"Auto",description:"Provider default tier selection (OpenAI family)"},{value:"default",label:"Default",description:"Standard priority processing (OpenAI family)"},{value:"flex",label:"Flex",description:"Flexible capacity tier (OpenAI/Google families)"},{value:"scale",label:"Scale",description:"Scale Tier credits (OpenAI family)"},{value:"priority",label:"Priority",description:"Priority on every supported family of the spawned model"},{value:"ultrafast",label:"Ultrafast",description:"Ultrafast serving (OpenAI family, where available)"}],condition:"advisorEnabled"}},"retry.maxRetries":{type:"number",default:10,ui:{tab:"model",group:"Retry & Fallback",label:"Retry Attempts",description:"Maximum retry attempts on API errors",options:[{value:"1",label:"1 retry"},{value:"2",label:"2 retries"},{value:"3",label:"3 retries"},{value:"5",label:"5 retries"},{value:"10",label:"10 retries"}]}},"retry.maxDelayMs":{type:"number",default:300000,ui:{tab:"model",group:"Retry & Fallback",label:"Max Retry Delay",description:"Maximum wait between retries, in ms. When the provider asks us to wait longer than this and no credential or model fallback succeeds, the request fails fast instead of sleeping (e.g. 3-hour Anthropic rate-limit windows). 0 disables the ceiling — to let the session auto-resume through provider-stated quota resets."}},"retry.waitForUsageReset":{type:"boolean",default:!1,ui:{tab:"model",group:"Retry & Fallback",label:"Wait For Usage Reset",description:"When a provider reports usage-limit exhaustion with a reset time (5-hour or weekly quota windows on any provider), sleep until the reset instead of failing fast past retry.maxDelayMs. Waits are abortable (Esc) but also hold subagents, so leave off for unattended runs."}},"retry.modelFallback":{type:"boolean",default:!0,ui:{tab:"model",group:"Retry & Fallback",label:"Retry Model Fallback",description:"Allow retry recovery to switch to models in retry.fallbackChains after provider errors. Independent of Auto-Promote Context"}},"retry.fallbackOn":{type:"enum",default:"any",values:["any","usage-limit","except-usage-limit"],ui:{tab:"model",group:"Retry & Fallback",label:"Fallback Trigger",description:"Which failed requests may switch to a configured fallback model",options:[{value:"any",label:"Any error",description:"Every provider error may switch models"},{value:"usage-limit",label:"Usage limits only",description:"Switch only on a usage limit; retry other errors on the same model, then surface them"},{value:"except-usage-limit",label:"All but usage limits",description:"Wait out or surface a usage limit; switch on other errors"}]}},"retry.rateLimitWalksChain":{type:"boolean",default:!1,ui:{tab:"model",group:"Retry & Fallback",label:"Rate Limit Walks Chain",description:"On a rate limit, do not hold the retry.fallbackChains walk for a turn whose thinking is signed by the failing model. Off (the default), such a turn keeps retrying the rate-limited model until retry.maxRetries is spent before the chain is reached."}},"retry.usageAwareFallback":{type:"boolean",default:!1,ui:{tab:"model",group:"Retry & Fallback",label:"Usage-Aware Fallback",description:"Use reliable coding-plan quota reports to prefer same-provider accounts, then configured fallback models, before a hard usage limit. Ordinary configured API keys are excluded."}},"retry.usageReservePct":{type:"number",default:10,ui:{tab:"model",group:"Retry & Fallback",label:"Reserve Margin",description:"Treat a coding-plan model as near its limit below this remaining percentage. Unknown or unmapped usage keeps the primary model.",condition:"usageAwareFallbackEnabled",options:[{value:"5",label:"5%",description:"Act only when nearly exhausted"},{value:"10",label:"10%",description:"Balanced safety margin"},{value:"15",label:"15%",description:"Conservative"},{value:"20",label:"20%",description:"Early protection"},{value:"25",label:"25%",description:"Very conservative"}]}},"retry.usageReservePolicy":{type:"enum",default:"confirm",values:["confirm","auto","fail-closed"],ui:{tab:"model",group:"Retry & Fallback",label:"Reserve Policy",description:"What to do when every same-provider coding-plan account is inside the reserve margin.",condition:"usageAwareFallbackEnabled",options:[{value:"confirm",label:"Confirm interactively",description:"Keep interactive sessions on the primary until confirmed; background agents auto-fallback"},{value:"auto",label:"Auto-fallback",description:"Always select the next eligible configured fallback"},{value:"fail-closed",label:"Fail closed",description:"Do not spend reserve quota or select a fallback"}]}},"retry.fallbackChains":{type:"record",default:{},ui:{tab:"model",group:"Retry & Fallback",label:"Retry Fallback Chains",description:`JSON object mapping model roles, model selectors ("provider/model-id"), or provider wildcards ("provider/*") to ordered fallback selectors, e.g. {"default":["openai/gpt-4o-mini"],"google-antigravity/*":["google/*","google-vertex/*"]}. Model-oriented keys apply whenever that model/provider is active, regardless of role; a "provider/*" entry keeps the failing model's id and swaps the provider. An id-prefixed wildcard ("openrouter/google/*") re-prefixes the failing model's bare id (google-antigravity/gemini-x -> openrouter/google/gemini-x) and, used as a key, matches only that provider's ids under the prefix. A fallback entry may carry an explicit thinking suffix ("provider/model:low", ":high", ":max", ":off"); a bare entry inherits the failing turn's effort, and "provider/*" entries always inherit.`}},"retry.fallbackRevertPolicy":{type:"enum",default:"cooldown-expiry",values:["cooldown-expiry","never"],ui:{tab:"model",group:"Retry & Fallback",label:"Fallback Revert Policy",description:"When to return to the primary model after a fallback",options:[{value:"cooldown-expiry",label:"Cooldown expiry",description:"Return to the primary model after its suppression window ends"},{value:"never",label:"Never",description:"Stay on the fallback model until manually changed"}]}},"providers.anthropic.serverSideFallback":{type:"boolean",default:!1,ui:{tab:"model",group:"Retry & Fallback",label:"Anthropic Server-Side Fallback (Fable 5)",description:"When a Claude Fable 5 / Mythos 5 request is blocked by Anthropic's safety classifier, retry it on Claude Opus 5 server-side (Anthropic `server-side-fallback-2026-06-01` beta). Opt-in — leaving this off preserves the pre-fallback behavior for every request."}},"providers.ollama-cloud.maxConcurrency":{type:"number",default:3,ui:{tab:"providers",group:"Services",label:"Ollama Cloud Max Concurrency",description:"Maximum concurrent Ollama Cloud subagent runs per process; 0 disables the provider-specific limit"}},"providers.webSearchTimeoutSeconds":{type:"number",default:60,ui:{tab:"providers",group:"Services",label:"Web Search Timeout",description:"Hard timeout for each provider's search transport before web_search advances to the next fallback, in seconds (maximum 300)",options:[{value:"30",label:"30 seconds"},{value:"60",label:"1 minute"},{value:"120",label:"2 minutes"},{value:"180",label:"3 minutes"},{value:"300",label:"5 minutes"}]}},"providers.antigravityEndpoint":{type:"enum",default:"auto",values:["auto","production","sandbox"],ui:{tab:"providers",group:"Services",label:"Antigravity Endpoint Mode",description:"Endpoint routing strategy for google-antigravity providers (chat, search, image, discovery)",options:[{value:"auto",label:"Auto",description:"Try production endpoint, fail over to sandbox on 5xx/429"},{value:"production",label:"Production Only",description:"Force production endpoint only"},{value:"sandbox",label:"Sandbox Only",description:"Force sandbox endpoint only"}]}},"providers.fireworksTier":{type:"enum",default:"standard",values:["standard","priority"],ui:{tab:"providers",group:"Fireworks",label:"Fireworks Tier",description:'Serving path for Fireworks requests. Priority sends `service_tier: "priority"` for higher reliability during peak traffic at a higher price; Standard omits it. Fast (`-fast`) models ignore this — Fast is its own serving path.',options:[{value:"standard",label:"Standard",description:"Default serving path (no service_tier)"},{value:"priority",label:"Priority",description:"Priority serving path: higher reliability, premium per-token pricing"}]}},"providers.tinyModelDevice":{type:"enum",default:"default",values:["default","gpu","cpu","mlx","metal","webgpu","cuda","dml","coreml","auto","wasm","webnn","webnn-gpu","webnn-cpu","webnn-npu"],ui:{tab:"providers",group:"Tiny Model",label:"Tiny Model Device",description:"Inference backend for local tiny models (titles + memory): an ONNX execution provider, or `mlx` to download MLX weights and run them through mlx-lm on Apple silicon. Default uses CPU-only ONNX. The PI_TINY_DEVICE env var overrides this.",options:[{value:"default",label:"Default",description:"CPU-only inference"},{value:"gpu",label:"GPU",description:"Accelerated provider (WebGPU/Metal, CUDA, or DirectML)"},{value:"cpu",label:"CPU",description:"CPU-only inference"},{value:"mlx",label:"MLX",description:"Apple silicon GPU via mlx-lm (Python subprocess; macOS arm64)"},{value:"metal",label:"Metal",description:"Alias for MLX"},{value:"webgpu",label:"WebGPU",description:"WebGPU/Metal backend"},{value:"cuda",label:"CUDA",description:"NVIDIA CUDA (Linux x64)"},{value:"dml",label:"DirectML",description:"DirectML backend (Windows)"},{value:"coreml",label:"CoreML",description:"Apple CoreML (opt-in; can fail to load)"},{value:"auto",label:"Auto",description:"Let ONNX Runtime choose a provider"},{value:"wasm",label:"WASM",description:"WebAssembly backend"},{value:"webnn",label:"WebNN",description:"WebNN backend"},{value:"webnn-gpu",label:"WebNN GPU",description:"WebNN GPU device"},{value:"webnn-cpu",label:"WebNN CPU",description:"WebNN CPU device"},{value:"webnn-npu",label:"WebNN NPU",description:"WebNN NPU device"}]}},"providers.tinyModelDtype":{type:"enum",default:"default",values:["default","q4","q4f16","q8","fp16","fp32","int8","uint8","bnb4","q2","q2f16","q1","q1f16","auto"],ui:{tab:"providers",group:"Tiny Model",label:"Tiny Model Precision",description:"ONNX quantization/precision for local tiny models. Default uses each model's shipped dtype (q4); lower precision is faster, higher is more faithful. Ignored by the MLX backend (its repos are pre-quantized 4-bit). The PI_TINY_DTYPE env var overrides this.",options:[{value:"default",label:"Default",description:"Each model's shipped dtype (currently q4)"},{value:"q4",label:"q4",description:"4-bit weights; smallest and fastest"},{value:"q4f16",label:"q4f16",description:"4-bit weights with fp16 activations"},{value:"q8",label:"q8",description:"8-bit quantization"},{value:"fp16",label:"fp16",description:"16-bit float; higher fidelity, larger"},{value:"fp32",label:"fp32",description:"Full precision; largest and slowest"},{value:"int8",label:"int8",description:"Signed 8-bit integer"},{value:"uint8",label:"uint8",description:"Unsigned 8-bit integer"},{value:"bnb4",label:"bnb4",description:"bitsandbytes 4-bit"},{value:"q2",label:"q2",description:"2-bit weights"},{value:"q2f16",label:"q2f16",description:"2-bit weights with fp16 activations"},{value:"q1",label:"q1",description:"1-bit weights"},{value:"q1f16",label:"q1f16",description:"1-bit weights with fp16 activations"},{value:"auto",label:"Auto",description:"Let transformers.js choose per device"}]}},"providers.autoThinkingMaxEffort":{type:"enum",default:"xhigh",values:["xhigh","max"],ui:{tab:"model",group:"Thinking",label:"Auto Thinking Ceiling",description:"Highest effort the `auto` classifier may resolve. `xhigh` keeps the classifier one tier below the top, so only an explicit `ultrathink` reaches `max`; `max` lets a turn the classifier judges exceptional bill the top tier on models that expose it.",condition:"autoThinkingActive",options:[{value:"xhigh",label:"xhigh",description:"Classifier stops at xhigh (default)"},{value:"max",label:"max",description:"Classifier may resolve max where the model supports it"}]}},"features.unexpectedStopDetection":{type:"enum",default:"mechanical",values:["none","mechanical","smart"],ui:{tab:"interaction",group:"Agent",label:"Unexpected Stops",description:"Automatically recover when the assistant stops without a visible message. Smart also classifies text-only stops with a small model.",options:[{value:"none",label:"None",description:"Disabled"},{value:"mechanical",label:"Mechanical",description:"Retry stops with no visible assistant message; tool calls are excluded (default)"},{value:"smart",label:"Smart",description:"Mechanical + small-model classification of text-only stops"}]}},"providers.kimiApiFormat":{type:"enum",default:"auto",values:["auto","openai","anthropic"],ui:{tab:"providers",group:"Protocol",label:"Kimi API Format",description:"API format for Kimi Code provider (auto follows live model metadata)",options:[{value:"auto",label:"Auto",description:"Use the model's server-declared protocol"},{value:"openai",label:"OpenAI",description:"api.kimi.com"},{value:"anthropic",label:"Anthropic",description:"api.moonshot.ai"}]}},"providers.openaiWebsockets":{type:"enum",default:"auto",values:["auto","off","on"],ui:{tab:"providers",group:"Protocol",label:"OpenAI Codex WebSockets",description:"WebSocket policy for OpenAI Codex models only",options:[{value:"auto",label:"Auto",description:"Use Codex model defaults"},{value:"off",label:"Off",description:"Disable WebSockets for OpenAI Codex models"},{value:"on",label:"On",description:"Force websockets for OpenAI Codex models"}]}},"providers.openaiResponsesWebsockets":{type:"boolean",default:!1,ui:{tab:"providers",group:"Protocol",label:"OpenAI Responses WebSockets",description:"Opt in for catalog-supported standard Responses models; model or request false disables it"}},"providers.openaiLiveSteering":{type:"boolean",default:!1,ui:{tab:"providers",group:"Protocol",label:"OpenAI Live Steering",description:"Deliver messages typed while a GPT-6 response streams into that response over the Codex WebSocket, instead of waiting for the next tool boundary"}},"providers.muse-code.storeResponses":{type:"boolean",default:!1,ui:{tab:"providers",group:"Protocol",label:"Muse Code Stored Responses",description:"Store Muse Code results on Meta's servers so a turn whose connection drops is recovered instead of re-run. Stored runs keep prompts and outputs on Meta's side."}},"providers.openai-codex.daybreak":{type:"boolean",default:!0,ui:{tab:"providers",group:"Protocol",label:"Codex Daybreak Blue",description:"Automatically request the Daybreak Blue cyber access program on ChatGPT accounts eligible for it. OpenAI may use content from Daybreak Blue sessions to improve its models. Does not cover dedicated Daybreak Blue models (gpt-daybreak-blue-*), which may still run as Daybreak sessions."}},"providers.cacheRetention":{type:"enum",default:"auto",values:["auto","short","long","none"],ui:{tab:"providers",group:"Protocol",label:"Prompt Cache Retention",description:"Prompt-cache retention forwarded to providers that support it (Anthropic, Bedrock, OpenRouter, OpenAI)",options:[{value:"auto",label:"Auto",description:"Provider default — Anthropic OAuth subscriber sessions default to 1h, API keys use 5m; PI_CACHE_RETENTION still applies"},{value:"short",label:"Short (5m)",description:"Cheapest cache writes; pair with cache warming to keep short entries alive while idle"},{value:"long",label:"Long (1h+)",description:"Longer TTL where supported (Anthropic/Bedrock 1h, OpenAI GPT-5.6+ Responses 12h); pricier writes, only warmed during active runs"},{value:"none",label:"Off",description:"Disable prompt caching and cache-affinity routing"}]}},"providers.cacheWarming":{type:"enum",default:"idle",values:["off","streaming","idle"],ui:{tab:"providers",group:"Protocol",label:"Cache Warming",description:"Re-send the last request with a one-token output budget shortly before its prompt-cache entry expires",options:[{value:"off",label:"Off",description:"Disable cache warming"},{value:"streaming",label:"Streaming",description:"Protect expensive prefixes during long tool executions; stops when the agent settles"},{value:"idle",label:"Idle",description:"Also refresh 5-minute entries between runs while the expected savings stay above the cost floor"}]}},"providers.streamFirstEventTimeoutSeconds":{type:"number",default:-1,ui:{tab:"providers",group:"Timeouts",label:"Stream First Event Timeout",description:"Seconds to wait for the first model stream event; -1 uses provider/env defaults, 0 disables the watchdog",options:[{value:"-1",label:"Auto",description:"Use provider defaults and PI_* timeout env vars"},{value:"0",label:"Off",description:"Disable first-event timeout"},{value:"300",label:"5 minutes"},{value:"600",label:"10 minutes"},{value:"1800",label:"30 minutes"}]}},"providers.streamIdleTimeoutSeconds":{type:"number",default:-1,ui:{tab:"providers",group:"Timeouts",label:"Stream Idle Timeout",description:"Seconds a model stream may stay silent between events; -1 uses provider/env defaults, 0 disables the watchdog",options:[{value:"-1",label:"Auto",description:"Use provider defaults and PI_* timeout env vars"},{value:"0",label:"Off",description:"Disable idle timeout"},{value:"300",label:"5 minutes"},{value:"600",label:"10 minutes"},{value:"1800",label:"30 minutes"}]}},"providers.openrouterVariant":{type:"enum",default:"default",values:["default","nitro","floor","online","exacto"],ui:{tab:"providers",group:"Protocol",label:"OpenRouter Routing",description:"Default routing-variant suffix appended to OpenRouter model IDs (overridden when the selector already names a variant)",options:[{value:"default",label:"Default",description:"No suffix; use OpenRouter's default routing"},{value:"nitro",label:":nitro",description:"Prioritize throughput / lowest latency"},{value:"floor",label:":floor",description:"Prioritize cheapest available provider"},{value:"online",label:":online",description:"Enable OpenRouter's web-search plugin"},{value:"exacto",label:":exacto",description:"Cherry-picked high-quality providers (only defined for select models)"}]}},"live.voice":{type:"enum",default:"sol",values:["arbor","breeze","cove","ember","juniper","maple","sol","spruce","vale"],ui:{tab:"providers",group:"Services",label:"Live Voice",description:"Voice used by Codex-backed realtime voice sessions",options:[{value:"arbor",label:"Arbor"},{value:"breeze",label:"Breeze"},{value:"cove",label:"Cove"},{value:"ember",label:"Ember"},{value:"juniper",label:"Juniper"},{value:"maple",label:"Maple"},{value:"sol",label:"Sol"},{value:"spruce",label:"Spruce"},{value:"vale",label:"Vale"}]}},"tts.localVoice":{type:"enum",default:"af_heart",values:["af_heart","af_bella","af_nicole","af_aoede","af_kore","af_sarah","am_michael","am_fenrir","am_puck","bf_emma","bm_george","bm_fable"],ui:{tab:"providers",group:"Services",label:"Local TTS Voice",description:"Kokoro voice used by the local TTS backend (American/British, female/male)",options:[{value:"af_heart",label:"Heart (American female)"},{value:"af_bella",label:"Bella (American female)"},{value:"af_nicole",label:"Nicole (American female)"},{value:"af_aoede",label:"Aoede (American female)"},{value:"af_kore",label:"Kore (American female)"},{value:"af_sarah",label:"Sarah (American female)"},{value:"am_michael",label:"Michael (American male)"},{value:"am_fenrir",label:"Fenrir (American male)"},{value:"am_puck",label:"Puck (American male)"},{value:"bf_emma",label:"Emma (British female)"},{value:"bm_george",label:"George (British male)"},{value:"bm_fable",label:"Fable (British male)"}]}},"tts.localSpeed":{type:"number",default:1,ui:{tab:"providers",group:"Services",label:"Local TTS Speed",description:"Speaking rate of the local TTS backend (tts tool, omp say). 1 = normal; clamped to 0.5–2.5",options:[{value:"0.5",label:"0.5×"},{value:"0.75",label:"0.75×"},{value:"1",label:"1× (normal)"},{value:"1.25",label:"1.25×"},{value:"1.5",label:"1.5×"},{value:"1.75",label:"1.75×"},{value:"2",label:"2×"},{value:"2.5",label:"2.5×"}]}},"speech.enabled":{type:"boolean",default:!1,ui:{tab:"providers",group:"Services",label:"Speech Vocalization",description:"Speak the assistant's output aloud through the speakers as it streams"}},"speech.mode":{type:"enum",default:"assistant",values:["all","assistant","yield"],ui:{tab:"providers",group:"Services",label:"Speech Vocalization Mode",description:"What to speak: all = assistant messages + thinking; assistant = messages only; yield = only the final message at turn end",options:[{value:"all",label:"All (messages + thinking)"},{value:"assistant",label:"Assistant messages"},{value:"yield",label:"Final message only"}]}},"speech.enhanced":{type:"boolean",default:!1,ui:{tab:"providers",group:"Services",label:"Enhanced Speech Rewriting",description:"Rewrite assistant output into natural spoken prose with the tiny/smol model before synthesis (describes code, drops links and markdown). Falls back to mechanical cleanup on failure"}},"speech.voice":{type:"enum",default:"af_heart",values:["af_heart","af_bella","af_nicole","af_aoede","af_kore","af_sarah","am_michael","am_fenrir","am_puck","bf_emma","bm_george","bm_fable"],ui:{tab:"providers",group:"Services",label:"Speech Vocalization Voice",description:"Kokoro voice used when speaking the assistant's output aloud",options:[{value:"af_heart",label:"Heart (American female)"},{value:"af_bella",label:"Bella (American female)"},{value:"af_nicole",label:"Nicole (American female)"},{value:"af_aoede",label:"Aoede (American female)"},{value:"af_kore",label:"Kore (American female)"},{value:"af_sarah",label:"Sarah (American female)"},{value:"am_michael",label:"Michael (American male)"},{value:"am_fenrir",label:"Fenrir (American male)"},{value:"am_puck",label:"Puck (American male)"},{value:"bf_emma",label:"Emma (British female)"},{value:"bm_george",label:"George (British male)"},{value:"bm_fable",label:"Fable (British male)"}]}},"speech.speed":{type:"number",default:1,ui:{tab:"providers",group:"Services",label:"Speech Vocalization Speed",description:"Speaking rate when reading the assistant's output aloud. 1 = normal; clamped to 0.5–2.5",options:[{value:"0.5",label:"0.5×"},{value:"0.75",label:"0.75×"},{value:"1",label:"1× (normal)"},{value:"1.25",label:"1.25×"},{value:"1.5",label:"1.5×"},{value:"1.75",label:"1.75×"},{value:"2",label:"2×"},{value:"2.5",label:"2.5×"}]}},"providers.fetch":{type:"enum",default:"auto",values:["auto","native","trafilatura","lynx","parallel","firecrawl","jina"],ui:{tab:"providers",group:"Services",label:"Fetch Provider",description:"Reader backend priority for the fetch/read URL tool",options:[{value:"auto",label:"Auto",description:"Priority: native > trafilatura > lynx > parallel > firecrawl > jina"},{value:"native",label:"Native",description:"In-process HTML→Markdown converter (always available)"},{value:"trafilatura",label:"Trafilatura",description:"Auto-installs via uv/pip"},{value:"lynx",label:"Lynx",description:"Requires lynx system package"},{value:"parallel",label:"Parallel",description:"Requires PARALLEL_API_KEY"},{value:"firecrawl",label:"Firecrawl",description:"Requires FIRECRAWL_API_KEY"},{value:"jina",label:"Jina",description:"Uses r.jina.ai reader (JINA_API_KEY optional)"}]}},"codexResets.autoRedeem5h":{type:"enum",default:"unset",values:["unset","yes","no"],ui:{tab:"providers",group:"Services",label:"Codex Auto-Redeem Saved Resets (5h)",description:"Spend saved Codex resets on 5-hour-only blocks and on expiring credits whose fullest chat window is 5h. unset asks before spending and never spends without a prompt; yes spends without asking; no never spends.",options:[{value:"unset",label:"Unset",description:"Ask before spending; never spend without a prompt."},{value:"yes",label:"Yes",description:"Spend eligible saved resets without asking."},{value:"no",label:"No",description:"Never spend saved resets for this window."}]}},"codexResets.autoRedeemWeekly":{type:"enum",default:"unset",values:["unset","yes","no"],ui:{tab:"providers",group:"Services",label:"Codex Auto-Redeem Saved Resets (Weekly)",description:"Spend saved Codex resets on weekly blocks and on expiring credits whose fullest chat window is weekly. A block known only from a short 429 wait needs both Codex windows. unset asks before spending and never spends without a prompt; yes spends without asking; no never spends.",options:[{value:"unset",label:"Unset",description:"Ask before spending; never spend without a prompt."},{value:"yes",label:"Yes",description:"Spend eligible saved resets without asking."},{value:"no",label:"No",description:"Never spend saved resets for this window."}]}},"codexResets.minBlockedMinutes":{type:"number",default:60,ui:{tab:"providers",group:"Services",label:"Codex Auto-Redeem Min Block",description:"Only auto-redeem when the natural unblock — the latest reset among the exhausted 5h/weekly windows — is at least this many minutes away (don't spend a scarce credit to save a short wait). Raise it (e.g. 360) to ignore 5h-only blocks."}},"codexResets.keepCredits":{type:"number",default:0,ui:{tab:"providers",group:"Services",label:"Codex Auto-Redeem Reserve",description:"Never auto-spend below this many saved resets (0 = the last credit may be spent automatically). Credits about to expire are exempt — a reserved credit that expires preserves nothing."}},"codexResets.salvageHorizonHours":{type:"number",default:12,ui:{tab:"providers",group:"Services",label:"Codex Reset Salvage Horizon",description:"With auto-redeem enabled, spend a saved Codex reset within this many hours of expiry when either chat window has meaningful usage. 0 disables early salvage; credits expiring within 5 minutes are still attempted regardless of usage."}},"claudeResets.autoRedeem5h":{type:"enum",default:"unset",values:["unset","yes","no"],ui:{tab:"providers",group:"Services",label:"Claude Auto-Redeem Saved Resets (5h)",description:"Spend Claude Cedar or Juniper resets on 5-hour-only blocks and on expiring grants whose fullest covered limit is 5h. unset asks before spending and never spends without a prompt; yes spends without asking; no never spends.",options:[{value:"unset",label:"Unset",description:"Ask before spending; never spend without a prompt."},{value:"yes",label:"Yes",description:"Spend eligible saved resets without asking."},{value:"no",label:"No",description:"Never spend saved resets for this window."}]}},"claudeResets.autoRedeemWeekly":{type:"enum",default:"unset",values:["unset","yes","no"],ui:{tab:"providers",group:"Services",label:"Claude Auto-Redeem Saved Resets (Weekly)",description:"Spend Claude Cedar resets on weekly or model-scoped blocks and on expiring grants whose fullest covered limit is weekly. unset asks before spending and never spends without a prompt; yes spends without asking; no never spends.",options:[{value:"unset",label:"Unset",description:"Ask before spending; never spend without a prompt."},{value:"yes",label:"Yes",description:"Spend eligible saved resets without asking."},{value:"no",label:"No",description:"Never spend saved resets for this window."}]}},"claudeResets.autoRedeemFable":{type:"enum",default:"unset",values:["unset","yes","no"],ui:{tab:"providers",group:"Services",label:"Claude Auto-Redeem Fable Resets",description:"Spend Claude Fable launch resets, which restore Fable weekly usage plus the 5h window. Only this setting governs them. unset asks before spending and never spends without a prompt; yes spends without asking; no never spends.",options:[{value:"unset",label:"Unset",description:"Ask before spending; never spend without a prompt."},{value:"yes",label:"Yes",description:"Spend eligible saved resets without asking."},{value:"no",label:"No",description:"Never spend saved resets for this window."}]}},"claudeResets.minBlockedMinutes":{type:"number",default:60,ui:{tab:"providers",group:"Services",label:"Claude Auto-Redeem Min Block",description:"Only auto-redeem when the natural unblock — the latest reset among the exhausted covered windows — is at least this many minutes away. A 5-hour-only reset is never used for a weekly or model-scoped block."}},"claudeResets.keepCredits":{type:"number",default:0,ui:{tab:"providers",group:"Services",label:"Claude Auto-Redeem Reserve",description:"Keep at least this many Claude resets banked (0 allows the last eligible reset to be spent automatically). The reserve applies to early salvage, but not to eligible resets expiring within 5 minutes."}},"claudeResets.salvageHorizonHours":{type:"number",default:12,ui:{tab:"providers",group:"Services",label:"Claude Reset Salvage Horizon",description:"With auto-redeem enabled, use a server-selected Cedar reset within this many hours of expiry when its covered windows have meaningful usage. 0 disables early salvage; eligible Cedar or Juniper resets expiring within 5 minutes are still attempted regardless of usage or reserve. Provider limit requirements still apply."}},"provider.appendOnlyContext":{type:"enum",default:"auto",values:["auto","on","off"],ui:{tab:"providers",group:"Protocol",label:"Append-Only Context",description:"Cache system prompt + tool specs and keep an append-only message log so provider prefix caches (DeepSeek, Xiaomi/SGLang, Anthropic) hit at maximum rate. Auto enables for known prefix-cache providers.",options:[{value:"auto",label:"Auto",description:"Enable for known prefix-cache providers (recommended)"},{value:"on",label:"On",description:"Always enable append-only context"},{value:"off",label:"Off",description:"Disable append-only context"}]}},"telemetry.otlpExportEnabled":{type:"boolean",default:!0,ui:{tab:"providers",group:"Privacy",label:"OTLP Telemetry Export",description:"Allow OMP to export traces, logs, and metrics using OTEL_* endpoints. Changes take effect on the next launch."}},"advisor.enabled":{type:"boolean",default:!1,ui:{tab:"model",group:"Advisor",label:"Enable Advisor",description:"Pair a second model (assigned to the 'advisor' role) that passively reviews each turn and injects notes."}},"advisor.syncBacklog":{type:"enum",default:"off",values:["off","1","3","5","strict"],ui:{tab:"model",group:"Advisor",label:"Advisor Sync Backlog",description:"Pause main agent until advisor backlog falls below threshold. Numeric values cap wait at 30 seconds; strict waits for all scheduled reviews without a wall-clock cap. Off disables catch-up delays. Abort, failure, and disposal release waits.",condition:"advisorEnabled"}},"advisor.immuneTurns":{type:"number",default:3,ui:{tab:"model",group:"Advisor",label:"Advisor Immune Turns",description:"After an advisor concern or blocker interrupts, route further concerns as non-interrupting asides for this many primary turns. Blockers are exempt from the cooldown.",options:[{value:"0",label:"0 steps",description:"No cooldown."},{value:"1",label:"1 step"},{value:"2",label:"2 steps"},{value:"3",label:"3 steps",description:"Default."},{value:"4",label:"4 steps"},{value:"5",label:"5 steps"}],condition:"advisorEnabled"}},"advisor.continueSeverity":{type:"enum",default:"concern",values:["nit","concern","blocker"],ui:{tab:"model",group:"Advisor",label:"Advisor Continue Severity",description:"Minimum severity of an advisor note that wakes the agent after it finished with a final answer. Lower-severity notes stay as a card at the end of the transcript and reach the agent with your next message.",options:[{value:"nit",label:"Nit",description:"Every note continues the run."},{value:"concern",label:"Concern",description:"Concerns and blockers continue the run. Default."},{value:"blocker",label:"Blocker",description:"Only blockers continue the run."}],condition:"advisorEnabled"}},"advisor.reviewMode":{type:"enum",default:"turn",values:["turn","agent-end"],ui:{tab:"model",group:"Advisor",label:"Advisor Review Mode",description:"Default advisor cadence when no WATCHDOG.yml roster is present. turn reviews every primary turn; agent-end reviews only final yields.",options:[{value:"turn",label:"Every turn",description:"Review every primary update (tool-call round)."},{value:"agent-end",label:"Agent end",description:"Review only at final yields (once per run)."}],condition:"advisorEnabled"}},"advisor.reviewInterval":{type:"number",default:1,ui:{tab:"model",group:"Advisor",label:"Advisor Review Interval",description:"Default advisor cadence when no WATCHDOG.yml roster is present: review every Nth eligible primary update. 1 = every update. Skipped updates are sent with the next scheduled review.",options:[{value:"1",label:"Every eligible update",description:"Default."},{value:"2",label:"Every 2nd"},{value:"3",label:"Every 3rd"},{value:"5",label:"Every 5th"},{value:"10",label:"Every 10th"}],condition:"advisorEnabled"}},"advisor.maxNotesPerUpdate":{type:"number",default:4,ui:{tab:"model",group:"Advisor",label:"Advisor Max Notes Per Update",description:"Maximum non-blocker advice notes accepted per advisor prompt update (1–32; UI offers 1–5 quick picks). Blockers are exempt.",options:[{value:"1",label:"1 note",description:"Anti-flood (strict)."},{value:"2",label:"2 notes"},{value:"3",label:"3 notes"},{value:"4",label:"4 notes",description:"Frontier reasoning models. Default."},{value:"5",label:"5 notes"}],condition:"advisorEnabled"}},"advisor.evictStaleResults":{type:"boolean",default:!0,ui:{tab:"model",group:"Advisor",label:"Advisor Evict Stale Results",description:"Before each review, replace the advisor's read/grep/glob output from older reviews with a short placeholder. The latest review is kept.",condition:"advisorEnabled"}},"workspace.additionalDirectories":{type:"array",default:[],ui:{tab:"context",group:"General",label:"Additional Workspace Dirs",description:"Extra workspace directories added to every session as additional roots (multi-root workspace). Managed live via /add-dir and /remove-dir. Paths resolve relative to cwd; absolute paths recommended. The agent is told these roots exist and can read/grep/glob them."}},"contextFiles.extra":{type:"array",default:[],ui:{tab:"context",group:"General",label:"Extra Context Files",editor:"json",description:'Extra instruction filenames loaded beside AGENTS.md. Use a JSON list of names, not paths, e.g. ["AGENTS.local.md"]; [] disables extras. Start a new session to load them.',condition:"contextFilesExtraNotProject"}},"contextPromotion.enabled":{type:"boolean",default:!1,ui:{tab:"context",group:"General",label:"Auto-Promote Context",description:"Promote to the model's contextPromotionTarget on context overflow instead of compacting. Retry fallback switches are controlled by Retry Model Fallback"}},extendedContext:{type:"boolean",default:!1,ui:{tab:"context",group:"General",label:"Extended Context",description:"Use larger context windows where supported; may incur premium pricing. Off keeps default or standard-pricing windows"}},"compaction.enabled":{type:"boolean",default:!0,ui:{tab:"context",group:"Compaction",label:"Auto-Compact",description:"Automatically compact context when it gets too large"}},"compaction.experimentalContextManagement":{type:"boolean",default:!1,ui:{tab:"context",group:"Compaction",label:"Notes-backed context windows (experimental)",description:"Keep persistent notes and searchable raw history across context windows."}},"compaction.midTurnEnabled":{type:"boolean",default:!0,ui:{tab:"context",group:"Compaction",label:"Mid-Turn Compaction",description:"Check thresholds at safe mid-turn tool-loop boundaries before the next provider request; subagents always check, since their whole assignment is one turn"}},"compaction.methodOrder":{type:"array",default:["remote","snapcompact","handoff","shake","soft"],ui:{tab:"context",group:"Compaction",label:"Compaction Method Order",description:"Preferred fallback order for automatic context maintenance; unavailable or failed methods advance to the next choice",options:[{value:"remote",label:"Server compaction",description:"Use provider-native server compaction (OpenAI Responses compact, Anthropic compaction beta, including on Bedrock) when the active route supports it"},{value:"snapcompact",label:"Snapcompact",description:"Archive history onto dense bitmap images the active vision model reads back; no LLM call"},{value:"handoff",label:"Handoff",description:"Generate a handoff document and continue from it as the compaction summary"},{value:"soft",label:"Soft compaction",description:"Summarize in place with a compaction model without using server compaction"},{value:"shake",label:"Shake",description:"Drop recoverable heavy content in place without an LLM call"}],ordered:!0}},"compaction.thresholdPercent":{type:"number",default:-1,ui:{tab:"context",group:"Compaction",label:"Compaction Threshold",description:"Percent threshold for context maintenance; set to Default to use legacy reserve-based behavior",options:[{value:"default",label:"Default",description:"Legacy reserve-based threshold"},{value:"10",label:"10%",description:"Extremely early maintenance"},{value:"20",label:"20%",description:"Very early maintenance"},{value:"30",label:"30%",description:"Early maintenance"},{value:"40",label:"40%",description:"Moderately early maintenance"},{value:"50",label:"50%",description:"Halfway point"},{value:"60",label:"60%",description:"Moderate context usage"},{value:"70",label:"70%",description:"Balanced"},{value:"75",label:"75%",description:"Slightly aggressive"},{value:"80",label:"80%",description:"Typical threshold"},{value:"85",label:"85%",description:"Aggressive context usage"},{value:"90",label:"90%",description:"Very aggressive"},{value:"95",label:"95%",description:"Near context limit"}]}},"compaction.thresholdTokens":{type:"number",default:-1,ui:{tab:"context",group:"Compaction",label:"Compaction Token Limit",description:"Fixed token limit for context maintenance; overrides percentage if set",options:[{value:"default",label:"Default",description:"Use percentage-based threshold"},{value:"25000",label:"25K tokens",description:"1/8 of a 200K window"},{value:"50000",label:"50K tokens",description:"1/4 of a 200K window"},{value:"100000",label:"100K tokens",description:"1/2 of a 200K window"},{value:"150000",label:"150K tokens",description:"3/4 of a 200K window"},{value:"200000",label:"200K tokens",description:"Full standard context window"},{value:"300000",label:"300K tokens",description:"Large context window"},{value:"500000",label:"500K tokens",description:"Very large context window"}]}},"compaction.handoffSaveToDisk":{type:"boolean",default:!1,ui:{tab:"context",group:"Compaction",label:"Save Handoff Docs",description:"Save generated handoff documents to markdown files for the auto-handoff flow"}},"compaction.remoteStreamingV2Enabled":{type:"boolean",default:!0,ui:{tab:"context",group:"Compaction",label:"Remote Compaction V2",description:"Use Responses streaming compaction for compatible remote compaction models"}},"compaction.asyncEnabled":{type:"boolean",default:!0,ui:{tab:"context",group:"Compaction",label:"Async Compaction",description:"Speculatively summarize in the background as context nears the compaction threshold, then splice the ready result in when the threshold is crossed"}},"compaction.idleEnabled":{type:"boolean",default:!1,ui:{tab:"context",group:"Compaction",label:"Idle Compaction",description:"Compact context while idle when token count exceeds threshold"}},"compaction.idleThresholdTokens":{type:"number",default:200000,ui:{tab:"context",group:"Compaction",label:"Idle Compaction Threshold",description:"Token count above which idle compaction triggers",options:[{value:"100000",label:"100K tokens"},{value:"200000",label:"200K tokens"},{value:"300000",label:"300K tokens"},{value:"400000",label:"400K tokens"},{value:"500000",label:"500K tokens"},{value:"600000",label:"600K tokens"},{value:"700000",label:"700K tokens"},{value:"800000",label:"800K tokens"},{value:"900000",label:"900K tokens"}]}},"compaction.idleTimeoutSeconds":{type:"number",default:300,ui:{tab:"context",group:"Compaction",label:"Idle Compaction Delay",description:"Seconds to wait while idle before compacting; with a 1-hour prompt cache, compaction instead runs just before the cache expires",options:[{value:"60",label:"1 minute"},{value:"120",label:"2 minutes"},{value:"300",label:"5 minutes"},{value:"600",label:"10 minutes"},{value:"1800",label:"30 minutes"},{value:"3600",label:"1 hour"}]}},"compaction.supersedeReads":{type:"boolean",default:!0,ui:{tab:"context",group:"Compaction",label:"Supersede Stale Reads",description:"Prune older read results when the same file is read again (cache-aware, runs every turn)"}},"compaction.dropUseless":{type:"boolean",default:!0,ui:{tab:"context",group:"Compaction",label:"Elide Uneventful Results",description:"Prune tool results flagged contextually useless (no matches, timed-out waits) once consumed (cache-aware)"}},"snapcompact.systemPrompt":{type:"enum",default:"none",values:["none","agents-md","all"],ui:{tab:"context",group:"Experimental",label:"Snapcompact System Prompt",description:"Experimental: render selected system prompt text as dense PNG image(s) and attach to the first user message (vision models only). Saves tokens; loses prompt caching for imaged text.",options:[{value:"none",label:"None",description:"Keep the system prompt as text."},{value:"agents-md",label:"AGENTS.md",description:"Only move loaded context-file instructions to images, when that saves tokens."},{value:"all",label:"All",description:"Move the full system prompt to images, when that saves tokens."}]}},"snapcompact.toolResults":{type:"boolean",default:!1,ui:{tab:"context",group:"Experimental",label:"Snapcompact Tool Results",description:"Experimental: render large tool results, the newest one included, as dense PNG image(s) instead of text (vision models only). Saves tokens on accumulated search and command output; read results stay text unless the model is known to edit exactly from images."}},"tools.format":{type:"enum",default:"auto",values:["auto","native","glm","hermes","kimi","xml","anthropic","deepseek","harmony","qwen3","gemini","gemma","minimax"],ui:{tab:"context",group:"Experimental",label:"Tool Calling Mode",description:"Controls how tools are exposed to the model. Auto uses provider-native tool calls unless the selected model is marked as not supporting them, then falls back to the GLM owned dialect. Native forces provider-native tools; the other values force the named owned dialect.",options:[{value:"auto",label:"Auto",description:"Use native tool calls unless the model is known not to support them."},{value:"native",label:"Native",description:"Use provider-native tool calls."},{value:"glm",label:"GLM",description:"Use GLM-style in-band tool calls."},{value:"hermes",label:"Hermes",description:"Use Hermes-style in-band tool calls."},{value:"kimi",label:"Kimi",description:"Use Kimi-style in-band tool calls."},{value:"xml",label:"XML",description:"Use generic XML in-band tool calls."},{value:"anthropic",label:"Anthropic",description:"Use Anthropic-style in-band tool calls."},{value:"deepseek",label:"DeepSeek",description:"Use DeepSeek-style in-band tool calls."},{value:"harmony",label:"Harmony",description:"Use Harmony-style in-band tool calls."},{value:"qwen3",label:"Qwen3",description:"Use the Qwen3 owned dialect."},{value:"gemini",label:"Gemini",description:"Use the Gemini owned dialect."},{value:"gemma",label:"Gemma",description:"Use the Gemma owned dialect."},{value:"minimax",label:"MiniMax",description:"Use the MiniMax owned dialect."}]}},"snapcompact.shape":{type:"enum",default:"auto",values:["auto","8x8r-bw","8x8r-sent","8x8u-bw","8x8u-sent","6x6u-bw","6x6u-sent","5x8-bw","5x8-sent","6x12-dim","8x13-bw","8on16-bw","8on22-bw","11on16-bw","silver16-bw","doc-8on16-bw","doc-8on16-sent","doc-8on16-sent-dim"],ui:{tab:"context",group:"Experimental",label:"Snapcompact Shape",description:"Frame shape snapcompact prints text with (compaction archive and inline imaging). Auto picks a shape tuned for the current model.",options:[{value:"auto",label:"Auto",description:"Picks a shape tuned for the current model, falling back to its provider family."},{value:"8x8r-bw",label:"8x8 repeated, black",description:"unscii square cell, black ink, every line printed twice with the copy on a pale highlight band."},{value:"8x8r-sent",label:"8x8 repeated, sentence hues",description:"Repeated grid with ink cycling six hues at sentence boundaries."},{value:"8x8u-bw",label:"8x8, black",description:"Plain unscii square cell, single-printed lines, black ink."},{value:"8x8u-sent",label:"8x8, sentence hues",description:"Plain unscii square cell with sentence-hue ink."},{value:"6x6u-bw",label:"6x6 dense, black",description:"unscii squeezed to 6x6 — densest readable cell, fewest frames — in black ink."},{value:"6x6u-sent",label:"6x6 dense, sentence hues",description:"Densest cell with sentence-hue ink."},{value:"5x8-bw",label:"5x8 legacy, black",description:"Original X.org 5x8 glyphs on the 2576px frame, black ink."},{value:"5x8-sent",label:"5x8 legacy, sentence hues",description:"The original snapcompact shape (pre-shape-table sessions rendered this)."},{value:"6x12-dim",label:"6x12, dimmed stopwords",description:"X.org 6x12 glyphs, black ink, function words dimmed gray."},{value:"8x13-bw",label:"8x13, black",description:"X.org 8x13 glyphs, black ink."},{value:"8on16-bw",label:"8x13 on 16px pitch, black",description:"8x13 glyphs on an 8x16 cell (extra leading), black ink."},{value:"8on22-bw",label:"8x13 on 22px pitch (leading), black",description:"8x13 glyphs on an 8x22 cell — extra line spacing so rows don't crowd. Default for OpenAI/Google."},{value:"11on16-bw",label:"8x13 on 11px advance (tracking), black",description:"8x13 glyphs on an 11x16 cell — extra letter spacing so characters don't merge. Default for Anthropic."},{value:"silver16-bw",label:"Silver 16, CJK",description:"Embedded Silver TrueType font on a 16px grid for CJK and other non-Latin text."},{value:"doc-8on16-bw",label:"Doc 8on16, black",description:"Two word-wrapped newspaper columns of 8x13 glyphs on a 16px pitch, black ink."},{value:"doc-8on16-sent",label:"Doc 8on16, sentence hues",description:"Two-column doc layout with sentence-hue ink."},{value:"doc-8on16-sent-dim",label:"Doc 8on16, sentence hues + dimmed stopwords",description:"Two-column doc layout, sentence-hue ink, function words dimmed gray."}]}},"branchSummary.enabled":{type:"boolean",default:!1,ui:{tab:"context",group:"General",label:"Branch Summaries",description:"Prompt to summarize when leaving a branch"}},"memory.backend":{type:"enum",default:"off",values:["off","local","hindsight","mnemopi","sharpshooter"],ui:{tab:"memory",group:"General",label:"Memory Backend",description:"Off, local summary pipeline, Mnemopi SQLite, Hindsight remote memory, or Sharpshooter",options:[{value:"off",label:"Off",description:"No memory subsystem runs"},{value:"local",label:"Local",description:"Local rollout summarisation pipeline (memory_summary.md)"},{value:"hindsight",label:"Hindsight",description:"Vectorize Hindsight remote memory service"},{value:"mnemopi",label:"Mnemopi",description:"Local SQLite recall/retain backend with optional embeddings"},{value:"sharpshooter",label:"Sharpshooter",description:"Friction-gated project decision files (architecture/product/style), consolidated in the background"}]}},"sharpshooter.model":{type:"string",ui:{tab:"memory",group:"Sharpshooter",label:"Sharpshooter Model",description:"Model selector for extraction/consolidation, empty = smol role"}},"autolearn.enabled":{type:"boolean",default:!1,ui:{tab:"memory",group:"Auto-Learn",label:"Auto-Learn (experimental)",description:"After the agent stops, nudge it to capture lessons to memory and create/enhance isolated managed skills"}},"autolearn.autoContinue":{type:"boolean",default:!1,ui:{tab:"memory",group:"Auto-Learn",label:"Auto-run capture at stop",description:"When on, auto-run one private capture turn at stop (uses extra tokens). When off, only standing auto-learn guidance remains.",condition:"autolearnActive"}},"mnemopi.dbPath":{type:"string",ui:{tab:"memory",group:"Mnemopi",label:"Mnemopi DB Path",description:"Optional SQLite DB path; a leading ~ is the home directory. Defaults to the agent memories directory.",condition:"mnemopiActive"}},"mnemopi.bank":{type:"string",ui:{tab:"memory",group:"Mnemopi",label:"Mnemopi Bank",description:"Optional shared bank base name. Per-project modes derive project-local banks from it.",condition:"mnemopiActive"}},"mnemopi.scoping":{type:"enum",default:"per-project",values:["global","per-project","per-project-tagged"],ui:{tab:"memory",group:"Mnemopi",label:"Mnemopi Scoping",description:"global = one shared bank; per-project = isolated bank per cwd; per-project-tagged = project-local writes plus global recall visibility",options:[{value:"global",label:"Global",description:"One shared Mnemopi bank for every project"},{value:"per-project",label:"Per project",description:"Project-local Mnemopi bank per cwd basename"},{value:"per-project-tagged",label:"Per project (tagged)",description:"Write to a project-local bank but merge project + shared recall results"}],condition:"mnemopiActive"}},"mnemopi.embeddingVariant":{type:"enum",default:"en",values:["en","multilingual"],ui:{tab:"memory",group:"Mnemopi",label:"Embedding variant",description:"Local embedding model family. en = stronger English model; multilingual = cross-language model. Changing this rebuilds existing memory embeddings on next start.",options:[{value:"en",label:"English (bge-base-en-v1.5)",description:"BAAI/bge-base-en-v1.5 (768d), English-only"},{value:"multilingual",label:"Multilingual (multilingual-e5-large)",description:"intfloat/multilingual-e5-large (1024d), cross-language recall"}],condition:"mnemopiActive"}},"mnemopi.autoRecall":{type:"boolean",default:!0,ui:{tab:"memory",group:"Mnemopi",label:"Mnemopi Auto Recall",description:"Recall local memories into the first turn of each session",condition:"mnemopiActive"}},"mnemopi.autoRetain":{type:"boolean",default:!0,ui:{tab:"memory",group:"Mnemopi",label:"Mnemopi Auto Retain",description:"Retain completed conversation turns into local Mnemopi memory",condition:"mnemopiActive"}},"mnemopi.polyphonicRecall":{type:"boolean",default:!1,ui:{tab:"memory",group:"Mnemopi",label:"Mnemopi Polyphonic Recall",description:"Fuse recall with graph, fact, vector and temporal voices so linked memories surface without a keyword match",condition:"mnemopiActive"}},"mnemopi.enhancedRecall":{type:"boolean",default:!1,ui:{tab:"memory",group:"Mnemopi",label:"Mnemopi Enhanced Recall",description:"Cache recall results for repeated and similar queries with identical options; any memory write clears it",condition:"mnemopiActive"}},"mnemopi.proactiveLinking":{type:"boolean",default:!1,ui:{tab:"memory",group:"Mnemopi",label:"Mnemopi Proactive Linking",description:"Ingest new memories into the episodic graph as they are stored, linking them to related entities and memories",condition:"mnemopiActive"}},"mnemopi.noEmbeddings":{type:"boolean",default:!1,ui:{tab:"memory",group:"Mnemopi",label:"Mnemopi Disable Embeddings",description:"Force deterministic FTS-only recall instead of vector embeddings",condition:"mnemopiActive"}},"mnemopi.embeddingModel":{type:"string",ui:{tab:"memory",group:"Mnemopi",label:"Mnemopi Embedding Model",description:"Advanced: explicit embedding model id that overrides the variant. Leave empty to use mnemopi.embeddingVariant.",condition:"mnemopiActive"}},"mnemopi.embeddingApiUrl":{type:"string",ui:{tab:"memory",group:"Mnemopi",label:"Mnemopi Embedding API URL",description:"Optional OpenAI-compatible embedding endpoint passed to Mnemopi",condition:"mnemopiActive"}},"mnemopi.embeddingApiKey":{type:"string",ui:{tab:"memory",group:"Mnemopi",label:"Mnemopi Embedding API Key",description:"Optional embedding API key passed to Mnemopi",condition:"mnemopiActive"}},"mnemopi.llmMode":{type:"enum",default:"smol",values:["none","smol","remote"],ui:{tab:"memory",group:"Mnemopi",label:"Mnemopi LLM Mode",description:"Use no LLM, the online tiny model (the TINY role from /models, else @smol), or a remote OpenAI-compatible endpoint",condition:"mnemopiActive",options:[{value:"none",label:"None",description:"Disable Mnemopi LLM-backed extraction"},{value:"smol",label:"Online (tiny)",description:"Use the online tiny model (the TINY role from /models, else @smol)"},{value:"remote",label:"Remote",description:"Use the Mnemopi remote LLM settings below"}]}},"mnemopi.llmBaseUrl":{type:"string",ui:{tab:"memory",group:"Mnemopi",label:"Mnemopi LLM Base URL",description:"Optional OpenAI-compatible LLM endpoint for Mnemopi remote mode",condition:"mnemopiActive"}},"mnemopi.llmApiKey":{type:"string",ui:{tab:"memory",group:"Mnemopi",label:"Mnemopi LLM API Key",description:"Optional LLM API key for Mnemopi remote mode",condition:"mnemopiActive"}},"mnemopi.llmModel":{type:"string",ui:{tab:"memory",group:"Mnemopi",label:"Mnemopi LLM Model",description:"Optional LLM model name for Mnemopi remote mode",condition:"mnemopiActive"}},"hindsight.apiUrl":{type:"string",default:"http://localhost:8888",ui:{tab:"memory",group:"Hindsight",label:"Hindsight API URL",description:"Hindsight server URL (Cloud or self-hosted)",condition:"hindsightActive"}},"hindsight.apiToken":{type:"string",ui:{tab:"memory",group:"Hindsight",label:"Hindsight API Token",description:"Bearer token for authenticated Hindsight servers",condition:"hindsightActive"}},"hindsight.bankId":{type:"string",ui:{tab:"memory",group:"Hindsight",label:"Hindsight Bank ID",description:"Memory bank identifier (default: project name)",condition:"hindsightActive"}},"hindsight.scoping":{type:"enum",default:"per-project-tagged",values:["global","per-project","per-project-tagged"],ui:{tab:"memory",group:"Hindsight",label:"Hindsight Scoping",description:"global = one shared bank; per-project = isolated bank per cwd; per-project-tagged = shared bank with project tags so global + project memories merge on recall",options:[{value:"global",label:"Global",description:"One shared bank — every project sees the same memories"},{value:"per-project",label:"Per project",description:"Isolated bank per cwd basename — projects cannot see each other's memories"},{value:"per-project-tagged",label:"Per project (tagged)",description:"Shared bank, retains tagged with project:<cwd>. Recall surfaces project + untagged global memories together"}],condition:"hindsightActive"}},"hindsight.globalScope":{type:"boolean",default:!1,ui:{tab:"memory",group:"Hindsight",label:"Hindsight Global Scope",description:"Let retain and learn take scope: global, which stores a memory without the project tag so every project recalls it. Needs global or per-project-tagged scoping",condition:"hindsightActive"}},"hindsight.autoRecall":{type:"boolean",default:!0,ui:{tab:"memory",group:"Hindsight",label:"Hindsight Auto Recall",description:"Recall memories on the first turn of each session",condition:"hindsightActive"}},"hindsight.autoRetain":{type:"boolean",default:!0,ui:{tab:"memory",group:"Hindsight",label:"Hindsight Auto Retain",description:"Retain transcript every N turns and at session boundaries",condition:"hindsightActive"}},"hindsight.retainMode":{type:"enum",default:"full-session",values:["full-session","last-turn"],ui:{tab:"memory",group:"Hindsight",label:"Hindsight Retain Mode",description:"full-session = upsert one document per session, last-turn = chunked",options:[{value:"full-session",label:"Full session",description:"Upsert one document per session (recommended)"},{value:"last-turn",label:"Last turn",description:"Chunked retention sliced by turn boundaries"}],condition:"hindsightActive"}},"hindsight.mentalModelsEnabled":{type:"boolean",default:!0,ui:{tab:"memory",group:"Hindsight",label:"Hindsight Mental Models",description:"Read curated reflect summaries (mental models) into developer instructions at boot. Loads existing models on the bank — does not write. Pair with hindsight.mentalModelAutoSeed to also auto-create the built-in seed set.",condition:"hindsightActive"}},"hindsight.mentalModelAutoSeed":{type:"boolean",default:!0,ui:{tab:"memory",group:"Hindsight",label:"Hindsight Mental Model Auto-Seed",description:"At session start, create any built-in mental models (project-conventions, project-decisions, user-preferences) that do not yet exist on the bank.",condition:"hindsightActive"}},"ttsr.enabled":{type:"boolean",default:!0,ui:{tab:"context",group:"Rules (TTSR)",label:"TTSR",description:"Interrupt the agent mid-stream when output matches rule patterns (Time-Traveling Stream Rules)"}},"ttsr.judge":{type:"enum",default:"auto",values:["auto","on","off"],ui:{tab:"context",group:"Rules (TTSR)",label:"Judged Rules",description:"Ask the judge model role each `question` rule about completed replies, reasoning, and tool calls; a yes injects the rule as a warning",options:[{value:"auto",label:"Auto",description:"Judge only when the judge role resolves to a native TypeSafe jev model"},{value:"on",label:"On",description:"Always judge, whichever model the judge role resolves to"},{value:"off",label:"Off",description:"Never judge; question rules stay inactive"}]}},"ttsr.contextMode":{type:"enum",default:"discard",values:["discard","keep"],ui:{tab:"context",group:"Rules (TTSR)",label:"TTSR Context Mode",description:"What to do with partial output when TTSR triggers"}},"ttsr.interruptMode":{type:"enum",default:"always",values:["never","prose-only","tool-only","always"],ui:{tab:"context",group:"Rules (TTSR)",label:"TTSR Interrupt Mode",description:"When to interrupt mid-stream vs inject warning after completion",options:[{value:"always",label:"always",description:"Interrupt on prose and tool streams"},{value:"prose-only",label:"prose-only",description:"Interrupt only on reply/thinking matches"},{value:"tool-only",label:"tool-only",description:"Interrupt only on tool-call argument matches"},{value:"never",label:"never",description:"Never interrupt; inject warning after completion"}]}},"ttsr.repeatMode":{type:"enum",default:"once",values:["once","after-gap"],ui:{tab:"context",group:"Rules (TTSR)",label:"TTSR Repeat Mode",description:"How rules can repeat: once per session or after a message gap"}},"ttsr.repeatGap":{type:"number",default:10,ui:{tab:"context",group:"Rules (TTSR)",label:"TTSR Repeat Gap",description:"Messages before a rule can trigger again",options:[{value:"5",label:"5 messages"},{value:"10",label:"10 messages"},{value:"15",label:"15 messages"},{value:"20",label:"20 messages"},{value:"30",label:"30 messages"}]}},"ttsr.builtinRules":{type:"boolean",default:!0,ui:{tab:"context",group:"Rules (TTSR)",label:"Built-in Rules",description:"Load the default rules shipped with the agent (override individually with ttsr.disabledRules)"}},"ttsr.disabledRules":{type:"array",default:[],ui:{tab:"context",group:"Rules (TTSR)",label:"Disabled Rules",description:"Rule names to ignore entirely (applies to bundled defaults and your own rules)"}},"edit.mode":{type:"enum",default:"hashline",values:["apply_patch","hashline","patch","replace","sloppy","none"],ui:{tab:"files",group:"Editing",label:"Edit Mode",description:"Select the edit tool variant (replace, patch, hashline, or apply_patch); none removes the edit tool and keeps bash enabled"}},"edit.fuzzyMatch":{type:"boolean",default:!0,ui:{tab:"files",group:"Editing",label:"Fuzzy Match",description:"Accept high-confidence fuzzy matches for whitespace differences"}},"edit.fuzzyThreshold":{type:"number",default:0.95,ui:{tab:"files",group:"Editing",label:"Fuzzy Match Threshold",description:"Similarity threshold (0-1) for accepting fuzzy matches",options:[{value:"0.85",label:"0.85",description:"Lenient"},{value:"0.90",label:"0.90",description:"Moderate"},{value:"0.95",label:"0.95",description:"Default"},{value:"0.98",label:"0.98",description:"Strict"}]}},"edit.streamingAbort":{type:"boolean",default:!1,ui:{tab:"files",group:"Editing",label:"Abort on Failed Preview",description:"Abort streaming edit tool calls when patch preview fails"}},"edit.recoverInlineEdits":{type:"boolean",default:!0,ui:{tab:"files",group:"Editing",label:"Recover Inline Edit Payloads",description:"Execute edit payloads the model emits as plain text by converting them into edit tool calls"}},"edit.blockAutoGenerated":{type:"boolean",default:!0,ui:{tab:"files",group:"Editing",label:"Block Auto-Generated Files",description:"Prevent editing of files that appear to be auto-generated (protoc, sqlc, swagger, etc.)"}},"edit.enforceSeenLines":{type:"boolean",default:!0,ui:{tab:"files",group:"Editing",label:"Enforce Seen-Line Guard",description:"Reject edits anchored on lines a prior read/search never displayed in full"}},"edit.blackbox.enabled":{type:"boolean",default:!1,ui:{tab:"files",group:"Editing",label:"Record Parse Regressions",description:"Append full before/after source when an edit introduces an AST parse failure"}},"edit.autoRepair.enabled":{type:"boolean",default:!1,ui:{tab:"files",group:"Editing",label:"Auto-Repair Parse Regressions",description:"When an edit breaks a file's AST parse, ask the smol model to fix the broken region (validated by re-parse; falls back to a warning)"}},"tools.artifactSpillThreshold":{type:"number",default:50,ui:{tab:"tools",group:"Output Limits",label:"Artifact Spill Threshold (KB)",description:"Tool output above this size is saved as an artifact; tail is kept inline",options:[{value:"1",label:"1 KB",description:"~250 tokens"},{value:"2.5",label:"2.5 KB",description:"~625 tokens"},{value:"5",label:"5 KB",description:"~1.25K tokens"},{value:"10",label:"10 KB",description:"~2.5K tokens"},{value:"20",label:"20 KB",description:"~5K tokens"},{value:"30",label:"30 KB",description:"~7.5K tokens"},{value:"50",label:"50 KB",description:"Default; ~12.5K tokens"},{value:"75",label:"75 KB",description:"~19K tokens"},{value:"100",label:"100 KB",description:"~25K tokens"},{value:"200",label:"200 KB",description:"~50K tokens"},{value:"500",label:"500 KB",description:"~125K tokens"},{value:"1000",label:"1 MB",description:"~250K tokens"}]}},"tools.artifactTailBytes":{type:"number",default:20,ui:{tab:"tools",group:"Output Limits",label:"Artifact Tail Size (KB)",description:"Amount of tail content kept inline when output spills to artifact",options:[{value:"1",label:"1 KB",description:"~250 tokens"},{value:"2.5",label:"2.5 KB",description:"~625 tokens"},{value:"5",label:"5 KB",description:"~1.25K tokens"},{value:"10",label:"10 KB",description:"~2.5K tokens"},{value:"20",label:"20 KB",description:"Default; ~5K tokens"},{value:"50",label:"50 KB",description:"~12.5K tokens"},{value:"100",label:"100 KB",description:"~25K tokens"},{value:"200",label:"200 KB",description:"~50K tokens"}]}},"tools.artifactHeadBytes":{type:"number",default:20,ui:{tab:"tools",group:"Output Limits",label:"Artifact Head Size (KB)",description:"Amount of head content kept inline alongside the tail when output spills to artifact (middle elision). 0 disables — keep tail only.",options:[{value:"0",label:"0 KB",description:"Disabled; tail-only truncation"},{value:"1",label:"1 KB",description:"~250 tokens"},{value:"2.5",label:"2.5 KB",description:"~625 tokens"},{value:"5",label:"5 KB",description:"~1.25K tokens"},{value:"10",label:"10 KB",description:"~2.5K tokens"},{value:"20",label:"20 KB",description:"Default; ~5K tokens"},{value:"50",label:"50 KB",description:"~12.5K tokens"},{value:"100",label:"100 KB",description:"~25K tokens"},{value:"200",label:"200 KB",description:"~50K tokens"}]}},"tools.outputMaxColumns":{type:"number",default:768,ui:{tab:"tools",group:"Output Limits",label:"Output Column Cap",description:"Per-line byte cap for streaming tool outputs (bash, python, js eval) and `read`. Lines wider than this are ellipsis-truncated; remaining bytes up to the next newline are dropped. 0 disables.",options:[{value:"0",label:"Off",description:"No per-line cap"},{value:"256",label:"256",description:"Tight"},{value:"512",label:"512"},{value:"768",label:"768",description:"Default"},{value:"1024",label:"1024"},{value:"2048",label:"2048"},{value:"4096",label:"4096",description:"Loose"}]}},"tools.artifactTailLines":{type:"number",default:500,ui:{tab:"tools",group:"Output Limits",label:"Artifact Tail Lines",description:"Maximum lines of tail content kept inline when output spills to artifact",options:[{value:"50",label:"50 lines",description:"~250 tokens"},{value:"100",label:"100 lines",description:"~500 tokens"},{value:"250",label:"250 lines",description:"~1.25K tokens"},{value:"500",label:"500 lines",description:"Default; ~2.5K tokens"},{value:"1000",label:"1000 lines",description:"~5K tokens"},{value:"2000",label:"2000 lines",description:"~10K tokens"},{value:"5000",label:"5000 lines",description:"~25K tokens"}]}},"tools.artifactMaxBytes":{type:"number",default:16,ui:{tab:"tools",group:"Output Limits",label:"Artifact File Cap (MB)",description:"Maximum size of the artifact file saved for streaming tool output (bash, python, js eval). Larger output keeps its beginning (up to 3 MB) and its most recent remainder, with a truncation notice between them. 0 = unlimited.",options:[{value:"0",label:"Unlimited",description:"Save the complete output"},{value:"4",label:"4 MB"},{value:"16",label:"16 MB",description:"Default"},{value:"64",label:"64 MB"},{value:"256",label:"256 MB"},{value:"1024",label:"1 GB"}]}},readLineNumbers:{type:"boolean",default:!1,ui:{tab:"files",group:"Reading",label:"Line Numbers",description:"Prepend line numbers to read tool output by default"}},"read.defaultLimit":{type:"number",default:300,ui:{tab:"files",group:"Reading",label:"Default Read Limit",description:"Default number of lines returned when agent calls read without a limit",options:[{value:"200",label:"200 lines"},{value:"300",label:"300 lines"},{value:"500",label:"500 lines"},{value:"1000",label:"1000 lines"},{value:"5000",label:"5000 lines"}]}},"read.renderMarkdown":{type:"boolean",default:!1,ui:{tab:"files",group:"Reading",label:"Markdown Previews",description:"Render Markdown read results as formatted terminal Markdown previews instead of raw source"}},"read.summarize.enabled":{type:"boolean",default:!0,ui:{tab:"files",group:"Read Summaries",label:"Read Summaries",description:"Return structural code summaries when read is called without an explicit selector"}},"read.summarize.prose":{type:"boolean",default:!1,ui:{tab:"files",group:"Read Summaries",label:"Prose Summaries",description:"Return structural summaries for Markdown and plain text reads"}},"read.summarize.minBodyLines":{type:"number",default:4,ui:{tab:"files",group:"Read Summaries",label:"Read Summary Body Lines",description:"Minimum multiline body or literal length before read summaries collapse it"}},"read.summarize.minCommentLines":{type:"number",default:6,ui:{tab:"files",group:"Read Summaries",label:"Read Summary Comment Lines",description:"Minimum multiline block comment length before read summaries collapse it"}},"read.summarize.minTotalLines":{type:"number",default:100,ui:{tab:"files",group:"Read Summaries",label:"Read Summary Minimum File Length",description:"Files with fewer total lines are read verbatim instead of structurally summarized"}},"read.summarize.unfoldUntil":{type:"number",default:50,ui:{tab:"files",group:"Read Summaries",label:"Read Summary Unfold Target",description:"BFS-unfold elidable spans until the summary is at least this many visible lines. 0 keeps only the outermost elisions."}},"read.summarize.unfoldLimit":{type:"number",default:100,ui:{tab:"files",group:"Read Summaries",label:"Read Summary Unfold Ceiling",description:"Hard ceiling on summary size while BFS-unfolding. An unfold whose revealed lines would exceed this is skipped (that span stays folded) and unfolding continues with the remaining spans."}},"read.toolResultPreview":{type:"boolean",default:!1,ui:{tab:"files",group:"Reading",label:"Inline Read Previews",description:"Render read tool results inline in the transcript instead of summary rows"}},"tools.approval":{type:"record",default:{},ui:{tab:"interaction",group:"Approvals",label:"Tool Approval Policies",description:"Per-tool approval policies. Set to 'allow' to auto-approve, 'prompt' to require confirmation, or 'deny' to block. Overrides are honored in every approval mode."}},"tools.approvalMode":{type:"enum",default:"yolo",values:["always-ask","always-ask-cached","write","yolo"],ui:{tab:"interaction",group:"Approvals",label:"Tool Approval",description:"Default approval behavior for tool calls. 'Always ask' auto-approves read-only tools only. 'Ask and remember' also asks before file reads, and can remember a file or folder. 'Write' auto-approves read and workspace-write tools. 'Yolo' auto-approves all tiers; user policy may still prompt or block.",options:[{value:"always-ask",label:"Always ask",description:"Auto-approve read-only tools; require confirmation for write and exec tools."},{value:"always-ask-cached",label:"Ask and remember",description:"Ask before reading or writing a file, with answers that remember the file or its folder for this session or every session; require confirmation for exec tools."},{value:"write",label:"Write",description:"Auto-approve read-only and write tools; require confirmation for exec tools such as bash, eval, browser, and task."},{value:"yolo",label:"Yolo",description:"Auto-approve read, write, and exec tools. User policy can still require confirmation or block calls."}]}},"tools.restrictedFolders":{type:"array",default:[],ui:{tab:"interaction",group:"Approvals",label:"Restricted Folders",editor:"json",description:'Folders where every read, write, edit, search, or command needs an explicit approval, whatever the approval mode or a remembered grant. The folder and everything under it is restricted; commands are matched by the directory they run in. A JSON list of paths, e.g. ["~/secrets"].',condition:"restrictedFoldersNotProject"}},"todo.enabled":{type:"boolean",default:!0,ui:{tab:"tools",group:"Available Tools",label:"Todos",description:"Enable the todo tool for task tracking"}},"todo.reminders":{type:"boolean",default:!0,ui:{tab:"tools",group:"Todos",label:"Todo Reminders",description:"Remind the agent to complete todos before stopping"}},"todo.remindersMax":{type:"number",default:3,ui:{tab:"tools",group:"Todos",label:"Todo Reminder Limit",description:"Maximum number of todo reminders before giving up",options:[{value:"1",label:"1 reminder"},{value:"2",label:"2 reminders"},{value:"3",label:"3 reminders"},{value:"5",label:"5 reminders"}]}},"todo.eager":{type:"enum",default:"default",values:["default","preferred","always"],ui:{tab:"tools",group:"Todos",label:"Create Todos Automatically",description:"How strongly to push automatic todo-list creation after the first message",options:[{value:"default",label:"Default",description:"Model decides; no automatic todo list"},{value:"preferred",label:"Preferred",description:"Suggests a todo list on the first message (reminder, not forced)"},{value:"always",label:"Always",description:"Forces a comprehensive todo list on the first message"}]}},"tasks.todoClearDelay":{type:"number",default:60,ui:{tab:"tools",group:"Todos",label:"Todo Auto-Clear Delay",description:"Delay before completed or abandoned todos are removed from the todo widget",options:[{value:"0",label:"Instant"},{value:"60",label:"1 minute",description:"Default"},{value:"300",label:"5 minutes"},{value:"900",label:"15 minutes"},{value:"1800",label:"30 minutes"},{value:"3600",label:"1 hour"},{value:"-1",label:"Never"}]}},"glob.enabled":{type:"boolean",default:!0,ui:{tab:"tools",group:"Available Tools",label:"Glob",description:"Enable the glob tool for glob-based file lookup"}},"grep.enabled":{type:"boolean",default:!0,ui:{tab:"tools",group:"Available Tools",label:"Grep",description:"Enable the grep tool for regex content search"}},"grep.contextBefore":{type:"number",default:1,ui:{tab:"tools",group:"Grep & Browser",label:"Grep Context Before",description:"Lines of context before each grep match",options:[{value:"0",label:"0 lines"},{value:"1",label:"1 line"},{value:"2",label:"2 lines"},{value:"3",label:"3 lines"},{value:"5",label:"5 lines"}]}},"grep.contextAfter":{type:"number",default:3,ui:{tab:"tools",group:"Grep & Browser",label:"Grep Context After",description:"Lines of context after each grep match",options:[{value:"0",label:"0 lines"},{value:"1",label:"1 line"},{value:"2",label:"2 lines"},{value:"3",label:"3 lines"},{value:"5",label:"5 lines"},{value:"10",label:"10 lines"}]}},"astGrep.enabled":{type:"boolean",default:!1,ui:{tab:"tools",group:"Available Tools",label:"AST Grep",description:"Enable the ast_grep tool for structural AST search"}},"astEdit.enabled":{type:"boolean",default:!0,ui:{tab:"tools",group:"Available Tools",label:"AST Edit",description:"Enable the ast_edit tool for structural AST rewrites"}},"find.verifyModel":{type:"string",ui:{tab:"tools",group:"Find",label:"Find Verification Model",description:"Model selector (e.g. openrouter/liquid/d1-ultra) tried first for find's passage verification, before the judge role; filename and sketch ranking stay on the judge role. Unset: the judge role verifies too"}},"find.enabled":{type:"enum",default:"auto",values:["auto","on","off"],ui:{tab:"tools",group:"Available Tools",label:"Find (semantic grep)",description:"Enable the find tool: natural-language search for files and line ranges, judged by the judge model role. Auto enables it only when the judge role resolves to a native TypeSafe jev model",options:[{value:"auto",label:"Auto",description:"Enable when the judge role resolves to a native TypeSafe jev model"},{value:"on",label:"On",description:"Always enable, whichever model the judge role resolves to"},{value:"off",label:"Off",description:"Disable the find tool"}]}},"debug.enabled":{type:"boolean",default:!0,ui:{tab:"tools",group:"Available Tools",label:"Debug",description:"Enable the debug tool for DAP-based debugging"}},"launch.enabled":{type:"boolean",default:!0,ui:{tab:"tools",group:"Available Tools",label:"Services",description:"Enable named bash services and proc:// supervision for shared long-running project processes"}},"speechgen.enabled":{type:"boolean",default:!1,ui:{tab:"tools",group:"Available Tools",label:"Speech Generation",description:"Enable the tts tool for on-device (Kokoro) or xAI Grok Voice speech-file synthesis"}},"generate_image.enabled":{type:"boolean",default:!1,ui:{tab:"tools",group:"Available Tools",label:"Generate Image",description:"Enable the generate_image tool (text-to-image generation and editing). Exposed as an xd:// device when tools.xdev is on."}},"computer.enabled":{type:"boolean",default:!1,ui:{tab:"tools",group:"Available Tools",label:"Computer",description:"Enable the scriptable host-desktop eval prelude (screenshots, input, accessibility)"}},"ratchet.enabled":{type:"boolean",default:!1,ui:{tab:"tools",group:"Available Tools",label:"Ratchet",description:"Enable the ratchet eval/hillclimb prelude; /ratchet turns it on for the current session"}},"archive.enabled":{type:"boolean",default:!0,ui:{tab:"tools",group:"Available Tools",label:"Archive",description:"Enable the read-only archive eval prelude: prompt history, recent projects, past sessions and recaps"}},"computer.display":{type:"string",default:"active",ui:{tab:"tools",group:"Computer",label:"Computer Display",description:"Active window's display (active), all displays (all), or a native display id"}},"computer.maxWidth":{type:"number",default:3840,ui:{tab:"tools",group:"Computer",label:"Computer Screenshot Width",description:"Maximum screenshot width in pixels"}},"computer.maxHeight":{type:"number",default:2400,ui:{tab:"tools",group:"Computer",label:"Computer Screenshot Height",description:"Maximum screenshot height in pixels"}},"computer.backgroundFallback":{type:"enum",default:"takeover",values:["takeover","refuse"],ui:{tab:"tools",group:"Computer",label:"Computer Background Fallback",description:"What window input does when its background route is unavailable: rerun it in takeover and return focus to your app (macOS; elsewhere plain takeover), or refuse, which also keeps the agent from taking the foreground or opening macOS menus itself",options:[{value:"takeover",label:"Takeover",description:"Briefly bring the target forward for that one call, then return focus to your app (on macOS even if you kept typing)"},{value:"refuse",label:"Refuse",description:"Fail the call; nothing takes over, and the agent's own takeover, raise, activating open, desktop input and macOS menus (context menus, popup and menu buttons; they take your keyboard while open) are refused too"}]}},"images.questionTimeoutMs":{type:"number",default:300000,ui:{tab:"tools",group:"Execution",label:"Image Question Timeout",description:"Per-request timeout for the vision-model call behind read's ?q= image questions, in milliseconds. A stalled provider fails fast with a timeout error instead of blocking until manual abort. Set to 0 to disable the timeout.",options:[{value:"0",label:"Disabled"},{value:"60000",label:"1 minute"},{value:"120000",label:"2 minutes"},{value:"180000",label:"3 minutes"},{value:"300000",label:"5 minutes"}]}},"checkpoint.enabled":{type:"boolean",default:!1,ui:{tab:"tools",group:"Available Tools",label:"Checkpoint/Rewind",description:"Enable the checkpoint and rewind tools for context checkpointing"}},"fetch.enabled":{type:"boolean",default:!0,ui:{tab:"tools",group:"Available Tools",label:"Read URLs",description:"Allow the read tool to fetch and process URLs"}},"vault.enabled":{type:"boolean",default:!1,ui:{tab:"tools",group:"Available Tools",label:"Obsidian Vault",description:"Enable the vault:// internal URL for reading and editing Obsidian vault content via the Obsidian CLI. When disabled, vault:// resolution is refused and the vault:// entry is omitted from the system prompt."}},"github.enabled":{type:"boolean",default:!1,ui:{tab:"tools",group:"Available Tools",label:"GitHub CLI",description:"Enable the github tool (op-based dispatch for repository, issue, pull request, diff, search, checkout, push, and Actions watch workflows)"}},"github.cache.enabled":{type:"boolean",default:!0,ui:{tab:"tools",group:"GitHub",label:"GitHub View Cache",description:"Cache rendered issue/PR view output in ~/.omp/cache/github-cache.db so repeated reads are free"}},"github.cache.softTtlSec":{type:"number",default:300,ui:{tab:"tools",group:"GitHub",label:"GitHub Cache Soft TTL",description:"Within this window, cached issue/PR view rows are returned directly (seconds; default 5 minutes)"}},"github.cache.hardTtlSec":{type:"number",default:604800,ui:{tab:"tools",group:"GitHub",label:"GitHub Cache Hard TTL",description:"Past the soft TTL the cached row is returned and refreshed in the background; past the hard TTL it is dropped (seconds; default 7 days)"}},"web_search.enabled":{type:"boolean",default:!0,ui:{tab:"tools",group:"Available Tools",label:"Web Search",description:"Enable the web_search tool for live web results"}},"security.enabled":{type:"boolean",default:!1,ui:{tab:"tools",group:"Available Tools",label:"Security",description:"Enable OMP-native security scan planning, execution, and the read-only security:// resource namespace"}},"ask.enabled":{type:"boolean",default:!0,ui:{tab:"tools",group:"Available Tools",label:"Ask",description:"Enable the ask tool for interactive user questions"}},"out.enabled":{type:"boolean",default:!0,ui:{tab:"tools",group:"Available Tools",label:"Out",description:"Let the agent reply mid-task by writing to out://, shown like a response without ending its turn. Unset: on in the interactive TUI, off in print, RPC, and ACP"}},"tools.intentTracing":{type:"boolean",default:!0,ui:{tab:"tools",group:"Execution",label:"Intent Tracing",description:"Ask the agent to describe the intent of each tool call before executing it"}},"tools.abortOnFabricatedResult":{type:"boolean",default:!0,ui:{tab:"tools",group:"Execution",label:"Abort On Fabricated Tool Result",description:"With in-band tool calls, stop the model immediately when it starts hallucinating a tool result mid-turn. Disable to let the model finish generating and discard the fabricated continuation instead."}},"tools.speculativeExecution.enabled":{type:"boolean",default:!1,ui:{tab:"tools",group:"Execution",label:"Experimental Speculative Execution",description:"Enable the discard-safe first slice: validated local reads through direct read calls and nested eval. Network requests, provider completions, and live filesystem writes are not part of this baseline."}},"tools.speculativeExecution.maxInFlight":{type:"number",default:2,ui:{tab:"tools",group:"Execution",label:"Speculative Execution Concurrency",description:"Maximum number of validated local reads allowed to run before normal dispatch.",options:[{value:"1",label:"1 operation"},{value:"2",label:"2 operations"},{value:"3",label:"3 operations"},{value:"4",label:"4 operations"}]}},"tools.maxTimeout":{type:"number",default:0,ui:{tab:"tools",group:"Execution",label:"Max Tool Timeout",description:"Maximum timeout in seconds the agent can set for any tool (0 = no limit)",options:[{value:"0",label:"No limit"},{value:"30",label:"30 seconds"},{value:"60",label:"60 seconds"},{value:"120",label:"120 seconds"},{value:"300",label:"5 minutes"},{value:"600",label:"10 minutes"}]}},"async.enabled":{type:"boolean",default:!0,ui:{tab:"tools",group:"Execution",label:"Async Execution",description:"Enable async bash commands and background task execution"}},"async.printWake":{type:"boolean",default:!1,ui:{tab:"tools",group:"Execution",label:"Wake Print Mode on Job Results",description:"In print mode (-p, --mode json), keep running after the last prompt while this run's background jobs are active, and start another turn in the same session with each job's result; exits once no job or result is pending. Off: print mode exits after its prompts and cancels running jobs"}},"async.widgets":{type:"boolean",default:!0,ui:{tab:"tools",group:"Execution",label:"Live Job Widgets",description:"Draw a live widget for each running background job (charts, bars, status grids derived from its output) in the wait card, the jobs pill and the jobs sheet, and caption long shell commands with one line on what they do. The `widget` model role (default: `smol`) writes one spec and at most one caption per job; updates need no further model calls"}},"tools.xdev":{type:"boolean",default:!0,ui:{tab:"tools",group:"Discovery & MCP",label:"xd:// Tools",description:"Mount rarely-used (discoverable) tools under xd:// device URLs driven via read/write instead of shipping their schemas on every request. Sessions whose explicit tool list grants read but omits write mount devices through a device-only write transport (only local:// scratch stays writable besides devices). Disable to expose every enabled tool top-level."}},"tools.xdevDocs":{type:"enum",default:"catalog",values:["inline","builtins","catalog"],ui:{tab:"tools",group:"Discovery & MCP",label:"xd:// Prompt Docs",description:"Choose which mounted-device docs and schemas are inlined in the system prompt. Built-ins keeps core tools inline while MCP and extension tools stay on-demand.",options:[{value:"inline",label:"All Devices",description:"Inline docs and schemas for every mounted device."},{value:"builtins",label:"Built-ins Only",description:"Inline built-in docs; fetch MCP and extension docs on demand."},{value:"catalog",label:"Catalog Only",description:"List every device; fetch all docs on demand."}]}},"tools.xdevInlineDevices":{type:"array",default:[],ui:{tab:"tools",group:"Discovery & MCP",label:"xd:// Inline Devices",description:"When xd:// Prompt Docs is Built-ins Only, inline dynamic devices whose names match these glob patterns (for example mcp__context_mode_*). Catalog Only ignores this setting."}},"tools.xdevNotices":{type:"boolean",default:!0,ui:{tab:"tools",group:"Discovery & MCP",label:"xd:// Mount Notices",description:"Show an `xd://: mounted …` notice when MCP or extension tools are mounted or unmounted. The model still learns of the change with its next prompt."}},"dev.autoqa":{type:"boolean",default:!0,ui:{tab:"tools",group:"Developer",label:"Auto QA",description:"Automated tool issue reporting (xd://report_issue). On by default; the first report asks for consent, and denying it disables reporting until re-enabled explicitly"}},"dev.autoqaPush.endpoint":{type:"string",default:"https://qa.omp.sh/v1/grievances",ui:{tab:"tools",group:"Developer",label:"Auto QA Push Endpoint",description:"Full URL receiving Auto QA JSON reports (default https://qa.omp.sh/v1/grievances)"}},"lsp.enabled":{type:"boolean",default:!0,ui:{tab:"files",group:"LSP",label:"LSP",description:"Language-server integration: the lsp tool, diagnostics on write/edit, and format on write (--no-lsp disables for the run)"}},"lsp.lazy":{type:"boolean",default:!0,ui:{tab:"files",group:"LSP",label:"Lazy LSP Startup",description:"Start language servers on first use (lsp tool or editing a matching file type) instead of at session startup"}},"lsp.shared":{type:"boolean",default:!0,ui:{tab:"files",group:"LSP",label:"Shared Language Servers",description:"Start language servers through the per-project daemon broker. Each connection gets its own server. While another omp instance in the project is running, a released server stays warm and the next connection reuses it instead of cold-starting (falls back to private servers when unavailable)"}},"lsp.formatOnWrite":{type:"boolean",default:!1,ui:{tab:"files",group:"LSP",label:"Format on Write",description:"Automatically format code files using LSP after writing"}},"lsp.diagnosticsOnWrite":{type:"boolean",default:!0,ui:{tab:"files",group:"LSP",label:"Diagnostics on Write",description:"Return LSP diagnostics after writing code files"}},"lsp.diagnosticsOnEdit":{type:"boolean",default:!1,ui:{tab:"files",group:"LSP",label:"Diagnostics on Edit",description:"Return LSP diagnostics after editing code files"}},"lsp.diagnosticsDeduplicate":{type:"boolean",default:!0,ui:{tab:"files",group:"LSP",label:"Deduplicate Diagnostics",description:"Suppress post-edit LSP diagnostics already shown for a file; only surface new or changed ones"}},"lsp.requestTimeout":{type:"number",default:10,ui:{tab:"files",group:"LSP",label:"Request Timeout",description:"Seconds to wait for a language server's diagnostics, hover and other answers when the agent sets no timeout; late post-edit diagnostics wait at least this long. Raise it for servers that are slow on a cold start. The lsp tool's timeout argument can still raise or lower it per call",options:[{value:"10",label:"10 seconds",description:"Default"},{value:"20",label:"20 seconds"},{value:"30",label:"30 seconds"},{value:"60",label:"1 minute"},{value:"120",label:"2 minutes"},{value:"300",label:"5 minutes"}]}},"bash.enabled":{type:"boolean",default:!0,ui:{tab:"shell",group:"Bash",label:"Bash",description:"Enable the bash tool for shell command execution"}},"bash.allowCompoundCommands":{type:"boolean",default:!1,ui:{tab:"shell",group:"Bash",label:"Allow Compound Commands",description:"Evaluate literal && chains per command; unmatched commands use normal bash approval policy and mode"}},"bash.autoBackground.enabled":{type:"boolean",default:!0,ui:{tab:"shell",group:"Bash",label:"Bash Auto-Background",description:"Automatically background long-running bash commands and deliver the result later"}},"bash.gitGuard":{type:"boolean",default:!1,ui:{tab:"shell",group:"Bash",label:"Git Guard",description:"Refuse git commands that discard or move shared work in a repository's main checkout: stash, reset --hard or to another commit, and checkout/switch/restore outside a merge or rebase conflict. In a linked worktree they run, saving uncommitted changes they discard first"}},"bash.patterns":{type:"array",default:[],ui:{tab:"shell",group:"Bash",label:"Bash Approval Patterns",description:"Ordered bash command approval rules. Each item has match and approval fields; only '*' wildcards are supported."}},"bashInterceptor.enabled":{type:"boolean",default:!1,ui:{tab:"shell",group:"Bash",label:"Bash Interceptor",description:"Block shell commands that have dedicated tools"}},"bash.direnv":{type:"enum",default:"auto",values:["auto","off"],ui:{tab:"shell",group:"Bash",label:"direnv Auto-Load",description:"Auto-load a repo's direnv/devenv `.envrc` into the bash session so devenv tools and env vars are present without manual `direnv exec`. Honors direnv's allow list: an `.envrc` you haven't `direnv allow`ed is never executed"}},"bash.direnvLoadTimeoutMs":{type:"number",default:30000,ui:{tab:"shell",group:"Bash",label:"direnv Load Timeout (ms)",description:"Max wait for the first `direnv export` (a cold devenv shell can be slow); on timeout the session runs without the direnv env"}},"shellMinimizer.enabled":{type:"boolean",default:!0,ui:{tab:"shell",group:"Bash",label:"Shell Minimizer",description:"Compress verbose shell output (git, npm, cargo, etc.) before returning it to the agent"}},"shellMinimizer.sourceOutlineLevel":{type:"enum",default:"default",values:["default","aggressive"],ui:{tab:"shell",group:"Bash",label:"Shell Minimizer Source Outline",description:"Source outline mode for cat/read of source files: default or aggressive"}},"eval.py":{type:"boolean",default:!0,ui:{tab:"shell",group:"Eval & Runtimes",label:"Python Eval Backend",description:"Allow the eval tool to dispatch Python cells to the IPython kernel"}},"eval.js":{type:"boolean",default:!0,ui:{tab:"shell",group:"Eval & Runtimes",label:"JavaScript Eval Backend",description:"Allow the eval tool to dispatch JavaScript cells to the in-process runtime"}},"eval.autoProvision":{type:"boolean",default:!0,ui:{tab:"shell",group:"Eval & Runtimes",label:"Eval Environment Provisioning",description:"Automatically create the managed JavaScript eval package environment on first install"}},"eval.tools.enabled":{type:"boolean",default:!0,ui:{tab:"shell",group:"Eval & Runtimes",label:"Eval-Defined Tools",description:"Let eval cells define tools (@tool in Python, tool(fn) in JS) that task, agent(), and workpool() subagents can call"}},"eval.workpool.freshAgents":{type:"boolean",default:!1,ui:{tab:"shell",group:"Eval & Runtimes",label:"Fresh Workpool Agents",description:"Spawn a new subagent for every workpool item instead of reusing workers or batching queued items"}},"eval.autoBackground.enabled":{type:"boolean",default:!1,ui:{tab:"shell",group:"Eval & Runtimes",label:"Eval Auto-Background",description:"Automatically background long-running eval cells and deliver the result later"}},"python.kernelMode":{type:"enum",default:"session",values:["session","per-call"],ui:{tab:"shell",group:"Eval & Runtimes",label:"Python Kernel Mode",description:"Keep the IPython kernel alive across eval calls or start fresh each time"}},"python.interpreter":{type:"string",default:"",ui:{tab:"shell",group:"Eval & Runtimes",label:"Python Interpreter",description:"Optional path to an exact Python executable. When set, automatic Python runtime discovery is skipped."}},"task.isolation.enabled":{type:"boolean",default:!1,ui:{tab:"tasks",group:"Isolation",label:"Allow Isolated Subagents",description:"Allow per-task isolation with `isolated: true`; tasks without it run in the shared checkout"}},"isolation.backend":{type:"enum",default:"auto",values:["auto","apfs","btrfs","zfs","reflink","overlayfs","projfs","block-clone","rcopy"],ui:{tab:"tasks",group:"Isolation",label:"Isolation Backend",description:"Backend used for subagent isolation and worktree cloning",options:[{value:"auto",label:"Auto",description:"Isolated subagents use ovnfs checkouts when ovnfs is found; otherwise (and for worktrees) the PAL picks the best available backend"},{value:"apfs",label:"APFS",description:"macOS clonefile reflink (APFS)"},{value:"btrfs",label:"btrfs",description:"btrfs subvolume snapshot"},{value:"zfs",label:"ZFS",description:"ZFS snapshot + clone"},{value:"reflink",label:"Reflink",description:"Linux FICLONE per-file reflink"},{value:"overlayfs",label:"Overlayfs",description:"Linux kernel overlay (or fuse-overlayfs fallback)"},{value:"projfs",label:"ProjFS",description:"Windows Projected File System"},{value:"block-clone",label:"Block clone",description:"Windows FSCTL_DUPLICATE_EXTENTS_TO_FILE (NTFS/ReFS)"},{value:"rcopy",label:"Recursive copy",description:"git worktree if available, otherwise recursive copy"}]}},"worktree.clone":{type:"boolean",default:!0,ui:{tab:"tasks",group:"Isolation",label:"Clone Checkout into Worktrees",description:"New worktrees from `github pr_checkout` and `git worktree add` in bash start as a copy-on-write clone of the current checkout so ignored build artifacts (node_modules, target) carry over; falls back to a plain checkout when the filesystem cannot clone"}},"worktree.cleanSource":{type:"boolean",default:!1,ui:{tab:"tasks",group:"Isolation",label:"Clean Source Checkout on /wt",description:"When creating a worktree with `/wt`, reset tracked changes and remove untracked files from the original checkout after carrying them over"}},"worktree.onStart":{type:"enum",default:"off",values:["off","ask","create"],ui:{tab:"tasks",group:"Isolation",label:"Worktree on Start",description:"Whether fresh interactive sessions start in a new linked worktree",options:[{value:"off",label:"Off",description:"Start in the current checkout"},{value:"ask",label:"Ask",description:"Ask at session start"},{value:"create",label:"Create",description:"Always start in a new worktree on a `wt/*` branch"}]}},"worktree.onExit":{type:"enum",default:"keep",values:["keep","ask","remove"],ui:{tab:"tasks",group:"Isolation",label:"Worktree on Exit",description:"What to do on exit with worktrees created since omp started (on start or with `/wt`)",options:[{value:"keep",label:"Keep",description:"Leave worktrees in place"},{value:"ask",label:"Ask",description:"Ask on exit"},{value:"remove",label:"Remove",description:"Remove clean worktrees; ask when they have uncommitted changes or new commits. Gitignored files (e.g. `.env`) are deleted too"}]}},"task.isolation.apply":{type:"boolean",default:!0,ui:{tab:"tasks",group:"Isolation",label:"Apply Isolated Changes",description:"Automatically apply successful isolated task changes to the parent checkout; disable to retain patch or branch artifacts"}},"ovnfs.path":{type:"string",ui:{tab:"tasks",group:"Isolation",label:"ovnfs Binary",description:"ovnfs executable; unset looks for `ovnfs` on PATH. When it is found, ovnfs checkouts (copy-on-write views of a folder, ready in about a second at any size) serve every separate copy: the system prompt tells agents to open checkouts instead of git worktrees or copies, and isolated subagents (when allowed, with `isolation.backend` on auto) run in checkouts instead of native clones"}},"task.isolation.merge":{type:"enum",default:"patch",values:["patch","branch"],ui:{tab:"tasks",group:"Isolation",label:"Isolation Merge Strategy",description:"How isolated task changes are integrated (patch apply or branch merge)",options:[{value:"patch",label:"Patch",description:"Combine diffs and git apply"},{value:"branch",label:"Branch",description:"Commit per task, merge with --no-ff"}]}},"task.isolation.commits":{type:"enum",default:"generic",values:["generic","ai"],ui:{tab:"tasks",group:"Isolation",label:"Isolation Commit Style",description:"Commit message style for nested repo changes (generic or AI-generated)",options:[{value:"generic",label:"Generic",description:"Static commit message"},{value:"ai",label:"AI",description:"AI-generated commit message from diff"}]}},"worktree.base":{type:"string",ui:{tab:"tasks",group:"Isolation",label:"Worktree Base Directory",description:"Base directory for agent-managed worktrees — task-isolation copies, `github` PR checkouts, and `omp worktree` cleanup all live here. Unset uses ~/.omp/wt. Must be an absolute or ~-relative path; relative paths are ignored. The OMP_WORKTREE_DIR env var overrides this."}},"task.eager":{type:"enum",default:"default",values:["default","preferred","always"],ui:{tab:"tasks",group:"Subagents",label:"Prefer Task Delegation",description:"How strongly to push the main agent to delegate work; subagents keep the model's own policy",options:[{value:"default",label:"Default",description:"Uses the selected model's policy; some models require an explicit delegation request"},{value:"preferred",label:"Preferred",description:"Adds delegation guidance to the system prompt"},{value:"always",label:"Always",description:"Prompt guidance plus a first-turn delegation reminder"}]}},"task.autoParallel":{type:"enum",default:"off",values:["off","suggest","on"],ui:{tab:"tasks",group:"Subagents",label:"Auto Parallel",description:"Ask the native judge resolved through the 'judge' role which parts of each new top-level prompt can run concurrently. Needs a native judge and the task tool; without them nothing is judged.",options:[{value:"off",label:"Off",description:"Never split prompts"},{value:"suggest",label:"Suggest",description:"Judge each prompt and report the split without acting on it"},{value:"on",label:"On",description:"When a prompt splits into independent subtasks, tell the agent to delegate them in parallel"}]}},"task.batch":{type:"boolean",default:!0,ui:{tab:"tasks",group:"Subagents",label:"Batch Task Calls",description:"Switch the task tool to its batch shape: one call carries { context, tasks[] } — one subagent per item, with an optional per-item agent (defaulting to the session spawn-policy agent), per-item isolation, and a required shared context prepended to every assignment. With async.enabled=true, each spawn runs as an independent background agent with the normal idle/parked lifecycle; otherwise the call blocks for merged results. Disable to restore the flat single-spawn schema."}},"task.steps":{type:"boolean",default:!1,ui:{tab:"tasks",group:"Subagents",label:"Sequential Task Steps",description:"Spawns take ordered `steps` instead of one `task`: the subagent gets the first step, then each next one once it finishes the previous; past 4 steps, earlier messages carry two or more. The last step's result is the task's result."}},"task.structured":{type:"boolean",default:!1,ui:{tab:"tasks",group:"Subagents",label:"Structured Task Results",description:"Expose outputSchema/schemaMode on the task tool and return subagent results through the yield tool, validated against caller or agent output schemas. Off: task subagents have no yield tool and return their final message as plain text, except agents whose definition sets structured: true. Eval agent()/workpool spawns always keep structured results."}},"task.speculativeLaunch":{type:"boolean",default:!0,ui:{tab:"tasks",group:"Subagents",label:"Speculative Task Launch",description:"Start each batch subagent as soon as its tasks[] item finishes streaming instead of waiting for the whole task call. Launched agents are aborted if the finished call fails validation, is blocked, or its arguments change. Requires auto-allowed task approval and no extension tool lifecycle handlers."}},"task.enableEffort":{type:"boolean",default:!1,ui:{tab:"tasks",group:"Subagents",label:"Per-Task Effort",description:"Expose the optional effort parameter on task spawns, allowing callers to override each subagent's thinking level"}},"task.perCallModel":{type:"enum",default:"off",values:["off","eval","on"],ui:{tab:"tasks",group:"Subagents",label:"Per-Call Model",description:"Whether a subagent call may pick its model with one exact provider/model-id[@upstream][:level] selector. An @upstream pin is part of the model identity and is supported only by aggregators. Only models the configuration already routes to are accepted. Project settings can turn it off but not on, and never approve a model.",options:[{value:"off",label:"Off",description:"Reject `model` on task items and eval agent()/workpool()"},{value:"eval",label:"Eval only",description:"Accept `model` in eval agent() and workpool() only"},{value:"on",label:"On",description:"Accept `model` on task items and in eval agent()/workpool()"}]}},"task.perCallModelAllow":{type:"array",default:[],ui:{tab:"tasks",group:"Subagents",label:"Per-Call Model Allowlist",editor:"json",condition:"perCallModelAllowNotProject",description:"Exact selectors: `provider/model-id`, including `@upstream` only for a pinned OpenRouter/Vercel route (e.g. `openrouter/x@y`). When set, a per-call model must also be listed here. Empty: every model the configuration grants. A project list can only narrow this one."}},"task.maxConcurrency":{type:"number",default:32,ui:{tab:"tasks",group:"Subagents",label:"Max Concurrent Tasks",description:"Maximum number of subagents running concurrently",options:[{value:"0",label:"Unlimited"},{value:"1",label:"1 task"},{value:"2",label:"2 tasks"},{value:"4",label:"4 tasks"},{value:"8",label:"8 tasks"},{value:"16",label:"16 tasks"},{value:"32",label:"32 tasks"},{value:"64",label:"64 tasks"}]}},"task.workerThreads":{type:"number",default:4,ui:{tab:"tasks",group:"Subagents",label:"Subagent Worker Threads",description:"Maximum worker threads for subagents. Up to 8 concurrent subagents run on the main thread; at 9 one worker joins, and one more each time the count doubles (18, 36, 72). Workers stop a minute after no subagent is live in them; 0 keeps every subagent on the main thread",options:[{value:"0",label:"Main thread only"},{value:"1",label:"Up to 1 worker"},{value:"2",label:"Up to 2 workers"},{value:"4",label:"Up to 4 workers",description:"Default"},{value:"8",label:"Up to 8 workers"}]}},"task.enableLsp":{type:"boolean",default:!1,ui:{tab:"tasks",group:"Subagents",label:"LSP in Subagents",description:"Allow subagents spawned via the task tool to use the lsp tool. Off by default to keep subagents cheap; enable when LSP-aware delegation is worth the extra tokens."}},"task.maxRecursionDepth":{type:"number",default:2,ui:{tab:"tasks",group:"Subagents",label:"Max Task Recursion",description:"How many levels deep subagents can spawn their own subagents",options:[{value:"-1",label:"Unlimited"},{value:"0",label:"None"},{value:"1",label:"Single"},{value:"2",label:"Double"},{value:"3",label:"Triple"}]}},"task.maxRuntimeMs":{type:"number",default:0,ui:{tab:"tasks",group:"Subagents",label:"Max Subagent Runtime",description:"Hard wall-clock limit per subagent (ms). 0 disables it. Defense-in-depth against provider-side stream hangs that escape the inference-layer watchdog; triggers a normal subagent abort with a 'timed out' reason.",options:[{value:"0",label:"Unlimited",description:"Default"},{value:"300000",label:"5 minutes"},{value:"900000",label:"15 minutes"},{value:"1800000",label:"30 minutes"},{value:"3600000",label:"1 hour"}]}},"task.completionProbe":{type:"boolean",default:!0,ui:{tab:"tasks",group:"Subagents",label:"Subagent Completion Probe",description:"Ask a working subagent, through a cached side request like /btw, to estimate how complete its task is: after 2, 5, 10 and 30 more minutes, then hourly. The estimate shows next to the subagent in wait and task views. Only subagents spawned by the main agent of an interactive session are asked; print, RPC, ACP and SDK runs never probe."}},"task.agentIdleTtlMs":{type:"number",default:420000,ui:{tab:"tasks",group:"Subagents",label:"Agent Idle TTL",description:"How long an idle subagent stays live in memory before being parked to disk (ms). Parked agents are revived automatically when messaged or resumed. 0 keeps idle agents live until exit."}},"task.softRequestBudget":{type:"number",default:200,ui:{tab:"tasks",group:"Subagents",label:"Soft Subagent Request Budget",description:"Soft per-subagent request budget (assistant requests per run). Crossing it injects a wrap-up steering notice (see task.softRequestBudgetNotice); at 1.5x the budget the run is force-stopped and the agent must hand back its partial findings. 0 disables the guard. Bundled scout/sonic agents cap out at a lower built-in budget, so a value below that cap still applies to them. A task.agentSoftRequestBudget entry replaces this budget for the agent it names.",options:[{value:"0",label:"Disabled"},{value:"90",label:"90 requests"},{value:"150",label:"150 requests"},{value:"200",label:"200 requests",description:"Default"}]}},"task.softRequestBudgetNotice":{type:"boolean",default:!0,ui:{tab:"tasks",group:"Subagents",label:"Soft Request Budget Notice",description:"Inject one steering notice when a subagent crosses its soft request budget, asking it to wrap up before the 1.5x forced-yield stop."}},"task.maxEffort":{type:"enum",default:"max",values:["minimal","low","medium","high","xhigh","max"],ui:{tab:"tasks",group:"Subagents",label:"Maximum Per-Spawn Effort",description:"Maximum reasoning effort allowed for the task tool's per-spawn effort hint or a per-call model. An explicit `:level` is clamped to the highest supported effort at or below this ceiling, and an omitted `:level` inherits the agent's thinking level capped at this value; cold revival re-applies the cap. Unset, `:inherit` and `:off` keep their existing meaning. A per-call model must support an effort at or below this ceiling; the default preserves the model's full range.",options:[{value:"minimal",label:"min",description:"Very brief reasoning (~1k tokens)"},{value:"low",label:"low",description:"Light reasoning (~2k tokens)"},{value:"medium",label:"medium",description:"Moderate reasoning (~8k tokens)"},{value:"high",label:"high",description:"Deep reasoning (~16k tokens)"},{value:"xhigh",label:"xhigh",description:"Extended reasoning (~32k tokens)"},{value:"max",label:"max",description:"Maximum reasoning the model supports"}]}},"task.prewalk":{type:"boolean",default:!1,ui:{tab:"tasks",group:"Subagents",label:"Generic Task Prewalk",description:"Arm prewalk for the bundled generic `task` subagent: it starts on its resolved model, plans and begins the implementation, then hands off to the 'smol' role at its first edit/write. Per-agent overrides (task.agentPrewalk, configured from the /agents hub) and user agent `prewalk` frontmatter apply regardless of this toggle."}},"task.showResolvedModelBadge":{type:"boolean",default:!1,ui:{tab:"appearance",group:"Display",label:"Show Resolved Model Badge",description:"Display the actual model ID used by each subagent in the task widget status line"}},"plan.enabled":{type:"boolean",default:!0,ui:{tab:"tasks",group:"Modes",label:"Plan Mode",description:"Enable plan mode for read-only exploration and planning before execution"}},"plan.defaultOnStartup":{type:"boolean",default:!1,ui:{tab:"tasks",group:"Modes",label:"Start in Plan Mode",description:"Automatically enter plan mode at the start of every new session",condition:"planModeEnabled"}},"plan.autosave":{type:"boolean",default:!1,ui:{tab:"tasks",group:"Modes",label:"Autosave Plans",description:"Automatically save approved plans to disk when plan mode completes",condition:"planModeEnabled"}},"plan.autosaveDir":{type:"string",ui:{tab:"tasks",group:"Modes",label:"Autosave Directory",description:"Directory for autosaved plans. Supports ~, absolute, and cwd-relative paths. Empty uses <project>/.omp/plans/.",condition:"planAutosaveEnabled"}},"goal.enabled":{type:"boolean",default:!0,ui:{tab:"tasks",group:"Modes",label:"Goal Mode",description:"Enable per-session goal mode and the hidden goal tool"}},"goal.statusInFooter":{type:"boolean",default:!0,ui:{tab:"tasks",group:"Modes",label:"Goal Status in Footer",description:"Show token budget alongside the goal indicator in the status line"}},"goal.continuationModes":{type:"array",default:["interactive"],ui:{tab:"tasks",group:"Modes",label:"Goal Continuation Modes",description:'Run modes where active goals may auto-continue between turns ("interactive", "rpc")'}},"title.icons":{type:"enum",default:"nf+emoji",values:["nf+emoji","emoji","boring"],ui:{tab:"appearance",group:"Display",label:"Title Icons",description:"Icon and short code that head new generated or /rename session titles",options:[{value:"nf+emoji",label:"Nerd Font + Emoji",description:"Nerd Font glyph where the Nerd Font symbol preset renders it, else the emoji (default)"},{value:"emoji",label:"Emoji",description:"Always the emoji"},{value:"boring",label:"Boring",description:"Plain title: no icon or code"}]}},"title.generator":{type:"enum",default:"fork",values:["fork","tiny"],ui:{tab:"tasks",group:"Modes",label:"Title Generator",description:"What names an untitled session from the user's messages",options:[{value:"fork",label:"Fork",description:"A side turn of the reply on the session's model: reads its prompt cache, adds the card icon (default)"},{value:"tiny",label:"Tiny",description:"The title model role only; plain titles without a card"}]}},"title.refreshOnReplan":{type:"boolean",default:!0,ui:{tab:"tasks",group:"Modes",label:"Refresh Title on Replan",description:"Refresh generated session titles after todo init replans unless the title was set by the user"}},"title.refreshAfterPrompts":{type:"number",default:0,ui:{tab:"tasks",group:"Modes",label:"Refresh Title After Prompts",description:"Every this many operator prompts, ask the judge model whether a generated session title still fits the conversation, and regenerate it if not",options:[{value:"0",label:"Off",description:"Default"},{value:"1",label:"Every prompt"},{value:"3",label:"Every 3 prompts"},{value:"5",label:"Every 5 prompts"},{value:"10",label:"Every 10 prompts"}]}},"skills.registryUrl":{type:"string",default:"https://skills.omp.sh",ui:{tab:"interaction",group:"Skills",label:"Skill Registry",description:"Skillshare registry used by `omp skill` to install, search, and publish skills (https://host[:port])"}},"skills.enableSkillCommands":{type:"boolean",default:!0,ui:{tab:"tasks",group:"Commands & Skills",label:"Skill Commands",description:"Register skills as /skill:name commands"}},"commands.enableClaudeUser":{type:"boolean",default:!1,ui:{tab:"tasks",group:"Commands & Skills",label:"Claude User Commands",description:"Load commands from ~/.claude/commands/"}},"commands.enableClaudeProject":{type:"boolean",default:!0,ui:{tab:"tasks",group:"Commands & Skills",label:"Claude Project Commands",description:"Load commands from .claude/commands/"}},"commands.enableOpencodeUser":{type:"boolean",default:!1,ui:{tab:"tasks",group:"Commands & Skills",label:"OpenCode User Commands",description:"Load commands from ~/.config/opencode/commands/"}},"commands.enableOpencodeProject":{type:"boolean",default:!0,ui:{tab:"tasks",group:"Commands & Skills",label:"OpenCode Project Commands",description:"Load commands from .opencode/commands/"}},"extensionHandlers.toolCallTimeoutMs":{type:"number",default:30000,ui:{tab:"tools",group:"Extensions",label:"Tool Call Handler Timeout (ms)",description:"Positive finite active-work timeout for extension tool_call handlers; invalid values use 30000ms, and time awaiting OMP-owned dialogs does not count"}},"extensionHandlers.modeControl":{type:"boolean",default:!0,ui:{tab:"tools",group:"Extensions",label:"Extension Mode Control",description:"Let extensions enter and exit plan, vibe, goal, and loop modes via ctx.sessionModes.set(); reading mode state stays available"}},"extensionRenderers.assistantText":{type:"boolean",default:!1,ui:{tab:"tools",group:"Extensions",label:"Extension Reply Renderers",description:"Let extensions change how assistant replies are drawn, redraw a reply in place, and receive clicks on their own links; the session, exports and model context keep the reply as written"}},"extensionRenderers.transcriptPresenters":{type:"boolean",default:!1,ui:{tab:"tools",group:"Extensions",label:"Extension Transcript Presenters",description:"Let extensions draw transcript blocks such as tool calls in full, as one compact row, or hidden; the session, exports and model context are unchanged"}},"exa.enabled":{type:"boolean",default:!0,ui:{tab:"providers",group:"Services",label:"Exa",description:"Enable the Exa web search provider"}},"exa.searchDelayMs":{type:"number",default:1000,ui:{tab:"providers",group:"Services",label:"Exa Search Delay",description:"Minimum delay between Exa web search requests in milliseconds; set 0 to disable pacing"}},"searxng.endpoint":{type:"string",ui:{tab:"providers",group:"Services",label:"SearXNG Endpoint",description:"Base URL of a self-hosted SearXNG instance used for web search"}},"browser.enabled":{type:"boolean",default:!0,ui:{tab:"tools",group:"Available Tools",label:"Browser",description:"Enable the browser eval prelude for scripted browser automation"}},"browser.cdpUrl":{type:"string",ui:{tab:"tools",group:"Grep & Browser",label:"Browser CDP URL",description:"Default HTTP CDP discovery endpoint (for example http://127.0.0.1:9222) to attach to instead of launching a browser. An explicit app on the tool call takes precedence."}},"browser.relay":{type:"boolean",default:!1,ui:{tab:"tools",group:"Grep & Browser",label:"Browser Relay",description:"Drive your own Chrome tabs through the omp browser relay. Install the extension once (`omp browser-relay install`); the relay server auto-starts when the browser prelude needs it. Takes precedence over Browser CDP URL; set PI_BROWSER_RELAY=0 or PI_BROWSER_RELAY=1 to override."}},"browser.relayUrl":{type:"string",ui:{tab:"tools",group:"Grep & Browser",label:"Browser Relay URL",description:"omp browser relay endpoint (default http://127.0.0.1:9224)."}},"browser.headless":{type:"boolean",default:!0,ui:{tab:"tools",group:"Grep & Browser",label:"Headless Browser",description:"Run the browser without a window (disable to show it). omp's WebKit tabs gain or lose their windows at once where the engine ships its viewer (macOS); elsewhere a visible browser is Chromium, launched in the new mode by the next open."}},"browser.cmux":{type:"boolean",default:!0,ui:{tab:"tools",group:"Grep & Browser",label:"cmux Browser",description:"Use cmux WKWebView surfaces for browser automation when a cmux socket is available. Set PI_BROWSER_CMUX=0 or PI_BROWSER_CMUX=1 to override."}},"browser.tern":{type:"boolean",default:!0,ui:{tab:"tools",group:"Grep & Browser",label:"Tern Browser",description:`Inside a Tern pane, open browser tabs as picture-in-pictures over omp's pane (native web view) instead of omp's own headless browser; falls back to that browser when no Tern window can host them. An explicit app, the relay and Browser CDP URL take precedence; app "own" opts one open out. Set PI_BROWSER_TERN=0 or PI_BROWSER_TERN=1 to override.`}},"browser.webkit":{type:"boolean",default:!0,ui:{tab:"tools",group:"Grep & Browser",label:"WebKit Browser",description:`Open browser tabs in omp's own headless WebKit engine instead of managed Chromium when the engine is installed (omp downloads it to ~/.o2/lib/abkit before Chrome for Testing when no browser is installed; see Browser WebKit Path). Chromium still opens a visible browser where the engine ships no viewer, and tabs the engine fails to start; an explicit app, the relay, Browser CDP URL, Tern and cmux take precedence; app "chromium" opts one open out. Set PI_BROWSER_WEBKIT=0 or PI_BROWSER_WEBKIT=1 to override.`}},"browser.webkitPath":{type:"string",ui:{tab:"tools",group:"Grep & Browser",label:"Browser WebKit Path",description:"omp's WebKit engine: its host executable, or an ABKit engine directory (which holds it as ABHost; ABHost.exe on Windows). If unset, omp runs the installed engine, ~/.o2/lib/abkit/ABHost (ABHost.exe on Windows). Supports ~. PI_BROWSER_WEBKIT_PATH overrides it."}},"browser.freezeOnTurnEnd":{type:"boolean",default:!0,ui:{tab:"tools",group:"Grep & Browser",label:"Freeze Browser Tabs On Turn End",description:"Freeze OMP-owned headless Chromium tabs when a turn settles so animated pages stop burning CPU/GPU while idle (WebKit tabs draw nothing unless asked). Tabs unfreeze automatically on next use; pass persist:true on open to opt a tab out."}},"browser.idleCloseSec":{type:"number",default:1800,ui:{tab:"tools",group:"Grep & Browser",label:"Browser Idle Close Timeout",description:"Close OMP-owned headless browser tabs and Tern browser picture-in-pictures idle longer than this many seconds (0 = never; session dispose still reaps). Never touches relay/CDP/spawned browsers or other sessions' tabs.",options:[{value:"0",label:"Never"},{value:"900",label:"15 minutes"},{value:"1800",label:"30 minutes"},{value:"3600",label:"1 hour"}]}},"browser.screenshotDir":{type:"string",ui:{tab:"tools",group:"Grep & Browser",label:"Screenshot Directory",description:"Directory to save screenshots. If unset, screenshots go to a temp file. Supports ~. Examples: ~/Downloads, ~/Desktop, /sdcard/Download (Android)"}},"ida.enabled":{type:"boolean",default:!0,ui:{tab:"tools",group:"Available Tools",label:"IDA Pro",description:"Open executables read with `read` in IDA Pro (idalib) and enable the `ida` tool; inert when no IDA install is found"}},"ida.python":{type:"string",default:"",ui:{tab:"tools",group:"IDA Pro",label:"IDA Python",description:"Python interpreter that can import ida_domain and idapro; empty auto-detects"}},"ida.installDir":{type:"string",default:"",ui:{tab:"tools",group:"IDA Pro",label:"IDA Install Dir",description:"Directory containing libidalib, exported as IDADIR; empty auto-detects ($IDADIR, ida-config.json, standard install paths)"}},"ida.maxOpen":{type:"number",default:4,ui:{tab:"tools",group:"IDA Pro",label:"IDA Max Open Databases",description:"Most IDA databases (omp.ida.* daemons in omp ps) open at once per project; opening another saves and closes the least recently used idle one",options:[{value:"2",label:"2"},{value:"4",label:"4"},{value:"8",label:"8"},{value:"16",label:"16"}]}},"ida.idleCloseSec":{type:"number",default:900,ui:{tab:"tools",group:"IDA Pro",label:"IDA Idle Close Timeout",description:"Save and close IDA databases idle longer than this many seconds (0 = never); the exec namespace resets on reopen",options:[{value:"0",label:"Never"},{value:"300",label:"5 minutes"},{value:"900",label:"15 minutes"},{value:"1800",label:"30 minutes"},{value:"3600",label:"1 hour"}]}},"mcp.enableProjectConfig":{type:"boolean",default:!0,ui:{tab:"tools",group:"Discovery & MCP",label:"MCP Project Config",description:"Load .mcp.json/mcp.json from project root"}},"mcp.startupTimeoutMs":{type:"number",default:250,ui:{tab:"tools",group:"Discovery & MCP",label:"MCP Startup Window",description:"Wait this many milliseconds for initial MCP tool discovery; 0 waits until connections settle"}},"mcp.renderMarkdownResults":{type:"boolean",default:!0,ui:{tab:"tools",group:"Discovery & MCP",label:"MCP Markdown Results",description:"Render non-JSON MCP text results as Markdown in the transcript"}},"mcp.notifications":{type:"boolean",default:!1,ui:{tab:"tools",group:"Discovery & MCP",label:"MCP Update Injection",description:"Inject MCP resource updates into the agent conversation"}},"mcp.notificationDebounceMs":{type:"number",default:500,ui:{tab:"tools",group:"Discovery & MCP",label:"MCP Notification Debounce",description:"Debounce window in milliseconds for MCP resource updates before injecting them into the conversation"}},"images.urls.enabled":{type:"boolean",default:!1,ui:{tab:"model",group:"Vision",label:"Serve Images as URLs",description:"Publish outgoing images through the configured backend chain and send URL-fetching providers short URLs instead of inline base64. Falls back to inline automatically when every backend or a provider fetch fails"}},"images.urls.backends":{type:"array",default:["provider-files","tailscale","cloudflared","litterbox"],ui:{tab:"model",group:"Vision",label:"Image URL Backends",description:"Ordered destinations tried when publishing images for provider access",options:[{value:"imgur",label:"Imgur",description:"Uploads require either an Imgur access token or client ID."},{value:"imageshack",label:"ImageShack",description:"The API requires a paid subscription."},{value:"flickr",label:"Flickr",description:"image-host"},{value:"chevereto",label:"Chevereto",description:"self-hosted"},{value:"vgyme",label:"vgy.me",description:"image-host"},{value:"dropbox",label:"Dropbox",description:"cloud-files"},{value:"ftp",label:"FTP / FTPS / SFTP",description:"file-transfer"},{value:"onedrive",label:"OneDrive",description:"cloud-files"},{value:"google-drive",label:"Google Drive",description:"cloud-files"},{value:"puush",label:"puush-compatible endpoint",description:"The public service is defunct; a replacement endpoint is required."},{value:"box",label:"Box",description:"cloud-files"},{value:"amazon-s3",label:"Amazon S3",description:"s3"},{value:"google-cloud-storage",label:"Google Cloud Storage",description:"object-storage"},{value:"azure-storage",label:"Azure Blob Storage",description:"object-storage"},{value:"backblaze-b2",label:"Backblaze B2",description:"Configure either native B2 application keys or S3-compatible access keys."},{value:"owncloud",label:"ownCloud / Nextcloud",description:"webdav"},{value:"mediafire",label:"MediaFire-compatible endpoint",description:"The public API is deprecated; a replacement endpoint is required."},{value:"sendspace",label:"SendSpace-compatible endpoint",description:"The public discovery API is deprecated; a replacement endpoint is required."},{value:"localhostr",label:"Hostr-compatible endpoint",description:"The public service is offline; a replacement endpoint is required."},{value:"lambda",label:"Lambda-compatible endpoint",description:"The public service is offline; a replacement endpoint is required."},{value:"pomf",label:"Pomf",description:"pomf"},{value:"uguu",label:"Uguu",description:"Public uploads expire after approximately three hours."},{value:"seafile",label:"Seafile",description:"cloud-files"},{value:"s-ul",label:"s-ul",description:"file-host"},{value:"lobfile",label:"LobFile-compatible endpoint",description:"The public service is offline; a replacement endpoint is required."},{value:"transfer-sh",label:"transfer.sh-compatible endpoint",description:"The defunct public endpoint is blocked; a self-hosted replacement is required."},{value:"plik",label:"Plik",description:"self-hosted"},{value:"shared-folder",label:"Shared folder",description:"filesystem"},{value:"catbox",label:"Catbox",description:"anonymous-host"},{value:"litterbox",label:"Litterbox",description:"Uploads are temporary."},{value:"0x0",label:"0x0.st",description:"Public uploads expire after a retention window determined by file size."},{value:"tmpfiles",label:"tmpfiles.org",description:"Public uploads are temporary."},{value:"discord",label:"Discord",description:"messaging"},{value:"provider-files",label:"Model provider files",description:"Provider file references are API-local rather than public image URLs."},{value:"direct",label:"Direct public URL",description:"local-serving"},{value:"cloudflared",label:"Cloudflare quick tunnel",description:"tunnel"},{value:"ngrok",label:"ngrok",description:"tunnel"},{value:"tailscale",label:"Tailscale Funnel",description:"tunnel"},{value:"ssh",label:"SSH reverse tunnel",description:"tunnel"},{value:"command",label:"Uploader command",description:"external-command"},{value:"localhost-run",label:"localhost.run",description:"tunnel"},{value:"pinggy",label:"Pinggy",description:"tunnel"},{value:"devtunnel",label:"Microsoft dev tunnel",description:"The devtunnel CLI must be logged in locally."},{value:"zrok",label:"zrok",description:"The local zrok environment must be enabled."},{value:"bore",label:"bore",description:"tunnel"},{value:"named-cloudflared",label:"Named Cloudflare Tunnel",description:"tunnel"},{value:"r2",label:"Cloudflare R2",description:"s3"},{value:"tigris",label:"Tigris",description:"s3"},{value:"minio",label:"MinIO",description:"s3"},{value:"garage",label:"Garage",description:"s3"}],ordered:!0}},"images.urls.command":{type:"string",ui:{tab:"model",group:"Vision",label:"Image Upload Command",description:"Argv template for the command backend; {file} is the image path, {mime}/{ext} optional. The last URL printed on stdout is used (e.g. pasta -b -f {file})"}},"images.urls.publicBaseUrl":{type:"string",ui:{tab:"model",group:"Vision",label:"Image URL Public Base",description:"Externally reachable base URL fronting the blob server (required for ssh, optional for direct)"}},"images.urls.ttlHours":{type:"number",default:72,ui:{tab:"model",group:"Vision",label:"Image URL Lifetime (hours)",description:"Serving window for locally hosted image URLs, measured from the last time a conversation sent them; resuming a conversation re-arms the window at the same link. 0 keeps links alive while the broker runs"}},"images.urls.bindHost":{type:"string",default:"127.0.0.1",ui:{tab:"model",group:"Vision",label:"Image URL Bind Host",description:"Host the blob server binds to; loopback for tunnels, 0.0.0.0 for direct serving"}},"images.urls.sshTarget":{type:"string",ui:{tab:"model",group:"Vision",label:"Image URL SSH Target",description:"user@host destination for the ssh reverse forward"}},"images.urls.sshRemotePort":{type:"number",default:8787,ui:{tab:"model",group:"Vision",label:"Image URL SSH Remote Port",description:"Remote listen port of the ssh reverse forward that your web server proxies to"}},"secrets.enabled":{type:"boolean",default:!1,ui:{tab:"providers",group:"Privacy",label:"Hide Secrets",description:"Obfuscate configured secrets and redact credential-shaped tokens before sending to AI providers"}},"stt.enabled":{type:"boolean",default:!1,ui:{tab:"interaction",group:"Speech",label:"Speech-to-Text",description:"Enable speech-to-text input via microphone"}},"stt.submitTrigger":{type:"enum",default:"never",values:["never","release","release-complete","say-submit"],ui:{tab:"interaction",group:"Speech",label:"Speech-to-Text Submit Trigger",description:"Choose when speech dictation automatically submits: Never, Release (2+ words), Release with complete sentence, or When I Say Submit.",options:[{value:"never",label:"Never",description:"Never automatically submit; insert dictation and remain in editor."},{value:"release",label:"Release",description:"Submit on release if the utterance has 2+ words to avoid accidental sends."},{value:"release-complete",label:"Release with complete sentence",description:"Submit on release if the utterance ends with sentence-terminal punctuation (. ? ! etc.)."},{value:"say-submit",label:"When I Say Submit",description:"Submit if the utterance ends with a word containing 'submit' (strips that word before submitting)."}]}},"collab.relayUrl":{type:"string",default:"wss://my.omp.sh",ui:{tab:"interaction",group:"Collab",label:"Relay URL",description:"Relay used by /collab (wss://host[:port])"}},"collab.webUrl":{type:"string",default:"",ui:{tab:"interaction",group:"Collab",label:"Web UI URL",description:"Browser UI used by /collab links; empty derives from collab.relayUrl; explicit http:// is localhost-only"}},"collab.displayName":{type:"string",default:"",ui:{tab:"interaction",group:"Collab",label:"Display Name",description:"Name shown to other collab participants (default: OS username)"}},"collab.autoStart":{type:"enum",default:"off",values:["off","view","control"],ui:{tab:"interaction",group:"Collab",label:"Auto Start",description:"Host every interactive session via collab.relayUrl as it starts and publish it to the local registry (omp collab list); rooms rotate on session switch",options:[{value:"off",label:"Off",description:"Share only when /collab is run"},{value:"view",label:"View",description:"Auto-host; the registry hands out view-only links (omp collab link --view)"},{value:"control",label:"Control",description:"Auto-host; the registry hands out control links that can prompt the session"}]}},"share.serverUrl":{type:"string",default:"https://my.omp.sh/s",ui:{tab:"interaction",group:"Collab",label:"Share Server",description:"Share viewer/upload base used by /share (encrypted blob upload + viewer; links are <base>/<id>#<key>)"}},"share.store":{type:"enum",default:"blob",values:["blob","gist"],ui:{tab:"interaction",group:"Collab",label:"Share Store",description:"Where /share uploads the encrypted session blob",options:[{value:"blob",label:"Encrypted Blob",description:"Upload to the share server (no GitHub account needed; avoids gist API rate limits)"},{value:"gist",label:"GitHub Gist",description:"Push to a secret gist (needs authenticated gh), falling back to the share server"}]}},"share.redactSecrets":{type:"boolean",default:!0,ui:{tab:"interaction",group:"Collab",label:"Share Secret Redaction",description:"Run the secret obfuscator over /share snapshots before upload (uses the secrets.* config)"}},"stream.serverUrl":{type:"string",default:"https://live.omp.sh",ui:{tab:"interaction",group:"Stream",label:"Stream Server",description:"Live stream server used by `omp stream` (https://host[:port]); viewers watch at <base>/<your Stencil username>"}},"stream.redactPatterns":{type:"array",default:[],ui:{tab:"interaction",group:"Stream",label:"Extra Redaction Patterns",description:"Additional regular expressions redacted from every streamed row, on top of env/secrets.yml values and built-in credential shapes"}},"spotlight.experiment.enabled":{type:"boolean",default:!1,ui:{tab:"tools",group:"Developer",label:"Spotlight Experiment",description:"Shape tool output and rank find results with Stencil Spotlight, and log each shaped result to the session"}}}};var sd={"retry.enabled":{type:"boolean",default:!0,ui:{tab:"model",group:"Retry & Fallback",label:"Retry Enabled",description:"Retry transient provider errors (rate limits, outages, quota walls)."}},"retry.baseDelayMs":{type:"number",default:500,ui:{tab:"model",group:"Retry & Fallback",label:"Retry Base Delay (ms)",description:"Initial backoff before the first retry."}},"thinkingBudgets.minimal":{type:"number",default:1024,ui:{tab:"model",group:"Thinking",label:"Minimal Thinking Budget",description:"Token budget for the minimal thinking level."}},"thinkingBudgets.low":{type:"number",default:2048,ui:{tab:"model",group:"Thinking",label:"Low Thinking Budget",description:"Token budget for the low thinking level."}},"thinkingBudgets.medium":{type:"number",default:8192,ui:{tab:"model",group:"Thinking",label:"Medium Thinking Budget",description:"Token budget for the medium thinking level."}},"thinkingBudgets.high":{type:"number",default:16384,ui:{tab:"model",group:"Thinking",label:"High Thinking Budget",description:"Token budget for the high thinking level."}},"thinkingBudgets.xhigh":{type:"number",default:32768,ui:{tab:"model",group:"Thinking",label:"XHigh Thinking Budget",description:"Token budget for the xhigh thinking level."}},"thinkingBudgets.max":{type:"number",default:32768,ui:{tab:"model",group:"Thinking",label:"Max Thinking Budget",description:"Token budget for the max thinking level."}},"stt.language":{type:"string",default:"en",ui:{tab:"interaction",group:"Speech",label:"Speech-to-Text Language",description:'Source language for dictation (ISO-639-1, e.g. "id", "en"). Sent to the recognizer as a hint; leave it as "en" only if your dictation is English.'}},modelTags:{type:"record",default:{},ui:{tab:"model",group:"Prompt",label:"Model Tags",description:"Custom role/tag metadata; can introduce additional roles. JSON record."}},modelProviderOrder:{type:"array",default:[],ui:{tab:"model",group:"Prompt",label:"Model Provider Order",description:"Preferred provider order when a model id is ambiguous. JSON array."}},cycleOrder:{type:"array",default:["smol","default","slow"],ui:{tab:"model",group:"Prompt",label:"Model Cycle Order",description:"Roles cycled by the model switcher. JSON array."}},enabledModels:{type:"array",default:[],ui:{tab:"model",group:"Prompt",label:"Enabled Models",description:"Allow-list of models; supports path-scoped entries. Empty means all available models. JSON array."}},"task.agentServiceTierOverrides":{type:"record",default:{},ui:{tab:"model",group:"Sampling",label:"Agent Service Tier Overrides",description:"Sparse exact-name service-tier overrides for agents spawned by task/eval dispatch. JSON record."}},"compaction.reserveTokens":{type:"number",ui:{tab:"context",group:"Compaction",label:"Compaction Reserve Tokens",description:"Absolute reserve floor. Unset = larger of 16384 and 15% of the context window."}},"compaction.keepRecentTokens":{type:"number",default:20000,ui:{tab:"context",group:"Compaction",label:"Keep Recent Tokens",description:"Recent tokens always preserved through compaction."}},"compaction.autoContinue":{type:"boolean",default:!0,ui:{tab:"context",group:"Compaction",label:"Auto-Continue",description:"Continue automatically after compaction."}},"autolearn.minToolCalls":{type:"number",default:5,ui:{tab:"memory",group:"Auto-Learn",label:"Min Tool Calls",description:"Only nudge after a turn that used at least this many tools.",condition:"autolearnActive"}},shellPath:{type:"string",ui:{tab:"shell",group:"Bash",label:"Shell Path",description:"Override the shell binary used by bash."}},"bash.autoBackground.thresholdMs":{type:"number",default:60000,ui:{tab:"shell",group:"Bash",label:"Auto-Background Threshold (ms)",description:"Threshold before auto-backgrounding long-running commands."}},"task.agentAdvisor":{type:"record",default:{},ui:{tab:"tasks",group:"Subagents",label:"Agent Advisor Overrides",description:'Per-agent subagent advisor: agent name → "on" / "off" / advisor model pattern. JSON record.'}},enabledProviders:{type:"array",default:[],ui:{tab:"providers",group:"Services",label:"Enabled Providers",description:"Foreign user-level discovery sources to load; supports path-scoped entries. JSON array."}},disabledProviders:{type:"array",default:[],ui:{tab:"providers",group:"Services",label:"Disabled Providers",description:"Disabled model/discovery providers; supports path-scoped entries. JSON array."}}};var xn=od,ot={...xn.entries,...sd};function Re(t,r){return t[r]?.value}function vo(t,r){switch(t){case void 0:return!0;case"advisorEnabled":return Re(r,"advisor.enabled")===!0;case"vimModeEnabled":return Re(r,"tui.vimMode")===!0;case"hindsightActive":return Re(r,"memory.backend")==="hindsight";case"mnemopiActive":return Re(r,"memory.backend")==="mnemopi";case"autolearnActive":return Re(r,"autolearn.enabled")===!0;case"autoThinkingActive":return Re(r,"defaultThinkingLevel")==="auto";case"usageAwareFallbackEnabled":return Re(r,"retry.usageAwareFallback")===!0;case"planModeEnabled":return Re(r,"plan.enabled")===!0;case"composerPredictionsEnabled":return Re(r,"composer.predictions")===!0;case"planAutosaveEnabled":return Re(r,"plan.enabled")===!0&&Re(r,"plan.autosave")===!0;case"unexpectedStopSmart":return Re(r,"features.unexpectedStopDetection")==="smart";case"macOS":case"hasImageProtocol":return!0;default:return!0}}function ld(t){return Object.entries(ot).filter(([,r])=>r.ui.tab===t)}function xo(t,r,l){if(!l)return!0;return t.toLowerCase().includes(l)||r.ui.label.toLowerCase().includes(l)||r.ui.description.toLowerCase().includes(l)}function Mt(t){if(t===void 0||t===null)return"";if(Array.isArray(t)||typeof t==="object")return JSON.stringify(t);return String(t)}function zu(t){let r=t.trim();if(r===""||r==="-"||r==="+"||r===".")return null;let l=Number(r);return Number.isFinite(l)?l:null}function Hu(t){let r=t.trim();if(r==="")return[];try{let l=JSON.parse(r);return Array.isArray(l)?l:null}catch{return null}}function Wu(t){let r=t.trim();if(r==="")return{};try{let l=JSON.parse(r);return typeof l==="object"&&l!==null&&!Array.isArray(l)?l:null}catch{return null}}function dd(t,r){if(t==="number"){let l=zu(r);return l===null?{ok:!1,error:"A number is required, e.g. 1200."}:{ok:!0,value:l}}if(t==="array"){let l=Hu(r);return l===null?{ok:!1,error:'This key is a JSON array, e.g. ["anthropic","openai"].'}:{ok:!0,value:l}}if(t==="record"){let l=Wu(r);return l===null?{ok:!1,error:'This key is a JSON object, e.g. {"bash":"prompt"}.'}:{ok:!0,value:l}}return{ok:!0,value:r.trim()}}function cd({options:t,value:r,saving:l,onCommit:c}){let[b,p]=n(!1),g=Array.isArray(r)?r.filter((x)=>typeof x==="string"):[],h=t.filter((x)=>!g.includes(x.value)),v=(x)=>t.find((A)=>A.value===x)?.label||x,k=(x,A)=>{let N=x+A;if(N<0||N>=g.length)return;let M=[...g],[P]=M.splice(x,1);M.splice(N,0,P),c(M)};return e("div",{className:"flex max-w-72 flex-wrap items-center justify-end gap-1.5",children:[g.map((x,A)=>e("span",{className:"inline-flex items-center gap-1 rounded-md border border-ink/15 bg-ink/[0.03] px-2 py-0.5 text-[10px] text-ink",children:[A>0&&e("button",{type:"button","aria-label":`Move ${v(x)} earlier`,onClick:()=>k(A,-1),disabled:l,className:"text-ink/40 hover:text-ink cursor-pointer disabled:opacity-40",children:"←"}),v(x),A<g.length-1&&e("button",{type:"button","aria-label":`Move ${v(x)} later`,onClick:()=>k(A,1),disabled:l,className:"text-ink/40 hover:text-ink cursor-pointer disabled:opacity-40",children:"→"}),e("button",{type:"button","aria-label":`Remove ${v(x)}`,onClick:()=>c(g.filter((N)=>N!==x)),disabled:l,className:"text-ink/40 hover:text-error cursor-pointer disabled:opacity-40",children:e(y,{size:10})})]},x)),g.length===0&&e("span",{className:"text-[10px] text-ink/40",children:"nothing selected"}),e("div",{className:"relative",children:[e("button",{type:"button",onClick:()=>p((x)=>!x),disabled:l||h.length===0,"aria-expanded":b,"aria-label":"Add an option",className:"flex items-center gap-0.5 rounded-md border border-ink/15 px-2 py-0.5 text-[10px] text-ink/70 hover:text-ink hover:bg-ink/5 cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:[e(Y,{size:10})," add"]}),b&&h.length>0&&e("div",{className:"glass-popover absolute right-0 top-full z-20 mt-1 max-h-44 w-48 overflow-auto rounded-md border border-ink/15 bg-paper p-1 shadow-lg",children:h.map((x)=>e("button",{type:"button",onClick:()=>{c([...g,x.value]),p(!1)},className:"block w-full rounded px-2 py-1 text-left text-[11px] text-ink/80 hover:bg-ink/5 cursor-pointer",children:x.label||x.value},x.value))})]})]})}function pd({entryKey:t,entry:r,value:l,initialValue:c,onChangeDirty:b,onCommit:p,saving:g,saveError:h}){let[v,k]=n(()=>Mt(l)),[x,A]=n(null),[N,M]=n(!1),P=o(!1),E=o(c),S=Array.isArray(r.ui.options)?r.ui.options:null;i(()=>{k(Mt(l)),A(null),P.current=!1},[l]);let R=()=>{k(Mt(E.current)),A(null),P.current=!1,b(t,!1)},T=async(z)=>{let q=v;if(k(Mt(z)),A(null),P.current=!1,await p(t,z))b(t,!1);else k(q),P.current=!0,b(t,!0)},O=()=>{if(!P.current)return;let z=dd(r.type,v);if(!z.ok){A(z.error);return}if(JSON.stringify(z.value)===JSON.stringify(l)){A(null),P.current=!1,b(t,!1);return}T(z.value)},L=()=>{let z=P.current;if(P.current=!0,A(null),!z)b(t,!0)};if(r.type==="boolean"){let z=l===!0;return e("button",{type:"button",role:"switch","aria-checked":z,"aria-label":r.ui.label,onClick:()=>void T(!z),disabled:g,className:`relative h-5 w-9 shrink-0 rounded-full transition-colors cursor-pointer disabled:cursor-progress ${z?"bg-ink":"bg-ink/15"} ${g?"opacity-50":""}`,children:e("span",{className:`absolute top-0.5 h-4 w-4 rounded-full bg-paper shadow-sm transition-all ${z?"left-[18px]":"left-0.5"}`})})}if(r.type==="array"&&r.ui.ordered&&S)return e(cd,{options:S,value:l,saving:g,onCommit:(z)=>void T(z)});let _=S??(r.type==="enum"&&r.values?r.values.map((z)=>({value:z,label:z,description:""})):null);if(_){let z=l===void 0||l===null?"":String(l);return e("div",{className:"flex shrink-0 items-center gap-2",children:e("select",{"aria-label":r.ui.label,value:z,onChange:(q)=>{let G=q.currentTarget.value;if(G===z)return;if(r.type==="number"){let j=Number(G);if(!Number.isFinite(j))return;T(j)}else T(G)},disabled:g,className:`max-w-56 rounded-md border border-ink/15 bg-paper px-2 py-1 text-ink cursor-pointer disabled:cursor-progress ${g?"opacity-50":""}`,children:[z===""&&e("option",{value:"",disabled:!0,children:"select…"}),_.map((q)=>e("option",{value:q.value,children:q.label||q.value},q.value))]})})}let K=r.type==="string"||r.type==="number"||r.type==="array"||r.type==="record",V=r.type==="array"?'["anthropic","openai"]':r.type==="record"?'{"bash":"prompt"}':r.type==="number"?"unset":r.credential?"not set":"unset";return e("div",{className:"flex shrink-0 flex-col items-end gap-1",children:[e("div",{className:"flex items-center gap-1",children:[e("input",{"aria-label":r.ui.label,"aria-invalid":x?!0:void 0,type:r.credential&&!N?"password":"text",inputMode:r.type==="number"?"decimal":void 0,value:v,onChange:(z)=>{k(z.currentTarget.value),L()},onBlur:()=>{if(K)O()},onKeyDown:(z)=>{if(z.key==="Enter")z.preventDefault(),O();if(z.key==="Escape")z.preventDefault(),R()},disabled:g,spellcheck:!1,placeholder:V,className:`bg-paper border rounded-md px-2 py-1 text-ink text-right text-[11px] ${r.type==="string"&&!r.credential?"":"font-mono"} ${r.type==="number"?"w-28":"w-48"} ${x||h?"border-error":"border-ink/15"} ${g?"opacity-50 cursor-progress":""} focus:outline-none focus:border-ink/50`}),r.credential&&e("button",{type:"button","aria-label":N?`Hide ${r.ui.label}`:`Show ${r.ui.label}`,title:N?"Hide the value":"Show the value",onClick:()=>M((z)=>!z),className:"rounded p-1 text-ink/35 hover:text-ink hover:bg-ink/5 cursor-pointer",children:N?e(wt,{size:11}):e(Ge,{size:11})}),K&&P.current&&e("button",{type:"button","aria-label":`Save ${r.ui.label}`,title:"Save (Enter)",onClick:O,disabled:g,className:"rounded p-1 text-ink/50 hover:text-ink hover:bg-ink/5 cursor-pointer disabled:opacity-40",children:e(f,{size:11})}),K&&x&&e("button",{type:"button","aria-label":`Discard the change to ${r.ui.label}`,title:"Discard (Escape)",onClick:R,className:"rounded p-1 text-error/70 hover:text-error hover:bg-error/5 cursor-pointer",children:e(y,{size:11})})]}),x&&e("span",{className:"max-w-56 text-right text-[10px] leading-snug text-error",children:x})]})}var ko=80;function md({tabs:t,entries:r,activeTabId:l,onSelectTab:c,searchQuery:b,dirtyKeys:p,savingKeys:g,saveErrors:h,onCommit:v,onReset:k,onDirty:x}){let A=t.find((R)=>R.id===l)??t[0],N=b.trim().toLowerCase(),M=u(()=>{let R=new Map;for(let T of Object.values(ot)){if(!T.ui||!vo(T.ui.condition,r))continue;R.set(T.ui.tab,(R.get(T.ui.tab)??0)+1)}return R},[r]),P=u(()=>{if(N)return Object.entries(ot).filter(([R,T])=>T.ui&&xo(R,T,N)).map(([R])=>R).slice(0,ko);return ld(A.id).filter(([,R])=>R.ui&&vo(R.ui.condition,r)).map(([R])=>R)},[r,A.id,N]),E=u(()=>{if(!N)return[];let R=[],T=new Map;for(let O of P){let L=ot[O],_=t.find((z)=>z.id===L?.ui.tab),K=`${L?.ui.tab??"?"}\x00${L?.ui.group??""}`,V=T.get(K);if(!V)V={label:L?.ui.group?`${_?.label??L?.ui.tab} · ${L.ui.group}`:_?.label??L?.ui.tab??"Other",keys:[]},T.set(K,V),R.push({id:K,...V});V.keys.push(O)}return R},[P,N,t]),S=u(()=>N?Object.entries(ot).filter(([R,T])=>T.ui&&xo(R,T,N)).length:0,[N]);return e("div",{className:"w-full flex flex-col gap-3 text-xs",children:[N?e("div",{className:"flex items-center justify-between gap-3 rounded-md border border-ink/15 bg-ink/[0.03] px-2.5 py-1.5",children:[e("span",{className:"flex min-w-0 items-center gap-1.5 text-[11px] text-ink/60",children:[e(F,{size:11,className:"shrink-0 text-ink/40"}),e("span",{className:"truncate",children:["Searching every tab — ",e("span",{className:"font-medium text-ink",children:S}),S>ko&&e("span",{children:[" (showing the first ",ko,")"]})," ","matching key",S===1?"":"s"]})]}),e("span",{className:"shrink-0 rounded bg-ink/10 px-1.5 py-px font-mono text-[10px] text-ink/60",children:b.trim()})]}):e("div",{role:"tablist","aria-label":"OMP config tabs",className:"flex items-center gap-1 overflow-x-auto pb-1 scrollbar-overlay-container",children:t.map((R)=>{let T=R.id===A.id,O=M.get(R.id)??0;return e("button",{type:"button",role:"tab","aria-selected":T,onClick:()=>c(R.id),title:O===0?`${R.label} — no setting is available in this tab right now`:`${O} setting${O===1?"":"s"}`,className:`shrink-0 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors cursor-pointer ${T?"bg-ink/10 text-ink":"text-ink/55 hover:bg-ink/5 hover:text-ink"}`,children:[R.label,e("span",{className:`ml-1.5 font-mono text-[10px] ${T?"text-ink/50":"text-ink/35"}`,children:O})]},R.id)})}),N&&e("div",{className:"flex items-center gap-2 text-[10px] text-ink/40",children:[e(y,{size:10}),"Clear the search to browse by tab again."]}),e("div",{className:"w-full rounded-lg border border-ink/10 divide-y divide-ink/5",children:[N?E.map((R)=>e(ud,{keys:R.keys,entries:r,groupLabel:R.label,dirtyKeys:p,savingKeys:g,saveErrors:h,onCommit:v,onReset:k,onDirty:x},R.id)):A.groups.map((R)=>{let T=P.filter((O)=>ot[O]?.ui.group===R);if(T.length===0)return null;return e(ud,{keys:T,entries:r,groupLabel:R,dirtyKeys:p,savingKeys:g,saveErrors:h,onCommit:v,onReset:k,onDirty:x},R)}),P.length===0&&e("div",{className:"px-3 py-6 text-center text-ink/40",children:N?"No setting matches that search.":"No setting is available in this tab right now."})]})]})}function ud({keys:t,entries:r,groupLabel:l,dirtyKeys:c,savingKeys:b,saveErrors:p,onCommit:g,onReset:h,onDirty:v}){return e("div",{children:[e("div",{className:"px-3 py-1.5 bg-ink/[0.02] text-[10px] uppercase tracking-wide text-ink/40 font-medium",children:l}),t.map((k)=>{let x=ot[k];if(!x?.ui)return null;let A=r[k]?.value,N=r[k]?.value!==void 0,M=c.has(k),P=b.has(k),E=p.get(k);return e("div",{className:"flex items-start justify-between gap-3 px-3 py-2 hover:bg-ink/[0.02]",children:[e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex flex-wrap items-center gap-1.5",children:[e("span",{className:"font-medium text-ink",children:x.ui.label}),e("span",{className:"font-mono text-[10px] text-ink/35",title:"config key",children:k}),M&&!P&&e("span",{className:"shrink-0 rounded bg-warning/15 px-1 py-px text-[10px] font-semibold text-warning",children:"unsaved"}),P&&e("span",{className:"shrink-0 text-[10px] text-ink/40",children:"saving…"}),E&&!P&&e("span",{className:"shrink-0 rounded bg-error/10 px-1 py-px text-[10px] font-semibold text-error",title:E,children:"save failed"})]}),x.ui.description&&e("div",{className:"text-[10px] text-ink/40 leading-snug",children:x.ui.description}),E&&!P&&e("div",{className:"text-[10px] text-error leading-snug",children:E}),x.ui.warning&&e("div",{className:"text-[10px] text-error/80 leading-snug",children:x.ui.warning})]}),e("div",{className:"flex shrink-0 items-center gap-1.5 pt-0.5",children:[e(pd,{entryKey:k,entry:x,value:A,initialValue:A,onChangeDirty:v,onCommit:g,saving:P,saveError:Boolean(E)}),e("button",{type:"button","aria-label":`Reset ${x.ui.label}`,title:N?"Reset to the schema default":"This key is not set — omp already uses the schema default",onClick:()=>h(k),disabled:P||!N,className:"rounded p-1 text-ink/30 hover:text-ink transition-colors cursor-pointer hover:bg-ink/5 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:e(ct,{size:11})}),M&&e(f,{size:11,className:"text-ink/30"})]})]},k)})]})}function Gu(t){return new Date(t).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function gd({running:t,state:r,refreshing:l,updatedAt:c,searchQuery:b,onSearchChange:p,onRefresh:g}){let h=r?.contextUsage?.percent,v=typeof h==="number"&&Number.isFinite(h),k=v?nc(h):0,x=ac[rc(k)],A=Qn(r?.contextUsage?.tokens),N=Qn(r?.contextUsage?.contextWindow),M=r?.model?.id;return e("div",{className:"flex flex-col gap-3 pb-3 border-b border-ink/10",children:[e("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e("div",{children:[e("h2",{className:"text-sm font-semibold text-ink",children:"OMP Engine"}),e("p",{className:"text-ink/50 mt-0.5",children:["Live agent state and the full native config schema from oh-my-pi.",c!==null&&e("span",{className:"text-ink/40",children:[" Read at ",Gu(c),"."]})]})]}),e("div",{className:"flex items-center gap-2",children:[e("div",{className:"relative",children:[e(F,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-ink/40 pointer-events-none"}),e("input",{"aria-label":"Search settings",type:"search",value:b,onChange:(P)=>p(P.currentTarget.value),placeholder:"Search every setting…",className:"w-52 bg-paper border border-ink/15 rounded-md pl-6 pr-6 py-1 text-ink placeholder:text-ink/40 focus:outline-none focus:border-ink/40"}),b&&e("button",{type:"button","aria-label":"Clear search",onClick:()=>p(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 text-ink/40 hover:text-ink cursor-pointer",children:e(y,{size:11})})]}),e("button",{type:"button",onClick:g,disabled:l,"aria-busy":l,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg border border-ink/15 text-ink/70 hover:text-ink hover:bg-ink/5 transition-all cursor-pointer disabled:opacity-50",children:[l?e(m,{size:12,className:"animate-spin"}):e(C,{size:12}),l?"Refreshing…":"Refresh"]})]})]}),e("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2",children:[e(kn,{label:"Engine",children:e("span",{className:"flex items-center gap-1.5",children:[e("span",{"aria-hidden":"true",className:`h-1.5 w-1.5 rounded-full ${t?"bg-success":"bg-ink/25"}`}),t?"Running":"Idle"]})}),e(kn,{label:"Model",children:[e("span",{className:"block truncate",title:M?`${r?.model?.provider??""} / ${M}`:void 0,children:M??"–"}),r?.model?.provider&&e("span",{className:"block truncate text-[10px] font-normal text-ink/40",children:r.model.provider})]}),e(kn,{label:"Thinking",children:e("span",{className:"capitalize",children:r?.thinkingLevel??"–"})}),e(kn,{label:"Context",children:[e("span",{className:v?x.text:void 0,children:v?`${h.toFixed(1)}%`:"–"}),v&&e("span",{className:"mt-1 block h-1 w-full overflow-hidden rounded-full bg-ink/10","aria-hidden":"true",children:e("span",{className:`block h-full rounded-full ${x.fill}`,style:{width:`${k}%`}})}),A&&e("span",{className:"mt-0.5 block text-[10px] font-normal text-ink/40",children:[A,N?` / ${N}`:""," tokens"]})]})]})]})}function kn({label:t,children:r}){return e("div",{className:"rounded-lg border border-ink/10 bg-ink/[0.03] px-3 py-2",children:[e("div",{className:"text-[10px] uppercase tracking-wide text-ink/40",children:t}),e("div",{className:"font-semibold text-ink mt-0.5",children:r})]})}var Ot={default:{label:"Default",section:"chat",kinds:["chat"]},smol:{label:"Fast",section:"chat",kinds:["chat"]},slow:{label:"Thinking",section:"chat",kinds:["chat"]},vision:{label:"Vision",section:"chat",kinds:["chat"]},plan:{label:"Architect",section:"chat",kinds:["chat"]},commit:{label:"Commit",section:"chat",kinds:["chat"]},tiny:{label:"Tiny",section:"chat",kinds:["tiny","chat"]},memory:{label:"Memory",section:"chat",kinds:["tiny","chat"]},task:{label:"Subtask",section:"chat",kinds:["chat"]},advisor:{label:"Advisor",section:"chat",kinds:["chat"]},widget:{label:"Job widgets",section:"chat",kinds:["chat"]},image:{label:"Image generation",section:"kind",kinds:["image"]},web:{label:"Web search",section:"kind",kinds:["search"]},speech:{label:"Speech (TTS)",section:"kind",kinds:["tts"]},dictation:{label:"Dictation (STT)",section:"kind",kinds:["stt"]},judge:{label:"Judge",section:"kind",kinds:["judge","tiny","chat"]}},yo=Object.keys(Ot);function qu(t,r){let l=Ot[t];if(!l)return!1;if(l.kinds.includes(r.kind))return!0;return t==="web"&&r.kind==="chat"&&r.webCapable===!0}function bd(t,r){return r.filter((l)=>qu(t,l)).sort((l,c)=>l.provider.localeCompare(c.provider)||l.name.localeCompare(c.name))}function wo(t,r){let l=Object.keys(t);if(l.length!==Object.keys(r).length)return!1;return l.every((c)=>r[c]===t[c])}function So(t,r){return t.find((l)=>wo(l.roles,r))??null}function fd({role:t,info:r,value:l,candidates:c,disabled:b,onChange:p}){let g=c.some((v)=>v.selector===l),h=`${r.label} (${t}) model`;return e("div",{className:"flex items-center justify-between gap-3 px-3 py-2.5",children:[e("div",{className:"min-w-0",children:[e("div",{className:"font-medium text-ink",children:r.label}),e("div",{className:"font-mono text-[10px] text-ink/35",children:t})]}),e(Le,{ariaLabel:h,value:l,placeholder:"omp default",onChange:(v)=>p(t,v),disabled:b,className:"w-60 max-w-[60%]",options:[...l&&!g?[{value:l,label:`${l} (not in catalog)`}]:[],...c.map((v)=>({value:v.selector,label:v.name,hint:v.selector,group:v.provider}))]})]})}function hd({presets:t,selectedPreset:r,inUse:l,busy:c,onApply:b,onSave:p,onUpdate:g,onDelete:h}){let[v,k]=n(!1),[x,A]=n(""),[N,M]=n(!1),P=async()=>{let E=x.trim();if(!E)return;if(await p(E))A(""),k(!1)};return e("div",{className:"rounded-lg border border-ink/10 bg-ink/[0.02] px-3 py-2 mb-3",children:[e("div",{className:"flex flex-wrap items-center gap-2",children:[e("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-ink/50",children:"Preset"}),e("select",{"aria-label":"Model role preset",value:r?.id??"",disabled:c||t.length===0,onChange:(E)=>{let S=t.find((R)=>R.id===E.currentTarget.value);if(S)b(S)},className:"bg-paper border border-ink/15 rounded-md px-2 py-1 text-ink text-[11px] cursor-pointer disabled:opacity-50 min-w-[10rem]",children:[e("option",{value:"",children:t.length===0?"No presets yet":"Custom"}),t.map((E)=>e("option",{value:E.id,children:E.name},E.id))]}),r&&e("span",{className:`inline-flex items-center gap-1 text-[10px] ${l?"text-ink/50":"text-warning"}`,title:l?"The live roles are this preset":"The roles differ from this preset — Update stores them",children:l?e(d,{children:[e(f,{size:11})," in use"]}):"modified"}),e("div",{className:"ml-auto flex items-center gap-1.5",children:[e("button",{type:"button",onClick:()=>k((E)=>!E),disabled:c,title:"Save the current roles as a new preset",className:"flex items-center gap-1 px-2 py-1 rounded-md border border-ink/15 text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50 text-[11px]",children:[e(Y,{size:11})," Save as…"]}),e("button",{type:"button",onClick:g,disabled:c||!r,title:r?`Overwrite “${r.name}” with the current roles`:"Pick a preset first",className:"flex items-center gap-1 px-2 py-1 rounded-md border border-ink/15 text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-40 text-[11px]",children:[e(yt,{size:11})," Update"]}),e("button",{type:"button",onClick:()=>M(!0),disabled:c||!r,title:r?`Delete “${r.name}”`:"Pick a preset first",className:"p-1 rounded-md border border-ink/15 text-ink/50 hover:text-error hover:border-error/40 transition-colors cursor-pointer disabled:opacity-40",children:e(U,{size:12})})]})]}),v&&e("div",{className:"flex items-center gap-2 pt-2",children:[e("input",{"aria-label":"New preset name",type:"text",value:x,autoFocus:!0,onInput:(E)=>A(E.currentTarget.value),onKeyDown:(E)=>{if(E.key==="Enter")P();if(E.key==="Escape")k(!1),A("")},placeholder:"e.g. cheap, thinking, review",className:"flex-1 bg-paper border border-ink/15 rounded-md px-2 py-1 text-ink text-[11px]"}),e("button",{type:"button",onClick:()=>void P(),disabled:!x.trim()||c,className:"px-2 py-1 rounded-md border border-ink/15 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50 text-[11px]",children:"Save"}),e("button",{type:"button",onClick:()=>{k(!1),A("")},className:"px-2 py-1 rounded-md text-ink/50 hover:text-ink cursor-pointer text-[11px]",children:"Cancel"})]}),N&&r&&e("div",{className:"flex items-center gap-2 pt-2 text-[11px] text-ink/70",children:[e("span",{children:["Delete “",r.name,"”? The roles themselves are untouched."]}),e("button",{type:"button",onClick:()=>{M(!1),h()},disabled:c,className:"px-2 py-1 rounded-md border border-error/40 text-error hover:bg-error/10 transition-colors cursor-pointer disabled:opacity-50",children:"Delete"}),e("button",{type:"button",onClick:()=>M(!1),className:"px-2 py-1 rounded-md text-ink/50 hover:text-ink cursor-pointer",children:"Cancel"})]})]})}var Vu=[{id:"chat",title:"Chat roles",note:"Each takes a chat model. “omp default” removes the override and omp resolves the role itself."},{id:"kind",title:"Model-kind roles",note:"Each takes a model of that kind only — a chat model here is silently unusable."}];function vd({roles:t,presets:r,candidates:l,candidatesError:c,onSaveRoles:b,onSavePreset:p,onUpdatePreset:g,onDeletePreset:h,savedRole:v,writeError:k,onDismissWriteError:x}){let[A,N]=n(t),[M,P]=n(!1),[E,S]=n(()=>So(r,t)?.id??null);i(()=>{N(t)},[t]),i(()=>{S((q)=>{if(q&&!r.some((G)=>G.id===q))return null;if(q)return q;return So(r,A)?.id??null})},[r,A]);let R=u(()=>r.find((q)=>q.id===E)??null,[r,E]),T=u(()=>Boolean(R&&wo(R.roles,A)),[R,A]),O=a(async(q)=>{N(q),P(!0);try{await b(q)}finally{P(!1)}},[b]),L=a((q,G)=>{let j={...A};if(G)j[q]=G;else delete j[q];O(j)},[O,A]),_=a((q)=>{S(q.id),O({...q.roles})},[O]),K=a(async(q)=>{P(!0);try{return await p(q,A)}finally{P(!1)}},[A,p]),V=a(async()=>{if(!R)return;P(!0);try{await g({...R,roles:A})}finally{P(!1)}},[R,A,g]),z=a(async()=>{if(!R)return;P(!0);try{await h(R),S(null)}finally{P(!1)}},[R,h]);return e("div",{className:"pt-2",children:[e("div",{className:"flex items-center justify-between gap-3 pb-2",children:[e("div",{children:[e("h3",{className:"text-sm font-semibold text-ink",children:"Model Roles"}),e("p",{className:"text-ink/50 mt-0.5",children:"Role → model selectors from config.yml. Pick a preset to switch every role at once."})]}),e("div",{className:"flex shrink-0 items-center gap-2",children:[e("span",{className:"rounded bg-ink/5 px-1.5 py-0.5 text-[10px] text-ink/60",title:"Roles with an override in config.yml",children:[Object.keys(A).length," / ",yo.length," set"]}),v&&e("span",{className:"inline-flex items-center gap-1 text-[10px] text-ink/60",children:[e(f,{size:11})," saved"]})]})]}),e(hd,{presets:r,selectedPreset:R,inUse:T,busy:M,onApply:_,onSave:K,onUpdate:V,onDelete:z}),k&&e("div",{className:"flex items-start gap-1.5 pb-2 text-[10px] text-error",children:[e(B,{size:11,className:"mt-px flex-shrink-0"}),e("span",{className:"flex-1",children:k}),x&&e("button",{type:"button",onClick:x,className:"text-ink/40 hover:text-ink cursor-pointer","aria-label":"Dismiss role write error",children:"×"})]}),c&&e("div",{className:"flex items-start gap-1.5 pb-2 text-[10px] text-warning",children:[e(B,{size:11,className:"mt-px flex-shrink-0"}),e("span",{children:["Model catalog unavailable (",c,"). Stored selectors stay editable; new picks need a working omp install."]})]}),Vu.map((q)=>{let G=yo.filter((j)=>Ot[j].section===q.id);return e("div",{className:"mb-3",children:[e("div",{className:"pb-1",children:[e("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-ink/50",children:q.title}),e("div",{className:"text-[10px] text-ink/40 leading-snug",children:q.note})]}),e("div",{className:"rounded-lg border border-ink/10 divide-y divide-ink/5",children:G.map((j)=>e(fd,{role:j,info:Ot[j],value:A[j]??"",candidates:bd(j,l),disabled:M,onChange:L},j))})]},q.id)})]})}function xd({extensions:t,savedExtension:r,pendingIds:l,onToggle:c}){return e("div",{className:"pt-2",children:[e("div",{className:"flex items-center justify-between pb-2",children:[e("div",{children:[e("h3",{className:"text-sm font-semibold text-ink",children:"Extensions"}),e("p",{className:"text-ink/50 mt-0.5",children:["TS/JS modules loaded from ",e("span",{className:"font-mono",children:".omp/extensions"}),". Disabling one writes to config.yml and applies to the next session."]})]}),r&&e("span",{className:"inline-flex shrink-0 items-center gap-1 text-[10px] text-ink/60",children:[e(f,{size:11})," saved"]})]}),t.length===0?e("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-3 text-[11px] text-ink/50",children:[e(pi,{size:13,className:"text-ink/35"}),e("span",{children:["No extension modules found. Add a ",e("span",{className:"font-mono",children:".ts"})," or"," ",e("span",{className:"font-mono",children:".js"})," file under"," ",e("span",{className:"font-mono",children:"~/.omp/extensions"})," (or a workspace’s"," ",e("span",{className:"font-mono",children:".omp/extensions"}),") and refresh."]})]}):e("div",{className:"rounded-lg border border-ink/10 divide-y divide-ink/5",children:t.map((b)=>{let p=!b.disabled,g=l.has(b.id);return e("div",{className:"flex items-center justify-between gap-3 px-3 py-2.5",children:[e("div",{className:"min-w-0",children:[e("div",{className:"font-medium text-ink",children:b.name}),e("div",{className:"text-[10px] text-ink/40 truncate font-mono",title:`${b.sourceRoot}/${b.filePath}`,children:[b.sourceRoot," · ",b.filePath]})]}),e("div",{className:"flex shrink-0 items-center gap-2",children:[e("span",{className:"text-[10px] text-ink/40",children:g?"saving…":p?"enabled":"disabled"}),g&&e(m,{size:11,className:"animate-spin text-ink/40"}),e("button",{type:"button",role:"switch","aria-checked":p,"aria-label":`${b.name} enabled`,disabled:g,onClick:()=>c(b),className:`relative h-5 w-9 rounded-full transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-progress ${p?"bg-ink":"bg-ink/15"}`,children:e("span",{className:`absolute top-0.5 h-4 w-4 rounded-full bg-paper shadow-sm transition-all ${p?"left-[18px]":"left-0.5"}`})})]})]},b.id)})})]})}function kd(t){if(typeof t!=="object"||t===null||!("roles"in t))return null;let r=t.roles;if(typeof r!=="object"||r===null||Array.isArray(r))return null;return Object.fromEntries(Object.entries(r).filter((l)=>typeof l[1]==="string"))}function yd(t){if(typeof t!=="object"||t===null||!("error"in t))return null;return typeof t.error==="string"?t.error:null}function wd(t){let[r,l]=n({}),[c,b]=n([]),[p,g]=n([]),[h,v]=n(null),[k,x]=n(null),A=a(()=>x(null),[]),N=a((T)=>{let O=kd(T);if(O)l(O);if(typeof T!=="object"||T===null)return;if("presets"in T&&Array.isArray(T.presets))b(T.presets);if("candidates"in T&&Array.isArray(T.candidates))g(T.candidates);if("candidatesError"in T)v(typeof T.candidatesError==="string"?T.candidatesError:null)},[]),M=a(async(T)=>{let O=r;l(T),x(null);try{let _=await(await fetch("/api/model-roles",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:T})})).json(),K=kd(_);if(K)l(K);let V=typeof _==="object"&&_!==null&&"success"in _&&_.success===!0;if(V)t("role-map");else l(O),x(yd(_)??"The role write was refused");return V}catch(L){return console.error("Failed to save model roles:",L),l(O),x(L instanceof Error?L.message:String(L)),!1}},[t,r]),P=a(async(T,O="")=>{x(null);try{let _=await(await fetch(`/api/model-roles${O}`,T)).json();if(typeof _==="object"&&_!==null&&"presets"in _&&Array.isArray(_.presets))b(_.presets);let K=typeof _==="object"&&_!==null&&"success"in _&&_.success===!0;if(!K)x(yd(_)??"The preset write was refused");return K}catch(L){return console.error("Failed to save model role preset:",L),x(L instanceof Error?L.message:String(L)),!1}},[]),E=a((T,O)=>P({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({preset:{name:T,roles:O}})}),[P]),S=a((T)=>P({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({preset:{id:T.id,name:T.name,roles:T.roles}})}),[P]),R=a((T)=>P({method:"DELETE"},`?id=${encodeURIComponent(T.id)}`),[P]);return{roles:r,presets:c,candidates:p,candidatesError:h,writeError:k,clearWriteError:A,applyPayload:N,writeRoles:M,savePreset:E,updatePreset:S,deletePreset:R}}var Yu=2000;async function Ju(t){let r=await fetch("/api/settings/omp-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json().catch(()=>null);if(typeof l!=="object"||l===null)return{ok:!1,error:`The config route answered ${r.status} without a body`};let c="success"in l&&l.success===!0,b="error"in l&&typeof l.error==="string"?l.error:void 0,p="value"in l?l.value:void 0;return{ok:c,...b?{error:b}:{},...p===void 0?{}:{value:p}}}function Sd(){let[t,r]=n({}),[l,c]=n(new Set),[b,p]=n(new Set),[g,h]=n(new Map),[v,k]=n(null),x=o(!0);i(()=>()=>{x.current=!1},[]);let A=a((T)=>{r(T)},[]),N=a((T)=>{k(T),setTimeout(()=>k((O)=>O===T?null:O),Yu)},[]),M=a((T,O)=>{if(!x.current)return;if(c((L)=>{let _=new Set(L);return _.delete(T),_}),p((L)=>{let _=new Set(L);return _.delete(T),_}),O.ok){if(h((L)=>{if(!L.has(T))return L;let _=new Map(L);return _.delete(T),_}),O.value!==void 0)r((L)=>({...L,[T]:{...L[T],value:O.value}}));N(T)}else h((L)=>new Map(L).set(T,O.error??"omp rejected the write"))},[N]),P=a(async(T,O)=>{c((L)=>new Set(L).add(T)),p((L)=>{let _=new Set(L);return _.delete(T),_});try{let L=await Ju(O);return M(T,L),L.ok}catch(L){return console.error("Failed to write omp config:",L),M(T,{ok:!1,error:L instanceof Error?L.message:String(L)}),!1}},[M]),E=a((T,O)=>P(T,{key:T,value:O}),[P]),S=a((T)=>P(T,{key:T,action:"reset"}),[P]),R=a((T,O)=>{p((L)=>{let _=new Set(L);if(O)_.add(T);else _.delete(T);return _})},[]);return{entries:t,savingKeys:l,dirtyKeys:b,saveErrors:g,savedKey:v,applyEntries:A,commitValue:E,resetKey:S,setDirty:R,flashSaved:N}}function No(t){if(typeof t!=="object"||t===null||!("error"in t))return null;return typeof t.error==="string"?t.error:null}function Nd(t){let[r,l]=n(null),[c,b]=n(!1),[p,g]=n([]),[h,v]=n(!0),[k,x]=n(!1),[A,N]=n(null),[M,P]=n(null),[E,S]=n(xn.tabs[0]?.id??"appearance"),[R,T]=n(""),[O,L]=n(new Set),[_,K]=n(null),[V,z]=n(!0);i(()=>()=>z(!1),[]);let q=Sd(),{applyEntries:G,flashSaved:j,savedKey:H}=q,X=wd(j),oe=a((Z)=>{if(Z)v(!0);else x(!0);P(null),Promise.all([fetch("/api/omp/state").then((Q)=>Q.json()),fetch("/api/settings/omp-config").then((Q)=>Q.json()),fetch("/api/model-roles").then((Q)=>Q.json()),fetch("/api/omp/extensions").then((Q)=>Q.json())]).then(([Q,re,ue,ve])=>{if(!V)return;if(Q.running&&Q.state)l(Q.state);else l(null);b(Boolean(Q.running));let Ne=No(re);if(Ne)P(Ne);else if(re.entries)G(re.entries);X.applyPayload(ue);let ce=No(ve);if(ce)K({message:ce});else if(Array.isArray(ve.extensions))g(ve.extensions);N(Date.now())}).catch((Q)=>{if(console.error("Failed to load omp settings:",Q),!V)return;P(Q instanceof Error?Q.message:String(Q))}).finally(()=>{if(!V)return;v(!1),x(!1)})},[G,X.applyPayload,V]);i(()=>{oe(!0)},[oe]);let te=async(Z)=>{let Q=!Z.disabled;L((re)=>new Set(re).add(Z.id));try{let re=await fetch("/api/omp/extensions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:Z.id,disabled:Q})}),ue=await re.json().catch(()=>null),ve=No(ue)??(re.ok?null:`The toggle answered ${re.status}`),Ne=`ext-${Z.id}`;if(ve){K({message:ve,scope:Ne});return}g((ce)=>ce.map((be)=>be.id===Z.id?{...be,disabled:Q}:be)),K((ce)=>ce?.scope===Ne?null:ce),j(Ne)}catch(re){console.error("Failed to toggle extension:",re),K({message:re instanceof Error?re.message:String(re),scope:`ext-${Z.id}`})}finally{L((re)=>{let ue=new Set(re);return ue.delete(Z.id),ue})}};if(h)return e("div",{className:"flex items-center justify-center p-8 text-ink/40 text-xs",children:"Reading omp’s state, config schema and extensions…"});return e("div",{className:"w-full space-y-4 text-ink pb-2 text-xs",children:[e(gd,{running:c,state:r,refreshing:k,updatedAt:A,searchQuery:R,onSearchChange:T,onRefresh:()=>oe(!1)}),M&&e("div",{className:"flex items-start gap-2 rounded-lg border border-error/30 bg-error/5 px-3 py-2 text-[11px] text-error",children:[e(B,{size:13,className:"mt-px flex-shrink-0"}),e("span",{className:"flex-1",children:["omp’s config could not be read: ",M,". The rows below cannot show what config.yml holds until this succeeds."]}),e("button",{type:"button",onClick:()=>oe(!1),className:"flex shrink-0 items-center gap-1 rounded border border-error/40 px-2 py-0.5 font-medium hover:bg-error/10 cursor-pointer",children:"Retry"})]}),_&&e("div",{className:"flex items-start gap-2 rounded-lg border border-error/30 bg-error/5 px-3 py-2 text-[11px] text-error",children:[e(B,{size:13,className:"mt-px flex-shrink-0"}),e("span",{className:"flex-1 break-words",children:_.message}),e("button",{type:"button",onClick:()=>K(null),"aria-label":"Dismiss error",className:"text-error/60 hover:text-error cursor-pointer",children:e(y,{size:12})})]}),e("div",{className:"pt-1",children:[e("div",{className:"flex items-center justify-between gap-3 pb-2",children:[e("div",{children:[e("h3",{className:"text-sm font-semibold text-ink",children:"Config"}),e("p",{className:"text-ink/50 mt-0.5",children:["Schema-driven settings backed by ",e("span",{className:"font-mono",children:"omp config"}),".",R.trim()&&", matching keys only"]})]}),H&&H!=="role-map"&&!H.startsWith("ext-")&&e("span",{className:"inline-flex shrink-0 items-center gap-1 text-[10px] text-ink/60",children:[e(f,{size:11})," saved ",e("span",{className:"font-mono",children:H})]})]}),e(md,{tabs:xn.tabs,entries:q.entries,activeTabId:E,onSelectTab:S,searchQuery:R,dirtyKeys:q.dirtyKeys,savingKeys:q.savingKeys,saveErrors:q.saveErrors,onCommit:q.commitValue,onReset:q.resetKey,onDirty:q.setDirty})]}),e(vd,{roles:X.roles,presets:X.presets,candidates:X.candidates,candidatesError:X.candidatesError,onSaveRoles:X.writeRoles,onSavePreset:X.savePreset,onUpdatePreset:X.updatePreset,onDeletePreset:X.deletePreset,savedRole:H==="role-map"?"roles":null,writeError:X.writeError,onDismissWriteError:X.clearWriteError}),e(xd,{extensions:p,savedExtension:H?.startsWith("ext-")?H.slice(4):null,pendingIds:O,onToggle:te})]})}var Xu={"7d":7,"30d":30,"90d":90},Td=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Qu=/^\d{4}-\d{2}-\d{2}$/;function Pd(t){return t<10?`0${t}`:String(t)}function Ue(t){let r=new Date(t);return`${r.getFullYear()}-${Pd(r.getMonth()+1)}-${Pd(r.getDate())}`}function yn(t){if(!Qu.test(t))return null;let r=Date.parse(`${t}T00:00:00`);if(Number.isNaN(r))return null;return Ue(r)===t?t:null}function Id(t,r,l){if(t==="custom"){let c=l?.from?yn(l.from):null,b=l?.to?yn(l.to):null;if(c&&b&&c<=b)return{from:c,to:b};return Cd("30d",r)}if(t==="all")return null;if(t==="today"){let c=Ue(r);return{from:c,to:c}}return Cd(t,r)}function Cd(t,r){let l=Xu[t];return{from:Ue(r-(l-1)*86400000),to:Ue(r)}}function Zu(t){if(!t)return"Undated";let r=new Date(`${t}T00:00:00`);return Number.isNaN(r.getTime())?t:`${Td[r.getMonth()]} ${r.getDate()}`}function wn(t,r){if(r==="month")return t.slice(0,7);if(r==="week"){let l=new Date(`${t}T00:00:00`);if(Number.isNaN(l.getTime()))return t;let c=new Date(l);return c.setDate(l.getDate()-(l.getDay()+6)%7),Ue(c.getTime())}return t}function Po(t,r){if(r==="month"){let[l,c]=t.split("-"),b=Td[Number(c)-1]??t,p=Number(l);return Number.isFinite(p)&&p!==new Date().getFullYear()?`${b} ${l}`:b}return Zu(t)}function Ad(t,r){if(t==="today"||t==="7d"||t==="30d")return"day";if(t==="90d")return"week";if(t==="all")return"month";let l=r?.from?yn(r.from):null,c=r?.to?yn(r.to):null;if(!l||!c)return"day";let b=Math.round((Date.parse(`${c}T00:00:00`)-Date.parse(`${l}T00:00:00`))/86400000)+1;if(b<=31)return"day";if(b<=120)return"week";return"month"}function Rd(t,r=400){let l=Date.parse(`${t.from}T00:00:00`),c=Date.parse(`${t.to}T00:00:00`);if(Number.isNaN(l)||Number.isNaN(c)||c<l)return[];let b=[];for(let p=l;p<=c&&b.length<r;p+=86400000){let g=Ue(p);if(b[b.length-1]!==g)b.push(g)}return b}function Md(t){let r="",l="";for(let c of t){if(!c)continue;if(!r||c<r)r=c;if(!l||c>l)l=c}return r&&l?{from:r,to:l}:null}function Co(t,r){return t<r?-1:t>r?1:0}function Ed({range:t,onRange:r,ranges:l,customFrom:c,customTo:b,onCustomFrom:p,onCustomTo:g,periodLabel:h,generatedAt:v,refreshing:k,onRefresh:x}){let[A,N]=n(!1),M=Ue(v);return e("div",{className:"flex flex-col gap-2 border-b border-ink/10 pb-3 sm:flex-row sm:items-center sm:justify-between",children:[e("div",{className:"flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[e("span",{className:"truncate text-xs font-semibold text-ink/75",children:h}),k&&e("span",{className:"text-[10px] text-ink/40",children:"updating…"})]}),e("div",{className:"flex flex-wrap items-center gap-2",children:[e("div",{className:"relative min-w-0 flex-1 sm:flex-none",children:[e("button",{type:"button","aria-expanded":A,onClick:()=>N((P)=>!P),className:"flex items-center gap-1.5 rounded-md border border-ink/15 bg-paper px-2.5 py-1 text-[11px] font-medium text-ink/80 transition-colors hover:bg-ink/5",children:[e($o,{size:12,"aria-hidden":"true"}),e("span",{children:t==="custom"?`${c} – ${b}`:l.find((P)=>P.id===t)?.label??"Month"})]}),A&&e("div",{className:"glass-popover absolute left-0 top-full z-30 mt-1 w-64 max-w-[calc(100vw-2rem)] divide-y divide-ink/5 rounded-md border border-ink/15 bg-paper py-1 text-[11px] shadow-lg sm:left-auto sm:right-0",children:[l.map((P)=>e("button",{type:"button","aria-current":t===P.id?"true":void 0,onClick:()=>{if(r(P.id),P.id!=="custom")N(!1)},className:`flex w-full items-center justify-between gap-2 px-3 py-1.5 text-left transition-colors hover:bg-ink/5 ${t===P.id?"bg-ink/5 font-semibold text-ink":"text-ink/70"}`,children:[e("span",{className:"truncate",children:P.label}),e("span",{className:"shrink-0 text-[10px] text-ink/40",children:P.dateRange})]},P.id)),t==="custom"&&e("div",{className:"space-y-2 px-3 py-2",children:[{label:"From",value:c,set:p,min:void 0,max:b},{label:"To",value:b,set:g,min:c,max:M}].map((P)=>e("label",{className:"block",children:[e("span",{className:"text-[10px] font-mono uppercase tracking-wider text-ink/40",children:P.label}),e("input",{type:"date",value:P.value,min:P.min,max:P.max,onChange:(E)=>P.set(E.currentTarget.value),className:"mt-0.5 w-full rounded border border-ink/15 bg-paper px-1.5 py-1 text-[11px] text-ink focus:border-ink/40 focus:outline-none"})]},P.label))})]})]}),e("button",{type:"button",onClick:x,title:"Refresh token usage","aria-label":"Refresh token usage",className:"rounded-md border border-ink/15 bg-paper p-1.5 text-ink/80 transition-colors hover:bg-ink/5",children:e(C,{size:12,className:k?"animate-spin":"","aria-hidden":"true"})})]})]})}function He(t,r=2){if(t>0&&Number(t.toFixed(r))===0)return"< $0.01";return`$${t.toFixed(r)}`}function Ee(t){if(!Number.isFinite(t)||t<=0)return"0";if(t>=1e9)return`${(t/1e9).toFixed(1)}B`;if(t>=1e6)return`${(t/1e6).toFixed(1)}M`;if(t>=1000)return`${(t/1000).toFixed(1)}K`;return String(Math.round(t))}function tm(t){let r=t.cacheRead+t.input;return r>0?t.cacheRead/r:null}function Oe(t){let r=tm(t);return r===null?"—":`${(r*100).toFixed(1)}%`}function Lt(t){if(t.tokens<=0)return"—";return`$${(t.cost/t.tokens*1e6).toFixed(2)}`}function Od(t){return{rawCost:He(t.cost),costPerMillion:Lt(t),processedTokens:Ee(t.tokens),activeRate:`${t.activeDays} active ${t.activeDays===1?"day":"days"}`,cachedInput:Ee(t.cacheRead),cachedPercent:`${Oe(t)} of observed input`,uncachedInput:Ee(t.input),cacheWrite:Ee(t.cacheWrite),outputTokens:Ee(t.output),reasoning:`${Ee(t.reasoning)} reasoning`,records:t.records,unpricedRecords:t.unpriced}}function Ld({totals:t,periodName:r}){let l=Od(t),c=t.cacheRead+t.input>0?t.cacheRead/(t.cacheRead+t.input):0;return e("div",{className:"grid grid-cols-1 gap-3 xl:grid-cols-3",children:[e("div",{className:"flex flex-col justify-between rounded-lg border border-ink/15 bg-paper p-3.5 shadow-xs",children:[e("div",{children:[e("div",{className:"mb-2 flex items-baseline justify-between gap-2",children:[e("span",{className:"font-mono text-[10px] font-semibold uppercase tracking-wider text-ink/40",children:"Provider-reported cost"}),e("span",{className:"font-mono text-[10px] uppercase tracking-wider text-ink/30",children:r})]}),e("div",{className:"flex items-baseline gap-1.5",children:[e("span",{className:"text-2xl font-bold tracking-tight tabular-nums text-ink",children:l.rawCost}),e("span",{className:"text-[11px] text-ink/45",children:"at API rates"})]}),e("p",{className:"mt-1 text-[11px] text-ink/50",children:[Lt(t)," per 1M tokens · ",l.processedTokens," tokens ·"," ",t.records.toLocaleString("en-US")," turns"]})]}),e("div",{className:"mt-3",children:[e("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-ink/10",children:e("div",{className:"h-full rounded-full bg-ink/80",style:{width:`${Math.min(100,c*100)}%`}})}),e("div",{className:"mt-1.5 flex items-center justify-between text-[11px] text-ink/60",children:[e("span",{children:[Oe(t)," served from cache"]}),e("span",{className:"tabular-nums text-ink/80",children:[l.cachedInput," cached"]})]})]})]}),e("div",{className:"grid grid-cols-2 gap-2.5 xl:col-span-2",children:[e(nt,{value:l.processedTokens,label:"Processed tokens",hint:l.activeRate}),e(nt,{value:l.outputTokens,label:"Output",hint:l.reasoning}),e(nt,{value:l.uncachedInput,label:"Uncached input",hint:`${l.cacheWrite} cache writes`}),e(nt,{value:He(t.cacheReadCost),label:"Paid for cache reads",hint:`${l.cachedInput} read at the cache rate`,tone:"muted"})]})]})}var Sn=["var(--theme-ink)","color-mix(in oklab, var(--theme-ink) 72%, transparent)","color-mix(in oklab, var(--theme-ink) 54%, transparent)","color-mix(in oklab, var(--theme-ink) 38%, transparent)","color-mix(in oklab, var(--theme-ink) 26%, transparent)","color-mix(in oklab, var(--theme-ink) 16%, transparent)"];function Dd(t,r,l){let c=t.byProvider[l];if(!c)return 0;return r==="cost"?c.cost:c.tokens}function Ud({buckets:t,metric:r,providers:l,visible:c,onToggle:b,granularity:p}){let g=l.filter((S)=>c.has(S.id));if(t.length===0)return e("div",{className:"flex h-32 items-center justify-center text-[11px] text-ink/40",children:"No usage recorded in this period."});let h=[],v=Array(t.length).fill(0);for(let S of g)v=v.map((R,T)=>R+Dd(t[T],r,S.id)),h.push(v);let k=Math.max(...v,0),x=k>0?k:1,A=(S)=>t.length===1?0:S/(t.length-1)*100,N=(S)=>98-S/x*94,M=(S)=>r==="cost"?He(S):Ee(S),P=(S)=>t.reduce((R,T)=>R+Dd(T,r,S),0),E=(S)=>{let R=h[S],T=S===0?Array(t.length).fill(0):h[S-1],O=R.map((_,K)=>`${K===0?"M":"L"}${A(K).toFixed(2)},${N(_).toFixed(2)}`),L=[...T].reverse().map((_,K)=>`L${A(t.length-1-K).toFixed(2)},${N(_).toFixed(2)}`);return`${O.join(" ")} ${L.join(" ")} Z`};return e("div",{className:"flex flex-col gap-2",children:[e("div",{className:"relative h-32",children:[e("div",{className:"absolute inset-0 flex flex-col justify-between pb-4 pt-1",children:[e("div",{className:"w-full border-t border-dashed border-ink/5"}),e("div",{className:"w-full border-t border-dashed border-ink/5"}),e("div",{className:"w-full border-t border-ink/15"})]}),e("div",{className:"absolute bottom-4 left-0 top-0 flex w-10 flex-col justify-between font-mono text-[10px] text-ink/40",children:[e("span",{children:M(k)}),e("span",{children:M(k/2)}),e("span",{children:"0"})]}),e("div",{className:"absolute bottom-4 left-10 right-0 top-0",children:e("svg",{className:"h-full w-full",preserveAspectRatio:"none",viewBox:"0 0 100 100",role:"img","aria-label":`${r} by provider, bucketed by ${p}`,children:g.map((S,R)=>e("path",{d:E(R),fill:Sn[l.indexOf(S)%Sn.length],stroke:"none"},S.id))})}),e("div",{className:"absolute bottom-0 left-10 right-0 flex h-4 items-end justify-between text-[10px] text-ink/40",children:[e("span",{children:t[0]?.label}),t.length>2&&e("span",{children:t[Math.floor(t.length/2)]?.label}),t.length>1&&e("span",{children:t[t.length-1]?.label})]})]}),e("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:l.map((S)=>{let R=c.has(S.id),T=P(S.id);return e("button",{type:"button","aria-pressed":R,onClick:()=>b(S.id),className:`flex items-center gap-1.5 text-[10px] transition-opacity ${R?"text-ink/70":"line-through text-ink/35"} hover:text-ink`,title:`${S.name}: ${M(T)} in this period`,children:[e("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 rounded-full",style:{background:Sn[l.indexOf(S)%Sn.length]}}),e("span",{className:"font-medium",children:S.name}),e("span",{className:"font-mono tabular-nums text-ink/45",children:M(T)})]},S.id)})})]})}function nm(t){return[{id:"provider",label:"PROVIDER"},{id:"model",label:"MODEL"},{id:"day",label:t==="week"?"WEEK":t==="month"?"MONTH":"DAY"},{id:"project",label:"PROJECT"}]}var om=8,rm=14;function Fd({tab:t,onTab:r,rows:l,totals:c,granularity:b,providerNames:p}){let[g,h]=n(null),[v,k]=n(!1),x=t==="provider"||t==="model",A=u(()=>new Set(l.filter((S)=>S.kind==="group").slice(0,3).map((S)=>S.provider??"")),[l]),N=g??A,M=u(()=>{if(!x)return l;let S=[];for(let R of l)if(R.kind==="group"||v||N.has(R.provider??""))S.push(R);return S},[l,x,v,N]),P=(S)=>{let R=new Set(N);if(R.has(S))R.delete(S);else R.add(S);h(R)},E=t==="day"?b:t==="model"?"Provider / Model":t;return e("div",{className:"grid grid-cols-1 gap-3 xl:grid-cols-3",children:[e("div",{className:"rounded-lg border border-ink/15 bg-paper p-3.5 shadow-xs xl:col-span-2",children:[e("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-x-2 gap-y-1.5",children:[e("span",{className:"flex items-baseline gap-2 text-xs font-semibold text-ink",children:["Breakdown",e("span",{className:"font-mono text-[10px] font-normal uppercase tracking-wider text-ink/35",children:x?"period total":`${l.length} ${l.length===1?"row":"rows"} · ${b}`})]}),e("div",{role:"tablist","aria-label":"Breakdown",className:"flex shrink-0 rounded bg-ink/5 p-0.5",children:nm(b).map((S)=>e("button",{type:"button",role:"tab","aria-selected":t===S.id,onClick:()=>r(S.id),className:`rounded px-2 py-0.5 text-[10px] font-bold tracking-wider transition-colors ${t===S.id?"bg-paper text-ink shadow-xs":"text-ink/50 hover:text-ink"}`,children:S.label},S.id))})]}),l.length===0?e("p",{className:"py-6 text-center text-[11px] text-ink/40",children:"No usage recorded in this period."}):e("div",{className:"overflow-x-auto",children:e("div",{className:x?void 0:"overflow-y-auto",style:x?void 0:{maxHeight:`${rm*1.6}rem`},children:e("table",{className:"w-full text-[11px]",children:[e("thead",{children:e("tr",{className:"border-b border-ink/10 text-ink/40",children:[e("th",{className:"pb-2 text-left font-medium capitalize",children:E}),e("th",{className:"pb-2 text-right font-medium",children:"Cost"}),e("th",{className:"pb-2 text-right font-medium",children:"Share"}),e("th",{className:"pb-2 text-right font-medium",children:"Tokens"}),e("th",{className:"hidden pb-2 text-right font-medium sm:table-cell",children:"Cache"}),e("th",{className:"hidden pb-2 text-right font-medium sm:table-cell",children:"Turns"})]})}),e("tbody",{className:"divide-y divide-ink/5",children:M.map((S)=>{let R=S.kind==="group",T=S.provider??"",O=!R||v||N.has(T);return e("tr",{className:R?"bg-ink/[0.02]":void 0,children:[e("td",{className:"py-2",children:e("div",{className:"flex items-center gap-2",style:{paddingLeft:`${S.depth*14}px`},children:[R?e("button",{type:"button","aria-expanded":O,"aria-label":`${S.label} models`,onClick:()=>P(T),className:"-ml-0.5 text-ink/50 transition-colors hover:text-ink",children:O?e(I,{size:12}):e(se,{size:12})}):null,S.provider&&e(Me,{provider:{slug:S.provider,name:p[S.provider]??S.provider},size:R?16:14,radius:4}),e("span",{className:`whitespace-nowrap ${R?"font-semibold text-ink":"font-medium text-ink/85"}`,children:S.label})]})}),e("td",{className:`py-2 text-right tabular-nums ${R?"font-bold text-ink":"text-ink/80"}`,children:He(S.cost)}),e("td",{className:"py-2 text-right tabular-nums text-ink/60",children:[S.sharePercent.toFixed(1),"%"]}),e("td",{className:"py-2 text-right tabular-nums text-ink/60",children:Ee(S.tokens)}),e("td",{className:"hidden py-2 text-right tabular-nums text-ink/60 sm:table-cell",children:S.cacheHit}),e("td",{className:"hidden py-2 text-right tabular-nums text-ink/60 sm:table-cell",children:S.records.toLocaleString("en-US")})]},S.key)})})]})})}),e("div",{className:"mt-3 flex h-1.5 w-full overflow-hidden rounded-full bg-ink/5",children:l.filter((S)=>S.kind==="group"||!x).slice(0,om).map((S,R)=>e("div",{className:R===0?"bg-ink/80":R===1?"border-l border-paper bg-ink/45":"border-l border-paper bg-ink/25",style:{width:`${S.sharePercent}%`}},S.key))}),x&&!v&&M.length<l.length&&e("button",{type:"button",onClick:()=>k(!0),className:"mt-2 text-[10px] font-semibold text-ink/50 transition-colors hover:text-ink",children:["Show all ",l.length," rows"]})]}),e("div",{className:"rounded-lg border border-ink/15 bg-paper p-3.5 shadow-xs",children:[e("div",{className:"mb-3 flex items-baseline justify-between gap-2",children:[e("span",{className:"text-xs font-semibold text-ink",children:"Cost quality"}),e("span",{className:"font-mono text-[10px] uppercase tracking-wider text-ink/35",children:"period total"})]}),e("dl",{className:"space-y-2 text-[11px]",children:[e("div",{className:"flex items-center justify-between",children:[e("dt",{className:"text-ink/60",children:"Cost per 1M tokens"}),e("dd",{className:"tabular-nums font-semibold text-ink",children:Lt(c)})]}),e("div",{className:"flex items-center justify-between",children:[e("dt",{className:"text-ink/60",children:"Cache hit rate"}),e("dd",{className:"tabular-nums font-semibold text-ink",children:Oe(c)})]}),e("div",{className:"flex items-center justify-between",children:[e("dt",{className:"text-ink/60",children:"Unpriced turns"}),e("dd",{className:"tabular-nums font-semibold text-ink",children:c.records>0?`${(c.unpriced/c.records*100).toFixed(1)}%`:"–"})]}),e("div",{className:"flex items-center justify-between",children:[e("dt",{className:"text-ink/60",children:"Turns"}),e("dd",{className:"tabular-nums font-semibold text-ink",children:c.records.toLocaleString("en-US")})]})]}),e("div",{className:"mt-3 border-t border-ink/10 pt-2.5",children:[e("div",{className:"flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/60",children:"Paid for cache reads"}),e("span",{className:"tabular-nums font-semibold text-ink",children:He(c.cacheReadCost)})]}),e("p",{className:"mt-1 text-[10px] leading-tight text-ink/40",children:"Provider-reported cost only. A turn with no reported rate counts as unpriced rather than free."})]})]})]})}function jd(t){if(!Number.isFinite(t)||t<1000)return"just now";let r=Math.round(t/1000);if(r<60)return`${r}s ago`;let l=Math.round(r/60);if(l<60)return`${l} min ago`;return`${Math.round(l/60)} h ago`}function $d({index:t,generatedAt:r,providers:l}){let c=t.state==="building",p=!(t.indexedAt>0)?t.state==="failed"?"Index failed":"No sessions indexed yet":c?`Updated ${jd(r-t.indexedAt)} · rechecking`:t.state==="failed"?"Index failed":`Updated ${jd(r-t.indexedAt)}`;return e("div",{className:"flex flex-wrap items-center justify-center gap-x-2 gap-y-1 pt-2 text-center text-[10px] text-ink/40",children:[e("span",{children:[p," · ",t.transcripts.toLocaleString("en-US")," transcripts ·"," ",t.records.toLocaleString("en-US")," records · ",l," ",l===1?"provider":"providers"]}),e("span",{"aria-hidden":"true",children:"·"}),e("span",{children:["index scan ",t.scanMs.toLocaleString("en-US")," ms"]}),t.state==="failed"&&t.error&&e(d,{children:[e("span",{"aria-hidden":"true",children:"·"}),e("span",{className:"text-[var(--theme-error)]",children:t.error})]})]})}var im=1500;function Bd(t,r){let[l,c]=n(null),[b,p]=n(null),[g,h]=n(!0),[v,k]=n(!1),x=o(null),A=o(null),N=o(null),M=o(!1),P=()=>{if(N.current!==null)clearTimeout(N.current),N.current=null},E=a(()=>{let T=new URLSearchParams({range:t});if(t==="custom")T.set("customFrom",r.from),T.set("customTo",r.to);return`/api/telemetry/tokens?${T.toString()}${M.current?"&refresh=1":""}`},[t,r.from,r.to]),S=a(async(T)=>{x.current?.abort();let O=new AbortController;x.current=O,M.current=T,k(!0);try{let L=await fetch(E(),{signal:O.signal,method:T?"POST":"GET"}),_=await L.json();if(!L.ok||_.error)throw Error(_.error??`Token usage failed (${L.status})`);if(A.current=_,c(_),p(null),h(!1),P(),_.index.state==="building")N.current=setTimeout(()=>{M.current=!1,S(!1)},im)}catch(L){if(O.signal.aborted)return;p(L instanceof Error?L.message:"Failed to load token usage"),h(!1)}finally{if(!O.signal.aborted)k(!1)}},[E]);i(()=>(h((T)=>T&&A.current===null),S(!1),()=>{x.current?.abort(),P()}),[S]);let R=a((T=!1)=>{P(),S(T)},[S]);return{payload:l,error:b,loading:g,refreshing:v,reload:R}}function To(t,r){let l=new Map;for(let c of t){let b=wn(c.day,r),p=l.get(b);if(!p)p={key:b,label:Po(b,r),cost:0,tokens:0,byProvider:{}},l.set(b,p);p.cost+=c.cost,p.tokens+=c.tokens;for(let[g,h]of Object.entries(c.providers)){let v=p.byProvider[g]??{cost:0,tokens:0};v.cost+=h.cost,v.tokens+=h.tokens,p.byProvider[g]=v}}return[...l.values()].sort((c,b)=>Co(c.key,b.key))}function Ut(t,r){return r>0?Math.round(t/r*1000)/10:0}function am(t,r){let l=[];for(let c of t){l.push({key:`p:${c.id}`,label:c.name,provider:c.id,kind:"group",cost:c.cost,tokens:c.tokens,records:c.records,cacheHit:Oe(c),sharePercent:Ut(c.cost,r),depth:0});for(let b of c.models)l.push({key:`m:${c.id}:${b.model}`,label:b.model||"unknown",provider:c.id,model:b.model,kind:"row",cost:b.cost,tokens:b.tokens,records:b.records,cacheHit:Oe(b),sharePercent:Ut(b.cost,r),shareOfParentPercent:Ut(b.cost,c.cost),depth:1})}return l}function sm(t,r,l,c){let b=To(t,r),p=new Map;for(let h of t){let v=wn(h.day,r),k=p.get(v)??{records:0,cacheRead:0,input:0};k.records+=h.records,k.cacheRead+=h.cacheRead,k.input+=h.input,p.set(v,k)}let g=new Set(b.map((h)=>h.key));for(let h of c?Rd(c):[]){let v=wn(h,r);if(g.has(v))continue;g.add(v),b.push({key:v,label:Po(v,r),cost:0,tokens:0,byProvider:{}})}return[...b].sort((h,v)=>Co(h.key,v.key)).map((h)=>{let v=p.get(h.key)??{records:0,cacheRead:0,input:0};return{key:`d:${h.key}`,label:h.label,kind:"row",cost:h.cost,tokens:h.tokens,records:v.records,cacheHit:Oe(v),sharePercent:Ut(h.cost,l),depth:0}})}function lm(t,r){return[...t].sort((l,c)=>c.cost-l.cost).map((l)=>({key:`j:${l.project}`,label:l.project,kind:"row",cost:l.cost,tokens:l.tokens,records:l.records,cacheHit:Oe(l),sharePercent:Ut(l.cost,r),depth:0}))}function _d(t,r,l,c){switch(t){case"provider":case"model":return am(r.providers,r.totals.cost);case"day":return sm(r.days,l,r.totals.cost,c);case"project":return lm(r.projects,r.totals.cost)}}var dm=[{id:"cost",label:"COST"},{id:"tokens",label:"TOKENS"}],cm={today:"Day","7d":"Week","30d":"Month","90d":"90 days",all:"All time",custom:"Custom"};function Kd({settings:t,onUpdate:r}){let[l,c]=n("30d"),[b,p]=n("model"),[g,h]=n("cost"),[v]=n(()=>Ue(Date.now())),[k,x]=n(()=>Ue(Date.now()-2505600000)),[A,N]=n(v),[M,P]=n(new Set),{payload:E,error:S,loading:R,refreshing:T,reload:O}=Bd(l,{from:k,to:A}),L=E?.providers??[],_=E?.totals??pm,K=Ad(l,{from:k,to:A}),V=u(()=>Id(l,E?.generatedAt??Date.now(),{from:k,to:A})??Md((E?.days??[]).map((H)=>H.day)),[l,E?.generatedAt,E?.days,k,A]),z=u(()=>To(E?.days??[],K),[E?.days,K]),q=u(()=>E?_d(b,{totals:_,providers:E.providers,days:E.days,projects:E.projects},K,V):[],[b,E,_,K,V]),G=u(()=>Object.fromEntries(L.map((H)=>[H.id,H.name])),[L]),j=u(()=>new Set(L.filter((H)=>!M.has(H.id)).map((H)=>H.id)),[L,M]);if(S&&!E)return e("div",{className:"mx-auto max-w-md space-y-3 py-10 text-center",children:[e("p",{className:"text-xs font-semibold text-ink",children:"Token usage could not be read"}),e("p",{className:"text-[11px] text-ink/60",children:S}),e("button",{type:"button",onClick:()=>O(!0),className:"rounded-md border border-ink/15 bg-paper px-3 py-1 text-[11px] font-medium text-ink hover:bg-ink/5",children:"Retry"})]});if(R||!E)return e("div",{className:"space-y-3","aria-busy":"true",children:[e("div",{className:"h-8 w-full animate-pulse rounded-md bg-ink/5"}),e("div",{className:"grid grid-cols-1 gap-3 xl:grid-cols-3",children:[e("div",{className:"h-28 animate-pulse rounded-lg bg-ink/5 xl:col-span-2"}),e("div",{className:"h-28 animate-pulse rounded-lg bg-ink/5"})]}),e("div",{className:"h-52 animate-pulse rounded-lg bg-ink/5"}),e("p",{className:"text-center text-[10px] text-ink/40",children:"Indexing session transcripts…"})]});return e("div",{className:"w-full space-y-4 pb-2 text-xs text-ink",children:[e(Ed,{range:l,onRange:c,ranges:E.timeRanges,customFrom:k,customTo:A,onCustomFrom:x,onCustomTo:N,periodLabel:E.periodLabel,generatedAt:E.generatedAt,refreshing:T,onRefresh:()=>O(!0)}),S&&e("div",{role:"status",className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-[var(--theme-error)]/40 bg-[var(--theme-error)]/5 px-3 py-1.5 text-[11px]",children:[e("span",{className:"text-ink/75",children:["Showing the last successful read. ",S]}),e("button",{type:"button",onClick:()=>O(!0),className:"rounded border border-ink/15 bg-paper px-2 py-0.5 font-medium text-ink hover:bg-ink/5",children:"Retry"})]}),e(Ld,{totals:_,periodName:cm[l]}),e("div",{className:"rounded-lg border border-ink/15 bg-paper p-3.5 shadow-xs",children:[e("div",{className:"mb-3 flex flex-wrap items-start justify-between gap-2",children:[e("div",{className:"flex flex-wrap items-center gap-2",children:[e("span",{className:"text-xs font-semibold capitalize text-ink",children:[g," by provider"]}),e("span",{className:"text-[10px] text-ink/45",children:[z.length," ",K," ",z.length===1?"bucket":"buckets"," · click a legend entry to hide it"]})]}),e("div",{role:"tablist","aria-label":"Chart metric",className:"flex rounded bg-ink/5 p-0.5",children:dm.map((H)=>e("button",{type:"button",role:"tab","aria-selected":g===H.id,onClick:()=>h(H.id),className:`rounded px-2 py-0.5 text-[10px] font-bold tracking-wider transition-colors ${g===H.id?"bg-paper text-ink shadow-xs":"text-ink/50 hover:text-ink"}`,children:H.label},H.id))})]}),e(Ud,{buckets:z,metric:g,granularity:K,providers:L.map((H)=>({id:H.id,name:H.name})),visible:j,onToggle:(H)=>P((X)=>{let oe=new Set(X);if(oe.has(H))oe.delete(H);else oe.add(H);return oe})})]}),e(Fd,{tab:b,onTab:p,rows:q,totals:_,granularity:K,providerNames:G}),e($d,{index:E.index,generatedAt:E.generatedAt,providers:L.length}),e("details",{className:"rounded-lg border border-ink/10 bg-ink/[0.02] px-3 py-2 text-[10px] text-ink/50",children:[e("summary",{className:"cursor-pointer select-none font-semibold text-ink/60",children:"How these numbers are produced"}),e("ul",{className:"mt-2 space-y-1 leading-relaxed",children:[e("li",{children:"Cost and tokens are omp's own per-message records, attributed to the provider and model that served the turn. A turn without a reported rate is counted as unpriced, never as free."}),e("li",{children:"Cache hit rate is cache reads over all observed input. “Paid for cache reads” is what those reads cost, not what they saved."}),e("li",{children:"Each transcript is read once; later requests re-read only the bytes appended since. Clearing Kabmo's database rebuilds the index from the session files."}),e("li",{children:[_.records.toLocaleString("en-US")," turns in this period · ",Ee(_.tokens)," tokens ·"," ",Oe(_)," cached · ",He(_.cost)," at API rates · ",L.length," ",L.length===1?"provider":"providers"]})]})]})]})}var pm={cost:0,tokens:0,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,cacheReadCost:0,records:0,unpriced:0,activeDays:0};function um({provider:t}){return e(Me,{provider:{slug:t.id,name:t.name,...t.iconUrl?{iconUrl:t.iconUrl}:{}},size:20})}function zd({report:t,selectedProviderId:r,onSelectProvider:l}){let c=ys(t);return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0 select-none",children:[e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex items-center justify-between",children:e("span",{className:"text-xs font-semibold text-ink",children:[c.length," provider",c.length===1?"":"s"," with keys"]})}),e("div",{className:"flex-1 scrollbar-overlay-container p-1.5 space-y-3 text-xs",children:c.length===0?e("p",{className:"px-2.5 py-3 text-[11px] text-ink/50 leading-relaxed",children:"No provider credentials detected. Add an API key in Settings → Providers."}):e("div",{children:[e("div",{className:"px-2.5 pt-1.5 pb-1 text-[10px] font-bold text-ink/50 uppercase tracking-wider",children:"Providers"}),e("div",{className:"space-y-0.5",children:c.map((b)=>{let p=b.id===r;return e("button",{type:"button",onClick:()=>l(b.id),className:`w-full text-left px-2.5 py-2 rounded-lg transition-colors cursor-pointer flex flex-col gap-0.5 group ${p?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e("div",{className:"flex items-center justify-between gap-1.5",children:[e("div",{className:"flex items-center gap-1.5 min-w-0",children:[e("div",{className:"relative",children:[e(um,{provider:b}),e("span",{className:`absolute -top-0.5 -right-0.5 w-1.5 h-1.5 rounded-full ${b.error?"bg-error/60":"bg-ink"}`})]}),e("span",{className:"font-semibold text-xs text-ink truncate",children:b.name})]}),e("span",{className:`text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 font-medium ${b.error?"text-error":"text-ink/70"}`,children:vs(b)})]}),e("p",{className:"text-[11px] text-ink/60 line-clamp-1 leading-snug pl-5",children:b.hint})]},b.id)})})]})})]})}function Hd(){let t=ke(),{report:r,isLoading:l,error:c,reload:b}=iu(),[p,g]=n(""),h=r?ys(r):[],v=h.find((k)=>k.id===p)??h[0];if(i(()=>{if(v&&v.id!==p)g(v.id)},[v,p]),c&&!r)return e("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-8 text-center text-xs",children:[e(B,{size:16,className:"text-error"}),e("p",{className:"text-error text-xs",children:c}),e("button",{type:"button",onClick:()=>b(),className:"text-[11px] font-semibold text-ink/70 hover:text-ink underline underline-offset-2",children:"Try again"})]});if(!r)return e("div",{className:"flex h-full w-full items-center justify-center text-ink/40 text-xs",children:"Loading provider usage..."});return e("div",{className:"flex h-full w-full overflow-hidden bg-paper text-xs text-ink",children:e(ye,{pane:t.pane,onBack:t.back,listLabel:"Usage",list:e(zd,{report:r,selectedProviderId:v?.id??"",onSelectProvider:(k)=>{g(k),t.openDetail()}}),detail:e("div",{className:"flex-1 h-full overflow-hidden flex flex-col",children:[e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex items-center justify-between gap-3 flex-shrink-0",children:[e("div",{className:"flex items-center gap-2 min-w-0",children:[e("span",{className:"text-xs font-semibold text-ink/75 truncate",children:["Updated ",Zr(r.generatedAt)]}),r.isMock&&e("span",{className:"text-[10px] font-mono uppercase tracking-wider bg-ink/5 border border-ink/15 rounded px-1.5 py-0.5 text-ink/60",children:"Mock"})]}),e("button",{type:"button",onClick:()=>b({force:!0}),disabled:l,className:"p-1.5 bg-paper border border-ink/15 rounded-md hover:bg-ink/5 text-ink/80 transition-colors disabled:opacity-50 flex-shrink-0",title:"Refresh usage",children:e(C,{size:12,className:l?"animate-spin text-ink":""})})]}),e("div",{className:"flex-1 overflow-y-auto scrollbar-overlay-container p-3.5 space-y-4",children:[c&&e("p",{className:"text-error text-xs",children:c}),v?e(ru,{summary:v.summary}):e("p",{className:"text-[11px] text-ink/50 leading-relaxed",children:"No provider credentials detected. Add an API key in Settings → Providers and it will appear here."}),e(au,{})]})]})})})}function Ao({label:t,enabled:r,onToggle:l}){return e("button",{type:"button",role:"switch","aria-checked":r,"aria-label":`${r?"Disable":"Enable"} ${t}`,onClick:l,className:`relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none ${r?"bg-ink":"bg-ink/20"}`,children:e("span",{"aria-hidden":"true",className:`pointer-events-none inline-block h-5 w-5 transform rounded-full bg-paper shadow ring-0 transition duration-200 ease-in-out ${r?"translate-x-5":"translate-x-0"}`})})}function Io({icon:t,title:r,description:l,enabled:c,onToggle:b}){return e("div",{className:"flex items-start justify-between gap-4 py-3",children:[e("div",{className:"flex items-start gap-3",children:[e("div",{className:"w-8 h-8 rounded-md bg-ink/5 border border-ink/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e(t,{size:16,className:c?"text-ink":"text-ink/40"})}),e("div",{children:[e("div",{className:"text-sm font-semibold text-ink",children:r}),e("p",{className:"text-ink/65 text-[11px] mt-1 leading-relaxed",children:l})]})]}),e(Ao,{label:r,enabled:c,onToggle:b})]})}function Wd({icon:t,title:r,description:l,enabled:c,current:b,onToggle:p}){return e("div",{className:"rounded-lg border border-ink/10 bg-canvas/40 p-3 space-y-2",children:[e("div",{className:"flex items-center justify-between gap-3",children:[e("div",{className:"flex items-center gap-2 min-w-0",children:[e(t,{size:15,className:c?"text-ink":"text-ink/40"}),e("span",{className:"text-sm font-semibold text-ink",children:r}),b&&e("span",{className:"text-[9px] uppercase font-mono px-1.5 py-0.5 rounded bg-ink/10 text-ink/80 font-bold",children:"This device"})]}),e(Ao,{label:`${r} notifications`,enabled:c,onToggle:p})]}),e("p",{className:"text-ink/65 text-[11px] leading-relaxed",children:l})]})}var mm={desktop:"notifyDesktopEnabled",mobile:"notifyMobileEnabled"};function Gd({settings:t,onUpdate:r}){let[l,c]=n(!1),b=()=>{c(!0),Xp(),setTimeout(()=>c(!1),600)},p=t.chatCompletionSound??t.soundAlerts??!0,g=t.notifyDesktopEnabled!==!1,h=t.notifyMobileEnabled!==!1,v=t.notifyOnFinish===!0||t.notifyOnAsk===!0||t.notifyOnError===!0,k=Zp();i(()=>{if(v&&(k==="mobile"?h:g))Jp()},[v,g,h,k]),i(()=>{em(t)},[t]);let x=(N,M)=>{if(r({[mm[N]]:M}),M)Jp()},A=(N,M)=>{if(r({[N]:M}),M)Jp()};return e("div",{className:"w-full space-y-6 text-xs text-ink",children:[e("div",{className:"bg-paper border border-ink/15 rounded-lg p-4 shadow-xs space-y-4",children:[e("div",{className:"flex items-start justify-between gap-4",children:[e("div",{className:"flex items-start gap-3",children:[e("div",{className:"w-8 h-8 rounded-md bg-ink/5 border border-ink/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:p?e(Pn,{size:16,className:"text-ink"}):e(or,{size:16,className:"text-ink/40"})}),e("div",{children:[e("div",{className:"text-sm font-semibold text-ink flex items-center gap-2",children:[e("span",{children:"AI Response Completion Sound"}),e("span",{className:"text-[10px] uppercase font-mono px-1.5 py-0.5 rounded bg-ink/10 text-ink/80 font-bold",children:"Audio Chime"})]}),e("p",{className:"text-ink/65 text-[11px] mt-1 leading-relaxed",children:"Play an audible notification chime when the AI completes generating its response, thinking blocks, or diagnostic execution."})]})]}),e(Ao,{label:"AI response completion sound",enabled:p,onToggle:()=>{let N=!p;if(r({chatCompletionSound:N,soundAlerts:N}),N)Xp()}})]}),e("div",{className:"pt-3 border-t border-ink/10 flex items-center justify-between",children:[e("span",{className:"text-[11px] text-ink/60 flex items-center gap-1.5",children:[e(Fe,{size:13,className:"text-ink/60"}),"Warm harmonic chime synthesized natively via Web Audio"]}),e("button",{type:"button",onClick:b,className:`px-3 py-1.5 rounded-md border border-ink/20 bg-paper hover:bg-ink/5 text-ink font-medium text-[11px] flex items-center gap-1.5 transition-all shadow-xs active:scale-95 ${l?"border-ink bg-ink/10":""}`,children:[e(Pn,{size:13,className:l?"animate-bounce text-ink":"text-ink/70"}),e("span",{children:l?"Playing...":"Test Sound"})]})]})]}),e("div",{className:"bg-paper border border-ink/15 rounded-lg p-4 shadow-xs space-y-4",children:[e("div",{className:"flex items-start gap-3",children:[e("div",{className:"w-8 h-8 rounded-md bg-ink/5 border border-ink/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e(jo,{size:16,className:"text-ink"})}),e("div",{children:[e("div",{className:"text-sm font-semibold text-ink",children:"System Notifications"}),e("p",{className:"text-ink/65 text-[11px] mt-1 leading-relaxed",children:"Sent whether or not Kabmo is the window you are looking at. Clicking one opens that session; the sidebar badge stays the in-app record either way."})]})]}),e("div",{className:"grid gap-3 sm:grid-cols-2",children:[e(Wd,{icon:Aa,title:"Desktop",description:"This computer: a browser tab, an installed PWA, or the desktop shell.",enabled:g,current:k==="desktop",onToggle:()=>x("desktop",!g)}),e(Wd,{icon:cr,title:"Mobile",description:"A phone or tablet, including the Android and iOS shells.",enabled:h,current:k==="mobile",onToggle:()=>x("mobile",!h)})]}),e("div",{className:"pt-3 border-t border-ink/10",children:[e("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-ink/50 pb-1",children:"Notify me when"}),e("div",{className:"divide-y divide-ink/10",children:[e(Io,{icon:ne,title:"Run finished",description:"A session's agent finished its turn.",enabled:t.notifyOnFinish===!0,onToggle:()=>A("notifyOnFinish",t.notifyOnFinish!==!0)}),e(Io,{icon:ze,title:"Waiting for you",description:"An agent is blocked on a question or an approval.",enabled:t.notifyOnAsk===!0,onToggle:()=>A("notifyOnAsk",t.notifyOnAsk!==!0)}),e(Io,{icon:D,title:"Run failed",description:"A run ended in failure, with the reason when the agent reported one.",enabled:t.notifyOnError===!0,onToggle:()=>A("notifyOnError",t.notifyOnError!==!0)})]})]})]})]})}function wA({isOpen:t,onClose:r,initialCategory:l="appearance",appSettings:c={},autoOpenAddProvider:b=!1}){let[p,g]=n(l),[h,v]=n("browse"),[k,x]=n(b),[A,N]=n(""),[M,P]=n(!1),E=Cp(),{isReloading:S,reload:R}=ar(),{isRestarting:T,restart:O}=sr(),{pushToast:L}=Ve(),{harnesses:_}=Nn(),K=_.filter((Q)=>!Q.builtIn&&!Q.enabled).map((Q)=>Q.id),[V,z]=n(()=>NA(ir,c)),q=o(null);Uo(q,{open:t,onClose:r}),i(()=>{if(t)g(l),x(b),P(b),N("")},[t,l,b]),_e("omp:open-settings",(Q)=>{let re=Q;if(re.detail?.category)g(re.detail.category);if(re.detail?.autoOpenAdd)x(!0)});let G=(Q)=>{z((re)=>{let ue=typeof Q==="function"?Q(re):{...re,...Q};return dr(re,ue),E(rr(re,ue,Q)),ue}),L("Setting was saved","success")},j=async()=>{let Q=await R();L(Q.message,Q.ok?"success":"error")},H=async()=>{let Q=await O();L(Q.message,Q.ok?"success":"error")},X=(Q)=>{g(Q),P(!0)};if(!t)return null;let oe=mr(_.map((Q)=>Q.id)),te=oe.find((Q)=>Q.id===p)||oe[0],Z=()=>{switch(p){case"appearance":return e(Dr,{settings:V,onUpdate:G});case"chats":return e(Qr,{settings:V,onUpdate:G});case"keyboard":return e(ii,{settings:V,onUpdate:G});case"projects":return e(Ri,{});case"providers":return e(Qa,{autoOpenAdd:k,onAddModalClose:()=>x(!1)});case"agents":return e(ds,{settings:V,onUpdate:G});case"harness-index":return e(so,{});case"behavior":return e(ps,{});case"commands":return e(ms,{settings:V,onUpdate:G});case"mcp":return e(Ts,{settings:V,onUpdate:G});case"token-usage":return e(Kd,{settings:V,onUpdate:G});case"notifications":return e(Gd,{settings:V,onUpdate:G});case"plugins":return e(gl,{});case"panel-plugins":return e(Fl,{});case"skills":return e(ol,{settings:V,onUpdate:G,onNavigateToCatalog:(Q)=>{v(Q??"browse"),g("skills-catalog")}});case"skills-catalog":return e(Ql,{initialTab:h});case"omp":return e(Nd,{settings:V,onUpdate:G});case"usage":return e(Hd,{});default:{let Q=yg(p);if(Q)return e(so,{only:Q});return e(ed,{category:p})}}};return e("div",{className:"fixed inset-0 modal-scrim backdrop-blur-[2px] z-50 flex items-center justify-center p-0 md:p-6 animate-in fade-in duration-150",onClick:r,children:e("div",{ref:q,role:"dialog","aria-modal":"true","aria-label":"Settings",tabIndex:-1,className:"glass-overlay relative bg-paper border border-ink/15 md:rounded-2xl shadow-2xl w-full h-full md:max-w-5xl lg:max-w-6xl xl:max-w-[1280px] md:h-[min(90vh,900px)] md:max-h-[92vh] flex flex-col md:flex-row overflow-hidden text-ink",onClick:(Q)=>Q.stopPropagation(),children:[e("div",{className:"hidden md:flex w-72 flex-shrink-0 h-full",children:e(Rn,{activeCategory:p,onSelectCategory:(Q)=>g(Q),searchQuery:A,onSearchChange:N,onReloadOmp:j,isReloading:S,onRestartKabmo:H,isRestarting:T,disabledHarnesses:K,categories:oe,className:"w-full"})}),e("div",{className:`flex-1 flex-col h-full overflow-hidden ${M?"flex":"hidden md:flex"}`,children:[e("div",{className:"px-6 border-b border-ink/10 flex items-center justify-between flex-shrink-0",style:{height:"calc(4rem + env(safe-area-inset-top, 0px))",paddingTop:"env(safe-area-inset-top, 0px)",paddingLeft:"max(1.5rem, env(safe-area-inset-left, 0px))",paddingRight:"max(1.5rem, env(safe-area-inset-right, 0px))"},children:[e("div",{className:"flex items-center space-x-3 min-w-0",children:[e("button",{type:"button",onClick:()=>P(!1),className:"md:hidden p-1.5 -ml-2 rounded-lg hover:bg-ink/5 active:bg-ink/10 text-ink","aria-label":"Back to categories",children:e(ma,{size:20})}),e("div",{className:"truncate",children:[e("h3",{className:"font-semibold text-base tracking-tight text-ink leading-tight",children:te.label}),e("p",{className:"text-[11px] text-ink/60 truncate hidden sm:block",children:te.description})]})]}),e("button",{type:"button",onClick:r,className:"p-1.5 rounded-lg text-ink/50 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer","aria-label":"Close settings",children:e(y,{size:18,strokeWidth:2.2})})]}),e("div",{className:`flex-1 scrollbar-overlay-container w-full ${["projects","providers","agents","behavior","commands","mcp","plugins","skills","skills-catalog","usage","panel-plugins","chats"].includes(p)?"p-0 flex flex-col":"p-6 md:p-8 flex flex-col"}`,style:{paddingBottom:"env(safe-area-inset-bottom, 0px)"},children:e("div",{className:"w-full h-full flex-1 flex flex-col",children:Z()})})]}),e("div",{className:`flex-1 flex-col h-full bg-canvas md:hidden ${M?"hidden":"flex"}`,children:[e("div",{className:"px-4 border-b border-ink/10 flex items-center justify-between flex-shrink-0 bg-canvas",style:{height:"calc(3.5rem + env(safe-area-inset-top, 0px))",paddingTop:"env(safe-area-inset-top, 0px)",paddingLeft:"max(1rem, env(safe-area-inset-left, 0px))",paddingRight:"max(1rem, env(safe-area-inset-right, 0px))"},children:[e("span",{className:"font-bold text-sm tracking-tight text-ink",children:"Settings"}),e("button",{type:"button",onClick:r,className:"p-1.5 rounded-lg text-ink/50 hover:text-ink","aria-label":"Close",children:e(y,{size:18})})]}),e("div",{className:"flex-1 overflow-hidden",style:{paddingBottom:"env(safe-area-inset-bottom, 0px)"},children:e(Rn,{activeCategory:p,onSelectCategory:X,searchQuery:A,onSearchChange:N,onReloadOmp:j,isReloading:S,onRestartKabmo:H,isRestarting:T,disabledHarnesses:K,className:"w-full border-r-0"})})]})]})})}export{wA as SettingsModal};
|