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,239 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
objectOrEmpty,
|
|
5
|
+
updateJsonFile
|
|
6
|
+
} from "./chunk-PAXYQZH7.js";
|
|
7
|
+
|
|
8
|
+
// src/agent/computer/settings.ts
|
|
9
|
+
import fs from "node:fs/promises";
|
|
10
|
+
import { readFileSync } from "node:fs";
|
|
11
|
+
import path from "node:path";
|
|
12
|
+
function computerSettingsPath(stateDir) {
|
|
13
|
+
return path.join(stateDir, "computer", "settings.json");
|
|
14
|
+
}
|
|
15
|
+
async function computerEnabled(stateDir) {
|
|
16
|
+
try {
|
|
17
|
+
return JSON.parse(await fs.readFile(computerSettingsPath(stateDir), "utf8")).enabled !== false;
|
|
18
|
+
} catch {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function computerEnabledSync(stateDir) {
|
|
23
|
+
try {
|
|
24
|
+
return JSON.parse(readFileSync(computerSettingsPath(stateDir), "utf8")).enabled !== false;
|
|
25
|
+
} catch {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async function writeSettings(stateDir, change) {
|
|
30
|
+
await updateJsonFile(computerSettingsPath(stateDir), objectOrEmpty, (current) => ({ ...current, ...change }));
|
|
31
|
+
}
|
|
32
|
+
async function setComputerEnabled(stateDir, enabled) {
|
|
33
|
+
await writeSettings(stateDir, { enabled });
|
|
34
|
+
}
|
|
35
|
+
async function generatedPasswordsAllowed(stateDir) {
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(await fs.readFile(computerSettingsPath(stateDir), "utf8")).generatePasswords !== false;
|
|
38
|
+
} catch {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function setGeneratedPasswords(stateDir, allowed) {
|
|
43
|
+
await writeSettings(stateDir, { generatePasswords: allowed });
|
|
44
|
+
}
|
|
45
|
+
async function headlessSetting(stateDir) {
|
|
46
|
+
try {
|
|
47
|
+
return JSON.parse(await fs.readFile(computerSettingsPath(stateDir), "utf8")).headless === true;
|
|
48
|
+
} catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function setHeadless(stateDir, on) {
|
|
53
|
+
await writeSettings(stateDir, { headless: on });
|
|
54
|
+
}
|
|
55
|
+
async function browserProvider(stateDir) {
|
|
56
|
+
try {
|
|
57
|
+
const value = JSON.parse(await fs.readFile(computerSettingsPath(stateDir), "utf8")).browserProvider;
|
|
58
|
+
return value === "browser-use" || value === "auto" ? value : "local";
|
|
59
|
+
} catch {
|
|
60
|
+
return "local";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function setBrowserProvider(stateDir, provider) {
|
|
64
|
+
await writeSettings(stateDir, { browserProvider: provider });
|
|
65
|
+
}
|
|
66
|
+
var parseBrowserDisplay = (value) => value === "hidden" || value === "visible" ? value : void 0;
|
|
67
|
+
async function browserDisplay(stateDir) {
|
|
68
|
+
try {
|
|
69
|
+
return parseBrowserDisplay(JSON.parse(await fs.readFile(computerSettingsPath(stateDir), "utf8")).display) ?? "hidden";
|
|
70
|
+
} catch {
|
|
71
|
+
return "hidden";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async function setBrowserDisplay(stateDir, display) {
|
|
75
|
+
await writeSettings(stateDir, { display });
|
|
76
|
+
}
|
|
77
|
+
var COMPUTER_OFF = "Computer use is off. Run `clikcode computer on` to enable it.";
|
|
78
|
+
async function unattendedEnabled(stateDir) {
|
|
79
|
+
try {
|
|
80
|
+
return JSON.parse(await fs.readFile(computerSettingsPath(stateDir), "utf8")).unattended === true;
|
|
81
|
+
} catch {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function setUnattended(stateDir, on) {
|
|
86
|
+
await writeSettings(stateDir, { unattended: on });
|
|
87
|
+
}
|
|
88
|
+
async function captchaSolvingAllowed(stateDir) {
|
|
89
|
+
try {
|
|
90
|
+
return JSON.parse(await fs.readFile(computerSettingsPath(stateDir), "utf8")).solveCaptchas !== false;
|
|
91
|
+
} catch {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async function setCaptchaSolving(stateDir, allowed) {
|
|
96
|
+
await writeSettings(stateDir, { solveCaptchas: allowed });
|
|
97
|
+
}
|
|
98
|
+
var HOME_EGRESS = "home";
|
|
99
|
+
var EGRESS_NAME = /^[a-z0-9][a-z0-9-]{0,31}$/;
|
|
100
|
+
var SSH_TARGET = /^(?:[A-Za-z0-9._-]+@)?[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
101
|
+
var PROXY_URL = /^(?:socks5|socks4|http|https):\/\/(?:\[[0-9a-fA-F:]+\]|[A-Za-z0-9.-]+):\d{1,5}\/?$/;
|
|
102
|
+
function egressProblem(entry) {
|
|
103
|
+
if (typeof entry.name !== "string" || !EGRESS_NAME.test(entry.name)) return "An egress name is lower-case letters, digits and dashes (at most 32).";
|
|
104
|
+
if (entry.name === HOME_EGRESS) return `"home" is this computer's own connection; it is always there and needs no entry.`;
|
|
105
|
+
const hasSsh = entry.ssh !== void 0, hasProxy = entry.proxy !== void 0;
|
|
106
|
+
if (hasSsh === hasProxy) return "Give an egress either ssh (an ssh host) or proxy (socks5://host:port or http://host:port), not both.";
|
|
107
|
+
if (hasSsh && (typeof entry.ssh !== "string" || !SSH_TARGET.test(entry.ssh))) return "ssh is a host from ~/.ssh/config or user@host (letters, digits, dot, dash, underscore).";
|
|
108
|
+
if (hasProxy) {
|
|
109
|
+
if (typeof entry.proxy !== "string" || !PROXY_URL.test(entry.proxy)) return "proxy is socks5://host:port, socks4://host:port, http://host:port or https://host:port.";
|
|
110
|
+
const port = Number(/:(\d+)\/?$/.exec(entry.proxy)?.[1]);
|
|
111
|
+
if (!(port >= 1 && port <= 65535)) return "The proxy port is 1 to 65535.";
|
|
112
|
+
}
|
|
113
|
+
return void 0;
|
|
114
|
+
}
|
|
115
|
+
function parseEgress(value) {
|
|
116
|
+
if (!Array.isArray(value)) return [];
|
|
117
|
+
const out = [];
|
|
118
|
+
for (const item of value) {
|
|
119
|
+
if (!item || typeof item !== "object") continue;
|
|
120
|
+
const raw = item;
|
|
121
|
+
if (egressProblem(raw) || out.some((entry) => entry.name === raw.name)) continue;
|
|
122
|
+
out.push({ name: raw.name, ...raw.ssh !== void 0 ? { ssh: raw.ssh } : { proxy: raw.proxy.replace(/\/$/, "") } });
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
async function egressSetting(stateDir) {
|
|
127
|
+
try {
|
|
128
|
+
return parseEgress(JSON.parse(await fs.readFile(computerSettingsPath(stateDir), "utf8")).egress);
|
|
129
|
+
} catch {
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
async function egressList(stateDir) {
|
|
134
|
+
return [{ name: HOME_EGRESS }, ...await egressSetting(stateDir)];
|
|
135
|
+
}
|
|
136
|
+
async function addEgress(stateDir, entry) {
|
|
137
|
+
const problem = egressProblem(entry);
|
|
138
|
+
if (problem) throw new Error(problem);
|
|
139
|
+
const clean = { name: entry.name, ...entry.ssh !== void 0 ? { ssh: entry.ssh } : { proxy: entry.proxy.replace(/\/$/, "") } };
|
|
140
|
+
const after = await updateJsonFile(computerSettingsPath(stateDir), objectOrEmpty, (current) => {
|
|
141
|
+
const list = parseEgress(current.egress);
|
|
142
|
+
const at = list.findIndex((item) => item.name === clean.name);
|
|
143
|
+
if (at >= 0) list[at] = clean;
|
|
144
|
+
else list.push(clean);
|
|
145
|
+
return { ...current, egress: list };
|
|
146
|
+
});
|
|
147
|
+
return parseEgress(after.egress);
|
|
148
|
+
}
|
|
149
|
+
async function removeEgress(stateDir, name) {
|
|
150
|
+
let removed = false;
|
|
151
|
+
await updateJsonFile(computerSettingsPath(stateDir), objectOrEmpty, (current) => {
|
|
152
|
+
const list = parseEgress(current.egress);
|
|
153
|
+
const kept = list.filter((item) => item.name !== name);
|
|
154
|
+
removed = kept.length !== list.length;
|
|
155
|
+
return removed ? { ...current, egress: kept } : void 0;
|
|
156
|
+
});
|
|
157
|
+
return removed;
|
|
158
|
+
}
|
|
159
|
+
var COMPUTER_TUNABLES = {
|
|
160
|
+
agentModel: { default: "claude-sonnet-5-5", about: "The model a headless agent (`clikcode agent run`) runs on under Claude Code. Codex runs on the chat's own model." },
|
|
161
|
+
captchaVoterModel: { default: "claude-haiku-5-5", about: "The model the captcha voter on your Claude subscription uses for a hard picture question." },
|
|
162
|
+
captchaCodexVoterModel: { default: "", about: "The model the captcha voter on your Codex subscription uses (unset: the Codex account's own default)." },
|
|
163
|
+
captchaTileVoters: { default: "gpt-6-luna,gpt-5.6-luna,gpt-6.1-terra,gpt-6-sol,gpt-5.6-terra,gpt-5.6-sol,gpt-5.3-codex", list: true, about: "Captcha voters for picture-grid squares, best first (comma-separated; only subscription or free models are ever seated)." },
|
|
164
|
+
captchaClickVoters: { default: "gpt-6-sol,gpt-6.1-terra,gpt-6-luna,gpt-5.6-sol,gpt-5.6-terra,gpt-5.6-luna", list: true, about: "Captcha voters for where-to-click questions, best first." },
|
|
165
|
+
captchaOrderVoters: { default: "gpt-6-sol,gpt-6.1-terra,gpt-5.6-sol,gpt-6-luna,gpt-5.6-terra,gpt-5.6-luna", list: true, about: "Captcha voters for matching, ordering and picking questions, best first." },
|
|
166
|
+
captchaTextVoters: { default: "gpt-6-luna,gpt-5.6-luna,gpt-6.1-terra,gpt-6-sol,gpt-5.6-terra", list: true, about: "Captcha voters for reading distorted text, best first." },
|
|
167
|
+
captchaTranscribeModels: { default: "whisper-large-v3,whisper-large-v3-turbo,gpt-4o-mini-transcribe,whisper-1,gpt-4o-transcribe", list: true, about: "Speech-to-text models for audio captchas, best first (subscription or free ones are asked first; the others may bill a fraction of a cent a clip)." },
|
|
168
|
+
captchaSubscription: { default: true, about: "Let a hard captcha question be answered on your signed-in Claude or Codex subscription (off: Gateway voters only)." },
|
|
169
|
+
captchaVoteLog: { default: false, about: "Print each captcha voter's answer to stderr while solving (for diagnosing the solver)." },
|
|
170
|
+
keygrabLog: { default: false, about: "Print each keygrab step to stderr (for diagnosing a key capture)." }
|
|
171
|
+
};
|
|
172
|
+
async function computerTunable(stateDir, name) {
|
|
173
|
+
const fallback = COMPUTER_TUNABLES[name].default;
|
|
174
|
+
try {
|
|
175
|
+
const value = (JSON.parse(await fs.readFile(computerSettingsPath(stateDir), "utf8")).tunables ?? {})[name];
|
|
176
|
+
return typeof value === typeof fallback ? value : fallback;
|
|
177
|
+
} catch {
|
|
178
|
+
return fallback;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
async function computerTunableList(stateDir, name) {
|
|
182
|
+
const value = await computerTunable(stateDir, name);
|
|
183
|
+
return typeof value === "string" ? value.split(",").map((part) => part.trim()).filter(Boolean) : [];
|
|
184
|
+
}
|
|
185
|
+
async function setComputerTunable(stateDir, name, text) {
|
|
186
|
+
if (!(name in COMPUTER_TUNABLES)) throw new Error(`No setting "${name}". Settings: ${Object.keys(COMPUTER_TUNABLES).join(", ")}.`);
|
|
187
|
+
const key = name;
|
|
188
|
+
const fallback = COMPUTER_TUNABLES[key].default;
|
|
189
|
+
let value;
|
|
190
|
+
if (text === "default") value = void 0;
|
|
191
|
+
else if (typeof fallback === "boolean") {
|
|
192
|
+
if (!/^(on|off|true|false)$/i.test(text)) throw new Error(`${name} is on or off.`);
|
|
193
|
+
value = /^(on|true)$/i.test(text);
|
|
194
|
+
} else {
|
|
195
|
+
const list = "list" in COMPUTER_TUNABLES[key];
|
|
196
|
+
if (list ? !text.split(",").every((part) => /^[A-Za-z0-9._:/-]{1,120}$/.test(part.trim())) : !/^[A-Za-z0-9._:/-]{1,120}$/.test(text)) throw new Error(list ? `${name} is a comma-separated list of model names such as ${fallback}.` : `${name} is a model name such as ${fallback}.`);
|
|
197
|
+
if (list) text = text.split(",").map((part) => part.trim()).join(",");
|
|
198
|
+
value = text;
|
|
199
|
+
}
|
|
200
|
+
await updateJsonFile(computerSettingsPath(stateDir), objectOrEmpty, (current) => {
|
|
201
|
+
const tunables = { ...current.tunables ?? {} };
|
|
202
|
+
if (value === void 0) delete tunables[key];
|
|
203
|
+
else tunables[key] = value;
|
|
204
|
+
return { ...current, tunables };
|
|
205
|
+
});
|
|
206
|
+
return value ?? fallback;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export {
|
|
210
|
+
computerSettingsPath,
|
|
211
|
+
computerEnabled,
|
|
212
|
+
computerEnabledSync,
|
|
213
|
+
setComputerEnabled,
|
|
214
|
+
generatedPasswordsAllowed,
|
|
215
|
+
setGeneratedPasswords,
|
|
216
|
+
headlessSetting,
|
|
217
|
+
setHeadless,
|
|
218
|
+
browserProvider,
|
|
219
|
+
setBrowserProvider,
|
|
220
|
+
parseBrowserDisplay,
|
|
221
|
+
browserDisplay,
|
|
222
|
+
setBrowserDisplay,
|
|
223
|
+
COMPUTER_OFF,
|
|
224
|
+
unattendedEnabled,
|
|
225
|
+
setUnattended,
|
|
226
|
+
captchaSolvingAllowed,
|
|
227
|
+
setCaptchaSolving,
|
|
228
|
+
HOME_EGRESS,
|
|
229
|
+
egressProblem,
|
|
230
|
+
parseEgress,
|
|
231
|
+
egressSetting,
|
|
232
|
+
egressList,
|
|
233
|
+
addEgress,
|
|
234
|
+
removeEgress,
|
|
235
|
+
COMPUTER_TUNABLES,
|
|
236
|
+
computerTunable,
|
|
237
|
+
computerTunableList,
|
|
238
|
+
setComputerTunable
|
|
239
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
SHARED_COMPUTER_TOOLS,
|
|
5
|
+
runSharedComputerTool
|
|
6
|
+
} from "./chunk-5IKLK33T.js";
|
|
7
|
+
import "./chunk-E4F4OUAC.js";
|
|
8
|
+
import "./chunk-OHKZUEJW.js";
|
|
9
|
+
import "./chunk-LM6EIA4B.js";
|
|
10
|
+
import "./chunk-RDLLDYFO.js";
|
|
11
|
+
import "./chunk-74WNMLMS.js";
|
|
12
|
+
import "./chunk-GLY7RM3C.js";
|
|
13
|
+
import "./chunk-W2NVSDO5.js";
|
|
14
|
+
import "./chunk-EXN4KHLB.js";
|
|
15
|
+
import "./chunk-BNTXAZXW.js";
|
|
16
|
+
import "./chunk-LAVFOA3S.js";
|
|
17
|
+
import "./chunk-2GAB36IE.js";
|
|
18
|
+
import "./chunk-WOVTYST3.js";
|
|
19
|
+
import "./chunk-3RXBMYKZ.js";
|
|
20
|
+
import "./chunk-34JQYQCA.js";
|
|
21
|
+
import "./chunk-JYBONKD4.js";
|
|
22
|
+
import "./chunk-MCSDWZET.js";
|
|
23
|
+
import "./chunk-BOQBXGSN.js";
|
|
24
|
+
import "./chunk-KCQ4TBLS.js";
|
|
25
|
+
import "./chunk-FBKXE4EJ.js";
|
|
26
|
+
import "./chunk-DW2BMUKY.js";
|
|
27
|
+
import "./chunk-B4HNJRAH.js";
|
|
28
|
+
import "./chunk-OQ245JLA.js";
|
|
29
|
+
import "./chunk-25T3GVS7.js";
|
|
30
|
+
import "./chunk-4GXAO3UY.js";
|
|
31
|
+
import "./chunk-SNU37TQI.js";
|
|
32
|
+
import "./chunk-XAHGBPWT.js";
|
|
33
|
+
import "./chunk-FT5TX7OX.js";
|
|
34
|
+
import "./chunk-7NMUTGOW.js";
|
|
35
|
+
import "./chunk-FFGU4GCC.js";
|
|
36
|
+
import "./chunk-7AULZ7OD.js";
|
|
37
|
+
import "./chunk-UA5K2BTI.js";
|
|
38
|
+
import "./chunk-2BBELGHY.js";
|
|
39
|
+
import "./chunk-TQDM7S5N.js";
|
|
40
|
+
import "./chunk-TULAXS77.js";
|
|
41
|
+
import "./chunk-IMLTL2MY.js";
|
|
42
|
+
import "./chunk-DQYVQ2N7.js";
|
|
43
|
+
import "./chunk-IGZ6C2MC.js";
|
|
44
|
+
import "./chunk-4NN3XQQT.js";
|
|
45
|
+
import "./chunk-WPB5WEZJ.js";
|
|
46
|
+
import "./chunk-GYMAI5NY.js";
|
|
47
|
+
import "./chunk-W3YYPBEA.js";
|
|
48
|
+
import "./chunk-XIBYREEY.js";
|
|
49
|
+
import "./chunk-MP4KZOQC.js";
|
|
50
|
+
import "./chunk-PWBF2X3V.js";
|
|
51
|
+
import "./chunk-HU5SSUFX.js";
|
|
52
|
+
import "./chunk-AKRYTS2D.js";
|
|
53
|
+
import "./chunk-4GVEJ5FK.js";
|
|
54
|
+
import "./chunk-O7BNJIXU.js";
|
|
55
|
+
import "./chunk-MCBRVPA7.js";
|
|
56
|
+
import "./chunk-RJLHVYQY.js";
|
|
57
|
+
import "./chunk-YMCH3L2S.js";
|
|
58
|
+
import "./chunk-I75EDU75.js";
|
|
59
|
+
import "./chunk-NAOX3JUB.js";
|
|
60
|
+
import "./chunk-GGYKY4GF.js";
|
|
61
|
+
import "./chunk-5SM5UAWN.js";
|
|
62
|
+
import "./chunk-PAXYQZH7.js";
|
|
63
|
+
import "./chunk-CAADDF6M.js";
|
|
64
|
+
import "./chunk-G3QP67Z7.js";
|
|
65
|
+
import "./chunk-4L2ZZM4Q.js";
|
|
66
|
+
import "./chunk-F6F47QAY.js";
|
|
67
|
+
import "./chunk-RDDWQBEM.js";
|
|
68
|
+
import "./chunk-MPAJ446F.js";
|
|
69
|
+
import "./chunk-CBANJFBO.js";
|
|
70
|
+
import "./chunk-PWXII6HF.js";
|
|
71
|
+
export {
|
|
72
|
+
SHARED_COMPUTER_TOOLS,
|
|
73
|
+
runSharedComputerTool
|
|
74
|
+
};
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
installedRecord,
|
|
5
|
+
localBuildCommit,
|
|
6
|
+
reconnectWindowMachine,
|
|
7
|
+
updateRemoteMachine
|
|
8
|
+
} from "./chunk-VEWPCZPG.js";
|
|
9
|
+
import {
|
|
10
|
+
forgetMachine,
|
|
11
|
+
newMachineRecord,
|
|
12
|
+
readMachines,
|
|
13
|
+
updateMachine,
|
|
14
|
+
updateMachines,
|
|
15
|
+
updatePolicy
|
|
16
|
+
} from "./chunk-X6WF7JEV.js";
|
|
17
|
+
import {
|
|
18
|
+
defaultLoginUser,
|
|
19
|
+
installOnMachine,
|
|
20
|
+
targetHost,
|
|
21
|
+
targetUser,
|
|
22
|
+
uninstallFromMachine,
|
|
23
|
+
validateSshTarget,
|
|
24
|
+
withUser
|
|
25
|
+
} from "./chunk-UFQ5A5PW.js";
|
|
26
|
+
import {
|
|
27
|
+
withSlowWait
|
|
28
|
+
} from "./chunk-COAS5ETR.js";
|
|
29
|
+
import {
|
|
30
|
+
chooseOption
|
|
31
|
+
} from "./chunk-ROGXPGYR.js";
|
|
32
|
+
import {
|
|
33
|
+
wrapWords
|
|
34
|
+
} from "./chunk-FF7ZVYJF.js";
|
|
35
|
+
import {
|
|
36
|
+
source_default
|
|
37
|
+
} from "./chunk-LVRRWP4W.js";
|
|
38
|
+
|
|
39
|
+
// src/tui/pickers/remote.ts
|
|
40
|
+
function remoteHostOf(prompter) {
|
|
41
|
+
return {
|
|
42
|
+
prompter,
|
|
43
|
+
ask: (label) => prompter.question(`${label} \u203A `, void 0, { cancellable: true }).catch((error) => {
|
|
44
|
+
if (error.code === "ERR_PROMPT_CANCELLED") return void 0;
|
|
45
|
+
throw error;
|
|
46
|
+
}),
|
|
47
|
+
withBusy: (label, work) => withSlowWait(prompter.startWaiting && prompter.stopWaiting ? prompter : void 0, label, work),
|
|
48
|
+
line: (text) => {
|
|
49
|
+
if (prompter.activity) prompter.activity(text);
|
|
50
|
+
else process.stderr.write(`${text}
|
|
51
|
+
`);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function say(host, mark, text, tail = "") {
|
|
56
|
+
const plain = `${text}${tail}`;
|
|
57
|
+
const width = process.stdout.columns ? Math.max(20, process.stdout.columns - 6) : Infinity;
|
|
58
|
+
const rows = width === Infinity ? [plain] : wrapWords(plain, width);
|
|
59
|
+
rows.forEach((row, at) => {
|
|
60
|
+
const start = rows.slice(0, at).reduce((sum, item) => sum + item.length, 0);
|
|
61
|
+
const offset = plain.indexOf(row, start);
|
|
62
|
+
const dimFrom = Math.max(0, Math.min(row.length, text.length - offset));
|
|
63
|
+
const drawn = `${row.slice(0, dimFrom)}${dimFrom < row.length ? source_default.dim(row.slice(dimFrom)) : ""}`;
|
|
64
|
+
host.line(at === 0 && mark ? `${mark} ${drawn}` : drawn);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function stepLines(host) {
|
|
68
|
+
let current = 0;
|
|
69
|
+
let total = 0;
|
|
70
|
+
return {
|
|
71
|
+
start: (_step, index, count) => {
|
|
72
|
+
current = index;
|
|
73
|
+
total = count;
|
|
74
|
+
},
|
|
75
|
+
done: (step, detail) => say(host, source_default.green("\u2713"), `${current}/${total} ${step}`, detail ? ` \xB7 ${detail}` : "")
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
async function runInstall(host, machine, update) {
|
|
79
|
+
let target = machine.sshTarget;
|
|
80
|
+
let asked = false;
|
|
81
|
+
const commit = update ? localBuildCommit() : void 0;
|
|
82
|
+
for (; ; ) {
|
|
83
|
+
host.line(`${update ? "Updating" : "Installing"} ClikCode on ${machine.name} (${target}) ${commit ? `to this build's commit ${commit.slice(0, 8)}` : "from GitHub main"}`);
|
|
84
|
+
const outcome = await host.withBusy(`${update ? "updating" : "installing"} ClikCode on ${machine.name}`, () => update ? updateRemoteMachine({ ...machine, sshTarget: target }, stepLines(host), commit ? { commit } : {}) : installOnMachine(target, stepLines(host)));
|
|
85
|
+
if (outcome.ok || !outcome.auth || asked) return { outcome, machine };
|
|
86
|
+
asked = true;
|
|
87
|
+
const who = targetUser(target) ? "" : ` (as ${await defaultLoginUser(target)}, ssh's default)`;
|
|
88
|
+
say(host, source_default.yellow("!"), `${outcome.message}${who}`);
|
|
89
|
+
const retried = await askLoginUser(host, machine.name, target);
|
|
90
|
+
if (!retried) return { outcome, machine };
|
|
91
|
+
target = retried;
|
|
92
|
+
machine.sshTarget = target;
|
|
93
|
+
await updateMachine(machine.id, (record) => {
|
|
94
|
+
record.sshTarget = target;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async function askLoginUser(host, name, target) {
|
|
99
|
+
for (; ; ) {
|
|
100
|
+
const typed = await host.ask(`Log in to ${name} as which user?`);
|
|
101
|
+
if (typed === void 0) return void 0;
|
|
102
|
+
if (!typed.trim()) {
|
|
103
|
+
say(host, source_default.yellow("!"), "Type a user name, or Esc to add nothing.");
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
return withUser(target, typed);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
say(host, source_default.yellow("!"), `${error instanceof Error ? error.message : String(error)} Type another, or Esc to add nothing.`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async function addDiscoveredMachine(host, found) {
|
|
114
|
+
if (found.os === "windows") throw new Error(`${found.name} runs Windows: ClikCode Remote does not support it yet.`);
|
|
115
|
+
const existing = (await readMachines()).find((machine) => machine.tailscale?.nodeId === found.nodeId);
|
|
116
|
+
if (existing?.ready) return { id: existing.id };
|
|
117
|
+
let target = existing?.sshTarget ?? validateSshTarget(found.dnsName ?? found.hostName);
|
|
118
|
+
if (!targetUser(target)) {
|
|
119
|
+
const typed = await askLoginUser(host, found.name, target);
|
|
120
|
+
if (!typed) return {};
|
|
121
|
+
target = typed;
|
|
122
|
+
}
|
|
123
|
+
if (existing) {
|
|
124
|
+
existing.sshTarget = target;
|
|
125
|
+
await updateMachine(existing.id, (record) => {
|
|
126
|
+
record.sshTarget = target;
|
|
127
|
+
});
|
|
128
|
+
return installNew(host, existing, true);
|
|
129
|
+
}
|
|
130
|
+
return installNew(host, newMachineRecord({
|
|
131
|
+
name: found.name,
|
|
132
|
+
sshTarget: target,
|
|
133
|
+
os: found.os,
|
|
134
|
+
tailscale: { nodeId: found.nodeId, ...found.dnsName ? { dnsName: found.dnsName } : {} }
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
async function addByAddress(host, typed) {
|
|
138
|
+
const target = validateSshTarget(typed);
|
|
139
|
+
return installNew(host, newMachineRecord({ name: targetHost(target).split(".")[0] || target, sshTarget: target }));
|
|
140
|
+
}
|
|
141
|
+
async function installNew(host, machine, recorded = false) {
|
|
142
|
+
if (!recorded) await updateMachines((machines) => [...machines, machine]);
|
|
143
|
+
const { outcome } = await runInstall(host, machine, false);
|
|
144
|
+
if (!outcome.ok) {
|
|
145
|
+
say(host, source_default.red("\u2717"), `${outcome.step}: ${outcome.message}`);
|
|
146
|
+
if (outcome.windows) await forgetMachine(machine.id);
|
|
147
|
+
return {};
|
|
148
|
+
}
|
|
149
|
+
const { info } = outcome;
|
|
150
|
+
const existing = info.installationId ? (await readMachines()).find((other) => other.id !== machine.id && other.installationId === info.installationId) : void 0;
|
|
151
|
+
if (existing) {
|
|
152
|
+
await forgetMachine(machine.id);
|
|
153
|
+
await updateMachine(existing.id, (record) => installedRecord(record, info));
|
|
154
|
+
reconnectWindowMachine(existing.id);
|
|
155
|
+
return { id: existing.id, notice: `${machine.name} is ${existing.name}, already added: it is up to date now.` };
|
|
156
|
+
}
|
|
157
|
+
await updateMachine(machine.id, (record) => {
|
|
158
|
+
installedRecord(record, info);
|
|
159
|
+
record.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
|
|
160
|
+
});
|
|
161
|
+
return { id: machine.id, notice: `${machine.name} is added. Its chats are on the board (\u2190 on an empty prompt, \u2190 again for machines); sign in to providers there from its own chats.` };
|
|
162
|
+
}
|
|
163
|
+
function machineActions(machine) {
|
|
164
|
+
const auto = updatePolicy(machine) === "auto";
|
|
165
|
+
return [
|
|
166
|
+
machine.ready ? { label: "Update ClikCode", value: "update" } : { label: "Finish installing", value: "install" },
|
|
167
|
+
{ label: auto ? "Updates: automatic \xB7 ask first instead" : "Updates: ask first \xB7 automatic instead", value: "policy" },
|
|
168
|
+
{ label: "Remove\u2026", value: "remove" }
|
|
169
|
+
];
|
|
170
|
+
}
|
|
171
|
+
async function machineAction(host, machine, action) {
|
|
172
|
+
const auto = updatePolicy(machine) === "auto";
|
|
173
|
+
if (machine.updateError && action === "update") say(host, source_default.yellow("!"), `The last update of ${machine.name} failed: ${machine.updateError}`);
|
|
174
|
+
if (action === "install") {
|
|
175
|
+
const { notice } = await installNew(host, machine, true);
|
|
176
|
+
return notice ? { notice } : {};
|
|
177
|
+
}
|
|
178
|
+
if (action === "policy") {
|
|
179
|
+
const updates = auto ? "ask" : "auto";
|
|
180
|
+
await updateMachine(machine.id, (record) => {
|
|
181
|
+
record.updates = updates;
|
|
182
|
+
});
|
|
183
|
+
return { notice: updates === "ask" ? `${machine.name} is updated only when you say so: Tab on it in /machine, or /update in one of its chats.` : `${machine.name} is updated to this build by itself when it differs; its chats switch over once they are quiet.` };
|
|
184
|
+
}
|
|
185
|
+
if (action === "update") {
|
|
186
|
+
const { outcome } = await runInstall(host, machine, true);
|
|
187
|
+
if (!outcome.ok) {
|
|
188
|
+
say(host, source_default.red("\u2717"), `${outcome.step}: ${outcome.message}`);
|
|
189
|
+
return {};
|
|
190
|
+
}
|
|
191
|
+
const { info } = outcome;
|
|
192
|
+
reconnectWindowMachine(machine.id);
|
|
193
|
+
return { notice: `ClikCode on ${machine.name} is updated${info.commit ? ` to ${info.commit.slice(0, 8)}` : ""}; its chats switch over once they are quiet.` };
|
|
194
|
+
}
|
|
195
|
+
if (action !== "remove") return {};
|
|
196
|
+
const how = await chooseOption(host.prompter, `Remove ${machine.name}`, [
|
|
197
|
+
{ label: "Cancel", value: "cancel" },
|
|
198
|
+
{ label: "Forget it here", detail: "\xB7 ClikCode stays installed there", value: "forget" },
|
|
199
|
+
{ label: "Forget it and uninstall ClikCode there", detail: "\xB7 removes ~/.local/share/clikcode and ~/.local/bin/clikcode; its chats and accounts stay", value: "uninstall" },
|
|
200
|
+
{ label: "Forget it, uninstall, and delete its ClikCode data", detail: `\xB7 also ~/.clikcode there: every chat and account on ${machine.name}`, value: "data" }
|
|
201
|
+
]);
|
|
202
|
+
if (!how || how === "cancel") return {};
|
|
203
|
+
if (how === "data") {
|
|
204
|
+
const sure = await chooseOption(host.prompter, `Delete every ClikCode chat and account on ${machine.name}?`, [
|
|
205
|
+
{ label: "Cancel", value: false },
|
|
206
|
+
{ label: `Delete ~/.clikcode on ${machine.name}`, value: true }
|
|
207
|
+
]);
|
|
208
|
+
if (!sure) return {};
|
|
209
|
+
}
|
|
210
|
+
if (how === "uninstall" || how === "data") {
|
|
211
|
+
const result = await host.withBusy(`uninstalling ClikCode on ${machine.name}`, () => uninstallFromMachine(machine.sshTarget, how === "data"));
|
|
212
|
+
if (!result.ok) {
|
|
213
|
+
say(host, source_default.red("\u2717"), `Uninstalling on ${machine.name} failed: ${result.message ?? "no answer"}. It is still added; try again when it is online, or choose "Forget it here".`);
|
|
214
|
+
return {};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
await forgetMachine(machine.id, { remember: true });
|
|
218
|
+
return { notice: how === "forget" ? `${machine.name} is forgotten here; ClikCode is still installed there.` : `${machine.name} is removed, and ClikCode is uninstalled there${how === "data" ? ", its data too" : ""}.` };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export {
|
|
222
|
+
remoteHostOf,
|
|
223
|
+
addDiscoveredMachine,
|
|
224
|
+
addByAddress,
|
|
225
|
+
machineActions,
|
|
226
|
+
machineAction
|
|
227
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
CARD_APPROVAL_MS,
|
|
5
|
+
cardBrand,
|
|
6
|
+
cardExpired,
|
|
7
|
+
cardFieldFor,
|
|
8
|
+
cardValueFor,
|
|
9
|
+
describeCard,
|
|
10
|
+
describeSavedCard,
|
|
11
|
+
listCards,
|
|
12
|
+
luhnValid,
|
|
13
|
+
parseExpiry,
|
|
14
|
+
readCardSecret,
|
|
15
|
+
removeCard,
|
|
16
|
+
saveCard
|
|
17
|
+
} from "./chunk-KCQ4TBLS.js";
|
|
18
|
+
import "./chunk-I75EDU75.js";
|
|
19
|
+
import "./chunk-4L2ZZM4Q.js";
|
|
20
|
+
import "./chunk-F6F47QAY.js";
|
|
21
|
+
import "./chunk-RDDWQBEM.js";
|
|
22
|
+
import "./chunk-MPAJ446F.js";
|
|
23
|
+
import "./chunk-CBANJFBO.js";
|
|
24
|
+
import "./chunk-PWXII6HF.js";
|
|
25
|
+
export {
|
|
26
|
+
CARD_APPROVAL_MS,
|
|
27
|
+
cardBrand,
|
|
28
|
+
cardExpired,
|
|
29
|
+
cardFieldFor,
|
|
30
|
+
cardValueFor,
|
|
31
|
+
describeCard,
|
|
32
|
+
describeSavedCard,
|
|
33
|
+
listCards,
|
|
34
|
+
luhnValid,
|
|
35
|
+
parseExpiry,
|
|
36
|
+
readCardSecret,
|
|
37
|
+
removeCard,
|
|
38
|
+
saveCard
|
|
39
|
+
};
|