token-goat 2.9.26 → 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-CQHY4SL7.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-5M3NRJD2.mjs → token-goat-chunk-4STDIGYC.mjs} +2 -2
- package/dist/{token-goat-chunk-BH4ZVRB2.mjs → token-goat-chunk-5NNYIUGV.mjs} +2 -2
- package/dist/{token-goat-chunk-LHUP4DXZ.mjs → token-goat-chunk-66LODAUT.mjs} +1 -1
- package/dist/{token-goat-chunk-M6CVNHTW.mjs → token-goat-chunk-6CCQDAYY.mjs} +69 -566
- package/dist/{token-goat-chunk-62IHOU6L.mjs → token-goat-chunk-6DQNNFJ6.mjs} +5 -3
- package/dist/{token-goat-chunk-H2CPLEMP.mjs → token-goat-chunk-6SGLIPQB.mjs} +40 -20
- package/dist/{token-goat-chunk-MBDJR6HU.mjs → token-goat-chunk-6Z5ULNE5.mjs} +3570 -3970
- package/dist/token-goat-chunk-7MAFDRVR.mjs +47 -0
- package/dist/{token-goat-chunk-POOI26O6.mjs → token-goat-chunk-7R2XYKC5.mjs} +6 -5
- package/dist/{token-goat-chunk-E6B2UFDF.mjs → token-goat-chunk-BCN2YQC6.mjs} +10 -8
- package/dist/token-goat-chunk-BJBRGPBX.mjs +244 -0
- package/dist/{token-goat-chunk-TG5ZPD6B.mjs → token-goat-chunk-CBMY2FGI.mjs} +479 -544
- package/dist/{token-goat-chunk-LRIZ7K3F.mjs → token-goat-chunk-CC2PYJM7.mjs} +2 -1
- package/dist/{token-goat-chunk-7EPYB34H.mjs → token-goat-chunk-D5ICEPSB.mjs} +14 -14
- package/dist/token-goat-chunk-D7GHQKQD.mjs +30 -0
- package/dist/{token-goat-chunk-JALB3KWJ.mjs → token-goat-chunk-EL7M26WP.mjs} +7623 -8462
- package/dist/{token-goat-chunk-ZZT6PVB3.mjs → token-goat-chunk-F7QZRIWM.mjs} +69 -20
- package/dist/{token-goat-chunk-FLEYOCAS.mjs → token-goat-chunk-FSTWAOW6.mjs} +3 -3
- package/dist/token-goat-chunk-GGLEE35R.mjs +564 -0
- package/dist/{token-goat-chunk-IKZLSRII.mjs → token-goat-chunk-HUDC5GS5.mjs} +2 -2
- package/dist/{token-goat-chunk-43JFN26X.mjs → token-goat-chunk-HXNAC4ZF.mjs} +22 -964
- package/dist/token-goat-chunk-I7CB3X4K.mjs +1379 -0
- package/dist/{token-goat-chunk-GKZ2US5B.mjs → token-goat-chunk-IFORDBGC.mjs} +32 -27
- package/dist/{token-goat-chunk-CXBOFPF4.mjs → token-goat-chunk-IHKZ3QNA.mjs} +26 -15
- package/dist/token-goat-chunk-IZXKVT4A.mjs +711 -0
- package/dist/{token-goat-chunk-PAV6NNY7.mjs → token-goat-chunk-JXK2HQXS.mjs} +22 -8
- package/dist/{token-goat-chunk-6E2IDLHF.mjs → token-goat-chunk-L45ZQRT7.mjs} +1 -1
- package/dist/{token-goat-chunk-MDV5VWF4.mjs → token-goat-chunk-L7SDVGBT.mjs} +196 -14
- package/dist/token-goat-chunk-LEG3JNJ6.mjs +139 -0
- package/dist/{token-goat-chunk-7SXPJOSZ.mjs → token-goat-chunk-M56BWPBN.mjs} +1 -1
- package/dist/{token-goat-chunk-G6EYO5CD.mjs → token-goat-chunk-MAMQPC43.mjs} +2 -87
- package/dist/{token-goat-chunk-VVROQBQJ.mjs → token-goat-chunk-MMLMALWK.mjs} +5 -3
- package/dist/{token-goat-chunk-D2X7XN5M.mjs → token-goat-chunk-MVSWBNMD.mjs} +7 -231
- package/dist/{token-goat-chunk-C2PG4K5D.mjs → token-goat-chunk-NILVK7XM.mjs} +4 -4
- package/dist/{token-goat-chunk-BAWKGODL.mjs → token-goat-chunk-Q4S3UQGO.mjs} +1 -1
- package/dist/{token-goat-chunk-MWID3YOY.mjs → token-goat-chunk-QM76S6YS.mjs} +3 -3
- package/dist/{token-goat-chunk-4GEDH2WU.mjs → token-goat-chunk-RJH64KQH.mjs} +81 -70
- package/dist/{token-goat-chunk-STYRLQIW.mjs → token-goat-chunk-RSS3TLXU.mjs} +2 -2
- package/dist/{token-goat-chunk-5BQ7W7D7.mjs → token-goat-chunk-SJEKA7Y2.mjs} +21 -16
- package/dist/{token-goat-chunk-RIB6XY2V.mjs → token-goat-chunk-UBUKHVYW.mjs} +1 -1
- package/dist/{token-goat-chunk-7Y6GWTII.mjs → token-goat-chunk-VE27HPIF.mjs} +14 -10
- package/dist/{token-goat-chunk-RH27ZSPF.mjs → token-goat-chunk-VWZKZPSR.mjs} +100 -23
- package/dist/{token-goat-chunk-L45IWWMC.mjs → token-goat-chunk-XI2VFAV6.mjs} +6 -6
- package/dist/{token-goat-chunk-WNBSCSAI.mjs → token-goat-chunk-XKY4VKJ4.mjs} +1 -1
- package/dist/{token-goat-chunk-L43RKNHA.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-ADMR3QVF.mjs +0 -41
- package/dist/token-goat-chunk-MZTO4FXH.mjs +0 -26
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
2
|
const require = __cjsRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
PassthroughFilter,
|
|
5
5
|
compressedTokensSaved,
|
|
6
6
|
deliverCompressed,
|
|
7
7
|
dispatchArgv,
|
|
8
8
|
filterByName,
|
|
9
9
|
selectFilter
|
|
10
|
-
} from "./token-goat-chunk-
|
|
10
|
+
} from "./token-goat-chunk-RJH64KQH.mjs";
|
|
11
11
|
import {
|
|
12
|
-
capTokens,
|
|
13
|
-
shlexSplit,
|
|
14
12
|
storeBashOutputSync
|
|
15
|
-
} from "./token-goat-chunk-
|
|
13
|
+
} from "./token-goat-chunk-HXNAC4ZF.mjs";
|
|
14
|
+
import {
|
|
15
|
+
capTokens,
|
|
16
|
+
shlexSplit
|
|
17
|
+
} from "./token-goat-chunk-4RN64ZND.mjs";
|
|
16
18
|
import {
|
|
17
19
|
recordStat
|
|
18
|
-
} from "./token-goat-chunk-
|
|
20
|
+
} from "./token-goat-chunk-MVSWBNMD.mjs";
|
|
19
21
|
import {
|
|
20
22
|
detectHarness,
|
|
21
23
|
loadConfig
|
|
22
|
-
} from "./token-goat-chunk-
|
|
24
|
+
} from "./token-goat-chunk-CC2PYJM7.mjs";
|
|
23
25
|
import {
|
|
24
26
|
init_define_import_meta_env
|
|
25
27
|
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
@@ -108,11 +110,41 @@ function wrappedShell() {
|
|
|
108
110
|
function canRunWrappedShell() {
|
|
109
111
|
return process.platform !== "win32" || resolveWindowsBash() !== null;
|
|
110
112
|
}
|
|
113
|
+
function resolvePowerShell(env = process.env, isExe = isExecutable) {
|
|
114
|
+
const override = env["TOKEN_GOAT_POWERSHELL"] || env["TOKEN_GOAT_PWSH"];
|
|
115
|
+
if (override && isExe(override)) return override;
|
|
116
|
+
if (process.platform === "win32") {
|
|
117
|
+
for (const dir of (env["PATH"] ?? "").split(path.delimiter)) {
|
|
118
|
+
if (!dir) continue;
|
|
119
|
+
const cand = path.join(dir, "pwsh.exe");
|
|
120
|
+
if (isExe(cand)) return cand;
|
|
121
|
+
}
|
|
122
|
+
const systemRoot = env["SystemRoot"] ?? env["windir"] ?? "C:\\Windows";
|
|
123
|
+
const defaultPs = path.join(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
|
|
124
|
+
if (isExe(defaultPs)) return defaultPs;
|
|
125
|
+
return "powershell.exe";
|
|
126
|
+
}
|
|
127
|
+
for (const dir of (env["PATH"] ?? "").split(path.delimiter)) {
|
|
128
|
+
if (!dir) continue;
|
|
129
|
+
const cand = path.join(dir, "pwsh");
|
|
130
|
+
if (isExe(cand)) return cand;
|
|
131
|
+
}
|
|
132
|
+
for (const cand of ["/usr/bin/pwsh", "/usr/local/bin/pwsh", "/opt/microsoft/powershell/7/pwsh"]) {
|
|
133
|
+
if (isExe(cand)) return cand;
|
|
134
|
+
}
|
|
135
|
+
return "pwsh";
|
|
136
|
+
}
|
|
137
|
+
function canRunPowerShell(env = process.env, isExe = isExecutable) {
|
|
138
|
+
if (process.platform === "win32") return true;
|
|
139
|
+
try {
|
|
140
|
+
const ps = resolvePowerShell(env, isExe);
|
|
141
|
+
return isExe(ps);
|
|
142
|
+
} catch {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
111
146
|
|
|
112
147
|
// src/bash_runner.ts
|
|
113
|
-
var IdentityFilter = class extends ToolFilter {
|
|
114
|
-
name = "passthrough";
|
|
115
|
-
};
|
|
116
148
|
var DEFAULT_TIMEOUT_SECONDS = 600;
|
|
117
149
|
var MAX_CAPTURE_BYTES = 32 * 1024 * 1024;
|
|
118
150
|
var MIN_RECORD_STAT_BYTES = 32;
|
|
@@ -180,8 +212,22 @@ function resolveFilter(command, filterName, cwd) {
|
|
|
180
212
|
function baseSpawnOptions(timeout, cwd) {
|
|
181
213
|
return { timeout: timeout * 1e3, cwd };
|
|
182
214
|
}
|
|
183
|
-
function spawnTarget(command, nativeShell) {
|
|
184
|
-
|
|
215
|
+
function spawnTarget(command, nativeShell, shellType) {
|
|
216
|
+
if (shellType === "pwsh" || shellType === "powershell") {
|
|
217
|
+
const ps = resolvePowerShell();
|
|
218
|
+
return {
|
|
219
|
+
file: ps,
|
|
220
|
+
args: [
|
|
221
|
+
"-NoProfile",
|
|
222
|
+
"-NonInteractive",
|
|
223
|
+
"-Command",
|
|
224
|
+
"$c = $env:TG_CMD; Remove-Item Env:\\TG_CMD -ErrorAction SilentlyContinue; [scriptblock]::Create($c).Invoke(); if ($LASTEXITCODE -ne $null -and $LASTEXITCODE -ne 0) { exit $LASTEXITCODE }"
|
|
225
|
+
],
|
|
226
|
+
shell: false,
|
|
227
|
+
cmdEnv: { TG_CMD: command }
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
const shell = nativeShell || shellType === "native" ? true : wrappedShell();
|
|
185
231
|
if (typeof shell === "string") return { file: shell, args: ["-c", 'eval "$TG_CMD"'], shell: false, cmdEnv: { TG_CMD: command } };
|
|
186
232
|
return { file: command, args: [], shell };
|
|
187
233
|
}
|
|
@@ -214,17 +260,17 @@ async function run(command, opts = {}) {
|
|
|
214
260
|
const { filter, argv } = resolveFilter(command, opts.filterName, opts.cwd);
|
|
215
261
|
if (filter === null) {
|
|
216
262
|
if ((opts.maxTokens ?? 0) > 0 || opts.quietSuccess) {
|
|
217
|
-
return wrapAndCompress(command, argv, new
|
|
263
|
+
return wrapAndCompress(command, argv, new PassthroughFilter(), timeout, resolveProfile(opts.compressionProfile), opts);
|
|
218
264
|
}
|
|
219
|
-
return passthrough(command, timeout, opts.cwd, opts.env, opts.nativeShell);
|
|
265
|
+
return passthrough(command, timeout, opts.cwd, opts.env, opts.nativeShell, opts.shellType);
|
|
220
266
|
}
|
|
221
267
|
return wrapAndCompress(command, argv, filter, timeout, resolveProfile(opts.compressionProfile), opts);
|
|
222
268
|
}
|
|
223
|
-
function runRaw(command, timeout = DEFAULT_TIMEOUT_SECONDS) {
|
|
224
|
-
return passthrough(command, timeout, void 0, void 0);
|
|
269
|
+
function runRaw(command, timeout = DEFAULT_TIMEOUT_SECONDS, nativeShell, shellType) {
|
|
270
|
+
return passthrough(command, timeout, void 0, void 0, nativeShell, shellType);
|
|
225
271
|
}
|
|
226
|
-
function passthrough(command, timeout, cwd, env, nativeShell) {
|
|
227
|
-
const { file, args, shell, cmdEnv } = spawnTarget(command, nativeShell);
|
|
272
|
+
function passthrough(command, timeout, cwd, env, nativeShell, shellType) {
|
|
273
|
+
const { file, args, shell, cmdEnv } = spawnTarget(command, nativeShell, shellType);
|
|
228
274
|
const result = spawnSync(file, args, {
|
|
229
275
|
...baseSpawnOptions(timeout, cwd),
|
|
230
276
|
shell,
|
|
@@ -247,7 +293,7 @@ async function wrapAndCompress(command, argv, filter, timeout, profile, opts) {
|
|
|
247
293
|
const writeStdout = opts.writeStdout ?? ((s) => process.stdout.write(s));
|
|
248
294
|
const writeStderr = opts.writeStderr ?? ((s) => process.stderr.write(s));
|
|
249
295
|
const startTime = Date.now();
|
|
250
|
-
const { file, args, shell, cmdEnv } = spawnTarget(command, opts.nativeShell);
|
|
296
|
+
const { file, args, shell, cmdEnv } = spawnTarget(command, opts.nativeShell, opts.shellType);
|
|
251
297
|
const stdoutSink = new CaptureSink(MAX_CAPTURE_BYTES);
|
|
252
298
|
const stderrSink = new CaptureSink(MAX_CAPTURE_BYTES);
|
|
253
299
|
let timedOut = false;
|
|
@@ -311,11 +357,13 @@ async function wrapAndCompress(command, argv, filter, timeout, profile, opts) {
|
|
|
311
357
|
let text = delivered;
|
|
312
358
|
const maxTokens = opts.maxTokens ?? 0;
|
|
313
359
|
if (maxTokens > 0) text = capTokens(text, maxTokens);
|
|
360
|
+
const capped = text !== delivered;
|
|
314
361
|
let body = text + marker;
|
|
315
|
-
if (applied) {
|
|
362
|
+
if (applied || capped) {
|
|
316
363
|
const fullRaw = (stdoutText + (stderrText ? "\n" + stderrText : "")).trim();
|
|
317
364
|
const recallId = storeBashOutputSync(command, fullRaw, exitCode, opts.cwd ?? null);
|
|
318
365
|
body += "\n[token-goat] full output: bash-output " + recallId + " --full";
|
|
366
|
+
if (opts.capHint) body += "\n[token-goat] " + opts.capHint;
|
|
319
367
|
}
|
|
320
368
|
writeStdout(body.endsWith("\n") ? body : body + "\n");
|
|
321
369
|
if (applied) recordSavings(compressed);
|
|
@@ -332,6 +380,7 @@ export {
|
|
|
332
380
|
clipToDeliveryCap,
|
|
333
381
|
deliveredOutputBytes,
|
|
334
382
|
canRunWrappedShell,
|
|
383
|
+
canRunPowerShell,
|
|
335
384
|
DEFAULT_TIMEOUT_SECONDS,
|
|
336
385
|
MAX_CAPTURE_BYTES,
|
|
337
386
|
DEFAULT_HEARTBEAT_INTERVAL_MS,
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
pptxOutline,
|
|
7
7
|
pptxSlideText,
|
|
8
8
|
pptxTextGrep
|
|
9
|
-
} from "./token-goat-chunk-
|
|
10
|
-
import "./token-goat-chunk-
|
|
9
|
+
} from "./token-goat-chunk-Q4S3UQGO.mjs";
|
|
10
|
+
import "./token-goat-chunk-UBUKHVYW.mjs";
|
|
11
11
|
import "./token-goat-chunk-XTQAOTSO.mjs";
|
|
12
12
|
import "./token-goat-chunk-AH6QILZM.mjs";
|
|
13
|
-
import "./token-goat-chunk-
|
|
13
|
+
import "./token-goat-chunk-L45ZQRT7.mjs";
|
|
14
14
|
import "./token-goat-chunk-NMTKNYGF.mjs";
|
|
15
15
|
import "./token-goat-chunk-Y4AFKTHK.mjs";
|
|
16
16
|
import "./token-goat-chunk-GMOUBOX4.mjs";
|