clikcode 1.0.3 → 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 +498 -112593
- package/dist/computer-tools.js +36642 -21258
- 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,483 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
MCP_SERVERS_KEY,
|
|
5
|
+
mcpConfigFilePath,
|
|
6
|
+
parseMcpServerEntry
|
|
7
|
+
} from "./chunk-DQYVQ2N7.js";
|
|
8
|
+
import {
|
|
9
|
+
allLocalHarnesses,
|
|
10
|
+
localHarnessCapabilityManifest
|
|
11
|
+
} from "./chunk-KYUHIFP3.js";
|
|
12
|
+
import {
|
|
13
|
+
quiet
|
|
14
|
+
} from "./chunk-RDDWQBEM.js";
|
|
15
|
+
|
|
16
|
+
// src/agent/mcp/import.ts
|
|
17
|
+
import { chmod, mkdir, readdir, readFile, writeFile } from "node:fs/promises";
|
|
18
|
+
import { homedir } from "node:os";
|
|
19
|
+
import { dirname, join } from "node:path";
|
|
20
|
+
function vendorSources() {
|
|
21
|
+
return allLocalHarnesses().flatMap((harness) => (localHarnessCapabilityManifest(harness).managers?.mcp?.serverFiles ?? []).map((file) => ({ ...file, vendor: harness.displayName, command: harness.command })));
|
|
22
|
+
}
|
|
23
|
+
var IMPORT_MARKER_FILE = "mcp-import.json";
|
|
24
|
+
function isRecord(value) {
|
|
25
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
26
|
+
}
|
|
27
|
+
function strings(value) {
|
|
28
|
+
if (value === void 0) return [];
|
|
29
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string") ? value : void 0;
|
|
30
|
+
}
|
|
31
|
+
function stringRecord(value) {
|
|
32
|
+
if (value === void 0) return {};
|
|
33
|
+
if (!isRecord(value)) return void 0;
|
|
34
|
+
return Object.values(value).every((item) => typeof item === "string") ? value : void 0;
|
|
35
|
+
}
|
|
36
|
+
function unexpandedPlaceholder(entry) {
|
|
37
|
+
return /\$\{[^}]*\}|\{(env|file):[^}]*\}/.test(JSON.stringify(entry));
|
|
38
|
+
}
|
|
39
|
+
function stdioEntry(command, args, env) {
|
|
40
|
+
if (typeof command !== "string" || !command.trim()) return { skip: "names no command or URL" };
|
|
41
|
+
const argv = strings(args);
|
|
42
|
+
const environment = stringRecord(env);
|
|
43
|
+
if (!argv || !environment) return { skip: "has arguments or environment that are not plain strings" };
|
|
44
|
+
return { entry: { command, ...argv.length ? { args: argv } : {}, ...Object.keys(environment).length ? { env: environment } : {} } };
|
|
45
|
+
}
|
|
46
|
+
function remoteEntry(url, sse, headers) {
|
|
47
|
+
if (typeof url !== "string" || !/^https?:\/\//i.test(url)) return { skip: "has a URL that is not http(s)" };
|
|
48
|
+
const table = stringRecord(headers);
|
|
49
|
+
if (!table) return { skip: "has headers that are not plain strings" };
|
|
50
|
+
return { entry: { ...sse ? { type: "sse" } : {}, url, ...Object.keys(table).length ? { headers: table } : {} } };
|
|
51
|
+
}
|
|
52
|
+
var STDIO_TYPES = /* @__PURE__ */ new Set(["stdio", "local"]);
|
|
53
|
+
var HTTP_TYPES = /* @__PURE__ */ new Set(["http", "streamable-http", "streamable_http", "streamablehttp", "remote"]);
|
|
54
|
+
function normalize(dialect, raw) {
|
|
55
|
+
if (!isRecord(raw)) return { skip: "is not an object" };
|
|
56
|
+
if (raw.disabled === true || raw.enabled === false) return { skip: "is disabled there" };
|
|
57
|
+
if (typeof raw.cwd === "string" && raw.cwd.trim()) return { skip: "depends on a working directory mcp.json cannot express" };
|
|
58
|
+
let result;
|
|
59
|
+
if (dialect === "goose") {
|
|
60
|
+
if (raw.type === "stdio") {
|
|
61
|
+
if (Array.isArray(raw.env_keys) && raw.env_keys.length) return { skip: "keeps its secrets in the Goose keyring" };
|
|
62
|
+
result = stdioEntry(raw.cmd, raw.args, raw.envs);
|
|
63
|
+
} else if (raw.type === "streamable_http" || raw.type === "sse") {
|
|
64
|
+
result = remoteEntry(raw.uri, raw.type === "sse", raw.headers);
|
|
65
|
+
} else {
|
|
66
|
+
return { skip: `is a Goose ${String(raw.type ?? "unknown")} extension, not a portable MCP server` };
|
|
67
|
+
}
|
|
68
|
+
} else if (dialect === "opencode") {
|
|
69
|
+
if (raw.type === "local") {
|
|
70
|
+
const argv = strings(raw.command);
|
|
71
|
+
if (!argv?.length) return { skip: "names no command" };
|
|
72
|
+
result = stdioEntry(argv[0], argv.slice(1), raw.environment);
|
|
73
|
+
} else if (raw.type === "remote") {
|
|
74
|
+
result = remoteEntry(raw.url, false, raw.headers);
|
|
75
|
+
} else {
|
|
76
|
+
return { skip: `has transport type "${String(raw.type)}"` };
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
if (dialect === "codex" && typeof raw.bearer_token_env_var === "string") {
|
|
80
|
+
return { skip: "reads its bearer token from an environment variable at launch" };
|
|
81
|
+
}
|
|
82
|
+
const type = typeof raw.type === "string" ? raw.type.toLowerCase() : void 0;
|
|
83
|
+
if (type && !STDIO_TYPES.has(type) && !HTTP_TYPES.has(type) && type !== "sse") {
|
|
84
|
+
return { skip: `has transport type "${raw.type}", which ClikCode's agent does not speak` };
|
|
85
|
+
}
|
|
86
|
+
const headers = dialect === "codex" ? raw.http_headers ?? raw.headers : raw.headers;
|
|
87
|
+
if (dialect === "gemini" && typeof raw.httpUrl === "string") {
|
|
88
|
+
result = remoteEntry(raw.httpUrl, false, headers);
|
|
89
|
+
} else if (typeof raw.url === "string" || typeof raw.serverUrl === "string") {
|
|
90
|
+
const sse = type === "sse" || dialect === "gemini" && !type;
|
|
91
|
+
result = remoteEntry(raw.url ?? raw.serverUrl, sse, headers);
|
|
92
|
+
} else {
|
|
93
|
+
result = stdioEntry(raw.command, raw.args, raw.env);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if ("skip" in result) return result;
|
|
97
|
+
if (unexpandedPlaceholder(result.entry)) return { skip: "uses ${VAR}-style placeholders the vendor expands and ClikCode would not" };
|
|
98
|
+
if (!parseMcpServerEntry("probe", result.entry)) return { skip: "is not a server ClikCode's agent could start" };
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
function identity(entry) {
|
|
102
|
+
return typeof entry.url === "string" ? `url:${entry.url}` : `cmd:${JSON.stringify([entry.command, entry.args ?? []])}`;
|
|
103
|
+
}
|
|
104
|
+
function namedServerTable(value) {
|
|
105
|
+
if (isRecord(value)) return value;
|
|
106
|
+
if (!Array.isArray(value)) return void 0;
|
|
107
|
+
const entries = value.filter((item) => isRecord(item) && typeof item.name === "string" && !!item.name);
|
|
108
|
+
return Object.fromEntries(entries.map((item) => [item.name, item]));
|
|
109
|
+
}
|
|
110
|
+
async function readServerTable(path, source) {
|
|
111
|
+
let text;
|
|
112
|
+
try {
|
|
113
|
+
text = await readFile(path, "utf8");
|
|
114
|
+
} catch {
|
|
115
|
+
return void 0;
|
|
116
|
+
}
|
|
117
|
+
if (!text.trim()) return void 0;
|
|
118
|
+
let root;
|
|
119
|
+
try {
|
|
120
|
+
if (source.format === "toml") root = parseToml(text);
|
|
121
|
+
else if (source.format === "yaml") root = (await import("yaml")).parse(text);
|
|
122
|
+
else root = JSON.parse(source.format === "jsonc" ? stripJsonc(text) : text);
|
|
123
|
+
} catch {
|
|
124
|
+
return void 0;
|
|
125
|
+
}
|
|
126
|
+
let table = root;
|
|
127
|
+
for (const key of source.key) table = isRecord(table) ? table[key] : void 0;
|
|
128
|
+
return namedServerTable(table);
|
|
129
|
+
}
|
|
130
|
+
function vendorConfigCandidates(source, home, profile, workspace) {
|
|
131
|
+
const project = source.projectRelative && workspace ? [join(workspace, ...source.projectRelative)] : [];
|
|
132
|
+
if (!source.homeRelative) return project;
|
|
133
|
+
if (!profile) return [join(home, ...source.homeRelative), ...project];
|
|
134
|
+
const files = [];
|
|
135
|
+
if (profile.env === "HOME") files.push(join(profile.path, ...source.homeRelative));
|
|
136
|
+
else {
|
|
137
|
+
files.push(join(profile.path, ...source.homeRelative));
|
|
138
|
+
if (source.homeRelative.length > 1) files.push(join(profile.path, ...source.homeRelative.slice(1)));
|
|
139
|
+
if (source.rootRelative) files.push(join(profile.path, ...source.rootRelative));
|
|
140
|
+
}
|
|
141
|
+
return [.../* @__PURE__ */ new Set([...files, ...project])];
|
|
142
|
+
}
|
|
143
|
+
async function namesInVendorFile(path, source) {
|
|
144
|
+
let text;
|
|
145
|
+
try {
|
|
146
|
+
text = await readFile(path, "utf8");
|
|
147
|
+
} catch {
|
|
148
|
+
return "missing";
|
|
149
|
+
}
|
|
150
|
+
if (!text.trim()) return "missing";
|
|
151
|
+
let root;
|
|
152
|
+
try {
|
|
153
|
+
if (source.format === "toml") root = parseToml(text);
|
|
154
|
+
else if (source.format === "yaml") root = (await import("yaml")).parse(text);
|
|
155
|
+
else root = JSON.parse(source.format === "jsonc" ? stripJsonc(text) : text);
|
|
156
|
+
} catch {
|
|
157
|
+
return "unreadable";
|
|
158
|
+
}
|
|
159
|
+
let table = root;
|
|
160
|
+
for (const key of source.key) {
|
|
161
|
+
if (!isRecord(table) || !(key in table)) return /* @__PURE__ */ new Set();
|
|
162
|
+
table = table[key];
|
|
163
|
+
}
|
|
164
|
+
const servers = namedServerTable(table);
|
|
165
|
+
return servers ? new Set(Object.keys(servers)) : "unreadable";
|
|
166
|
+
}
|
|
167
|
+
async function vendorMcpServerNames(command, home, profile, workspace) {
|
|
168
|
+
const sources = vendorSources().filter((source) => source.command === command);
|
|
169
|
+
const names = /* @__PURE__ */ new Set();
|
|
170
|
+
if (!sources.length) return { known: false, names };
|
|
171
|
+
for (const source of sources) {
|
|
172
|
+
for (const path of vendorConfigCandidates(source, home, profile, workspace)) {
|
|
173
|
+
const found = await namesInVendorFile(path, source);
|
|
174
|
+
if (found === "missing") continue;
|
|
175
|
+
if (found === "unreadable") return { known: true, names, unreadable: path };
|
|
176
|
+
for (const name of found) names.add(name);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return { known: true, names };
|
|
180
|
+
}
|
|
181
|
+
async function vendorConfigFiles(source, home, stateDir) {
|
|
182
|
+
if (!source.homeRelative) return [];
|
|
183
|
+
const paths = [join(home, ...source.homeRelative)];
|
|
184
|
+
const profiles = join(stateDir, "profiles", source.command);
|
|
185
|
+
const ids = await readdir(profiles).catch(() => []);
|
|
186
|
+
for (const id of ids.sort()) {
|
|
187
|
+
paths.push(join(profiles, id, ...source.homeRelative));
|
|
188
|
+
if (source.rootRelative) paths.push(join(profiles, id, ...source.rootRelative));
|
|
189
|
+
}
|
|
190
|
+
return [...new Set(paths)];
|
|
191
|
+
}
|
|
192
|
+
async function importVendorMcpServers(stateDir, home = homedir()) {
|
|
193
|
+
const markerPath = join(stateDir, IMPORT_MARKER_FILE);
|
|
194
|
+
if (await readFile(markerPath, "utf8").then(() => true, () => false)) return { ran: false, imported: [], skipped: [] };
|
|
195
|
+
const configPath = mcpConfigFilePath(stateDir);
|
|
196
|
+
let root = {};
|
|
197
|
+
const existingText = await readFile(configPath, "utf8").catch(quiet("agent/mcp/import"));
|
|
198
|
+
if (existingText?.trim()) {
|
|
199
|
+
let parsed;
|
|
200
|
+
try {
|
|
201
|
+
parsed = JSON.parse(existingText);
|
|
202
|
+
} catch {
|
|
203
|
+
parsed = void 0;
|
|
204
|
+
}
|
|
205
|
+
if (!isRecord(parsed)) return { ran: false, imported: [], skipped: [], problem: `${configPath} is not a JSON object` };
|
|
206
|
+
root = parsed;
|
|
207
|
+
}
|
|
208
|
+
const existing = isRecord(root[MCP_SERVERS_KEY]) ? { ...root[MCP_SERVERS_KEY] } : {};
|
|
209
|
+
const taken = /* @__PURE__ */ new Map();
|
|
210
|
+
const identities = /* @__PURE__ */ new Map();
|
|
211
|
+
for (const [name, raw] of Object.entries(existing)) {
|
|
212
|
+
taken.set(name, "mcp.json");
|
|
213
|
+
if (isRecord(raw)) identities.set(identity(raw), name);
|
|
214
|
+
}
|
|
215
|
+
const imported = [];
|
|
216
|
+
const skipped = [];
|
|
217
|
+
const added = {};
|
|
218
|
+
for (const source of vendorSources()) {
|
|
219
|
+
for (const path of await vendorConfigFiles(source, home, stateDir)) {
|
|
220
|
+
const table = await readServerTable(path, source);
|
|
221
|
+
if (!table) continue;
|
|
222
|
+
for (const [name, raw] of Object.entries(table)) {
|
|
223
|
+
const from = source.vendor;
|
|
224
|
+
if (name === "clikcode-conversations") {
|
|
225
|
+
skipped.push({ name, from, reason: "is ClikCode's own; its agent has these tools built in" });
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
const normalized = normalize(source.dialect, raw);
|
|
229
|
+
if ("skip" in normalized) {
|
|
230
|
+
skipped.push({ name, from, reason: normalized.skip });
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
const id = identity(normalized.entry);
|
|
234
|
+
const owner = taken.get(name);
|
|
235
|
+
if (owner) {
|
|
236
|
+
if (identities.get(id) !== name) {
|
|
237
|
+
skipped.push({ name, from, reason: owner === "mcp.json" ? "mcp.json already has a server by that name" : `conflicts with ${owner}'s definition, which was kept` });
|
|
238
|
+
}
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
const alias = identities.get(id);
|
|
242
|
+
if (alias) {
|
|
243
|
+
skipped.push({ name, from, reason: `same server as "${alias}"` });
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
taken.set(name, from);
|
|
247
|
+
identities.set(id, name);
|
|
248
|
+
added[name] = normalized.entry;
|
|
249
|
+
imported.push({ name, from });
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (imported.length) {
|
|
254
|
+
const latestText = await readFile(configPath, "utf8").catch(quiet("agent/mcp/import"));
|
|
255
|
+
let latest = root;
|
|
256
|
+
if (latestText?.trim() && latestText !== existingText) {
|
|
257
|
+
try {
|
|
258
|
+
const parsed = JSON.parse(latestText);
|
|
259
|
+
if (isRecord(parsed)) latest = parsed;
|
|
260
|
+
} catch {
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
const latestServers = isRecord(latest[MCP_SERVERS_KEY]) ? latest[MCP_SERVERS_KEY] : {};
|
|
264
|
+
const merged = { ...latestServers };
|
|
265
|
+
for (const [name, entry] of Object.entries(added)) if (!(name in merged)) merged[name] = entry;
|
|
266
|
+
await mkdir(dirname(configPath), { recursive: true });
|
|
267
|
+
await writeFile(configPath, `${JSON.stringify({ ...latest, [MCP_SERVERS_KEY]: merged }, null, 2)}
|
|
268
|
+
`, { encoding: "utf8", mode: 384 });
|
|
269
|
+
await chmod(configPath, 384).catch(quiet("agent/mcp/import"));
|
|
270
|
+
}
|
|
271
|
+
await mkdir(stateDir, { recursive: true });
|
|
272
|
+
await writeFile(markerPath, `${JSON.stringify({ ranAt: (/* @__PURE__ */ new Date()).toISOString(), imported, skipped }, null, 2)}
|
|
273
|
+
`, "utf8");
|
|
274
|
+
return { ran: true, imported, skipped };
|
|
275
|
+
}
|
|
276
|
+
function importNotice(result) {
|
|
277
|
+
if (!result.imported.length) return void 0;
|
|
278
|
+
const list = result.imported.map((server) => `${server.name} (${server.from})`).join(", ");
|
|
279
|
+
return `Imported ${result.imported.length} MCP server${result.imported.length === 1 ? "" : "s"} from your harness configs into mcp.json: ${list}`;
|
|
280
|
+
}
|
|
281
|
+
function stripJsonc(text) {
|
|
282
|
+
let out = "";
|
|
283
|
+
for (let i = 0; i < text.length; i++) {
|
|
284
|
+
const char = text[i];
|
|
285
|
+
if (char === '"') {
|
|
286
|
+
let j = i + 1;
|
|
287
|
+
while (j < text.length && text[j] !== '"') j += text[j] === "\\" ? 2 : 1;
|
|
288
|
+
out += text.slice(i, j + 1);
|
|
289
|
+
i = j;
|
|
290
|
+
} else if (char === "/" && text[i + 1] === "/") {
|
|
291
|
+
while (i < text.length && text[i] !== "\n") i++;
|
|
292
|
+
out += "\n";
|
|
293
|
+
} else if (char === "/" && text[i + 1] === "*") {
|
|
294
|
+
const end = text.indexOf("*/", i + 2);
|
|
295
|
+
i = end < 0 ? text.length : end + 1;
|
|
296
|
+
} else {
|
|
297
|
+
out += char;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return out.replace(/,(\s*[}\]])/g, "$1");
|
|
301
|
+
}
|
|
302
|
+
function parseToml(text) {
|
|
303
|
+
const root = {};
|
|
304
|
+
let current = root;
|
|
305
|
+
let i = 0;
|
|
306
|
+
const peek = (offset = 0) => text[i + offset] ?? "";
|
|
307
|
+
const skipSpace = (newlines) => {
|
|
308
|
+
for (; ; ) {
|
|
309
|
+
const char = peek();
|
|
310
|
+
if (char === " " || char === " " || char === "\r" || newlines && char === "\n") i++;
|
|
311
|
+
else if (char === "#") {
|
|
312
|
+
while (i < text.length && peek() !== "\n") i++;
|
|
313
|
+
} else return;
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
const fail = () => {
|
|
317
|
+
throw new Error(`TOML parse error at ${i}`);
|
|
318
|
+
};
|
|
319
|
+
const basicString = () => {
|
|
320
|
+
let value2 = "";
|
|
321
|
+
i++;
|
|
322
|
+
while (peek() !== '"') {
|
|
323
|
+
if (i >= text.length || peek() === "\n") fail();
|
|
324
|
+
if (peek() === "\\") {
|
|
325
|
+
const next = peek(1);
|
|
326
|
+
const escapes = { n: "\n", t: " ", r: "\r", '"': '"', "\\": "\\", b: "\b", f: "\f" };
|
|
327
|
+
if (next === "u" || next === "U") {
|
|
328
|
+
const length = next === "u" ? 4 : 8;
|
|
329
|
+
value2 += String.fromCodePoint(parseInt(text.slice(i + 2, i + 2 + length), 16));
|
|
330
|
+
i += 2 + length;
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
value2 += escapes[next] ?? fail();
|
|
334
|
+
i += 2;
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
value2 += peek();
|
|
338
|
+
i++;
|
|
339
|
+
}
|
|
340
|
+
i++;
|
|
341
|
+
return value2;
|
|
342
|
+
};
|
|
343
|
+
const delimited = (quote) => {
|
|
344
|
+
const end = text.indexOf(quote, i + quote.length);
|
|
345
|
+
if (end < 0) fail();
|
|
346
|
+
const value2 = text.slice(i + quote.length, end);
|
|
347
|
+
i = end + quote.length;
|
|
348
|
+
return quote.length === 3 ? value2.replace(/^\r?\n/, "") : value2;
|
|
349
|
+
};
|
|
350
|
+
const key = () => {
|
|
351
|
+
if (peek() === '"') return basicString();
|
|
352
|
+
if (peek() === "'") return delimited("'");
|
|
353
|
+
const match = /^[A-Za-z0-9_-]+/.exec(text.slice(i));
|
|
354
|
+
if (!match) fail();
|
|
355
|
+
i += match[0].length;
|
|
356
|
+
return match[0];
|
|
357
|
+
};
|
|
358
|
+
const keyPath = () => {
|
|
359
|
+
const path = [key()];
|
|
360
|
+
for (; ; ) {
|
|
361
|
+
skipSpace(false);
|
|
362
|
+
if (peek() !== ".") return path;
|
|
363
|
+
i++;
|
|
364
|
+
skipSpace(false);
|
|
365
|
+
path.push(key());
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
const table = (base, path) => {
|
|
369
|
+
let node = base;
|
|
370
|
+
for (const part of path) {
|
|
371
|
+
let next = node[part];
|
|
372
|
+
if (Array.isArray(next)) next = next[next.length - 1];
|
|
373
|
+
if (!isRecord(next)) {
|
|
374
|
+
next = {};
|
|
375
|
+
node[part] = next;
|
|
376
|
+
}
|
|
377
|
+
node = next;
|
|
378
|
+
}
|
|
379
|
+
return node;
|
|
380
|
+
};
|
|
381
|
+
const value = () => {
|
|
382
|
+
if (text.startsWith('"""', i)) return delimited('"""');
|
|
383
|
+
if (text.startsWith("'''", i)) return delimited("'''");
|
|
384
|
+
if (peek() === '"') return basicString();
|
|
385
|
+
if (peek() === "'") return delimited("'");
|
|
386
|
+
if (peek() === "[") {
|
|
387
|
+
i++;
|
|
388
|
+
const items = [];
|
|
389
|
+
for (; ; ) {
|
|
390
|
+
skipSpace(true);
|
|
391
|
+
if (peek() === "]") {
|
|
392
|
+
i++;
|
|
393
|
+
return items;
|
|
394
|
+
}
|
|
395
|
+
items.push(value());
|
|
396
|
+
skipSpace(true);
|
|
397
|
+
if (peek() === ",") i++;
|
|
398
|
+
else if (peek() !== "]") fail();
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (peek() === "{") {
|
|
402
|
+
i++;
|
|
403
|
+
const inline = {};
|
|
404
|
+
skipSpace(false);
|
|
405
|
+
if (peek() === "}") {
|
|
406
|
+
i++;
|
|
407
|
+
return inline;
|
|
408
|
+
}
|
|
409
|
+
for (; ; ) {
|
|
410
|
+
skipSpace(false);
|
|
411
|
+
const path = keyPath();
|
|
412
|
+
if (peek() !== "=") fail();
|
|
413
|
+
i++;
|
|
414
|
+
skipSpace(false);
|
|
415
|
+
table(inline, path.slice(0, -1))[path[path.length - 1]] = value();
|
|
416
|
+
skipSpace(false);
|
|
417
|
+
if (peek() === ",") {
|
|
418
|
+
i++;
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
if (peek() === "}") {
|
|
422
|
+
i++;
|
|
423
|
+
return inline;
|
|
424
|
+
}
|
|
425
|
+
fail();
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
const match = /^[-+0-9A-Za-z_:.]+/.exec(text.slice(i));
|
|
429
|
+
if (!match) fail();
|
|
430
|
+
i += match[0].length;
|
|
431
|
+
if (match[0] === "true") return true;
|
|
432
|
+
if (match[0] === "false") return false;
|
|
433
|
+
const number = Number(match[0].replace(/_/g, ""));
|
|
434
|
+
return Number.isNaN(number) ? match[0] : number;
|
|
435
|
+
};
|
|
436
|
+
while (i < text.length) {
|
|
437
|
+
skipSpace(true);
|
|
438
|
+
if (i >= text.length) break;
|
|
439
|
+
const start = i;
|
|
440
|
+
try {
|
|
441
|
+
if (text.startsWith("[[", i)) {
|
|
442
|
+
i += 2;
|
|
443
|
+
skipSpace(false);
|
|
444
|
+
const path = keyPath();
|
|
445
|
+
if (!text.startsWith("]]", i)) fail();
|
|
446
|
+
i += 2;
|
|
447
|
+
const parent = table(root, path.slice(0, -1));
|
|
448
|
+
const last = path[path.length - 1];
|
|
449
|
+
const list = Array.isArray(parent[last]) ? parent[last] : parent[last] = [];
|
|
450
|
+
current = {};
|
|
451
|
+
list.push(current);
|
|
452
|
+
} else if (peek() === "[") {
|
|
453
|
+
i++;
|
|
454
|
+
skipSpace(false);
|
|
455
|
+
const path = keyPath();
|
|
456
|
+
if (peek() !== "]") fail();
|
|
457
|
+
i++;
|
|
458
|
+
current = table(root, path);
|
|
459
|
+
} else {
|
|
460
|
+
const path = keyPath();
|
|
461
|
+
if (peek() !== "=") fail();
|
|
462
|
+
i++;
|
|
463
|
+
skipSpace(false);
|
|
464
|
+
table(current, path.slice(0, -1))[path[path.length - 1]] = value();
|
|
465
|
+
}
|
|
466
|
+
skipSpace(false);
|
|
467
|
+
if (i < text.length && peek() !== "\n") fail();
|
|
468
|
+
} catch {
|
|
469
|
+
i = Math.max(i, start + 1);
|
|
470
|
+
while (i < text.length && peek() !== "\n") i++;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
return root;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
export {
|
|
477
|
+
vendorSources,
|
|
478
|
+
vendorMcpServerNames,
|
|
479
|
+
vendorConfigFiles,
|
|
480
|
+
importVendorMcpServers,
|
|
481
|
+
importNotice,
|
|
482
|
+
stripJsonc
|
|
483
|
+
};
|