token-goat 2.6.36 → 2.8.0

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.
Files changed (34) hide show
  1. package/README.md +31 -5
  2. package/SECURITY.md +46 -17
  3. package/dist/{token-goat-chunk-UFOVM7ZN.mjs → token-goat-chunk-2F6TFBZE.mjs} +1274 -367
  4. package/dist/token-goat-chunk-324QOJYZ.mjs +91 -0
  5. package/dist/{token-goat-chunk-V465YKOR.mjs → token-goat-chunk-44Y77VHR.mjs} +365 -23
  6. package/dist/{token-goat-chunk-CNDOJ3ZP.mjs → token-goat-chunk-4KZILRZN.mjs} +2 -2
  7. package/dist/token-goat-chunk-5CVKO3DA.mjs +185 -0
  8. package/dist/token-goat-chunk-A62K4XW2.mjs +23 -0
  9. package/dist/{token-goat-chunk-VYMGEVZS.mjs → token-goat-chunk-AO6MFFTW.mjs} +317 -11
  10. package/dist/{token-goat-chunk-65BKISIS.mjs → token-goat-chunk-FBGBTICM.mjs} +4 -4
  11. package/dist/{token-goat-chunk-LN6OUHTV.mjs → token-goat-chunk-J35AKWEQ.mjs} +5 -5
  12. package/dist/{token-goat-hook-chunk-BDR6C6IE.mjs → token-goat-chunk-LVCBDJVE.mjs} +318 -51
  13. package/dist/token-goat-chunk-R4SR7MQY.mjs +486 -0
  14. package/dist/{token-goat-chunk-IYTVE6KN.mjs → token-goat-chunk-SRAR6DOK.mjs} +133 -141
  15. package/dist/{token-goat-chunk-MGOUYAA2.mjs → token-goat-chunk-TUPJRK7R.mjs} +1 -1
  16. package/dist/{token-goat-chunk-KYFJC37X.mjs → token-goat-chunk-VXSYZGBA.mjs} +582 -135
  17. package/dist/{token-goat-chunk-DG53MVNJ.mjs → token-goat-chunk-WN5T5EW5.mjs} +212 -212
  18. package/dist/token-goat-hook.mjs +7 -7
  19. package/dist/token-goat.core.mjs +5 -5
  20. package/package.json +9 -7
  21. package/dist/token-goat-chunk-FRTBMRP7.mjs +0 -10048
  22. package/dist/token-goat-hook-chunk-3QYSN4QV.mjs +0 -14764
  23. package/dist/token-goat-hook-chunk-3ZDBWJDF.mjs +0 -13659
  24. package/dist/token-goat-hook-chunk-5UH54CW6.mjs +0 -912
  25. package/dist/token-goat-hook-chunk-6ODM3MP7.mjs +0 -706
  26. package/dist/token-goat-hook-chunk-A77A26A7.mjs +0 -18184
  27. package/dist/token-goat-hook-chunk-BUOCULAM.mjs +0 -29
  28. package/dist/token-goat-hook-chunk-C6GIABOX.mjs +0 -15971
  29. package/dist/token-goat-hook-chunk-E257IGSN.mjs +0 -153
  30. package/dist/token-goat-hook-chunk-MW5HPEGD.mjs +0 -10411
  31. package/dist/token-goat-hook-chunk-QSCYNJ2B.mjs +0 -23
  32. package/dist/token-goat-hook-chunk-RFRLWOQH.mjs +0 -11
  33. package/dist/token-goat-hook-chunk-XUMIVYEN.mjs +0 -109
  34. package/dist/token-goat-hook-chunk-Y2WHX2P3.mjs +0 -6463
@@ -1,23 +0,0 @@
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-hook-chunk-BDR6C6IE.mjs";
8
- import "./token-goat-hook-chunk-3ZDBWJDF.mjs";
9
- import {
10
- MAX_STDIN_BYTES,
11
- readStdinJson
12
- } from "./token-goat-hook-chunk-5UH54CW6.mjs";
13
- import "./token-goat-hook-chunk-A77A26A7.mjs";
14
- import "./token-goat-hook-chunk-Y2WHX2P3.mjs";
15
- import "./token-goat-hook-chunk-BUOCULAM.mjs";
16
- import "./token-goat-hook-chunk-RFRLWOQH.mjs";
17
- export {
18
- MAX_STDIN_BYTES,
19
- buildEvent,
20
- readStdinJson,
21
- relay,
22
- relayInProcess
23
- };
@@ -1,11 +0,0 @@
1
- import { createRequire as __cjsRequire } from 'node:module';
2
- const require = __cjsRequire(import.meta.url);
3
- var __defProp = Object.defineProperty;
4
- var __export = (target, all) => {
5
- for (var name in all)
6
- __defProp(target, name, { get: all[name], enumerable: true });
7
- };
8
-
9
- export {
10
- __export
11
- };
@@ -1,109 +0,0 @@
1
- import { createRequire as __cjsRequire } from 'node:module';
2
- const require = __cjsRequire(import.meta.url);
3
- import {
4
- clearModuleCaches
5
- } from "./token-goat-hook-chunk-BUOCULAM.mjs";
6
- import "./token-goat-hook-chunk-RFRLWOQH.mjs";
7
-
8
- // src/batch_serve.ts
9
- function swapEnv(next) {
10
- const before = { ...process.env };
11
- for (const key of Object.keys(process.env)) if (!(key in next)) delete process.env[key];
12
- for (const [key, value] of Object.entries(next)) process.env[key] = value;
13
- return () => {
14
- for (const key of Object.keys(process.env)) if (!(key in before)) delete process.env[key];
15
- for (const [key, value] of Object.entries(before)) process.env[key] = value;
16
- };
17
- }
18
- function captureOutput() {
19
- let out = "";
20
- let errText = "";
21
- const realOut = process.stdout.write.bind(process.stdout);
22
- const realErr = process.stderr.write.bind(process.stderr);
23
- const sink = (append) => ((chunk, enc, cb) => {
24
- append(typeof chunk === "string" ? chunk : String(chunk));
25
- const done = typeof enc === "function" ? enc : cb;
26
- if (typeof done === "function") done();
27
- return true;
28
- });
29
- process.stdout.write = sink((s) => {
30
- out += s;
31
- });
32
- process.stderr.write = sink((s) => {
33
- errText += s;
34
- });
35
- return {
36
- stdout: () => out,
37
- stderr: () => errText,
38
- restore: () => {
39
- process.stdout.write = realOut;
40
- process.stderr.write = realErr;
41
- }
42
- };
43
- }
44
- async function serveOne(req, runFn) {
45
- const cwdBefore = process.cwd();
46
- const restoreEnv = swapEnv(req.env ?? { ...process.env });
47
- const cap = captureOutput();
48
- let status;
49
- try {
50
- if (req.cwd !== void 0) process.chdir(req.cwd);
51
- process.exitCode = void 0;
52
- await runFn([process.execPath, "token-goat", ...req.argv]);
53
- status = typeof process.exitCode === "number" ? process.exitCode : 0;
54
- } catch (e) {
55
- cap.restore();
56
- process.stderr.write("");
57
- status = 1;
58
- const captured = { out: cap.stdout(), err: cap.stderr() + String(e instanceof Error ? e.stack ?? e.message : e) + "\n" };
59
- restoreEnv();
60
- process.exitCode = void 0;
61
- try {
62
- process.chdir(cwdBefore);
63
- } catch {
64
- }
65
- clearModuleCaches();
66
- return { id: req.id, status, stdout: captured.out, stderr: captured.err };
67
- }
68
- cap.restore();
69
- const stdout = cap.stdout();
70
- const stderr = cap.stderr();
71
- restoreEnv();
72
- process.exitCode = void 0;
73
- try {
74
- process.chdir(cwdBefore);
75
- } catch {
76
- }
77
- clearModuleCaches();
78
- return { id: req.id, status, stdout, stderr };
79
- }
80
- function serveBatch(token, runFn) {
81
- let buffered = "";
82
- let chain = Promise.resolve();
83
- process.stdin.setEncoding("utf8");
84
- process.stdin.on("data", (chunk) => {
85
- buffered += chunk;
86
- for (; ; ) {
87
- const nl = buffered.indexOf("\n");
88
- if (nl === -1) break;
89
- const line = buffered.slice(0, nl);
90
- buffered = buffered.slice(nl + 1);
91
- if (line.trim() === "") continue;
92
- const req = JSON.parse(line);
93
- chain = chain.then(async () => {
94
- const res = await serveOne(req, runFn);
95
- process.stdout.write(`${token} ${JSON.stringify(res)}
96
- `);
97
- });
98
- }
99
- });
100
- process.stdin.on("end", () => {
101
- void chain.then(() => {
102
- process.exitCode = 0;
103
- });
104
- });
105
- }
106
- export {
107
- serveBatch,
108
- serveOne
109
- };