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,176 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
visibleSlice
|
|
5
|
+
} from "./chunk-G3QP67Z7.js";
|
|
6
|
+
|
|
7
|
+
// src/harness/protocol/tools.ts
|
|
8
|
+
function formatToolRow(name, detail, category) {
|
|
9
|
+
const lines = detail?.trim().split(/\r?\n/) ?? [];
|
|
10
|
+
const firstLine = lines[0]?.trim();
|
|
11
|
+
const shown = firstLine ? visibleSlice(lines.length > 1 ? `${firstLine} \u2026` : firstLine, 72) : "";
|
|
12
|
+
const verb = toolVerb(name, category ?? toolCategory(name));
|
|
13
|
+
if (verb === "$") return shown ? `$ ${shown}` : name;
|
|
14
|
+
return shown ? `${verb} ${shown}` : verb;
|
|
15
|
+
}
|
|
16
|
+
var CONVERSATION_ROWS = {
|
|
17
|
+
search_conversations: "Search conversation",
|
|
18
|
+
read_conversation: "Read conversation",
|
|
19
|
+
active_conversations: "Active conversations",
|
|
20
|
+
hindsight: "Hindsight"
|
|
21
|
+
};
|
|
22
|
+
function conversationRow(name) {
|
|
23
|
+
const mcp = /^mcp__(.+?)__(.+)$/.exec(name);
|
|
24
|
+
if (mcp && mcp[1].replace(/-/g, "") !== "clikcodeconversations") return void 0;
|
|
25
|
+
return CONVERSATION_ROWS[mcp ? mcp[2] : name];
|
|
26
|
+
}
|
|
27
|
+
function toolVerb(name, category) {
|
|
28
|
+
const conversation = conversationRow(name);
|
|
29
|
+
if (conversation) return conversation;
|
|
30
|
+
const mcp = /^mcp__(.+?)__(.+)$/.exec(name);
|
|
31
|
+
if (mcp) return `${mcp[1]} \u203A ${mcp[2]}`;
|
|
32
|
+
if (isAgentToolName(name)) return "Agent";
|
|
33
|
+
const normalized = name.toLowerCase().replace(/[^a-z]/g, "");
|
|
34
|
+
switch (category) {
|
|
35
|
+
case "run":
|
|
36
|
+
return "$";
|
|
37
|
+
case "read":
|
|
38
|
+
return "Read";
|
|
39
|
+
case "edit":
|
|
40
|
+
return /write|create/.test(normalized) ? "Write" : "Edit";
|
|
41
|
+
case "search":
|
|
42
|
+
if (/glob|findfiles/.test(normalized)) return "Glob";
|
|
43
|
+
if (/^(grep|rg|ripgrep)$/.test(normalized)) return "Grep";
|
|
44
|
+
if (/^(ls|list|listdir|listfiles|listdirectory)$/.test(normalized)) return "List";
|
|
45
|
+
return "Search";
|
|
46
|
+
case "fetch":
|
|
47
|
+
return /search/.test(normalized) ? "Web search" : "Fetch";
|
|
48
|
+
default:
|
|
49
|
+
return name;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function argumentSummary(input, max = 60) {
|
|
53
|
+
const parts = Object.entries(input ?? {}).flatMap(([key, value]) => {
|
|
54
|
+
if (value === void 0 || value === null || value === "") return [];
|
|
55
|
+
const text = typeof value === "string" ? value.replace(/\s+/g, " ").trim() : JSON.stringify(value);
|
|
56
|
+
return text ? [`${key}=${text.length > 24 ? `${text.slice(0, 23)}\u2026` : text}`] : [];
|
|
57
|
+
});
|
|
58
|
+
const joined = parts.join(" ");
|
|
59
|
+
return joined ? joined.length > max ? `${joined.slice(0, max - 1)}\u2026` : joined : void 0;
|
|
60
|
+
}
|
|
61
|
+
function commandText(command) {
|
|
62
|
+
if (typeof command === "string") return command;
|
|
63
|
+
return Array.isArray(command) ? command.map(String).join(" ") : void 0;
|
|
64
|
+
}
|
|
65
|
+
function toolLabel(name, input, category) {
|
|
66
|
+
const WANTED = [
|
|
67
|
+
"filepath",
|
|
68
|
+
"path",
|
|
69
|
+
"notebookpath",
|
|
70
|
+
"absolutepath",
|
|
71
|
+
"command",
|
|
72
|
+
"commandline",
|
|
73
|
+
"pattern",
|
|
74
|
+
"query",
|
|
75
|
+
"url"
|
|
76
|
+
];
|
|
77
|
+
const normalise = (key) => key.replace(/[\s_-]/g, "").toLowerCase();
|
|
78
|
+
const pick = (keys) => keys.map((wanted) => Object.entries(input ?? {}).find(([key]) => normalise(key) === wanted)?.[1]).map((value) => Array.isArray(value) && value.every((part) => typeof part === "string") ? value.join(" ") : value).find((value) => typeof value === "string" && Boolean(value.trim()));
|
|
79
|
+
const kind = category ?? toolCategory(name, input);
|
|
80
|
+
const target = pick(WANTED);
|
|
81
|
+
if (target) return formatToolRow(name, target, kind);
|
|
82
|
+
if (isAgentToolName(name)) return formatToolRow(name, pick(["description", "task", "prompt", "instructions"]), kind);
|
|
83
|
+
return formatToolRow(name, name.startsWith("mcp__") ? argumentSummary(input) : void 0, kind);
|
|
84
|
+
}
|
|
85
|
+
function isAgentToolName(name) {
|
|
86
|
+
const normalized = name.split(/[\s(]/, 1)[0]?.toLowerCase().replace(/[^a-z]/g, "") ?? "";
|
|
87
|
+
return /^(task|agent|subagent|delegate|spawn|spawnagent|followuptask|collabagent|launchagent|runagent)$/.test(normalized) || normalized.endsWith("subagent");
|
|
88
|
+
}
|
|
89
|
+
var TOOL_NAME_CATEGORIES = [
|
|
90
|
+
["fetch", /^(webfetch|websearch|webbrowse|webread|browse|curl|httpget|http|fetchurl|googlewebsearch|searchweb|webfetchtool)$/],
|
|
91
|
+
["edit", /^(edit|write|patch|applypatch|strreplace|strreplaceeditor|multiedit|createfile|updatefile|writefile|filewrite|notebookedit|insert|append|replace|create|delete|remove|strreplacefile|writetofile|replaceinfile)$/],
|
|
92
|
+
["read", /^(read|view|open|cat|readfile|getfile|fileread|viewfile|openfile|notebookread|readmanyfiles|readfiles|readmultiplefiles|readmcpresource)$/],
|
|
93
|
+
["run", /^(bash|sh|shell|exec|execute|run|runcommand|runterminalcmd|terminal|command|process|localshell|execcommand|runshellcommand|shellcommand|writestdin|execbash|bashtool|runbash)$/],
|
|
94
|
+
["search", /^(grep|glob|find|search|rg|ripgrep|listdir|listdirectory|listdirectories|listfolder|readdir|list|ls|listfiles|codebasesearch|filesearch|searchfiles|findfiles|todoread|searchfilecontent|grepsearch|globtool|greptool|lstool)$/],
|
|
95
|
+
["fetch", /^(fetch|request|download)$/]
|
|
96
|
+
];
|
|
97
|
+
var TOOL_INPUT_CATEGORIES = [
|
|
98
|
+
["run", "command"],
|
|
99
|
+
["search", "pattern"],
|
|
100
|
+
["search", "query"],
|
|
101
|
+
["fetch", "url"]
|
|
102
|
+
];
|
|
103
|
+
var CLAUDE_TOOL_NAMES = {
|
|
104
|
+
// Read/Edit/Write/Bash/Glob/Grep/WebFetch/NotebookRead/NotebookEdit all
|
|
105
|
+
// match the verb table already. These two are the background-shell tools it
|
|
106
|
+
// cannot reach, and they carry no input that would classify them either.
|
|
107
|
+
BashOutput: "run",
|
|
108
|
+
KillShell: "run"
|
|
109
|
+
};
|
|
110
|
+
var GATEWAY_HARNESS_COMMAND = "gateway";
|
|
111
|
+
var HARNESS_TOOL_MAPPINGS = {
|
|
112
|
+
claude: { stream: "structured", names: CLAUDE_TOOL_NAMES, note: "tool_use blocks carry name and input; Edit/Write also carry a diff, which settles them outright." },
|
|
113
|
+
qwen: { stream: "structured", names: CLAUDE_TOOL_NAMES, note: "Claude-shaped stream, parsed by the same branch and named the same way." },
|
|
114
|
+
grok: { stream: "structured", names: CLAUDE_TOOL_NAMES, note: "Claude-shaped stream, confirmed live from its own init line, so the same branch reads it." },
|
|
115
|
+
gemini: { stream: "structured", names: CLAUDE_TOOL_NAMES, note: "stream-json in the Claude shape; its ACP mode is a flag, not a subcommand." },
|
|
116
|
+
codex: { stream: "structured", note: "command_execution is a run by the shape of its own envelope; mcp_tool_call classifies by the MCP tool name." },
|
|
117
|
+
opencode: { stream: "structured", note: "part.tool with part.state.input: the verb table reads the name, the input shape covers the rest." },
|
|
118
|
+
kilo: { stream: "structured", note: "an OpenCode fork emitting the same envelope." },
|
|
119
|
+
goose: { stream: "structured", note: "names are server-prefixed (developer__shell), which no verb table can match; the command in their input is what classifies them." },
|
|
120
|
+
cline: { stream: "structured", note: "ACP toolRequest carries name and arguments." },
|
|
121
|
+
droid: { stream: "structured", note: "ACP toolRequest carries name and arguments." },
|
|
122
|
+
kiro: { stream: "structured", note: "ACP toolRequest carries name and arguments." },
|
|
123
|
+
amp: { stream: "structured", names: CLAUDE_TOOL_NAMES, note: 'declares the Claude stream (`claude-stream-json`), so its tools are named the Claude way; this row said "classify by name where the stream reports one" and left them to the generic verb table.' },
|
|
124
|
+
pi: { stream: "structured", note: "JSON-lines turn; tool events classify by name where the stream reports one." },
|
|
125
|
+
antigravity: { stream: "structured", note: "step_update carries tool_name AND tool_info.parameters (CommandLine on run_command, AbsolutePath on view_file), verified against agy 1.2.7. An earlier note here claimed there was no input, which is why every tool row read as a bare name." },
|
|
126
|
+
cursor: { stream: "structured", note: "tool events carry a name and a description, not an input record; the verb table alone classifies them." },
|
|
127
|
+
command: { stream: "structured", note: "tool_running/tool_completed/tool_errored carry toolName; shell and edit both match the verb table." },
|
|
128
|
+
dcode: { stream: "structured", note: "ACP tool updates carry the operation and input; vendor-specific names have not been verified live." },
|
|
129
|
+
devin: { stream: "structured", note: "ACP tool updates carry the operation and input; vendor-specific names have not been verified live." },
|
|
130
|
+
junie: { stream: "structured", note: "ACP tool updates carry the operation and input; vendor-specific names have not been verified live." },
|
|
131
|
+
mcode: { stream: "structured", note: "ACP tool updates carry the operation and input; vendor-specific names have not been verified live." },
|
|
132
|
+
auggie: { stream: "structured", note: "JSON turn; ACP tool events classify by name." },
|
|
133
|
+
copilot: { stream: "structured", note: "ACP agent_message_chunk and tool_call updates use the same response and tool rows as other ACP agents. The one-shot CLI fallback is text-only." },
|
|
134
|
+
aider: { stream: "text", note: "text-only turn output; the vendor CLI publishes no machine-readable tool events." },
|
|
135
|
+
hermes: { stream: "structured", note: "the turn is `hermes acp`, which emits tool_call updates (terminal is execute, delegate_task is the sub-agent). `chat --quiet` is the text fallback and has no tool events." },
|
|
136
|
+
openclaw: { stream: "text", note: "agent --local --json is one envelope (`final`) after the turn. Tool streaming exists only on `openclaw acp`, which requires a running Gateway and is not this turn." },
|
|
137
|
+
kimi: { stream: "structured", note: "its CLI turn emits stream-json, and its ACP surface is a subcommand rather than a flag." },
|
|
138
|
+
vibe: { stream: "structured", note: "--output streaming is newline-delimited JSON per message; vibe-acp is a separate binary." },
|
|
139
|
+
openhands: { stream: "structured", note: "--json streams JSONL events in headless mode; `acp` is a subcommand." },
|
|
140
|
+
[GATEWAY_HARNESS_COMMAND]: {
|
|
141
|
+
stream: "structured",
|
|
142
|
+
// read_file/list_dir/glob/grep/write_file/edit_file/multi_edit/bash/
|
|
143
|
+
// web_fetch all match the verb table. These two are the background-shell
|
|
144
|
+
// pair it cannot reach; todo_write and exit_plan_mode stay unclassified
|
|
145
|
+
// because neither is work on the user's code.
|
|
146
|
+
names: { bash_output: "run", bash_input: "run", kill_bash: "run" },
|
|
147
|
+
note: "ClikCode's own loop: the tool name is ours, so the verb table settles all but the background-shell pair."
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
function categoryOf(name, input, harness) {
|
|
151
|
+
const category = toolCategory(name, input, false, harness);
|
|
152
|
+
return category ? { category } : {};
|
|
153
|
+
}
|
|
154
|
+
function toolCategory(name, input, hasDiff = false, harness) {
|
|
155
|
+
if (hasDiff) return "edit";
|
|
156
|
+
const declared = harness ? HARNESS_TOOL_MAPPINGS[harness]?.names?.[name] : void 0;
|
|
157
|
+
if (declared) return declared;
|
|
158
|
+
const normalized = name.toLowerCase().replace(/[^a-z]/g, "");
|
|
159
|
+
for (const [category, pattern] of TOOL_NAME_CATEGORIES) if (pattern.test(normalized)) return category;
|
|
160
|
+
for (const [category, key] of TOOL_INPUT_CATEGORIES) {
|
|
161
|
+
const value = input?.[key];
|
|
162
|
+
if (typeof value === "string" && value.trim()) return category;
|
|
163
|
+
}
|
|
164
|
+
return void 0;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export {
|
|
168
|
+
formatToolRow,
|
|
169
|
+
argumentSummary,
|
|
170
|
+
commandText,
|
|
171
|
+
toolLabel,
|
|
172
|
+
isAgentToolName,
|
|
173
|
+
GATEWAY_HARNESS_COMMAND,
|
|
174
|
+
categoryOf,
|
|
175
|
+
toolCategory
|
|
176
|
+
};
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
gatewayConnection
|
|
5
|
+
} from "./chunk-2OLS7V66.js";
|
|
6
|
+
import {
|
|
7
|
+
gatewaySubscriptionsOn,
|
|
8
|
+
subscriptionsHeader
|
|
9
|
+
} from "./chunk-GQBZU6EO.js";
|
|
10
|
+
import {
|
|
11
|
+
withoutFreeTag
|
|
12
|
+
} from "./chunk-F252T6Y3.js";
|
|
13
|
+
import {
|
|
14
|
+
CLIKCODE_USER_AGENT
|
|
15
|
+
} from "./chunk-NAOX3JUB.js";
|
|
16
|
+
import {
|
|
17
|
+
Conf
|
|
18
|
+
} from "./chunk-GGYKY4GF.js";
|
|
19
|
+
import {
|
|
20
|
+
quiet
|
|
21
|
+
} from "./chunk-RDDWQBEM.js";
|
|
22
|
+
import {
|
|
23
|
+
stateDirectory
|
|
24
|
+
} from "./chunk-MPAJ446F.js";
|
|
25
|
+
|
|
26
|
+
// src/gateway/models.ts
|
|
27
|
+
import { createHash } from "node:crypto";
|
|
28
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
29
|
+
import { dirname, join } from "node:path";
|
|
30
|
+
var ACCESS = /* @__PURE__ */ new Set(["subscription", "free", "paid"]);
|
|
31
|
+
function gatewayModelLabel(model) {
|
|
32
|
+
if (model.own?.modelId) return `${withoutFreeTag(model.own.modelId)} (Hosted AI)`;
|
|
33
|
+
const name = withoutFreeTag(model.id);
|
|
34
|
+
return model.access && model.access !== "paid" ? `${name} (${model.access})` : name;
|
|
35
|
+
}
|
|
36
|
+
var MAKER_NAMES = {
|
|
37
|
+
openai: "OpenAI",
|
|
38
|
+
xai: "xAI",
|
|
39
|
+
zai: "Z.ai",
|
|
40
|
+
ibm: "IBM",
|
|
41
|
+
bytedance: "ByteDance",
|
|
42
|
+
nousresearch: "Nous Research",
|
|
43
|
+
inclusionai: "inclusionAI",
|
|
44
|
+
aionlabs: "AionLabs",
|
|
45
|
+
"nex-agi": "Nex AGI",
|
|
46
|
+
"nomic-ai": "Nomic",
|
|
47
|
+
deepseek: "DeepSeek",
|
|
48
|
+
minimax: "MiniMax",
|
|
49
|
+
moonshot: "Moonshot AI",
|
|
50
|
+
thinkingmachines: "Thinking Machines",
|
|
51
|
+
sao10k: "Sao10K",
|
|
52
|
+
nvidia: "NVIDIA"
|
|
53
|
+
};
|
|
54
|
+
var OWN_MODELS_GROUP = "Your models";
|
|
55
|
+
function gatewayMakerName(model) {
|
|
56
|
+
if (model.own) return OWN_MODELS_GROUP;
|
|
57
|
+
const maker = model.maker;
|
|
58
|
+
if (!maker) return "Other";
|
|
59
|
+
return MAKER_NAMES[maker] ?? maker.replace(/(^|[-_ ])(\w)/g, (_m, space, letter) => `${space ? " " : ""}${letter.toUpperCase()}`);
|
|
60
|
+
}
|
|
61
|
+
function gatewayModelsByMaker(models) {
|
|
62
|
+
const key = (model) => model.own ? "" : model.maker ? gatewayMakerName(model).toLowerCase() : "\uFFFF";
|
|
63
|
+
return [...models].sort((left, right) => key(left).localeCompare(key(right)));
|
|
64
|
+
}
|
|
65
|
+
async function uncensoredConsentRequest(options, version) {
|
|
66
|
+
const { baseUrl, apiKey } = gatewayConnection(options.config ?? new Conf({ projectName: "clikcode", configFileMode: 384 }));
|
|
67
|
+
const response = await (options.fetchImpl ?? fetch)(`${baseUrl}/v1/uncensored-consent`, {
|
|
68
|
+
...version !== void 0 ? { method: "POST", body: JSON.stringify({ accepted: true, version }) } : {},
|
|
69
|
+
headers: {
|
|
70
|
+
authorization: `Bearer ${apiKey}`,
|
|
71
|
+
accept: "application/json",
|
|
72
|
+
"user-agent": CLIKCODE_USER_AGENT,
|
|
73
|
+
...version !== void 0 ? { "content-type": "application/json" } : {}
|
|
74
|
+
},
|
|
75
|
+
signal: AbortSignal.timeout(options.timeoutMs ?? MODELS_TIMEOUT_MS)
|
|
76
|
+
});
|
|
77
|
+
const body = await response.json().catch(quiet("gateway/uncensored-consent")) ?? {};
|
|
78
|
+
if (!response.ok || typeof body.version !== "string" || typeof body.terms !== "string" || typeof body.accepted !== "boolean") {
|
|
79
|
+
throw new Error(body.error?.message ?? `the ClikDeploy Gateway did not return the agreement (HTTP ${response.status})`);
|
|
80
|
+
}
|
|
81
|
+
return { version: body.version, terms: body.terms, accepted: body.accepted, acceptedAt: typeof body.acceptedAt === "string" ? body.acceptedAt : null };
|
|
82
|
+
}
|
|
83
|
+
function gatewayUncensoredConsent(options = {}) {
|
|
84
|
+
return uncensoredConsentRequest(options);
|
|
85
|
+
}
|
|
86
|
+
function acceptGatewayUncensoredTerms(version, options = {}) {
|
|
87
|
+
return uncensoredConsentRequest(options, version);
|
|
88
|
+
}
|
|
89
|
+
function gatewayModelDetail(model) {
|
|
90
|
+
if (model.own) {
|
|
91
|
+
return [
|
|
92
|
+
model.own.state === "asleep" ? "asleep: wakes when used (a few minutes)" : model.own.state === "failed" ? `failed${model.own.detail ? `: ${model.own.detail}` : ""}` : model.own.state === "starting" ? "starting" : "running",
|
|
93
|
+
"on your compute, no per-token charge",
|
|
94
|
+
model.own.tools ? "" : "no tool calls"
|
|
95
|
+
].filter(Boolean).join(" \xB7 ");
|
|
96
|
+
}
|
|
97
|
+
return [
|
|
98
|
+
model.tags?.includes("abliterated") ? "abliterated" : "",
|
|
99
|
+
model.tags?.includes("uncensored") ? "uncensored" : "",
|
|
100
|
+
model.price ? gatewayPriceLabel(model.price, false) : ""
|
|
101
|
+
].filter(Boolean).join(" \xB7 ");
|
|
102
|
+
}
|
|
103
|
+
function gatewayPriceLabel(price, unit = true) {
|
|
104
|
+
const money = (n) => `$${Number(n.toFixed(n < 1 ? 3 : 2))}`;
|
|
105
|
+
const pair = (rate) => `${money(rate.inMTok)}/${money(rate.outMTok)}`;
|
|
106
|
+
const full = pair(price.full);
|
|
107
|
+
const charged = pair(price.charged);
|
|
108
|
+
const per = unit ? " per 1M" : "";
|
|
109
|
+
if (price.discountPercent <= 0 || charged === full) return `${charged}${per}`;
|
|
110
|
+
return `${full} \u2192 ${charged}${per} (${price.discountPercent}% off)`;
|
|
111
|
+
}
|
|
112
|
+
var TTL_MS = 6e4;
|
|
113
|
+
var MODELS_TIMEOUT_MS = 15e3;
|
|
114
|
+
var cached;
|
|
115
|
+
function authDigest(apiKey) {
|
|
116
|
+
return createHash("sha256").update(apiKey).digest("hex");
|
|
117
|
+
}
|
|
118
|
+
function diskCachePath() {
|
|
119
|
+
return join(stateDirectory(), "cache", "gateway-models.json");
|
|
120
|
+
}
|
|
121
|
+
async function savedGatewayModels(options = {}) {
|
|
122
|
+
const config = options.config ?? new Conf({ projectName: "clikcode", configFileMode: 384 });
|
|
123
|
+
const { baseUrl, apiKey } = gatewayConnection(config);
|
|
124
|
+
try {
|
|
125
|
+
const saved = JSON.parse(await readFile(diskCachePath(), "utf8"));
|
|
126
|
+
const sameSwitch = (saved.subscriptions ?? true) === gatewaySubscriptionsOn(config);
|
|
127
|
+
return saved.baseUrl === baseUrl && saved.auth === authDigest(apiKey) && sameSwitch && Array.isArray(saved.list?.models) ? saved.list : void 0;
|
|
128
|
+
} catch {
|
|
129
|
+
return void 0;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async function saveGatewayModels(baseUrl, auth, subscriptions, list) {
|
|
133
|
+
const file = diskCachePath();
|
|
134
|
+
await mkdir(dirname(file), { recursive: true });
|
|
135
|
+
await writeFile(file, JSON.stringify({ baseUrl, auth, subscriptions, at: Date.now(), list }), { mode: 384 });
|
|
136
|
+
}
|
|
137
|
+
function sameGatewayModel(a, b) {
|
|
138
|
+
const fold = (id) => id.trim().toLowerCase().split("/").pop().replace(/[._]/g, "-");
|
|
139
|
+
return fold(a) === fold(b);
|
|
140
|
+
}
|
|
141
|
+
function gatewayModelForWord(models, value) {
|
|
142
|
+
const exact = models.find((model) => sameGatewayModel(model.id, value));
|
|
143
|
+
if (exact) return exact;
|
|
144
|
+
const words = value.trim().toLowerCase().split(/[\s-]+/).filter(Boolean);
|
|
145
|
+
const parts = (id) => id.toLowerCase().split(/[-._/:\s]+/);
|
|
146
|
+
const holding = models.filter((model) => words.every((word) => parts(model.id).includes(word)));
|
|
147
|
+
const version = (id) => parts(id).filter((part) => /^\d+$/.test(part)).map(Number);
|
|
148
|
+
const newer = (a, b) => {
|
|
149
|
+
const x = version(a.id);
|
|
150
|
+
const y = version(b.id);
|
|
151
|
+
for (let i = 0; i < Math.max(x.length, y.length); i += 1) if ((y[i] ?? -1) !== (x[i] ?? -1)) return (y[i] ?? -1) - (x[i] ?? -1);
|
|
152
|
+
return Number(parts(a.id).includes("fast")) - Number(parts(b.id).includes("fast"));
|
|
153
|
+
};
|
|
154
|
+
return [...holding].sort(newer)[0];
|
|
155
|
+
}
|
|
156
|
+
function isAutomaticModelWord(value) {
|
|
157
|
+
return /^(auto|automatic|default|gateway)$/i.test(value.trim());
|
|
158
|
+
}
|
|
159
|
+
async function gatewayModels(options = {}) {
|
|
160
|
+
const config = options.config ?? new Conf({ projectName: "clikcode", configFileMode: 384 });
|
|
161
|
+
const { baseUrl, apiKey } = gatewayConnection(config);
|
|
162
|
+
const auth = authDigest(apiKey);
|
|
163
|
+
const subscriptions = gatewaySubscriptionsOn(config);
|
|
164
|
+
if (!options.fresh && cached && cached.baseUrl === baseUrl && cached.auth === auth && cached.subscriptions === subscriptions && Date.now() - cached.at < TTL_MS) return cached.list;
|
|
165
|
+
let response;
|
|
166
|
+
let body;
|
|
167
|
+
try {
|
|
168
|
+
const signal = AbortSignal.timeout(options.timeoutMs ?? MODELS_TIMEOUT_MS);
|
|
169
|
+
response = await (options.fetchImpl ?? fetch)(`${baseUrl}/v1/models`, {
|
|
170
|
+
headers: { authorization: `Bearer ${apiKey}`, accept: "application/json", "user-agent": CLIKCODE_USER_AGENT, ...subscriptionsHeader(subscriptions) },
|
|
171
|
+
signal
|
|
172
|
+
});
|
|
173
|
+
body = await response.json().catch(quiet("gateway/models"));
|
|
174
|
+
} catch (error) {
|
|
175
|
+
const saved = await savedGatewayModels({ config });
|
|
176
|
+
if (saved) return saved;
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
179
|
+
if (!response.ok || !Array.isArray(body?.data)) {
|
|
180
|
+
const error = body?.error;
|
|
181
|
+
const message = typeof error === "string" ? error : error && typeof error === "object" && typeof error.message === "string" ? error.message : void 0;
|
|
182
|
+
const reason = message ?? (response.status === 404 ? "this Gateway does not offer a model choice yet" : `HTTP ${response.status}`);
|
|
183
|
+
throw Object.assign(new Error(`ClikDeploy Gateway models: ${reason}`), { statusCode: response.status });
|
|
184
|
+
}
|
|
185
|
+
const switchState = body.clikcode?.subscriptions;
|
|
186
|
+
const list = { ...fromOpenAIModelList(body.data), ...typeof switchState === "boolean" ? { subscriptions: switchState } : {} };
|
|
187
|
+
cached = { baseUrl, auth, subscriptions, at: Date.now(), list };
|
|
188
|
+
await saveGatewayModels(baseUrl, auth, subscriptions, list).catch(quiet("gateway/models"));
|
|
189
|
+
return list;
|
|
190
|
+
}
|
|
191
|
+
var GATEWAY_AUTO_MODEL = "auto";
|
|
192
|
+
function fromOpenAIModelList(data) {
|
|
193
|
+
let auto = null;
|
|
194
|
+
const models = [];
|
|
195
|
+
const speech = [];
|
|
196
|
+
for (const raw of data) {
|
|
197
|
+
if (!raw || typeof raw !== "object") continue;
|
|
198
|
+
const entry = raw;
|
|
199
|
+
if (typeof entry.id !== "string" || !entry.id) continue;
|
|
200
|
+
if (typeof entry.type === "string" && /transcri|speech|stt|audio/i.test(entry.type)) {
|
|
201
|
+
speech.push({ id: entry.id, ...typeof entry.access === "string" && ACCESS.has(entry.access) ? { access: entry.access } : {} });
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
if (entry.type !== void 0 && entry.type !== "chat") continue;
|
|
205
|
+
if (entry.id === GATEWAY_AUTO_MODEL) {
|
|
206
|
+
const contextWindow = typeof entry.context_length === "number" && entry.context_length > 0 ? entry.context_length : void 0;
|
|
207
|
+
const maxOutput = typeof entry.max_output_tokens === "number" && entry.max_output_tokens > 0 ? entry.max_output_tokens : void 0;
|
|
208
|
+
auto = {
|
|
209
|
+
...contextWindow ? { contextWindow } : {},
|
|
210
|
+
...maxOutput ? { maxOutput } : {},
|
|
211
|
+
...entry.capabilities?.vision === true ? { vision: true } : {}
|
|
212
|
+
};
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
if (entry.owned_by === "self-hosted" && entry.deployment && typeof entry.deployment === "object") {
|
|
216
|
+
const state = entry.deployment.state === "asleep" || entry.deployment.state === "starting" ? entry.deployment.state : entry.deployment.state === "running" ? "running" : "failed";
|
|
217
|
+
models.push({
|
|
218
|
+
id: entry.id,
|
|
219
|
+
own: { state, ...typeof entry.deployment.detail === "string" ? { detail: entry.deployment.detail } : {}, tools: entry.capabilities?.tools !== false, ...typeof entry.deployment.modelId === "string" && entry.deployment.modelId ? { modelId: entry.deployment.modelId } : {} },
|
|
220
|
+
...typeof entry.context_length === "number" && entry.context_length > 0 ? { contextWindow: entry.context_length } : {}
|
|
221
|
+
});
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
const pricing = entry.pricing;
|
|
225
|
+
const num = (key) => typeof pricing?.[key] === "number" ? pricing[key] : void 0;
|
|
226
|
+
const charged = { inMTok: num("input_per_mtok"), outMTok: num("output_per_mtok") };
|
|
227
|
+
models.push({
|
|
228
|
+
id: entry.id,
|
|
229
|
+
...typeof entry.owned_by === "string" && entry.owned_by && entry.owned_by !== "clikdeploy" ? { maker: entry.owned_by } : {},
|
|
230
|
+
...typeof entry.access === "string" && ACCESS.has(entry.access) ? { access: entry.access } : {},
|
|
231
|
+
...Array.isArray(entry.sources) ? (() => {
|
|
232
|
+
const sources = entry.sources.flatMap((item) => {
|
|
233
|
+
const source = item;
|
|
234
|
+
return typeof source?.id === "string" && source.id && typeof source.access === "string" && ACCESS.has(source.access) ? [{ id: source.id, access: source.access }] : [];
|
|
235
|
+
});
|
|
236
|
+
return sources.length ? { sources } : {};
|
|
237
|
+
})() : {},
|
|
238
|
+
...Array.isArray(entry.tags) && entry.tags.some((tag) => typeof tag === "string") ? { tags: entry.tags.filter((tag) => typeof tag === "string") } : {},
|
|
239
|
+
...typeof entry.context_length === "number" && entry.context_length > 0 ? { contextWindow: entry.context_length } : {},
|
|
240
|
+
...entry.capabilities?.vision === true ? { vision: true } : {},
|
|
241
|
+
...entry.capabilities?.reasoning === true ? { reasoning: true } : {},
|
|
242
|
+
...typeof entry.max_output_tokens === "number" && entry.max_output_tokens > 0 ? { maxOutput: entry.max_output_tokens } : {},
|
|
243
|
+
...typeof entry.tokens_per_second === "number" && entry.tokens_per_second > 0 ? { tokensPerSecond: entry.tokens_per_second } : {},
|
|
244
|
+
...charged.inMTok !== void 0 && charged.outMTok !== void 0 ? {
|
|
245
|
+
price: {
|
|
246
|
+
full: { inMTok: num("full_input_per_mtok") ?? charged.inMTok, outMTok: num("full_output_per_mtok") ?? charged.outMTok },
|
|
247
|
+
discountPercent: num("discount_percent") ?? 0,
|
|
248
|
+
charged: { inMTok: charged.inMTok, outMTok: charged.outMTok }
|
|
249
|
+
}
|
|
250
|
+
} : {}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
return { auto, models, ...speech.length ? { speech } : {} };
|
|
254
|
+
}
|
|
255
|
+
function gatewaySessionModelLabel(modelId) {
|
|
256
|
+
if (!modelId.startsWith("private-deployment:")) return modelId;
|
|
257
|
+
const served = cached?.list.models.find((entry) => entry.id === modelId)?.own?.modelId;
|
|
258
|
+
return served ? `${withoutFreeTag(served)} (Hosted AI)` : "Hosted AI model";
|
|
259
|
+
}
|
|
260
|
+
function resetGatewayModelCache() {
|
|
261
|
+
cached = void 0;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export {
|
|
265
|
+
gatewayModelLabel,
|
|
266
|
+
gatewayMakerName,
|
|
267
|
+
gatewayModelsByMaker,
|
|
268
|
+
gatewayUncensoredConsent,
|
|
269
|
+
acceptGatewayUncensoredTerms,
|
|
270
|
+
gatewayModelDetail,
|
|
271
|
+
gatewayPriceLabel,
|
|
272
|
+
savedGatewayModels,
|
|
273
|
+
sameGatewayModel,
|
|
274
|
+
gatewayModelForWord,
|
|
275
|
+
isAutomaticModelWord,
|
|
276
|
+
gatewayModels,
|
|
277
|
+
fromOpenAIModelList,
|
|
278
|
+
gatewaySessionModelLabel,
|
|
279
|
+
resetGatewayModelCache
|
|
280
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
STATE_ROLLUPS,
|
|
5
|
+
capInvocations,
|
|
6
|
+
invocationRollups,
|
|
7
|
+
invocationTokenCount,
|
|
8
|
+
loadInvocationLog,
|
|
9
|
+
resetInvocationLogCache,
|
|
10
|
+
storeInvocationLog
|
|
11
|
+
} from "./chunk-NKDATMEM.js";
|
|
12
|
+
import "./chunk-O3EW7LAY.js";
|
|
13
|
+
import "./chunk-KHW6TX6I.js";
|
|
14
|
+
import "./chunk-F6F47QAY.js";
|
|
15
|
+
import "./chunk-RDDWQBEM.js";
|
|
16
|
+
import "./chunk-MPAJ446F.js";
|
|
17
|
+
import "./chunk-CBANJFBO.js";
|
|
18
|
+
import "./chunk-PWXII6HF.js";
|
|
19
|
+
export {
|
|
20
|
+
STATE_ROLLUPS,
|
|
21
|
+
capInvocations,
|
|
22
|
+
invocationRollups,
|
|
23
|
+
invocationTokenCount,
|
|
24
|
+
loadInvocationLog,
|
|
25
|
+
resetInvocationLogCache,
|
|
26
|
+
storeInvocationLog
|
|
27
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
listPlugins,
|
|
5
|
+
setPluginEnabled
|
|
6
|
+
} from "./chunk-K2NLG2HK.js";
|
|
7
|
+
import "./chunk-DQYVQ2N7.js";
|
|
8
|
+
import {
|
|
9
|
+
emitResult
|
|
10
|
+
} from "./chunk-JGIWATSG.js";
|
|
11
|
+
import {
|
|
12
|
+
isJsonDefaultMode
|
|
13
|
+
} from "./chunk-5B6TVO4A.js";
|
|
14
|
+
import {
|
|
15
|
+
source_default
|
|
16
|
+
} from "./chunk-LVRRWP4W.js";
|
|
17
|
+
import "./chunk-F6F47QAY.js";
|
|
18
|
+
import "./chunk-RDDWQBEM.js";
|
|
19
|
+
import {
|
|
20
|
+
stateDirectory
|
|
21
|
+
} from "./chunk-MPAJ446F.js";
|
|
22
|
+
import "./chunk-CBANJFBO.js";
|
|
23
|
+
import "./chunk-PWXII6HF.js";
|
|
24
|
+
|
|
25
|
+
// src/commands/plugin.ts
|
|
26
|
+
import { stdout as output } from "node:process";
|
|
27
|
+
function roots() {
|
|
28
|
+
return { stateDir: stateDirectory() };
|
|
29
|
+
}
|
|
30
|
+
async function reported(action, run) {
|
|
31
|
+
try {
|
|
32
|
+
await run();
|
|
33
|
+
} catch (error) {
|
|
34
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
35
|
+
if (isJsonDefaultMode()) emitResult({ plugin: action, error: message });
|
|
36
|
+
else output.write(`
|
|
37
|
+
${source_default.red("\u2717")} ${message}
|
|
38
|
+
|
|
39
|
+
`);
|
|
40
|
+
process.exitCode = 1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function pluginList() {
|
|
44
|
+
return reported("list", async () => {
|
|
45
|
+
const plugins = listPlugins(roots());
|
|
46
|
+
if (isJsonDefaultMode()) return emitResult({ plugin: "list", plugins });
|
|
47
|
+
output.write(`
|
|
48
|
+
${source_default.bold("Plugins")}
|
|
49
|
+
`);
|
|
50
|
+
for (const plugin of plugins) {
|
|
51
|
+
const state = plugin.enabled ? source_default.green("enabled ") : source_default.dim("disabled");
|
|
52
|
+
output.write(` ${state} ${source_default.bold(plugin.id)}${plugin.version ? source_default.dim(` ${plugin.version}`) : ""}
|
|
53
|
+
`);
|
|
54
|
+
if (plugin.description) output.write(` ${source_default.dim(plugin.description.slice(0, 100))}
|
|
55
|
+
`);
|
|
56
|
+
}
|
|
57
|
+
if (!plugins.length) output.write(` ${source_default.dim("none -- install one in Claude Code (/plugin)")}
|
|
58
|
+
`);
|
|
59
|
+
output.write("\n");
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function pluginSetEnabled(name, enabled) {
|
|
63
|
+
return reported(enabled ? "enable" : "disable", async () => {
|
|
64
|
+
const plugin = await setPluginEnabled(roots(), name, enabled);
|
|
65
|
+
if (isJsonDefaultMode()) return emitResult({ plugin: enabled ? "enable" : "disable", id: plugin.id, enabled });
|
|
66
|
+
const note = source_default.dim(" in ClikCode (Claude Code's own setting is unchanged)");
|
|
67
|
+
output.write(`
|
|
68
|
+
${source_default.green("\u2713")} ${source_default.bold(plugin.id)} ${enabled ? "enabled" : "disabled"}${note}.
|
|
69
|
+
|
|
70
|
+
`);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
pluginList,
|
|
75
|
+
pluginSetEnabled
|
|
76
|
+
};
|