@iowarp/clio-coder 0.4.6 → 0.4.8
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/.claude-plugin/marketplace.json +283 -0
- package/CHANGELOG.md +79 -0
- package/CONTRIBUTING.md +178 -96
- package/NOTICE +8 -0
- package/README.md +100 -47
- package/dist/acp-JWPQZM2D.js +130 -0
- package/dist/agents-4GCDIRVX.js +149 -0
- package/dist/assets/codewiki.json +1 -1
- package/dist/assets/tui-notices/get-east-asian-width-LICENSE +9 -0
- package/dist/assets/tui-notices/marked-LICENSE +44 -0
- package/dist/assets/tui-notices/pi-tui-LICENSE +21 -0
- package/dist/assets/web-notices/@hono__node-server-LICENSE +21 -0
- package/dist/assets/web-notices/hono-LICENSE +21 -0
- package/dist/auth-SYAKTDQE.js +551 -0
- package/dist/background-OW67WMYR.js +37 -0
- package/dist/builtins-TKS63VNV.js +22 -0
- package/dist/chunk-2JSCCEKO.js +85 -0
- package/dist/chunk-2SXGG2IV.js +391 -0
- package/dist/chunk-2U2U5POA.js +59 -0
- package/dist/chunk-2ZWLMA3T.js +658 -0
- package/dist/chunk-36XSBPXL.js +579 -0
- package/dist/chunk-3IQOZRQ6.js +396 -0
- package/dist/chunk-3XE4NRLF.js +324 -0
- package/dist/chunk-44U2OUSM.js +243 -0
- package/dist/chunk-4P6M2TTE.js +119 -0
- package/dist/chunk-526ABLHD.js +1219 -0
- package/dist/chunk-5C2OQHLR.js +674 -0
- package/dist/chunk-5D2FNBMG.js +185 -0
- package/dist/chunk-5EQO5NWP.js +243 -0
- package/dist/chunk-5HULHKT2.js +32 -0
- package/dist/chunk-5UG6EZI3.js +66 -0
- package/dist/chunk-5W4FRA5Q.js +22283 -0
- package/dist/chunk-6R5MBXBJ.js +386 -0
- package/dist/chunk-6TKOFFGE.js +1058 -0
- package/dist/chunk-6UJ7RDI7.js +1143 -0
- package/dist/chunk-6X7VOCDY.js +44 -0
- package/dist/chunk-7QQRPB2E.js +915 -0
- package/dist/chunk-ARRUMZ7X.js +1377 -0
- package/dist/chunk-ATB3Q7YO.js +663 -0
- package/dist/chunk-AUHVBIDW.js +19 -0
- package/dist/chunk-BE4I3UJ2.js +668 -0
- package/dist/chunk-BFPHMSK7.js +169 -0
- package/dist/chunk-BHJMMCXS.js +466 -0
- package/dist/chunk-BIY22UUK.js +1322 -0
- package/dist/chunk-D55WO5J7.js +110 -0
- package/dist/chunk-DVJL77SO.js +162 -0
- package/dist/chunk-E2NSPYLC.js +814 -0
- package/dist/chunk-EFXMQYI6.js +4484 -0
- package/dist/chunk-EPYATQMG.js +2718 -0
- package/dist/chunk-EXKUF426.js +1801 -0
- package/dist/chunk-F7Y6QTPL.js +689 -0
- package/dist/chunk-FB3KTE2J.js +1710 -0
- package/dist/chunk-FNVPQQYT.js +117 -0
- package/dist/chunk-GEVQNST4.js +101 -0
- package/dist/chunk-GEYX2NZ5.js +697 -0
- package/dist/chunk-GJBJHJNY.js +2120 -0
- package/dist/chunk-GM4TY6VN.js +1233 -0
- package/dist/chunk-GVU4CXPJ.js +5191 -0
- package/dist/chunk-H5DPSUBB.js +637 -0
- package/dist/chunk-H77XBUBM.js +688 -0
- package/dist/chunk-HMGAKB7E.js +380 -0
- package/dist/chunk-HP7KJ5O2.js +797 -0
- package/dist/chunk-HVCAY2FH.js +67 -0
- package/dist/chunk-ICYIUNO4.js +35 -0
- package/dist/chunk-IILXVWJY.js +223 -0
- package/dist/chunk-JCVIL6TY.js +595 -0
- package/dist/chunk-JIMWEYWO.js +63 -0
- package/dist/chunk-JLBVCROW.js +562 -0
- package/dist/chunk-JOBN2YQQ.js +176 -0
- package/dist/chunk-JOL2QRLE.js +152 -0
- package/dist/chunk-JRA6OBHY.js +974 -0
- package/dist/chunk-JV25I7ID.js +1865 -0
- package/dist/chunk-JYKUMHCQ.js +705 -0
- package/dist/chunk-K3W6BF5C.js +283 -0
- package/dist/chunk-K45LHSCI.js +194 -0
- package/dist/chunk-K53E2PTW.js +1289 -0
- package/dist/chunk-K5UJD6MM.js +39 -0
- package/dist/chunk-KGP3UQGJ.js +200 -0
- package/dist/chunk-KKRXONXG.js +43 -0
- package/dist/chunk-KWJXCL2X.js +103 -0
- package/dist/chunk-L75H5B3B.js +446 -0
- package/dist/chunk-LLCGGVSW.js +108 -0
- package/dist/chunk-LZCCBLRC.js +57 -0
- package/dist/chunk-LZDLYSUN.js +197 -0
- package/dist/chunk-MATCRH3M.js +667 -0
- package/dist/chunk-MEHBW2SP.js +132 -0
- package/dist/chunk-MUXNDNMZ.js +659 -0
- package/dist/chunk-MWMW53WW.js +7346 -0
- package/dist/chunk-MZDPF35R.js +45 -0
- package/dist/chunk-MZKYVIWW.js +188 -0
- package/dist/chunk-O2QJDRWP.js +362 -0
- package/dist/chunk-O3HSB2YL.js +693 -0
- package/dist/chunk-OEMFEL26.js +891 -0
- package/dist/chunk-OH3YYA3B.js +15 -0
- package/dist/chunk-OPC4DQD6.js +634 -0
- package/dist/chunk-ORRNGQDV.js +207 -0
- package/dist/chunk-P4JS3MH5.js +165 -0
- package/dist/chunk-P7GTE4FX.js +308 -0
- package/dist/chunk-PAQVETLA.js +962 -0
- package/dist/chunk-PFZJMXIY.js +146 -0
- package/dist/chunk-PGEFOTJB.js +1974 -0
- package/dist/chunk-PJ5H5B7A.js +3151 -0
- package/dist/chunk-PMUUAABD.js +604 -0
- package/dist/chunk-Q32C6AWI.js +236 -0
- package/dist/chunk-QGIC5SX5.js +139 -0
- package/dist/chunk-QLAGXTTV.js +482 -0
- package/dist/chunk-QLKCCC2J.js +573 -0
- package/dist/chunk-QWUSS2QP.js +3630 -0
- package/dist/chunk-QYSAZMSH.js +47 -0
- package/dist/chunk-R5NRX5N4.js +123 -0
- package/dist/chunk-RAUOKUZV.js +1572 -0
- package/dist/chunk-RBES4TCZ.js +302 -0
- package/dist/chunk-RFCKPS2V.js +26 -0
- package/dist/chunk-RFULVPBX.js +318 -0
- package/dist/chunk-RKFNU5UA.js +404 -0
- package/dist/chunk-RM3XJX7P.js +1148 -0
- package/dist/chunk-RNLAPBJL.js +386 -0
- package/dist/chunk-RPMNIFRY.js +65 -0
- package/dist/chunk-RRZFRIJP.js +42 -0
- package/dist/chunk-RXI7K4J5.js +4493 -0
- package/dist/chunk-SER7RRAE.js +4271 -0
- package/dist/chunk-STC6CWUZ.js +402 -0
- package/dist/chunk-TEHVMHOK.js +97 -0
- package/dist/chunk-TOPICHGR.js +33 -0
- package/dist/chunk-U3TPUXOQ.js +2653 -0
- package/dist/chunk-UB33F3YW.js +709 -0
- package/dist/chunk-UDAK6GR2.js +175 -0
- package/dist/chunk-USBBEKHW.js +177 -0
- package/dist/chunk-V4ZKOKRB.js +13433 -0
- package/dist/chunk-W5RM7YAH.js +78 -0
- package/dist/chunk-W7KNI3F5.js +215 -0
- package/dist/chunk-WFTSK7N3.js +637 -0
- package/dist/chunk-WJWNZXRM.js +395 -0
- package/dist/chunk-WLHX3MM5.js +63 -0
- package/dist/chunk-WS4FOGLY.js +686 -0
- package/dist/chunk-WTZVSMQZ.js +52 -0
- package/dist/chunk-WWRV5RJI.js +165 -0
- package/dist/chunk-X6FLVUM5.js +141 -0
- package/dist/chunk-XC5POIL4.js +68 -0
- package/dist/chunk-XTLJDC2X.js +1013 -0
- package/dist/chunk-XW2UZICE.js +372 -0
- package/dist/chunk-Y3JU5RPK.js +8 -0
- package/dist/chunk-YGIV24MF.js +1018 -0
- package/dist/chunk-YJCCMYYT.js +125 -0
- package/dist/chunk-YKIIWURD.js +36 -0
- package/dist/chunk-YQ3GFEUY.js +341 -0
- package/dist/chunk-YXANQGCX.js +179 -0
- package/dist/chunk-YXFKLMX2.js +222 -0
- package/dist/chunk-ZST3FRCV.js +132 -0
- package/dist/cli/index.js +40 -40
- package/dist/clio-BPBAPZGA.js +26 -0
- package/dist/code-nav-KBQ3RIFK.js +686 -0
- package/dist/components-6DKAXWFN.js +674 -0
- package/dist/config-FWL5JK2H.js +270 -0
- package/dist/config-graph-ACDB26L2.js +156 -0
- package/dist/configure-ZIZ4YV62.js +85 -0
- package/dist/context-EZZPT2ZV.js +1074 -0
- package/dist/context-VIL5MFRH.js +282 -0
- package/dist/context-Z3GOBHDK.js +344 -0
- package/dist/context-clear-ZPB3L7MN.js +188 -0
- package/dist/context-index-W6A4V7OC.js +120 -0
- package/dist/context-map-DKL3QT6D.js +555 -0
- package/dist/context-working-set-2GLBVF7L.js +1559 -0
- package/dist/detail-VSBWYSGZ.js +119 -0
- package/dist/dispatch-runner-EEEHGKX4.js +2442 -0
- package/dist/docs-VMMWFVHL.js +101 -0
- package/dist/doctor-V5L4IQGP.js +812 -0
- package/dist/eval-VJYJ2BV3.js +5050 -0
- package/dist/eval-inventory-CX24K2JT.js +260 -0
- package/dist/evals-J2H5V6DD.js +104 -0
- package/dist/evidence-POWAEBEW.js +229 -0
- package/dist/evidence-XCCCLS36.js +242 -0
- package/dist/evidence-Y35YSXH6.js +388 -0
- package/dist/evolve-GPG72VB6.js +613 -0
- package/dist/extensions-YIZ7W3DA.js +308 -0
- package/dist/fleet-2MDCQ2VK.js +264 -0
- package/dist/fleet-W2AF3TOJ.js +919 -0
- package/dist/fleet-commands-WS56G26H.js +75 -0
- package/dist/fleet-decisions-MYGZ3JW7.js +52 -0
- package/dist/fleet-graph-ELTBXBAV.js +136 -0
- package/dist/fleet-inspect-45IK73L4.js +308 -0
- package/dist/fleet-preflight-T5NCZKHE.js +22 -0
- package/dist/fleet-validate-VG4JBLA4.js +91 -0
- package/dist/fleet-verify-VTSABAYO.js +206 -0
- package/dist/fleet-view-XC7WMKSS.js +123 -0
- package/dist/init-VTJNNTIP.js +329 -0
- package/dist/install-6PIF6F6W.js +19 -0
- package/dist/interop-IU6BNA7C.js +246 -0
- package/dist/inventory-QPQUTUUZ.js +123 -0
- package/dist/library-HUTAS57T.js +492 -0
- package/dist/library-LF7DLU6S.js +306 -0
- package/dist/library-Q3NWL5CM.js +75 -0
- package/dist/library-import-PPW4YUC5.js +183 -0
- package/dist/library-inventory-DIRVFRZU.js +56 -0
- package/dist/library-validation-XHUZ3INE.js +42 -0
- package/dist/memory-Z2LSKNV6.js +516 -0
- package/dist/models-3FTREYPY.js +302 -0
- package/dist/monitor-HF2MQRB3.js +781 -0
- package/dist/orchestrator-UYPA6W4S.js +41502 -0
- package/dist/panes-736XB73K.js +74 -0
- package/dist/panes-C4P3PIWT.js +103 -0
- package/dist/paths-JQ4QYIYB.js +67 -0
- package/dist/preload-XSLRYH3Y.js +120 -0
- package/dist/reset-V7QSPZYE.js +345 -0
- package/dist/resources-OJGDFHYT.js +181 -0
- package/dist/run-T354SMDW.js +892 -0
- package/dist/settings-MWZXO6RV.js +72 -0
- package/dist/share-Y5ZKJPND.js +293 -0
- package/dist/skills-4GLZC4LN.js +100 -0
- package/dist/skills-eval-L5T7GODM.js +1074 -0
- package/dist/skills-inventory-LASKXEZI.js +138 -0
- package/dist/slash-commands-OIMRU36D.js +95 -0
- package/dist/steer-KMAM2Y2C.js +77 -0
- package/dist/support-AWC3XKPX.js +38 -0
- package/dist/system-CD75NYBU.js +116 -0
- package/dist/targets-VSZX2J2S.js +1116 -0
- package/dist/tasks-AN567LYH.js +36 -0
- package/dist/terminal-lease-6KTWNHVY.js +418 -0
- package/dist/tools-AGRK3V5J.js +28 -0
- package/dist/trace-P4MQZD33.js +524 -0
- package/dist/tui-primitives-A6MUW32V.js +18 -0
- package/dist/uninstall-BRUTEPIC.js +432 -0
- package/dist/upgrade-SBCGHQGJ.js +307 -0
- package/dist/usage-BIDVTO6V.js +1061 -0
- package/dist/verifiers-LTGCAMXS.js +630 -0
- package/dist/verify-OZU4LLNP.js +30 -0
- package/dist/web/client/THIRD_PARTY_LICENSES.md +1809 -0
- package/dist/web/client/assets/abnfDiagram-VCTEODGH-C5wfoHm3.js +1 -0
- package/dist/web/client/assets/arc-oH91sfLl.js +1 -0
- package/dist/web/client/assets/architecture-7GRP2DOG-EGozsYEO.js +1 -0
- package/dist/web/client/assets/architectureDiagram-5GKGNRK7-z9FokbJl.js +36 -0
- package/dist/web/client/assets/array-BifhSqXX.js +1 -0
- package/dist/web/client/assets/atkinson-hyperlegible-next-latin-ext-wght-normal-C6vrW8VD.woff2 +0 -0
- package/dist/web/client/assets/atkinson-hyperlegible-next-latin-wght-normal-BcXVPD7q.woff2 +0 -0
- package/dist/web/client/assets/blockDiagram-I7D4REHJ-wi0_CYHL.js +129 -0
- package/dist/web/client/assets/c4Diagram-7LVT6UL2-DV7NYc2W.js +38 -0
- package/dist/web/client/assets/channel-CiUWbHN9.js +1 -0
- package/dist/web/client/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
- package/dist/web/client/assets/chunk-4HAMMTFA-Bhsegh3F.js +62 -0
- package/dist/web/client/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
- package/dist/web/client/assets/chunk-75Z2AOVW-RQCckcQG.js +2 -0
- package/dist/web/client/assets/chunk-DU6HZSFF-C5USiOAy.js +125 -0
- package/dist/web/client/assets/chunk-F27PBJKO-BcNqv2x1.js +1 -0
- package/dist/web/client/assets/chunk-FOHPRMQF-CoA4358r.js +161 -0
- package/dist/web/client/assets/chunk-GMAD6QVW-Bq8JWiZT.js +72 -0
- package/dist/web/client/assets/chunk-GVQU2GXP-DbchrAeJ.js +1 -0
- package/dist/web/client/assets/chunk-IMKFNOWR-DrpvjocK.js +231 -0
- package/dist/web/client/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
- package/dist/web/client/assets/chunk-L3NEJ4N5-DHLmTnCe.js +1 -0
- package/dist/web/client/assets/chunk-OSK3NFVY-CsRbtN9n.js +10 -0
- package/dist/web/client/assets/chunk-P2QGCYS3-aqPbxoMh.js +1 -0
- package/dist/web/client/assets/chunk-POPQ4Y6H-Dl5vw0h0.js +1 -0
- package/dist/web/client/assets/chunk-PWAF6VOD-D7OBRSdO.js +1 -0
- package/dist/web/client/assets/chunk-SHT3W25Y-CdKCIwuB.js +168 -0
- package/dist/web/client/assets/chunk-SVP7TREG-B94Nu_1-.js +88 -0
- package/dist/web/client/assets/chunk-TICWLB2K-jjRQI_hk.js +206 -0
- package/dist/web/client/assets/chunk-XXDRQBXY-azkbKE37.js +1 -0
- package/dist/web/client/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
- package/dist/web/client/assets/classDiagram-ZZMXUADV-CMODalmo.js +1 -0
- package/dist/web/client/assets/classDiagram-v2-VYDZK3BY-CMODalmo.js +1 -0
- package/dist/web/client/assets/commit-mono-latin-400-normal-s0S3qwFW.woff +0 -0
- package/dist/web/client/assets/commit-mono-latin-400-normal-wzhe4RuD.woff2 +0 -0
- package/dist/web/client/assets/cose-bilkent-JH36ORCC-RbQL23qS.js +1 -0
- package/dist/web/client/assets/cynefin-OW5HDTMX--i9RDU5f.js +1 -0
- package/dist/web/client/assets/cynefinDiagram-5FMLGOSQ-cRcvyBdp.js +62 -0
- package/dist/web/client/assets/cytoscape.esm-c2aL46s-.js +321 -0
- package/dist/web/client/assets/dagre-C-rnJpZF.js +1 -0
- package/dist/web/client/assets/dagre-GXQ25YYZ-C9mZmAPe.js +4 -0
- package/dist/web/client/assets/defaultLocale-BFoDCU3G.js +1 -0
- package/dist/web/client/assets/diagram-S7CK7UJ4-Oj_zlLDY.js +30 -0
- package/dist/web/client/assets/diagram-UQ7AKVKN-BWKbbfcR.js +41 -0
- package/dist/web/client/assets/diagram-VSXAHHWV-C3N3f7DO.js +3 -0
- package/dist/web/client/assets/diagram-VX7I27RA-CtDKDAWe.js +24 -0
- package/dist/web/client/assets/diagram-Z3DM3KII-B8bkBRCz.js +24 -0
- package/dist/web/client/assets/dist-D0_q-A2b.js +1 -0
- package/dist/web/client/assets/ebnfDiagram-PWID7BFC-CskW-Whx.js +1 -0
- package/dist/web/client/assets/erDiagram-RLTQ6QDP-C-83cgCW.js +99 -0
- package/dist/web/client/assets/eventmodeling-NTZA5JFV-DjVq8wKU.js +1 -0
- package/dist/web/client/assets/flowDiagram-HODETNUW-BUiCBGXt.js +1 -0
- package/dist/web/client/assets/ganttDiagram-EL5Y4UJY-B2lb8lvF.js +292 -0
- package/dist/web/client/assets/gitGraph-4MIJSDKK-B40cQtBE.js +1 -0
- package/dist/web/client/assets/gitGraphDiagram-WWUBYQGX-CH-7P7Di.js +106 -0
- package/dist/web/client/assets/graphlib-DS17s2tU.js +1 -0
- package/dist/web/client/assets/index-Dsi52apB.css +1 -0
- package/dist/web/client/assets/index-FSIC94pi.js +83 -0
- package/dist/web/client/assets/info-A6RAGUB7-eCCE9D_Q.js +1 -0
- package/dist/web/client/assets/infoDiagram-27XIBGKW-DRnvqMjM.js +2 -0
- package/dist/web/client/assets/init-C-OQMol4.js +1 -0
- package/dist/web/client/assets/ishikawaDiagram-5VMMS53U-DBA_55wp.js +70 -0
- package/dist/web/client/assets/journeyDiagram-3NMN7TZE-C-ewpNl7.js +139 -0
- package/dist/web/client/assets/kanban-definition-UXKFOSKX-B1taGsu0.js +89 -0
- package/dist/web/client/assets/katex-ZlcWpGUi.js +257 -0
- package/dist/web/client/assets/line-lZ0kyxDI.js +1 -0
- package/dist/web/client/assets/linear-DIc8FgZj.js +1 -0
- package/dist/web/client/assets/mermaid-parser.core-SXolxpXw.js +7 -0
- package/dist/web/client/assets/mermaid.core-DXgQtkNg.js +44 -0
- package/dist/web/client/assets/mindmap-definition-YA3MSWOX-DXJas9K7.js +96 -0
- package/dist/web/client/assets/newsreader-latin-ext-wght-normal-C-3rgBeH.woff2 +0 -0
- package/dist/web/client/assets/newsreader-latin-wght-normal-CCVVNp6i.woff2 +0 -0
- package/dist/web/client/assets/newsreader-vietnamese-wght-normal-Czsa-EzN.woff2 +0 -0
- package/dist/web/client/assets/ordinal-BDEzSJ7C.js +1 -0
- package/dist/web/client/assets/packet-AYTQ26CC-OqVl_07o.js +1 -0
- package/dist/web/client/assets/path-fybaL0A-.js +1 -0
- package/dist/web/client/assets/pegDiagram-XKGWAZYB-CPE_zdfN.js +1 -0
- package/dist/web/client/assets/pie-WAS4IAKB-DAxnMBLe.js +1 -0
- package/dist/web/client/assets/pieDiagram-E7YTZNPT-Uwjpufxv.js +39 -0
- package/dist/web/client/assets/prism-bash-D6zCJ74D.js +1 -0
- package/dist/web/client/assets/prism-c-04YixN25.js +1 -0
- package/dist/web/client/assets/prism-clike-DapgWyxx.js +1 -0
- package/dist/web/client/assets/prism-core-BngLtbUd.js +1 -0
- package/dist/web/client/assets/prism-cpp-C-lJbC-6.js +1 -0
- package/dist/web/client/assets/prism-css-CPgOzxXp.js +1 -0
- package/dist/web/client/assets/prism-diff-BF8m0_mq.js +3 -0
- package/dist/web/client/assets/prism-docker-DkT6yOFj.js +1 -0
- package/dist/web/client/assets/prism-fortran-Be5x3y1V.js +1 -0
- package/dist/web/client/assets/prism-go-C_8qAH5n.js +1 -0
- package/dist/web/client/assets/prism-ini-BESK3y0r.js +1 -0
- package/dist/web/client/assets/prism-javascript-BnO-swvr.js +1 -0
- package/dist/web/client/assets/prism-json-Dp_-W-Hv.js +1 -0
- package/dist/web/client/assets/prism-jsx-D-D0NWtC.js +1 -0
- package/dist/web/client/assets/prism-julia-DIjOgiAV.js +1 -0
- package/dist/web/client/assets/prism-latex-DNMbqcH_.js +1 -0
- package/dist/web/client/assets/prism-makefile-CRKWLQ8l.js +1 -0
- package/dist/web/client/assets/prism-markdown-C0FPJ1Iz.js +1 -0
- package/dist/web/client/assets/prism-markup-Cp04rIa1.js +1 -0
- package/dist/web/client/assets/prism-matlab-D-nk08al.js +1 -0
- package/dist/web/client/assets/prism-python-CfiSVtM6.js +1 -0
- package/dist/web/client/assets/prism-r-QmNGR8LX.js +1 -0
- package/dist/web/client/assets/prism-rust-Bu9N8X3N.js +1 -0
- package/dist/web/client/assets/prism-shell-session-Be4UuYoM.js +1 -0
- package/dist/web/client/assets/prism-sql-CYhVDMEE.js +1 -0
- package/dist/web/client/assets/prism-toml-DKb54GAT.js +1 -0
- package/dist/web/client/assets/prism-tsx-p6J2Kc_4.js +1 -0
- package/dist/web/client/assets/prism-typescript-BMqONzxf.js +1 -0
- package/dist/web/client/assets/prism-yaml-C0JHu8gr.js +1 -0
- package/dist/web/client/assets/purify.es-ChwZkWde.js +3 -0
- package/dist/web/client/assets/quadrantDiagram-AXDQQJYC-Bjs4yjgs.js +7 -0
- package/dist/web/client/assets/radar-RG4KPBEZ-CuCKjHM3.js +1 -0
- package/dist/web/client/assets/railroad-74A4TZTK-CnQK-Cc1.js +1 -0
- package/dist/web/client/assets/railroad-abnf-HS5TGJTU-BcW01NZG.js +1 -0
- package/dist/web/client/assets/railroad-ebnf-LZEXJU2U-B7YCEDDd.js +1 -0
- package/dist/web/client/assets/railroad-peg-WCYAUIDC-DjNZbSTZ.js +1 -0
- package/dist/web/client/assets/railroadDiagram-O6MQD6OU-BDDIPNLL.js +1 -0
- package/dist/web/client/assets/requirementDiagram-BXWQKSXE-B5Ydyxc1.js +84 -0
- package/dist/web/client/assets/rough.esm-Dy-Kn_BL.js +1 -0
- package/dist/web/client/assets/sankeyDiagram-P5KCCOFB-Bw2Qym75.js +40 -0
- package/dist/web/client/assets/sequenceDiagram-WJ2MYXX4-BZf36nO0.js +162 -0
- package/dist/web/client/assets/sizeCapture-INFHLROL-B0uUizjq.js +1 -0
- package/dist/web/client/assets/src-yeptRXpt.js +1 -0
- package/dist/web/client/assets/stateDiagram-D77RDMKH-DnH6JRkp.js +1 -0
- package/dist/web/client/assets/stateDiagram-v2-MP3YSRHH-C7QtHeK4.js +1 -0
- package/dist/web/client/assets/swimlanes-42K2YHIH-D9PZmtZg.js +1 -0
- package/dist/web/client/assets/swimlanesDiagram-VR7AAH4N-CBZlPFky.js +8 -0
- package/dist/web/client/assets/timeline-definition-24CTP7MA-CrkZZBo7.js +120 -0
- package/dist/web/client/assets/treeView-Q6P3EWNA-C9zDShoC.js +1 -0
- package/dist/web/client/assets/treemap-WGGIJYW6-B-plj9yK.js +1 -0
- package/dist/web/client/assets/vennDiagram-4TSXK5OY-VeOdaphN.js +34 -0
- package/dist/web/client/assets/wardley-WFR3VGLG-Wl1P_m6L.js +1 -0
- package/dist/web/client/assets/wardleyDiagram-VM6X3IG4-B85-R9t2.js +78 -0
- package/dist/web/client/assets/xychartDiagram-S5SC5T6Z-BrD8OW8m.js +7 -0
- package/dist/web/client/clio-coder-logo.webp +0 -0
- package/dist/web/client/icon-192.png +0 -0
- package/dist/web/client/icon-512.png +0 -0
- package/dist/web/client/index.html +4 -0
- package/dist/web/client/manifest.webmanifest +15 -0
- package/dist/web/client/offline.css +55 -0
- package/dist/web/client/offline.html +5 -0
- package/dist/web/client/offline.js +27 -0
- package/dist/web/client/sw.js +34 -0
- package/dist/web/ops-worker.js +37 -0
- package/dist/web/reads-worker.js +1726 -0
- package/dist/web/server.js +8499 -0
- package/dist/web-EU6ATJWA.js +13 -0
- package/dist/web-fetch-U22Q7HV4.js +788 -0
- package/dist/wiki-generate-LZRLFG6I.js +623 -0
- package/dist/with-panes-X5CZOGML.js +628 -0
- package/dist/worker/entry.js +300 -93
- package/docs/README.md +58 -14
- package/docs/architecture/acp.md +5 -9
- package/docs/architecture/alcf-provider.md +0 -3
- package/docs/architecture/architecture.md +8 -10
- package/docs/architecture/artifact-placement.md +0 -3
- package/docs/architecture/artifact-versions.md +3 -6
- package/docs/architecture/capacity-and-scheduling.md +0 -3
- package/docs/architecture/context-engine.md +35 -4
- package/docs/architecture/context-working-set.md +0 -3
- package/docs/architecture/dispatch-architecture-rationale.md +0 -3
- package/docs/architecture/dispatch-typed-intent.md +0 -3
- package/docs/architecture/evidence-and-memory.md +0 -3
- package/docs/architecture/library.md +30 -0
- package/docs/architecture/middleware-and-components.md +1 -4
- package/docs/architecture/model-catalog.md +21 -4
- package/docs/architecture/observability.md +0 -3
- package/docs/architecture/pi-boundary.md +23 -8
- package/docs/architecture/prompt-envelope-and-tools.md +6 -9
- package/docs/architecture/provider-adapter-cookbook.md +1 -4
- package/docs/architecture/safety-model.md +21 -5
- package/docs/architecture/session-lifecycle.md +12 -4
- package/docs/architecture/time-conventions.md +0 -3
- package/docs/architecture/trace-store.md +28 -20
- package/docs/architecture/tui-design.md +108 -12
- package/docs/architecture/worker-context.md +104 -0
- package/docs/architecture/worker-dispatch-mechanics.md +1 -4
- package/docs/guide/authoring-plugins.md +158 -0
- package/docs/guide/built-in-agents.md +5 -8
- package/docs/guide/commands-and-modes.md +162 -61
- package/docs/guide/configuration-and-targets.md +198 -5
- package/docs/guide/configuration-reference.md +36 -38
- package/docs/guide/environment-variables.md +2 -5
- package/docs/guide/exit-codes-and-output.md +1 -4
- package/docs/guide/extensions-and-sharing.md +92 -55
- package/docs/guide/fleet-dispatch.md +31 -7
- package/docs/guide/glossary.md +1 -4
- package/docs/guide/harness-extensions.md +289 -0
- package/docs/guide/installation-and-lifecycle.md +10 -13
- package/docs/guide/interop.md +241 -0
- package/docs/guide/panes-and-files.md +3 -6
- package/docs/guide/plugins.md +77 -0
- package/docs/guide/proactive-memory.md +0 -3
- package/docs/guide/resource-library.md +109 -45
- package/docs/guide/skills-marketplace.md +34 -73
- package/docs/guide/tool-usage.md +19 -10
- package/docs/guide/troubleshooting.md +1 -4
- package/docs/history/config-knobs-audit.md +0 -3
- package/docs/history/release-cut-checklist.md +0 -3
- package/docs/process/development-pipeline.md +14 -17
- package/docs/process/documentation-coverage.md +31 -4
- package/docs/process/documentation-guide.md +28 -27
- package/docs/process/eval-runner.md +8 -6
- package/docs/process/evals-internal.md +0 -3
- package/docs/process/evolution.md +0 -3
- package/docs/process/fleet-demo-runbook.md +0 -3
- package/docs/process/git-commit-provenance.md +0 -3
- package/docs/process/performance-methodology.md +2 -5
- package/docs/process/release-cut-checklist.md +114 -217
- package/docs/process/scientific-validation.md +23 -3
- package/evals/scalar-decision-machinery.ts +1 -1
- package/examples/extensions/README.md +67 -0
- package/examples/extensions/lab-status/clio-coder-extension.json +14 -0
- package/examples/extensions/lab-status/extension.mjs +68 -0
- package/examples/extensions/lab-status/jobs.synthetic.json +9 -0
- package/examples/extensions/measurements/clio-coder-extension.json +28 -0
- package/examples/extensions/measurements/summarize.cjs +23 -0
- package/library/README.md +109 -0
- package/library/_authoring/templates/agent/README.md +28 -0
- package/library/_authoring/templates/agent/agents/benchmark-scout.md +30 -0
- package/library/_authoring/templates/agent/plugin.json +23 -0
- package/library/_authoring/templates/fleet/README.md +29 -0
- package/library/_authoring/templates/fleet/fleets/pipeline-review.md +31 -0
- package/library/_authoring/templates/fleet/plugin.json +23 -0
- package/library/_authoring/templates/plugin/README.md +37 -0
- package/library/_authoring/templates/plugin/agents/data-curator.md +31 -0
- package/library/_authoring/templates/plugin/assets/curation-guide.md +22 -0
- package/library/_authoring/templates/plugin/plugin.json +42 -0
- package/library/_authoring/templates/plugin/prompts/inspect-dataset.md +15 -0
- package/library/_authoring/templates/plugin/skills/dataset-curation/SKILL.md +36 -0
- package/library/_authoring/templates/plugin/skills/dataset-curation/evals.md +17 -0
- package/library/_authoring/templates/prompt/README.md +28 -0
- package/library/_authoring/templates/prompt/plugin.json +23 -0
- package/library/_authoring/templates/prompt/prompts/paper-summary.md +26 -0
- package/library/_authoring/templates/skill/README.md +24 -0
- package/library/_authoring/templates/skill/SKILL.md +39 -0
- package/library/_authoring/templates/skill/evals.md +30 -0
- package/library/_authoring/templates/skill/plugin.json +23 -0
- package/library/agents/README.md +7 -0
- package/library/fleets/README.md +7 -0
- package/library/plugins/materio/README.md +137 -0
- package/library/plugins/materio/ai.iowarp.clio/agents/materio-lab-definer.md +208 -0
- package/library/plugins/materio/ai.iowarp.clio/agents/materio-literature-reviewer.md +308 -0
- package/library/plugins/materio/ai.iowarp.clio/agents/materio-research-explorer.md +249 -0
- package/library/plugins/materio/ai.iowarp.clio/agents/materio-task-executor.md +416 -0
- package/library/plugins/materio/ai.iowarp.clio/agents/materio-task-verifier.md +60 -0
- package/library/plugins/materio/ai.iowarp.clio/agents/materio-workflow-planner.md +238 -0
- package/library/plugins/materio/ai.iowarp.clio/fleets/materio-execute-task.md +50 -0
- package/library/plugins/materio/ai.iowarp.clio/prompts/materio/add-task.md +66 -0
- package/library/plugins/materio/ai.iowarp.clio/prompts/materio/archive-task.md +65 -0
- package/library/plugins/materio/ai.iowarp.clio/prompts/materio/checkpoint.md +26 -0
- package/library/plugins/materio/ai.iowarp.clio/prompts/materio/define-research-tasks.md +230 -0
- package/library/plugins/materio/ai.iowarp.clio/prompts/materio/define-virtual-lab.md +181 -0
- package/library/plugins/materio/ai.iowarp.clio/prompts/materio/execute-task.md +292 -0
- package/library/plugins/materio/ai.iowarp.clio/prompts/materio/help.md +129 -0
- package/library/plugins/materio/ai.iowarp.clio/prompts/materio/identify-research.md +206 -0
- package/library/plugins/materio/ai.iowarp.clio/prompts/materio/literature-review.md +201 -0
- package/library/plugins/materio/ai.iowarp.clio/prompts/materio/pause-research.md +12 -0
- package/library/plugins/materio/ai.iowarp.clio/prompts/materio/progress.md +105 -0
- package/library/plugins/materio/ai.iowarp.clio/prompts/materio/remove-task.md +63 -0
- package/library/plugins/materio/ai.iowarp.clio/prompts/materio/resume-research.md +64 -0
- package/library/plugins/materio/ai.iowarp.clio/prompts/materio/settings.md +16 -0
- package/library/plugins/materio/ai.iowarp.clio/prompts/materio/status.md +92 -0
- package/library/plugins/materio/ai.iowarp.clio/prompts/materio/upload-data.md +104 -0
- package/library/plugins/materio/ai.iowarp.clio/prompts/materio/wtfp.md +145 -0
- package/library/plugins/materio/ai.iowarp.clio/references/execution.md +56 -0
- package/library/plugins/materio/ai.iowarp.portability/provenance.json +9 -0
- package/library/plugins/materio/assets/actions/add-task.md +86 -0
- package/library/plugins/materio/assets/actions/archive-task.md +84 -0
- package/library/plugins/materio/assets/actions/checkpoint.md +47 -0
- package/library/plugins/materio/assets/actions/define-research-tasks.md +228 -0
- package/library/plugins/materio/assets/actions/define-virtual-lab.md +179 -0
- package/library/plugins/materio/assets/actions/execute-task.md +290 -0
- package/library/plugins/materio/assets/actions/help.md +140 -0
- package/library/plugins/materio/assets/actions/identify-research.md +204 -0
- package/library/plugins/materio/assets/actions/literature-review.md +199 -0
- package/library/plugins/materio/assets/actions/pause-research.md +34 -0
- package/library/plugins/materio/assets/actions/progress.md +125 -0
- package/library/plugins/materio/assets/actions/remove-task.md +82 -0
- package/library/plugins/materio/assets/actions/resume-research.md +84 -0
- package/library/plugins/materio/assets/actions/settings.md +38 -0
- package/library/plugins/materio/assets/actions/status.md +112 -0
- package/library/plugins/materio/assets/actions/upload-data.md +123 -0
- package/library/plugins/materio/assets/actions/wtfp.md +179 -0
- package/library/plugins/materio/assets/references/research-domains.md +134 -0
- package/library/plugins/materio/assets/references/research-policy.md +77 -0
- package/library/plugins/materio/assets/references/traditional-workflows.md +146 -0
- package/library/plugins/materio/assets/scripts/check_physics.py +271 -0
- package/library/plugins/materio/assets/scripts/check_scripts.py +248 -0
- package/library/plugins/materio/assets/scripts/project_plugin.py +165 -0
- package/library/plugins/materio/assets/scripts/research_state.py +400 -0
- package/library/plugins/materio/assets/scripts/verify_citations.py +616 -0
- package/library/plugins/materio/assets/templates/RESEARCH.md +39 -0
- package/library/plugins/materio/assets/templates/VIRTUAL-LAB.md +120 -0
- package/library/plugins/materio/assets/templates/WORKFLOW.md +42 -0
- package/library/plugins/materio/assets/templates/config.json +5 -0
- package/library/plugins/materio/evals/scripts.yaml +29 -0
- package/library/plugins/materio/plugin.json +530 -0
- package/library/plugins/materio/skills/materio-lab-definer/SKILL.md +74 -0
- package/library/plugins/materio/skills/materio-literature-reviewer/SKILL.md +64 -0
- package/library/plugins/materio/skills/materio-research-explorer/SKILL.md +74 -0
- package/library/plugins/materio/skills/materio-task-executor/SKILL.md +214 -0
- package/library/plugins/materio/skills/materio-task-verifier/SKILL.md +46 -0
- package/library/plugins/materio/skills/materio-workflow-planner/SKILL.md +79 -0
- package/library/plugins/materio/tests/test_check_physics.py +139 -0
- package/library/plugins/materio/tests/test_check_scripts.py +140 -0
- package/library/plugins/materio/tests/test_research_state.py +291 -0
- package/library/plugins/materio/tests/test_verify_citations.py +337 -0
- package/library/prompts/README.md +7 -0
- package/library/registry.yaml +921 -0
- package/library/skills/README.md +120 -0
- package/library/skills/coding/ast-grep/SKILL.md +213 -0
- package/library/skills/coding/ast-grep/evals.md +82 -0
- package/library/skills/coding/ast-grep/plugin.json +23 -0
- package/library/skills/coding/coding-standards/SKILL.md +164 -0
- package/library/skills/coding/coding-standards/evals.md +57 -0
- package/library/skills/coding/coding-standards/plugin.json +23 -0
- package/library/skills/coding/prototype/SKILL.md +151 -0
- package/library/skills/coding/prototype/evals.md +61 -0
- package/library/skills/coding/prototype/plugin.json +23 -0
- package/library/skills/coding/tdd/SKILL.md +134 -0
- package/library/skills/coding/tdd/evals.md +61 -0
- package/library/skills/coding/tdd/plugin.json +23 -0
- package/library/skills/context/context-handoff/SKILL.md +176 -0
- package/library/skills/context/context-handoff/evals.md +101 -0
- package/library/skills/context/context-handoff/plugin.json +23 -0
- package/library/skills/context/context-prime/SKILL.md +131 -0
- package/library/skills/context/context-prime/evals.md +99 -0
- package/library/skills/context/context-prime/plugin.json +23 -0
- package/library/skills/git/branch-closeout/SKILL.md +132 -0
- package/library/skills/git/branch-closeout/plugin.json +23 -0
- package/library/skills/git/file-ticket/SKILL.md +126 -0
- package/library/skills/git/file-ticket/plugin.json +23 -0
- package/library/skills/git/fix-issue/SKILL.md +136 -0
- package/library/skills/git/fix-issue/plugin.json +23 -0
- package/library/skills/git/resolve-merge-conflicts/SKILL.md +151 -0
- package/library/skills/git/resolve-merge-conflicts/evals.md +85 -0
- package/library/skills/git/resolve-merge-conflicts/plugin.json +23 -0
- package/library/skills/git/ship/SKILL.md +134 -0
- package/library/skills/git/ship/plugin.json +23 -0
- package/library/skills/git/worktree-create/SKILL.md +127 -0
- package/library/skills/git/worktree-create/plugin.json +23 -0
- package/library/skills/git/worktree-merge/SKILL.md +147 -0
- package/library/skills/git/worktree-merge/plugin.json +23 -0
- package/library/skills/meta/clio-coder-dev/SKILL.md +101 -0
- package/library/skills/meta/clio-coder-dev/evals.md +46 -0
- package/library/skills/meta/clio-coder-dev/plugin.json +23 -0
- package/library/skills/meta/clio-coder-test/SKILL.md +156 -0
- package/library/skills/meta/clio-coder-test/evals.md +62 -0
- package/library/skills/meta/clio-coder-test/plugin.json +23 -0
- package/library/skills/meta/clio-coder-test/references/test-map.md +97 -0
- package/library/skills/meta/credentials/SKILL.md +132 -0
- package/library/skills/meta/credentials/evals.md +104 -0
- package/library/skills/meta/credentials/plugin.json +23 -0
- package/library/skills/meta/find-skills/SKILL.md +85 -0
- package/library/skills/meta/find-skills/evals.md +65 -0
- package/library/skills/meta/find-skills/plugin.json +23 -0
- package/library/skills/meta/herdr/SKILL.md +133 -0
- package/library/skills/meta/herdr/evals.md +38 -0
- package/library/skills/meta/herdr/plugin.json +23 -0
- package/library/skills/meta/skill-craft/SKILL.md +139 -0
- package/library/skills/meta/skill-craft/evals.md +49 -0
- package/library/skills/meta/skill-craft/plugin.json +23 -0
- package/library/skills/planning/archify/SKILL.md +196 -0
- package/library/skills/planning/archify/plugin.json +23 -0
- package/library/skills/planning/architecture/SKILL.md +184 -0
- package/library/skills/planning/architecture/evals.md +101 -0
- package/library/skills/planning/architecture/plugin.json +23 -0
- package/library/skills/planning/backlog/SKILL.md +212 -0
- package/library/skills/planning/backlog/evals.md +185 -0
- package/library/skills/planning/backlog/plugin.json +23 -0
- package/library/skills/planning/prd/SKILL.md +129 -0
- package/library/skills/planning/prd/evals.md +103 -0
- package/library/skills/planning/prd/plugin.json +23 -0
- package/library/skills/planning/product-intent/SKILL.md +173 -0
- package/library/skills/planning/product-intent/evals.md +106 -0
- package/library/skills/planning/product-intent/plugin.json +23 -0
- package/library/skills/planning/tech-spec/SKILL.md +172 -0
- package/library/skills/planning/tech-spec/evals.md +120 -0
- package/library/skills/planning/tech-spec/plugin.json +23 -0
- package/library/skills/registry.yaml +144 -0
- package/library/skills/remote.yaml +13 -0
- package/library/skills/research/arxiv-literature/SKILL.md +168 -0
- package/library/skills/research/arxiv-literature/evals.md +108 -0
- package/library/skills/research/arxiv-literature/plugin.json +23 -0
- package/library/skills/research/experiment-protocol/SKILL.md +148 -0
- package/library/skills/research/experiment-protocol/evals.md +114 -0
- package/library/skills/research/experiment-protocol/plugin.json +23 -0
- package/library/skills/research/scientific-debugging/SKILL.md +149 -0
- package/library/skills/research/scientific-debugging/evals.md +156 -0
- package/library/skills/research/scientific-debugging/plugin.json +23 -0
- package/library/skills/research/scientific-modernization/SKILL.md +170 -0
- package/library/skills/research/scientific-modernization/evals.md +111 -0
- package/library/skills/research/scientific-modernization/plugin.json +23 -0
- package/library/skills/skill-marketplace.json +507 -0
- package/library/skills/workflow/cut-it/SKILL.md +153 -0
- package/library/skills/workflow/cut-it/evals.md +143 -0
- package/library/skills/workflow/cut-it/plugin.json +23 -0
- package/library/skills/workflow/design-council/SKILL.md +233 -0
- package/library/skills/workflow/design-council/evals.md +258 -0
- package/library/skills/workflow/design-council/plugin.json +23 -0
- package/library/skills/workflow/grill-me/SKILL.md +267 -0
- package/library/skills/workflow/grill-me/evals.md +231 -0
- package/library/skills/workflow/grill-me/plugin.json +23 -0
- package/library/skills/workflow/workflow-distiller/SKILL.md +204 -0
- package/library/skills/workflow/workflow-distiller/evals.md +233 -0
- package/library/skills/workflow/workflow-distiller/plugin.json +23 -0
- package/package.json +23 -14
- package/src/cli/agents.ts +1 -1
- package/src/cli/config-inspect.ts +1 -1
- package/src/cli/configure.ts +2 -2
- package/src/cli/docs.ts +65 -328
- package/src/cli/eval.ts +40 -6
- package/src/cli/extensions.ts +74 -8
- package/src/cli/fleet-preflight.ts +2 -0
- package/src/cli/fleet.ts +2 -0
- package/src/cli/index.ts +4 -4
- package/src/cli/interop-inspect.ts +61 -33
- package/src/cli/interop.ts +79 -9
- package/src/cli/library-import.ts +139 -0
- package/src/cli/library.ts +418 -120
- package/src/cli/run.ts +26 -9
- package/src/cli/skills-eval.ts +43 -6
- package/src/cli/skills-inventory.ts +6 -2
- package/src/cli/skills.ts +44 -491
- package/src/cli/trace.ts +4 -65
- package/src/cli/uninstall.ts +26 -0
- package/src/cli/usage.ts +3 -0
- package/src/cli/web.ts +79 -0
- package/src/core/bus-events.ts +8 -4
- package/src/core/config.ts +71 -0
- package/src/core/defaults.ts +1 -1
- package/src/core/domain-loader.ts +37 -28
- package/src/core/recent-models.ts +2 -2
- package/src/core/session-routing.ts +3 -3
- package/src/core/state-file-lock.ts +1 -1
- package/src/core/termination.ts +13 -9
- package/src/core/tool-names.ts +5 -0
- package/src/domains/agents/contract.ts +1 -1
- package/src/domains/agents/extension.ts +53 -9
- package/src/domains/agents/fleet-commands.ts +92 -1
- package/src/domains/agents/fleet-contract.ts +87 -19
- package/src/domains/agents/recipe.ts +5 -4
- package/src/domains/agents/registry.ts +80 -24
- package/src/domains/config/extension.ts +5 -4
- package/src/domains/config/keybindings.ts +155 -95
- package/src/domains/context/worker/contract.ts +91 -0
- package/src/domains/context/worker/pressure.ts +120 -0
- package/src/domains/context/worker/recall.ts +62 -0
- package/src/domains/context/worker/select.ts +164 -0
- package/src/domains/context/worker/snapshot.ts +35 -0
- package/src/domains/context/worker/store.ts +16 -0
- package/src/domains/context/working-set/replay/synthetic.ts +2 -1
- package/src/domains/dispatch/active-route-planner.ts +2 -0
- package/src/domains/dispatch/backoff.ts +1 -0
- package/src/domains/dispatch/code-step.ts +12 -2
- package/src/domains/dispatch/contract.ts +3 -0
- package/src/domains/dispatch/execution-plan.ts +2 -0
- package/src/domains/dispatch/extension.ts +184 -39
- package/src/domains/dispatch/fleet-plan.ts +10 -0
- package/src/domains/dispatch/fleet-run.ts +1 -0
- package/src/domains/dispatch/index.ts +1 -0
- package/src/domains/dispatch/orphan-recovery.ts +2 -0
- package/src/domains/dispatch/receipt-integrity.ts +7 -0
- package/src/domains/dispatch/state.ts +2 -2
- package/src/domains/dispatch/types.ts +7 -0
- package/src/domains/dispatch/validation.ts +12 -0
- package/src/domains/dispatch/workspace-checkpoint.ts +1 -1
- package/src/domains/eval/metrics/tracked.ts +22 -2
- package/src/domains/evidence/failure-attribution.ts +1 -0
- package/src/domains/evidence/trust-status.ts +22 -3
- package/src/domains/extensions/command-schema.ts +145 -0
- package/src/domains/extensions/command-tools.ts +15 -0
- package/src/domains/extensions/compatibility.ts +7 -0
- package/src/domains/extensions/contract.ts +0 -4
- package/src/domains/extensions/discovery.ts +69 -205
- package/src/domains/extensions/extension.ts +0 -4
- package/src/domains/extensions/index.ts +1 -5
- package/src/domains/extensions/manager.ts +1 -6
- package/src/domains/extensions/operator-commands.ts +29 -0
- package/src/domains/extensions/operator-runtime.ts +485 -0
- package/src/domains/extensions/public-api.ts +53 -0
- package/src/domains/extensions/runtime-child.mjs +114 -0
- package/src/domains/extensions/runtime-process.ts +306 -0
- package/src/domains/extensions/runtime-schema.ts +146 -0
- package/src/domains/extensions/snapshot-access.ts +21 -0
- package/src/domains/extensions/snapshot.ts +4 -32
- package/src/domains/extensions/state.ts +5 -83
- package/src/domains/extensions/types.ts +33 -34
- package/src/domains/interop/adopt.ts +546 -0
- package/src/domains/interop/detect.ts +50 -12
- package/src/domains/interop/foreign.ts +554 -0
- package/src/domains/interop/import.ts +277 -0
- package/src/domains/interop/index.ts +24 -0
- package/src/domains/interop/install.ts +6 -0
- package/src/domains/interop/inventory.ts +351 -0
- package/src/domains/interop/projection.ts +360 -0
- package/src/domains/interop/registry.ts +106 -3
- package/src/domains/interop/types.ts +51 -0
- package/src/domains/lifecycle/migrations/index.ts +0 -2
- package/src/domains/lifecycle/naming-resources.ts +1 -1
- package/src/domains/middleware/hooks.ts +2 -2
- package/src/domains/middleware/marketplace-offer.ts +1 -1
- package/src/domains/mux/contract.ts +1 -1
- package/src/domains/observability/background-memory-usage.ts +3 -0
- package/src/domains/observability/compaction-usage.ts +2 -0
- package/src/domains/observability/cost.ts +5 -0
- package/src/domains/observability/extension.ts +1 -0
- package/src/domains/observability/out-of-turn-usage.ts +2 -0
- package/src/domains/observability/trace-store.ts +65 -5
- package/src/domains/plugins/catalog.ts +204 -0
- package/src/domains/plugins/contract.ts +24 -0
- package/src/domains/plugins/discovery.ts +316 -0
- package/src/domains/plugins/extension.ts +40 -0
- package/src/domains/plugins/index.ts +77 -0
- package/src/domains/plugins/integrity.ts +6 -0
- package/src/domains/plugins/manifest.ts +3 -0
- package/src/domains/plugins/resources.ts +102 -0
- package/src/domains/plugins/state.ts +753 -0
- package/src/domains/plugins/types.ts +217 -0
- package/src/domains/prompts/extension.ts +4 -10
- package/src/domains/prompts/fragments/operating/skills.md +10 -10
- package/src/domains/providers/cache-deployment.ts +147 -0
- package/src/domains/providers/catalog.ts +12 -7
- package/src/domains/providers/extension.ts +27 -5
- package/src/domains/providers/index.ts +1 -0
- package/src/domains/providers/plugins.ts +3 -13
- package/src/domains/providers/runtimes/common/local-synth.ts +4 -0
- package/src/domains/providers/types/target-descriptor.ts +17 -0
- package/src/domains/resources/common-loader.ts +9 -6
- package/src/domains/resources/index.ts +67 -0
- package/src/domains/resources/library-actions.ts +836 -0
- package/src/domains/resources/library-evals.ts +38 -0
- package/src/domains/resources/library-inventory.ts +1048 -0
- package/src/domains/resources/library-types.ts +50 -0
- package/src/domains/resources/library-validation.ts +634 -0
- package/src/domains/resources/library.ts +437 -156
- package/src/domains/resources/package-references.ts +66 -0
- package/src/domains/resources/prompts/loader.ts +75 -41
- package/src/domains/resources/skills/install.ts +2 -2
- package/src/domains/resources/skills/loader.ts +77 -22
- package/src/domains/resources/skills/marketplace.ts +48 -57
- package/src/domains/resources/skills/promotion.ts +2 -2
- package/src/domains/resources/skills/provenance-pin.ts +17 -4
- package/src/domains/safety/action-classifier.ts +2 -2
- package/src/domains/safety/default-path-policy.ts +3 -1
- package/src/domains/safety/policy-engine.ts +1 -1
- package/src/domains/safety/protected-artifacts.ts +21 -5
- package/src/domains/safety/skill-authority.ts +5 -2
- package/src/domains/session/compaction/compact.ts +4 -1
- package/src/domains/session/entries.ts +1 -0
- package/src/domains/session/usage.ts +6 -7
- package/src/domains/share/archive.ts +1 -1
- package/src/engine/acp/server.ts +11 -0
- package/src/engine/ai.ts +2 -0
- package/src/engine/apis/openai-completions.ts +61 -6
- package/src/engine/notices/pi-tui-LICENSE +21 -0
- package/src/engine/prewarm.ts +232 -0
- package/src/engine/provider-diagnostics.ts +6 -1
- package/src/engine/tui.ts +3 -0
- package/src/engine/worker-runtime.ts +58 -14
- package/src/engine/worker-tools.ts +5 -0
- package/src/entry/orchestrator.ts +46 -21
- package/src/entry/plugin-reload.ts +18 -0
- package/src/interactive/application-controller.ts +67 -21
- package/src/interactive/chat-loop-messages.ts +3 -0
- package/src/interactive/chat-loop.ts +32 -11
- package/src/interactive/chat-panel.ts +5 -1
- package/src/interactive/clio-editor.ts +53 -21
- package/src/interactive/command-output.ts +56 -1
- package/src/interactive/editor-submit.ts +65 -28
- package/src/interactive/fleet-run-preview.ts +2 -0
- package/src/interactive/follow-up-queue-panel.ts +3 -3
- package/src/interactive/footer/dashboard.ts +4 -1
- package/src/interactive/footer/notifications.ts +2 -2
- package/src/interactive/footer/widgets.ts +2 -2
- package/src/interactive/interactive-application.ts +209 -21
- package/src/interactive/interactive-input-runtime.ts +254 -7
- package/src/interactive/interactive-presentation.ts +41 -12
- package/src/interactive/interactive-slash-runtime.ts +37 -8
- package/src/interactive/keybinding-manager.ts +156 -79
- package/src/interactive/keyboard-owner.ts +37 -0
- package/src/interactive/leader-key.ts +49 -102
- package/src/interactive/leader-menu.ts +45 -0
- package/src/interactive/overlay-ask-user-lifecycle.ts +9 -1
- package/src/interactive/overlay-frame.ts +15 -0
- package/src/interactive/overlay-key-routing.ts +46 -47
- package/src/interactive/overlay-lifecycle.ts +30 -15
- package/src/interactive/overlay-resource-openers.ts +56 -46
- package/src/interactive/overlays/ask-user.ts +630 -556
- package/src/interactive/overlays/extension-panel.ts +70 -0
- package/src/interactive/overlays/extensions.ts +28 -5
- package/src/interactive/overlays/fleet-run-approval.ts +7 -3
- package/src/interactive/overlays/help-reference.ts +89 -40
- package/src/interactive/overlays/interop.ts +122 -3
- package/src/interactive/overlays/keybinding-detail.ts +2 -2
- package/src/interactive/overlays/library-lifecycle.ts +90 -0
- package/src/interactive/overlays/library-model.ts +574 -0
- package/src/interactive/overlays/library-review.ts +557 -0
- package/src/interactive/overlays/library-tabs.ts +3 -15
- package/src/interactive/overlays/library.ts +602 -0
- package/src/interactive/overlays/list-overlay.ts +218 -39
- package/src/interactive/overlays/model-selector.ts +28 -25
- package/src/interactive/overlays/session-selector.ts +9 -3
- package/src/interactive/overlays/settings.ts +25 -18
- package/src/interactive/overlays/tree-selector.ts +16 -11
- package/src/interactive/permission-hint.ts +13 -0
- package/src/interactive/permission-overlay.ts +77 -28
- package/src/interactive/prewarm.ts +11 -197
- package/src/interactive/prompt-source-label.ts +21 -0
- package/src/interactive/renderers/reference-card.ts +35 -0
- package/src/interactive/renderers/worker-entry.ts +35 -3
- package/src/interactive/session-usage-reseed.ts +2 -0
- package/src/interactive/side-question.ts +2 -0
- package/src/interactive/slash-autocomplete.ts +99 -1
- package/src/interactive/slash-commands.ts +390 -67
- package/src/interactive/slash-spec.ts +0 -1
- package/src/interactive/terminal-lease.ts +44 -12
- package/src/interactive/turn-context.ts +1 -0
- package/src/interactive/turn-persistence.ts +3 -0
- package/src/interactive/turn-prewarm.ts +126 -19
- package/src/interactive/turn-queues.ts +8 -7
- package/src/interactive/turn-runtime.ts +15 -1
- package/src/interactive/view/view-overlay.ts +19 -14
- package/src/interactive/welcome-dashboard.ts +525 -408
- package/src/tools/bootstrap.ts +8 -0
- package/src/tools/builtin-tool-catalog.ts +15 -6
- package/src/tools/context/index.ts +58 -5
- package/src/tools/context/library.ts +465 -0
- package/src/tools/context/surface.ts +20 -6
- package/src/tools/core-bootstrap.ts +3 -0
- package/src/tools/dispatch-admission.ts +24 -1
- package/src/tools/dispatch-arguments.ts +8 -0
- package/src/tools/dispatch-plan.ts +32 -0
- package/src/tools/dispatch-schema.ts +31 -1
- package/src/tools/dispatch-types.ts +3 -0
- package/src/tools/dispatch.ts +1 -1
- package/src/tools/harness-extensions.ts +169 -0
- package/src/tools/observation.ts +4 -0
- package/src/tools/policy.ts +7 -1
- package/src/tools/registry.ts +31 -3
- package/src/tools/worker-evidence.ts +5 -0
- package/src/worker/context-seed.ts +192 -0
- package/src/worker/entry.ts +1 -0
- package/src/worker/spec-contract.ts +35 -1
- package/dist/acp-UVEVWSDL.js +0 -130
- package/dist/agents-VWY37DTK.js +0 -148
- package/dist/auth-PCV2XQDV.js +0 -551
- package/dist/builtins-PD652MTK.js +0 -22
- package/dist/chunk-22PQ4TX4.js +0 -360
- package/dist/chunk-24T2YZ7A.js +0 -22648
- package/dist/chunk-2AKYFREM.js +0 -1008
- package/dist/chunk-2QPI3TR3.js +0 -162
- package/dist/chunk-3BJGMT2D.js +0 -324
- package/dist/chunk-3HQVBIKD.js +0 -308
- package/dist/chunk-3JLFK5MW.js +0 -193
- package/dist/chunk-3O2ZAUGQ.js +0 -283
- package/dist/chunk-3QKXHCGS.js +0 -59
- package/dist/chunk-3T4DXWP6.js +0 -668
- package/dist/chunk-3UW3KU4A.js +0 -21
- package/dist/chunk-3WBALRQH.js +0 -5076
- package/dist/chunk-4DU2TVI4.js +0 -108
- package/dist/chunk-4U4TKZFR.js +0 -5052
- package/dist/chunk-4VMV6OS6.js +0 -101
- package/dist/chunk-536HXRFE.js +0 -1257
- package/dist/chunk-5CMARGPF.js +0 -477
- package/dist/chunk-5CY4Q6QI.js +0 -141
- package/dist/chunk-5QRX7SLS.js +0 -1018
- package/dist/chunk-5VTJP36Q.js +0 -36
- package/dist/chunk-5ZSZEYJK.js +0 -119
- package/dist/chunk-6HAO6X5B.js +0 -197
- package/dist/chunk-6OII3LOK.js +0 -404
- package/dist/chunk-6RYDAVQT.js +0 -4338
- package/dist/chunk-6VRRJT7L.js +0 -146
- package/dist/chunk-6YA46L5A.js +0 -386
- package/dist/chunk-77CZRFTE.js +0 -634
- package/dist/chunk-7JSSKXG2.js +0 -1215
- package/dist/chunk-7WUZEB2M.js +0 -165
- package/dist/chunk-7YJWEF2L.js +0 -974
- package/dist/chunk-ACCKVSHU.js +0 -44
- package/dist/chunk-B3MOMLJ4.js +0 -433
- package/dist/chunk-BBV5TKE6.js +0 -35
- package/dist/chunk-BLTEAUCB.js +0 -668
- package/dist/chunk-BS4GAMUB.js +0 -233
- package/dist/chunk-BT7HGDOX.js +0 -3151
- package/dist/chunk-CBSKDFWL.js +0 -101
- package/dist/chunk-CXQ37WJH.js +0 -45
- package/dist/chunk-DXLUVUD4.js +0 -1490
- package/dist/chunk-DZK63TZJ.js +0 -1334
- package/dist/chunk-E7RF4KBO.js +0 -266
- package/dist/chunk-ECOMVOHP.js +0 -139
- package/dist/chunk-EHOSNVVM.js +0 -59
- package/dist/chunk-F5Z7EWMN.js +0 -4484
- package/dist/chunk-FQOOGXBH.js +0 -579
- package/dist/chunk-GLYBJ4RQ.js +0 -396
- package/dist/chunk-HHVJNVUJ.js +0 -179
- package/dist/chunk-HL26ADLH.js +0 -77
- package/dist/chunk-HPTJF6DG.js +0 -2465
- package/dist/chunk-HXHFDHB6.js +0 -962
- package/dist/chunk-HZ2T2YED.js +0 -1687
- package/dist/chunk-HZFBVU5X.js +0 -666
- package/dist/chunk-I2K2NCZQ.js +0 -659
- package/dist/chunk-IGLVVNEG.js +0 -402
- package/dist/chunk-IKRWLEDA.js +0 -1567
- package/dist/chunk-J2FYEQ5L.js +0 -33
- package/dist/chunk-JMPL7NUB.js +0 -108
- package/dist/chunk-K2HL3GBL.js +0 -998
- package/dist/chunk-KAFMW7WM.js +0 -386
- package/dist/chunk-KTFSFCVN.js +0 -46
- package/dist/chunk-LIN2K3EL.js +0 -66
- package/dist/chunk-LUL5Z66S.js +0 -221
- package/dist/chunk-LVFANMOH.js +0 -466
- package/dist/chunk-LY4N4TTL.js +0 -117
- package/dist/chunk-LZBMXNLP.js +0 -1196
- package/dist/chunk-M6TAYK66.js +0 -807
- package/dist/chunk-N2OKBREN.js +0 -243
- package/dist/chunk-NC4KV7EL.js +0 -39
- package/dist/chunk-NF3BK5WR.js +0 -42
- package/dist/chunk-NNWJYUNO.js +0 -573
- package/dist/chunk-NTK3WTHM.js +0 -141
- package/dist/chunk-ODUTYZIU.js +0 -688
- package/dist/chunk-OQM5IVJY.js +0 -1377
- package/dist/chunk-P5JMBPDJ.js +0 -7192
- package/dist/chunk-P5SC4DLJ.js +0 -47
- package/dist/chunk-P6M7RKMI.js +0 -97
- package/dist/chunk-PWWSIB2A.js +0 -52
- package/dist/chunk-PZN2LQY6.js +0 -674
- package/dist/chunk-Q7NNUHQV.js +0 -705
- package/dist/chunk-QCOV5DFY.js +0 -911
- package/dist/chunk-QNWRHOMF.js +0 -692
- package/dist/chunk-QRFXEO6Y.js +0 -17
- package/dist/chunk-QXFBABFJ.js +0 -380
- package/dist/chunk-RGZNQ5CT.js +0 -657
- package/dist/chunk-SRZOW5L2.js +0 -1865
- package/dist/chunk-SXQKNKRA.js +0 -223
- package/dist/chunk-T334FW2H.js +0 -362
- package/dist/chunk-T52TPHYC.js +0 -318
- package/dist/chunk-TJFDL26W.js +0 -658
- package/dist/chunk-TN5FW4XY.js +0 -172
- package/dist/chunk-U7H5WRG5.js +0 -123
- package/dist/chunk-UFYNOQK4.js +0 -302
- package/dist/chunk-URBGEOH3.js +0 -32
- package/dist/chunk-USZA7GWL.js +0 -341
- package/dist/chunk-UUQ5G6EZ.js +0 -697
- package/dist/chunk-VAHLPXPY.js +0 -399
- package/dist/chunk-VANN3GDP.js +0 -2488
- package/dist/chunk-VHMX7SXF.js +0 -1289
- package/dist/chunk-WJIMKGD6.js +0 -132
- package/dist/chunk-WKUYQBCG.js +0 -795
- package/dist/chunk-WNGF5AJX.js +0 -1911
- package/dist/chunk-WV6TDAPN.js +0 -3627
- package/dist/chunk-X3BI7HTV.js +0 -562
- package/dist/chunk-XWMSPJYN.js +0 -149
- package/dist/chunk-YPRSNUTC.js +0 -395
- package/dist/chunk-ZS43Y2FT.js +0 -438
- package/dist/clio-QQCMTUZE.js +0 -26
- package/dist/code-nav-GUPM6766.js +0 -686
- package/dist/components-TNIKXCBH.js +0 -674
- package/dist/config-IIM7YOD3.js +0 -621
- package/dist/configure-4ZM5HWJX.js +0 -73
- package/dist/context-44BZLJ3J.js +0 -344
- package/dist/context-AIDVQKMW.js +0 -278
- package/dist/context-OL5P3HEP.js +0 -1031
- package/dist/context-clear-OQV76MYP.js +0 -184
- package/dist/context-index-HP2JFUWA.js +0 -120
- package/dist/context-map-INTXD54D.js +0 -555
- package/dist/context-working-set-ZUW3EGLS.js +0 -1556
- package/dist/detail-UXPWRANG.js +0 -115
- package/dist/dispatch-runner-P3ZW6G77.js +0 -2438
- package/dist/docs-BL7ROUFN.js +0 -292
- package/dist/doctor-JJVGPZWT.js +0 -797
- package/dist/eval-V2RTN3UH.js +0 -4972
- package/dist/eval-inventory-QOYZERXJ.js +0 -315
- package/dist/evidence-35PYWGSO.js +0 -225
- package/dist/evidence-CIGGKI6J.js +0 -383
- package/dist/evolve-33SM3NJP.js +0 -609
- package/dist/extensions-YVRHX6ZI.js +0 -229
- package/dist/fleet-LFO7SIPC.js +0 -908
- package/dist/fleet-commands-RLK72GU3.js +0 -75
- package/dist/fleet-decisions-3SBSCTCW.js +0 -159
- package/dist/fleet-graph-JZIBCGMW.js +0 -134
- package/dist/fleet-inspect-2L5YGGZJ.js +0 -469
- package/dist/fleet-preflight-QRSHIIDE.js +0 -22
- package/dist/fleet-validate-LIAVKDUU.js +0 -92
- package/dist/fleet-verify-JIK3OQZR.js +0 -202
- package/dist/fleet-view-IWHYGQKK.js +0 -118
- package/dist/init-NJEDOTQW.js +0 -321
- package/dist/interop-RVCAYECG.js +0 -115
- package/dist/inventory-74UL7UHU.js +0 -118
- package/dist/library-CTKZA7K3.js +0 -226
- package/dist/memory-I76I5VUH.js +0 -512
- package/dist/models-D4YDIQZQ.js +0 -289
- package/dist/monitor-NKVD55HX.js +0 -775
- package/dist/orchestrator-I6OATVPK.js +0 -39518
- package/dist/panes-7BTYH3XQ.js +0 -103
- package/dist/panes-WPOMEMRH.js +0 -74
- package/dist/paths-J3KN7UAO.js +0 -67
- package/dist/preload-EJAWJEIO.js +0 -116
- package/dist/reset-4XMQKDNZ.js +0 -345
- package/dist/resources-TVYVXK3Q.js +0 -125
- package/dist/run-OWQNNSJU.js +0 -872
- package/dist/share-NPZZMUXG.js +0 -290
- package/dist/skills-OXFEAWMT.js +0 -510
- package/dist/skills-eval-J5TCKSJA.js +0 -1034
- package/dist/skills-inventory-7II4DM57.js +0 -133
- package/dist/slash-commands-MDSDSWYF.js +0 -92
- package/dist/steer-S7D7IKPU.js +0 -77
- package/dist/support-5VAEC32W.js +0 -38
- package/dist/targets-KILZEOCE.js +0 -1109
- package/dist/tasks-R6P6OV22.js +0 -36
- package/dist/terminal-lease-LZCG2KN3.js +0 -405
- package/dist/tools-6OCQ6SVB.js +0 -28
- package/dist/trace-JHLXWUMN.js +0 -572
- package/dist/tui-primitives-RCY2HN7G.js +0 -17
- package/dist/uninstall-FXYMFFRT.js +0 -407
- package/dist/upgrade-D2OZH6IQ.js +0 -307
- package/dist/usage-PIASNUS4.js +0 -1052
- package/dist/verifiers-LTHUY2PX.js +0 -630
- package/dist/verify-HYF7KBVE.js +0 -30
- package/dist/web-fetch-MQN4FH3X.js +0 -788
- package/dist/wiki-generate-RK7JQ5NP.js +0 -615
- package/dist/with-panes-OFTNAR4Y.js +0 -628
- package/skills/README.md +0 -418
- package/skills/coding/ast-grep/SKILL.md +0 -213
- package/skills/coding/ast-grep/evals.md +0 -82
- package/skills/coding/coding-standards/SKILL.md +0 -164
- package/skills/coding/coding-standards/evals.md +0 -57
- package/skills/coding/prototype/SKILL.md +0 -151
- package/skills/coding/prototype/evals.md +0 -61
- package/skills/coding/tdd/SKILL.md +0 -134
- package/skills/coding/tdd/evals.md +0 -61
- package/skills/context/context-handoff/SKILL.md +0 -176
- package/skills/context/context-handoff/evals.md +0 -101
- package/skills/context/context-prime/SKILL.md +0 -131
- package/skills/context/context-prime/evals.md +0 -99
- package/skills/git/branch-closeout/SKILL.md +0 -132
- package/skills/git/file-ticket/SKILL.md +0 -126
- package/skills/git/fix-issue/SKILL.md +0 -136
- package/skills/git/resolve-merge-conflicts/SKILL.md +0 -151
- package/skills/git/resolve-merge-conflicts/evals.md +0 -85
- package/skills/git/ship/SKILL.md +0 -134
- package/skills/git/worktree-create/SKILL.md +0 -127
- package/skills/git/worktree-merge/SKILL.md +0 -147
- package/skills/meta/clio-coder-dev/SKILL.md +0 -101
- package/skills/meta/clio-coder-dev/evals.md +0 -46
- package/skills/meta/clio-coder-test/SKILL.md +0 -146
- package/skills/meta/clio-coder-test/evals.md +0 -48
- package/skills/meta/clio-coder-test/references/test-map.md +0 -96
- package/skills/meta/credentials/SKILL.md +0 -132
- package/skills/meta/credentials/evals.md +0 -104
- package/skills/meta/find-skills/SKILL.md +0 -78
- package/skills/meta/find-skills/evals.md +0 -47
- package/skills/meta/herdr/SKILL.md +0 -133
- package/skills/meta/herdr/evals.md +0 -38
- package/skills/meta/skill-craft/SKILL.md +0 -125
- package/skills/meta/skill-craft/evals.md +0 -41
- package/skills/planning/archify/SKILL.md +0 -196
- package/skills/planning/architecture/SKILL.md +0 -184
- package/skills/planning/architecture/evals.md +0 -101
- package/skills/planning/backlog/SKILL.md +0 -212
- package/skills/planning/backlog/evals.md +0 -185
- package/skills/planning/prd/SKILL.md +0 -129
- package/skills/planning/prd/evals.md +0 -103
- package/skills/planning/product-intent/SKILL.md +0 -173
- package/skills/planning/product-intent/evals.md +0 -106
- package/skills/planning/tech-spec/SKILL.md +0 -172
- package/skills/planning/tech-spec/evals.md +0 -120
- package/skills/registry.yaml +0 -144
- package/skills/remote.yaml +0 -13
- package/skills/research/arxiv-literature/SKILL.md +0 -168
- package/skills/research/arxiv-literature/evals.md +0 -108
- package/skills/research/experiment-protocol/SKILL.md +0 -148
- package/skills/research/experiment-protocol/evals.md +0 -114
- package/skills/research/scientific-debugging/SKILL.md +0 -149
- package/skills/research/scientific-debugging/evals.md +0 -156
- package/skills/research/scientific-modernization/SKILL.md +0 -170
- package/skills/research/scientific-modernization/evals.md +0 -111
- package/skills/skill-marketplace.json +0 -507
- package/skills/workflow/cut-it/SKILL.md +0 -153
- package/skills/workflow/cut-it/evals.md +0 -143
- package/skills/workflow/design-council/SKILL.md +0 -233
- package/skills/workflow/design-council/evals.md +0 -258
- package/skills/workflow/grill-me/SKILL.md +0 -267
- package/skills/workflow/grill-me/evals.md +0 -231
- package/skills/workflow/workflow-distiller/SKILL.md +0 -201
- package/skills/workflow/workflow-distiller/evals.md +0 -225
- package/src/domains/extensions/resource-path.ts +0 -27
- package/src/domains/extensions/resources.ts +0 -37
- package/src/domains/lifecycle/migrations/2026-09-01-extension-install-digests.ts +0 -27
- package/src/interactive/overlays/agents.ts +0 -70
- package/src/interactive/overlays/library-install-confirm.ts +0 -152
- package/src/interactive/overlays/prompts.ts +0 -89
- package/src/interactive/overlays/skills-hub.ts +0 -615
- /package/{skills → library/skills}/coding/ast-grep/references/rule_reference.md +0 -0
- /package/{skills → library/skills}/coding/prototype/references/LOGIC.md +0 -0
- /package/{skills → library/skills}/coding/prototype/references/UI.md +0 -0
- /package/{skills → library/skills}/coding/tdd/references/mocking.md +0 -0
- /package/{skills → library/skills}/coding/tdd/references/tests.md +0 -0
- /package/{skills → library/skills}/context/context-handoff/scripts/new-handoff.sh +0 -0
- /package/{skills → library/skills}/git/branch-closeout/evals.md +0 -0
- /package/{skills → library/skills}/git/branch-closeout/references/closeout-checklist.md +0 -0
- /package/{skills → library/skills}/git/file-ticket/assets/issue-template.md +0 -0
- /package/{skills → library/skills}/git/file-ticket/evals.md +0 -0
- /package/{skills → library/skills}/git/file-ticket/references/issue-discovery.md +0 -0
- /package/{skills → library/skills}/git/fix-issue/evals.md +0 -0
- /package/{skills → library/skills}/git/fix-issue/references/diagnosis-and-rca.md +0 -0
- /package/{skills → library/skills}/git/resolve-merge-conflicts/references/conflict-matrix.md +0 -0
- /package/{skills → library/skills}/git/ship/assets/pr-template.md +0 -0
- /package/{skills → library/skills}/git/ship/evals.md +0 -0
- /package/{skills → library/skills}/git/ship/references/remote-and-branch-policy.md +0 -0
- /package/{skills → library/skills}/git/worktree-create/evals.md +0 -0
- /package/{skills → library/skills}/git/worktree-create/references/worktree-setup.md +0 -0
- /package/{skills → library/skills}/git/worktree-merge/evals.md +0 -0
- /package/{skills → library/skills}/git/worktree-merge/references/merge-strategies.md +0 -0
- /package/{skills → library/skills}/meta/clio-coder-test/references/harness.md +0 -0
- /package/{skills → library/skills}/planning/archify/evals.md +0 -0
|
@@ -0,0 +1,4484 @@
|
|
|
1
|
+
import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
createDelayedManualCodeInput,
|
|
4
|
+
promptOAuthSelection
|
|
5
|
+
} from "./chunk-LK2FN5JY.js";
|
|
6
|
+
import {
|
|
7
|
+
editTextExternally,
|
|
8
|
+
resolveExternalEditor
|
|
9
|
+
} from "./chunk-R2CT5YDO.js";
|
|
10
|
+
import {
|
|
11
|
+
createLifecyclePresenter,
|
|
12
|
+
shortenPath
|
|
13
|
+
} from "./chunk-RNLAPBJL.js";
|
|
14
|
+
import {
|
|
15
|
+
column,
|
|
16
|
+
terminalColumns,
|
|
17
|
+
truncate,
|
|
18
|
+
twoColumnRow,
|
|
19
|
+
wrapPlain
|
|
20
|
+
} from "./chunk-ZIDFQJRB.js";
|
|
21
|
+
import {
|
|
22
|
+
credentialWriteFailed,
|
|
23
|
+
printPlaintextCredentialWarning
|
|
24
|
+
} from "./chunk-YKIIWURD.js";
|
|
25
|
+
import {
|
|
26
|
+
fingerprintNativeRuntime
|
|
27
|
+
} from "./chunk-QJMRYTCX.js";
|
|
28
|
+
import {
|
|
29
|
+
INHERITED_PROJECT_CONTEXT,
|
|
30
|
+
acceptInteropAgents,
|
|
31
|
+
declineInteropAgents,
|
|
32
|
+
detectInteropAgents,
|
|
33
|
+
interopProposals,
|
|
34
|
+
renderProposalEntry,
|
|
35
|
+
resolveOnPath
|
|
36
|
+
} from "./chunk-GJBJHJNY.js";
|
|
37
|
+
import {
|
|
38
|
+
initializeClioHome
|
|
39
|
+
} from "./chunk-PFZJMXIY.js";
|
|
40
|
+
import {
|
|
41
|
+
printError,
|
|
42
|
+
printOk,
|
|
43
|
+
source_default
|
|
44
|
+
} from "./chunk-ATB3Q7YO.js";
|
|
45
|
+
import {
|
|
46
|
+
isOrchestratorEligibleRuntime,
|
|
47
|
+
probeCapabilitiesForModel,
|
|
48
|
+
readTargetModelSnapshot,
|
|
49
|
+
recordTargetModelSnapshot
|
|
50
|
+
} from "./chunk-GVU4CXPJ.js";
|
|
51
|
+
import {
|
|
52
|
+
greetLmStudio,
|
|
53
|
+
probeJson,
|
|
54
|
+
registerBuiltinRuntimes,
|
|
55
|
+
targetRootUrl
|
|
56
|
+
} from "./chunk-QWUSS2QP.js";
|
|
57
|
+
import {
|
|
58
|
+
buildProviderSupportEntry,
|
|
59
|
+
configuredTargetsForRuntime,
|
|
60
|
+
describeRuntimeModels,
|
|
61
|
+
listKnownModelsForRuntime,
|
|
62
|
+
listProviderSupportEntries,
|
|
63
|
+
supportGroupLabel
|
|
64
|
+
} from "./chunk-YXANQGCX.js";
|
|
65
|
+
import {
|
|
66
|
+
getCatalogModelForRuntime
|
|
67
|
+
} from "./chunk-UDAK6GR2.js";
|
|
68
|
+
import {
|
|
69
|
+
credentialsPresent
|
|
70
|
+
} from "./chunk-TOPICHGR.js";
|
|
71
|
+
import {
|
|
72
|
+
authStoragePath,
|
|
73
|
+
openAuthStorage,
|
|
74
|
+
registerClioOAuthProviders,
|
|
75
|
+
resolveAuthTarget,
|
|
76
|
+
resolveRuntimeAuthTarget,
|
|
77
|
+
targetRequiresAuth
|
|
78
|
+
} from "./chunk-PAQVETLA.js";
|
|
79
|
+
import {
|
|
80
|
+
SettingsValidationError,
|
|
81
|
+
bindAgentProfileInSettings,
|
|
82
|
+
readSettings,
|
|
83
|
+
removeTargetFromSettings,
|
|
84
|
+
settingsPath,
|
|
85
|
+
updateSavedSettingsDocument,
|
|
86
|
+
updateSettings,
|
|
87
|
+
validateSettings,
|
|
88
|
+
withSettingsLock
|
|
89
|
+
} from "./chunk-PGEFOTJB.js";
|
|
90
|
+
import {
|
|
91
|
+
warnLegacyNaming
|
|
92
|
+
} from "./chunk-DVNAPPXU.js";
|
|
93
|
+
import {
|
|
94
|
+
DEFAULT_SETTINGS_YAML,
|
|
95
|
+
THINKING_LEVELS
|
|
96
|
+
} from "./chunk-3XE4NRLF.js";
|
|
97
|
+
import {
|
|
98
|
+
require_dist
|
|
99
|
+
} from "./chunk-B5GGDIHT.js";
|
|
100
|
+
import {
|
|
101
|
+
AUTONOMY_LEVELS
|
|
102
|
+
} from "./chunk-EM2WNQS2.js";
|
|
103
|
+
import {
|
|
104
|
+
resolveClioDirs
|
|
105
|
+
} from "./chunk-CTTI7G3T.js";
|
|
106
|
+
import {
|
|
107
|
+
safeResourceWrite
|
|
108
|
+
} from "./chunk-ZZFWWYLX.js";
|
|
109
|
+
import {
|
|
110
|
+
getVersionInfo
|
|
111
|
+
} from "./chunk-GD55RTIW.js";
|
|
112
|
+
import {
|
|
113
|
+
getRuntimeRegistry
|
|
114
|
+
} from "./chunk-SRCEQKQS.js";
|
|
115
|
+
import {
|
|
116
|
+
__toESM,
|
|
117
|
+
init_esm_shims
|
|
118
|
+
} from "./chunk-ECBHH7LU.js";
|
|
119
|
+
|
|
120
|
+
// src/cli/configure.ts
|
|
121
|
+
init_esm_shims();
|
|
122
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
123
|
+
import { stdin as input, stdout as output2 } from "node:process";
|
|
124
|
+
|
|
125
|
+
// src/cli/ask.ts
|
|
126
|
+
init_esm_shims();
|
|
127
|
+
async function ask(rl, label, defaultValue) {
|
|
128
|
+
if (rl.text) return rl.text(label, defaultValue);
|
|
129
|
+
const suffix = defaultValue && defaultValue.length > 0 ? ` [${defaultValue}]` : "";
|
|
130
|
+
try {
|
|
131
|
+
const answer = (await rl.question(`${label}${suffix}: `)).trim();
|
|
132
|
+
if (answer.length === 0) return defaultValue ?? "";
|
|
133
|
+
if (answer.toLowerCase() === "q" || answer.toLowerCase() === "quit") return null;
|
|
134
|
+
return answer;
|
|
135
|
+
} catch {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async function askYesNo(rl, label, defaultValue) {
|
|
140
|
+
if (rl.choose && rl.interactive) return await rl.choose(label, ["yes", "no"], defaultValue ? "yes" : "no") === "yes";
|
|
141
|
+
const marker = defaultValue ? "Y/n" : "y/N";
|
|
142
|
+
for (; ; ) {
|
|
143
|
+
const answer = await ask(rl, `${label} [${marker}]`);
|
|
144
|
+
if (answer === null) return defaultValue;
|
|
145
|
+
if (answer.length === 0) return defaultValue;
|
|
146
|
+
const lc = answer.toLowerCase();
|
|
147
|
+
if (lc === "y" || lc === "yes") return true;
|
|
148
|
+
if (lc === "n" || lc === "no") return false;
|
|
149
|
+
process.stderr.write(`invalid response: ${answer}
|
|
150
|
+
`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// src/cli/configure-editor.ts
|
|
155
|
+
init_esm_shims();
|
|
156
|
+
var import_yaml = __toESM(require_dist(), 1);
|
|
157
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
158
|
+
async function editSettings(prompts) {
|
|
159
|
+
const file = settingsPath();
|
|
160
|
+
const original = existsSync(file) ? readFileSync(file, "utf8") : null;
|
|
161
|
+
let draft = original ?? DEFAULT_SETTINGS_YAML;
|
|
162
|
+
const editor = resolveExternalEditor();
|
|
163
|
+
for (; ; ) {
|
|
164
|
+
const result = editTextExternally(draft, editor, ".yaml");
|
|
165
|
+
if (!result.ok || result.text === void 0) throw new Error(result.error ?? "Editor did not return a draft");
|
|
166
|
+
draft = `${result.text}
|
|
167
|
+
`;
|
|
168
|
+
if (draft === original) {
|
|
169
|
+
prompts.output.write("Settings unchanged.\n");
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
try {
|
|
173
|
+
const validated = validateSettings((0, import_yaml.parse)(draft));
|
|
174
|
+
if (validated.issues.length) throw new SettingsValidationError(validated.issues);
|
|
175
|
+
} catch (error) {
|
|
176
|
+
prompts.output.write(`${error instanceof Error ? error.message : String(error)}
|
|
177
|
+
`);
|
|
178
|
+
if (await prompts.choose("Invalid draft", ["Return to editor", "Discard draft"], "Return to editor") === "Return to editor")
|
|
179
|
+
continue;
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
const choice = await prompts.choose(
|
|
183
|
+
"Save validated settings?",
|
|
184
|
+
["Save", "Return to editor", "Discard draft"],
|
|
185
|
+
"Save"
|
|
186
|
+
);
|
|
187
|
+
if (choice === "Return to editor") continue;
|
|
188
|
+
if (choice !== "Save") return false;
|
|
189
|
+
withSettingsLock(() => {
|
|
190
|
+
const current = existsSync(file) ? readFileSync(file, "utf8") : null;
|
|
191
|
+
if (current !== original)
|
|
192
|
+
throw new Error("Settings changed while the editor was open. Reopen the editor to keep those changes.");
|
|
193
|
+
safeResourceWrite(file, draft, { encoding: "utf8", mode: 420, backup: original !== null });
|
|
194
|
+
});
|
|
195
|
+
prompts.output.write(`Settings saved to ${file}${original === null ? "" : `; previous file: ${file}.bak`}
|
|
196
|
+
`);
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// src/cli/configure-interop.ts
|
|
202
|
+
init_esm_shims();
|
|
203
|
+
import { stdout as output } from "node:process";
|
|
204
|
+
|
|
205
|
+
// src/cli/configure-target.ts
|
|
206
|
+
init_esm_shims();
|
|
207
|
+
|
|
208
|
+
// src/cli/validate-model.ts
|
|
209
|
+
init_esm_shims();
|
|
210
|
+
var SAMPLE_SIZE = 10;
|
|
211
|
+
function sample(models) {
|
|
212
|
+
const shown = models.slice(0, SAMPLE_SIZE).join(", ");
|
|
213
|
+
return models.length > SAMPLE_SIZE ? `${shown}, \u2026` : shown;
|
|
214
|
+
}
|
|
215
|
+
function describeLiveTarget(live) {
|
|
216
|
+
return live.url ? `target '${live.targetId}' at ${live.url}` : `target '${live.targetId}'`;
|
|
217
|
+
}
|
|
218
|
+
function formatUnadvertisedModelReason(modelId, live) {
|
|
219
|
+
const resident = live.resident.length > 0 ? live.resident.join(", ") : "none";
|
|
220
|
+
return `${describeLiveTarget(live)} does not advertise model '${modelId}'. Advertised (${live.models.length}): ${sample(live.models)}. Resident instances: ${resident}. Pass one of the advertised ids with --model, or --force to save a model the target cannot serve.`;
|
|
221
|
+
}
|
|
222
|
+
function validateModelChoice(input2) {
|
|
223
|
+
const { runtimeId, modelId, knownModels, live, force } = input2;
|
|
224
|
+
if (live !== void 0) return validateAgainstLive(modelId, live, force);
|
|
225
|
+
if (knownModels.length === 0) return validateAgainstLive(modelId, live, force);
|
|
226
|
+
if (knownModels.includes(modelId)) return { ok: true };
|
|
227
|
+
if (force) {
|
|
228
|
+
return {
|
|
229
|
+
ok: true,
|
|
230
|
+
warning: `model '${modelId}' not in ${runtimeId} catalog (use without --force to reject)`
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
ok: false,
|
|
235
|
+
reason: `model '${modelId}' not in ${runtimeId} catalog. Known: ${sample(knownModels)}. Use --force to skip validation.`,
|
|
236
|
+
knownModels: knownModels.slice(0, SAMPLE_SIZE)
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function validateAgainstLive(modelId, live, force) {
|
|
240
|
+
if (!live || live.models.length === 0) return { ok: true };
|
|
241
|
+
if (live.models.includes(modelId)) return { ok: true };
|
|
242
|
+
const reason = formatUnadvertisedModelReason(modelId, live);
|
|
243
|
+
if (force) return { ok: true, warning: `${reason.replace(/ Pass one of.*$/u, "")} Saved anyway because of --force.` };
|
|
244
|
+
return { ok: false, reason, knownModels: live.models.slice(0, SAMPLE_SIZE) };
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// src/cli/configure-target.ts
|
|
248
|
+
var DEFAULT_PORTS = {
|
|
249
|
+
llamacpp: 8080,
|
|
250
|
+
"llamacpp-anthropic": 8080,
|
|
251
|
+
"llamacpp-completion": 8080,
|
|
252
|
+
"llamacpp-embed": 8080,
|
|
253
|
+
"llamacpp-rerank": 8080,
|
|
254
|
+
"lmstudio-native": 1234,
|
|
255
|
+
lmstudio: 1234,
|
|
256
|
+
"ollama-native": 11434,
|
|
257
|
+
vllm: 8e3,
|
|
258
|
+
sglang: 3e4,
|
|
259
|
+
"lemonade-anthropic": 8e3,
|
|
260
|
+
lemonade: 8e3,
|
|
261
|
+
"anthropic-compat": 8e3,
|
|
262
|
+
"openai-compat": 8e3,
|
|
263
|
+
litellm: 4e3
|
|
264
|
+
};
|
|
265
|
+
function trimTrailing(url) {
|
|
266
|
+
return url.endsWith("/") && url.length > 1 ? url.slice(0, -1) : url;
|
|
267
|
+
}
|
|
268
|
+
function normalizeUrl(input2, runtimeId) {
|
|
269
|
+
const trimmed = input2.trim();
|
|
270
|
+
if (trimmed.length === 0) return defaultUrlFor(runtimeId);
|
|
271
|
+
const hasScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed);
|
|
272
|
+
let withScheme = hasScheme ? trimmed : `http://${trimmed}`;
|
|
273
|
+
if (runtimeId === "lmstudio") withScheme = withScheme.replace(/^ws:/u, "http:").replace(/^wss:/u, "https:");
|
|
274
|
+
try {
|
|
275
|
+
const parsed = new URL(withScheme);
|
|
276
|
+
if (!hasScheme && !parsed.port && DEFAULT_PORTS[runtimeId]) {
|
|
277
|
+
parsed.port = String(DEFAULT_PORTS[runtimeId]);
|
|
278
|
+
}
|
|
279
|
+
return trimTrailing(parsed.toString());
|
|
280
|
+
} catch {
|
|
281
|
+
return trimTrailing(withScheme);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
function defaultUrlFor(runtimeId) {
|
|
285
|
+
const port = DEFAULT_PORTS[runtimeId];
|
|
286
|
+
return port ? `http://127.0.0.1:${port}` : "http://127.0.0.1:8080";
|
|
287
|
+
}
|
|
288
|
+
function deriveTargetId(runtimeId, existing) {
|
|
289
|
+
const base = runtimeId;
|
|
290
|
+
const taken = new Set(existing.map((e) => e.id));
|
|
291
|
+
if (!taken.has(base)) return base;
|
|
292
|
+
for (let i = 2; i < 1e3; i++) {
|
|
293
|
+
const candidate = `${base}-${i}`;
|
|
294
|
+
if (!taken.has(candidate)) return candidate;
|
|
295
|
+
}
|
|
296
|
+
return `${base}-${Date.now()}`;
|
|
297
|
+
}
|
|
298
|
+
function targetApiKeyRef(targetId, targets) {
|
|
299
|
+
const taken = new Set(targets.filter((target) => target.id !== targetId).map((target) => target.auth?.apiKeyRef));
|
|
300
|
+
const base = `target:${targetId}`;
|
|
301
|
+
let ref = base;
|
|
302
|
+
for (let suffix = 2; taken.has(ref); suffix += 1) ref = `${base}-${suffix}`;
|
|
303
|
+
return ref;
|
|
304
|
+
}
|
|
305
|
+
async function buildProbeContext(runtime, target) {
|
|
306
|
+
const probeCtx = {
|
|
307
|
+
credentialsPresent: credentialsPresent(),
|
|
308
|
+
httpTimeoutMs: 5e3
|
|
309
|
+
};
|
|
310
|
+
if (!runtime || !target || !targetRequiresAuth(target, runtime)) return probeCtx;
|
|
311
|
+
try {
|
|
312
|
+
const resolution = await openAuthStorage().resolveForTarget(resolveAuthTarget(target, runtime), {
|
|
313
|
+
includeFallback: false
|
|
314
|
+
});
|
|
315
|
+
if (resolution.apiKey) probeCtx.authToken = resolution.apiKey;
|
|
316
|
+
} catch {
|
|
317
|
+
}
|
|
318
|
+
return probeCtx;
|
|
319
|
+
}
|
|
320
|
+
function runtimeKnownModelsFor(runtimeId) {
|
|
321
|
+
return listKnownModelsForRuntime(runtimeId);
|
|
322
|
+
}
|
|
323
|
+
function catalogContextWindowFor(runtime, modelId) {
|
|
324
|
+
const catalogModel = getCatalogModelForRuntime(runtime.id, modelId);
|
|
325
|
+
if (typeof catalogModel?.contextWindow === "number" && catalogModel.contextWindow > 0) {
|
|
326
|
+
return catalogModel.contextWindow;
|
|
327
|
+
}
|
|
328
|
+
if (runtimeKnownModelsFor(runtime.id).includes(modelId) && runtime.defaultCapabilities.contextWindow > 0) {
|
|
329
|
+
return runtime.defaultCapabilities.contextWindow;
|
|
330
|
+
}
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
function validateResolvedModel(runtime, target, modelId, force, inventory) {
|
|
334
|
+
if (!modelId) return true;
|
|
335
|
+
const knownModels = runtimeKnownModelsFor(runtime.id);
|
|
336
|
+
const live = inventory.source === "probe" ? liveInventoryFor(target, inventory) : void 0;
|
|
337
|
+
const validation = validateModelChoice({ runtimeId: runtime.id, modelId, knownModels, live, force });
|
|
338
|
+
if (!validation.ok) {
|
|
339
|
+
process.stderr.write(`error: ${validation.reason}
|
|
340
|
+
`);
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
if (validation.warning) process.stderr.write(`warning: ${validation.warning}
|
|
344
|
+
`);
|
|
345
|
+
if (knownModels.length === 0 && live === void 0 && runtime.kind === "http") {
|
|
346
|
+
process.stderr.write(
|
|
347
|
+
`warning: could not verify model '${modelId}': ${target.url ?? `target '${target.id}'`} returned no model list; it is saved as written
|
|
348
|
+
`
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
return true;
|
|
352
|
+
}
|
|
353
|
+
function modelChoiceRefusal(runtime, target, modelId, inventory) {
|
|
354
|
+
const live = inventory.source === "probe" ? liveInventoryFor(target, inventory) : void 0;
|
|
355
|
+
const validation = validateModelChoice({
|
|
356
|
+
runtimeId: runtime.id,
|
|
357
|
+
modelId,
|
|
358
|
+
knownModels: runtimeKnownModelsFor(runtime.id),
|
|
359
|
+
live,
|
|
360
|
+
force: false
|
|
361
|
+
});
|
|
362
|
+
return validation.ok ? null : validation.reason;
|
|
363
|
+
}
|
|
364
|
+
function validateContextWindowOverride(runtime, modelId, contextWindow, force) {
|
|
365
|
+
if (contextWindow === void 0 || !modelId) return true;
|
|
366
|
+
const catalogMax = catalogContextWindowFor(runtime, modelId);
|
|
367
|
+
if (catalogMax === null || contextWindow <= catalogMax) return true;
|
|
368
|
+
const message = `--context-window ${contextWindow} exceeds catalog max ${catalogMax} for model '${modelId}'`;
|
|
369
|
+
if (!force) {
|
|
370
|
+
process.stderr.write(`error: ${message}. Use --force to override.
|
|
371
|
+
`);
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
process.stderr.write(`warning: ${message}
|
|
375
|
+
`);
|
|
376
|
+
return true;
|
|
377
|
+
}
|
|
378
|
+
async function runtimeProbe(runtime, target, authToken) {
|
|
379
|
+
if (typeof runtime.probe !== "function") return null;
|
|
380
|
+
try {
|
|
381
|
+
const context = await buildProbeContext(runtime, target);
|
|
382
|
+
return await runtime.probe(target, authToken === void 0 ? context : { ...context, authToken });
|
|
383
|
+
} catch (err) {
|
|
384
|
+
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
async function runtimeProbeModels(runtime, target, authToken) {
|
|
388
|
+
if (typeof runtime.probeModels !== "function") return [];
|
|
389
|
+
try {
|
|
390
|
+
const context = await buildProbeContext(runtime, target);
|
|
391
|
+
return await runtime.probeModels(target, authToken === void 0 ? context : { ...context, authToken });
|
|
392
|
+
} catch {
|
|
393
|
+
return [];
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
function applyTarget(settings, descriptor) {
|
|
397
|
+
const idx = settings.targets.findIndex((e) => e.id === descriptor.id);
|
|
398
|
+
if (idx >= 0) settings.targets[idx] = descriptor;
|
|
399
|
+
else settings.targets.push(descriptor);
|
|
400
|
+
}
|
|
401
|
+
function setOrchestratorPointer(settings, descriptor, model) {
|
|
402
|
+
const runtime = getRuntimeRegistry().get(descriptor.runtime);
|
|
403
|
+
if (!runtime) {
|
|
404
|
+
throw new Error(
|
|
405
|
+
`cannot use target '${descriptor.id}' as orchestrator target because runtime '${descriptor.runtime}' is not registered`
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
if (!isOrchestratorEligibleRuntime(runtime)) {
|
|
409
|
+
throw new Error(
|
|
410
|
+
`cannot use target '${descriptor.id}' as orchestrator target because runtime '${runtime.id}' is not an HTTP/native runtime`
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
settings.chat.target = descriptor.id;
|
|
414
|
+
settings.chat.model = model ?? descriptor.defaultModel ?? null;
|
|
415
|
+
}
|
|
416
|
+
function setWorkerDefaultPointer(settings, descriptor, model) {
|
|
417
|
+
settings.fleet.default.target = descriptor.id;
|
|
418
|
+
settings.fleet.default.model = model ?? descriptor.defaultModel ?? null;
|
|
419
|
+
}
|
|
420
|
+
function setBackgroundPointer(settings, descriptor, model) {
|
|
421
|
+
const runtime = getRuntimeRegistry().get(descriptor.runtime);
|
|
422
|
+
if (!runtime || !isOrchestratorEligibleRuntime(runtime)) {
|
|
423
|
+
throw new Error(
|
|
424
|
+
`cannot use target '${descriptor.id}' as background target because runtime '${descriptor.runtime}' is not an HTTP/native runtime`
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
settings.context.memory.target = descriptor.id;
|
|
428
|
+
settings.context.memory.model = model ?? descriptor.defaultModel ?? null;
|
|
429
|
+
}
|
|
430
|
+
function assertOrchestratorReplacementEligible(settings, descriptor) {
|
|
431
|
+
if (settings.chat.target !== descriptor.id && settings.context.memory.target !== descriptor.id) return;
|
|
432
|
+
const role = settings.chat.target === descriptor.id ? "orchestrator" : "background";
|
|
433
|
+
const runtime = getRuntimeRegistry().get(descriptor.runtime);
|
|
434
|
+
if (!runtime) {
|
|
435
|
+
throw new Error(
|
|
436
|
+
`cannot update ${role} target '${descriptor.id}' because runtime '${descriptor.runtime}' is not registered`
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
if (!isOrchestratorEligibleRuntime(runtime)) {
|
|
440
|
+
throw new Error(`cannot update ${role} target '${descriptor.id}' to non-HTTP/native runtime '${runtime.id}'`);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
function setWorkerProfilePointer(settings, name, descriptor, model) {
|
|
444
|
+
const trimmed = name.trim();
|
|
445
|
+
if (trimmed.length === 0) throw new Error("fleet profile name must be non-empty");
|
|
446
|
+
settings.fleet.profiles[trimmed] = {
|
|
447
|
+
target: descriptor.id,
|
|
448
|
+
model: model ?? descriptor.defaultModel ?? null,
|
|
449
|
+
thinkingLevel: "off"
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
function contextWindowUndiscovered(descriptor, probe) {
|
|
453
|
+
if (!probe?.ok) return false;
|
|
454
|
+
if (typeof descriptor.capabilities?.contextWindow === "number" && descriptor.capabilities.contextWindow > 0) {
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
const discovered = probeCapabilitiesForModel(
|
|
458
|
+
{
|
|
459
|
+
target: descriptor,
|
|
460
|
+
probeCapabilities: probe.discoveredCapabilities ?? null,
|
|
461
|
+
probeModelCapabilities: probe.modelCapabilities ?? null,
|
|
462
|
+
probeModelId: probe.capabilityModelId ?? null
|
|
463
|
+
},
|
|
464
|
+
descriptor.defaultModel
|
|
465
|
+
);
|
|
466
|
+
return !(typeof discovered?.contextWindow === "number" && discovered.contextWindow > 0);
|
|
467
|
+
}
|
|
468
|
+
function warnUndiscoveredContextWindow(descriptor, probe) {
|
|
469
|
+
if (!contextWindowUndiscovered(descriptor, probe)) return;
|
|
470
|
+
process.stdout.write(
|
|
471
|
+
" warning: the target reported no context window; Clio will use the runtime default as a guess. Set one with --context-window.\n"
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
function modelSupportsThinking(runtime, descriptor, probe) {
|
|
475
|
+
const discovered = probe ? probeCapabilitiesForModel(
|
|
476
|
+
{
|
|
477
|
+
target: descriptor,
|
|
478
|
+
probeCapabilities: probe.discoveredCapabilities ?? null,
|
|
479
|
+
probeModelCapabilities: probe.modelCapabilities ?? null,
|
|
480
|
+
probeModelId: probe.capabilityModelId ?? null
|
|
481
|
+
},
|
|
482
|
+
descriptor.defaultModel
|
|
483
|
+
) : null;
|
|
484
|
+
if (typeof discovered?.reasoning === "boolean") return discovered.reasoning;
|
|
485
|
+
if (typeof descriptor.capabilities?.reasoning === "boolean") return descriptor.capabilities.reasoning;
|
|
486
|
+
return runtime.defaultCapabilities.reasoning === true;
|
|
487
|
+
}
|
|
488
|
+
function probeReadings(probe) {
|
|
489
|
+
const readings = [];
|
|
490
|
+
if (probe.models && probe.models.length > 0) readings.push(`${probe.models.length} models`);
|
|
491
|
+
if (probe.serverVersion) readings.push(probe.serverVersion);
|
|
492
|
+
if (probe.discoveredCapabilities && Object.keys(probe.discoveredCapabilities).length > 0) {
|
|
493
|
+
readings.push("capabilities");
|
|
494
|
+
}
|
|
495
|
+
return readings;
|
|
496
|
+
}
|
|
497
|
+
function probeLines(descriptor, probe) {
|
|
498
|
+
const latency = probe.latencyMs !== void 0 ? ` (${probe.latencyMs}ms)` : "";
|
|
499
|
+
if (!probe.ok) {
|
|
500
|
+
if (descriptor.runtime === "antigravity-code") {
|
|
501
|
+
const next = probe.failureKind === "missing" ? "install the official Antigravity CLI and put `agy` on PATH" : probe.failureKind === "authentication" ? "run `agy` yourself and complete sign-in; Clio never reads or manages that session" : probe.failureKind === "unsupported-feature" ? "update `agy`; this integration requires its structured JSON model catalog" : "run `agy` directly to inspect setup, then re-run `clio-coder targets --probe`";
|
|
502
|
+
return [`probe failed${latency}: ${probe.error ?? "unknown"}`, ` ${next}`];
|
|
503
|
+
}
|
|
504
|
+
const where = descriptor.url ? ` ${descriptor.url}` : "";
|
|
505
|
+
return [
|
|
506
|
+
`probe failed${latency}:${where} ${probe.error ?? "unknown"}`,
|
|
507
|
+
` check the server is running and reachable, then re-run: clio-coder configure --id ${descriptor.id} --url <url>`
|
|
508
|
+
];
|
|
509
|
+
}
|
|
510
|
+
const readings = probeReadings(probe);
|
|
511
|
+
if (readings.length > 0) return [`probe ok${latency} ${readings.join(", ")}`];
|
|
512
|
+
return [
|
|
513
|
+
`probe reachable${latency}, but the target answered no model list and no version`,
|
|
514
|
+
" Clio cannot verify the model id or the context window from here and will send both as written.",
|
|
515
|
+
" re-read them once the server serves them with: clio-coder targets --probe"
|
|
516
|
+
];
|
|
517
|
+
}
|
|
518
|
+
function buildDescriptor(runtime, id, parts) {
|
|
519
|
+
const descriptor = { id, runtime: runtime.id };
|
|
520
|
+
if (parts.url) descriptor.url = parts.url;
|
|
521
|
+
if (parts.model) descriptor.defaultModel = parts.model;
|
|
522
|
+
const auth = {};
|
|
523
|
+
if (parts.apiKeyEnv) auth.apiKeyEnvVar = parts.apiKeyEnv;
|
|
524
|
+
if (parts.apiKeyRef) auth.apiKeyRef = parts.apiKeyRef;
|
|
525
|
+
if (parts.oauthProfile) auth.oauthProfile = parts.oauthProfile;
|
|
526
|
+
if (Object.keys(auth).length > 0) descriptor.auth = auth;
|
|
527
|
+
if (parts.gateway) descriptor.gateway = true;
|
|
528
|
+
if (parts.lifecycle) descriptor.lifecycle = parts.lifecycle;
|
|
529
|
+
const caps = {};
|
|
530
|
+
if (parts.contextWindow !== void 0) caps.contextWindow = parts.contextWindow;
|
|
531
|
+
if (parts.maxTokens !== void 0) caps.maxTokens = parts.maxTokens;
|
|
532
|
+
if (parts.reasoning !== void 0) caps.reasoning = parts.reasoning;
|
|
533
|
+
if (Object.keys(caps).length > 0) descriptor.capabilities = caps;
|
|
534
|
+
if (parts.lmstudio) descriptor.lmstudio = parts.lmstudio;
|
|
535
|
+
if (parts.litellm) descriptor.litellm = parts.litellm;
|
|
536
|
+
return descriptor;
|
|
537
|
+
}
|
|
538
|
+
function describeAuthStatus(runtime, target) {
|
|
539
|
+
const status = openAuthStorage().statusForTarget(
|
|
540
|
+
target ? resolveAuthTarget(target, runtime) : resolveRuntimeAuthTarget(runtime),
|
|
541
|
+
{ includeFallback: false }
|
|
542
|
+
);
|
|
543
|
+
if (!status.available) return "none stored";
|
|
544
|
+
if (status.source === "environment") return `environment${status.detail ? ` (${status.detail})` : ""}`;
|
|
545
|
+
if (status.source === "stored-api-key") return "stored api key";
|
|
546
|
+
if (status.source === "stored-oauth") return "stored oauth";
|
|
547
|
+
return status.source;
|
|
548
|
+
}
|
|
549
|
+
function advertisedModelIds(inventory) {
|
|
550
|
+
const ids = [...inventory.models];
|
|
551
|
+
for (const id of Object.keys(inventory.modelStates ?? {})) if (!ids.includes(id)) ids.push(id);
|
|
552
|
+
return ids;
|
|
553
|
+
}
|
|
554
|
+
function residentModelIds(modelStates) {
|
|
555
|
+
return Object.entries(modelStates ?? {}).filter(([, status]) => status.state === "loaded" || status.state === "loading").map(([id]) => id);
|
|
556
|
+
}
|
|
557
|
+
function liveInventoryFor(target, inventory) {
|
|
558
|
+
return {
|
|
559
|
+
targetId: target.id,
|
|
560
|
+
url: target.url,
|
|
561
|
+
models: advertisedModelIds(inventory),
|
|
562
|
+
resident: residentModelIds(inventory.modelStates)
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
async function resolveSupportedWireModels(runtime, target, existing, authToken) {
|
|
566
|
+
const known = listKnownModelsForRuntime(runtime.id);
|
|
567
|
+
const liveAuthoritative = runtime.externalAgentLoop?.modelCatalog === "live-authoritative";
|
|
568
|
+
if (known.length > 0 && !liveAuthoritative) return { models: known, source: "catalog" };
|
|
569
|
+
let probeError;
|
|
570
|
+
if (runtime.kind === "http" || liveAuthoritative) {
|
|
571
|
+
const probe = await runtimeProbe(runtime, target, authToken);
|
|
572
|
+
if (probe?.ok && probe.models && probe.models.length > 0) {
|
|
573
|
+
recordTargetModelSnapshot(target, probe.models, probe.modelLabels ? { modelLabels: probe.modelLabels } : {});
|
|
574
|
+
return {
|
|
575
|
+
models: [...probe.models],
|
|
576
|
+
source: "probe",
|
|
577
|
+
modelStates: probe.modelStates,
|
|
578
|
+
...probe.modelLabels ? { labels: probe.modelLabels } : {}
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
probeError = probe?.error;
|
|
582
|
+
const discovered = await runtimeProbeModels(runtime, target, authToken);
|
|
583
|
+
if (discovered.length > 0) {
|
|
584
|
+
recordTargetModelSnapshot(target, discovered);
|
|
585
|
+
return { models: discovered, source: "probe" };
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
const cached = readTargetModelSnapshot(target);
|
|
589
|
+
if (cached && cached.models.length > 0) {
|
|
590
|
+
return {
|
|
591
|
+
models: [...cached.models],
|
|
592
|
+
source: "cache",
|
|
593
|
+
...cached.modelLabels ? { labels: cached.modelLabels } : {},
|
|
594
|
+
...probeError ? { probeError } : {}
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
if (known.length > 0) return { models: known, source: "catalog", ...probeError ? { probeError } : {} };
|
|
598
|
+
if (existing?.wireModels && existing.wireModels.length > 0) {
|
|
599
|
+
recordTargetModelSnapshot(target, existing.wireModels);
|
|
600
|
+
return { models: [...existing.wireModels], source: "legacy" };
|
|
601
|
+
}
|
|
602
|
+
return { models: [], source: "none", ...probeError ? { probeError } : {} };
|
|
603
|
+
}
|
|
604
|
+
function inventoryGap(runtime, target) {
|
|
605
|
+
if (runtime.externalAgentLoop?.modelCatalog === "live-authoritative") {
|
|
606
|
+
return "Antigravity returned no live model catalog; run `agy` yourself, complete sign-in, then probe again";
|
|
607
|
+
}
|
|
608
|
+
if (runtime.kind !== "http") return `${runtime.id} does not list its models; type the id the provider documents`;
|
|
609
|
+
return `${target.url ?? runtime.id} answered no model list; type the id the server serves`;
|
|
610
|
+
}
|
|
611
|
+
var LOCAL_APP_RUNTIME_IDS = /* @__PURE__ */ new Set(["ollama-native", "lmstudio"]);
|
|
612
|
+
var PROTOCOL_COMPAT_RUNTIME_IDS = /* @__PURE__ */ new Set(["openai-compat", "anthropic-compat"]);
|
|
613
|
+
function runtimesForCategory(entries, category) {
|
|
614
|
+
switch (category) {
|
|
615
|
+
case "local-app":
|
|
616
|
+
return entries.filter((entry) => LOCAL_APP_RUNTIME_IDS.has(entry.runtimeId));
|
|
617
|
+
case "local-http":
|
|
618
|
+
return entries.filter((entry) => entry.group === "local-http" && !LOCAL_APP_RUNTIME_IDS.has(entry.runtimeId));
|
|
619
|
+
case "chatgpt":
|
|
620
|
+
return entries.filter((entry) => entry.runtimeId === "openai-codex");
|
|
621
|
+
case "cloud-api": {
|
|
622
|
+
const byLabel = (a, b) => a.label.localeCompare(b.label) || a.runtimeId.localeCompare(b.runtimeId);
|
|
623
|
+
const named = entries.filter((entry) => entry.group === "cloud-api").slice().sort(byLabel);
|
|
624
|
+
const compat = entries.filter((entry) => PROTOCOL_COMPAT_RUNTIME_IDS.has(entry.runtimeId)).map((entry) => ({ ...entry, group: "cloud-api" })).sort(byLabel);
|
|
625
|
+
return [...named, ...compat];
|
|
626
|
+
}
|
|
627
|
+
case "all":
|
|
628
|
+
return entries.slice();
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
function railPrefix(plain) {
|
|
632
|
+
return plain ? " " : `${source_default.cyan("\u2502")} `;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// src/cli/select.ts
|
|
636
|
+
init_esm_shims();
|
|
637
|
+
import { emitKeypressEvents } from "node:readline";
|
|
638
|
+
function canSelect(input2 = process.stdin, output3 = process.stdout) {
|
|
639
|
+
return Boolean(input2.isTTY && output3.isTTY && typeof input2.setRawMode === "function" && process.env.TERM !== "dumb");
|
|
640
|
+
}
|
|
641
|
+
var ESC = "\x1B";
|
|
642
|
+
var CURSOR_HIDE = `${ESC}[?25l`;
|
|
643
|
+
var CURSOR_SHOW = `${ESC}[?25h`;
|
|
644
|
+
var ANSI_PATTERN = new RegExp(`${ESC}\\[[0-9;?]*[A-Za-z]`, "gu");
|
|
645
|
+
function printedWidth(text) {
|
|
646
|
+
return text.replace(ANSI_PATTERN, "").length;
|
|
647
|
+
}
|
|
648
|
+
function headingLines(heading) {
|
|
649
|
+
if (heading === void 0) return [];
|
|
650
|
+
return typeof heading === "string" ? [heading] : [...heading];
|
|
651
|
+
}
|
|
652
|
+
async function readKeys(input2, output3, hideCursor, onStart, onKey, onEnd) {
|
|
653
|
+
const wasRaw = input2.isRaw === true;
|
|
654
|
+
emitKeypressEvents(input2);
|
|
655
|
+
input2.setRawMode(true);
|
|
656
|
+
input2.resume();
|
|
657
|
+
if (hideCursor) output3.write(CURSOR_HIDE);
|
|
658
|
+
onStart();
|
|
659
|
+
try {
|
|
660
|
+
return await new Promise((resolve) => {
|
|
661
|
+
const finish2 = (result) => {
|
|
662
|
+
input2.off("keypress", handleKey);
|
|
663
|
+
input2.off("end", handleEnd);
|
|
664
|
+
input2.off("close", handleEnd);
|
|
665
|
+
resolve(result);
|
|
666
|
+
};
|
|
667
|
+
function handleEnd() {
|
|
668
|
+
finish2(onEnd());
|
|
669
|
+
}
|
|
670
|
+
function handleKey(str, key) {
|
|
671
|
+
onKey(str, key ?? {}, finish2);
|
|
672
|
+
}
|
|
673
|
+
input2.on("keypress", handleKey);
|
|
674
|
+
input2.once("end", handleEnd);
|
|
675
|
+
input2.once("close", handleEnd);
|
|
676
|
+
});
|
|
677
|
+
} finally {
|
|
678
|
+
if (hideCursor) output3.write(CURSOR_SHOW);
|
|
679
|
+
if (!wasRaw) input2.setRawMode(false);
|
|
680
|
+
input2.pause();
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
function makeFrame(output3) {
|
|
684
|
+
let drawn = 0;
|
|
685
|
+
return {
|
|
686
|
+
draw(lines) {
|
|
687
|
+
if (drawn > 0) output3.write(`${ESC}[${drawn}A${ESC}[0J`);
|
|
688
|
+
output3.write(`${lines.join("\n")}
|
|
689
|
+
`);
|
|
690
|
+
drawn = lines.length;
|
|
691
|
+
},
|
|
692
|
+
erase() {
|
|
693
|
+
if (drawn > 0) output3.write(`${ESC}[${drawn}A${ESC}[0J`);
|
|
694
|
+
drawn = 0;
|
|
695
|
+
},
|
|
696
|
+
drawn: () => drawn
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
function choiceRows(spec, index, windowStart, viewport) {
|
|
700
|
+
const { choices, rail, railWidth, output: output3, markerWidth, marker } = spec;
|
|
701
|
+
const room = terminalColumns(output3) - railWidth;
|
|
702
|
+
const hasHints = choices.some((choice) => choice.hint !== void 0);
|
|
703
|
+
const labelWidth = Math.min(30, Math.max(...choices.map((choice) => choice.label.length)));
|
|
704
|
+
const hintRoom = room - markerWidth - labelWidth - 2;
|
|
705
|
+
const end = Math.min(choices.length, windowStart + viewport);
|
|
706
|
+
const lines = [];
|
|
707
|
+
if (windowStart > 0) lines.push(`${rail}${source_default.dim(` \u2191 ${windowStart} more`)}`);
|
|
708
|
+
for (let position = windowStart; position < end; position++) {
|
|
709
|
+
const choice = choices[position];
|
|
710
|
+
if (choice === void 0) continue;
|
|
711
|
+
const active = position === index;
|
|
712
|
+
const aligned = hasHints && hintRoom >= 12;
|
|
713
|
+
const label = aligned ? column(choice.label, labelWidth) : truncate(choice.label, room - markerWidth);
|
|
714
|
+
const hint = aligned && choice.hint !== void 0 ? truncate(choice.hint, hintRoom) : "";
|
|
715
|
+
const styledLabel = active ? source_default.cyan.bold(label) : label;
|
|
716
|
+
lines.push(`${rail}${marker(position)}${styledLabel}${hint.length > 0 ? ` ${source_default.dim(hint)}` : ""}`.trimEnd());
|
|
717
|
+
}
|
|
718
|
+
if (end < choices.length) lines.push(`${rail}${source_default.dim(` \u2193 ${choices.length - end} more`)}`);
|
|
719
|
+
return lines;
|
|
720
|
+
}
|
|
721
|
+
function viewportFor(output3, overhead, total, requested) {
|
|
722
|
+
if (requested !== void 0) return Math.max(1, Math.min(total, requested));
|
|
723
|
+
const rows = typeof output3.rows === "number" && output3.rows > 0 ? output3.rows : 24;
|
|
724
|
+
return Math.max(3, Math.min(total, rows - overhead));
|
|
725
|
+
}
|
|
726
|
+
async function promptSelect(options) {
|
|
727
|
+
const input2 = options.input ?? process.stdin;
|
|
728
|
+
const output3 = options.output ?? process.stdout;
|
|
729
|
+
let choices = options.choices;
|
|
730
|
+
if (choices.length === 0) return { kind: "back" };
|
|
731
|
+
const rail = options.railPrefix ?? "";
|
|
732
|
+
const railWidth = 3;
|
|
733
|
+
const head = headingLines(options.heading);
|
|
734
|
+
const frame = makeFrame(output3);
|
|
735
|
+
let index = Math.min(Math.max(options.initialIndex ?? 0, 0), choices.length - 1);
|
|
736
|
+
let windowStart = 0;
|
|
737
|
+
let query = "";
|
|
738
|
+
const filter = () => {
|
|
739
|
+
choices = options.choices.filter((choice) => choice.label.toLowerCase().includes(query.toLowerCase()));
|
|
740
|
+
index = 0;
|
|
741
|
+
windowStart = 0;
|
|
742
|
+
render();
|
|
743
|
+
};
|
|
744
|
+
const render = () => {
|
|
745
|
+
const viewport = viewportFor(output3, head.length + (options.searchable ? 6 : 5), choices.length, options.maxVisible);
|
|
746
|
+
if (index < windowStart) windowStart = index;
|
|
747
|
+
else if (index >= windowStart + viewport) windowStart = index - viewport + 1;
|
|
748
|
+
windowStart = Math.max(0, Math.min(windowStart, choices.length - viewport));
|
|
749
|
+
const lines = [];
|
|
750
|
+
for (const line of head) lines.push(`${rail}${line}`.trimEnd());
|
|
751
|
+
if (head.length > 0) lines.push(rail.trimEnd());
|
|
752
|
+
if (options.searchable)
|
|
753
|
+
lines.push(`${rail}${truncate(`Filter: ${query || "(type to search)"}`, terminalColumns(output3) - railWidth)}`);
|
|
754
|
+
if (choices.length === 0) lines.push(`${rail}No matching models`);
|
|
755
|
+
lines.push(
|
|
756
|
+
...choiceRows(
|
|
757
|
+
{
|
|
758
|
+
choices,
|
|
759
|
+
rail,
|
|
760
|
+
railWidth,
|
|
761
|
+
output: output3,
|
|
762
|
+
markerWidth: 2,
|
|
763
|
+
marker: (position) => `${position === index ? source_default.cyan("\u276F") : " "} `
|
|
764
|
+
},
|
|
765
|
+
index,
|
|
766
|
+
windowStart,
|
|
767
|
+
viewport
|
|
768
|
+
)
|
|
769
|
+
);
|
|
770
|
+
lines.push(rail.trimEnd());
|
|
771
|
+
const legend = ["\u2191/\u2193 move", "enter select"];
|
|
772
|
+
if (options.backLabel !== void 0 && options.backLabel !== "quit") legend.push(`esc ${options.backLabel}`);
|
|
773
|
+
if (options.searchable) legend.push("type to filter", "ctrl-u clear", "ctrl-c quit");
|
|
774
|
+
else legend.push(options.backLabel === "quit" ? "esc or q quit" : "q quit");
|
|
775
|
+
lines.push(`${rail}${source_default.dim(legend.join(" \xB7 "))}`);
|
|
776
|
+
frame.draw(lines);
|
|
777
|
+
};
|
|
778
|
+
const result = await readKeys(
|
|
779
|
+
input2,
|
|
780
|
+
output3,
|
|
781
|
+
true,
|
|
782
|
+
render,
|
|
783
|
+
(str, key, finish2) => {
|
|
784
|
+
if (key.ctrl && (key.name === "c" || key.name === "d")) {
|
|
785
|
+
finish2({ kind: "quit" });
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
if (options.searchable) {
|
|
789
|
+
if (key.ctrl && key.name === "u") {
|
|
790
|
+
query = "";
|
|
791
|
+
filter();
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
if (key.name === "backspace") {
|
|
795
|
+
query = query.slice(0, -1);
|
|
796
|
+
filter();
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
if (!key.ctrl && !key.meta && str?.length === 1 && str >= " " && str !== "\x7F") {
|
|
800
|
+
query += str;
|
|
801
|
+
filter();
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
if (choices.length === 0 && !["escape", "left"].includes(key.name ?? "")) return;
|
|
805
|
+
}
|
|
806
|
+
switch (key.name) {
|
|
807
|
+
case "up":
|
|
808
|
+
case "k":
|
|
809
|
+
index = (index - 1 + choices.length) % choices.length;
|
|
810
|
+
render();
|
|
811
|
+
return;
|
|
812
|
+
case "down":
|
|
813
|
+
case "j":
|
|
814
|
+
case "tab":
|
|
815
|
+
index = (index + 1) % choices.length;
|
|
816
|
+
render();
|
|
817
|
+
return;
|
|
818
|
+
case "pageup":
|
|
819
|
+
index = Math.max(0, index - 5);
|
|
820
|
+
render();
|
|
821
|
+
return;
|
|
822
|
+
case "pagedown":
|
|
823
|
+
index = Math.min(choices.length - 1, index + 5);
|
|
824
|
+
render();
|
|
825
|
+
return;
|
|
826
|
+
case "home":
|
|
827
|
+
index = 0;
|
|
828
|
+
render();
|
|
829
|
+
return;
|
|
830
|
+
case "end":
|
|
831
|
+
index = choices.length - 1;
|
|
832
|
+
render();
|
|
833
|
+
return;
|
|
834
|
+
case "return":
|
|
835
|
+
case "enter":
|
|
836
|
+
case "space": {
|
|
837
|
+
const choice = choices[index];
|
|
838
|
+
finish2(choice === void 0 ? { kind: "back" } : { kind: "selected", value: choice.value });
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
case "escape":
|
|
842
|
+
case "left":
|
|
843
|
+
case "backspace":
|
|
844
|
+
finish2({ kind: "back" });
|
|
845
|
+
return;
|
|
846
|
+
case "q":
|
|
847
|
+
finish2({ kind: "quit" });
|
|
848
|
+
return;
|
|
849
|
+
default: {
|
|
850
|
+
const digit = Number.parseInt(key.name ?? "", 10);
|
|
851
|
+
if (Number.isInteger(digit) && digit >= 1 && digit <= choices.length) {
|
|
852
|
+
index = digit - 1;
|
|
853
|
+
render();
|
|
854
|
+
const choice = choices[index];
|
|
855
|
+
if (choice !== void 0) finish2({ kind: "selected", value: choice.value });
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
},
|
|
860
|
+
() => ({ kind: "quit" })
|
|
861
|
+
);
|
|
862
|
+
if (options.clearOnExit) frame.erase();
|
|
863
|
+
return result;
|
|
864
|
+
}
|
|
865
|
+
async function promptMultiSelect(options) {
|
|
866
|
+
const input2 = options.input ?? process.stdin;
|
|
867
|
+
const output3 = options.output ?? process.stdout;
|
|
868
|
+
const choices = options.choices;
|
|
869
|
+
if (choices.length === 0) return { kind: "selected", values: [] };
|
|
870
|
+
const rail = options.railPrefix ?? "";
|
|
871
|
+
const railWidth = 3;
|
|
872
|
+
const head = headingLines(options.heading);
|
|
873
|
+
const frame = makeFrame(output3);
|
|
874
|
+
const checked = choices.map((choice) => choice.checked === true);
|
|
875
|
+
let index = 0;
|
|
876
|
+
let windowStart = 0;
|
|
877
|
+
const render = () => {
|
|
878
|
+
const viewport = viewportFor(output3, head.length + 5, choices.length, options.maxVisible);
|
|
879
|
+
if (index < windowStart) windowStart = index;
|
|
880
|
+
else if (index >= windowStart + viewport) windowStart = index - viewport + 1;
|
|
881
|
+
windowStart = Math.max(0, Math.min(windowStart, choices.length - viewport));
|
|
882
|
+
const lines = [];
|
|
883
|
+
for (const line of head) lines.push(`${rail}${line}`.trimEnd());
|
|
884
|
+
if (head.length > 0) lines.push(rail.trimEnd());
|
|
885
|
+
lines.push(
|
|
886
|
+
...choiceRows(
|
|
887
|
+
{
|
|
888
|
+
choices,
|
|
889
|
+
rail,
|
|
890
|
+
railWidth,
|
|
891
|
+
output: output3,
|
|
892
|
+
markerWidth: 4,
|
|
893
|
+
marker: (position) => {
|
|
894
|
+
const cursor = position === index ? source_default.cyan("\u276F") : " ";
|
|
895
|
+
const box = checked[position] === true ? source_default.green("\u25C9") : source_default.dim("\u25CB");
|
|
896
|
+
return `${cursor} ${box} `;
|
|
897
|
+
}
|
|
898
|
+
},
|
|
899
|
+
index,
|
|
900
|
+
windowStart,
|
|
901
|
+
viewport
|
|
902
|
+
)
|
|
903
|
+
);
|
|
904
|
+
lines.push(rail.trimEnd());
|
|
905
|
+
const legend = ["\u2191/\u2193 move", "space toggle", `enter ${options.confirmLabel ?? "confirm"}`];
|
|
906
|
+
if (options.backLabel !== void 0) legend.push(`esc ${options.backLabel}`);
|
|
907
|
+
lines.push(`${rail}${source_default.dim(legend.join(" \xB7 "))}`);
|
|
908
|
+
frame.draw(lines);
|
|
909
|
+
};
|
|
910
|
+
const result = await readKeys(
|
|
911
|
+
input2,
|
|
912
|
+
output3,
|
|
913
|
+
true,
|
|
914
|
+
render,
|
|
915
|
+
(_str, key, finish2) => {
|
|
916
|
+
if (key.ctrl && (key.name === "c" || key.name === "d")) {
|
|
917
|
+
finish2({ kind: "quit" });
|
|
918
|
+
return;
|
|
919
|
+
}
|
|
920
|
+
switch (key.name) {
|
|
921
|
+
case "up":
|
|
922
|
+
case "k":
|
|
923
|
+
index = (index - 1 + choices.length) % choices.length;
|
|
924
|
+
render();
|
|
925
|
+
return;
|
|
926
|
+
case "down":
|
|
927
|
+
case "j":
|
|
928
|
+
case "tab":
|
|
929
|
+
index = (index + 1) % choices.length;
|
|
930
|
+
render();
|
|
931
|
+
return;
|
|
932
|
+
case "home":
|
|
933
|
+
index = 0;
|
|
934
|
+
render();
|
|
935
|
+
return;
|
|
936
|
+
case "end":
|
|
937
|
+
index = choices.length - 1;
|
|
938
|
+
render();
|
|
939
|
+
return;
|
|
940
|
+
case "space":
|
|
941
|
+
checked[index] = checked[index] !== true;
|
|
942
|
+
render();
|
|
943
|
+
return;
|
|
944
|
+
case "a":
|
|
945
|
+
{
|
|
946
|
+
const turnOn = checked.some((value) => !value);
|
|
947
|
+
checked.fill(turnOn);
|
|
948
|
+
}
|
|
949
|
+
render();
|
|
950
|
+
return;
|
|
951
|
+
case "return":
|
|
952
|
+
case "enter":
|
|
953
|
+
finish2({
|
|
954
|
+
kind: "selected",
|
|
955
|
+
values: choices.filter((_choice, position) => checked[position] === true).map((choice) => choice.value)
|
|
956
|
+
});
|
|
957
|
+
return;
|
|
958
|
+
case "escape":
|
|
959
|
+
case "left":
|
|
960
|
+
finish2({ kind: "back" });
|
|
961
|
+
return;
|
|
962
|
+
default: {
|
|
963
|
+
const digit = Number.parseInt(key.name ?? "", 10);
|
|
964
|
+
if (Number.isInteger(digit) && digit >= 1 && digit <= choices.length) {
|
|
965
|
+
index = digit - 1;
|
|
966
|
+
checked[index] = checked[index] !== true;
|
|
967
|
+
render();
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
},
|
|
972
|
+
() => ({ kind: "quit" })
|
|
973
|
+
);
|
|
974
|
+
if (options.clearOnExit) frame.erase();
|
|
975
|
+
return result;
|
|
976
|
+
}
|
|
977
|
+
function typedText(str, key) {
|
|
978
|
+
if (key.ctrl === true || key.meta === true) return null;
|
|
979
|
+
if (typeof str !== "string" || str.length === 0) return null;
|
|
980
|
+
if (/[\u0000-\u001F\u007F]/u.test(str)) return null;
|
|
981
|
+
return str;
|
|
982
|
+
}
|
|
983
|
+
async function promptText(options) {
|
|
984
|
+
const input2 = options.input ?? process.stdin;
|
|
985
|
+
const output3 = options.output ?? process.stdout;
|
|
986
|
+
const rail = options.railPrefix ?? "";
|
|
987
|
+
const railWidth = printedWidth(rail);
|
|
988
|
+
const head = headingLines(options.heading);
|
|
989
|
+
const frame = makeFrame(output3);
|
|
990
|
+
let value = options.initial ?? "";
|
|
991
|
+
let caret = value.length;
|
|
992
|
+
let error = null;
|
|
993
|
+
let below = 0;
|
|
994
|
+
let parked = false;
|
|
995
|
+
const render = () => {
|
|
996
|
+
if (parked) {
|
|
997
|
+
output3.write(`\r${below > 0 ? `${ESC}[${below}B` : ""}`);
|
|
998
|
+
parked = false;
|
|
999
|
+
}
|
|
1000
|
+
const room = Math.max(8, terminalColumns(output3) - railWidth - 2);
|
|
1001
|
+
const shown = options.mask === true ? "\u2022".repeat(value.length) : value;
|
|
1002
|
+
const lines = [];
|
|
1003
|
+
for (const line of head) lines.push(`${rail}${line}`.trimEnd());
|
|
1004
|
+
if (head.length > 0) lines.push(rail.trimEnd());
|
|
1005
|
+
const fieldIndex = lines.length;
|
|
1006
|
+
lines.push(`${rail}${source_default.cyan("\u276F")} ${truncate(shown, room)}`);
|
|
1007
|
+
if (error !== null) lines.push(`${rail}${source_default.yellow(truncate(error, room))}`);
|
|
1008
|
+
else if (options.hint !== void 0) lines.push(`${rail}${source_default.dim(truncate(options.hint, room))}`);
|
|
1009
|
+
lines.push(rail.trimEnd());
|
|
1010
|
+
const legend = ["enter accept"];
|
|
1011
|
+
if (options.backLabel !== void 0) legend.push(`esc ${options.backLabel}`);
|
|
1012
|
+
legend.push("ctrl-c quit");
|
|
1013
|
+
lines.push(`${rail}${source_default.dim(legend.join(" \xB7 "))}`);
|
|
1014
|
+
frame.draw(lines);
|
|
1015
|
+
below = lines.length - fieldIndex;
|
|
1016
|
+
const columnOffset = railWidth + 2 + Math.min(caret, room);
|
|
1017
|
+
output3.write(`${ESC}[${below}A\r${columnOffset > 0 ? `${ESC}[${columnOffset}C` : ""}`);
|
|
1018
|
+
parked = true;
|
|
1019
|
+
};
|
|
1020
|
+
const unpark = () => {
|
|
1021
|
+
if (!parked) return;
|
|
1022
|
+
output3.write(`\r${below > 0 ? `${ESC}[${below}B` : ""}`);
|
|
1023
|
+
parked = false;
|
|
1024
|
+
};
|
|
1025
|
+
const result = await readKeys(
|
|
1026
|
+
input2,
|
|
1027
|
+
output3,
|
|
1028
|
+
false,
|
|
1029
|
+
render,
|
|
1030
|
+
(str, key, finish2) => {
|
|
1031
|
+
if (key.ctrl === true) {
|
|
1032
|
+
switch (key.name) {
|
|
1033
|
+
case "c":
|
|
1034
|
+
case "d":
|
|
1035
|
+
unpark();
|
|
1036
|
+
finish2({ kind: "quit" });
|
|
1037
|
+
return;
|
|
1038
|
+
case "a":
|
|
1039
|
+
caret = 0;
|
|
1040
|
+
render();
|
|
1041
|
+
return;
|
|
1042
|
+
case "e":
|
|
1043
|
+
caret = value.length;
|
|
1044
|
+
render();
|
|
1045
|
+
return;
|
|
1046
|
+
case "u":
|
|
1047
|
+
value = value.slice(caret);
|
|
1048
|
+
caret = 0;
|
|
1049
|
+
render();
|
|
1050
|
+
return;
|
|
1051
|
+
case "k":
|
|
1052
|
+
value = value.slice(0, caret);
|
|
1053
|
+
render();
|
|
1054
|
+
return;
|
|
1055
|
+
case "w": {
|
|
1056
|
+
const head_ = value.slice(0, caret).replace(/\S+\s*$/u, "");
|
|
1057
|
+
value = head_ + value.slice(caret);
|
|
1058
|
+
caret = head_.length;
|
|
1059
|
+
render();
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
default:
|
|
1063
|
+
return;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
switch (key.name) {
|
|
1067
|
+
case "escape":
|
|
1068
|
+
unpark();
|
|
1069
|
+
finish2({ kind: "back" });
|
|
1070
|
+
return;
|
|
1071
|
+
case "return":
|
|
1072
|
+
case "enter": {
|
|
1073
|
+
const answer = value.trim();
|
|
1074
|
+
const reason = options.validate?.(answer) ?? null;
|
|
1075
|
+
if (reason !== null) {
|
|
1076
|
+
error = reason;
|
|
1077
|
+
render();
|
|
1078
|
+
return;
|
|
1079
|
+
}
|
|
1080
|
+
unpark();
|
|
1081
|
+
finish2({ kind: "value", value: answer });
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
case "backspace":
|
|
1085
|
+
if (caret > 0) {
|
|
1086
|
+
value = value.slice(0, caret - 1) + value.slice(caret);
|
|
1087
|
+
caret -= 1;
|
|
1088
|
+
error = null;
|
|
1089
|
+
render();
|
|
1090
|
+
}
|
|
1091
|
+
return;
|
|
1092
|
+
case "delete":
|
|
1093
|
+
if (caret < value.length) {
|
|
1094
|
+
value = value.slice(0, caret) + value.slice(caret + 1);
|
|
1095
|
+
error = null;
|
|
1096
|
+
render();
|
|
1097
|
+
}
|
|
1098
|
+
return;
|
|
1099
|
+
case "left":
|
|
1100
|
+
caret = Math.max(0, caret - 1);
|
|
1101
|
+
render();
|
|
1102
|
+
return;
|
|
1103
|
+
case "right":
|
|
1104
|
+
caret = Math.min(value.length, caret + 1);
|
|
1105
|
+
render();
|
|
1106
|
+
return;
|
|
1107
|
+
case "home":
|
|
1108
|
+
caret = 0;
|
|
1109
|
+
render();
|
|
1110
|
+
return;
|
|
1111
|
+
case "end":
|
|
1112
|
+
caret = value.length;
|
|
1113
|
+
render();
|
|
1114
|
+
return;
|
|
1115
|
+
default: {
|
|
1116
|
+
const typed = typedText(str, key);
|
|
1117
|
+
if (typed === null) return;
|
|
1118
|
+
value = value.slice(0, caret) + typed + value.slice(caret);
|
|
1119
|
+
caret += typed.length;
|
|
1120
|
+
error = null;
|
|
1121
|
+
render();
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
},
|
|
1125
|
+
() => {
|
|
1126
|
+
unpark();
|
|
1127
|
+
return { kind: "quit" };
|
|
1128
|
+
}
|
|
1129
|
+
);
|
|
1130
|
+
if (options.clearOnExit) frame.erase();
|
|
1131
|
+
return result;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
// src/cli/configure-interop.ts
|
|
1135
|
+
function describe(proposal) {
|
|
1136
|
+
const lines = [
|
|
1137
|
+
"",
|
|
1138
|
+
`${proposal.label} is installed and not configured as a delegation agent.`,
|
|
1139
|
+
"",
|
|
1140
|
+
renderProposalEntry(proposal),
|
|
1141
|
+
"",
|
|
1142
|
+
`projectContext stays ${INHERITED_PROJECT_CONTEXT}: this agent receives your task text, never the project projection.`,
|
|
1143
|
+
`toolGovernance is clio-coder-policy: its tool calls are gated by Clio safety.`
|
|
1144
|
+
];
|
|
1145
|
+
if (proposal.needsNetworkInstall) {
|
|
1146
|
+
lines.push(`The ACP adapter is not installed locally; npx fetches it the first time you delegate.`);
|
|
1147
|
+
}
|
|
1148
|
+
return `${lines.join("\n")}
|
|
1149
|
+
`;
|
|
1150
|
+
}
|
|
1151
|
+
function proposalHint(proposal) {
|
|
1152
|
+
const command = [proposal.entry.command, ...proposal.entry.args ?? []].join(" ");
|
|
1153
|
+
return proposal.needsNetworkInstall ? `${command} (npx fetches the adapter on first use)` : command;
|
|
1154
|
+
}
|
|
1155
|
+
async function reviewInteropAgents(io) {
|
|
1156
|
+
const report = await detectInteropAgents({ cwd: process.cwd(), probeVersion: true });
|
|
1157
|
+
const proposals = interopProposals(report, readSettings());
|
|
1158
|
+
if (proposals.length === 0) {
|
|
1159
|
+
if (!io.quiet) output.write("No new coding agents to connect.\n");
|
|
1160
|
+
return { code: 0, wired: [], back: false };
|
|
1161
|
+
}
|
|
1162
|
+
const streams = io.streams;
|
|
1163
|
+
const interactive = streams !== void 0 && canSelect(streams.in, streams.out);
|
|
1164
|
+
if (!interactive && io.rl === null) {
|
|
1165
|
+
for (const proposal of proposals) output.write(describe(proposal));
|
|
1166
|
+
output.write("\nRun `clio-coder configure --interop` on a terminal to connect any of these.\n");
|
|
1167
|
+
return { code: 0, wired: [], back: false };
|
|
1168
|
+
}
|
|
1169
|
+
const accepted = [];
|
|
1170
|
+
const declined = [];
|
|
1171
|
+
if (interactive && streams) {
|
|
1172
|
+
const presenter = io.presenter ?? createLifecyclePresenter({ stream: streams.out });
|
|
1173
|
+
const rail = io.rail ?? railPrefix(presenter.isPlain());
|
|
1174
|
+
presenter.note(
|
|
1175
|
+
`Clio found ${proposals.length === 1 ? "one coding agent" : `${proposals.length} coding agents`} it can delegate to. A peer receives your task text and never the project projection, and its tool calls are gated by Clio safety.`
|
|
1176
|
+
);
|
|
1177
|
+
const result = await promptMultiSelect({
|
|
1178
|
+
heading: ["", source_default.bold("Delegate to any of these?")],
|
|
1179
|
+
choices: proposals.map((proposal) => ({
|
|
1180
|
+
value: proposal.kind,
|
|
1181
|
+
label: proposal.label,
|
|
1182
|
+
hint: proposalHint(proposal)
|
|
1183
|
+
})),
|
|
1184
|
+
railPrefix: rail,
|
|
1185
|
+
backLabel: "back",
|
|
1186
|
+
confirmLabel: "confirm",
|
|
1187
|
+
clearOnExit: true,
|
|
1188
|
+
input: streams.in,
|
|
1189
|
+
output: streams.out
|
|
1190
|
+
});
|
|
1191
|
+
if (result.kind === "back") return { code: 0, wired: [], back: true };
|
|
1192
|
+
if (result.kind === "quit") return { code: 0, wired: [], back: false };
|
|
1193
|
+
for (const proposal of proposals) {
|
|
1194
|
+
(result.values.includes(proposal.kind) ? accepted : declined).push(proposal.kind);
|
|
1195
|
+
}
|
|
1196
|
+
} else if (io.rl !== null) {
|
|
1197
|
+
for (const proposal of proposals) {
|
|
1198
|
+
output.write(describe(proposal));
|
|
1199
|
+
const yes = await askYesNo(io.rl, `Add ${proposal.label} as delegation agent \`${proposal.entry.id}\`?`, false);
|
|
1200
|
+
(yes ? accepted : declined).push(proposal.kind);
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
const wired = [];
|
|
1204
|
+
if (accepted.length > 0) {
|
|
1205
|
+
const result = acceptInteropAgents(accepted, report);
|
|
1206
|
+
for (const diagnostic of result.diagnostics) {
|
|
1207
|
+
if (io.presenter) io.presenter.warn(diagnostic);
|
|
1208
|
+
else output.write(`note: ${diagnostic}
|
|
1209
|
+
`);
|
|
1210
|
+
}
|
|
1211
|
+
for (const id of result.wired) {
|
|
1212
|
+
wired.push(id);
|
|
1213
|
+
if (!io.presenter) printOk(`delegation agent ${id} added; use \`/delegate ${id} <task>\``);
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
if (declined.length > 0) {
|
|
1217
|
+
declineInteropAgents(declined, report);
|
|
1218
|
+
const line = `Declined ${declined.join(", ")}; Clio stays quiet about them until their version or path changes.`;
|
|
1219
|
+
if (io.presenter) io.presenter.note(line);
|
|
1220
|
+
else output.write(`${line}
|
|
1221
|
+
`);
|
|
1222
|
+
}
|
|
1223
|
+
return { code: 0, wired, back: false };
|
|
1224
|
+
}
|
|
1225
|
+
async function runInteropReview(io) {
|
|
1226
|
+
return (await reviewInteropAgents(io)).code;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
// src/cli/configure-layout.ts
|
|
1230
|
+
init_esm_shims();
|
|
1231
|
+
function maxLength(values) {
|
|
1232
|
+
return values.reduce((widest, value) => Math.max(widest, value.length), 0);
|
|
1233
|
+
}
|
|
1234
|
+
var CONFIGURE_CATEGORY_CHOICES = [
|
|
1235
|
+
{
|
|
1236
|
+
category: "local-app",
|
|
1237
|
+
label: "Local app",
|
|
1238
|
+
summary: "Ollama or LM Studio (recommended for new users)",
|
|
1239
|
+
aliases: ["local"]
|
|
1240
|
+
},
|
|
1241
|
+
{
|
|
1242
|
+
category: "local-http",
|
|
1243
|
+
label: "Local HTTP server",
|
|
1244
|
+
summary: "llama.cpp / vLLM / SGLang / OpenAI/Anthropic-compatible",
|
|
1245
|
+
aliases: ["http"]
|
|
1246
|
+
},
|
|
1247
|
+
{
|
|
1248
|
+
category: "chatgpt",
|
|
1249
|
+
label: "ChatGPT plan",
|
|
1250
|
+
summary: "Plus or Pro via Codex OAuth",
|
|
1251
|
+
aliases: ["codex"]
|
|
1252
|
+
},
|
|
1253
|
+
{
|
|
1254
|
+
category: "cloud-api",
|
|
1255
|
+
label: "Cloud API key",
|
|
1256
|
+
summary: "Anthropic, OpenAI, OpenRouter, Groq, Google, DeepSeek, Mistral, Bedrock, or any OpenAI/Anthropic-compatible endpoint (e.g. Inception)",
|
|
1257
|
+
aliases: ["cloud"]
|
|
1258
|
+
},
|
|
1259
|
+
{
|
|
1260
|
+
category: "all",
|
|
1261
|
+
label: "All runtimes",
|
|
1262
|
+
summary: "advanced (full list)",
|
|
1263
|
+
aliases: ["a"]
|
|
1264
|
+
}
|
|
1265
|
+
];
|
|
1266
|
+
function formatCategoryMenu(width) {
|
|
1267
|
+
const leftWidth = maxLength(CONFIGURE_CATEGORY_CHOICES.map((choice, index) => `${index + 1}. ${choice.label}`)) + 2;
|
|
1268
|
+
const lines = [];
|
|
1269
|
+
for (const [index, choice] of CONFIGURE_CATEGORY_CHOICES.entries()) {
|
|
1270
|
+
lines.push(...twoColumnRow(`${index + 1}. ${choice.label}`, choice.summary, { indent: 2, leftWidth, width }));
|
|
1271
|
+
}
|
|
1272
|
+
return lines;
|
|
1273
|
+
}
|
|
1274
|
+
function matchCategoryChoice(answer) {
|
|
1275
|
+
const lc = answer.trim().toLowerCase();
|
|
1276
|
+
if (lc.length === 0) return null;
|
|
1277
|
+
for (const [index, choice] of CONFIGURE_CATEGORY_CHOICES.entries()) {
|
|
1278
|
+
if (lc === String(index + 1) || lc === choice.category || choice.aliases.includes(lc)) {
|
|
1279
|
+
return choice.category;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
return null;
|
|
1283
|
+
}
|
|
1284
|
+
function formatRuntimeMenu(items, width) {
|
|
1285
|
+
if (items.length === 0) return [];
|
|
1286
|
+
const leftWidth = maxLength(items.map((item, index) => `${String(index + 1).padStart(2)}. ${item.runtimeId}`)) + 1;
|
|
1287
|
+
const lines = [];
|
|
1288
|
+
let lastGroup = null;
|
|
1289
|
+
const grouped = new Set(items.map((item) => item.group)).size > 1;
|
|
1290
|
+
for (const [index, item] of items.entries()) {
|
|
1291
|
+
if (grouped && item.group !== lastGroup) {
|
|
1292
|
+
lastGroup = item.group;
|
|
1293
|
+
lines.push(` ${item.group}:`);
|
|
1294
|
+
}
|
|
1295
|
+
lines.push(
|
|
1296
|
+
...twoColumnRow(`${String(index + 1).padStart(2)}. ${item.runtimeId}`, item.summary, {
|
|
1297
|
+
indent: 4,
|
|
1298
|
+
leftWidth,
|
|
1299
|
+
width
|
|
1300
|
+
})
|
|
1301
|
+
);
|
|
1302
|
+
}
|
|
1303
|
+
return lines;
|
|
1304
|
+
}
|
|
1305
|
+
var LIST_INDENT = 2;
|
|
1306
|
+
var LIST_GAP = 1;
|
|
1307
|
+
var LIST_MIN_MODELS = 16;
|
|
1308
|
+
function formatRuntimeList(rows, width) {
|
|
1309
|
+
if (rows.length === 0) return [];
|
|
1310
|
+
const targetCells = rows.map((row) => `targets=${row.targets}`);
|
|
1311
|
+
const idWidth = maxLength(rows.map((row) => row.runtimeId));
|
|
1312
|
+
const labelWidth = maxLength(rows.map((row) => row.label));
|
|
1313
|
+
const authWidth = maxLength(rows.map((row) => row.auth));
|
|
1314
|
+
const targetsWidth = maxLength(targetCells);
|
|
1315
|
+
const alignedWidth = LIST_INDENT + idWidth + LIST_GAP + labelWidth + LIST_GAP + authWidth + LIST_GAP + targetsWidth;
|
|
1316
|
+
const inline = width >= alignedWidth + LIST_GAP + LIST_MIN_MODELS;
|
|
1317
|
+
const pad = " ".repeat(LIST_INDENT);
|
|
1318
|
+
const detailPad = " ".repeat(LIST_INDENT + 2);
|
|
1319
|
+
const lines = [];
|
|
1320
|
+
let lastGroup = null;
|
|
1321
|
+
for (const [index, row] of rows.entries()) {
|
|
1322
|
+
if (row.group !== lastGroup) {
|
|
1323
|
+
if (lastGroup !== null) lines.push("");
|
|
1324
|
+
lastGroup = row.group;
|
|
1325
|
+
lines.push(`${row.group}:`);
|
|
1326
|
+
}
|
|
1327
|
+
const targetCell = targetCells[index] ?? "";
|
|
1328
|
+
const models = `models=${row.models}`;
|
|
1329
|
+
if (inline) {
|
|
1330
|
+
const id = column(row.runtimeId, idWidth);
|
|
1331
|
+
const label = column(row.label, labelWidth);
|
|
1332
|
+
const auth = column(row.auth, authWidth);
|
|
1333
|
+
lines.push(truncate(`${pad}${id} ${label} ${auth} ${column(targetCell, targetsWidth)} ${models}`, width));
|
|
1334
|
+
continue;
|
|
1335
|
+
}
|
|
1336
|
+
lines.push(truncate(`${pad}${column(row.runtimeId, idWidth)} ${column(row.auth, authWidth)} ${targetCell}`, width));
|
|
1337
|
+
lines.push(truncate(`${detailPad}${row.label} \xB7 ${models}`, width));
|
|
1338
|
+
}
|
|
1339
|
+
return lines;
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
// src/cli/configure-oauth.ts
|
|
1343
|
+
init_esm_shims();
|
|
1344
|
+
async function loginOAuthRuntime(rl, runtime) {
|
|
1345
|
+
const auth = openAuthStorage();
|
|
1346
|
+
if (runtime.authNotice) process.stdout.write(`note: ${runtime.authNotice}
|
|
1347
|
+
`);
|
|
1348
|
+
const manualCodeInput = createDelayedManualCodeInput(
|
|
1349
|
+
rl,
|
|
1350
|
+
"Paste verification code if browser callback does not complete automatically: "
|
|
1351
|
+
);
|
|
1352
|
+
try {
|
|
1353
|
+
await auth.login(runtime.oauthProviderId ?? runtime.id, {
|
|
1354
|
+
onAuth: ({ url, instructions }) => {
|
|
1355
|
+
process.stdout.write(`
|
|
1356
|
+
Open: ${url}
|
|
1357
|
+
`);
|
|
1358
|
+
if (instructions) process.stdout.write(`${instructions}
|
|
1359
|
+
`);
|
|
1360
|
+
process.stdout.write("Waiting for the browser callback. A manual code prompt will appear if needed.\n");
|
|
1361
|
+
},
|
|
1362
|
+
onDeviceCode: ({ verificationUri, userCode }) => {
|
|
1363
|
+
process.stdout.write(`
|
|
1364
|
+
Open: ${verificationUri}
|
|
1365
|
+
`);
|
|
1366
|
+
process.stdout.write(`Enter code: ${userCode}
|
|
1367
|
+
`);
|
|
1368
|
+
},
|
|
1369
|
+
onPrompt: async (prompt) => {
|
|
1370
|
+
const answer = await rl.question(`${prompt.message}${prompt.allowEmpty ? " " : ": "}`);
|
|
1371
|
+
return prompt.allowEmpty ? answer : answer.trim();
|
|
1372
|
+
},
|
|
1373
|
+
onSelect: (prompt) => promptOAuthSelection(rl, prompt),
|
|
1374
|
+
onManualCodeInput: manualCodeInput.onManualCodeInput,
|
|
1375
|
+
onProgress: (message) => {
|
|
1376
|
+
process.stderr.write(`${message}
|
|
1377
|
+
`);
|
|
1378
|
+
}
|
|
1379
|
+
});
|
|
1380
|
+
if (credentialWriteFailed(auth, `credential for ${runtime.id} was not stored`)) return false;
|
|
1381
|
+
printOk(`authenticated ${runtime.id}`);
|
|
1382
|
+
return true;
|
|
1383
|
+
} catch (error) {
|
|
1384
|
+
printError(error instanceof Error ? error.message : String(error));
|
|
1385
|
+
return false;
|
|
1386
|
+
} finally {
|
|
1387
|
+
manualCodeInput.cancel();
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
// src/cli/configure-onboarding.ts
|
|
1392
|
+
init_esm_shims();
|
|
1393
|
+
import { createInterface } from "node:readline/promises";
|
|
1394
|
+
function canRunOnboarding(streams) {
|
|
1395
|
+
return canSelect(streams.in, streams.out);
|
|
1396
|
+
}
|
|
1397
|
+
var LABEL_WIDTH = 11;
|
|
1398
|
+
function railWriter(out) {
|
|
1399
|
+
let lines = 0;
|
|
1400
|
+
const stream = {
|
|
1401
|
+
write(chunk) {
|
|
1402
|
+
const text = typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf8");
|
|
1403
|
+
for (const char of text) if (char === "\n") lines += 1;
|
|
1404
|
+
return out.write(chunk);
|
|
1405
|
+
},
|
|
1406
|
+
isTTY: out.isTTY,
|
|
1407
|
+
columns: out.columns
|
|
1408
|
+
};
|
|
1409
|
+
return {
|
|
1410
|
+
stream,
|
|
1411
|
+
mark: () => lines,
|
|
1412
|
+
rewindTo(mark) {
|
|
1413
|
+
const back = lines - mark;
|
|
1414
|
+
if (back > 0) out.write(`\x1B[${back}A\x1B[0J`);
|
|
1415
|
+
lines = mark;
|
|
1416
|
+
}
|
|
1417
|
+
};
|
|
1418
|
+
}
|
|
1419
|
+
function supportFor(runtime) {
|
|
1420
|
+
return buildProviderSupportEntry(runtime);
|
|
1421
|
+
}
|
|
1422
|
+
function allEntries() {
|
|
1423
|
+
return listProviderSupportEntries(getRuntimeRegistry().list());
|
|
1424
|
+
}
|
|
1425
|
+
function draftDescriptor(answers, runtime, withModel) {
|
|
1426
|
+
const apiKeyRef = answers.credential === "stored" ? targetApiKeyRef(answers.targetId ?? runtime.id, readSettings().targets) : answers.credential === "keep" ? answers.existing?.auth?.apiKeyRef ?? runtime.id : void 0;
|
|
1427
|
+
const configured = buildDescriptor(runtime, answers.targetId ?? runtime.id, {
|
|
1428
|
+
...answers.url !== void 0 ? { url: answers.url } : {},
|
|
1429
|
+
...withModel && answers.model !== void 0 ? { model: answers.model } : {},
|
|
1430
|
+
...answers.apiKeyEnv !== void 0 ? { apiKeyEnv: answers.apiKeyEnv } : {},
|
|
1431
|
+
...apiKeyRef !== void 0 ? { apiKeyRef } : {},
|
|
1432
|
+
...runtime.auth === "oauth" ? { oauthProfile: answers.existing?.auth?.oauthProfile ?? runtime.oauthProviderId ?? runtime.id } : {}
|
|
1433
|
+
});
|
|
1434
|
+
const descriptor = { ...answers.existing, ...configured };
|
|
1435
|
+
if (!withModel) delete descriptor.defaultModel;
|
|
1436
|
+
if (answers.existing?.auth || configured.auth) {
|
|
1437
|
+
descriptor.auth = { ...answers.existing?.auth, ...configured.auth };
|
|
1438
|
+
if (runtime.auth === "api-key") {
|
|
1439
|
+
if (answers.credential !== "env") delete descriptor.auth.apiKeyEnvVar;
|
|
1440
|
+
if (answers.credential !== "stored" && answers.credential !== "keep") delete descriptor.auth.apiKeyRef;
|
|
1441
|
+
}
|
|
1442
|
+
if (Object.keys(descriptor.auth).length === 0) delete descriptor.auth;
|
|
1443
|
+
}
|
|
1444
|
+
return descriptor;
|
|
1445
|
+
}
|
|
1446
|
+
var CATEGORY_STEP = {
|
|
1447
|
+
id: "category",
|
|
1448
|
+
applies: (answers) => answers.mode !== "edit" && !answers.fixedRuntime,
|
|
1449
|
+
run: async (wizard, answers) => {
|
|
1450
|
+
const current = CONFIGURE_CATEGORY_CHOICES.findIndex((choice2) => choice2.category === answers.category);
|
|
1451
|
+
const result = await promptSelect({
|
|
1452
|
+
heading: ["", source_default.bold("How will you connect Clio to a model?")],
|
|
1453
|
+
choices: CONFIGURE_CATEGORY_CHOICES.map((choice2) => ({
|
|
1454
|
+
value: choice2.category,
|
|
1455
|
+
label: choice2.label,
|
|
1456
|
+
hint: choice2.summary
|
|
1457
|
+
})),
|
|
1458
|
+
initialIndex: current >= 0 ? current : 0,
|
|
1459
|
+
railPrefix: wizard.rail,
|
|
1460
|
+
backLabel: "cancel",
|
|
1461
|
+
clearOnExit: true,
|
|
1462
|
+
input: wizard.input,
|
|
1463
|
+
output: wizard.output
|
|
1464
|
+
});
|
|
1465
|
+
if (result.kind === "quit") return "quit";
|
|
1466
|
+
if (result.kind === "back") return "back";
|
|
1467
|
+
if (answers.category !== result.value) {
|
|
1468
|
+
answers.runtime = void 0;
|
|
1469
|
+
answers.detected = void 0;
|
|
1470
|
+
}
|
|
1471
|
+
answers.category = result.value;
|
|
1472
|
+
const choice = CONFIGURE_CATEGORY_CHOICES.find((entry) => entry.category === result.value);
|
|
1473
|
+
wizard.answer("Connection", choice?.label ?? result.value);
|
|
1474
|
+
return "next";
|
|
1475
|
+
}
|
|
1476
|
+
};
|
|
1477
|
+
var RUNTIME_STEP = {
|
|
1478
|
+
id: "runtime",
|
|
1479
|
+
applies: (answers) => answers.mode !== "edit" && !answers.fixedRuntime,
|
|
1480
|
+
run: async (wizard, answers) => {
|
|
1481
|
+
const registry = getRuntimeRegistry();
|
|
1482
|
+
const chatEntries = allEntries().filter((entry) => {
|
|
1483
|
+
const runtime2 = registry.get(entry.runtimeId);
|
|
1484
|
+
return runtime2 !== null && (answers.mode !== "first" || isOrchestratorEligibleRuntime(runtime2));
|
|
1485
|
+
});
|
|
1486
|
+
const entries = answers.category ? runtimesForCategory(chatEntries, answers.category) : chatEntries;
|
|
1487
|
+
const usable = entries.length > 0 ? entries : chatEntries;
|
|
1488
|
+
const previous = usable.findIndex((entry) => entry.runtimeId === answers.runtime?.id);
|
|
1489
|
+
const featured = usable.findIndex((entry) => entry.featured);
|
|
1490
|
+
const result = await promptSelect({
|
|
1491
|
+
heading: ["", source_default.bold("Which runtime?")],
|
|
1492
|
+
choices: usable.map((entry) => ({ value: entry.runtimeId, label: entry.runtimeId, hint: entry.summary })),
|
|
1493
|
+
initialIndex: previous >= 0 ? previous : featured >= 0 ? featured : 0,
|
|
1494
|
+
railPrefix: wizard.rail,
|
|
1495
|
+
backLabel: "back",
|
|
1496
|
+
clearOnExit: true,
|
|
1497
|
+
input: wizard.input,
|
|
1498
|
+
output: wizard.output
|
|
1499
|
+
});
|
|
1500
|
+
if (result.kind === "quit") return "quit";
|
|
1501
|
+
if (result.kind === "back") return "back";
|
|
1502
|
+
const runtime = registry.get(result.value);
|
|
1503
|
+
if (!runtime) return "back";
|
|
1504
|
+
if (answers.runtime?.id !== runtime.id) {
|
|
1505
|
+
answers.targetId = void 0;
|
|
1506
|
+
answers.url = void 0;
|
|
1507
|
+
answers.detected = void 0;
|
|
1508
|
+
answers.credential = void 0;
|
|
1509
|
+
answers.apiKeyEnv = void 0;
|
|
1510
|
+
answers.apiKeyLiteral = void 0;
|
|
1511
|
+
answers.model = void 0;
|
|
1512
|
+
answers.thinking = void 0;
|
|
1513
|
+
answers.contextWindow = void 0;
|
|
1514
|
+
answers.probe = void 0;
|
|
1515
|
+
answers.inventory = void 0;
|
|
1516
|
+
answers.inventoryKey = void 0;
|
|
1517
|
+
}
|
|
1518
|
+
answers.runtime = runtime;
|
|
1519
|
+
wizard.answer("Runtime", `${runtime.id} ${source_default.dim(supportFor(runtime).summary)}`);
|
|
1520
|
+
return "next";
|
|
1521
|
+
}
|
|
1522
|
+
};
|
|
1523
|
+
var TARGET_ID_STEP = {
|
|
1524
|
+
id: "target-id",
|
|
1525
|
+
applies: (answers) => answers.mode !== "edit",
|
|
1526
|
+
run: async (wizard, answers) => {
|
|
1527
|
+
const runtime = answers.runtime;
|
|
1528
|
+
if (!runtime) return "back";
|
|
1529
|
+
const result = await promptText({
|
|
1530
|
+
heading: ["", source_default.bold("Target id")],
|
|
1531
|
+
initial: answers.targetId ?? deriveTargetId(runtime.id, readSettings().targets),
|
|
1532
|
+
hint: "the name you will use for this target in `clio-coder targets`",
|
|
1533
|
+
railPrefix: wizard.rail,
|
|
1534
|
+
backLabel: "back",
|
|
1535
|
+
clearOnExit: true,
|
|
1536
|
+
validate: (value) => {
|
|
1537
|
+
if (value.length === 0) return "a target id is required";
|
|
1538
|
+
if (/\s/u.test(value)) return "a target id cannot contain spaces";
|
|
1539
|
+
if (readSettings().targets.some((target) => target.id === value))
|
|
1540
|
+
return "that target id already exists; choose another or use Edit a target";
|
|
1541
|
+
return null;
|
|
1542
|
+
},
|
|
1543
|
+
input: wizard.input,
|
|
1544
|
+
output: wizard.output
|
|
1545
|
+
});
|
|
1546
|
+
if (result.kind === "quit") return "quit";
|
|
1547
|
+
if (result.kind === "back") return "back";
|
|
1548
|
+
if (answers.targetId !== result.value) answers.inventoryKey = void 0;
|
|
1549
|
+
answers.targetId = result.value;
|
|
1550
|
+
wizard.answer("Target id", result.value);
|
|
1551
|
+
return "next";
|
|
1552
|
+
}
|
|
1553
|
+
};
|
|
1554
|
+
var URL_STEP = {
|
|
1555
|
+
id: "url",
|
|
1556
|
+
applies: (answers) => answers.runtime !== void 0 && supportFor(answers.runtime).supportsCustomUrl,
|
|
1557
|
+
run: async (wizard, answers) => {
|
|
1558
|
+
const runtime = answers.runtime;
|
|
1559
|
+
if (!runtime) return "back";
|
|
1560
|
+
const local = supportFor(runtime).group === "local-http";
|
|
1561
|
+
const result = await promptText({
|
|
1562
|
+
heading: ["", source_default.bold(local ? "Where is the server?" : "Base URL")],
|
|
1563
|
+
initial: answers.url ?? defaultUrlFor(runtime.id),
|
|
1564
|
+
hint: "host:port is enough; Clio fills in the scheme and the port it knows",
|
|
1565
|
+
railPrefix: wizard.rail,
|
|
1566
|
+
backLabel: "back",
|
|
1567
|
+
clearOnExit: true,
|
|
1568
|
+
validate: (value) => value.length === 0 ? "a URL is required for this runtime" : null,
|
|
1569
|
+
input: wizard.input,
|
|
1570
|
+
output: wizard.output
|
|
1571
|
+
});
|
|
1572
|
+
if (result.kind === "quit") return "quit";
|
|
1573
|
+
if (result.kind === "back") return "back";
|
|
1574
|
+
const url = normalizeUrl(result.value, runtime.id);
|
|
1575
|
+
if (answers.url !== url) {
|
|
1576
|
+
answers.inventoryKey = void 0;
|
|
1577
|
+
answers.detected = void 0;
|
|
1578
|
+
}
|
|
1579
|
+
answers.url = url;
|
|
1580
|
+
wizard.answer("URL", url);
|
|
1581
|
+
await reportReachability(wizard, answers, runtime, url);
|
|
1582
|
+
return "next";
|
|
1583
|
+
}
|
|
1584
|
+
};
|
|
1585
|
+
async function reportReachability(wizard, answers, runtime, url) {
|
|
1586
|
+
const draft = draftDescriptor(answers, runtime, false);
|
|
1587
|
+
const probe = await runtimeProbe(runtime, draft, answers.apiKeyLiteral);
|
|
1588
|
+
if (probe !== null) {
|
|
1589
|
+
if (probe.ok) {
|
|
1590
|
+
const readings = probeReadings(probe);
|
|
1591
|
+
wizard.presenter.step(`reachable, ${readings.length > 0 ? readings.join(", ") : "no model list offered"}`);
|
|
1592
|
+
} else if (probe.authFailed) {
|
|
1593
|
+
wizard.presenter.warn("rejected the key");
|
|
1594
|
+
} else {
|
|
1595
|
+
wizard.presenter.warn(`not reachable, you can fix this later: ${probe.error ?? "no reply"}`);
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
if (probe?.ok && runtime.id === "lmstudio") {
|
|
1599
|
+
const greeting = await greetLmStudio(draft, { credentialsPresent: /* @__PURE__ */ new Set(), httpTimeoutMs: 750 });
|
|
1600
|
+
if (!greeting.ok) wizard.presenter.warn(`${url} answered, but not with the LM Studio greeting`);
|
|
1601
|
+
}
|
|
1602
|
+
if (PROTOCOL_COMPAT_RUNTIME_IDS.has(runtime.id)) {
|
|
1603
|
+
const fingerprint = await fingerprintNativeRuntime(url);
|
|
1604
|
+
if (fingerprint && getRuntimeRegistry().get(fingerprint.runtimeId)) {
|
|
1605
|
+
answers.detected = { runtimeId: fingerprint.runtimeId, displayName: fingerprint.displayName };
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
var DETECTED_RUNTIME_STEP = {
|
|
1610
|
+
id: "detected-runtime",
|
|
1611
|
+
applies: (answers) => answers.mode !== "edit" && answers.detected !== void 0 && answers.runtime !== void 0,
|
|
1612
|
+
run: async (wizard, answers) => {
|
|
1613
|
+
const detected = answers.detected;
|
|
1614
|
+
const runtime = answers.runtime;
|
|
1615
|
+
if (!detected || !runtime) return "next";
|
|
1616
|
+
const native = getRuntimeRegistry().get(detected.runtimeId);
|
|
1617
|
+
if (!native) return "next";
|
|
1618
|
+
const result = await promptSelect({
|
|
1619
|
+
heading: ["", source_default.bold(`That URL is serving ${detected.displayName}.`)],
|
|
1620
|
+
choices: [
|
|
1621
|
+
{
|
|
1622
|
+
value: true,
|
|
1623
|
+
label: `Use ${native.id}`,
|
|
1624
|
+
hint: "its own runtime, with resident-model lifecycle and its real capabilities"
|
|
1625
|
+
},
|
|
1626
|
+
{ value: false, label: `Keep ${runtime.id}`, hint: "the generic protocol runtime you picked" }
|
|
1627
|
+
],
|
|
1628
|
+
initialIndex: 0,
|
|
1629
|
+
railPrefix: wizard.rail,
|
|
1630
|
+
backLabel: "back",
|
|
1631
|
+
clearOnExit: true,
|
|
1632
|
+
input: wizard.input,
|
|
1633
|
+
output: wizard.output
|
|
1634
|
+
});
|
|
1635
|
+
if (result.kind === "quit") return "quit";
|
|
1636
|
+
if (result.kind === "back") return "back";
|
|
1637
|
+
if (result.value) {
|
|
1638
|
+
answers.runtime = native;
|
|
1639
|
+
answers.inventoryKey = void 0;
|
|
1640
|
+
wizard.answer("Detected", `${detected.displayName}, using runtime ${native.id}`);
|
|
1641
|
+
} else {
|
|
1642
|
+
wizard.answer("Detected", `${detected.displayName}, keeping runtime ${runtime.id}`);
|
|
1643
|
+
}
|
|
1644
|
+
return "next";
|
|
1645
|
+
}
|
|
1646
|
+
};
|
|
1647
|
+
function defaultCredentialSource(runtime, targetId) {
|
|
1648
|
+
const status = openAuthStorage().statusForTarget(resolveRuntimeAuthTarget(runtime), { includeFallback: false });
|
|
1649
|
+
if (status.source === "stored-api-key") return "keep";
|
|
1650
|
+
if (status.source === "environment") return "env";
|
|
1651
|
+
return targetRequiresAuth({ id: targetId, runtime: runtime.id }, runtime) ? "env" : "skip";
|
|
1652
|
+
}
|
|
1653
|
+
async function connectOAuth(wizard, runtime) {
|
|
1654
|
+
const rl = createInterface({ input: wizard.streams.in, output: wizard.streams.out });
|
|
1655
|
+
try {
|
|
1656
|
+
return await loginOAuthRuntime(rl, runtime);
|
|
1657
|
+
} finally {
|
|
1658
|
+
rl.close();
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
var CREDENTIAL_STEP = {
|
|
1662
|
+
id: "credential",
|
|
1663
|
+
applies: (answers) => answers.runtime?.auth === "api-key" || answers.runtime?.auth === "oauth",
|
|
1664
|
+
run: async (wizard, answers) => {
|
|
1665
|
+
const runtime = answers.runtime;
|
|
1666
|
+
if (!runtime) return "back";
|
|
1667
|
+
const stored = describeAuthStatus(runtime, answers.existing);
|
|
1668
|
+
if (runtime.auth === "oauth") {
|
|
1669
|
+
const result2 = await promptSelect({
|
|
1670
|
+
heading: [
|
|
1671
|
+
"",
|
|
1672
|
+
source_default.bold(`Sign in to ${runtime.displayName}`),
|
|
1673
|
+
source_default.dim(`credential: ${stored}`),
|
|
1674
|
+
"Sign-in stores credentials immediately; target settings wait for Save."
|
|
1675
|
+
],
|
|
1676
|
+
choices: [
|
|
1677
|
+
{ value: "oauth-connect", label: "Connect now", hint: "opens your browser and waits for the callback" },
|
|
1678
|
+
{
|
|
1679
|
+
value: "oauth-skip",
|
|
1680
|
+
label: "Later",
|
|
1681
|
+
hint: `run \`clio-coder auth login ${runtime.id}\` before the first turn`
|
|
1682
|
+
}
|
|
1683
|
+
],
|
|
1684
|
+
initialIndex: answers.credential === "oauth-skip" ? 1 : 0,
|
|
1685
|
+
railPrefix: wizard.rail,
|
|
1686
|
+
backLabel: "back",
|
|
1687
|
+
clearOnExit: true,
|
|
1688
|
+
input: wizard.input,
|
|
1689
|
+
output: wizard.output
|
|
1690
|
+
});
|
|
1691
|
+
if (result2.kind === "quit") return "quit";
|
|
1692
|
+
if (result2.kind === "back") return "back";
|
|
1693
|
+
answers.credential = result2.value;
|
|
1694
|
+
if (result2.value === "oauth-connect") {
|
|
1695
|
+
const connected = await connectOAuth(wizard, runtime);
|
|
1696
|
+
if (!connected) {
|
|
1697
|
+
wizard.presenter.warn(`sign-in did not complete; run \`clio-coder auth login ${runtime.id}\` when ready`);
|
|
1698
|
+
wizard.answer("Credential", "not connected yet");
|
|
1699
|
+
return "next";
|
|
1700
|
+
}
|
|
1701
|
+
wizard.answer("Credential", `connected to ${runtime.id}`);
|
|
1702
|
+
return "next";
|
|
1703
|
+
}
|
|
1704
|
+
wizard.answer("Credential", "not connected yet");
|
|
1705
|
+
return "next";
|
|
1706
|
+
}
|
|
1707
|
+
const hasStored = answers.existing?.auth?.apiKeyRef !== void 0 || stored !== "none stored";
|
|
1708
|
+
const choices = [
|
|
1709
|
+
{
|
|
1710
|
+
value: "env",
|
|
1711
|
+
label: "Environment variable",
|
|
1712
|
+
hint: "read at call time; nothing is written to disk"
|
|
1713
|
+
},
|
|
1714
|
+
{
|
|
1715
|
+
value: "stored",
|
|
1716
|
+
label: "Store the key",
|
|
1717
|
+
hint: "written to credentials.yaml, mode 0600, not encrypted"
|
|
1718
|
+
},
|
|
1719
|
+
...hasStored ? [{ value: "keep", label: "Keep what is there", hint: stored }] : [],
|
|
1720
|
+
{ value: "skip", label: "No key", hint: "this target needs no credential" }
|
|
1721
|
+
];
|
|
1722
|
+
const current = answers.credential ?? defaultCredentialSource(runtime, answers.targetId ?? runtime.id);
|
|
1723
|
+
const initial = Math.max(
|
|
1724
|
+
0,
|
|
1725
|
+
choices.findIndex((choice) => choice.value === current)
|
|
1726
|
+
);
|
|
1727
|
+
const result = await promptSelect({
|
|
1728
|
+
heading: ["", source_default.bold("How should Clio get the API key?"), source_default.dim(`currently: ${stored}`)],
|
|
1729
|
+
choices,
|
|
1730
|
+
initialIndex: initial,
|
|
1731
|
+
railPrefix: wizard.rail,
|
|
1732
|
+
backLabel: "back",
|
|
1733
|
+
clearOnExit: true,
|
|
1734
|
+
input: wizard.input,
|
|
1735
|
+
output: wizard.output
|
|
1736
|
+
});
|
|
1737
|
+
if (result.kind === "quit") return "quit";
|
|
1738
|
+
if (result.kind === "back") return "back";
|
|
1739
|
+
answers.credential = result.value;
|
|
1740
|
+
if (result.value !== "env") answers.apiKeyEnv = void 0;
|
|
1741
|
+
answers.inventoryKey = void 0;
|
|
1742
|
+
if (result.value !== "stored") answers.apiKeyLiteral = void 0;
|
|
1743
|
+
if (result.value === "keep") wizard.answer("Credential", stored);
|
|
1744
|
+
if (result.value === "skip") wizard.answer("Credential", "none");
|
|
1745
|
+
return "next";
|
|
1746
|
+
}
|
|
1747
|
+
};
|
|
1748
|
+
var CREDENTIAL_VALUE_STEP = {
|
|
1749
|
+
id: "credential-value",
|
|
1750
|
+
applies: (answers) => answers.credential === "env" || answers.credential === "stored",
|
|
1751
|
+
run: async (wizard, answers) => {
|
|
1752
|
+
const runtime = answers.runtime;
|
|
1753
|
+
if (!runtime) return "back";
|
|
1754
|
+
const wantsEnv = answers.credential === "env";
|
|
1755
|
+
const result = await promptText({
|
|
1756
|
+
heading: ["", source_default.bold(wantsEnv ? "Which environment variable?" : "Paste the API key")],
|
|
1757
|
+
initial: wantsEnv ? answers.apiKeyEnv ?? runtime.credentialsEnvVar ?? "" : "",
|
|
1758
|
+
hint: wantsEnv ? "Clio reads it every time it calls the provider, so the key never lands on disk" : `stored at ${shortenPath(authStoragePath())}`,
|
|
1759
|
+
...wantsEnv ? {} : { mask: true },
|
|
1760
|
+
validate: (value) => value.length > 0 ? null : `Enter ${wantsEnv ? "an environment variable" : "a key"}, or press Escape to choose No key.`,
|
|
1761
|
+
railPrefix: wizard.rail,
|
|
1762
|
+
backLabel: "back",
|
|
1763
|
+
clearOnExit: true,
|
|
1764
|
+
input: wizard.input,
|
|
1765
|
+
output: wizard.output
|
|
1766
|
+
});
|
|
1767
|
+
if (result.kind === "quit") return "quit";
|
|
1768
|
+
if (result.kind === "back") return "back";
|
|
1769
|
+
if (wantsEnv) {
|
|
1770
|
+
answers.apiKeyEnv = result.value.length > 0 ? result.value : void 0;
|
|
1771
|
+
answers.inventoryKey = void 0;
|
|
1772
|
+
wizard.answer("Credential", result.value.length > 0 ? `$${result.value}` : "none");
|
|
1773
|
+
return "next";
|
|
1774
|
+
}
|
|
1775
|
+
answers.apiKeyLiteral = result.value.length > 0 ? result.value : void 0;
|
|
1776
|
+
answers.inventoryKey = void 0;
|
|
1777
|
+
wizard.answer("Credential", result.value.length > 0 ? "stored in credentials.yaml" : "none");
|
|
1778
|
+
return "next";
|
|
1779
|
+
}
|
|
1780
|
+
};
|
|
1781
|
+
async function modelInventory(answers, runtime) {
|
|
1782
|
+
const key = [
|
|
1783
|
+
runtime.id,
|
|
1784
|
+
answers.targetId,
|
|
1785
|
+
answers.url,
|
|
1786
|
+
answers.apiKeyEnv,
|
|
1787
|
+
answers.apiKeyLiteral ? "literal" : ""
|
|
1788
|
+
].join("|");
|
|
1789
|
+
if (answers.inventoryKey === key && answers.inventory) return answers.inventory;
|
|
1790
|
+
const inventory = await resolveSupportedWireModels(
|
|
1791
|
+
runtime,
|
|
1792
|
+
draftDescriptor(answers, runtime, false),
|
|
1793
|
+
void 0,
|
|
1794
|
+
answers.apiKeyLiteral
|
|
1795
|
+
);
|
|
1796
|
+
answers.inventory = inventory;
|
|
1797
|
+
answers.inventoryKey = key;
|
|
1798
|
+
return inventory;
|
|
1799
|
+
}
|
|
1800
|
+
var MODEL_STEP = {
|
|
1801
|
+
id: "model",
|
|
1802
|
+
applies: () => true,
|
|
1803
|
+
run: async (wizard, answers) => {
|
|
1804
|
+
const runtime = answers.runtime;
|
|
1805
|
+
if (!runtime) return "back";
|
|
1806
|
+
const support = supportFor(runtime);
|
|
1807
|
+
const inventory = await modelInventory(answers, runtime);
|
|
1808
|
+
const catalogOrdered = support.modelSource === "catalog";
|
|
1809
|
+
const preferred = answers.model ?? (inventory.source === "probe" ? inventory.models[0] : support.defaultModel) ?? (catalogOrdered ? void 0 : inventory.models[0]) ?? void 0;
|
|
1810
|
+
if (inventory.models.length === 0) {
|
|
1811
|
+
wizard.presenter.warn(inventoryGap(runtime, { url: answers.url }));
|
|
1812
|
+
const result2 = await promptText({
|
|
1813
|
+
heading: ["", source_default.bold("Which model?")],
|
|
1814
|
+
initial: preferred ?? "",
|
|
1815
|
+
hint: "the wire id the provider documents; Clio sends it as written",
|
|
1816
|
+
railPrefix: wizard.rail,
|
|
1817
|
+
backLabel: "back",
|
|
1818
|
+
clearOnExit: true,
|
|
1819
|
+
validate: (value) => value.length === 0 ? "a model id is required" : null,
|
|
1820
|
+
input: wizard.input,
|
|
1821
|
+
output: wizard.output
|
|
1822
|
+
});
|
|
1823
|
+
if (result2.kind === "quit") return "quit";
|
|
1824
|
+
if (result2.kind === "back") return "back";
|
|
1825
|
+
answers.model = result2.value;
|
|
1826
|
+
wizard.answer("Model", result2.value);
|
|
1827
|
+
await readModelCapabilities(answers, runtime);
|
|
1828
|
+
return "next";
|
|
1829
|
+
}
|
|
1830
|
+
const selected = inventory.models.indexOf(preferred ?? "");
|
|
1831
|
+
const result = await promptSelect({
|
|
1832
|
+
heading: [
|
|
1833
|
+
"",
|
|
1834
|
+
source_default.bold("Which model?"),
|
|
1835
|
+
source_default.dim(
|
|
1836
|
+
inventory.source === "probe" ? "read live from the target just now" : inventory.source === "cache" ? "cached model snapshot; not verified in this run" : "model hints; not a live account catalog"
|
|
1837
|
+
)
|
|
1838
|
+
],
|
|
1839
|
+
choices: inventory.models.map((model) => {
|
|
1840
|
+
const state = inventory.modelStates?.[model]?.state;
|
|
1841
|
+
const hint = model === preferred ? "default" : state !== void 0 && state !== "unknown" ? state : void 0;
|
|
1842
|
+
const label = inventory.labels?.[model];
|
|
1843
|
+
return {
|
|
1844
|
+
value: model,
|
|
1845
|
+
label: label && label !== model ? `${model} \u2014 ${label}` : model,
|
|
1846
|
+
...hint === void 0 ? {} : { hint }
|
|
1847
|
+
};
|
|
1848
|
+
}),
|
|
1849
|
+
initialIndex: selected >= 0 ? selected : 0,
|
|
1850
|
+
railPrefix: wizard.rail,
|
|
1851
|
+
backLabel: "back",
|
|
1852
|
+
clearOnExit: true,
|
|
1853
|
+
input: wizard.input,
|
|
1854
|
+
output: wizard.output
|
|
1855
|
+
});
|
|
1856
|
+
if (result.kind === "quit") return "quit";
|
|
1857
|
+
if (result.kind === "back") return "back";
|
|
1858
|
+
const refusal = modelChoiceRefusal(
|
|
1859
|
+
runtime,
|
|
1860
|
+
{ id: answers.targetId ?? runtime.id, url: answers.url },
|
|
1861
|
+
result.value,
|
|
1862
|
+
inventory
|
|
1863
|
+
);
|
|
1864
|
+
if (refusal !== null) {
|
|
1865
|
+
wizard.presenter.warn(refusal);
|
|
1866
|
+
return "back";
|
|
1867
|
+
}
|
|
1868
|
+
answers.model = result.value;
|
|
1869
|
+
wizard.answer("Model", result.value);
|
|
1870
|
+
await readModelCapabilities(answers, runtime);
|
|
1871
|
+
return "next";
|
|
1872
|
+
}
|
|
1873
|
+
};
|
|
1874
|
+
async function readModelCapabilities(answers, runtime) {
|
|
1875
|
+
const descriptor = draftDescriptor(answers, runtime, true);
|
|
1876
|
+
const probe = await runtimeProbe(runtime, descriptor, answers.apiKeyLiteral);
|
|
1877
|
+
answers.probe = probe;
|
|
1878
|
+
if (probe?.ok && probe.models) {
|
|
1879
|
+
recordTargetModelSnapshot(descriptor, probe.models, probe.modelLabels ? { modelLabels: probe.modelLabels } : {});
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
var THINKING_HINTS = {
|
|
1883
|
+
off: "never ask this model to think before answering",
|
|
1884
|
+
minimal: "a sentence of reasoning",
|
|
1885
|
+
low: "short reasoning, the usual choice",
|
|
1886
|
+
medium: "more reasoning on hard turns",
|
|
1887
|
+
high: "long reasoning, slower and more expensive",
|
|
1888
|
+
xhigh: "longer still, where the model offers it",
|
|
1889
|
+
max: "everything the model will spend"
|
|
1890
|
+
};
|
|
1891
|
+
var THINKING_STEP = {
|
|
1892
|
+
id: "thinking",
|
|
1893
|
+
applies: (answers) => {
|
|
1894
|
+
if (answers.mode !== "first" && !PROTOCOL_COMPAT_RUNTIME_IDS.has(answers.runtime?.id ?? "")) return false;
|
|
1895
|
+
const runtime = answers.runtime;
|
|
1896
|
+
if (!runtime || answers.model === void 0) return false;
|
|
1897
|
+
if (PROTOCOL_COMPAT_RUNTIME_IDS.has(runtime.id)) return true;
|
|
1898
|
+
return modelSupportsThinking(runtime, draftDescriptor(answers, runtime, true), answers.probe ?? null);
|
|
1899
|
+
},
|
|
1900
|
+
run: async (wizard, answers) => {
|
|
1901
|
+
const current = THINKING_LEVELS.indexOf(answers.thinking ?? "low");
|
|
1902
|
+
const result = await promptSelect({
|
|
1903
|
+
heading: [
|
|
1904
|
+
"",
|
|
1905
|
+
source_default.bold("How hard should it think?"),
|
|
1906
|
+
source_default.dim(
|
|
1907
|
+
answers.mode === "first" ? "changeable any time in `clio-coder configure`" : "off disables reasoning for this target; chat and fleet thinking defaults stay unchanged"
|
|
1908
|
+
)
|
|
1909
|
+
],
|
|
1910
|
+
choices: THINKING_LEVELS.map((level) => ({ value: level, label: level, hint: THINKING_HINTS[level] })),
|
|
1911
|
+
initialIndex: current >= 0 ? current : 0,
|
|
1912
|
+
railPrefix: wizard.rail,
|
|
1913
|
+
backLabel: "back",
|
|
1914
|
+
clearOnExit: true,
|
|
1915
|
+
input: wizard.input,
|
|
1916
|
+
output: wizard.output
|
|
1917
|
+
});
|
|
1918
|
+
if (result.kind === "quit") return "quit";
|
|
1919
|
+
if (result.kind === "back") return "back";
|
|
1920
|
+
answers.thinking = result.value;
|
|
1921
|
+
wizard.answer("Thinking", result.value);
|
|
1922
|
+
return "next";
|
|
1923
|
+
}
|
|
1924
|
+
};
|
|
1925
|
+
var ANTIGRAVITY_COLLEAGUE_STEP = {
|
|
1926
|
+
id: "antigravity-colleague",
|
|
1927
|
+
applies: (answers) => answers.mode === "first" && answers.runtime !== void 0 && isOrchestratorEligibleRuntime(answers.runtime) && resolveOnPath(["agy"]).presence === "present" && !readSettings().targets.some((target) => target.runtime === "antigravity-code"),
|
|
1928
|
+
run: async (wizard, answers) => {
|
|
1929
|
+
const runtime = getRuntimeRegistry().get("antigravity-code");
|
|
1930
|
+
if (!runtime) return "next";
|
|
1931
|
+
const choice = await promptSelect({
|
|
1932
|
+
heading: [
|
|
1933
|
+
"",
|
|
1934
|
+
source_default.bold("Add your local Antigravity research colleague?"),
|
|
1935
|
+
source_default.dim("optional, experimental, dispatch-only; Clio does not authenticate or inspect its session")
|
|
1936
|
+
],
|
|
1937
|
+
choices: [
|
|
1938
|
+
{ value: false, label: "Not now", hint: "your primary Clio target is unchanged" },
|
|
1939
|
+
{ value: true, label: "Add read-only colleague", hint: "probe the non-generating model catalog" }
|
|
1940
|
+
],
|
|
1941
|
+
initialIndex: answers.antigravity ? 1 : 0,
|
|
1942
|
+
railPrefix: wizard.rail,
|
|
1943
|
+
backLabel: "back",
|
|
1944
|
+
clearOnExit: true,
|
|
1945
|
+
input: wizard.input,
|
|
1946
|
+
output: wizard.output
|
|
1947
|
+
});
|
|
1948
|
+
if (choice.kind === "quit") return "quit";
|
|
1949
|
+
if (choice.kind === "back") return "back";
|
|
1950
|
+
if (!choice.value) {
|
|
1951
|
+
answers.antigravity = void 0;
|
|
1952
|
+
wizard.answer("Colleague", "not added");
|
|
1953
|
+
return "next";
|
|
1954
|
+
}
|
|
1955
|
+
const targetId = deriveTargetId(runtime.id, readSettings().targets);
|
|
1956
|
+
const descriptor = buildDescriptor(runtime, targetId, {});
|
|
1957
|
+
const inventory = await resolveSupportedWireModels(runtime, descriptor);
|
|
1958
|
+
if (inventory.source !== "probe" || inventory.models.length === 0) {
|
|
1959
|
+
answers.antigravity = void 0;
|
|
1960
|
+
wizard.presenter.warn(
|
|
1961
|
+
inventory.probeError ?? "Antigravity did not return a live catalog. Run `agy` yourself, complete sign-in, then add it from Configure \u2192 Targets."
|
|
1962
|
+
);
|
|
1963
|
+
wizard.answer("Colleague", "not added; sign in with agy first");
|
|
1964
|
+
return "next";
|
|
1965
|
+
}
|
|
1966
|
+
const picked = await promptSelect({
|
|
1967
|
+
heading: ["", source_default.bold("Antigravity research model"), source_default.dim("live account catalog")],
|
|
1968
|
+
choices: inventory.models.map((model) => ({
|
|
1969
|
+
value: model,
|
|
1970
|
+
label: inventory.labels?.[model] ? `${model} \u2014 ${inventory.labels[model]}` : model
|
|
1971
|
+
})),
|
|
1972
|
+
initialIndex: 0,
|
|
1973
|
+
railPrefix: wizard.rail,
|
|
1974
|
+
backLabel: "back",
|
|
1975
|
+
clearOnExit: true,
|
|
1976
|
+
input: wizard.input,
|
|
1977
|
+
output: wizard.output
|
|
1978
|
+
});
|
|
1979
|
+
if (picked.kind === "quit") return "quit";
|
|
1980
|
+
if (picked.kind === "back") return "back";
|
|
1981
|
+
answers.antigravity = { targetId, model: picked.value };
|
|
1982
|
+
wizard.answer("Colleague", `${targetId}/${picked.value} \u2192 world-knowledge`);
|
|
1983
|
+
return "next";
|
|
1984
|
+
}
|
|
1985
|
+
};
|
|
1986
|
+
var CONTEXT_STEP = {
|
|
1987
|
+
id: "context-window",
|
|
1988
|
+
applies: (answers) => PROTOCOL_COMPAT_RUNTIME_IDS.has(answers.runtime?.id ?? "") || answers.mode === "edit",
|
|
1989
|
+
run: async (wizard, answers) => {
|
|
1990
|
+
const result = await promptText({
|
|
1991
|
+
heading: ["", source_default.bold("Context window in tokens")],
|
|
1992
|
+
initial: answers.contextWindow === void 0 ? "" : String(answers.contextWindow),
|
|
1993
|
+
hint: "optional override; blank uses detected capabilities or the runtime default",
|
|
1994
|
+
validate: (value) => value === "" || Number.isSafeInteger(Number(value)) && Number(value) > 0 ? null : "enter a positive whole number, or leave blank",
|
|
1995
|
+
railPrefix: wizard.rail,
|
|
1996
|
+
backLabel: "back",
|
|
1997
|
+
clearOnExit: true,
|
|
1998
|
+
input: wizard.input,
|
|
1999
|
+
output: wizard.output
|
|
2000
|
+
});
|
|
2001
|
+
if (result.kind !== "value") return result.kind;
|
|
2002
|
+
answers.contextWindow = result.value ? Number(result.value) : void 0;
|
|
2003
|
+
wizard.answer("Context", result.value || "detected / runtime default");
|
|
2004
|
+
return "next";
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
2007
|
+
var REVIEW_STEP = {
|
|
2008
|
+
id: "review",
|
|
2009
|
+
applies: () => true,
|
|
2010
|
+
run: async (wizard, answers) => {
|
|
2011
|
+
const result = await promptSelect({
|
|
2012
|
+
heading: [
|
|
2013
|
+
"",
|
|
2014
|
+
source_default.bold("Review target"),
|
|
2015
|
+
`${answers.targetId} \xB7 ${answers.runtime?.id} \xB7 ${answers.model}`,
|
|
2016
|
+
answers.mode === "first" ? "Use for chat and fleet." : "Existing chat, fleet, memory, and profile defaults stay in place.",
|
|
2017
|
+
"Escape returns to the previous step; settings are saved only when you choose Save."
|
|
2018
|
+
],
|
|
2019
|
+
choices: [
|
|
2020
|
+
{ value: "save", label: "Save target" },
|
|
2021
|
+
{ value: "back", label: "Back" },
|
|
2022
|
+
{ value: "cancel", label: "Cancel setup" }
|
|
2023
|
+
],
|
|
2024
|
+
railPrefix: wizard.rail,
|
|
2025
|
+
backLabel: "back",
|
|
2026
|
+
clearOnExit: true,
|
|
2027
|
+
input: wizard.input,
|
|
2028
|
+
output: wizard.output
|
|
2029
|
+
});
|
|
2030
|
+
if (result.kind !== "selected") return result.kind;
|
|
2031
|
+
return result.value === "save" ? "next" : result.value === "back" ? "back" : "cancel";
|
|
2032
|
+
}
|
|
2033
|
+
};
|
|
2034
|
+
var STEPS = [
|
|
2035
|
+
CATEGORY_STEP,
|
|
2036
|
+
RUNTIME_STEP,
|
|
2037
|
+
TARGET_ID_STEP,
|
|
2038
|
+
CREDENTIAL_STEP,
|
|
2039
|
+
CREDENTIAL_VALUE_STEP,
|
|
2040
|
+
URL_STEP,
|
|
2041
|
+
DETECTED_RUNTIME_STEP,
|
|
2042
|
+
MODEL_STEP,
|
|
2043
|
+
THINKING_STEP,
|
|
2044
|
+
CONTEXT_STEP,
|
|
2045
|
+
ANTIGRAVITY_COLLEAGUE_STEP,
|
|
2046
|
+
REVIEW_STEP
|
|
2047
|
+
];
|
|
2048
|
+
function applyAnswers(settings, answers, descriptor, chatEligible) {
|
|
2049
|
+
const current = settings.targets.find((target) => target.id === descriptor.id);
|
|
2050
|
+
if (answers.mode === "edit") {
|
|
2051
|
+
if (JSON.stringify(current) !== JSON.stringify(answers.existing))
|
|
2052
|
+
throw new Error("This target changed during setup; reopen Edit to keep those changes.");
|
|
2053
|
+
} else if (current) throw new Error(`Target '${descriptor.id}' already exists; use Edit a target.`);
|
|
2054
|
+
applyTarget(settings, descriptor);
|
|
2055
|
+
if (answers.mode === "first" && chatEligible) setOrchestratorPointer(settings, descriptor, answers.model ?? null);
|
|
2056
|
+
if (answers.mode === "first") setWorkerDefaultPointer(settings, descriptor, answers.model ?? null);
|
|
2057
|
+
if (answers.mode === "first" && answers.thinking !== void 0) {
|
|
2058
|
+
settings.chat.thinkingLevel = answers.thinking;
|
|
2059
|
+
settings.fleet.default.thinkingLevel = answers.thinking;
|
|
2060
|
+
}
|
|
2061
|
+
if (answers.antigravity !== void 0) {
|
|
2062
|
+
const antigravityRuntime = getRuntimeRegistry().get("antigravity-code");
|
|
2063
|
+
if (!antigravityRuntime) throw new Error("Antigravity runtime disappeared before settings were written");
|
|
2064
|
+
const external = buildDescriptor(antigravityRuntime, answers.antigravity.targetId, {
|
|
2065
|
+
model: answers.antigravity.model
|
|
2066
|
+
});
|
|
2067
|
+
applyTarget(settings, external);
|
|
2068
|
+
setWorkerProfilePointer(settings, "world-knowledge-external", external, answers.antigravity.model);
|
|
2069
|
+
bindAgentProfileInSettings(settings, "world-knowledge", "world-knowledge-external");
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
async function runOnboardingWizard(streams, options = {
|
|
2073
|
+
mode: "first"
|
|
2074
|
+
}) {
|
|
2075
|
+
const writer = railWriter(streams.out);
|
|
2076
|
+
const presenter = createLifecyclePresenter({ stream: writer.stream });
|
|
2077
|
+
const rail = railPrefix(presenter.isPlain());
|
|
2078
|
+
const columns = streams.out.columns ?? 80;
|
|
2079
|
+
const wizard = {
|
|
2080
|
+
streams,
|
|
2081
|
+
presenter,
|
|
2082
|
+
rail,
|
|
2083
|
+
input: streams.in,
|
|
2084
|
+
output: streams.out,
|
|
2085
|
+
answer: (label, value) => {
|
|
2086
|
+
presenter.fields([[label.padEnd(LABEL_WIDTH), truncate(value, Math.max(12, columns - LABEL_WIDTH - 6))]]);
|
|
2087
|
+
}
|
|
2088
|
+
};
|
|
2089
|
+
presenter.header(
|
|
2090
|
+
options.mode === "edit" ? `Edit target: ${options.target.id}` : options.mode === "first" ? "Welcome to Clio Coder" : "Add a target",
|
|
2091
|
+
"configure"
|
|
2092
|
+
);
|
|
2093
|
+
presenter.note("Pick a model; escape goes back. Review and save when ready.");
|
|
2094
|
+
presenter.note(`Result: ${shortenPath(settingsPath())}`);
|
|
2095
|
+
const existing = options.mode === "edit" ? options.target : void 0;
|
|
2096
|
+
const answers = {
|
|
2097
|
+
mode: options.mode,
|
|
2098
|
+
existing,
|
|
2099
|
+
runtime: existing ? getRuntimeRegistry().get(existing.runtime) ?? void 0 : options.mode !== "edit" ? options.runtime : void 0,
|
|
2100
|
+
fixedRuntime: options.mode !== "edit" && options.runtime !== void 0,
|
|
2101
|
+
targetId: existing?.id,
|
|
2102
|
+
url: existing?.url,
|
|
2103
|
+
model: existing?.defaultModel,
|
|
2104
|
+
credential: existing?.auth?.apiKeyEnvVar ? "env" : existing?.auth?.apiKeyRef ? "keep" : void 0,
|
|
2105
|
+
apiKeyEnv: existing?.auth?.apiKeyEnvVar,
|
|
2106
|
+
contextWindow: existing?.capabilities?.contextWindow,
|
|
2107
|
+
thinking: existing?.capabilities?.reasoning === false ? "off" : void 0
|
|
2108
|
+
};
|
|
2109
|
+
if (existing && !answers.runtime) {
|
|
2110
|
+
presenter.fail(`Unknown runtime: ${existing.runtime}`);
|
|
2111
|
+
return 2;
|
|
2112
|
+
}
|
|
2113
|
+
const marks = new Array(STEPS.length).fill(writer.mark());
|
|
2114
|
+
let cursor = 0;
|
|
2115
|
+
let direction = 1;
|
|
2116
|
+
while (cursor < STEPS.length) {
|
|
2117
|
+
const step = STEPS[cursor];
|
|
2118
|
+
if (step === void 0) break;
|
|
2119
|
+
if (!step.applies(answers)) {
|
|
2120
|
+
cursor += direction;
|
|
2121
|
+
if (cursor < 0) return cancel(presenter, answers);
|
|
2122
|
+
continue;
|
|
2123
|
+
}
|
|
2124
|
+
marks[cursor] = writer.mark();
|
|
2125
|
+
const outcome = await step.run(wizard, answers);
|
|
2126
|
+
if (outcome === "quit" || outcome === "cancel") return cancel(presenter, answers, outcome === "quit");
|
|
2127
|
+
if (outcome === "back") {
|
|
2128
|
+
direction = -1;
|
|
2129
|
+
cursor -= 1;
|
|
2130
|
+
while (cursor >= 0 && !(STEPS[cursor]?.applies(answers) ?? false)) cursor -= 1;
|
|
2131
|
+
if (cursor < 0) return cancel(presenter, answers);
|
|
2132
|
+
writer.rewindTo(marks[cursor] ?? writer.mark());
|
|
2133
|
+
continue;
|
|
2134
|
+
}
|
|
2135
|
+
direction = 1;
|
|
2136
|
+
cursor += 1;
|
|
2137
|
+
}
|
|
2138
|
+
const code = finish(wizard, answers);
|
|
2139
|
+
if (code === 0 && answers.mode === "first") {
|
|
2140
|
+
await reviewInteropAgents({ rl: null, streams, presenter, rail, quiet: true });
|
|
2141
|
+
}
|
|
2142
|
+
return code;
|
|
2143
|
+
}
|
|
2144
|
+
function cancel(presenter, answers, quit = false) {
|
|
2145
|
+
presenter.done("Cancelled; target settings not saved");
|
|
2146
|
+
if (answers.mode === "first") printError("configuration cancelled");
|
|
2147
|
+
return answers.mode === "first" || quit ? 130 : 0;
|
|
2148
|
+
}
|
|
2149
|
+
function finish(wizard, answers) {
|
|
2150
|
+
const runtime = answers.runtime;
|
|
2151
|
+
const targetId = answers.targetId;
|
|
2152
|
+
if (!runtime || targetId === void 0) return cancel(wizard.presenter, answers);
|
|
2153
|
+
const presenter = wizard.presenter;
|
|
2154
|
+
const reasoning = PROTOCOL_COMPAT_RUNTIME_IDS.has(runtime.id) && answers.thinking !== void 0 ? answers.thinking !== "off" : void 0;
|
|
2155
|
+
const descriptor = draftDescriptor(answers, runtime, true);
|
|
2156
|
+
descriptor.capabilities = { ...descriptor.capabilities };
|
|
2157
|
+
if (reasoning !== void 0) descriptor.capabilities.reasoning = reasoning;
|
|
2158
|
+
if (answers.contextWindow === void 0) delete descriptor.capabilities.contextWindow;
|
|
2159
|
+
else descriptor.capabilities.contextWindow = answers.contextWindow;
|
|
2160
|
+
const chatEligible = isOrchestratorEligibleRuntime(runtime);
|
|
2161
|
+
try {
|
|
2162
|
+
const preview = readSettings();
|
|
2163
|
+
applyAnswers(preview, answers, descriptor, chatEligible);
|
|
2164
|
+
const validated = validateSettings(preview);
|
|
2165
|
+
if (validated.issues.length) throw new SettingsValidationError(validated.issues);
|
|
2166
|
+
initializeClioHome();
|
|
2167
|
+
if (answers.apiKeyLiteral !== void 0 && descriptor.auth?.apiKeyRef) {
|
|
2168
|
+
const auth = openAuthStorage();
|
|
2169
|
+
auth.setApiKey(descriptor.auth.apiKeyRef, answers.apiKeyLiteral);
|
|
2170
|
+
if (credentialWriteFailed(auth, `credential for ${runtime.id} was not stored; target '${targetId}' not saved`)) {
|
|
2171
|
+
presenter.done("Nothing written");
|
|
2172
|
+
return 1;
|
|
2173
|
+
}
|
|
2174
|
+
printPlaintextCredentialWarning();
|
|
2175
|
+
}
|
|
2176
|
+
updateSettings((settings) => applyAnswers(settings, answers, descriptor, chatEligible));
|
|
2177
|
+
} catch (error) {
|
|
2178
|
+
presenter.fail("settings were not written", error instanceof Error ? error.message : String(error));
|
|
2179
|
+
presenter.done("Target settings not saved");
|
|
2180
|
+
return 1;
|
|
2181
|
+
}
|
|
2182
|
+
presenter.completedStep(`target ${targetId} saved, runtime ${runtime.id}`);
|
|
2183
|
+
if (answers.mode === "first" && chatEligible)
|
|
2184
|
+
presenter.completedStep(`chat runs on ${targetId}${answers.model ? `, model ${answers.model}` : ""}`);
|
|
2185
|
+
else if (!chatEligible)
|
|
2186
|
+
presenter.completedStep(`${runtime.id} cannot answer chat; ${targetId} is registered for dispatch only`);
|
|
2187
|
+
if (answers.mode === "first") presenter.completedStep(`fleet default is ${targetId}`);
|
|
2188
|
+
else presenter.note("Use Targets & Auth to change chat, fleet, or background defaults.");
|
|
2189
|
+
if (answers.mode === "first" && answers.thinking !== void 0)
|
|
2190
|
+
presenter.completedStep(`thinking level ${answers.thinking}`);
|
|
2191
|
+
if (answers.antigravity !== void 0) {
|
|
2192
|
+
presenter.completedStep(
|
|
2193
|
+
`world-knowledge bound read-only to ${answers.antigravity.targetId}/${answers.antigravity.model}`
|
|
2194
|
+
);
|
|
2195
|
+
}
|
|
2196
|
+
presenter.completedStep(`settings written to ${shortenPath(settingsPath())}`);
|
|
2197
|
+
if (contextWindowUndiscovered(descriptor, answers.probe ?? null)) {
|
|
2198
|
+
presenter.warn(
|
|
2199
|
+
`${targetId} reported no context window, so Clio will use the runtime default as a guess. Set the real one with \`clio-coder configure --id ${targetId} --runtime ${runtime.id} --context-window <N>\`.`
|
|
2200
|
+
);
|
|
2201
|
+
}
|
|
2202
|
+
presenter.commandAdvice("Start Clio:", "clio-coder");
|
|
2203
|
+
presenter.commandAdvice("Change any of this later:", "clio-coder configure");
|
|
2204
|
+
presenter.done("Done");
|
|
2205
|
+
return 0;
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
// src/cli/configure-prompts.ts
|
|
2209
|
+
init_esm_shims();
|
|
2210
|
+
import { createInterface as createInterface2 } from "node:readline/promises";
|
|
2211
|
+
var ConfigureNavigation = class extends Error {
|
|
2212
|
+
constructor(kind) {
|
|
2213
|
+
super(kind);
|
|
2214
|
+
this.kind = kind;
|
|
2215
|
+
}
|
|
2216
|
+
kind;
|
|
2217
|
+
};
|
|
2218
|
+
var ConfigurePrompts = class {
|
|
2219
|
+
constructor(input2, output3) {
|
|
2220
|
+
this.input = input2;
|
|
2221
|
+
this.output = output3;
|
|
2222
|
+
}
|
|
2223
|
+
input;
|
|
2224
|
+
output;
|
|
2225
|
+
get interactive() {
|
|
2226
|
+
return canSelect(this.input, this.output);
|
|
2227
|
+
}
|
|
2228
|
+
clearScreen() {
|
|
2229
|
+
if (this.interactive) this.output.write("\x1B[H\x1B[2J");
|
|
2230
|
+
}
|
|
2231
|
+
async question(query, options) {
|
|
2232
|
+
const rl = createInterface2({ input: this.input, output: this.output });
|
|
2233
|
+
try {
|
|
2234
|
+
return await new Promise((resolve, reject) => {
|
|
2235
|
+
rl.once("close", () => reject(new ConfigureNavigation("quit")));
|
|
2236
|
+
rl.once("SIGINT", () => reject(new ConfigureNavigation("quit")));
|
|
2237
|
+
rl.question(query, options ?? {}).then(resolve, reject);
|
|
2238
|
+
});
|
|
2239
|
+
} finally {
|
|
2240
|
+
rl.close();
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
async text(label, initial = "", mask = false) {
|
|
2244
|
+
if (!this.interactive) {
|
|
2245
|
+
const value = (await this.question(`${label}${initial ? ` [${initial}]` : ""}: `)).trim();
|
|
2246
|
+
if (/^(q|quit)$/iu.test(value)) throw new ConfigureNavigation("quit");
|
|
2247
|
+
return value || initial;
|
|
2248
|
+
}
|
|
2249
|
+
const result = await promptText({
|
|
2250
|
+
heading: ["", label],
|
|
2251
|
+
railPrefix: railPrefix(createLifecyclePresenter({ stream: this.output }).isPlain()),
|
|
2252
|
+
initial,
|
|
2253
|
+
mask,
|
|
2254
|
+
backLabel: "back",
|
|
2255
|
+
clearOnExit: true,
|
|
2256
|
+
input: this.input,
|
|
2257
|
+
output: this.output
|
|
2258
|
+
});
|
|
2259
|
+
if (result.kind !== "value") throw new ConfigureNavigation(result.kind);
|
|
2260
|
+
return result.value;
|
|
2261
|
+
}
|
|
2262
|
+
async choose(label, choices, current, searchable = false) {
|
|
2263
|
+
if (!this.interactive) return this.text(`${label} [${choices.join("|")}]`, current);
|
|
2264
|
+
const result = await promptSelect({
|
|
2265
|
+
heading: ["", label],
|
|
2266
|
+
railPrefix: railPrefix(createLifecyclePresenter({ stream: this.output }).isPlain()),
|
|
2267
|
+
choices: choices.map((value) => ({ value, label: value })),
|
|
2268
|
+
initialIndex: Math.max(0, choices.indexOf(current)),
|
|
2269
|
+
...searchable ? { searchable: true, maxVisible: 8 } : {},
|
|
2270
|
+
backLabel: "back",
|
|
2271
|
+
clearOnExit: true,
|
|
2272
|
+
input: this.input,
|
|
2273
|
+
output: this.output
|
|
2274
|
+
});
|
|
2275
|
+
if (result.kind !== "selected") throw new ConfigureNavigation(result.kind);
|
|
2276
|
+
return result.value;
|
|
2277
|
+
}
|
|
2278
|
+
};
|
|
2279
|
+
|
|
2280
|
+
// src/cli/configure-quick.ts
|
|
2281
|
+
init_esm_shims();
|
|
2282
|
+
function endpointUrl(value) {
|
|
2283
|
+
const url = new URL(value.includes("://") ? value : `http://${value}`);
|
|
2284
|
+
if (!["http:", "https:"].includes(url.protocol) || !url.hostname)
|
|
2285
|
+
throw new Error("Use an http:// or https:// endpoint URL.");
|
|
2286
|
+
if (url.username || url.password)
|
|
2287
|
+
throw new Error("Enter the endpoint without credentials; Clio asks for a key when needed.");
|
|
2288
|
+
return url.toString().replace(/\/$/u, "");
|
|
2289
|
+
}
|
|
2290
|
+
async function connect(url, key) {
|
|
2291
|
+
const settings = readSettings();
|
|
2292
|
+
const registry = getRuntimeRegistry();
|
|
2293
|
+
const matches = settings.targets.filter((target2) => {
|
|
2294
|
+
const runtime2 = registry.get(target2.runtime);
|
|
2295
|
+
if (!target2.url || !runtime2 || !isOrchestratorEligibleRuntime(runtime2)) return false;
|
|
2296
|
+
try {
|
|
2297
|
+
return endpointUrl(target2.url) === url;
|
|
2298
|
+
} catch {
|
|
2299
|
+
return false;
|
|
2300
|
+
}
|
|
2301
|
+
});
|
|
2302
|
+
const existing = matches.find((target2) => target2.id === settings.chat.target) ?? matches[0];
|
|
2303
|
+
let runtime = existing ? registry.get(existing.runtime) : null;
|
|
2304
|
+
let token = key;
|
|
2305
|
+
if (existing && runtime && token === void 0) {
|
|
2306
|
+
const auth = await openAuthStorage().resolveForTarget(resolveAuthTarget(existing, runtime), {
|
|
2307
|
+
includeFallback: false
|
|
2308
|
+
});
|
|
2309
|
+
token = auth.apiKey;
|
|
2310
|
+
}
|
|
2311
|
+
const ctx = { credentialsPresent: /* @__PURE__ */ new Set(), httpTimeoutMs: 5e3, authToken: token ?? "" };
|
|
2312
|
+
if (!runtime) {
|
|
2313
|
+
const root = targetRootUrl({ id: "quick", runtime: "openai-compat", url }) ?? url;
|
|
2314
|
+
const headers = token ? { Authorization: `Bearer ${token}` } : {};
|
|
2315
|
+
const native = await fingerprintNativeRuntime(root, headers);
|
|
2316
|
+
let id = native?.runtimeId ?? "openai-compat";
|
|
2317
|
+
if (!native) {
|
|
2318
|
+
const info = await probeJson({
|
|
2319
|
+
url: `${root}/v1/model/info`,
|
|
2320
|
+
headers,
|
|
2321
|
+
timeoutMs: 1e3
|
|
2322
|
+
});
|
|
2323
|
+
if (info.ok && info.data?.data?.some((row) => typeof row.model_name === "string" && row.model_info !== void 0))
|
|
2324
|
+
id = "litellm";
|
|
2325
|
+
}
|
|
2326
|
+
runtime = registry.get(id);
|
|
2327
|
+
}
|
|
2328
|
+
if (!runtime) throw new Error("No compatible runtime is available. Open Settings \u2192 Targets & Auth.");
|
|
2329
|
+
const target = existing ? structuredClone(existing) : {
|
|
2330
|
+
id: deriveTargetId(runtime.id, settings.targets),
|
|
2331
|
+
runtime: runtime.id,
|
|
2332
|
+
url
|
|
2333
|
+
};
|
|
2334
|
+
let probe = await runtime.probe?.(target, ctx) ?? {
|
|
2335
|
+
ok: false,
|
|
2336
|
+
error: "This connection does not support endpoint checks."
|
|
2337
|
+
};
|
|
2338
|
+
let models = probe.ok ? probe.models ?? await runtime.probeModels?.(target, ctx) ?? [] : [];
|
|
2339
|
+
if (!existing && runtime.id === "openai-compat" && !probe.ok && /HTTP (401|403|404)/u.test(probe.error ?? "")) {
|
|
2340
|
+
const anthropic = registry.get("anthropic-compat");
|
|
2341
|
+
if (anthropic) {
|
|
2342
|
+
const candidate = { ...target, runtime: anthropic.id };
|
|
2343
|
+
const catalog = await anthropic.probeModels?.(candidate, ctx) ?? [];
|
|
2344
|
+
if (catalog.length > 0) {
|
|
2345
|
+
runtime = anthropic;
|
|
2346
|
+
target.runtime = anthropic.id;
|
|
2347
|
+
target.id = deriveTargetId(anthropic.id, settings.targets);
|
|
2348
|
+
models = catalog;
|
|
2349
|
+
probe = { ok: true, models };
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
models = [...new Set(models)].filter((id) => probe.modelCapabilities?.[id]?.chat !== false);
|
|
2354
|
+
return { runtime, target, existing, probe, models };
|
|
2355
|
+
}
|
|
2356
|
+
async function runQuickConnect(prompts) {
|
|
2357
|
+
const initial = readSettings();
|
|
2358
|
+
const first = initial.targets.length === 0;
|
|
2359
|
+
const current = initial.targets.find((target) => target.id === initial.chat.target);
|
|
2360
|
+
let url = current?.url ?? "";
|
|
2361
|
+
let key;
|
|
2362
|
+
let connection;
|
|
2363
|
+
let model = "";
|
|
2364
|
+
let step = "url";
|
|
2365
|
+
let askedKey = false;
|
|
2366
|
+
let optionalKey = false;
|
|
2367
|
+
let notice = "";
|
|
2368
|
+
const presenter = createLifecyclePresenter({ stream: prompts.output });
|
|
2369
|
+
for (; ; ) {
|
|
2370
|
+
prompts.clearScreen();
|
|
2371
|
+
presenter.header("Quick Connect", "configure");
|
|
2372
|
+
presenter.note("Connect one model to power Clio. Change other settings whenever you need them.");
|
|
2373
|
+
if (notice) {
|
|
2374
|
+
presenter.warn(notice);
|
|
2375
|
+
notice = "";
|
|
2376
|
+
}
|
|
2377
|
+
try {
|
|
2378
|
+
if (step === "url") {
|
|
2379
|
+
presenter.note("LM Studio: localhost:1234 \xB7 Ollama: localhost:11434");
|
|
2380
|
+
const answer = await prompts.text("Endpoint URL", url);
|
|
2381
|
+
if (!answer) {
|
|
2382
|
+
notice = "Enter the endpoint URL shown by your model server or API provider.";
|
|
2383
|
+
continue;
|
|
2384
|
+
}
|
|
2385
|
+
try {
|
|
2386
|
+
url = endpointUrl(answer);
|
|
2387
|
+
} catch (error) {
|
|
2388
|
+
notice = error instanceof Error ? error.message : String(error);
|
|
2389
|
+
continue;
|
|
2390
|
+
}
|
|
2391
|
+
key = void 0;
|
|
2392
|
+
askedKey = false;
|
|
2393
|
+
connection = void 0;
|
|
2394
|
+
} else if (step === "key") {
|
|
2395
|
+
presenter.note(`Endpoint: ${url}`);
|
|
2396
|
+
if (optionalKey)
|
|
2397
|
+
presenter.note("Some APIs publish models publicly but require a key for chat. Leave blank for a keyless server.");
|
|
2398
|
+
key = await prompts.text("API key (saved locally when you choose Connect)", "", true) || void 0;
|
|
2399
|
+
if (!key && !optionalKey) {
|
|
2400
|
+
notice = "Enter a key, or press Escape to change the endpoint.";
|
|
2401
|
+
continue;
|
|
2402
|
+
}
|
|
2403
|
+
askedKey = true;
|
|
2404
|
+
}
|
|
2405
|
+
if (step === "url" || step === "key") {
|
|
2406
|
+
presenter.note("Checking the endpoint and reading its model list\u2026");
|
|
2407
|
+
connection = await connect(url, key);
|
|
2408
|
+
if (!connection.probe.ok) {
|
|
2409
|
+
if (connection.probe.authFailed || /HTTP (401|403)/u.test(connection.probe.error ?? "")) {
|
|
2410
|
+
optionalKey = false;
|
|
2411
|
+
notice = key ? "The endpoint rejected that key. Try again, or Escape to go back." : "This endpoint needs an API key.";
|
|
2412
|
+
step = "key";
|
|
2413
|
+
} else {
|
|
2414
|
+
notice = `Could not connect: ${connection.probe.error ?? "no reply"}. Check the URL and that the server is running.`;
|
|
2415
|
+
step = "url";
|
|
2416
|
+
}
|
|
2417
|
+
continue;
|
|
2418
|
+
}
|
|
2419
|
+
if (!connection.existing && !askedKey && connection.runtime.auth === "api-key" && connection.runtime.tier !== "local-native") {
|
|
2420
|
+
optionalKey = true;
|
|
2421
|
+
step = "key";
|
|
2422
|
+
continue;
|
|
2423
|
+
}
|
|
2424
|
+
if (connection.models.length === 0) {
|
|
2425
|
+
notice = "The endpoint offered no chat models. Load a model and retry. Servers without model discovery can use Settings \u2192 Targets & Auth.";
|
|
2426
|
+
step = "url";
|
|
2427
|
+
continue;
|
|
2428
|
+
}
|
|
2429
|
+
const preferred = connection.existing?.id === initial.chat.target ? initial.chat.model : connection.target.defaultModel;
|
|
2430
|
+
model = preferred && connection.models.includes(preferred) ? preferred : connection.models[0] ?? "";
|
|
2431
|
+
step = connection.models.length === 1 ? "save" : "model";
|
|
2432
|
+
continue;
|
|
2433
|
+
}
|
|
2434
|
+
if (!connection) {
|
|
2435
|
+
step = "url";
|
|
2436
|
+
continue;
|
|
2437
|
+
}
|
|
2438
|
+
if (step === "model") {
|
|
2439
|
+
presenter.note(`Connected: ${url} (${connection.runtime.displayName})`);
|
|
2440
|
+
model = await prompts.choose("Choose the model for Clio", connection.models, model, true);
|
|
2441
|
+
if (!connection.models.includes(model)) {
|
|
2442
|
+
notice = "Choose a model from the endpoint's live list.";
|
|
2443
|
+
continue;
|
|
2444
|
+
}
|
|
2445
|
+
step = "save";
|
|
2446
|
+
continue;
|
|
2447
|
+
}
|
|
2448
|
+
presenter.fields([
|
|
2449
|
+
["Endpoint", url],
|
|
2450
|
+
["Model", model],
|
|
2451
|
+
["Connection", "live model discovery passed"]
|
|
2452
|
+
]);
|
|
2453
|
+
presenter.note(
|
|
2454
|
+
first ? "Ready with recommended defaults: workspace edits, approval for unrecognized commands, one worker, $5 tracked session budget." : "Use this model for chat. Your other settings and role assignments stay in place."
|
|
2455
|
+
);
|
|
2456
|
+
const choice = await prompts.choose("Ready to connect", ["Connect", "Back"], "Connect");
|
|
2457
|
+
if (choice !== "Connect") throw new ConfigureNavigation("back");
|
|
2458
|
+
const descriptor = structuredClone(connection.target);
|
|
2459
|
+
if (!connection.existing) descriptor.defaultModel = model;
|
|
2460
|
+
if (key) {
|
|
2461
|
+
descriptor.auth = { ...descriptor.auth, apiKeyRef: targetApiKeyRef(descriptor.id, readSettings().targets) };
|
|
2462
|
+
delete descriptor.auth.apiKeyEnvVar;
|
|
2463
|
+
}
|
|
2464
|
+
const apply = (settings) => {
|
|
2465
|
+
const target = settings.targets.find((entry) => entry.id === descriptor.id);
|
|
2466
|
+
if (JSON.stringify(target) !== JSON.stringify(connection?.existing))
|
|
2467
|
+
throw new Error("This target changed during setup. Reopen Quick Connect to keep those changes.");
|
|
2468
|
+
applyTarget(settings, descriptor);
|
|
2469
|
+
setOrchestratorPointer(settings, descriptor, model);
|
|
2470
|
+
if (first && !settings.fleet.default.target) setWorkerDefaultPointer(settings, descriptor, model);
|
|
2471
|
+
};
|
|
2472
|
+
const preview = readSettings();
|
|
2473
|
+
apply(preview);
|
|
2474
|
+
const validated = validateSettings(preview);
|
|
2475
|
+
if (validated.issues.length) throw new SettingsValidationError(validated.issues);
|
|
2476
|
+
initializeClioHome();
|
|
2477
|
+
if (key && descriptor.auth?.apiKeyRef) {
|
|
2478
|
+
const auth = openAuthStorage();
|
|
2479
|
+
auth.setApiKey(descriptor.auth.apiKeyRef, key);
|
|
2480
|
+
if (credentialWriteFailed(auth, "The key was not saved; connection settings were not changed."))
|
|
2481
|
+
throw new Error("The key could not be saved. Check permissions on the credentials file and retry.");
|
|
2482
|
+
printPlaintextCredentialWarning();
|
|
2483
|
+
}
|
|
2484
|
+
updateSettings(apply);
|
|
2485
|
+
presenter.done(`Connected: ${descriptor.id} / ${model}`);
|
|
2486
|
+
presenter.commandAdvice("Start Clio:", "clio-coder");
|
|
2487
|
+
return "connected";
|
|
2488
|
+
} catch (error) {
|
|
2489
|
+
if (!(error instanceof ConfigureNavigation)) {
|
|
2490
|
+
notice = error instanceof Error ? error.message : String(error);
|
|
2491
|
+
step = "url";
|
|
2492
|
+
continue;
|
|
2493
|
+
}
|
|
2494
|
+
if (error.kind === "quit" || step === "url") {
|
|
2495
|
+
presenter.done("Quick Connect cancelled; connection settings not saved.");
|
|
2496
|
+
return error.kind;
|
|
2497
|
+
}
|
|
2498
|
+
step = step === "save" && (connection?.models.length ?? 0) > 1 ? "model" : step === "model" || step === "save" ? askedKey ? "key" : "url" : "url";
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
// src/cli/configure.ts
|
|
2504
|
+
var HELP = `clio-coder configure
|
|
2505
|
+
|
|
2506
|
+
Configure model targets and runtime settings for chat and fleet dispatch.
|
|
2507
|
+
|
|
2508
|
+
Usage:
|
|
2509
|
+
clio-coder configure Quick Connect, Settings, or Diagnostics
|
|
2510
|
+
clio-coder configure --quick connect an endpoint with recommended defaults
|
|
2511
|
+
clio-coder configure --settings open the complete settings menu
|
|
2512
|
+
clio-coder configure --section <name> open one section directly:
|
|
2513
|
+
targets, models, chat, fleet,
|
|
2514
|
+
permissions, panes, skills, diagnostics, advanced
|
|
2515
|
+
Without a terminal this prints the
|
|
2516
|
+
section's values and exits.
|
|
2517
|
+
clio-coder configure --json emit the effective settings as JSON
|
|
2518
|
+
clio-coder configure --edit edit all user settings in VISUAL/EDITOR;
|
|
2519
|
+
validate and review before saving
|
|
2520
|
+
clio-coder configure --interop review detected coding agents as delegation peers
|
|
2521
|
+
clio-coder configure --list list target runtimes (user-facing only)
|
|
2522
|
+
clio-coder configure --list --all list every registered runtime including aliases
|
|
2523
|
+
clio-coder configure --id <targetId> [flags] --runtime <runtimeId>
|
|
2524
|
+
clio-coder configure --help, -h show this message
|
|
2525
|
+
|
|
2526
|
+
In the interactive menus: arrow keys move, enter opens, escape goes back, q
|
|
2527
|
+
quits. Where the terminal cannot support that, the same menus are numbered and
|
|
2528
|
+
answered by typing a number, b for back, or q to quit.
|
|
2529
|
+
|
|
2530
|
+
Non-interactive flags:
|
|
2531
|
+
--id <targetId> target id to register (required when non-interactive)
|
|
2532
|
+
--runtime <runtimeId> runtime to use when registering non-interactively
|
|
2533
|
+
--url <host> target base URL (http(s):// or ws://)
|
|
2534
|
+
--model <wireModelId> default model id for this target
|
|
2535
|
+
--orchestrator-model <id> model to use when setting chat default
|
|
2536
|
+
--background-model <id> model to use for proactive task memory
|
|
2537
|
+
--fleet-model <id> model to use when setting fleet default
|
|
2538
|
+
(mutually exclusive with --agent-profile)
|
|
2539
|
+
--agent-profile <name> save this target as a named fleet profile
|
|
2540
|
+
--agent-profile-model <id> model to use for --agent-profile
|
|
2541
|
+
--bind-agent <agentId> bind this --agent-profile to an agent
|
|
2542
|
+
--api-key-env <VAR> read API key from this env var at call time
|
|
2543
|
+
--api-key <literal> store API key in credentials.yaml
|
|
2544
|
+
--force save a model outside the runtime catalog, or one the
|
|
2545
|
+
target does not advertise, without refusing
|
|
2546
|
+
--gateway mark the target as a gateway
|
|
2547
|
+
--lifecycle <user-managed|clio-coder-managed>
|
|
2548
|
+
resident model lifecycle policy
|
|
2549
|
+
--set-orchestrator use this target for chat
|
|
2550
|
+
--set-background use this target for proactive task memory
|
|
2551
|
+
--set-fleet-default use this target for the fleet default
|
|
2552
|
+
--context-window <N> capability override
|
|
2553
|
+
--max-tokens <N> output token capability override
|
|
2554
|
+
--reasoning <true|false> capability override
|
|
2555
|
+
`;
|
|
2556
|
+
function parseSetupArgs(argv) {
|
|
2557
|
+
const out = {
|
|
2558
|
+
positional: [],
|
|
2559
|
+
help: false,
|
|
2560
|
+
list: false,
|
|
2561
|
+
all: false,
|
|
2562
|
+
interop: false,
|
|
2563
|
+
json: false,
|
|
2564
|
+
edit: false,
|
|
2565
|
+
quick: false,
|
|
2566
|
+
settings: false,
|
|
2567
|
+
force: false,
|
|
2568
|
+
gateway: false,
|
|
2569
|
+
setOrchestrator: false,
|
|
2570
|
+
setBackground: false,
|
|
2571
|
+
setWorkerDefault: false
|
|
2572
|
+
};
|
|
2573
|
+
for (let i = 0; i < argv.length; i++) {
|
|
2574
|
+
const a = argv[i];
|
|
2575
|
+
const need = () => {
|
|
2576
|
+
const v = argv[i + 1];
|
|
2577
|
+
if (v === void 0) throw new Error(`${a} requires a value`);
|
|
2578
|
+
i += 1;
|
|
2579
|
+
return v;
|
|
2580
|
+
};
|
|
2581
|
+
switch (a) {
|
|
2582
|
+
case "--help":
|
|
2583
|
+
case "-h":
|
|
2584
|
+
out.help = true;
|
|
2585
|
+
break;
|
|
2586
|
+
case "--json":
|
|
2587
|
+
out.json = true;
|
|
2588
|
+
break;
|
|
2589
|
+
case "--edit":
|
|
2590
|
+
out.edit = true;
|
|
2591
|
+
break;
|
|
2592
|
+
case "--quick":
|
|
2593
|
+
out.quick = true;
|
|
2594
|
+
break;
|
|
2595
|
+
case "--settings":
|
|
2596
|
+
out.settings = true;
|
|
2597
|
+
break;
|
|
2598
|
+
case "--section":
|
|
2599
|
+
out.section = need();
|
|
2600
|
+
break;
|
|
2601
|
+
case "--list":
|
|
2602
|
+
out.list = true;
|
|
2603
|
+
break;
|
|
2604
|
+
case "--all":
|
|
2605
|
+
out.all = true;
|
|
2606
|
+
break;
|
|
2607
|
+
case "--interop":
|
|
2608
|
+
out.interop = true;
|
|
2609
|
+
break;
|
|
2610
|
+
case "--remove":
|
|
2611
|
+
out.remove = need();
|
|
2612
|
+
break;
|
|
2613
|
+
case "--rename":
|
|
2614
|
+
out.renameOld = need();
|
|
2615
|
+
out.renameNew = need();
|
|
2616
|
+
break;
|
|
2617
|
+
case "--id":
|
|
2618
|
+
out.id = need();
|
|
2619
|
+
break;
|
|
2620
|
+
case "--runtime":
|
|
2621
|
+
out.runtime = need();
|
|
2622
|
+
break;
|
|
2623
|
+
case "--url":
|
|
2624
|
+
out.url = need();
|
|
2625
|
+
break;
|
|
2626
|
+
case "--model":
|
|
2627
|
+
out.model = need();
|
|
2628
|
+
break;
|
|
2629
|
+
case "--orchestrator-model":
|
|
2630
|
+
out.orchestratorModel = need();
|
|
2631
|
+
break;
|
|
2632
|
+
case "--background-model":
|
|
2633
|
+
out.backgroundModel = need();
|
|
2634
|
+
break;
|
|
2635
|
+
case "--fleet-model":
|
|
2636
|
+
out.workerModel = need();
|
|
2637
|
+
break;
|
|
2638
|
+
case "--agent-profile":
|
|
2639
|
+
out.workerProfile = need();
|
|
2640
|
+
break;
|
|
2641
|
+
case "--agent-profile-model":
|
|
2642
|
+
out.workerProfileModel = need();
|
|
2643
|
+
break;
|
|
2644
|
+
case "--bind-agent":
|
|
2645
|
+
out.bindAgent = need();
|
|
2646
|
+
break;
|
|
2647
|
+
case "--api-key-env":
|
|
2648
|
+
out.apiKeyEnv = need();
|
|
2649
|
+
break;
|
|
2650
|
+
case "--api-key":
|
|
2651
|
+
out.apiKey = need();
|
|
2652
|
+
break;
|
|
2653
|
+
case "--force":
|
|
2654
|
+
out.force = true;
|
|
2655
|
+
break;
|
|
2656
|
+
case "--gateway":
|
|
2657
|
+
out.gateway = true;
|
|
2658
|
+
break;
|
|
2659
|
+
case "--lifecycle": {
|
|
2660
|
+
const v = need();
|
|
2661
|
+
if (v !== "user-managed" && v !== "clio-coder-managed") {
|
|
2662
|
+
throw new Error("--lifecycle must be user-managed or clio-coder-managed");
|
|
2663
|
+
}
|
|
2664
|
+
out.lifecycle = v;
|
|
2665
|
+
break;
|
|
2666
|
+
}
|
|
2667
|
+
case "--set-orchestrator":
|
|
2668
|
+
out.setOrchestrator = true;
|
|
2669
|
+
break;
|
|
2670
|
+
case "--set-background":
|
|
2671
|
+
out.setBackground = true;
|
|
2672
|
+
break;
|
|
2673
|
+
case "--set-fleet-default":
|
|
2674
|
+
out.setWorkerDefault = true;
|
|
2675
|
+
break;
|
|
2676
|
+
case "--context-window": {
|
|
2677
|
+
const n = Number(need());
|
|
2678
|
+
if (!Number.isFinite(n) || n <= 0) throw new Error("--context-window must be a positive number");
|
|
2679
|
+
out.contextWindow = Math.floor(n);
|
|
2680
|
+
break;
|
|
2681
|
+
}
|
|
2682
|
+
case "--max-tokens": {
|
|
2683
|
+
const n = Number(need());
|
|
2684
|
+
if (!Number.isFinite(n) || n <= 0) throw new Error("--max-tokens must be a positive number");
|
|
2685
|
+
out.maxTokens = Math.floor(n);
|
|
2686
|
+
break;
|
|
2687
|
+
}
|
|
2688
|
+
case "--reasoning": {
|
|
2689
|
+
const v = need().toLowerCase();
|
|
2690
|
+
if (v !== "true" && v !== "false") throw new Error("--reasoning must be true or false");
|
|
2691
|
+
out.reasoning = v === "true";
|
|
2692
|
+
break;
|
|
2693
|
+
}
|
|
2694
|
+
default:
|
|
2695
|
+
if (a.startsWith("-")) throw new Error(`unknown flag: ${a}`);
|
|
2696
|
+
out.positional.push(a);
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
return out;
|
|
2700
|
+
}
|
|
2701
|
+
function ensureRegistryPopulated() {
|
|
2702
|
+
registerClioOAuthProviders();
|
|
2703
|
+
const registry = getRuntimeRegistry();
|
|
2704
|
+
if (registry.list().length === 0) registerBuiltinRuntimes(registry);
|
|
2705
|
+
}
|
|
2706
|
+
var RUNTIME_LIST_CAPTION = "every registered runtime. run `clio-coder auth list` for the ones clio authenticates itself; the rest authenticate through their own tool (claude-cli, aws-sdk) or need no credential.";
|
|
2707
|
+
function printRuntimeList(includeHidden) {
|
|
2708
|
+
const settings = readSettings();
|
|
2709
|
+
const auth = openAuthStorage();
|
|
2710
|
+
const rows = [];
|
|
2711
|
+
for (const entry of listProviderSupportEntries(getRuntimeRegistry().list(), { includeHidden })) {
|
|
2712
|
+
const runtime = getRuntimeRegistry().get(entry.runtimeId);
|
|
2713
|
+
const status = runtime && entry.connectable ? auth.statusForTarget(resolveRuntimeAuthTarget(runtime), {
|
|
2714
|
+
includeFallback: false
|
|
2715
|
+
}) : null;
|
|
2716
|
+
const authLabel = runtime?.auth === "oauth" ? status?.available ? "connected" : "login" : runtime?.auth === "api-key" ? status?.available ? "credential" : targetRequiresAuth({ id: entry.runtimeId, runtime: entry.runtimeId }, runtime) ? "needs-key" : "key-optional" : runtime?.auth ?? "none";
|
|
2717
|
+
rows.push({
|
|
2718
|
+
group: supportGroupLabel(entry.group),
|
|
2719
|
+
runtimeId: entry.runtimeId,
|
|
2720
|
+
label: entry.label,
|
|
2721
|
+
auth: authLabel,
|
|
2722
|
+
targets: configuredTargetsForRuntime(settings, entry.runtimeId).length,
|
|
2723
|
+
models: describeRuntimeModels(entry, 2)
|
|
2724
|
+
});
|
|
2725
|
+
}
|
|
2726
|
+
const width = terminalColumns();
|
|
2727
|
+
for (const line of formatRuntimeList(rows, width)) {
|
|
2728
|
+
process.stdout.write(`${line}
|
|
2729
|
+
`);
|
|
2730
|
+
}
|
|
2731
|
+
for (const line of wrapPlain(RUNTIME_LIST_CAPTION, width)) {
|
|
2732
|
+
process.stdout.write(`${line}
|
|
2733
|
+
`);
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
function printSummary(settings, descriptor, probe) {
|
|
2737
|
+
process.stdout.write(`
|
|
2738
|
+
saved target ${descriptor.id} (runtime=${descriptor.runtime})
|
|
2739
|
+
`);
|
|
2740
|
+
if (descriptor.url) process.stdout.write(` url ${descriptor.url}
|
|
2741
|
+
`);
|
|
2742
|
+
if (descriptor.defaultModel) process.stdout.write(` model ${descriptor.defaultModel}
|
|
2743
|
+
`);
|
|
2744
|
+
if (descriptor.auth?.apiKeyEnvVar) process.stdout.write(` apiKeyEnv ${descriptor.auth.apiKeyEnvVar}
|
|
2745
|
+
`);
|
|
2746
|
+
if (descriptor.gateway) process.stdout.write(" gateway true\n");
|
|
2747
|
+
if (descriptor.lifecycle) process.stdout.write(` lifecycle ${descriptor.lifecycle}
|
|
2748
|
+
`);
|
|
2749
|
+
if (probe) {
|
|
2750
|
+
for (const line of probeLines(descriptor, probe)) process.stdout.write(` ${line}
|
|
2751
|
+
`);
|
|
2752
|
+
}
|
|
2753
|
+
warnUndiscoveredContextWindow(descriptor, probe);
|
|
2754
|
+
if (settings.chat.target === descriptor.id) process.stdout.write(" orchestrator target\n");
|
|
2755
|
+
if (settings.context.memory.target === descriptor.id) process.stdout.write(" background memory target\n");
|
|
2756
|
+
if (settings.fleet.default.target === descriptor.id) process.stdout.write(" fleet default\n");
|
|
2757
|
+
for (const [name, profile] of Object.entries(settings.fleet.profiles)) {
|
|
2758
|
+
if (profile.target === descriptor.id) process.stdout.write(` fleet profile ${name}
|
|
2759
|
+
`);
|
|
2760
|
+
}
|
|
2761
|
+
process.stdout.write(`
|
|
2762
|
+
settings written to ${settingsPath()}
|
|
2763
|
+
`);
|
|
2764
|
+
}
|
|
2765
|
+
function resolveModelChoice(answer, wireModels, defaultValue) {
|
|
2766
|
+
if (answer.length === 0) return defaultValue;
|
|
2767
|
+
const numeric = Number(answer);
|
|
2768
|
+
if (Number.isInteger(numeric) && numeric >= 1 && numeric <= wireModels.length) {
|
|
2769
|
+
return wireModels[numeric - 1];
|
|
2770
|
+
}
|
|
2771
|
+
return answer;
|
|
2772
|
+
}
|
|
2773
|
+
async function askModelChoice(rl, label, wireModels, defaultValue) {
|
|
2774
|
+
const answer = await ask(rl, `${label} (number or id)`, defaultValue ?? "");
|
|
2775
|
+
if (answer === null) return null;
|
|
2776
|
+
return resolveModelChoice(answer, wireModels, defaultValue) ?? "";
|
|
2777
|
+
}
|
|
2778
|
+
function refuseCatalogSeededModel(runtime, support) {
|
|
2779
|
+
printError(
|
|
2780
|
+
`--model is required for ${runtime.id}: its ${support.modelHints.length} model ids come from the provider catalog in name order, which recommends none of them`
|
|
2781
|
+
);
|
|
2782
|
+
process.stderr.write(
|
|
2783
|
+
` run \`clio-coder configure --runtime ${runtime.id}\` with no other flags to choose from the full list
|
|
2784
|
+
`
|
|
2785
|
+
);
|
|
2786
|
+
}
|
|
2787
|
+
async function runNonInteractive(runtime, args) {
|
|
2788
|
+
if (!args.id) {
|
|
2789
|
+
printError("--id is required when passing flags non-interactively");
|
|
2790
|
+
return 2;
|
|
2791
|
+
}
|
|
2792
|
+
if (args.workerProfileModel !== void 0 && args.workerProfile === void 0) {
|
|
2793
|
+
printError("--agent-profile-model requires --agent-profile");
|
|
2794
|
+
return 2;
|
|
2795
|
+
}
|
|
2796
|
+
if (args.bindAgent !== void 0 && args.workerProfile === void 0) {
|
|
2797
|
+
printError("--bind-agent requires --agent-profile");
|
|
2798
|
+
return 2;
|
|
2799
|
+
}
|
|
2800
|
+
if (args.workerProfile !== void 0 && args.workerProfile.trim().length === 0) {
|
|
2801
|
+
printError("--agent-profile must be non-empty");
|
|
2802
|
+
return 2;
|
|
2803
|
+
}
|
|
2804
|
+
if (args.workerProfile !== void 0 && args.workerModel !== void 0) {
|
|
2805
|
+
printError(
|
|
2806
|
+
"--fleet-model and --agent-profile conflict; use --agent-profile-model for the profile, or drop --agent-profile to set the fleet default"
|
|
2807
|
+
);
|
|
2808
|
+
return 2;
|
|
2809
|
+
}
|
|
2810
|
+
initializeClioHome();
|
|
2811
|
+
const settings = readSettings();
|
|
2812
|
+
const auth = openAuthStorage();
|
|
2813
|
+
const support = buildProviderSupportEntry(runtime);
|
|
2814
|
+
const existing = settings.targets.find((e) => e.id === args.id);
|
|
2815
|
+
if (existing && (getRuntimeRegistry().get(existing.runtime)?.id ?? existing.runtime) !== runtime.id) {
|
|
2816
|
+
printError(`target ${args.id} already exists with runtime ${existing.runtime}`);
|
|
2817
|
+
return 2;
|
|
2818
|
+
}
|
|
2819
|
+
let url = args.url ? normalizeUrl(args.url, runtime.id) : existing?.url;
|
|
2820
|
+
if (!url && support.supportsCustomUrl) {
|
|
2821
|
+
url = defaultUrlFor(runtime.id);
|
|
2822
|
+
}
|
|
2823
|
+
if (url && runtime.id === "lmstudio") {
|
|
2824
|
+
const greeting = await greetLmStudio(
|
|
2825
|
+
{ id: args.id, runtime: runtime.id, url },
|
|
2826
|
+
{ credentialsPresent: /* @__PURE__ */ new Set(), httpTimeoutMs: 750 }
|
|
2827
|
+
);
|
|
2828
|
+
if (!greeting.ok) {
|
|
2829
|
+
printError(`refusing to save LM Studio target '${args.id}': ${url} did not return the LM Studio greeting`);
|
|
2830
|
+
return 2;
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
if (url && (runtime.id === "openai-compat" || runtime.id === "anthropic-compat")) {
|
|
2834
|
+
const fingerprint = await fingerprintNativeRuntime(url);
|
|
2835
|
+
if (fingerprint) {
|
|
2836
|
+
process.stdout.write(
|
|
2837
|
+
`note: detected ${fingerprint.displayName} at ${url}; consider \`clio-coder targets convert ${args.id} --runtime ${fingerprint.runtimeId}\` for proper resident-model lifecycle
|
|
2838
|
+
`
|
|
2839
|
+
);
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
const authStatus = auth.statusForTarget(
|
|
2843
|
+
existing ? resolveAuthTarget(existing, runtime) : resolveRuntimeAuthTarget(runtime),
|
|
2844
|
+
{ includeFallback: false }
|
|
2845
|
+
);
|
|
2846
|
+
const apiKeyEnv = args.apiKeyEnv ?? existing?.auth?.apiKeyEnvVar;
|
|
2847
|
+
const apiKeyRef = runtime.auth === "api-key" && (args.apiKey || existing?.auth?.apiKeyRef || authStatus.source === "stored-api-key") ? args.apiKey ? targetApiKeyRef(args.id, settings.targets) : existing?.auth?.apiKeyRef ?? runtime.id : void 0;
|
|
2848
|
+
const oauthProfile = runtime.auth === "oauth" ? existing?.auth?.oauthProfile ?? runtime.oauthProviderId ?? runtime.id : void 0;
|
|
2849
|
+
const seed = {
|
|
2850
|
+
...existing,
|
|
2851
|
+
...buildDescriptor(runtime, args.id, {
|
|
2852
|
+
...url !== void 0 ? { url } : {},
|
|
2853
|
+
...args.model !== void 0 ? { model: args.model } : existing?.defaultModel ? { model: existing.defaultModel } : support.defaultModel ? { model: support.defaultModel } : {},
|
|
2854
|
+
...apiKeyEnv !== void 0 ? { apiKeyEnv } : {},
|
|
2855
|
+
...apiKeyRef !== void 0 ? { apiKeyRef } : {},
|
|
2856
|
+
...oauthProfile !== void 0 ? { oauthProfile } : {},
|
|
2857
|
+
gateway: args.gateway || existing?.gateway === true,
|
|
2858
|
+
...args.lifecycle !== void 0 ? { lifecycle: args.lifecycle } : existing?.lifecycle !== void 0 ? { lifecycle: existing.lifecycle } : {},
|
|
2859
|
+
...args.contextWindow !== void 0 ? { contextWindow: args.contextWindow } : {},
|
|
2860
|
+
...args.maxTokens !== void 0 ? { maxTokens: args.maxTokens } : {},
|
|
2861
|
+
...args.reasoning !== void 0 ? { reasoning: args.reasoning } : {},
|
|
2862
|
+
...existing?.lmstudio ? { lmstudio: existing.lmstudio } : {},
|
|
2863
|
+
...existing?.litellm ? { litellm: existing.litellm } : {}
|
|
2864
|
+
})
|
|
2865
|
+
};
|
|
2866
|
+
seed.capabilities = { ...existing?.capabilities, ...seed.capabilities };
|
|
2867
|
+
if (seed.auth) seed.auth = { ...existing?.auth, ...seed.auth };
|
|
2868
|
+
const inventory = await resolveSupportedWireModels(runtime, seed, existing, args.apiKey);
|
|
2869
|
+
const wireModels = inventory.models;
|
|
2870
|
+
const model = args.model ?? existing?.defaultModel ?? (inventory.source === "probe" ? wireModels[0] : support.defaultModel) ?? (support.modelSource === "catalog" ? void 0 : wireModels[0]);
|
|
2871
|
+
if (model === void 0 && support.modelSource === "catalog") {
|
|
2872
|
+
refuseCatalogSeededModel(runtime, support);
|
|
2873
|
+
return 2;
|
|
2874
|
+
}
|
|
2875
|
+
if (!validateResolvedModel(runtime, seed, model, args.force, inventory)) return 2;
|
|
2876
|
+
if (!validateContextWindowOverride(runtime, model, args.contextWindow, args.force)) return 2;
|
|
2877
|
+
const descriptor = {
|
|
2878
|
+
...existing,
|
|
2879
|
+
...buildDescriptor(runtime, args.id, {
|
|
2880
|
+
...url !== void 0 ? { url } : {},
|
|
2881
|
+
...model ? { model } : {},
|
|
2882
|
+
...apiKeyEnv !== void 0 ? { apiKeyEnv } : {},
|
|
2883
|
+
...apiKeyRef !== void 0 ? { apiKeyRef } : {},
|
|
2884
|
+
...oauthProfile !== void 0 ? { oauthProfile } : {},
|
|
2885
|
+
gateway: args.gateway || existing?.gateway === true,
|
|
2886
|
+
...args.lifecycle !== void 0 ? { lifecycle: args.lifecycle } : existing?.lifecycle !== void 0 ? { lifecycle: existing.lifecycle } : {},
|
|
2887
|
+
...args.contextWindow !== void 0 ? { contextWindow: args.contextWindow } : {},
|
|
2888
|
+
...args.maxTokens !== void 0 ? { maxTokens: args.maxTokens } : {},
|
|
2889
|
+
...args.reasoning !== void 0 ? { reasoning: args.reasoning } : {},
|
|
2890
|
+
...existing?.lmstudio ? { lmstudio: existing.lmstudio } : {},
|
|
2891
|
+
...existing?.litellm ? { litellm: existing.litellm } : {}
|
|
2892
|
+
})
|
|
2893
|
+
};
|
|
2894
|
+
descriptor.capabilities = { ...existing?.capabilities, ...descriptor.capabilities };
|
|
2895
|
+
if (descriptor.auth) descriptor.auth = { ...existing?.auth, ...descriptor.auth };
|
|
2896
|
+
const setOrchestrator = args.setOrchestrator || args.orchestratorModel !== void 0;
|
|
2897
|
+
const setBackground = args.setBackground || args.backgroundModel !== void 0;
|
|
2898
|
+
if ((setOrchestrator || setBackground) && !isOrchestratorEligibleRuntime(runtime)) {
|
|
2899
|
+
printError(
|
|
2900
|
+
`cannot use target '${descriptor.id}' as a chat or background target because runtime '${runtime.id}' is not an HTTP/native runtime`
|
|
2901
|
+
);
|
|
2902
|
+
return 1;
|
|
2903
|
+
}
|
|
2904
|
+
try {
|
|
2905
|
+
assertOrchestratorReplacementEligible(settings, descriptor);
|
|
2906
|
+
} catch (error) {
|
|
2907
|
+
printError(error instanceof Error ? error.message : String(error));
|
|
2908
|
+
return 1;
|
|
2909
|
+
}
|
|
2910
|
+
if (args.apiKey && apiKeyRef) {
|
|
2911
|
+
auth.setApiKey(apiKeyRef, args.apiKey);
|
|
2912
|
+
if (credentialWriteFailed(auth, `credential for ${runtime.id} was not stored; target '${descriptor.id}' not saved`))
|
|
2913
|
+
return 1;
|
|
2914
|
+
printPlaintextCredentialWarning();
|
|
2915
|
+
}
|
|
2916
|
+
const setWorkerDefault = args.setWorkerDefault || args.workerProfile === void 0 && args.workerModel !== void 0;
|
|
2917
|
+
const applyConfiguration = (target) => {
|
|
2918
|
+
applyTarget(target, descriptor);
|
|
2919
|
+
if (setOrchestrator)
|
|
2920
|
+
setOrchestratorPointer(target, descriptor, args.orchestratorModel ?? descriptor.defaultModel ?? null);
|
|
2921
|
+
if (setBackground) setBackgroundPointer(target, descriptor, args.backgroundModel ?? descriptor.defaultModel ?? null);
|
|
2922
|
+
if (setWorkerDefault)
|
|
2923
|
+
setWorkerDefaultPointer(target, descriptor, args.workerModel ?? descriptor.defaultModel ?? null);
|
|
2924
|
+
if (args.workerProfile !== void 0) {
|
|
2925
|
+
setWorkerProfilePointer(
|
|
2926
|
+
target,
|
|
2927
|
+
args.workerProfile,
|
|
2928
|
+
descriptor,
|
|
2929
|
+
args.workerProfileModel ?? descriptor.defaultModel ?? null
|
|
2930
|
+
);
|
|
2931
|
+
if (args.bindAgent !== void 0) bindAgentProfileInSettings(target, args.bindAgent, args.workerProfile);
|
|
2932
|
+
}
|
|
2933
|
+
};
|
|
2934
|
+
applyConfiguration(settings);
|
|
2935
|
+
updateSettings(applyConfiguration);
|
|
2936
|
+
const probe = await runtimeProbe(runtime, descriptor, args.apiKey);
|
|
2937
|
+
if (probe?.ok && probe.models) {
|
|
2938
|
+
recordTargetModelSnapshot(descriptor, probe.models, probe.modelLabels ? { modelLabels: probe.modelLabels } : {});
|
|
2939
|
+
}
|
|
2940
|
+
printSummary(settings, descriptor, probe);
|
|
2941
|
+
if (runtime.auth === "oauth" && !auth.statusForTarget(existing ? resolveAuthTarget(existing, runtime) : resolveRuntimeAuthTarget(runtime), {
|
|
2942
|
+
includeFallback: false
|
|
2943
|
+
}).available) {
|
|
2944
|
+
process.stdout.write(
|
|
2945
|
+
`note: authenticate ${runtime.id} with \`clio-coder auth login ${runtime.id}\` before using this target
|
|
2946
|
+
`
|
|
2947
|
+
);
|
|
2948
|
+
}
|
|
2949
|
+
printOk(`target ${args.id} saved`);
|
|
2950
|
+
return 0;
|
|
2951
|
+
}
|
|
2952
|
+
async function pickRuntime(rl) {
|
|
2953
|
+
const registry = getRuntimeRegistry();
|
|
2954
|
+
const entries = listProviderSupportEntries(registry.list());
|
|
2955
|
+
return pickRuntimeFromEntries(rl, entries, "\nSupported runtimes:");
|
|
2956
|
+
}
|
|
2957
|
+
async function pickRuntimeFromEntries(rl, entries, heading) {
|
|
2958
|
+
const registry = getRuntimeRegistry();
|
|
2959
|
+
if (entries.length === 0) {
|
|
2960
|
+
process.stderr.write("no runtimes available in this category\n");
|
|
2961
|
+
return null;
|
|
2962
|
+
}
|
|
2963
|
+
process.stdout.write(`${heading}
|
|
2964
|
+
`);
|
|
2965
|
+
const menu = formatRuntimeMenu(
|
|
2966
|
+
entries.map((entry) => ({
|
|
2967
|
+
group: supportGroupLabel(entry.group),
|
|
2968
|
+
runtimeId: entry.runtimeId,
|
|
2969
|
+
summary: entry.summary
|
|
2970
|
+
})),
|
|
2971
|
+
terminalColumns()
|
|
2972
|
+
);
|
|
2973
|
+
for (const line of menu) process.stdout.write(`${line}
|
|
2974
|
+
`);
|
|
2975
|
+
const allowedIds = new Set(entries.map((entry) => entry.runtimeId));
|
|
2976
|
+
const defaultRuntimeId = entries.find((entry) => entry.featured)?.runtimeId ?? "";
|
|
2977
|
+
for (; ; ) {
|
|
2978
|
+
const answer = await ask(rl, "\nSelection (number or runtime id)", defaultRuntimeId);
|
|
2979
|
+
if (answer === null) return null;
|
|
2980
|
+
if (answer.length === 0) {
|
|
2981
|
+
process.stderr.write(`pick a number from 1 to ${entries.length}, or type a runtime id
|
|
2982
|
+
`);
|
|
2983
|
+
continue;
|
|
2984
|
+
}
|
|
2985
|
+
const numeric = Number(answer);
|
|
2986
|
+
if (Number.isInteger(numeric) && numeric >= 1 && numeric <= entries.length) {
|
|
2987
|
+
const picked = entries[numeric - 1];
|
|
2988
|
+
if (picked) {
|
|
2989
|
+
const runtime = registry.get(picked.runtimeId);
|
|
2990
|
+
if (runtime) return runtime;
|
|
2991
|
+
}
|
|
2992
|
+
}
|
|
2993
|
+
if (allowedIds.has(answer)) {
|
|
2994
|
+
const match = registry.get(answer);
|
|
2995
|
+
if (match) return match;
|
|
2996
|
+
}
|
|
2997
|
+
process.stderr.write(`unknown runtime id for this category: ${answer}
|
|
2998
|
+
`);
|
|
2999
|
+
}
|
|
3000
|
+
}
|
|
3001
|
+
async function pickCategory(rl) {
|
|
3002
|
+
process.stdout.write("\nHow will you connect Clio to a model?\n\n");
|
|
3003
|
+
for (const line of formatCategoryMenu(terminalColumns())) process.stdout.write(`${line}
|
|
3004
|
+
`);
|
|
3005
|
+
for (; ; ) {
|
|
3006
|
+
const answer = await ask(rl, "\nSelection", "1");
|
|
3007
|
+
if (answer === null) return null;
|
|
3008
|
+
if (answer.length === 0) continue;
|
|
3009
|
+
const category = matchCategoryChoice(answer);
|
|
3010
|
+
if (category) return category;
|
|
3011
|
+
process.stderr.write(`invalid choice: ${answer}
|
|
3012
|
+
`);
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3015
|
+
async function pickRuntimeViaCategory(rl) {
|
|
3016
|
+
const registry = getRuntimeRegistry();
|
|
3017
|
+
const allEntries2 = listProviderSupportEntries(registry.list());
|
|
3018
|
+
const category = await pickCategory(rl);
|
|
3019
|
+
if (category === null) return null;
|
|
3020
|
+
if (category === "all") return pickRuntime(rl);
|
|
3021
|
+
const filtered = runtimesForCategory(allEntries2, category);
|
|
3022
|
+
if (filtered.length === 0) {
|
|
3023
|
+
process.stderr.write("no runtimes available for that category; falling back to full list\n");
|
|
3024
|
+
return pickRuntime(rl);
|
|
3025
|
+
}
|
|
3026
|
+
if (category === "chatgpt") {
|
|
3027
|
+
const only = filtered[0];
|
|
3028
|
+
if (only) {
|
|
3029
|
+
const runtime = registry.get(only.runtimeId);
|
|
3030
|
+
if (runtime) {
|
|
3031
|
+
process.stdout.write(`
|
|
3032
|
+
Using ${runtime.id} (${only.summary}).
|
|
3033
|
+
`);
|
|
3034
|
+
return runtime;
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
return pickRuntime(rl);
|
|
3038
|
+
}
|
|
3039
|
+
if (filtered.length === 1) {
|
|
3040
|
+
const only = filtered[0];
|
|
3041
|
+
if (only) {
|
|
3042
|
+
const runtime = registry.get(only.runtimeId);
|
|
3043
|
+
if (runtime) {
|
|
3044
|
+
process.stdout.write(`
|
|
3045
|
+
Using ${runtime.id} (${only.summary}).
|
|
3046
|
+
`);
|
|
3047
|
+
return runtime;
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
3051
|
+
const heading = category === "local-app" ? "\nLocal apps:" : category === "local-http" ? "\nLocal HTTP servers:" : "\nCloud APIs:";
|
|
3052
|
+
return pickRuntimeFromEntries(rl, filtered, heading);
|
|
3053
|
+
}
|
|
3054
|
+
async function maybeSteerToNativeRuntime(rl, currentRuntime, url) {
|
|
3055
|
+
if (currentRuntime.id !== "openai-compat" && currentRuntime.id !== "anthropic-compat") return currentRuntime;
|
|
3056
|
+
const fingerprint = await fingerprintNativeRuntime(url);
|
|
3057
|
+
if (!fingerprint) return currentRuntime;
|
|
3058
|
+
const native = getRuntimeRegistry().get(fingerprint.runtimeId);
|
|
3059
|
+
if (!native) return currentRuntime;
|
|
3060
|
+
process.stdout.write(`
|
|
3061
|
+
Detected ${fingerprint.displayName} at ${url}.
|
|
3062
|
+
`);
|
|
3063
|
+
const switchIt = await askYesNo(rl, `Use ${fingerprint.runtimeId} runtime instead of ${currentRuntime.id}?`, true);
|
|
3064
|
+
if (!switchIt) return currentRuntime;
|
|
3065
|
+
process.stdout.write(`Using ${fingerprint.runtimeId} runtime.
|
|
3066
|
+
`);
|
|
3067
|
+
return native;
|
|
3068
|
+
}
|
|
3069
|
+
async function runTargetSetupInteractive(rl, runtime, defaults) {
|
|
3070
|
+
const auth = openAuthStorage();
|
|
3071
|
+
const settings = readSettings();
|
|
3072
|
+
let support = buildProviderSupportEntry(runtime);
|
|
3073
|
+
const initialRuntimeId = runtime.id;
|
|
3074
|
+
const existingForRuntime = configuredTargetsForRuntime(settings, initialRuntimeId);
|
|
3075
|
+
const existing = defaults.id ? settings.targets.find((entry) => entry.id === defaults.id && entry.runtime === initialRuntimeId) ?? null : null;
|
|
3076
|
+
if (existingForRuntime.length > 0) {
|
|
3077
|
+
process.stdout.write(`
|
|
3078
|
+
Existing targets for ${runtime.id}:
|
|
3079
|
+
`);
|
|
3080
|
+
for (const target of existingForRuntime) {
|
|
3081
|
+
process.stdout.write(` - ${target.id}${target.defaultModel ? ` (${target.defaultModel})` : ""}
|
|
3082
|
+
`);
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
process.stdout.write(`
|
|
3086
|
+
Selected runtime: ${runtime.id} (${support.summary})
|
|
3087
|
+
`);
|
|
3088
|
+
process.stdout.write(`Credentials: ${describeAuthStatus(runtime, existing ?? void 0)}
|
|
3089
|
+
`);
|
|
3090
|
+
if (support.modelHints.length > 0) {
|
|
3091
|
+
process.stdout.write(`Known models: ${describeRuntimeModels(support, 4)}
|
|
3092
|
+
`);
|
|
3093
|
+
}
|
|
3094
|
+
const suggestedId = defaults.id ?? existing?.id ?? deriveTargetId(runtime.id, settings.targets);
|
|
3095
|
+
const idInput = await ask(rl, "Target id", suggestedId);
|
|
3096
|
+
if (idInput === null || idInput.length === 0) {
|
|
3097
|
+
printError("target id is required");
|
|
3098
|
+
return 2;
|
|
3099
|
+
}
|
|
3100
|
+
const targetId = idInput;
|
|
3101
|
+
let url = existing?.url;
|
|
3102
|
+
if (support.supportsCustomUrl) {
|
|
3103
|
+
const urlDefault = defaults.url ?? existing?.url ?? defaultUrlFor(runtime.id);
|
|
3104
|
+
const urlInput = await ask(
|
|
3105
|
+
rl,
|
|
3106
|
+
support.group === "local-http" ? "Target URL" : "Base URL override (blank for runtime default)",
|
|
3107
|
+
urlDefault
|
|
3108
|
+
);
|
|
3109
|
+
if (urlInput === null) return 0;
|
|
3110
|
+
if (urlInput.length > 0) url = normalizeUrl(urlInput, runtime.id);
|
|
3111
|
+
} else if (defaults.url) {
|
|
3112
|
+
url = normalizeUrl(defaults.url, runtime.id);
|
|
3113
|
+
}
|
|
3114
|
+
if (url) {
|
|
3115
|
+
const steered = await maybeSteerToNativeRuntime(rl, runtime, url);
|
|
3116
|
+
if (steered.id !== runtime.id) {
|
|
3117
|
+
runtime = steered;
|
|
3118
|
+
support = buildProviderSupportEntry(runtime);
|
|
3119
|
+
}
|
|
3120
|
+
if (runtime.id === "lmstudio") {
|
|
3121
|
+
const greeting = await greetLmStudio(
|
|
3122
|
+
{ id: targetId, runtime: runtime.id, url },
|
|
3123
|
+
{ credentialsPresent: /* @__PURE__ */ new Set(), httpTimeoutMs: 750 }
|
|
3124
|
+
);
|
|
3125
|
+
if (!greeting.ok) {
|
|
3126
|
+
printError(`refusing to save LM Studio target '${targetId}': ${url} did not return the LM Studio greeting`);
|
|
3127
|
+
return 2;
|
|
3128
|
+
}
|
|
3129
|
+
}
|
|
3130
|
+
}
|
|
3131
|
+
let apiKeyEnv;
|
|
3132
|
+
let apiKeyLiteral;
|
|
3133
|
+
let apiKeyRef = existing?.auth?.apiKeyRef;
|
|
3134
|
+
let oauthProfile = runtime.auth === "oauth" ? existing?.auth?.oauthProfile ?? runtime.oauthProviderId ?? runtime.id : void 0;
|
|
3135
|
+
const authStatus = auth.statusForTarget(
|
|
3136
|
+
existing ? resolveAuthTarget(existing, runtime) : resolveRuntimeAuthTarget(runtime),
|
|
3137
|
+
{ includeFallback: false }
|
|
3138
|
+
);
|
|
3139
|
+
if (runtime.auth === "api-key") {
|
|
3140
|
+
const needsCredential = targetRequiresAuth({ id: targetId, runtime: runtime.id }, runtime);
|
|
3141
|
+
const defaultSource = existing?.auth?.apiKeyRef || authStatus.source === "stored-api-key" ? "keep" : authStatus.source === "environment" || existing?.auth?.apiKeyEnvVar || needsCredential ? "env" : "skip";
|
|
3142
|
+
process.stdout.write(
|
|
3143
|
+
"\nCredential source: env reads a key from an environment variable, stored writes one to\ncredentials.yaml, keep leaves the current one alone, skip uses no key at all.\n"
|
|
3144
|
+
);
|
|
3145
|
+
const choice = await ask(rl, "Credential source [env|stored|keep|skip]", defaultSource);
|
|
3146
|
+
if (choice === null) return 0;
|
|
3147
|
+
const normalized = choice.trim().toLowerCase();
|
|
3148
|
+
if (normalized === "stored") {
|
|
3149
|
+
const literal = await rl.text("API key literal (stored in credentials.yaml, mode 0600)", "", true);
|
|
3150
|
+
if (literal !== null && literal.length > 0) {
|
|
3151
|
+
apiKeyLiteral = literal;
|
|
3152
|
+
apiKeyRef = targetApiKeyRef(targetId, settings.targets);
|
|
3153
|
+
}
|
|
3154
|
+
} else if (normalized === "env") {
|
|
3155
|
+
const envDefault = defaults.apiKeyEnv ?? existing?.auth?.apiKeyEnvVar ?? runtime.credentialsEnvVar ?? "";
|
|
3156
|
+
const envAnswer = await ask(rl, "Env var name (blank for no key)", envDefault);
|
|
3157
|
+
if (envAnswer === null) return 0;
|
|
3158
|
+
if (envAnswer.length > 0) apiKeyEnv = envAnswer;
|
|
3159
|
+
apiKeyRef = void 0;
|
|
3160
|
+
} else if (normalized === "keep") {
|
|
3161
|
+
apiKeyEnv = existing?.auth?.apiKeyEnvVar ?? (authStatus.source === "environment" ? runtime.credentialsEnvVar : void 0);
|
|
3162
|
+
apiKeyRef = existing?.auth?.apiKeyRef ?? (authStatus.source === "stored-api-key" ? runtime.id : void 0);
|
|
3163
|
+
} else {
|
|
3164
|
+
apiKeyEnv = void 0;
|
|
3165
|
+
apiKeyRef = void 0;
|
|
3166
|
+
}
|
|
3167
|
+
}
|
|
3168
|
+
if (runtime.auth === "oauth") {
|
|
3169
|
+
const connectNow = authStatus.available ? await askYesNo(rl, `Reconnect ${runtime.displayName}?`, false) : await askYesNo(rl, `Connect ${runtime.displayName} now?`, true);
|
|
3170
|
+
if (connectNow) {
|
|
3171
|
+
const connected = await loginOAuthRuntime(rl, runtime);
|
|
3172
|
+
if (!connected) return 1;
|
|
3173
|
+
}
|
|
3174
|
+
oauthProfile = existing?.auth?.oauthProfile ?? runtime.oauthProviderId ?? runtime.id;
|
|
3175
|
+
}
|
|
3176
|
+
let model = defaults.model;
|
|
3177
|
+
let inventory = { models: [], source: "none" };
|
|
3178
|
+
const tentative = buildDescriptor(runtime, targetId, {
|
|
3179
|
+
...url !== void 0 ? { url } : {},
|
|
3180
|
+
...apiKeyEnv !== void 0 ? { apiKeyEnv } : {},
|
|
3181
|
+
...apiKeyRef !== void 0 ? { apiKeyRef } : {},
|
|
3182
|
+
...oauthProfile !== void 0 ? { oauthProfile } : {},
|
|
3183
|
+
gateway: defaults.gateway,
|
|
3184
|
+
...defaults.lifecycle !== void 0 ? { lifecycle: defaults.lifecycle } : existing?.lifecycle !== void 0 ? { lifecycle: existing.lifecycle } : {},
|
|
3185
|
+
...defaults.contextWindow !== void 0 ? { contextWindow: defaults.contextWindow } : {},
|
|
3186
|
+
...defaults.maxTokens !== void 0 ? { maxTokens: defaults.maxTokens } : {},
|
|
3187
|
+
...defaults.reasoning !== void 0 ? { reasoning: defaults.reasoning } : {},
|
|
3188
|
+
...existing?.lmstudio ? { lmstudio: existing.lmstudio } : {},
|
|
3189
|
+
...existing?.litellm ? { litellm: existing.litellm } : {}
|
|
3190
|
+
});
|
|
3191
|
+
if (existing?.auth?.headers) tentative.auth = { ...tentative.auth, headers: existing.auth.headers };
|
|
3192
|
+
if (runtime.kind === "http" || runtime.externalAgentLoop?.modelCatalog === "live-authoritative") {
|
|
3193
|
+
inventory = await resolveSupportedWireModels(runtime, tentative, existing ?? void 0, apiKeyLiteral);
|
|
3194
|
+
}
|
|
3195
|
+
const wireModels = inventory.models;
|
|
3196
|
+
const catalogOrdered = support.modelSource === "catalog";
|
|
3197
|
+
model = model ?? existing?.defaultModel ?? (inventory.source === "probe" ? wireModels[0] : support.defaultModel) ?? (catalogOrdered ? void 0 : wireModels[0]);
|
|
3198
|
+
if (wireModels.length > 0) {
|
|
3199
|
+
process.stdout.write("\nSelectable models:\n");
|
|
3200
|
+
for (const [index, wireModel] of wireModels.entries()) {
|
|
3201
|
+
const label = inventory.labels?.[wireModel];
|
|
3202
|
+
process.stdout.write(
|
|
3203
|
+
` ${index + 1}. ${wireModel}${label && label !== wireModel ? ` \u2014 ${label}` : ""}${wireModel === model ? " [default]" : ""}
|
|
3204
|
+
`
|
|
3205
|
+
);
|
|
3206
|
+
}
|
|
3207
|
+
if (inventory.source === "cache") process.stdout.write(" cached model snapshot (not verified in this run)\n");
|
|
3208
|
+
if (inventory.probeError) process.stdout.write(` live probe unavailable: ${inventory.probeError}
|
|
3209
|
+
`);
|
|
3210
|
+
if (!model && catalogOrdered) {
|
|
3211
|
+
process.stdout.write(` listed in provider catalog order, which recommends none of them; pick one.
|
|
3212
|
+
`);
|
|
3213
|
+
}
|
|
3214
|
+
for (; ; ) {
|
|
3215
|
+
const pickedModel = await askModelChoice(rl, "Default target model", wireModels, model);
|
|
3216
|
+
if (pickedModel === null) return 0;
|
|
3217
|
+
if (pickedModel.length > 0) model = pickedModel;
|
|
3218
|
+
if (!model) {
|
|
3219
|
+
process.stdout.write(" a model is required: enter a number from the list or a model id.\n");
|
|
3220
|
+
continue;
|
|
3221
|
+
}
|
|
3222
|
+
if (validateResolvedModel(runtime, tentative, model, defaults.force, inventory)) break;
|
|
3223
|
+
}
|
|
3224
|
+
} else {
|
|
3225
|
+
for (; ; ) {
|
|
3226
|
+
if (model && validateResolvedModel(runtime, tentative, model, defaults.force, inventory)) break;
|
|
3227
|
+
const manual = await ask(rl, "Default model id (blank to leave empty)", model ?? "");
|
|
3228
|
+
if (manual === null) return 0;
|
|
3229
|
+
model = manual.length > 0 ? manual : void 0;
|
|
3230
|
+
if (!model) break;
|
|
3231
|
+
}
|
|
3232
|
+
}
|
|
3233
|
+
let contextWindowChoice = defaults.contextWindow;
|
|
3234
|
+
let reasoningChoice = defaults.reasoning;
|
|
3235
|
+
if (PROTOCOL_COMPAT_RUNTIME_IDS.has(runtime.id)) {
|
|
3236
|
+
if (contextWindowChoice === void 0) {
|
|
3237
|
+
const cwDefault = existing?.capabilities?.contextWindow ?? runtime.defaultCapabilities.contextWindow;
|
|
3238
|
+
const cwAnswer = await ask(
|
|
3239
|
+
rl,
|
|
3240
|
+
"Context window in tokens (blank for runtime default)",
|
|
3241
|
+
cwDefault > 0 ? String(cwDefault) : ""
|
|
3242
|
+
);
|
|
3243
|
+
if (cwAnswer === null) return 0;
|
|
3244
|
+
if (cwAnswer.length > 0) {
|
|
3245
|
+
const parsed = Number(cwAnswer);
|
|
3246
|
+
if (Number.isInteger(parsed) && parsed > 0) contextWindowChoice = parsed;
|
|
3247
|
+
else process.stderr.write(`ignoring invalid context window: ${cwAnswer}
|
|
3248
|
+
`);
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3251
|
+
if (reasoningChoice === void 0) {
|
|
3252
|
+
const reasoningDefault = existing?.capabilities?.reasoning ?? runtime.defaultCapabilities.reasoning === true;
|
|
3253
|
+
reasoningChoice = await askYesNo(rl, "Does this model support reasoning / thinking?", reasoningDefault);
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
if (!validateContextWindowOverride(runtime, model, contextWindowChoice, defaults.force)) return 2;
|
|
3257
|
+
const gatewayDefault = defaults.gateway || existing?.gateway === true;
|
|
3258
|
+
const gatewayAnswer = gatewayDefault ? true : await askYesNo(rl, "Mark as gateway?", false);
|
|
3259
|
+
const configured = buildDescriptor(runtime, targetId, {
|
|
3260
|
+
...url !== void 0 ? { url } : {},
|
|
3261
|
+
...model !== void 0 ? { model } : {},
|
|
3262
|
+
...apiKeyEnv !== void 0 ? { apiKeyEnv } : {},
|
|
3263
|
+
...apiKeyRef !== void 0 ? { apiKeyRef } : {},
|
|
3264
|
+
...oauthProfile !== void 0 ? { oauthProfile } : {},
|
|
3265
|
+
gateway: gatewayAnswer,
|
|
3266
|
+
...defaults.lifecycle !== void 0 ? { lifecycle: defaults.lifecycle } : existing?.lifecycle !== void 0 ? { lifecycle: existing.lifecycle } : {},
|
|
3267
|
+
...contextWindowChoice !== void 0 ? { contextWindow: contextWindowChoice } : {},
|
|
3268
|
+
...defaults.maxTokens !== void 0 ? { maxTokens: defaults.maxTokens } : {},
|
|
3269
|
+
...reasoningChoice !== void 0 ? { reasoning: reasoningChoice } : {},
|
|
3270
|
+
...existing?.lmstudio ? { lmstudio: existing.lmstudio } : {},
|
|
3271
|
+
...existing?.litellm ? { litellm: existing.litellm } : {}
|
|
3272
|
+
});
|
|
3273
|
+
const descriptor = {
|
|
3274
|
+
...existing,
|
|
3275
|
+
...configured,
|
|
3276
|
+
capabilities: { ...existing?.capabilities, ...configured.capabilities }
|
|
3277
|
+
};
|
|
3278
|
+
if (existing?.auth?.headers) descriptor.auth = { ...configured.auth, headers: existing.auth.headers };
|
|
3279
|
+
else if (!configured.auth) delete descriptor.auth;
|
|
3280
|
+
try {
|
|
3281
|
+
assertOrchestratorReplacementEligible(settings, descriptor);
|
|
3282
|
+
} catch (error) {
|
|
3283
|
+
printError(error instanceof Error ? error.message : String(error));
|
|
3284
|
+
return 1;
|
|
3285
|
+
}
|
|
3286
|
+
const probe = await runtimeProbe(runtime, descriptor, apiKeyLiteral);
|
|
3287
|
+
if (probe?.ok && probe.models) recordTargetModelSnapshot(descriptor, probe.models);
|
|
3288
|
+
if (probe) {
|
|
3289
|
+
process.stdout.write("\n");
|
|
3290
|
+
for (const line of probeLines(descriptor, probe)) process.stdout.write(`${line}
|
|
3291
|
+
`);
|
|
3292
|
+
if (!probe.ok) {
|
|
3293
|
+
const keepAnyway = await askYesNo(rl, "save this target anyway, without a reply from it?", true);
|
|
3294
|
+
if (!keepAnyway) {
|
|
3295
|
+
printError("aborted; settings not changed");
|
|
3296
|
+
return 0;
|
|
3297
|
+
}
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
const setOrchestrator = !isOrchestratorEligibleRuntime(runtime) ? false : defaults.setOrchestrator ? true : await askYesNo(rl, "use as orchestrator (chat) target?", !settings.chat.target);
|
|
3301
|
+
const setWorkerDefault = defaults.setWorkerDefault ? true : await askYesNo(rl, "use as fleet default?", !settings.fleet.default.target);
|
|
3302
|
+
const setBackground = !isOrchestratorEligibleRuntime(runtime) ? false : defaults.setBackground ? true : await askYesNo(rl, "use as background memory target?", false);
|
|
3303
|
+
const orchestratorModel = setOrchestrator ? defaults.orchestratorModel ?? await askModelChoice(
|
|
3304
|
+
rl,
|
|
3305
|
+
"Orchestrator model",
|
|
3306
|
+
wireModels,
|
|
3307
|
+
settings.chat.target === targetId ? settings.chat.model ?? model : model
|
|
3308
|
+
) : void 0;
|
|
3309
|
+
if (orchestratorModel === null) return 0;
|
|
3310
|
+
const workerModel = setWorkerDefault ? defaults.workerModel ?? await askModelChoice(
|
|
3311
|
+
rl,
|
|
3312
|
+
"Fleet model",
|
|
3313
|
+
wireModels,
|
|
3314
|
+
settings.fleet.default.target === targetId ? settings.fleet.default.model ?? model : model
|
|
3315
|
+
) : void 0;
|
|
3316
|
+
if (workerModel === null) return 0;
|
|
3317
|
+
const backgroundModel = setBackground ? defaults.backgroundModel ?? await askModelChoice(
|
|
3318
|
+
rl,
|
|
3319
|
+
"Background memory model",
|
|
3320
|
+
wireModels,
|
|
3321
|
+
settings.context.memory.target === targetId ? settings.context.memory.model ?? model : model
|
|
3322
|
+
) : void 0;
|
|
3323
|
+
if (backgroundModel === null) return 0;
|
|
3324
|
+
if (apiKeyLiteral && apiKeyRef) {
|
|
3325
|
+
auth.setApiKey(apiKeyRef, apiKeyLiteral);
|
|
3326
|
+
if (credentialWriteFailed(auth, `credential for ${runtime.id} was not stored; target '${descriptor.id}' not saved`))
|
|
3327
|
+
return 1;
|
|
3328
|
+
printPlaintextCredentialWarning();
|
|
3329
|
+
}
|
|
3330
|
+
const applyWizardChoice = (target) => {
|
|
3331
|
+
applyTarget(target, descriptor);
|
|
3332
|
+
if (setOrchestrator) setOrchestratorPointer(target, descriptor, orchestratorModel);
|
|
3333
|
+
if (setBackground) setBackgroundPointer(target, descriptor, backgroundModel);
|
|
3334
|
+
if (setWorkerDefault) setWorkerDefaultPointer(target, descriptor, workerModel);
|
|
3335
|
+
};
|
|
3336
|
+
applyWizardChoice(settings);
|
|
3337
|
+
updateSettings(applyWizardChoice);
|
|
3338
|
+
printSummary(settings, descriptor, probe);
|
|
3339
|
+
printOk(`target ${targetId} saved`);
|
|
3340
|
+
await runInteropReview({ rl });
|
|
3341
|
+
return 0;
|
|
3342
|
+
}
|
|
3343
|
+
function runTargetRemove(id) {
|
|
3344
|
+
if (!readSettings().targets.some((e) => e.id === id)) {
|
|
3345
|
+
printError(`no target with id ${id}`);
|
|
3346
|
+
return 1;
|
|
3347
|
+
}
|
|
3348
|
+
updateSettings((settings) => {
|
|
3349
|
+
removeTargetFromSettings(settings, id);
|
|
3350
|
+
});
|
|
3351
|
+
printOk(`removed target ${id}`);
|
|
3352
|
+
return 0;
|
|
3353
|
+
}
|
|
3354
|
+
function runTargetRename(oldId, newId) {
|
|
3355
|
+
if (oldId === newId) {
|
|
3356
|
+
printError("old and new id are identical");
|
|
3357
|
+
return 2;
|
|
3358
|
+
}
|
|
3359
|
+
const current = readSettings();
|
|
3360
|
+
if (current.targets.some((e) => e.id === newId)) {
|
|
3361
|
+
printError(`target id already exists: ${newId}`);
|
|
3362
|
+
return 2;
|
|
3363
|
+
}
|
|
3364
|
+
if (!current.targets.some((e) => e.id === oldId)) {
|
|
3365
|
+
printError(`no target with id ${oldId}`);
|
|
3366
|
+
return 1;
|
|
3367
|
+
}
|
|
3368
|
+
updateSettings((settings) => {
|
|
3369
|
+
const target = settings.targets.find((e) => e.id === oldId);
|
|
3370
|
+
if (!target) return;
|
|
3371
|
+
target.id = newId;
|
|
3372
|
+
if (settings.chat.target === oldId) settings.chat.target = newId;
|
|
3373
|
+
if (settings.context.memory.target === oldId) settings.context.memory.target = newId;
|
|
3374
|
+
if (settings.fleet.default.target === oldId) settings.fleet.default.target = newId;
|
|
3375
|
+
for (const profile of Object.values(settings.fleet.profiles)) {
|
|
3376
|
+
if (profile.target === oldId) profile.target = newId;
|
|
3377
|
+
}
|
|
3378
|
+
for (const roster of Object.values(settings.fleet.rosters)) {
|
|
3379
|
+
for (const member of roster.members) if (member.target === oldId) member.target = newId;
|
|
3380
|
+
}
|
|
3381
|
+
const renameRef = (entry) => {
|
|
3382
|
+
const [head, ...rest] = entry.split("/");
|
|
3383
|
+
if (head !== oldId) return entry;
|
|
3384
|
+
return rest.length === 0 ? newId : `${newId}/${rest.join("/")}`;
|
|
3385
|
+
};
|
|
3386
|
+
settings.chat.modelPicker.cycleSet = settings.chat.modelPicker.cycleSet.map(renameRef);
|
|
3387
|
+
settings.chat.modelPicker.favorites = settings.chat.modelPicker.favorites.map(renameRef);
|
|
3388
|
+
});
|
|
3389
|
+
printOk(`renamed ${oldId} to ${newId}`);
|
|
3390
|
+
return 0;
|
|
3391
|
+
}
|
|
3392
|
+
var NONE = "(none)";
|
|
3393
|
+
var onOff = (value) => value ? "enabled" : "disabled";
|
|
3394
|
+
var listOr = (values, fallback = NONE) => values.length > 0 ? values.join(", ") : fallback;
|
|
3395
|
+
async function askInteger(io, label, current, apply, min = 0) {
|
|
3396
|
+
const answer = await ask(io.rl, label, String(current));
|
|
3397
|
+
if (answer === null) return;
|
|
3398
|
+
const parsed = Number(answer);
|
|
3399
|
+
if (!Number.isSafeInteger(parsed) || parsed < min) {
|
|
3400
|
+
io.warn(`${label} must be a whole number of at least ${min}; left at ${current}
|
|
3401
|
+
`);
|
|
3402
|
+
return;
|
|
3403
|
+
}
|
|
3404
|
+
const value = parsed;
|
|
3405
|
+
apply(value);
|
|
3406
|
+
io.ok(`${label} set to ${value}`);
|
|
3407
|
+
}
|
|
3408
|
+
async function askChoice(io, label, allowed, current, apply) {
|
|
3409
|
+
const answer = await io.rl.choose(label, allowed, current);
|
|
3410
|
+
if (answer === null) return;
|
|
3411
|
+
const value = answer.trim().toLowerCase();
|
|
3412
|
+
if (!allowed.includes(value)) {
|
|
3413
|
+
io.warn(`${label} must be one of ${allowed.join(", ")}; left at ${current}
|
|
3414
|
+
`);
|
|
3415
|
+
return;
|
|
3416
|
+
}
|
|
3417
|
+
apply(value);
|
|
3418
|
+
io.ok(`${label} set to ${value}`);
|
|
3419
|
+
}
|
|
3420
|
+
async function runTargetWizard(io, options) {
|
|
3421
|
+
const before = readSettings().targets;
|
|
3422
|
+
io.rl.clearScreen();
|
|
3423
|
+
const code = await runOnboardingWizard(io.streams, options);
|
|
3424
|
+
if (code === 130) throw new ConfigureNavigation("quit");
|
|
3425
|
+
if (code !== 0) {
|
|
3426
|
+
await io.rl.text("Press Enter to return");
|
|
3427
|
+
io.warn("Target settings were not saved.");
|
|
3428
|
+
return;
|
|
3429
|
+
}
|
|
3430
|
+
const changed = readSettings().targets.find(
|
|
3431
|
+
(target) => JSON.stringify(target) !== JSON.stringify(before.find((entry) => entry.id === target.id))
|
|
3432
|
+
);
|
|
3433
|
+
if (changed) io.ok(`Target ${changed.id} saved`);
|
|
3434
|
+
}
|
|
3435
|
+
var SECTIONS = [
|
|
3436
|
+
{
|
|
3437
|
+
id: "targets",
|
|
3438
|
+
title: "Targets & Auth",
|
|
3439
|
+
summary: "providers, endpoints, credentials, models",
|
|
3440
|
+
aliases: ["auth", "target", "providers"],
|
|
3441
|
+
fields: () => {
|
|
3442
|
+
const settings = readSettings();
|
|
3443
|
+
const rows = [
|
|
3444
|
+
["Chat target", `${settings.chat.target ?? NONE} (model: ${settings.chat.model ?? "target default"})`],
|
|
3445
|
+
[
|
|
3446
|
+
"Fleet target",
|
|
3447
|
+
`${settings.fleet.default.target ?? NONE} (model: ${settings.fleet.default.model ?? "target default"})`
|
|
3448
|
+
]
|
|
3449
|
+
];
|
|
3450
|
+
if (settings.targets.length === 0) rows.push(["Registered", "(no targets registered)"]);
|
|
3451
|
+
else
|
|
3452
|
+
for (const target of settings.targets) {
|
|
3453
|
+
rows.push([
|
|
3454
|
+
` ${target.id}`,
|
|
3455
|
+
`${target.runtime}, model ${target.defaultModel ?? "unset"}${settings.chat.target === target.id ? " [chat]" : ""}${settings.fleet.default.target === target.id ? " [fleet]" : ""}`
|
|
3456
|
+
]);
|
|
3457
|
+
}
|
|
3458
|
+
return rows;
|
|
3459
|
+
},
|
|
3460
|
+
actions: [
|
|
3461
|
+
{
|
|
3462
|
+
label: "Add a target",
|
|
3463
|
+
hint: "register a provider endpoint",
|
|
3464
|
+
run: async (io) => {
|
|
3465
|
+
if (canRunOnboarding(io.streams)) {
|
|
3466
|
+
await runTargetWizard(io, { mode: readSettings().targets.length === 0 ? "first" : "add" });
|
|
3467
|
+
return;
|
|
3468
|
+
}
|
|
3469
|
+
const runtime = await pickRuntimeViaCategory(io.rl);
|
|
3470
|
+
if (runtime) await runTargetSetupInteractive(io.rl, runtime, emptyArgs());
|
|
3471
|
+
}
|
|
3472
|
+
},
|
|
3473
|
+
{
|
|
3474
|
+
label: "Set the chat target",
|
|
3475
|
+
hint: "which target answers in chat",
|
|
3476
|
+
run: async (io) => {
|
|
3477
|
+
await assignTarget(io, "chat");
|
|
3478
|
+
}
|
|
3479
|
+
},
|
|
3480
|
+
{
|
|
3481
|
+
label: "Set the fleet default target",
|
|
3482
|
+
hint: "which target dispatched workers use",
|
|
3483
|
+
run: async (io) => {
|
|
3484
|
+
await assignTarget(io, "fleet");
|
|
3485
|
+
}
|
|
3486
|
+
},
|
|
3487
|
+
{
|
|
3488
|
+
label: "Remove a target",
|
|
3489
|
+
run: async (io) => {
|
|
3490
|
+
const settings = readSettings();
|
|
3491
|
+
const ids = settings.targets.map((target) => target.id);
|
|
3492
|
+
if (ids.length === 0) {
|
|
3493
|
+
io.warn("No targets to remove.");
|
|
3494
|
+
return;
|
|
3495
|
+
}
|
|
3496
|
+
io.out.write(` Registered: ${ids.join(", ")}
|
|
3497
|
+
`);
|
|
3498
|
+
const chosen = await io.rl.choose("Target to remove", ids, ids[0] ?? "");
|
|
3499
|
+
if (chosen === null || !ids.includes(chosen)) return;
|
|
3500
|
+
if (await askYesNo(io.rl, `Remove target '${chosen}'?`, false)) {
|
|
3501
|
+
if (runTargetRemove(chosen) === 0) io.ok(`Removed target ${chosen}`);
|
|
3502
|
+
else io.warn(`Could not remove target ${chosen}`);
|
|
3503
|
+
}
|
|
3504
|
+
}
|
|
3505
|
+
},
|
|
3506
|
+
{
|
|
3507
|
+
label: "Edit a target",
|
|
3508
|
+
hint: "endpoint, credentials, model, capabilities",
|
|
3509
|
+
run: async (io) => {
|
|
3510
|
+
const targets = readSettings().targets;
|
|
3511
|
+
if (targets.length === 0) return;
|
|
3512
|
+
const id = await io.rl.choose(
|
|
3513
|
+
"Target to edit",
|
|
3514
|
+
targets.map((target2) => target2.id),
|
|
3515
|
+
targets[0]?.id ?? ""
|
|
3516
|
+
);
|
|
3517
|
+
const target = targets.find((entry) => entry.id === id);
|
|
3518
|
+
if (!target) return;
|
|
3519
|
+
if (canRunOnboarding(io.streams)) {
|
|
3520
|
+
await runTargetWizard(io, { mode: "edit", target });
|
|
3521
|
+
} else {
|
|
3522
|
+
const runtime = getRuntimeRegistry().get(target.runtime);
|
|
3523
|
+
if (runtime) await runTargetSetupInteractive(io.rl, runtime, { ...emptyArgs(), id });
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
},
|
|
3527
|
+
{
|
|
3528
|
+
label: "Rename a target",
|
|
3529
|
+
run: async (io) => {
|
|
3530
|
+
const ids = readSettings().targets.map((target) => target.id);
|
|
3531
|
+
if (ids.length === 0) return;
|
|
3532
|
+
const id = await io.rl.choose("Target to rename", ids, ids[0] ?? "");
|
|
3533
|
+
const name = await ask(io.rl, "New target id", id);
|
|
3534
|
+
if (!name || name === id) return;
|
|
3535
|
+
if (ids.includes(name)) {
|
|
3536
|
+
io.warn(`Target id already exists: ${name}`);
|
|
3537
|
+
return;
|
|
3538
|
+
}
|
|
3539
|
+
if (runTargetRename(id, name) === 0) io.ok(`Renamed ${id} to ${name}`);
|
|
3540
|
+
else io.warn(`Could not rename target ${id}`);
|
|
3541
|
+
}
|
|
3542
|
+
},
|
|
3543
|
+
{
|
|
3544
|
+
label: "Set the background memory target",
|
|
3545
|
+
run: async (io) => assignTarget(io, "memory")
|
|
3546
|
+
}
|
|
3547
|
+
]
|
|
3548
|
+
},
|
|
3549
|
+
{
|
|
3550
|
+
id: "models",
|
|
3551
|
+
title: "Models & Thinking",
|
|
3552
|
+
summary: "default model, thinking level, favorites",
|
|
3553
|
+
aliases: ["model", "thinking"],
|
|
3554
|
+
fields: () => {
|
|
3555
|
+
const settings = readSettings();
|
|
3556
|
+
return [
|
|
3557
|
+
["Chat model", settings.chat.model ?? "(target default)"],
|
|
3558
|
+
["Chat thinking", settings.chat.thinkingLevel],
|
|
3559
|
+
["Fleet thinking", settings.fleet.default.thinkingLevel],
|
|
3560
|
+
["Favorites", listOr(settings.chat.modelPicker.favorites)],
|
|
3561
|
+
["Model cycle set", listOr(settings.chat.modelPicker.cycleSet)]
|
|
3562
|
+
];
|
|
3563
|
+
},
|
|
3564
|
+
actions: [
|
|
3565
|
+
{
|
|
3566
|
+
label: "Chat thinking level",
|
|
3567
|
+
hint: THINKING_LEVELS.join(" | "),
|
|
3568
|
+
run: async (io) => {
|
|
3569
|
+
await askChoice(io, "Chat thinking level", THINKING_LEVELS, readSettings().chat.thinkingLevel, (value) => {
|
|
3570
|
+
updateSettings((draft) => {
|
|
3571
|
+
draft.chat.thinkingLevel = value;
|
|
3572
|
+
});
|
|
3573
|
+
});
|
|
3574
|
+
}
|
|
3575
|
+
},
|
|
3576
|
+
{
|
|
3577
|
+
label: "Fleet thinking level",
|
|
3578
|
+
hint: THINKING_LEVELS.join(" | "),
|
|
3579
|
+
run: async (io) => {
|
|
3580
|
+
await askChoice(
|
|
3581
|
+
io,
|
|
3582
|
+
"Fleet thinking level",
|
|
3583
|
+
THINKING_LEVELS,
|
|
3584
|
+
readSettings().fleet.default.thinkingLevel,
|
|
3585
|
+
(value) => {
|
|
3586
|
+
updateSettings((draft) => {
|
|
3587
|
+
draft.fleet.default.thinkingLevel = value;
|
|
3588
|
+
});
|
|
3589
|
+
}
|
|
3590
|
+
);
|
|
3591
|
+
}
|
|
3592
|
+
},
|
|
3593
|
+
{
|
|
3594
|
+
label: "Chat default model",
|
|
3595
|
+
hint: "blank clears the override",
|
|
3596
|
+
run: async (io) => {
|
|
3597
|
+
const model = await ask(
|
|
3598
|
+
io.rl,
|
|
3599
|
+
"Chat default model (blank for the target default)",
|
|
3600
|
+
readSettings().chat.model ?? ""
|
|
3601
|
+
);
|
|
3602
|
+
if (model === null) return;
|
|
3603
|
+
updateSavedSettingsDocument((saved) => {
|
|
3604
|
+
const document = saved;
|
|
3605
|
+
document.chat = { ...document.chat, model: model.length > 0 ? model : null };
|
|
3606
|
+
return document;
|
|
3607
|
+
});
|
|
3608
|
+
io.ok(model.length > 0 ? `Chat default model set to ${model}` : "Chat default model cleared");
|
|
3609
|
+
}
|
|
3610
|
+
},
|
|
3611
|
+
{
|
|
3612
|
+
label: "Model favorites",
|
|
3613
|
+
hint: "comma-separated",
|
|
3614
|
+
run: async (io) => {
|
|
3615
|
+
await askList(io, "Model favorites", readSettings().chat.modelPicker.favorites, (values) => {
|
|
3616
|
+
updateSettings((draft) => {
|
|
3617
|
+
draft.chat.modelPicker.favorites = values;
|
|
3618
|
+
});
|
|
3619
|
+
});
|
|
3620
|
+
}
|
|
3621
|
+
},
|
|
3622
|
+
{
|
|
3623
|
+
label: "Cycle set",
|
|
3624
|
+
hint: "comma-separated models for the scoped cycle actions",
|
|
3625
|
+
run: async (io) => {
|
|
3626
|
+
await askList(io, "Cycle set", readSettings().chat.modelPicker.cycleSet, (values) => {
|
|
3627
|
+
updateSettings((draft) => {
|
|
3628
|
+
draft.chat.modelPicker.cycleSet = values;
|
|
3629
|
+
});
|
|
3630
|
+
});
|
|
3631
|
+
}
|
|
3632
|
+
}
|
|
3633
|
+
]
|
|
3634
|
+
},
|
|
3635
|
+
{
|
|
3636
|
+
id: "chat",
|
|
3637
|
+
title: "Chat Defaults",
|
|
3638
|
+
summary: "streaming, progress, compaction",
|
|
3639
|
+
fields: () => {
|
|
3640
|
+
const settings = readSettings();
|
|
3641
|
+
return [
|
|
3642
|
+
["Smooth streaming", settings.interface.smoothStreaming],
|
|
3643
|
+
["Terminal progress", onOff(settings.interface.terminalProgress)],
|
|
3644
|
+
[
|
|
3645
|
+
"Max output tokens",
|
|
3646
|
+
settings.chat.maxOutputTokens > 0 ? String(settings.chat.maxOutputTokens) : "(runtime default)"
|
|
3647
|
+
],
|
|
3648
|
+
["Prompt prewarm", onOff(settings.chat.prewarm)],
|
|
3649
|
+
[
|
|
3650
|
+
"Auto-compaction",
|
|
3651
|
+
settings.context.compaction.auto ? `enabled at ${Math.round(settings.context.compaction.threshold * 100)}%` : "disabled"
|
|
3652
|
+
],
|
|
3653
|
+
[
|
|
3654
|
+
"Working-set eviction",
|
|
3655
|
+
settings.context.workingSet.enabled ? `enabled (${settings.context.workingSet.policy})` : "disabled"
|
|
3656
|
+
]
|
|
3657
|
+
];
|
|
3658
|
+
},
|
|
3659
|
+
actions: [
|
|
3660
|
+
{
|
|
3661
|
+
label: "Smooth streaming",
|
|
3662
|
+
hint: "off | auto | on",
|
|
3663
|
+
run: async (io) => {
|
|
3664
|
+
await askChoice(
|
|
3665
|
+
io,
|
|
3666
|
+
"Smooth streaming",
|
|
3667
|
+
["off", "auto", "on"],
|
|
3668
|
+
readSettings().interface.smoothStreaming,
|
|
3669
|
+
(value) => {
|
|
3670
|
+
updateSettings((draft) => {
|
|
3671
|
+
draft.interface.smoothStreaming = value;
|
|
3672
|
+
});
|
|
3673
|
+
}
|
|
3674
|
+
);
|
|
3675
|
+
}
|
|
3676
|
+
},
|
|
3677
|
+
{
|
|
3678
|
+
label: "Terminal progress indicator",
|
|
3679
|
+
hint: "toggle",
|
|
3680
|
+
run: async (io) => {
|
|
3681
|
+
let next = false;
|
|
3682
|
+
updateSettings((draft) => {
|
|
3683
|
+
draft.interface.terminalProgress = !draft.interface.terminalProgress;
|
|
3684
|
+
next = draft.interface.terminalProgress;
|
|
3685
|
+
});
|
|
3686
|
+
io.ok(`Terminal progress ${onOff(next)}`);
|
|
3687
|
+
}
|
|
3688
|
+
},
|
|
3689
|
+
{
|
|
3690
|
+
label: "Max output tokens",
|
|
3691
|
+
hint: "0 for the runtime default",
|
|
3692
|
+
run: async (io) => {
|
|
3693
|
+
await askInteger(io, "Max output tokens", readSettings().chat.maxOutputTokens, (value) => {
|
|
3694
|
+
updateSettings((draft) => {
|
|
3695
|
+
draft.chat.maxOutputTokens = value;
|
|
3696
|
+
});
|
|
3697
|
+
});
|
|
3698
|
+
}
|
|
3699
|
+
},
|
|
3700
|
+
{
|
|
3701
|
+
label: "Prompt prewarm",
|
|
3702
|
+
hint: "toggle",
|
|
3703
|
+
run: async (io) => {
|
|
3704
|
+
let next = false;
|
|
3705
|
+
updateSettings((draft) => {
|
|
3706
|
+
draft.chat.prewarm = !draft.chat.prewarm;
|
|
3707
|
+
next = draft.chat.prewarm;
|
|
3708
|
+
});
|
|
3709
|
+
io.ok(`Prompt prewarm ${onOff(next)}`);
|
|
3710
|
+
}
|
|
3711
|
+
},
|
|
3712
|
+
{
|
|
3713
|
+
label: "Auto-compaction",
|
|
3714
|
+
hint: "toggle",
|
|
3715
|
+
run: async (io) => {
|
|
3716
|
+
let next = false;
|
|
3717
|
+
updateSettings((draft) => {
|
|
3718
|
+
draft.context.compaction.auto = !draft.context.compaction.auto;
|
|
3719
|
+
next = draft.context.compaction.auto;
|
|
3720
|
+
});
|
|
3721
|
+
io.ok(`Auto-compaction ${onOff(next)}`);
|
|
3722
|
+
}
|
|
3723
|
+
}
|
|
3724
|
+
]
|
|
3725
|
+
},
|
|
3726
|
+
{
|
|
3727
|
+
id: "fleet",
|
|
3728
|
+
title: "Fleet",
|
|
3729
|
+
summary: "concurrency, retries, worker timeouts",
|
|
3730
|
+
fields: () => {
|
|
3731
|
+
const settings = readSettings();
|
|
3732
|
+
return [
|
|
3733
|
+
["Concurrency limit", String(settings.fleet.concurrency)],
|
|
3734
|
+
["Max retries", String(settings.fleet.retry.maxRetries)],
|
|
3735
|
+
["Tool calls per run", String(settings.fleet.limits.toolCallsPerRun)],
|
|
3736
|
+
["Run timeout", `${settings.fleet.limits.internalRunTimeoutMs / 1e3}s`],
|
|
3737
|
+
["Worker profiles", listOr(Object.keys(settings.fleet.profiles))],
|
|
3738
|
+
[
|
|
3739
|
+
"Subagent pins",
|
|
3740
|
+
listOr(Object.entries(settings.fleet.agentProfiles).map(([agent, profile]) => `${agent} -> ${profile}`))
|
|
3741
|
+
],
|
|
3742
|
+
["Remote nodes", listOr(settings.fleet.nodes.map((node) => node.id))]
|
|
3743
|
+
];
|
|
3744
|
+
},
|
|
3745
|
+
actions: [
|
|
3746
|
+
{
|
|
3747
|
+
label: "Concurrency limit",
|
|
3748
|
+
hint: "auto, or a positive integer",
|
|
3749
|
+
run: async (io) => {
|
|
3750
|
+
const current = String(readSettings().fleet.concurrency);
|
|
3751
|
+
const answer = await ask(io.rl, "Concurrency limit [auto or a number]", current);
|
|
3752
|
+
if (answer === null) return;
|
|
3753
|
+
if (answer.trim().toLowerCase() === "auto") {
|
|
3754
|
+
updateSettings((draft) => {
|
|
3755
|
+
draft.fleet.concurrency = "auto";
|
|
3756
|
+
});
|
|
3757
|
+
io.ok("Concurrency limit set to auto");
|
|
3758
|
+
return;
|
|
3759
|
+
}
|
|
3760
|
+
const parsed = Number(answer);
|
|
3761
|
+
if (!Number.isFinite(parsed) || parsed < 1) {
|
|
3762
|
+
io.warn(`Concurrency limit must be auto or at least 1; left at ${current}
|
|
3763
|
+
`);
|
|
3764
|
+
return;
|
|
3765
|
+
}
|
|
3766
|
+
updateSettings((draft) => {
|
|
3767
|
+
draft.fleet.concurrency = Math.floor(parsed);
|
|
3768
|
+
});
|
|
3769
|
+
io.ok(`Concurrency limit set to ${Math.floor(parsed)}`);
|
|
3770
|
+
}
|
|
3771
|
+
},
|
|
3772
|
+
{
|
|
3773
|
+
label: "Max retries",
|
|
3774
|
+
run: async (io) => {
|
|
3775
|
+
await askInteger(io, "Max retries", readSettings().fleet.retry.maxRetries, (value) => {
|
|
3776
|
+
updateSettings((draft) => {
|
|
3777
|
+
draft.fleet.retry.maxRetries = value;
|
|
3778
|
+
});
|
|
3779
|
+
});
|
|
3780
|
+
}
|
|
3781
|
+
},
|
|
3782
|
+
{
|
|
3783
|
+
label: "Tool calls per run",
|
|
3784
|
+
run: async (io) => {
|
|
3785
|
+
await askInteger(
|
|
3786
|
+
io,
|
|
3787
|
+
"Tool calls per run",
|
|
3788
|
+
readSettings().fleet.limits.toolCallsPerRun,
|
|
3789
|
+
(value) => {
|
|
3790
|
+
updateSettings((draft) => {
|
|
3791
|
+
draft.fleet.limits.toolCallsPerRun = value;
|
|
3792
|
+
});
|
|
3793
|
+
},
|
|
3794
|
+
1
|
|
3795
|
+
);
|
|
3796
|
+
}
|
|
3797
|
+
},
|
|
3798
|
+
{
|
|
3799
|
+
label: "Run timeout",
|
|
3800
|
+
hint: "seconds",
|
|
3801
|
+
run: async (io) => {
|
|
3802
|
+
const current = readSettings().fleet.limits.internalRunTimeoutMs / 1e3;
|
|
3803
|
+
const answer = await ask(io.rl, "Run timeout in seconds", String(current));
|
|
3804
|
+
if (answer === null) return;
|
|
3805
|
+
const parsed = Number(answer);
|
|
3806
|
+
if (!Number.isFinite(parsed) || parsed < 1) {
|
|
3807
|
+
io.warn(`Run timeout must be at least 1 second; left at ${current}s
|
|
3808
|
+
`);
|
|
3809
|
+
return;
|
|
3810
|
+
}
|
|
3811
|
+
updateSettings((draft) => {
|
|
3812
|
+
draft.fleet.limits.internalRunTimeoutMs = Math.floor(parsed * 1e3);
|
|
3813
|
+
});
|
|
3814
|
+
io.ok(`Run timeout set to ${Math.floor(parsed)}s`);
|
|
3815
|
+
}
|
|
3816
|
+
}
|
|
3817
|
+
]
|
|
3818
|
+
},
|
|
3819
|
+
{
|
|
3820
|
+
id: "permissions",
|
|
3821
|
+
title: "Permissions & Autonomy",
|
|
3822
|
+
summary: "autonomy level, worker permissions, cost limits",
|
|
3823
|
+
aliases: ["autonomy", "safety"],
|
|
3824
|
+
fields: () => {
|
|
3825
|
+
const settings = readSettings();
|
|
3826
|
+
return [
|
|
3827
|
+
["Autonomy level", settings.safety.autonomy],
|
|
3828
|
+
["Worker permissions", settings.fleet.permissions.mode],
|
|
3829
|
+
["Session cost limit", `$${settings.safety.limits.sessionCostUsd} USD`],
|
|
3830
|
+
["Turn tool budget", String(settings.safety.limits.chatToolCallsPerTurn)],
|
|
3831
|
+
["Review watchdog", onOff(settings.safety.review.enabled)]
|
|
3832
|
+
];
|
|
3833
|
+
},
|
|
3834
|
+
actions: [
|
|
3835
|
+
{
|
|
3836
|
+
label: "Autonomy level",
|
|
3837
|
+
hint: AUTONOMY_LEVELS.join(" | "),
|
|
3838
|
+
run: async (io) => {
|
|
3839
|
+
io.out.write(
|
|
3840
|
+
" read-only inspects; suggest asks before changes; auto-edit permits workspace\n edits; full-auto skips autonomy prompts. Safety rules still apply at every level.\n"
|
|
3841
|
+
);
|
|
3842
|
+
await askChoice(io, "Autonomy level", AUTONOMY_LEVELS, readSettings().safety.autonomy, (value) => {
|
|
3843
|
+
updateSettings((draft) => {
|
|
3844
|
+
draft.safety.autonomy = value;
|
|
3845
|
+
});
|
|
3846
|
+
});
|
|
3847
|
+
}
|
|
3848
|
+
},
|
|
3849
|
+
{
|
|
3850
|
+
label: "Worker permission mode",
|
|
3851
|
+
hint: "deny | fail | escalate",
|
|
3852
|
+
run: async (io) => {
|
|
3853
|
+
await askChoice(
|
|
3854
|
+
io,
|
|
3855
|
+
"Worker permission mode",
|
|
3856
|
+
["deny", "fail", "escalate"],
|
|
3857
|
+
readSettings().fleet.permissions.mode,
|
|
3858
|
+
(value) => {
|
|
3859
|
+
updateSettings((draft) => {
|
|
3860
|
+
draft.fleet.permissions.mode = value;
|
|
3861
|
+
});
|
|
3862
|
+
}
|
|
3863
|
+
);
|
|
3864
|
+
}
|
|
3865
|
+
},
|
|
3866
|
+
{
|
|
3867
|
+
label: "Session cost limit",
|
|
3868
|
+
hint: "USD",
|
|
3869
|
+
run: async (io) => {
|
|
3870
|
+
const current = readSettings().safety.limits.sessionCostUsd;
|
|
3871
|
+
const answer = await ask(io.rl, "Session cost limit in USD", String(current));
|
|
3872
|
+
if (answer === null) return;
|
|
3873
|
+
const parsed = Number(answer);
|
|
3874
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
3875
|
+
io.warn(`Session cost limit must be greater than 0; left at $${current}
|
|
3876
|
+
`);
|
|
3877
|
+
return;
|
|
3878
|
+
}
|
|
3879
|
+
updateSettings((draft) => {
|
|
3880
|
+
draft.safety.limits.sessionCostUsd = parsed;
|
|
3881
|
+
});
|
|
3882
|
+
io.ok(`Session cost limit set to $${parsed} USD`);
|
|
3883
|
+
}
|
|
3884
|
+
},
|
|
3885
|
+
{
|
|
3886
|
+
label: "Turn tool budget",
|
|
3887
|
+
run: async (io) => {
|
|
3888
|
+
await askInteger(
|
|
3889
|
+
io,
|
|
3890
|
+
"Turn tool budget",
|
|
3891
|
+
readSettings().safety.limits.chatToolCallsPerTurn,
|
|
3892
|
+
(value) => {
|
|
3893
|
+
updateSettings((draft) => {
|
|
3894
|
+
draft.safety.limits.chatToolCallsPerTurn = value;
|
|
3895
|
+
});
|
|
3896
|
+
},
|
|
3897
|
+
1
|
|
3898
|
+
);
|
|
3899
|
+
}
|
|
3900
|
+
},
|
|
3901
|
+
{
|
|
3902
|
+
label: "Turn-end review watchdog",
|
|
3903
|
+
hint: "toggle",
|
|
3904
|
+
run: async (io) => {
|
|
3905
|
+
let next = false;
|
|
3906
|
+
updateSettings((draft) => {
|
|
3907
|
+
draft.safety.review.enabled = !draft.safety.review.enabled;
|
|
3908
|
+
next = draft.safety.review.enabled;
|
|
3909
|
+
});
|
|
3910
|
+
io.ok(`Review watchdog ${onOff(next)}`);
|
|
3911
|
+
}
|
|
3912
|
+
}
|
|
3913
|
+
]
|
|
3914
|
+
},
|
|
3915
|
+
{
|
|
3916
|
+
id: "panes",
|
|
3917
|
+
title: "Panes & Layout",
|
|
3918
|
+
summary: "terminal panes, startup layout, display mode",
|
|
3919
|
+
aliases: ["layout", "interface", "pane"],
|
|
3920
|
+
fields: () => {
|
|
3921
|
+
const settings = readSettings();
|
|
3922
|
+
return [
|
|
3923
|
+
["Panes capability", settings.interface.panes.enabled],
|
|
3924
|
+
["Startup layout", settings.interface.panes.layout],
|
|
3925
|
+
["TUI mode", settings.interface.mode],
|
|
3926
|
+
["Output style", settings.interface.outputDetail],
|
|
3927
|
+
["Desktop notifications", onOff(settings.interface.desktopNotifications)],
|
|
3928
|
+
["Git commit attribution", onOff(settings.integrations.git.commitAttribution)]
|
|
3929
|
+
];
|
|
3930
|
+
},
|
|
3931
|
+
actions: [
|
|
3932
|
+
{
|
|
3933
|
+
label: "Panes capability",
|
|
3934
|
+
hint: "off | auto | embedded",
|
|
3935
|
+
run: async (io) => {
|
|
3936
|
+
await askChoice(
|
|
3937
|
+
io,
|
|
3938
|
+
"Panes capability",
|
|
3939
|
+
["off", "auto", "embedded"],
|
|
3940
|
+
readSettings().interface.panes.enabled,
|
|
3941
|
+
(value) => {
|
|
3942
|
+
updateSettings((draft) => {
|
|
3943
|
+
draft.interface.panes.enabled = value;
|
|
3944
|
+
});
|
|
3945
|
+
}
|
|
3946
|
+
);
|
|
3947
|
+
}
|
|
3948
|
+
},
|
|
3949
|
+
{
|
|
3950
|
+
label: "Startup layout",
|
|
3951
|
+
hint: "off | workers | cockpit",
|
|
3952
|
+
run: async (io) => {
|
|
3953
|
+
await askChoice(
|
|
3954
|
+
io,
|
|
3955
|
+
"Startup layout",
|
|
3956
|
+
["off", "workers", "cockpit"],
|
|
3957
|
+
readSettings().interface.panes.layout,
|
|
3958
|
+
(value) => {
|
|
3959
|
+
updateSettings((draft) => {
|
|
3960
|
+
draft.interface.panes.layout = value;
|
|
3961
|
+
});
|
|
3962
|
+
}
|
|
3963
|
+
);
|
|
3964
|
+
}
|
|
3965
|
+
},
|
|
3966
|
+
{
|
|
3967
|
+
label: "TUI mode",
|
|
3968
|
+
hint: "regular | fullscreen",
|
|
3969
|
+
run: async (io) => {
|
|
3970
|
+
await askChoice(io, "TUI mode", ["regular", "fullscreen"], readSettings().interface.mode, (value) => {
|
|
3971
|
+
updateSettings((draft) => {
|
|
3972
|
+
draft.interface.mode = value;
|
|
3973
|
+
});
|
|
3974
|
+
});
|
|
3975
|
+
}
|
|
3976
|
+
},
|
|
3977
|
+
{
|
|
3978
|
+
label: "Output style",
|
|
3979
|
+
hint: "compact | standard | detailed",
|
|
3980
|
+
run: async (io) => {
|
|
3981
|
+
await askChoice(
|
|
3982
|
+
io,
|
|
3983
|
+
"Output style",
|
|
3984
|
+
["compact", "standard", "detailed"],
|
|
3985
|
+
readSettings().interface.outputDetail,
|
|
3986
|
+
(value) => {
|
|
3987
|
+
updateSettings((draft) => {
|
|
3988
|
+
draft.interface.outputDetail = value;
|
|
3989
|
+
});
|
|
3990
|
+
}
|
|
3991
|
+
);
|
|
3992
|
+
}
|
|
3993
|
+
},
|
|
3994
|
+
{
|
|
3995
|
+
label: "Desktop notifications",
|
|
3996
|
+
hint: "toggle",
|
|
3997
|
+
run: async (io) => {
|
|
3998
|
+
let next = false;
|
|
3999
|
+
updateSettings((draft) => {
|
|
4000
|
+
draft.interface.desktopNotifications = !draft.interface.desktopNotifications;
|
|
4001
|
+
next = draft.interface.desktopNotifications;
|
|
4002
|
+
});
|
|
4003
|
+
io.ok(`Desktop notifications ${onOff(next)}`);
|
|
4004
|
+
}
|
|
4005
|
+
},
|
|
4006
|
+
{
|
|
4007
|
+
label: "Git commit attribution",
|
|
4008
|
+
hint: "toggle",
|
|
4009
|
+
run: async (io) => {
|
|
4010
|
+
let next = false;
|
|
4011
|
+
updateSettings((draft) => {
|
|
4012
|
+
draft.integrations.git.commitAttribution = !draft.integrations.git.commitAttribution;
|
|
4013
|
+
next = draft.integrations.git.commitAttribution;
|
|
4014
|
+
});
|
|
4015
|
+
io.ok(`Git commit attribution ${onOff(next)}`);
|
|
4016
|
+
}
|
|
4017
|
+
}
|
|
4018
|
+
]
|
|
4019
|
+
},
|
|
4020
|
+
{
|
|
4021
|
+
id: "skills",
|
|
4022
|
+
title: "Skills & Extensions",
|
|
4023
|
+
summary: "project imports, ACP peers, plugins",
|
|
4024
|
+
aliases: ["extensions", "skill", "interop"],
|
|
4025
|
+
fields: () => {
|
|
4026
|
+
const settings = readSettings();
|
|
4027
|
+
const rows = [
|
|
4028
|
+
["Trust project imports", settings.integrations.projectResources.trustProjectImports ? "trusted" : "untrusted"],
|
|
4029
|
+
["External ACP agents", String(settings.integrations.externalAgents.entries.length)]
|
|
4030
|
+
];
|
|
4031
|
+
for (const agent of settings.integrations.externalAgents.entries) {
|
|
4032
|
+
rows.push([` ${agent.id}`, `${agent.command} (governance: ${agent.toolGovernance ?? "default"})`]);
|
|
4033
|
+
}
|
|
4034
|
+
rows.push(
|
|
4035
|
+
["Runtime plugins", listOr(settings.integrations.runtimePlugins)],
|
|
4036
|
+
["Library remote sync", onOff(settings.integrations.library.sync)]
|
|
4037
|
+
);
|
|
4038
|
+
return rows;
|
|
4039
|
+
},
|
|
4040
|
+
actions: [
|
|
4041
|
+
{
|
|
4042
|
+
label: "Trust project imports",
|
|
4043
|
+
hint: "toggle",
|
|
4044
|
+
run: async (io) => {
|
|
4045
|
+
let next = false;
|
|
4046
|
+
updateSettings((draft) => {
|
|
4047
|
+
draft.integrations.projectResources.trustProjectImports = !draft.integrations.projectResources.trustProjectImports;
|
|
4048
|
+
next = draft.integrations.projectResources.trustProjectImports;
|
|
4049
|
+
});
|
|
4050
|
+
io.ok(`Project imports ${next ? "trusted" : "untrusted"}`);
|
|
4051
|
+
}
|
|
4052
|
+
},
|
|
4053
|
+
{
|
|
4054
|
+
label: "Review external ACP agents",
|
|
4055
|
+
hint: "runs the interop review",
|
|
4056
|
+
run: async (io) => {
|
|
4057
|
+
await runInteropReview({ rl: io.rl, streams: io.streams });
|
|
4058
|
+
}
|
|
4059
|
+
},
|
|
4060
|
+
{
|
|
4061
|
+
label: "Library remote sync",
|
|
4062
|
+
hint: "toggle",
|
|
4063
|
+
run: async (io) => {
|
|
4064
|
+
let next = false;
|
|
4065
|
+
updateSettings((draft) => {
|
|
4066
|
+
draft.integrations.library.sync = !draft.integrations.library.sync;
|
|
4067
|
+
next = draft.integrations.library.sync;
|
|
4068
|
+
});
|
|
4069
|
+
io.ok(`Library remote sync ${onOff(next)}`);
|
|
4070
|
+
}
|
|
4071
|
+
}
|
|
4072
|
+
]
|
|
4073
|
+
},
|
|
4074
|
+
{
|
|
4075
|
+
id: "diagnostics",
|
|
4076
|
+
title: "Diagnostics",
|
|
4077
|
+
summary: "version, directories, doctor, raw settings",
|
|
4078
|
+
aliases: ["doctor", "diag"],
|
|
4079
|
+
fields: () => {
|
|
4080
|
+
const dirs = resolveClioDirs();
|
|
4081
|
+
const info = getVersionInfo();
|
|
4082
|
+
return [
|
|
4083
|
+
["Clio Coder", info.clio],
|
|
4084
|
+
["Node.js", info.node],
|
|
4085
|
+
["Platform", info.platform],
|
|
4086
|
+
["Config dir", shortenPath(dirs.config)],
|
|
4087
|
+
["Data dir", shortenPath(dirs.data)],
|
|
4088
|
+
["State dir", shortenPath(dirs.state)],
|
|
4089
|
+
["Cache dir", shortenPath(dirs.cache)]
|
|
4090
|
+
];
|
|
4091
|
+
},
|
|
4092
|
+
actions: [
|
|
4093
|
+
{
|
|
4094
|
+
label: "Run doctor",
|
|
4095
|
+
hint: "read-only health check",
|
|
4096
|
+
run: async (io) => {
|
|
4097
|
+
const { runDoctorCommand } = await import("./doctor-V5L4IQGP.js");
|
|
4098
|
+
await runDoctorCommand([]);
|
|
4099
|
+
await io.rl.text("Press Enter to return");
|
|
4100
|
+
}
|
|
4101
|
+
},
|
|
4102
|
+
{
|
|
4103
|
+
label: "Show raw settings.yaml",
|
|
4104
|
+
run: async (io) => {
|
|
4105
|
+
const file = settingsPath();
|
|
4106
|
+
if (!existsSync2(file)) {
|
|
4107
|
+
io.out.write(" settings.yaml does not exist yet.\n");
|
|
4108
|
+
return;
|
|
4109
|
+
}
|
|
4110
|
+
io.out.write(`
|
|
4111
|
+
--- ${shortenPath(file)} ---
|
|
4112
|
+
${readFileSync2(file, "utf8")}--- end ---
|
|
4113
|
+
`);
|
|
4114
|
+
await io.rl.text("Press Enter to return");
|
|
4115
|
+
}
|
|
4116
|
+
}
|
|
4117
|
+
]
|
|
4118
|
+
},
|
|
4119
|
+
{
|
|
4120
|
+
id: "advanced",
|
|
4121
|
+
title: "All Settings",
|
|
4122
|
+
summary: "validated editor for every setting",
|
|
4123
|
+
aliases: ["all", "settings"],
|
|
4124
|
+
fields: () => [
|
|
4125
|
+
["Settings file", shortenPath(settingsPath())],
|
|
4126
|
+
["Reference", "clio-coder docs configuration-reference"]
|
|
4127
|
+
],
|
|
4128
|
+
actions: [
|
|
4129
|
+
{
|
|
4130
|
+
label: "Edit all settings",
|
|
4131
|
+
hint: "VISUAL / EDITOR; validate before saving",
|
|
4132
|
+
run: async (io) => {
|
|
4133
|
+
if (await editSettings(io.rl)) io.ok("Settings saved; previous file kept at settings.yaml.bak");
|
|
4134
|
+
}
|
|
4135
|
+
}
|
|
4136
|
+
]
|
|
4137
|
+
}
|
|
4138
|
+
];
|
|
4139
|
+
function emptyArgs() {
|
|
4140
|
+
return {
|
|
4141
|
+
positional: [],
|
|
4142
|
+
help: false,
|
|
4143
|
+
list: false,
|
|
4144
|
+
all: false,
|
|
4145
|
+
interop: false,
|
|
4146
|
+
json: false,
|
|
4147
|
+
edit: false,
|
|
4148
|
+
quick: false,
|
|
4149
|
+
settings: false,
|
|
4150
|
+
force: false,
|
|
4151
|
+
gateway: false,
|
|
4152
|
+
setOrchestrator: false,
|
|
4153
|
+
setBackground: false,
|
|
4154
|
+
setWorkerDefault: false
|
|
4155
|
+
};
|
|
4156
|
+
}
|
|
4157
|
+
async function askList(io, label, current, apply) {
|
|
4158
|
+
const answer = await ask(io.rl, `${label} (comma-separated, blank clears)`, current.join(", "));
|
|
4159
|
+
if (answer === null) return;
|
|
4160
|
+
const values = answer.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0);
|
|
4161
|
+
apply(values);
|
|
4162
|
+
io.ok(values.length === 0 ? `${label} cleared` : `${label} set to ${values.join(", ")}`);
|
|
4163
|
+
}
|
|
4164
|
+
async function assignTarget(io, role) {
|
|
4165
|
+
const settings = readSettings();
|
|
4166
|
+
const ids = settings.targets.filter((target2) => {
|
|
4167
|
+
const runtime = getRuntimeRegistry().get(target2.runtime);
|
|
4168
|
+
return role === "fleet" || runtime !== null && isOrchestratorEligibleRuntime(runtime);
|
|
4169
|
+
}).map((target2) => target2.id);
|
|
4170
|
+
if (ids.length === 0) {
|
|
4171
|
+
io.warn("No eligible targets registered yet. Add one first.");
|
|
4172
|
+
return;
|
|
4173
|
+
}
|
|
4174
|
+
io.out.write(` Registered: ${ids.join(", ")}
|
|
4175
|
+
`);
|
|
4176
|
+
const currentTarget = role === "chat" ? settings.chat.target : role === "fleet" ? settings.fleet.default.target : settings.context.memory.target;
|
|
4177
|
+
const label = role === "chat" ? "Chat" : role === "fleet" ? "Fleet" : "Background memory";
|
|
4178
|
+
const chosen = await io.rl.choose(`${label} target`, ids, currentTarget ?? ids[0] ?? "");
|
|
4179
|
+
if (chosen === null) return;
|
|
4180
|
+
if (!ids.includes(chosen)) {
|
|
4181
|
+
io.warn(`${chosen} is not a registered target; nothing changed.`);
|
|
4182
|
+
return;
|
|
4183
|
+
}
|
|
4184
|
+
const target = settings.targets.find((entry) => entry.id === chosen);
|
|
4185
|
+
const model = await ask(io.rl, `Model override (blank uses ${target?.defaultModel ?? "the target default"})`, "");
|
|
4186
|
+
if (model === null) return;
|
|
4187
|
+
updateSettings((draft) => {
|
|
4188
|
+
if (role === "chat") {
|
|
4189
|
+
draft.chat.target = chosen;
|
|
4190
|
+
draft.chat.model = model.length > 0 ? model : null;
|
|
4191
|
+
} else if (role === "fleet") {
|
|
4192
|
+
draft.fleet.default.target = chosen;
|
|
4193
|
+
draft.fleet.default.model = model.length > 0 ? model : null;
|
|
4194
|
+
} else {
|
|
4195
|
+
draft.context.memory.target = chosen;
|
|
4196
|
+
draft.context.memory.model = model.length > 0 ? model : null;
|
|
4197
|
+
}
|
|
4198
|
+
});
|
|
4199
|
+
io.ok(`${label} target set to ${chosen}`);
|
|
4200
|
+
}
|
|
4201
|
+
async function pickEntry(rl, io, entries, backLabel, plain, initialIndex = 0) {
|
|
4202
|
+
const out = io.out;
|
|
4203
|
+
if (canSelect(io.in, out)) {
|
|
4204
|
+
const result = await promptSelect({
|
|
4205
|
+
initialIndex,
|
|
4206
|
+
clearOnExit: true,
|
|
4207
|
+
choices: entries.map((entry, index2) => ({
|
|
4208
|
+
value: index2,
|
|
4209
|
+
label: entry.label,
|
|
4210
|
+
...entry.hint === void 0 ? {} : { hint: entry.hint }
|
|
4211
|
+
})),
|
|
4212
|
+
railPrefix: railPrefix(plain),
|
|
4213
|
+
backLabel,
|
|
4214
|
+
input: io.in,
|
|
4215
|
+
output: out
|
|
4216
|
+
});
|
|
4217
|
+
if (result.kind === "selected") return { kind: "index", index: result.value };
|
|
4218
|
+
return result.kind === "quit" ? { kind: "quit" } : { kind: "back" };
|
|
4219
|
+
}
|
|
4220
|
+
const rail = railPrefix(plain);
|
|
4221
|
+
entries.forEach((entry, index2) => {
|
|
4222
|
+
out.write(`${rail}${index2 + 1}. ${entry.label}${entry.hint === void 0 ? "" : ` (${entry.hint})`}
|
|
4223
|
+
`);
|
|
4224
|
+
});
|
|
4225
|
+
out.write(`${rail}b. ${backLabel}
|
|
4226
|
+
${rail}q. Quit
|
|
4227
|
+
`);
|
|
4228
|
+
const answer = await ask(rl, "\nSelection", "b");
|
|
4229
|
+
if (answer === null) return { kind: "quit" };
|
|
4230
|
+
const trimmed = answer.trim().toLowerCase();
|
|
4231
|
+
if (trimmed === "b" || trimmed === "back" || trimmed.length === 0) return { kind: "back" };
|
|
4232
|
+
if (trimmed === "q" || trimmed === "quit") return { kind: "quit" };
|
|
4233
|
+
const index = Number.parseInt(trimmed, 10) - 1;
|
|
4234
|
+
if (Number.isInteger(index) && index >= 0 && index < entries.length) return { kind: "index", index };
|
|
4235
|
+
out.write(`${rail}Not one of the choices: ${answer}
|
|
4236
|
+
`);
|
|
4237
|
+
return { kind: "back" };
|
|
4238
|
+
}
|
|
4239
|
+
function renderSection(spec, out) {
|
|
4240
|
+
const presenter = createLifecyclePresenter({ stream: out });
|
|
4241
|
+
presenter.header(spec.title, "configure");
|
|
4242
|
+
presenter.note(`Source: ${shortenPath(settingsPath())}`);
|
|
4243
|
+
presenter.fields(spec.fields());
|
|
4244
|
+
return presenter;
|
|
4245
|
+
}
|
|
4246
|
+
async function runSection(rl, streams, spec, backLabel) {
|
|
4247
|
+
let selected = 0;
|
|
4248
|
+
let notice;
|
|
4249
|
+
for (; ; ) {
|
|
4250
|
+
rl.clearScreen();
|
|
4251
|
+
const presenter = renderSection(spec, streams.out);
|
|
4252
|
+
if (notice) {
|
|
4253
|
+
if (notice.warning) presenter.warn(notice.text);
|
|
4254
|
+
else presenter.completedStep(notice.text);
|
|
4255
|
+
notice = void 0;
|
|
4256
|
+
}
|
|
4257
|
+
const io = {
|
|
4258
|
+
rl,
|
|
4259
|
+
out: streams.out,
|
|
4260
|
+
streams,
|
|
4261
|
+
ok: (text) => {
|
|
4262
|
+
notice = { text, warning: false };
|
|
4263
|
+
},
|
|
4264
|
+
warn: (text) => {
|
|
4265
|
+
notice = { text: text.trim(), warning: true };
|
|
4266
|
+
}
|
|
4267
|
+
};
|
|
4268
|
+
presenter.blank();
|
|
4269
|
+
const choice = await pickEntry(rl, streams, spec.actions, backLabel, presenter.isPlain(), selected);
|
|
4270
|
+
if (choice.kind !== "index") return choice.kind;
|
|
4271
|
+
selected = choice.index;
|
|
4272
|
+
const action = spec.actions[selected];
|
|
4273
|
+
try {
|
|
4274
|
+
if (action !== void 0) await action.run(io);
|
|
4275
|
+
} catch (error) {
|
|
4276
|
+
if (error instanceof ConfigureNavigation) {
|
|
4277
|
+
if (error.kind === "quit") return "quit";
|
|
4278
|
+
} else
|
|
4279
|
+
notice = { text: `Change not saved: ${error instanceof Error ? error.message : String(error)}`, warning: true };
|
|
4280
|
+
}
|
|
4281
|
+
}
|
|
4282
|
+
}
|
|
4283
|
+
async function runConfigSectionsMenu(rl, streams, backLabel = "quit") {
|
|
4284
|
+
let selected = 0;
|
|
4285
|
+
for (; ; ) {
|
|
4286
|
+
rl.clearScreen();
|
|
4287
|
+
const presenter = createLifecyclePresenter({ stream: streams.out });
|
|
4288
|
+
presenter.header("Clio Coder Settings", "configure");
|
|
4289
|
+
presenter.note(`Source: ${shortenPath(settingsPath())}`);
|
|
4290
|
+
presenter.blank();
|
|
4291
|
+
const choice = await pickEntry(
|
|
4292
|
+
rl,
|
|
4293
|
+
streams,
|
|
4294
|
+
SECTIONS.map((section) => ({ label: section.title, hint: section.summary })),
|
|
4295
|
+
backLabel,
|
|
4296
|
+
presenter.isPlain(),
|
|
4297
|
+
selected
|
|
4298
|
+
);
|
|
4299
|
+
if (choice.kind !== "index") return choice.kind;
|
|
4300
|
+
selected = choice.index;
|
|
4301
|
+
const spec = SECTIONS[selected];
|
|
4302
|
+
if (spec === void 0) continue;
|
|
4303
|
+
if (await runSection(rl, streams, spec, "back") === "quit") return "quit";
|
|
4304
|
+
}
|
|
4305
|
+
}
|
|
4306
|
+
async function runConfigLauncher(rl, streams) {
|
|
4307
|
+
let selected = 0;
|
|
4308
|
+
const exitCode = () => readSettings().chat.target ? 0 : 130;
|
|
4309
|
+
for (; ; ) {
|
|
4310
|
+
rl.clearScreen();
|
|
4311
|
+
const presenter = createLifecyclePresenter({ stream: streams.out });
|
|
4312
|
+
presenter.header("Clio Coder", "configure");
|
|
4313
|
+
presenter.note("Connect a model and start coding. Everything else is optional.");
|
|
4314
|
+
presenter.blank();
|
|
4315
|
+
const choice = await pickEntry(
|
|
4316
|
+
rl,
|
|
4317
|
+
streams,
|
|
4318
|
+
[
|
|
4319
|
+
{ label: "Quick Connect", hint: "endpoint \u2192 model \u2192 ready" },
|
|
4320
|
+
{ label: "Settings", hint: "all configuration options" },
|
|
4321
|
+
{ label: "Diagnostics", hint: "check an existing installation" }
|
|
4322
|
+
],
|
|
4323
|
+
"quit",
|
|
4324
|
+
presenter.isPlain(),
|
|
4325
|
+
selected
|
|
4326
|
+
);
|
|
4327
|
+
if (choice.kind !== "index") return exitCode();
|
|
4328
|
+
selected = choice.index;
|
|
4329
|
+
if (selected === 0) {
|
|
4330
|
+
const result = await runQuickConnect(rl);
|
|
4331
|
+
if (result === "connected") return 0;
|
|
4332
|
+
if (result === "quit") return exitCode();
|
|
4333
|
+
} else if (selected === 1) {
|
|
4334
|
+
if (await runConfigSectionsMenu(rl, streams, "back") === "quit") return exitCode();
|
|
4335
|
+
} else {
|
|
4336
|
+
const section = findSection("diagnostics");
|
|
4337
|
+
if (section && await runSection(rl, streams, section, "back") === "quit") return exitCode();
|
|
4338
|
+
}
|
|
4339
|
+
}
|
|
4340
|
+
}
|
|
4341
|
+
function findSection(name) {
|
|
4342
|
+
const wanted = name.trim().toLowerCase();
|
|
4343
|
+
return SECTIONS.find((section) => section.id === wanted || (section.aliases ?? []).includes(wanted));
|
|
4344
|
+
}
|
|
4345
|
+
var SECTION_IDS = SECTIONS.map((section) => section.id);
|
|
4346
|
+
async function runInteractive(rl, preselectedRuntime, defaults, streams) {
|
|
4347
|
+
if (defaults.quick) {
|
|
4348
|
+
if (!canRunOnboarding(streams)) {
|
|
4349
|
+
printError("--quick needs a terminal; use --id and --runtime for unattended setup");
|
|
4350
|
+
return 2;
|
|
4351
|
+
}
|
|
4352
|
+
return await runQuickConnect(rl) === "connected" ? 0 : 130;
|
|
4353
|
+
}
|
|
4354
|
+
if (defaults.settings) {
|
|
4355
|
+
await runConfigSectionsMenu(rl, streams);
|
|
4356
|
+
return 0;
|
|
4357
|
+
}
|
|
4358
|
+
if (preselectedRuntime) {
|
|
4359
|
+
if (canRunOnboarding(streams))
|
|
4360
|
+
return runOnboardingWizard(streams, {
|
|
4361
|
+
mode: readSettings().targets.length === 0 ? "first" : "add",
|
|
4362
|
+
runtime: preselectedRuntime
|
|
4363
|
+
});
|
|
4364
|
+
return await runTargetSetupInteractive(rl, preselectedRuntime, defaults);
|
|
4365
|
+
}
|
|
4366
|
+
if (defaults.section !== void 0) {
|
|
4367
|
+
const spec = findSection(defaults.section);
|
|
4368
|
+
if (spec === void 0) {
|
|
4369
|
+
printError(`unknown section: ${defaults.section}. Sections: ${SECTION_IDS.join(", ")}`);
|
|
4370
|
+
return 2;
|
|
4371
|
+
}
|
|
4372
|
+
if (streams.in.isTTY !== true) {
|
|
4373
|
+
renderSection(spec, streams.out).done("Done");
|
|
4374
|
+
return 0;
|
|
4375
|
+
}
|
|
4376
|
+
await runSection(rl, streams, spec, "quit");
|
|
4377
|
+
return 0;
|
|
4378
|
+
}
|
|
4379
|
+
if (canRunOnboarding(streams)) return runConfigLauncher(rl, streams);
|
|
4380
|
+
if (readSettings().targets.length === 0) {
|
|
4381
|
+
const runtime = await pickRuntimeViaCategory(rl);
|
|
4382
|
+
if (!runtime) {
|
|
4383
|
+
printError("configuration cancelled");
|
|
4384
|
+
return 130;
|
|
4385
|
+
}
|
|
4386
|
+
return await runTargetSetupInteractive(rl, runtime, defaults);
|
|
4387
|
+
}
|
|
4388
|
+
await runConfigSectionsMenu(rl, streams);
|
|
4389
|
+
return 0;
|
|
4390
|
+
}
|
|
4391
|
+
async function runConfigureCommand(argv, inStream = input, outStream = output2) {
|
|
4392
|
+
let args;
|
|
4393
|
+
try {
|
|
4394
|
+
args = parseSetupArgs(argv);
|
|
4395
|
+
} catch (err) {
|
|
4396
|
+
printError(err instanceof Error ? err.message : String(err));
|
|
4397
|
+
process.stdout.write(HELP);
|
|
4398
|
+
return 2;
|
|
4399
|
+
}
|
|
4400
|
+
if (args.help) {
|
|
4401
|
+
process.stdout.write(HELP);
|
|
4402
|
+
return 0;
|
|
4403
|
+
}
|
|
4404
|
+
ensureRegistryPopulated();
|
|
4405
|
+
if (args.edit) {
|
|
4406
|
+
if (!inStream.isTTY || !outStream.isTTY) {
|
|
4407
|
+
printError("--edit needs a terminal; use configure --json to inspect settings without one");
|
|
4408
|
+
return 2;
|
|
4409
|
+
}
|
|
4410
|
+
try {
|
|
4411
|
+
await editSettings(new ConfigurePrompts(inStream, outStream));
|
|
4412
|
+
return 0;
|
|
4413
|
+
} catch (error) {
|
|
4414
|
+
if (error instanceof ConfigureNavigation) return 0;
|
|
4415
|
+
printError(error instanceof Error ? error.message : String(error));
|
|
4416
|
+
return 1;
|
|
4417
|
+
}
|
|
4418
|
+
}
|
|
4419
|
+
if (args.json) {
|
|
4420
|
+
const settings = readSettings();
|
|
4421
|
+
outStream.write(`${JSON.stringify(settings, null, 2)}
|
|
4422
|
+
`);
|
|
4423
|
+
return 0;
|
|
4424
|
+
}
|
|
4425
|
+
if (args.list) {
|
|
4426
|
+
printRuntimeList(args.all);
|
|
4427
|
+
return 0;
|
|
4428
|
+
}
|
|
4429
|
+
if (args.interop) {
|
|
4430
|
+
if (!inStream.isTTY) return runInteropReview({ rl: null });
|
|
4431
|
+
const rl2 = new ConfigurePrompts(inStream, outStream);
|
|
4432
|
+
return runInteropReview({ rl: rl2, streams: { in: inStream, out: outStream } });
|
|
4433
|
+
}
|
|
4434
|
+
if (args.remove) return runTargetRemove(args.remove);
|
|
4435
|
+
if (args.renameOld && args.renameNew) return runTargetRename(args.renameOld, args.renameNew);
|
|
4436
|
+
if (args.positional.length > 0) {
|
|
4437
|
+
printError(
|
|
4438
|
+
"`clio-coder configure` accepts flags, not positional runtimes. Use `clio-coder auth login <runtime>` first when authentication is needed, then `clio-coder configure --runtime <runtimeId> ...`."
|
|
4439
|
+
);
|
|
4440
|
+
return 2;
|
|
4441
|
+
}
|
|
4442
|
+
const runtimeId = args.runtime;
|
|
4443
|
+
let runtime = null;
|
|
4444
|
+
if (runtimeId) {
|
|
4445
|
+
runtime = getRuntimeRegistry().get(runtimeId);
|
|
4446
|
+
if (!runtime) {
|
|
4447
|
+
printError(`unknown runtime id: ${runtimeId}`);
|
|
4448
|
+
process.stdout.write("run `clio-coder configure --list` to see registered runtimes\n");
|
|
4449
|
+
return 2;
|
|
4450
|
+
}
|
|
4451
|
+
if (runtimeId === "lmstudio-native" && runtime.id === "lmstudio") {
|
|
4452
|
+
warnLegacyNaming(runtimeId, runtime.id);
|
|
4453
|
+
}
|
|
4454
|
+
}
|
|
4455
|
+
const hasTargetSetupFlag = args.id !== void 0 || args.url !== void 0 || args.model !== void 0 || args.workerProfile !== void 0 || args.workerProfileModel !== void 0 || args.apiKey !== void 0 || args.apiKeyEnv !== void 0 || args.gateway || args.lifecycle !== void 0 || args.setOrchestrator || args.setBackground || args.backgroundModel !== void 0 || args.orchestratorModel !== void 0 || args.workerModel !== void 0 || args.bindAgent !== void 0 || args.setWorkerDefault || args.contextWindow !== void 0 || args.maxTokens !== void 0 || args.reasoning !== void 0;
|
|
4456
|
+
const nonInteractive = runtime !== null && hasTargetSetupFlag;
|
|
4457
|
+
if (nonInteractive && runtime) return runNonInteractive(runtime, args);
|
|
4458
|
+
if ((runtimeId !== void 0 || hasTargetSetupFlag) && !inStream.isTTY) {
|
|
4459
|
+
printError(
|
|
4460
|
+
runtime === null ? "--runtime is required when configuring a target non-interactively" : "--id is required when passing flags non-interactively"
|
|
4461
|
+
);
|
|
4462
|
+
return 2;
|
|
4463
|
+
}
|
|
4464
|
+
const rl = new ConfigurePrompts(inStream, outStream);
|
|
4465
|
+
try {
|
|
4466
|
+
return await runInteractive(rl, runtime, args, { in: inStream, out: outStream });
|
|
4467
|
+
} catch (err) {
|
|
4468
|
+
if (err instanceof ConfigureNavigation) {
|
|
4469
|
+
if (readSettings().targets.length > 0) return 0;
|
|
4470
|
+
printError("configuration cancelled");
|
|
4471
|
+
return 130;
|
|
4472
|
+
}
|
|
4473
|
+
printError(err instanceof Error ? err.message : String(err));
|
|
4474
|
+
return 1;
|
|
4475
|
+
}
|
|
4476
|
+
}
|
|
4477
|
+
|
|
4478
|
+
export {
|
|
4479
|
+
resolveSupportedWireModels,
|
|
4480
|
+
runTargetRemove,
|
|
4481
|
+
runTargetRename,
|
|
4482
|
+
runConfigureCommand
|
|
4483
|
+
};
|
|
4484
|
+
//# sourceMappingURL=chunk-EFXMQYI6.js.map
|