clikcode 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -14
- package/dist/chunk-23TDEBGZ.js +71 -0
- package/dist/chunk-25T3GVS7.js +425 -0
- package/dist/chunk-2BBELGHY.js +11 -0
- package/dist/chunk-2EOL5PZL.js +208 -0
- package/dist/chunk-2GAB36IE.js +26 -0
- package/dist/chunk-2OLS7V66.js +2440 -0
- package/dist/chunk-2QFO2URB.js +179 -0
- package/dist/chunk-2QWPQRSU.js +254 -0
- package/dist/chunk-2YPAPAR3.js +184 -0
- package/dist/chunk-2ZAG5372.js +33 -0
- package/dist/chunk-32IKAIZC.js +12507 -0
- package/dist/chunk-34AZEGYW.js +95 -0
- package/dist/chunk-34JQYQCA.js +175 -0
- package/dist/chunk-34ZISPAO.js +67 -0
- package/dist/chunk-3AAAARE6.js +46 -0
- package/dist/chunk-3AJ6Q3OY.js +510 -0
- package/dist/chunk-3B2CHX7M.js +884 -0
- package/dist/chunk-3BUFORRX.js +59 -0
- package/dist/chunk-3QLHYYFK.js +30 -0
- package/dist/chunk-3RXBMYKZ.js +140 -0
- package/dist/chunk-3TFNIJWS.js +52 -0
- package/dist/chunk-3W3IPDFP.js +119 -0
- package/dist/chunk-3WMS7SEE.js +417 -0
- package/dist/chunk-435ZNSZ3.js +23 -0
- package/dist/chunk-4AQ5NINV.js +39 -0
- package/dist/chunk-4GVEJ5FK.js +168 -0
- package/dist/chunk-4GXAO3UY.js +262 -0
- package/dist/chunk-4L2ZZM4Q.js +332 -0
- package/dist/chunk-4LPDG57B.js +17 -0
- package/dist/chunk-4NN3XQQT.js +223 -0
- package/dist/chunk-4QZEZME7.js +54 -0
- package/dist/chunk-4R6CSC3S.js +38 -0
- package/dist/chunk-4RHXTL3W.js +514 -0
- package/dist/chunk-4SJMPTVQ.js +18 -0
- package/dist/chunk-4VY7G6TX.js +114 -0
- package/dist/chunk-5642PBF7.js +124 -0
- package/dist/chunk-5B6TVO4A.js +33 -0
- package/dist/chunk-5BJLDUPL.js +62 -0
- package/dist/chunk-5HMFFJWU.js +19 -0
- package/dist/chunk-5IKLK33T.js +69 -0
- package/dist/chunk-5NQ5FFMX.js +44 -0
- package/dist/chunk-5QNNW5L6.js +176 -0
- package/dist/chunk-5SM5UAWN.js +239 -0
- package/dist/chunk-5WYJTA6O.js +74 -0
- package/dist/chunk-5ZSR2Y5T.js +227 -0
- package/dist/chunk-5ZWUM5GH.js +39 -0
- package/dist/chunk-64E7D4HY.js +364 -0
- package/dist/chunk-6CK466BC.js +99 -0
- package/dist/chunk-6ES45HHO.js +138 -0
- package/dist/chunk-6HYEZFGL.js +277 -0
- package/dist/chunk-6Y7HLXGW.js +29 -0
- package/dist/chunk-6YKK4FYR.js +258 -0
- package/dist/chunk-74WNMLMS.js +117 -0
- package/dist/chunk-7AULZ7OD.js +55 -0
- package/dist/chunk-7DOKGSUN.js +101 -0
- package/dist/chunk-7IH5LTIZ.js +195 -0
- package/dist/chunk-7ISTS5NS.js +21 -0
- package/dist/chunk-7NMUTGOW.js +527 -0
- package/dist/chunk-7PNHUZEL.js +153 -0
- package/dist/chunk-7TSQLONI.js +88 -0
- package/dist/chunk-AE7TOLD5.js +30 -0
- package/dist/chunk-AEMHSXKA.js +130 -0
- package/dist/chunk-AKRYTS2D.js +211 -0
- package/dist/chunk-AMNSE36L.js +59 -0
- package/dist/chunk-AZVD74ZV.js +23 -0
- package/dist/chunk-B35DVOTK.js +1981 -0
- package/dist/chunk-B4HNJRAH.js +626 -0
- package/dist/chunk-B5WYPPHS.js +13 -0
- package/dist/chunk-BBOVDXQM.js +59 -0
- package/dist/chunk-BD3ECZLK.js +62 -0
- package/dist/chunk-BDGSOT74.js +4578 -0
- package/dist/chunk-BF5VEOPK.js +31 -0
- package/dist/chunk-BFFRW4XH.js +47 -0
- package/dist/chunk-BFPC6PEW.js +208 -0
- package/dist/chunk-BGEMY2JJ.js +376 -0
- package/dist/chunk-BISGNHKD.js +35 -0
- package/dist/chunk-BMRAEBRY.js +21 -0
- package/dist/chunk-BNTXAZXW.js +127 -0
- package/dist/chunk-BOQBXGSN.js +75 -0
- package/dist/chunk-BTJDSTQP.js +213 -0
- package/dist/chunk-BUOPJQP5.js +218 -0
- package/dist/chunk-BXFJS65Q.js +52 -0
- package/dist/chunk-BXPQFSX5.js +59 -0
- package/dist/chunk-C57LIWNY.js +1269 -0
- package/dist/chunk-C6YVCCWR.js +74 -0
- package/dist/chunk-CAADDF6M.js +167 -0
- package/dist/chunk-CBANJFBO.js +69 -0
- package/dist/chunk-CERF3RIB.js +597 -0
- package/dist/chunk-COAS5ETR.js +46 -0
- package/dist/chunk-CQ7J6UQ7.js +78 -0
- package/dist/chunk-CRUVYGO2.js +26 -0
- package/dist/chunk-CVFVFRGN.js +58 -0
- package/dist/chunk-D2UK66HM.js +37 -0
- package/dist/chunk-D2W7SA4R.js +18 -0
- package/dist/chunk-DA44ZENT.js +501 -0
- package/dist/chunk-DAJ76TOC.js +99 -0
- package/dist/chunk-DCZ6CIUM.js +147 -0
- package/dist/chunk-DF35KMXM.js +1314 -0
- package/dist/chunk-DGASQT26.js +151 -0
- package/dist/chunk-DJT57C5P.js +55 -0
- package/dist/chunk-DKDPZTD3.js +44 -0
- package/dist/chunk-DQYVQ2N7.js +77 -0
- package/dist/chunk-DRTP2RTY.js +266 -0
- package/dist/chunk-DW2BMUKY.js +61 -0
- package/dist/chunk-DW5T5ZVU.js +307 -0
- package/dist/chunk-DXKNDNFC.js +164 -0
- package/dist/chunk-DZEQ7UYR.js +291 -0
- package/dist/chunk-E4F4OUAC.js +463 -0
- package/dist/chunk-EE4B6A7W.js +69 -0
- package/dist/chunk-EISKIYWG.js +23 -0
- package/dist/chunk-EKAQK7UQ.js +235 -0
- package/dist/chunk-EOBTJV32.js +123 -0
- package/dist/chunk-ESF3DIZY.js +325 -0
- package/dist/chunk-EVOHOZ4U.js +45 -0
- package/dist/chunk-EXN4KHLB.js +110 -0
- package/dist/chunk-F252T6Y3.js +78 -0
- package/dist/chunk-F3DP4ZA2.js +40 -0
- package/dist/chunk-F6F47QAY.js +58 -0
- package/dist/chunk-FA3Y23ZW.js +57 -0
- package/dist/chunk-FBKXE4EJ.js +640 -0
- package/dist/chunk-FCGEB3H6.js +23 -0
- package/dist/chunk-FF7ZVYJF.js +3732 -0
- package/dist/chunk-FFGKN6L3.js +39 -0
- package/dist/chunk-FFGU4GCC.js +94 -0
- package/dist/chunk-FSFDAOVP.js +74 -0
- package/dist/chunk-FT5TX7OX.js +1573 -0
- package/dist/chunk-G3QP67Z7.js +232 -0
- package/dist/chunk-G5ORJKV2.js +179 -0
- package/dist/chunk-GFNC62PE.js +111 -0
- package/dist/chunk-GGK43Q3N.js +67 -0
- package/dist/chunk-GGYKY4GF.js +11537 -0
- package/dist/chunk-GGYNHGNJ.js +55 -0
- package/dist/chunk-GLY7RM3C.js +354 -0
- package/dist/chunk-GQBZU6EO.js +20 -0
- package/dist/chunk-GSXENUZL.js +9 -0
- package/dist/chunk-GTOAT5D3.js +40 -0
- package/dist/chunk-GWCMDPQU.js +1007 -0
- package/dist/chunk-GXYSMYHJ.js +152 -0
- package/dist/chunk-GYMAI5NY.js +14 -0
- package/dist/chunk-H2VZMKPE.js +30 -0
- package/dist/chunk-H4THUNBM.js +2091 -0
- package/dist/chunk-HGRVSNUZ.js +361 -0
- package/dist/chunk-HI4VY473.js +27 -0
- package/dist/chunk-HOJRSD3Q.js +447 -0
- package/dist/chunk-HRX25W35.js +82 -0
- package/dist/chunk-HSE4AQYV.js +55 -0
- package/dist/chunk-HU5SSUFX.js +383 -0
- package/dist/chunk-I3GDBJLH.js +196 -0
- package/dist/chunk-I75EDU75.js +684 -0
- package/dist/chunk-IBA7DMIO.js +20 -0
- package/dist/chunk-IC6N4NZA.js +231 -0
- package/dist/chunk-IF43HIGV.js +284 -0
- package/dist/chunk-IGZ6C2MC.js +439 -0
- package/dist/chunk-IMLTL2MY.js +192 -0
- package/dist/chunk-IMZL6SGR.js +33 -0
- package/dist/chunk-IS4USJPY.js +516 -0
- package/dist/chunk-ISFSPN2F.js +82 -0
- package/dist/chunk-IXE7GTFI.js +55 -0
- package/dist/chunk-IZ77QJQG.js +36 -0
- package/dist/chunk-J2PACWRQ.js +34 -0
- package/dist/chunk-J6EGFVQX.js +180 -0
- package/dist/chunk-JEKOD43D.js +22 -0
- package/dist/chunk-JGIWATSG.js +30 -0
- package/dist/chunk-JYBONKD4.js +43 -0
- package/dist/chunk-K2NLG2HK.js +454 -0
- package/dist/chunk-KCQ4TBLS.js +164 -0
- package/dist/chunk-KD5KIVMS.js +176 -0
- package/dist/chunk-KHW6TX6I.js +63 -0
- package/dist/chunk-KI5GZFCE.js +520 -0
- package/dist/chunk-KN34B7NO.js +105 -0
- package/dist/chunk-KYUHIFP3.js +136 -0
- package/dist/chunk-KZL5VS4B.js +300 -0
- package/dist/chunk-L3VW3QIH.js +48 -0
- package/dist/chunk-LA6MG4ET.js +2110 -0
- package/dist/chunk-LAVFOA3S.js +66 -0
- package/dist/chunk-LB4OA77N.js +13 -0
- package/dist/chunk-LBFRF2K4.js +196 -0
- package/dist/chunk-LM6EIA4B.js +93 -0
- package/dist/chunk-LPCNRGJ7.js +692 -0
- package/dist/chunk-LSLNL5T3.js +168 -0
- package/dist/chunk-LVRRWP4W.js +568 -0
- package/dist/chunk-LWCFBRHL.js +33 -0
- package/dist/chunk-LXFTMGZZ.js +166 -0
- package/dist/chunk-M33LVA4M.js +151 -0
- package/dist/chunk-M3FO5UMK.js +4944 -0
- package/dist/chunk-M5QNDBAY.js +66 -0
- package/dist/chunk-M6ND6KBE.js +1291 -0
- package/dist/chunk-M7H3WQTE.js +76 -0
- package/dist/chunk-MCBRVPA7.js +191 -0
- package/dist/chunk-MCSDWZET.js +91 -0
- package/dist/chunk-MDT5XDXL.js +289 -0
- package/dist/chunk-MJG3IQY4.js +91 -0
- package/dist/chunk-MOU3N2UL.js +44 -0
- package/dist/chunk-MP4KZOQC.js +3451 -0
- package/dist/chunk-MPAJ446F.js +66 -0
- package/dist/chunk-MVJZZ6AL.js +16 -0
- package/dist/chunk-MXS6S2PY.js +253 -0
- package/dist/chunk-N3SFDYM7.js +291 -0
- package/dist/chunk-NAOX3JUB.js +13 -0
- package/dist/chunk-NEKKIBCX.js +283 -0
- package/dist/chunk-NKDATMEM.js +133 -0
- package/dist/chunk-NR4FMC4K.js +395 -0
- package/dist/chunk-NSOHOJBR.js +221 -0
- package/dist/chunk-NTDB6QKF.js +29 -0
- package/dist/chunk-NWEYRBWK.js +25 -0
- package/dist/chunk-O2YSNYWD.js +23 -0
- package/dist/chunk-O3EW7LAY.js +54 -0
- package/dist/chunk-O7BNJIXU.js +366 -0
- package/dist/chunk-OARL2NXZ.js +116 -0
- package/dist/chunk-OHKZUEJW.js +351 -0
- package/dist/chunk-OKU45BXA.js +647 -0
- package/dist/chunk-OL4JBD3J.js +59 -0
- package/dist/chunk-OLUO5DDR.js +192 -0
- package/dist/chunk-OQ245JLA.js +196 -0
- package/dist/chunk-P72UZAQI.js +289 -0
- package/dist/chunk-PAL2ENB6.js +20 -0
- package/dist/chunk-PAXYQZH7.js +53 -0
- package/dist/chunk-PDPEM5VW.js +51 -0
- package/dist/chunk-PEWCDI2C.js +668 -0
- package/dist/chunk-PGZ54EDX.js +27 -0
- package/dist/chunk-PRWVLDZF.js +73 -0
- package/dist/chunk-PSQQ75VJ.js +52 -0
- package/dist/chunk-PUOVIFHW.js +118 -0
- package/dist/chunk-PWBF2X3V.js +107 -0
- package/dist/chunk-PWXII6HF.js +43 -0
- package/dist/chunk-Q35VLJRT.js +80 -0
- package/dist/chunk-QJP7EYGL.js +128 -0
- package/dist/chunk-QPQKX2MK.js +8836 -0
- package/dist/chunk-QQRLPY25.js +1053 -0
- package/dist/chunk-QUS4ER2W.js +407 -0
- package/dist/chunk-QYHI3YET.js +29 -0
- package/dist/chunk-QYRU2UQI.js +32 -0
- package/dist/chunk-R6XVVQGC.js +13 -0
- package/dist/chunk-R7QN6ONS.js +483 -0
- package/dist/chunk-RD23MPGC.js +221 -0
- package/dist/chunk-RDDWQBEM.js +185 -0
- package/dist/chunk-RDLLDYFO.js +104 -0
- package/dist/chunk-RE4TGORR.js +84 -0
- package/dist/chunk-RJLHVYQY.js +217 -0
- package/dist/chunk-RJLPTWHW.js +905 -0
- package/dist/chunk-RKUVLRZI.js +295 -0
- package/dist/chunk-ROGXPGYR.js +37 -0
- package/dist/chunk-RSZGEL5U.js +163 -0
- package/dist/chunk-RVUOIJXN.js +909 -0
- package/dist/chunk-RW7F4JRP.js +11 -0
- package/dist/chunk-S4UO3AO3.js +53 -0
- package/dist/chunk-S5JAAF6S.js +585 -0
- package/dist/chunk-SNU37TQI.js +56 -0
- package/dist/chunk-SQVUDO2O.js +31 -0
- package/dist/chunk-SYVHIYQT.js +66 -0
- package/dist/chunk-SZBQMTG2.js +85 -0
- package/dist/chunk-T5VCXA3J.js +25 -0
- package/dist/chunk-TK6NSP56.js +30 -0
- package/dist/chunk-TKWVMA6L.js +22 -0
- package/dist/chunk-TQDKJHWX.js +59 -0
- package/dist/chunk-TQDM7S5N.js +127 -0
- package/dist/chunk-TULAXS77.js +23 -0
- package/dist/chunk-TVT45XNH.js +4625 -0
- package/dist/chunk-TWCVV2JO.js +467 -0
- package/dist/chunk-U4DKAD6S.js +47 -0
- package/dist/chunk-UA5K2BTI.js +564 -0
- package/dist/chunk-UAMKCMOK.js +40 -0
- package/dist/chunk-UBMVADBF.js +51 -0
- package/dist/chunk-UFQ5A5PW.js +645 -0
- package/dist/chunk-UOD2SOLL.js +1301 -0
- package/dist/chunk-UTSB4LOW.js +156 -0
- package/dist/chunk-UVXNIUTN.js +412 -0
- package/dist/chunk-UXVPXYPE.js +90 -0
- package/dist/chunk-UYEEMIWR.js +374 -0
- package/dist/chunk-VBGM5ZBW.js +54 -0
- package/dist/chunk-VEWPCZPG.js +762 -0
- package/dist/chunk-VIRDLZ5E.js +108 -0
- package/dist/chunk-VMPO7WKN.js +52 -0
- package/dist/chunk-W2NVSDO5.js +5122 -0
- package/dist/chunk-W3YYPBEA.js +176 -0
- package/dist/chunk-W5AYOICN.js +280 -0
- package/dist/chunk-W5GZOIUF.js +27 -0
- package/dist/chunk-WHKNLZ3C.js +76 -0
- package/dist/chunk-WKBEPPQ5.js +1409 -0
- package/dist/chunk-WM3Z6QKQ.js +151 -0
- package/dist/chunk-WMI2TPMA.js +31 -0
- package/dist/chunk-WNX5VD7S.js +150 -0
- package/dist/chunk-WOVTYST3.js +60 -0
- package/dist/chunk-WPB5WEZJ.js +546 -0
- package/dist/chunk-WUO5EOAT.js +44 -0
- package/dist/chunk-WWLJMP6D.js +133 -0
- package/dist/chunk-WZMLH3XP.js +58 -0
- package/dist/chunk-WZYVLUVQ.js +79 -0
- package/dist/chunk-X2OCPVU5.js +135 -0
- package/dist/chunk-X3CL6DTR.js +95 -0
- package/dist/chunk-X6WF7JEV.js +354 -0
- package/dist/chunk-XAHGBPWT.js +44 -0
- package/dist/chunk-XCKQ5BM2.js +228 -0
- package/dist/chunk-XIBYREEY.js +106 -0
- package/dist/chunk-XKW5NDMR.js +378 -0
- package/dist/chunk-XRDALAO3.js +100 -0
- package/dist/chunk-XUP22EAS.js +41 -0
- package/dist/chunk-XWAC3MKW.js +243 -0
- package/dist/chunk-Y3R7JMXB.js +59 -0
- package/dist/chunk-Y54LTP4W.js +82 -0
- package/dist/chunk-Y7UECI4M.js +99 -0
- package/dist/chunk-YACGDFHC.js +47 -0
- package/dist/chunk-YHNIQPKY.js +71 -0
- package/dist/chunk-YMBR6HYP.js +111 -0
- package/dist/chunk-YMCH3L2S.js +26 -0
- package/dist/chunk-Z4ZU6T7V.js +99 -0
- package/dist/chunk-ZDPF67ZZ.js +173 -0
- package/dist/chunk-ZFC2Q67K.js +101 -0
- package/dist/chunk-ZGHNNSCT.js +114 -0
- package/dist/chunk-ZGX3ERAT.js +173 -0
- package/dist/chunk-ZI3YHEBY.js +37 -0
- package/dist/chunk-ZN7G6JLS.js +639 -0
- package/dist/chunk-ZNPFQMXT.js +47 -0
- package/dist/chunk-ZOU3LV4U.js +63 -0
- package/dist/chunk-ZT7B4H2V.js +117 -0
- package/dist/chunk-ZZCBDNZI.js +58 -0
- package/dist/cli.js +498 -112593
- package/dist/computer-tools.js +36642 -21258
- package/dist/harness-catalog.cjs +88 -43
- package/dist/index.js +1 -1
- package/dist/local-model-supervisor.cjs +555 -0
- package/package.json +3 -4
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
backgroundOnly,
|
|
5
|
+
callComputerDriver,
|
|
6
|
+
clipboardReply,
|
|
7
|
+
driverElementToken,
|
|
8
|
+
driverNotice,
|
|
9
|
+
driverPermissionNotice,
|
|
10
|
+
driverSupports,
|
|
11
|
+
friendlyDriverError,
|
|
12
|
+
inToolWords,
|
|
13
|
+
latestObservation,
|
|
14
|
+
noElementTokensNotice,
|
|
15
|
+
observedSnapshot,
|
|
16
|
+
rememberObservation,
|
|
17
|
+
summarizeApps,
|
|
18
|
+
unaddressableObservation,
|
|
19
|
+
withTokenLine
|
|
20
|
+
} from "./chunk-OHKZUEJW.js";
|
|
21
|
+
import {
|
|
22
|
+
formatMcpResult
|
|
23
|
+
} from "./chunk-RDLLDYFO.js";
|
|
24
|
+
import {
|
|
25
|
+
openTransport
|
|
26
|
+
} from "./chunk-GLY7RM3C.js";
|
|
27
|
+
import {
|
|
28
|
+
LoginError
|
|
29
|
+
} from "./chunk-BNTXAZXW.js";
|
|
30
|
+
import {
|
|
31
|
+
clikDeployConnection
|
|
32
|
+
} from "./chunk-7AULZ7OD.js";
|
|
33
|
+
import {
|
|
34
|
+
defineTool
|
|
35
|
+
} from "./chunk-2BBELGHY.js";
|
|
36
|
+
import {
|
|
37
|
+
getApiKeyForUrl
|
|
38
|
+
} from "./chunk-TQDM7S5N.js";
|
|
39
|
+
import {
|
|
40
|
+
credentialOnScreen
|
|
41
|
+
} from "./chunk-MP4KZOQC.js";
|
|
42
|
+
import {
|
|
43
|
+
COMPUTER_OFF,
|
|
44
|
+
computerEnabled
|
|
45
|
+
} from "./chunk-5SM5UAWN.js";
|
|
46
|
+
import {
|
|
47
|
+
registerSecret,
|
|
48
|
+
scrubSecrets
|
|
49
|
+
} from "./chunk-CBANJFBO.js";
|
|
50
|
+
|
|
51
|
+
// src/agent/computer/driver-actions.ts
|
|
52
|
+
var DESKTOP_ACTIONS = [
|
|
53
|
+
"windows",
|
|
54
|
+
"apps",
|
|
55
|
+
"observe",
|
|
56
|
+
"click",
|
|
57
|
+
"double_click",
|
|
58
|
+
"right_click",
|
|
59
|
+
"drag",
|
|
60
|
+
"type",
|
|
61
|
+
"key",
|
|
62
|
+
"hotkey",
|
|
63
|
+
"scroll",
|
|
64
|
+
"zoom",
|
|
65
|
+
"launch_app",
|
|
66
|
+
"bring_to_front",
|
|
67
|
+
"invoke_menu",
|
|
68
|
+
"set_window_frame",
|
|
69
|
+
"screen_size",
|
|
70
|
+
"clipboard_read",
|
|
71
|
+
"clipboard_write"
|
|
72
|
+
];
|
|
73
|
+
var INPUT_ACTIONS = /* @__PURE__ */ new Set(["click", "double_click", "right_click", "drag", "type", "key", "hotkey", "scroll"]);
|
|
74
|
+
var WINDOW_STATE_TIMEOUT_MS = 1e4;
|
|
75
|
+
var WINDOW_STATE_MAX_ELEMENTS = 1500;
|
|
76
|
+
var simpleKeys = (keys) => Array.isArray(keys) && keys.length >= 2 && keys.length <= 4 && keys.every((key) => typeof key === "string" && /^[a-z0-9_-]{1,20}$/i.test(key));
|
|
77
|
+
var coordinate = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1e5;
|
|
78
|
+
var signed = (value) => typeof value === "number" && Number.isFinite(value) && Math.abs(value) <= 1e5;
|
|
79
|
+
var dimension = (value) => typeof value === "number" && Number.isFinite(value) && value >= 1 && value <= 1e5;
|
|
80
|
+
var APP_NAME = /^[\p{L}\p{N} ._+@!:-]{1,120}$/u;
|
|
81
|
+
var REVERSE_DNS = /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+$/;
|
|
82
|
+
function launchRequest(args, platform) {
|
|
83
|
+
const launch = {};
|
|
84
|
+
if (args.app !== void 0) {
|
|
85
|
+
if (typeof args.app !== "string" || !APP_NAME.test(args.app) || /^[-\s]|\s-/.test(args.app)) throw new Error("Launch needs an app name or id from apps, with no path and no flags.");
|
|
86
|
+
if (platform === "darwin" && REVERSE_DNS.test(args.app)) launch["bundle_id"] = args.app;
|
|
87
|
+
else if (platform === "win32" && args.app.includes("!")) launch["aumid"] = args.app;
|
|
88
|
+
else launch["name"] = args.app;
|
|
89
|
+
}
|
|
90
|
+
if (args.urls !== void 0) {
|
|
91
|
+
const urls = args.urls;
|
|
92
|
+
const ok = Array.isArray(urls) && urls.length >= 1 && urls.length <= 5 && urls.every((url) => {
|
|
93
|
+
try {
|
|
94
|
+
return typeof url === "string" && url.length <= 2e3 && ["http:", "https:"].includes(new URL(url).protocol);
|
|
95
|
+
} catch {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
if (!ok) throw new Error("Launch urls must be one to five http or https addresses.");
|
|
100
|
+
launch["urls"] = urls;
|
|
101
|
+
}
|
|
102
|
+
if (!Object.keys(launch).length) throw new Error("Launch needs an app (a name or id from apps) or urls.");
|
|
103
|
+
return { name: "launch_app", args: launch };
|
|
104
|
+
}
|
|
105
|
+
function computerDriverAction(args, platform = process.platform) {
|
|
106
|
+
if (args.action === "windows") return { name: "list_windows", args: { on_screen_only: true } };
|
|
107
|
+
if (args.action === "apps") return { name: "list_apps", args: {} };
|
|
108
|
+
if (args.action === "screen_size") return { name: "get_screen_size", args: {} };
|
|
109
|
+
if (args.action === "clipboard_read") return { name: "clipboard_read", args: { include_text: true } };
|
|
110
|
+
if (args.action === "clipboard_write") {
|
|
111
|
+
if (typeof args.text !== "string" || !args.text.length || args.text.length > 2e4) throw new Error("Clipboard write needs text of 1 to 20,000 characters.");
|
|
112
|
+
return { name: "clipboard_write", args: { text: args.text } };
|
|
113
|
+
}
|
|
114
|
+
if (args.action === "launch_app") return launchRequest(args, platform);
|
|
115
|
+
if (args.delivery !== void 0 && args.delivery !== "background" && args.delivery !== "foreground") throw new Error("Delivery is background (the default) or foreground.");
|
|
116
|
+
if (args.delivery === "foreground" && !INPUT_ACTIONS.has(args.action)) throw new Error("Delivery foreground applies only to click, double_click, right_click, drag, type, key, hotkey and scroll.");
|
|
117
|
+
const windowed = args.pid !== void 0 || args.window_id !== void 0;
|
|
118
|
+
if (windowed && (!Number.isSafeInteger(args.pid) || args.pid < 1 || !Number.isSafeInteger(args.window_id) || args.window_id < 0)) {
|
|
119
|
+
throw new Error("Choose an exact window from the windows action, with both pid and window_id.");
|
|
120
|
+
}
|
|
121
|
+
const needWindow = (what) => {
|
|
122
|
+
if (!windowed) throw new Error(`${what} needs an exact window: give pid and window_id from the windows action.`);
|
|
123
|
+
};
|
|
124
|
+
const foreground = args.delivery === "foreground" ? { delivery_mode: "foreground" } : {};
|
|
125
|
+
const base = windowed ? { pid: args.pid, window_id: args.window_id, scope: "window" } : { target: { kind: "desktop", display_id: "primary" } };
|
|
126
|
+
const point = coordinate(args.x) && coordinate(args.y) ? { x: args.x, y: args.y } : void 0;
|
|
127
|
+
const at = windowed && args.element_token ? { element_token: args.element_token } : point;
|
|
128
|
+
switch (args.action) {
|
|
129
|
+
case "observe":
|
|
130
|
+
return windowed ? { name: "get_window_state", args: { pid: args.pid, window_id: args.window_id, max_elements: WINDOW_STATE_MAX_ELEMENTS, timeout_ms: WINDOW_STATE_TIMEOUT_MS, ...args.query ? { query: args.query } : {} } } : { name: "get_desktop_state", args: {} };
|
|
131
|
+
case "click":
|
|
132
|
+
if (!at) throw new Error(windowed ? "Click needs an element_token or x and y from a fresh observation." : "Click needs x and y from a fresh desktop observation.");
|
|
133
|
+
return { name: "click", args: { ...base, ...at, ...foreground } };
|
|
134
|
+
case "double_click":
|
|
135
|
+
case "right_click": {
|
|
136
|
+
if (!at) throw new Error(windowed ? `${args.action === "double_click" ? "Double click" : "Right click"} needs an element_token or x and y from a fresh observation.` : `${args.action === "double_click" ? "Double click" : "Right click"} needs x and y from a fresh desktop observation.`);
|
|
137
|
+
if (windowed) return { name: args.action, args: { pid: args.pid, window_id: args.window_id, ...at, ...foreground } };
|
|
138
|
+
return { name: "click", args: { ...base, ...at, ...args.action === "double_click" ? { count: 2 } : { button: "right" }, ...foreground } };
|
|
139
|
+
}
|
|
140
|
+
case "drag":
|
|
141
|
+
if (!point || !coordinate(args.to_x) || !coordinate(args.to_y)) throw new Error("Drag needs x and y (where to press) and to_x and to_y (where to release), from a fresh observation.");
|
|
142
|
+
return { name: "drag", args: { ...base, from_x: args.x, from_y: args.y, to_x: args.to_x, to_y: args.to_y, ...foreground } };
|
|
143
|
+
case "zoom":
|
|
144
|
+
needWindow("Zoom");
|
|
145
|
+
if (!point || !coordinate(args.to_x) || !coordinate(args.to_y) || args.to_x <= args.x || args.to_y <= args.y) throw new Error("Zoom needs the region corners: x and y (top left) and to_x and to_y (bottom right), in pixels of the latest window observation.");
|
|
146
|
+
return { name: "zoom", args: { pid: args.pid, window_id: args.window_id, x1: args.x, y1: args.y, x2: args.to_x, y2: args.to_y } };
|
|
147
|
+
case "type":
|
|
148
|
+
if (typeof args.text !== "string" || args.text.length > 2e4) throw new Error("Type needs text of at most 20,000 characters.");
|
|
149
|
+
if (windowed && !at) throw new Error("Type needs an element_token or x and y from a fresh observation.");
|
|
150
|
+
return { name: "type_text", args: { ...base, ...at ?? {}, text: args.text, ...foreground } };
|
|
151
|
+
case "key":
|
|
152
|
+
if (!args.key || !/^[A-Za-z0-9_-]{1,30}$/.test(args.key)) throw new Error("Key needs one simple key.");
|
|
153
|
+
return { name: "press_key", args: { ...base, key: args.key, ...foreground } };
|
|
154
|
+
case "hotkey":
|
|
155
|
+
if (!simpleKeys(args.keys)) throw new Error("Hotkey needs two to four simple keys.");
|
|
156
|
+
return { name: "hotkey", args: { ...base, keys: args.keys, ...foreground } };
|
|
157
|
+
case "scroll":
|
|
158
|
+
if (!args.direction || !["up", "down", "left", "right"].includes(args.direction)) throw new Error("Scroll needs a direction.");
|
|
159
|
+
return { name: "scroll", args: { ...base, ...point && !windowed ? point : {}, direction: args.direction, amount: Math.min(10, Math.max(1, Math.floor(args.amount ?? 1))), ...foreground } };
|
|
160
|
+
case "bring_to_front":
|
|
161
|
+
needWindow("Bring to front");
|
|
162
|
+
return { name: "bring_to_front", args: { pid: args.pid, window_id: args.window_id } };
|
|
163
|
+
case "invoke_menu": {
|
|
164
|
+
needWindow("Menu");
|
|
165
|
+
const path = args.path;
|
|
166
|
+
if (!Array.isArray(path) || path.length < 1 || path.length > 16 || !path.every((label) => typeof label === "string" && label.trim().length > 0 && label.length <= 100)) {
|
|
167
|
+
throw new Error('Menu needs a path of one to sixteen menu labels, such as ["File", "Save As..."].');
|
|
168
|
+
}
|
|
169
|
+
return { name: "invoke_menu", args: { pid: args.pid, window_id: args.window_id, path } };
|
|
170
|
+
}
|
|
171
|
+
case "set_window_frame":
|
|
172
|
+
needWindow("Set window frame");
|
|
173
|
+
if (!signed(args.x) || !signed(args.y) || !dimension(args.width) || !dimension(args.height)) throw new Error("Set window frame needs x, y (top left) and width, height, in the units of the windows listing.");
|
|
174
|
+
return { name: "set_window_frame", args: { pid: args.pid, window_id: args.window_id, x: args.x, y: args.y, width: args.width, height: args.height } };
|
|
175
|
+
default:
|
|
176
|
+
throw new Error("Unknown desktop action.");
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// src/agent/tools/computer.ts
|
|
181
|
+
var privateNotice = "A password, code or card number is showing in the ClikCode browser, and a screenshot would show it. Submit or clear the form first.";
|
|
182
|
+
var needsImages = "Zoom returns a picture, and this model cannot see images. Use observe and act on element_token instead.";
|
|
183
|
+
var describeAction = (args) => {
|
|
184
|
+
const where = args.window_id !== void 0 ? `Window ${args.window_id} of process ${args.pid}` : "Primary desktop";
|
|
185
|
+
switch (args.action) {
|
|
186
|
+
case "type":
|
|
187
|
+
return `${where}: type (${args.text?.length ?? 0} characters).`;
|
|
188
|
+
case "clipboard_read":
|
|
189
|
+
return "Read the text on the clipboard (privacy sensitive; anything shaped like a password or key is hidden from the agent).";
|
|
190
|
+
case "clipboard_write":
|
|
191
|
+
return `Replace the clipboard with ${args.text?.length ?? 0} characters of text.`;
|
|
192
|
+
case "launch_app":
|
|
193
|
+
return `Launch ${args.app ?? (args.urls ?? []).join(", ")}.`;
|
|
194
|
+
case "invoke_menu":
|
|
195
|
+
return `${where}: menu ${(args.path ?? []).join(" > ")}.`;
|
|
196
|
+
case "bring_to_front":
|
|
197
|
+
return `${where}: bring to the front (takes focus).`;
|
|
198
|
+
case "windows":
|
|
199
|
+
case "apps":
|
|
200
|
+
case "screen_size":
|
|
201
|
+
return `${args.action === "windows" ? "List windows" : args.action === "apps" ? "List apps" : "Read the screen size"}.`;
|
|
202
|
+
default:
|
|
203
|
+
return `${where}: ${args.action}${args.delivery === "foreground" ? " (foreground: takes focus)" : ""}.`;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
var computerDesktopTool = defineTool({
|
|
207
|
+
name: "computer_use",
|
|
208
|
+
class: "exec",
|
|
209
|
+
description: "Control the local desktop (Linux, macOS, Windows) through cua-driver. Use it for what page tools cannot reach: a browser popup window, a native permission or file dialog, or any other app. `windows` lists windows and `apps` the graphical apps (with `query` it also searches installed ones); `launch_app` opens one by name (or opens urls). Then `observe` and act: click, double_click, right_click, drag (x, y to to_x, to_y), type, key, hotkey, scroll, or `invoke_menu` with a menu path, which is exact and needs no pixels. `zoom` crops a window region (x, y to to_x, to_y) for a closer look; `set_window_frame` moves and sizes a window; `screen_size` gives the display size. With no pid and window_id an action works on the primary desktop by screenshot coordinates; with both (from `windows`) it works on that one window and prefers an element_token: observing a window prints its elements as rows `[N]` and, on its second line, the token of a row (the observation id, a colon, the row number); pass that token, or just the row number for the latest observation of that window. Always observe first; coordinates and tokens expire when the window is observed again. On Linux Wayland a window observe may come back without a screenshot: act on its element_token, which works without one. When a window observe says its rows cannot be used as tokens, do what it says instead of retrying them. Actions run in the background by default and do not move the user's focus. If one is refused because the window must be in front (keys, hotkeys, scrolling and clicks sometimes are, notably on Wayland), you may retry that same action once with delivery \"foreground\", which briefly takes focus from the user and puts it back; do that only when the user can spare it, never by default. `bring_to_front` leaves a window in front, which also takes focus. `clipboard_read` returns the user's clipboard text, which is private: call it only when the user asked you to use what they copied; `clipboard_write` replaces it. Observing the desktop, zooming, or observing the ClikCode browser window is refused while a typed password, code or card number is in a tab on screen. Never type credentials.",
|
|
210
|
+
parameters: { type: "object", additionalProperties: false, required: ["action"], properties: {
|
|
211
|
+
action: { type: "string", enum: [...DESKTOP_ACTIONS] },
|
|
212
|
+
pid: { type: "integer", minimum: 1, description: "Process id from windows, to act on one window." },
|
|
213
|
+
window_id: { type: "integer", minimum: 0, description: "Exact window id from windows, with pid." },
|
|
214
|
+
element_token: { type: "string", description: 'With a window: an element of its latest observe, as the token that observe names (such as "s0000002a:77") or the bare row number ("77").' },
|
|
215
|
+
x: { type: "number", description: "Screenshot x coordinate (desktop or window). For drag and zoom the start or top-left corner; for set_window_frame the left edge." },
|
|
216
|
+
y: { type: "number", description: "Screenshot y coordinate (desktop or window). For drag and zoom the start or top-left corner; for set_window_frame the top edge." },
|
|
217
|
+
to_x: { type: "number", description: "drag: where to release. zoom: the bottom-right corner." },
|
|
218
|
+
to_y: { type: "number", description: "drag: where to release. zoom: the bottom-right corner." },
|
|
219
|
+
width: { type: "number", minimum: 1, description: "set_window_frame: new width, in the units of windows." },
|
|
220
|
+
height: { type: "number", minimum: 1, description: "set_window_frame: new height, in the units of windows." },
|
|
221
|
+
text: { type: "string", description: "Text to type or to put on the clipboard. Never include credentials." },
|
|
222
|
+
key: { type: "string", description: "One key, such as Escape or Enter." },
|
|
223
|
+
keys: { type: "array", items: { type: "string" }, description: 'Hotkey such as ["ctrl", "l"].' },
|
|
224
|
+
direction: { type: "string", enum: ["up", "down", "left", "right"] },
|
|
225
|
+
amount: { type: "integer", minimum: 1, maximum: 10 },
|
|
226
|
+
query: { type: "string", description: "With a window: accessibility tree search for observe. With apps: search installed and running apps by name." },
|
|
227
|
+
app: { type: "string", description: 'launch_app: the app name from apps (macOS: a bundle id such as com.apple.Safari; Windows: a name or package id with "!"). No paths, no flags.' },
|
|
228
|
+
urls: { type: "array", items: { type: "string" }, maxItems: 5, description: "launch_app: http or https addresses to open (in the default browser when no app is given)." },
|
|
229
|
+
path: { type: "array", items: { type: "string" }, minItems: 1, maxItems: 16, description: 'invoke_menu: menu labels from the top menu to the item, such as ["File", "Save As..."].' },
|
|
230
|
+
delivery: { type: "string", enum: ["background", "foreground"], description: 'Click, double_click, right_click, drag, type, key, hotkey, scroll only. "background" (default) never moves focus. "foreground" briefly brings the window to the front, acts, and restores focus: it interrupts the user, so use it only after a background attempt was refused.' }
|
|
231
|
+
} },
|
|
232
|
+
label: (args) => `Desktop ${args.action}${args.window_id !== void 0 ? ` (window ${args.window_id})` : ""}`,
|
|
233
|
+
describe: async (args) => describeAction(args),
|
|
234
|
+
async run(args, ctx) {
|
|
235
|
+
if (!await computerEnabled(ctx.stateDir)) return { output: COMPUTER_OFF, isError: true };
|
|
236
|
+
const picture = args.action === "observe" || args.action === "zoom";
|
|
237
|
+
if (picture && await credentialOnScreen(ctx.stateDir, args.pid)) return { output: privateNotice, isError: true };
|
|
238
|
+
if (args.action === "zoom" && ctx.acceptsImages !== true) return { output: needsImages, isError: true };
|
|
239
|
+
try {
|
|
240
|
+
const windowed = args.pid !== void 0 && args.window_id !== void 0;
|
|
241
|
+
const observed = windowed ? latestObservation(args.pid, args.window_id) : void 0;
|
|
242
|
+
if (args.element_token && observed?.unaddressable && args.action !== "observe") return { output: noElementTokensNotice, isError: true };
|
|
243
|
+
const request = computerDriverAction(windowed && args.element_token ? { ...args, element_token: driverElementToken(args.element_token, observed?.snapshot) } : args);
|
|
244
|
+
const withImage = ctx.acceptsImages === true && picture;
|
|
245
|
+
const driverArgs = request.name === "get_window_state" ? { ...request.args, include_screenshot: withImage } : { ...request.args };
|
|
246
|
+
if (request.name === "get_window_state" && !await driverSupports("get_window_state", "timeout_ms")) delete driverArgs["timeout_ms"];
|
|
247
|
+
const raw = await callComputerDriver(request.name, driverArgs, ctx.signal);
|
|
248
|
+
let result = friendlyDriverError(backgroundOnly(formatMcpResult(raw, withImage), args.delivery === "foreground"));
|
|
249
|
+
result = { ...result, output: inToolWords(result.output) };
|
|
250
|
+
if (request.name === "get_window_state" && !raw.isError) {
|
|
251
|
+
const snapshot = observedSnapshot(raw);
|
|
252
|
+
const unaddressable = unaddressableObservation(raw);
|
|
253
|
+
rememberObservation(args.pid, args.window_id, { ...snapshot ? { snapshot } : {}, ...unaddressable ? { unaddressable } : {} });
|
|
254
|
+
result = { ...result, output: unaddressable ? `${noElementTokensNotice}
|
|
255
|
+
|
|
256
|
+
${result.output}` : withTokenLine(result.output, snapshot) };
|
|
257
|
+
}
|
|
258
|
+
if (args.action === "apps" && !raw.isError) result = { ...result, output: summarizeApps(raw, args.query) ?? result.output };
|
|
259
|
+
if (args.action === "clipboard_read" && !raw.isError) result = { ...result, output: clipboardReply(raw, formatMcpResult(raw).output) };
|
|
260
|
+
if (args.action !== "windows") return result;
|
|
261
|
+
const notices = (await Promise.all([driverNotice(), driverPermissionNotice()])).filter((notice) => Boolean(notice));
|
|
262
|
+
return notices.length ? { ...result, output: `${notices.join("\n")}
|
|
263
|
+
|
|
264
|
+
${result.output}` } : result;
|
|
265
|
+
} catch (error) {
|
|
266
|
+
return { output: error instanceof Error ? error.message : String(error), isError: true };
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
var computerTools = [computerDesktopTool];
|
|
271
|
+
|
|
272
|
+
// src/agent/tools/clikdeploy-step-up.ts
|
|
273
|
+
var connection = () => clikDeployConnection();
|
|
274
|
+
function rememberUnlock(config, codeConfig, url, key, token) {
|
|
275
|
+
config.set("adminMfaToken", token);
|
|
276
|
+
if (config !== codeConfig && getApiKeyForUrl(codeConfig, url) === key) codeConfig.set("adminMfaToken", token);
|
|
277
|
+
}
|
|
278
|
+
function responseError(value) {
|
|
279
|
+
if (!value || typeof value !== "object") return void 0;
|
|
280
|
+
const result = value;
|
|
281
|
+
const content = Array.isArray(result.content) ? result.content : [];
|
|
282
|
+
const text = content.filter((item) => Boolean(item && typeof item === "object" && typeof item.text === "string")).map((item) => item.text).join("\n");
|
|
283
|
+
let data;
|
|
284
|
+
try {
|
|
285
|
+
data = JSON.parse(text);
|
|
286
|
+
} catch {
|
|
287
|
+
}
|
|
288
|
+
if (result.isError === true || data?.error === true) return `${String(data?.code ?? "")} ${String(data?.message ?? data?.detail ?? text)}`.trim();
|
|
289
|
+
return void 0;
|
|
290
|
+
}
|
|
291
|
+
async function unlock(url, key, code, signal) {
|
|
292
|
+
const response = await fetch(`${url}/api/admin/2fa/unlock`, {
|
|
293
|
+
method: "POST",
|
|
294
|
+
headers: { authorization: `Bearer ${key}`, "content-type": "application/json" },
|
|
295
|
+
body: JSON.stringify({ code }),
|
|
296
|
+
signal: signal ?? AbortSignal.timeout(2e4)
|
|
297
|
+
});
|
|
298
|
+
const body = await response.json().catch(() => ({}));
|
|
299
|
+
if (!response.ok || !String(body.data?.token ?? body.token ?? "")) throw new Error(response.status === 400 ? "ClikDeploy rejected the authenticator code." : `ClikDeploy authenticator unlock failed (HTTP ${response.status}).`);
|
|
300
|
+
return String(body.data?.token ?? body.token);
|
|
301
|
+
}
|
|
302
|
+
async function adminCall(url, key, token, password, name, args, signal) {
|
|
303
|
+
const headers = { authorization: `Bearer ${key}`, ...token ? { "x-admin-mfa": token } : {} };
|
|
304
|
+
const transport = openTransport({ name: "clikdeploy", transport: "http", url: `${url}/mcp?toolmode=search`, headers }, {});
|
|
305
|
+
try {
|
|
306
|
+
const options = { timeoutMs: 3e4, ...signal ? { signal } : {} };
|
|
307
|
+
const initialized = await transport.request("initialize", { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "clikcode", version: "1" } }, options);
|
|
308
|
+
if (typeof initialized.protocolVersion === "string") transport.setProtocolVersion(initialized.protocolVersion);
|
|
309
|
+
transport.notify("notifications/initialized");
|
|
310
|
+
if (password) headers["x-superadmin-password"] = password;
|
|
311
|
+
return await transport.request("tools/call", { name: "call_tool", arguments: { name, arguments: { ...args, confirm: true } } }, options);
|
|
312
|
+
} finally {
|
|
313
|
+
delete headers["x-superadmin-password"];
|
|
314
|
+
await transport.close();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
var clikDeployStepUpTool = defineTool({
|
|
318
|
+
name: "clikdeploy_step_up",
|
|
319
|
+
class: "exec",
|
|
320
|
+
description: "Privately ask the user for a ClikDeploy authenticator code and unlock admin mutations immediately (action: unlock). For a specific protected admin tool, action: call executes that tool with a private super admin password if required. Never ask the user to paste either credential into chat or a shell command. The password applies only to this one tool call. Use the ordinary ClikDeploy tool first; use call only after it specifically requires step-up.",
|
|
321
|
+
parameters: { type: "object", additionalProperties: false, required: ["action"], properties: {
|
|
322
|
+
action: { type: "string", enum: ["unlock", "call"] },
|
|
323
|
+
tool: { type: "string", description: "Exact admin_* tool name to retry after a step-up refusal." },
|
|
324
|
+
arguments: { type: "object", description: "The same non-secret arguments as the refused tool call." },
|
|
325
|
+
password: { type: "boolean", description: "Ask privately for the super admin password for this one call." }
|
|
326
|
+
} },
|
|
327
|
+
label: (args) => args.action === "unlock" ? "Unlock ClikDeploy admin" : `Run ${args.tool ?? "ClikDeploy admin tool"} with private step-up`,
|
|
328
|
+
describe: async (args) => args.action === "unlock" ? "Verify a private authenticator code with ClikDeploy and store its admin unlock token." : `Run ClikDeploy ${args.tool ?? "admin tool"} with fields ${Object.keys(args.arguments ?? {}).join(", ").slice(0, 200)}${args.password ? " and a privately entered super admin password" : ""}.`,
|
|
329
|
+
async run(args, ctx) {
|
|
330
|
+
try {
|
|
331
|
+
if (!ctx.requestPrivateSecret) throw new Error("This chat cannot show private prompts. Open it in the terminal or VS Code.");
|
|
332
|
+
const { url, key, config, codeConfig } = connection();
|
|
333
|
+
if (args.action === "unlock") {
|
|
334
|
+
const code = await ctx.requestPrivateSecret("ClikDeploy authenticator", "Enter the current authenticator code to unlock admin changes.", ctx.signal);
|
|
335
|
+
if (!code) return { output: "Authenticator unlock cancelled.", isError: true };
|
|
336
|
+
registerSecret(code);
|
|
337
|
+
const token2 = await unlock(url, key, code, ctx.signal);
|
|
338
|
+
registerSecret(token2);
|
|
339
|
+
rememberUnlock(config, codeConfig, url, key, token2);
|
|
340
|
+
return { output: "ClikDeploy admin changes are unlocked. Retry the protected action." };
|
|
341
|
+
}
|
|
342
|
+
if (!args.tool || !/^admin_[a-z0-9_]+$/.test(args.tool)) throw new Error("Name the exact built-in admin_* tool that requested step-up.");
|
|
343
|
+
const values = args.arguments ?? {};
|
|
344
|
+
if (Object.keys(values).some((key2) => /password|totp|code|token/i.test(key2))) throw new Error("Keep credentials out of tool arguments; this tool asks privately.");
|
|
345
|
+
const action = `${args.tool} ${JSON.stringify(values).slice(0, 300)}`;
|
|
346
|
+
let token = config.get("adminMfaToken");
|
|
347
|
+
if (!token) {
|
|
348
|
+
const code = await ctx.requestPrivateSecret("ClikDeploy authenticator", `Enter the authenticator code to run ${action}.`, ctx.signal);
|
|
349
|
+
if (!code) return { output: "ClikDeploy step-up cancelled.", isError: true };
|
|
350
|
+
registerSecret(code);
|
|
351
|
+
token = await unlock(url, key, code, ctx.signal);
|
|
352
|
+
registerSecret(token);
|
|
353
|
+
rememberUnlock(config, codeConfig, url, key, token);
|
|
354
|
+
}
|
|
355
|
+
let password;
|
|
356
|
+
if (args.password) {
|
|
357
|
+
password = await ctx.requestPrivateSecret("ClikDeploy super admin", `Enter the super admin password to run ${action}. It is used for this action only.`, ctx.signal);
|
|
358
|
+
if (!password) return { output: "ClikDeploy step-up cancelled.", isError: true };
|
|
359
|
+
registerSecret(password);
|
|
360
|
+
}
|
|
361
|
+
const result = await adminCall(url, key, token, password, args.tool, values, ctx.signal);
|
|
362
|
+
const failure = responseError(result);
|
|
363
|
+
if (failure) return { output: scrubSecrets(failure), isError: true };
|
|
364
|
+
return { output: scrubSecrets(JSON.stringify(result).slice(0, 12e3)) };
|
|
365
|
+
} catch (error) {
|
|
366
|
+
return { output: scrubSecrets(error instanceof Error ? error.message : String(error)), isError: true };
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
// src/agent/schema-validate.ts
|
|
372
|
+
function typeOf(value) {
|
|
373
|
+
if (value === null) return "null";
|
|
374
|
+
if (Array.isArray(value)) return "array";
|
|
375
|
+
if (typeof value === "number") return Number.isInteger(value) ? "integer" : "number";
|
|
376
|
+
return typeof value;
|
|
377
|
+
}
|
|
378
|
+
function matchesType(value, expected) {
|
|
379
|
+
const actual = typeOf(value);
|
|
380
|
+
return actual === expected || expected === "number" && actual === "integer";
|
|
381
|
+
}
|
|
382
|
+
function validateAgainstSchema(value, schema, at = "args") {
|
|
383
|
+
const errors = [];
|
|
384
|
+
const types = typeof schema.type === "string" ? [schema.type] : Array.isArray(schema.type) ? schema.type.map(String) : [];
|
|
385
|
+
if (types.length && !types.some((type) => matchesType(value, type))) {
|
|
386
|
+
errors.push(`${at}: expected ${types.join(" or ")}, got ${typeOf(value)}`);
|
|
387
|
+
return errors;
|
|
388
|
+
}
|
|
389
|
+
if (Array.isArray(schema.enum) && !schema.enum.some((option) => option === value)) {
|
|
390
|
+
errors.push(`${at}: must be one of ${schema.enum.map((option) => JSON.stringify(option)).join(", ")}`);
|
|
391
|
+
}
|
|
392
|
+
if (typeof value === "number") {
|
|
393
|
+
if (typeof schema.minimum === "number" && value < schema.minimum) errors.push(`${at}: must be >= ${schema.minimum}`);
|
|
394
|
+
if (typeof schema.maximum === "number" && value > schema.maximum) errors.push(`${at}: must be <= ${schema.maximum}`);
|
|
395
|
+
}
|
|
396
|
+
if (Array.isArray(value) && schema.items && typeof schema.items === "object") {
|
|
397
|
+
value.forEach((entry, index) => errors.push(...validateAgainstSchema(entry, schema.items, `${at}[${index}]`)));
|
|
398
|
+
if (typeof schema.minItems === "number" && value.length < schema.minItems) errors.push(`${at}: needs at least ${schema.minItems} item(s)`);
|
|
399
|
+
}
|
|
400
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
401
|
+
const record = value;
|
|
402
|
+
const properties = schema.properties && typeof schema.properties === "object" ? schema.properties : {};
|
|
403
|
+
for (const key of Array.isArray(schema.required) ? schema.required.map(String) : []) {
|
|
404
|
+
if (record[key] === void 0) errors.push(`${at}.${key}: required property is missing`);
|
|
405
|
+
}
|
|
406
|
+
for (const [key, entry] of Object.entries(record)) {
|
|
407
|
+
if (entry === void 0) continue;
|
|
408
|
+
if (properties[key]) errors.push(...validateAgainstSchema(entry, properties[key], `${at}.${key}`));
|
|
409
|
+
else if (schema.additionalProperties === false) {
|
|
410
|
+
errors.push(`${at}.${key}: unknown property (allowed: ${Object.keys(properties).join(", ") || "none"})`);
|
|
411
|
+
} else if (schema.additionalProperties && typeof schema.additionalProperties === "object") {
|
|
412
|
+
errors.push(...validateAgainstSchema(entry, schema.additionalProperties, `${at}.${key}`));
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return errors;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// src/agent/computer/private-login-prompt.ts
|
|
420
|
+
var ASK = { password: "Enter password", code: "Enter verification code", email: "Enter email", username: "Enter username or email", accountId: "Enter account ID" };
|
|
421
|
+
var askFor = (field) => ASK[field.key] ?? `Enter ${field.label.replace(/[:*]+$/, "").trim().toLowerCase()}`;
|
|
422
|
+
async function askPrivateLogin(observer, site, fields, signal) {
|
|
423
|
+
if (!observer.askQuestions) return void 0;
|
|
424
|
+
if (!fields.length) return void 0;
|
|
425
|
+
const result = await observer.askQuestions({
|
|
426
|
+
title: new URL(site).hostname === "profile.clikcode" ? "Your autofill profile" : `${new URL(site).hostname.replace(/^www\./, "")} ${fields.every((field) => field.key.startsWith("fill")) ? "details" : "sign in"}`,
|
|
427
|
+
questions: fields.map((field) => field.kind === "choice" ? { id: field.key, prompt: field.label, options: (field.options ?? []).map((label) => ({ label })), secret: true } : field.current ? { id: field.key, prompt: field.label, options: [], initial: field.current, secret: true, maskInput: field.kind === "password", ...field.format ? { format: field.format } : {} } : { id: field.key, prompt: askFor(field), options: [], secret: true, maskInput: field.kind === "password", ...field.format ? { format: field.format, maskInput: false } : {}, ...field.required ? {} : { optional: true } })
|
|
428
|
+
}, signal);
|
|
429
|
+
if (result.kind !== "answered") return void 0;
|
|
430
|
+
const values = Object.fromEntries(fields.map((field) => [field.key, result.answers[field.key]?.[0] ?? ""]));
|
|
431
|
+
if (fields.some((field) => field.required && !values[field.key])) throw new LoginError("Complete the visible login fields.");
|
|
432
|
+
for (const field of fields) if (field.kind === "choice" && !field.options?.includes(values[field.key])) throw new LoginError("Choose one of the listed options.");
|
|
433
|
+
return values;
|
|
434
|
+
}
|
|
435
|
+
async function askPrivateChoice(observer, title, prompt, options, signal) {
|
|
436
|
+
if (!observer.askQuestions) return void 0;
|
|
437
|
+
const result = await observer.askQuestions({
|
|
438
|
+
title,
|
|
439
|
+
questions: [{ id: "choice", prompt, options: options.map((label) => ({ label })), secret: true }]
|
|
440
|
+
}, signal);
|
|
441
|
+
if (result.kind !== "answered") return void 0;
|
|
442
|
+
const picked = result.answers.choice?.[0];
|
|
443
|
+
return picked && options.includes(picked) ? picked : void 0;
|
|
444
|
+
}
|
|
445
|
+
async function askPrivateSecret(observer, name, hint, signal) {
|
|
446
|
+
if (!observer.askQuestions) return void 0;
|
|
447
|
+
const result = await observer.askQuestions({
|
|
448
|
+
title: `${name}`,
|
|
449
|
+
questions: [{ id: "secret", prompt: hint, options: [], secret: true, maskInput: true }]
|
|
450
|
+
}, signal);
|
|
451
|
+
if (result.kind !== "answered") return void 0;
|
|
452
|
+
return result.answers.secret?.[0]?.trim() || void 0;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
export {
|
|
456
|
+
computerDesktopTool,
|
|
457
|
+
computerTools,
|
|
458
|
+
clikDeployStepUpTool,
|
|
459
|
+
validateAgainstSchema,
|
|
460
|
+
askPrivateLogin,
|
|
461
|
+
askPrivateChoice,
|
|
462
|
+
askPrivateSecret
|
|
463
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/harness/protocol/format.ts
|
|
5
|
+
function units(ms) {
|
|
6
|
+
const seconds = Math.max(0, Math.floor(ms / 1e3));
|
|
7
|
+
if (seconds < 60) return [seconds, "s"];
|
|
8
|
+
const minutes = Math.floor(seconds / 60);
|
|
9
|
+
if (minutes < 60) return [minutes, "m", seconds % 60, "s"];
|
|
10
|
+
const hours = Math.floor(minutes / 60);
|
|
11
|
+
return hours < 24 ? [hours, "h", minutes % 60, "m"] : [Math.floor(hours / 24), "d", hours % 24, "h"];
|
|
12
|
+
}
|
|
13
|
+
function formatElapsed(ms) {
|
|
14
|
+
const [major, majorUnit, minor, minorUnit] = units(ms);
|
|
15
|
+
return minorUnit === void 0 || !minor ? `${major}${majorUnit}` : `${major}${majorUnit} ${minor}${minorUnit}`;
|
|
16
|
+
}
|
|
17
|
+
function formatDuration(ms) {
|
|
18
|
+
return ms < 1e4 ? `${(Math.max(0, ms) / 1e3).toFixed(1)}s` : formatElapsed(ms);
|
|
19
|
+
}
|
|
20
|
+
function relativeTime(iso, now = Date.now()) {
|
|
21
|
+
if (!iso) return "";
|
|
22
|
+
const then = Date.parse(iso);
|
|
23
|
+
if (Number.isNaN(then)) return "";
|
|
24
|
+
const delta = Math.max(0, now - then);
|
|
25
|
+
if (delta < 45e3) return "just now";
|
|
26
|
+
const minutes = Math.round(delta / 6e4);
|
|
27
|
+
if (minutes < 60) return `${minutes}m ago`;
|
|
28
|
+
const hours = Math.round(delta / 36e5);
|
|
29
|
+
if (hours < 24) return `${hours}h ago`;
|
|
30
|
+
const days = Math.round(delta / 864e5);
|
|
31
|
+
if (days < 7) return `${days}d ago`;
|
|
32
|
+
const date = new Date(then);
|
|
33
|
+
return date.toLocaleDateString(void 0, {
|
|
34
|
+
month: "short",
|
|
35
|
+
day: "numeric",
|
|
36
|
+
...date.getFullYear() === new Date(now).getFullYear() ? {} : { year: "numeric" }
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function quotaResetPhrase(reset, now = Date.now()) {
|
|
40
|
+
const hours24 = reset.getHours();
|
|
41
|
+
const time = `${hours24 % 12 || 12}:${reset.getMinutes().toString().padStart(2, "0")}${hours24 >= 12 ? "PM" : "AM"}`;
|
|
42
|
+
const today = new Date(now);
|
|
43
|
+
const sameDay = reset.getFullYear() === today.getFullYear() && reset.getMonth() === today.getMonth() && reset.getDate() === today.getDate();
|
|
44
|
+
if (sameDay) return time;
|
|
45
|
+
const weekday = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][reset.getDay()];
|
|
46
|
+
const month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][reset.getMonth()];
|
|
47
|
+
return `${time} ${weekday} ${month} ${reset.getDate()}`;
|
|
48
|
+
}
|
|
49
|
+
function compactCount(count) {
|
|
50
|
+
return count < 1e3 ? String(count) : count < 1e6 ? `${(count / 1e3).toFixed(count < 1e4 ? 1 : 0)}k` : `${(count / 1e6).toFixed(1)}M`;
|
|
51
|
+
}
|
|
52
|
+
function dollars(amount) {
|
|
53
|
+
return `$${amount !== 0 && Math.abs(amount) < 0.01 ? amount.toFixed(4) : amount.toFixed(2)}`;
|
|
54
|
+
}
|
|
55
|
+
function tildePath(path, home) {
|
|
56
|
+
if (home === void 0) return path.replace(/^\/home\/[^/]+|^\/Users\/[^/]+|^[A-Z]:\\Users\\[^\\]+/, "~");
|
|
57
|
+
if (path === home) return "~";
|
|
58
|
+
return path.startsWith(`${home}/`) ? `~/${path.slice(home.length + 1)}` : path;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
formatElapsed,
|
|
63
|
+
formatDuration,
|
|
64
|
+
relativeTime,
|
|
65
|
+
quotaResetPhrase,
|
|
66
|
+
compactCount,
|
|
67
|
+
dollars,
|
|
68
|
+
tildePath
|
|
69
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
describeTask,
|
|
5
|
+
listTasks,
|
|
6
|
+
saveTask,
|
|
7
|
+
summarizeTasks,
|
|
8
|
+
taskId
|
|
9
|
+
} from "./chunk-SNU37TQI.js";
|
|
10
|
+
import "./chunk-I75EDU75.js";
|
|
11
|
+
import "./chunk-4L2ZZM4Q.js";
|
|
12
|
+
import "./chunk-F6F47QAY.js";
|
|
13
|
+
import "./chunk-RDDWQBEM.js";
|
|
14
|
+
import "./chunk-MPAJ446F.js";
|
|
15
|
+
import "./chunk-CBANJFBO.js";
|
|
16
|
+
import "./chunk-PWXII6HF.js";
|
|
17
|
+
export {
|
|
18
|
+
describeTask,
|
|
19
|
+
listTasks,
|
|
20
|
+
saveTask,
|
|
21
|
+
summarizeTasks,
|
|
22
|
+
taskId
|
|
23
|
+
};
|