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,626 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
runCli
|
|
5
|
+
} from "./chunk-PWBF2X3V.js";
|
|
6
|
+
import {
|
|
7
|
+
sleep
|
|
8
|
+
} from "./chunk-YMCH3L2S.js";
|
|
9
|
+
import {
|
|
10
|
+
namedSecretNames,
|
|
11
|
+
readNamedSecret
|
|
12
|
+
} from "./chunk-I75EDU75.js";
|
|
13
|
+
import {
|
|
14
|
+
objectOrEmpty,
|
|
15
|
+
updateJsonFile
|
|
16
|
+
} from "./chunk-PAXYQZH7.js";
|
|
17
|
+
import {
|
|
18
|
+
quiet,
|
|
19
|
+
swallowed
|
|
20
|
+
} from "./chunk-RDDWQBEM.js";
|
|
21
|
+
import {
|
|
22
|
+
scrubSecrets
|
|
23
|
+
} from "./chunk-CBANJFBO.js";
|
|
24
|
+
|
|
25
|
+
// src/agent/computer/secret-destinations.ts
|
|
26
|
+
import fs2 from "node:fs/promises";
|
|
27
|
+
import path2 from "node:path";
|
|
28
|
+
|
|
29
|
+
// src/agent/computer/cli-stdin-support.ts
|
|
30
|
+
import fs from "node:fs";
|
|
31
|
+
import path from "node:path";
|
|
32
|
+
var STDIN_ARGS_JSON_MIN_VERSION = "1.0.35";
|
|
33
|
+
function parseCliVersion(text) {
|
|
34
|
+
const match = /(\d+)\.(\d+)\.(\d+)/.exec(text);
|
|
35
|
+
return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : void 0;
|
|
36
|
+
}
|
|
37
|
+
function versionAtLeast(text, min = STDIN_ARGS_JSON_MIN_VERSION) {
|
|
38
|
+
const have = parseCliVersion(text);
|
|
39
|
+
const need = parseCliVersion(min);
|
|
40
|
+
if (!have) return false;
|
|
41
|
+
for (let i = 0; i < 3; i++) if (have[i] !== need[i]) return have[i] > need[i];
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
function resolveOnPath(command) {
|
|
45
|
+
for (const entry of (process.env.PATH ?? "").split(path.delimiter)) {
|
|
46
|
+
if (!entry) continue;
|
|
47
|
+
const candidate = path.join(entry, command);
|
|
48
|
+
try {
|
|
49
|
+
fs.accessSync(candidate, fs.constants.X_OK);
|
|
50
|
+
if (fs.statSync(candidate).isFile()) return candidate;
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
var cache = /* @__PURE__ */ new Map();
|
|
57
|
+
var VERSION_CHECK_TIMEOUT_MS = 45e3;
|
|
58
|
+
async function cliStdinSupport(command, signal, options = {}) {
|
|
59
|
+
const found = resolveOnPath(command);
|
|
60
|
+
if (!found) return "missing";
|
|
61
|
+
let key = found;
|
|
62
|
+
try {
|
|
63
|
+
key = `${found}:${fs.statSync(found).mtimeMs}`;
|
|
64
|
+
} catch {
|
|
65
|
+
}
|
|
66
|
+
const known = cache.get(key);
|
|
67
|
+
if (known !== void 0) return known;
|
|
68
|
+
const result = await runCli(command, ["--version"], { signal, timeoutMs: options.timeoutMs ?? VERSION_CHECK_TIMEOUT_MS, maxChars: 2e3 });
|
|
69
|
+
if (result.missing) return "missing";
|
|
70
|
+
if (result.code !== 0 || !parseCliVersion(result.text)) return "unknown";
|
|
71
|
+
const answer = versionAtLeast(result.text) ? "yes" : "old";
|
|
72
|
+
cache.set(key, answer);
|
|
73
|
+
return answer;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// src/agent/computer/secret-destinations.ts
|
|
77
|
+
var VENDOR_MFA_DESTINATION = "clikdeploy-vendor-mfa";
|
|
78
|
+
var JSON_ARGS = (fields) => `{${fields}}`;
|
|
79
|
+
var DEFAULT_DESTINATIONS = {
|
|
80
|
+
"clikdeploy-secret": {
|
|
81
|
+
about: "a ClikDeploy platform secret (key)",
|
|
82
|
+
run: ["clikdeploy", "tools", "run", "admin_platform_set_secret", "--args-json", "-", "--confirm"],
|
|
83
|
+
stdin: JSON_ARGS('"key":"{{key}}","value":"{{secret|json}}"')
|
|
84
|
+
},
|
|
85
|
+
"clikdeploy-app-secret": {
|
|
86
|
+
about: "a ClikDeploy app secret (app, key)",
|
|
87
|
+
run: ["clikdeploy", "tools", "run", "set_secret", "--args-json", "-", "--confirm"],
|
|
88
|
+
stdin: JSON_ARGS('"appId":"{{app}}","key":"{{key}}","value":"{{secret|json}}"')
|
|
89
|
+
},
|
|
90
|
+
"clikdeploy-compute": {
|
|
91
|
+
about: "one field of a ClikDeploy compute provider card (provider, field)",
|
|
92
|
+
run: ["clikdeploy", "tools", "run", "admin_compute_save_credentials", "--args-json", "-", "--confirm"],
|
|
93
|
+
stdin: JSON_ARGS('"provider":"{{provider}}","credentials":{"{{field}}":"{{secret|json}}"}')
|
|
94
|
+
},
|
|
95
|
+
// The secret is the OAuth client secret; the client id is not one and is a slot. Adding needs only the admin's
|
|
96
|
+
// API key (the CLI's own sign-in): no code and no password, as long as the connector has no client stored.
|
|
97
|
+
"clikdeploy-connector": {
|
|
98
|
+
about: "a ClikDeploy connector's OAuth app (integration, client_id); the key is its client secret; client_id may be secret:<saved name>",
|
|
99
|
+
vaultSlots: ["client_id"],
|
|
100
|
+
run: ["clikdeploy", "tools", "run", "admin_platform_save_connector_credentials", "--args-json", "-", "--confirm"],
|
|
101
|
+
stdin: JSON_ARGS('"integrationId":"{{integration}}","clientId":"{{client_id}}","clientSecret":"{{secret|json}}"')
|
|
102
|
+
},
|
|
103
|
+
// A provider organization's usage key (an Anthropic Admin key). It never serves a call; ClikDeploy tests it with the vendor
|
|
104
|
+
// before saving and refuses it with the vendor's reason. The admin's own API key is enough: no password.
|
|
105
|
+
"clikdeploy-usage-reader": {
|
|
106
|
+
about: "file the usage key of an AI provider organization in ClikDeploy (provider, e.g. anthropic; label optional); ClikDeploy tests it with the vendor and saves nothing if the vendor refuses it",
|
|
107
|
+
optionalSlots: ["label"],
|
|
108
|
+
run: ["clikdeploy", "tools", "run", "admin_ai_manage", "--args-json", "-", "--confirm"],
|
|
109
|
+
stdin: JSON_ARGS('"action":"add_usage_reader","provider":"{{provider}}","secret":"{{secret|json}}","label":"{{label}}"')
|
|
110
|
+
},
|
|
111
|
+
"clikdeploy-connection": {
|
|
112
|
+
about: "connect an API key to a ClikDeploy connector (integration) for the signed-in account; the result is `connected` or `NOT connected: <reason>`, read back from ClikDeploy",
|
|
113
|
+
verify: "connection",
|
|
114
|
+
run: ["clikdeploy", "tools", "run", "connect_connector", "--args-json", "-", "--confirm"],
|
|
115
|
+
stdin: JSON_ARGS('"integrationId":"{{integration}}","apiKey":"{{secret|json}}"')
|
|
116
|
+
},
|
|
117
|
+
// Some vendors expose a token id as the basic-auth username. It can be read from the vault at send time.
|
|
118
|
+
"clikdeploy-connection-basic": {
|
|
119
|
+
about: "connect a username and password to a ClikDeploy connector (integration, username; username may be secret:<saved name>); the result is `connected` or `NOT connected: <reason>`",
|
|
120
|
+
vaultSlots: ["username"],
|
|
121
|
+
verify: "connection",
|
|
122
|
+
run: ["clikdeploy", "tools", "run", "connect_connector", "--args-json", "-", "--confirm"],
|
|
123
|
+
stdin: JSON_ARGS('"integrationId":"{{integration}}","username":"{{username}}","password":"{{secret|json}}"')
|
|
124
|
+
},
|
|
125
|
+
// The vendor gives one key and it is the basic-auth username (BugHerd, HTML/CSS to Image): the password is blank unless one is given.
|
|
126
|
+
"clikdeploy-connection-basic-key": {
|
|
127
|
+
about: "connect a key that is the basic-auth USERNAME to a ClikDeploy connector (integration; password optional, blank by default); the result is `connected` or `NOT connected: <reason>`",
|
|
128
|
+
optionalSlots: ["password"],
|
|
129
|
+
verify: "connection",
|
|
130
|
+
run: ["clikdeploy", "tools", "run", "connect_connector", "--args-json", "-", "--confirm"],
|
|
131
|
+
stdin: JSON_ARGS('"integrationId":"{{integration}}","username":"{{secret|json}}","password":"{{password}}"')
|
|
132
|
+
},
|
|
133
|
+
// The captured value is a TOTP authenticator seed (a base32 key or an otpauth:// URI) for one of the
|
|
134
|
+
// owner's vendor accounts (account, e.g. "aws/root"). ClikDeploy stores it encrypted and hands out
|
|
135
|
+
// only the rolling code (auth_code / admin_vendor_mfa_code), never the seed. The admin's own API key
|
|
136
|
+
// is enough to store it during an account setup.
|
|
137
|
+
"clikdeploy-vendor-mfa": {
|
|
138
|
+
about: 'store a vendor authenticator seed in ClikDeploy (account, e.g. "aws/root"; label optional, no spaces); only the rolling code is ever handed out, never the seed',
|
|
139
|
+
optionalSlots: ["label"],
|
|
140
|
+
run: ["clikdeploy", "tools", "run", "admin_vendor_mfa_store", "--args-json", "-", "--confirm"],
|
|
141
|
+
stdin: JSON_ARGS('"account":"{{account}}","seed":"{{secret|json}}","label":"{{label}}"')
|
|
142
|
+
},
|
|
143
|
+
"github-secret": { about: "a GitHub repository secret (repo, key)", run: ["gh", "secret", "set", "{{key}}", "--repo", "{{repo}}"], stdin: "{{secret}}" },
|
|
144
|
+
// A harness's own API key (OpenCode's, from opencode.ai/auth) signed into a ClikCode account on this machine: the sign-in reads it
|
|
145
|
+
// from stdin as a pasted key, so it is never on screen. `label`: the account to sign in again (left out: the harness's only one
|
|
146
|
+
// that needs a sign-in, else a new account).
|
|
147
|
+
"clikcode-account": {
|
|
148
|
+
about: "sign a ClikCode harness account in with this key (harness, e.g. opencode; label optional: the account to sign in again)",
|
|
149
|
+
optionalSlots: ["label"],
|
|
150
|
+
run: ["clikcode", "accounts", "login", "{{harness}}", "--label", "{{label}}"],
|
|
151
|
+
stdin: "{{secret}}\n"
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
var CONNECTION_TO = /* @__PURE__ */ new Set(["clikdeploy-connection", "clikdeploy-connection-basic", "clikdeploy-connection-basic-key"]);
|
|
155
|
+
var CONNECTION_SLOTS = /* @__PURE__ */ new Set(["integration", "username", "password"]);
|
|
156
|
+
function normalizeSendTo(value) {
|
|
157
|
+
const plain = (item) => {
|
|
158
|
+
if (!item || typeof item !== "object") return item;
|
|
159
|
+
const { values, ...first } = item;
|
|
160
|
+
let rest = first;
|
|
161
|
+
let connectionValues = rest.connectionValues ?? values;
|
|
162
|
+
if (CONNECTION_TO.has(rest.to) && rest.with && typeof rest.with === "object") {
|
|
163
|
+
const slots = {};
|
|
164
|
+
const extra = {};
|
|
165
|
+
for (const [name, v] of Object.entries(rest.with)) (CONNECTION_SLOTS.has(name) ? slots : extra)[name] = v;
|
|
166
|
+
if (Object.keys(extra).length) {
|
|
167
|
+
const given = typeof connectionValues === "string" ? (() => {
|
|
168
|
+
try {
|
|
169
|
+
return JSON.parse(connectionValues);
|
|
170
|
+
} catch {
|
|
171
|
+
return void 0;
|
|
172
|
+
}
|
|
173
|
+
})() : connectionValues;
|
|
174
|
+
if (given && typeof given === "object") {
|
|
175
|
+
connectionValues = { ...extra, ...given };
|
|
176
|
+
rest = { ...rest, with: slots };
|
|
177
|
+
} else if (connectionValues === void 0) {
|
|
178
|
+
connectionValues = extra;
|
|
179
|
+
rest = { ...rest, with: slots };
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return connectionValues === void 0 ? rest : { ...rest, connectionValues };
|
|
184
|
+
};
|
|
185
|
+
if (Array.isArray(value)) return value.map(plain);
|
|
186
|
+
if (typeof value === "string" && /^\s*[[{]/.test(value)) {
|
|
187
|
+
try {
|
|
188
|
+
return normalizeSendTo(JSON.parse(value));
|
|
189
|
+
} catch {
|
|
190
|
+
return void 0;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (typeof value === "string" && value) return [{ to: value }];
|
|
194
|
+
if (value && typeof value === "object") return [plain(value)];
|
|
195
|
+
return void 0;
|
|
196
|
+
}
|
|
197
|
+
var EXAMPLE = 'Example: {"to":"clikdeploy-secret","with":{"key":"SALAD_API_KEY"}}';
|
|
198
|
+
var NAME = /^[a-z][a-z0-9-]{1,40}$/;
|
|
199
|
+
var SAFE_VALUE = /^[A-Za-z0-9_][\w.@:/ -]{0,119}$/;
|
|
200
|
+
var VAULT_REF = /^secret:([A-Za-z0-9][\w./-]{0,80})$/;
|
|
201
|
+
var VALUE_NAME = /^[A-Za-z_][\w-]{0,40}$/;
|
|
202
|
+
var VALUE_TEXT = /^(?!https?:\/\/)[^\s\u0000-\u001f\u007f]{1,256}$/i;
|
|
203
|
+
var VALUE_FORMAT = "short plain text with no spaces (an id, a region, an account email), not a web address";
|
|
204
|
+
function readConnectionValues(raw) {
|
|
205
|
+
if (raw === void 0 || raw === null || raw === "") return {};
|
|
206
|
+
let map = raw;
|
|
207
|
+
if (typeof map === "string") {
|
|
208
|
+
try {
|
|
209
|
+
map = JSON.parse(map);
|
|
210
|
+
} catch {
|
|
211
|
+
return { problem: 'connectionValues must be a map such as {"app_id":"WJUQDEJ3SG"}.' };
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (!map || typeof map !== "object" || Array.isArray(map)) return { problem: 'connectionValues must be a map such as {"app_id":"WJUQDEJ3SG"}.' };
|
|
215
|
+
const values = {};
|
|
216
|
+
for (const [name, value] of Object.entries(map)) {
|
|
217
|
+
if (!VALUE_NAME.test(name)) return { problem: `connectionValues has a name "${name.slice(0, 41)}" that is not a plain identifier.` };
|
|
218
|
+
if (typeof value === "string" && VAULT_REF.test(value.trim())) {
|
|
219
|
+
values[name] = value.trim();
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (typeof value !== "string" || !VALUE_TEXT.test(value.trim())) return { problem: `connectionValues.${name} must be ${VALUE_FORMAT}, or secret:<saved name> for a value saved earlier (read_value, capture_secret).` };
|
|
223
|
+
values[name] = value.trim();
|
|
224
|
+
}
|
|
225
|
+
return { values };
|
|
226
|
+
}
|
|
227
|
+
var takesConnectionValues = (template) => template.verify === "connection";
|
|
228
|
+
var SLOT = /\{\{([a-z][a-z0-9_]*)(\|json)?\}\}/g;
|
|
229
|
+
var destinationsFile = (stateDir) => path2.join(stateDir, "computer", "destinations.json");
|
|
230
|
+
async function loadDestinations(stateDir) {
|
|
231
|
+
let own = {};
|
|
232
|
+
try {
|
|
233
|
+
own = JSON.parse(await fs2.readFile(destinationsFile(stateDir), "utf8"));
|
|
234
|
+
} catch (error) {
|
|
235
|
+
swallowed("agent/computer/secret-destinations", error);
|
|
236
|
+
}
|
|
237
|
+
const merged = { ...DEFAULT_DESTINATIONS, ...own };
|
|
238
|
+
for (const [name, template] of Object.entries(merged)) {
|
|
239
|
+
if (template.verify || !template.run.includes("connect_connector") || !slotsOf(template).includes("integration")) continue;
|
|
240
|
+
merged[name] = { ...template, verify: "connection" };
|
|
241
|
+
}
|
|
242
|
+
return merged;
|
|
243
|
+
}
|
|
244
|
+
function slotsOf(template) {
|
|
245
|
+
const text = [...template.run, template.stdin ?? ""].join("\n");
|
|
246
|
+
return [...new Set([...text.matchAll(SLOT)].map((match) => match[1]))].filter((slot) => slot !== "secret");
|
|
247
|
+
}
|
|
248
|
+
var carriesSecret = (template) => [...template.run, template.stdin ?? ""].some((part) => part.includes("{{secret}}") || part.includes("{{secret|json}}"));
|
|
249
|
+
async function addDestination(stateDir, name, template) {
|
|
250
|
+
if (!NAME.test(name)) throw new Error("A destination name is lower-case letters, digits and dashes, such as my-vault.");
|
|
251
|
+
if (!template.run.length || !template.run[0]) throw new Error("A destination needs a command to run.");
|
|
252
|
+
if (!carriesSecret(template)) throw new Error("A destination needs {{secret}} in its command (or its stdin), or the key is never sent.");
|
|
253
|
+
await updateJsonFile(destinationsFile(stateDir), (raw) => objectOrEmpty(raw), (own) => ({ ...own, [name]: template }));
|
|
254
|
+
}
|
|
255
|
+
async function removeDestination(stateDir, name) {
|
|
256
|
+
let removed = false;
|
|
257
|
+
await updateJsonFile(destinationsFile(stateDir), (raw) => objectOrEmpty(raw), (own) => {
|
|
258
|
+
if (!(name in own)) return void 0;
|
|
259
|
+
removed = true;
|
|
260
|
+
const { [name]: _gone, ...rest } = own;
|
|
261
|
+
return rest;
|
|
262
|
+
});
|
|
263
|
+
return removed;
|
|
264
|
+
}
|
|
265
|
+
var describeKnown = (all) => Object.entries(all).map(([name, template]) => `${name}${slotsOf(template).length ? `(${slotsOf(template).join(", ")})` : ""}${template.about ? ` - ${template.about}` : ""}`).join("; ");
|
|
266
|
+
async function declaredConnectionValues(integration, signal) {
|
|
267
|
+
const shown = await runCli("clikdeploy", ["integrations", "show", integration], { signal, timeoutMs: 3e4, maxChars: 4e6 });
|
|
268
|
+
if (shown.missing) return void 0;
|
|
269
|
+
const parsed = firstJsonObject(shown.text);
|
|
270
|
+
const proxy = parsed?.status === "error" ? void 0 : parsed?.data?.proxy;
|
|
271
|
+
if (!proxy || typeof proxy !== "object") return void 0;
|
|
272
|
+
const variables = proxy.variables && typeof proxy.variables === "object" ? proxy.variables : {};
|
|
273
|
+
const template = typeof proxy.base_url === "string" ? proxy.base_url : "";
|
|
274
|
+
return Object.fromEntries(Object.entries(variables).map(([name, v]) => [name, { ...v, required: !v.optional && v.default === void 0 && template.includes(`{${name}}`) }]));
|
|
275
|
+
}
|
|
276
|
+
var mfaReason = (node) => node.reason || (typeof node.error === "string" ? node.error : node.error?.message) || node.message;
|
|
277
|
+
async function vendorMfaCode(account, signal) {
|
|
278
|
+
if (!account.trim()) return { error: "no account given" };
|
|
279
|
+
const shown = await runCli("clikdeploy", ["tools", "run", "admin_vendor_mfa_code", "--args-json", JSON.stringify({ account: account.trim() })], { signal, timeoutMs: 3e4, maxChars: 1e6 });
|
|
280
|
+
if (shown.missing) return { error: "the clikdeploy CLI is not installed on this machine" };
|
|
281
|
+
const parsed = firstJsonObject(shown.text);
|
|
282
|
+
if (!parsed) return { error: "ClikDeploy returned nothing readable" };
|
|
283
|
+
const envelope = parsed.data && typeof parsed.data === "object" ? parsed.data : parsed;
|
|
284
|
+
const inner = envelope.data && typeof envelope.data === "object" ? envelope.data : envelope;
|
|
285
|
+
if (parsed.status === "error" || envelope.status === "error" || typeof inner.code !== "string") {
|
|
286
|
+
return { error: mfaReason(envelope) || mfaReason(parsed) || "no code was returned (is the account stored, and does this key own it?)" };
|
|
287
|
+
}
|
|
288
|
+
return { code: inner.code, secondsRemaining: typeof inner.secondsRemaining === "number" ? inner.secondsRemaining : 30 };
|
|
289
|
+
}
|
|
290
|
+
async function vendorMfaAccounts(signal) {
|
|
291
|
+
const shown = await runCli("clikdeploy", ["tools", "run", "admin_vendor_mfa_list"], { signal, timeoutMs: 3e4, maxChars: 1e6 });
|
|
292
|
+
if (shown.missing) return [];
|
|
293
|
+
const parsed = firstJsonObject(shown.text);
|
|
294
|
+
if (!parsed || parsed.status === "error") return [];
|
|
295
|
+
return (parsed.data?.data?.accounts ?? []).map((row) => row.account).filter((account) => typeof account === "string");
|
|
296
|
+
}
|
|
297
|
+
function vendorMfaAccountFor(siteUrl, accounts) {
|
|
298
|
+
let labels;
|
|
299
|
+
try {
|
|
300
|
+
labels = new URL(siteUrl).hostname.toLowerCase().split(".");
|
|
301
|
+
} catch {
|
|
302
|
+
return void 0;
|
|
303
|
+
}
|
|
304
|
+
const matches = accounts.filter((account) => {
|
|
305
|
+
const vendor = account.split("/")[0].toLowerCase();
|
|
306
|
+
return vendor.length >= 3 && labels.includes(vendor);
|
|
307
|
+
});
|
|
308
|
+
return matches.length === 1 ? matches[0] : void 0;
|
|
309
|
+
}
|
|
310
|
+
var ACCEPTS = { "api-key": ["clikdeploy-connection"], basic: ["clikdeploy-connection-basic", "clikdeploy-connection-basic-key"], custom: [], "aws-sigv4": ["clikdeploy-connection"], oauth: ["clikdeploy-connection"] };
|
|
311
|
+
async function declaredCustomProps(integration, signal) {
|
|
312
|
+
const stored = await runCli("clikdeploy", ["tools", "run", "connector_spec_get", "--args-json", JSON.stringify({ id: integration })], { signal, timeoutMs: 2e4, maxChars: 4e6 });
|
|
313
|
+
const auth = firstJsonObject(stored.text)?.data?.data?.spec?.auth;
|
|
314
|
+
if (!auth?.kind || !["custom", "jwt", "oauth1", "mtls"].includes(auth.kind) || !auth.custom?.props || !Object.keys(auth.custom.props).length) return void 0;
|
|
315
|
+
return { kind: auth.kind, props: auth.custom.props };
|
|
316
|
+
}
|
|
317
|
+
function customAuthBody(custom, key, values, prop) {
|
|
318
|
+
const names = Object.keys(custom.props);
|
|
319
|
+
const secrets = names.filter((n) => custom.props[n].secret || custom.props[n].type === "secret");
|
|
320
|
+
const target = prop ?? (secrets.length === 1 ? secrets[0] : names.length === 1 ? names[0] : void 0);
|
|
321
|
+
const describe = names.map((n) => `${n}${custom.props[n].secret || custom.props[n].type === "secret" ? " (secret)" : ""}${custom.props[n].required ? "" : " (optional)"}`).join(", ");
|
|
322
|
+
if (!target || !names.includes(target)) return { problem: `declares ${custom.kind} auth with props ${describe}: say which one the captured key is with with.prop, and give the others as values ({"name": "text" or "secret:<saved name>"}).` };
|
|
323
|
+
const props = { [target]: key };
|
|
324
|
+
const rest = {};
|
|
325
|
+
for (const [name, v] of Object.entries(values)) (names.includes(name) ? props : rest)[name] = v;
|
|
326
|
+
const missing = names.filter((n) => custom.props[n].required && !props[n]);
|
|
327
|
+
if (missing.length) return { problem: `declares ${custom.kind} auth with props ${describe}; the captured key went to ${target}, and ${missing.join(", ")} ${missing.length === 1 ? "is" : "are"} still needed: give ${missing.length === 1 ? "it" : "them"} as values ({"${missing[0]}": "text" or "secret:<saved name>"}).` };
|
|
328
|
+
return { props, rest };
|
|
329
|
+
}
|
|
330
|
+
function describeShapes(integration, kind) {
|
|
331
|
+
const shapes = {
|
|
332
|
+
"api-key": `{"to":"clikdeploy-connection","with":{"integration":"${integration}"}} (the captured key is the API key)`,
|
|
333
|
+
oauth: `{"to":"clikdeploy-connection","with":{"integration":"${integration}"}} (the captured key is a token; the connector may prefer oauth_connect)`,
|
|
334
|
+
basic: `{"to":"clikdeploy-connection-basic","with":{"integration":"${integration}","username":"<name or secret:<saved name>>"}} (the captured key is the PASSWORD), or {"to":"clikdeploy-connection-basic-key","with":{"integration":"${integration}"}} (the captured key is the USERNAME; add "password" for a fixed one, else blank)`,
|
|
335
|
+
"aws-sigv4": `a saved accessKeyId/secretAccessKey pair, optionally sessionToken, packed as JSON and sent through clikdeploy-connection for ${integration}`,
|
|
336
|
+
custom: `named props: the captured key fills the secret prop (with.prop names it when there are several), and the other props go as values, e.g. {"to":"clikdeploy-connection","with":{"integration":"${integration}","prop":"app_secret"},"connectionValues":{"app_id":"secret:<saved name>"}}`,
|
|
337
|
+
jwt: `named props, like custom auth: the captured key fills the secret prop, the public one goes as a value`
|
|
338
|
+
};
|
|
339
|
+
return `${integration} declares ${kind} auth. Accepted: ${shapes[kind] ?? `none of the known shapes (auth kind "${kind}")`}.`;
|
|
340
|
+
}
|
|
341
|
+
async function declaredAuthKind(integration, signal) {
|
|
342
|
+
const shown = await runCli("clikdeploy", ["integrations", "show", integration], { signal, timeoutMs: 3e4, maxChars: 4e6 });
|
|
343
|
+
if (shown.missing) return void 0;
|
|
344
|
+
const parsed = firstJsonObject(shown.text);
|
|
345
|
+
const kind = parsed?.status === "error" ? void 0 : parsed?.data?.auth?.kind;
|
|
346
|
+
if (kind !== "custom" || !integration.startsWith("amazonaws-")) return kind;
|
|
347
|
+
const stored = await runCli("clikdeploy", ["tools", "run", "connector_spec_get", "--args-json", JSON.stringify({ id: integration })], { signal, timeoutMs: 2e4, maxChars: 4e6 });
|
|
348
|
+
const spec = firstJsonObject(stored.text)?.data?.data?.spec;
|
|
349
|
+
return spec?.auth?.signing?.scheme === "aws-sigv4" ? "aws-sigv4" : kind;
|
|
350
|
+
}
|
|
351
|
+
function describeDeclared(integration, declared) {
|
|
352
|
+
const names = Object.entries(declared).map(([name, info]) => `${name}${info.label ? ` (${info.label}${info.description ? `: ${info.description}` : ""})` : ""}`);
|
|
353
|
+
return names.length ? `${integration} takes these values: ${names.join("; ")}. Each is ${VALUE_FORMAT}.` : `${integration} takes no values.`;
|
|
354
|
+
}
|
|
355
|
+
async function destinationProblem(stateDir, list, declared, authKind) {
|
|
356
|
+
const all = await loadDestinations(stateDir);
|
|
357
|
+
for (const [index, item] of list.entries()) {
|
|
358
|
+
const at = `send_to[${index}]`;
|
|
359
|
+
const d = item;
|
|
360
|
+
if (!d || typeof d !== "object" || typeof d.to !== "string") return `${at} needs {to: "<destination>", with: {...}}. ${EXAMPLE}`;
|
|
361
|
+
const template = all[d.to];
|
|
362
|
+
if (!template) return `${at}: no destination named "${d.to}". Known: ${describeKnown(all)}. The user adds more with \`clikcode computer destination add\`. ${EXAMPLE}`;
|
|
363
|
+
if (d.connectionValues !== void 0) {
|
|
364
|
+
if (!takesConnectionValues(template)) return `${at}: connectionValues only goes with clikdeploy-connection or clikdeploy-connection-basic, not "${d.to}".`;
|
|
365
|
+
const read = readConnectionValues(d.connectionValues);
|
|
366
|
+
if (read.problem) return `${at}: ${read.problem}`;
|
|
367
|
+
const refs = Object.entries(read.values ?? {}).flatMap(([name, v]) => {
|
|
368
|
+
const m = VAULT_REF.exec(v);
|
|
369
|
+
return m ? [[name, m[1]]] : [];
|
|
370
|
+
});
|
|
371
|
+
if (refs.length) {
|
|
372
|
+
const have = await namedSecretNames(stateDir).catch(() => []);
|
|
373
|
+
const lost = refs.find(([, saved2]) => !have.includes(saved2));
|
|
374
|
+
if (lost) return `${at}: values.${lost[0]} names a saved secret "${lost[1]}" that is not in the Secrets Manager.`;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (authKind && takesConnectionValues(template) && typeof d.with?.integration === "string" && SAFE_VALUE.test(d.with.integration)) {
|
|
378
|
+
const kind = await authKind(d.with.integration).catch(quiet("agent/computer/secret-destinations"));
|
|
379
|
+
if (kind && kind in ACCEPTS && !ACCEPTS[kind].includes(d.to)) return `${at}: ${d.to} does not fit ${d.with.integration}. ${describeShapes(d.with.integration, kind)}`;
|
|
380
|
+
}
|
|
381
|
+
if (declared && takesConnectionValues(template) && typeof d.with?.integration === "string" && SAFE_VALUE.test(d.with.integration)) {
|
|
382
|
+
const known = await declared(d.with.integration).catch(quiet("agent/computer/secret-destinations"));
|
|
383
|
+
if (known) {
|
|
384
|
+
const given = Object.keys(readConnectionValues(d.connectionValues).values ?? {});
|
|
385
|
+
const unknown = given.filter((name) => !(name in known));
|
|
386
|
+
const missing = Object.entries(known).filter(([name, info]) => info.required !== false && !given.includes(name)).map(([name]) => name);
|
|
387
|
+
if (unknown.length || missing.length) return `${at}: ${unknown.length ? `values has ${unknown.join(", ")}, which ${d.with.integration} does not take` : `${d.with.integration} needs a value for ${missing.join(", ")}`}. ${describeDeclared(d.with.integration, known)} Example: {"to":"${d.to}","with":{"integration":"${d.with.integration}"},"values":{${Object.keys(known).map((name) => `"${name}":"..."`).join(",")}}}`;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
const saved = template.vaultSlots?.length ? await namedSecretNames(stateDir).catch(() => []) : [];
|
|
391
|
+
for (const slot of slotsOf(template)) {
|
|
392
|
+
const value = d.with?.[slot];
|
|
393
|
+
const ref = typeof value === "string" && template.vaultSlots?.includes(slot) ? VAULT_REF.exec(value) : null;
|
|
394
|
+
if (ref) {
|
|
395
|
+
if (!saved.includes(ref[1])) return `${at}: with.${slot} names a saved secret "${ref[1]}" that is not in the Secrets Manager.`;
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
if (template.optionalSlots?.includes(slot) && (value === void 0 || value === "")) continue;
|
|
399
|
+
if (typeof value === "string" && value && template.optionalSlots?.includes(slot) && !SAFE_VALUE.test(value)) return `${at}: "${d.to}" takes with.${slot} only as letters, digits, dot, dash, underscore and slash, with no spaces (it is optional: leave it out, or write it like "acme-console").`;
|
|
400
|
+
if (typeof value !== "string" || !SAFE_VALUE.test(value)) return `${at}: "${d.to}" needs with.${slot} (letters, digits, dot, dash, underscore, slash; not starting with a dash). ${EXAMPLE}`;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return void 0;
|
|
404
|
+
}
|
|
405
|
+
function fill(text, params, secret) {
|
|
406
|
+
return text.replace(SLOT, (_all, slot, json) => slot === "secret" ? json ? JSON.stringify(secret).slice(1, -1) : secret : params[slot] ?? "");
|
|
407
|
+
}
|
|
408
|
+
var say = (text) => {
|
|
409
|
+
const start = text.indexOf("{");
|
|
410
|
+
if (start >= 0) {
|
|
411
|
+
try {
|
|
412
|
+
const parsed = JSON.parse(text.slice(start));
|
|
413
|
+
const failure = typeof parsed.error === "object" ? parsed.error.message ?? parsed.error.code : parsed.error;
|
|
414
|
+
const inner = typeof parsed.data?.error === "object" ? parsed.data.error.message : parsed.data?.error;
|
|
415
|
+
const line = [parsed.message ?? failure ?? parsed.data?.message ?? inner, parsed.data?.appliedToWebProcess !== void 0 ? `appliedToWebProcess=${parsed.data.appliedToWebProcess}` : "", parsed.data?.reloadReason].filter(Boolean).join(" \xB7 ");
|
|
416
|
+
return line;
|
|
417
|
+
} catch {
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return text.trim().split("\n").slice(-3).join(" ").slice(0, 300);
|
|
421
|
+
};
|
|
422
|
+
function firstJsonObject(text) {
|
|
423
|
+
for (let at = text.indexOf("{"); at >= 0; at = text.indexOf("{", at + 1)) {
|
|
424
|
+
if (at > 0 && text[at - 1] !== "\n") continue;
|
|
425
|
+
try {
|
|
426
|
+
const value = JSON.parse(text.slice(at));
|
|
427
|
+
if (value && typeof value === "object") return value;
|
|
428
|
+
} catch {
|
|
429
|
+
}
|
|
430
|
+
const end = text.lastIndexOf("}");
|
|
431
|
+
if (end > at) {
|
|
432
|
+
try {
|
|
433
|
+
const value = JSON.parse(text.slice(at, end + 1));
|
|
434
|
+
if (value && typeof value === "object") return value;
|
|
435
|
+
} catch {
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return void 0;
|
|
440
|
+
}
|
|
441
|
+
async function connectionState(integration, signal) {
|
|
442
|
+
const shown = await runCli("clikdeploy", ["integrations", "show", integration], { signal, timeoutMs: 6e4, maxChars: 4e6 });
|
|
443
|
+
if (shown.missing) return { connected: false, reason: "the clikdeploy command is not installed on this computer" };
|
|
444
|
+
const parsed = firstJsonObject(shown.text);
|
|
445
|
+
if (!parsed) return { connected: false, reason: `could not read the connection back (${say(shown.text) || "no answer"})` };
|
|
446
|
+
if (parsed.status === "error") return { connected: false, reason: `could not read the connection back (${(parsed.message ?? "error").split("\n")[0]})` };
|
|
447
|
+
const statuses = [parsed.data?.connection?.status, ...(parsed.data?.accounts ?? []).map((account) => account.status)].filter(Boolean);
|
|
448
|
+
if (statuses.includes("active")) return { connected: true };
|
|
449
|
+
return { connected: false, reason: statuses.length ? `${integration} shows a connection with status "${statuses[0]}", not active` : `ClikDeploy shows no connection for ${integration}` };
|
|
450
|
+
}
|
|
451
|
+
var SEND_RETRY_DELAY_MS = 1500;
|
|
452
|
+
var JSON_FAILURE = /Unexpected end of JSON input|Unexpected token[^\n]*JSON|is not valid JSON|JSON\.parse|non-JSON/i;
|
|
453
|
+
function replyStatus(text) {
|
|
454
|
+
const parsed = firstJsonObject(text);
|
|
455
|
+
return parsed?.status === "error" && typeof parsed.httpStatus === "number" ? parsed.httpStatus : void 0;
|
|
456
|
+
}
|
|
457
|
+
function emptyReply(result) {
|
|
458
|
+
const status = replyStatus(result.text);
|
|
459
|
+
if (status !== void 0) return status >= 500 && status <= 504;
|
|
460
|
+
const text = result.text.trim();
|
|
461
|
+
if (!text) return result.code !== 0;
|
|
462
|
+
if (result.code === 0 && !JSON_FAILURE.test(text)) return false;
|
|
463
|
+
return JSON_FAILURE.test(text) || /\b(?:HTTP\s*)?50[0-4]\b|bad gateway|service unavailable|gateway time-?out/i.test(text) && !/"status"\s*:\s*"error"/.test(text);
|
|
464
|
+
}
|
|
465
|
+
function describeEmptyReply(result) {
|
|
466
|
+
const text = result.text.replace(/\s+/g, " ").trim();
|
|
467
|
+
const status = replyStatus(result.text) ?? /\b(?:HTTP\s*)?([45]\d\d)\b/.exec(text)?.[1];
|
|
468
|
+
return `ClikDeploy's connect call returned an empty or non-JSON reply (${status ? `HTTP ${status}` : "HTTP status not shown by the command"}, exit ${result.code ?? "none"}${text ? `, it said: "${text.slice(0, 160)}"` : ", it printed nothing"})`;
|
|
469
|
+
}
|
|
470
|
+
function noStdinMessage(program, support) {
|
|
471
|
+
if (support === "missing") return `The ${program} command is not installed on this computer.`;
|
|
472
|
+
const why = support === "old" ? `the installed ${program} is older than 1.0.35 and cannot read --args-json from stdin` : `\`${program} --version\` did not answer (timed out, failed, or printed no version), so it is not known to read --args-json from stdin`;
|
|
473
|
+
return `${why}; the key is never put on the command line, where other processes can read it. Update ${program} (or retry once it answers), then send it again with send_secret. The key is still saved.`;
|
|
474
|
+
}
|
|
475
|
+
async function sendToDestinations(stateDir, list, value, signal, options = {}) {
|
|
476
|
+
const all = await loadDestinations(stateDir);
|
|
477
|
+
const out = [];
|
|
478
|
+
for (const d of list) {
|
|
479
|
+
const template = all[d.to];
|
|
480
|
+
const given = d.with ?? {};
|
|
481
|
+
const label = `${d.to}${Object.keys(given).length ? ` (${Object.values(given).join(", ")})` : ""}`;
|
|
482
|
+
const params = {};
|
|
483
|
+
let unreadable;
|
|
484
|
+
for (const [slot, raw] of Object.entries(given)) {
|
|
485
|
+
const ref = template.vaultSlots?.includes(slot) ? VAULT_REF.exec(raw) : null;
|
|
486
|
+
if (!ref) {
|
|
487
|
+
params[slot] = raw;
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
const stored = (await readNamedSecret(stateDir, ref[1]).catch(() => "")).trim();
|
|
491
|
+
if (!stored || !SAFE_VALUE.test(stored)) {
|
|
492
|
+
unreadable = `The saved secret "${ref[1]}" is missing or is not a plain id, so ${slot} could not be filled.`;
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
params[slot] = stored;
|
|
496
|
+
}
|
|
497
|
+
if (unreadable) {
|
|
498
|
+
out.push({ label, ok: false, message: unreadable });
|
|
499
|
+
continue;
|
|
500
|
+
}
|
|
501
|
+
const [program, ...args] = template.run.map((part) => fill(part, params, value));
|
|
502
|
+
let stdin = template.stdin !== void 0 ? fill(template.stdin, params, value) : void 0;
|
|
503
|
+
const extra = takesConnectionValues(template) ? readConnectionValues(d.connectionValues) : {};
|
|
504
|
+
if (extra.problem) {
|
|
505
|
+
out.push({ label, ok: false, message: `NOT connected: ${extra.problem}` });
|
|
506
|
+
continue;
|
|
507
|
+
}
|
|
508
|
+
if (extra.values) {
|
|
509
|
+
let bad;
|
|
510
|
+
for (const [name, v] of Object.entries(extra.values)) {
|
|
511
|
+
const ref = VAULT_REF.exec(v);
|
|
512
|
+
if (!ref) continue;
|
|
513
|
+
const stored = (await readNamedSecret(stateDir, ref[1]).catch(() => "")).trim();
|
|
514
|
+
if (!VALUE_TEXT.test(stored)) {
|
|
515
|
+
bad = `The saved secret "${ref[1]}" is missing or is not a plain value, so ${name} could not be filled (${VALUE_FORMAT}).`;
|
|
516
|
+
break;
|
|
517
|
+
}
|
|
518
|
+
extra.values[name] = stored;
|
|
519
|
+
}
|
|
520
|
+
if (bad) {
|
|
521
|
+
out.push({ label, ok: false, message: `NOT connected: ${bad}` });
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
const dash = args.indexOf("--args-json");
|
|
526
|
+
if (template.verify === "connection" && dash >= 0 && args[dash + 1] !== void 0) {
|
|
527
|
+
const inStdin = args[dash + 1] === "-";
|
|
528
|
+
const text = inStdin ? stdin ?? "" : args[dash + 1];
|
|
529
|
+
let body;
|
|
530
|
+
try {
|
|
531
|
+
body = JSON.parse(text);
|
|
532
|
+
} catch {
|
|
533
|
+
out.push({ label, ok: false, message: `NOT connected: the destination "${d.to}" has no JSON in its --args-json (saved destinations: \`clikcode computer destination list\`).` });
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
536
|
+
if (extra.values && Object.keys(extra.values).length) body = { ...body, baseUrlVariables: extra.values };
|
|
537
|
+
const json = JSON.stringify(body);
|
|
538
|
+
const support = await cliStdinSupport(program, signal);
|
|
539
|
+
if (support !== "yes") {
|
|
540
|
+
out.push({ label, ok: false, message: `NOT connected: ${noStdinMessage(program, support)}` });
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
args[dash + 1] = "-";
|
|
544
|
+
stdin = json;
|
|
545
|
+
} else if (stdin !== void 0 && extra.values && Object.keys(extra.values).length) {
|
|
546
|
+
out.push({ label, ok: false, message: `NOT connected: the destination "${d.to}" has no --args-json to carry the values.` });
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
if (stdin === "") stdin = void 0;
|
|
550
|
+
if (stdin !== void 0 && dash >= 0 && args[dash + 1] === "-") {
|
|
551
|
+
const support = await cliStdinSupport(program, signal);
|
|
552
|
+
if (support !== "yes") {
|
|
553
|
+
out.push({ label, ok: false, message: `NOT delivered: ${noStdinMessage(program, support)}` });
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
let result = await runCli(program, args, { ...stdin !== void 0 ? { stdin } : {}, signal, timeoutMs: 9e4 });
|
|
558
|
+
if (!result.missing && template.verify === "connection" && emptyReply(result)) {
|
|
559
|
+
await sleep(options.retryDelayMs ?? SEND_RETRY_DELAY_MS);
|
|
560
|
+
result = await runCli(program, args, { ...stdin !== void 0 ? { stdin } : {}, signal, timeoutMs: 9e4 });
|
|
561
|
+
}
|
|
562
|
+
if (result.missing) {
|
|
563
|
+
out.push({ label, ok: false, message: `The ${program} command is not installed on this computer.` });
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
if (template.verify === "connection" && params.integration && dash >= 0 && /Provide \{ props/.test(result.text)) {
|
|
567
|
+
const custom = await declaredCustomProps(params.integration, signal).catch(quiet("agent/computer/secret-destinations"));
|
|
568
|
+
const shaped = custom ? customAuthBody(custom, value, extra.values ?? {}, given.prop) : { problem: "asks for named props, and its declared props could not be read" };
|
|
569
|
+
if ("problem" in shaped) {
|
|
570
|
+
out.push({ label, ok: false, message: `NOT connected: ${params.integration} ${shaped.problem}` });
|
|
571
|
+
continue;
|
|
572
|
+
}
|
|
573
|
+
const sent = JSON.parse(args[dash + 1] === "-" ? stdin ?? "{}" : args[dash + 1]);
|
|
574
|
+
const { apiKey: _key, baseUrlVariables: _values, ...keep } = sent;
|
|
575
|
+
const reshaped = JSON.stringify({ ...keep, props: shaped.props, ...Object.keys(shaped.rest).length ? { baseUrlVariables: shaped.rest } : {} });
|
|
576
|
+
if (args[dash + 1] === "-") stdin = reshaped;
|
|
577
|
+
else args[dash + 1] = reshaped;
|
|
578
|
+
result = await runCli(program, args, { ...stdin !== void 0 ? { stdin } : {}, signal, timeoutMs: 9e4 });
|
|
579
|
+
}
|
|
580
|
+
if (template.verify === "connection" && params.integration) {
|
|
581
|
+
const said = scrubSecrets(say(result.text)).replace(/\s+/g, " ").slice(0, 160);
|
|
582
|
+
const state = await connectionState(params.integration, signal);
|
|
583
|
+
if (emptyReply(result)) {
|
|
584
|
+
if (state.connected) {
|
|
585
|
+
out.push({ label, ok: true, message: "connected (the connect call's reply was empty or not JSON, but ClikDeploy lists an active connection)" });
|
|
586
|
+
continue;
|
|
587
|
+
}
|
|
588
|
+
out.push({ label, ok: false, message: `NOT connected: ${scrubSecrets(describeEmptyReply(result))}${state.reason ? `; ${state.reason}` : ""}. The key is still saved; send it again with send_secret.` });
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
591
|
+
const failed = result.code !== 0 || /"status"\s*:\s*"error"/.test(result.text) || /"success"\s*:\s*false/.test(result.text);
|
|
592
|
+
if (failed && /Provide \{/.test(result.text)) {
|
|
593
|
+
const kind = await declaredAuthKind(params.integration, signal).catch(quiet("agent/computer/secret-destinations"));
|
|
594
|
+
out.push({ label, ok: false, message: `NOT connected: ${d.to} sent the wrong shape. ${kind ? describeShapes(params.integration, kind) : `Basic auth takes username and password: use clikdeploy-connection-basic (key = password) or clikdeploy-connection-basic-key (key = username).`}` });
|
|
595
|
+
continue;
|
|
596
|
+
}
|
|
597
|
+
const reason = failed ? said || `the connect command failed (exit ${result.code})` : state.reason ? `${state.reason}${said ? `; the command said: ${said}` : ""}` : "";
|
|
598
|
+
out.push(state.connected && !failed ? { label, ok: true, message: "connected" } : { label, ok: false, message: `NOT connected: ${scrubSecrets(reason || "no active connection found after connecting")}` });
|
|
599
|
+
continue;
|
|
600
|
+
}
|
|
601
|
+
const ok = result.code === 0;
|
|
602
|
+
out.push({ label, ok, message: scrubSecrets(say(result.text)).trim() || (ok ? "delivered (the command succeeded and printed nothing)" : `failed (exit ${result.code ?? "none"}, the command printed nothing)`) });
|
|
603
|
+
}
|
|
604
|
+
return out.map((delivery) => delivery.message.trim() ? delivery : { ...delivery, message: delivery.ok ? "delivered" : "NOT delivered: no reason was given" });
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
export {
|
|
608
|
+
VENDOR_MFA_DESTINATION,
|
|
609
|
+
normalizeSendTo,
|
|
610
|
+
loadDestinations,
|
|
611
|
+
slotsOf,
|
|
612
|
+
addDestination,
|
|
613
|
+
removeDestination,
|
|
614
|
+
describeKnown,
|
|
615
|
+
declaredConnectionValues,
|
|
616
|
+
vendorMfaCode,
|
|
617
|
+
vendorMfaAccounts,
|
|
618
|
+
vendorMfaAccountFor,
|
|
619
|
+
declaredCustomProps,
|
|
620
|
+
customAuthBody,
|
|
621
|
+
declaredAuthKind,
|
|
622
|
+
destinationProblem,
|
|
623
|
+
firstJsonObject,
|
|
624
|
+
connectionState,
|
|
625
|
+
sendToDestinations
|
|
626
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
serveThenExit,
|
|
5
|
+
untilInputEnds,
|
|
6
|
+
untilStopped
|
|
7
|
+
} from "./chunk-4R6CSC3S.js";
|
|
8
|
+
import "./chunk-PWXII6HF.js";
|
|
9
|
+
export {
|
|
10
|
+
serveThenExit,
|
|
11
|
+
untilInputEnds,
|
|
12
|
+
untilStopped
|
|
13
|
+
};
|