clikcode 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -14
- package/dist/chunk-23TDEBGZ.js +71 -0
- package/dist/chunk-25T3GVS7.js +425 -0
- package/dist/chunk-2BBELGHY.js +11 -0
- package/dist/chunk-2EOL5PZL.js +208 -0
- package/dist/chunk-2GAB36IE.js +26 -0
- package/dist/chunk-2OLS7V66.js +2440 -0
- package/dist/chunk-2QFO2URB.js +179 -0
- package/dist/chunk-2QWPQRSU.js +254 -0
- package/dist/chunk-2YPAPAR3.js +184 -0
- package/dist/chunk-2ZAG5372.js +33 -0
- package/dist/chunk-32IKAIZC.js +12507 -0
- package/dist/chunk-34AZEGYW.js +95 -0
- package/dist/chunk-34JQYQCA.js +175 -0
- package/dist/chunk-34ZISPAO.js +67 -0
- package/dist/chunk-3AAAARE6.js +46 -0
- package/dist/chunk-3AJ6Q3OY.js +510 -0
- package/dist/chunk-3B2CHX7M.js +884 -0
- package/dist/chunk-3BUFORRX.js +59 -0
- package/dist/chunk-3QLHYYFK.js +30 -0
- package/dist/chunk-3RXBMYKZ.js +140 -0
- package/dist/chunk-3TFNIJWS.js +52 -0
- package/dist/chunk-3W3IPDFP.js +119 -0
- package/dist/chunk-3WMS7SEE.js +417 -0
- package/dist/chunk-435ZNSZ3.js +23 -0
- package/dist/chunk-4AQ5NINV.js +39 -0
- package/dist/chunk-4GVEJ5FK.js +168 -0
- package/dist/chunk-4GXAO3UY.js +262 -0
- package/dist/chunk-4L2ZZM4Q.js +332 -0
- package/dist/chunk-4LPDG57B.js +17 -0
- package/dist/chunk-4NN3XQQT.js +223 -0
- package/dist/chunk-4QZEZME7.js +54 -0
- package/dist/chunk-4R6CSC3S.js +38 -0
- package/dist/chunk-4RHXTL3W.js +514 -0
- package/dist/chunk-4SJMPTVQ.js +18 -0
- package/dist/chunk-4VY7G6TX.js +114 -0
- package/dist/chunk-5642PBF7.js +124 -0
- package/dist/chunk-5B6TVO4A.js +33 -0
- package/dist/chunk-5BJLDUPL.js +62 -0
- package/dist/chunk-5HMFFJWU.js +19 -0
- package/dist/chunk-5IKLK33T.js +69 -0
- package/dist/chunk-5NQ5FFMX.js +44 -0
- package/dist/chunk-5QNNW5L6.js +176 -0
- package/dist/chunk-5SM5UAWN.js +239 -0
- package/dist/chunk-5WYJTA6O.js +74 -0
- package/dist/chunk-5ZSR2Y5T.js +227 -0
- package/dist/chunk-5ZWUM5GH.js +39 -0
- package/dist/chunk-64E7D4HY.js +364 -0
- package/dist/chunk-6CK466BC.js +99 -0
- package/dist/chunk-6ES45HHO.js +138 -0
- package/dist/chunk-6HYEZFGL.js +277 -0
- package/dist/chunk-6Y7HLXGW.js +29 -0
- package/dist/chunk-6YKK4FYR.js +258 -0
- package/dist/chunk-74WNMLMS.js +117 -0
- package/dist/chunk-7AULZ7OD.js +55 -0
- package/dist/chunk-7DOKGSUN.js +101 -0
- package/dist/chunk-7IH5LTIZ.js +195 -0
- package/dist/chunk-7ISTS5NS.js +21 -0
- package/dist/chunk-7NMUTGOW.js +527 -0
- package/dist/chunk-7PNHUZEL.js +153 -0
- package/dist/chunk-7TSQLONI.js +88 -0
- package/dist/chunk-AE7TOLD5.js +30 -0
- package/dist/chunk-AEMHSXKA.js +130 -0
- package/dist/chunk-AKRYTS2D.js +211 -0
- package/dist/chunk-AMNSE36L.js +59 -0
- package/dist/chunk-AZVD74ZV.js +23 -0
- package/dist/chunk-B35DVOTK.js +1981 -0
- package/dist/chunk-B4HNJRAH.js +626 -0
- package/dist/chunk-B5WYPPHS.js +13 -0
- package/dist/chunk-BBOVDXQM.js +59 -0
- package/dist/chunk-BD3ECZLK.js +62 -0
- package/dist/chunk-BDGSOT74.js +4578 -0
- package/dist/chunk-BF5VEOPK.js +31 -0
- package/dist/chunk-BFFRW4XH.js +47 -0
- package/dist/chunk-BFPC6PEW.js +208 -0
- package/dist/chunk-BGEMY2JJ.js +376 -0
- package/dist/chunk-BISGNHKD.js +35 -0
- package/dist/chunk-BMRAEBRY.js +21 -0
- package/dist/chunk-BNTXAZXW.js +127 -0
- package/dist/chunk-BOQBXGSN.js +75 -0
- package/dist/chunk-BTJDSTQP.js +213 -0
- package/dist/chunk-BUOPJQP5.js +218 -0
- package/dist/chunk-BXFJS65Q.js +52 -0
- package/dist/chunk-BXPQFSX5.js +59 -0
- package/dist/chunk-C57LIWNY.js +1269 -0
- package/dist/chunk-C6YVCCWR.js +74 -0
- package/dist/chunk-CAADDF6M.js +167 -0
- package/dist/chunk-CBANJFBO.js +69 -0
- package/dist/chunk-CERF3RIB.js +597 -0
- package/dist/chunk-COAS5ETR.js +46 -0
- package/dist/chunk-CQ7J6UQ7.js +78 -0
- package/dist/chunk-CRUVYGO2.js +26 -0
- package/dist/chunk-CVFVFRGN.js +58 -0
- package/dist/chunk-D2UK66HM.js +37 -0
- package/dist/chunk-D2W7SA4R.js +18 -0
- package/dist/chunk-DA44ZENT.js +501 -0
- package/dist/chunk-DAJ76TOC.js +99 -0
- package/dist/chunk-DCZ6CIUM.js +147 -0
- package/dist/chunk-DF35KMXM.js +1314 -0
- package/dist/chunk-DGASQT26.js +151 -0
- package/dist/chunk-DJT57C5P.js +55 -0
- package/dist/chunk-DKDPZTD3.js +44 -0
- package/dist/chunk-DQYVQ2N7.js +77 -0
- package/dist/chunk-DRTP2RTY.js +266 -0
- package/dist/chunk-DW2BMUKY.js +61 -0
- package/dist/chunk-DW5T5ZVU.js +307 -0
- package/dist/chunk-DXKNDNFC.js +164 -0
- package/dist/chunk-DZEQ7UYR.js +291 -0
- package/dist/chunk-E4F4OUAC.js +463 -0
- package/dist/chunk-EE4B6A7W.js +69 -0
- package/dist/chunk-EISKIYWG.js +23 -0
- package/dist/chunk-EKAQK7UQ.js +235 -0
- package/dist/chunk-EOBTJV32.js +123 -0
- package/dist/chunk-ESF3DIZY.js +325 -0
- package/dist/chunk-EVOHOZ4U.js +45 -0
- package/dist/chunk-EXN4KHLB.js +110 -0
- package/dist/chunk-F252T6Y3.js +78 -0
- package/dist/chunk-F3DP4ZA2.js +40 -0
- package/dist/chunk-F6F47QAY.js +58 -0
- package/dist/chunk-FA3Y23ZW.js +57 -0
- package/dist/chunk-FBKXE4EJ.js +640 -0
- package/dist/chunk-FCGEB3H6.js +23 -0
- package/dist/chunk-FF7ZVYJF.js +3732 -0
- package/dist/chunk-FFGKN6L3.js +39 -0
- package/dist/chunk-FFGU4GCC.js +94 -0
- package/dist/chunk-FSFDAOVP.js +74 -0
- package/dist/chunk-FT5TX7OX.js +1573 -0
- package/dist/chunk-G3QP67Z7.js +232 -0
- package/dist/chunk-G5ORJKV2.js +179 -0
- package/dist/chunk-GFNC62PE.js +111 -0
- package/dist/chunk-GGK43Q3N.js +67 -0
- package/dist/chunk-GGYKY4GF.js +11537 -0
- package/dist/chunk-GGYNHGNJ.js +55 -0
- package/dist/chunk-GLY7RM3C.js +354 -0
- package/dist/chunk-GQBZU6EO.js +20 -0
- package/dist/chunk-GSXENUZL.js +9 -0
- package/dist/chunk-GTOAT5D3.js +40 -0
- package/dist/chunk-GWCMDPQU.js +1007 -0
- package/dist/chunk-GXYSMYHJ.js +152 -0
- package/dist/chunk-GYMAI5NY.js +14 -0
- package/dist/chunk-H2VZMKPE.js +30 -0
- package/dist/chunk-H4THUNBM.js +2091 -0
- package/dist/chunk-HGRVSNUZ.js +361 -0
- package/dist/chunk-HI4VY473.js +27 -0
- package/dist/chunk-HOJRSD3Q.js +447 -0
- package/dist/chunk-HRX25W35.js +82 -0
- package/dist/chunk-HSE4AQYV.js +55 -0
- package/dist/chunk-HU5SSUFX.js +383 -0
- package/dist/chunk-I3GDBJLH.js +196 -0
- package/dist/chunk-I75EDU75.js +684 -0
- package/dist/chunk-IBA7DMIO.js +20 -0
- package/dist/chunk-IC6N4NZA.js +231 -0
- package/dist/chunk-IF43HIGV.js +284 -0
- package/dist/chunk-IGZ6C2MC.js +439 -0
- package/dist/chunk-IMLTL2MY.js +192 -0
- package/dist/chunk-IMZL6SGR.js +33 -0
- package/dist/chunk-IS4USJPY.js +516 -0
- package/dist/chunk-ISFSPN2F.js +82 -0
- package/dist/chunk-IXE7GTFI.js +55 -0
- package/dist/chunk-IZ77QJQG.js +36 -0
- package/dist/chunk-J2PACWRQ.js +34 -0
- package/dist/chunk-J6EGFVQX.js +180 -0
- package/dist/chunk-JEKOD43D.js +22 -0
- package/dist/chunk-JGIWATSG.js +30 -0
- package/dist/chunk-JYBONKD4.js +43 -0
- package/dist/chunk-K2NLG2HK.js +454 -0
- package/dist/chunk-KCQ4TBLS.js +164 -0
- package/dist/chunk-KD5KIVMS.js +176 -0
- package/dist/chunk-KHW6TX6I.js +63 -0
- package/dist/chunk-KI5GZFCE.js +520 -0
- package/dist/chunk-KN34B7NO.js +105 -0
- package/dist/chunk-KYUHIFP3.js +136 -0
- package/dist/chunk-KZL5VS4B.js +300 -0
- package/dist/chunk-L3VW3QIH.js +48 -0
- package/dist/chunk-LA6MG4ET.js +2110 -0
- package/dist/chunk-LAVFOA3S.js +66 -0
- package/dist/chunk-LB4OA77N.js +13 -0
- package/dist/chunk-LBFRF2K4.js +196 -0
- package/dist/chunk-LM6EIA4B.js +93 -0
- package/dist/chunk-LPCNRGJ7.js +692 -0
- package/dist/chunk-LSLNL5T3.js +168 -0
- package/dist/chunk-LVRRWP4W.js +568 -0
- package/dist/chunk-LWCFBRHL.js +33 -0
- package/dist/chunk-LXFTMGZZ.js +166 -0
- package/dist/chunk-M33LVA4M.js +151 -0
- package/dist/chunk-M3FO5UMK.js +4944 -0
- package/dist/chunk-M5QNDBAY.js +66 -0
- package/dist/chunk-M6ND6KBE.js +1291 -0
- package/dist/chunk-M7H3WQTE.js +76 -0
- package/dist/chunk-MCBRVPA7.js +191 -0
- package/dist/chunk-MCSDWZET.js +91 -0
- package/dist/chunk-MDT5XDXL.js +289 -0
- package/dist/chunk-MJG3IQY4.js +91 -0
- package/dist/chunk-MOU3N2UL.js +44 -0
- package/dist/chunk-MP4KZOQC.js +3451 -0
- package/dist/chunk-MPAJ446F.js +66 -0
- package/dist/chunk-MVJZZ6AL.js +16 -0
- package/dist/chunk-MXS6S2PY.js +253 -0
- package/dist/chunk-N3SFDYM7.js +291 -0
- package/dist/chunk-NAOX3JUB.js +13 -0
- package/dist/chunk-NEKKIBCX.js +283 -0
- package/dist/chunk-NKDATMEM.js +133 -0
- package/dist/chunk-NR4FMC4K.js +395 -0
- package/dist/chunk-NSOHOJBR.js +221 -0
- package/dist/chunk-NTDB6QKF.js +29 -0
- package/dist/chunk-NWEYRBWK.js +25 -0
- package/dist/chunk-O2YSNYWD.js +23 -0
- package/dist/chunk-O3EW7LAY.js +54 -0
- package/dist/chunk-O7BNJIXU.js +366 -0
- package/dist/chunk-OARL2NXZ.js +116 -0
- package/dist/chunk-OHKZUEJW.js +351 -0
- package/dist/chunk-OKU45BXA.js +647 -0
- package/dist/chunk-OL4JBD3J.js +59 -0
- package/dist/chunk-OLUO5DDR.js +192 -0
- package/dist/chunk-OQ245JLA.js +196 -0
- package/dist/chunk-P72UZAQI.js +289 -0
- package/dist/chunk-PAL2ENB6.js +20 -0
- package/dist/chunk-PAXYQZH7.js +53 -0
- package/dist/chunk-PDPEM5VW.js +51 -0
- package/dist/chunk-PEWCDI2C.js +668 -0
- package/dist/chunk-PGZ54EDX.js +27 -0
- package/dist/chunk-PRWVLDZF.js +73 -0
- package/dist/chunk-PSQQ75VJ.js +52 -0
- package/dist/chunk-PUOVIFHW.js +118 -0
- package/dist/chunk-PWBF2X3V.js +107 -0
- package/dist/chunk-PWXII6HF.js +43 -0
- package/dist/chunk-Q35VLJRT.js +80 -0
- package/dist/chunk-QJP7EYGL.js +128 -0
- package/dist/chunk-QPQKX2MK.js +8836 -0
- package/dist/chunk-QQRLPY25.js +1053 -0
- package/dist/chunk-QUS4ER2W.js +407 -0
- package/dist/chunk-QYHI3YET.js +29 -0
- package/dist/chunk-QYRU2UQI.js +32 -0
- package/dist/chunk-R6XVVQGC.js +13 -0
- package/dist/chunk-R7QN6ONS.js +483 -0
- package/dist/chunk-RD23MPGC.js +221 -0
- package/dist/chunk-RDDWQBEM.js +185 -0
- package/dist/chunk-RDLLDYFO.js +104 -0
- package/dist/chunk-RE4TGORR.js +84 -0
- package/dist/chunk-RJLHVYQY.js +217 -0
- package/dist/chunk-RJLPTWHW.js +905 -0
- package/dist/chunk-RKUVLRZI.js +295 -0
- package/dist/chunk-ROGXPGYR.js +37 -0
- package/dist/chunk-RSZGEL5U.js +163 -0
- package/dist/chunk-RVUOIJXN.js +909 -0
- package/dist/chunk-RW7F4JRP.js +11 -0
- package/dist/chunk-S4UO3AO3.js +53 -0
- package/dist/chunk-S5JAAF6S.js +585 -0
- package/dist/chunk-SNU37TQI.js +56 -0
- package/dist/chunk-SQVUDO2O.js +31 -0
- package/dist/chunk-SYVHIYQT.js +66 -0
- package/dist/chunk-SZBQMTG2.js +85 -0
- package/dist/chunk-T5VCXA3J.js +25 -0
- package/dist/chunk-TK6NSP56.js +30 -0
- package/dist/chunk-TKWVMA6L.js +22 -0
- package/dist/chunk-TQDKJHWX.js +59 -0
- package/dist/chunk-TQDM7S5N.js +127 -0
- package/dist/chunk-TULAXS77.js +23 -0
- package/dist/chunk-TVT45XNH.js +4625 -0
- package/dist/chunk-TWCVV2JO.js +467 -0
- package/dist/chunk-U4DKAD6S.js +47 -0
- package/dist/chunk-UA5K2BTI.js +564 -0
- package/dist/chunk-UAMKCMOK.js +40 -0
- package/dist/chunk-UBMVADBF.js +51 -0
- package/dist/chunk-UFQ5A5PW.js +645 -0
- package/dist/chunk-UOD2SOLL.js +1301 -0
- package/dist/chunk-UTSB4LOW.js +156 -0
- package/dist/chunk-UVXNIUTN.js +412 -0
- package/dist/chunk-UXVPXYPE.js +90 -0
- package/dist/chunk-UYEEMIWR.js +374 -0
- package/dist/chunk-VBGM5ZBW.js +54 -0
- package/dist/chunk-VEWPCZPG.js +762 -0
- package/dist/chunk-VIRDLZ5E.js +108 -0
- package/dist/chunk-VMPO7WKN.js +52 -0
- package/dist/chunk-W2NVSDO5.js +5122 -0
- package/dist/chunk-W3YYPBEA.js +176 -0
- package/dist/chunk-W5AYOICN.js +280 -0
- package/dist/chunk-W5GZOIUF.js +27 -0
- package/dist/chunk-WHKNLZ3C.js +76 -0
- package/dist/chunk-WKBEPPQ5.js +1409 -0
- package/dist/chunk-WM3Z6QKQ.js +151 -0
- package/dist/chunk-WMI2TPMA.js +31 -0
- package/dist/chunk-WNX5VD7S.js +150 -0
- package/dist/chunk-WOVTYST3.js +60 -0
- package/dist/chunk-WPB5WEZJ.js +546 -0
- package/dist/chunk-WUO5EOAT.js +44 -0
- package/dist/chunk-WWLJMP6D.js +133 -0
- package/dist/chunk-WZMLH3XP.js +58 -0
- package/dist/chunk-WZYVLUVQ.js +79 -0
- package/dist/chunk-X2OCPVU5.js +135 -0
- package/dist/chunk-X3CL6DTR.js +95 -0
- package/dist/chunk-X6WF7JEV.js +354 -0
- package/dist/chunk-XAHGBPWT.js +44 -0
- package/dist/chunk-XCKQ5BM2.js +228 -0
- package/dist/chunk-XIBYREEY.js +106 -0
- package/dist/chunk-XKW5NDMR.js +378 -0
- package/dist/chunk-XRDALAO3.js +100 -0
- package/dist/chunk-XUP22EAS.js +41 -0
- package/dist/chunk-XWAC3MKW.js +243 -0
- package/dist/chunk-Y3R7JMXB.js +59 -0
- package/dist/chunk-Y54LTP4W.js +82 -0
- package/dist/chunk-Y7UECI4M.js +99 -0
- package/dist/chunk-YACGDFHC.js +47 -0
- package/dist/chunk-YHNIQPKY.js +71 -0
- package/dist/chunk-YMBR6HYP.js +111 -0
- package/dist/chunk-YMCH3L2S.js +26 -0
- package/dist/chunk-Z4ZU6T7V.js +99 -0
- package/dist/chunk-ZDPF67ZZ.js +173 -0
- package/dist/chunk-ZFC2Q67K.js +101 -0
- package/dist/chunk-ZGHNNSCT.js +114 -0
- package/dist/chunk-ZGX3ERAT.js +173 -0
- package/dist/chunk-ZI3YHEBY.js +37 -0
- package/dist/chunk-ZN7G6JLS.js +639 -0
- package/dist/chunk-ZNPFQMXT.js +47 -0
- package/dist/chunk-ZOU3LV4U.js +63 -0
- package/dist/chunk-ZT7B4H2V.js +117 -0
- package/dist/chunk-ZZCBDNZI.js +58 -0
- package/dist/cli.js +494 -112923
- package/dist/computer-tools.js +36642 -21259
- package/dist/harness-catalog.cjs +88 -43
- package/dist/index.js +1 -1
- package/dist/local-model-supervisor.cjs +555 -0
- package/package.json +3 -4
|
@@ -0,0 +1,1053 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
copilotAccountModels,
|
|
5
|
+
freePlanModels,
|
|
6
|
+
planIsFree,
|
|
7
|
+
preferredFreeModel
|
|
8
|
+
} from "./chunk-DA44ZENT.js";
|
|
9
|
+
import {
|
|
10
|
+
modelLabel
|
|
11
|
+
} from "./chunk-F252T6Y3.js";
|
|
12
|
+
import {
|
|
13
|
+
heldOff,
|
|
14
|
+
markAccountNeedsSignIn,
|
|
15
|
+
recordBackgroundOutcome
|
|
16
|
+
} from "./chunk-CVFVFRGN.js";
|
|
17
|
+
import {
|
|
18
|
+
GOOSE_DRIVEN_HARNESSES,
|
|
19
|
+
discoverGooseProviders,
|
|
20
|
+
gooseConnect,
|
|
21
|
+
gooseModelsDevModels,
|
|
22
|
+
modelsDevCache,
|
|
23
|
+
modelsDevFiles,
|
|
24
|
+
modelsDevProvider,
|
|
25
|
+
providerKeyNames
|
|
26
|
+
} from "./chunk-QJP7EYGL.js";
|
|
27
|
+
import {
|
|
28
|
+
acpConfigOptionValues,
|
|
29
|
+
acpDiscoverySession,
|
|
30
|
+
acpProbeArgv,
|
|
31
|
+
acpSessionModels,
|
|
32
|
+
queryAcp
|
|
33
|
+
} from "./chunk-ESF3DIZY.js";
|
|
34
|
+
import {
|
|
35
|
+
nativeAccountEnvironment,
|
|
36
|
+
nativeProfileEnvironment
|
|
37
|
+
} from "./chunk-ZGX3ERAT.js";
|
|
38
|
+
import {
|
|
39
|
+
localHarnessForCommand,
|
|
40
|
+
modelDisplayId,
|
|
41
|
+
modelIdFromDisplay
|
|
42
|
+
} from "./chunk-KYUHIFP3.js";
|
|
43
|
+
import {
|
|
44
|
+
PROBE_DEADLINE_MS,
|
|
45
|
+
binaryFingerprint,
|
|
46
|
+
expandAuthPaths,
|
|
47
|
+
harnessBinaryIdentity,
|
|
48
|
+
mayRunInBackground,
|
|
49
|
+
resolveBinaryPath,
|
|
50
|
+
runVendorCommand,
|
|
51
|
+
sameFingerprint,
|
|
52
|
+
vendorCommandText
|
|
53
|
+
} from "./chunk-DF35KMXM.js";
|
|
54
|
+
import {
|
|
55
|
+
jsonMemo
|
|
56
|
+
} from "./chunk-ZT7B4H2V.js";
|
|
57
|
+
import {
|
|
58
|
+
stripAnsi
|
|
59
|
+
} from "./chunk-G3QP67Z7.js";
|
|
60
|
+
import {
|
|
61
|
+
atomicWriteFile
|
|
62
|
+
} from "./chunk-F6F47QAY.js";
|
|
63
|
+
import {
|
|
64
|
+
quiet,
|
|
65
|
+
swallowed
|
|
66
|
+
} from "./chunk-RDDWQBEM.js";
|
|
67
|
+
import {
|
|
68
|
+
stateDirectory
|
|
69
|
+
} from "./chunk-MPAJ446F.js";
|
|
70
|
+
|
|
71
|
+
// src/harness/accounts/model-catalog.ts
|
|
72
|
+
import { homedir as homedir3 } from "node:os";
|
|
73
|
+
import { join as join5 } from "node:path";
|
|
74
|
+
import { readFile as readFile4, stat as stat3 } from "node:fs/promises";
|
|
75
|
+
import { createHash } from "node:crypto";
|
|
76
|
+
|
|
77
|
+
// src/harness/accounts/claude-models.ts
|
|
78
|
+
import { open } from "node:fs/promises";
|
|
79
|
+
var LATEST = /latest_per_family:\{([^}]*)\}/;
|
|
80
|
+
var ALIAS_ENTRY = /([a-z]+):"(claude-[a-z0-9-]+)"/g;
|
|
81
|
+
var MODEL_ENTRY = /\{id:"(claude-[a-z0-9-]+)",family:"[a-z]+",display_name:"([^"]{1,40})"/g;
|
|
82
|
+
function parseClaudeModelTable(text, into = { aliases: {}, displayNames: {} }) {
|
|
83
|
+
const latest = LATEST.exec(text);
|
|
84
|
+
if (latest) for (const [, alias, id] of latest[1].matchAll(ALIAS_ENTRY)) into.aliases[alias] = id;
|
|
85
|
+
for (const [, id, name] of text.matchAll(MODEL_ENTRY)) into.displayNames[id] ??= name;
|
|
86
|
+
return into;
|
|
87
|
+
}
|
|
88
|
+
async function scanBinary(path) {
|
|
89
|
+
const CHUNK = 8 * 1024 * 1024;
|
|
90
|
+
const OVERLAP = 64 * 1024;
|
|
91
|
+
const table = { aliases: {}, displayNames: {} };
|
|
92
|
+
const handle = await open(path, "r");
|
|
93
|
+
try {
|
|
94
|
+
const buffer = Buffer.alloc(CHUNK + OVERLAP);
|
|
95
|
+
let carried = 0;
|
|
96
|
+
for (let position = 0; ; ) {
|
|
97
|
+
const { bytesRead } = await handle.read(buffer, carried, CHUNK, position);
|
|
98
|
+
if (!bytesRead) break;
|
|
99
|
+
const length = carried + bytesRead;
|
|
100
|
+
parseClaudeModelTable(buffer.toString("latin1", 0, length), table);
|
|
101
|
+
position += bytesRead;
|
|
102
|
+
carried = Math.min(OVERLAP, length);
|
|
103
|
+
buffer.copy(buffer, 0, length - carried, length);
|
|
104
|
+
}
|
|
105
|
+
} finally {
|
|
106
|
+
await handle.close();
|
|
107
|
+
}
|
|
108
|
+
return Object.keys(table.aliases).length ? table : void 0;
|
|
109
|
+
}
|
|
110
|
+
var memo = jsonMemo("cache/claude-models.json", () => void 0, (parsed) => {
|
|
111
|
+
const file = parsed;
|
|
112
|
+
return file.v === 1 ? file : void 0;
|
|
113
|
+
});
|
|
114
|
+
var current;
|
|
115
|
+
var pending;
|
|
116
|
+
async function claudeModelTable(binary = "claude") {
|
|
117
|
+
const fingerprint = await binaryFingerprint(await resolveBinaryPath(binary));
|
|
118
|
+
if (!fingerprint) return void 0;
|
|
119
|
+
if (current && sameFingerprint(current.fingerprint, fingerprint)) return current.table;
|
|
120
|
+
const remembered = await memo.read();
|
|
121
|
+
if (remembered && sameFingerprint(remembered.fingerprint, fingerprint)) {
|
|
122
|
+
current = { fingerprint, table: remembered.table };
|
|
123
|
+
return remembered.table;
|
|
124
|
+
}
|
|
125
|
+
pending ??= scanBinary(fingerprint.path).then(async (table) => {
|
|
126
|
+
if (table) {
|
|
127
|
+
current = { fingerprint, table };
|
|
128
|
+
await memo.write({ v: 1, fingerprint, table });
|
|
129
|
+
}
|
|
130
|
+
return table;
|
|
131
|
+
}).catch(quiet("harness/accounts/claude-models")).finally(() => {
|
|
132
|
+
pending = void 0;
|
|
133
|
+
});
|
|
134
|
+
return pending;
|
|
135
|
+
}
|
|
136
|
+
function claudeModelLabel(model) {
|
|
137
|
+
const table = current?.table;
|
|
138
|
+
if (!table) return void 0;
|
|
139
|
+
const id = table.aliases[model] ?? model;
|
|
140
|
+
return table.displayNames[id];
|
|
141
|
+
}
|
|
142
|
+
function claudeModelAliases(table) {
|
|
143
|
+
return table ? Object.keys(table.aliases) : [];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// src/harness/accounts/hermes-discovery.ts
|
|
147
|
+
import { join } from "node:path";
|
|
148
|
+
function hermesCachedModels(cacheJson) {
|
|
149
|
+
try {
|
|
150
|
+
const cache = JSON.parse(cacheJson);
|
|
151
|
+
const models = /* @__PURE__ */ new Set();
|
|
152
|
+
for (const [provider, bucket] of Object.entries(cache)) {
|
|
153
|
+
if (!bucket || !Array.isArray(bucket.models)) continue;
|
|
154
|
+
for (const model of bucket.models) {
|
|
155
|
+
if (typeof model === "string" && model.trim()) models.add(`${provider}:${model.trim()}`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return [...models];
|
|
159
|
+
} catch {
|
|
160
|
+
return [];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function hermesToolsetNames(listText) {
|
|
164
|
+
const names = /* @__PURE__ */ new Set();
|
|
165
|
+
for (const line of listText.split(/\r?\n/)) {
|
|
166
|
+
const match = /(?:enabled|disabled)\s+([a-z][a-z0-9_-]*)\b/.exec(line);
|
|
167
|
+
if (match) names.add(match[1]);
|
|
168
|
+
}
|
|
169
|
+
return [...names];
|
|
170
|
+
}
|
|
171
|
+
function hermesInstallDirectory(versionText) {
|
|
172
|
+
return /^Install directory:\s*(.+)\s*$/m.exec(versionText)?.[1]?.trim() || void 0;
|
|
173
|
+
}
|
|
174
|
+
var installs = /* @__PURE__ */ new Map();
|
|
175
|
+
async function hermesInstall(harness, environment) {
|
|
176
|
+
const key = await harnessBinaryIdentity(harness.binary) ?? harness.binary;
|
|
177
|
+
let asked = installs.get(key);
|
|
178
|
+
if (!asked) {
|
|
179
|
+
asked = vendorCommandText({ gate: { inert: "--version" }, binary: harness.binary, argv: ["--version"], environment, deadlineMs: PROBE_DEADLINE_MS }).then(hermesInstallDirectory, () => void 0);
|
|
180
|
+
installs.set(key, asked);
|
|
181
|
+
}
|
|
182
|
+
const install = await asked;
|
|
183
|
+
if (!install) {
|
|
184
|
+
if (installs.get(key) === asked) installs.delete(key);
|
|
185
|
+
return void 0;
|
|
186
|
+
}
|
|
187
|
+
return { install, python: join(install, "venv", process.platform === "win32" ? "Scripts/python.exe" : "bin/python") };
|
|
188
|
+
}
|
|
189
|
+
async function discoverHermesChoices(harness, account) {
|
|
190
|
+
const environment = nativeProfileEnvironment(account?.nativeProfile);
|
|
191
|
+
const toolsText = await vendorCommandText({ gate: harness, argv: ["tools", "list"], environment, deadlineMs: PROBE_DEADLINE_MS }).catch(() => "");
|
|
192
|
+
return { toolsets: hermesToolsetNames(toolsText) };
|
|
193
|
+
}
|
|
194
|
+
var INVENTORY_SCRIPT = `
|
|
195
|
+
import json
|
|
196
|
+
from hermes_cli.inventory import build_models_payload, load_picker_context
|
|
197
|
+
from hermes_cli.auth import get_auth_status
|
|
198
|
+
CHECKED = {"nous", "openai-codex", "xai-oauth", "qwen-oauth", "minimax-oauth", "copilot-acp", "azure-foundry"}
|
|
199
|
+
p = build_models_payload(load_picker_context(), explicit_only=False, include_unconfigured=True,
|
|
200
|
+
picker_hints=True, canonical_order=True, pricing=False, capabilities=False, refresh=False,
|
|
201
|
+
probe_custom_providers=False, probe_current_custom_provider=False, max_models=200)
|
|
202
|
+
rows = []
|
|
203
|
+
for row in p.get("providers") or []:
|
|
204
|
+
slug = row.get("slug")
|
|
205
|
+
if not slug or row.get("source") == "virtual":
|
|
206
|
+
continue
|
|
207
|
+
ready = bool(row.get("authenticated"))
|
|
208
|
+
if slug in CHECKED:
|
|
209
|
+
try:
|
|
210
|
+
ready = bool(get_auth_status(slug).get("logged_in"))
|
|
211
|
+
except Exception:
|
|
212
|
+
pass
|
|
213
|
+
models = [m.get("id") or m.get("model") or m.get("name") if isinstance(m, dict) else m for m in row.get("models") or []]
|
|
214
|
+
rows.append({"provider": slug, "name": row.get("name"), "ready": ready, "authType": row.get("auth_type"), "models": [m for m in models if m]})
|
|
215
|
+
print("\\x00HERMES_INVENTORY" + json.dumps({"providers": rows, "model": p.get("model"), "provider": p.get("provider")}))
|
|
216
|
+
`;
|
|
217
|
+
var HERMES_OAUTH_PROVIDERS = /* @__PURE__ */ new Set(["anthropic", "nous", "openai-codex", "xai-oauth", "qwen-oauth", "minimax-oauth"]);
|
|
218
|
+
function hermesConnect(provider, name, authType) {
|
|
219
|
+
if (provider === "nous") return { id: provider, label: "Nous Portal", detail: "sign in in the browser", argv: ["auth", "add", "nous"] };
|
|
220
|
+
if (HERMES_OAUTH_PROVIDERS.has(provider)) return { id: provider, label: name, detail: "sign in in the browser", argv: ["auth", "add", provider] };
|
|
221
|
+
if (authType === "api_key" && provider !== "custom") return { id: provider, label: name, detail: "paste an API key", argv: ["auth", "add", provider] };
|
|
222
|
+
return { id: provider, label: name, detail: "set up in Hermes", argv: ["model"] };
|
|
223
|
+
}
|
|
224
|
+
var CONNECT_ORDER = (item) => item.id === "nous" ? 0 : item.detail.startsWith("sign in") ? 1 : item.detail.startsWith("paste") ? 2 : 3;
|
|
225
|
+
function hermesInventory(output) {
|
|
226
|
+
const marker = output.lastIndexOf("\0HERMES_INVENTORY");
|
|
227
|
+
if (marker < 0) return void 0;
|
|
228
|
+
try {
|
|
229
|
+
const parsed = JSON.parse(output.slice(marker + "\0HERMES_INVENTORY".length).split("\n")[0]);
|
|
230
|
+
const models = [];
|
|
231
|
+
const labels = {};
|
|
232
|
+
const connect = [];
|
|
233
|
+
for (const row of parsed.providers ?? []) {
|
|
234
|
+
if (typeof row.provider !== "string" || !row.provider) continue;
|
|
235
|
+
const name = typeof row.name === "string" && row.name ? row.name : row.provider;
|
|
236
|
+
const rowModels = Array.isArray(row.models) ? row.models.filter((model) => typeof model === "string" && Boolean(model.trim())) : [];
|
|
237
|
+
if (row.ready !== true || !rowModels.length) {
|
|
238
|
+
connect.push(hermesConnect(row.provider, name, typeof row.authType === "string" ? row.authType : void 0));
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
for (const model of rowModels) models.push(`${row.provider}:${model.trim()}`);
|
|
242
|
+
}
|
|
243
|
+
connect.sort((left, right) => CONNECT_ORDER(left) - CONNECT_ORDER(right) || left.label.localeCompare(right.label));
|
|
244
|
+
const configured = typeof parsed.model === "string" && parsed.model && typeof parsed.provider === "string" && parsed.provider ? `${parsed.provider}:${parsed.model}` : void 0;
|
|
245
|
+
return models.length || connect.length ? { models, ...configured ? { configured } : {}, labels, connect } : void 0;
|
|
246
|
+
} catch {
|
|
247
|
+
return void 0;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
async function discoverHermesModels(harness, account) {
|
|
251
|
+
const environment = nativeProfileEnvironment(account?.nativeProfile);
|
|
252
|
+
const found = await hermesInstall(harness, environment);
|
|
253
|
+
if (!found) return void 0;
|
|
254
|
+
const { install, python } = found;
|
|
255
|
+
const outcome = await runVendorCommand({
|
|
256
|
+
gate: harness,
|
|
257
|
+
binary: python,
|
|
258
|
+
argv: ["-c", INVENTORY_SCRIPT],
|
|
259
|
+
cwd: install,
|
|
260
|
+
deadlineMs: PROBE_DEADLINE_MS,
|
|
261
|
+
environment: { ...environment, PYTHONPATH: install, PYTHONHOME: "" }
|
|
262
|
+
});
|
|
263
|
+
const output = outcome.status === "ok" ? outcome.value.stdout : "";
|
|
264
|
+
return hermesInventory(output);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// src/harness/accounts/openclaw-discovery.ts
|
|
268
|
+
function jsonDocument(output) {
|
|
269
|
+
const start = output.indexOf("{");
|
|
270
|
+
if (start < 0) return void 0;
|
|
271
|
+
try {
|
|
272
|
+
return JSON.parse(output.slice(start));
|
|
273
|
+
} catch {
|
|
274
|
+
return void 0;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function openClawInventory(catalogJson, pluginsJson) {
|
|
278
|
+
const catalog = jsonDocument(catalogJson);
|
|
279
|
+
if (!catalog || !Array.isArray(catalog.models)) return void 0;
|
|
280
|
+
const models = [];
|
|
281
|
+
const labels = {};
|
|
282
|
+
const readyProviders = /* @__PURE__ */ new Set();
|
|
283
|
+
let configured;
|
|
284
|
+
for (const row of catalog.models) {
|
|
285
|
+
if (typeof row.key !== "string" || !row.key.includes("/")) continue;
|
|
286
|
+
const tags = Array.isArray(row.tags) ? row.tags : [];
|
|
287
|
+
const isDefault = tags.includes("default");
|
|
288
|
+
if (isDefault) configured = row.key;
|
|
289
|
+
if (row.available !== true && !isDefault) continue;
|
|
290
|
+
models.push(row.key);
|
|
291
|
+
if (row.available === true) readyProviders.add(row.key.split("/")[0]);
|
|
292
|
+
if (typeof row.name === "string" && row.name) labels[row.key] = row.name;
|
|
293
|
+
}
|
|
294
|
+
const plugins = jsonDocument(pluginsJson);
|
|
295
|
+
const connect = [];
|
|
296
|
+
const seen = /* @__PURE__ */ new Set();
|
|
297
|
+
for (const plugin of plugins?.plugins ?? []) {
|
|
298
|
+
if (plugin.enabled !== true || !Array.isArray(plugin.providerIds)) continue;
|
|
299
|
+
const backends = new Set(Array.isArray(plugin.cliBackendIds) ? plugin.cliBackendIds : []);
|
|
300
|
+
const name = typeof plugin.name === "string" && plugin.name && !plugin.name.startsWith("@") ? plugin.name : void 0;
|
|
301
|
+
for (const provider of plugin.providerIds) {
|
|
302
|
+
if (typeof provider !== "string" || !provider || backends.has(provider) || readyProviders.has(provider) || seen.has(provider)) continue;
|
|
303
|
+
seen.add(provider);
|
|
304
|
+
connect.push({
|
|
305
|
+
id: provider,
|
|
306
|
+
label: plugin.providerIds.length === 1 && name ? name : provider,
|
|
307
|
+
detail: "sign in or paste a key",
|
|
308
|
+
argv: ["models", "auth", "login", "--provider", provider]
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
connect.sort((left, right) => left.label.localeCompare(right.label));
|
|
313
|
+
return { models, ...configured ? { configured } : {}, labels, connect };
|
|
314
|
+
}
|
|
315
|
+
async function discoverOpenClawModels(harness, account) {
|
|
316
|
+
const environment = nativeProfileEnvironment(account?.nativeProfile);
|
|
317
|
+
const [catalogJson, pluginsJson] = await Promise.all([
|
|
318
|
+
vendorCommandText({ gate: harness, argv: ["models", "list", "--all", "--refresh", "--json"], environment, deadlineMs: PROBE_DEADLINE_MS }).catch(() => ""),
|
|
319
|
+
vendorCommandText({ gate: harness, argv: ["plugins", "list", "--json"], environment, deadlineMs: PROBE_DEADLINE_MS }).catch(() => "")
|
|
320
|
+
]);
|
|
321
|
+
return openClawInventory(catalogJson, pluginsJson);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// src/harness/accounts/opencode-discovery.ts
|
|
325
|
+
import { readFile } from "node:fs/promises";
|
|
326
|
+
import { homedir } from "node:os";
|
|
327
|
+
import { join as join2 } from "node:path";
|
|
328
|
+
var COMMON = ["anthropic", "openai", "github-copilot", "google", "openrouter", "xai", "deepseek", "groq", "mistral", "amazon-bedrock", "azure"];
|
|
329
|
+
function opencodeConnect(cacheJson, connectedModels) {
|
|
330
|
+
let cache;
|
|
331
|
+
try {
|
|
332
|
+
cache = JSON.parse(cacheJson);
|
|
333
|
+
} catch {
|
|
334
|
+
return [];
|
|
335
|
+
}
|
|
336
|
+
if (!cache || typeof cache !== "object") return [];
|
|
337
|
+
const connected = new Set(connectedModels.map((model) => model.split("/")[0]));
|
|
338
|
+
const connect = [];
|
|
339
|
+
for (const [id, provider] of Object.entries(cache)) {
|
|
340
|
+
if (!id || connected.has(id) || !provider || typeof provider !== "object") continue;
|
|
341
|
+
const name = typeof provider.name === "string" && provider.name ? provider.name : id;
|
|
342
|
+
const keyed = Array.isArray(provider.env) && provider.env.length > 0;
|
|
343
|
+
connect.push({ id, label: name, detail: keyed ? "sign in or paste a key" : "sign in", argv: ["auth", "login", "--provider", id] });
|
|
344
|
+
}
|
|
345
|
+
const rank = (item) => {
|
|
346
|
+
const index = COMMON.indexOf(item.id);
|
|
347
|
+
return index < 0 ? COMMON.length : index;
|
|
348
|
+
};
|
|
349
|
+
return connect.sort((left, right) => rank(left) - rank(right) || left.label.localeCompare(right.label));
|
|
350
|
+
}
|
|
351
|
+
async function discoverOpencodeConnect(harness, connectedModels) {
|
|
352
|
+
const cacheRoot = process.env.XDG_CACHE_HOME?.trim() || join2(homedir(), ".cache");
|
|
353
|
+
const cacheJson = await readFile(join2(cacheRoot, harness.binary, "models.json"), "utf8").catch(() => "");
|
|
354
|
+
return cacheJson ? opencodeConnect(cacheJson, connectedModels) : [];
|
|
355
|
+
}
|
|
356
|
+
function opencodeVerboseModels(raw) {
|
|
357
|
+
const models = [];
|
|
358
|
+
const free = [];
|
|
359
|
+
const blocks = stripAnsi(raw).split(/^([^\s{}"]+\/\S+)[ \t]*$/m);
|
|
360
|
+
for (let index = 1; index < blocks.length; index += 2) {
|
|
361
|
+
const id = blocks[index];
|
|
362
|
+
models.push(id);
|
|
363
|
+
let meta;
|
|
364
|
+
try {
|
|
365
|
+
meta = JSON.parse(blocks[index + 1] ?? "");
|
|
366
|
+
} catch {
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
const isFree = typeof meta.isFree === "boolean" ? meta.isFree : meta.cost?.input === 0 && meta.cost?.output === 0;
|
|
370
|
+
if (isFree) free.push(id);
|
|
371
|
+
}
|
|
372
|
+
return { models, free };
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// src/harness/accounts/pi-discovery.ts
|
|
376
|
+
import { readdir, readFile as readFile2, realpath, stat } from "node:fs/promises";
|
|
377
|
+
import { dirname, join as join3 } from "node:path";
|
|
378
|
+
function piModels(listing) {
|
|
379
|
+
const models = [];
|
|
380
|
+
const lines = stripAnsi(listing).split(/\r?\n/);
|
|
381
|
+
const header = lines.findIndex((line) => /^\s*provider\s+model\b/.test(line));
|
|
382
|
+
if (header < 0) return models;
|
|
383
|
+
for (const line of lines.slice(header + 1)) {
|
|
384
|
+
const [provider, model] = line.trim().split(/\s+/);
|
|
385
|
+
if (provider && model) models.push(`${provider}/${model}`);
|
|
386
|
+
}
|
|
387
|
+
return models;
|
|
388
|
+
}
|
|
389
|
+
function piConfiguredModel(settings, listed) {
|
|
390
|
+
if (!settings) return void 0;
|
|
391
|
+
try {
|
|
392
|
+
const parsed = JSON.parse(settings);
|
|
393
|
+
if (typeof parsed.defaultProvider !== "string" || typeof parsed.defaultModel !== "string") return void 0;
|
|
394
|
+
const model = `${parsed.defaultProvider}/${parsed.defaultModel}`;
|
|
395
|
+
return listed.includes(model) ? model : void 0;
|
|
396
|
+
} catch {
|
|
397
|
+
return void 0;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
var COMMON2 = ["anthropic", "openai-codex", "openai", "github-copilot", "google", "xai", "openrouter", "deepseek", "mistral", "groq"];
|
|
401
|
+
function piConnect(providers, connectedModels) {
|
|
402
|
+
const connected = new Set(connectedModels.map((model) => model.split("/")[0]));
|
|
403
|
+
const rank = (id) => {
|
|
404
|
+
const index = COMMON2.indexOf(id);
|
|
405
|
+
return index < 0 ? COMMON2.length : index;
|
|
406
|
+
};
|
|
407
|
+
return providers.filter((provider) => !connected.has(provider.id)).map((provider) => ({ id: provider.id, label: provider.label, detail: "sign in inside Pi", argv: [] })).sort((left, right) => rank(left.id) - rank(right.id) || left.label.localeCompare(right.label));
|
|
408
|
+
}
|
|
409
|
+
function piProviderLabel(source, id) {
|
|
410
|
+
for (const match of source.matchAll(/\bname:\s*"([^"]+)"/g)) {
|
|
411
|
+
if (!/api key$/i.test(match[1])) return match[1];
|
|
412
|
+
}
|
|
413
|
+
return id;
|
|
414
|
+
}
|
|
415
|
+
async function isDirectory(path) {
|
|
416
|
+
return stat(path).then((info) => info.isDirectory(), () => false);
|
|
417
|
+
}
|
|
418
|
+
async function piProvidersDirectory(harness) {
|
|
419
|
+
const binary = await resolveBinaryPath(harness.binary);
|
|
420
|
+
if (!binary) return void 0;
|
|
421
|
+
let directory = dirname(await realpath(binary).catch(() => binary));
|
|
422
|
+
for (let depth = 0; depth < 6; depth += 1) {
|
|
423
|
+
for (const candidate of [
|
|
424
|
+
join3(directory, "node_modules", "@earendil-works", "pi-ai", "dist", "providers"),
|
|
425
|
+
join3(directory, "..", "pi-ai", "dist", "providers")
|
|
426
|
+
]) {
|
|
427
|
+
if (await isDirectory(candidate)) return candidate;
|
|
428
|
+
}
|
|
429
|
+
directory = dirname(directory);
|
|
430
|
+
}
|
|
431
|
+
return void 0;
|
|
432
|
+
}
|
|
433
|
+
async function discoverPiProviders(harness) {
|
|
434
|
+
const directory = await piProvidersDirectory(harness);
|
|
435
|
+
if (!directory) return [];
|
|
436
|
+
const ids = (await readdir(directory)).filter((name) => name.endsWith(".models.js")).map((name) => name.slice(0, -".models.js".length));
|
|
437
|
+
return Promise.all(ids.map(async (id) => ({
|
|
438
|
+
id,
|
|
439
|
+
label: piProviderLabel(await readFile2(join3(directory, `${id}.js`), "utf8").catch(() => ""), id)
|
|
440
|
+
})));
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// src/harness/accounts/aider-discovery.ts
|
|
444
|
+
import { mkdtemp, readFile as readFile3, rm, stat as stat2 } from "node:fs/promises";
|
|
445
|
+
import { homedir as homedir2, tmpdir } from "node:os";
|
|
446
|
+
import { join as join4 } from "node:path";
|
|
447
|
+
var AIDER_PROVIDERS = [
|
|
448
|
+
{ env: "OPENROUTER_API_KEY", prefix: "openrouter/", label: "OpenRouter" },
|
|
449
|
+
{ env: "ANTHROPIC_API_KEY", prefix: "anthropic/", label: "Anthropic" },
|
|
450
|
+
{ env: "OPENAI_API_KEY", prefix: "openai/", label: "OpenAI" },
|
|
451
|
+
{ env: "DEEPSEEK_API_KEY", prefix: "deepseek/", label: "DeepSeek" },
|
|
452
|
+
{ env: "GEMINI_API_KEY", prefix: "gemini/", label: "Gemini" },
|
|
453
|
+
{ env: "VERTEXAI_PROJECT", prefix: "vertex_ai/", label: "Vertex AI" }
|
|
454
|
+
];
|
|
455
|
+
function parseEnvFile(text) {
|
|
456
|
+
const values = {};
|
|
457
|
+
for (const line of text.split(/\r?\n/)) {
|
|
458
|
+
const match = /^\s*(?:export\s+)?([A-Z0-9_]+)\s*=\s*"?([^"\n]*)"?\s*$/.exec(line);
|
|
459
|
+
if (match && match[2].trim()) values[match[1]] = match[2].trim();
|
|
460
|
+
}
|
|
461
|
+
return values;
|
|
462
|
+
}
|
|
463
|
+
function aiderListedModels(output, prefix) {
|
|
464
|
+
return output.split(/\r?\n/).map((line) => /^- (\S+)\s*$/.exec(line)?.[1]).filter((model) => Boolean(model?.startsWith(prefix)));
|
|
465
|
+
}
|
|
466
|
+
function openRouterModels(json) {
|
|
467
|
+
try {
|
|
468
|
+
const data = JSON.parse(json).data ?? [];
|
|
469
|
+
const models = [];
|
|
470
|
+
const labels = {};
|
|
471
|
+
for (const entry of data) {
|
|
472
|
+
if (typeof entry.id !== "string" || !entry.id) continue;
|
|
473
|
+
models.push(`openrouter/${entry.id}`);
|
|
474
|
+
if (typeof entry.name === "string" && entry.name) labels[`openrouter/${entry.id}`] = entry.name;
|
|
475
|
+
}
|
|
476
|
+
return { models, labels };
|
|
477
|
+
} catch {
|
|
478
|
+
return { models: [], labels: {} };
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
function openRouterCacheFile() {
|
|
482
|
+
return join4(stateDirectory(), "openrouter-models.json");
|
|
483
|
+
}
|
|
484
|
+
async function openRouterList() {
|
|
485
|
+
const file = openRouterCacheFile();
|
|
486
|
+
const kept = await stat2(file).catch(quiet("harness/accounts/aider-discovery"));
|
|
487
|
+
if (kept && Date.now() - kept.mtimeMs < 24 * 60 * 6e4) return readFile3(file, "utf8").catch(() => "");
|
|
488
|
+
try {
|
|
489
|
+
const response = await fetch("https://openrouter.ai/api/v1/models");
|
|
490
|
+
if (!response.ok) throw new Error(String(response.status));
|
|
491
|
+
const body = await response.text();
|
|
492
|
+
await atomicWriteFile(file, body).catch(quiet("harness/accounts/aider-discovery"));
|
|
493
|
+
return body;
|
|
494
|
+
} catch {
|
|
495
|
+
return kept ? readFile3(file, "utf8").catch(() => "") : "";
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
async function aiderKeyedProviders(environment) {
|
|
499
|
+
const home = environment.HOME || homedir2();
|
|
500
|
+
const keys = { ...parseEnvFile(await readFile3(join4(home, ".aider", "oauth-keys.env"), "utf8").catch(() => "")), ...environment };
|
|
501
|
+
return AIDER_PROVIDERS.filter((provider) => keys[provider.env]?.trim());
|
|
502
|
+
}
|
|
503
|
+
async function discoverAiderModels(harness, environment) {
|
|
504
|
+
const providers = await aiderKeyedProviders(environment);
|
|
505
|
+
const models = [];
|
|
506
|
+
let labels = {};
|
|
507
|
+
const scratch = await mkdtemp(join4(tmpdir(), "clikcode-aider-"));
|
|
508
|
+
try {
|
|
509
|
+
for (const provider of providers) {
|
|
510
|
+
if (provider.prefix === "openrouter/") {
|
|
511
|
+
const live = openRouterModels(await openRouterList());
|
|
512
|
+
if (live.models.length) {
|
|
513
|
+
models.push(...live.models);
|
|
514
|
+
labels = { ...labels, ...live.labels };
|
|
515
|
+
continue;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
const printed = await vendorCommandText({ gate: harness, argv: ["--no-git", "--list-models", provider.prefix], environment, deadlineMs: PROBE_DEADLINE_MS, cwd: scratch }).catch(() => "");
|
|
519
|
+
models.push(...aiderListedModels(printed, provider.prefix));
|
|
520
|
+
}
|
|
521
|
+
} finally {
|
|
522
|
+
await rm(scratch, { recursive: true, force: true }).catch(quiet("harness/accounts/aider-discovery"));
|
|
523
|
+
}
|
|
524
|
+
const connect = providers.length ? [] : [{
|
|
525
|
+
id: "openrouter",
|
|
526
|
+
label: "OpenRouter",
|
|
527
|
+
detail: "sign in with Aider",
|
|
528
|
+
argv: harness.loginArgv ?? []
|
|
529
|
+
}];
|
|
530
|
+
return { models: [...new Set(models)], labels, connect };
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// src/harness/accounts/model-catalog.ts
|
|
534
|
+
function nativeModelLabel(harnessCommand, model) {
|
|
535
|
+
if (!model) return void 0;
|
|
536
|
+
if (harnessCommand === "claude") return modelLabel(claudeModelLabel(model) ?? model, harnessCommand);
|
|
537
|
+
try {
|
|
538
|
+
const harness = harnessCommand ? localHarnessForCommand(harnessCommand) : void 0;
|
|
539
|
+
return harness ? harnessModelLabel(harness, model) : model;
|
|
540
|
+
} catch {
|
|
541
|
+
return model;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
var BRACKETED_MODEL = /^([^[\]]+)\[([^\]]*)\]$/;
|
|
545
|
+
var vendorModelNames = /* @__PURE__ */ new Map();
|
|
546
|
+
function rememberVendorModelNames(harness, catalog) {
|
|
547
|
+
for (const [model, name] of Object.entries(catalog?.labels ?? {})) {
|
|
548
|
+
if (BRACKETED_MODEL.test(model) && name) vendorModelNames.set(`${harness.command}\0${model}`, name);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
function modelSettingsDetail(model) {
|
|
552
|
+
const inner = BRACKETED_MODEL.exec(model)?.[2];
|
|
553
|
+
if (!inner) return void 0;
|
|
554
|
+
const parts = inner.split(",").flatMap((pair) => {
|
|
555
|
+
const [key, value] = pair.split("=").map((part) => part.trim());
|
|
556
|
+
if (!key || value === "false") return [];
|
|
557
|
+
if (value === void 0 || value === "true") return [key.replace(/_/g, " ")];
|
|
558
|
+
if (key === "context") return [`${value} context`];
|
|
559
|
+
return [`${key.replace(/_/g, " ")} ${value}`];
|
|
560
|
+
});
|
|
561
|
+
return parts.length ? parts.join(" \xB7 ") : void 0;
|
|
562
|
+
}
|
|
563
|
+
function harnessModelLabel(harness, model) {
|
|
564
|
+
const bracketed = BRACKETED_MODEL.exec(model);
|
|
565
|
+
if (bracketed) return vendorModelNames.get(`${harness.command}\0${model}`) ?? bracketed[1].trim();
|
|
566
|
+
return modelLabel(modelDisplayId(harness, model), harness.command, harness.provider);
|
|
567
|
+
}
|
|
568
|
+
function modelIdFromLabel(harness, models, typed) {
|
|
569
|
+
if (models.includes(typed)) return typed;
|
|
570
|
+
const spelled = modelIdFromDisplay(harness, typed);
|
|
571
|
+
if (models.includes(spelled)) return spelled;
|
|
572
|
+
const matches = models.filter((model) => harnessModelLabel(harness, model) === typed || modelDisplayId(harness, model) === typed);
|
|
573
|
+
return matches.length === 1 ? matches[0] : spelled;
|
|
574
|
+
}
|
|
575
|
+
var memo2 = jsonMemo("model-catalog.json", () => ({ v: 1, entries: {} }), (parsed) => {
|
|
576
|
+
const file = parsed;
|
|
577
|
+
return file.v === 1 && file.entries && typeof file.entries === "object" ? file : void 0;
|
|
578
|
+
});
|
|
579
|
+
var discoveries = /* @__PURE__ */ new Map();
|
|
580
|
+
function resetModelCatalogMemo() {
|
|
581
|
+
memo2.reset();
|
|
582
|
+
discoveries.clear();
|
|
583
|
+
}
|
|
584
|
+
var SERVER_LIST_TTL_MS = 3e5;
|
|
585
|
+
function serverModelList(harness) {
|
|
586
|
+
return Boolean(harness.modelsDevCatalog) || !listsModelsLive(harness) && !harness.acp?.liveModelList && Boolean(harness.modelDiscoveryArgv || harness.acp && harness.acp.listsModels !== false);
|
|
587
|
+
}
|
|
588
|
+
function listsModelsLive(harness) {
|
|
589
|
+
if (harness.nativeOperations?.includes("model-list")) return true;
|
|
590
|
+
if (harness.acp?.liveModelList) return true;
|
|
591
|
+
return Boolean(harness.acp && harness.acp.listsModels !== false && !harness.acp.providerConfigId && !harness.modelDiscoveryArgv);
|
|
592
|
+
}
|
|
593
|
+
async function fileIdentity(path) {
|
|
594
|
+
if (!path) return "-";
|
|
595
|
+
try {
|
|
596
|
+
const info = await stat3(path);
|
|
597
|
+
return `${path}:${info.mtimeMs}:${info.size}`;
|
|
598
|
+
} catch {
|
|
599
|
+
return `${path}:absent`;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
function catalogProfileRoot(harness, account) {
|
|
603
|
+
return account?.nativeProfile?.path ?? (harness.profileEnv ? process.env[harness.profileEnv]?.trim() : void 0) ?? (harness.nativeStateDir ? join5(homedir3(), harness.nativeStateDir) : void 0);
|
|
604
|
+
}
|
|
605
|
+
async function catalogFingerprint(harness, account) {
|
|
606
|
+
const root = catalogProfileRoot(harness, account);
|
|
607
|
+
const files = [
|
|
608
|
+
// The binary: an update changes what `models` prints and, for Claude
|
|
609
|
+
// Code, the alias table read out of the bundle itself.
|
|
610
|
+
await resolveBinaryPath(harness.binary),
|
|
611
|
+
...harness.acp?.binary ? [await resolveBinaryPath(harness.acp.binary)] : [],
|
|
612
|
+
...root ? (harness.modelCatalogFiles ?? []).map((file) => join5(root, ...file.split("/"))) : [],
|
|
613
|
+
...(harness.modelCatalogHomeFiles ?? []).map((file) => join5(homedir3(), ...file.split("/"))),
|
|
614
|
+
// OpenClaw's sign-ins live in the agent's SQLite auth store.
|
|
615
|
+
// The models.dev catalog a list was read from: a newer copy is a new list.
|
|
616
|
+
...harness.modelsDevCatalog ? modelsDevFiles() : [],
|
|
617
|
+
...harness.modelStrategy === "aider-providers" ? [openRouterCacheFile()] : [],
|
|
618
|
+
// A sign-in changes which models a vendor lists (Pi, Qwen, Cline): its
|
|
619
|
+
// credential files are part of what the list was read from.
|
|
620
|
+
...(await Promise.all((harness.authFiles ?? []).map((entry) => expandAuthPaths(entry.path.replace(/\/$/, ""), {
|
|
621
|
+
...process.env,
|
|
622
|
+
...account?.nativeProfile ? { [account.nativeProfile.env]: account.nativeProfile.path } : {}
|
|
623
|
+
})))).flat()
|
|
624
|
+
];
|
|
625
|
+
const identities = await Promise.all(files.map(fileIdentity));
|
|
626
|
+
const driven = harness.modelStrategy === "goose-providers" ? await Promise.all([...new Set(Object.values(GOOSE_DRIVEN_HARNESSES))].map(async (command) => {
|
|
627
|
+
const drivenHarness = localHarnessForCommand(command);
|
|
628
|
+
return drivenHarness ? catalogFingerprint(drivenHarness) : "";
|
|
629
|
+
})) : [];
|
|
630
|
+
const discoveryContract = JSON.stringify({
|
|
631
|
+
transport: harness.transport,
|
|
632
|
+
acp: harness.acp && { binary: harness.acp.binary, argv: harness.acp.argv, listsModels: harness.acp.listsModels },
|
|
633
|
+
modelDiscoveryArgv: harness.modelDiscoveryArgv,
|
|
634
|
+
liveModelList: listsModelsLive(harness)
|
|
635
|
+
});
|
|
636
|
+
const keys = harness.modelStrategy === "goose-providers" ? [`keys:${providerKeyNames().join(",")}`] : [];
|
|
637
|
+
return [discoveryContract, ...identities, ...driven, ...keys].join("|");
|
|
638
|
+
}
|
|
639
|
+
function cacheKey(harness, account) {
|
|
640
|
+
return `${harness.command}:${account?.nativeProfile?.path ?? account?.id ?? "default"}`;
|
|
641
|
+
}
|
|
642
|
+
async function cachedCatalog(harness, account, options) {
|
|
643
|
+
const cached = (await memo2.load()).entries[cacheKey(harness, account)];
|
|
644
|
+
if (!cached) return void 0;
|
|
645
|
+
if (cached.fingerprint !== (options?.fingerprint ?? await catalogFingerprint(harness, account))) return void 0;
|
|
646
|
+
if (account?.models?.some((model) => !cached.result.models.includes(model))) return void 0;
|
|
647
|
+
if (harness.acp && cached.result.models.length === 0) return void 0;
|
|
648
|
+
const isExpired = serverModelList(harness) && Date.now() - cached.at >= SERVER_LIST_TTL_MS;
|
|
649
|
+
if (isExpired && !options?.allowStale) return void 0;
|
|
650
|
+
rememberVendorModelNames(harness, cached.result);
|
|
651
|
+
return cached.result;
|
|
652
|
+
}
|
|
653
|
+
var MODEL_CATALOG_PICKER_WAIT_MS = 3e3;
|
|
654
|
+
var CLAUDE_FALLBACK_ALIASES = ["fable", "opus", "sonnet", "haiku"];
|
|
655
|
+
function defaultModelCatalogFallback(harness, account) {
|
|
656
|
+
const models = new Set(account?.models ?? []);
|
|
657
|
+
if (harness.modelStrategy === "claude-table") CLAUDE_FALLBACK_ALIASES.forEach((model) => models.add(model));
|
|
658
|
+
return { models: [...models] };
|
|
659
|
+
}
|
|
660
|
+
function warmNativeModelCatalog(harness, account) {
|
|
661
|
+
if (!harness) return;
|
|
662
|
+
void nativeModelCatalog(harness, account).catch(quiet("harness/accounts/model-catalog"));
|
|
663
|
+
}
|
|
664
|
+
async function nativeModelCatalogForPicker(harness, account, waitMs = harness.acp?.listsModels ? 1e4 : MODEL_CATALOG_PICKER_WAIT_MS) {
|
|
665
|
+
const cached = await cachedCatalog(harness, account, { allowStale: true });
|
|
666
|
+
if (cached) {
|
|
667
|
+
if (serverModelList(harness) && !await cachedCatalog(harness, account)) {
|
|
668
|
+
nativeModelCatalog(harness, account).catch(quiet("harness/accounts/model-catalog"));
|
|
669
|
+
}
|
|
670
|
+
return cached;
|
|
671
|
+
}
|
|
672
|
+
const fallback = defaultModelCatalogFallback(harness, account);
|
|
673
|
+
const discovery = nativeModelCatalog(harness, account).catch(quiet("harness/accounts/model-catalog"));
|
|
674
|
+
let timer;
|
|
675
|
+
const deadline = new Promise((resolve) => {
|
|
676
|
+
timer = setTimeout(() => resolve(void 0), waitMs);
|
|
677
|
+
timer.unref?.();
|
|
678
|
+
});
|
|
679
|
+
try {
|
|
680
|
+
return await Promise.race([discovery, deadline]) ?? fallback;
|
|
681
|
+
} finally {
|
|
682
|
+
if (timer) clearTimeout(timer);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
async function resolveNativeModel(harness, account) {
|
|
686
|
+
const catalog = await nativeModelCatalog(harness, account);
|
|
687
|
+
const free = freePlanModels(harness, account, catalog);
|
|
688
|
+
const chosen = catalog.configured?.trim() || (harness.defaultModel && catalog.models.includes(harness.defaultModel) ? harness.defaultModel : void 0);
|
|
689
|
+
if (planIsFree(account?.plan) && free.size && !(chosen && free.has(chosen))) return preferredFreeModel(free);
|
|
690
|
+
return chosen ?? catalog.models.find((model) => model.trim().length > 0);
|
|
691
|
+
}
|
|
692
|
+
async function syncAccountModels(accountId, models) {
|
|
693
|
+
try {
|
|
694
|
+
const { readState } = await import("./chunk-5NQ5FFMX.js");
|
|
695
|
+
const { writeState } = await import("./chunk-U4DKAD6S.js");
|
|
696
|
+
const state = await readState({ transcripts: [] });
|
|
697
|
+
const account = state.accounts.find((item) => item.id === accountId);
|
|
698
|
+
if (!account || models.length === 0) return;
|
|
699
|
+
const next = [...new Set(models)];
|
|
700
|
+
if (next.length === account.models.length && next.every((model, index) => model === account.models[index])) return;
|
|
701
|
+
account.models = next;
|
|
702
|
+
await writeState(state);
|
|
703
|
+
} catch (error) {
|
|
704
|
+
swallowed("harness/accounts/model-catalog", error);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
async function nativeModelCatalog(harness, account) {
|
|
708
|
+
const fingerprint = await catalogFingerprint(harness, account);
|
|
709
|
+
const cached = await cachedCatalog(harness, account, { fingerprint });
|
|
710
|
+
if (cached) return cached;
|
|
711
|
+
const key = [cacheKey(harness, account), fingerprint, ...account?.models ?? []].join("\n");
|
|
712
|
+
const running = discoveries.get(key);
|
|
713
|
+
if (running) return running;
|
|
714
|
+
const discovery = discoverModelCatalog(harness, account, fingerprint, key).finally(() => {
|
|
715
|
+
if (discoveries.get(key) === discovery) discoveries.delete(key);
|
|
716
|
+
});
|
|
717
|
+
discoveries.set(key, discovery);
|
|
718
|
+
return discovery;
|
|
719
|
+
}
|
|
720
|
+
async function discoverModelCatalog(harness, account, fingerprint, key) {
|
|
721
|
+
const held = `catalog:${createHash("sha256").update(key).digest("hex").slice(0, 32)}`;
|
|
722
|
+
const offline = await heldOff(held);
|
|
723
|
+
const outcome = { signedOut: false };
|
|
724
|
+
const result = await nativeModelCatalogUncached(harness, account, void 0, { offline, outcome });
|
|
725
|
+
rememberVendorModelNames(harness, result);
|
|
726
|
+
if (outcome.signedOut) await markAccountNeedsSignIn(account);
|
|
727
|
+
if (!result.models.length && (harness.modelsDevCatalog || harness.modelStrategy === "aider-providers" || harness.acp || harness.modelDiscoveryArgv)) {
|
|
728
|
+
if (!offline && !outcome.signedOut) await recordBackgroundOutcome(held, "failed");
|
|
729
|
+
return result;
|
|
730
|
+
}
|
|
731
|
+
if (offline) return result;
|
|
732
|
+
await recordBackgroundOutcome(held, "ok");
|
|
733
|
+
await rememberCatalog(harness, account, fingerprint, result);
|
|
734
|
+
return result;
|
|
735
|
+
}
|
|
736
|
+
var SPAWNING_STRATEGIES = /* @__PURE__ */ new Set([
|
|
737
|
+
"hermes-inventory",
|
|
738
|
+
"openclaw-inventory",
|
|
739
|
+
"aider-providers",
|
|
740
|
+
"copilot-server",
|
|
741
|
+
"goose-providers"
|
|
742
|
+
]);
|
|
743
|
+
async function rememberCatalog(harness, account, fingerprint, result) {
|
|
744
|
+
(await memo2.load()).entries[cacheKey(harness, account)] = { at: Date.now(), fingerprint, result };
|
|
745
|
+
memo2.changed();
|
|
746
|
+
await memo2.save();
|
|
747
|
+
if (account?.id && result.models.length) {
|
|
748
|
+
syncAccountModels(account.id, result.models).catch(quiet("harness/accounts/model-catalog"));
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
async function recordLiveModelCatalog(harness, account, answer, fresh) {
|
|
752
|
+
if (!listsModelsLive(harness)) return;
|
|
753
|
+
const listed = acpSessionModels(answer);
|
|
754
|
+
if (!listed.models.length) return;
|
|
755
|
+
const fingerprint = await catalogFingerprint(harness, account);
|
|
756
|
+
const previous = (await memo2.load()).entries[cacheKey(harness, account)];
|
|
757
|
+
const configured = fresh ? listed.current : previous?.fingerprint === fingerprint ? previous.result.configured : void 0;
|
|
758
|
+
const result = await nativeModelCatalogUncached(harness, account, { ...listed, current: configured });
|
|
759
|
+
rememberVendorModelNames(harness, result);
|
|
760
|
+
if (previous?.fingerprint === fingerprint && JSON.stringify(previous.result) === JSON.stringify(result)) return;
|
|
761
|
+
await rememberCatalog(harness, account, fingerprint, result);
|
|
762
|
+
}
|
|
763
|
+
function discoveredModelsFrom(raw) {
|
|
764
|
+
const models = /* @__PURE__ */ new Set();
|
|
765
|
+
const add = (value) => {
|
|
766
|
+
if (typeof value !== "string") return;
|
|
767
|
+
const model = value.trim();
|
|
768
|
+
if (/^[a-z0-9][a-z0-9._:/-]{1,127}$/i.test(model)) models.add(model);
|
|
769
|
+
};
|
|
770
|
+
try {
|
|
771
|
+
const visit = (value) => {
|
|
772
|
+
if (Array.isArray(value)) return value.forEach(visit);
|
|
773
|
+
if (!value || typeof value !== "object") return;
|
|
774
|
+
for (const [key, child] of Object.entries(value)) {
|
|
775
|
+
if (/^(?:id|model|modelId|slug)$/i.test(key)) add(child);
|
|
776
|
+
else visit(child);
|
|
777
|
+
}
|
|
778
|
+
};
|
|
779
|
+
visit(JSON.parse(raw));
|
|
780
|
+
} catch {
|
|
781
|
+
for (const line of stripAnsi(raw).split(/\r?\n/)) {
|
|
782
|
+
const clean = line.trim().replace(/^[•*✓✔❯>\-]+\s*/, "");
|
|
783
|
+
if (!clean) continue;
|
|
784
|
+
const bracketed = /\[([a-z0-9][a-z0-9._:/-]*)\]\s*$/i.exec(clean)?.[1];
|
|
785
|
+
if (bracketed && !/^(?:default|current|active|selected|recommended|beta|new|free)$/i.test(bracketed)) {
|
|
786
|
+
add(bracketed);
|
|
787
|
+
continue;
|
|
788
|
+
}
|
|
789
|
+
const token = clean.split(/\s+/, 1)[0]?.replace(/^['"`]|['"`,:]$/g, "");
|
|
790
|
+
if (token && (clean === token || /[\/.\d:_-]/.test(token))) add(token);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
return [...models];
|
|
794
|
+
}
|
|
795
|
+
function adoptInventory(d, inventory) {
|
|
796
|
+
d.models.clear();
|
|
797
|
+
inventory.models.forEach((model) => d.models.add(model));
|
|
798
|
+
d.labels = { ...d.labels, ...inventory.labels };
|
|
799
|
+
if (inventory.configured) d.configured = inventory.configured;
|
|
800
|
+
d.connect = inventory.connect;
|
|
801
|
+
}
|
|
802
|
+
var VENDOR_MODEL_DISCOVERY = {
|
|
803
|
+
"codex-cache": async ({ profileRoot, liveListed, state: d }) => {
|
|
804
|
+
if (!profileRoot) return;
|
|
805
|
+
try {
|
|
806
|
+
const config = await readFile4(join5(profileRoot, "config.toml"), "utf8");
|
|
807
|
+
d.configured = /^\s*model\s*=\s*["']([^"']+)["']/m.exec(config)?.[1]?.trim();
|
|
808
|
+
} catch (error) {
|
|
809
|
+
swallowed("harness/accounts/model-catalog", error);
|
|
810
|
+
}
|
|
811
|
+
if (liveListed?.models.length) {
|
|
812
|
+
liveListed.models.forEach((model) => d.models.add(model));
|
|
813
|
+
d.labels = { ...d.labels, ...liveListed.labels };
|
|
814
|
+
} else {
|
|
815
|
+
try {
|
|
816
|
+
const cache = JSON.parse(await readFile4(join5(profileRoot, "models_cache.json"), "utf8"));
|
|
817
|
+
for (const model of cache.models ?? []) {
|
|
818
|
+
if (typeof model.slug === "string" && model.slug.trim() && model.visibility !== "hide") d.models.add(model.slug.trim());
|
|
819
|
+
}
|
|
820
|
+
} catch (error) {
|
|
821
|
+
swallowed("harness/accounts/model-catalog", error);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
},
|
|
825
|
+
"claude-table": async ({ harness, profileRoot, state: d }) => {
|
|
826
|
+
if (!profileRoot) return;
|
|
827
|
+
try {
|
|
828
|
+
const settings = JSON.parse(await readFile4(join5(profileRoot, "settings.json"), "utf8"));
|
|
829
|
+
if (typeof settings.model === "string" && settings.model.trim()) d.configured = settings.model.trim();
|
|
830
|
+
} catch (error) {
|
|
831
|
+
swallowed("harness/accounts/model-catalog", error);
|
|
832
|
+
}
|
|
833
|
+
const table = await claudeModelTable(harness.binary);
|
|
834
|
+
const aliases = claudeModelAliases(table);
|
|
835
|
+
(aliases.length ? aliases : CLAUDE_FALLBACK_ALIASES).forEach((model) => d.models.add(model));
|
|
836
|
+
if (table) {
|
|
837
|
+
d.labels = {};
|
|
838
|
+
for (const alias of aliases) {
|
|
839
|
+
const name = table.displayNames[table.aliases[alias]];
|
|
840
|
+
if (name) d.labels[alias] = name;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
},
|
|
844
|
+
// Hermes has no `models` command. `hermes model` is an interactive picker;
|
|
845
|
+
// its list (signed-in providers only) is read from the install's inventory,
|
|
846
|
+
// with the provider cache as the fallback. Every id is `provider:model`, so
|
|
847
|
+
// the choice keeps its provider. The configured model is `config get model
|
|
848
|
+
// --json`'s `default` plus `provider` (`{"default":"gpt-6-astra","provider":"openai-codex",...}`).
|
|
849
|
+
"hermes-inventory": async ({ harness, account, profileRoot, state: d }) => {
|
|
850
|
+
const environment = nativeProfileEnvironment(account?.nativeProfile);
|
|
851
|
+
const inventory = await discoverHermesModels(harness, account).catch(quiet("harness/accounts/model-catalog"));
|
|
852
|
+
if (inventory) {
|
|
853
|
+
adoptInventory(d, inventory);
|
|
854
|
+
} else if (profileRoot) {
|
|
855
|
+
try {
|
|
856
|
+
for (const model of hermesCachedModels(await readFile4(join5(profileRoot, "provider_models_cache.json"), "utf8"))) d.models.add(model);
|
|
857
|
+
} catch (error) {
|
|
858
|
+
swallowed("harness/accounts/model-catalog", error);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
try {
|
|
862
|
+
if (!d.configured) {
|
|
863
|
+
const parsed = JSON.parse(await vendorCommandText({ gate: harness, argv: ["config", "get", "model", "--json"], environment, deadlineMs: PROBE_DEADLINE_MS }));
|
|
864
|
+
const model = typeof parsed.default === "string" ? parsed.default.trim() : "";
|
|
865
|
+
const provider = typeof parsed.provider === "string" ? parsed.provider.trim() : "";
|
|
866
|
+
if (model) d.configured = provider ? `${provider}:${model}` : model;
|
|
867
|
+
}
|
|
868
|
+
} catch (error) {
|
|
869
|
+
swallowed("harness/accounts/model-catalog", error);
|
|
870
|
+
}
|
|
871
|
+
},
|
|
872
|
+
"openclaw-inventory": async ({ harness, account, state: d }) => {
|
|
873
|
+
const inventory = await discoverOpenClawModels(harness, account).catch(quiet("harness/accounts/model-catalog"));
|
|
874
|
+
if (inventory) adoptInventory(d, inventory);
|
|
875
|
+
},
|
|
876
|
+
// Aider: the models of each provider it has a key for (aider-discovery.ts).
|
|
877
|
+
"aider-providers": async ({ harness, account, state: d }) => {
|
|
878
|
+
const found = await discoverAiderModels(harness, nativeAccountEnvironment(harness, account)).catch(quiet("harness/accounts/model-catalog"));
|
|
879
|
+
if (!found) return;
|
|
880
|
+
found.models.forEach((model) => d.models.add(model));
|
|
881
|
+
d.labels = { ...d.labels, ...found.labels };
|
|
882
|
+
if (found.connect.length) d.connect = found.connect;
|
|
883
|
+
},
|
|
884
|
+
// Copilot: the models its own server offers this account (`models.list`
|
|
885
|
+
// on `copilot --headless`, which only its own sign-in may ask). The public
|
|
886
|
+
// models.dev catalog, what Copilot offers anyone, only when that fails. It
|
|
887
|
+
// has no `copilot models` command (github/copilot-cli#700, #1356, #236), so
|
|
888
|
+
// no hardcoded list stands in for them.
|
|
889
|
+
"copilot-server": async ({ account, state: d }) => {
|
|
890
|
+
const own = await copilotAccountModels(nativeProfileEnvironment(account?.nativeProfile)).catch(quiet("harness/accounts/model-catalog"));
|
|
891
|
+
const listed = own ?? modelsDevProvider(await modelsDevCache(), "github-copilot");
|
|
892
|
+
if (own) d.models.clear();
|
|
893
|
+
listed.models.forEach((model) => d.models.add(model));
|
|
894
|
+
d.labels = { ...d.labels, ...listed.labels };
|
|
895
|
+
},
|
|
896
|
+
// Goose: its configured providers' models, and the rest to set up. A
|
|
897
|
+
// provider that is another agent CLI (claude-code) lists that harness's own
|
|
898
|
+
// models, so its sign-in carries over with nothing more to do.
|
|
899
|
+
"goose-providers": async ({ harness, account, state: d }) => {
|
|
900
|
+
const providers = await discoverGooseProviders(harness, nativeProfileEnvironment(account?.nativeProfile)).catch(quiet("harness/accounts/model-catalog"));
|
|
901
|
+
if (!providers) return;
|
|
902
|
+
d.models.clear();
|
|
903
|
+
const modelsDev = await modelsDevCache();
|
|
904
|
+
const labels = { ...d.labels };
|
|
905
|
+
for (const provider of providers.filter((item) => item.configured)) {
|
|
906
|
+
const drivenCommand = GOOSE_DRIVEN_HARNESSES[provider.id];
|
|
907
|
+
const drivenHarness = drivenCommand ? localHarnessForCommand(drivenCommand) : void 0;
|
|
908
|
+
if (drivenHarness) {
|
|
909
|
+
const driven = await nativeModelCatalog(drivenHarness).catch(quiet("harness/accounts/model-catalog"));
|
|
910
|
+
for (const model of driven?.models ?? []) {
|
|
911
|
+
d.models.add(`${provider.id}/${model}`);
|
|
912
|
+
const name = driven?.labels?.[model];
|
|
913
|
+
if (name) labels[`${provider.id}/${model}`] = name;
|
|
914
|
+
}
|
|
915
|
+
} else {
|
|
916
|
+
gooseModelsDevModels(modelsDev, provider.id).forEach((model) => d.models.add(model));
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
d.labels = labels;
|
|
920
|
+
d.connect = gooseConnect(providers);
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
var PRINTED_MODEL_LIST = {
|
|
924
|
+
// OpenCode and Kilo print only connected providers' models, each with its
|
|
925
|
+
// price and (Kilo) whether it is free; the rest of what they know is
|
|
926
|
+
// offered as a sign-in.
|
|
927
|
+
"opencode-verbose": async ({ harness, profileRoot, state: d }, printed) => {
|
|
928
|
+
const verbose = opencodeVerboseModels(printed);
|
|
929
|
+
verbose.models.forEach((model) => d.models.add(model));
|
|
930
|
+
d.free = verbose.free;
|
|
931
|
+
if (profileRoot) {
|
|
932
|
+
const raw = await readFile4(join5(profileRoot, ".config", harness.command, `${harness.command}.json`), "utf8").catch(quiet("harness/accounts/model-catalog"));
|
|
933
|
+
let set;
|
|
934
|
+
try {
|
|
935
|
+
set = raw ? JSON.parse(raw).model : void 0;
|
|
936
|
+
} catch {
|
|
937
|
+
set = void 0;
|
|
938
|
+
}
|
|
939
|
+
if (typeof set === "string" && verbose.models.includes(set)) d.configured ??= set;
|
|
940
|
+
}
|
|
941
|
+
d.connect = await discoverOpencodeConnect(harness, verbose.models);
|
|
942
|
+
},
|
|
943
|
+
// Pi prints a provider/model table; the generic reader cannot see a model
|
|
944
|
+
// in it. Its other providers are signed in to inside Pi.
|
|
945
|
+
"pi-table": async ({ harness, profileRoot, state: d }, printed) => {
|
|
946
|
+
for (const misread of discoveredModelsFrom(printed)) d.models.delete(misread);
|
|
947
|
+
for (const model of [...d.models]) if (model.startsWith("/")) d.models.delete(model);
|
|
948
|
+
const piListed = piModels(printed);
|
|
949
|
+
piListed.forEach((model) => d.models.add(model));
|
|
950
|
+
const settings = profileRoot ? await readFile4(join5(profileRoot, "settings.json"), "utf8").catch(quiet("harness/accounts/model-catalog")) : void 0;
|
|
951
|
+
d.configured ??= piConfiguredModel(settings, piListed);
|
|
952
|
+
d.connect = piConnect(await discoverPiProviders(harness), piListed);
|
|
953
|
+
}
|
|
954
|
+
};
|
|
955
|
+
async function nativeModelCatalogUncached(harness, account, liveListed, run = {}) {
|
|
956
|
+
const d = { models: new Set(account?.models ?? []) };
|
|
957
|
+
const { models } = d;
|
|
958
|
+
const addDiscoveredModels = (raw) => {
|
|
959
|
+
for (const model of discoveredModelsFrom(raw)) models.add(model);
|
|
960
|
+
};
|
|
961
|
+
const profileRoot = catalogProfileRoot(harness, account);
|
|
962
|
+
const context = { harness, account, profileRoot, liveListed, state: d };
|
|
963
|
+
const mayRun = !run.offline && await mayRunInBackground(harness, nativeAccountEnvironment(harness, account));
|
|
964
|
+
if (!run.offline && !mayRun && run.outcome) run.outcome.signedOut = true;
|
|
965
|
+
if (harness.modelStrategy && (mayRun || !SPAWNING_STRATEGIES.has(harness.modelStrategy))) await VENDOR_MODEL_DISCOVERY[harness.modelStrategy](context);
|
|
966
|
+
const liveOnly = Boolean(liveListed && harness.acp?.liveModelList);
|
|
967
|
+
if (harness.acp && harness.acp.listsModels !== false && (!harness.modelDiscoveryArgv || liveOnly) && (liveListed || mayRun)) {
|
|
968
|
+
const listed = liveListed ?? await queryAcp(
|
|
969
|
+
harness.acp.binary ?? harness.binary,
|
|
970
|
+
[...harness.acp.argv, ...await acpProbeArgv(harness, account)],
|
|
971
|
+
nativeProfileEnvironment(account?.nativeProfile),
|
|
972
|
+
async (request) => {
|
|
973
|
+
const session = await acpDiscoverySession(request);
|
|
974
|
+
const efforts = harness.acp?.effortConfigId ? acpConfigOptionValues(session, harness.acp.effortConfigId) : [];
|
|
975
|
+
return { ...acpSessionModels(session), ...efforts.length ? { efforts } : {} };
|
|
976
|
+
},
|
|
977
|
+
void 0,
|
|
978
|
+
{ gate: harness, discovery: harness }
|
|
979
|
+
).catch(quiet("harness/accounts/model-catalog"));
|
|
980
|
+
if (listed?.models.length) {
|
|
981
|
+
if (harness.acp.listsModels === true) models.clear();
|
|
982
|
+
listed.models.forEach((model) => models.add(model));
|
|
983
|
+
d.labels = { ...d.labels, ...listed.labels };
|
|
984
|
+
if (listed.current && listed.models.includes(listed.current)) d.configured ??= listed.current;
|
|
985
|
+
}
|
|
986
|
+
if (listed?.efforts?.length) d.effortValues = listed.efforts;
|
|
987
|
+
}
|
|
988
|
+
if (harness.modelDiscoveryArgv && !liveOnly && mayRun) {
|
|
989
|
+
const environment = nativeProfileEnvironment(account?.nativeProfile);
|
|
990
|
+
try {
|
|
991
|
+
const printed = await vendorCommandText({ gate: harness, argv: harness.modelDiscoveryArgv, environment, deadlineMs: PROBE_DEADLINE_MS });
|
|
992
|
+
if (harness.modelListFormat) await PRINTED_MODEL_LIST[harness.modelListFormat](context, printed);
|
|
993
|
+
else addDiscoveredModels(printed);
|
|
994
|
+
} catch (error) {
|
|
995
|
+
swallowed("harness/accounts/model-catalog", error);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
if (d.configured) models.add(d.configured);
|
|
999
|
+
return {
|
|
1000
|
+
...d.configured ? { configured: d.configured } : {},
|
|
1001
|
+
models: [...models],
|
|
1002
|
+
...d.labels ? { labels: d.labels } : {},
|
|
1003
|
+
...d.free?.length ? { free: d.free } : {},
|
|
1004
|
+
...d.connect?.length ? { connect: d.connect } : {},
|
|
1005
|
+
...d.effortValues?.length ? { effortValues: d.effortValues } : {}
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
function acpEffortPerModel(harness) {
|
|
1009
|
+
return Boolean(harness.acp?.effortConfigId && harness.acp.inheritCliOptions === false && harness.acp.listsModels !== false);
|
|
1010
|
+
}
|
|
1011
|
+
async function acpModelEffortChoices(harness, account, model) {
|
|
1012
|
+
const effortConfigId = harness.acp?.effortConfigId;
|
|
1013
|
+
if (!harness.acp || !effortConfigId) return void 0;
|
|
1014
|
+
return queryAcp(
|
|
1015
|
+
harness.acp.binary ?? harness.binary,
|
|
1016
|
+
[...harness.acp.argv, ...await acpProbeArgv(harness, account)],
|
|
1017
|
+
nativeProfileEnvironment(account?.nativeProfile),
|
|
1018
|
+
async (request) => {
|
|
1019
|
+
const session = await acpDiscoverySession(request);
|
|
1020
|
+
let answer = session;
|
|
1021
|
+
const modelOption = Array.isArray(session.configOptions) ? session.configOptions.find((option2) => (option2?.id ?? option2?.configId) === "model") : void 0;
|
|
1022
|
+
const current2 = session.models?.currentModelId ?? modelOption?.currentValue;
|
|
1023
|
+
if (model && model !== current2 && typeof session.sessionId === "string") {
|
|
1024
|
+
const updated = modelOption ? await request("session/set_config_option", { sessionId: session.sessionId, configId: "model", value: model }) : await request("session/set_model", { sessionId: session.sessionId, modelId: model });
|
|
1025
|
+
if (Array.isArray(updated?.configOptions)) answer = updated;
|
|
1026
|
+
}
|
|
1027
|
+
const values = acpConfigOptionValues(answer, effortConfigId);
|
|
1028
|
+
if (!values.length) return void 0;
|
|
1029
|
+
const option = answer.configOptions?.find((entry) => (entry?.id ?? entry?.configId) === effortConfigId);
|
|
1030
|
+
const fallback = typeof option?.currentValue === "string" && values.includes(option.currentValue) ? option.currentValue : void 0;
|
|
1031
|
+
return { values, ...fallback ? { default: fallback } : {} };
|
|
1032
|
+
},
|
|
1033
|
+
void 0,
|
|
1034
|
+
{ gate: harness, discovery: harness }
|
|
1035
|
+
);
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
export {
|
|
1039
|
+
discoverHermesChoices,
|
|
1040
|
+
nativeModelLabel,
|
|
1041
|
+
rememberVendorModelNames,
|
|
1042
|
+
modelSettingsDetail,
|
|
1043
|
+
harnessModelLabel,
|
|
1044
|
+
modelIdFromLabel,
|
|
1045
|
+
resetModelCatalogMemo,
|
|
1046
|
+
warmNativeModelCatalog,
|
|
1047
|
+
nativeModelCatalogForPicker,
|
|
1048
|
+
resolveNativeModel,
|
|
1049
|
+
nativeModelCatalog,
|
|
1050
|
+
recordLiveModelCatalog,
|
|
1051
|
+
acpEffortPerModel,
|
|
1052
|
+
acpModelEffortChoices
|
|
1053
|
+
};
|