token-goat 2.6.35 → 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 (35) hide show
  1. package/README.md +35 -7
  2. package/SECURITY.md +47 -16
  3. package/dist/{token-goat-chunk-I2KCEGIP.mjs → token-goat-chunk-2F6TFBZE.mjs} +1355 -408
  4. package/dist/token-goat-chunk-324QOJYZ.mjs +91 -0
  5. package/dist/{token-goat-chunk-K7W3P2TJ.mjs → token-goat-chunk-44Y77VHR.mjs} +425 -39
  6. package/dist/{token-goat-chunk-UIZVX3HN.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-SIHYQCTM.mjs → token-goat-chunk-AO6MFFTW.mjs} +331 -13
  10. package/dist/{token-goat-chunk-DRAIYVUI.mjs → token-goat-chunk-FBGBTICM.mjs} +4 -4
  11. package/dist/{token-goat-chunk-YF67EWRH.mjs → token-goat-chunk-J35AKWEQ.mjs} +5 -5
  12. package/dist/{token-goat-hook-chunk-4POU6OHK.mjs → token-goat-chunk-LVCBDJVE.mjs} +318 -51
  13. package/dist/token-goat-chunk-R4SR7MQY.mjs +486 -0
  14. package/dist/{token-goat-chunk-D5IZEGN2.mjs → token-goat-chunk-SRAR6DOK.mjs} +144 -147
  15. package/dist/{token-goat-hook-chunk-NIPXIAPA.mjs → token-goat-chunk-TUPJRK7R.mjs} +1 -1
  16. package/dist/{token-goat-chunk-HW4VUKJ5.mjs → token-goat-chunk-VXSYZGBA.mjs} +589 -141
  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 +18 -15
  21. package/scripts/install-git-hooks.mjs +55 -0
  22. package/dist/token-goat-chunk-DQIT5JIF.mjs +0 -13659
  23. package/dist/token-goat-chunk-Y2NH6DGZ.mjs +0 -10048
  24. package/dist/token-goat-hook-chunk-2O7P4Z6Q.mjs +0 -6419
  25. package/dist/token-goat-hook-chunk-3AAH72SO.mjs +0 -15970
  26. package/dist/token-goat-hook-chunk-3QYSN4QV.mjs +0 -14764
  27. package/dist/token-goat-hook-chunk-BUOCULAM.mjs +0 -29
  28. package/dist/token-goat-hook-chunk-CRBMPT74.mjs +0 -900
  29. package/dist/token-goat-hook-chunk-D6UJEFHX.mjs +0 -153
  30. package/dist/token-goat-hook-chunk-J4HKWUWZ.mjs +0 -23
  31. package/dist/token-goat-hook-chunk-NXVT4F3S.mjs +0 -10406
  32. package/dist/token-goat-hook-chunk-RFRLWOQH.mjs +0 -11
  33. package/dist/token-goat-hook-chunk-VU6VGZBM.mjs +0 -706
  34. package/dist/token-goat-hook-chunk-XM4W3WCO.mjs +0 -18144
  35. package/dist/token-goat-hook-chunk-XUMIVYEN.mjs +0 -109
@@ -0,0 +1,91 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import "./token-goat-chunk-AEX54RUZ.mjs";
4
+
5
+ // src/mcp_stdio.ts
6
+ import process from "node:process";
7
+ var STDIO_MAX_BUFFER_BYTES = 10 * 1024 * 1024;
8
+ var StdioServerTransport = class {
9
+ stdin;
10
+ stdout;
11
+ buffer;
12
+ started = false;
13
+ onmessage;
14
+ onclose;
15
+ onerror;
16
+ // Arrow properties rather than bound methods so `off()` can remove the exact same function
17
+ // reference `on()` added -- a fresh `.bind(this)` at removal time would leave the listener
18
+ // attached, and a second `mcp-serve` in the same process would then see every message twice.
19
+ ondata = (chunk) => {
20
+ const size = (this.buffer?.length ?? 0) + chunk.length;
21
+ if (size > STDIO_MAX_BUFFER_BYTES) {
22
+ this.buffer = void 0;
23
+ this.onerror?.(new Error(`MCP stdio read buffer exceeded ${STDIO_MAX_BUFFER_BYTES} bytes`));
24
+ void this.close();
25
+ return;
26
+ }
27
+ this.buffer = this.buffer === void 0 ? chunk : Buffer.concat([this.buffer, chunk]);
28
+ this.drain();
29
+ };
30
+ onstreamerror = (error) => {
31
+ this.onerror?.(error);
32
+ };
33
+ constructor(stdin = process.stdin, stdout = process.stdout) {
34
+ this.stdin = stdin;
35
+ this.stdout = stdout;
36
+ }
37
+ async start() {
38
+ if (this.started) throw new Error("StdioServerTransport already started");
39
+ this.started = true;
40
+ this.stdin.on("data", this.ondata);
41
+ this.stdin.on("error", this.onstreamerror);
42
+ return Promise.resolve();
43
+ }
44
+ /**
45
+ * Consumes every complete line currently buffered. A line that is not valid JSON is reported and
46
+ * skipped rather than closing the connection: one malformed message is not a reason to drop a
47
+ * working session, and the next line may well be fine.
48
+ */
49
+ drain() {
50
+ for (; ; ) {
51
+ const buffer = this.buffer;
52
+ if (buffer === void 0) return;
53
+ const index = buffer.indexOf("\n");
54
+ if (index === -1) return;
55
+ const line = buffer.toString("utf8", 0, index).replace(/\r$/, "");
56
+ this.buffer = buffer.subarray(index + 1);
57
+ if (line.trim().length === 0) continue;
58
+ let message;
59
+ try {
60
+ message = JSON.parse(line);
61
+ } catch (err) {
62
+ this.onerror?.(err instanceof Error ? err : new Error(String(err)));
63
+ continue;
64
+ }
65
+ this.onmessage?.(message);
66
+ }
67
+ }
68
+ /**
69
+ * Resolves once the message is handed off. Waiting for `drain` when the stream says it is full
70
+ * is what keeps a long reply from being silently truncated on a slow or small pipe.
71
+ */
72
+ send(message) {
73
+ return new Promise((resolve) => {
74
+ if (this.stdout.write(`${JSON.stringify(message)}
75
+ `)) resolve();
76
+ else this.stdout.once("drain", resolve);
77
+ });
78
+ }
79
+ async close() {
80
+ this.stdin.off("data", this.ondata);
81
+ this.stdin.off("error", this.onstreamerror);
82
+ if (this.stdin.listenerCount("data") === 0) this.stdin.pause();
83
+ this.buffer = void 0;
84
+ this.onclose?.();
85
+ return Promise.resolve();
86
+ }
87
+ };
88
+ export {
89
+ STDIO_MAX_BUFFER_BYTES,
90
+ StdioServerTransport
91
+ };