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,291 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
quiet
|
|
5
|
+
} from "./chunk-RDDWQBEM.js";
|
|
6
|
+
import {
|
|
7
|
+
stateDirectory
|
|
8
|
+
} from "./chunk-MPAJ446F.js";
|
|
9
|
+
import "./chunk-CBANJFBO.js";
|
|
10
|
+
import "./chunk-PWXII6HF.js";
|
|
11
|
+
|
|
12
|
+
// src/commands/computer-ops.ts
|
|
13
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
14
|
+
import { readFile } from "node:fs/promises";
|
|
15
|
+
var print = (value) => void process.stdout.write(`${JSON.stringify(value)}
|
|
16
|
+
`);
|
|
17
|
+
var whole = (value, name, min, max) => {
|
|
18
|
+
if (value === void 0) return void 0;
|
|
19
|
+
const n = Number(value);
|
|
20
|
+
if (!Number.isInteger(n) || n < min || n > max) throw new Error(`--${name} is a whole number from ${min} to ${max}.`);
|
|
21
|
+
return n;
|
|
22
|
+
};
|
|
23
|
+
var NAME = /^[a-z0-9][a-z0-9._/-]{0,95}$/i;
|
|
24
|
+
var TAB = /^[a-z0-9][a-z0-9._-]{0,79}$/i;
|
|
25
|
+
var tabOf = (tab, fallback) => {
|
|
26
|
+
const t = tab ?? fallback;
|
|
27
|
+
if (!TAB.test(t)) throw new Error("--tab is letters, digits, dots, dashes and underscores.");
|
|
28
|
+
return t;
|
|
29
|
+
};
|
|
30
|
+
async function readText(file) {
|
|
31
|
+
if (file !== "-") return readFile(file, "utf8");
|
|
32
|
+
const chunks = [];
|
|
33
|
+
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
34
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
35
|
+
}
|
|
36
|
+
async function agentRun(flags) {
|
|
37
|
+
const { runHeadlessAgent } = await import("./chunk-P72UZAQI.js");
|
|
38
|
+
const prompt = (await readText(flags.promptFile)).trim();
|
|
39
|
+
if (!prompt) throw new Error("The prompt is empty.");
|
|
40
|
+
for (const pattern of flags.blockUrl ?? []) new RegExp(pattern, "i");
|
|
41
|
+
let servers;
|
|
42
|
+
if (flags.mcpConfig) {
|
|
43
|
+
const parsed = JSON.parse(await readFile(flags.mcpConfig, "utf8"));
|
|
44
|
+
if (!parsed.mcpServers || typeof parsed.mcpServers !== "object") throw new Error('--mcp-config is a JSON file with {"mcpServers": {name: {command, args, env}}}.');
|
|
45
|
+
servers = parsed.mcpServers;
|
|
46
|
+
}
|
|
47
|
+
const { untilStopped } = await import("./chunk-B5WYPPHS.js");
|
|
48
|
+
const result = await untilStopped((signal) => runHeadlessAgent({
|
|
49
|
+
prompt,
|
|
50
|
+
stateDir: stateDirectory(),
|
|
51
|
+
signal,
|
|
52
|
+
...flags.tab ? { computer: { tab: tabOf(flags.tab, ""), ...flags.egress ? { egress: flags.egress } : {}, ...flags.blockUrl?.length ? { blockUrls: flags.blockUrl } : {}, ...flags.blockMessage ? { blockMessage: flags.blockMessage } : {} } } : {},
|
|
53
|
+
...servers ? { servers } : {},
|
|
54
|
+
maxCalls: whole(flags.maxCalls, "max-calls", 1, 1e3) ?? 60,
|
|
55
|
+
maxMs: (whole(flags.maxMinutes, "max-minutes", 1, 240) ?? 20) * 6e4,
|
|
56
|
+
stallMs: (whole(flags.stallMinutes, "stall-minutes", 1, 60) ?? 5) * 6e4,
|
|
57
|
+
...flags.session ?? process.env.CLIKCODE_SESSION_ID ? { sessionId: flags.session ?? process.env.CLIKCODE_SESSION_ID } : {},
|
|
58
|
+
...flags.model ? { model: flags.model } : {}
|
|
59
|
+
}));
|
|
60
|
+
print(result);
|
|
61
|
+
if (result.error) process.exitCode = 1;
|
|
62
|
+
}
|
|
63
|
+
async function computerMcp(flags, signal) {
|
|
64
|
+
const { serveComputerMcp, maxCallsFromEnv } = await import("./chunk-LSLNL5T3.js");
|
|
65
|
+
await serveComputerMcp({
|
|
66
|
+
tab: tabOf(flags.tab, ""),
|
|
67
|
+
maxCalls: whole(flags.maxCalls, "max-calls", 1, 5e3) ?? maxCallsFromEnv() ?? 200,
|
|
68
|
+
...flags.activity ? { activity: flags.activity } : {},
|
|
69
|
+
...flags.egress ? { egress: flags.egress } : {},
|
|
70
|
+
...flags.blockUrl?.length ? { blockUrls: flags.blockUrl } : {},
|
|
71
|
+
...flags.blockMessage ? { blockMessage: flags.blockMessage } : {}
|
|
72
|
+
}, signal);
|
|
73
|
+
}
|
|
74
|
+
function delivery(flags) {
|
|
75
|
+
let sendTo;
|
|
76
|
+
if (flags.sendTo) {
|
|
77
|
+
const parsed = JSON.parse(flags.sendTo);
|
|
78
|
+
const list = Array.isArray(parsed) ? parsed : [parsed];
|
|
79
|
+
if (!list.every((d) => d && typeof d === "object" && typeof d.to === "string")) throw new Error('--send-to is a JSON destination {"to": ..., "with": {...}} or a list of them.');
|
|
80
|
+
sendTo = list;
|
|
81
|
+
}
|
|
82
|
+
if (flags.keyName && !/^[\w .-]{1,40}$/.test(flags.keyName)) throw new Error("--key-name is up to 40 letters, digits, spaces, dots and dashes.");
|
|
83
|
+
if (flags.secretName && !NAME.test(flags.secretName)) throw new Error("--secret-name is a vault name such as acme/key.");
|
|
84
|
+
return { ...sendTo ? { sendTo } : {}, ...flags.keyName ? { keyName: flags.keyName } : {}, ...flags.secretName ? { secretName: flags.secretName } : {} };
|
|
85
|
+
}
|
|
86
|
+
async function computerKeygrab(name, url, flags) {
|
|
87
|
+
if (!NAME.test(name) || name.includes("/")) throw new Error("The name is letters, digits, dots and dashes (the site or service the key is for).");
|
|
88
|
+
if (!/^https?:\/\//.test(url)) throw new Error("The address is an http(s) page to start from.");
|
|
89
|
+
const alternates = (flags.alternate ?? []).filter((a) => /^https?:\/\//.test(a));
|
|
90
|
+
const dir = stateDirectory();
|
|
91
|
+
const { liveKeygrab } = await import("./chunk-435ZNSZ3.js");
|
|
92
|
+
const tab = tabOf(flags.tab, "keygrab");
|
|
93
|
+
if (flags.egress) await (await import("./chunk-ZFC2Q67K.js")).bindTabEgress(dir, tab, flags.egress);
|
|
94
|
+
const outcome = await liveKeygrab({ stateDir: dir, tab, delivery: delivery(flags) }, name, url, { maxMs: (whole(flags.maxMinutes, "max-minutes", 1, 120) ?? 5) * 6e4, ...whole(flags.maxSteps, "max-steps", 1, 200) ? { maxSteps: whole(flags.maxSteps, "max-steps", 1, 200) } : {}, ...alternates.length ? { alternates } : {} });
|
|
95
|
+
print(outcome);
|
|
96
|
+
}
|
|
97
|
+
async function computerKeygrabResume(name, flags) {
|
|
98
|
+
if (flags.click && flags.goto) throw new Error("Give --click or --goto, not both.");
|
|
99
|
+
const { resumeKeygrab } = await import("./chunk-Y54LTP4W.js");
|
|
100
|
+
const maxMinutes = whole(flags.maxMinutes, "max-minutes", 1, 60), maxSteps = whole(flags.maxSteps, "max-steps", 1, 100);
|
|
101
|
+
const result = await resumeKeygrab({ stateDir: stateDirectory(), id: name, delivery: delivery(flags), ...flags.click ? { click: flags.click } : {}, ...flags.goto ? { goto: flags.goto } : {}, ...flags.only ? { only: true } : {}, ...maxMinutes ? { maxMs: maxMinutes * 6e4 } : {}, ...maxSteps ? { maxSteps } : {} });
|
|
102
|
+
print({ name, reattached: result.reattached, ...result.pressed ? { pressed: result.pressed } : {}, outcome: result.outcome });
|
|
103
|
+
}
|
|
104
|
+
async function computerKeygrabBackoff(name, flags) {
|
|
105
|
+
const park = await import("./chunk-H2VZMKPE.js");
|
|
106
|
+
const dir = stateDirectory();
|
|
107
|
+
if (flags.set && flags.clear) throw new Error("Give --set or --clear, not both.");
|
|
108
|
+
if (flags.clear) {
|
|
109
|
+
await park.clearBackoff(dir, name);
|
|
110
|
+
return print({ name, until: null });
|
|
111
|
+
}
|
|
112
|
+
const until = flags.set ? await park.recordBackoff(dir, name) : await park.backoffUntil(dir, name);
|
|
113
|
+
print({ name, until: until?.toISOString() ?? null, hours: park.BACKOFF_HOURS });
|
|
114
|
+
}
|
|
115
|
+
async function look(page) {
|
|
116
|
+
const text = await page.evaluate(() => (globalThis.document.body?.innerText ?? "").slice(0, 4e3)).catch(() => "");
|
|
117
|
+
const controls = await page.evaluate(() => Array.from(globalThis.document.querySelectorAll("button, [role=button], a")).map((n) => (n.textContent ?? "").replace(/\s+/g, " ").trim()).filter((t) => t && t.length <= 60).slice(0, 12)).catch(() => []);
|
|
118
|
+
return { text, controls };
|
|
119
|
+
}
|
|
120
|
+
async function oauthConnectOutcome(connector, options = {}) {
|
|
121
|
+
const dir = stateDirectory();
|
|
122
|
+
const tab = tabOf(options.tab, "oauth");
|
|
123
|
+
const { oauthConnect, ConsentStop, pageExcerpt } = await import("./chunk-M5QNDBAY.js");
|
|
124
|
+
const { scrubSecrets } = await import("./chunk-BMRAEBRY.js");
|
|
125
|
+
const browser = await import("./chunk-ZFC2Q67K.js");
|
|
126
|
+
const { profileEmail } = await import("./chunk-BXFJS65Q.js");
|
|
127
|
+
if (options.egress) await browser.bindTabEgress(dir, tab, options.egress);
|
|
128
|
+
let page = await browser.openNewComputerPage(dir, tab);
|
|
129
|
+
const reopen = async (old) => {
|
|
130
|
+
await browser.closeOwnedPage(dir, old, tab).catch(quiet("commands/computer-ops"));
|
|
131
|
+
page = await browser.openNewComputerPage(dir, tab);
|
|
132
|
+
return page;
|
|
133
|
+
};
|
|
134
|
+
try {
|
|
135
|
+
const done = await oauthConnect(connector, page, { email: await profileEmail(dir), stateDir: dir, reopen, ...options.progress ? { progress: options.progress } : {} });
|
|
136
|
+
return { ok: true, note: `consent finished: ${done.steps.length} presses, an active connection is shown` };
|
|
137
|
+
} catch (error) {
|
|
138
|
+
const message = scrubSecrets(error instanceof Error ? error.message : String(error)).slice(0, 300);
|
|
139
|
+
if (!(error instanceof ConsentStop)) return { ok: false, stop: { kind: "unknown", message, url: "", pageText: "", controls: [] } };
|
|
140
|
+
const looked = error.detail ? void 0 : await look(page);
|
|
141
|
+
const seen = error.detail ?? { kind: "unknown", url: "", pageText: pageExcerpt(looked?.text ?? ""), controls: looked?.controls ?? [] };
|
|
142
|
+
return { ok: false, stop: { ...seen, message } };
|
|
143
|
+
} finally {
|
|
144
|
+
await browser.closeComputerPage(dir, tab).catch(quiet("commands/computer-ops"));
|
|
145
|
+
await browser.releaseComputerBrowser(dir).catch(quiet("commands/computer-ops"));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
async function computerPageRead(url, flags) {
|
|
149
|
+
const { readPage } = await import("./chunk-C6YVCCWR.js");
|
|
150
|
+
const dir = stateDirectory();
|
|
151
|
+
try {
|
|
152
|
+
print(await readPage(dir, url, {
|
|
153
|
+
tab: tabOf(flags.tab, "page"),
|
|
154
|
+
...flags.egress ? { egress: flags.egress } : {},
|
|
155
|
+
...flags.evalFile ? { evaluate: await readText(flags.evalFile) } : {},
|
|
156
|
+
...flags.collect ? { collect: new RegExp(flags.collect, "i") } : {},
|
|
157
|
+
...whole(flags.timeout, "timeout", 1, 120) ? { timeoutMs: whole(flags.timeout, "timeout", 1, 120) * 1e3 } : {},
|
|
158
|
+
...whole(flags.maxBytes, "max-bytes", 1e3, 5e7) ? { maxFileBytes: whole(flags.maxBytes, "max-bytes", 1e3, 5e7) } : {},
|
|
159
|
+
...flags.humanCheck ? { humanCheck: true } : {}
|
|
160
|
+
}));
|
|
161
|
+
} finally {
|
|
162
|
+
await (await import("./chunk-ZFC2Q67K.js")).releaseComputerBrowser(dir).catch(quiet("commands/computer-ops"));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async function computerPageFetch(url, flags) {
|
|
166
|
+
const { fetchInBrowser } = await import("./chunk-C6YVCCWR.js");
|
|
167
|
+
const dir = stateDirectory();
|
|
168
|
+
try {
|
|
169
|
+
print(await fetchInBrowser(dir, url, { tab: tabOf(flags.tab, "page"), ...flags.egress ? { egress: flags.egress } : {}, ...whole(flags.maxBytes, "max-bytes", 1e3, 5e7) ? { maxBytes: whole(flags.maxBytes, "max-bytes", 1e3, 5e7) } : {} }));
|
|
170
|
+
} finally {
|
|
171
|
+
await (await import("./chunk-ZFC2Q67K.js")).releaseComputerBrowser(dir).catch(quiet("commands/computer-ops"));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async function computerTabList() {
|
|
175
|
+
const { readTabRecords } = await import("./chunk-IMZL6SGR.js");
|
|
176
|
+
print({ tabs: (await readTabRecords(stateDirectory())).map((r) => ({ tab: r.tab ?? null, lastUsedAt: new Date(r.lastUsedAt).toISOString(), openedAt: new Date(r.openedAt).toISOString(), ...r.parked ? { parked: true } : {}, ...r.egress ? { egress: r.egress } : {} })) });
|
|
177
|
+
}
|
|
178
|
+
async function computerTabClose(tabs) {
|
|
179
|
+
const { closeTabsByLabel } = await import("./chunk-IMZL6SGR.js");
|
|
180
|
+
const closed = [];
|
|
181
|
+
for (const tab of tabs) {
|
|
182
|
+
tabOf(tab, "");
|
|
183
|
+
if ((await closeTabsByLabel(stateDirectory(), tab).catch(() => [])).length) closed.push(tab);
|
|
184
|
+
}
|
|
185
|
+
print({ closed });
|
|
186
|
+
}
|
|
187
|
+
async function computerDeskFinished(flags) {
|
|
188
|
+
const desk = await import("./chunk-MOU3N2UL.js");
|
|
189
|
+
const dir = stateDirectory();
|
|
190
|
+
if (flags.remove) {
|
|
191
|
+
for (const item of await desk.listDeskItems(dir)) if (item.resume === flags.remove && item.status === "waiting") await desk.removeDeskItem(dir, item.id);
|
|
192
|
+
return print({ removed: flags.remove });
|
|
193
|
+
}
|
|
194
|
+
const items = flags.take ? await desk.takeFinishedResumes(dir) : (await desk.listDeskItems(dir)).filter((item) => item.status === "done" && item.resume && !item.resumeSent);
|
|
195
|
+
print({ finished: items.map((item) => ({ id: item.id, resume: item.resume, kind: item.kind, label: item.label })) });
|
|
196
|
+
}
|
|
197
|
+
async function computerSettings(name, value) {
|
|
198
|
+
const { COMPUTER_TUNABLES, computerTunable, setComputerTunable } = await import("./chunk-YHNIQPKY.js");
|
|
199
|
+
const dir = stateDirectory();
|
|
200
|
+
if (name && value !== void 0) return print({ [name]: await setComputerTunable(dir, name, value) });
|
|
201
|
+
const names = name ? [name] : Object.keys(COMPUTER_TUNABLES);
|
|
202
|
+
const out = {};
|
|
203
|
+
for (const key of names) {
|
|
204
|
+
if (!(key in COMPUTER_TUNABLES)) throw new Error(`No setting "${key}". Settings: ${Object.keys(COMPUTER_TUNABLES).join(", ")}.`);
|
|
205
|
+
const k = key;
|
|
206
|
+
out[key] = { value: await computerTunable(dir, k), default: COMPUTER_TUNABLES[k].default, about: COMPUTER_TUNABLES[k].about };
|
|
207
|
+
}
|
|
208
|
+
print(out);
|
|
209
|
+
}
|
|
210
|
+
async function computerSecretRename(from, to) {
|
|
211
|
+
if (!NAME.test(from) || !NAME.test(to)) throw new Error("Secret names are letters, digits, dots, dashes and slashes.");
|
|
212
|
+
const vault = await import("./chunk-Q35VLJRT.js");
|
|
213
|
+
if (vault.canonicalSecretName(from) === vault.canonicalSecretName(to)) throw new Error(`"${from}" and "${to}" already name the same secret; nothing to rename.`);
|
|
214
|
+
const dir = stateDirectory();
|
|
215
|
+
const info = (await vault.namedSecretInfo(dir)).find((item) => item.name === from);
|
|
216
|
+
const value = info ? await vault.readNamedSecret(dir, from).catch(() => "") : "";
|
|
217
|
+
if (!value) return print({ renamed: false, from, to });
|
|
218
|
+
await vault.saveNamedSecret(dir, to, value, { ...info?.meta?.vendor ? { vendor: info.meta.vendor } : {}, ...info?.meta?.owner ? { owner: info.meta.owner } : {}, ...info?.meta?.url ? { url: info.meta.url } : {}, ...info?.meta?.page ? { page: info.meta.page } : {} }, { legacy: true });
|
|
219
|
+
print({ renamed: await vault.deleteNamedSecret(dir, from), from, to });
|
|
220
|
+
}
|
|
221
|
+
var GENERATED_TOKEN = "generated-token";
|
|
222
|
+
async function computerSecretGenerate(name, flags) {
|
|
223
|
+
if (!NAME.test(name)) throw new Error("The secret name is letters, digits, dots, dashes and slashes.");
|
|
224
|
+
const origin = flags.url.replace(/\/+$/, "");
|
|
225
|
+
if (!/^https:\/\/[a-z0-9.-]+(:\d+)?$/i.test(origin)) throw new Error("--url is the https origin the token is for, e.g. https://example.com");
|
|
226
|
+
const prefix = flags.prefix ?? "";
|
|
227
|
+
if (!/^[A-Za-z0-9_-]{0,20}$/.test(prefix)) throw new Error("--prefix is up to 20 letters, digits, dashes and underscores.");
|
|
228
|
+
const token = `${prefix}${randomBytes(whole(flags.bytes, "bytes", 16, 64) ?? 32).toString("hex")}`;
|
|
229
|
+
const { registerSecret } = await import("./chunk-BMRAEBRY.js");
|
|
230
|
+
registerSecret(token);
|
|
231
|
+
await (await import("./chunk-Q35VLJRT.js")).saveGeneratedToken(stateDirectory(), name, token, origin, { vendor: GENERATED_TOKEN });
|
|
232
|
+
print({ name, url: origin, sha256: createHash("sha256").update(token).digest("hex") });
|
|
233
|
+
}
|
|
234
|
+
async function computerSecretPin(name, flags) {
|
|
235
|
+
const origin = await (await import("./chunk-Q35VLJRT.js")).pinEarlierToken(stateDirectory(), name, flags.url.replace(/\/+$/, ""), GENERATED_TOKEN);
|
|
236
|
+
print({ name, pinned: origin });
|
|
237
|
+
}
|
|
238
|
+
async function computerSecretCall(name, flags) {
|
|
239
|
+
const vault = await import("./chunk-Q35VLJRT.js");
|
|
240
|
+
const dir = stateDirectory();
|
|
241
|
+
const info = (await vault.namedSecretInfo(dir)).find((item) => item.name === name);
|
|
242
|
+
if (!info) throw new Error(`No saved token named "${name}".`);
|
|
243
|
+
const pinned = await vault.pinnedToken(dir, name);
|
|
244
|
+
if (!pinned) throw new Error(`"${name}" was not made by \`clikcode computer secrets generate\` on this computer (or was changed since); only such a token can be used this way.`);
|
|
245
|
+
if (info.meta?.url && info.meta.url !== pinned.origin) throw new Error(`The site recorded for "${name}" (${info.meta.url}) is not the one it was made for (${pinned.origin}); it is not sent.`);
|
|
246
|
+
const origin = pinned.origin;
|
|
247
|
+
let base;
|
|
248
|
+
try {
|
|
249
|
+
base = new URL(origin);
|
|
250
|
+
} catch {
|
|
251
|
+
throw new Error(`The site recorded for "${name}" is not an address.`);
|
|
252
|
+
}
|
|
253
|
+
if (base.protocol !== "https:") throw new Error(`The site recorded for "${name}" is not https.`);
|
|
254
|
+
if (!flags.path.startsWith("/") || flags.path.startsWith("//")) throw new Error("--path is a path on that site, starting with one /.");
|
|
255
|
+
const target = new URL(flags.path, base.origin);
|
|
256
|
+
if (target.origin !== base.origin) throw new Error("--path must stay on the site the token belongs to.");
|
|
257
|
+
const token = pinned.value;
|
|
258
|
+
const { registerSecret, scrubSecrets } = await import("./chunk-BMRAEBRY.js");
|
|
259
|
+
registerSecret(token);
|
|
260
|
+
const headers = { authorization: `Bearer ${token}` };
|
|
261
|
+
for (const line of flags.header ?? []) {
|
|
262
|
+
const at = line.indexOf(":");
|
|
263
|
+
if (at < 1) throw new Error("--header is name: value");
|
|
264
|
+
const key = line.slice(0, at).trim().toLowerCase();
|
|
265
|
+
if (key === "authorization" || key === "host" || key === "cookie") throw new Error(`--header may not set ${key}.`);
|
|
266
|
+
headers[key] = line.slice(at + 1).trim();
|
|
267
|
+
}
|
|
268
|
+
const method = (flags.method ?? (flags.dataFile ? "POST" : "GET")).toUpperCase();
|
|
269
|
+
if (!/^(GET|POST|PUT|PATCH|DELETE)$/.test(method)) throw new Error("--method is GET, POST, PUT, PATCH or DELETE.");
|
|
270
|
+
const response = await fetch(target, { method, headers, ...flags.dataFile ? { body: await readText(flags.dataFile) } : {}, signal: AbortSignal.timeout((whole(flags.timeout, "timeout", 1, 600) ?? 90) * 1e3) });
|
|
271
|
+
print({ status: response.status, contentType: response.headers.get("content-type") ?? "", body: scrubSecrets(await response.text()) });
|
|
272
|
+
}
|
|
273
|
+
export {
|
|
274
|
+
GENERATED_TOKEN,
|
|
275
|
+
agentRun,
|
|
276
|
+
computerDeskFinished,
|
|
277
|
+
computerKeygrab,
|
|
278
|
+
computerKeygrabBackoff,
|
|
279
|
+
computerKeygrabResume,
|
|
280
|
+
computerMcp,
|
|
281
|
+
computerPageFetch,
|
|
282
|
+
computerPageRead,
|
|
283
|
+
computerSecretCall,
|
|
284
|
+
computerSecretGenerate,
|
|
285
|
+
computerSecretPin,
|
|
286
|
+
computerSecretRename,
|
|
287
|
+
computerSettings,
|
|
288
|
+
computerTabClose,
|
|
289
|
+
computerTabList,
|
|
290
|
+
oauthConnectOutcome
|
|
291
|
+
};
|