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/session/store/paths.ts
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
import { homedir, userInfo } from "node:os";
|
|
7
|
+
import { join, resolve } from "node:path";
|
|
8
|
+
function stateDirectory() {
|
|
9
|
+
const dir = process.env.CLIKCODE_HOME?.trim() || join(homedir(), ".clikcode");
|
|
10
|
+
assertNotRealStateUnderTest(dir);
|
|
11
|
+
return dir;
|
|
12
|
+
}
|
|
13
|
+
function realStateDirectory() {
|
|
14
|
+
try {
|
|
15
|
+
return resolve(userInfo().homedir, ".clikcode");
|
|
16
|
+
} catch {
|
|
17
|
+
return void 0;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function assertNotRealStateUnderTest(dir) {
|
|
21
|
+
if (!process.env.VITEST) return;
|
|
22
|
+
const real = realStateDirectory();
|
|
23
|
+
if (real && resolve(dir) === real) {
|
|
24
|
+
throw new Error(`A test reached the real ClikCode state (${real}). Tests must run against a throwaway CLIKCODE_HOME (vitest.setup.ts sets one).`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function sessionsDirectory() {
|
|
28
|
+
return join(stateDirectory(), "sessions");
|
|
29
|
+
}
|
|
30
|
+
function safeRecordFileName(id) {
|
|
31
|
+
return /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(id) ? id : `h-${createHash("sha256").update(id).digest("hex")}`;
|
|
32
|
+
}
|
|
33
|
+
function sessionFilePath(id) {
|
|
34
|
+
return join(sessionsDirectory(), `${safeRecordFileName(id)}.json`);
|
|
35
|
+
}
|
|
36
|
+
function sessionTurnPath(id) {
|
|
37
|
+
return join(sessionsDirectory(), `${safeRecordFileName(id)}.turn`);
|
|
38
|
+
}
|
|
39
|
+
function sessionLogPath(id) {
|
|
40
|
+
return join(sessionsDirectory(), `${safeRecordFileName(id)}.jsonl`);
|
|
41
|
+
}
|
|
42
|
+
function sessionLoggedPath(id) {
|
|
43
|
+
return join(sessionsDirectory(), `${safeRecordFileName(id)}.logged`);
|
|
44
|
+
}
|
|
45
|
+
function sessionPendingPath(id) {
|
|
46
|
+
return join(sessionsDirectory(), `${safeRecordFileName(id)}.pending`);
|
|
47
|
+
}
|
|
48
|
+
function sessionLegacyBackupPath(id) {
|
|
49
|
+
return join(sessionsDirectory(), `${safeRecordFileName(id)}.json-v1`);
|
|
50
|
+
}
|
|
51
|
+
function sessionLockPath(id) {
|
|
52
|
+
return `${sessionFilePath(id)}.lock`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export {
|
|
56
|
+
stateDirectory,
|
|
57
|
+
sessionsDirectory,
|
|
58
|
+
safeRecordFileName,
|
|
59
|
+
sessionFilePath,
|
|
60
|
+
sessionTurnPath,
|
|
61
|
+
sessionLogPath,
|
|
62
|
+
sessionLoggedPath,
|
|
63
|
+
sessionPendingPath,
|
|
64
|
+
sessionLegacyBackupPath,
|
|
65
|
+
sessionLockPath
|
|
66
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
claimMessage,
|
|
5
|
+
isClaimed
|
|
6
|
+
} from "./chunk-XAHGBPWT.js";
|
|
7
|
+
import "./chunk-4L2ZZM4Q.js";
|
|
8
|
+
import "./chunk-F6F47QAY.js";
|
|
9
|
+
import "./chunk-RDDWQBEM.js";
|
|
10
|
+
import "./chunk-MPAJ446F.js";
|
|
11
|
+
import "./chunk-CBANJFBO.js";
|
|
12
|
+
import "./chunk-PWXII6HF.js";
|
|
13
|
+
export {
|
|
14
|
+
claimMessage,
|
|
15
|
+
isClaimed
|
|
16
|
+
};
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
HARNESS_DEFAULT_SETTINGS,
|
|
5
|
+
normalizedConversation,
|
|
6
|
+
normalizedPermissionMode,
|
|
7
|
+
normalizedSessionPermission,
|
|
8
|
+
normalizedStatus
|
|
9
|
+
} from "./chunk-BISGNHKD.js";
|
|
10
|
+
import {
|
|
11
|
+
DRAFT_BASELINE,
|
|
12
|
+
STATE_BASELINE,
|
|
13
|
+
baselineOf,
|
|
14
|
+
ephemeralSessions,
|
|
15
|
+
readLocalApiToken,
|
|
16
|
+
readSecretsFile,
|
|
17
|
+
rememberBaseline
|
|
18
|
+
} from "./chunk-BGEMY2JJ.js";
|
|
19
|
+
import {
|
|
20
|
+
loadIndex,
|
|
21
|
+
storeIndex
|
|
22
|
+
} from "./chunk-XCKQ5BM2.js";
|
|
23
|
+
import {
|
|
24
|
+
HARNESS_STATE_VERSION
|
|
25
|
+
} from "./chunk-NWEYRBWK.js";
|
|
26
|
+
import {
|
|
27
|
+
markFromIndex,
|
|
28
|
+
markTranscriptLoaded,
|
|
29
|
+
sessionFromIndex,
|
|
30
|
+
transcriptWasLoaded
|
|
31
|
+
} from "./chunk-TWCVV2JO.js";
|
|
32
|
+
import {
|
|
33
|
+
ConversationLogMissingError,
|
|
34
|
+
readSessionTranscript
|
|
35
|
+
} from "./chunk-RVUOIJXN.js";
|
|
36
|
+
import {
|
|
37
|
+
STATE_ROLLUPS
|
|
38
|
+
} from "./chunk-NKDATMEM.js";
|
|
39
|
+
import {
|
|
40
|
+
cloneData,
|
|
41
|
+
hidden
|
|
42
|
+
} from "./chunk-KHW6TX6I.js";
|
|
43
|
+
import {
|
|
44
|
+
withStateLock
|
|
45
|
+
} from "./chunk-4L2ZZM4Q.js";
|
|
46
|
+
|
|
47
|
+
// src/session/state/read.ts
|
|
48
|
+
import { randomUUID } from "node:crypto";
|
|
49
|
+
|
|
50
|
+
// src/turn/compaction.ts
|
|
51
|
+
var DEFAULT_COMPACT_AT_TOKENS = 15e4;
|
|
52
|
+
var MIN_COMPACT_AT_TOKENS = 2e4;
|
|
53
|
+
var TURNS_BETWEEN_COMPACTIONS = 2;
|
|
54
|
+
var COMPACTING = "Compacting\u2026";
|
|
55
|
+
var COMPACTED = "Compacted";
|
|
56
|
+
var NOTHING_TO_COMPACT = "Nothing to compact yet.";
|
|
57
|
+
var compactFailedLine = (reason) => `Could not compact: ${reason.replace(/^Could not compact:\s*/, "")}`;
|
|
58
|
+
var COMPACT_REQUEST = "/compact";
|
|
59
|
+
var isCompactRequest = (prompt) => prompt.trim() === COMPACT_REQUEST;
|
|
60
|
+
function parseCompactAt(word) {
|
|
61
|
+
const match = /^(\d+(?:\.\d+)?)\s*([km]?)(?:\s*tokens?)?$/i.exec(word.trim());
|
|
62
|
+
if (!match) return void 0;
|
|
63
|
+
const unit = match[2].toLowerCase();
|
|
64
|
+
return Math.round(Number(match[1]) * (unit === "m" ? 1e6 : unit === "k" ? 1e3 : 1));
|
|
65
|
+
}
|
|
66
|
+
function compactAt(settings) {
|
|
67
|
+
const set = settings?.compactAt;
|
|
68
|
+
return typeof set === "number" && Number.isFinite(set) && set >= MIN_COMPACT_AT_TOKENS ? set : DEFAULT_COMPACT_AT_TOKENS;
|
|
69
|
+
}
|
|
70
|
+
function tokenLabel(tokens) {
|
|
71
|
+
return tokens >= 1e6 ? `${Math.round(tokens / 1e5) / 10}m` : `${Math.round(tokens / 1e3)}k`;
|
|
72
|
+
}
|
|
73
|
+
var knownCompactAt;
|
|
74
|
+
function noteCompactAt(settings) {
|
|
75
|
+
knownCompactAt = compactAt(settings);
|
|
76
|
+
}
|
|
77
|
+
var currentCompactAt = () => knownCompactAt ?? DEFAULT_COMPACT_AT_TOKENS;
|
|
78
|
+
function compactDescription() {
|
|
79
|
+
return `compact this conversation now; /compact <tokens> sets when it compacts by itself (now ${tokenLabel(currentCompactAt())})`;
|
|
80
|
+
}
|
|
81
|
+
function contextTokens(usage) {
|
|
82
|
+
if (usage?.contextUsed !== void 0 && usage.contextUsed > 0) return usage.contextUsed;
|
|
83
|
+
if (usage?.contextPercent !== void 0 && usage.contextWindow) return Math.round(usage.contextPercent / 100 * usage.contextWindow);
|
|
84
|
+
return void 0;
|
|
85
|
+
}
|
|
86
|
+
var COMPACT_COMMAND_NAMES = ["compact", "compress"];
|
|
87
|
+
function compactionMechanism(harness, commands = []) {
|
|
88
|
+
if (harness.nativeOperations?.includes("compact")) return { kind: "native-api", prompt: COMPACT_REQUEST };
|
|
89
|
+
if (harness.acp?.compactCommand) return { kind: "native-command", prompt: harness.acp.compactCommand.prompt };
|
|
90
|
+
const names = commands.map((name) => name.replace(/^\//, "").toLowerCase());
|
|
91
|
+
const named = COMPACT_COMMAND_NAMES.find((name) => names.includes(name));
|
|
92
|
+
if (named) return { kind: "native-command", prompt: `/${named}` };
|
|
93
|
+
if (harness.nativeSlashPassthrough) return { kind: "native-command", prompt: COMPACT_REQUEST };
|
|
94
|
+
if (harness.compactThreshold) return { kind: "vendor-threshold" };
|
|
95
|
+
return { kind: "rewrite" };
|
|
96
|
+
}
|
|
97
|
+
function turnsSinceCompaction(session) {
|
|
98
|
+
const record = session.compaction;
|
|
99
|
+
const messages = session.messages ?? [];
|
|
100
|
+
const from = record ? Math.min(record.through, messages.length) : 0;
|
|
101
|
+
return messages.slice(from).filter((message) => message.role === "user" && !message.automatic).length;
|
|
102
|
+
}
|
|
103
|
+
function effectiveThreshold(threshold, record) {
|
|
104
|
+
const after = record?.after;
|
|
105
|
+
return after !== void 0 && after > threshold / 2 ? Math.max(threshold, after * 2) : threshold;
|
|
106
|
+
}
|
|
107
|
+
function noteContextAfterCompaction(session) {
|
|
108
|
+
const record = session.compaction;
|
|
109
|
+
if (!record || record.after !== void 0 || turnsSinceCompaction(session) < 1) return false;
|
|
110
|
+
const used = contextTokens(session.lastUsage);
|
|
111
|
+
if (used === void 0 || Date.parse(session.lastUsage.at) < Date.parse(record.at)) return false;
|
|
112
|
+
record.after = used;
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
function shouldCompact(session, threshold, since) {
|
|
116
|
+
const usage = session.lastUsage;
|
|
117
|
+
const used = contextTokens(usage);
|
|
118
|
+
if (used === void 0 || Date.parse(usage.at) < since) return false;
|
|
119
|
+
if (session.compaction && turnsSinceCompaction(session) < TURNS_BETWEEN_COMPACTIONS) return false;
|
|
120
|
+
return used >= effectiveThreshold(threshold, session.compaction);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// src/session/state/read.ts
|
|
124
|
+
async function assembleState(index, secrets, transcripts) {
|
|
125
|
+
const sessions = await Promise.all(index.sessions.map(async (meta) => {
|
|
126
|
+
const load = transcripts === "all" || transcripts.has(meta.id);
|
|
127
|
+
const transcript = load ? await readSessionTranscript(meta.id).catch((error) => {
|
|
128
|
+
if (transcripts === "all" && error instanceof ConversationLogMissingError) return void 0;
|
|
129
|
+
throw error;
|
|
130
|
+
}) : void 0;
|
|
131
|
+
const session = {
|
|
132
|
+
...cloneData(meta),
|
|
133
|
+
...transcript ?? {}
|
|
134
|
+
};
|
|
135
|
+
markFromIndex(session);
|
|
136
|
+
if (transcript) markTranscriptLoaded(session);
|
|
137
|
+
return session;
|
|
138
|
+
}));
|
|
139
|
+
const state = {
|
|
140
|
+
version: index.version,
|
|
141
|
+
installationId: index.installationId,
|
|
142
|
+
devicePublicKey: cloneData(index.devicePublicKey ?? {}),
|
|
143
|
+
accounts: cloneData(index.accounts),
|
|
144
|
+
sessions,
|
|
145
|
+
invocations: cloneData(index.invocations),
|
|
146
|
+
globalSettings: cloneData(index.globalSettings),
|
|
147
|
+
providerSettings: cloneData(index.providerSettings ?? {})
|
|
148
|
+
};
|
|
149
|
+
noteCompactAt(state.globalSettings);
|
|
150
|
+
return attachHidden(state, secrets, index.invocationRollups);
|
|
151
|
+
}
|
|
152
|
+
function attachHidden(state, secrets, rollups) {
|
|
153
|
+
hidden(state, "localApiToken", secrets.localApiToken ?? "");
|
|
154
|
+
hidden(state, "devicePrivateKeyPem", secrets.devicePrivateKeyPem ?? "");
|
|
155
|
+
hidden(state, STATE_ROLLUPS, rollups);
|
|
156
|
+
return state;
|
|
157
|
+
}
|
|
158
|
+
function normalizedState(raw) {
|
|
159
|
+
const sessions = raw.sessions.map((session) => {
|
|
160
|
+
const next = {
|
|
161
|
+
...session,
|
|
162
|
+
...normalizedConversation(session),
|
|
163
|
+
...normalizedStatus(session),
|
|
164
|
+
...normalizedSessionPermission(session)
|
|
165
|
+
};
|
|
166
|
+
if (sessionFromIndex(session)) markFromIndex(next);
|
|
167
|
+
if (transcriptWasLoaded(session)) markTranscriptLoaded(next);
|
|
168
|
+
return next;
|
|
169
|
+
});
|
|
170
|
+
const accounts = (Array.isArray(raw.accounts) ? raw.accounts : []).map((account) => {
|
|
171
|
+
const { usageLearning: _estimate, ...kept } = account;
|
|
172
|
+
return kept;
|
|
173
|
+
});
|
|
174
|
+
const normalized = {
|
|
175
|
+
...raw,
|
|
176
|
+
accounts,
|
|
177
|
+
sessions,
|
|
178
|
+
invocations: Array.isArray(raw.invocations) ? raw.invocations : [],
|
|
179
|
+
globalSettings: { ...HARNESS_DEFAULT_SETTINGS, ...raw.globalSettings, permissionMode: normalizedPermissionMode(raw.globalSettings?.permissionMode) },
|
|
180
|
+
providerSettings: Object.fromEntries(Object.entries(raw.providerSettings && typeof raw.providerSettings === "object" ? raw.providerSettings : {}).map(([provider, settings]) => [
|
|
181
|
+
provider,
|
|
182
|
+
{ ...settings, ...settings.permissionMode ? { permissionMode: normalizedPermissionMode(settings.permissionMode) } : {} }
|
|
183
|
+
]))
|
|
184
|
+
};
|
|
185
|
+
return attachHidden(
|
|
186
|
+
normalized,
|
|
187
|
+
{ localApiToken: raw.localApiToken, devicePrivateKeyPem: raw.devicePrivateKeyPem },
|
|
188
|
+
raw[STATE_ROLLUPS] ?? {}
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
async function createIndex() {
|
|
192
|
+
await withStateLock(async () => {
|
|
193
|
+
if (await loadIndex()) return;
|
|
194
|
+
await storeIndex({
|
|
195
|
+
version: HARNESS_STATE_VERSION,
|
|
196
|
+
installationId: randomUUID(),
|
|
197
|
+
accounts: [],
|
|
198
|
+
sessions: [],
|
|
199
|
+
invocations: [],
|
|
200
|
+
invocationRollups: {},
|
|
201
|
+
globalSettings: { ...HARNESS_DEFAULT_SETTINGS },
|
|
202
|
+
providerSettings: {}
|
|
203
|
+
}, { backup: true });
|
|
204
|
+
});
|
|
205
|
+
const index = await loadIndex();
|
|
206
|
+
if (!index) throw new Error("local AI harness state could not be created");
|
|
207
|
+
return index;
|
|
208
|
+
}
|
|
209
|
+
async function readState(options) {
|
|
210
|
+
const transcripts = options?.transcripts ?? "all";
|
|
211
|
+
const wanted = transcripts === "all" ? "all" : new Set(transcripts);
|
|
212
|
+
const index = await loadIndex() ?? await createIndex();
|
|
213
|
+
let secrets = await readSecretsFile();
|
|
214
|
+
if (!secrets.localApiToken && index.version <= HARNESS_STATE_VERSION) {
|
|
215
|
+
await readLocalApiToken();
|
|
216
|
+
secrets = await readSecretsFile();
|
|
217
|
+
}
|
|
218
|
+
const raw = await assembleState(index, secrets, wanted);
|
|
219
|
+
rememberBaseline(raw);
|
|
220
|
+
const normalized = normalizedState(raw);
|
|
221
|
+
hidden(normalized, STATE_BASELINE, raw[STATE_BASELINE]);
|
|
222
|
+
return withDrafts(normalized);
|
|
223
|
+
}
|
|
224
|
+
function withDrafts(state) {
|
|
225
|
+
const added = [];
|
|
226
|
+
for (const session of ephemeralSessions()) {
|
|
227
|
+
if (!state.sessions.some((item) => item.id === session.id)) {
|
|
228
|
+
state.sessions.push(session);
|
|
229
|
+
added.push(session);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (added.length) hidden(state, DRAFT_BASELINE, baselineOf({ ...state, sessions: added }).sessions);
|
|
233
|
+
return state;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export {
|
|
237
|
+
MIN_COMPACT_AT_TOKENS,
|
|
238
|
+
COMPACTING,
|
|
239
|
+
COMPACTED,
|
|
240
|
+
NOTHING_TO_COMPACT,
|
|
241
|
+
compactFailedLine,
|
|
242
|
+
COMPACT_REQUEST,
|
|
243
|
+
isCompactRequest,
|
|
244
|
+
parseCompactAt,
|
|
245
|
+
compactAt,
|
|
246
|
+
tokenLabel,
|
|
247
|
+
noteCompactAt,
|
|
248
|
+
compactDescription,
|
|
249
|
+
compactionMechanism,
|
|
250
|
+
noteContextAfterCompaction,
|
|
251
|
+
shouldCompact,
|
|
252
|
+
readState
|
|
253
|
+
};
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
ampUsageProbe,
|
|
5
|
+
antigravityUsageReading,
|
|
6
|
+
auggieUsageReading,
|
|
7
|
+
clineUsageReading,
|
|
8
|
+
commandCodeUsageReading,
|
|
9
|
+
copilotUsageReading,
|
|
10
|
+
cursorUsageReading,
|
|
11
|
+
devinUsageReading,
|
|
12
|
+
hermesUsageReading,
|
|
13
|
+
kiloUsageReading,
|
|
14
|
+
kimiUsageReading,
|
|
15
|
+
kiroUsageReading,
|
|
16
|
+
vibeUsageReading
|
|
17
|
+
} from "./chunk-DA44ZENT.js";
|
|
18
|
+
import {
|
|
19
|
+
claudeRateLimitReading,
|
|
20
|
+
claudeUsageCommandReading,
|
|
21
|
+
nativeUsageCache,
|
|
22
|
+
usageCacheKey,
|
|
23
|
+
usageReading,
|
|
24
|
+
usageWindow,
|
|
25
|
+
usageWindowName
|
|
26
|
+
} from "./chunk-XWAC3MKW.js";
|
|
27
|
+
import {
|
|
28
|
+
queryAcp
|
|
29
|
+
} from "./chunk-ESF3DIZY.js";
|
|
30
|
+
import {
|
|
31
|
+
readState
|
|
32
|
+
} from "./chunk-MXS6S2PY.js";
|
|
33
|
+
import {
|
|
34
|
+
writeState
|
|
35
|
+
} from "./chunk-RKUVLRZI.js";
|
|
36
|
+
import {
|
|
37
|
+
localHarnessForCommand
|
|
38
|
+
} from "./chunk-KYUHIFP3.js";
|
|
39
|
+
import {
|
|
40
|
+
PROBE_DEADLINE_MS,
|
|
41
|
+
probeCommand,
|
|
42
|
+
queryJsonRpc
|
|
43
|
+
} from "./chunk-DF35KMXM.js";
|
|
44
|
+
import {
|
|
45
|
+
CLIKCODE_VERSION
|
|
46
|
+
} from "./chunk-NAOX3JUB.js";
|
|
47
|
+
import {
|
|
48
|
+
quiet
|
|
49
|
+
} from "./chunk-RDDWQBEM.js";
|
|
50
|
+
|
|
51
|
+
// src/harness/accounts/usage-probes.ts
|
|
52
|
+
import { readFile } from "node:fs/promises";
|
|
53
|
+
import { homedir } from "node:os";
|
|
54
|
+
import { join } from "node:path";
|
|
55
|
+
|
|
56
|
+
// src/harness/accounts/grok-usage.ts
|
|
57
|
+
var PERIOD_NAMES = {
|
|
58
|
+
USAGE_PERIOD_TYPE_DAILY: "daily",
|
|
59
|
+
USAGE_PERIOD_TYPE_WEEKLY: "weekly",
|
|
60
|
+
USAGE_PERIOD_TYPE_MONTHLY: "monthly"
|
|
61
|
+
};
|
|
62
|
+
function protoNumber(value) {
|
|
63
|
+
const raw = value && typeof value === "object" ? value.val : value;
|
|
64
|
+
const parsed = typeof raw === "string" ? Number(raw) : raw;
|
|
65
|
+
return typeof parsed === "number" && Number.isFinite(parsed) ? parsed : void 0;
|
|
66
|
+
}
|
|
67
|
+
function grokBillingReading(result) {
|
|
68
|
+
const config = result?.config;
|
|
69
|
+
const period = config?.currentPeriod;
|
|
70
|
+
if (!period || typeof period !== "object") return void 0;
|
|
71
|
+
const type = typeof period.type === "string" ? period.type : "";
|
|
72
|
+
const name = PERIOD_NAMES[type] ?? (type.replace(/^USAGE_PERIOD_TYPE_/, "").toLowerCase() || "plan");
|
|
73
|
+
const tier = result.subscription_tier;
|
|
74
|
+
if (typeof tier === "string" && /free/i.test(tier)) return { windows: [], label: "Free plan", plan: { name: tier } };
|
|
75
|
+
const reading = usageReading([usageWindow(name, protoNumber(config.creditUsagePercent) ?? 0, period.end ?? config.billingPeriodEnd)]);
|
|
76
|
+
return reading && typeof tier === "string" && tier ? { ...reading, plan: { name: tier } } : reading;
|
|
77
|
+
}
|
|
78
|
+
async function grokUsageReading(environment) {
|
|
79
|
+
let harness;
|
|
80
|
+
try {
|
|
81
|
+
harness = localHarnessForCommand("grok");
|
|
82
|
+
} catch {
|
|
83
|
+
harness = void 0;
|
|
84
|
+
}
|
|
85
|
+
if (!harness) return void 0;
|
|
86
|
+
const result = await queryAcp(
|
|
87
|
+
harness.binary,
|
|
88
|
+
["agent", "--no-leader", "stdio"],
|
|
89
|
+
environment,
|
|
90
|
+
(request) => request("_x.ai/billing", { format: "credits" }),
|
|
91
|
+
void 0,
|
|
92
|
+
{ gate: harness }
|
|
93
|
+
);
|
|
94
|
+
return grokBillingReading(result);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// src/harness/accounts/usage-probes.ts
|
|
98
|
+
function catalogHarness(command) {
|
|
99
|
+
try {
|
|
100
|
+
return localHarnessForCommand(command);
|
|
101
|
+
} catch {
|
|
102
|
+
return void 0;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async function codexUsageReading(environment) {
|
|
106
|
+
let signedOut = false;
|
|
107
|
+
const harness = catalogHarness("codex");
|
|
108
|
+
if (!harness) return void 0;
|
|
109
|
+
const response = await queryJsonRpc({
|
|
110
|
+
gate: harness,
|
|
111
|
+
argv: ["app-server", "--listen", "stdio://"],
|
|
112
|
+
environment,
|
|
113
|
+
deadlineMs: PROBE_DEADLINE_MS,
|
|
114
|
+
label: "codex app-server",
|
|
115
|
+
jsonrpcVersion: false
|
|
116
|
+
}, async (peer) => {
|
|
117
|
+
await peer.request("initialize", { clientInfo: { name: "clikcode", version: CLIKCODE_VERSION } });
|
|
118
|
+
peer.notify("initialized", {});
|
|
119
|
+
try {
|
|
120
|
+
return await peer.request("account/rateLimits/read", { excludeResetCreditDetails: true });
|
|
121
|
+
} catch (error) {
|
|
122
|
+
signedOut = /token_expired|sign(?:ing)? in again|401 Unauthorized/i.test(error instanceof Error ? error.message : String(error));
|
|
123
|
+
return void 0;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
if (signedOut) return { windows: [], account: "signed-out" };
|
|
127
|
+
const reading = codexRateLimitsReading(response?.rateLimits);
|
|
128
|
+
const plan = await codexPlan(environment);
|
|
129
|
+
if (!plan) return reading;
|
|
130
|
+
if (reading) return { ...reading, plan: { name: plan } };
|
|
131
|
+
return response ? { windows: [], label: /^free$/i.test(plan) ? "Free plan" : `${plan} plan`, plan: { name: plan } } : { windows: [], plan: { name: plan } };
|
|
132
|
+
}
|
|
133
|
+
async function codexPlan(environment) {
|
|
134
|
+
try {
|
|
135
|
+
const home = environment.CODEX_HOME ?? join(environment.HOME ?? homedir(), ".codex");
|
|
136
|
+
const auth = JSON.parse(await readFile(join(home, "auth.json"), "utf8"));
|
|
137
|
+
const token = auth.tokens?.id_token;
|
|
138
|
+
if (typeof token !== "string") return void 0;
|
|
139
|
+
const claims = JSON.parse(Buffer.from(token.split(".")[1] ?? "", "base64url").toString("utf8"));
|
|
140
|
+
const plan = claims["https://api.openai.com/auth"]?.chatgpt_plan_type;
|
|
141
|
+
return typeof plan === "string" && plan ? plan : void 0;
|
|
142
|
+
} catch {
|
|
143
|
+
return void 0;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
var CLAUDE_USAGE_PROBE_ARGV = ["-p", "/usage", "--output-format", "json", "--no-session-persistence", "--strict-mcp-config"];
|
|
147
|
+
async function claudeUsageReading(environment) {
|
|
148
|
+
const harness = localHarnessForCommand("claude");
|
|
149
|
+
if (!harness) return void 0;
|
|
150
|
+
try {
|
|
151
|
+
const output = await probeCommand(harness, CLAUDE_USAGE_PROBE_ARGV, environment);
|
|
152
|
+
if (output === void 0) return void 0;
|
|
153
|
+
const result = JSON.parse(output).result;
|
|
154
|
+
return typeof result === "string" ? claudeUsageCommandReading(result) : void 0;
|
|
155
|
+
} catch {
|
|
156
|
+
return void 0;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function claudeStreamReading(lineText) {
|
|
160
|
+
if (!lineText.includes("rate_limit_event")) return void 0;
|
|
161
|
+
let parsed;
|
|
162
|
+
try {
|
|
163
|
+
parsed = JSON.parse(lineText);
|
|
164
|
+
} catch {
|
|
165
|
+
return void 0;
|
|
166
|
+
}
|
|
167
|
+
const record = parsed;
|
|
168
|
+
if (record.type !== "rate_limit_event") return void 0;
|
|
169
|
+
return claudeRateLimitReading(record.rate_limit_info);
|
|
170
|
+
}
|
|
171
|
+
function codexRateLimitsReading(rateLimits) {
|
|
172
|
+
const windows = rateLimits && typeof rateLimits === "object" ? rateLimits : void 0;
|
|
173
|
+
const part = (window) => {
|
|
174
|
+
if (typeof window?.usedPercent !== "number" || typeof window.windowDurationMins !== "number") return void 0;
|
|
175
|
+
const resetsAt = window.resetsAt ?? (typeof window.resetsInSeconds === "number" ? Date.now() + window.resetsInSeconds * 1e3 : void 0);
|
|
176
|
+
return usageWindow(usageWindowName(window.windowDurationMins), window.usedPercent, resetsAt);
|
|
177
|
+
};
|
|
178
|
+
return usageReading([part(windows?.primary), part(windows?.secondary)]);
|
|
179
|
+
}
|
|
180
|
+
var labelOnly = (probe) => async (environment) => {
|
|
181
|
+
const label = await probe(environment);
|
|
182
|
+
return label === void 0 ? void 0 : { windows: [], label };
|
|
183
|
+
};
|
|
184
|
+
var NATIVE_USAGE_PROBES = {
|
|
185
|
+
codex: codexUsageReading,
|
|
186
|
+
claude: claudeUsageReading,
|
|
187
|
+
auggie: auggieUsageReading,
|
|
188
|
+
// Free: an ACP extension call, not a turn (grok-usage.ts).
|
|
189
|
+
grok: grokUsageReading,
|
|
190
|
+
// Free reads of the harness's own usage surface (cli-usage-probes.ts).
|
|
191
|
+
copilot: copilotUsageReading,
|
|
192
|
+
antigravity: antigravityUsageReading,
|
|
193
|
+
kimi: kimiUsageReading,
|
|
194
|
+
amp: labelOnly(ampUsageProbe),
|
|
195
|
+
kilo: kiloUsageReading,
|
|
196
|
+
cline: clineUsageReading,
|
|
197
|
+
cursor: cursorUsageReading,
|
|
198
|
+
kiro: kiroUsageReading,
|
|
199
|
+
command: commandCodeUsageReading,
|
|
200
|
+
devin: devinUsageReading,
|
|
201
|
+
hermes: hermesUsageReading,
|
|
202
|
+
vibe: vibeUsageReading
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// src/harness/accounts/stream-usage.ts
|
|
206
|
+
function streamQuotaReading(value) {
|
|
207
|
+
const record = value && typeof value === "object" ? value : void 0;
|
|
208
|
+
if (!record) return void 0;
|
|
209
|
+
const info = record.rate_limit_info ?? record.rateLimitInfo;
|
|
210
|
+
const unified = info && typeof info === "object" ? info.unifiedWindows ?? info.unified_windows : void 0;
|
|
211
|
+
if (unified && typeof unified === "object") {
|
|
212
|
+
const windows = unified;
|
|
213
|
+
const window = (name, key) => {
|
|
214
|
+
const entry = windows[key];
|
|
215
|
+
return usageWindow(
|
|
216
|
+
name,
|
|
217
|
+
typeof entry?.utilization === "number" ? entry.utilization * 100 : void 0,
|
|
218
|
+
entry?.resetsAt ?? entry?.resets_at
|
|
219
|
+
);
|
|
220
|
+
};
|
|
221
|
+
return usageReading([window("5h", "five_hour"), window("weekly", "seven_day")]);
|
|
222
|
+
}
|
|
223
|
+
return codexRateLimitsReading(record.rate_limits ?? record.rateLimits);
|
|
224
|
+
}
|
|
225
|
+
function streamQuotaReadingFromLine(lineText) {
|
|
226
|
+
if (!lineText.includes("rate_limit") && !lineText.includes("rateLimit")) return void 0;
|
|
227
|
+
try {
|
|
228
|
+
return streamQuotaReading(JSON.parse(lineText));
|
|
229
|
+
} catch {
|
|
230
|
+
return void 0;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
var NATIVE_STREAM_USAGE_READINGS = {
|
|
234
|
+
claude: claudeStreamReading
|
|
235
|
+
};
|
|
236
|
+
function accountUsageFrom(entry) {
|
|
237
|
+
return {
|
|
238
|
+
at: new Date(entry.at).toISOString(),
|
|
239
|
+
...entry.label === void 0 ? {} : { label: entry.label },
|
|
240
|
+
...entry.failed ? { failed: true } : {},
|
|
241
|
+
...entry.windows?.length ? { windows: entry.windows } : {}
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
var PUBLISH_INTERVAL_MS = 6e4;
|
|
245
|
+
var published = /* @__PURE__ */ new Map();
|
|
246
|
+
async function publishUsageReading(cacheKey, accountId, reading) {
|
|
247
|
+
const entry = { at: Date.now(), ...reading.label === void 0 ? {} : { label: reading.label }, ...reading.windows.length ? { windows: reading.windows } : {} };
|
|
248
|
+
nativeUsageCache.set(cacheKey, entry);
|
|
249
|
+
if (!accountId) return;
|
|
250
|
+
const slot = published.get(accountId);
|
|
251
|
+
if (slot && entry.at - slot.at < PUBLISH_INTERVAL_MS) {
|
|
252
|
+
slot.latest = entry;
|
|
253
|
+
slot.timer ??= setTimeout(() => {
|
|
254
|
+
slot.timer = void 0;
|
|
255
|
+
const latest = slot.latest;
|
|
256
|
+
slot.latest = void 0;
|
|
257
|
+
if (latest) void storeAccountUsage(accountId, latest).catch(quiet("harness/accounts/stream-usage"));
|
|
258
|
+
}, slot.at + PUBLISH_INTERVAL_MS - entry.at).unref();
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
await storeAccountUsage(accountId, entry);
|
|
262
|
+
}
|
|
263
|
+
async function storeAccountUsage(accountId, entry) {
|
|
264
|
+
const slot = published.get(accountId);
|
|
265
|
+
if (slot) slot.at = Date.now();
|
|
266
|
+
else published.set(accountId, { at: Date.now() });
|
|
267
|
+
const state = await readState({ transcripts: [] });
|
|
268
|
+
const account = state.accounts.find((item) => item.id === accountId);
|
|
269
|
+
if (!account) return;
|
|
270
|
+
account.usage = accountUsageFrom(entry);
|
|
271
|
+
await writeState(state).catch(quiet("harness/accounts/stream-usage"));
|
|
272
|
+
}
|
|
273
|
+
async function recordNativeStreamUsage(session, lineText) {
|
|
274
|
+
if (!session.nativeHarness) return void 0;
|
|
275
|
+
return recordDerivedUsage(session, streamQuotaReadingFromLine(lineText) ?? NATIVE_STREAM_USAGE_READINGS[session.nativeHarness]?.(lineText));
|
|
276
|
+
}
|
|
277
|
+
async function recordDerivedUsage(session, reading) {
|
|
278
|
+
if (!reading?.label) return void 0;
|
|
279
|
+
const cacheKey = usageCacheKey(session.nativeHarness, session.accountId, session.nativeSessionId);
|
|
280
|
+
await publishUsageReading(cacheKey, session.accountId, reading).catch(quiet("harness/accounts/stream-usage"));
|
|
281
|
+
return reading.label;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export {
|
|
285
|
+
codexRateLimitsReading,
|
|
286
|
+
NATIVE_USAGE_PROBES,
|
|
287
|
+
NATIVE_STREAM_USAGE_READINGS,
|
|
288
|
+
accountUsageFrom,
|
|
289
|
+
recordNativeStreamUsage,
|
|
290
|
+
recordDerivedUsage
|
|
291
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/version.ts
|
|
5
|
+
var CLIKCODE_VERSION = "1.0.5" ? "1.0.5" : CLIKCODE_VERSION_FALLBACK;
|
|
6
|
+
var CLIKCODE_USER_AGENT = `ClikCode/${CLIKCODE_VERSION}`;
|
|
7
|
+
var CLIKCODE_COMMIT = "115185099091aac3b85bdc4bd2755a8b375cd019" ? "115185099091aac3b85bdc4bd2755a8b375cd019" : void 0;
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
CLIKCODE_VERSION,
|
|
11
|
+
CLIKCODE_USER_AGENT,
|
|
12
|
+
CLIKCODE_COMMIT
|
|
13
|
+
};
|