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,640 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
OPENS_ANOTHER_APP,
|
|
5
|
+
PRESSABLE,
|
|
6
|
+
readPageControls
|
|
7
|
+
} from "./chunk-DW2BMUKY.js";
|
|
8
|
+
import {
|
|
9
|
+
connectionState
|
|
10
|
+
} from "./chunk-B4HNJRAH.js";
|
|
11
|
+
import {
|
|
12
|
+
detectBlocker
|
|
13
|
+
} from "./chunk-OQ245JLA.js";
|
|
14
|
+
import {
|
|
15
|
+
saveTask
|
|
16
|
+
} from "./chunk-SNU37TQI.js";
|
|
17
|
+
import {
|
|
18
|
+
quiet
|
|
19
|
+
} from "./chunk-RDDWQBEM.js";
|
|
20
|
+
import {
|
|
21
|
+
scrubSecrets
|
|
22
|
+
} from "./chunk-CBANJFBO.js";
|
|
23
|
+
|
|
24
|
+
// src/agent/computer/oauth-consent.ts
|
|
25
|
+
import { spawn } from "node:child_process";
|
|
26
|
+
var NEVER = /\b(deny|cancel|decline|reject|no thanks|not now|sign out|log ?out|remove|delete|back|create (?:an )?account|sign ?up|forgot)\b/i;
|
|
27
|
+
var CONSENT_PROVIDERS = [
|
|
28
|
+
{ id: "google", host: /(^|\.)accounts\.google\.com$|(^|\.)google\.com$/i, actions: [
|
|
29
|
+
{ note: "Continued past the unverified-app notice.", name: /^go to .*\(unsafe\)$/i, notice: true },
|
|
30
|
+
{ note: "Opened Advanced.", name: /^advanced$/i, leaf: true, notice: true },
|
|
31
|
+
{ note: "Allowed access.", name: /^(continue|allow|allow all)$/i },
|
|
32
|
+
{ note: "Acknowledged the notice.", name: /^i understand$/i, notice: true }
|
|
33
|
+
] },
|
|
34
|
+
{ id: "microsoft", host: /(^|\.)(login\.microsoftonline\.com|login\.live\.com|microsoft\.com)$/i, actions: [
|
|
35
|
+
{ note: "Accepted the permissions.", name: /^accept$/i },
|
|
36
|
+
{ note: "Declined to stay signed in.", name: /^no$/i, when: /stay signed in/i }
|
|
37
|
+
] },
|
|
38
|
+
{ id: "github", host: /(^|\.)github\.com$/i, actions: [
|
|
39
|
+
{ note: "Authorized the app.", name: /^authori[sz]e\b[\w .-]{0,60}$/i }
|
|
40
|
+
] },
|
|
41
|
+
{ id: "slack", host: /(^|\.)slack\.com$/i, actions: [
|
|
42
|
+
{ note: "Allowed access.", name: /^(allow|authori[sz]e)$/i }
|
|
43
|
+
] },
|
|
44
|
+
{ id: "atlassian", host: /(^|\.)(atlassian\.com|atlassian\.net)$/i, actions: [
|
|
45
|
+
{ note: "Accepted access.", name: /^(accept|allow access)$/i }
|
|
46
|
+
] },
|
|
47
|
+
{ id: "notion", host: /(^|\.)notion\.(so|com)$/i, actions: [
|
|
48
|
+
{ note: "Allowed access.", name: /^(allow access|select pages|grant access)$/i }
|
|
49
|
+
] }
|
|
50
|
+
];
|
|
51
|
+
var GENERIC_ACTIONS = [
|
|
52
|
+
{ note: "Allowed access.", name: /^(allow( access)?|authori[sz]e( (app|access))?|accept|accept and continue|grant access|approve)$/i },
|
|
53
|
+
{ note: "Continued on the permission screen.", name: /^continue$/i, when: /\b(access|permissions?|authori[sz]e|wants to|allow)\b/i }
|
|
54
|
+
];
|
|
55
|
+
var providerFor = (host) => CONSENT_PROVIDERS.find((p) => p.host.test(host));
|
|
56
|
+
var NOT_CHOOSER = /\b(sign out|log ?out|switch|remove|use another|add (?:an )?account|different account)\b/i;
|
|
57
|
+
function namesClient(controls, pageText, options) {
|
|
58
|
+
const names = (options.appNames ?? []).filter(Boolean).map((n) => n.toLowerCase());
|
|
59
|
+
const lower = pageText.toLowerCase();
|
|
60
|
+
return names.some((n) => lower.includes(n)) || !!options.redirectHost && lower.includes(options.redirectHost.toLowerCase()) || controls.some((c) => !c.leaf && names.some((n) => c.name.toLowerCase().includes(n)));
|
|
61
|
+
}
|
|
62
|
+
var UNSAFE_NOTICE_APP = /^go to (.*) \(unsafe\)$/i;
|
|
63
|
+
var AFFIRMATIVE = /^(?:authori[sz]e(?: [\w .'&-]{1,60})?|allow(?: access| all)?|approve(?: [\w .'&-]{1,40})?|accept(?: and continue)?|grant(?: access| permission)?|continue as [\w .'@+-]{1,80})$/i;
|
|
64
|
+
var NEGATIVE = /^(?:cancel|deny|decline|reject|no,? thanks|not now|do not allow)$/i;
|
|
65
|
+
function readConsent(controls, pageText, options = {}) {
|
|
66
|
+
if (classifyStuck(pageText) || detectBlocker(pageText) === "a captcha") return { consent: false };
|
|
67
|
+
const names = (options.appNames ?? []).filter(Boolean);
|
|
68
|
+
const lower = pageText.toLowerCase();
|
|
69
|
+
const mentions = names.some((n) => lower.includes(n.toLowerCase())) || !!options.redirectHost && lower.includes(options.redirectHost.toLowerCase()) || controls.some((c) => !c.leaf && names.some((n) => c.name.toLowerCase().includes(n.toLowerCase())) && AFFIRMATIVE.test(c.name));
|
|
70
|
+
if (!mentions) return { consent: false };
|
|
71
|
+
const presses = controls.filter((c) => !c.leaf);
|
|
72
|
+
if (!presses.some((c) => NEGATIVE.test(c.name))) return { consent: false };
|
|
73
|
+
const index = controls.findIndex((c) => !c.leaf && c.name.length <= 100 && !NEVER.test(c.name) && AFFIRMATIVE.test(c.name));
|
|
74
|
+
return index >= 0 ? { consent: true, index } : { consent: false };
|
|
75
|
+
}
|
|
76
|
+
var SELECT_ALL = /^select all\b/i;
|
|
77
|
+
var NOT_A_SCOPE = /\b(newsletter|marketing|promotion|offers?|subscribe|remember|keep me|stay signed|don'?t ask|do not ask|terms|privacy|robot|human)\b/i;
|
|
78
|
+
function scopeTicks(boxes, pageText, options = {}) {
|
|
79
|
+
if (!boxes.length || classifyStuck(pageText) || detectBlocker(pageText) === "a captcha") return [];
|
|
80
|
+
const lower = pageText.toLowerCase();
|
|
81
|
+
const names = (options.appNames ?? []).filter(Boolean);
|
|
82
|
+
if (!(names.some((n) => lower.includes(n.toLowerCase())) || !!options.redirectHost && lower.includes(options.redirectHost.toLowerCase()))) return [];
|
|
83
|
+
const scopes = boxes.filter((b) => !NOT_A_SCOPE.test(b.name));
|
|
84
|
+
const all = scopes.find((b) => SELECT_ALL.test(b.name.trim()));
|
|
85
|
+
if (all) return all.checked && scopes.every((b) => b.checked) ? [] : all.checked ? scopes.filter((b) => !b.checked).map((b) => b.index) : [all.index];
|
|
86
|
+
return scopes.filter((b) => !b.checked).map((b) => b.index);
|
|
87
|
+
}
|
|
88
|
+
var scopesTicked = (boxes) => boxes.filter((b) => !NOT_A_SCOPE.test(b.name)).every((b) => b.checked);
|
|
89
|
+
var SIGN_IN_PROVIDERS = [/^(?:continue|sign ?(?:in|up)|log ?in)\s+(?:in\s+)?(?:with|using|via)\s+google\b/i, /^(?:continue|sign ?(?:in|up)|log ?in)\s+(?:in\s+)?(?:with|using|via)\s+github\b/i];
|
|
90
|
+
function googleStep(url, pageText) {
|
|
91
|
+
let path = "";
|
|
92
|
+
try {
|
|
93
|
+
path = new URL(url).pathname;
|
|
94
|
+
} catch {
|
|
95
|
+
return void 0;
|
|
96
|
+
}
|
|
97
|
+
if (/\/signin\/oauth\/error\b/.test(path)) return "error";
|
|
98
|
+
if (/\/signin\/challenge\b|\/challenge\//.test(path)) return "challenge";
|
|
99
|
+
if (/\/signin\/oauth\/warning\b/.test(path) || /hasn.t verified this app/i.test(pageText)) return "warning";
|
|
100
|
+
if (/\/signin\/oauth\/(?:v\d+\/)?consent\b/.test(path) || /wants (?:additional )?access to your google account/i.test(pageText)) return "consent";
|
|
101
|
+
if (/\/signin\/oauth\/id\b/.test(path) || /signing back in to/i.test(pageText)) return "identity";
|
|
102
|
+
if (/accountchooser/i.test(path) || /\bchoose an account\b/i.test(pageText)) return "chooser";
|
|
103
|
+
return void 0;
|
|
104
|
+
}
|
|
105
|
+
function nextPress(host, controls, pageText, options = {}) {
|
|
106
|
+
const email = options.email?.trim().toLowerCase();
|
|
107
|
+
if (email && !options.skipAccount && options.account !== false) {
|
|
108
|
+
const i = controls.findIndex((c) => !c.leaf && c.name.toLowerCase().includes(email) && !NOT_CHOOSER.test(c.name));
|
|
109
|
+
if (i >= 0) return { index: i, note: "Chose the account.", phase: "account" };
|
|
110
|
+
}
|
|
111
|
+
if (classifyStuck(pageText)) return void 0;
|
|
112
|
+
const table = [...providerFor(host)?.actions ?? [], ...GENERIC_ACTIONS];
|
|
113
|
+
for (const action of table) {
|
|
114
|
+
if (action.when && !action.when.test(pageText)) continue;
|
|
115
|
+
const i = controls.findIndex((c) => (action.leaf || !c.leaf) && c.name.length <= 80 && !NEVER.test(c.name) && action.name.test(c.name));
|
|
116
|
+
if (i < 0) continue;
|
|
117
|
+
if (options.requireClient) {
|
|
118
|
+
const unsafe = UNSAFE_NOTICE_APP.exec(controls[i].name.trim());
|
|
119
|
+
if (unsafe && !(options.appNames ?? []).some((n) => n && unsafe[1].toLowerCase().includes(n.toLowerCase()))) return void 0;
|
|
120
|
+
if (!(action.notice && !unsafe) && !namesClient(controls, pageText, options)) return void 0;
|
|
121
|
+
}
|
|
122
|
+
return { index: i, note: action.note, phase: action.notice ? "notice" : "grant", ...AFFIRMATIVE.test(controls[i].name) ? { consent: true } : {} };
|
|
123
|
+
}
|
|
124
|
+
const read = readConsent(controls, pageText, { ...options.appNames ? { appNames: options.appNames } : {}, ...options.redirectHost ? { redirectHost: options.redirectHost } : {} });
|
|
125
|
+
if (read.consent && read.index !== void 0) return { index: read.index, note: "Granted access on the consent screen.", phase: "grant", consent: true };
|
|
126
|
+
for (const [rank, re] of SIGN_IN_PROVIDERS.entries()) {
|
|
127
|
+
const i = controls.findIndex((c) => !c.leaf && re.test(c.name.replace(/\s*last used\s*$/i, "").trim()));
|
|
128
|
+
if (i >= 0) return { index: i, note: rank === 0 ? "Signed in with Google." : "Signed in with GitHub.", phase: "sign-in" };
|
|
129
|
+
}
|
|
130
|
+
return void 0;
|
|
131
|
+
}
|
|
132
|
+
function decideSelectors(selectors) {
|
|
133
|
+
const choose = [];
|
|
134
|
+
for (const [i, s] of selectors.entries()) {
|
|
135
|
+
if (s.selected) continue;
|
|
136
|
+
if (s.options.length === 1) {
|
|
137
|
+
choose.push({ selector: i, option: s.options[0] });
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
return { stop: `The consent page needs a choice${s.label ? ` ("${s.label}")` : ""} and offers ${s.options.length ? `${s.options.length} options: ${s.options.slice(0, 12).join(" | ")}` : "none"}. Nothing was pressed; tell me which one to use.` };
|
|
141
|
+
}
|
|
142
|
+
return { choose };
|
|
143
|
+
}
|
|
144
|
+
function stopReason(pageText, hasPasswordBox, hasCodeBox) {
|
|
145
|
+
const blocker = detectBlocker(pageText);
|
|
146
|
+
if (blocker === "a captcha") return "a captcha";
|
|
147
|
+
if (hasPasswordBox) return "a login password (sign in first with the login action, which uses the saved login or Google)";
|
|
148
|
+
if (hasCodeBox || blocker === "an SMS or authenticator code") return "a verification code (MFA)";
|
|
149
|
+
return void 0;
|
|
150
|
+
}
|
|
151
|
+
function callbackState(url, redirectUri, pageText, ownsCallback = () => false) {
|
|
152
|
+
let here;
|
|
153
|
+
try {
|
|
154
|
+
here = new URL(url);
|
|
155
|
+
} catch {
|
|
156
|
+
return "elsewhere";
|
|
157
|
+
}
|
|
158
|
+
let target;
|
|
159
|
+
try {
|
|
160
|
+
target = redirectUri ? new URL(redirectUri) : void 0;
|
|
161
|
+
} catch {
|
|
162
|
+
target = void 0;
|
|
163
|
+
}
|
|
164
|
+
const onCallback = target ? here.origin === target.origin && here.pathname === target.pathname : ownsCallback(here) && /\/oauth\/callback\b|\/callback\b/.test(here.pathname);
|
|
165
|
+
if (!onCallback) return "elsewhere";
|
|
166
|
+
if (/\b(error|denied|failed|invalid|expired|not connected|something went wrong)\b/i.test(pageText) && !/\bconnected\b/i.test(pageText.replace(/not connected/gi, ""))) return "problem";
|
|
167
|
+
if (/\b(connected|success|successfully|authori[sz]ed|you can (?:now )?close|all set)\b/i.test(pageText)) return "connected";
|
|
168
|
+
return "waiting";
|
|
169
|
+
}
|
|
170
|
+
var CONNECTOR_ID = /^[A-Za-z0-9][\w.-]{0,60}$/;
|
|
171
|
+
var ERROR_ADDRESS = /^https?:\/\/errors\.clikdeploy\.com(?:\/|$)/i;
|
|
172
|
+
var URL_KEYS = ["authorizationUrl", "authorization_url", "authorizeUrl", "url"];
|
|
173
|
+
function jsonOf(text) {
|
|
174
|
+
const start = text.indexOf("{");
|
|
175
|
+
if (start < 0) return void 0;
|
|
176
|
+
try {
|
|
177
|
+
return JSON.parse(text.slice(start));
|
|
178
|
+
} catch {
|
|
179
|
+
return void 0;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function isErrorDocument(value) {
|
|
183
|
+
if (!value || typeof value !== "object") return false;
|
|
184
|
+
const v = value;
|
|
185
|
+
return v.success === false || v.status === "error" || typeof v.type === "string" && ERROR_ADDRESS.test(v.type) || typeof v.error === "string" || typeof v.status === "number" && v.status >= 400;
|
|
186
|
+
}
|
|
187
|
+
function authorizationProblem(raw, ownsCallback, options = {}) {
|
|
188
|
+
let url;
|
|
189
|
+
try {
|
|
190
|
+
url = new URL(raw);
|
|
191
|
+
} catch {
|
|
192
|
+
return "it is not an address";
|
|
193
|
+
}
|
|
194
|
+
const loopback = /^(?:127\.\d+\.\d+\.\d+|localhost|\[::1\])$/i.test(url.hostname);
|
|
195
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && loopback)) return `it is not https (${url.protocol}//${url.host})`;
|
|
196
|
+
const redirect = url.searchParams.get("redirect_uri");
|
|
197
|
+
if (options.strict && (!url.searchParams.get("client_id") || !redirect)) return `${url.host}${url.pathname} is not an OAuth authorization request (no client_id and redirect_uri)`;
|
|
198
|
+
if (redirect) {
|
|
199
|
+
let back;
|
|
200
|
+
try {
|
|
201
|
+
back = new URL(redirect);
|
|
202
|
+
} catch {
|
|
203
|
+
return "its redirect_uri is not an address";
|
|
204
|
+
}
|
|
205
|
+
if (!ownsCallback(back)) return `it sends the authorization to ${back.host}, which is not the platform's callback`;
|
|
206
|
+
}
|
|
207
|
+
return void 0;
|
|
208
|
+
}
|
|
209
|
+
function authorizationUrl(text, ownsCallback = ownsClikDeployCallback) {
|
|
210
|
+
const json = jsonOf(text);
|
|
211
|
+
if (json !== void 0) {
|
|
212
|
+
if (isErrorDocument(json)) return void 0;
|
|
213
|
+
const walk = (value) => {
|
|
214
|
+
if (value && typeof value === "object") {
|
|
215
|
+
const record = value;
|
|
216
|
+
for (const key of URL_KEYS) {
|
|
217
|
+
const v = record[key];
|
|
218
|
+
if (typeof v === "string" && /^https?:\/\//.test(v) && !ERROR_ADDRESS.test(v) && !authorizationProblem(v, ownsCallback)) return v;
|
|
219
|
+
}
|
|
220
|
+
for (const v of Object.values(record)) {
|
|
221
|
+
const found2 = walk(v);
|
|
222
|
+
if (found2) return found2;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return void 0;
|
|
226
|
+
};
|
|
227
|
+
const found = walk(json);
|
|
228
|
+
if (found) return found;
|
|
229
|
+
}
|
|
230
|
+
for (const m of text.matchAll(/https?:\/\/[^\s"'<>]+/g)) {
|
|
231
|
+
const url = m[0].replace(/[.,;)]+$/, "");
|
|
232
|
+
if (!ERROR_ADDRESS.test(url) && !authorizationProblem(url, ownsCallback, { strict: true })) return url;
|
|
233
|
+
}
|
|
234
|
+
return void 0;
|
|
235
|
+
}
|
|
236
|
+
function startFailure(text) {
|
|
237
|
+
const json = jsonOf(text);
|
|
238
|
+
const pick = (v) => typeof v === "string" && v.trim() ? v.split("\n")[0].trim() : void 0;
|
|
239
|
+
const said = json && typeof json === "object" ? pick(json.message) ?? pick(json.detail) ?? pick(json.error) ?? pick(json.title) : void 0;
|
|
240
|
+
return said ?? text.trim().split("\n").slice(-3).join(" ").slice(0, 200);
|
|
241
|
+
}
|
|
242
|
+
var ownsClikDeployCallback = (url) => url.protocol === "https:" && /(^|\.)clikdeploy\.com$/i.test(url.hostname);
|
|
243
|
+
function startViaCli(connector, signal) {
|
|
244
|
+
return new Promise((resolve, reject) => {
|
|
245
|
+
const child = spawn("clikdeploy", ["integrations", "connect", connector, "--no-browser"], { stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
|
|
246
|
+
let text = "";
|
|
247
|
+
let settled = false;
|
|
248
|
+
const stop = () => {
|
|
249
|
+
child.kill();
|
|
250
|
+
};
|
|
251
|
+
const timer = setTimeout(() => {
|
|
252
|
+
if (!settled) {
|
|
253
|
+
settled = true;
|
|
254
|
+
stop();
|
|
255
|
+
reject(new Error("ClikDeploy did not return an authorization URL within a minute."));
|
|
256
|
+
}
|
|
257
|
+
}, 6e4);
|
|
258
|
+
const look = (final) => {
|
|
259
|
+
if (settled) return;
|
|
260
|
+
const url = authorizationUrl(text);
|
|
261
|
+
if (url) {
|
|
262
|
+
settled = true;
|
|
263
|
+
clearTimeout(timer);
|
|
264
|
+
resolve({ url, stop });
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (final) {
|
|
268
|
+
settled = true;
|
|
269
|
+
clearTimeout(timer);
|
|
270
|
+
const said = startFailure(text);
|
|
271
|
+
reject(new Error(`ClikDeploy would not start the connection for ${connector}: ${scrubSecrets(said) || "no answer"}`));
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
const feed = (chunk) => {
|
|
275
|
+
text = (text + String(chunk)).slice(-2e4);
|
|
276
|
+
look(false);
|
|
277
|
+
};
|
|
278
|
+
child.stdout.on("data", feed);
|
|
279
|
+
child.stderr.on("data", feed);
|
|
280
|
+
child.once("error", (error) => {
|
|
281
|
+
if (settled) return;
|
|
282
|
+
settled = true;
|
|
283
|
+
clearTimeout(timer);
|
|
284
|
+
reject(new Error(error.code === "ENOENT" ? "The clikdeploy command is not installed on this computer." : error.message));
|
|
285
|
+
});
|
|
286
|
+
child.once("close", () => look(true));
|
|
287
|
+
signal?.addEventListener("abort", stop, { once: true });
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
var CLIKDEPLOY_PLATFORM = {
|
|
291
|
+
appNames: ["ClikDeploy"],
|
|
292
|
+
ownsCallback: ownsClikDeployCallback,
|
|
293
|
+
start: startViaCli,
|
|
294
|
+
status: (id, signal) => connectionState(id, signal)
|
|
295
|
+
};
|
|
296
|
+
async function readControls(page) {
|
|
297
|
+
return page.evaluate(readPageControls, { pressable: PRESSABLE, otherApp: OPENS_ANOTHER_APP.source, cap: 1500, identifiers: true });
|
|
298
|
+
}
|
|
299
|
+
var PLACEHOLDER = /^(?:select|choose|pick|-+|—|–)\b|^$/i;
|
|
300
|
+
async function readSelectors(page) {
|
|
301
|
+
const found = [];
|
|
302
|
+
const natives = await page.evaluate(() => {
|
|
303
|
+
const doc = globalThis.document;
|
|
304
|
+
return Array.from(doc.querySelectorAll("select")).filter((n) => n.getClientRects().length).map((n) => {
|
|
305
|
+
const label = (n.getAttribute("aria-label") || n.labels?.[0]?.textContent || "").replace(/\s+/g, " ").trim();
|
|
306
|
+
const options = Array.from(n.options).map((o) => ({ text: String(o.textContent ?? "").replace(/\s+/g, " ").trim(), value: String(o.value ?? ""), selected: !!o.selected, disabled: !!o.disabled }));
|
|
307
|
+
return { label, options };
|
|
308
|
+
});
|
|
309
|
+
}).catch(() => []);
|
|
310
|
+
for (const n of natives) {
|
|
311
|
+
const real = n.options.filter((o) => o.value !== "" && !o.disabled && !PLACEHOLDER.test(o.text));
|
|
312
|
+
const chosen = n.options.find((o) => o.selected && o.value !== "" && !PLACEHOLDER.test(o.text));
|
|
313
|
+
found.push({ label: n.label, options: real.map((o) => o.text), ...chosen ? { selected: chosen.text } : {} });
|
|
314
|
+
}
|
|
315
|
+
const boxes = page.locator("[role=combobox]:visible, button[aria-haspopup=listbox]:visible");
|
|
316
|
+
const count = Math.min(await boxes.count().catch(() => 0), 4);
|
|
317
|
+
for (let i = 0; i < count; i++) {
|
|
318
|
+
const box = boxes.nth(i);
|
|
319
|
+
const shown = (await box.innerText({ timeout: 1e3 }).catch(() => "") || "").replace(/\s+/g, " ").trim();
|
|
320
|
+
const label = (await box.getAttribute("aria-label").catch(() => "") || "").trim();
|
|
321
|
+
if (shown && !PLACEHOLDER.test(shown)) {
|
|
322
|
+
found.push({ label, options: [shown], selected: shown });
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
await box.click({ timeout: 2e3 }).catch(quiet("agent/computer/oauth-consent"));
|
|
326
|
+
const options = (await page.locator("[role=option]:visible").allInnerTexts().catch(() => [])).map((t) => t.replace(/\s+/g, " ").trim()).filter((t) => t && !PLACEHOLDER.test(t));
|
|
327
|
+
await page.keyboard.press("Escape").catch(quiet("agent/computer/oauth-consent"));
|
|
328
|
+
found.push({ label: label || shown, options });
|
|
329
|
+
}
|
|
330
|
+
return found;
|
|
331
|
+
}
|
|
332
|
+
async function settleSelectors(page) {
|
|
333
|
+
const selectors = await readSelectors(page);
|
|
334
|
+
const plan = decideSelectors(selectors);
|
|
335
|
+
if ("stop" in plan) return plan.stop;
|
|
336
|
+
for (const { selector, option } of plan.choose) {
|
|
337
|
+
const native = page.locator("select:visible");
|
|
338
|
+
const n = await native.count().catch(() => 0);
|
|
339
|
+
const chosen = selector < n ? await native.nth(selector).selectOption({ label: option }, { timeout: 3e3 }).then(() => true, () => false) : await clickNode(page.locator("[role=combobox]:visible, button[aria-haspopup=listbox]:visible").nth(selector - n)) && await clickNode(page.getByRole("option", { name: option }).first());
|
|
340
|
+
if (!chosen) return `The consent page's only choice (${option}) could not be selected. Nothing was pressed.`;
|
|
341
|
+
}
|
|
342
|
+
return void 0;
|
|
343
|
+
}
|
|
344
|
+
var BOXES = "input[type=checkbox], [role=checkbox]";
|
|
345
|
+
async function readScopeBoxes(page) {
|
|
346
|
+
return page.evaluate((selector) => {
|
|
347
|
+
const doc = globalThis.document;
|
|
348
|
+
const all = Array.from(doc.querySelectorAll(selector));
|
|
349
|
+
const out = [];
|
|
350
|
+
all.forEach((n, index) => {
|
|
351
|
+
const holder = n.closest?.("label") ?? n.parentElement;
|
|
352
|
+
if (!n.getClientRects().length && !holder?.getClientRects().length) return;
|
|
353
|
+
let name = String(n.getAttribute("aria-label") || n.labels?.[0]?.textContent || "").replace(/\s+/g, " ").trim();
|
|
354
|
+
for (let up = n.parentElement, depth = 0; !name && up && depth < 8; up = up.parentElement, depth++) {
|
|
355
|
+
if (Array.from(up.querySelectorAll(selector)).length > 1) break;
|
|
356
|
+
name = String(up.textContent ?? "").replace(/\s+/g, " ").trim();
|
|
357
|
+
}
|
|
358
|
+
out.push({ index, name: name.slice(0, 120), checked: n.checked === true || n.getAttribute("aria-checked") === "true" });
|
|
359
|
+
});
|
|
360
|
+
return out;
|
|
361
|
+
}, BOXES);
|
|
362
|
+
}
|
|
363
|
+
async function clickNode(node, timeout = 3e3) {
|
|
364
|
+
await node.scrollIntoViewIfNeeded({ timeout: 1500 }).catch(quiet("agent/computer/oauth-consent"));
|
|
365
|
+
if (await node.click({ timeout }).then(() => true, () => false)) return true;
|
|
366
|
+
if (await node.click({ timeout: 1500, force: true }).then(() => true, () => false)) return true;
|
|
367
|
+
return node.evaluate((n) => {
|
|
368
|
+
n.click();
|
|
369
|
+
return true;
|
|
370
|
+
}).catch(() => false);
|
|
371
|
+
}
|
|
372
|
+
async function tickScopes(page, text, options) {
|
|
373
|
+
let ticked = 0;
|
|
374
|
+
let boxes = await readScopeBoxes(page).catch(() => []);
|
|
375
|
+
const rounds = boxes.length + 3;
|
|
376
|
+
for (let round = 0; round < rounds; round++) {
|
|
377
|
+
const next = scopeTicks(boxes, text, options)[0];
|
|
378
|
+
if (next === void 0) break;
|
|
379
|
+
const before = boxes.find((b) => b.index === next);
|
|
380
|
+
if (!await clickNode(page.locator(BOXES).nth(next))) return { stop: `A scope checkbox on the consent page could not be pressed (${before?.name || "unnamed"}). Nothing was pressed.` };
|
|
381
|
+
ticked++;
|
|
382
|
+
await page.waitForTimeout(200).catch(quiet("agent/computer/oauth-consent"));
|
|
383
|
+
boxes = await readScopeBoxes(page).catch(() => []);
|
|
384
|
+
}
|
|
385
|
+
if (boxes.length && !scopesTicked(boxes)) return { stop: `The consent page has scope checkboxes that would not tick (${boxes.filter((b) => !b.checked && !NOT_A_SCOPE.test(b.name)).map((b) => b.name || "unnamed").slice(0, 6).join(" | ")}). Nothing was pressed.` };
|
|
386
|
+
return { ticked };
|
|
387
|
+
}
|
|
388
|
+
async function press(page, control) {
|
|
389
|
+
const exact = control.name;
|
|
390
|
+
const candidates = control.leaf ? [page.getByText(exact, { exact: true })] : [page.getByRole("button", { name: exact, exact: true }), page.getByRole("link", { name: exact, exact: true }), page.locator(PRESSABLE).filter({ hasText: exact }), page.getByText(exact, { exact: true })];
|
|
391
|
+
for (const base of candidates) {
|
|
392
|
+
const shown = base.filter({ visible: true });
|
|
393
|
+
const count = await shown.count().catch(() => 0);
|
|
394
|
+
for (let i = 0; i < Math.min(count, 8); i++) {
|
|
395
|
+
const one = shown.nth(i);
|
|
396
|
+
const away = await one.evaluate((node, otherApp) => new RegExp(otherApp, "i").test(node.closest("a[href]")?.getAttribute("href") ?? ""), OPENS_ANOTHER_APP.source).catch(() => false);
|
|
397
|
+
if (away) continue;
|
|
398
|
+
if (await clickNode(one)) return true;
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
var UNRECOGNIZED_CLIENT = /unrecogni[sz]ed[\s_-]*client|unknown[\s_-]*client|invalid[_\s-]*client|client[_\s-]*id[^.\n]{0,40}(?:not found|invalid|unknown|unrecogni|does not exist)|no such (?:oauth )?(?:client|app)|(?:oauth )?(?:client|app) (?:not found|does not exist|is not registered)/i;
|
|
405
|
+
var NO_CREDITS = /\bno (?:api )?credits?\b|(?:add|buy|purchase|top up) (?:more )?credits?|out of credits|insufficient (?:credits?|funds|balance)|payment required|credit balance|billing|add (?:a )?payment method|upgrade (?:your )?(?:plan|account)\b|card number|\bsubscribe\b.{0,40}\bto continue/i;
|
|
406
|
+
function classifyStuck(pageText) {
|
|
407
|
+
if (UNRECOGNIZED_CLIENT.test(pageText)) return { kind: "unrecognized-client", label: "the vendor does not recognize the OAuth client (its app registration is missing or wrong; register the app by hand)" };
|
|
408
|
+
if (NO_CREDITS.test(pageText)) return { kind: "payment", label: "the vendor wants payment, credits or a plan before it will continue", reason: "payment" };
|
|
409
|
+
const blocker = detectBlocker(pageText);
|
|
410
|
+
if (blocker === "a captcha") return { kind: "captcha", label: "a captcha" };
|
|
411
|
+
if (blocker === "an SMS or authenticator code") return { kind: "mfa", label: "a verification code (MFA or SMS)" };
|
|
412
|
+
if (blocker === "a payment page") return { kind: "payment", label: "a payment page", reason: "payment" };
|
|
413
|
+
return void 0;
|
|
414
|
+
}
|
|
415
|
+
function pageExcerpt(text, max = 300) {
|
|
416
|
+
return scrubSecrets(text).replace(/\s+/g, " ").replace(/[\w.+-]+@[\w-]+(?:\.[\w-]+)+/g, "[email]").replace(/[A-Za-z0-9_\-.~+/=]{32,}/g, "[token]").trim().slice(0, max);
|
|
417
|
+
}
|
|
418
|
+
function jsonErrorBody(text) {
|
|
419
|
+
const t = text.trim();
|
|
420
|
+
if (!t.startsWith("{")) return void 0;
|
|
421
|
+
try {
|
|
422
|
+
const v = JSON.parse(t);
|
|
423
|
+
if (!v || typeof v !== "object" || !("message" in v || "error" in v || "error_description" in v || "errors" in v)) return void 0;
|
|
424
|
+
return pageExcerpt(t);
|
|
425
|
+
} catch {
|
|
426
|
+
return void 0;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
function stuckOn(page, controls, pageText = "") {
|
|
430
|
+
try {
|
|
431
|
+
const url = new URL(page.url());
|
|
432
|
+
const names = [...new Set(controls.filter((c) => !c.leaf && !c.name.includes("@")).map((c) => c.name))].slice(0, 10);
|
|
433
|
+
const json = jsonErrorBody(pageText);
|
|
434
|
+
const excerpt = json ?? pageExcerpt(pageText);
|
|
435
|
+
const kind = classifyStuck(pageText);
|
|
436
|
+
return `The browser is on ${url.host}${url.pathname}; it shows: ${scrubSecrets(names.join(" | ")) || "nothing to press"}.${excerpt ? ` Page ${json ? "JSON error" : "text"}: "${excerpt}".` : ""}${kind ? ` This looks like ${kind.label}.` : ""}`;
|
|
437
|
+
} catch {
|
|
438
|
+
return "";
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
var ConsentStop = class extends Error {
|
|
442
|
+
constructor(message, reason, detail) {
|
|
443
|
+
super(message);
|
|
444
|
+
this.reason = reason;
|
|
445
|
+
this.detail = detail;
|
|
446
|
+
this.name = "ConsentStop";
|
|
447
|
+
}
|
|
448
|
+
reason;
|
|
449
|
+
detail;
|
|
450
|
+
};
|
|
451
|
+
function stopDetail(page, controls, pageText, kind) {
|
|
452
|
+
let url = "";
|
|
453
|
+
try {
|
|
454
|
+
const u = new URL(page.url());
|
|
455
|
+
url = `${u.origin}${u.pathname}`;
|
|
456
|
+
} catch {
|
|
457
|
+
}
|
|
458
|
+
const known = classifyStuck(pageText)?.kind;
|
|
459
|
+
return {
|
|
460
|
+
kind: kind ?? known ?? "unknown",
|
|
461
|
+
url,
|
|
462
|
+
pageText: jsonErrorBody(pageText) ?? pageExcerpt(pageText),
|
|
463
|
+
controls: [...new Set(controls.filter((c) => !c.leaf && !c.name.includes("@")).map((c) => scrubSecrets(c.name)))].slice(0, 12)
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
async function oauthConnect(connector, page, options = {}) {
|
|
467
|
+
try {
|
|
468
|
+
return await driveConsent(connector, page, options);
|
|
469
|
+
} catch (error) {
|
|
470
|
+
if (error instanceof ConsentStop && error.reason === "payment" && options.stateDir) {
|
|
471
|
+
const saved = await saveTask(options.stateDir, { vendor: connector, kind: "oauth-app", status: "needs-human", reason: "payment", note: `oauth_connect stopped: ${error.message}` }).then(() => true, () => false);
|
|
472
|
+
if (saved) throw new ConsentStop(`${error.message} Recorded in the human queue as needs-human [payment].`, "payment", error.detail);
|
|
473
|
+
}
|
|
474
|
+
throw error;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
var MAX_ACCOUNT_PRESSES = 2;
|
|
478
|
+
async function driveConsent(connector, firstPage, options) {
|
|
479
|
+
if (!CONNECTOR_ID.test(connector)) throw new Error("oauth_connect needs target: a connector id such as slack or github.");
|
|
480
|
+
const platform = { ...CLIKDEPLOY_PLATFORM, ...options.platform, ...options.start ? { start: options.start } : {}, ...options.status ? { status: options.status } : {} };
|
|
481
|
+
const started = await platform.start(connector, options.signal);
|
|
482
|
+
const status = platform.status;
|
|
483
|
+
const appNames = platform.appNames.filter(Boolean);
|
|
484
|
+
const steps = [];
|
|
485
|
+
let page = firstPage;
|
|
486
|
+
try {
|
|
487
|
+
const problem = authorizationProblem(started.url, platform.ownsCallback);
|
|
488
|
+
if (problem) throw new ConsentStop(`The authorization URL was not opened: ${problem}.`);
|
|
489
|
+
let redirectUri;
|
|
490
|
+
let redirectHost;
|
|
491
|
+
try {
|
|
492
|
+
const u = new URL(started.url).searchParams.get("redirect_uri");
|
|
493
|
+
if (u) {
|
|
494
|
+
redirectUri = u;
|
|
495
|
+
redirectHost = new URL(u).host;
|
|
496
|
+
}
|
|
497
|
+
} catch {
|
|
498
|
+
}
|
|
499
|
+
const open = async () => {
|
|
500
|
+
try {
|
|
501
|
+
await page.goto(started.url, { waitUntil: "domcontentloaded", timeout: 3e4 });
|
|
502
|
+
} catch (error) {
|
|
503
|
+
throw new ConsentStop(`The authorization URL did not open (${scrubSecrets(error instanceof Error ? error.message : String(error)).split("\n")[0].slice(0, 160)}).`);
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
await open();
|
|
507
|
+
const deadline = Date.now() + (options.timeoutMs ?? 12e4);
|
|
508
|
+
let captchaTried = false;
|
|
509
|
+
let idle = 0, stopSeen = 0, accountPresses = 0, restarts = 0, lastPress = { key: "", at: 0 }, controls = [], lastText = "";
|
|
510
|
+
const restart = async (why) => {
|
|
511
|
+
if (restarts >= 1 || !options.reopen) return false;
|
|
512
|
+
restarts++;
|
|
513
|
+
page = await options.reopen(page);
|
|
514
|
+
accountPresses = 0;
|
|
515
|
+
stopSeen = 0;
|
|
516
|
+
idle = 0;
|
|
517
|
+
lastPress = { key: "", at: 0 };
|
|
518
|
+
steps.push(`Reopened the authorization URL in a fresh tab (${why}).`);
|
|
519
|
+
options.progress?.(`Reopened the authorization URL in a fresh tab (${why}).
|
|
520
|
+
`);
|
|
521
|
+
await open();
|
|
522
|
+
return true;
|
|
523
|
+
};
|
|
524
|
+
while (Date.now() < deadline) {
|
|
525
|
+
if (options.signal?.aborted) throw new Error("Stopped.");
|
|
526
|
+
if (page.isClosed()) throw new ConsentStop("The browser tab was closed before consent finished.");
|
|
527
|
+
const url = page.url();
|
|
528
|
+
const text = await page.evaluate(() => (globalThis.document.body?.innerText ?? "").slice(0, 6e3)).catch(() => "");
|
|
529
|
+
lastText = text;
|
|
530
|
+
const at = callbackState(url, redirectUri, text, platform.ownsCallback);
|
|
531
|
+
if (at === "problem") throw new ConsentStop(`The callback page reported a problem instead of a connection (${new URL(url).host}${new URL(url).pathname}). Check the consent was allowed and try again.`);
|
|
532
|
+
if (at === "connected" || at === "waiting") {
|
|
533
|
+
let last = "";
|
|
534
|
+
for (let tries = 0; tries < 8; tries++) {
|
|
535
|
+
const state = await status(connector, options.signal);
|
|
536
|
+
if (state.connected) {
|
|
537
|
+
steps.push("Confirmed: ClikDeploy shows an active connection.");
|
|
538
|
+
return { connector, steps };
|
|
539
|
+
}
|
|
540
|
+
last = state.reason ?? "";
|
|
541
|
+
await page.waitForTimeout(2500).catch(quiet("agent/computer/oauth-consent"));
|
|
542
|
+
}
|
|
543
|
+
throw new ConsentStop(`The callback page was reached but ClikDeploy shows no active connection${last ? ` (${scrubSecrets(last)})` : ""}.`);
|
|
544
|
+
}
|
|
545
|
+
const host = (() => {
|
|
546
|
+
try {
|
|
547
|
+
return new URL(url).hostname;
|
|
548
|
+
} catch {
|
|
549
|
+
return "";
|
|
550
|
+
}
|
|
551
|
+
})();
|
|
552
|
+
const step = providerFor(options.providerHost ?? host)?.id === "google" ? googleStep(url, text) : void 0;
|
|
553
|
+
controls = await readControls(page).catch(() => []);
|
|
554
|
+
if (step === "challenge" || step === "error") {
|
|
555
|
+
if (await restart(step === "challenge" ? "Google asked to re-verify" : "Google showed an error page")) continue;
|
|
556
|
+
const hasPassword2 = await page.locator("input[type=password]:visible").count().catch(() => 0) > 0;
|
|
557
|
+
const why2 = step === "challenge" ? stopReason(text, hasPassword2, false) ?? "a Google re-verification" : "a Google error page";
|
|
558
|
+
throw new ConsentStop(`Stopped at ${why2}${restarts ? " (also after reopening in a fresh tab)" : ""}. Nothing was typed. ${stuckOn(page, controls, text)}`, classifyStuck(text)?.reason, stopDetail(page, controls, text, hasPassword2 ? "password" : void 0));
|
|
559
|
+
}
|
|
560
|
+
const hasPassword = await page.locator("input[type=password]:visible").count().catch(() => 0) > 0;
|
|
561
|
+
const hasCode = await page.locator("input[autocomplete=one-time-code]:visible").count().catch(() => 0) > 0;
|
|
562
|
+
let why = stopReason(text, hasPassword, hasCode);
|
|
563
|
+
if (why === "a captcha" && !captchaTried && options.stateDir) {
|
|
564
|
+
captchaTried = true;
|
|
565
|
+
const { captchaSolvingAllowed } = await import("./chunk-YHNIQPKY.js");
|
|
566
|
+
const { passHumanCheck } = await import("./chunk-F3DP4ZA2.js");
|
|
567
|
+
const passed = await passHumanCheck(page, { stateDir: options.stateDir, solve: await captchaSolvingAllowed(options.stateDir) }).catch(quiet("agent/computer/oauth-consent"));
|
|
568
|
+
if (passed?.outcome === "cleared") {
|
|
569
|
+
stopSeen = 0;
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
572
|
+
why = stopReason(text, hasPassword, hasCode);
|
|
573
|
+
}
|
|
574
|
+
if (why) {
|
|
575
|
+
if (++stopSeen >= 2) throw new ConsentStop(`Stopped at ${why}. Nothing was typed. ${stuckOn(page, controls, text)}`, classifyStuck(text)?.reason, stopDetail(page, controls, text, hasPassword ? "password" : hasCode ? "mfa" : void 0));
|
|
576
|
+
} else {
|
|
577
|
+
stopSeen = 0;
|
|
578
|
+
const next = nextPress(options.providerHost ?? host, controls, text, { ...options.email ? { email: options.email } : {}, account: step === void 0 || step === "chooser", appNames, requireClient: true, ...redirectHost ? { redirectHost } : {} });
|
|
579
|
+
const control = next && controls[next.index];
|
|
580
|
+
if (next && control && !(lastPress.key === `${url}|${control.name}` && Date.now() - lastPress.at < 2500)) {
|
|
581
|
+
if (next.phase === "account" && ++accountPresses > MAX_ACCOUNT_PRESSES) throw new ConsentStop(`The account chooser keeps coming back after the account was chosen. ${stuckOn(page, controls, text)}`);
|
|
582
|
+
if (next.phase === "grant") {
|
|
583
|
+
const ticks = await tickScopes(page, text, { appNames, ...redirectHost ? { redirectHost } : {} });
|
|
584
|
+
if ("stop" in ticks) throw new ConsentStop(`${ticks.stop} ${stuckOn(page, controls, text)}`);
|
|
585
|
+
if (ticks.ticked) {
|
|
586
|
+
steps.push("Ticked the scope checkboxes.");
|
|
587
|
+
options.progress?.("Ticked the scope checkboxes.\n");
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
if (next.consent) {
|
|
591
|
+
const blocked = await settleSelectors(page);
|
|
592
|
+
if (blocked) throw new ConsentStop(`${blocked} ${stuckOn(page, controls, text)}`, void 0, stopDetail(page, controls, text, "choice"));
|
|
593
|
+
}
|
|
594
|
+
if (await press(page, control)) {
|
|
595
|
+
lastPress = { key: `${url}|${control.name}`, at: Date.now() };
|
|
596
|
+
steps.push(next.note);
|
|
597
|
+
options.progress?.(`${next.note}
|
|
598
|
+
`);
|
|
599
|
+
idle = 0;
|
|
600
|
+
if (next.phase === "account") await page.waitForURL((u) => u.href !== url, { timeout: 8e3 }).catch(quiet("agent/computer/oauth-consent"));
|
|
601
|
+
}
|
|
602
|
+
} else {
|
|
603
|
+
const kind = classifyStuck(text);
|
|
604
|
+
if (++idle >= (kind ? 3 : 15)) throw new ConsentStop(`Stopped at ${kind ? kind.label : "a screen it does not recognize"}. ${stuckOn(page, controls, text)}`, kind?.reason, stopDetail(page, controls, text));
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
await page.waitForTimeout(700).catch(quiet("agent/computer/oauth-consent"));
|
|
608
|
+
}
|
|
609
|
+
{
|
|
610
|
+
const kind = classifyStuck(lastText);
|
|
611
|
+
throw new ConsentStop(`Consent did not finish in time. ${stuckOn(page, controls, lastText)}`, kind?.reason, stopDetail(page, controls, lastText));
|
|
612
|
+
}
|
|
613
|
+
} finally {
|
|
614
|
+
started.stop();
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
export {
|
|
619
|
+
GENERIC_ACTIONS,
|
|
620
|
+
providerFor,
|
|
621
|
+
readConsent,
|
|
622
|
+
scopeTicks,
|
|
623
|
+
scopesTicked,
|
|
624
|
+
googleStep,
|
|
625
|
+
nextPress,
|
|
626
|
+
decideSelectors,
|
|
627
|
+
stopReason,
|
|
628
|
+
callbackState,
|
|
629
|
+
authorizationProblem,
|
|
630
|
+
authorizationUrl,
|
|
631
|
+
startFailure,
|
|
632
|
+
ownsClikDeployCallback,
|
|
633
|
+
CLIKDEPLOY_PLATFORM,
|
|
634
|
+
readControls,
|
|
635
|
+
press,
|
|
636
|
+
classifyStuck,
|
|
637
|
+
pageExcerpt,
|
|
638
|
+
ConsentStop,
|
|
639
|
+
oauthConnect
|
|
640
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
CHAT_HAVE_REVISION,
|
|
5
|
+
STALE_BASE,
|
|
6
|
+
chatHasContent,
|
|
7
|
+
moveChat,
|
|
8
|
+
movedChatMachine,
|
|
9
|
+
movedChatMessage
|
|
10
|
+
} from "./chunk-DAJ76TOC.js";
|
|
11
|
+
import "./chunk-YMCH3L2S.js";
|
|
12
|
+
import "./chunk-RDDWQBEM.js";
|
|
13
|
+
import "./chunk-MPAJ446F.js";
|
|
14
|
+
import "./chunk-CBANJFBO.js";
|
|
15
|
+
import "./chunk-PWXII6HF.js";
|
|
16
|
+
export {
|
|
17
|
+
CHAT_HAVE_REVISION,
|
|
18
|
+
STALE_BASE,
|
|
19
|
+
chatHasContent,
|
|
20
|
+
moveChat,
|
|
21
|
+
movedChatMachine,
|
|
22
|
+
movedChatMessage
|
|
23
|
+
};
|