clikcode 1.0.3 → 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 +498 -112593
- package/dist/computer-tools.js +36642 -21258
- 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
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ registry, install the same release from GitHub:
|
|
|
58
58
|
`npm install -g https://github.com/Jgracier/ClikCode/releases/latest/download/clikcode.tgz`.
|
|
59
59
|
|
|
60
60
|
For VS Code (and VSCodium, Cursor, Windsurf), the **ClikCode** extension
|
|
61
|
-
(`clikcode.clikcode`, on the Visual Studio Marketplace
|
|
61
|
+
(`clikcode.clikcode`, on the Visual Studio Marketplace) puts the
|
|
62
62
|
same chats in a panel beside your code; it runs the ClikCode you installed.
|
|
63
63
|
The same slash commands work there. Its chat bar shows the account's usage and,
|
|
64
64
|
where turns report a price, what the chat has cost so far ("$1.23 this chat").
|
|
@@ -183,7 +183,7 @@ so ClikCode points those back at your real home. Turns still commit, push and
|
|
|
183
183
|
install as you.
|
|
184
184
|
|
|
185
185
|
Switch by hand with `/account` in a session, or
|
|
186
|
-
`clikcode sessions
|
|
186
|
+
`clikcode sessions command <id> /account <label>`.
|
|
187
187
|
|
|
188
188
|
### An older Intel Mac
|
|
189
189
|
|
|
@@ -347,10 +347,16 @@ command: `/provider` to pick from a list, or its name directly — `/claude`,
|
|
|
347
347
|
The conversation keeps its name, its history and its place in your list. No
|
|
348
348
|
vendor can read another vendor's memory, so ClikCode writes the conversation
|
|
349
349
|
into the new tool's own thread where it knows that tool's format, and sends it
|
|
350
|
-
as context where it does not.
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
On a long thread that costs tokens and a few seconds. Nothing else changes.
|
|
350
|
+
as context where it does not. A conversation larger than the `/compact`
|
|
351
|
+
threshold (or half the new model's window) arrives fitted to it, and the chat
|
|
352
|
+
says "Compacted"; the whole conversation stays in a file the tool is told
|
|
353
|
+
about. On a long thread that costs tokens and a few seconds. Nothing else changes.
|
|
354
|
+
|
|
355
|
+
ClikCode compacts a conversation by itself once its context passes the
|
|
356
|
+
`/compact` threshold, between turns, using each tool's own compaction (Claude
|
|
357
|
+
Code's `/compact`, Codex's compact operation, Gemini's and Aider's own
|
|
358
|
+
thresholds, ...). A tool with none gets the conversation retold in a fresh
|
|
359
|
+
thread, fitted to half the threshold.
|
|
354
360
|
|
|
355
361
|
## MCP servers for ClikCode's own agent
|
|
356
362
|
|
|
@@ -365,6 +371,11 @@ clikcode mcp login <name> # OAuth sign-in to a remote server
|
|
|
365
371
|
clikcode mcp logout <name> # forget that sign-in
|
|
366
372
|
```
|
|
367
373
|
|
|
374
|
+
An open ClikCode chat detects changes to this shared MCP configuration and
|
|
375
|
+
quietly restarts at the next idle prompt, reopening the same conversation with
|
|
376
|
+
the updated servers. A running turn finishes first; if the window never goes
|
|
377
|
+
idle, `/restart` switches it when you choose.
|
|
378
|
+
|
|
368
379
|
A tool's own servers are managed with that tool's own commands (`/mcp` in a
|
|
369
380
|
conversation on it).
|
|
370
381
|
|
|
@@ -388,18 +399,18 @@ when you would rather type than pick.
|
|
|
388
399
|
| `clikcode accounts login <tool> [--label <label>]` | Run that tool's own login, kept separate from your others |
|
|
389
400
|
| `clikcode accounts list` / `status` / `logout` / `remove` | Your accounts: what they are called, and what is left on each |
|
|
390
401
|
| `clikcode models` | The models your local accounts offer |
|
|
391
|
-
| `clikcode usage` |
|
|
402
|
+
| `clikcode usage` | What `/usage all` shows: each provider's accounts, turns, tokens and cost, then the last seven days (what is left on each account is `accounts list`) |
|
|
392
403
|
| `clikcode sessions list` / `show` / `create` / `resume` (also `open`) / `send` / `command` / `set` / `close` | Your conversations, including ones a tool started on its own; `command <id> <slash…>` runs a slash command on one |
|
|
393
404
|
| `clikcode send <prompt> [--chat <id\|name\|last>] [--harness <tool>] [--model <model>] [--permissions <mode>]` | Send one message without opening a session: a new chat, or continue one |
|
|
394
405
|
| `clikcode search <words>` | Find the conversations that mention something, any provider, most mentions first; `--json` gives each hit and its first mention |
|
|
395
406
|
| `clikcode logs [--session <id>] [--role <role>] [--since 10m] [-f]` | What every ClikCode window, worker and editor bridge did, in order; the first place to look when something went wrong |
|
|
396
|
-
| `clikcode permissions [ask\|bypass\|auto]` | Approval behavior for
|
|
407
|
+
| `clikcode permissions [ask\|bypass\|auto] [--chat <chat>]` | Approval behavior: the default for new chats, or one chat's with `--chat <chat>` |
|
|
397
408
|
| `clikcode computer on` / `off` / `status` / `inspect` / `login [url] [--new]` / `logins` | Browser and desktop use for ClikCode's agent, and its private sign-in: see `docs/COMPUTER_USE.md` |
|
|
398
409
|
| `clikcode mcp add` / `list` / `remove` / `login` / `logout` | MCP servers for ClikCode's own agent (below) |
|
|
399
410
|
| `clikcode plugin list` / `enable <plugin>` / `disable <plugin>` | Which of Claude Code's plugins ClikCode's own agent uses |
|
|
400
411
|
| `clikcode acp add <command> <binary> [-- <flags>]` / `acp list` / `acp remove` | An ACP agent the catalog does not ship |
|
|
401
|
-
| `clikcode gateway login [--github]` / `gateway status` / `
|
|
402
|
-
| `clikcode gateway
|
|
412
|
+
| `clikcode gateway login [--github]` / `gateway status` / `clikcode models --gateway` | ClikDeploy Gateway sign-in (Google by default), and the models it offers |
|
|
413
|
+
| `clikcode usage --gateway [--days N]` | Your AI use and credit as ClikDeploy Gateway records it: every call, by surface and model |
|
|
403
414
|
| `clikcode gateway credit [--amount USD]` | Add AI credit: opens a Stripe checkout ($5–$500). Paying it also saves your card for automatic top-ups when credit runs low |
|
|
404
415
|
| `clikcode gateway credit --auto-topup on\|off` | Turn those automatic top-ups on or off |
|
|
405
416
|
|
|
@@ -428,7 +439,7 @@ conversation board — so it pins eleven; typed, `/resume` still works.)
|
|
|
428
439
|
| `/model [name]` | choose or set a model |
|
|
429
440
|
| `/hosted ai` | search Hugging Face and run a hosted AI model on ClikDeploy compute |
|
|
430
441
|
| `/machine` | the machine this chat runs on: move it, add one, or update or remove one |
|
|
431
|
-
| `/restart` |
|
|
442
|
+
| `/restart` | reload this window after a ClikCode build or shared tool configuration changes; the chat stays and what is running keeps running |
|
|
432
443
|
| `/new [first message]` | start a fresh conversation (the current one stays resumable) |
|
|
433
444
|
| `/permissions [ask\|bypass\|auto]` (also `/permission`) | approval behavior |
|
|
434
445
|
| `/settings` | configure this workspace (below) |
|
|
@@ -444,7 +455,7 @@ reference reads better that way. All of them, grouped as `/help` groups them:
|
|
|
444
455
|
| Command | What it does |
|
|
445
456
|
| --- | --- |
|
|
446
457
|
| `/new [first message]` (also `/clear`, `/reset`) | start a fresh conversation (the current one stays resumable) |
|
|
447
|
-
| `/compact [
|
|
458
|
+
| `/compact [tokens]` | compact this conversation now, with the tool's own compaction; `/compact 150k` sets the size at which ClikCode compacts every conversation by itself (default 150k tokens) |
|
|
448
459
|
| `/history` | show this conversation; a summary carried for its opening turns comes first |
|
|
449
460
|
| `/hindsight` | this conversation cut into topics, newest first, with the files each one changed, numbered by your prompts — the numbers `/fork @N` and `/redo @N` take |
|
|
450
461
|
| `/copy` | copy the last answer |
|
|
@@ -609,9 +620,9 @@ If you want to work on ClikCode itself:
|
|
|
609
620
|
|
|
610
621
|
```sh
|
|
611
622
|
pnpm install
|
|
612
|
-
pnpm build # dist/index.js (the entry), cli.js, harness-catalog.cjs, ai-router-runtime.cjs
|
|
623
|
+
pnpm build # dist/index.js (the entry), cli.js, harness-catalog.cjs, ai-router-runtime.cjs;
|
|
624
|
+
# fails on a missing or extra runtime dependency
|
|
613
625
|
pnpm build:analyze # + bundle report: top inputs by bytes, runtime packages
|
|
614
|
-
pnpm build:strict # + fail on a missing or extra runtime dependency
|
|
615
626
|
pnpm type-check # tsc over src/ and over packages/clikrouter
|
|
616
627
|
pnpm test # the ClikCode suite
|
|
617
628
|
pnpm test:router # the router package's suite
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
PROVIDER_ORDER,
|
|
5
|
+
VALID_EFFORTS,
|
|
6
|
+
VALID_PERMISSION_MODES,
|
|
7
|
+
applyDefaultSetting,
|
|
8
|
+
chatNamed,
|
|
9
|
+
compareProviders,
|
|
10
|
+
conversationOption,
|
|
11
|
+
conversationPreview,
|
|
12
|
+
hasConversationContent,
|
|
13
|
+
integrationLabel,
|
|
14
|
+
isBlankConversation,
|
|
15
|
+
latestChat,
|
|
16
|
+
normalizeModelWord,
|
|
17
|
+
optionForControl,
|
|
18
|
+
optionForHarness,
|
|
19
|
+
parseHarnessOption,
|
|
20
|
+
sessionPermissionModes,
|
|
21
|
+
setSessionHarnessOption
|
|
22
|
+
} from "./chunk-TWCVV2JO.js";
|
|
23
|
+
import "./chunk-PDPEM5VW.js";
|
|
24
|
+
import "./chunk-WWLJMP6D.js";
|
|
25
|
+
import "./chunk-CRUVYGO2.js";
|
|
26
|
+
import "./chunk-FF7ZVYJF.js";
|
|
27
|
+
import "./chunk-IMLTL2MY.js";
|
|
28
|
+
import "./chunk-BUOPJQP5.js";
|
|
29
|
+
import "./chunk-3B2CHX7M.js";
|
|
30
|
+
import "./chunk-RVUOIJXN.js";
|
|
31
|
+
import "./chunk-QUS4ER2W.js";
|
|
32
|
+
import "./chunk-DQYVQ2N7.js";
|
|
33
|
+
import "./chunk-KYUHIFP3.js";
|
|
34
|
+
import "./chunk-RSZGEL5U.js";
|
|
35
|
+
import "./chunk-CQ7J6UQ7.js";
|
|
36
|
+
import "./chunk-XKW5NDMR.js";
|
|
37
|
+
import "./chunk-W3YYPBEA.js";
|
|
38
|
+
import "./chunk-XIBYREEY.js";
|
|
39
|
+
import "./chunk-EE4B6A7W.js";
|
|
40
|
+
import "./chunk-WZYVLUVQ.js";
|
|
41
|
+
import "./chunk-KHW6TX6I.js";
|
|
42
|
+
import "./chunk-YMCH3L2S.js";
|
|
43
|
+
import "./chunk-4QZEZME7.js";
|
|
44
|
+
import "./chunk-LVRRWP4W.js";
|
|
45
|
+
import "./chunk-G3QP67Z7.js";
|
|
46
|
+
import "./chunk-4L2ZZM4Q.js";
|
|
47
|
+
import "./chunk-F6F47QAY.js";
|
|
48
|
+
import "./chunk-RDDWQBEM.js";
|
|
49
|
+
import "./chunk-MPAJ446F.js";
|
|
50
|
+
import "./chunk-CBANJFBO.js";
|
|
51
|
+
import "./chunk-PWXII6HF.js";
|
|
52
|
+
export {
|
|
53
|
+
PROVIDER_ORDER,
|
|
54
|
+
VALID_EFFORTS,
|
|
55
|
+
VALID_PERMISSION_MODES,
|
|
56
|
+
applyDefaultSetting,
|
|
57
|
+
chatNamed,
|
|
58
|
+
compareProviders,
|
|
59
|
+
conversationOption,
|
|
60
|
+
conversationPreview,
|
|
61
|
+
hasConversationContent,
|
|
62
|
+
integrationLabel,
|
|
63
|
+
isBlankConversation,
|
|
64
|
+
latestChat,
|
|
65
|
+
normalizeModelWord,
|
|
66
|
+
optionForControl,
|
|
67
|
+
optionForHarness,
|
|
68
|
+
parseHarnessOption,
|
|
69
|
+
sessionPermissionModes,
|
|
70
|
+
setSessionHarnessOption
|
|
71
|
+
};
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
profileEmail
|
|
5
|
+
} from "./chunk-4GXAO3UY.js";
|
|
6
|
+
import {
|
|
7
|
+
saveTask
|
|
8
|
+
} from "./chunk-SNU37TQI.js";
|
|
9
|
+
import {
|
|
10
|
+
claimMessage,
|
|
11
|
+
isClaimed
|
|
12
|
+
} from "./chunk-XAHGBPWT.js";
|
|
13
|
+
import {
|
|
14
|
+
sleep
|
|
15
|
+
} from "./chunk-YMCH3L2S.js";
|
|
16
|
+
import {
|
|
17
|
+
CredentialError,
|
|
18
|
+
deleteNamedSecret,
|
|
19
|
+
namedSecretNames,
|
|
20
|
+
readNamedSecret,
|
|
21
|
+
saveNamedSecret,
|
|
22
|
+
savedLoginsForSite
|
|
23
|
+
} from "./chunk-I75EDU75.js";
|
|
24
|
+
import {
|
|
25
|
+
quiet
|
|
26
|
+
} from "./chunk-RDDWQBEM.js";
|
|
27
|
+
|
|
28
|
+
// src/agent/computer/email-api.ts
|
|
29
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
30
|
+
import http from "node:http";
|
|
31
|
+
|
|
32
|
+
// src/agent/computer/parking.ts
|
|
33
|
+
function vendorOf(site) {
|
|
34
|
+
try {
|
|
35
|
+
const parts = new URL(site).hostname.replace(/^www\./, "").split(".");
|
|
36
|
+
const name = parts.length > 2 && ["co", "com", "org", "net"].includes(parts.at(-2)) ? parts.at(-3) : parts.at(-2) ?? parts[0];
|
|
37
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").slice(0, 60) || "unknown";
|
|
38
|
+
} catch {
|
|
39
|
+
return "unknown";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function reasonFor(fields) {
|
|
43
|
+
const labels = fields.map((field) => field.label.toLowerCase()).join(" ");
|
|
44
|
+
if (/captcha|robot|not a robot/.test(labels)) return "captcha";
|
|
45
|
+
if (fields.some((field) => field.transient) || /\b(code|verification|authenticator|otp|2fa|two-factor)\b/.test(labels)) return "two-factor";
|
|
46
|
+
if (/\b(phone|sms|text message)\b/.test(labels)) return "sms";
|
|
47
|
+
return "other";
|
|
48
|
+
}
|
|
49
|
+
var Parked = class extends Error {
|
|
50
|
+
};
|
|
51
|
+
async function park(stateDir, site, fields, why) {
|
|
52
|
+
const vendor = vendorOf(site);
|
|
53
|
+
const asks = fields.map((field) => field.label).join(", ").slice(0, 200);
|
|
54
|
+
await saveTask(stateDir, { vendor, kind: "other", status: "needs-human", reason: reasonFor(fields), note: `needs from you: ${asks}${why ? ` (${why})` : ""}` });
|
|
55
|
+
throw new Parked(`Parked: ${vendor} needs ${asks} from the user${why ? ` (${why})` : ""}. It is recorded in the queue as needs-human. Do not ask the user; go on to the next vendor.`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/agent/computer/email-api.ts
|
|
59
|
+
var EMAIL_TOKEN_SECRET = "email/gmail";
|
|
60
|
+
var EMAIL_CLIENT_SECRET = "email/google-client";
|
|
61
|
+
var GMAIL_SCOPE = "https://www.googleapis.com/auth/gmail.readonly";
|
|
62
|
+
var GOOGLE = {
|
|
63
|
+
auth: "https://accounts.google.com/o/oauth2/v2/auth",
|
|
64
|
+
token: "https://oauth2.googleapis.com/token",
|
|
65
|
+
gmail: "https://gmail.googleapis.com/gmail/v1/users/me"
|
|
66
|
+
};
|
|
67
|
+
var cached = /* @__PURE__ */ new Map();
|
|
68
|
+
async function emailClient(stateDir) {
|
|
69
|
+
try {
|
|
70
|
+
const client = JSON.parse(await readNamedSecret(stateDir, EMAIL_CLIENT_SECRET));
|
|
71
|
+
if (client.clientId && client.clientSecret) return { clientId: client.clientId, clientSecret: client.clientSecret };
|
|
72
|
+
} catch {
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const clientId2 = await readNamedSecret(stateDir, `${EMAIL_CLIENT_SECRET}-id`), clientSecret2 = await readNamedSecret(stateDir, `${EMAIL_CLIENT_SECRET}-secret`);
|
|
76
|
+
if (clientId2 && clientSecret2) return { clientId: clientId2, clientSecret: clientSecret2 };
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
const clientId = process.env.CLIKCODE_GOOGLE_CLIENT_ID, clientSecret = process.env.CLIKCODE_GOOGLE_CLIENT_SECRET;
|
|
80
|
+
if (clientId && clientSecret) return { clientId, clientSecret };
|
|
81
|
+
throw new CredentialError(`No Google OAuth client is set up for email. Save a Desktop-app client as the secrets "${EMAIL_CLIENT_SECRET}-id" and "${EMAIL_CLIENT_SECRET}-secret" (or one JSON secret "${EMAIL_CLIENT_SECRET}") or set CLIKCODE_GOOGLE_CLIENT_ID and CLIKCODE_GOOGLE_CLIENT_SECRET.`);
|
|
82
|
+
}
|
|
83
|
+
var norm = (address) => address.trim().toLowerCase();
|
|
84
|
+
var MAILBOX_PREFIX = "email/gmail/";
|
|
85
|
+
function mailboxSecretName(address) {
|
|
86
|
+
const slug = norm(address).replace(/[^a-z0-9._-]/g, "_");
|
|
87
|
+
return `${MAILBOX_PREFIX}${slug.length <= 40 ? slug : createHash("sha256").update(norm(address)).digest("hex").slice(0, 40)}`;
|
|
88
|
+
}
|
|
89
|
+
async function readStored(stateDir, name) {
|
|
90
|
+
try {
|
|
91
|
+
const s = JSON.parse(await readNamedSecret(stateDir, name));
|
|
92
|
+
return s.refreshToken && s.email ? s : void 0;
|
|
93
|
+
} catch {
|
|
94
|
+
return void 0;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async function saveStored(stateDir, s) {
|
|
98
|
+
await saveNamedSecret(stateDir, mailboxSecretName(s.email), JSON.stringify(s), { vendor: "gmail", owner: s.email, env: "oauth" });
|
|
99
|
+
}
|
|
100
|
+
async function migrateLegacy(stateDir) {
|
|
101
|
+
const old = await readStored(stateDir, EMAIL_TOKEN_SECRET);
|
|
102
|
+
if (!old) return;
|
|
103
|
+
if (!await readStored(stateDir, mailboxSecretName(old.email))) await saveStored(stateDir, old);
|
|
104
|
+
await deleteNamedSecret(stateDir, EMAIL_TOKEN_SECRET).catch(quiet("agent/computer/email-api"));
|
|
105
|
+
}
|
|
106
|
+
async function allStored(stateDir) {
|
|
107
|
+
await migrateLegacy(stateDir);
|
|
108
|
+
const names = (await namedSecretNames(stateDir).catch(() => [])).filter((name) => name.toLowerCase().startsWith(MAILBOX_PREFIX));
|
|
109
|
+
const out = [];
|
|
110
|
+
for (const name of names) {
|
|
111
|
+
const s = await readStored(stateDir, name);
|
|
112
|
+
if (s) out.push(s);
|
|
113
|
+
}
|
|
114
|
+
return out.sort((a, b) => a.email.localeCompare(b.email));
|
|
115
|
+
}
|
|
116
|
+
async function defaultStored(stateDir, all) {
|
|
117
|
+
const mine = (await profileEmail(stateDir).catch(quiet("agent/computer/email-api")))?.trim().toLowerCase();
|
|
118
|
+
return all.find((s) => norm(s.email) === mine) ?? all[0];
|
|
119
|
+
}
|
|
120
|
+
async function emailStatus(stateDir) {
|
|
121
|
+
const all = await allStored(stateDir);
|
|
122
|
+
const def = await defaultStored(stateDir, all);
|
|
123
|
+
if (!def) return { connected: false, mailboxes: [] };
|
|
124
|
+
return { connected: true, email: def.email, connectedAt: def.connectedAt, mailboxes: all.map((s) => ({ email: s.email, connectedAt: s.connectedAt, default: s === def })) };
|
|
125
|
+
}
|
|
126
|
+
async function emailConnected(stateDir, address) {
|
|
127
|
+
const all = await allStored(stateDir);
|
|
128
|
+
return address ? all.some((s) => norm(s.email) === norm(address)) : all.length > 0;
|
|
129
|
+
}
|
|
130
|
+
async function disconnectEmail(stateDir, address) {
|
|
131
|
+
const all = await allStored(stateDir);
|
|
132
|
+
let removed = false;
|
|
133
|
+
for (const s of all.filter((item) => !address || norm(item.email) === norm(address))) {
|
|
134
|
+
cached.delete(cacheKey(stateDir, s.email));
|
|
135
|
+
removed = await deleteNamedSecret(stateDir, mailboxSecretName(s.email)) || removed;
|
|
136
|
+
}
|
|
137
|
+
return removed;
|
|
138
|
+
}
|
|
139
|
+
var cacheKey = (stateDir, address) => `${stateDir}\0${norm(address)}`;
|
|
140
|
+
async function pickMailbox(stateDir, options = {}) {
|
|
141
|
+
const all = await allStored(stateDir);
|
|
142
|
+
if (options.address) {
|
|
143
|
+
const hit = all.find((s) => norm(s.email) === norm(options.address));
|
|
144
|
+
if (!hit) throw new CredentialError(`${options.address} is not a connected mailbox.${all.length ? ` Connected: ${all.map((s) => s.email).join(", ")}.` : ""} Connect it with email_connect (address), or \`clikcode computer email connect --address ${options.address}\`.`);
|
|
145
|
+
return hit.email;
|
|
146
|
+
}
|
|
147
|
+
for (const hint of options.hints ?? []) {
|
|
148
|
+
const hit = hint && all.find((s) => norm(s.email) === norm(hint));
|
|
149
|
+
if (hit) return hit.email;
|
|
150
|
+
}
|
|
151
|
+
const def = await defaultStored(stateDir, all);
|
|
152
|
+
if (!def) throw new CredentialError("No mailbox is connected. Run `clikcode computer email connect`, or the browser tool action email_connect.");
|
|
153
|
+
return def.email;
|
|
154
|
+
}
|
|
155
|
+
async function loginAddresses(stateDir, site) {
|
|
156
|
+
try {
|
|
157
|
+
return (await savedLoginsForSite(stateDir, site)).filter((login) => !login.rejected).map((login) => login.label);
|
|
158
|
+
} catch {
|
|
159
|
+
return [];
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
var b64u = (bytes) => bytes.toString("base64url");
|
|
163
|
+
async function startConsent(stateDir, options = {}) {
|
|
164
|
+
const endpoints = options.endpoints ?? GOOGLE;
|
|
165
|
+
const client = await emailClient(stateDir);
|
|
166
|
+
const verifier = b64u(randomBytes(32));
|
|
167
|
+
const challenge = b64u(createHash("sha256").update(verifier).digest());
|
|
168
|
+
const state = b64u(randomBytes(16));
|
|
169
|
+
let finish, fail;
|
|
170
|
+
const done = new Promise((resolve, reject) => {
|
|
171
|
+
finish = resolve;
|
|
172
|
+
fail = reject;
|
|
173
|
+
});
|
|
174
|
+
done.catch(quiet("agent/computer/email-api"));
|
|
175
|
+
const server = http.createServer((req, res) => {
|
|
176
|
+
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
177
|
+
if (url.pathname !== "/callback") {
|
|
178
|
+
res.writeHead(404).end();
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const page = (text) => {
|
|
182
|
+
res.writeHead(200, { "content-type": "text/html; charset=utf-8" }).end(`<!doctype html><title>ClikCode</title><body style="font:16px system-ui;margin:3rem">${text}</body>`);
|
|
183
|
+
};
|
|
184
|
+
const code = url.searchParams.get("code");
|
|
185
|
+
if (url.searchParams.get("state") !== state || !code) {
|
|
186
|
+
page("Email was not connected. You can close this tab.");
|
|
187
|
+
fail(new Error(url.searchParams.get("error") ? `Google did not grant access (${url.searchParams.get("error")}).` : "The redirect did not match this request."));
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
exchange(stateDir, client, code, verifier, redirect(server), endpoints).then(
|
|
191
|
+
(email) => {
|
|
192
|
+
page("Email connected. You can close this tab.");
|
|
193
|
+
finish({ email });
|
|
194
|
+
},
|
|
195
|
+
(error) => {
|
|
196
|
+
page("Email was not connected. You can close this tab.");
|
|
197
|
+
fail(error);
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
});
|
|
201
|
+
await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
202
|
+
const timer = setTimeout(() => fail(new Error("Consent was not completed in time.")), options.timeoutMs ?? 18e4);
|
|
203
|
+
timer.unref();
|
|
204
|
+
const close = () => {
|
|
205
|
+
clearTimeout(timer);
|
|
206
|
+
server.close();
|
|
207
|
+
server.closeAllConnections?.();
|
|
208
|
+
};
|
|
209
|
+
done.then(close, close);
|
|
210
|
+
const params = new URLSearchParams({ client_id: client.clientId, redirect_uri: redirect(server), response_type: "code", scope: GMAIL_SCOPE, access_type: "offline", prompt: "consent", state, code_challenge: challenge, code_challenge_method: "S256", ...options.loginHint ? { login_hint: options.loginHint } : {} });
|
|
211
|
+
return { url: `${endpoints.auth}?${params}`, done, cancel: () => fail(new Error("Consent was cancelled.")) };
|
|
212
|
+
}
|
|
213
|
+
function redirect(server) {
|
|
214
|
+
return `http://127.0.0.1:${server.address().port}/callback`;
|
|
215
|
+
}
|
|
216
|
+
async function exchange(stateDir, client, code, verifier, redirectUri, endpoints) {
|
|
217
|
+
const res = await fetch(endpoints.token, {
|
|
218
|
+
method: "POST",
|
|
219
|
+
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
220
|
+
signal: AbortSignal.timeout(2e4),
|
|
221
|
+
body: new URLSearchParams({ code, client_id: client.clientId, client_secret: client.clientSecret, redirect_uri: redirectUri, grant_type: "authorization_code", code_verifier: verifier })
|
|
222
|
+
});
|
|
223
|
+
const body = await res.json().catch(() => ({}));
|
|
224
|
+
if (!res.ok || !body.access_token) throw new Error(`Google refused the code (${body.error ?? res.status}).`);
|
|
225
|
+
if (!body.refresh_token) throw new Error("Google gave no refresh token; remove the app at myaccount.google.com/permissions and connect again.");
|
|
226
|
+
const profile = await (await fetch(`${endpoints.gmail}/profile`, { headers: { authorization: `Bearer ${body.access_token}` }, signal: AbortSignal.timeout(2e4) })).json().catch(() => ({}));
|
|
227
|
+
const email = profile.emailAddress ?? "";
|
|
228
|
+
if (!email) throw new Error("Google did not say which account this consent was for, so it was not saved.");
|
|
229
|
+
await saveStored(stateDir, { refreshToken: body.refresh_token, email, connectedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
230
|
+
cached.set(cacheKey(stateDir, email), { token: body.access_token, expires: Date.now() + (body.expires_in ?? 3e3) * 1e3 - 6e4 });
|
|
231
|
+
return email;
|
|
232
|
+
}
|
|
233
|
+
async function accessToken(stateDir, endpoints, address, signal) {
|
|
234
|
+
const live = address ? cached.get(cacheKey(stateDir, address)) : void 0;
|
|
235
|
+
if (live && live.expires > Date.now()) return live.token;
|
|
236
|
+
const email = await pickMailbox(stateDir, { address });
|
|
237
|
+
const hit = cached.get(cacheKey(stateDir, email));
|
|
238
|
+
if (hit && hit.expires > Date.now()) return hit.token;
|
|
239
|
+
const saved = (await allStored(stateDir)).find((s) => norm(s.email) === norm(email));
|
|
240
|
+
const client = await emailClient(stateDir);
|
|
241
|
+
const res = await fetch(endpoints.token, {
|
|
242
|
+
method: "POST",
|
|
243
|
+
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
244
|
+
signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(2e4)]) : AbortSignal.timeout(2e4),
|
|
245
|
+
body: new URLSearchParams({ client_id: client.clientId, client_secret: client.clientSecret, refresh_token: saved.refreshToken, grant_type: "refresh_token" })
|
|
246
|
+
});
|
|
247
|
+
const body = await res.json().catch(() => ({}));
|
|
248
|
+
if (!res.ok || !body.access_token) {
|
|
249
|
+
if (body.error === "invalid_grant") throw new CredentialError(`Google no longer accepts the saved consent for ${saved.email} (an app still in testing mode expires it after 7 days). Reconnect with \`clikcode computer email connect --address ${saved.email}\`.`);
|
|
250
|
+
throw new Error(`Google would not refresh the mailbox token (${body.error ?? res.status}).`);
|
|
251
|
+
}
|
|
252
|
+
cached.set(cacheKey(stateDir, saved.email), { token: body.access_token, expires: Date.now() + (body.expires_in ?? 3e3) * 1e3 - 6e4 });
|
|
253
|
+
return body.access_token;
|
|
254
|
+
}
|
|
255
|
+
var decode = (data) => data ? Buffer.from(data, "base64url").toString("utf8") : "";
|
|
256
|
+
function collect(part, kind, out = []) {
|
|
257
|
+
if (!part) return out;
|
|
258
|
+
if (part.mimeType === kind && part.body?.data) out.push(decode(part.body.data));
|
|
259
|
+
for (const child of part.parts ?? []) collect(child, kind, out);
|
|
260
|
+
return out;
|
|
261
|
+
}
|
|
262
|
+
function htmlToText(html) {
|
|
263
|
+
return html.replace(/<(?:style|script)[\s\S]*?<\/(?:style|script)>/gi, " ").replace(/<[^>]+>/g, " ").replace(/ /g, " ").replace(/&/g, "&").replace(/'/g, "'").replace(/"/g, '"').replace(/\s+/g, " ").trim();
|
|
264
|
+
}
|
|
265
|
+
var HREF = /href\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s>"']+))/gi;
|
|
266
|
+
var hrefValue = (m) => (m[1] ?? m[2] ?? m[3] ?? "").replace(/&/g, "&");
|
|
267
|
+
function mailText(plain, html) {
|
|
268
|
+
const own = plain.trim();
|
|
269
|
+
if (!html) return own;
|
|
270
|
+
const fromHtml = htmlToText(html);
|
|
271
|
+
return own.length >= 40 || own.length >= fromHtml.length ? own || fromHtml : fromHtml;
|
|
272
|
+
}
|
|
273
|
+
function hrefs(html) {
|
|
274
|
+
return [...html.matchAll(HREF)].map(hrefValue).filter((href) => /^https:/.test(href));
|
|
275
|
+
}
|
|
276
|
+
function textLinks(plain) {
|
|
277
|
+
return [...plain.matchAll(/https:\/\/[^\s<>()"']+/g)].map((m) => m[0].replace(/[.,;:!?]+$/, ""));
|
|
278
|
+
}
|
|
279
|
+
function anchors(html) {
|
|
280
|
+
return [...html.matchAll(/<a\b([^>]*)>([\s\S]*?)<\/a>/gi)].flatMap((m) => {
|
|
281
|
+
const found = [...m[1].matchAll(HREF)][0];
|
|
282
|
+
const href = found ? hrefValue(found) : void 0;
|
|
283
|
+
if (!href || !/^https:/.test(href)) return [];
|
|
284
|
+
const text = htmlToText(m[2].replace(/<img\b[^>]*alt\s*=\s*["']([^"']*)["'][^>]*>/gi, " $1 "));
|
|
285
|
+
return [{ href, text, .../button|btn|padding\s*:\s*\d|border-radius|background(?:-color)?\s*:/i.test(m[1]) ? { button: true } : {}, .../<img\b/i.test(m[2]) && !htmlToText(m[2].replace(/<img\b[^>]*>/gi, "")) ? { image: true } : {} }];
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
var EmailAmbiguous = class extends Error {
|
|
289
|
+
};
|
|
290
|
+
var MARKETING = /newsletter|webinar|new features|what'?s new|\bpromo(?:tion(?:al)?)?s?\b|% off|\bsale\b|digest|unsubscribe from (?:these|all)/i;
|
|
291
|
+
var isMarketing = (mail) => MARKETING.test(mail.subject) || MARKETING.test(mail.text.slice(0, 200));
|
|
292
|
+
var BODY_START = 400;
|
|
293
|
+
var BODY_START_WIDE = 1500;
|
|
294
|
+
function senderMatch(mail, site, options = {}) {
|
|
295
|
+
const name = vendorOf(site);
|
|
296
|
+
const forms = [.../* @__PURE__ */ new Set([name, name.replace(/-/g, ""), name.replace(/-/g, " ")])].filter((form) => form.length >= 3 && form !== "unknown");
|
|
297
|
+
const from = mail.from.toLowerCase();
|
|
298
|
+
const domain = /@([^>\s]+)/.exec(from)?.[1] ?? "";
|
|
299
|
+
const display = from.replace(/<.*$/, "");
|
|
300
|
+
const flat = (text) => text.toLowerCase().replace(/[^a-z0-9]+/g, " ");
|
|
301
|
+
const inDomain = forms.some((form) => domain.replace(/[^a-z0-9]/g, "").includes(form.replace(/[^a-z0-9]/g, "")));
|
|
302
|
+
if (inDomain || forms.some((form) => flat(display).includes(flat(form)))) return { tier: 1, domain };
|
|
303
|
+
if (forms.some((form) => flat(mail.subject).includes(flat(form)))) return { tier: 2, domain };
|
|
304
|
+
if (forms.some((form) => flat(mail.text.slice(0, options.widen ? BODY_START_WIDE : BODY_START)).includes(flat(form)))) return { tier: 3, domain };
|
|
305
|
+
return { tier: 0, domain };
|
|
306
|
+
}
|
|
307
|
+
async function waitForEmail(stateDir, query) {
|
|
308
|
+
if (!query.from && !query.subject && !query.site) throw new Error("Name the sender (from), words from the subject, or the site the email is for.");
|
|
309
|
+
const address = await pickMailbox(stateDir, { address: query.address });
|
|
310
|
+
const endpoints = query.endpoints ?? GOOGLE;
|
|
311
|
+
const since = query.since ?? Date.now() - 15 * 6e4;
|
|
312
|
+
const q = [query.from ? `from:(${query.from})` : "", query.subject ? `subject:(${query.subject})` : "", `after:${Math.floor(since / 1e3) - 1}`].filter(Boolean).join(" ");
|
|
313
|
+
const timeoutMs = query.timeoutMs ?? 9e4;
|
|
314
|
+
const deadline = Date.now() + timeoutMs;
|
|
315
|
+
const timeout = () => new Error(`No email matched ${query.site ? `an email for ${vendorOf(query.site)}` : q} within ${Math.round(timeoutMs / 1e3)} seconds.`);
|
|
316
|
+
const budget = AbortSignal.timeout(Math.max(1, timeoutMs));
|
|
317
|
+
const signal = query.signal ? AbortSignal.any([query.signal, budget]) : budget;
|
|
318
|
+
const readMessages = /* @__PURE__ */ new Map();
|
|
319
|
+
try {
|
|
320
|
+
for (; ; ) {
|
|
321
|
+
signal.throwIfAborted();
|
|
322
|
+
const token = await accessToken(stateDir, endpoints, address, signal);
|
|
323
|
+
const headers = { authorization: `Bearer ${token}` };
|
|
324
|
+
let found = [];
|
|
325
|
+
let pageToken;
|
|
326
|
+
const pages = /* @__PURE__ */ new Set();
|
|
327
|
+
do {
|
|
328
|
+
signal.throwIfAborted();
|
|
329
|
+
const list = await fetch(`${endpoints.gmail}/messages?${new URLSearchParams({ q, maxResults: "100", ...pageToken ? { pageToken } : {}, ...query.spam ? { includeSpamTrash: "true" } : {} })}`, { headers, signal });
|
|
330
|
+
if (!list.ok) throw new Error(`Gmail would not list messages (HTTP ${list.status}).`);
|
|
331
|
+
const page = await list.json();
|
|
332
|
+
for (const { id } of page.messages ?? []) {
|
|
333
|
+
const claimId = `${norm(address)}:${id}`;
|
|
334
|
+
if (query.consume && (await isClaimed(stateDir, claimId) || await isClaimed(stateDir, id))) continue;
|
|
335
|
+
const prior = readMessages.get(id);
|
|
336
|
+
if (prior) {
|
|
337
|
+
found.push(prior);
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
const res = await fetch(`${endpoints.gmail}/messages/${encodeURIComponent(id)}?format=full`, { headers, signal });
|
|
341
|
+
if (!res.ok) throw new Error(`Gmail would not read a message (HTTP ${res.status}).`);
|
|
342
|
+
const message = await res.json();
|
|
343
|
+
const header = (name) => message.payload?.headers?.find((h) => h.name.toLowerCase() === name)?.value ?? "";
|
|
344
|
+
const html = collect(message.payload, "text/html").join("\n");
|
|
345
|
+
const plain = collect(message.payload, "text/plain").join("\n");
|
|
346
|
+
found.push({ id, from: header("from"), subject: header("subject"), text: mailText(plain, html), links: [.../* @__PURE__ */ new Set([...hrefs(html), ...textLinks(plain)])], anchors: anchors(html), receivedAt: Number(message.internalDate ?? 0), mailbox: address });
|
|
347
|
+
readMessages.set(id, found[found.length - 1]);
|
|
348
|
+
}
|
|
349
|
+
pageToken = page.nextPageToken;
|
|
350
|
+
if (pageToken && pages.has(pageToken)) throw new Error("Gmail repeated a message page token.");
|
|
351
|
+
if (pageToken) pages.add(pageToken);
|
|
352
|
+
} while (pageToken);
|
|
353
|
+
found = found.filter((mail) => mail.receivedAt >= since && (!query.accept || query.accept(mail)));
|
|
354
|
+
if (query.site) {
|
|
355
|
+
const widen = found.filter((mail) => !isMarketing(mail)).length === 1;
|
|
356
|
+
const scored = found.map((mail) => ({ mail, ...senderMatch(mail, query.site, { widen }) })).filter((item) => item.tier > 0);
|
|
357
|
+
const best = Math.min(...scored.map((item) => item.tier), 9);
|
|
358
|
+
found = scored.filter((item) => item.tier === best).map((item) => item.mail);
|
|
359
|
+
const senders = new Set(found.map((mail) => /@([^>\s]+)/.exec(mail.from.toLowerCase())?.[1] ?? mail.from));
|
|
360
|
+
if (senders.size > 1) throw new EmailAmbiguous(`Emails from ${[...senders].slice(0, 3).join(" and ")} both fit ${vendorOf(query.site)}; not choosing between them.`);
|
|
361
|
+
}
|
|
362
|
+
for (const mail of found.sort((a, b) => b.receivedAt - a.receivedAt)) {
|
|
363
|
+
if (!query.consume || await claimMessage(stateDir, `${norm(address)}:${mail.id}`)) return mail;
|
|
364
|
+
}
|
|
365
|
+
if (Date.now() >= deadline) throw timeout();
|
|
366
|
+
await sleep(Math.min(query.pollMs ?? 3e3, Math.max(0, deadline - Date.now())));
|
|
367
|
+
}
|
|
368
|
+
} catch (error) {
|
|
369
|
+
if (query.signal?.aborted) throw query.signal.reason;
|
|
370
|
+
if (budget.aborted) throw timeout();
|
|
371
|
+
throw error;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
var OWN_MAILBOX_MS = 2e4;
|
|
375
|
+
async function findEmail(stateDir, query) {
|
|
376
|
+
const chosen = await pickMailbox(stateDir, { address: query.address, hints: query.hints });
|
|
377
|
+
const others = query.address ? [] : (await allStored(stateDir)).map((s) => s.email).filter((email) => norm(email) !== norm(chosen));
|
|
378
|
+
const total = query.timeoutMs ?? 9e4;
|
|
379
|
+
const deadline = Date.now() + total;
|
|
380
|
+
const own = Math.min(query.ownMs ?? OWN_MAILBOX_MS, Math.max(1, Math.floor(total / 2)));
|
|
381
|
+
const attempt = (address, timeoutMs, signal2) => waitForEmail(stateDir, { ...query, address, timeoutMs, signal: signal2 });
|
|
382
|
+
if (!others.length) return attempt(chosen, total, query.signal);
|
|
383
|
+
let primaryError;
|
|
384
|
+
try {
|
|
385
|
+
return await attempt(chosen, own, query.signal);
|
|
386
|
+
} catch (error) {
|
|
387
|
+
if (query.signal?.aborted) throw error;
|
|
388
|
+
if (error instanceof EmailAmbiguous) throw error;
|
|
389
|
+
primaryError = error;
|
|
390
|
+
}
|
|
391
|
+
const stop = new AbortController();
|
|
392
|
+
const signal = query.signal ? AbortSignal.any([query.signal, stop.signal]) : stop.signal;
|
|
393
|
+
try {
|
|
394
|
+
const addresses = primaryError instanceof Error && /^No email matched/.test(primaryError.message) ? [chosen, ...others] : others;
|
|
395
|
+
return await Promise.any(addresses.map((address) => attempt(address, Math.max(1, deadline - Date.now()), signal)));
|
|
396
|
+
} catch (error) {
|
|
397
|
+
if (query.signal?.aborted) throw error;
|
|
398
|
+
const inner = error instanceof AggregateError ? error.errors : [error];
|
|
399
|
+
const other = [primaryError, ...inner].find((e) => e instanceof Error && !/^No email matched/.test(e.message));
|
|
400
|
+
if (other) throw other;
|
|
401
|
+
throw new Error(`No email matched ${query.site ? `an email for ${vendorOf(query.site)}` : [query.from, query.subject].filter(Boolean).join(" ")} within ${Math.round(total / 1e3)} seconds in ${[chosen, ...others].join(", ")}.`);
|
|
402
|
+
} finally {
|
|
403
|
+
stop.abort();
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export {
|
|
408
|
+
vendorOf,
|
|
409
|
+
Parked,
|
|
410
|
+
park,
|
|
411
|
+
EMAIL_TOKEN_SECRET,
|
|
412
|
+
EMAIL_CLIENT_SECRET,
|
|
413
|
+
emailStatus,
|
|
414
|
+
emailConnected,
|
|
415
|
+
disconnectEmail,
|
|
416
|
+
pickMailbox,
|
|
417
|
+
loginAddresses,
|
|
418
|
+
startConsent,
|
|
419
|
+
mailText,
|
|
420
|
+
EmailAmbiguous,
|
|
421
|
+
MARKETING,
|
|
422
|
+
senderMatch,
|
|
423
|
+
waitForEmail,
|
|
424
|
+
findEmail
|
|
425
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/agent/tool-contract.ts
|
|
5
|
+
function defineTool(definition) {
|
|
6
|
+
return definition;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
defineTool
|
|
11
|
+
};
|