token-goat 2.9.25 → 2.9.28
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 +28 -88
- package/SECURITY.md +14 -0
- package/dist/{token-goat-chunk-ORO4GOMA.mjs → token-goat-chunk-4JJBFT7V.mjs} +3 -3
- package/dist/token-goat-chunk-4JMWPWCS.mjs +96 -0
- package/dist/token-goat-chunk-4RN64ZND.mjs +954 -0
- package/dist/{token-goat-chunk-6W2FFT6H.mjs → token-goat-chunk-4STDIGYC.mjs} +2 -2
- package/dist/{token-goat-chunk-EZVRN44Y.mjs → token-goat-chunk-5NNYIUGV.mjs} +2 -2
- package/dist/{token-goat-chunk-ILROZWXE.mjs → token-goat-chunk-66LODAUT.mjs} +1 -1
- package/dist/{token-goat-chunk-VAIJUZG6.mjs → token-goat-chunk-6CCQDAYY.mjs} +69 -566
- package/dist/{token-goat-chunk-UGCNTVF4.mjs → token-goat-chunk-6DQNNFJ6.mjs} +5 -3
- package/dist/{token-goat-chunk-ZWFP4ZU7.mjs → token-goat-chunk-6SGLIPQB.mjs} +40 -20
- package/dist/{token-goat-chunk-TWVFMUTZ.mjs → token-goat-chunk-6Z5ULNE5.mjs} +3570 -3970
- package/dist/token-goat-chunk-7MAFDRVR.mjs +47 -0
- package/dist/{token-goat-chunk-PPNKB5HP.mjs → token-goat-chunk-7R2XYKC5.mjs} +6 -5
- package/dist/{token-goat-chunk-KYV7E6ZJ.mjs → token-goat-chunk-BCN2YQC6.mjs} +10 -8
- package/dist/token-goat-chunk-BJBRGPBX.mjs +244 -0
- package/dist/{token-goat-chunk-Z5ZTBSHL.mjs → token-goat-chunk-CBMY2FGI.mjs} +479 -544
- package/dist/{token-goat-chunk-UTKNLKYE.mjs → token-goat-chunk-CC2PYJM7.mjs} +2 -1
- package/dist/{token-goat-chunk-7PQYG6TN.mjs → token-goat-chunk-D5ICEPSB.mjs} +14 -14
- package/dist/token-goat-chunk-D7GHQKQD.mjs +30 -0
- package/dist/{token-goat-chunk-NNXCBELZ.mjs → token-goat-chunk-EL7M26WP.mjs} +7623 -8455
- package/dist/{token-goat-chunk-TVTDINTO.mjs → token-goat-chunk-F7QZRIWM.mjs} +69 -20
- package/dist/{token-goat-chunk-MBRX5AP6.mjs → token-goat-chunk-FSTWAOW6.mjs} +3 -3
- package/dist/token-goat-chunk-GGLEE35R.mjs +564 -0
- package/dist/{token-goat-chunk-YZ67F2HJ.mjs → token-goat-chunk-HUDC5GS5.mjs} +2 -2
- package/dist/{token-goat-chunk-BIBZQRC6.mjs → token-goat-chunk-HXNAC4ZF.mjs} +22 -964
- package/dist/token-goat-chunk-I7CB3X4K.mjs +1379 -0
- package/dist/{token-goat-chunk-KMCVX3P2.mjs → token-goat-chunk-IFORDBGC.mjs} +32 -27
- package/dist/{token-goat-chunk-25NRXKIW.mjs → token-goat-chunk-IHKZ3QNA.mjs} +26 -15
- package/dist/token-goat-chunk-IZXKVT4A.mjs +711 -0
- package/dist/{token-goat-chunk-UEQUZDHQ.mjs → token-goat-chunk-JXK2HQXS.mjs} +22 -8
- package/dist/{token-goat-chunk-YE4TGC4Z.mjs → token-goat-chunk-L45ZQRT7.mjs} +1 -1
- package/dist/{token-goat-chunk-IEF2NZFZ.mjs → token-goat-chunk-L7SDVGBT.mjs} +196 -14
- package/dist/token-goat-chunk-LEG3JNJ6.mjs +139 -0
- package/dist/{token-goat-chunk-3FSAZR32.mjs → token-goat-chunk-M56BWPBN.mjs} +1 -1
- package/dist/{token-goat-chunk-QZZPWFVF.mjs → token-goat-chunk-MAMQPC43.mjs} +2 -87
- package/dist/{token-goat-chunk-OHMKCBZI.mjs → token-goat-chunk-MMLMALWK.mjs} +5 -3
- package/dist/{token-goat-chunk-KOL5WXDW.mjs → token-goat-chunk-MVSWBNMD.mjs} +7 -231
- package/dist/{token-goat-chunk-J2PRBQ24.mjs → token-goat-chunk-NILVK7XM.mjs} +4 -4
- package/dist/{token-goat-chunk-OUQIGPW3.mjs → token-goat-chunk-Q4S3UQGO.mjs} +1 -1
- package/dist/{token-goat-chunk-EX2DVKAT.mjs → token-goat-chunk-QM76S6YS.mjs} +3 -3
- package/dist/{token-goat-chunk-G7YWBH25.mjs → token-goat-chunk-RJH64KQH.mjs} +86 -72
- package/dist/{token-goat-chunk-RLDBVMXR.mjs → token-goat-chunk-RSS3TLXU.mjs} +2 -2
- package/dist/{token-goat-chunk-T6652D3F.mjs → token-goat-chunk-SJEKA7Y2.mjs} +21 -16
- package/dist/{token-goat-chunk-II5WBDFB.mjs → token-goat-chunk-UBUKHVYW.mjs} +1 -1
- package/dist/{token-goat-chunk-2SSDSUSF.mjs → token-goat-chunk-VE27HPIF.mjs} +14 -10
- package/dist/{token-goat-chunk-Y463KPAQ.mjs → token-goat-chunk-VWZKZPSR.mjs} +100 -23
- package/dist/{token-goat-chunk-K4TNHLGS.mjs → token-goat-chunk-XI2VFAV6.mjs} +6 -6
- package/dist/{token-goat-chunk-ZDFDCXU2.mjs → token-goat-chunk-XKY4VKJ4.mjs} +1 -1
- package/dist/{token-goat-chunk-BQ6ZDLTF.mjs → token-goat-chunk-YWSP6IU7.mjs} +1 -1
- package/dist/token-goat-hook.mjs +23 -17
- package/dist/token-goat.core.mjs +32 -27
- package/docs/cli.md +32 -21
- package/docs/install.md +2 -0
- package/package.json +1 -1
- package/dist/token-goat-chunk-EDCVQLBR.mjs +0 -26
- package/dist/token-goat-chunk-WEYODFTA.mjs +0 -41
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
buildEvent,
|
|
5
|
+
relay,
|
|
6
|
+
relayInProcess
|
|
7
|
+
} from "./token-goat-chunk-EL7M26WP.mjs";
|
|
8
|
+
import "./token-goat-chunk-F7QZRIWM.mjs";
|
|
9
|
+
import "./token-goat-chunk-I7CB3X4K.mjs";
|
|
10
|
+
import {
|
|
11
|
+
MAX_STDIN_BYTES,
|
|
12
|
+
readStdinJson
|
|
13
|
+
} from "./token-goat-chunk-VE27HPIF.mjs";
|
|
14
|
+
import "./token-goat-chunk-6Z5ULNE5.mjs";
|
|
15
|
+
import "./token-goat-chunk-IZXKVT4A.mjs";
|
|
16
|
+
import "./token-goat-chunk-RJH64KQH.mjs";
|
|
17
|
+
import "./token-goat-chunk-6DQNNFJ6.mjs";
|
|
18
|
+
import "./token-goat-chunk-MMLMALWK.mjs";
|
|
19
|
+
import "./token-goat-chunk-L7SDVGBT.mjs";
|
|
20
|
+
import "./token-goat-chunk-6CCQDAYY.mjs";
|
|
21
|
+
import "./token-goat-chunk-GGLEE35R.mjs";
|
|
22
|
+
import "./token-goat-chunk-MAMQPC43.mjs";
|
|
23
|
+
import "./token-goat-chunk-HXNAC4ZF.mjs";
|
|
24
|
+
import "./token-goat-chunk-BJBRGPBX.mjs";
|
|
25
|
+
import "./token-goat-chunk-4JMWPWCS.mjs";
|
|
26
|
+
import "./token-goat-chunk-4RN64ZND.mjs";
|
|
27
|
+
import "./token-goat-chunk-MVSWBNMD.mjs";
|
|
28
|
+
import "./token-goat-chunk-3BTK54F3.mjs";
|
|
29
|
+
import "./token-goat-chunk-D5ICEPSB.mjs";
|
|
30
|
+
import "./token-goat-chunk-HUDC5GS5.mjs";
|
|
31
|
+
import "./token-goat-chunk-M56BWPBN.mjs";
|
|
32
|
+
import "./token-goat-chunk-CC2PYJM7.mjs";
|
|
33
|
+
import "./token-goat-chunk-EEIDFMEM.mjs";
|
|
34
|
+
import "./token-goat-chunk-OSUFN2FV.mjs";
|
|
35
|
+
import "./token-goat-chunk-L45ZQRT7.mjs";
|
|
36
|
+
import "./token-goat-chunk-NMTKNYGF.mjs";
|
|
37
|
+
import "./token-goat-chunk-Y4AFKTHK.mjs";
|
|
38
|
+
import "./token-goat-chunk-GMOUBOX4.mjs";
|
|
39
|
+
import "./token-goat-chunk-RRNZMM3A.mjs";
|
|
40
|
+
import "./token-goat-chunk-A37V4PBF.mjs";
|
|
41
|
+
export {
|
|
42
|
+
MAX_STDIN_BYTES,
|
|
43
|
+
buildEvent,
|
|
44
|
+
readStdinJson,
|
|
45
|
+
relay,
|
|
46
|
+
relayInProcess
|
|
47
|
+
};
|
|
@@ -20,17 +20,18 @@ import {
|
|
|
20
20
|
setOcrTimeoutForTesting,
|
|
21
21
|
setTesseractEntryForTesting,
|
|
22
22
|
verifyOcrLangCache
|
|
23
|
-
} from "./token-goat-chunk-
|
|
24
|
-
import "./token-goat-chunk-
|
|
25
|
-
import "./token-goat-chunk-
|
|
23
|
+
} from "./token-goat-chunk-4STDIGYC.mjs";
|
|
24
|
+
import "./token-goat-chunk-BJBRGPBX.mjs";
|
|
25
|
+
import "./token-goat-chunk-MVSWBNMD.mjs";
|
|
26
|
+
import "./token-goat-chunk-M56BWPBN.mjs";
|
|
26
27
|
import {
|
|
27
28
|
DEFAULT_OCR_LANG,
|
|
28
29
|
isSupportedOcrLang,
|
|
29
30
|
resolveOcrLangs
|
|
30
|
-
} from "./token-goat-chunk-
|
|
31
|
+
} from "./token-goat-chunk-CC2PYJM7.mjs";
|
|
31
32
|
import "./token-goat-chunk-EEIDFMEM.mjs";
|
|
32
33
|
import "./token-goat-chunk-OSUFN2FV.mjs";
|
|
33
|
-
import "./token-goat-chunk-
|
|
34
|
+
import "./token-goat-chunk-L45ZQRT7.mjs";
|
|
34
35
|
import "./token-goat-chunk-NMTKNYGF.mjs";
|
|
35
36
|
import "./token-goat-chunk-GMOUBOX4.mjs";
|
|
36
37
|
import "./token-goat-chunk-A37V4PBF.mjs";
|
|
@@ -7,16 +7,18 @@ import {
|
|
|
7
7
|
resolveFilter,
|
|
8
8
|
run,
|
|
9
9
|
runRaw
|
|
10
|
-
} from "./token-goat-chunk-
|
|
11
|
-
import "./token-goat-chunk-
|
|
12
|
-
import "./token-goat-chunk-
|
|
13
|
-
import "./token-goat-chunk-
|
|
14
|
-
import "./token-goat-chunk-
|
|
15
|
-
import "./token-goat-chunk-
|
|
16
|
-
import "./token-goat-chunk-
|
|
10
|
+
} from "./token-goat-chunk-F7QZRIWM.mjs";
|
|
11
|
+
import "./token-goat-chunk-RJH64KQH.mjs";
|
|
12
|
+
import "./token-goat-chunk-HXNAC4ZF.mjs";
|
|
13
|
+
import "./token-goat-chunk-BJBRGPBX.mjs";
|
|
14
|
+
import "./token-goat-chunk-4RN64ZND.mjs";
|
|
15
|
+
import "./token-goat-chunk-MVSWBNMD.mjs";
|
|
16
|
+
import "./token-goat-chunk-HUDC5GS5.mjs";
|
|
17
|
+
import "./token-goat-chunk-M56BWPBN.mjs";
|
|
18
|
+
import "./token-goat-chunk-CC2PYJM7.mjs";
|
|
17
19
|
import "./token-goat-chunk-EEIDFMEM.mjs";
|
|
18
20
|
import "./token-goat-chunk-OSUFN2FV.mjs";
|
|
19
|
-
import "./token-goat-chunk-
|
|
21
|
+
import "./token-goat-chunk-L45ZQRT7.mjs";
|
|
20
22
|
import "./token-goat-chunk-NMTKNYGF.mjs";
|
|
21
23
|
import "./token-goat-chunk-GMOUBOX4.mjs";
|
|
22
24
|
import "./token-goat-chunk-A37V4PBF.mjs";
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
recordStat,
|
|
5
|
+
redactSecrets
|
|
6
|
+
} from "./token-goat-chunk-MVSWBNMD.mjs";
|
|
7
|
+
import {
|
|
8
|
+
loadConfig
|
|
9
|
+
} from "./token-goat-chunk-CC2PYJM7.mjs";
|
|
10
|
+
import {
|
|
11
|
+
atomicWriteText,
|
|
12
|
+
ensureDirSync,
|
|
13
|
+
sanitizeIdForFilename,
|
|
14
|
+
tokenGoatHome
|
|
15
|
+
} from "./token-goat-chunk-L45ZQRT7.mjs";
|
|
16
|
+
import {
|
|
17
|
+
init_define_import_meta_env
|
|
18
|
+
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
19
|
+
|
|
20
|
+
// src/disk_cache.ts
|
|
21
|
+
init_define_import_meta_env();
|
|
22
|
+
import * as fs from "node:fs";
|
|
23
|
+
import * as path from "node:path";
|
|
24
|
+
var DEFAULT_MAX_COUNT = 200;
|
|
25
|
+
var DEFAULT_MAX_AGE_MS = 24 * 3600 * 1e3;
|
|
26
|
+
function sanitizeId(id) {
|
|
27
|
+
return sanitizeIdForFilename(id, 64);
|
|
28
|
+
}
|
|
29
|
+
function blobDir(subdir) {
|
|
30
|
+
return path.join(tokenGoatHome(), subdir);
|
|
31
|
+
}
|
|
32
|
+
function blobPath(subdir, id) {
|
|
33
|
+
const safe = sanitizeId(id);
|
|
34
|
+
if (!safe) return null;
|
|
35
|
+
const dir = blobDir(subdir);
|
|
36
|
+
const candidate = path.join(dir, `${safe}.json`);
|
|
37
|
+
try {
|
|
38
|
+
const rel = path.relative(dir, candidate);
|
|
39
|
+
if (rel.startsWith("..")) return null;
|
|
40
|
+
} catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return candidate;
|
|
44
|
+
}
|
|
45
|
+
function isBlobStale(subdir, id) {
|
|
46
|
+
const p = blobPath(subdir, id);
|
|
47
|
+
if (p === null) return false;
|
|
48
|
+
try {
|
|
49
|
+
const stat = fs.statSync(p);
|
|
50
|
+
return Date.now() - stat.mtimeMs > DEFAULT_MAX_AGE_MS;
|
|
51
|
+
} catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function subdirCacheDefaults(subdir) {
|
|
56
|
+
try {
|
|
57
|
+
if (subdir === "bash_outputs") {
|
|
58
|
+
const bc = loadConfig().bash_compress;
|
|
59
|
+
return { maxCount: bc.cache_max_file_count, maxBytes: bc.cache_max_bytes, maxBytesPerItem: bc.cache_max_bytes_per_output };
|
|
60
|
+
}
|
|
61
|
+
if (subdir === "web_outputs") {
|
|
62
|
+
const wf = loadConfig().webfetch;
|
|
63
|
+
return { maxCount: wf.max_file_count, maxBytes: wf.max_bytes, maxBytesPerItem: Number.POSITIVE_INFINITY };
|
|
64
|
+
}
|
|
65
|
+
} catch {
|
|
66
|
+
}
|
|
67
|
+
return { maxCount: DEFAULT_MAX_COUNT, maxBytes: Number.POSITIVE_INFINITY, maxBytesPerItem: Number.POSITIVE_INFINITY };
|
|
68
|
+
}
|
|
69
|
+
function storeBlob(subdir, id, value, opts = {}) {
|
|
70
|
+
const p = blobPath(subdir, id);
|
|
71
|
+
if (!p) return false;
|
|
72
|
+
const defaults = subdirCacheDefaults(subdir);
|
|
73
|
+
const maxBytesPerItem = opts.maxBytesPerItem ?? defaults.maxBytesPerItem;
|
|
74
|
+
let rawJson;
|
|
75
|
+
try {
|
|
76
|
+
rawJson = JSON.stringify(value);
|
|
77
|
+
} catch {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
let json;
|
|
81
|
+
try {
|
|
82
|
+
const result = redactSecrets(rawJson);
|
|
83
|
+
json = result.text;
|
|
84
|
+
if (result.count > 0) recordStat("secret_redacted", 0, result.count, void 0, subdir);
|
|
85
|
+
} catch {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
if (Number.isFinite(maxBytesPerItem) && Buffer.byteLength(json, "utf-8") > maxBytesPerItem) return false;
|
|
89
|
+
try {
|
|
90
|
+
const dir = path.dirname(p);
|
|
91
|
+
if (!fs.existsSync(dir)) ensureDirSync(dir);
|
|
92
|
+
atomicWriteText(p, json);
|
|
93
|
+
} catch {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
pruneBlobs(
|
|
97
|
+
subdir,
|
|
98
|
+
opts.maxCount ?? defaults.maxCount,
|
|
99
|
+
opts.maxAgeMs ?? DEFAULT_MAX_AGE_MS,
|
|
100
|
+
opts.maxBytes ?? defaults.maxBytes,
|
|
101
|
+
p
|
|
102
|
+
);
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
function loadBlob(subdir, id) {
|
|
106
|
+
const p = blobPath(subdir, id);
|
|
107
|
+
if (!p) return null;
|
|
108
|
+
try {
|
|
109
|
+
if (!fs.existsSync(p)) return null;
|
|
110
|
+
return JSON.parse(fs.readFileSync(p, "utf8"));
|
|
111
|
+
} catch {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function listBlobs(subdir) {
|
|
116
|
+
const dir = blobDir(subdir);
|
|
117
|
+
const out = [];
|
|
118
|
+
try {
|
|
119
|
+
if (!fs.existsSync(dir)) return out;
|
|
120
|
+
for (const file of fs.readdirSync(dir)) {
|
|
121
|
+
if (!file.endsWith(".json")) continue;
|
|
122
|
+
const id = file.slice(0, -5);
|
|
123
|
+
let mtime = 0;
|
|
124
|
+
try {
|
|
125
|
+
mtime = fs.statSync(path.join(dir, file)).mtimeMs;
|
|
126
|
+
} catch {
|
|
127
|
+
}
|
|
128
|
+
const value = loadBlob(subdir, id);
|
|
129
|
+
if (value !== null) out.push({ id, mtime, value });
|
|
130
|
+
}
|
|
131
|
+
} catch {
|
|
132
|
+
return out;
|
|
133
|
+
}
|
|
134
|
+
return out;
|
|
135
|
+
}
|
|
136
|
+
function pruneBlobs(subdir, maxCount = DEFAULT_MAX_COUNT, maxAgeMs = DEFAULT_MAX_AGE_MS, maxBytes = Number.POSITIVE_INFINITY, protectedPath) {
|
|
137
|
+
return pruneBlobDir(blobDir(subdir), maxCount, maxAgeMs, maxBytes, protectedPath);
|
|
138
|
+
}
|
|
139
|
+
function pruneBlobDir(dir, maxCount = DEFAULT_MAX_COUNT, maxAgeMs = DEFAULT_MAX_AGE_MS, maxBytes = Number.POSITIVE_INFINITY, protectedPath) {
|
|
140
|
+
let removed = 0;
|
|
141
|
+
try {
|
|
142
|
+
if (!fs.existsSync(dir)) return 0;
|
|
143
|
+
const cutoff = Date.now() - maxAgeMs;
|
|
144
|
+
let kept = [];
|
|
145
|
+
let protectedEntry;
|
|
146
|
+
for (const file of fs.readdirSync(dir)) {
|
|
147
|
+
const full = path.join(dir, file);
|
|
148
|
+
let stat;
|
|
149
|
+
try {
|
|
150
|
+
stat = fs.statSync(full);
|
|
151
|
+
} catch {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (!stat.isFile()) continue;
|
|
155
|
+
if (protectedPath !== void 0 && full === protectedPath) {
|
|
156
|
+
protectedEntry = [full, stat.mtimeMs, stat.size];
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (stat.mtimeMs < cutoff) {
|
|
160
|
+
try {
|
|
161
|
+
fs.unlinkSync(full);
|
|
162
|
+
removed++;
|
|
163
|
+
} catch {
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
} else if (file.endsWith(".json")) {
|
|
167
|
+
kept.push([full, stat.mtimeMs, stat.size]);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const countBudget = protectedEntry ? Math.max(0, maxCount - 1) : maxCount;
|
|
171
|
+
if (kept.length > countBudget) {
|
|
172
|
+
kept.sort((a, b) => a[1] - b[1]);
|
|
173
|
+
const excess = kept.slice(0, kept.length - countBudget);
|
|
174
|
+
kept = kept.slice(kept.length - countBudget);
|
|
175
|
+
for (const [full] of excess) {
|
|
176
|
+
try {
|
|
177
|
+
fs.unlinkSync(full);
|
|
178
|
+
removed++;
|
|
179
|
+
} catch {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (Number.isFinite(maxBytes)) {
|
|
185
|
+
kept.sort((a, b) => a[1] - b[1]);
|
|
186
|
+
let total = kept.reduce((sum, [, , size]) => sum + size, 0) + (protectedEntry ? protectedEntry[2] : 0);
|
|
187
|
+
while (total > maxBytes && kept.length > 0) {
|
|
188
|
+
const oldest = kept.shift();
|
|
189
|
+
if (!oldest) break;
|
|
190
|
+
const [full, , size] = oldest;
|
|
191
|
+
try {
|
|
192
|
+
fs.unlinkSync(full);
|
|
193
|
+
removed++;
|
|
194
|
+
total -= size;
|
|
195
|
+
} catch {
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
} catch {
|
|
201
|
+
return removed;
|
|
202
|
+
}
|
|
203
|
+
return removed;
|
|
204
|
+
}
|
|
205
|
+
var SWEEPABLE_CACHE_SUBDIRS = [
|
|
206
|
+
{ subdir: "bash_outputs", countCapped: true },
|
|
207
|
+
{ subdir: "web_outputs", countCapped: true },
|
|
208
|
+
{ subdir: "mcp_outputs", countCapped: true },
|
|
209
|
+
{ subdir: "sessions", countCapped: false }
|
|
210
|
+
];
|
|
211
|
+
function sweepCacheRoots(extraRoots = []) {
|
|
212
|
+
let removed = 0;
|
|
213
|
+
const roots = [tokenGoatHome(), ...extraRoots];
|
|
214
|
+
const seen = /* @__PURE__ */ new Set();
|
|
215
|
+
for (const root of roots) {
|
|
216
|
+
if (!root || seen.has(root)) continue;
|
|
217
|
+
seen.add(root);
|
|
218
|
+
for (const { subdir, countCapped } of SWEEPABLE_CACHE_SUBDIRS) {
|
|
219
|
+
try {
|
|
220
|
+
const defaults = subdirCacheDefaults(subdir);
|
|
221
|
+
removed += pruneBlobDir(
|
|
222
|
+
path.join(root, subdir),
|
|
223
|
+
countCapped ? defaults.maxCount : Number.POSITIVE_INFINITY,
|
|
224
|
+
DEFAULT_MAX_AGE_MS,
|
|
225
|
+
countCapped ? defaults.maxBytes : Number.POSITIVE_INFINITY
|
|
226
|
+
);
|
|
227
|
+
} catch {
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return removed;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export {
|
|
235
|
+
DEFAULT_MAX_COUNT,
|
|
236
|
+
DEFAULT_MAX_AGE_MS,
|
|
237
|
+
blobPath,
|
|
238
|
+
isBlobStale,
|
|
239
|
+
storeBlob,
|
|
240
|
+
loadBlob,
|
|
241
|
+
listBlobs,
|
|
242
|
+
pruneBlobs,
|
|
243
|
+
sweepCacheRoots
|
|
244
|
+
};
|