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.
Files changed (323) hide show
  1. package/README.md +25 -14
  2. package/dist/chunk-23TDEBGZ.js +71 -0
  3. package/dist/chunk-25T3GVS7.js +425 -0
  4. package/dist/chunk-2BBELGHY.js +11 -0
  5. package/dist/chunk-2EOL5PZL.js +208 -0
  6. package/dist/chunk-2GAB36IE.js +26 -0
  7. package/dist/chunk-2OLS7V66.js +2440 -0
  8. package/dist/chunk-2QFO2URB.js +179 -0
  9. package/dist/chunk-2QWPQRSU.js +254 -0
  10. package/dist/chunk-2YPAPAR3.js +184 -0
  11. package/dist/chunk-2ZAG5372.js +33 -0
  12. package/dist/chunk-32IKAIZC.js +12507 -0
  13. package/dist/chunk-34AZEGYW.js +95 -0
  14. package/dist/chunk-34JQYQCA.js +175 -0
  15. package/dist/chunk-34ZISPAO.js +67 -0
  16. package/dist/chunk-3AAAARE6.js +46 -0
  17. package/dist/chunk-3AJ6Q3OY.js +510 -0
  18. package/dist/chunk-3B2CHX7M.js +884 -0
  19. package/dist/chunk-3BUFORRX.js +59 -0
  20. package/dist/chunk-3QLHYYFK.js +30 -0
  21. package/dist/chunk-3RXBMYKZ.js +140 -0
  22. package/dist/chunk-3TFNIJWS.js +52 -0
  23. package/dist/chunk-3W3IPDFP.js +119 -0
  24. package/dist/chunk-3WMS7SEE.js +417 -0
  25. package/dist/chunk-435ZNSZ3.js +23 -0
  26. package/dist/chunk-4AQ5NINV.js +39 -0
  27. package/dist/chunk-4GVEJ5FK.js +168 -0
  28. package/dist/chunk-4GXAO3UY.js +262 -0
  29. package/dist/chunk-4L2ZZM4Q.js +332 -0
  30. package/dist/chunk-4LPDG57B.js +17 -0
  31. package/dist/chunk-4NN3XQQT.js +223 -0
  32. package/dist/chunk-4QZEZME7.js +54 -0
  33. package/dist/chunk-4R6CSC3S.js +38 -0
  34. package/dist/chunk-4RHXTL3W.js +514 -0
  35. package/dist/chunk-4SJMPTVQ.js +18 -0
  36. package/dist/chunk-4VY7G6TX.js +114 -0
  37. package/dist/chunk-5642PBF7.js +124 -0
  38. package/dist/chunk-5B6TVO4A.js +33 -0
  39. package/dist/chunk-5BJLDUPL.js +62 -0
  40. package/dist/chunk-5HMFFJWU.js +19 -0
  41. package/dist/chunk-5IKLK33T.js +69 -0
  42. package/dist/chunk-5NQ5FFMX.js +44 -0
  43. package/dist/chunk-5QNNW5L6.js +176 -0
  44. package/dist/chunk-5SM5UAWN.js +239 -0
  45. package/dist/chunk-5WYJTA6O.js +74 -0
  46. package/dist/chunk-5ZSR2Y5T.js +227 -0
  47. package/dist/chunk-5ZWUM5GH.js +39 -0
  48. package/dist/chunk-64E7D4HY.js +364 -0
  49. package/dist/chunk-6CK466BC.js +99 -0
  50. package/dist/chunk-6ES45HHO.js +138 -0
  51. package/dist/chunk-6HYEZFGL.js +277 -0
  52. package/dist/chunk-6Y7HLXGW.js +29 -0
  53. package/dist/chunk-6YKK4FYR.js +258 -0
  54. package/dist/chunk-74WNMLMS.js +117 -0
  55. package/dist/chunk-7AULZ7OD.js +55 -0
  56. package/dist/chunk-7DOKGSUN.js +101 -0
  57. package/dist/chunk-7IH5LTIZ.js +195 -0
  58. package/dist/chunk-7ISTS5NS.js +21 -0
  59. package/dist/chunk-7NMUTGOW.js +527 -0
  60. package/dist/chunk-7PNHUZEL.js +153 -0
  61. package/dist/chunk-7TSQLONI.js +88 -0
  62. package/dist/chunk-AE7TOLD5.js +30 -0
  63. package/dist/chunk-AEMHSXKA.js +130 -0
  64. package/dist/chunk-AKRYTS2D.js +211 -0
  65. package/dist/chunk-AMNSE36L.js +59 -0
  66. package/dist/chunk-AZVD74ZV.js +23 -0
  67. package/dist/chunk-B35DVOTK.js +1981 -0
  68. package/dist/chunk-B4HNJRAH.js +626 -0
  69. package/dist/chunk-B5WYPPHS.js +13 -0
  70. package/dist/chunk-BBOVDXQM.js +59 -0
  71. package/dist/chunk-BD3ECZLK.js +62 -0
  72. package/dist/chunk-BDGSOT74.js +4578 -0
  73. package/dist/chunk-BF5VEOPK.js +31 -0
  74. package/dist/chunk-BFFRW4XH.js +47 -0
  75. package/dist/chunk-BFPC6PEW.js +208 -0
  76. package/dist/chunk-BGEMY2JJ.js +376 -0
  77. package/dist/chunk-BISGNHKD.js +35 -0
  78. package/dist/chunk-BMRAEBRY.js +21 -0
  79. package/dist/chunk-BNTXAZXW.js +127 -0
  80. package/dist/chunk-BOQBXGSN.js +75 -0
  81. package/dist/chunk-BTJDSTQP.js +213 -0
  82. package/dist/chunk-BUOPJQP5.js +218 -0
  83. package/dist/chunk-BXFJS65Q.js +52 -0
  84. package/dist/chunk-BXPQFSX5.js +59 -0
  85. package/dist/chunk-C57LIWNY.js +1269 -0
  86. package/dist/chunk-C6YVCCWR.js +74 -0
  87. package/dist/chunk-CAADDF6M.js +167 -0
  88. package/dist/chunk-CBANJFBO.js +69 -0
  89. package/dist/chunk-CERF3RIB.js +597 -0
  90. package/dist/chunk-COAS5ETR.js +46 -0
  91. package/dist/chunk-CQ7J6UQ7.js +78 -0
  92. package/dist/chunk-CRUVYGO2.js +26 -0
  93. package/dist/chunk-CVFVFRGN.js +58 -0
  94. package/dist/chunk-D2UK66HM.js +37 -0
  95. package/dist/chunk-D2W7SA4R.js +18 -0
  96. package/dist/chunk-DA44ZENT.js +501 -0
  97. package/dist/chunk-DAJ76TOC.js +99 -0
  98. package/dist/chunk-DCZ6CIUM.js +147 -0
  99. package/dist/chunk-DF35KMXM.js +1314 -0
  100. package/dist/chunk-DGASQT26.js +151 -0
  101. package/dist/chunk-DJT57C5P.js +55 -0
  102. package/dist/chunk-DKDPZTD3.js +44 -0
  103. package/dist/chunk-DQYVQ2N7.js +77 -0
  104. package/dist/chunk-DRTP2RTY.js +266 -0
  105. package/dist/chunk-DW2BMUKY.js +61 -0
  106. package/dist/chunk-DW5T5ZVU.js +307 -0
  107. package/dist/chunk-DXKNDNFC.js +164 -0
  108. package/dist/chunk-DZEQ7UYR.js +291 -0
  109. package/dist/chunk-E4F4OUAC.js +463 -0
  110. package/dist/chunk-EE4B6A7W.js +69 -0
  111. package/dist/chunk-EISKIYWG.js +23 -0
  112. package/dist/chunk-EKAQK7UQ.js +235 -0
  113. package/dist/chunk-EOBTJV32.js +123 -0
  114. package/dist/chunk-ESF3DIZY.js +325 -0
  115. package/dist/chunk-EVOHOZ4U.js +45 -0
  116. package/dist/chunk-EXN4KHLB.js +110 -0
  117. package/dist/chunk-F252T6Y3.js +78 -0
  118. package/dist/chunk-F3DP4ZA2.js +40 -0
  119. package/dist/chunk-F6F47QAY.js +58 -0
  120. package/dist/chunk-FA3Y23ZW.js +57 -0
  121. package/dist/chunk-FBKXE4EJ.js +640 -0
  122. package/dist/chunk-FCGEB3H6.js +23 -0
  123. package/dist/chunk-FF7ZVYJF.js +3732 -0
  124. package/dist/chunk-FFGKN6L3.js +39 -0
  125. package/dist/chunk-FFGU4GCC.js +94 -0
  126. package/dist/chunk-FSFDAOVP.js +74 -0
  127. package/dist/chunk-FT5TX7OX.js +1573 -0
  128. package/dist/chunk-G3QP67Z7.js +232 -0
  129. package/dist/chunk-G5ORJKV2.js +179 -0
  130. package/dist/chunk-GFNC62PE.js +111 -0
  131. package/dist/chunk-GGK43Q3N.js +67 -0
  132. package/dist/chunk-GGYKY4GF.js +11537 -0
  133. package/dist/chunk-GGYNHGNJ.js +55 -0
  134. package/dist/chunk-GLY7RM3C.js +354 -0
  135. package/dist/chunk-GQBZU6EO.js +20 -0
  136. package/dist/chunk-GSXENUZL.js +9 -0
  137. package/dist/chunk-GTOAT5D3.js +40 -0
  138. package/dist/chunk-GWCMDPQU.js +1007 -0
  139. package/dist/chunk-GXYSMYHJ.js +152 -0
  140. package/dist/chunk-GYMAI5NY.js +14 -0
  141. package/dist/chunk-H2VZMKPE.js +30 -0
  142. package/dist/chunk-H4THUNBM.js +2091 -0
  143. package/dist/chunk-HGRVSNUZ.js +361 -0
  144. package/dist/chunk-HI4VY473.js +27 -0
  145. package/dist/chunk-HOJRSD3Q.js +447 -0
  146. package/dist/chunk-HRX25W35.js +82 -0
  147. package/dist/chunk-HSE4AQYV.js +55 -0
  148. package/dist/chunk-HU5SSUFX.js +383 -0
  149. package/dist/chunk-I3GDBJLH.js +196 -0
  150. package/dist/chunk-I75EDU75.js +684 -0
  151. package/dist/chunk-IBA7DMIO.js +20 -0
  152. package/dist/chunk-IC6N4NZA.js +231 -0
  153. package/dist/chunk-IF43HIGV.js +284 -0
  154. package/dist/chunk-IGZ6C2MC.js +439 -0
  155. package/dist/chunk-IMLTL2MY.js +192 -0
  156. package/dist/chunk-IMZL6SGR.js +33 -0
  157. package/dist/chunk-IS4USJPY.js +516 -0
  158. package/dist/chunk-ISFSPN2F.js +82 -0
  159. package/dist/chunk-IXE7GTFI.js +55 -0
  160. package/dist/chunk-IZ77QJQG.js +36 -0
  161. package/dist/chunk-J2PACWRQ.js +34 -0
  162. package/dist/chunk-J6EGFVQX.js +180 -0
  163. package/dist/chunk-JEKOD43D.js +22 -0
  164. package/dist/chunk-JGIWATSG.js +30 -0
  165. package/dist/chunk-JYBONKD4.js +43 -0
  166. package/dist/chunk-K2NLG2HK.js +454 -0
  167. package/dist/chunk-KCQ4TBLS.js +164 -0
  168. package/dist/chunk-KD5KIVMS.js +176 -0
  169. package/dist/chunk-KHW6TX6I.js +63 -0
  170. package/dist/chunk-KI5GZFCE.js +520 -0
  171. package/dist/chunk-KN34B7NO.js +105 -0
  172. package/dist/chunk-KYUHIFP3.js +136 -0
  173. package/dist/chunk-KZL5VS4B.js +300 -0
  174. package/dist/chunk-L3VW3QIH.js +48 -0
  175. package/dist/chunk-LA6MG4ET.js +2110 -0
  176. package/dist/chunk-LAVFOA3S.js +66 -0
  177. package/dist/chunk-LB4OA77N.js +13 -0
  178. package/dist/chunk-LBFRF2K4.js +196 -0
  179. package/dist/chunk-LM6EIA4B.js +93 -0
  180. package/dist/chunk-LPCNRGJ7.js +692 -0
  181. package/dist/chunk-LSLNL5T3.js +168 -0
  182. package/dist/chunk-LVRRWP4W.js +568 -0
  183. package/dist/chunk-LWCFBRHL.js +33 -0
  184. package/dist/chunk-LXFTMGZZ.js +166 -0
  185. package/dist/chunk-M33LVA4M.js +151 -0
  186. package/dist/chunk-M3FO5UMK.js +4944 -0
  187. package/dist/chunk-M5QNDBAY.js +66 -0
  188. package/dist/chunk-M6ND6KBE.js +1291 -0
  189. package/dist/chunk-M7H3WQTE.js +76 -0
  190. package/dist/chunk-MCBRVPA7.js +191 -0
  191. package/dist/chunk-MCSDWZET.js +91 -0
  192. package/dist/chunk-MDT5XDXL.js +289 -0
  193. package/dist/chunk-MJG3IQY4.js +91 -0
  194. package/dist/chunk-MOU3N2UL.js +44 -0
  195. package/dist/chunk-MP4KZOQC.js +3451 -0
  196. package/dist/chunk-MPAJ446F.js +66 -0
  197. package/dist/chunk-MVJZZ6AL.js +16 -0
  198. package/dist/chunk-MXS6S2PY.js +253 -0
  199. package/dist/chunk-N3SFDYM7.js +291 -0
  200. package/dist/chunk-NAOX3JUB.js +13 -0
  201. package/dist/chunk-NEKKIBCX.js +283 -0
  202. package/dist/chunk-NKDATMEM.js +133 -0
  203. package/dist/chunk-NR4FMC4K.js +395 -0
  204. package/dist/chunk-NSOHOJBR.js +221 -0
  205. package/dist/chunk-NTDB6QKF.js +29 -0
  206. package/dist/chunk-NWEYRBWK.js +25 -0
  207. package/dist/chunk-O2YSNYWD.js +23 -0
  208. package/dist/chunk-O3EW7LAY.js +54 -0
  209. package/dist/chunk-O7BNJIXU.js +366 -0
  210. package/dist/chunk-OARL2NXZ.js +116 -0
  211. package/dist/chunk-OHKZUEJW.js +351 -0
  212. package/dist/chunk-OKU45BXA.js +647 -0
  213. package/dist/chunk-OL4JBD3J.js +59 -0
  214. package/dist/chunk-OLUO5DDR.js +192 -0
  215. package/dist/chunk-OQ245JLA.js +196 -0
  216. package/dist/chunk-P72UZAQI.js +289 -0
  217. package/dist/chunk-PAL2ENB6.js +20 -0
  218. package/dist/chunk-PAXYQZH7.js +53 -0
  219. package/dist/chunk-PDPEM5VW.js +51 -0
  220. package/dist/chunk-PEWCDI2C.js +668 -0
  221. package/dist/chunk-PGZ54EDX.js +27 -0
  222. package/dist/chunk-PRWVLDZF.js +73 -0
  223. package/dist/chunk-PSQQ75VJ.js +52 -0
  224. package/dist/chunk-PUOVIFHW.js +118 -0
  225. package/dist/chunk-PWBF2X3V.js +107 -0
  226. package/dist/chunk-PWXII6HF.js +43 -0
  227. package/dist/chunk-Q35VLJRT.js +80 -0
  228. package/dist/chunk-QJP7EYGL.js +128 -0
  229. package/dist/chunk-QPQKX2MK.js +8836 -0
  230. package/dist/chunk-QQRLPY25.js +1053 -0
  231. package/dist/chunk-QUS4ER2W.js +407 -0
  232. package/dist/chunk-QYHI3YET.js +29 -0
  233. package/dist/chunk-QYRU2UQI.js +32 -0
  234. package/dist/chunk-R6XVVQGC.js +13 -0
  235. package/dist/chunk-R7QN6ONS.js +483 -0
  236. package/dist/chunk-RD23MPGC.js +221 -0
  237. package/dist/chunk-RDDWQBEM.js +185 -0
  238. package/dist/chunk-RDLLDYFO.js +104 -0
  239. package/dist/chunk-RE4TGORR.js +84 -0
  240. package/dist/chunk-RJLHVYQY.js +217 -0
  241. package/dist/chunk-RJLPTWHW.js +905 -0
  242. package/dist/chunk-RKUVLRZI.js +295 -0
  243. package/dist/chunk-ROGXPGYR.js +37 -0
  244. package/dist/chunk-RSZGEL5U.js +163 -0
  245. package/dist/chunk-RVUOIJXN.js +909 -0
  246. package/dist/chunk-RW7F4JRP.js +11 -0
  247. package/dist/chunk-S4UO3AO3.js +53 -0
  248. package/dist/chunk-S5JAAF6S.js +585 -0
  249. package/dist/chunk-SNU37TQI.js +56 -0
  250. package/dist/chunk-SQVUDO2O.js +31 -0
  251. package/dist/chunk-SYVHIYQT.js +66 -0
  252. package/dist/chunk-SZBQMTG2.js +85 -0
  253. package/dist/chunk-T5VCXA3J.js +25 -0
  254. package/dist/chunk-TK6NSP56.js +30 -0
  255. package/dist/chunk-TKWVMA6L.js +22 -0
  256. package/dist/chunk-TQDKJHWX.js +59 -0
  257. package/dist/chunk-TQDM7S5N.js +127 -0
  258. package/dist/chunk-TULAXS77.js +23 -0
  259. package/dist/chunk-TVT45XNH.js +4625 -0
  260. package/dist/chunk-TWCVV2JO.js +467 -0
  261. package/dist/chunk-U4DKAD6S.js +47 -0
  262. package/dist/chunk-UA5K2BTI.js +564 -0
  263. package/dist/chunk-UAMKCMOK.js +40 -0
  264. package/dist/chunk-UBMVADBF.js +51 -0
  265. package/dist/chunk-UFQ5A5PW.js +645 -0
  266. package/dist/chunk-UOD2SOLL.js +1301 -0
  267. package/dist/chunk-UTSB4LOW.js +156 -0
  268. package/dist/chunk-UVXNIUTN.js +412 -0
  269. package/dist/chunk-UXVPXYPE.js +90 -0
  270. package/dist/chunk-UYEEMIWR.js +374 -0
  271. package/dist/chunk-VBGM5ZBW.js +54 -0
  272. package/dist/chunk-VEWPCZPG.js +762 -0
  273. package/dist/chunk-VIRDLZ5E.js +108 -0
  274. package/dist/chunk-VMPO7WKN.js +52 -0
  275. package/dist/chunk-W2NVSDO5.js +5122 -0
  276. package/dist/chunk-W3YYPBEA.js +176 -0
  277. package/dist/chunk-W5AYOICN.js +280 -0
  278. package/dist/chunk-W5GZOIUF.js +27 -0
  279. package/dist/chunk-WHKNLZ3C.js +76 -0
  280. package/dist/chunk-WKBEPPQ5.js +1409 -0
  281. package/dist/chunk-WM3Z6QKQ.js +151 -0
  282. package/dist/chunk-WMI2TPMA.js +31 -0
  283. package/dist/chunk-WNX5VD7S.js +150 -0
  284. package/dist/chunk-WOVTYST3.js +60 -0
  285. package/dist/chunk-WPB5WEZJ.js +546 -0
  286. package/dist/chunk-WUO5EOAT.js +44 -0
  287. package/dist/chunk-WWLJMP6D.js +133 -0
  288. package/dist/chunk-WZMLH3XP.js +58 -0
  289. package/dist/chunk-WZYVLUVQ.js +79 -0
  290. package/dist/chunk-X2OCPVU5.js +135 -0
  291. package/dist/chunk-X3CL6DTR.js +95 -0
  292. package/dist/chunk-X6WF7JEV.js +354 -0
  293. package/dist/chunk-XAHGBPWT.js +44 -0
  294. package/dist/chunk-XCKQ5BM2.js +228 -0
  295. package/dist/chunk-XIBYREEY.js +106 -0
  296. package/dist/chunk-XKW5NDMR.js +378 -0
  297. package/dist/chunk-XRDALAO3.js +100 -0
  298. package/dist/chunk-XUP22EAS.js +41 -0
  299. package/dist/chunk-XWAC3MKW.js +243 -0
  300. package/dist/chunk-Y3R7JMXB.js +59 -0
  301. package/dist/chunk-Y54LTP4W.js +82 -0
  302. package/dist/chunk-Y7UECI4M.js +99 -0
  303. package/dist/chunk-YACGDFHC.js +47 -0
  304. package/dist/chunk-YHNIQPKY.js +71 -0
  305. package/dist/chunk-YMBR6HYP.js +111 -0
  306. package/dist/chunk-YMCH3L2S.js +26 -0
  307. package/dist/chunk-Z4ZU6T7V.js +99 -0
  308. package/dist/chunk-ZDPF67ZZ.js +173 -0
  309. package/dist/chunk-ZFC2Q67K.js +101 -0
  310. package/dist/chunk-ZGHNNSCT.js +114 -0
  311. package/dist/chunk-ZGX3ERAT.js +173 -0
  312. package/dist/chunk-ZI3YHEBY.js +37 -0
  313. package/dist/chunk-ZN7G6JLS.js +639 -0
  314. package/dist/chunk-ZNPFQMXT.js +47 -0
  315. package/dist/chunk-ZOU3LV4U.js +63 -0
  316. package/dist/chunk-ZT7B4H2V.js +117 -0
  317. package/dist/chunk-ZZCBDNZI.js +58 -0
  318. package/dist/cli.js +494 -112923
  319. package/dist/computer-tools.js +36642 -21259
  320. package/dist/harness-catalog.cjs +88 -43
  321. package/dist/index.js +1 -1
  322. package/dist/local-model-supervisor.cjs +555 -0
  323. package/package.json +3 -4
@@ -0,0 +1,1007 @@
1
+ import { createRequire as __clikcodeCreateRequire } from 'node:module';
2
+ const require = __clikcodeCreateRequire(import.meta.url);
3
+ import {
4
+ VOIP_REFUSED
5
+ } from "./chunk-2GAB36IE.js";
6
+ import {
7
+ allAtOnce,
8
+ broadestOption,
9
+ revealedOptions,
10
+ selectorsOf
11
+ } from "./chunk-JYBONKD4.js";
12
+ import {
13
+ nextPress,
14
+ pageExcerpt
15
+ } from "./chunk-FBKXE4EJ.js";
16
+ import "./chunk-DW2BMUKY.js";
17
+ import "./chunk-B4HNJRAH.js";
18
+ import {
19
+ CAPTCHA_FIELD_WORDS,
20
+ CAPTCHA_WORDS,
21
+ detectBlocker
22
+ } from "./chunk-OQ245JLA.js";
23
+ import "./chunk-SNU37TQI.js";
24
+ import "./chunk-PWBF2X3V.js";
25
+ import {
26
+ hideKeyLikeText,
27
+ keyShaped
28
+ } from "./chunk-MCBRVPA7.js";
29
+ import {
30
+ sleep
31
+ } from "./chunk-YMCH3L2S.js";
32
+ import "./chunk-I75EDU75.js";
33
+ import "./chunk-PAXYQZH7.js";
34
+ import "./chunk-4L2ZZM4Q.js";
35
+ import "./chunk-F6F47QAY.js";
36
+ import {
37
+ quiet
38
+ } from "./chunk-RDDWQBEM.js";
39
+ import "./chunk-MPAJ446F.js";
40
+ import {
41
+ scrubSecrets
42
+ } from "./chunk-CBANJFBO.js";
43
+ import "./chunk-PWXII6HF.js";
44
+
45
+ // src/agent/computer/keygrab-explore.ts
46
+ var KEY_WORDS = /\b(?:api|developers?|keys?|tokens?|integrations?|access|credentials?)\b/i;
47
+ var DESTRUCTIVE = /\b(?:delete|remove|cancel|sign ?out|log ?out|logout|billing|invoices?|upgrade|downgrade|subscriptions?|plans?|payments?|pricing|deactivate|close (?:my )?account|disconnect|unsubscribe|purchase|buy|checkout|revoke|reset|regenerat\w*|rotate|roll|deauthori[sz]e|leave)\b/i;
48
+ var SETTINGS_WORDS = /\b(?:settings|account|profile|organi[sz]ations?|workspaces?|team|admin|preferences|security|my account|manage|console|dashboard|projects?)\b/i;
49
+ var OPENER_WORDS = /\b(?:account|profile|avatar|user(?: menu)?|my account|settings|workspace|organi[sz]ation|org|team|switch|switcher|menu|you|me)\b/i;
50
+ var SKIP_ONBOARDING = /^(?:skip(?: for now| this step| tour)?|maybe later|not now|no,? thanks|remind me later)$/i;
51
+ var SEARCH_FIELD = /search|find/i;
52
+ var pathOf = (url) => {
53
+ try {
54
+ const u = new URL(url);
55
+ return `${u.origin}${u.pathname}`;
56
+ } catch {
57
+ return url;
58
+ }
59
+ };
60
+ var safe = (name) => name.length > 0 && name.length <= 60 && !DESTRUCTIVE.test(name);
61
+ var keyWord = (name) => KEY_WORDS.test(name) && safe(name);
62
+ var settingsWord = (name) => SETTINGS_WORDS.test(name) && safe(name);
63
+ var httpsHref = (c) => {
64
+ try {
65
+ const u = new URL(c.href ?? "");
66
+ return u.protocol === "https:" ? u.href : void 0;
67
+ } catch {
68
+ return void 0;
69
+ }
70
+ };
71
+ function added(view, before) {
72
+ const had = new Set(before.controls.map((c) => c.name));
73
+ return view.controls.filter((c) => !had.has(c.name));
74
+ }
75
+ function menuOpeners(view, email) {
76
+ const mail = email?.toLowerCase();
77
+ return view.controls.filter((c) => !c.footer && c.name.length <= 80 && !DESTRUCTIVE.test(c.name) && (c.menu === true || !c.leaf && OPENER_WORDS.test(c.name) || mail && c.name.toLowerCase().includes(mail) || /^[A-Z]{1,2}$/.test(c.name.trim()) || /@/.test(c.name)) && !(c.leaf && c.menu !== true)).sort((a, b) => Number(b.menu === true) - Number(a.menu === true));
78
+ }
79
+ async function exploreForKeys(deps, start, options = {}) {
80
+ const maxPages = options.maxPages ?? 8;
81
+ const visited = [...options.seen ?? []];
82
+ const menus = [...options.seenMenus ?? []];
83
+ const tried = /* @__PURE__ */ new Set();
84
+ const queued = /* @__PURE__ */ new Set();
85
+ const frontier = [];
86
+ let pages = 0;
87
+ let current = start;
88
+ let needsSignIn = false;
89
+ const hit = {};
90
+ const record = (v) => {
91
+ const p = pathOf(v.url);
92
+ if (p && !visited.includes(p)) visited.push(p);
93
+ };
94
+ const done = (found) => ({ ...found ? { found } : {}, visited, menus, tried: [...tried], last: current, ...needsSignIn ? { needsSignIn } : {} });
95
+ record(start);
96
+ const enqueue = (c, from, rank, via) => {
97
+ const href = httpsHref(c);
98
+ const key = href ? pathOf(href) : `${via ?? ""}>${c.name}`;
99
+ if (queued.has(key) || href && visited.includes(pathOf(href))) return;
100
+ queued.add(key);
101
+ frontier.push({ name: c.name, ...href ? { href } : {}, from, ...via ? { via } : {}, rank });
102
+ frontier.sort((a, b) => a.rank - b.rank);
103
+ };
104
+ const harvest = (v, via, items = v.controls) => {
105
+ for (const c of items) {
106
+ if (c.leaf && !c.href) continue;
107
+ if (!safe(c.name) || c.footer && !keyWord(c.name)) continue;
108
+ if (keyWord(c.name)) enqueue(c, v.url, c.footer ? 1 : 0, via);
109
+ else if (settingsWord(c.name) && (c.nav || via || c.menu)) enqueue(c, v.url, 2, via);
110
+ }
111
+ };
112
+ const visit = async (c) => {
113
+ tried.add(c.name);
114
+ let v;
115
+ if (c.href) v = await deps.open(c.href);
116
+ else {
117
+ if (pathOf(current.url) !== pathOf(c.from)) {
118
+ const back = await deps.open(c.from);
119
+ if (!back) return void 0;
120
+ current = back;
121
+ }
122
+ if (c.via && !await deps.click(c.via)) return void 0;
123
+ if (c.via) await deps.sleep(300);
124
+ if (!await deps.click(c.name)) return void 0;
125
+ await deps.sleep(700);
126
+ v = await deps.look();
127
+ }
128
+ if (!v) return void 0;
129
+ pages++;
130
+ current = v;
131
+ record(v);
132
+ deps.say?.(`explored ${pathOf(v.url)}`);
133
+ return v;
134
+ };
135
+ const readMenus = async (view) => {
136
+ let opened = 0;
137
+ for (const opener of menuOpeners(view, options.email)) {
138
+ if (opened >= 3 || tried.has(`menu:${opener.name}`)) continue;
139
+ tried.add(`menu:${opener.name}`);
140
+ if (!await deps.click(opener.name)) continue;
141
+ opened++;
142
+ await deps.sleep(350);
143
+ const after = await deps.look();
144
+ const items = added(after, view).filter((c) => !c.leaf || c.href);
145
+ if (items.length) menus.push(`${opener.name}: ${items.map((c) => c.name).slice(0, 14).join(" | ")}`.slice(0, 300));
146
+ current = after;
147
+ harvest(after, opener.name, items);
148
+ const direct = frontier.find((c) => c.via === opener.name && !c.href && c.rank === 0);
149
+ if (direct && pages < maxPages) {
150
+ frontier.splice(frontier.indexOf(direct), 1);
151
+ tried.add(direct.name);
152
+ if (await deps.click(direct.name)) {
153
+ await deps.sleep(700);
154
+ const v = await deps.look();
155
+ pages++;
156
+ current = v;
157
+ record(v);
158
+ if (deps.isKeyPage(v)) {
159
+ hit.v = v;
160
+ return;
161
+ }
162
+ harvest(v);
163
+ return;
164
+ }
165
+ }
166
+ if (deps.press) {
167
+ await deps.press("Escape");
168
+ await deps.sleep(200);
169
+ current = await deps.look();
170
+ }
171
+ }
172
+ };
173
+ const search = async (view) => {
174
+ const field = view.fields.find((f) => SEARCH_FIELD.test(f));
175
+ if (!field || !deps.press || tried.has("search")) return;
176
+ tried.add("search");
177
+ if (await deps.fill(field, options.searchWords ?? "API key")) return;
178
+ if (await deps.press("Enter")) return;
179
+ await deps.sleep(900);
180
+ const v = await deps.look();
181
+ menus.push(`search "API key": ${v.controls.filter((c) => !c.leaf || c.href).map((c) => c.name).slice(0, 10).join(" | ")}`.slice(0, 300));
182
+ pages++;
183
+ current = v;
184
+ record(v);
185
+ if (deps.isKeyPage(v)) {
186
+ hit.v = v;
187
+ return;
188
+ }
189
+ harvest(v);
190
+ };
191
+ const skip = start.controls.find((c) => !c.leaf && !c.footer && SKIP_ONBOARDING.test(c.name.trim()));
192
+ if (skip && await deps.click(skip.name)) {
193
+ await deps.sleep(500);
194
+ current = await deps.look();
195
+ if (deps.isKeyPage(current)) return done(current);
196
+ }
197
+ const first = current;
198
+ harvest(first);
199
+ while (!hit.v && frontier[0]?.rank === 0 && pages < maxPages) {
200
+ const next = frontier.shift();
201
+ const v = await visit(next);
202
+ if (!v) continue;
203
+ if (deps.needsSignIn(v)) {
204
+ needsSignIn = true;
205
+ return done();
206
+ }
207
+ if (deps.isKeyPage(v)) return done(v);
208
+ harvest(v);
209
+ }
210
+ if (!hit.v && pages < maxPages) {
211
+ await readMenus(first);
212
+ }
213
+ if (hit.v) return done(hit.v);
214
+ if (pages < maxPages) {
215
+ await search(first);
216
+ }
217
+ if (hit.v) return done(hit.v);
218
+ while (frontier.length && pages < maxPages) {
219
+ const next = frontier.shift();
220
+ const v = await visit(next);
221
+ if (!v) continue;
222
+ if (deps.needsSignIn(v)) {
223
+ needsSignIn = true;
224
+ return done();
225
+ }
226
+ if (deps.isKeyPage(v)) return done(v);
227
+ harvest(v);
228
+ }
229
+ return done();
230
+ }
231
+
232
+ // src/agent/computer/keygrab.ts
233
+ var KEY_NAME = "ClikCode";
234
+ var KEY_PATHS = ["/settings/api-keys", "/account/api", "/dashboard/api", "/developers", "/developer", "/api-keys", "/keys", "/settings/tokens"];
235
+ var GOOGLE_BUTTON = /^(?:[\w ]{0,24}?\s)?(?:with|using|via)\s+google\b|^google$/i;
236
+ var GITHUB_BUTTON = /^(?:[\w ]{0,24}?\s)?(?:with|using|via)\s+github\b|^github$/i;
237
+ var SOCIAL_HOST = /(^|\.)(github\.com|google\.com|plus\.google\.com)$/i;
238
+ var providerRank = (c) => /\b(continue|sign ?in|sign ?up|log ?in|login|register|connect|start)\b/i.test(c.name) ? 0 : /\b(with|using|via)\b/i.test(c.name) ? 1 : 2;
239
+ var API_LINK = /api (keys?|tokens?|credentials|developers?)/i;
240
+ var API_LINK_AREA = /\bapi\b[^.]{0,30}\b(?:account|portal|console|dashboard|access|sign ?up|register)\b|\b(?:developer|api) (?:portal|console|dashboard|account)\b/i;
241
+ var VOIP_WORDS = VOIP_REFUSED;
242
+ function safeControlNames(controls, max) {
243
+ return controls.slice(0, max).map((c) => hideKeyLikeText(scrubSecrets(c.name)).text);
244
+ }
245
+ function capturedButNotConnected(message) {
246
+ const saved = /SAVED "([^"]+)"/.exec(message)?.[1];
247
+ if (!saved) return void 0;
248
+ const failed = message.split("\n").map((l) => l.trim()).find((l) => /^(?:NOT SENT|NOT connected|FAILED|ERROR)\b|not connected|refused|rejected/i.test(l) && !/^SAVED/.test(l));
249
+ return `a key was captured and saved as ${saved}, but its destination did not take it: ${(failed ?? "the delivery failed").slice(0, 220)}`;
250
+ }
251
+ var COUNTRY_WORDS = /\b(?:(?:u\.?s\.?|united states|american) (?:phone |mobile )?numbers? (?:are |is )?not (?:supported|accepted|allowed)|country (?:is )?not (?:supported|available)|not available in your (?:country|region))\b/i;
252
+ var NOT_A_WAY_IN = /\b(?:blog|news|articles?|press|careers|webinars?|podcasts?|changelog|status)\b/i;
253
+ var API_LINK_WEAK = /^(developers?|api|api access|developer portal|for developers|credentials|keys|tokens?|developer settings)$/i;
254
+ var SIGN_IN_ENTRY = /^(log ?in|sign ?in)$/i;
255
+ var SIGN_UP_ENTRY = /^(sign ?up|get started|get (your )?api key|register|create (an )?account|try (it )?(for )?free|start (for )?free|start building)\b[\w ]{0,15}$/i;
256
+ var CREATE = /^\W*(create|generate|new|add|get|request|issue)\b[^.]{0,30}?\b(key|token|secret|credential)s?\b/i;
257
+ var CREATE_BARE = /^\W*(create|generate|new)\W*$/i;
258
+ var NEVER_KEY = /\b(delete|revoke|remove|rotate|regenerate|roll|cancel|deactivate)\b/i;
259
+ var REVEAL = /^(show|reveal|view|copy|display)\b(?:.{0,24}\b(?:key|token|secret)\b)?\W*$/i;
260
+ var CONFIRM = /^(create|generate|save|continue|ok|done|submit|add|confirm)\b/i;
261
+ var SIGN_IN_LOOSE = /\b(sign ?up|sign ?in|log ?in|register)\b/i;
262
+ var SUBMIT = /^(sign ?up|create( account)?|register|continue|next|get started|submit)\b/i;
263
+ var TERMS_NOTICE = /by (?:proceeding|continuing|clicking|signing up|registering)[^.\n]{0,60}\b(?:agree|accept)|\b(?:agree|accept)[^.\n]{0,40}(?:terms|privacy)/i;
264
+ var COMPLETE_SIGNUP = /^(?:complete (?:your )?(?:registration|sign ?up|account(?: setup)?|setup|profile)|finish(?: sign ?up| setup| registration)?|accept(?: and continue)?|agree(?: and continue)?|i agree|create (?:my )?account|continue)$/i;
265
+ var NAME_FIELD = /name|label|description|title/i;
266
+ var SENT_CODE = /(?:sent|emailed|texted)[^.\n]{0,60}\bcode\b|code[^.\n]{0,40}(?:sent|emailed|texted) to|check your (?:e-?mail|inbox|phone)|text message|\bsms\b/i;
267
+ var CODE_PAGE = /(?:enter|type|paste)[^.\n]{0,40}\bcode\b|verification code|check your (?:e-?mail|inbox)|we(?:'ve| have) sent[^.\n]{0,40}(?:e-?mail|code)/i;
268
+ var RETIRED = /[^.\n]{0,60}\b(?:was|has been|is being|were) (?:retired|discontinued|shut down|sunset|deprecated)\b[^.\n]{0,60}/i;
269
+ var NOT_FOUND = /\b404\b|page (?:not found|does(?:n't| not) exist)|not found|no such page|couldn'?t find|can'?t find|\boops\b|doesn'?t exist|does not exist/i;
270
+ var CAPTCHA_TEXT = CAPTCHA_WORDS;
271
+ var CAPTCHA_FIELD = CAPTCHA_FIELD_WORDS;
272
+ var PAYMENT_TEXT = /enter your (?:credit |debit )?card|(?:credit |debit )?card (?:number|details) (?:is )?required|\bcard number\b|\bcvc\b|\bcvv\b|expir(?:y|ation) date|payment method (?:is )?required|(?:add|enter) (?:a )?(?:valid )?payment method to (?:continue|proceed|get)|(?<!\bno )(?<!\bwithout a )credit card (?:is )?required(?! for)|enter (?:a )?valid card/i;
273
+ var PAYMENT_FIELD = /card number|\bcvc\b|\bcvv\b|expir(?:y|ation)|name on card/i;
274
+ var IDENTITY_STRONG = /verify your (?:identity|id\b|business)|confirm your identity|(?:upload|scan|take|submit)[^.\n]{0,40}(?:passport|driver'?s licen[cs]e|government[- ]issued|id (?:card|document))|please (?:provide|submit)[^.\n]{0,30}(?:business|company) (?:verification|registration)/i;
275
+ var IDENTITY_WEAK = /identity verification|business verification|verify your business|\bKYC (?:check|verification|process|required|documents?)|know your customer (?:check|verification|process)/i;
276
+ var IDENTITY_WALL = new RegExp(`${IDENTITY_STRONG.source}|${IDENTITY_WEAK.source}`, "i");
277
+ var paymentWall = (text) => /\bplan\b|pricing|upgrade|subscription|paid tier/i.test(text) ? "paid-plan" : "card";
278
+ function keygrabWall(text, keyPage = false, signInOffered = false, extra = {}) {
279
+ const blocker = detectBlocker(text);
280
+ if (/make an offer|buy this domain|domain(?: name)? is for sale|this domain (?:is|may be) for sale|domain for sale/i.test(text)) return { kind: "retire", reasonCode: "domain-for-sale", what: "a domain-for-sale page (the vendor looks gone)" };
281
+ if (/error 1016|origin dns error|server ip address could not be found|ERR_NAME_NOT_RESOLVED|DNS_PROBE_FINISHED|site can.t be reached|this domain (?:has )?expired/i.test(text)) return { kind: "retire", reasonCode: "host-dead", what: "a site that no longer resolves (the vendor looks gone)" };
282
+ if (extra.captchaFrame || CAPTCHA_TEXT.test(text) || (extra.fields ?? []).some((f) => CAPTCHA_FIELD.test(f))) return { kind: "captcha", reasonCode: "captcha", what: "a captcha" };
283
+ const signUpForm = /verification e-?mail|we(?:'ll| will) e-?mail you/i.test(text) && (extra.fields ?? []).some((f) => /e-?mail/i.test(f)) && !/passport|licen[cs]e|upload|government/i.test(text);
284
+ if (!signUpForm && IDENTITY_STRONG.test(text) || !keyPage && !signInOffered && IDENTITY_WEAK.test(text)) return { kind: "identity", reasonCode: "identity-check", what: "identity or business verification" };
285
+ if (/(?:e-?mail|address)[^.\n]{0,50}(?:not allowed|not accepted|not supported|is blocked|invalid domain|not permitted)|(?:personal|free|public|gmail)[^.\n]{0,30}(?:e-?mail|address)[^.\n]{0,30}(?:not|can(?:'|no)t)|(?:work|business|company) e-?mail (?:is )?(?:required|only)|use a (?:work|business|company) e-?mail/i.test(text)) return { kind: "decision", reasonCode: /(?:work|business|company) e-?mail/i.test(text) ? "work-email" : "free-mail", what: "a refusal of the email address" };
286
+ if (!keyPage && ((extra.fields ?? []).some((f) => PAYMENT_FIELD.test(f)) || PAYMENT_TEXT.test(text))) return { kind: "payment", reasonCode: paymentWall(text), what: "a payment page" };
287
+ if (keyPage || signInOffered) return void 0;
288
+ if (/(?:verify|confirm|enter|add)[^.\n]{0,30}(?:phone|mobile)(?: number)?|(?:sms|text message)[^.\n]{0,40}code|code[^.\n]{0,30}(?:sent|texted)[^.\n]{0,20}(?:phone|number|\+\d)|phone verification/i.test(text) && /verif|code|confirm/i.test(text)) return { kind: "sms", reasonCode: "phone-verification", what: "a phone (SMS) verification" };
289
+ if (blocker === "an SMS or authenticator code") return { kind: "mfa", reasonCode: "verification-code", what: "an authenticator or SMS code" };
290
+ if (blocker === "a review page" || /waitlist|wait list|pending (?:manual )?approval|manual(?:ly)? (?:review|approv)|request access|invite[- ]only|by invitation|we(?:'ll| will) (?:review|be in touch)/i.test(text)) return { kind: "vendor-contact", reasonCode: "approval-needed", what: "a manual approval or waitlist" };
291
+ return void 0;
292
+ }
293
+ var BANNER_TEXT = /cookie|consent|privacy|gdpr/i;
294
+ var BANNER_REJECT = /^(?:reject(?: all)?(?: cookies)?|decline(?: all)?(?: cookies)?|deny(?: all)?|refuse(?: all)?|(?:use |accept |allow )?(?:only )?(?:strictly )?(?:necessary|essential|required)(?: cookies)?(?: only)?|only (?:necessary|essential|required)(?: cookies)?|continue without accepting|no,? thanks)$/i;
295
+ var BANNER_ACCEPT = /^(?:accept(?: all)?(?: cookies)?|allow(?: all)?(?: cookies)?|i agree|agree(?: and (?:continue|close|proceed))?|got it|ok(?:ay)?|i understand|understood)$/i;
296
+ var BANNER_ACCEPT_BARE = /^(?:ok(?:ay)?|got it|agree|i understand|understood)$/i;
297
+ function bannerButton(view) {
298
+ if (!BANNER_TEXT.test(view.text)) return void 0;
299
+ const live = view.controls.filter((c) => !c.leaf && c.name.length <= 40);
300
+ const reject = live.find((c) => BANNER_REJECT.test(c.name.trim()));
301
+ if (reject) return reject;
302
+ const cookies = /cookie|consent/i.test(view.text);
303
+ return live.find((c) => BANNER_ACCEPT.test(c.name.trim()) && (cookies || !BANNER_ACCEPT_BARE.test(c.name.trim())));
304
+ }
305
+ var CHOOSER_TEXT = /\b(?:choose|select|pick) (?:the |a |your )?(?:product|plan|account(?: type)?|option|portal|service)\b[^.\n]{0,30}(?:sign ?in|log ?in|continue)?/i;
306
+ var CHOOSER_PREFERRED = /\b(?:api|developers?)\b|^(?:community|free|developer|self[- ]serve|personal|individual|basic|starter|hobby)\b/i;
307
+ function chooserOptions(view) {
308
+ if (!CHOOSER_TEXT.test(view.text)) return void 0;
309
+ const after = view.text.slice(Math.max(0, view.text.search(CHOOSER_TEXT)));
310
+ const options = view.controls.filter((c) => c.name.length <= 80 && !c.footer && after.includes(c.name.slice(0, 20)) && !CHOOSER_TEXT.test(c.name) && !/^(?:sign ?in|log ?in|continue|discover|search|pricing|about|documentation|status)$/i.test(c.name));
311
+ const pick = options.find((c) => CHOOSER_PREFERRED.test(c.name) && !/^(?:pro|platform)\b/i.test(c.name));
312
+ return { options, ...pick ? { pick } : {} };
313
+ }
314
+ function startCandidates(url, alternates = []) {
315
+ const out = [];
316
+ const add = (u) => {
317
+ if (u && !out.includes(u)) out.push(u);
318
+ };
319
+ add(url);
320
+ for (const alt of alternates) add(alt);
321
+ let host = "";
322
+ try {
323
+ host = new URL(url).hostname.replace(/^www\./, "");
324
+ } catch {
325
+ return out;
326
+ }
327
+ const labels = host.split(".");
328
+ const second = /* @__PURE__ */ new Set(["co", "com", "org", "net", "gov", "ac"]);
329
+ const keep = labels.length > 2 && second.has(labels[labels.length - 2]) && labels[labels.length - 1].length === 2 ? 3 : 2;
330
+ for (let i = 1; labels.length - i >= keep; i++) add(`https://${labels.slice(i).join(".")}/`);
331
+ const root = labels.slice(-keep).join(".");
332
+ add(`https://developer.${root}/`);
333
+ add(`https://developers.${root}/`);
334
+ for (const path of ["/developers", "/signup", "/register", "/login", "/account"]) add(`https://${root}${path}`);
335
+ return out;
336
+ }
337
+ var HOSTS_OF_SIGN_IN = /(^|\.)(accounts\.google\.com|google\.com|github\.com)$/i;
338
+ var hostOf = (url) => {
339
+ try {
340
+ return new URL(url).hostname;
341
+ } catch {
342
+ return "";
343
+ }
344
+ };
345
+ var originOf = (url) => {
346
+ try {
347
+ return new URL(url).origin;
348
+ } catch {
349
+ return "";
350
+ }
351
+ };
352
+ var pathOf2 = (url) => {
353
+ try {
354
+ const u = new URL(url);
355
+ return `${u.origin}${u.pathname}`;
356
+ } catch {
357
+ return "";
358
+ }
359
+ };
360
+ var pressable = (c) => !c.leaf && c.name.length <= 80;
361
+ var Halt = class extends Error {
362
+ constructor(stop) {
363
+ super(stop.message);
364
+ this.stop = stop;
365
+ }
366
+ stop;
367
+ };
368
+ async function runKeygrab(port, options) {
369
+ const now = options.now ?? Date.now;
370
+ const sleep2 = options.sleep ?? sleep;
371
+ const maxSteps = options.maxSteps ?? 60, maxMs = options.maxMs ?? 24e4;
372
+ const began = now();
373
+ let steps = 0;
374
+ let route = "none";
375
+ const trail = [];
376
+ let authTries = 0;
377
+ const visited = [...options.resume?.visited ?? []];
378
+ const menus = [...options.resume?.menus ?? []];
379
+ const triedNames = /* @__PURE__ */ new Set();
380
+ const sink = options.log;
381
+ const say = (line) => sink?.(`keygrab ${options.id}: ${line}`);
382
+ const act = async (what, run) => {
383
+ if (steps >= maxSteps) throw await stop("unknown", `keygrab used its ${maxSteps}-step budget (${what})`);
384
+ if (now() - began > maxMs) throw await stop("unknown", `keygrab used its ${Math.round(maxMs / 1e3)}s budget (${what})`);
385
+ steps++;
386
+ trail.push(what.slice(0, 80));
387
+ say(`${steps}: ${what.slice(0, 80)}`);
388
+ return run();
389
+ };
390
+ let keyOnScreen = false;
391
+ const stop = async (kind, message, human, view) => {
392
+ const seen = view ?? await port.look().catch(() => ({ url: "", text: "", controls: [], fields: [], hasPassword: false }));
393
+ const withhold = keyOnScreen || showsKey(seen) || hideKeyLikeText(seen.text).hidden > 0;
394
+ const screenshot = withhold ? void 0 : await port.screenshot().catch(quiet("agent/computer/keygrab"));
395
+ return new Halt({ kind, message, url: pathOf2(seen.url) || seen.url, pageText: pageExcerpt(hideKeyLikeText(seen.text).text), controls: safeControlNames(seen.controls.filter((c) => !c.leaf), 12), ...screenshot ? { screenshot } : {}, ...human ? { human } : {}, trail: trail.slice(-30), actions: steps, ...signedIn ? { signedIn: true } : {}, ...visited.length ? { visited: visited.slice(-30) } : {}, ...menus.length ? { menus: menus.slice(-12) } : {} });
396
+ };
397
+ const wallStop = async (view, wall) => {
398
+ const host = hostOf(view.url) || "the vendor";
399
+ const url = pathOf2(view.url);
400
+ const human = { kind: wall.kind, ...url.startsWith("https://") ? { url } : {}, reasonCode: wall.reasonCode, instructions: `${host} shows ${wall.what} before a key can be had for ${options.id}; keygrab does not bypass it and nothing was paid.` };
401
+ return stop(wall.kind === "captcha" ? "captcha" : wall.kind === "payment" ? "payment" : wall.kind === "mfa" || wall.kind === "sms" ? "mfa" : "unknown", `${wall.what} at ${host}`, human, view);
402
+ };
403
+ const bareShell = (v) => v.text.trim().length < 300 && !v.fields.length && !v.controls.some((c) => !c.footer && !/terms|privacy|cookie|consent|status|contact|©|policy/i.test(c.name));
404
+ let banners = 0;
405
+ const dismissBanner = async (v) => {
406
+ for (let round = 0; round < 2 && banners < 4; round++) {
407
+ const button = bannerButton(v);
408
+ if (!button) return v;
409
+ banners++;
410
+ const err = await act(`dismiss the cookie banner (${button.name})`, () => port.click(button.name));
411
+ if (err) return v;
412
+ await sleep2(400);
413
+ v = await port.look();
414
+ }
415
+ return v;
416
+ };
417
+ let authenticatorTried = false;
418
+ const pastAuthenticator = async (view) => {
419
+ if (authenticatorTried || !port.authenticatorCode || !view.fields.length || SENT_CODE.test(view.text)) return false;
420
+ authenticatorTried = true;
421
+ const code = await act("read the authenticator code", () => port.authenticatorCode());
422
+ if (!code) return false;
423
+ const field = view.fields.find((f) => /code|otp|token|2fa|mfa/i.test(f)) ?? view.fields[0];
424
+ await act("type the authenticator code", () => port.fill(field, code));
425
+ const go = [...view.controls].reverse().find((c) => pressable(c) && /^(verify|confirm|continue|submit|next|log ?in|sign ?in)\b/i.test(c.name));
426
+ if (go) await click(go.name);
427
+ await sleep2(800);
428
+ return true;
429
+ };
430
+ let businessTried = false;
431
+ const pastFreeMail = async (view) => {
432
+ if (businessTried || !port.businessEmail) return false;
433
+ businessTried = true;
434
+ const field = view.fields.find((f) => /e-?mail/i.test(f));
435
+ if (!field) return false;
436
+ const address = await act("pick a business email address", () => port.businessEmail());
437
+ if (!address) return false;
438
+ await act("type the business email", () => port.fill(field, address));
439
+ const go = [...view.controls].reverse().find((c) => pressable(c) && /^(sign ?up|create (?:my |an )?account|get started|continue|next|submit|start(?: free)?(?: trial)?|register|join)\b/i.test(c.name));
440
+ if (!go) return false;
441
+ await click(go.name);
442
+ await sleep2(1500);
443
+ return true;
444
+ };
445
+ let phoneTried = false;
446
+ const pastPhone = async (view) => {
447
+ if (phoneTried || !port.smsCode) return "none";
448
+ phoneTried = true;
449
+ let v = view;
450
+ let since = Date.now() - 18e4;
451
+ const phoneField = v.fields.find((f) => /phone|mobile|\btel\b|cell/i.test(f));
452
+ const codeField = (fields) => fields.find((f) => /code|otp|pin|digit|verif/i.test(f));
453
+ if (phoneField && !codeField(v.fields)) {
454
+ await act("type the profile phone", () => port.fill(phoneField));
455
+ since = Date.now();
456
+ const send = [...v.controls].reverse().find((c) => pressable(c) && /^(send|text me|send (?:the )?code|get (?:a )?code|verify|continue|next|submit)\b/i.test(c.name));
457
+ if (!send) {
458
+ say("phone check: no button to send the code");
459
+ return "form";
460
+ }
461
+ await click(send.name);
462
+ await sleep2(2e3);
463
+ v = await port.look();
464
+ const again = v.fields.find((f) => /phone|mobile|\btel\b|cell/i.test(f));
465
+ if (again && !codeField(v.fields) && (VOIP_WORDS.test(v.text) || COUNTRY_WORDS.test(v.text))) {
466
+ await act("type the personal mobile (the site refused the VoIP number)", () => port.fill(again));
467
+ since = Date.now();
468
+ const resend = [...v.controls].reverse().find((c) => pressable(c) && /^(send|text me|send (?:the )?code|get (?:a )?code|verify|continue|next|submit)\b/i.test(c.name));
469
+ if (resend) {
470
+ await click(resend.name);
471
+ await sleep2(2e3);
472
+ v = await port.look();
473
+ }
474
+ }
475
+ }
476
+ const field = codeField(v.fields) ?? (v.fields.length === 1 ? v.fields[0] : void 0);
477
+ if (!field) {
478
+ say("phone check: no box for the code");
479
+ return "form";
480
+ }
481
+ const code = await act("read the texted code", () => port.smsCode(since));
482
+ if (!code) return "no-code";
483
+ await act("type the texted code", () => port.fill(field, code));
484
+ const go = [...v.controls].reverse().find((c) => pressable(c) && /^(verify|confirm|continue|submit|next|done)\b/i.test(c.name));
485
+ if (go) await click(go.name);
486
+ await sleep2(1500);
487
+ return "passed";
488
+ };
489
+ let cardTried = false;
490
+ const pastPayment = async (view) => {
491
+ if (cardTried || !port.cardAllowed || !view.fields.length) return false;
492
+ cardTried = true;
493
+ if (!await act("check the standing card rule against the payment page", () => port.cardAllowed(view.text))) return false;
494
+ for (const field of view.fields) await act(`fill ${field} from the profile or the saved card`, () => port.fill(field));
495
+ const go = [...view.controls].reverse().find((c) => pressable(c) && /^(?:continue|submit|save|next|add (?:card|payment(?: method)?)|start|create|verify|confirm|finish|complete)\b/i.test(c.name));
496
+ if (go) await click(go.name);
497
+ await sleep2(1500);
498
+ return true;
499
+ };
500
+ const guard = async (view) => {
501
+ const wall = keygrabWall(view.text, view.controls.some(isCreate), offersSignIn(view), { ...view.captchaFrame ? { captchaFrame: true } : {}, fields: view.fields });
502
+ if (wall?.kind === "captcha" && !view.captchaFrame && wordsOnly.has(pathOf2(view.url) || view.url)) return;
503
+ if (wall?.kind === "captcha" && answered.has(pathOf2(view.url) || view.url)) return;
504
+ if (wall?.kind === "mfa" && await pastAuthenticator(view)) return;
505
+ if (wall?.kind === "decision" && /work-email|free-mail/.test(wall.reasonCode) && await pastFreeMail(view)) return;
506
+ if (wall?.kind === "sms" || wall?.kind === "mfa" && /text|sms|phone|mobile/i.test(view.text)) {
507
+ const phone = await pastPhone(view);
508
+ if (phone === "passed") return;
509
+ if (phone === "form") throw await stop("unknown", `a phone-code form at ${hostOf(view.url) || "the vendor"} the runner cannot work; texted codes can be read (read_sms_code)`, void 0, view);
510
+ }
511
+ if (wall?.kind === "payment" && await pastPayment(view)) return;
512
+ if (wall) throw await wallStop(view, wall);
513
+ };
514
+ const captchaOn = (view) => keygrabWall(view.text, view.controls.some(isCreate), offersSignIn(view), { ...view.captchaFrame ? { captchaFrame: true } : {}, fields: view.fields })?.kind === "captcha";
515
+ const checkedAt = /* @__PURE__ */ new Map();
516
+ const wordsOnly = /* @__PURE__ */ new Set();
517
+ const answered = /* @__PURE__ */ new Set();
518
+ let checks = 0;
519
+ const pastCaptcha = async (view) => {
520
+ let v = view;
521
+ while (captchaOn(v) && port.humanCheck && !answered.has(pathOf2(v.url) || v.url)) {
522
+ const here = pathOf2(v.url) || v.url;
523
+ const tries = checkedAt.get(here) ?? 0;
524
+ if (tries >= 2 || checks >= 6) break;
525
+ checkedAt.set(here, tries + 1);
526
+ checks++;
527
+ const outcome = await act("get past the human check", () => port.humanCheck());
528
+ say(`human check: ${outcome}`);
529
+ if (outcome === "none" && !v.captchaFrame) {
530
+ wordsOnly.add(here);
531
+ return v;
532
+ }
533
+ if (outcome !== "cleared") break;
534
+ if (tries >= 1) {
535
+ answered.add(here);
536
+ return v;
537
+ }
538
+ await sleep2(800);
539
+ v = await dismissBanner(await port.look());
540
+ if (!v.captchaFrame) {
541
+ wordsOnly.add(pathOf2(v.url) || v.url);
542
+ return v;
543
+ }
544
+ }
545
+ return v;
546
+ };
547
+ const look = async () => {
548
+ let v = await port.look();
549
+ for (let wait = 0; wait < 6 && (!v.controls.length && v.text.trim().length < 40 || bareShell(v) || /\b(?:loading|just a minute|please wait)\b/i.test(v.text) && v.text.length < 400 && v.controls.length < 6); wait++) {
550
+ await sleep2(1500);
551
+ v = await port.look();
552
+ }
553
+ v = await dismissBanner(v);
554
+ v = await pastCaptcha(v);
555
+ await guard(v);
556
+ const here = pathOf2(v.url);
557
+ if (here && !visited.includes(here) && visited.length < 60) visited.push(here);
558
+ return v;
559
+ };
560
+ const click = async (name) => {
561
+ const err = await act(`click ${name}`, () => port.click(name));
562
+ if (err) say(`could not click "${name}"`);
563
+ return !err;
564
+ };
565
+ const isCreate = (c) => pressable(c) && !NEVER_KEY.test(c.name) && (CREATE.test(c.name) || CREATE_BARE.test(c.name));
566
+ const createOf = (v) => {
567
+ if (offersSignIn(v)) return void 0;
568
+ const exact = v.controls.find((c) => pressable(c) && !NEVER_KEY.test(c.name) && CREATE.test(c.name));
569
+ if (exact) return exact;
570
+ return /\b(api|key|token)/i.test(v.text) ? v.controls.find((c) => pressable(c) && !NEVER_KEY.test(c.name) && CREATE_BARE.test(c.name)) : void 0;
571
+ };
572
+ const revealOf = (v) => offersSignIn(v) ? void 0 : /\b(api|key|token|secret)/i.test(v.text) ? v.controls.find((c) => pressable(c) && REVEAL.test(c.name)) : void 0;
573
+ const offersSignIn = (v) => !v.hasPassword ? providerButtons(v, GOOGLE_BUTTON).length > 0 || providerButtons(v, GITHUB_BUTTON).length > 0 || v.controls.some((c) => pressable(c) && !c.footer && (SIGN_IN_ENTRY.test(c.name) || SIGN_UP_ENTRY.test(c.name))) : true;
574
+ const showsKey = (v) => !offersSignIn(v) && /\b(api[- ]?keys?|secret|token|access key)\b/i.test(v.text) && v.text.split(/\s+/).some((word) => keyShaped(word.replace(/^[("'`]+|[)"'`,.;]+$/g, "")));
575
+ const isKeyPage = (v) => !!createOf(v) || !!revealOf(v) || showsKey(v);
576
+ const hasEntry = (v) => !!entryOf(v, SIGN_IN_ENTRY) || !!entryOf(v, SIGN_UP_ENTRY) || !!entryOf(v, SIGN_IN_LOOSE);
577
+ const signEntry = (v) => !!entryOf(v, SIGN_IN_ENTRY) || !!entryOf(v, SIGN_UP_ENTRY);
578
+ const authWall = (v) => !isKeyPage(v) && (v.hasPassword || !!chooserOptions(v) || providerButtons(v, GOOGLE_BUTTON).length > 0 || providerButtons(v, GITHUB_BUTTON).length > 0 || v.fields.some((f) => /e-?mail/i.test(f)) && v.controls.some((c) => pressable(c) && SUBMIT.test(c.name)));
579
+ const providerScreens = async () => {
580
+ const email = await port.profileEmail().catch(quiet("agent/computer/keygrab"));
581
+ let idle = 0, chosen2 = false;
582
+ const loginTried = /* @__PURE__ */ new Set();
583
+ for (let round = 0; round < 10; round++) {
584
+ await sleep2(600);
585
+ const v = await look();
586
+ const host = hostOf(v.url);
587
+ if (!HOSTS_OF_SIGN_IN.test(host)) return;
588
+ if (v.hasPassword) {
589
+ const provider = /github\.com$/i.test(host) ? "GitHub" : "Google";
590
+ if (loginTried.has(host)) throw await stop("password", `${provider} still asks for a password after the saved login attempt`, { kind: "worker-setup", url: `https://${host}/`, reasonCode: "sign-in-needed", instructions: `The saved ${provider} login did not complete sign-in; check its saved account or verification requirement.` }, v);
591
+ loginTried.add(host);
592
+ const done = await act(`sign in to ${provider} with the saved login`, () => port.login());
593
+ if (!done.ok) throw await stop("password", `${provider} needs a sign-in the runner cannot do: ${done.message}`, { kind: "worker-setup", url: `https://${host}/`, reasonCode: "sign-in-needed", instructions: `The saved ${provider} login could not complete sign-in; check its saved account or verification requirement.` }, v);
594
+ continue;
595
+ }
596
+ const controls = v.controls.map((c) => ({ name: c.name, leaf: c.leaf === true }));
597
+ const next = nextPress(host, controls, v.text, { ...email ? { email } : {}, skipAccount: chosen2 });
598
+ const target = next && controls[next.index];
599
+ if (!target || !next) {
600
+ if (++idle >= 3) throw await stop("unknown", `a ${host} screen the runner does not know`, void 0, v);
601
+ continue;
602
+ }
603
+ idle = 0;
604
+ if (next.note === "Chose the account.") chosen2 = true;
605
+ if (next.note === "Chose the account." && email && target.name.toLowerCase().includes(email.toLowerCase())) await click(email);
606
+ else await click(target.name);
607
+ }
608
+ const last = await look();
609
+ if (HOSTS_OF_SIGN_IN.test(hostOf(last.url))) throw await stop("unknown", `still on a ${hostOf(last.url)} screen after pressing through it`, void 0, last);
610
+ };
611
+ const verifyEmail = async () => {
612
+ for (let round = 0; round < 2; round++) {
613
+ const v = await look();
614
+ if (!CODE_PAGE.test(v.text)) return;
615
+ const code = await act("read the emailed code", () => port.emailCode());
616
+ if (code) {
617
+ const field = v.fields.find((f) => /code|otp|token/i.test(f)) ?? v.fields[0];
618
+ if (field) await act("type the emailed code", () => port.fill(field, code));
619
+ const go = [...v.controls].reverse().find((c) => pressable(c) && /^(verify|confirm|continue|submit|next)\b/i.test(c.name));
620
+ if (go) await click(go.name);
621
+ await sleep2(800);
622
+ continue;
623
+ }
624
+ if (!await act("open the emailed link", () => port.emailLink())) throw await stop("unknown", "the vendor wants an emailed code or link and none could be read", void 0, v);
625
+ await sleep2(800);
626
+ }
627
+ };
628
+ let resetTried = false;
629
+ const resetPassword = async () => {
630
+ if (resetTried || !port.resetLink) return false;
631
+ resetTried = true;
632
+ let v = await look();
633
+ const forgot = v.controls.find((c) => pressable(c) && /forgot|reset (?:your )?password|can.?t (?:sign|log) in|trouble (?:signing|logging) in/i.test(c.name));
634
+ if (!forgot || !await click(forgot.name)) return false;
635
+ await sleep2(800);
636
+ v = await look();
637
+ for (const field of v.fields.filter((f) => /e-?mail|user/i.test(f))) await act(`fill ${field}`, () => port.fill(field));
638
+ const send = [...v.controls].reverse().find((c) => pressable(c) && /^(?:send|reset|continue|submit|next|email me|request|get (?:a )?(?:reset )?link)\b/i.test(c.name));
639
+ if (!send) return false;
640
+ await click(send.name);
641
+ await sleep2(1500);
642
+ if (!await act("open the emailed password-reset link", () => port.resetLink())) return false;
643
+ await sleep2(1500);
644
+ v = await look();
645
+ const boxes = v.fields.filter((f) => /password/i.test(f));
646
+ if (!boxes.length) return false;
647
+ for (const field of boxes) await act(`fill ${field} with a new saved password`, () => port.fill(field));
648
+ const save = [...v.controls].reverse().find((c) => pressable(c) && /^(?:reset|save|change|update|set|submit|continue|confirm)\b/i.test(c.name));
649
+ if (save) await click(save.name);
650
+ await sleep2(1500);
651
+ return true;
652
+ };
653
+ const emailRoute = async (v) => {
654
+ route = "email";
655
+ const done = await act("sign in with the profile email", () => port.login());
656
+ if (done.ok) return;
657
+ if (/did not accept the saved password|password (?:was )?(?:refused|rejected|incorrect)|incorrect password|wrong password|invalid (?:email or )?password/i.test(done.message) && await resetPassword()) {
658
+ const again = await act("sign in with the new password", () => port.login());
659
+ if (again.ok) return;
660
+ }
661
+ let here = await look();
662
+ const onLogin = here.controls.some((c) => pressable(c) && /^(log ?in|sign ?in)$/i.test(c.name));
663
+ const toSignUp = onLogin ? here.controls.find((c) => pressable(c) && /sign ?up|create (an )?account|register|get started/i.test(c.name) && !/^(log ?in|sign ?in)$/i.test(c.name)) : void 0;
664
+ if (toSignUp && await click(toSignUp.name)) {
665
+ await sleep2(800);
666
+ here = await look();
667
+ }
668
+ for (const field of here.fields.length ? here.fields : v.fields) await act(`fill ${field}`, () => port.fill(field));
669
+ const submit = [...here.controls].reverse().find((c) => pressable(c) && /^(sign ?up|create( account)?|register|continue|next|get started|submit)$/i.test(c.name)) ?? [...here.controls].reverse().find((c) => pressable(c) && SUBMIT.test(c.name) && c.name.length <= 30);
670
+ if (!submit) throw await stop("unknown", `the sign-in form has no button the runner knows (${done.message})`, void 0, here);
671
+ await click(submit.name);
672
+ await sleep2(800);
673
+ await verifyEmail();
674
+ const after = await look();
675
+ if (after.hasPassword && after.fields.length) throw await stop("unknown", "the sign-up form was not accepted (it is still showing)", void 0, after);
676
+ };
677
+ const completeRegistration = async () => {
678
+ for (let round = 0; round < 2; round++) {
679
+ const v = await look();
680
+ if (v.hasPassword || v.fields.length || !TERMS_NOTICE.test(v.text)) return;
681
+ const go = v.controls.find((c) => pressable(c) && !c.footer && COMPLETE_SIGNUP.test(c.name.trim()));
682
+ if (!go || !await click(go.name)) return;
683
+ await sleep2(900);
684
+ }
685
+ };
686
+ const authContext = (v) => v.hasPassword || v.fields.some((f) => /e-?mail|user ?name|login/i.test(f)) || /\b(?:sign|log) ?(?:in|up) (?:with|using)\b|\bcontinue with\b/i.test(v.text.slice(0, 3e3));
687
+ const providerButtons = (v, re) => v.controls.filter((c) => c.name.length <= 80 && (!c.leaf || providerRank(c) < 2) && (providerRank(c) < 2 || authContext(v)) && !c.footer && re.test(c.name) && !(c.href && SOCIAL_HOST.test(hostOf(c.href)))).sort((a, b) => providerRank(a) - providerRank(b));
688
+ const entryOf = (v, re) => v.controls.find((c) => pressable(c) && !c.footer && re.test(c.name.replace(/\s*last used\s*$/i, "").trim()));
689
+ const choose = async (v) => {
690
+ const chooser = chooserOptions(v);
691
+ if (!chooser) return false;
692
+ if (!chooser.pick) throw await stop("choice", `the site asks which product to sign in to and none is plainly the API one: ${chooser.options.map((o) => o.name).join(" | ").slice(0, 200)}`, void 0, v);
693
+ if (!await click(chooser.pick.name)) throw await stop("choice", `could not press the "${chooser.pick.name}" option (the others: ${chooser.options.filter((o) => o !== chooser.pick).map((o) => o.name).join(" | ").slice(0, 160)})`, void 0, v);
694
+ await sleep2(700);
695
+ return true;
696
+ };
697
+ let signedIn = options.resume?.signedIn === true;
698
+ const authenticate = async () => {
699
+ await signIn();
700
+ signedIn = true;
701
+ };
702
+ const signIn = async () => {
703
+ authTries++;
704
+ const pressed = /* @__PURE__ */ new Set();
705
+ const fresh = (re, page) => page.controls.find((c) => pressable(c) && !c.footer && !pressed.has(c.name) && re.test(c.name.replace(/\s*last used\s*$/i, "").trim()));
706
+ for (let attempt = 0; attempt < 4; attempt++) {
707
+ const v = await look();
708
+ if (await choose(v)) continue;
709
+ for (const [name, re] of [["google", GOOGLE_BUTTON], ["github", GITHUB_BUTTON]]) {
710
+ for (const button of providerButtons(v, re).slice(0, 3)) {
711
+ if (!await click(button.name)) continue;
712
+ await sleep2(700);
713
+ const after = await port.look();
714
+ if (!HOSTS_OF_SIGN_IN.test(hostOf(after.url)) && pathOf2(after.url) === pathOf2(v.url) && after.text === v.text) {
715
+ say(`"${button.name}" did not go anywhere`);
716
+ continue;
717
+ }
718
+ route = name;
719
+ await providerScreens();
720
+ await verifyEmail();
721
+ await completeRegistration();
722
+ return;
723
+ }
724
+ }
725
+ if (v.hasPassword) {
726
+ await emailRoute(v);
727
+ return;
728
+ }
729
+ const entry = fresh(SIGN_UP_ENTRY, v) ?? fresh(SIGN_IN_ENTRY, v) ?? fresh(SIGN_IN_LOOSE, v);
730
+ if (!entry && v.fields.some((f) => /e-?mail/i.test(f))) {
731
+ await emailRoute(v);
732
+ return;
733
+ }
734
+ if (!entry && pressed.size && !authWall(v) && !providerButtons(v, GOOGLE_BUTTON).length && !providerButtons(v, GITHUB_BUTTON).length) {
735
+ say("signed in by the last press");
736
+ return;
737
+ }
738
+ if (!entry) break;
739
+ pressed.add(entry.name);
740
+ await click(entry.name);
741
+ await sleep2(600);
742
+ }
743
+ throw await stop("unknown", "no way to sign in was found on the page");
744
+ };
745
+ let lastOpenError = "";
746
+ const openAt = async (url) => {
747
+ const err = await act(`open ${pathOf2(url).replace(/^https:\/\//, "")}`, () => port.open(url));
748
+ if (err) {
749
+ say(`could not open ${pathOf2(url)}: ${err.slice(0, 160)}`);
750
+ lastOpenError = err.slice(0, 200);
751
+ return void 0;
752
+ }
753
+ return look();
754
+ };
755
+ let shown = { url: "", text: "", controls: [], fields: [], hasPassword: false };
756
+ let exploredRuns = 0;
757
+ const exploreSignedIn = async (v) => {
758
+ if (exploredRuns >= 2 || isKeyPage(v)) return void 0;
759
+ const email = await port.profileEmail().catch(quiet("agent/computer/keygrab"));
760
+ const looksSignedIn = !offersSignIn(v) && menuOpeners(v, email).some((c) => c.menu === true || !!email && c.name.toLowerCase().includes(email.toLowerCase()));
761
+ if (!((signedIn || looksSignedIn) && !authWall(v))) return void 0;
762
+ exploredRuns++;
763
+ const explored = await exploreForKeys({
764
+ look,
765
+ click,
766
+ open: openAt,
767
+ sleep: sleep2,
768
+ say,
769
+ fill: (name, text) => act(`fill ${name}`, () => port.fill(name, text)),
770
+ ...port.press ? { press: (key) => act(`press ${key}`, () => port.press(key)) } : {},
771
+ isKeyPage,
772
+ needsSignIn: authWall
773
+ }, v, { maxPages: options.exploreMax ?? 8, ...email ? { email } : {}, seen: visited, seenMenus: menus });
774
+ visited.splice(0, visited.length, ...explored.visited);
775
+ menus.splice(0, menus.length, ...explored.menus);
776
+ for (const name of explored.tried) triedNames.add(name);
777
+ shown = explored.last;
778
+ return { ...explored.found ? { found: explored.found } : {}, last: explored.last };
779
+ };
780
+ let homeUrl = "";
781
+ const findKeyPage = async (start) => {
782
+ let v = start;
783
+ shown = start;
784
+ if (isKeyPage(v)) return v;
785
+ for (const known of (options.knownKeyPages ?? []).slice(0, 3)) {
786
+ let page = await openAt(known);
787
+ if (!page) continue;
788
+ if (authWall(page) && authTries < 2) {
789
+ await authenticate();
790
+ page = await openAt(known);
791
+ if (!page) continue;
792
+ }
793
+ if (isKeyPage(page)) return page;
794
+ v = page;
795
+ shown = page;
796
+ }
797
+ const explored = await exploreSignedIn(v);
798
+ if (explored?.found) return explored.found;
799
+ if (explored) {
800
+ v = explored.last;
801
+ shown = v;
802
+ }
803
+ const linksOf = (page) => [
804
+ ...page.controls.filter((c) => pressable(c) && !NEVER_KEY.test(c.name) && API_LINK.test(c.name)),
805
+ ...page.controls.filter((c) => pressable(c) && !NEVER_KEY.test(c.name) && !API_LINK.test(c.name) && API_LINK_AREA.test(c.name) && c.name.length <= 60),
806
+ ...page.controls.filter((c) => pressable(c) && !NEVER_KEY.test(c.name) && !API_LINK.test(c.name) && API_LINK_WEAK.test(c.name))
807
+ ].filter((c) => !triedNames.has(c.name) && !NOT_A_WAY_IN.test(c.name)).filter((c, i, all) => all.findIndex((o) => o.name === c.name) === i).slice(0, 3);
808
+ const sources = [{ page: v }];
809
+ if (homeUrl && pathOf2(homeUrl) !== pathOf2(v.url)) sources.push({ at: homeUrl, page: v });
810
+ for (const source of sources) {
811
+ if (source.at) {
812
+ const home = await openAt(source.at);
813
+ if (!home) continue;
814
+ if (isKeyPage(home)) return home;
815
+ source.page = home;
816
+ shown = home;
817
+ }
818
+ for (const link of linksOf(source.page)) {
819
+ if (!await click(link.name)) continue;
820
+ await sleep2(700);
821
+ v = await look();
822
+ if ((authWall(v) || !isKeyPage(v) && signEntry(v)) && authTries < 2) {
823
+ await authenticate();
824
+ v = await look();
825
+ const got = await exploreSignedIn(v);
826
+ if (got?.found) return got.found;
827
+ }
828
+ if (isKeyPage(v)) return v;
829
+ shown = v;
830
+ const deeper = v.controls.filter((c) => pressable(c) && !c.footer && !NEVER_KEY.test(c.name) && c.name !== link.name && (API_LINK.test(c.name) || API_LINK_AREA.test(c.name)) && c.name.length <= 60).slice(0, 2);
831
+ for (const next of deeper) {
832
+ if (!await click(next.name)) continue;
833
+ await sleep2(700);
834
+ let w = await look();
835
+ if ((authWall(w) || !isKeyPage(w) && signEntry(w)) && authTries < 2) {
836
+ await authenticate();
837
+ w = await look();
838
+ const got = await exploreSignedIn(w);
839
+ if (got?.found) return got.found;
840
+ }
841
+ if (isKeyPage(w)) return w;
842
+ shown = w;
843
+ if (source.at) break;
844
+ const back = await openAt(pathOf2(v.url));
845
+ if (!back) break;
846
+ }
847
+ if (source.at && pathOf2(v.url) !== pathOf2(source.at)) {
848
+ const back = await openAt(source.at);
849
+ if (!back) break;
850
+ }
851
+ }
852
+ }
853
+ const origins = [...new Set([originOf(options.url), originOf(v.url)].filter((o) => o && !HOSTS_OF_SIGN_IN.test(hostOf(o)) && !/^(?:auth|login|accounts|sso|idp|ui\.idp)\b/i.test(hostOf(o))))];
854
+ for (const origin of origins) {
855
+ for (const path of KEY_PATHS) {
856
+ let page = await openAt(`${origin}${path}`);
857
+ if (!page || NOT_FOUND.test(page.text.slice(0, 400))) continue;
858
+ if (authWall(page) && authTries < 2) {
859
+ await authenticate();
860
+ page = await openAt(`${origin}${path}`);
861
+ if (!page) continue;
862
+ const got = await exploreSignedIn(page);
863
+ if (got?.found) return got.found;
864
+ }
865
+ if (isKeyPage(page)) return page;
866
+ shown = page;
867
+ }
868
+ }
869
+ if (pathOf2(shown.url) && pathOf2(shown.url) !== pathOf2(await port.look().then((l) => l.url).catch(() => ""))) {
870
+ trail.push(`go back to ${pathOf2(shown.url).replace(/^https:\/\//, "")}`);
871
+ await port.open(shown.url).catch(quiet("agent/computer/keygrab"));
872
+ }
873
+ const gone = RETIRED.exec(start.text)?.[0];
874
+ const human = gone ? { kind: "retire", ...pathOf2(start.url).startsWith("https://") ? { url: pathOf2(start.url) } : {}, reasonCode: "vendor-retired", instructions: `${hostOf(start.url)} says "${gone.slice(0, 120)}" and has no API key page.` } : void 0;
875
+ throw await stop("unknown", "no API key page was found (menu links and the common paths were tried)", human, shown);
876
+ };
877
+ const chosen = [];
878
+ const chooseBroadest = async (form) => {
879
+ const done = /* @__PURE__ */ new Set();
880
+ for (let round = 0; round < 6; round++) {
881
+ const all = allAtOnce(form.controls, done);
882
+ if (all && pressable(all)) {
883
+ done.add(all.name);
884
+ if (await click(all.name)) {
885
+ chosen.push(all.name);
886
+ say(`chose "${all.name}"`);
887
+ await sleep2(300);
888
+ form = await look();
889
+ continue;
890
+ }
891
+ }
892
+ const selector = selectorsOf(form.controls, done)[0];
893
+ if (!selector) break;
894
+ done.add(selector.name);
895
+ const before = form.controls;
896
+ if (!await click(selector.name)) continue;
897
+ await sleep2(300);
898
+ const opened = await look();
899
+ const options2 = revealedOptions(before, opened.controls);
900
+ const pick = broadestOption(options2);
901
+ if (!pick) {
902
+ trail.push(`${selector.name}: no broad option among ${options2.slice(0, 6).join(", ") || "none"}; left as it is`.slice(0, 120));
903
+ form = opened;
904
+ continue;
905
+ }
906
+ if (await click(pick)) {
907
+ chosen.push(`${selector.name} -> ${pick}`);
908
+ trail.push(`broadest for "${selector.name}": ${pick} (of ${options2.slice(0, 6).join(", ")})`.slice(0, 120));
909
+ await sleep2(300);
910
+ }
911
+ form = await look();
912
+ }
913
+ return form;
914
+ };
915
+ const captured = async (target) => {
916
+ const got = await act("capture the key", () => port.capture(target));
917
+ if (got.ok) keyOnScreen = false;
918
+ return got;
919
+ };
920
+ try {
921
+ let startUrl = options.url;
922
+ if (port.probe && !options.resume) {
923
+ for (const candidate of startCandidates(options.url, options.alternates).slice(0, 14)) {
924
+ const got = await port.probe(candidate).catch(quiet("agent/computer/keygrab"));
925
+ if (got?.html && got.status !== 404 && got.status !== 410 && got.status < 500) {
926
+ startUrl = got.url || candidate;
927
+ break;
928
+ }
929
+ }
930
+ }
931
+ const first = options.resume ? await look() : await openAt(startUrl);
932
+ if (!first) throw await stop("unknown", `could not open ${pathOf2(startUrl)}${lastOpenError ? `: ${lastOpenError}` : ""}`);
933
+ let v = first;
934
+ homeUrl = options.resume ? startUrl : first.url;
935
+ const labels = hostOf(v.url).split(".");
936
+ if (!options.resume && !v.controls.length && !v.fields.length && labels.length > 2) {
937
+ const apex = await openAt(`https://${labels.slice(1).join(".")}/`);
938
+ if (apex) v = apex;
939
+ }
940
+ if (!options.resume && options.knownKeyPages?.length) {
941
+ const known = await openAt(options.knownKeyPages[0]);
942
+ if (known && (isKeyPage(known) || authWall(known))) v = known;
943
+ }
944
+ if (authWall(v) || !isKeyPage(v) && hasEntry(v)) {
945
+ await authenticate();
946
+ v = await look();
947
+ }
948
+ let page = await findKeyPage(v);
949
+ for (let retry = 0; retry < 2; retry++) {
950
+ if (showsKey(page) && !createOf(page)) {
951
+ const got = await captured();
952
+ if (got.ok) return { ok: true, note: `key captured from ${pathOf2(page.url)} and delivered; it was not shown`, steps, route, capturedOn: pathOf2(page.url) };
953
+ }
954
+ const create = createOf(page);
955
+ if (create) {
956
+ keyOnScreen = true;
957
+ await click(create.name);
958
+ await sleep2(700);
959
+ let dialog = await look();
960
+ const nameBox = dialog.fields.find((f) => NAME_FIELD.test(f)) ?? (dialog.fields.length === 1 && !dialog.hasPassword ? dialog.fields[0] : void 0);
961
+ if (nameBox && !showsKey(dialog)) {
962
+ await act(`name the key ${options.keyName ?? KEY_NAME}`, () => port.fill(nameBox, options.keyName ?? KEY_NAME));
963
+ dialog = await chooseBroadest(dialog);
964
+ const confirm = [...dialog.controls].reverse().find((c) => pressable(c) && CONFIRM.test(c.name) && !NEVER_KEY.test(c.name));
965
+ if (confirm) {
966
+ await click(confirm.name);
967
+ await sleep2(900);
968
+ dialog = await look();
969
+ }
970
+ }
971
+ let got = await captured();
972
+ if (!got.ok) {
973
+ const reveal2 = revealOf(dialog);
974
+ if (reveal2) {
975
+ keyOnScreen = true;
976
+ got = await captured(reveal2.name);
977
+ }
978
+ }
979
+ if (got.ok) return { ok: true, note: `key created (named ${options.keyName ?? KEY_NAME}${chosen.length ? `; broadest access chosen: ${chosen.join("; ")}` : ""}), captured unseen and delivered`, steps, route, capturedOn: pathOf2(dialog.url) };
980
+ throw await stop("unknown", capturedButNotConnected(got.message) ?? `a key may have been created but could not be captured: ${got.message.slice(0, 200)}`, void 0, dialog);
981
+ }
982
+ const reveal = revealOf(page);
983
+ if (reveal) {
984
+ keyOnScreen = true;
985
+ const got = await captured(reveal.name);
986
+ if (got.ok) return { ok: true, note: `key revealed with "${reveal.name}", captured unseen and delivered`, steps, route, capturedOn: pathOf2(page.url) };
987
+ throw await stop("unknown", `the key could not be captured: ${got.message.slice(0, 200)}`, void 0, page);
988
+ }
989
+ page = await look();
990
+ }
991
+ throw await stop("unknown", "the key page offers nothing the runner knows to press", void 0, page);
992
+ } catch (error) {
993
+ if (error instanceof Halt) return { ok: false, stop: error.stop, steps };
994
+ throw error;
995
+ }
996
+ }
997
+ export {
998
+ IDENTITY_WALL,
999
+ bannerButton,
1000
+ capturedButNotConnected,
1001
+ chooserOptions,
1002
+ keygrabWall,
1003
+ paymentWall,
1004
+ runKeygrab,
1005
+ safeControlNames,
1006
+ startCandidates
1007
+ };