token-goat 2.9.29 → 2.9.30
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 +34 -40
- package/SECURITY.md +28 -10
- package/THIRD_PARTY_NOTICES.md +40 -3
- package/dist/native/linux-arm64/tg-hook +0 -0
- package/dist/native/linux-x64/tg-hook +0 -0
- package/dist/ort-wasm-simd-threaded.mjs +59 -0
- package/dist/token-goat-chunk-3CHUNJ2O.mjs +53 -0
- package/dist/token-goat-chunk-3Z5S4KGM.mjs +918 -0
- package/dist/token-goat-chunk-4FVIAHSI.mjs +211 -0
- package/dist/{token-goat-chunk-PGTH2U4C.mjs → token-goat-chunk-4JJS54TR.mjs} +4 -3
- package/dist/token-goat-chunk-4LCCNRTG.mjs +313 -0
- package/dist/{token-goat-chunk-L7H3U27L.mjs → token-goat-chunk-54K3EUV3.mjs} +1 -1
- package/dist/token-goat-chunk-56EIMS3E.mjs +159 -0
- package/dist/token-goat-chunk-5BCIJXMO.mjs +609 -0
- package/dist/token-goat-chunk-5KDMCMF2.mjs +362 -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-GLXRTTLE.mjs → token-goat-chunk-64FBPDTK.mjs} +12 -8
- package/dist/{token-goat-chunk-G23DWHV4.mjs → token-goat-chunk-664RTTUV.mjs} +28 -15
- package/dist/token-goat-chunk-67TQJ76B.mjs +57 -0
- package/dist/token-goat-chunk-6QMAS7AB.mjs +42 -0
- package/dist/token-goat-chunk-7BXSNBY5.mjs +253 -0
- package/dist/{token-goat-chunk-IVWI2OCK.mjs → token-goat-chunk-7F2UBPD3.mjs} +40 -11
- package/dist/{token-goat-chunk-TGOXNAHW.mjs → token-goat-chunk-7IN2MKDS.mjs} +682 -501
- package/dist/token-goat-chunk-7NADEDKJ.mjs +124 -0
- package/dist/{token-goat-chunk-KOPIR3KZ.mjs → token-goat-chunk-A3CK6N5Z.mjs} +618 -72
- package/dist/{token-goat-chunk-O6I2XU4P.mjs → token-goat-chunk-AFLYLHDH.mjs} +44 -31
- package/dist/{token-goat-chunk-TCQANXYC.mjs → token-goat-chunk-AM5V6GSX.mjs} +18 -2
- package/dist/{token-goat-chunk-E4ZOJIZK.mjs → token-goat-chunk-APGZXSPS.mjs} +39 -146
- package/dist/{token-goat-chunk-D4ETHJD6.mjs → token-goat-chunk-ARDNEC2U.mjs} +9 -7
- package/dist/token-goat-chunk-ATCPY7EQ.mjs +134 -0
- package/dist/token-goat-chunk-B2RZZCSS.mjs +354 -0
- package/dist/{token-goat-chunk-BGYOZ6DO.mjs → token-goat-chunk-B45VMIIH.mjs} +6 -7
- package/dist/token-goat-chunk-BPGCUMR7.mjs +30 -0
- package/dist/{token-goat-chunk-TDUT2CL6.mjs → token-goat-chunk-C63JQV5K.mjs} +45 -6
- package/dist/{token-goat-chunk-ZER6EAXZ.mjs → token-goat-chunk-COBQGL5S.mjs} +2661 -2440
- package/dist/token-goat-chunk-COTXZHTS.mjs +39 -0
- package/dist/{token-goat-chunk-RQGGMPCR.mjs → token-goat-chunk-CYCEYAEO.mjs} +76 -16
- package/dist/token-goat-chunk-CZ3LUXYZ.mjs +4115 -0
- package/dist/{token-goat-chunk-ASLWOQ3I.mjs → token-goat-chunk-DZX2YDPT.mjs} +2 -1
- package/dist/token-goat-chunk-E3OQX2XT.mjs +824 -0
- package/dist/token-goat-chunk-EFHMMIGP.mjs +68 -0
- package/dist/token-goat-chunk-ETBHVDB6.mjs +328 -0
- package/dist/token-goat-chunk-EVMZJ27Z.mjs +147 -0
- package/dist/token-goat-chunk-EXKGNHEG.mjs +2096 -0
- package/dist/{token-goat-chunk-RTMVLHWX.mjs → token-goat-chunk-FBNQNSJK.mjs} +2555 -5127
- package/dist/{token-goat-chunk-NMTKNYGF.mjs → token-goat-chunk-FNFBKLRD.mjs} +74 -9
- package/dist/{token-goat-chunk-RLP6J7WR.mjs → token-goat-chunk-FZ3NEW5O.mjs} +33 -19
- package/dist/token-goat-chunk-G5PJ7AGM.mjs +36 -0
- package/dist/{token-goat-chunk-DNRPXHYH.mjs → token-goat-chunk-GFBSN7BD.mjs} +29 -401
- package/dist/{token-goat-chunk-XYWPOSCN.mjs → token-goat-chunk-GOLEOXZP.mjs} +763 -211
- package/dist/token-goat-chunk-H2K3QP6H.mjs +24 -0
- package/dist/token-goat-chunk-H2PHHGM5.mjs +188 -0
- package/dist/token-goat-chunk-HAVAOB3S.mjs +87 -0
- package/dist/token-goat-chunk-HG45AF2B.mjs +2228 -0
- package/dist/{token-goat-chunk-HUYUHODZ.mjs → token-goat-chunk-HOJLCGDP.mjs} +12965 -11748
- package/dist/{token-goat-chunk-435UQTKD.mjs → token-goat-chunk-HYBFA5X3.mjs} +118 -19
- package/dist/token-goat-chunk-IVALLT3S.mjs +48 -0
- package/dist/{token-goat-chunk-UXSXQQIY.mjs → token-goat-chunk-IVKIZWAB.mjs} +3 -3
- package/dist/{token-goat-chunk-52NSDWYY.mjs → token-goat-chunk-JB6QN6VF.mjs} +6 -4
- package/dist/{token-goat-chunk-HNFZZHFW.mjs → token-goat-chunk-JDHE26RP.mjs} +10 -3
- package/dist/{token-goat-chunk-FTP4U4QA.mjs → token-goat-chunk-JDU3EXSU.mjs} +12 -11
- package/dist/token-goat-chunk-JDWCRD6M.mjs +253 -0
- package/dist/{token-goat-chunk-6AK46ZT7.mjs → token-goat-chunk-JN4XMLSD.mjs} +5 -1
- package/dist/token-goat-chunk-JTQQGXZH.mjs +733 -0
- package/dist/token-goat-chunk-KKUFXAPD.mjs +25 -0
- package/dist/token-goat-chunk-KQNZDCBD.mjs +47 -0
- package/dist/{token-goat-chunk-2WOUYWLM.mjs → token-goat-chunk-KWPNJBDH.mjs} +27 -3
- package/dist/{token-goat-chunk-DPNLUJWB.mjs → token-goat-chunk-LOBGHXPB.mjs} +30 -8
- package/dist/token-goat-chunk-MKPF4CL5.mjs +37 -0
- package/dist/token-goat-chunk-MNWKPRAL.mjs +13 -0
- package/dist/{token-goat-chunk-DNSPXQXQ.mjs → token-goat-chunk-N2NMER56.mjs} +25 -15
- package/dist/token-goat-chunk-NYKZLXMK.mjs +218 -0
- package/dist/token-goat-chunk-OJBNYTJP.mjs +3087 -0
- package/dist/token-goat-chunk-P4QMM4WK.mjs +295 -0
- package/dist/token-goat-chunk-PD5VKH46.mjs +184 -0
- package/dist/token-goat-chunk-PEPTHRFF.mjs +129 -0
- package/dist/{token-goat-chunk-NMBWLRHW.mjs → token-goat-chunk-PU7V3FD6.mjs} +8721 -11104
- package/dist/token-goat-chunk-PY533T7F.mjs +46 -0
- package/dist/token-goat-chunk-Q5VTGRH7.mjs +761 -0
- package/dist/{token-goat-chunk-67BNIKKO.mjs → token-goat-chunk-QCLDAQTS.mjs} +31 -20
- package/dist/{token-goat-chunk-SE6E4BKJ.mjs → token-goat-chunk-QSBRTGM2.mjs} +9 -2
- package/dist/{token-goat-chunk-VZQEWRVH.mjs → token-goat-chunk-RC35RBUL.mjs} +4 -4
- package/dist/{token-goat-chunk-VMFWNHGR.mjs → token-goat-chunk-RHXKCZX3.mjs} +873 -504
- package/dist/{token-goat-chunk-PYSUADX4.mjs → token-goat-chunk-RZRTDST7.mjs} +17 -7
- package/dist/{token-goat-chunk-ONXH6NZ5.mjs → token-goat-chunk-SJHWVNDQ.mjs} +15 -21
- package/dist/token-goat-chunk-SMVRN2HU.mjs +188 -0
- package/dist/{token-goat-chunk-QO3LXVVR.mjs → token-goat-chunk-SQSSNQPE.mjs} +2295 -1718
- package/dist/{token-goat-chunk-2AWQ2R5X.mjs → token-goat-chunk-T4FK7VOV.mjs} +2 -2
- package/dist/token-goat-chunk-U4N3BN2W.mjs +92 -0
- package/dist/token-goat-chunk-UA5V6P3P.mjs +122 -0
- package/dist/{token-goat-chunk-UA5BKWWQ.mjs → token-goat-chunk-UQ5UK2T7.mjs} +15 -4
- package/dist/token-goat-chunk-USILZ3T3.mjs +53 -0
- package/dist/{token-goat-chunk-MELOKFDJ.mjs → token-goat-chunk-VES7EL7O.mjs} +7 -1
- package/dist/{token-goat-chunk-7CPMDFGB.mjs → token-goat-chunk-VL3YIFHZ.mjs} +389 -14
- package/dist/{token-goat-chunk-E5TK5DNO.mjs → token-goat-chunk-VPBBTSJR.mjs} +356 -129
- package/dist/{token-goat-chunk-YOOVFPTP.mjs → token-goat-chunk-W3QCJS6G.mjs} +10 -2
- package/dist/{token-goat-chunk-LZNBQTDK.mjs → token-goat-chunk-WY3L4DVT.mjs} +11 -7
- package/dist/token-goat-chunk-XKI4SEMX.mjs +66 -0
- package/dist/token-goat-chunk-XU4P6Z24.mjs +133 -0
- package/dist/{token-goat-chunk-H5J3C56Q.mjs → token-goat-chunk-Y776AENC.mjs} +112 -26
- package/dist/token-goat-chunk-YARZFCZS.mjs +359 -0
- package/dist/{token-goat-chunk-S4VSXURL.mjs → token-goat-chunk-Z44YO3QZ.mjs} +4 -0
- package/dist/token-goat-chunk-Z57YODA2.mjs +35 -0
- package/dist/{token-goat-chunk-PQ53BSCF.mjs → token-goat-chunk-ZCDTCVIS.mjs} +48 -29
- package/dist/token-goat-chunk-ZEJVMUQH.mjs +48 -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-PKRWMHVP.mjs → token-goat-chunk-ZQSJMO2R.mjs} +338 -170
- package/dist/token-goat-hook-client.cjs +87 -23
- package/dist/token-goat-hook-client.mjs +3 -3
- package/dist/token-goat-hook.mjs +46 -30
- package/dist/token-goat.core.mjs +6 -6
- package/docs/C4_RUNTIME_ARCHITECTURE.md +1 -1
- package/docs/cli.md +80 -46
- package/docs/install.md +47 -14
- package/docs/security.md +7 -7
- package/package.json +17 -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-C5YPNZKQ.mjs +0 -318
- package/dist/token-goat-chunk-CIQ2FTY3.mjs +0 -1990
- package/dist/token-goat-chunk-EUSDXRXU.mjs +0 -1429
- package/dist/token-goat-chunk-G7IWXCFF.mjs +0 -456
- package/dist/token-goat-chunk-JTKCQMQA.mjs +0 -418
- package/dist/token-goat-chunk-ORNFMIER.mjs +0 -295
- package/dist/token-goat-chunk-VQ6F6T7X.mjs +0 -36
- 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
|
@@ -1,295 +0,0 @@
|
|
|
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-S4VSXURL.mjs";
|
|
7
|
-
import {
|
|
8
|
-
relayInProcess
|
|
9
|
-
} from "./token-goat-chunk-QO3LXVVR.mjs";
|
|
10
|
-
import "./token-goat-chunk-IVWI2OCK.mjs";
|
|
11
|
-
import "./token-goat-chunk-DNRPXHYH.mjs";
|
|
12
|
-
import "./token-goat-chunk-RTMVLHWX.mjs";
|
|
13
|
-
import "./token-goat-chunk-L7H3U27L.mjs";
|
|
14
|
-
import "./token-goat-chunk-RRNZMM3A.mjs";
|
|
15
|
-
import "./token-goat-chunk-E4ZOJIZK.mjs";
|
|
16
|
-
import "./token-goat-chunk-E5TK5DNO.mjs";
|
|
17
|
-
import "./token-goat-chunk-ZER6EAXZ.mjs";
|
|
18
|
-
import "./token-goat-chunk-44BM7DDQ.mjs";
|
|
19
|
-
import "./token-goat-chunk-EUSDXRXU.mjs";
|
|
20
|
-
import "./token-goat-chunk-G7IWXCFF.mjs";
|
|
21
|
-
import "./token-goat-chunk-H5J3C56Q.mjs";
|
|
22
|
-
import "./token-goat-chunk-TDUT2CL6.mjs";
|
|
23
|
-
import "./token-goat-chunk-ONXH6NZ5.mjs";
|
|
24
|
-
import "./token-goat-chunk-O6I2XU4P.mjs";
|
|
25
|
-
import "./token-goat-chunk-D4ETHJD6.mjs";
|
|
26
|
-
import "./token-goat-chunk-52NSDWYY.mjs";
|
|
27
|
-
import "./token-goat-chunk-2WOUYWLM.mjs";
|
|
28
|
-
import "./token-goat-chunk-CIQ2FTY3.mjs";
|
|
29
|
-
import {
|
|
30
|
-
PROTOCOL_VERSION,
|
|
31
|
-
SERVER_SLOTS,
|
|
32
|
-
bundleEntryFiles,
|
|
33
|
-
configStamp,
|
|
34
|
-
endpointFor,
|
|
35
|
-
ensureServerKey,
|
|
36
|
-
mac,
|
|
37
|
-
macMatches,
|
|
38
|
-
nonce,
|
|
39
|
-
readFrames,
|
|
40
|
-
removeMarker,
|
|
41
|
-
serverKeyPath,
|
|
42
|
-
touchMarker,
|
|
43
|
-
writeFrame
|
|
44
|
-
} from "./token-goat-chunk-DPNLUJWB.mjs";
|
|
45
|
-
import "./token-goat-chunk-3BTK54F3.mjs";
|
|
46
|
-
import "./token-goat-chunk-VMFWNHGR.mjs";
|
|
47
|
-
import "./token-goat-chunk-435UQTKD.mjs";
|
|
48
|
-
import "./token-goat-chunk-7CPMDFGB.mjs";
|
|
49
|
-
import {
|
|
50
|
-
hookServerEnabled
|
|
51
|
-
} from "./token-goat-chunk-TGOXNAHW.mjs";
|
|
52
|
-
import "./token-goat-chunk-XB5KKOCG.mjs";
|
|
53
|
-
import {
|
|
54
|
-
clearPerRequestCaches
|
|
55
|
-
} from "./token-goat-chunk-YZAAZU2S.mjs";
|
|
56
|
-
import "./token-goat-chunk-IVE6U7KV.mjs";
|
|
57
|
-
import "./token-goat-chunk-XYWPOSCN.mjs";
|
|
58
|
-
import "./token-goat-chunk-TCQANXYC.mjs";
|
|
59
|
-
import "./token-goat-chunk-NMTKNYGF.mjs";
|
|
60
|
-
import {
|
|
61
|
-
VERSION,
|
|
62
|
-
configPath,
|
|
63
|
-
ensureDataDirPrivate
|
|
64
|
-
} from "./token-goat-chunk-MELOKFDJ.mjs";
|
|
65
|
-
import "./token-goat-chunk-Y4AFKTHK.mjs";
|
|
66
|
-
import "./token-goat-chunk-JTKCQMQA.mjs";
|
|
67
|
-
import {
|
|
68
|
-
init_define_import_meta_env
|
|
69
|
-
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
70
|
-
|
|
71
|
-
// src/hook_server.ts
|
|
72
|
-
init_define_import_meta_env();
|
|
73
|
-
import * as fs from "node:fs";
|
|
74
|
-
import * as net from "node:net";
|
|
75
|
-
import * as os from "node:os";
|
|
76
|
-
var IDLE_EXIT_MS = { primary: 30 * 6e4, overflow: 3 * 6e4 };
|
|
77
|
-
var KEY_CHECK_MS = 2e3;
|
|
78
|
-
var HANDSHAKE_IDLE_MS = 1e4;
|
|
79
|
-
function bundleStamp() {
|
|
80
|
-
return bundleEntryFiles().map((f) => {
|
|
81
|
-
try {
|
|
82
|
-
const st = fs.statSync(f);
|
|
83
|
-
return `${st.size}:${st.mtimeMs}`;
|
|
84
|
-
} catch {
|
|
85
|
-
return "-";
|
|
86
|
-
}
|
|
87
|
-
}).join("|");
|
|
88
|
-
}
|
|
89
|
-
var enabledMemo;
|
|
90
|
-
function stillEnabled() {
|
|
91
|
-
const key = `${process.env["TOKEN_GOAT_HOOK_SERVER"] ?? ""}|${configPath()}|${configStamp()}`;
|
|
92
|
-
if (enabledMemo?.key !== key) enabledMemo = { key, enabled: hookServerEnabled() };
|
|
93
|
-
return enabledMemo.enabled;
|
|
94
|
-
}
|
|
95
|
-
function retirementReason(loadedStamp) {
|
|
96
|
-
if (bundleStamp() !== loadedStamp) return "bundle replaced";
|
|
97
|
-
if (!stillEnabled()) return "disabled";
|
|
98
|
-
return void 0;
|
|
99
|
-
}
|
|
100
|
-
async function handle(request, runCli, send) {
|
|
101
|
-
clearPerRequestCaches();
|
|
102
|
-
if (request.kind === "cli") {
|
|
103
|
-
const res = await serveOne({ id: 0, argv: request.argv, cwd: request.cwd, env: request.env }, runCli, clearPerRequestCaches);
|
|
104
|
-
return send({ ok: true, stdout: res.stdout, stderr: res.stderr, status: res.status });
|
|
105
|
-
}
|
|
106
|
-
const startedAt = performance.now();
|
|
107
|
-
const cwdBefore = process.cwd();
|
|
108
|
-
const restoreEnv = swapEnv(request.env);
|
|
109
|
-
const afterReply = [];
|
|
110
|
-
try {
|
|
111
|
-
process.chdir(request.cwd);
|
|
112
|
-
const payload = JSON.parse(request.input);
|
|
113
|
-
const stdout = await relayInProcess(request.event, payload, request.harnessWaitMs, { elapsedMs: () => request.elapsedMs + (performance.now() - startedAt), afterReply: (work) => afterReply.push(work) });
|
|
114
|
-
send({ ok: true, stdout });
|
|
115
|
-
for (const work of afterReply) work();
|
|
116
|
-
} finally {
|
|
117
|
-
restoreEnv();
|
|
118
|
-
try {
|
|
119
|
-
process.chdir(cwdBefore);
|
|
120
|
-
} catch {
|
|
121
|
-
}
|
|
122
|
-
clearPerRequestCaches();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function listen(server, endpoint) {
|
|
126
|
-
const tryListen = () => new Promise((resolve) => {
|
|
127
|
-
server.once("error", resolve);
|
|
128
|
-
server.listen({ path: endpoint, readableAll: false, writableAll: false }, () => {
|
|
129
|
-
server.removeListener("error", resolve);
|
|
130
|
-
resolve(void 0);
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
return tryListen().then(async (err) => {
|
|
134
|
-
if (err === void 0) return true;
|
|
135
|
-
if (err.code !== "EADDRINUSE" || process.platform === "win32") return false;
|
|
136
|
-
const alive = await new Promise((resolve) => {
|
|
137
|
-
const probe = net.connect(endpoint);
|
|
138
|
-
probe.once("connect", () => {
|
|
139
|
-
probe.destroy();
|
|
140
|
-
resolve(true);
|
|
141
|
-
});
|
|
142
|
-
probe.once("error", () => resolve(false));
|
|
143
|
-
});
|
|
144
|
-
if (alive) return false;
|
|
145
|
-
fs.rmSync(endpoint, { force: true });
|
|
146
|
-
return await tryListen() === void 0;
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
async function runHookServer(slot, runCli) {
|
|
150
|
-
if (!Number.isInteger(slot) || slot < 0 || slot >= SERVER_SLOTS) throw new Error(`--slot must be an integer from 0 to ${SERVER_SLOTS - 1}`);
|
|
151
|
-
if (!hookServerEnabled()) {
|
|
152
|
-
touchMarker("disabled", configStamp());
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
ensureDataDirPrivate();
|
|
156
|
-
const key = ensureServerKey();
|
|
157
|
-
const keyPath = serverKeyPath();
|
|
158
|
-
const loadedStamp = bundleStamp();
|
|
159
|
-
const endpoint = endpointFor(slot);
|
|
160
|
-
process.chdir(os.tmpdir());
|
|
161
|
-
const status = { pid: process.pid, slot, version: VERSION, startedAt: Date.now(), lastUsedAt: Date.now(), served: 0, errors: 0 };
|
|
162
|
-
let busy = false;
|
|
163
|
-
let retiring = false;
|
|
164
|
-
let idleTimer;
|
|
165
|
-
const flushing = /* @__PURE__ */ new Set();
|
|
166
|
-
const awaitingRequest = /* @__PURE__ */ new Set();
|
|
167
|
-
const endWith = (socket, frame) => {
|
|
168
|
-
const flushed = new Promise((resolve) => {
|
|
169
|
-
socket.once("close", () => resolve());
|
|
170
|
-
writeFrame(socket, frame);
|
|
171
|
-
socket.end(() => resolve());
|
|
172
|
-
});
|
|
173
|
-
flushing.add(flushed);
|
|
174
|
-
void flushed.then(() => flushing.delete(flushed));
|
|
175
|
-
};
|
|
176
|
-
let socketIno;
|
|
177
|
-
const ownsEndpoint = () => {
|
|
178
|
-
if (socketIno === void 0) return true;
|
|
179
|
-
try {
|
|
180
|
-
return fs.statSync(endpoint, { bigint: true, throwIfNoEntry: false })?.ino === socketIno;
|
|
181
|
-
} catch {
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
const server = net.createServer((socket) => serveConnection(socket));
|
|
186
|
-
const exitOnceFlushed = () => void Promise.all(flushing).then(() => process.exit(0));
|
|
187
|
-
const stop = () => {
|
|
188
|
-
retiring = true;
|
|
189
|
-
if (idleTimer !== void 0) clearTimeout(idleTimer);
|
|
190
|
-
if (ownsEndpoint()) server.close();
|
|
191
|
-
for (const socket of awaitingRequest) endWith(socket, { t: "stale" });
|
|
192
|
-
awaitingRequest.clear();
|
|
193
|
-
if (!busy) exitOnceFlushed();
|
|
194
|
-
};
|
|
195
|
-
const armIdle = () => {
|
|
196
|
-
if (idleTimer !== void 0) clearTimeout(idleTimer);
|
|
197
|
-
idleTimer = setTimeout(stop, slot === 0 ? IDLE_EXIT_MS.primary : IDLE_EXIT_MS.overflow);
|
|
198
|
-
};
|
|
199
|
-
function serveConnection(socket) {
|
|
200
|
-
let nc = "";
|
|
201
|
-
let ns = "";
|
|
202
|
-
socket.setTimeout(HANDSHAKE_IDLE_MS, () => socket.destroy());
|
|
203
|
-
socket.on("error", () => socket.destroy());
|
|
204
|
-
socket.once("close", () => awaitingRequest.delete(socket));
|
|
205
|
-
const onMessage = (msg) => {
|
|
206
|
-
if (msg["t"] === "hello" && nc === "") {
|
|
207
|
-
if (msg["v"] !== PROTOCOL_VERSION || typeof msg["nc"] !== "string" || msg["nc"] === "") return void socket.destroy();
|
|
208
|
-
const reason = retiring ? "retiring" : retirementReason(loadedStamp);
|
|
209
|
-
if (reason !== void 0) {
|
|
210
|
-
if (reason === "disabled") touchMarker("disabled", configStamp());
|
|
211
|
-
if (reason === "bundle replaced") removeMarker(`spawn-${slot}`);
|
|
212
|
-
writeFrame(socket, { t: "stale" });
|
|
213
|
-
socket.end(() => {
|
|
214
|
-
if (!retiring) stop();
|
|
215
|
-
});
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
if (busy && msg["ctl"] !== true) {
|
|
219
|
-
writeFrame(socket, { t: "busy" });
|
|
220
|
-
return void socket.end();
|
|
221
|
-
}
|
|
222
|
-
nc = msg["nc"];
|
|
223
|
-
ns = nonce();
|
|
224
|
-
writeFrame(socket, { t: "challenge", v: PROTOCOL_VERSION, ns, mac: mac(key, "S", nc, ns) });
|
|
225
|
-
awaitingRequest.add(socket);
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
if (msg["t"] === "req" && ns !== "") {
|
|
229
|
-
const body = msg["body"];
|
|
230
|
-
if (typeof body !== "string" || !macMatches(mac(key, "C", nc, ns, body), msg["mac"])) return void socket.destroy();
|
|
231
|
-
if (!awaitingRequest.delete(socket)) return;
|
|
232
|
-
let request;
|
|
233
|
-
let parseError;
|
|
234
|
-
try {
|
|
235
|
-
request = JSON.parse(body);
|
|
236
|
-
} catch (e) {
|
|
237
|
-
parseError = e;
|
|
238
|
-
}
|
|
239
|
-
const kind = request?.kind;
|
|
240
|
-
if (kind === "status" || kind === "stop") {
|
|
241
|
-
const resBody = JSON.stringify({ ok: true, info: { ...status } });
|
|
242
|
-
endWith(socket, { t: "res", mac: mac(key, "R", nc, ns, resBody), body: resBody });
|
|
243
|
-
if (kind === "stop" && !retiring) stop();
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
if (busy || retiring) {
|
|
247
|
-
writeFrame(socket, { t: retiring ? "stale" : "busy" });
|
|
248
|
-
return void socket.end();
|
|
249
|
-
}
|
|
250
|
-
busy = true;
|
|
251
|
-
socket.setTimeout(0);
|
|
252
|
-
let replied = false;
|
|
253
|
-
const reply = (res) => {
|
|
254
|
-
if (replied) return;
|
|
255
|
-
replied = true;
|
|
256
|
-
const resBody = JSON.stringify(res);
|
|
257
|
-
endWith(socket, { t: "res", mac: mac(key, "R", nc, ns, resBody), body: resBody });
|
|
258
|
-
};
|
|
259
|
-
void (async () => {
|
|
260
|
-
try {
|
|
261
|
-
if (request === void 0) throw parseError;
|
|
262
|
-
await handle(request, runCli, reply);
|
|
263
|
-
status.served++;
|
|
264
|
-
} catch (e) {
|
|
265
|
-
status.errors++;
|
|
266
|
-
reply({ ok: false, error: e instanceof Error ? e.message : String(e) });
|
|
267
|
-
}
|
|
268
|
-
busy = false;
|
|
269
|
-
status.lastUsedAt = Date.now();
|
|
270
|
-
if (retiring) stop();
|
|
271
|
-
else armIdle();
|
|
272
|
-
})();
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
socket.destroy();
|
|
276
|
-
};
|
|
277
|
-
readFrames(socket, onMessage, () => void 0);
|
|
278
|
-
}
|
|
279
|
-
if (!await listen(server, endpoint)) return;
|
|
280
|
-
if (process.platform !== "win32") socketIno = fs.statSync(endpoint, { bigint: true }).ino;
|
|
281
|
-
removeMarker("failed");
|
|
282
|
-
setInterval(() => {
|
|
283
|
-
if (!fs.existsSync(keyPath) || !ownsEndpoint()) stop();
|
|
284
|
-
}, KEY_CHECK_MS).unref();
|
|
285
|
-
if (process.platform !== "win32") {
|
|
286
|
-
try {
|
|
287
|
-
fs.chmodSync(endpoint, 384);
|
|
288
|
-
} catch {
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
armIdle();
|
|
292
|
-
}
|
|
293
|
-
export {
|
|
294
|
-
runHookServer
|
|
295
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
-
const require = __cjsRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
DEFAULT_HEARTBEAT_INTERVAL_MS,
|
|
5
|
-
DEFAULT_TIMEOUT_SECONDS,
|
|
6
|
-
MAX_CAPTURE_BYTES,
|
|
7
|
-
resolveFilter,
|
|
8
|
-
run,
|
|
9
|
-
runRaw
|
|
10
|
-
} from "./token-goat-chunk-IVWI2OCK.mjs";
|
|
11
|
-
import "./token-goat-chunk-L7H3U27L.mjs";
|
|
12
|
-
import "./token-goat-chunk-ZER6EAXZ.mjs";
|
|
13
|
-
import "./token-goat-chunk-O6I2XU4P.mjs";
|
|
14
|
-
import "./token-goat-chunk-D4ETHJD6.mjs";
|
|
15
|
-
import "./token-goat-chunk-2WOUYWLM.mjs";
|
|
16
|
-
import "./token-goat-chunk-CIQ2FTY3.mjs";
|
|
17
|
-
import "./token-goat-chunk-435UQTKD.mjs";
|
|
18
|
-
import "./token-goat-chunk-7CPMDFGB.mjs";
|
|
19
|
-
import "./token-goat-chunk-TGOXNAHW.mjs";
|
|
20
|
-
import "./token-goat-chunk-XB5KKOCG.mjs";
|
|
21
|
-
import "./token-goat-chunk-YZAAZU2S.mjs";
|
|
22
|
-
import "./token-goat-chunk-IVE6U7KV.mjs";
|
|
23
|
-
import "./token-goat-chunk-XYWPOSCN.mjs";
|
|
24
|
-
import "./token-goat-chunk-TCQANXYC.mjs";
|
|
25
|
-
import "./token-goat-chunk-NMTKNYGF.mjs";
|
|
26
|
-
import "./token-goat-chunk-MELOKFDJ.mjs";
|
|
27
|
-
import "./token-goat-chunk-JTKCQMQA.mjs";
|
|
28
|
-
import "./token-goat-chunk-A37V4PBF.mjs";
|
|
29
|
-
export {
|
|
30
|
-
DEFAULT_HEARTBEAT_INTERVAL_MS,
|
|
31
|
-
DEFAULT_TIMEOUT_SECONDS,
|
|
32
|
-
MAX_CAPTURE_BYTES,
|
|
33
|
-
resolveFilter,
|
|
34
|
-
run,
|
|
35
|
-
runRaw
|
|
36
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
-
const require = __cjsRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
checkUpdateStatus,
|
|
5
|
-
cmdUpgrade,
|
|
6
|
-
compareSemver,
|
|
7
|
-
fetchLatestVersion
|
|
8
|
-
} from "./token-goat-chunk-2NNUA2LR.mjs";
|
|
9
|
-
import "./token-goat-chunk-TGOXNAHW.mjs";
|
|
10
|
-
import "./token-goat-chunk-YZAAZU2S.mjs";
|
|
11
|
-
import "./token-goat-chunk-IVE6U7KV.mjs";
|
|
12
|
-
import "./token-goat-chunk-XYWPOSCN.mjs";
|
|
13
|
-
import "./token-goat-chunk-TCQANXYC.mjs";
|
|
14
|
-
import "./token-goat-chunk-NMTKNYGF.mjs";
|
|
15
|
-
import "./token-goat-chunk-MELOKFDJ.mjs";
|
|
16
|
-
import "./token-goat-chunk-JTKCQMQA.mjs";
|
|
17
|
-
import "./token-goat-chunk-A37V4PBF.mjs";
|
|
18
|
-
export {
|
|
19
|
-
checkUpdateStatus,
|
|
20
|
-
cmdUpgrade,
|
|
21
|
-
compareSemver,
|
|
22
|
-
fetchLatestVersion
|
|
23
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
-
const require = __cjsRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
MAX_RESUME_CHARS,
|
|
5
|
-
MAX_RESUME_TOKENS,
|
|
6
|
-
buildResumePacket
|
|
7
|
-
} from "./token-goat-chunk-RLP6J7WR.mjs";
|
|
8
|
-
import "./token-goat-chunk-G7IWXCFF.mjs";
|
|
9
|
-
import "./token-goat-chunk-H5J3C56Q.mjs";
|
|
10
|
-
import "./token-goat-chunk-TDUT2CL6.mjs";
|
|
11
|
-
import "./token-goat-chunk-ONXH6NZ5.mjs";
|
|
12
|
-
import "./token-goat-chunk-O6I2XU4P.mjs";
|
|
13
|
-
import "./token-goat-chunk-D4ETHJD6.mjs";
|
|
14
|
-
import "./token-goat-chunk-52NSDWYY.mjs";
|
|
15
|
-
import "./token-goat-chunk-2WOUYWLM.mjs";
|
|
16
|
-
import "./token-goat-chunk-CIQ2FTY3.mjs";
|
|
17
|
-
import "./token-goat-chunk-435UQTKD.mjs";
|
|
18
|
-
import "./token-goat-chunk-7CPMDFGB.mjs";
|
|
19
|
-
import "./token-goat-chunk-TGOXNAHW.mjs";
|
|
20
|
-
import "./token-goat-chunk-XB5KKOCG.mjs";
|
|
21
|
-
import "./token-goat-chunk-YZAAZU2S.mjs";
|
|
22
|
-
import "./token-goat-chunk-IVE6U7KV.mjs";
|
|
23
|
-
import "./token-goat-chunk-XYWPOSCN.mjs";
|
|
24
|
-
import "./token-goat-chunk-TCQANXYC.mjs";
|
|
25
|
-
import "./token-goat-chunk-NMTKNYGF.mjs";
|
|
26
|
-
import "./token-goat-chunk-MELOKFDJ.mjs";
|
|
27
|
-
import "./token-goat-chunk-JTKCQMQA.mjs";
|
|
28
|
-
import "./token-goat-chunk-A37V4PBF.mjs";
|
|
29
|
-
export {
|
|
30
|
-
MAX_RESUME_CHARS,
|
|
31
|
-
MAX_RESUME_TOKENS,
|
|
32
|
-
buildResumePacket
|
|
33
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
-
const require = __cjsRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
RELAY_QUEUE_WAIT_MS,
|
|
5
|
-
buildEvent,
|
|
6
|
-
relay,
|
|
7
|
-
relayInProcess
|
|
8
|
-
} from "./token-goat-chunk-QO3LXVVR.mjs";
|
|
9
|
-
import "./token-goat-chunk-IVWI2OCK.mjs";
|
|
10
|
-
import {
|
|
11
|
-
MAX_STDIN_BYTES,
|
|
12
|
-
readStdinJson
|
|
13
|
-
} from "./token-goat-chunk-DNRPXHYH.mjs";
|
|
14
|
-
import "./token-goat-chunk-RTMVLHWX.mjs";
|
|
15
|
-
import "./token-goat-chunk-L7H3U27L.mjs";
|
|
16
|
-
import "./token-goat-chunk-RRNZMM3A.mjs";
|
|
17
|
-
import "./token-goat-chunk-E4ZOJIZK.mjs";
|
|
18
|
-
import "./token-goat-chunk-E5TK5DNO.mjs";
|
|
19
|
-
import "./token-goat-chunk-ZER6EAXZ.mjs";
|
|
20
|
-
import "./token-goat-chunk-44BM7DDQ.mjs";
|
|
21
|
-
import "./token-goat-chunk-EUSDXRXU.mjs";
|
|
22
|
-
import "./token-goat-chunk-G7IWXCFF.mjs";
|
|
23
|
-
import "./token-goat-chunk-H5J3C56Q.mjs";
|
|
24
|
-
import "./token-goat-chunk-TDUT2CL6.mjs";
|
|
25
|
-
import "./token-goat-chunk-ONXH6NZ5.mjs";
|
|
26
|
-
import "./token-goat-chunk-O6I2XU4P.mjs";
|
|
27
|
-
import "./token-goat-chunk-D4ETHJD6.mjs";
|
|
28
|
-
import "./token-goat-chunk-52NSDWYY.mjs";
|
|
29
|
-
import "./token-goat-chunk-2WOUYWLM.mjs";
|
|
30
|
-
import "./token-goat-chunk-CIQ2FTY3.mjs";
|
|
31
|
-
import "./token-goat-chunk-3BTK54F3.mjs";
|
|
32
|
-
import "./token-goat-chunk-VMFWNHGR.mjs";
|
|
33
|
-
import "./token-goat-chunk-435UQTKD.mjs";
|
|
34
|
-
import "./token-goat-chunk-7CPMDFGB.mjs";
|
|
35
|
-
import "./token-goat-chunk-TGOXNAHW.mjs";
|
|
36
|
-
import "./token-goat-chunk-XB5KKOCG.mjs";
|
|
37
|
-
import "./token-goat-chunk-YZAAZU2S.mjs";
|
|
38
|
-
import "./token-goat-chunk-IVE6U7KV.mjs";
|
|
39
|
-
import "./token-goat-chunk-XYWPOSCN.mjs";
|
|
40
|
-
import "./token-goat-chunk-TCQANXYC.mjs";
|
|
41
|
-
import "./token-goat-chunk-NMTKNYGF.mjs";
|
|
42
|
-
import "./token-goat-chunk-MELOKFDJ.mjs";
|
|
43
|
-
import "./token-goat-chunk-Y4AFKTHK.mjs";
|
|
44
|
-
import "./token-goat-chunk-JTKCQMQA.mjs";
|
|
45
|
-
import "./token-goat-chunk-A37V4PBF.mjs";
|
|
46
|
-
export {
|
|
47
|
-
MAX_STDIN_BYTES,
|
|
48
|
-
RELAY_QUEUE_WAIT_MS,
|
|
49
|
-
buildEvent,
|
|
50
|
-
readStdinJson,
|
|
51
|
-
relay,
|
|
52
|
-
relayInProcess
|
|
53
|
-
};
|