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,905 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
sessionOrProviderHarness
|
|
5
|
+
} from "./chunk-2EOL5PZL.js";
|
|
6
|
+
import {
|
|
7
|
+
aiHarnessSelect
|
|
8
|
+
} from "./chunk-MDT5XDXL.js";
|
|
9
|
+
import {
|
|
10
|
+
releaseHeldLocalModel
|
|
11
|
+
} from "./chunk-UYEEMIWR.js";
|
|
12
|
+
import {
|
|
13
|
+
isUsageExhaustedMessage,
|
|
14
|
+
matchesVendorTurn,
|
|
15
|
+
turnBackendForAccount
|
|
16
|
+
} from "./chunk-IF43HIGV.js";
|
|
17
|
+
import {
|
|
18
|
+
effortChoicesFor
|
|
19
|
+
} from "./chunk-DGASQT26.js";
|
|
20
|
+
import {
|
|
21
|
+
carriedHandoffModel,
|
|
22
|
+
carriedHandoffSettings,
|
|
23
|
+
synchronizeNativeTranscript
|
|
24
|
+
} from "./chunk-PUOVIFHW.js";
|
|
25
|
+
import {
|
|
26
|
+
setEmitHarnessOutput
|
|
27
|
+
} from "./chunk-LA6MG4ET.js";
|
|
28
|
+
import {
|
|
29
|
+
emitHarnessOutput,
|
|
30
|
+
parseSandboxMode
|
|
31
|
+
} from "./chunk-4RHXTL3W.js";
|
|
32
|
+
import {
|
|
33
|
+
gatewayModelForWord,
|
|
34
|
+
gatewayModels,
|
|
35
|
+
isAutomaticModelWord
|
|
36
|
+
} from "./chunk-W5AYOICN.js";
|
|
37
|
+
import {
|
|
38
|
+
gatewayConnection
|
|
39
|
+
} from "./chunk-2OLS7V66.js";
|
|
40
|
+
import {
|
|
41
|
+
GATEWAY_DEFAULT_EFFORT,
|
|
42
|
+
GATEWAY_EFFORTS,
|
|
43
|
+
gatewayEffort
|
|
44
|
+
} from "./chunk-QYHI3YET.js";
|
|
45
|
+
import {
|
|
46
|
+
isTurnCancelled
|
|
47
|
+
} from "./chunk-4LPDG57B.js";
|
|
48
|
+
import {
|
|
49
|
+
catalogModel,
|
|
50
|
+
resolveLocalModelId
|
|
51
|
+
} from "./chunk-TQDKJHWX.js";
|
|
52
|
+
import {
|
|
53
|
+
preferredAccountId
|
|
54
|
+
} from "./chunk-SQVUDO2O.js";
|
|
55
|
+
import {
|
|
56
|
+
modelIdFromLabel,
|
|
57
|
+
nativeModelCatalog,
|
|
58
|
+
resolveNativeModel
|
|
59
|
+
} from "./chunk-QQRLPY25.js";
|
|
60
|
+
import {
|
|
61
|
+
accountCanTakeTurn
|
|
62
|
+
} from "./chunk-XWAC3MKW.js";
|
|
63
|
+
import {
|
|
64
|
+
blankChatSweepable,
|
|
65
|
+
discardIfBlank,
|
|
66
|
+
ensureSessionOnDisk
|
|
67
|
+
} from "./chunk-ZZCBDNZI.js";
|
|
68
|
+
import {
|
|
69
|
+
readState
|
|
70
|
+
} from "./chunk-MXS6S2PY.js";
|
|
71
|
+
import {
|
|
72
|
+
resolveDefaultSettings
|
|
73
|
+
} from "./chunk-BISGNHKD.js";
|
|
74
|
+
import {
|
|
75
|
+
forgetSessionArtifacts,
|
|
76
|
+
removeStrandedFiles,
|
|
77
|
+
sessionIdsWithArtifacts,
|
|
78
|
+
writeState
|
|
79
|
+
} from "./chunk-RKUVLRZI.js";
|
|
80
|
+
import {
|
|
81
|
+
deleteConversations,
|
|
82
|
+
forceStoreSession,
|
|
83
|
+
pinDraft
|
|
84
|
+
} from "./chunk-BGEMY2JJ.js";
|
|
85
|
+
import {
|
|
86
|
+
loadIndex
|
|
87
|
+
} from "./chunk-XCKQ5BM2.js";
|
|
88
|
+
import {
|
|
89
|
+
harnessCommand
|
|
90
|
+
} from "./chunk-NWEYRBWK.js";
|
|
91
|
+
import {
|
|
92
|
+
VALID_PERMISSION_MODES,
|
|
93
|
+
chatNamed,
|
|
94
|
+
isBlankConversation,
|
|
95
|
+
latestChat,
|
|
96
|
+
leaveProvider,
|
|
97
|
+
normalizeModelWord,
|
|
98
|
+
optionForHarness,
|
|
99
|
+
parkNativeThread,
|
|
100
|
+
parseHarnessOption,
|
|
101
|
+
sessionFromIndex,
|
|
102
|
+
sessionPermissionModes
|
|
103
|
+
} from "./chunk-TWCVV2JO.js";
|
|
104
|
+
import {
|
|
105
|
+
ROUTE_CHOICES_TEXT,
|
|
106
|
+
isAiHarnessRoute,
|
|
107
|
+
isClikCodeAgent,
|
|
108
|
+
isGatewayService
|
|
109
|
+
} from "./chunk-CRUVYGO2.js";
|
|
110
|
+
import {
|
|
111
|
+
consumeSessionTurn,
|
|
112
|
+
sessionTranscriptMessages
|
|
113
|
+
} from "./chunk-FF7ZVYJF.js";
|
|
114
|
+
import {
|
|
115
|
+
liveWorkers,
|
|
116
|
+
sessionIsLive
|
|
117
|
+
} from "./chunk-BUOPJQP5.js";
|
|
118
|
+
import {
|
|
119
|
+
takeConversation
|
|
120
|
+
} from "./chunk-QUS4ER2W.js";
|
|
121
|
+
import {
|
|
122
|
+
harnessCanRunTurns,
|
|
123
|
+
harnessSupportsEffort,
|
|
124
|
+
harnessSupportsModelSelection,
|
|
125
|
+
localHarnessForCommand,
|
|
126
|
+
localHarnessForProvider
|
|
127
|
+
} from "./chunk-KYUHIFP3.js";
|
|
128
|
+
import {
|
|
129
|
+
ensureNativeHarness,
|
|
130
|
+
folderExists,
|
|
131
|
+
missingFolderMessage
|
|
132
|
+
} from "./chunk-DF35KMXM.js";
|
|
133
|
+
import {
|
|
134
|
+
emitResult
|
|
135
|
+
} from "./chunk-JGIWATSG.js";
|
|
136
|
+
import {
|
|
137
|
+
CLIKCODE_USER_AGENT
|
|
138
|
+
} from "./chunk-NAOX3JUB.js";
|
|
139
|
+
import {
|
|
140
|
+
Conf
|
|
141
|
+
} from "./chunk-GGYKY4GF.js";
|
|
142
|
+
import {
|
|
143
|
+
ensurePrivateDirectory
|
|
144
|
+
} from "./chunk-F6F47QAY.js";
|
|
145
|
+
import {
|
|
146
|
+
quiet
|
|
147
|
+
} from "./chunk-RDDWQBEM.js";
|
|
148
|
+
import {
|
|
149
|
+
safeRecordFileName,
|
|
150
|
+
stateDirectory
|
|
151
|
+
} from "./chunk-MPAJ446F.js";
|
|
152
|
+
|
|
153
|
+
// src/gateway/agents.ts
|
|
154
|
+
async function gatewayAgents(options = {}) {
|
|
155
|
+
const { baseUrl, apiKey } = gatewayConnection(options.config ?? new Conf({ projectName: "clikcode", configFileMode: 384 }));
|
|
156
|
+
const response = await (options.fetchImpl ?? fetch)(`${baseUrl}/v1/agents`, {
|
|
157
|
+
headers: { authorization: `Bearer ${apiKey}`, accept: "application/json", "user-agent": CLIKCODE_USER_AGENT },
|
|
158
|
+
signal: AbortSignal.timeout(1e4)
|
|
159
|
+
});
|
|
160
|
+
const body = await response.json().catch(quiet("gateway/agents"));
|
|
161
|
+
if (!response.ok) throw new Error(`ClikDeploy Gateway agents: HTTP ${response.status}`);
|
|
162
|
+
if (!body || typeof body !== "object" || !Array.isArray(body.data)) throw new Error("ClikDeploy Gateway agents: invalid roster response");
|
|
163
|
+
return body.data.flatMap((value) => {
|
|
164
|
+
if (!value || typeof value !== "object") return [];
|
|
165
|
+
const entry = value;
|
|
166
|
+
if (typeof entry.id !== "string" || !entry.id || typeof entry.name !== "string" || !entry.name || entry.enabled === false) return [];
|
|
167
|
+
return [{ id: entry.id, name: entry.name, ...typeof entry.description === "string" ? { description: entry.description } : {} }];
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// src/commands/ai/sessions.ts
|
|
172
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
173
|
+
|
|
174
|
+
// src/session/route-models.ts
|
|
175
|
+
function routeKeyOf(session) {
|
|
176
|
+
if (session.route === "gateway") return "gateway";
|
|
177
|
+
if (session.route === "clikcode-local") return "clikcode-local";
|
|
178
|
+
return session.nativeHarness;
|
|
179
|
+
}
|
|
180
|
+
function rememberRouteModel(session) {
|
|
181
|
+
const key = routeKeyOf(session);
|
|
182
|
+
if (!key) return;
|
|
183
|
+
session.routeModels = { ...session.routeModels, [key]: session.model ?? null };
|
|
184
|
+
}
|
|
185
|
+
function recallRouteModel(session, key, state) {
|
|
186
|
+
const own = session.routeModels;
|
|
187
|
+
if (own && key in own) return own[key];
|
|
188
|
+
const latest = [...state?.sessions ?? []].filter((other) => other.id !== session.id && routeKeyOf(other) === key && other.model).sort((left, right) => Date.parse(right.updatedAt ?? "") - Date.parse(left.updatedAt ?? ""))[0];
|
|
189
|
+
return latest?.model ?? void 0;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// src/commands/ai/conversations.ts
|
|
193
|
+
import { randomUUID } from "node:crypto";
|
|
194
|
+
|
|
195
|
+
// src/session/attach.ts
|
|
196
|
+
import { homedir } from "node:os";
|
|
197
|
+
|
|
198
|
+
// src/session/state/sweep.ts
|
|
199
|
+
import { stat, utimes, writeFile } from "node:fs/promises";
|
|
200
|
+
import { join } from "node:path";
|
|
201
|
+
var HOUR_MS = 60 * 6e4;
|
|
202
|
+
var SWEEP_EVERY_MS = 24 * HOUR_MS;
|
|
203
|
+
var ORPHAN_MIN_AGE_MS = HOUR_MS;
|
|
204
|
+
var STALE_TURN_MS = 24 * HOUR_MS;
|
|
205
|
+
var MAX_ORPHANS = 500;
|
|
206
|
+
function staleTurn(session, workerIsLive, isOpen, now) {
|
|
207
|
+
const pending = session.pendingTurn;
|
|
208
|
+
if (!pending || session.resumeAt || workerIsLive(session.id) || isOpen(session.id)) return false;
|
|
209
|
+
return now - (Date.parse(pending.updatedAt ?? pending.startedAt) || 0) > STALE_TURN_MS;
|
|
210
|
+
}
|
|
211
|
+
async function oldEnough(path, now) {
|
|
212
|
+
const info = await stat(path).catch(quiet("session/state/sweep"));
|
|
213
|
+
return !info || now - info.mtimeMs > ORPHAN_MIN_AGE_MS;
|
|
214
|
+
}
|
|
215
|
+
async function sweepState(now = Date.now()) {
|
|
216
|
+
const report = { orphans: 0, stranded: 0, blank: 0, settled: 0 };
|
|
217
|
+
report.stranded = await removeStrandedFiles(HOUR_MS, now);
|
|
218
|
+
const state = await readState();
|
|
219
|
+
const { isLive: workerIsLive, isOpen } = await liveWorkers();
|
|
220
|
+
let changed = false;
|
|
221
|
+
const blank = state.sessions.filter((session) => sessionFromIndex(session) && blankChatSweepable(session, workerIsLive, now, isOpen)).map((session) => session.id);
|
|
222
|
+
report.blank = blank.length;
|
|
223
|
+
if (report.blank) {
|
|
224
|
+
deleteConversations(state, blank);
|
|
225
|
+
changed = true;
|
|
226
|
+
}
|
|
227
|
+
for (const session of state.sessions) {
|
|
228
|
+
if (!staleTurn(session, workerIsLive, isOpen, now)) continue;
|
|
229
|
+
session.messages = sessionTranscriptMessages(session);
|
|
230
|
+
delete session.pendingTurn;
|
|
231
|
+
report.settled += 1;
|
|
232
|
+
changed = true;
|
|
233
|
+
}
|
|
234
|
+
if (changed) await writeState(state);
|
|
235
|
+
const names = (id) => [id, safeRecordFileName(id), id.replace(/[^A-Za-z0-9._-]/g, "_")];
|
|
236
|
+
const deleted = new Set(Object.keys((await loadIndex())?.deletedSessions ?? {}).flatMap(names));
|
|
237
|
+
const listed = new Set(state.sessions.flatMap((session) => names(session.id)));
|
|
238
|
+
const root = stateDirectory();
|
|
239
|
+
for (const id of await sessionIdsWithArtifacts()) {
|
|
240
|
+
if (report.orphans >= MAX_ORPHANS) break;
|
|
241
|
+
if (listed.has(id) || !deleted.has(id)) continue;
|
|
242
|
+
const places = [join(root, "sessions", id), join(root, "checkpoints", id), join(root, "turn-changes", `${id}.json`)];
|
|
243
|
+
if (!(await Promise.all(places.map((path) => oldEnough(path, now)))).every(Boolean)) continue;
|
|
244
|
+
await forgetSessionArtifacts(id);
|
|
245
|
+
report.orphans += 1;
|
|
246
|
+
}
|
|
247
|
+
return report;
|
|
248
|
+
}
|
|
249
|
+
var running;
|
|
250
|
+
function sweepStateDaily() {
|
|
251
|
+
if (process.env.VITEST) return Promise.resolve(void 0);
|
|
252
|
+
running ??= (async () => {
|
|
253
|
+
await ensurePrivateDirectory(join(stateDirectory(), "cache"));
|
|
254
|
+
const marker = join(stateDirectory(), "cache", "state-sweep");
|
|
255
|
+
const last = await stat(marker).catch(quiet("session/state/sweep"));
|
|
256
|
+
if (last && Date.now() - last.mtimeMs < SWEEP_EVERY_MS) return void 0;
|
|
257
|
+
await writeFile(marker, "", { mode: 384 }).catch(quiet("session/state/sweep"));
|
|
258
|
+
const now = /* @__PURE__ */ new Date();
|
|
259
|
+
await utimes(marker, now, now).catch(quiet("session/state/sweep"));
|
|
260
|
+
return sweepState();
|
|
261
|
+
})();
|
|
262
|
+
return running;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// src/session/exhaustion.ts
|
|
266
|
+
function accountHasUsage(account) {
|
|
267
|
+
return accountCanTakeTurn(account);
|
|
268
|
+
}
|
|
269
|
+
function sessionProviderHasUsage(accounts, provider) {
|
|
270
|
+
return accounts.some((account) => account.provider === provider && matchesVendorTurn(account) && accountHasUsage(account));
|
|
271
|
+
}
|
|
272
|
+
async function sameProviderCanTakeTurn(id) {
|
|
273
|
+
const state = await readState({ transcripts: [id] });
|
|
274
|
+
const session = state.sessions.find((item) => item.id === id);
|
|
275
|
+
return session ? sessionProviderHasUsage(state.accounts, session.provider) : false;
|
|
276
|
+
}
|
|
277
|
+
function resumePromptForPendingTurn(pending, prompt, sent = prompt) {
|
|
278
|
+
if (!pending || pending.prompt.trim() !== sent.trim()) return prompt;
|
|
279
|
+
return sent;
|
|
280
|
+
}
|
|
281
|
+
async function carryOnAfterExhaustion(offer, id, prompt, guard, sent = prompt) {
|
|
282
|
+
const key = (text) => `${id}
|
|
283
|
+
${text}`;
|
|
284
|
+
if (guard.autoResent !== key(prompt) && await sameProviderCanTakeTurn(id)) {
|
|
285
|
+
const state = await readState({ transcripts: [id] });
|
|
286
|
+
const session = state.sessions.find((item) => item.id === id);
|
|
287
|
+
if (session) {
|
|
288
|
+
const continuation = resumePromptForPendingTurn(session.pendingTurn, prompt, sent);
|
|
289
|
+
guard.autoResent = key(continuation);
|
|
290
|
+
return { retry: continuation };
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
const moved = await offer(id, prompt, sent);
|
|
294
|
+
if (moved && "waiting" in moved) return moved;
|
|
295
|
+
if (moved) return { moved };
|
|
296
|
+
return { stayed: [prompt, ...await sameProviderCanTakeTurn(id) ? [] : await takeQueuedMessages(id)] };
|
|
297
|
+
}
|
|
298
|
+
async function waitForReset(id, reset, prompt, sent = prompt, now = Date.now()) {
|
|
299
|
+
const state = await readState({ transcripts: [id] });
|
|
300
|
+
const session = state.sessions.find((item) => item.id === id);
|
|
301
|
+
if (!session) throw new Error(`AI session "${id}" was not found`);
|
|
302
|
+
const resumeAt = { at: reset.toISOString(), prompt: resumePromptForPendingTurn(session.pendingTurn, prompt, sent), setAt: new Date(now).toISOString() };
|
|
303
|
+
session.resumeAt = resumeAt;
|
|
304
|
+
await writeState(state);
|
|
305
|
+
return resumeAt;
|
|
306
|
+
}
|
|
307
|
+
async function stopWaitingForReset(id) {
|
|
308
|
+
const state = await readState({ transcripts: [] });
|
|
309
|
+
const session = state.sessions.find((item) => item.id === id);
|
|
310
|
+
if (!session?.resumeAt) return false;
|
|
311
|
+
delete session.resumeAt;
|
|
312
|
+
await writeState(state);
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// src/session/attach.ts
|
|
317
|
+
function activateSession(session) {
|
|
318
|
+
if (session.status === "active") return false;
|
|
319
|
+
session.status = "active";
|
|
320
|
+
session.closedAt = void 0;
|
|
321
|
+
session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
async function openConversation(requested, mode, ref, options = {}) {
|
|
325
|
+
const home = homedir();
|
|
326
|
+
const workspace = requested && folderExists(requested) ? requested : home;
|
|
327
|
+
const state = await readState({ transcripts: [] });
|
|
328
|
+
void sweepStateDaily().catch(quiet("session/attach"));
|
|
329
|
+
let session;
|
|
330
|
+
if (mode === "resume") {
|
|
331
|
+
if (!ref) throw new Error("resume needs a conversation id");
|
|
332
|
+
const id = state.sessions.some((item) => item.id === ref) ? ref : chatNamed(state.sessions, ref, "");
|
|
333
|
+
session = id ? state.sessions.find((item) => item.id === id) : void 0;
|
|
334
|
+
for (let into = session?.foldedInto; into; ) {
|
|
335
|
+
session = state.sessions.find((item) => item.id === into) ?? session;
|
|
336
|
+
into = session?.id === into ? session.foldedInto : void 0;
|
|
337
|
+
}
|
|
338
|
+
if (!session) throw new Error(`no chat matches "${ref}" -- use its name, the start of its id, or last`);
|
|
339
|
+
} else if (mode === "continue") {
|
|
340
|
+
const candidates = options.sameWorkspace ? state.sessions.filter((item) => item.status !== "archived" && item.workspace === workspace) : state.sessions;
|
|
341
|
+
session = latestChat(candidates, workspace);
|
|
342
|
+
}
|
|
343
|
+
if (session) {
|
|
344
|
+
let changed = activateSession(session);
|
|
345
|
+
if (session.workspace && !folderExists(session.workspace)) {
|
|
346
|
+
options.notice?.(`${missingFolderMessage(session.workspace)}; this chat continues in ${home}.`);
|
|
347
|
+
session.workspace = home;
|
|
348
|
+
session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
349
|
+
changed = true;
|
|
350
|
+
}
|
|
351
|
+
if (changed) await writeState(state);
|
|
352
|
+
return session.id;
|
|
353
|
+
}
|
|
354
|
+
if (requested && workspace !== requested) options.notice?.(`${missingFolderMessage(requested)}; this chat opens in ${home}.`);
|
|
355
|
+
const { isLive, isOpen } = await liveWorkers();
|
|
356
|
+
deleteConversations(state, state.sessions.filter((item) => blankChatSweepable(item, isLive, Date.now(), isOpen)).map((item) => item.id));
|
|
357
|
+
const fresh = launchSession(state, workspace);
|
|
358
|
+
state.sessions.push(fresh);
|
|
359
|
+
if (options.pin) pinDraft(fresh.id);
|
|
360
|
+
await writeState(state);
|
|
361
|
+
return fresh.id;
|
|
362
|
+
}
|
|
363
|
+
async function resolveSessionModel(id) {
|
|
364
|
+
const state = await readState({ transcripts: [id] });
|
|
365
|
+
const session = state.sessions.find((item) => item.id === id);
|
|
366
|
+
if (!session || session.model) return;
|
|
367
|
+
const harness = sessionOrProviderHarness(session);
|
|
368
|
+
if (!harness) return;
|
|
369
|
+
const account = session.accountId ? state.accounts.find((item) => item.id === session.accountId) : void 0;
|
|
370
|
+
const resolved = await resolveNativeModel(harness, account).catch(quiet("session/attach"));
|
|
371
|
+
if (!resolved) return;
|
|
372
|
+
session.model = resolved;
|
|
373
|
+
session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
374
|
+
await writeState(state);
|
|
375
|
+
}
|
|
376
|
+
var presence = /* @__PURE__ */ new Map();
|
|
377
|
+
async function claimConversation(id) {
|
|
378
|
+
const mine = presence.get(id);
|
|
379
|
+
if (mine && await mine.held()) return;
|
|
380
|
+
presence.delete(id);
|
|
381
|
+
const taken = await takeConversation(id, "client");
|
|
382
|
+
if ("hold" in taken) presence.set(id, taken.hold);
|
|
383
|
+
}
|
|
384
|
+
async function releaseConversationClaim(id) {
|
|
385
|
+
const mine = presence.get(id);
|
|
386
|
+
presence.delete(id);
|
|
387
|
+
await mine?.release();
|
|
388
|
+
}
|
|
389
|
+
async function leaveConversation(id) {
|
|
390
|
+
await releaseConversationClaim(id).catch(quiet("session/attach"));
|
|
391
|
+
await discardIfBlank(id).catch(quiet("session/attach"));
|
|
392
|
+
}
|
|
393
|
+
async function prepareTurn(targetId) {
|
|
394
|
+
await ensureSessionOnDisk(targetId);
|
|
395
|
+
const state = await readState({ transcripts: [targetId] });
|
|
396
|
+
return { state, active: state.sessions.find((item) => item.id === targetId) };
|
|
397
|
+
}
|
|
398
|
+
async function afterTurnFailure(resumeIn, id, error, turn) {
|
|
399
|
+
const cancelled = isTurnCancelled(error);
|
|
400
|
+
const queued = Boolean(turn.queuedTurnId && !cancelled);
|
|
401
|
+
if (queued) await releaseQueuedTurn(id, turn.queuedTurnId).catch(quiet("session/attach"));
|
|
402
|
+
const back = queued && turn.line ? [turn.line] : [];
|
|
403
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
404
|
+
if (cancelled || !resumeIn || !turn.line || !isUsageExhaustedMessage(message)) return { cancelled, back };
|
|
405
|
+
const next = await carryOnAfterExhaustion(resumeIn, id, turn.line, turn.guard, turn.sent ?? turn.line);
|
|
406
|
+
if ("stayed" in next) return { cancelled, back: [...back, ...next.stayed.filter((text) => !back.includes(text))] };
|
|
407
|
+
if ("waiting" in next) return { cancelled, back: [], waiting: next.waiting };
|
|
408
|
+
return { cancelled, ...next };
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// src/commands/ai/conversations.ts
|
|
412
|
+
function newConversationSession(state, source, now = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
413
|
+
const id = randomUUID();
|
|
414
|
+
const defaults = resolveDefaultSettings(state, source.provider);
|
|
415
|
+
return {
|
|
416
|
+
id,
|
|
417
|
+
conversationId: id,
|
|
418
|
+
route: source.route,
|
|
419
|
+
accountId: isClikCodeAgent(source) ? null : source.accountId ?? null,
|
|
420
|
+
provider: source.provider,
|
|
421
|
+
model: source.provider ? state.providerSettings[source.provider]?.model ?? null : null,
|
|
422
|
+
...!isClikCodeAgent(source) && source.nativeHarness ? { nativeHarness: source.nativeHarness } : {},
|
|
423
|
+
...source.harnessOptions ? { harnessOptions: { ...source.harnessOptions } } : {},
|
|
424
|
+
effort: source.effort ?? defaults.effort,
|
|
425
|
+
// A Gateway /new has always started without a stored mode (read as `ask`).
|
|
426
|
+
// ClikCode Local carries it: its agent honours the mode, and a fresh chat
|
|
427
|
+
// silently dropping `auto` back to `ask` would read as a new policy.
|
|
428
|
+
...isGatewayService(source) ? {} : { permissionMode: source.permissionMode ?? defaults.permissionMode },
|
|
429
|
+
workspace: source.workspace ?? process.cwd(),
|
|
430
|
+
createdAt: now,
|
|
431
|
+
updatedAt: now,
|
|
432
|
+
status: "active"
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
async function releaseQueuedTurn(id, queuedTurnId) {
|
|
436
|
+
const state = await readState({ transcripts: [id] });
|
|
437
|
+
const session = state.sessions.find((item) => item.id === id);
|
|
438
|
+
if (session && consumeSessionTurn(session, queuedTurnId)) await writeState(state);
|
|
439
|
+
}
|
|
440
|
+
async function takeQueuedMessages(id) {
|
|
441
|
+
const state = await readState({ transcripts: [id] });
|
|
442
|
+
const session = state.sessions.find((item) => item.id === id);
|
|
443
|
+
const taken = (session?.queuedTurns ?? []).filter((item) => !item.kind);
|
|
444
|
+
if (!session || !taken.length) return [];
|
|
445
|
+
for (const item of taken) consumeSessionTurn(session, item.id);
|
|
446
|
+
session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
447
|
+
await writeState(state);
|
|
448
|
+
return taken.map((item) => item.text);
|
|
449
|
+
}
|
|
450
|
+
async function newConversation(currentId, options = {}) {
|
|
451
|
+
const state = await readState({ transcripts: [] });
|
|
452
|
+
const current = state.sessions.find((item) => item.id === currentId) ?? options.lastSeen;
|
|
453
|
+
if (!current) throw new Error(`AI session "${currentId}" was not found`);
|
|
454
|
+
const created = newConversationSession(state, current);
|
|
455
|
+
if (options.sameModel && current.model) created.model = current.model;
|
|
456
|
+
state.sessions.push(created);
|
|
457
|
+
await writeState(state);
|
|
458
|
+
await resolveSessionModel(created.id);
|
|
459
|
+
return created.id;
|
|
460
|
+
}
|
|
461
|
+
async function turnIsRunning(id) {
|
|
462
|
+
const { workerTurn } = await import("./chunk-I3GDBJLH.js");
|
|
463
|
+
return Boolean(await workerTurn(id).catch(quiet("commands/ai/conversations")));
|
|
464
|
+
}
|
|
465
|
+
async function refuseWhileTurnRuns(id) {
|
|
466
|
+
const { workerTurn } = await import("./chunk-I3GDBJLH.js");
|
|
467
|
+
if (await workerTurn(id).catch(quiet("commands/ai/conversations"))) {
|
|
468
|
+
throw new Error("A turn is still running in this conversation -- switch when it ends, or stop it first.");
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
async function moveToProvider(id, harnessCommandName, selection = {}) {
|
|
472
|
+
const harness = localHarnessForCommand(harnessCommandName);
|
|
473
|
+
if (!harness) throw new Error(`unknown local harness: ${harnessCommandName}`);
|
|
474
|
+
const state = await readState({ transcripts: [id] });
|
|
475
|
+
const current = state.sessions.find((item) => item.id === id);
|
|
476
|
+
if (!current) throw new Error(`AI session "${id}" was not found`);
|
|
477
|
+
if (current.route === "local" && current.nativeHarness === harness.command) return;
|
|
478
|
+
const running2 = await turnIsRunning(id);
|
|
479
|
+
if (!running2) await synchronizeNativeTranscript(state, current);
|
|
480
|
+
const accountId = selection.accountId ?? preferredAccountId(state, harness.provider);
|
|
481
|
+
const account = accountId ? state.accounts.find((item) => item.id === accountId) : void 0;
|
|
482
|
+
const efforts = harnessSupportsEffort(harness) ? (await effortChoicesFor(harness, account, current.model).catch(quiet("commands/ai/conversations")))?.values : void 0;
|
|
483
|
+
const defaults = carriedHandoffSettings(current, harness, resolveDefaultSettings(state, harness.provider), efforts);
|
|
484
|
+
const lastUsedModel = [...state.sessions].filter((session) => session.nativeHarness === harness.command && session.model).sort((left, right) => Date.parse(right.updatedAt ?? "") - Date.parse(left.updatedAt ?? ""))[0]?.model;
|
|
485
|
+
const recalled = recallRouteModel(current, harness.command, state);
|
|
486
|
+
const listed = (candidate) => Boolean(candidate) && (!account?.models.length || account.models.includes(candidate));
|
|
487
|
+
const model = selection.model ?? (listed(recalled) ? recalled : null) ?? carriedHandoffModel(
|
|
488
|
+
current,
|
|
489
|
+
account?.models ?? [],
|
|
490
|
+
lastUsedModel ?? state.providerSettings[harness.provider]?.model ?? null
|
|
491
|
+
);
|
|
492
|
+
rememberRouteModel(current);
|
|
493
|
+
if (running2) parkNativeThread(current);
|
|
494
|
+
else leaveProvider(current);
|
|
495
|
+
Object.assign(current, {
|
|
496
|
+
route: "local",
|
|
497
|
+
provider: harness.provider,
|
|
498
|
+
nativeHarness: harness.command,
|
|
499
|
+
accountId,
|
|
500
|
+
model,
|
|
501
|
+
effort: defaults.effort,
|
|
502
|
+
permissionMode: defaults.permissionMode
|
|
503
|
+
});
|
|
504
|
+
await writeState(state);
|
|
505
|
+
await aiHarnessSelect(harnessCommandName, id, selection.prompter ? { prompter: selection.prompter } : {});
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// src/commands/ai/sessions.ts
|
|
509
|
+
var CLIKCODE_LOCAL_FIXED_FIELDS = "ClikCode Local runs ClikCode's own agent on a model this machine serves; account, provider, effort, and native sessions cannot be set per session (a model can, from ClikCode Local's catalog).";
|
|
510
|
+
async function assertRealModel(harness, account, model) {
|
|
511
|
+
if (!harness) return model;
|
|
512
|
+
const catalog = await nativeModelCatalog(harness, account);
|
|
513
|
+
const real = modelIdFromLabel(harness, catalog.models, model);
|
|
514
|
+
if (catalog.models.length && !catalog.models.includes(real)) {
|
|
515
|
+
throw new Error(`"${model}" is not a model ${harness.displayName} publishes. Choose one of: ${catalog.models.join(", ")}`);
|
|
516
|
+
}
|
|
517
|
+
return real;
|
|
518
|
+
}
|
|
519
|
+
async function chooseGatewayModel(value) {
|
|
520
|
+
if (isAutomaticModelWord(value)) return null;
|
|
521
|
+
let { models } = await gatewayModels();
|
|
522
|
+
let found = gatewayModelForWord(models, value);
|
|
523
|
+
if (!found) {
|
|
524
|
+
models = (await gatewayModels({ fresh: true })).models;
|
|
525
|
+
found = gatewayModelForWord(models, value);
|
|
526
|
+
}
|
|
527
|
+
if (!found) {
|
|
528
|
+
const wanted = value.trim().toLowerCase();
|
|
529
|
+
const near = models.filter((model) => model.id.toLowerCase().includes(wanted)).slice(0, 5).map((model) => model.id);
|
|
530
|
+
throw new Error(`"${value.trim()}" is not a model ClikDeploy Gateway offers you${near.length ? `. Did you mean: ${near.join(", ")}` : "; see `" + harnessCommand() + " models --gateway`"}.`);
|
|
531
|
+
}
|
|
532
|
+
return found.id;
|
|
533
|
+
}
|
|
534
|
+
async function selectGatewayAgent(id, agentId, agentName) {
|
|
535
|
+
const state = await readState({ transcripts: [id] });
|
|
536
|
+
const session = state.sessions.find((item) => item.id === id);
|
|
537
|
+
if (!session || session.route !== "gateway") throw new Error("Select a Gateway session before choosing an agent.");
|
|
538
|
+
if (agentId !== session.gatewayAgentId) {
|
|
539
|
+
delete session.gatewayAgentThreadId;
|
|
540
|
+
delete session.gatewayAgentName;
|
|
541
|
+
}
|
|
542
|
+
if (agentId) session.gatewayAgentId = agentId;
|
|
543
|
+
else delete session.gatewayAgentId;
|
|
544
|
+
if (agentId && agentName) session.gatewayAgentName = agentName;
|
|
545
|
+
session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
546
|
+
forceStoreSession(id);
|
|
547
|
+
await writeState(state);
|
|
548
|
+
}
|
|
549
|
+
async function gatewayAgentChoice(value) {
|
|
550
|
+
if (value.trim().toLowerCase() === "none") return void 0;
|
|
551
|
+
const agents = await gatewayAgents();
|
|
552
|
+
const found = agents.find((agent) => agent.id === value.trim());
|
|
553
|
+
if (!found) throw new Error(`Agent "${value}" is not available to this Gateway account; see \`clikcode gateway agents list\`.`);
|
|
554
|
+
return found.id;
|
|
555
|
+
}
|
|
556
|
+
function leaveVendorForRoute(session) {
|
|
557
|
+
if (session.pendingTurn) parkNativeThread(session);
|
|
558
|
+
else leaveProvider(session);
|
|
559
|
+
}
|
|
560
|
+
function applyGatewaySessionPolicy(session, state) {
|
|
561
|
+
if (session.nativeHarness && session.route !== "gateway") {
|
|
562
|
+
leaveVendorForRoute(session);
|
|
563
|
+
}
|
|
564
|
+
const keepModel = session.route === "gateway";
|
|
565
|
+
if (!keepModel) rememberRouteModel(session);
|
|
566
|
+
session.route = "gateway";
|
|
567
|
+
session.accountId = null;
|
|
568
|
+
session.provider = "gateway";
|
|
569
|
+
if (!keepModel) session.model = recallRouteModel(session, "gateway", state) ?? null;
|
|
570
|
+
if (!keepModel) delete session.gatewayAgentId;
|
|
571
|
+
if (!keepModel) delete session.gatewayAgentThreadId;
|
|
572
|
+
if (!keepModel) delete session.gatewayAgentName;
|
|
573
|
+
if (!keepModel || !gatewayEffort(session)) session.effort = GATEWAY_DEFAULT_EFFORT;
|
|
574
|
+
session.gatewayConfirmed = true;
|
|
575
|
+
shedVendorHarness(session);
|
|
576
|
+
}
|
|
577
|
+
function shedVendorHarness(session) {
|
|
578
|
+
parkNativeThread(session);
|
|
579
|
+
if (session.reported?.model) delete session.reported.model;
|
|
580
|
+
delete session.nativeHarness;
|
|
581
|
+
delete session.harnessOptions;
|
|
582
|
+
}
|
|
583
|
+
function applyClikCodeLocalSessionPolicy(session, state) {
|
|
584
|
+
if (session.nativeHarness && session.route !== "clikcode-local") {
|
|
585
|
+
leaveVendorForRoute(session);
|
|
586
|
+
}
|
|
587
|
+
if (session.route !== "clikcode-local") rememberRouteModel(session);
|
|
588
|
+
const recalled = session.route === "clikcode-local" ? void 0 : recallRouteModel(session, "clikcode-local", state);
|
|
589
|
+
session.route = "clikcode-local";
|
|
590
|
+
session.accountId = null;
|
|
591
|
+
session.provider = "clikcode-local";
|
|
592
|
+
session.model = recalled && catalogModel(recalled) ? recalled : session.model && catalogModel(session.model) ? session.model : null;
|
|
593
|
+
session.effort = "auto";
|
|
594
|
+
delete session.gatewayConfirmed;
|
|
595
|
+
delete session.gatewayAgentId;
|
|
596
|
+
delete session.gatewayAgentThreadId;
|
|
597
|
+
delete session.gatewayAgentName;
|
|
598
|
+
shedVendorHarness(session);
|
|
599
|
+
}
|
|
600
|
+
function applyClikCodeAgentSessionPolicy(session, route, state) {
|
|
601
|
+
if (route === "gateway") applyGatewaySessionPolicy(session, state);
|
|
602
|
+
else applyClikCodeLocalSessionPolicy(session, state);
|
|
603
|
+
}
|
|
604
|
+
function applyFreshLocalSessionPolicy(state, session) {
|
|
605
|
+
const defaults = resolveDefaultSettings(state, null);
|
|
606
|
+
session.route = "local";
|
|
607
|
+
session.accountId = null;
|
|
608
|
+
session.provider = null;
|
|
609
|
+
session.model = null;
|
|
610
|
+
session.effort = defaults.effort;
|
|
611
|
+
session.permissionMode = defaults.permissionMode;
|
|
612
|
+
delete session.gatewayConfirmed;
|
|
613
|
+
delete session.gatewayAgentId;
|
|
614
|
+
delete session.gatewayAgentThreadId;
|
|
615
|
+
delete session.gatewayAgentName;
|
|
616
|
+
shedVendorHarness(session);
|
|
617
|
+
}
|
|
618
|
+
setEmitHarnessOutput(emitHarnessOutput);
|
|
619
|
+
function findAccount(state, labelOrId, provider) {
|
|
620
|
+
const byId = state.accounts.find((item) => item.id === labelOrId);
|
|
621
|
+
if (byId) return byId;
|
|
622
|
+
const sameLabel = state.accounts.filter((item) => item.label === labelOrId);
|
|
623
|
+
return (provider ? sameLabel.find((item) => item.provider === provider) : void 0) ?? sameLabel[0];
|
|
624
|
+
}
|
|
625
|
+
async function aiSessionCreate(options) {
|
|
626
|
+
if (!isAiHarnessRoute(options.route)) throw new Error(ROUTE_CHOICES_TEXT);
|
|
627
|
+
if (options.agent && options.route !== "gateway") throw new Error("A Gateway agent requires --route gateway.");
|
|
628
|
+
const gatewayAgentId = options.agent ? await gatewayAgentChoice(options.agent) : void 0;
|
|
629
|
+
if (options.route === "gateway" && (options.account || options.provider)) {
|
|
630
|
+
throw new Error("ClikDeploy Gateway account and provider are selected by platform routing and cannot be overridden per session.");
|
|
631
|
+
}
|
|
632
|
+
if (options.route === "gateway" && options.effort && !GATEWAY_EFFORTS.includes(options.effort)) {
|
|
633
|
+
throw new Error(`ClikDeploy Gateway effort must be one of ${GATEWAY_EFFORTS.join(", ")}`);
|
|
634
|
+
}
|
|
635
|
+
if (options.route === "clikcode-local" && (options.account || options.provider || options.effort)) {
|
|
636
|
+
throw new Error(CLIKCODE_LOCAL_FIXED_FIELDS);
|
|
637
|
+
}
|
|
638
|
+
const localModel = options.route === "clikcode-local" && options.model ? resolveLocalModelId(options.model) : void 0;
|
|
639
|
+
const named = options.provider ? localHarnessForCommand(options.provider) : void 0;
|
|
640
|
+
const state = await readState({ transcripts: [] });
|
|
641
|
+
const account = options.account ? findAccount(state, options.account, named?.provider ?? options.provider) : void 0;
|
|
642
|
+
if (options.route === "local" && options.account && !account) throw new Error(`No account named "${options.account}"`);
|
|
643
|
+
if (account && options.provider && (named?.provider ?? options.provider) !== account.provider) {
|
|
644
|
+
throw new Error(`account "${account.label}" belongs to ${account.provider}, not ${options.provider}`);
|
|
645
|
+
}
|
|
646
|
+
const provider = named?.provider ?? options.provider ?? account?.provider ?? null;
|
|
647
|
+
const harness = provider ? localHarnessForProvider(provider) : void 0;
|
|
648
|
+
if (provider && !harness && options.route === "local") {
|
|
649
|
+
throw new Error(account && account.provider === provider ? `${provider} is no longer a supported tool; remove the account "${account.label}" with \`clikcode accounts remove ${account.id}\`` : `unknown local provider "${provider}"`);
|
|
650
|
+
}
|
|
651
|
+
const model = options.model === void 0 || options.route === "gateway" ? void 0 : normalizeModelWord(options.model);
|
|
652
|
+
if (model && harness && !harnessSupportsModelSelection(harness)) throw new Error(`${harness.displayName} does not publish a model selector.`);
|
|
653
|
+
if (model) await assertRealModel(harness, account, model);
|
|
654
|
+
if (options.effort && harness) {
|
|
655
|
+
const effortOption = optionForHarness(harness, "effort");
|
|
656
|
+
if (!effortOption) throw new Error(`${harness.displayName} does not publish a configurable reasoning-effort flag.`);
|
|
657
|
+
const choices = (await effortChoicesFor(harness, account, model)).values;
|
|
658
|
+
parseHarnessOption(choices.length ? { ...effortOption, values: choices } : effortOption, options.effort);
|
|
659
|
+
}
|
|
660
|
+
const defaults = resolveDefaultSettings(state, provider);
|
|
661
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
662
|
+
const id = randomUUID2();
|
|
663
|
+
const session = {
|
|
664
|
+
id,
|
|
665
|
+
conversationId: id,
|
|
666
|
+
route: options.route,
|
|
667
|
+
accountId: options.route === "gateway" ? null : account?.id ?? null,
|
|
668
|
+
provider: options.route === "gateway" ? "gateway" : provider,
|
|
669
|
+
model: options.route === "gateway" ? options.model !== void 0 ? await chooseGatewayModel(options.model) : null : model ?? (provider ? state.providerSettings[provider]?.model : void 0) ?? null,
|
|
670
|
+
effort: options.route === "gateway" ? options.effort ?? GATEWAY_DEFAULT_EFFORT : options.effort ?? (harness && !harnessSupportsEffort(harness) ? "" : defaults.effort),
|
|
671
|
+
// Every route: on the agent routes the agent is ClikCode's own, running
|
|
672
|
+
// here, and it honours the same approval setting.
|
|
673
|
+
permissionMode: defaults.permissionMode,
|
|
674
|
+
...options.route === "gateway" ? { gatewayConfirmed: true } : {},
|
|
675
|
+
...gatewayAgentId ? { gatewayAgentId } : {},
|
|
676
|
+
createdAt: now,
|
|
677
|
+
updatedAt: now,
|
|
678
|
+
status: "active"
|
|
679
|
+
};
|
|
680
|
+
if (options.route === "clikcode-local") {
|
|
681
|
+
applyClikCodeLocalSessionPolicy(session, state);
|
|
682
|
+
if (localModel) session.model = localModel;
|
|
683
|
+
}
|
|
684
|
+
state.sessions.push(session);
|
|
685
|
+
forceStoreSession(id);
|
|
686
|
+
await writeState(state);
|
|
687
|
+
if (options.route === "local") await (await import("./chunk-XRDALAO3.js")).ensureChatReady(id);
|
|
688
|
+
emitResult({ session: (await readState({ transcripts: [id] })).sessions.find((item) => item.id === id) ?? session });
|
|
689
|
+
}
|
|
690
|
+
async function aiSessionsList() {
|
|
691
|
+
const state = await readState({ transcripts: [] });
|
|
692
|
+
const { isLive: workerIsLive, isOpen, background } = await liveWorkers();
|
|
693
|
+
const sessions = state.sessions.filter((session) => !session.movedTo && !isBlankConversation(session)).map((session) => {
|
|
694
|
+
const commands = background(session.id)?.commands;
|
|
695
|
+
return { ...session, live: sessionIsLive(session, workerIsLive, isOpen), ...commands?.length ? { backgroundCommands: commands } : {} };
|
|
696
|
+
});
|
|
697
|
+
emitResult({ sessions });
|
|
698
|
+
}
|
|
699
|
+
function firstEverSession(state, workspace, now) {
|
|
700
|
+
const defaults = resolveDefaultSettings(state, null);
|
|
701
|
+
const id = randomUUID2();
|
|
702
|
+
return {
|
|
703
|
+
id,
|
|
704
|
+
conversationId: id,
|
|
705
|
+
route: "local",
|
|
706
|
+
accountId: null,
|
|
707
|
+
provider: null,
|
|
708
|
+
model: null,
|
|
709
|
+
effort: defaults.effort,
|
|
710
|
+
permissionMode: defaults.permissionMode,
|
|
711
|
+
workspace,
|
|
712
|
+
createdAt: now,
|
|
713
|
+
updatedAt: now,
|
|
714
|
+
status: "active"
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
function launchSession(state, workspace, now = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
718
|
+
const recent = [...state.sessions].sort((left, right) => right.updatedAt.localeCompare(left.updatedAt));
|
|
719
|
+
const previous = recent.find((session) => session.route === "local" && session.nativeHarness) ?? recent[0];
|
|
720
|
+
return previous ? { ...newConversationSession(state, previous, now), workspace } : firstEverSession(state, workspace, now);
|
|
721
|
+
}
|
|
722
|
+
async function aiSessionShow(id) {
|
|
723
|
+
const state = await readState({ transcripts: [id] });
|
|
724
|
+
const session = state.sessions.find((item) => item.id === id);
|
|
725
|
+
if (!session) throw new Error(`AI session "${id}" was not found`);
|
|
726
|
+
emitResult({ session });
|
|
727
|
+
}
|
|
728
|
+
async function endSession(id, intent) {
|
|
729
|
+
const state = await readState({ transcripts: [id] });
|
|
730
|
+
const session = state.sessions.find((item) => item.id === id);
|
|
731
|
+
if (!session) throw new Error(`AI session "${id}" was not found`);
|
|
732
|
+
const announce = () => {
|
|
733
|
+
if (intent === "close") emitHarnessOutput({ panel: "session-closed", sessionId: session.id, closed: true });
|
|
734
|
+
};
|
|
735
|
+
if (intent === "close") {
|
|
736
|
+
await releaseHeldLocalModel(session.id);
|
|
737
|
+
}
|
|
738
|
+
if (isBlankConversation(session)) {
|
|
739
|
+
deleteConversations(state, [id]);
|
|
740
|
+
await writeState(state);
|
|
741
|
+
return announce();
|
|
742
|
+
}
|
|
743
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
744
|
+
if (intent === "close") {
|
|
745
|
+
if (session.status !== "closed") {
|
|
746
|
+
session.status = "closed";
|
|
747
|
+
session.closedAt = now;
|
|
748
|
+
session.updatedAt = now;
|
|
749
|
+
await writeState(state);
|
|
750
|
+
}
|
|
751
|
+
} else {
|
|
752
|
+
session.status = "active";
|
|
753
|
+
delete session.closedAt;
|
|
754
|
+
session.updatedAt = now;
|
|
755
|
+
await writeState(state);
|
|
756
|
+
}
|
|
757
|
+
announce();
|
|
758
|
+
}
|
|
759
|
+
var aiSessionClose = (id) => endSession(id, "close");
|
|
760
|
+
var aiSessionLeave = (id) => endSession(id, "leave");
|
|
761
|
+
async function aiSessionSet(id, options) {
|
|
762
|
+
if (options.route !== void 0 && !isAiHarnessRoute(options.route)) throw new Error(ROUTE_CHOICES_TEXT);
|
|
763
|
+
const sandbox = options.sandbox === void 0 ? void 0 : parseSandboxMode(options.sandbox);
|
|
764
|
+
if (options.sandbox !== void 0 && !sandbox) throw new Error("sandbox must be off or workspace");
|
|
765
|
+
if (options.permissions !== void 0 && !VALID_PERMISSION_MODES.includes(options.permissions)) throw new Error("permissions must be ask, bypass, or auto");
|
|
766
|
+
const state = await readState({ transcripts: [id] });
|
|
767
|
+
const index = state.sessions.findIndex((item) => item.id === id);
|
|
768
|
+
if (index < 0) throw new Error(`AI session "${id}" was not found`);
|
|
769
|
+
const current = state.sessions[index];
|
|
770
|
+
const effectiveRoute = options.route ?? current.route;
|
|
771
|
+
if (options.agent !== void 0 && effectiveRoute !== "gateway") throw new Error("A Gateway agent requires the Gateway route.");
|
|
772
|
+
const gatewayAgentId = options.agent !== void 0 ? await gatewayAgentChoice(options.agent) : void 0;
|
|
773
|
+
if (effectiveRoute === "gateway" && (options.account || options.provider || options.nativeSession)) {
|
|
774
|
+
throw new Error("ClikDeploy Gateway account, provider, and native sessions are selected by platform routing and cannot be overridden per session.");
|
|
775
|
+
}
|
|
776
|
+
if (effectiveRoute === "gateway" && options.effort && options.effort !== "default" && !GATEWAY_EFFORTS.includes(options.effort)) {
|
|
777
|
+
throw new Error(`ClikDeploy Gateway effort must be one of default, ${GATEWAY_EFFORTS.join(", ")}`);
|
|
778
|
+
}
|
|
779
|
+
const gatewayModel = effectiveRoute === "gateway" && options.model !== void 0 ? await chooseGatewayModel(options.model) : void 0;
|
|
780
|
+
if (effectiveRoute === "clikcode-local" && (options.account || options.provider || options.effort || options.nativeSession)) {
|
|
781
|
+
throw new Error(CLIKCODE_LOCAL_FIXED_FIELDS);
|
|
782
|
+
}
|
|
783
|
+
const account = options.account === void 0 ? void 0 : findAccount(state, options.account, options.provider ?? current.provider);
|
|
784
|
+
if (options.account !== void 0 && !account) throw new Error(`No account named "${options.account}"`);
|
|
785
|
+
if (account && options.provider && options.provider !== account.provider) {
|
|
786
|
+
throw new Error(`account "${account.label}" belongs to ${account.provider}, not ${options.provider}`);
|
|
787
|
+
}
|
|
788
|
+
if (!account && options.provider && current.accountId) {
|
|
789
|
+
const currentAccount = state.accounts.find((item) => item.id === current.accountId);
|
|
790
|
+
if (currentAccount && currentAccount.provider !== options.provider) {
|
|
791
|
+
throw new Error(`account "${currentAccount.label}" belongs to ${currentAccount.provider}; select a matching account when changing provider`);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
if (options.nativeSession !== void 0) {
|
|
795
|
+
if (!current.nativeHarness) throw new Error("launch a native harness for this ClikCode session before attaching its native session id");
|
|
796
|
+
const harness = localHarnessForCommand(current.nativeHarness);
|
|
797
|
+
if (!harness?.session?.resumeIdPrefix) throw new Error(`${harness?.displayName ?? current.nativeHarness} does not declare exact native-session resume support`);
|
|
798
|
+
if (!options.nativeSession.trim()) throw new Error("native session id cannot be empty");
|
|
799
|
+
}
|
|
800
|
+
const selectedHarness = account ? localHarnessForProvider(account.provider) : options.provider ? localHarnessForProvider(options.provider) : current.nativeHarness ? localHarnessForCommand(current.nativeHarness) : void 0;
|
|
801
|
+
if (effectiveRoute === "local" && (options.account || options.provider) && !selectedHarness) {
|
|
802
|
+
throw new Error(`unknown local provider "${options.provider ?? account?.provider}"`);
|
|
803
|
+
}
|
|
804
|
+
const model = options.model === void 0 ? void 0 : effectiveRoute === "gateway" ? gatewayModel ?? null : effectiveRoute === "clikcode-local" ? resolveLocalModelId(options.model) : normalizeModelWord(options.model);
|
|
805
|
+
if (model && effectiveRoute !== "gateway" && effectiveRoute !== "clikcode-local" && selectedHarness && !harnessSupportsModelSelection(selectedHarness)) {
|
|
806
|
+
throw new Error(`${selectedHarness.displayName} does not publish a model selector.`);
|
|
807
|
+
}
|
|
808
|
+
if (model && effectiveRoute !== "gateway") await assertRealModel(selectedHarness, account ?? state.accounts.find((item) => item.id === current.accountId), model);
|
|
809
|
+
if (options.effort && selectedHarness) {
|
|
810
|
+
const effortOption = optionForHarness(selectedHarness, "effort");
|
|
811
|
+
if (!effortOption) throw new Error(`${selectedHarness.displayName} does not publish a configurable reasoning-effort flag.`);
|
|
812
|
+
const effortAccount = account ?? state.accounts.find((item) => item.id === current.accountId);
|
|
813
|
+
const choices = (await effortChoicesFor(selectedHarness, effortAccount, model ?? current.model)).values;
|
|
814
|
+
parseHarnessOption(choices.length ? { ...effortOption, values: choices } : effortOption, options.effort);
|
|
815
|
+
}
|
|
816
|
+
if (sandbox && !isClikCodeAgent({ route: effectiveRoute })) throw new Error("The sandbox applies to ClikCode's own agent (the gateway or clikcode-local route).");
|
|
817
|
+
if (options.permissions && !sessionPermissionModes({ route: effectiveRoute }, selectedHarness).includes(options.permissions)) {
|
|
818
|
+
if (!selectedHarness) throw new Error("Choose a provider before setting permissions.");
|
|
819
|
+
throw new Error(`${selectedHarness.displayName} does not support ${options.permissions} permissions.`);
|
|
820
|
+
}
|
|
821
|
+
const base = { ...current };
|
|
822
|
+
if (base.nativeHarness && (effectiveRoute !== "local" || selectedHarness && selectedHarness.command !== base.nativeHarness)) {
|
|
823
|
+
leaveVendorForRoute(base);
|
|
824
|
+
}
|
|
825
|
+
if (options.route === "local" && isClikCodeAgent(current)) applyFreshLocalSessionPolicy(state, base);
|
|
826
|
+
const next = {
|
|
827
|
+
...base,
|
|
828
|
+
...options.route ? { route: options.route } : {},
|
|
829
|
+
...account ? { accountId: account.id, provider: options.provider ?? account.provider } : {},
|
|
830
|
+
...options.provider ? { provider: options.provider } : {},
|
|
831
|
+
...options.model !== void 0 ? { model } : {},
|
|
832
|
+
...options.effort ? { effort: effectiveRoute === "gateway" && options.effort === "default" ? GATEWAY_DEFAULT_EFFORT : options.effort } : {},
|
|
833
|
+
...options.permissions ? { permissionMode: options.permissions } : {},
|
|
834
|
+
...sandbox === "off" ? { sandbox } : {},
|
|
835
|
+
...options.nativeSession !== void 0 ? { nativeSessionId: options.nativeSession.trim() } : {},
|
|
836
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
837
|
+
};
|
|
838
|
+
if (sandbox === "workspace") delete next.sandbox;
|
|
839
|
+
if (effectiveRoute !== "gateway") {
|
|
840
|
+
delete next.gatewayAgentId;
|
|
841
|
+
delete next.gatewayAgentThreadId;
|
|
842
|
+
delete next.gatewayAgentName;
|
|
843
|
+
} else if (options.agent !== void 0) {
|
|
844
|
+
if (gatewayAgentId !== next.gatewayAgentId) {
|
|
845
|
+
delete next.gatewayAgentThreadId;
|
|
846
|
+
delete next.gatewayAgentName;
|
|
847
|
+
}
|
|
848
|
+
if (gatewayAgentId) next.gatewayAgentId = gatewayAgentId;
|
|
849
|
+
else delete next.gatewayAgentId;
|
|
850
|
+
}
|
|
851
|
+
if (effectiveRoute === "gateway" || effectiveRoute === "clikcode-local") applyClikCodeAgentSessionPolicy(next, effectiveRoute, state);
|
|
852
|
+
else if (account) {
|
|
853
|
+
if (turnBackendForAccount(account) === "vendor" && selectedHarness && harnessCanRunTurns(selectedHarness)) {
|
|
854
|
+
if (next.nativeHarness !== selectedHarness.command) parkNativeThread(next);
|
|
855
|
+
next.nativeHarness = selectedHarness.command;
|
|
856
|
+
} else {
|
|
857
|
+
parkNativeThread(next);
|
|
858
|
+
delete next.nativeHarness;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
if (effectiveRoute === "local" && (options.provider || options.account) && selectedHarness && harnessCanRunTurns(selectedHarness) && await ensureNativeHarness(selectedHarness)) {
|
|
862
|
+
return aiSessionSet(id, options);
|
|
863
|
+
}
|
|
864
|
+
state.sessions[index] = next;
|
|
865
|
+
await writeState(state);
|
|
866
|
+
emitResult({ session: next });
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
export {
|
|
870
|
+
gatewayAgents,
|
|
871
|
+
assertRealModel,
|
|
872
|
+
chooseGatewayModel,
|
|
873
|
+
selectGatewayAgent,
|
|
874
|
+
applyGatewaySessionPolicy,
|
|
875
|
+
applyClikCodeLocalSessionPolicy,
|
|
876
|
+
applyClikCodeAgentSessionPolicy,
|
|
877
|
+
applyFreshLocalSessionPolicy,
|
|
878
|
+
aiSessionCreate,
|
|
879
|
+
aiSessionsList,
|
|
880
|
+
launchSession,
|
|
881
|
+
aiSessionShow,
|
|
882
|
+
aiSessionClose,
|
|
883
|
+
aiSessionLeave,
|
|
884
|
+
aiSessionSet,
|
|
885
|
+
accountHasUsage,
|
|
886
|
+
sessionProviderHasUsage,
|
|
887
|
+
resumePromptForPendingTurn,
|
|
888
|
+
waitForReset,
|
|
889
|
+
stopWaitingForReset,
|
|
890
|
+
activateSession,
|
|
891
|
+
openConversation,
|
|
892
|
+
resolveSessionModel,
|
|
893
|
+
claimConversation,
|
|
894
|
+
releaseConversationClaim,
|
|
895
|
+
leaveConversation,
|
|
896
|
+
prepareTurn,
|
|
897
|
+
afterTurnFailure,
|
|
898
|
+
newConversationSession,
|
|
899
|
+
releaseQueuedTurn,
|
|
900
|
+
takeQueuedMessages,
|
|
901
|
+
newConversation,
|
|
902
|
+
turnIsRunning,
|
|
903
|
+
refuseWhileTurnRuns,
|
|
904
|
+
moveToProvider
|
|
905
|
+
};
|