token-goat 2.9.29 → 2.9.31
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 +53 -42
- package/SECURITY.md +37 -11
- package/THIRD_PARTY_NOTICES.md +41 -4
- package/dist/native/linux-arm64/tg-hook +0 -0
- package/dist/native/linux-x64/tg-hook +0 -0
- package/dist/native/win32-arm64/tg-hook.exe +0 -0
- package/dist/native/win32-x64/tg-hook.exe +0 -0
- package/dist/ort-wasm-simd-threaded.mjs +59 -0
- package/dist/{token-goat-chunk-SE6E4BKJ.mjs → token-goat-chunk-25TRAWET.mjs} +23 -6
- package/dist/token-goat-chunk-2KXO6V2B.mjs +203 -0
- package/dist/{token-goat-chunk-UXSXQQIY.mjs → token-goat-chunk-2M7E4PF7.mjs} +43 -14
- package/dist/token-goat-chunk-2UPZGKKY.mjs +188 -0
- package/dist/token-goat-chunk-2WLPWKHV.mjs +135 -0
- package/dist/token-goat-chunk-2XBMMDBD.mjs +126 -0
- package/dist/token-goat-chunk-32ZOY4N5.mjs +23 -0
- package/dist/token-goat-chunk-3EZRNKTK.mjs +188 -0
- package/dist/token-goat-chunk-4ADZHI7J.mjs +63 -0
- package/dist/token-goat-chunk-4GBVPH3D.mjs +242 -0
- package/dist/{token-goat-chunk-2WOUYWLM.mjs → token-goat-chunk-4GILLLWY.mjs} +34 -7
- package/dist/token-goat-chunk-4NAPX7BA.mjs +90 -0
- package/dist/{token-goat-chunk-NMBWLRHW.mjs → token-goat-chunk-4SC7UJYV.mjs} +9981 -11563
- package/dist/token-goat-chunk-4SMRO4TO.mjs +366 -0
- package/dist/{token-goat-chunk-O6I2XU4P.mjs → token-goat-chunk-4ZBFWLXF.mjs} +310 -441
- package/dist/token-goat-chunk-57BIAXJL.mjs +286 -0
- package/dist/token-goat-chunk-5AC66HNP.mjs +115 -0
- package/dist/token-goat-chunk-5IMLKSOP.mjs +145 -0
- package/dist/token-goat-chunk-5RG5SBL6.mjs +221 -0
- package/dist/{token-goat-chunk-RRNZMM3A.mjs → token-goat-chunk-5Y6ZYL6U.mjs} +21 -2
- package/dist/token-goat-chunk-646E6U44.mjs +398 -0
- package/dist/token-goat-chunk-65N4RHP4.mjs +33 -0
- package/dist/{token-goat-chunk-6AK46ZT7.mjs → token-goat-chunk-6DG6HWP3.mjs} +13 -3
- package/dist/token-goat-chunk-6ENQSNRZ.mjs +573 -0
- package/dist/token-goat-chunk-6ZY4GNF2.mjs +91 -0
- package/dist/{token-goat-chunk-E5TK5DNO.mjs → token-goat-chunk-76FGDLRO.mjs} +574 -340
- package/dist/{token-goat-chunk-TGOXNAHW.mjs → token-goat-chunk-7EZTZOMC.mjs} +780 -767
- package/dist/token-goat-chunk-7MAOA6X4.mjs +3647 -0
- package/dist/token-goat-chunk-7R2ZVVAX.mjs +218 -0
- package/dist/{token-goat-chunk-TCQANXYC.mjs → token-goat-chunk-AM5V6GSX.mjs} +18 -2
- package/dist/token-goat-chunk-AUNGYYQX.mjs +184 -0
- package/dist/token-goat-chunk-AUQYRMMH.mjs +2985 -0
- package/dist/token-goat-chunk-B3PEKBYG.mjs +128 -0
- package/dist/{token-goat-chunk-KOPIR3KZ.mjs → token-goat-chunk-BA4HI6BW.mjs} +1910 -165
- package/dist/{token-goat-chunk-52NSDWYY.mjs → token-goat-chunk-BFCWY73P.mjs} +58 -20
- package/dist/token-goat-chunk-BPGCUMR7.mjs +30 -0
- package/dist/token-goat-chunk-BWGFUZZE.mjs +25 -0
- package/dist/token-goat-chunk-C75NA7PL.mjs +322 -0
- package/dist/token-goat-chunk-CBIQ7WTD.mjs +87 -0
- package/dist/token-goat-chunk-CETM74KC.mjs +307 -0
- package/dist/token-goat-chunk-CIMQ2BB3.mjs +233 -0
- package/dist/{token-goat-chunk-DNSPXQXQ.mjs → token-goat-chunk-CJLS3CDL.mjs} +70 -18
- package/dist/{token-goat-chunk-MELOKFDJ.mjs → token-goat-chunk-CO3UYX6G.mjs} +7 -1
- package/dist/token-goat-chunk-COPNXRJM.mjs +154 -0
- package/dist/token-goat-chunk-CSJ5L3NL.mjs +479 -0
- package/dist/token-goat-chunk-CVCEVUGK.mjs +315 -0
- package/dist/token-goat-chunk-CXHOFN7R.mjs +371 -0
- package/dist/token-goat-chunk-D735C4QM.mjs +603 -0
- package/dist/{token-goat-chunk-E4ZOJIZK.mjs → token-goat-chunk-DGS2LVNA.mjs} +70 -160
- package/dist/{token-goat-chunk-L7H3U27L.mjs → token-goat-chunk-DOWRSMWO.mjs} +1 -1
- package/dist/token-goat-chunk-E45INMY3.mjs +71 -0
- package/dist/token-goat-chunk-EC5F37F4.mjs +244 -0
- package/dist/{token-goat-chunk-XTQAOTSO.mjs → token-goat-chunk-EDBDRVH5.mjs} +4 -1
- package/dist/token-goat-chunk-EELTBKDM.mjs +613 -0
- package/dist/token-goat-chunk-EVMZJ27Z.mjs +147 -0
- package/dist/token-goat-chunk-EXKGNHEG.mjs +2096 -0
- package/dist/{token-goat-chunk-YOOVFPTP.mjs → token-goat-chunk-F4HYL64R.mjs} +12 -2
- package/dist/token-goat-chunk-F6PAUIEK.mjs +624 -0
- package/dist/token-goat-chunk-FDSREWLX.mjs +692 -0
- package/dist/{token-goat-chunk-NMTKNYGF.mjs → token-goat-chunk-FNFBKLRD.mjs} +74 -9
- package/dist/token-goat-chunk-G5PJ7AGM.mjs +36 -0
- package/dist/token-goat-chunk-GGGG7RWB.mjs +236 -0
- package/dist/{token-goat-chunk-TDUT2CL6.mjs → token-goat-chunk-GL3ETKSC.mjs} +276 -19
- package/dist/{token-goat-chunk-7CPMDFGB.mjs → token-goat-chunk-GVB2MUST.mjs} +265 -1567
- package/dist/token-goat-chunk-GWFLAUMQ.mjs +307 -0
- package/dist/token-goat-chunk-HAVAOB3S.mjs +87 -0
- package/dist/token-goat-chunk-HLPW63A7.mjs +48 -0
- package/dist/token-goat-chunk-HU4TORC5.mjs +1377 -0
- package/dist/token-goat-chunk-I7VKZZAW.mjs +35 -0
- package/dist/token-goat-chunk-IA6XSPE3.mjs +218 -0
- package/dist/token-goat-chunk-IAGXMHIK.mjs +863 -0
- package/dist/{token-goat-chunk-435UQTKD.mjs → token-goat-chunk-IK2DRMFX.mjs} +129 -74
- package/dist/{token-goat-chunk-ZER6EAXZ.mjs → token-goat-chunk-INNPTRUX.mjs} +2954 -2783
- package/dist/token-goat-chunk-JJ5BX4F4.mjs +129 -0
- package/dist/token-goat-chunk-JVFSHVFJ.mjs +129 -0
- package/dist/token-goat-chunk-KGEFFSHD.mjs +50 -0
- package/dist/token-goat-chunk-KKUFXAPD.mjs +25 -0
- package/dist/token-goat-chunk-KQBLRPBN.mjs +433 -0
- package/dist/token-goat-chunk-LCNQ2CNN.mjs +497 -0
- package/dist/token-goat-chunk-M3LFJDPU.mjs +58 -0
- package/dist/token-goat-chunk-M52KPT3C.mjs +87 -0
- package/dist/token-goat-chunk-MBEG42H7.mjs +150 -0
- package/dist/{token-goat-chunk-EVC4TOLE.mjs → token-goat-chunk-METECDOH.mjs} +3 -12
- package/dist/{token-goat-chunk-2AWQ2R5X.mjs → token-goat-chunk-MHX7XCC3.mjs} +3 -2
- package/dist/token-goat-chunk-MNWKPRAL.mjs +13 -0
- package/dist/token-goat-chunk-N5LSOVSU.mjs +137 -0
- package/dist/{token-goat-chunk-DPNLUJWB.mjs → token-goat-chunk-N5MMR2IW.mjs} +30 -8
- package/dist/token-goat-chunk-N7B3JQ2C.mjs +160 -0
- package/dist/{token-goat-chunk-VMFWNHGR.mjs → token-goat-chunk-NISNMD7T.mjs} +2545 -2953
- package/dist/token-goat-chunk-NMD42SFQ.mjs +434 -0
- package/dist/token-goat-chunk-NOSS5VWY.mjs +174 -0
- package/dist/token-goat-chunk-NSNSPPBG.mjs +69 -0
- package/dist/token-goat-chunk-OBOFIHKN.mjs +38 -0
- package/dist/token-goat-chunk-OBRFJ5O5.mjs +76 -0
- package/dist/token-goat-chunk-ODBT2USM.mjs +800 -0
- package/dist/token-goat-chunk-OS5EM5PP.mjs +107 -0
- package/dist/token-goat-chunk-OUKDTVNU.mjs +1178 -0
- package/dist/token-goat-chunk-OXFMP75N.mjs +566 -0
- package/dist/{token-goat-chunk-ASLWOQ3I.mjs → token-goat-chunk-OYIYKDDT.mjs} +2 -1
- package/dist/{token-goat-chunk-67BNIKKO.mjs → token-goat-chunk-P6HQSWQ3.mjs} +55 -47
- package/dist/token-goat-chunk-P6VGNTQT.mjs +71 -0
- package/dist/token-goat-chunk-PFWIMH2E.mjs +261 -0
- package/dist/token-goat-chunk-PJZXIS3G.mjs +39 -0
- package/dist/token-goat-chunk-PUO5INXP.mjs +606 -0
- package/dist/token-goat-chunk-PX5PQWTY.mjs +462 -0
- package/dist/token-goat-chunk-Q5QDBC6O.mjs +111 -0
- package/dist/token-goat-chunk-QFNQXSDT.mjs +40 -0
- package/dist/token-goat-chunk-QH7YVYOY.mjs +3957 -0
- package/dist/token-goat-chunk-QLMUHEPB.mjs +43 -0
- package/dist/{token-goat-chunk-PYSUADX4.mjs → token-goat-chunk-QQOJIHL3.mjs} +50 -14
- package/dist/token-goat-chunk-QQTWJY2O.mjs +85 -0
- package/dist/token-goat-chunk-QYHO5CPH.mjs +93 -0
- package/dist/token-goat-chunk-RELAVWAD.mjs +27 -0
- package/dist/token-goat-chunk-RSLPOBKQ.mjs +339 -0
- package/dist/token-goat-chunk-SAMFDIS2.mjs +712 -0
- package/dist/token-goat-chunk-SDELXLDM.mjs +48 -0
- package/dist/{token-goat-chunk-PGTH2U4C.mjs → token-goat-chunk-SOAFZNNZ.mjs} +164 -40
- package/dist/{token-goat-chunk-G23DWHV4.mjs → token-goat-chunk-SRTHT7KV.mjs} +33 -15
- package/dist/token-goat-chunk-T5P5ACNQ.mjs +212 -0
- package/dist/token-goat-chunk-T5YGG4V3.mjs +45 -0
- package/dist/token-goat-chunk-TAUZ4OFS.mjs +110 -0
- package/dist/token-goat-chunk-TM6MC754.mjs +40 -0
- package/dist/token-goat-chunk-TWUKBOMP.mjs +72 -0
- package/dist/token-goat-chunk-U2KSB4SG.mjs +56 -0
- package/dist/token-goat-chunk-U4WHMG6Y.mjs +898 -0
- package/dist/token-goat-chunk-UA5V6P3P.mjs +122 -0
- package/dist/token-goat-chunk-UGJHGR5A.mjs +52 -0
- package/dist/{token-goat-chunk-RQGGMPCR.mjs → token-goat-chunk-UOUDVA5U.mjs} +76 -16
- package/dist/{token-goat-chunk-HNFZZHFW.mjs → token-goat-chunk-URRJ33GR.mjs} +22 -4
- package/dist/token-goat-chunk-UZOROKIS.mjs +165 -0
- package/dist/token-goat-chunk-VIHGGGEI.mjs +4234 -0
- package/dist/token-goat-chunk-VTJLAA7P.mjs +21 -0
- package/dist/token-goat-chunk-VWDXLT4F.mjs +678 -0
- package/dist/token-goat-chunk-VWZA2H4P.mjs +368 -0
- package/dist/{token-goat-chunk-QO3LXVVR.mjs → token-goat-chunk-VXEXMJDL.mjs} +2964 -3153
- package/dist/token-goat-chunk-WBA5SKT4.mjs +547 -0
- package/dist/{token-goat-chunk-ONXH6NZ5.mjs → token-goat-chunk-WDH44VAU.mjs} +19 -22
- package/dist/token-goat-chunk-X2SUP3EI.mjs +107 -0
- package/dist/token-goat-chunk-X3BELZSJ.mjs +125 -0
- package/dist/{token-goat-chunk-RLP6J7WR.mjs → token-goat-chunk-XLRBNZCC.mjs} +40 -21
- package/dist/{token-goat-chunk-S4VSXURL.mjs → token-goat-chunk-XRKUX6CM.mjs} +4 -0
- package/dist/token-goat-chunk-XX6O25RN.mjs +82 -0
- package/dist/token-goat-chunk-XZSUHBVS.mjs +65 -0
- package/dist/token-goat-chunk-Y2ZTQOCL.mjs +35 -0
- package/dist/{token-goat-chunk-UA5BKWWQ.mjs → token-goat-chunk-YB4VMGK2.mjs} +15 -4
- package/dist/token-goat-chunk-YBIIY3HR.mjs +51 -0
- package/dist/{token-goat-chunk-PKRWMHVP.mjs → token-goat-chunk-YHVDKQBR.mjs} +389 -221
- package/dist/token-goat-chunk-YJB5XLWI.mjs +26 -0
- package/dist/{token-goat-chunk-PQ53BSCF.mjs → token-goat-chunk-YKB6AQG3.mjs} +53 -31
- package/dist/token-goat-chunk-YMTG2YA5.mjs +35 -0
- package/dist/token-goat-chunk-YPBZYQRV.mjs +40 -0
- package/dist/{token-goat-chunk-HUYUHODZ.mjs → token-goat-chunk-YY6AVUFL.mjs} +13246 -12247
- package/dist/token-goat-chunk-Z7N5OMMP.mjs +98 -0
- package/dist/{token-goat-chunk-BGHSSJUA.mjs → token-goat-chunk-ZFOBKUWH.mjs} +1 -1
- package/dist/token-goat-chunk-ZMBL6UVV.mjs +110 -0
- package/dist/token-goat-chunk-ZNMNUPAZ.mjs +938 -0
- package/dist/token-goat-hook-client.cjs +87 -23
- package/dist/token-goat-hook-client.mjs +3 -3
- package/dist/token-goat-hook.mjs +76 -31
- package/dist/token-goat.core.mjs +6 -6
- package/docs/C4_RUNTIME_ARCHITECTURE.md +2 -2
- package/docs/cli.md +113 -60
- package/docs/install.md +63 -20
- package/docs/security.md +10 -8
- package/package.json +18 -7
- package/scripts/verify-native-dist.mjs +386 -0
- package/dist/token-goat-chunk-2NNUA2LR.mjs +0 -143
- package/dist/token-goat-chunk-44BM7DDQ.mjs +0 -294
- package/dist/token-goat-chunk-BGYOZ6DO.mjs +0 -24
- package/dist/token-goat-chunk-C5YPNZKQ.mjs +0 -318
- package/dist/token-goat-chunk-CIQ2FTY3.mjs +0 -1990
- package/dist/token-goat-chunk-D4ETHJD6.mjs +0 -246
- package/dist/token-goat-chunk-DNRPXHYH.mjs +0 -1062
- package/dist/token-goat-chunk-EUSDXRXU.mjs +0 -1429
- package/dist/token-goat-chunk-FTP4U4QA.mjs +0 -64
- package/dist/token-goat-chunk-G7IWXCFF.mjs +0 -456
- package/dist/token-goat-chunk-GLXRTTLE.mjs +0 -36
- package/dist/token-goat-chunk-H5J3C56Q.mjs +0 -1511
- package/dist/token-goat-chunk-IVWI2OCK.mjs +0 -368
- package/dist/token-goat-chunk-JTKCQMQA.mjs +0 -418
- package/dist/token-goat-chunk-LZNBQTDK.mjs +0 -26
- package/dist/token-goat-chunk-ORNFMIER.mjs +0 -295
- package/dist/token-goat-chunk-RTMVLHWX.mjs +0 -7113
- package/dist/token-goat-chunk-VQ6F6T7X.mjs +0 -36
- package/dist/token-goat-chunk-VZQEWRVH.mjs +0 -312
- package/dist/token-goat-chunk-XYWPOSCN.mjs +0 -807
- package/dist/token-goat-chunk-YAGLESS3.mjs +0 -23
- package/dist/token-goat-chunk-YKSRAWUU.mjs +0 -33
- package/dist/token-goat-chunk-Z6KBMOBI.mjs +0 -53
|
@@ -0,0 +1,863 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
serveOne,
|
|
5
|
+
swapEnv
|
|
6
|
+
} from "./token-goat-chunk-XRKUX6CM.mjs";
|
|
7
|
+
import {
|
|
8
|
+
relayInProcess
|
|
9
|
+
} from "./token-goat-chunk-VXEXMJDL.mjs";
|
|
10
|
+
import "./token-goat-chunk-Q5QDBC6O.mjs";
|
|
11
|
+
import "./token-goat-chunk-G5PJ7AGM.mjs";
|
|
12
|
+
import "./token-goat-chunk-5RG5SBL6.mjs";
|
|
13
|
+
import "./token-goat-chunk-HLPW63A7.mjs";
|
|
14
|
+
import {
|
|
15
|
+
HOOK_EVENTS
|
|
16
|
+
} from "./token-goat-chunk-KKUFXAPD.mjs";
|
|
17
|
+
import "./token-goat-chunk-6ENQSNRZ.mjs";
|
|
18
|
+
import "./token-goat-chunk-PX5PQWTY.mjs";
|
|
19
|
+
import "./token-goat-chunk-VWDXLT4F.mjs";
|
|
20
|
+
import "./token-goat-chunk-DOWRSMWO.mjs";
|
|
21
|
+
import "./token-goat-chunk-5AC66HNP.mjs";
|
|
22
|
+
import "./token-goat-chunk-PUO5INXP.mjs";
|
|
23
|
+
import "./token-goat-chunk-2XBMMDBD.mjs";
|
|
24
|
+
import "./token-goat-chunk-PFWIMH2E.mjs";
|
|
25
|
+
import "./token-goat-chunk-Z7N5OMMP.mjs";
|
|
26
|
+
import "./token-goat-chunk-LCNQ2CNN.mjs";
|
|
27
|
+
import "./token-goat-chunk-GWFLAUMQ.mjs";
|
|
28
|
+
import "./token-goat-chunk-PJZXIS3G.mjs";
|
|
29
|
+
import "./token-goat-chunk-JVFSHVFJ.mjs";
|
|
30
|
+
import "./token-goat-chunk-ODBT2USM.mjs";
|
|
31
|
+
import "./token-goat-chunk-DGS2LVNA.mjs";
|
|
32
|
+
import "./token-goat-chunk-INNPTRUX.mjs";
|
|
33
|
+
import "./token-goat-chunk-VWZA2H4P.mjs";
|
|
34
|
+
import "./token-goat-chunk-N5LSOVSU.mjs";
|
|
35
|
+
import "./token-goat-chunk-OBOFIHKN.mjs";
|
|
36
|
+
import {
|
|
37
|
+
primeHiddenRulesAhead,
|
|
38
|
+
primeManagedPolicyAhead
|
|
39
|
+
} from "./token-goat-chunk-QH7YVYOY.mjs";
|
|
40
|
+
import "./token-goat-chunk-NOSS5VWY.mjs";
|
|
41
|
+
import "./token-goat-chunk-NMD42SFQ.mjs";
|
|
42
|
+
import "./token-goat-chunk-SAMFDIS2.mjs";
|
|
43
|
+
import "./token-goat-chunk-4SMRO4TO.mjs";
|
|
44
|
+
import "./token-goat-chunk-WBA5SKT4.mjs";
|
|
45
|
+
import "./token-goat-chunk-MNWKPRAL.mjs";
|
|
46
|
+
import "./token-goat-chunk-CIMQ2BB3.mjs";
|
|
47
|
+
import "./token-goat-chunk-WDH44VAU.mjs";
|
|
48
|
+
import "./token-goat-chunk-BPGCUMR7.mjs";
|
|
49
|
+
import "./token-goat-chunk-KQBLRPBN.mjs";
|
|
50
|
+
import "./token-goat-chunk-4ZBFWLXF.mjs";
|
|
51
|
+
import {
|
|
52
|
+
materializeShrunkImageFile
|
|
53
|
+
} from "./token-goat-chunk-C75NA7PL.mjs";
|
|
54
|
+
import "./token-goat-chunk-CBIQ7WTD.mjs";
|
|
55
|
+
import "./token-goat-chunk-P6VGNTQT.mjs";
|
|
56
|
+
import {
|
|
57
|
+
COPILOT_CLI_TOOL_NAME_MAP,
|
|
58
|
+
foldToolName
|
|
59
|
+
} from "./token-goat-chunk-76FGDLRO.mjs";
|
|
60
|
+
import "./token-goat-chunk-GL3ETKSC.mjs";
|
|
61
|
+
import "./token-goat-chunk-OXFMP75N.mjs";
|
|
62
|
+
import "./token-goat-chunk-NISNMD7T.mjs";
|
|
63
|
+
import "./token-goat-chunk-EVMZJ27Z.mjs";
|
|
64
|
+
import "./token-goat-chunk-IK2DRMFX.mjs";
|
|
65
|
+
import "./token-goat-chunk-5Y6ZYL6U.mjs";
|
|
66
|
+
import "./token-goat-chunk-4NAPX7BA.mjs";
|
|
67
|
+
import "./token-goat-chunk-U4WHMG6Y.mjs";
|
|
68
|
+
import {
|
|
69
|
+
limitDbWaitsForHook
|
|
70
|
+
} from "./token-goat-chunk-GVB2MUST.mjs";
|
|
71
|
+
import "./token-goat-chunk-XB5KKOCG.mjs";
|
|
72
|
+
import "./token-goat-chunk-OUKDTVNU.mjs";
|
|
73
|
+
import "./token-goat-chunk-3BTK54F3.mjs";
|
|
74
|
+
import "./token-goat-chunk-4GILLLWY.mjs";
|
|
75
|
+
import {
|
|
76
|
+
HARNESS_PROTOCOL_VERSION,
|
|
77
|
+
PROTOCOL_VERSION,
|
|
78
|
+
SERVER_SLOTS,
|
|
79
|
+
bundleEntryFiles,
|
|
80
|
+
challengeMacV2,
|
|
81
|
+
configStamp,
|
|
82
|
+
doneFrameMac,
|
|
83
|
+
endpointFor,
|
|
84
|
+
ensureServerKey,
|
|
85
|
+
mac,
|
|
86
|
+
macMatches,
|
|
87
|
+
nonce,
|
|
88
|
+
outFrameMac,
|
|
89
|
+
readFrames,
|
|
90
|
+
removeMarker,
|
|
91
|
+
requestMacV2,
|
|
92
|
+
serverKeyPath,
|
|
93
|
+
touchMarker,
|
|
94
|
+
writeFrame
|
|
95
|
+
} from "./token-goat-chunk-N5MMR2IW.mjs";
|
|
96
|
+
import "./token-goat-chunk-BFCWY73P.mjs";
|
|
97
|
+
import "./token-goat-chunk-KGEFFSHD.mjs";
|
|
98
|
+
import "./token-goat-chunk-XX6O25RN.mjs";
|
|
99
|
+
import "./token-goat-chunk-HAVAOB3S.mjs";
|
|
100
|
+
import "./token-goat-chunk-F6PAUIEK.mjs";
|
|
101
|
+
import "./token-goat-chunk-65N4RHP4.mjs";
|
|
102
|
+
import "./token-goat-chunk-X2SUP3EI.mjs";
|
|
103
|
+
import "./token-goat-chunk-T5P5ACNQ.mjs";
|
|
104
|
+
import {
|
|
105
|
+
hookServerEnabled,
|
|
106
|
+
ownGet
|
|
107
|
+
} from "./token-goat-chunk-7EZTZOMC.mjs";
|
|
108
|
+
import "./token-goat-chunk-QYHO5CPH.mjs";
|
|
109
|
+
import "./token-goat-chunk-4GBVPH3D.mjs";
|
|
110
|
+
import {
|
|
111
|
+
clearPerRequestCaches
|
|
112
|
+
} from "./token-goat-chunk-YZAAZU2S.mjs";
|
|
113
|
+
import "./token-goat-chunk-IVE6U7KV.mjs";
|
|
114
|
+
import "./token-goat-chunk-Y4AFKTHK.mjs";
|
|
115
|
+
import "./token-goat-chunk-HU4TORC5.mjs";
|
|
116
|
+
import "./token-goat-chunk-GGGG7RWB.mjs";
|
|
117
|
+
import "./token-goat-chunk-AM5V6GSX.mjs";
|
|
118
|
+
import "./token-goat-chunk-FNFBKLRD.mjs";
|
|
119
|
+
import {
|
|
120
|
+
VERSION,
|
|
121
|
+
configPath,
|
|
122
|
+
ensureDataDirPrivate
|
|
123
|
+
} from "./token-goat-chunk-CO3UYX6G.mjs";
|
|
124
|
+
import {
|
|
125
|
+
init_define_import_meta_env
|
|
126
|
+
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
127
|
+
|
|
128
|
+
// src/hook_server.ts
|
|
129
|
+
init_define_import_meta_env();
|
|
130
|
+
import * as fs from "node:fs";
|
|
131
|
+
import * as net from "node:net";
|
|
132
|
+
import * as os from "node:os";
|
|
133
|
+
|
|
134
|
+
// src/hook_adapters.ts
|
|
135
|
+
init_define_import_meta_env();
|
|
136
|
+
import * as crypto from "node:crypto";
|
|
137
|
+
var ADAPTER_HARNESSES = ["claudecode", "codex", "grok", "kimi", "copilot_cli"];
|
|
138
|
+
function isAdapterHarness(name) {
|
|
139
|
+
return typeof name === "string" && ADAPTER_HARNESSES.includes(name);
|
|
140
|
+
}
|
|
141
|
+
var HOOK_EVENT_SET = new Set(HOOK_EVENTS);
|
|
142
|
+
var done = (stdout, exit = 0) => ({ stdout, exit });
|
|
143
|
+
function get(v, k) {
|
|
144
|
+
return v === null || v === void 0 ? void 0 : v[k];
|
|
145
|
+
}
|
|
146
|
+
async function relayAsShim(event, input, io, harnessWaitMs) {
|
|
147
|
+
let payload;
|
|
148
|
+
try {
|
|
149
|
+
payload = JSON.parse(input);
|
|
150
|
+
} catch {
|
|
151
|
+
const text = input.trim();
|
|
152
|
+
let lenient = {};
|
|
153
|
+
if (text !== "") {
|
|
154
|
+
try {
|
|
155
|
+
lenient = JSON.parse(text);
|
|
156
|
+
} catch {
|
|
157
|
+
lenient = {};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const out = await io.relay(event, lenient);
|
|
161
|
+
return out === "" ? void 0 : out;
|
|
162
|
+
}
|
|
163
|
+
return io.relay(event, payload, harnessWaitMs);
|
|
164
|
+
}
|
|
165
|
+
var ASYNC_DETACH_TOOLS = /* @__PURE__ */ new Set(["Edit", "Write", "MultiEdit", "NotebookEdit"]);
|
|
166
|
+
var ASYNC_DETACH_SKIP_EXT_RE = /\.(md|mdx|markdown|rst)$/i;
|
|
167
|
+
var ASYNC_DETACH_BASH_MAX_BYTES = 200;
|
|
168
|
+
var ASYNC_DETACH_BASH_TEXT_KEYS = ["output", "content", "text", "body", "stdout", "stderr"];
|
|
169
|
+
var ASYNC_DETACH_LINE = '{"async":true}\n';
|
|
170
|
+
function bashResultByteLength(resp) {
|
|
171
|
+
if (typeof resp === "string") return Buffer.byteLength(resp, "utf8");
|
|
172
|
+
if (resp && typeof resp === "object") {
|
|
173
|
+
const persisted = get(resp, "persistedOutputSize");
|
|
174
|
+
if (typeof persisted === "number") return persisted;
|
|
175
|
+
for (const key of ASYNC_DETACH_BASH_TEXT_KEYS) {
|
|
176
|
+
const text = get(resp, key);
|
|
177
|
+
if (typeof text === "string" && text !== "") return Buffer.byteLength(text, "utf8");
|
|
178
|
+
}
|
|
179
|
+
return Buffer.byteLength(JSON.stringify(resp), "utf8");
|
|
180
|
+
}
|
|
181
|
+
return 0;
|
|
182
|
+
}
|
|
183
|
+
var TG_LEDGER_PREFIX_RE = /^(?:(?:cd\s+(?:"[^"]*"|'[^']*'|\S+)|export[ \t]+[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|[^\s"'])*(?:[ \t]+[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|[^\s"'])*)*)[ \t]*(?:&&|;|\r?\n)\s*)+/;
|
|
184
|
+
var TG_LEDGER_READ_RE = /^(?:[A-Za-z_][A-Za-z0-9_]*=\S+\s+)*(?:env\s+(?:(?:(?:-u|--unset)\s+\S+|-(?![A-Za-z]*C|-c)\S*|[A-Za-z_][A-Za-z0-9_]*=\S+)\s+)*)?(?:token-goat|tg|node(?:\.exe)?\s+["']?(?:\S*[\\/])?token-goat(?:\.mjs)?["']?)\s+(?:read|section|symbol)\b/i;
|
|
185
|
+
function isLedgerReadCommand(cmd) {
|
|
186
|
+
if (typeof cmd !== "string") return false;
|
|
187
|
+
const body = cmd.trim().replace(/^\(\s*/, "");
|
|
188
|
+
return TG_LEDGER_READ_RE.test((body.replace(TG_LEDGER_PREFIX_RE, "") || body).trim());
|
|
189
|
+
}
|
|
190
|
+
function isAsyncDetachEligible(event, input) {
|
|
191
|
+
if (event === "subagent_stop") return true;
|
|
192
|
+
if (event !== "post_tool_use") return false;
|
|
193
|
+
try {
|
|
194
|
+
const payload = JSON.parse(input);
|
|
195
|
+
const toolName = get(payload, "tool_name");
|
|
196
|
+
if (ASYNC_DETACH_TOOLS.has(toolName)) {
|
|
197
|
+
const toolInput = get(payload, "tool_input") || {};
|
|
198
|
+
const filePath = get(toolInput, "file_path");
|
|
199
|
+
const notebookPath = get(toolInput, "notebook_path");
|
|
200
|
+
return !ASYNC_DETACH_SKIP_EXT_RE.test(typeof filePath === "string" ? filePath : typeof notebookPath === "string" ? notebookPath : "");
|
|
201
|
+
}
|
|
202
|
+
if (toolName === "Bash") return !isLedgerReadCommand(get(get(payload, "tool_input"), "command")) && bashResultByteLength(get(payload, "tool_response")) < ASYNC_DETACH_BASH_MAX_BYTES;
|
|
203
|
+
return false;
|
|
204
|
+
} catch {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
var TG_CD_PREFIX_RE = /^(?:cd\s+(?:"[^"]*"|'[^']*'|\S+)[ \t]*(?:&&|;|\r?\n)\s*)+/;
|
|
209
|
+
var TG_OWN_COMMAND_RE = /^(?:[A-Za-z_][A-Za-z0-9_]*=\S+\s+)*(?:token-goat\b|node(?:\.exe)?\s+["']?(?:\S*[\\/])?token-goat(?:\.mjs)?["']?\b)/i;
|
|
210
|
+
function isOwnTokenGoatCommand(cmd) {
|
|
211
|
+
if (typeof cmd !== "string" || cmd.trim() === "") return false;
|
|
212
|
+
const body = (cmd.replace(TG_CD_PREFIX_RE, "") || cmd).trim();
|
|
213
|
+
if (/[;&|`]|\$\(/.test(body)) return false;
|
|
214
|
+
return TG_OWN_COMMAND_RE.test(body);
|
|
215
|
+
}
|
|
216
|
+
var claudecode = {
|
|
217
|
+
unknown: "{}",
|
|
218
|
+
events: HOOK_EVENTS,
|
|
219
|
+
lost: () => "{}",
|
|
220
|
+
async run(req, io) {
|
|
221
|
+
const { event, input } = req;
|
|
222
|
+
if (!HOOK_EVENT_SET.has(event)) return done("{}");
|
|
223
|
+
if (event === "pre_tool_use") {
|
|
224
|
+
try {
|
|
225
|
+
const payload = JSON.parse(input);
|
|
226
|
+
if (get(payload, "tool_name") === "Bash" && isOwnTokenGoatCommand(get(get(payload, "tool_input"), "command"))) return done("{}");
|
|
227
|
+
} catch {
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
let harnessWaitMs = req.harnessWaitMs;
|
|
231
|
+
if (isAsyncDetachEligible(event, input)) harnessWaitMs = io.early(ASYNC_DETACH_LINE);
|
|
232
|
+
return done(await relayAsShim(event, input, io, harnessWaitMs) ?? "{}");
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
function stripTg(value) {
|
|
236
|
+
if (Array.isArray(value)) return value.map(stripTg);
|
|
237
|
+
if (value && typeof value === "object") {
|
|
238
|
+
const out = {};
|
|
239
|
+
for (const [k, v] of Object.entries(value)) {
|
|
240
|
+
if (k.startsWith("_tg_")) continue;
|
|
241
|
+
out[k] = stripTg(v);
|
|
242
|
+
}
|
|
243
|
+
return out;
|
|
244
|
+
}
|
|
245
|
+
return value;
|
|
246
|
+
}
|
|
247
|
+
function codexTranslate(stdout) {
|
|
248
|
+
let parsed;
|
|
249
|
+
try {
|
|
250
|
+
parsed = JSON.parse(stdout);
|
|
251
|
+
} catch {
|
|
252
|
+
return "{}";
|
|
253
|
+
}
|
|
254
|
+
return JSON.stringify(stripTg(parsed));
|
|
255
|
+
}
|
|
256
|
+
var codex = {
|
|
257
|
+
unknown: "{}",
|
|
258
|
+
events: HOOK_EVENTS,
|
|
259
|
+
lost: () => "{}",
|
|
260
|
+
async run(req, io) {
|
|
261
|
+
process.env["TOKEN_GOAT_HARNESS_OVERRIDE"] = "codex";
|
|
262
|
+
if (!HOOK_EVENT_SET.has(req.event)) return done("{}");
|
|
263
|
+
const stdout = await relayAsShim(req.event, req.input, io, req.harnessWaitMs);
|
|
264
|
+
return done(stdout === void 0 ? "{}" : codexTranslate(stdout));
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
var GROK_EVENTS = ["pre_tool_use", "post_tool_use", "notification", "stop", "pre_compact", "user_prompt_submit", "subagent_stop"];
|
|
268
|
+
var GROK_EVENT_SET = new Set(GROK_EVENTS);
|
|
269
|
+
function grokAllow(event) {
|
|
270
|
+
return event === "pre_tool_use" ? '{"decision":"allow"}' : "{}";
|
|
271
|
+
}
|
|
272
|
+
function grokTranslate(event, stdout) {
|
|
273
|
+
let parsed;
|
|
274
|
+
try {
|
|
275
|
+
parsed = JSON.parse(stdout);
|
|
276
|
+
} catch {
|
|
277
|
+
return done(grokAllow(event));
|
|
278
|
+
}
|
|
279
|
+
if (event !== "pre_tool_use") return done(JSON.stringify(parsed));
|
|
280
|
+
if (parsed && get(parsed, "decision") === "block") {
|
|
281
|
+
return done(JSON.stringify({ decision: "deny", reason: get(parsed, "reason") || "blocked by token-goat" }), 2);
|
|
282
|
+
}
|
|
283
|
+
return done('{"decision":"allow"}');
|
|
284
|
+
}
|
|
285
|
+
var grok = {
|
|
286
|
+
unknown: "{}",
|
|
287
|
+
events: GROK_EVENTS,
|
|
288
|
+
lost: (event) => grokTranslate(event, "{}").stdout,
|
|
289
|
+
async run(req, io) {
|
|
290
|
+
if (!GROK_EVENT_SET.has(req.event)) return done("{}");
|
|
291
|
+
try {
|
|
292
|
+
const stdout = await relayAsShim(req.event, req.input, io, req.harnessWaitMs);
|
|
293
|
+
return stdout === void 0 ? done(grokAllow(req.event)) : grokTranslate(req.event, stdout);
|
|
294
|
+
} catch {
|
|
295
|
+
return done(grokAllow(req.event));
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
function kimiHintText(parsed) {
|
|
300
|
+
if (!parsed || typeof parsed !== "object") return "";
|
|
301
|
+
const hso = get(parsed, "hookSpecificOutput");
|
|
302
|
+
const context = get(hso, "additionalContext");
|
|
303
|
+
if (hso && typeof hso === "object" && typeof context === "string") return context;
|
|
304
|
+
const systemMessage = get(parsed, "systemMessage");
|
|
305
|
+
if (typeof systemMessage === "string") return systemMessage;
|
|
306
|
+
return "";
|
|
307
|
+
}
|
|
308
|
+
function kimiTranslate(stdout) {
|
|
309
|
+
let parsed;
|
|
310
|
+
try {
|
|
311
|
+
parsed = JSON.parse(stdout);
|
|
312
|
+
} catch {
|
|
313
|
+
return "";
|
|
314
|
+
}
|
|
315
|
+
if (!parsed || typeof parsed !== "object") return "";
|
|
316
|
+
const reason = get(parsed, "reason");
|
|
317
|
+
if (get(parsed, "decision") === "block" && typeof reason === "string" && reason) {
|
|
318
|
+
return JSON.stringify({ message: reason, hookSpecificOutput: { permissionDecision: "deny", permissionDecisionReason: reason } });
|
|
319
|
+
}
|
|
320
|
+
const hint = kimiHintText(parsed);
|
|
321
|
+
if (hint) return JSON.stringify({ message: hint });
|
|
322
|
+
return "";
|
|
323
|
+
}
|
|
324
|
+
var kimi = {
|
|
325
|
+
unknown: "",
|
|
326
|
+
events: HOOK_EVENTS,
|
|
327
|
+
lost: () => kimiTranslate("{}"),
|
|
328
|
+
async run(req, io) {
|
|
329
|
+
process.env["TOKEN_GOAT_HARNESS_OVERRIDE"] = "kimi";
|
|
330
|
+
if (!HOOK_EVENT_SET.has(req.event)) return done("");
|
|
331
|
+
try {
|
|
332
|
+
const stdout = await relayAsShim(req.event, req.input, io, req.harnessWaitMs);
|
|
333
|
+
return done(stdout === void 0 ? "" : kimiTranslate(stdout));
|
|
334
|
+
} catch {
|
|
335
|
+
return done("");
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
var COPILOT_TO_TG_EVENT = {
|
|
340
|
+
sessionStart: "session_start",
|
|
341
|
+
preToolUse: "pre_tool_use",
|
|
342
|
+
postToolUse: "post_tool_use",
|
|
343
|
+
preCompact: "pre_compact",
|
|
344
|
+
agentStop: "stop",
|
|
345
|
+
subagentStop: "subagent_stop",
|
|
346
|
+
userPromptSubmitted: "user_prompt_submit",
|
|
347
|
+
postToolUseFailure: "post_tool_use_failure",
|
|
348
|
+
subagentStart: "subagent_start"
|
|
349
|
+
};
|
|
350
|
+
var VSCODE_ONLY_TO_TG_EVENT = {
|
|
351
|
+
SubagentStart: "subagent_start"
|
|
352
|
+
};
|
|
353
|
+
var FOLDED_COPILOT_TOOL_TO_TG = {};
|
|
354
|
+
for (const [k, v] of Object.entries(COPILOT_CLI_TOOL_NAME_MAP)) FOLDED_COPILOT_TOOL_TO_TG[foldToolName(k)] = v;
|
|
355
|
+
for (const v of Object.values(COPILOT_CLI_TOOL_NAME_MAP)) FOLDED_COPILOT_TOOL_TO_TG[foldToolName(v)] = v;
|
|
356
|
+
function ownLookup(map, key) {
|
|
357
|
+
return typeof key === "string" ? ownGet(map, key) : void 0;
|
|
358
|
+
}
|
|
359
|
+
function unqualified(name) {
|
|
360
|
+
return typeof name === "string" && name.includes(":") ? name.split(":").pop() : name;
|
|
361
|
+
}
|
|
362
|
+
function copilotCanonicalToolName(name) {
|
|
363
|
+
if (!name || typeof name !== "string") return name;
|
|
364
|
+
const direct = ownGet(COPILOT_CLI_TOOL_NAME_MAP, name);
|
|
365
|
+
if (direct !== void 0) return direct;
|
|
366
|
+
const stripped = unqualified(name);
|
|
367
|
+
const strippedDirect = ownLookup(COPILOT_CLI_TOOL_NAME_MAP, stripped);
|
|
368
|
+
if (strippedDirect !== void 0) return strippedDirect;
|
|
369
|
+
return ownGet(FOLDED_COPILOT_TOOL_TO_TG, foldToolName(name)) || ownGet(FOLDED_COPILOT_TOOL_TO_TG, foldToolName(stripped)) || name;
|
|
370
|
+
}
|
|
371
|
+
function parseMaybeJsonObject(value) {
|
|
372
|
+
if (value && typeof value === "object") return value;
|
|
373
|
+
if (typeof value === "string") {
|
|
374
|
+
try {
|
|
375
|
+
const parsed = JSON.parse(value);
|
|
376
|
+
if (parsed && typeof parsed === "object") return parsed;
|
|
377
|
+
} catch {
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return {};
|
|
381
|
+
}
|
|
382
|
+
function stableFallbackSessionId(cwd) {
|
|
383
|
+
const key = typeof cwd === "string" && cwd ? cwd : process.cwd();
|
|
384
|
+
return "copilot-" + crypto.createHash("sha256").update(key).digest("hex").slice(0, 16);
|
|
385
|
+
}
|
|
386
|
+
function copilotContext(resp) {
|
|
387
|
+
const hso = resp && get(resp, "hookSpecificOutput");
|
|
388
|
+
const context = get(hso, "additionalContext");
|
|
389
|
+
if (hso && typeof context === "string") return context;
|
|
390
|
+
const systemMessage = get(resp, "systemMessage");
|
|
391
|
+
if (resp && typeof systemMessage === "string") return systemMessage;
|
|
392
|
+
return void 0;
|
|
393
|
+
}
|
|
394
|
+
function copilotTranslate(copilotEvent, resp, toolName, originalToolArgs) {
|
|
395
|
+
if (copilotEvent === "preToolUse") {
|
|
396
|
+
const hso = resp && get(resp, "hookSpecificOutput");
|
|
397
|
+
const denied = resp && (get(resp, "decision") === "block" || hso && get(hso, "permissionDecision") === "deny");
|
|
398
|
+
if (denied) {
|
|
399
|
+
const reason = resp && get(resp, "reason") || hso && get(hso, "permissionDecisionReason") || "blocked by token-goat";
|
|
400
|
+
return { permissionDecision: "deny", permissionDecisionReason: reason };
|
|
401
|
+
}
|
|
402
|
+
const context = copilotContext(resp);
|
|
403
|
+
const shrinkPayload = typeof context === "string" && context.includes("data:image/");
|
|
404
|
+
const out = {};
|
|
405
|
+
const updated = hso && get(hso, "updatedInput");
|
|
406
|
+
if (updated && typeof updated === "object") {
|
|
407
|
+
out["modifiedArgs"] = updated;
|
|
408
|
+
} else if (shrinkPayload && (toolName === "view" || foldToolName(toolName) === "view")) {
|
|
409
|
+
const shrunkPath = materializeShrunkImageFile(context);
|
|
410
|
+
if (shrunkPath) out["modifiedArgs"] = Object.assign({}, originalToolArgs, { path: shrunkPath });
|
|
411
|
+
}
|
|
412
|
+
if (context && !shrinkPayload) out["additionalContext"] = context;
|
|
413
|
+
return out;
|
|
414
|
+
}
|
|
415
|
+
if (copilotEvent === "postToolUse") {
|
|
416
|
+
const hso = resp && get(resp, "hookSpecificOutput");
|
|
417
|
+
const updatedToolOutput = hso && get(hso, "updatedToolOutput");
|
|
418
|
+
const context = copilotContext(resp);
|
|
419
|
+
const out = {};
|
|
420
|
+
if (typeof updatedToolOutput === "string") out["modifiedResult"] = { resultType: "success", textResultForLlm: updatedToolOutput };
|
|
421
|
+
if (context) out["additionalContext"] = context;
|
|
422
|
+
return out;
|
|
423
|
+
}
|
|
424
|
+
if (copilotEvent === "postToolUseFailure" || copilotEvent === "sessionStart" || copilotEvent === "subagentStart" || copilotEvent === "userPromptSubmitted") {
|
|
425
|
+
const context = copilotContext(resp);
|
|
426
|
+
return context ? { additionalContext: context } : {};
|
|
427
|
+
}
|
|
428
|
+
if (copilotEvent === "agentStop" || copilotEvent === "subagentStop") {
|
|
429
|
+
if (resp && get(resp, "decision") === "block") return { decision: "block", reason: resp && get(resp, "reason") || "blocked by token-goat" };
|
|
430
|
+
const stopHso = resp && get(resp, "hookSpecificOutput");
|
|
431
|
+
const modifiedResponse = stopHso && get(stopHso, "updatedToolOutput");
|
|
432
|
+
if (copilotEvent === "subagentStop" && typeof modifiedResponse === "string") return { modifiedResponse };
|
|
433
|
+
return { decision: "allow" };
|
|
434
|
+
}
|
|
435
|
+
return {};
|
|
436
|
+
}
|
|
437
|
+
function viaJson(value) {
|
|
438
|
+
return JSON.parse(JSON.stringify(value));
|
|
439
|
+
}
|
|
440
|
+
async function copilotRelayVscode(tgEvent, payload, scriptDir, io) {
|
|
441
|
+
process.env["TOKEN_GOAT_HARNESS_OVERRIDE"] = "vscode";
|
|
442
|
+
if (scriptDir !== void 0) process.env["TOKEN_GOAT_VSCODE_HOOKS_DIR"] = scriptDir;
|
|
443
|
+
const sessionId = get(payload, "session_id");
|
|
444
|
+
const input = typeof sessionId === "string" && sessionId !== "" ? payload : Object.assign({}, payload, { session_id: stableFallbackSessionId(process.cwd()) });
|
|
445
|
+
const stdout = await io.relay(tgEvent, viaJson(input));
|
|
446
|
+
try {
|
|
447
|
+
const parsed = JSON.parse(stdout);
|
|
448
|
+
return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? JSON.stringify(parsed) : "{}";
|
|
449
|
+
} catch {
|
|
450
|
+
return "{}";
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
async function copilotRun(req, io) {
|
|
454
|
+
const copilotEvent = req.event;
|
|
455
|
+
const vscodeOnly = ownGet(VSCODE_ONLY_TO_TG_EVENT, copilotEvent);
|
|
456
|
+
const tgEvent = ownGet(COPILOT_TO_TG_EVENT, copilotEvent) ?? vscodeOnly;
|
|
457
|
+
if (!tgEvent) return "{}";
|
|
458
|
+
let payload;
|
|
459
|
+
try {
|
|
460
|
+
payload = JSON.parse(req.input);
|
|
461
|
+
} catch {
|
|
462
|
+
return "{}";
|
|
463
|
+
}
|
|
464
|
+
if (payload !== null && typeof payload === "object" && typeof get(payload, "hook_event_name") === "string" && get(payload, "toolName") === void 0) {
|
|
465
|
+
return copilotRelayVscode(tgEvent, payload, req.scriptDir, io);
|
|
466
|
+
}
|
|
467
|
+
if (vscodeOnly !== void 0) return "{}";
|
|
468
|
+
const toolName = payload && get(payload, "toolName");
|
|
469
|
+
const workingDirectory = payload && (get(payload, "workingDirectory") || get(payload, "cwd"));
|
|
470
|
+
const canonical = {
|
|
471
|
+
session_id: payload && get(payload, "sessionId") || stableFallbackSessionId(workingDirectory),
|
|
472
|
+
cwd: workingDirectory
|
|
473
|
+
};
|
|
474
|
+
const agentId = payload && (get(payload, "agent_id") || get(payload, "agentId"));
|
|
475
|
+
if (typeof agentId === "string" && agentId !== "") canonical["agent_id"] = agentId;
|
|
476
|
+
const traceparent = payload && (get(payload, "traceparent") || get(payload, "traceParent"));
|
|
477
|
+
if (typeof traceparent === "string" && traceparent !== "") canonical["traceparent"] = traceparent;
|
|
478
|
+
const tracestate = payload && (get(payload, "tracestate") || get(payload, "traceState"));
|
|
479
|
+
if (typeof tracestate === "string" && tracestate !== "") canonical["tracestate"] = tracestate;
|
|
480
|
+
const prompt = get(payload, "prompt");
|
|
481
|
+
if (typeof prompt === "string" && prompt !== "") canonical["prompt"] = prompt;
|
|
482
|
+
const response = get(payload, "response");
|
|
483
|
+
if (typeof response === "string" && response !== "") canonical["last_assistant_message"] = response;
|
|
484
|
+
let originalToolArgs = {};
|
|
485
|
+
if (toolName) {
|
|
486
|
+
originalToolArgs = parseMaybeJsonObject(get(payload, "toolArgs"));
|
|
487
|
+
canonical["tool_name"] = copilotCanonicalToolName(toolName);
|
|
488
|
+
canonical["tool_input"] = originalToolArgs;
|
|
489
|
+
}
|
|
490
|
+
const error = get(payload, "error");
|
|
491
|
+
if (typeof error === "string" && error !== "") canonical["error"] = error;
|
|
492
|
+
const rawResult = get(payload, "toolResult");
|
|
493
|
+
if (rawResult && typeof rawResult === "object") {
|
|
494
|
+
const camel = get(rawResult, "textResultForLlm");
|
|
495
|
+
const text = typeof camel === "string" ? camel : get(rawResult, "text_result_for_llm");
|
|
496
|
+
if (typeof text === "string") canonical["tool_response"] = text;
|
|
497
|
+
}
|
|
498
|
+
process.env["TOKEN_GOAT_HARNESS_OVERRIDE"] = "copilot_cli";
|
|
499
|
+
if (req.scriptDir !== void 0) process.env["TOKEN_GOAT_COPILOT_HOOKS_DIR"] = req.scriptDir;
|
|
500
|
+
else delete process.env["TOKEN_GOAT_COPILOT_HOOKS_DIR"];
|
|
501
|
+
const stdout = await io.relay(tgEvent, viaJson(canonical));
|
|
502
|
+
let resp;
|
|
503
|
+
try {
|
|
504
|
+
resp = JSON.parse(stdout);
|
|
505
|
+
} catch {
|
|
506
|
+
return "{}";
|
|
507
|
+
}
|
|
508
|
+
return JSON.stringify(copilotTranslate(copilotEvent, resp, toolName, originalToolArgs));
|
|
509
|
+
}
|
|
510
|
+
var copilotCli = {
|
|
511
|
+
unknown: "{}",
|
|
512
|
+
events: [...Object.keys(COPILOT_TO_TG_EVENT), ...Object.keys(VSCODE_ONLY_TO_TG_EVENT)],
|
|
513
|
+
lost: (event) => JSON.stringify(copilotTranslate(event, {}, void 0, {})),
|
|
514
|
+
async run(req, io) {
|
|
515
|
+
try {
|
|
516
|
+
return done(await copilotRun(req, io));
|
|
517
|
+
} catch {
|
|
518
|
+
return done("{}");
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
var ADAPTERS = { claudecode, codex, grok, kimi, copilot_cli: copilotCli };
|
|
523
|
+
async function runAdapter(harness, req, io) {
|
|
524
|
+
try {
|
|
525
|
+
return await ADAPTERS[harness].run(req, io);
|
|
526
|
+
} catch {
|
|
527
|
+
return done(harness === "grok" ? grokAllow(req.event) : ADAPTERS[harness].unknown);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
function noopOutputs(harness) {
|
|
531
|
+
const adapter = ADAPTERS[harness];
|
|
532
|
+
const noops = [];
|
|
533
|
+
for (const event of [...adapter.events].sort()) {
|
|
534
|
+
const out = adapter.lost(event);
|
|
535
|
+
if (out !== adapter.unknown) noops.push([event, out]);
|
|
536
|
+
}
|
|
537
|
+
return { noop: adapter.unknown, noops };
|
|
538
|
+
}
|
|
539
|
+
function noopFor(harness, event) {
|
|
540
|
+
const { noop, noops } = noopOutputs(harness);
|
|
541
|
+
return noops.find(([e]) => e === event)?.[1] ?? noop;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// src/hook_server.ts
|
|
545
|
+
var IDLE_EXIT_MS = { primary: 30 * 6e4, overflow: 3 * 6e4 };
|
|
546
|
+
var KEY_CHECK_MS = 2e3;
|
|
547
|
+
var HANDSHAKE_IDLE_MS = 1e4;
|
|
548
|
+
function bundleStamp() {
|
|
549
|
+
return bundleEntryFiles().map((f) => {
|
|
550
|
+
try {
|
|
551
|
+
const st = fs.statSync(f);
|
|
552
|
+
return `${st.size}:${st.mtimeMs}`;
|
|
553
|
+
} catch {
|
|
554
|
+
return "-";
|
|
555
|
+
}
|
|
556
|
+
}).join("|");
|
|
557
|
+
}
|
|
558
|
+
var enabledMemo;
|
|
559
|
+
function stillEnabled() {
|
|
560
|
+
const key = `${process.env["TOKEN_GOAT_HOOK_SERVER"] ?? ""}|${configPath()}|${configStamp()}`;
|
|
561
|
+
if (enabledMemo?.key !== key) enabledMemo = { key, enabled: hookServerEnabled() };
|
|
562
|
+
return enabledMemo.enabled;
|
|
563
|
+
}
|
|
564
|
+
function retirementReason(loadedStamp, judgeEnabled) {
|
|
565
|
+
if (bundleStamp() !== loadedStamp) return "bundle replaced";
|
|
566
|
+
if (judgeEnabled && !stillEnabled()) return "disabled";
|
|
567
|
+
return void 0;
|
|
568
|
+
}
|
|
569
|
+
async function handle(request, runCli, send) {
|
|
570
|
+
clearPerRequestCaches();
|
|
571
|
+
if (request.kind === "cli") {
|
|
572
|
+
const res = await serveOne({ id: 0, argv: request.argv, cwd: request.cwd, env: request.env }, runCli, clearPerRequestCaches);
|
|
573
|
+
return send({ ok: true, stdout: res.stdout, stderr: res.stderr, status: res.status });
|
|
574
|
+
}
|
|
575
|
+
limitDbWaitsForHook();
|
|
576
|
+
const startedAt = performance.now();
|
|
577
|
+
const cwdBefore = process.cwd();
|
|
578
|
+
const restoreEnv = swapEnv(request.env);
|
|
579
|
+
const afterReply = [];
|
|
580
|
+
try {
|
|
581
|
+
process.chdir(request.cwd);
|
|
582
|
+
const payload = JSON.parse(request.input);
|
|
583
|
+
const stdout = await relayInProcess(request.event, payload, request.harnessWaitMs, { elapsedMs: () => request.elapsedMs + (performance.now() - startedAt), afterReply: (work) => afterReply.push(work) });
|
|
584
|
+
send({ ok: true, stdout });
|
|
585
|
+
for (const work of afterReply) work();
|
|
586
|
+
} finally {
|
|
587
|
+
restoreEnv();
|
|
588
|
+
try {
|
|
589
|
+
process.chdir(cwdBefore);
|
|
590
|
+
} catch {
|
|
591
|
+
}
|
|
592
|
+
clearPerRequestCaches();
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
function parseHarnessRequest(body, harness) {
|
|
596
|
+
let r;
|
|
597
|
+
try {
|
|
598
|
+
r = JSON.parse(body);
|
|
599
|
+
} catch {
|
|
600
|
+
return void 0;
|
|
601
|
+
}
|
|
602
|
+
if (r === null || typeof r !== "object") return void 0;
|
|
603
|
+
const q = r;
|
|
604
|
+
const env = q["env"];
|
|
605
|
+
const wellFormed = q["kind"] === "hook" && q["harness"] === harness && typeof q["event"] === "string" && typeof q["input"] === "string" && typeof q["cwd"] === "string" && typeof q["elapsedMs"] === "number" && (q["harnessWaitMs"] === void 0 || typeof q["harnessWaitMs"] === "number") && (q["scriptDir"] === void 0 || typeof q["scriptDir"] === "string") && env !== null && typeof env === "object" && !Array.isArray(env) && Object.values(env).every((v) => typeof v === "string");
|
|
606
|
+
return wellFormed ? q : void 0;
|
|
607
|
+
}
|
|
608
|
+
async function handleHarness(request, harness, early, finish) {
|
|
609
|
+
clearPerRequestCaches();
|
|
610
|
+
limitDbWaitsForHook();
|
|
611
|
+
const startedAt = performance.now();
|
|
612
|
+
const cwdBefore = process.cwd();
|
|
613
|
+
const restoreEnv = swapEnv(request.env);
|
|
614
|
+
const afterReply = [];
|
|
615
|
+
const elapsedMs = () => request.elapsedMs + (performance.now() - startedAt);
|
|
616
|
+
try {
|
|
617
|
+
process.chdir(request.cwd);
|
|
618
|
+
const req = { event: request.event, input: request.input, ...request.harnessWaitMs === void 0 ? {} : { harnessWaitMs: request.harnessWaitMs }, ...request.scriptDir === void 0 ? {} : { scriptDir: request.scriptDir } };
|
|
619
|
+
const result = await runAdapter(harness, req, {
|
|
620
|
+
// An early frame is where the harness stops waiting, so the wait it records is its own clock up to here.
|
|
621
|
+
early: (data) => {
|
|
622
|
+
early(data);
|
|
623
|
+
return elapsedMs();
|
|
624
|
+
},
|
|
625
|
+
// Only native/tg-hook speaks this protocol, so every call served here is one the native client had served.
|
|
626
|
+
relay: (event, payload, harnessWaitMs) => relayInProcess(event, payload, harnessWaitMs, { elapsedMs, afterReply: (work) => afterReply.push(work), detail: "native" })
|
|
627
|
+
});
|
|
628
|
+
finish(result.stdout, result.exit);
|
|
629
|
+
for (const work of afterReply) work();
|
|
630
|
+
} finally {
|
|
631
|
+
restoreEnv();
|
|
632
|
+
try {
|
|
633
|
+
process.chdir(cwdBefore);
|
|
634
|
+
} catch {
|
|
635
|
+
}
|
|
636
|
+
clearPerRequestCaches();
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
function listen(server, endpoint) {
|
|
640
|
+
const tryListen = () => new Promise((resolve) => {
|
|
641
|
+
server.once("error", resolve);
|
|
642
|
+
server.listen({ path: endpoint, readableAll: false, writableAll: false }, () => {
|
|
643
|
+
server.removeListener("error", resolve);
|
|
644
|
+
resolve(void 0);
|
|
645
|
+
});
|
|
646
|
+
});
|
|
647
|
+
return tryListen().then(async (err) => {
|
|
648
|
+
if (err === void 0) return true;
|
|
649
|
+
if (err.code !== "EADDRINUSE" || process.platform === "win32") return false;
|
|
650
|
+
const alive = await new Promise((resolve) => {
|
|
651
|
+
const probe = net.connect(endpoint);
|
|
652
|
+
probe.once("connect", () => {
|
|
653
|
+
probe.destroy();
|
|
654
|
+
resolve(true);
|
|
655
|
+
});
|
|
656
|
+
probe.once("error", () => resolve(false));
|
|
657
|
+
});
|
|
658
|
+
if (alive) return false;
|
|
659
|
+
fs.rmSync(endpoint, { force: true });
|
|
660
|
+
return await tryListen() === void 0;
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
async function runHookServer(slot, runCli) {
|
|
664
|
+
if (!Number.isInteger(slot) || slot < 0 || slot >= SERVER_SLOTS) throw new Error(`--slot must be an integer from 0 to ${SERVER_SLOTS - 1}`);
|
|
665
|
+
if (!hookServerEnabled()) {
|
|
666
|
+
touchMarker("disabled", configStamp());
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
ensureDataDirPrivate();
|
|
670
|
+
primeHiddenRulesAhead();
|
|
671
|
+
primeManagedPolicyAhead();
|
|
672
|
+
const key = ensureServerKey();
|
|
673
|
+
const keyPath = serverKeyPath();
|
|
674
|
+
const loadedStamp = bundleStamp();
|
|
675
|
+
const endpoint = endpointFor(slot);
|
|
676
|
+
process.chdir(os.tmpdir());
|
|
677
|
+
const status = { pid: process.pid, slot, version: VERSION, startedAt: Date.now(), lastUsedAt: Date.now(), served: 0, errors: 0 };
|
|
678
|
+
let busy = false;
|
|
679
|
+
let retiring = false;
|
|
680
|
+
let idleTimer;
|
|
681
|
+
const flushing = /* @__PURE__ */ new Set();
|
|
682
|
+
const awaitingRequest = /* @__PURE__ */ new Set();
|
|
683
|
+
const endWith = (socket, frame) => {
|
|
684
|
+
const flushed = new Promise((resolve) => {
|
|
685
|
+
socket.once("close", () => resolve());
|
|
686
|
+
writeFrame(socket, frame);
|
|
687
|
+
socket.end(() => resolve());
|
|
688
|
+
});
|
|
689
|
+
flushing.add(flushed);
|
|
690
|
+
void flushed.then(() => flushing.delete(flushed));
|
|
691
|
+
};
|
|
692
|
+
let socketIno;
|
|
693
|
+
const ownsEndpoint = () => {
|
|
694
|
+
if (socketIno === void 0) return true;
|
|
695
|
+
try {
|
|
696
|
+
return fs.statSync(endpoint, { bigint: true, throwIfNoEntry: false })?.ino === socketIno;
|
|
697
|
+
} catch {
|
|
698
|
+
return true;
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
const server = net.createServer((socket) => serveConnection(socket));
|
|
702
|
+
const exitOnceFlushed = () => void Promise.all(flushing).then(() => process.exit(0));
|
|
703
|
+
const stop = () => {
|
|
704
|
+
retiring = true;
|
|
705
|
+
if (idleTimer !== void 0) clearTimeout(idleTimer);
|
|
706
|
+
if (ownsEndpoint()) server.close();
|
|
707
|
+
for (const socket of awaitingRequest) endWith(socket, { t: "stale" });
|
|
708
|
+
awaitingRequest.clear();
|
|
709
|
+
if (!busy) exitOnceFlushed();
|
|
710
|
+
};
|
|
711
|
+
const armIdle = () => {
|
|
712
|
+
if (idleTimer !== void 0) clearTimeout(idleTimer);
|
|
713
|
+
idleTimer = setTimeout(stop, slot === 0 ? IDLE_EXIT_MS.primary : IDLE_EXIT_MS.overflow);
|
|
714
|
+
};
|
|
715
|
+
function serveConnection(socket) {
|
|
716
|
+
let nc = "";
|
|
717
|
+
let ns = "";
|
|
718
|
+
let harness;
|
|
719
|
+
socket.setTimeout(HANDSHAKE_IDLE_MS, () => socket.destroy());
|
|
720
|
+
socket.on("error", () => socket.destroy());
|
|
721
|
+
socket.once("close", () => awaitingRequest.delete(socket));
|
|
722
|
+
const onMessage = (msg) => {
|
|
723
|
+
if (msg["t"] === "hello" && nc === "") {
|
|
724
|
+
const v2 = msg["v"] === HARNESS_PROTOCOL_VERSION;
|
|
725
|
+
if (msg["v"] !== PROTOCOL_VERSION && !v2 || typeof msg["nc"] !== "string" || msg["nc"] === "") return void socket.destroy();
|
|
726
|
+
if (v2) {
|
|
727
|
+
if (typeof msg["h"] !== "string") return void socket.destroy();
|
|
728
|
+
if (!isAdapterHarness(msg["h"])) return void endWith(socket, { t: "refused", reason: "unknown harness" });
|
|
729
|
+
harness = msg["h"];
|
|
730
|
+
}
|
|
731
|
+
const reason = retiring ? "retiring" : retirementReason(loadedStamp, !busy);
|
|
732
|
+
if (reason !== void 0) {
|
|
733
|
+
if (reason === "disabled") touchMarker("disabled", configStamp());
|
|
734
|
+
if (reason === "bundle replaced") removeMarker(`spawn-${slot}`);
|
|
735
|
+
writeFrame(socket, { t: "stale" });
|
|
736
|
+
socket.end(() => {
|
|
737
|
+
if (!retiring) stop();
|
|
738
|
+
});
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
if (busy && (harness !== void 0 || msg["ctl"] !== true)) {
|
|
742
|
+
writeFrame(socket, { t: "busy" });
|
|
743
|
+
return void socket.end();
|
|
744
|
+
}
|
|
745
|
+
nc = msg["nc"];
|
|
746
|
+
ns = nonce();
|
|
747
|
+
if (harness === void 0) {
|
|
748
|
+
writeFrame(socket, { t: "challenge", v: PROTOCOL_VERSION, ns, mac: mac(key, "S", nc, ns) });
|
|
749
|
+
} else {
|
|
750
|
+
const { noop, noops } = noopOutputs(harness);
|
|
751
|
+
writeFrame(socket, { t: "challenge", v: HARNESS_PROTOCOL_VERSION, ns, noop, noops, mac: challengeMacV2(key, nc, ns, harness, noop, noops) });
|
|
752
|
+
}
|
|
753
|
+
awaitingRequest.add(socket);
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
if (msg["t"] === "req" && ns !== "" && harness !== void 0) {
|
|
757
|
+
const h = harness;
|
|
758
|
+
const body = msg["body"];
|
|
759
|
+
if (typeof body !== "string" || !macMatches(requestMacV2(key, nc, ns, h, body), msg["mac"])) return void socket.destroy();
|
|
760
|
+
if (!awaitingRequest.delete(socket)) return;
|
|
761
|
+
const request = parseHarnessRequest(body, h);
|
|
762
|
+
if (request === void 0) return void socket.destroy();
|
|
763
|
+
if (busy || retiring) {
|
|
764
|
+
writeFrame(socket, { t: retiring ? "stale" : "busy" });
|
|
765
|
+
return void socket.end();
|
|
766
|
+
}
|
|
767
|
+
busy = true;
|
|
768
|
+
socket.setTimeout(0);
|
|
769
|
+
let seq = 0;
|
|
770
|
+
let finished = false;
|
|
771
|
+
const early = (data) => {
|
|
772
|
+
if (finished) return;
|
|
773
|
+
writeFrame(socket, { t: "out", seq, data, mac: outFrameMac(key, nc, ns, seq, data) });
|
|
774
|
+
seq++;
|
|
775
|
+
};
|
|
776
|
+
const finish = (stdout, exit) => {
|
|
777
|
+
if (finished) return;
|
|
778
|
+
finished = true;
|
|
779
|
+
endWith(socket, { t: "done", stdout, exit, n: seq, mac: doneFrameMac(key, nc, ns, stdout, exit, seq) });
|
|
780
|
+
};
|
|
781
|
+
void (async () => {
|
|
782
|
+
try {
|
|
783
|
+
await handleHarness(request, h, early, finish);
|
|
784
|
+
status.served++;
|
|
785
|
+
} catch {
|
|
786
|
+
status.errors++;
|
|
787
|
+
finish(noopFor(h, request.event), 0);
|
|
788
|
+
}
|
|
789
|
+
busy = false;
|
|
790
|
+
status.lastUsedAt = Date.now();
|
|
791
|
+
if (retiring) stop();
|
|
792
|
+
else armIdle();
|
|
793
|
+
})();
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
if (msg["t"] === "req" && ns !== "") {
|
|
797
|
+
const body = msg["body"];
|
|
798
|
+
if (typeof body !== "string" || !macMatches(mac(key, "C", nc, ns, body), msg["mac"])) return void socket.destroy();
|
|
799
|
+
if (!awaitingRequest.delete(socket)) return;
|
|
800
|
+
let request;
|
|
801
|
+
let parseError;
|
|
802
|
+
try {
|
|
803
|
+
request = JSON.parse(body);
|
|
804
|
+
} catch (e) {
|
|
805
|
+
parseError = e;
|
|
806
|
+
}
|
|
807
|
+
const kind = request?.kind;
|
|
808
|
+
if (kind === "status" || kind === "stop") {
|
|
809
|
+
const resBody = JSON.stringify({ ok: true, info: { ...status } });
|
|
810
|
+
endWith(socket, { t: "res", mac: mac(key, "R", nc, ns, resBody), body: resBody });
|
|
811
|
+
if (kind === "stop" && !retiring) stop();
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
if (busy || retiring) {
|
|
815
|
+
writeFrame(socket, { t: retiring ? "stale" : "busy" });
|
|
816
|
+
return void socket.end();
|
|
817
|
+
}
|
|
818
|
+
busy = true;
|
|
819
|
+
socket.setTimeout(0);
|
|
820
|
+
let replied = false;
|
|
821
|
+
const reply = (res) => {
|
|
822
|
+
if (replied) return;
|
|
823
|
+
replied = true;
|
|
824
|
+
const resBody = JSON.stringify(res);
|
|
825
|
+
endWith(socket, { t: "res", mac: mac(key, "R", nc, ns, resBody), body: resBody });
|
|
826
|
+
};
|
|
827
|
+
void (async () => {
|
|
828
|
+
try {
|
|
829
|
+
if (request === void 0) throw parseError;
|
|
830
|
+
await handle(request, runCli, reply);
|
|
831
|
+
status.served++;
|
|
832
|
+
} catch (e) {
|
|
833
|
+
status.errors++;
|
|
834
|
+
reply({ ok: false, error: e instanceof Error ? e.message : String(e) });
|
|
835
|
+
}
|
|
836
|
+
busy = false;
|
|
837
|
+
status.lastUsedAt = Date.now();
|
|
838
|
+
if (retiring) stop();
|
|
839
|
+
else armIdle();
|
|
840
|
+
})();
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
socket.destroy();
|
|
844
|
+
};
|
|
845
|
+
readFrames(socket, onMessage, () => void 0);
|
|
846
|
+
}
|
|
847
|
+
if (!await listen(server, endpoint)) return;
|
|
848
|
+
if (process.platform !== "win32") socketIno = fs.statSync(endpoint, { bigint: true }).ino;
|
|
849
|
+
removeMarker("failed");
|
|
850
|
+
setInterval(() => {
|
|
851
|
+
if (!fs.existsSync(keyPath) || !ownsEndpoint()) stop();
|
|
852
|
+
}, KEY_CHECK_MS).unref();
|
|
853
|
+
if (process.platform !== "win32") {
|
|
854
|
+
try {
|
|
855
|
+
fs.chmodSync(endpoint, 384);
|
|
856
|
+
} catch {
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
armIdle();
|
|
860
|
+
}
|
|
861
|
+
export {
|
|
862
|
+
runHookServer
|
|
863
|
+
};
|