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,151 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
INERT_DEADLINE_MS,
|
|
5
|
+
harnessBinaryIdentity,
|
|
6
|
+
vendorCommandText
|
|
7
|
+
} from "./chunk-DF35KMXM.js";
|
|
8
|
+
import {
|
|
9
|
+
jsonMemo
|
|
10
|
+
} from "./chunk-ZT7B4H2V.js";
|
|
11
|
+
import {
|
|
12
|
+
stripAnsi
|
|
13
|
+
} from "./chunk-G3QP67Z7.js";
|
|
14
|
+
import {
|
|
15
|
+
quiet
|
|
16
|
+
} from "./chunk-RDDWQBEM.js";
|
|
17
|
+
|
|
18
|
+
// src/harness/accounts/effort-choices.ts
|
|
19
|
+
import { homedir } from "node:os";
|
|
20
|
+
import { join } from "node:path";
|
|
21
|
+
import { readFile, stat } from "node:fs/promises";
|
|
22
|
+
var LEVEL = /^[a-z][a-z0-9-]{0,15}$/;
|
|
23
|
+
function parseHelpEffortChoices(help, flag) {
|
|
24
|
+
const lines = stripAnsi(help).split(/\r?\n/);
|
|
25
|
+
const named = new RegExp(`(^|[\\s,\\[])${flag.replace(/-/g, "\\-")}(?=$|[\\s<=\\]])`);
|
|
26
|
+
const listed = (raw, separator) => {
|
|
27
|
+
const words = raw.split(separator).map((word) => word.trim().replace(/^["']|["']$/g, "").replace(/^or\s+/, "")).filter(Boolean);
|
|
28
|
+
const scale = words.length >= 2 && words.every((word) => LEVEL.test(word)) && words.some((word) => word === "low" || word === "medium" || word === "high");
|
|
29
|
+
return scale ? words : [];
|
|
30
|
+
};
|
|
31
|
+
const fromBlock = (block) => {
|
|
32
|
+
if (/\be\.g\.|for example|depends on/i.test(block)) return [];
|
|
33
|
+
const possible = /\[possible values:\s*([^\]]+)\]/i.exec(block)?.[1];
|
|
34
|
+
if (possible) {
|
|
35
|
+
const found = listed(possible, /\s*,\s*/);
|
|
36
|
+
if (found.length) return found;
|
|
37
|
+
}
|
|
38
|
+
for (const [, inner] of block.matchAll(/\(([^()]{3,120})\)/g)) {
|
|
39
|
+
const found = listed(inner, /\s*,\s*|\s*\|\s*/);
|
|
40
|
+
if (found.length) return found;
|
|
41
|
+
}
|
|
42
|
+
const piped = /(?:^|\s)([a-z][a-z0-9-]*(?:\|[a-z][a-z0-9-]*)+)(?=[\s.,;]|$)/.exec(block)?.[1];
|
|
43
|
+
if (piped) {
|
|
44
|
+
const found = listed(piped, /\|/);
|
|
45
|
+
if (found.length) return found;
|
|
46
|
+
}
|
|
47
|
+
const colon = /:\s*((?:[a-z][a-z0-9-]*\s*,\s*)+(?:or\s+)?[a-z][a-z0-9-]*)/.exec(block)?.[1];
|
|
48
|
+
return colon ? listed(colon, /\s*,\s*/) : [];
|
|
49
|
+
};
|
|
50
|
+
const scan = (matches) => {
|
|
51
|
+
for (let at = 0; at < lines.length; at += 1) {
|
|
52
|
+
if (!matches(lines[at])) continue;
|
|
53
|
+
const found = fromBlock(lines.slice(at, at + 3).join(" ").replace(/\s+/g, " "));
|
|
54
|
+
if (found.length) return found;
|
|
55
|
+
}
|
|
56
|
+
return [];
|
|
57
|
+
};
|
|
58
|
+
const declared = scan((line) => named.test(line));
|
|
59
|
+
if (declared.length) return declared;
|
|
60
|
+
return scan((line) => /^\s*-/.test(line) && /effort|reasoning|thinking/i.test(line));
|
|
61
|
+
}
|
|
62
|
+
function codexModelEffort(cacheJson, model) {
|
|
63
|
+
try {
|
|
64
|
+
const cache2 = JSON.parse(cacheJson);
|
|
65
|
+
const entry = cache2.models?.find((item) => item.slug === model);
|
|
66
|
+
if (!entry || !Array.isArray(entry.supported_reasoning_levels)) return void 0;
|
|
67
|
+
const values = entry.supported_reasoning_levels.map((level) => level && typeof level === "object" ? level.effort : void 0).filter((level) => typeof level === "string" && LEVEL.test(level));
|
|
68
|
+
if (!values.length) return void 0;
|
|
69
|
+
const fallback = typeof entry.default_reasoning_level === "string" && values.includes(entry.default_reasoning_level) ? entry.default_reasoning_level : void 0;
|
|
70
|
+
return { values, ...fallback ? { default: fallback } : {} };
|
|
71
|
+
} catch {
|
|
72
|
+
return void 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
var cache = /* @__PURE__ */ new Map();
|
|
76
|
+
async function fileIdentity(path) {
|
|
77
|
+
try {
|
|
78
|
+
const info = await stat(path);
|
|
79
|
+
return `${path}:${info.mtimeMs}:${info.size}`;
|
|
80
|
+
} catch {
|
|
81
|
+
return `${path}:absent`;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
var helpMemo = jsonMemo("cache/effort-help.json", () => ({ v: 1, harnesses: {} }), (parsed) => {
|
|
85
|
+
const file = parsed;
|
|
86
|
+
return file.v === 1 && file.harnesses && typeof file.harnesses === "object" ? file : void 0;
|
|
87
|
+
});
|
|
88
|
+
async function helpChoices(harness) {
|
|
89
|
+
const flag = harness.effortArgvPrefix?.[0] ?? harness.acp?.effortArgvPrefix?.[0];
|
|
90
|
+
if (!flag) return void 0;
|
|
91
|
+
const identity = await harnessBinaryIdentity(harness.binary);
|
|
92
|
+
if (!identity) return void 0;
|
|
93
|
+
const memo = await helpMemo.load();
|
|
94
|
+
const remembered = memo.harnesses[harness.command];
|
|
95
|
+
if (remembered?.identity === identity) return remembered.values.length ? remembered.values : void 0;
|
|
96
|
+
let values = [];
|
|
97
|
+
try {
|
|
98
|
+
const helpArgv = harness.effortHelpArgv ?? ["--help"];
|
|
99
|
+
values = parseHelpEffortChoices(await vendorCommandText({ gate: { inert: "help text" }, binary: harness.binary, argv: helpArgv, environment: {}, deadlineMs: INERT_DEADLINE_MS }), flag);
|
|
100
|
+
} catch {
|
|
101
|
+
return void 0;
|
|
102
|
+
}
|
|
103
|
+
memo.harnesses[harness.command] = { identity, values };
|
|
104
|
+
helpMemo.changed();
|
|
105
|
+
await helpMemo.save();
|
|
106
|
+
return values.length ? values : void 0;
|
|
107
|
+
}
|
|
108
|
+
async function memoized(key, harness, ask) {
|
|
109
|
+
const identity = await harnessBinaryIdentity(harness.binary) ?? "unknown";
|
|
110
|
+
const kept = acpEfforts.get(key);
|
|
111
|
+
if (kept?.identity === identity) return kept.result;
|
|
112
|
+
const result = await ask().catch(quiet("harness/accounts/effort-choices"));
|
|
113
|
+
if (result) acpEfforts.set(key, { identity, result });
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
var acpEfforts = /* @__PURE__ */ new Map();
|
|
117
|
+
async function effortChoicesFor(harness, account, model) {
|
|
118
|
+
if (harness.modelCatalogFiles?.includes("models_cache.json") && harness.nativeStateDir) {
|
|
119
|
+
const root = account?.nativeProfile?.path ?? (harness.profileEnv ? process.env[harness.profileEnv]?.trim() : void 0) ?? join(homedir(), harness.nativeStateDir);
|
|
120
|
+
const path = join(root, "models_cache.json");
|
|
121
|
+
const key = `codex:${path}:${model ?? ""}`;
|
|
122
|
+
const identity = await fileIdentity(path);
|
|
123
|
+
const cached = cache.get(key);
|
|
124
|
+
if (cached?.identity === identity) return cached.result;
|
|
125
|
+
const found = codexModelEffort(await readFile(path, "utf8").catch(() => ""), model);
|
|
126
|
+
if (found) {
|
|
127
|
+
const result = { ...found, source: "vendor-models" };
|
|
128
|
+
cache.set(key, { identity, result });
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const { acpEffortPerModel, acpModelEffortChoices } = await import("./chunk-34ZISPAO.js");
|
|
133
|
+
if (acpEffortPerModel(harness)) {
|
|
134
|
+
const stated = await memoized(`acp:${harness.command}:${account?.id ?? ""}:${model ?? ""}`, harness, () => acpModelEffortChoices(harness, account, model));
|
|
135
|
+
if (stated) return { ...stated, source: "vendor-config" };
|
|
136
|
+
}
|
|
137
|
+
const fromHelp = await helpChoices(harness);
|
|
138
|
+
if (fromHelp) return { values: fromHelp, source: "vendor-help" };
|
|
139
|
+
if (harness.acp?.effortConfigId) {
|
|
140
|
+
const { nativeModelCatalog } = await import("./chunk-34ZISPAO.js");
|
|
141
|
+
const offered = (await nativeModelCatalog(harness, account).catch(quiet("harness/accounts/effort-choices")))?.effortValues;
|
|
142
|
+
if (offered?.length) return { values: [...offered], source: "vendor-config" };
|
|
143
|
+
}
|
|
144
|
+
return { values: [...harness.effortValues ?? []], source: "catalog" };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export {
|
|
148
|
+
parseHelpEffortChoices,
|
|
149
|
+
codexModelEffort,
|
|
150
|
+
effortChoicesFor
|
|
151
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
HEADLESS_HARNESSES,
|
|
5
|
+
agentRoute,
|
|
6
|
+
headlessAccount
|
|
7
|
+
} from "./chunk-3TFNIJWS.js";
|
|
8
|
+
import "./chunk-IF43HIGV.js";
|
|
9
|
+
import "./chunk-7TSQLONI.js";
|
|
10
|
+
import "./chunk-2YPAPAR3.js";
|
|
11
|
+
import "./chunk-4LPDG57B.js";
|
|
12
|
+
import "./chunk-XWAC3MKW.js";
|
|
13
|
+
import "./chunk-MXS6S2PY.js";
|
|
14
|
+
import "./chunk-BISGNHKD.js";
|
|
15
|
+
import "./chunk-RKUVLRZI.js";
|
|
16
|
+
import "./chunk-BGEMY2JJ.js";
|
|
17
|
+
import "./chunk-XCKQ5BM2.js";
|
|
18
|
+
import "./chunk-NWEYRBWK.js";
|
|
19
|
+
import "./chunk-TWCVV2JO.js";
|
|
20
|
+
import "./chunk-PDPEM5VW.js";
|
|
21
|
+
import "./chunk-WWLJMP6D.js";
|
|
22
|
+
import "./chunk-CRUVYGO2.js";
|
|
23
|
+
import "./chunk-FF7ZVYJF.js";
|
|
24
|
+
import "./chunk-IMLTL2MY.js";
|
|
25
|
+
import "./chunk-BUOPJQP5.js";
|
|
26
|
+
import "./chunk-3B2CHX7M.js";
|
|
27
|
+
import "./chunk-RVUOIJXN.js";
|
|
28
|
+
import "./chunk-QUS4ER2W.js";
|
|
29
|
+
import "./chunk-DQYVQ2N7.js";
|
|
30
|
+
import "./chunk-KYUHIFP3.js";
|
|
31
|
+
import "./chunk-RSZGEL5U.js";
|
|
32
|
+
import "./chunk-NKDATMEM.js";
|
|
33
|
+
import "./chunk-CQ7J6UQ7.js";
|
|
34
|
+
import "./chunk-XKW5NDMR.js";
|
|
35
|
+
import "./chunk-W3YYPBEA.js";
|
|
36
|
+
import "./chunk-XIBYREEY.js";
|
|
37
|
+
import "./chunk-EE4B6A7W.js";
|
|
38
|
+
import "./chunk-WZYVLUVQ.js";
|
|
39
|
+
import "./chunk-O3EW7LAY.js";
|
|
40
|
+
import "./chunk-KHW6TX6I.js";
|
|
41
|
+
import "./chunk-YMCH3L2S.js";
|
|
42
|
+
import "./chunk-4QZEZME7.js";
|
|
43
|
+
import "./chunk-LVRRWP4W.js";
|
|
44
|
+
import "./chunk-G3QP67Z7.js";
|
|
45
|
+
import "./chunk-4L2ZZM4Q.js";
|
|
46
|
+
import "./chunk-F6F47QAY.js";
|
|
47
|
+
import "./chunk-RDDWQBEM.js";
|
|
48
|
+
import "./chunk-MPAJ446F.js";
|
|
49
|
+
import "./chunk-CBANJFBO.js";
|
|
50
|
+
import "./chunk-PWXII6HF.js";
|
|
51
|
+
export {
|
|
52
|
+
HEADLESS_HARNESSES,
|
|
53
|
+
agentRoute,
|
|
54
|
+
headlessAccount
|
|
55
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
OWN_MODEL_IDLE_CHOICES,
|
|
5
|
+
alwaysStartOwnModels,
|
|
6
|
+
idleWords,
|
|
7
|
+
ownModelIdleMinutes,
|
|
8
|
+
ownModelStatus,
|
|
9
|
+
setAlwaysStartOwnModels,
|
|
10
|
+
setOwnModelIdleMinutes,
|
|
11
|
+
wakeOwnModel
|
|
12
|
+
} from "./chunk-X3CL6DTR.js";
|
|
13
|
+
import "./chunk-2OLS7V66.js";
|
|
14
|
+
import "./chunk-2QWPQRSU.js";
|
|
15
|
+
import "./chunk-IS4USJPY.js";
|
|
16
|
+
import "./chunk-2BBELGHY.js";
|
|
17
|
+
import "./chunk-QYHI3YET.js";
|
|
18
|
+
import "./chunk-4LPDG57B.js";
|
|
19
|
+
import "./chunk-TQDM7S5N.js";
|
|
20
|
+
import "./chunk-TQDKJHWX.js";
|
|
21
|
+
import "./chunk-GQBZU6EO.js";
|
|
22
|
+
import "./chunk-PEWCDI2C.js";
|
|
23
|
+
import "./chunk-TULAXS77.js";
|
|
24
|
+
import "./chunk-NWEYRBWK.js";
|
|
25
|
+
import "./chunk-YMCH3L2S.js";
|
|
26
|
+
import "./chunk-NAOX3JUB.js";
|
|
27
|
+
import "./chunk-GGYKY4GF.js";
|
|
28
|
+
import "./chunk-PAXYQZH7.js";
|
|
29
|
+
import "./chunk-4L2ZZM4Q.js";
|
|
30
|
+
import "./chunk-F6F47QAY.js";
|
|
31
|
+
import "./chunk-RDDWQBEM.js";
|
|
32
|
+
import "./chunk-MPAJ446F.js";
|
|
33
|
+
import "./chunk-CBANJFBO.js";
|
|
34
|
+
import "./chunk-PWXII6HF.js";
|
|
35
|
+
export {
|
|
36
|
+
OWN_MODEL_IDLE_CHOICES,
|
|
37
|
+
alwaysStartOwnModels,
|
|
38
|
+
idleWords,
|
|
39
|
+
ownModelIdleMinutes,
|
|
40
|
+
ownModelStatus,
|
|
41
|
+
setAlwaysStartOwnModels,
|
|
42
|
+
setOwnModelIdleMinutes,
|
|
43
|
+
wakeOwnModel
|
|
44
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/agent/mcp/config.ts
|
|
5
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
function oauthConfig(value) {
|
|
8
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
9
|
+
const raw = value;
|
|
10
|
+
const port = Number(raw.callbackPort);
|
|
11
|
+
const config = {
|
|
12
|
+
...typeof raw.clientId === "string" && raw.clientId.trim() ? { clientId: raw.clientId.trim() } : {},
|
|
13
|
+
...Number.isInteger(port) && port > 0 && port < 65536 ? { callbackPort: port } : {},
|
|
14
|
+
...typeof raw.scope === "string" && raw.scope.trim() ? { scope: raw.scope.trim() } : {}
|
|
15
|
+
};
|
|
16
|
+
return Object.keys(config).length ? config : void 0;
|
|
17
|
+
}
|
|
18
|
+
var MCP_SERVERS_KEY = "mcpServers";
|
|
19
|
+
function mcpConfigFilePath(stateDir) {
|
|
20
|
+
return join(stateDir, "mcp.json");
|
|
21
|
+
}
|
|
22
|
+
function stringRecord(value) {
|
|
23
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
24
|
+
return Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string"));
|
|
25
|
+
}
|
|
26
|
+
function parseMcpServerEntry(name, raw) {
|
|
27
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
28
|
+
const entry = raw;
|
|
29
|
+
if (entry.disabled === true || entry.enabled === false) return void 0;
|
|
30
|
+
const url = typeof entry.url === "string" ? entry.url : typeof entry.uri === "string" ? entry.uri : void 0;
|
|
31
|
+
if (url && /^https?:\/\//i.test(url)) {
|
|
32
|
+
const oauth = oauthConfig(entry.oauth);
|
|
33
|
+
return { name, transport: entry.type === "sse" ? "sse" : "http", url, headers: stringRecord(entry.headers), ...oauth ? { oauth } : {} };
|
|
34
|
+
}
|
|
35
|
+
const command = typeof entry.command === "string" ? entry.command : typeof entry.cmd === "string" ? entry.cmd : void 0;
|
|
36
|
+
if (!command?.trim()) return void 0;
|
|
37
|
+
const args = Array.isArray(entry.args) ? entry.args.filter((arg) => typeof arg === "string") : [];
|
|
38
|
+
return { name, transport: "stdio", command, args, env: stringRecord(entry.env) };
|
|
39
|
+
}
|
|
40
|
+
async function loadMcpServers(stateDir) {
|
|
41
|
+
const path = mcpConfigFilePath(stateDir);
|
|
42
|
+
let text;
|
|
43
|
+
try {
|
|
44
|
+
text = await readFile(path, "utf8");
|
|
45
|
+
} catch {
|
|
46
|
+
return { servers: [] };
|
|
47
|
+
}
|
|
48
|
+
if (!text.trim()) return { servers: [] };
|
|
49
|
+
let parsed;
|
|
50
|
+
try {
|
|
51
|
+
parsed = JSON.parse(text);
|
|
52
|
+
} catch {
|
|
53
|
+
return { servers: [], problem: `${path} is not valid JSON; no MCP servers were started` };
|
|
54
|
+
}
|
|
55
|
+
const table = parsed && typeof parsed === "object" ? parsed[MCP_SERVERS_KEY] : void 0;
|
|
56
|
+
if (!table || typeof table !== "object" || Array.isArray(table)) return { servers: [] };
|
|
57
|
+
return {
|
|
58
|
+
servers: Object.entries(table).flatMap(([name, raw]) => parseMcpServerEntry(name, raw) ?? [])
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
async function writeMcpOAuthConfig(stateDir, name, oauth) {
|
|
62
|
+
const path = mcpConfigFilePath(stateDir);
|
|
63
|
+
const root = JSON.parse(await readFile(path, "utf8"));
|
|
64
|
+
const entry = root?.[MCP_SERVERS_KEY]?.[name];
|
|
65
|
+
if (!entry || typeof entry !== "object") throw new Error(`${name} is not recorded in ${path}`);
|
|
66
|
+
entry.oauth = oauth;
|
|
67
|
+
await writeFile(path, `${JSON.stringify(root, null, 2)}
|
|
68
|
+
`, "utf8");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
MCP_SERVERS_KEY,
|
|
73
|
+
mcpConfigFilePath,
|
|
74
|
+
parseMcpServerEntry,
|
|
75
|
+
loadMcpServers,
|
|
76
|
+
writeMcpOAuthConfig
|
|
77
|
+
};
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
verificationCode
|
|
5
|
+
} from "./chunk-BOQBXGSN.js";
|
|
6
|
+
import "./chunk-25T3GVS7.js";
|
|
7
|
+
import "./chunk-4GXAO3UY.js";
|
|
8
|
+
import "./chunk-SNU37TQI.js";
|
|
9
|
+
import "./chunk-XAHGBPWT.js";
|
|
10
|
+
import "./chunk-MCBRVPA7.js";
|
|
11
|
+
import "./chunk-YMCH3L2S.js";
|
|
12
|
+
import "./chunk-I75EDU75.js";
|
|
13
|
+
import {
|
|
14
|
+
computerSettingsPath
|
|
15
|
+
} from "./chunk-5SM5UAWN.js";
|
|
16
|
+
import {
|
|
17
|
+
objectOrEmpty,
|
|
18
|
+
updateJsonFile
|
|
19
|
+
} from "./chunk-PAXYQZH7.js";
|
|
20
|
+
import "./chunk-4L2ZZM4Q.js";
|
|
21
|
+
import "./chunk-F6F47QAY.js";
|
|
22
|
+
import "./chunk-RDDWQBEM.js";
|
|
23
|
+
import "./chunk-MPAJ446F.js";
|
|
24
|
+
import "./chunk-CBANJFBO.js";
|
|
25
|
+
import "./chunk-PWXII6HF.js";
|
|
26
|
+
|
|
27
|
+
// src/agent/computer/sms-code.ts
|
|
28
|
+
import { spawn } from "node:child_process";
|
|
29
|
+
var TARGET = /^(?:[A-Za-z0-9._-]{1,64}@)?[A-Za-z0-9._-]{1,253}$/;
|
|
30
|
+
var APPLE_EPOCH = 978307200;
|
|
31
|
+
async function smsSource(stateDir) {
|
|
32
|
+
const { readFile } = await import("node:fs/promises");
|
|
33
|
+
try {
|
|
34
|
+
const value = JSON.parse(await readFile(computerSettingsPath(stateDir), "utf8")).smsSsh;
|
|
35
|
+
return typeof value === "string" && TARGET.test(value) ? value : void 0;
|
|
36
|
+
} catch {
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async function setSmsSource(stateDir, target) {
|
|
41
|
+
if (target !== void 0 && !TARGET.test(target)) throw new Error("Give the Mac as user@host (an SSH address this computer can reach without a password), or off.");
|
|
42
|
+
await updateJsonFile(computerSettingsPath(stateDir), objectOrEmpty, (current) => {
|
|
43
|
+
const next = { ...current };
|
|
44
|
+
if (target) next.smsSsh = target;
|
|
45
|
+
else delete next.smsSsh;
|
|
46
|
+
return next;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function messagesQuery(sinceUnixSeconds, limit = 12) {
|
|
50
|
+
const since = Math.max(0, Math.floor(sinceUnixSeconds));
|
|
51
|
+
const sent = `((CASE WHEN m.date > 100000000000 THEN m.date / 1000000000 ELSE m.date END) + ${APPLE_EPOCH})`;
|
|
52
|
+
return `SELECT ${sent} || char(31) || coalesce(h.id, char(63)) || char(31) || replace(replace(coalesce(m.text, char(32)), char(10), char(32)), char(13), char(32)) FROM message m LEFT JOIN handle h ON m.handle_id = h.ROWID WHERE m.is_from_me = 0 AND ${sent} >= ${since} ORDER BY m.date DESC LIMIT ${Math.max(1, Math.min(50, Math.floor(limit)))};`;
|
|
53
|
+
}
|
|
54
|
+
function textedCode(text) {
|
|
55
|
+
return verificationCode(text) ?? /\b(?:code|otp|passcode|pin)\s*(?:is\s*)?[:#-]?\s*(?:[A-Z]{1,3}-)?(\d{4,8})\b/i.exec(text)?.[1] ?? /(?:^|[^\w])(?:[A-Z]{1,3}-)?(\d{4,8})\b[^.\n]{0,50}\b(?:code|otp|passcode|pin)\b/i.exec(text)?.[1];
|
|
56
|
+
}
|
|
57
|
+
var squash = (value) => value.toLowerCase().replace(/[^a-z0-9+]/g, "");
|
|
58
|
+
function wantedText(sender, text, filter) {
|
|
59
|
+
const { from, site } = filter;
|
|
60
|
+
if (from && from.toLowerCase() !== "any") {
|
|
61
|
+
const wanted = squash(from);
|
|
62
|
+
if (!(wanted && squash(sender).includes(wanted)) && !text.toLowerCase().includes(from.toLowerCase())) return false;
|
|
63
|
+
}
|
|
64
|
+
if (site && !(from && from.toLowerCase() !== "any")) {
|
|
65
|
+
const vendor = vendorName(site);
|
|
66
|
+
if (vendor && !squash(sender).includes(vendor) && !squash(text).includes(vendor)) return false;
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
function vendorName(site) {
|
|
71
|
+
try {
|
|
72
|
+
const parts = new URL(site).hostname.replace(/^www\./, "").split(".");
|
|
73
|
+
const name = parts.length > 2 && ["co", "com", "org", "net"].includes(parts.at(-2)) ? parts.at(-3) : parts.at(-2) ?? parts[0];
|
|
74
|
+
return squash(name) || void 0;
|
|
75
|
+
} catch {
|
|
76
|
+
return squash(site) || void 0;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function codesFromRows(output, filter = {}) {
|
|
80
|
+
const wanted = typeof filter === "string" ? { from: filter } : filter;
|
|
81
|
+
const found = [];
|
|
82
|
+
for (const line of output.split("\n")) {
|
|
83
|
+
const [at, sender = "", text = ""] = line.split("");
|
|
84
|
+
if (!at || !text.trim() || !wantedText(sender, text, wanted)) continue;
|
|
85
|
+
const code = textedCode(text);
|
|
86
|
+
if (code) found.push({ code, from: sender, at: Number(at) });
|
|
87
|
+
}
|
|
88
|
+
return found.sort((x, y) => y.at - x.at);
|
|
89
|
+
}
|
|
90
|
+
function codeFromRows(output, filter = {}) {
|
|
91
|
+
return codesFromRows(output, filter)[0];
|
|
92
|
+
}
|
|
93
|
+
function smsProblem(stderr, target) {
|
|
94
|
+
if (/unable to open database|authorization denied|operation not permitted/i.test(stderr)) {
|
|
95
|
+
return `The Mac (${target}) would not let SSH read Messages: give Full Disk Access to remote logins. On macOS 13 or later: System Settings > General > Sharing > Remote Login (i) > "Allow full disk access for remote users". On macOS 10.15 to 12: System Preferences > Security & Privacy > Privacy > Full Disk Access > + > press Cmd+Shift+G, type /usr/libexec/sshd-keygen-wrapper, add it.`;
|
|
96
|
+
}
|
|
97
|
+
if (/permission denied \(publickey|host key verification failed|could not resolve|connection (?:refused|timed out)|no route/i.test(stderr)) return `This computer could not sign in to ${target} over SSH (${stderr.trim().split("\n").pop()?.slice(0, 120)}). It needs key sign-in with no password.`;
|
|
98
|
+
return `Reading texts on ${target} failed: ${stderr.trim().split("\n").pop()?.slice(0, 160) || "no answer"}`;
|
|
99
|
+
}
|
|
100
|
+
async function askMessages(target, sinceUnixSeconds, signal) {
|
|
101
|
+
const remote = `sqlite3 -readonly "$HOME/Library/Messages/chat.db" '${messagesQuery(sinceUnixSeconds)}'`;
|
|
102
|
+
return new Promise((resolve) => {
|
|
103
|
+
const child = spawn("ssh", ["-o", "BatchMode=yes", "-o", "ConnectTimeout=10", target, remote], { stdio: ["ignore", "pipe", "pipe"], ...signal ? { signal } : {} });
|
|
104
|
+
let out = "", err = "";
|
|
105
|
+
child.stdout.on("data", (chunk) => {
|
|
106
|
+
out = (out + String(chunk)).slice(-2e5);
|
|
107
|
+
});
|
|
108
|
+
child.stderr.on("data", (chunk) => {
|
|
109
|
+
err = (err + String(chunk)).slice(-4e3);
|
|
110
|
+
});
|
|
111
|
+
const timer = setTimeout(() => child.kill("SIGKILL"), 25e3);
|
|
112
|
+
child.on("error", (error) => {
|
|
113
|
+
clearTimeout(timer);
|
|
114
|
+
resolve({ error: smsProblem(String(error), target) });
|
|
115
|
+
});
|
|
116
|
+
child.on("close", (code) => {
|
|
117
|
+
clearTimeout(timer);
|
|
118
|
+
resolve(code === 0 && !/^Error:|unable to open database|authorization denied/im.test(err) ? { rows: out } : { error: smsProblem(err || `exit ${code}`, target) });
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
var TWILIO_NUMBER = /^\+[1-9]\d{6,14}$/;
|
|
123
|
+
var TWILIO_ACCOUNT = /^AC[0-9a-f]{32}$/;
|
|
124
|
+
var TWILIO_SID_SECRET = "sms-twilio/sid";
|
|
125
|
+
var TWILIO_KEY_SECRET = "sms-twilio/key";
|
|
126
|
+
async function twilioSms(stateDir) {
|
|
127
|
+
const { readFile } = await import("node:fs/promises");
|
|
128
|
+
try {
|
|
129
|
+
const value = JSON.parse(await readFile(computerSettingsPath(stateDir), "utf8")).smsTwilio;
|
|
130
|
+
if (!value || !TWILIO_NUMBER.test(value.number ?? "") || !TWILIO_ACCOUNT.test(value.account ?? "")) return void 0;
|
|
131
|
+
const others = (Array.isArray(value.others) ? value.others : []).filter((n) => typeof n === "string" && TWILIO_NUMBER.test(n));
|
|
132
|
+
return { number: value.number, account: value.account, ...others.length ? { others } : {} };
|
|
133
|
+
} catch {
|
|
134
|
+
return void 0;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
async function setTwilioSms(stateDir, value) {
|
|
138
|
+
if (value && (!TWILIO_NUMBER.test(value.number) || !TWILIO_ACCOUNT.test(value.account) || (value.others ?? []).some((n) => !TWILIO_NUMBER.test(n)))) throw new Error("Give the Twilio number as +<country><number> and the account SID (AC followed by 32 hex digits).");
|
|
139
|
+
await updateJsonFile(computerSettingsPath(stateDir), objectOrEmpty, (current) => {
|
|
140
|
+
const next = { ...current };
|
|
141
|
+
if (value) next.smsTwilio = value;
|
|
142
|
+
else delete next.smsTwilio;
|
|
143
|
+
return next;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function applyTwilioSetting(current, setting) {
|
|
147
|
+
if (setting === "off") return void 0;
|
|
148
|
+
const change = /^(add|remove):(.*)$/i.exec(setting);
|
|
149
|
+
if (change) {
|
|
150
|
+
const number2 = change[2].trim();
|
|
151
|
+
if (!TWILIO_NUMBER.test(number2)) throw new Error("Give the number as +<country><number>: clikcode computer sms twilio:add:+18734578891");
|
|
152
|
+
if (!current) throw new Error("Set the sign-up number first: clikcode computer sms twilio:+<number>:<account sid>");
|
|
153
|
+
const others2 = (current.others ?? []).filter((n) => n !== number2 && n !== current.number);
|
|
154
|
+
if (change[1].toLowerCase() === "add" && number2 !== current.number) others2.push(number2);
|
|
155
|
+
return { number: current.number, account: current.account, ...others2.length ? { others: others2 } : {} };
|
|
156
|
+
}
|
|
157
|
+
const [number = "", account = ""] = setting.split(":");
|
|
158
|
+
const others = (current?.account === account ? current.others ?? [] : []).filter((n) => n !== number);
|
|
159
|
+
return { number, account, ...others.length ? { others } : {} };
|
|
160
|
+
}
|
|
161
|
+
async function askTwilio(stateDir, sms, sinceUnixSeconds, signal, fetcher = fetch, given) {
|
|
162
|
+
const { readNamedSecret } = await import("./chunk-Q35VLJRT.js");
|
|
163
|
+
const [sid, key] = given ? [given.sid, given.key] : await Promise.all([readNamedSecret(stateDir, TWILIO_SID_SECRET), readNamedSecret(stateDir, TWILIO_KEY_SECRET)]).catch(() => [void 0, void 0]);
|
|
164
|
+
if (!sid || !key) return { error: `No Twilio API key is saved to read ${sms.number}'s texts (vault names ${TWILIO_SID_SECRET} and ${TWILIO_KEY_SECRET}).` };
|
|
165
|
+
const day = new Date((sinceUnixSeconds - 86400) * 1e3).toISOString().slice(0, 10);
|
|
166
|
+
const rowsOf = [];
|
|
167
|
+
try {
|
|
168
|
+
for (const number of [sms.number, ...sms.others ?? []]) {
|
|
169
|
+
const url = `https://api.twilio.com/2010-04-01/Accounts/${sms.account}/Messages.json?${new URLSearchParams({ To: number, "DateSent>": day, PageSize: "20" })}`;
|
|
170
|
+
const res = await fetcher(url, { headers: { authorization: `Basic ${Buffer.from(`${sid}:${key}`).toString("base64")}` }, signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(2e4)]) : AbortSignal.timeout(2e4) });
|
|
171
|
+
if (!res.ok) return { error: `Twilio would not list ${number}'s texts (HTTP ${res.status}).` };
|
|
172
|
+
rowsOf.push(...(await res.json()).messages ?? []);
|
|
173
|
+
}
|
|
174
|
+
const rows = rowsOf.filter((m) => m.direction === "inbound").map((m) => ({ at: Math.floor(Date.parse(m.date_sent || m.date_created || "") / 1e3), from: m.from ?? "?", body: (m.body ?? "").replace(/[\r\n\u001f]+/g, " ") })).filter((m) => Number.isFinite(m.at) && m.at >= sinceUnixSeconds).sort((a, b) => b.at - a.at);
|
|
175
|
+
return { rows: rows.map((m) => `${m.at}${m.from}${m.body}`).join("\n") };
|
|
176
|
+
} catch (error) {
|
|
177
|
+
return { error: `Reading ${sms.number}'s texts from Twilio failed: ${(error instanceof Error ? error.message : String(error)).slice(0, 120)}` };
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
var CLOCK_SLACK_S = 5;
|
|
181
|
+
async function waitForTextedCode(stateDir, options) {
|
|
182
|
+
const [target, twilio] = await Promise.all([smsSource(stateDir), twilioSms(stateDir)]);
|
|
183
|
+
if (!target && !twilio) return { error: "No phone is set up to read text messages: run clikcode computer sms twilio:+<number>:<account sid> (a Twilio number) or clikcode computer sms <user@host> (a Mac with Text Message Forwarding)." };
|
|
184
|
+
const { claimMessage } = await import("./chunk-MVJZZ6AL.js");
|
|
185
|
+
const stop = new AbortController();
|
|
186
|
+
const seconds = Math.min(Math.max(options.seconds ?? 90, 5), 180);
|
|
187
|
+
const budget = AbortSignal.timeout(seconds * 1e3);
|
|
188
|
+
const deadline = Date.now() + seconds * 1e3;
|
|
189
|
+
const signals = [stop.signal, budget, ...options.signal ? [options.signal] : []];
|
|
190
|
+
const signal = AbortSignal.any(signals);
|
|
191
|
+
const sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
192
|
+
const since = Math.floor(options.since / 1e3) - CLOCK_SLACK_S;
|
|
193
|
+
const filter = { ...options.from ? { from: options.from } : {}, ...options.site ? { site: options.site } : {} };
|
|
194
|
+
const names = [twilio?.number, target].filter(Boolean).join(" or ");
|
|
195
|
+
let onAbort;
|
|
196
|
+
const interrupted = new Promise((_resolve, reject) => {
|
|
197
|
+
onAbort = () => reject(signal.reason);
|
|
198
|
+
if (signal.aborted) onAbort();
|
|
199
|
+
else signal.addEventListener("abort", onAbort, { once: true });
|
|
200
|
+
});
|
|
201
|
+
interrupted.catch(() => void 0);
|
|
202
|
+
const health = /* @__PURE__ */ new Map();
|
|
203
|
+
const poll = async (source, ask) => {
|
|
204
|
+
const state = { answered: false };
|
|
205
|
+
health.set(source, state);
|
|
206
|
+
let failures = 0;
|
|
207
|
+
for (; ; ) {
|
|
208
|
+
signal.throwIfAborted();
|
|
209
|
+
if (Date.now() >= deadline) throw new Error("deadline");
|
|
210
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
211
|
+
const answer = await Promise.race([ask(), interrupted]).catch((error) => {
|
|
212
|
+
if (signal.aborted) throw error;
|
|
213
|
+
return { error: error instanceof Error ? error.message : String(error) };
|
|
214
|
+
});
|
|
215
|
+
if ("error" in answer) {
|
|
216
|
+
state.error = answer.error;
|
|
217
|
+
failures++;
|
|
218
|
+
await Promise.race([sleep(Math.min(4e3 * 2 ** Math.min(failures - 1, 3), 3e4)), interrupted]);
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
state.answered = true;
|
|
222
|
+
failures = 0;
|
|
223
|
+
const passes = filter.site && !filter.from && source.startsWith("twilio:") ? [filter, {}] : [filter];
|
|
224
|
+
for (const pass of passes) {
|
|
225
|
+
for (const found of codesFromRows(answer.rows, pass)) {
|
|
226
|
+
if (found.at < since) continue;
|
|
227
|
+
if (await claimMessage(stateDir, `${source}:${found.at}:${squash(found.from)}:${found.code}`, "sms")) return found;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
await Promise.race([sleep(4e3), interrupted]);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
const readers = [];
|
|
234
|
+
if (twilio) readers.push(poll(`twilio:${twilio.number}`, () => options.askTwilio ? options.askTwilio(twilio, since) : askTwilio(stateDir, twilio, since, signal)));
|
|
235
|
+
if (target) readers.push(poll(`mac:${target}`, () => (options.ask ?? askMessages)(target, since, signal)));
|
|
236
|
+
try {
|
|
237
|
+
return await Promise.race([Promise.any(readers), interrupted]);
|
|
238
|
+
} catch {
|
|
239
|
+
if (options.signal?.aborted) return { error: "Texted-code wait was cancelled." };
|
|
240
|
+
const states = [...health.values()];
|
|
241
|
+
if (states.length && states.every((item) => !item.answered && item.error)) return { error: states.map((item) => item.error).join(" ") };
|
|
242
|
+
const who = options.from ? ` from ${options.from}` : options.site ? ` naming ${vendorName(options.site) ?? options.site}` : "";
|
|
243
|
+
return { error: `No new texted code arrived on ${names} in time${who}.${options.site && !options.from ? ' If the text does not name the site, give from (the sender, or "any").' : ""}${target ? " Check that the iPhone forwards texts to that Mac (Settings > Messages > Text Message Forwarding)." : ""}` };
|
|
244
|
+
} finally {
|
|
245
|
+
stop.abort();
|
|
246
|
+
signal.removeEventListener("abort", onAbort);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
export {
|
|
250
|
+
CLOCK_SLACK_S,
|
|
251
|
+
TWILIO_KEY_SECRET,
|
|
252
|
+
TWILIO_SID_SECRET,
|
|
253
|
+
applyTwilioSetting,
|
|
254
|
+
askMessages,
|
|
255
|
+
askTwilio,
|
|
256
|
+
codeFromRows,
|
|
257
|
+
codesFromRows,
|
|
258
|
+
messagesQuery,
|
|
259
|
+
setSmsSource,
|
|
260
|
+
setTwilioSms,
|
|
261
|
+
smsProblem,
|
|
262
|
+
smsSource,
|
|
263
|
+
textedCode,
|
|
264
|
+
twilioSms,
|
|
265
|
+
waitForTextedCode
|
|
266
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/agent/computer/page-controls.ts
|
|
5
|
+
var OPENS_ANOTHER_APP = /^\s*(?!https?:|javascript:|about:)[a-z][a-z0-9+.-]*:/i;
|
|
6
|
+
var PRESSABLE = "button, [role=button], a, [role=link], input[type=submit], input[type=button], summary, [data-identifier], [data-email], [data-test-id], [onclick]";
|
|
7
|
+
var PRESSABLE_SITE = "button, [role=button], a, [role=link], [role=menuitem], [role=tab], input[type=submit], input[type=button], summary";
|
|
8
|
+
function readPageControls(opts) {
|
|
9
|
+
const leavesPage = new RegExp(opts.otherApp, "i");
|
|
10
|
+
const doc = globalThis.document;
|
|
11
|
+
const selector = `${opts.pressable}, span, div, p, li, label`;
|
|
12
|
+
let nodes = [];
|
|
13
|
+
if (opts.shadow) {
|
|
14
|
+
const walk = (root) => {
|
|
15
|
+
for (const n of Array.from(root.querySelectorAll(selector))) nodes.push(n);
|
|
16
|
+
for (const host of Array.from(root.querySelectorAll("*"))) if (host.shadowRoot) walk(host.shadowRoot);
|
|
17
|
+
};
|
|
18
|
+
walk(doc);
|
|
19
|
+
} else nodes = Array.from(doc.querySelectorAll(selector));
|
|
20
|
+
const out = [];
|
|
21
|
+
const seen = /* @__PURE__ */ new Set();
|
|
22
|
+
for (const n of nodes.slice(0, opts.cap)) {
|
|
23
|
+
if (!n.getClientRects().length) continue;
|
|
24
|
+
if (leavesPage.test(n.closest("a[href]")?.getAttribute("href") ?? "")) continue;
|
|
25
|
+
const isPress = n.matches(opts.pressable);
|
|
26
|
+
if (!isPress && n.children.length) continue;
|
|
27
|
+
const text = (n.getAttribute("aria-label") || n.value || n.textContent || "").replace(/\s+/g, " ").trim();
|
|
28
|
+
let name = text;
|
|
29
|
+
if (opts.identifiers) {
|
|
30
|
+
const ident = n.getAttribute("data-identifier") || n.getAttribute("data-email") || "";
|
|
31
|
+
name = (ident && !text.includes(ident) ? `${text} ${ident}` : text).trim();
|
|
32
|
+
}
|
|
33
|
+
if (!name || name.length > 120) continue;
|
|
34
|
+
const key = `${isPress}|${name}`;
|
|
35
|
+
if (seen.has(key)) continue;
|
|
36
|
+
seen.add(key);
|
|
37
|
+
if (!opts.detail) {
|
|
38
|
+
out.push({ name, leaf: !isPress });
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const popup = n.getAttribute("aria-haspopup");
|
|
42
|
+
out.push({
|
|
43
|
+
name,
|
|
44
|
+
leaf: !isPress,
|
|
45
|
+
...n.tagName === "A" && n.href ? { href: n.href } : {},
|
|
46
|
+
...n.closest("footer, [role=contentinfo]") ? { footer: true } : {},
|
|
47
|
+
...n.closest("nav, aside, [role=navigation], [role=complementary]") ? { nav: true } : {},
|
|
48
|
+
...name.length <= 40 && (popup && popup !== "false" || n.getAttribute("aria-expanded") === "false" || n.closest("[aria-haspopup]:not([aria-haspopup=false]), [aria-expanded=false], [role=listbox], [role=combobox], .dropdown, [class*=dropdown], [class*=avatar], [class*=user-menu], [class*=UserMenu]")) ? { menu: true } : {}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
var withPageControls = (fn, opts) => `(function(){ var read = ${readPageControls.toString()}; return (${fn.toString()})(function(){ return read(${JSON.stringify(opts)}); }); })()`;
|
|
54
|
+
|
|
55
|
+
export {
|
|
56
|
+
OPENS_ANOTHER_APP,
|
|
57
|
+
PRESSABLE,
|
|
58
|
+
PRESSABLE_SITE,
|
|
59
|
+
readPageControls,
|
|
60
|
+
withPageControls
|
|
61
|
+
};
|