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,66 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/agent/images.ts
|
|
5
|
+
import fs from "node:fs/promises";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
var IMAGE_MIME = {
|
|
8
|
+
".png": "image/png",
|
|
9
|
+
".jpg": "image/jpeg",
|
|
10
|
+
".jpeg": "image/jpeg",
|
|
11
|
+
".gif": "image/gif",
|
|
12
|
+
".webp": "image/webp"
|
|
13
|
+
};
|
|
14
|
+
var MAX_IMAGE_BYTES = 20 * 1024 * 1024;
|
|
15
|
+
async function readImageInputs(files) {
|
|
16
|
+
const out = [];
|
|
17
|
+
for (const file of files) {
|
|
18
|
+
const mimeType = IMAGE_MIME[path.extname(file).toLowerCase()];
|
|
19
|
+
if (!mimeType) continue;
|
|
20
|
+
try {
|
|
21
|
+
const stat = await fs.stat(file);
|
|
22
|
+
if (!stat.isFile() || stat.size > MAX_IMAGE_BYTES) continue;
|
|
23
|
+
out.push({ mimeType, data: (await fs.readFile(file)).toString("base64"), name: path.basename(file) });
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
var MAX_TOOL_IMAGE_BYTES = 3.75 * 1024 * 1024;
|
|
30
|
+
var MAX_IMAGE_SIDE = 8e3;
|
|
31
|
+
function sniffImage(bytes) {
|
|
32
|
+
const ascii = (start, end) => bytes.subarray(start, end).toString("latin1");
|
|
33
|
+
if (bytes.length >= 24 && bytes.readUInt32BE(0) === 2303741511 && bytes.readUInt32BE(4) === 218765834) {
|
|
34
|
+
return { mimeType: "image/png", width: bytes.readUInt32BE(16), height: bytes.readUInt32BE(20) };
|
|
35
|
+
}
|
|
36
|
+
if (bytes.length >= 10 && ascii(0, 4) === "GIF8") return { mimeType: "image/gif", width: bytes.readUInt16LE(6), height: bytes.readUInt16LE(8) };
|
|
37
|
+
if (bytes.length >= 16 && ascii(0, 4) === "RIFF" && ascii(8, 12) === "WEBP") {
|
|
38
|
+
const chunk = ascii(12, 16);
|
|
39
|
+
if (chunk === "VP8X" && bytes.length >= 30) return { mimeType: "image/webp", width: 1 + bytes.readUIntLE(24, 3), height: 1 + bytes.readUIntLE(27, 3) };
|
|
40
|
+
if (chunk === "VP8 " && bytes.length >= 30) return { mimeType: "image/webp", width: bytes.readUInt16LE(26) & 16383, height: bytes.readUInt16LE(28) & 16383 };
|
|
41
|
+
if (chunk === "VP8L" && bytes.length >= 25) {
|
|
42
|
+
const [b0, b1, b2, b3] = [bytes[21], bytes[22], bytes[23], bytes[24]];
|
|
43
|
+
return { mimeType: "image/webp", width: 1 + ((b1 & 63) << 8 | b0), height: 1 + ((b3 & 15) << 10 | b2 << 2 | (b1 & 192) >> 6) };
|
|
44
|
+
}
|
|
45
|
+
return { mimeType: "image/webp" };
|
|
46
|
+
}
|
|
47
|
+
if (bytes.length >= 3 && bytes[0] === 255 && bytes[1] === 216 && bytes[2] === 255) {
|
|
48
|
+
for (let offset = 2; offset + 9 <= bytes.length && bytes[offset] === 255; ) {
|
|
49
|
+
const marker = bytes[offset + 1];
|
|
50
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
|
|
51
|
+
return { mimeType: "image/jpeg", height: bytes.readUInt16BE(offset + 5), width: bytes.readUInt16BE(offset + 7) };
|
|
52
|
+
}
|
|
53
|
+
offset += 2 + bytes.readUInt16BE(offset + 2);
|
|
54
|
+
}
|
|
55
|
+
return { mimeType: "image/jpeg" };
|
|
56
|
+
}
|
|
57
|
+
return void 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
IMAGE_MIME,
|
|
62
|
+
readImageInputs,
|
|
63
|
+
MAX_TOOL_IMAGE_BYTES,
|
|
64
|
+
MAX_IMAGE_SIDE,
|
|
65
|
+
sniffImage
|
|
66
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
gatewaySubscriptionsOn,
|
|
5
|
+
setGatewaySubscriptions,
|
|
6
|
+
subscriptionsHeader
|
|
7
|
+
} from "./chunk-GQBZU6EO.js";
|
|
8
|
+
import "./chunk-PWXII6HF.js";
|
|
9
|
+
export {
|
|
10
|
+
gatewaySubscriptionsOn,
|
|
11
|
+
setGatewaySubscriptions,
|
|
12
|
+
subscriptionsHeader
|
|
13
|
+
};
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
accountUsage,
|
|
5
|
+
costSplitParts
|
|
6
|
+
} from "./chunk-J6EGFVQX.js";
|
|
7
|
+
import {
|
|
8
|
+
accountBackAt,
|
|
9
|
+
accountQuotaSpent,
|
|
10
|
+
accountUsageText,
|
|
11
|
+
outOfUsageText,
|
|
12
|
+
usageResetLabel
|
|
13
|
+
} from "./chunk-XWAC3MKW.js";
|
|
14
|
+
import {
|
|
15
|
+
isClikCodeAgent
|
|
16
|
+
} from "./chunk-CRUVYGO2.js";
|
|
17
|
+
import {
|
|
18
|
+
invocationRollups,
|
|
19
|
+
invocationTokenCount
|
|
20
|
+
} from "./chunk-NKDATMEM.js";
|
|
21
|
+
import {
|
|
22
|
+
compactCount,
|
|
23
|
+
dollars
|
|
24
|
+
} from "./chunk-EE4B6A7W.js";
|
|
25
|
+
|
|
26
|
+
// src/tui/slash/usage-report.ts
|
|
27
|
+
function sumInvocations(invocations) {
|
|
28
|
+
return invocations.reduce((total, invocation) => ({
|
|
29
|
+
accounts: total.accounts,
|
|
30
|
+
turns: total.turns + (invocation.kind === "maintenance" ? 0 : 1),
|
|
31
|
+
maintenance: total.maintenance + (invocation.kind === "maintenance" ? 1 : 0),
|
|
32
|
+
inputTokens: total.inputTokens + (invocation.inputTokens ?? 0),
|
|
33
|
+
outputTokens: total.outputTokens + (invocation.outputTokens ?? 0),
|
|
34
|
+
cacheReadTokens: total.cacheReadTokens + (invocation.cacheReadTokens ?? 0),
|
|
35
|
+
cacheWriteTokens: total.cacheWriteTokens + (invocation.cacheWriteTokens ?? 0),
|
|
36
|
+
totalTokens: total.totalTokens + invocationTokenCount(invocation),
|
|
37
|
+
costUsd: total.costUsd + (invocation.costUsd ?? 0),
|
|
38
|
+
costKnown: total.costKnown || invocation.costUsd !== void 0,
|
|
39
|
+
...invocation.costBreakdown || total.breakdown ? { breakdown: {
|
|
40
|
+
meteredUsd: (total.breakdown?.meteredUsd ?? 0) + (invocation.costBreakdown?.meteredUsd ?? 0),
|
|
41
|
+
gpuUsd: (total.breakdown?.gpuUsd ?? 0) + (invocation.costBreakdown?.gpuUsd ?? 0)
|
|
42
|
+
} } : {}
|
|
43
|
+
}), { accounts: 0, turns: 0, maintenance: 0, inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0, totalTokens: 0, costUsd: 0, costKnown: false });
|
|
44
|
+
}
|
|
45
|
+
function allowance(account, state, now) {
|
|
46
|
+
const usage = accountUsage(account, state, now);
|
|
47
|
+
const label = usage && accountUsageText(usage);
|
|
48
|
+
if (usage && label) {
|
|
49
|
+
const reset = usageResetLabel(usage.windows, now);
|
|
50
|
+
return { label, ...reset ? { reset } : {} };
|
|
51
|
+
}
|
|
52
|
+
if (account.status === "needs_login") return { label: "needs reauthentication" };
|
|
53
|
+
if (accountQuotaSpent(account, now)) return { label: outOfUsageText(accountBackAt(account, now), now) };
|
|
54
|
+
return { label: "not reported yet" };
|
|
55
|
+
}
|
|
56
|
+
function accountLines(account, state, session, now) {
|
|
57
|
+
const totals = sumInvocations(state.invocations.filter((item) => item.accountId === account.id));
|
|
58
|
+
const quota = allowance(account, state, now);
|
|
59
|
+
const name = account.id === session.accountId ? `${account.label} \xB7 current` : account.label;
|
|
60
|
+
const figures = [tokenFigure(totals.totalTokens), ...totals.maintenance ? [`${totals.maintenance} cache refresh${totals.maintenance === 1 ? "" : "es"}`] : []];
|
|
61
|
+
if (totals.costKnown) figures.push(dollars(totals.costUsd));
|
|
62
|
+
const shown = figures.filter(Boolean);
|
|
63
|
+
return [
|
|
64
|
+
` ${name}`,
|
|
65
|
+
...quota.label === "not reported yet" ? [] : [` ${quota.label}`],
|
|
66
|
+
...quota.reset ? [` ${quota.reset}`] : [],
|
|
67
|
+
...shown.length ? [` ${shown.join(" \xB7 ")}`] : []
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
function tokenFigure(tokens) {
|
|
71
|
+
return tokens ? `${compactCount(tokens)} tokens` : "";
|
|
72
|
+
}
|
|
73
|
+
function splitLines(totals, cacheWithinInput) {
|
|
74
|
+
const flow = [
|
|
75
|
+
...totals.inputTokens ? [`${compactCount(totals.inputTokens)} in${cacheWithinInput && totals.cacheReadTokens ? " (includes cached)" : ""}`] : [],
|
|
76
|
+
...totals.outputTokens ? [`${compactCount(totals.outputTokens)} out`] : []
|
|
77
|
+
];
|
|
78
|
+
const lines = flow.length ? [` ${flow.join(" \xB7 ")}`] : [];
|
|
79
|
+
if (totals.cacheReadTokens > 0) lines.push(` ${compactCount(totals.cacheReadTokens)} cached${cacheWithinInput ? " within input" : ""}`);
|
|
80
|
+
if (totals.cacheWriteTokens > 0) lines.push(` ${compactCount(totals.cacheWriteTokens)} cache written`);
|
|
81
|
+
return lines;
|
|
82
|
+
}
|
|
83
|
+
function conversationCost(state, sessionId) {
|
|
84
|
+
const totals = sumInvocations(state.invocations.filter((item) => item.sessionId === sessionId));
|
|
85
|
+
return totals.costKnown ? totals.costUsd : void 0;
|
|
86
|
+
}
|
|
87
|
+
function conversationCostBreakdown(state, sessionId) {
|
|
88
|
+
return sumInvocations(state.invocations.filter((item) => item.sessionId === sessionId)).breakdown;
|
|
89
|
+
}
|
|
90
|
+
function providerIds(session, providerId) {
|
|
91
|
+
return new Set([providerId, session.provider, session.nativeHarness].filter((id) => Boolean(id)));
|
|
92
|
+
}
|
|
93
|
+
function usageReport(state, session, options = {}) {
|
|
94
|
+
const now = options.now ?? Date.now();
|
|
95
|
+
const ids = providerIds(session, options.providerId);
|
|
96
|
+
const providerName = options.providerName ?? session.provider ?? session.nativeHarness ?? "this provider";
|
|
97
|
+
const accounts = isClikCodeAgent(session) ? [] : state.accounts.filter((account) => ids.has(account.provider));
|
|
98
|
+
const accountIds = new Set(accounts.map((account) => account.id));
|
|
99
|
+
const providerInvocations = state.invocations.filter((item) => accountIds.has(item.accountId) || ids.has(item.provider));
|
|
100
|
+
const totals = { ...sumInvocations(providerInvocations), accounts: accounts.length };
|
|
101
|
+
const conversation = sumInvocations(state.invocations.filter((item) => item.sessionId === session.id));
|
|
102
|
+
const chatBits = [`${conversation.turns} ${conversation.turns === 1 ? "turn" : "turns"}`, ...conversation.maintenance ? [`${conversation.maintenance} cache refresh${conversation.maintenance === 1 ? "" : "es"}`] : [], ...conversation.totalTokens ? [tokenFigure(conversation.totalTokens)] : []];
|
|
103
|
+
const cost = conversationCost(state, session.id);
|
|
104
|
+
if (cost !== void 0) chatBits.push(dollars(cost), ...costSplitParts(conversation.breakdown));
|
|
105
|
+
const lines = [
|
|
106
|
+
providerName,
|
|
107
|
+
"",
|
|
108
|
+
...accounts.length ? accounts.flatMap((account, index) => [...index ? [""] : [], ...accountLines(account, state, session, now)]) : [" No accounts on this provider"],
|
|
109
|
+
"",
|
|
110
|
+
...accounts.length === 1 ? [] : [` ${totals.accounts} accounts \xB7 ${totals.turns} ${totals.turns === 1 ? "turn" : "turns"}${totals.maintenance ? ` \xB7 ${totals.maintenance} cache refresh${totals.maintenance === 1 ? "" : "es"}` : ""}`],
|
|
111
|
+
...splitLines(totals, providerInvocations.some((item) => item.provider === "openai") && providerInvocations.every((item) => item.provider === "openai")),
|
|
112
|
+
...totals.costKnown && accounts.length !== 1 ? [` ${dollars(totals.costUsd)}`] : [],
|
|
113
|
+
"",
|
|
114
|
+
` This chat \xB7 ${chatBits.join(" \xB7 ")}`
|
|
115
|
+
];
|
|
116
|
+
return { text: lines.filter((line, index) => line || lines[index - 1]).join("\n"), totals };
|
|
117
|
+
}
|
|
118
|
+
var DAY_MS = 24 * 60 * 6e4;
|
|
119
|
+
var WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
120
|
+
var MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
121
|
+
function localDay(at) {
|
|
122
|
+
const date = new Date(at);
|
|
123
|
+
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
124
|
+
}
|
|
125
|
+
function costText(known, unknownTurns, knownTurns) {
|
|
126
|
+
if (!knownTurns) return "";
|
|
127
|
+
return unknownTurns ? `${dollars(known)}+` : dollars(known);
|
|
128
|
+
}
|
|
129
|
+
function tokensText(tokens, turns) {
|
|
130
|
+
return turns && !tokens ? "" : compactCount(tokens);
|
|
131
|
+
}
|
|
132
|
+
function usageDays(state, now = Date.now(), days = 7) {
|
|
133
|
+
const table = /* @__PURE__ */ new Map();
|
|
134
|
+
for (let back = 0; back < days; back += 1) {
|
|
135
|
+
const day = localDay(now - back * DAY_MS);
|
|
136
|
+
table.set(day, { day, turns: 0, maintenance: 0, tokens: 0, costUsd: 0, costTurns: 0, unknownCostTurns: 0 });
|
|
137
|
+
}
|
|
138
|
+
for (const invocation of state.invocations) {
|
|
139
|
+
const row = table.get(localDay(Date.parse(invocation.at)));
|
|
140
|
+
if (!row) continue;
|
|
141
|
+
row.turns += invocation.kind === "maintenance" ? 0 : 1;
|
|
142
|
+
row.maintenance += invocation.kind === "maintenance" ? 1 : 0;
|
|
143
|
+
row.tokens += invocationTokenCount(invocation);
|
|
144
|
+
if (invocation.costUsd !== void 0) {
|
|
145
|
+
row.costUsd += invocation.costUsd;
|
|
146
|
+
row.costTurns += 1;
|
|
147
|
+
} else row.unknownCostTurns += 1;
|
|
148
|
+
}
|
|
149
|
+
for (const rollup of invocationRollups(state)) {
|
|
150
|
+
const row = table.get(rollup.day);
|
|
151
|
+
if (!row) continue;
|
|
152
|
+
row.turns += rollup.calls - (rollup.maintenanceCalls ?? 0);
|
|
153
|
+
row.maintenance += rollup.maintenanceCalls ?? 0;
|
|
154
|
+
row.tokens += rollup.totalTokens ?? rollup.inputTokens + rollup.outputTokens;
|
|
155
|
+
row.unknownCostTurns += rollup.calls;
|
|
156
|
+
}
|
|
157
|
+
return [...table.values()];
|
|
158
|
+
}
|
|
159
|
+
function usageReportAll(state, session, options = {}) {
|
|
160
|
+
const now = options.now ?? Date.now();
|
|
161
|
+
const name = options.providerName ?? ((provider) => provider);
|
|
162
|
+
const providers = [.../* @__PURE__ */ new Set([...state.accounts.map((account) => account.provider), ...state.invocations.map((item) => item.provider)])].sort((left, right) => name(left).localeCompare(name(right)));
|
|
163
|
+
const sections = providers.map((provider) => {
|
|
164
|
+
const accounts = state.accounts.filter((account) => account.provider === provider);
|
|
165
|
+
const totals = sumInvocations(state.invocations.filter((item) => item.provider === provider));
|
|
166
|
+
const unknown = state.invocations.filter((item) => item.provider === provider && item.costUsd === void 0).length;
|
|
167
|
+
const cost = costText(totals.costUsd, unknown, totals.turns + totals.maintenance - unknown);
|
|
168
|
+
return [
|
|
169
|
+
name(provider),
|
|
170
|
+
...accounts.flatMap((account) => {
|
|
171
|
+
const quota = allowance(account, state, now);
|
|
172
|
+
const label = account.id === session.accountId ? `${account.label} \xB7 current` : account.label;
|
|
173
|
+
return [` ${label}${quota.label === "not reported yet" ? "" : ` \xB7 ${quota.label}`}${quota.reset ? ` \xB7 ${quota.reset}` : ""}`];
|
|
174
|
+
}),
|
|
175
|
+
` ${[`${totals.turns} ${totals.turns === 1 ? "turn" : "turns"}`, ...totals.maintenance ? [`${totals.maintenance} cache refresh${totals.maintenance === 1 ? "" : "es"}`] : [], tokensText(totals.totalTokens, totals.turns + totals.maintenance), cost].filter(Boolean).join(" \xB7 ")}`
|
|
176
|
+
].join("\n");
|
|
177
|
+
});
|
|
178
|
+
const days = usageDays(state, now).filter((row) => row.turns || row.maintenance);
|
|
179
|
+
const width = Math.max(0, ...days.map((row) => tokensText(row.tokens, row.turns + row.maintenance).length));
|
|
180
|
+
const week = days.map((row) => {
|
|
181
|
+
const date = /* @__PURE__ */ new Date(`${row.day}T12:00:00`);
|
|
182
|
+
const label = `${WEEKDAYS[date.getDay()]} ${MONTHS[date.getMonth()]} ${date.getDate()}`;
|
|
183
|
+
const cost = costText(row.costUsd, row.unknownCostTurns, row.costTurns);
|
|
184
|
+
const figures = [...width ? [tokensText(row.tokens, row.turns + row.maintenance).padStart(width)] : [], `${row.turns} ${row.turns === 1 ? "turn" : "turns"}`, ...row.maintenance ? [`${row.maintenance} cache refresh${row.maintenance === 1 ? "" : "es"}`] : [], ...cost ? [cost] : []];
|
|
185
|
+
return ` ${label.padEnd(11)} ${figures.join(" \xB7 ")}`;
|
|
186
|
+
});
|
|
187
|
+
return { text: [...sections.length ? sections : ["No providers yet"], ["Last 7 days", ...week.length ? week : [" Nothing recorded"]].join("\n")].join("\n\n") };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export {
|
|
191
|
+
conversationCost,
|
|
192
|
+
conversationCostBreakdown,
|
|
193
|
+
usageReport,
|
|
194
|
+
usageDays,
|
|
195
|
+
usageReportAll
|
|
196
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
specOf
|
|
5
|
+
} from "./chunk-EXN4KHLB.js";
|
|
6
|
+
|
|
7
|
+
// src/agent/computer/tool-names.ts
|
|
8
|
+
var RENAMED = { computer_web: "browser_use", computer_desktop: "computer_use" };
|
|
9
|
+
function currentToolName(name) {
|
|
10
|
+
return RENAMED[name] ?? name;
|
|
11
|
+
}
|
|
12
|
+
function toolForCall(name, args) {
|
|
13
|
+
const current = currentToolName(name);
|
|
14
|
+
const spec = typeof args["action"] === "string" ? specOf(args["action"]) : void 0;
|
|
15
|
+
return current === "browser_use" && spec?.kind === "account" ? "account_use" : current;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// src/agent/computer/hot-tools.ts
|
|
19
|
+
import { existsSync } from "node:fs";
|
|
20
|
+
import { stat } from "node:fs/promises";
|
|
21
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
22
|
+
var loaded;
|
|
23
|
+
function hotReloadEnabled() {
|
|
24
|
+
const forced = process.env.CLIKCODE_HOT_TOOLS;
|
|
25
|
+
if (forced === "1" || forced === "0") return forced === "1";
|
|
26
|
+
try {
|
|
27
|
+
return existsSync(fileURLToPath(new URL("../.git", import.meta.url)));
|
|
28
|
+
} catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function latest() {
|
|
33
|
+
let file;
|
|
34
|
+
try {
|
|
35
|
+
file = fileURLToPath(new URL("./computer-tools.js", import.meta.url));
|
|
36
|
+
} catch {
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
let mtime;
|
|
40
|
+
try {
|
|
41
|
+
mtime = (await stat(file)).mtimeMs;
|
|
42
|
+
} catch {
|
|
43
|
+
return void 0;
|
|
44
|
+
}
|
|
45
|
+
if (loaded?.mtime === mtime) return loaded.tools;
|
|
46
|
+
try {
|
|
47
|
+
const module = await import(`${pathToFileURL(file).href}?v=${mtime}`);
|
|
48
|
+
loaded = { mtime, tools: new Map((module.computerToolSet ?? []).map((tool) => [tool.name, tool])) };
|
|
49
|
+
} catch (error) {
|
|
50
|
+
const failure = error instanceof Error ? error.message : String(error);
|
|
51
|
+
loaded = { mtime, tools: void 0, failure };
|
|
52
|
+
process.stderr.write(`computer tools: could not load the rebuilt copy (${failure})
|
|
53
|
+
`);
|
|
54
|
+
}
|
|
55
|
+
return loaded.tools;
|
|
56
|
+
}
|
|
57
|
+
async function latestToolSet() {
|
|
58
|
+
const tools = await latest();
|
|
59
|
+
return tools && [...tools.values()];
|
|
60
|
+
}
|
|
61
|
+
async function latestTool(name) {
|
|
62
|
+
return hotReloadEnabled() ? (await latest())?.get(name) : void 0;
|
|
63
|
+
}
|
|
64
|
+
async function installedBuildStamp() {
|
|
65
|
+
try {
|
|
66
|
+
return (await stat(fileURLToPath(new URL("./computer-tools.js", import.meta.url)))).mtimeMs;
|
|
67
|
+
} catch {
|
|
68
|
+
return void 0;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function hotTool(tool) {
|
|
72
|
+
return { ...tool, run: async (args, context) => {
|
|
73
|
+
if (!hotReloadEnabled()) return tool.run(args, context);
|
|
74
|
+
const rebuilt = (await latest())?.get(tool.name);
|
|
75
|
+
const result = await (rebuilt ?? tool).run(args, context);
|
|
76
|
+
if (!rebuilt && loaded?.failure && !told.has(loaded.mtime)) {
|
|
77
|
+
told.add(loaded.mtime);
|
|
78
|
+
return { ...result, output: `[The rebuilt computer tools did not load (${loaded.failure.slice(0, 200)}); this ran the copy built into the program.]
|
|
79
|
+
${result.output}` };
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
} };
|
|
83
|
+
}
|
|
84
|
+
var told = /* @__PURE__ */ new Set();
|
|
85
|
+
|
|
86
|
+
export {
|
|
87
|
+
currentToolName,
|
|
88
|
+
toolForCall,
|
|
89
|
+
latestToolSet,
|
|
90
|
+
latestTool,
|
|
91
|
+
installedBuildStamp,
|
|
92
|
+
hotTool
|
|
93
|
+
};
|