token-goat 2.9.28 → 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.
Files changed (134) hide show
  1. package/README.md +36 -40
  2. package/SECURITY.md +28 -10
  3. package/THIRD_PARTY_NOTICES.md +40 -3
  4. package/dist/native/linux-arm64/tg-hook +0 -0
  5. package/dist/native/linux-x64/tg-hook +0 -0
  6. package/dist/ort-wasm-simd-threaded.mjs +59 -0
  7. package/dist/token-goat-chunk-3CHUNJ2O.mjs +53 -0
  8. package/dist/token-goat-chunk-3Z5S4KGM.mjs +918 -0
  9. package/dist/token-goat-chunk-4FVIAHSI.mjs +211 -0
  10. package/dist/{token-goat-chunk-66LODAUT.mjs → token-goat-chunk-4JJS54TR.mjs} +4 -3
  11. package/dist/token-goat-chunk-4LCCNRTG.mjs +313 -0
  12. package/dist/token-goat-chunk-54K3EUV3.mjs +35 -0
  13. package/dist/token-goat-chunk-56EIMS3E.mjs +159 -0
  14. package/dist/token-goat-chunk-5BCIJXMO.mjs +609 -0
  15. package/dist/token-goat-chunk-5KDMCMF2.mjs +362 -0
  16. package/dist/token-goat-chunk-5RG5SBL6.mjs +221 -0
  17. package/dist/{token-goat-chunk-RRNZMM3A.mjs → token-goat-chunk-5Y6ZYL6U.mjs} +21 -2
  18. package/dist/{token-goat-chunk-NILVK7XM.mjs → token-goat-chunk-64FBPDTK.mjs} +12 -6
  19. package/dist/{token-goat-chunk-LEG3JNJ6.mjs → token-goat-chunk-664RTTUV.mjs} +31 -15
  20. package/dist/token-goat-chunk-67TQJ76B.mjs +57 -0
  21. package/dist/token-goat-chunk-6QMAS7AB.mjs +42 -0
  22. package/dist/token-goat-chunk-7BXSNBY5.mjs +253 -0
  23. package/dist/{token-goat-chunk-F7QZRIWM.mjs → token-goat-chunk-7F2UBPD3.mjs} +42 -35
  24. package/dist/{token-goat-chunk-CC2PYJM7.mjs → token-goat-chunk-7IN2MKDS.mjs} +718 -595
  25. package/dist/token-goat-chunk-7NADEDKJ.mjs +124 -0
  26. package/dist/{token-goat-chunk-6SGLIPQB.mjs → token-goat-chunk-A3CK6N5Z.mjs} +621 -72
  27. package/dist/{token-goat-chunk-HXNAC4ZF.mjs → token-goat-chunk-AFLYLHDH.mjs} +48 -33
  28. package/dist/token-goat-chunk-AM5V6GSX.mjs +367 -0
  29. package/dist/{token-goat-chunk-I7CB3X4K.mjs → token-goat-chunk-APGZXSPS.mjs} +44 -148
  30. package/dist/{token-goat-chunk-BJBRGPBX.mjs → token-goat-chunk-ARDNEC2U.mjs} +11 -7
  31. package/dist/token-goat-chunk-ATCPY7EQ.mjs +134 -0
  32. package/dist/token-goat-chunk-B2RZZCSS.mjs +354 -0
  33. package/dist/{token-goat-chunk-QM76S6YS.mjs → token-goat-chunk-B45VMIIH.mjs} +6 -5
  34. package/dist/token-goat-chunk-BPGCUMR7.mjs +30 -0
  35. package/dist/{token-goat-chunk-GGLEE35R.mjs → token-goat-chunk-C63JQV5K.mjs} +49 -10
  36. package/dist/{token-goat-chunk-RJH64KQH.mjs → token-goat-chunk-COBQGL5S.mjs} +2661 -2440
  37. package/dist/token-goat-chunk-COTXZHTS.mjs +39 -0
  38. package/dist/token-goat-chunk-CYCEYAEO.mjs +265 -0
  39. package/dist/token-goat-chunk-CZ3LUXYZ.mjs +4115 -0
  40. package/dist/token-goat-chunk-DZX2YDPT.mjs +15 -0
  41. package/dist/token-goat-chunk-E3OQX2XT.mjs +824 -0
  42. package/dist/token-goat-chunk-EFHMMIGP.mjs +68 -0
  43. package/dist/token-goat-chunk-ETBHVDB6.mjs +328 -0
  44. package/dist/token-goat-chunk-EVMZJ27Z.mjs +147 -0
  45. package/dist/token-goat-chunk-EXKGNHEG.mjs +2096 -0
  46. package/dist/{token-goat-chunk-6Z5ULNE5.mjs → token-goat-chunk-FBNQNSJK.mjs} +2490 -4957
  47. package/dist/{token-goat-chunk-NMTKNYGF.mjs → token-goat-chunk-FNFBKLRD.mjs} +74 -9
  48. package/dist/{token-goat-chunk-XI2VFAV6.mjs → token-goat-chunk-FZ3NEW5O.mjs} +33 -19
  49. package/dist/token-goat-chunk-G5PJ7AGM.mjs +36 -0
  50. package/dist/{token-goat-chunk-VE27HPIF.mjs → token-goat-chunk-GFBSN7BD.mjs} +30 -398
  51. package/dist/{token-goat-chunk-L45ZQRT7.mjs → token-goat-chunk-GOLEOXZP.mjs} +780 -786
  52. package/dist/token-goat-chunk-H2K3QP6H.mjs +24 -0
  53. package/dist/token-goat-chunk-H2PHHGM5.mjs +188 -0
  54. package/dist/token-goat-chunk-HAVAOB3S.mjs +87 -0
  55. package/dist/token-goat-chunk-HG45AF2B.mjs +2228 -0
  56. package/dist/{token-goat-chunk-CBMY2FGI.mjs → token-goat-chunk-HOJLCGDP.mjs} +17113 -15554
  57. package/dist/{token-goat-chunk-HUDC5GS5.mjs → token-goat-chunk-HYBFA5X3.mjs} +120 -19
  58. package/dist/token-goat-chunk-IVALLT3S.mjs +48 -0
  59. package/dist/token-goat-chunk-IVE6U7KV.mjs +53 -0
  60. package/dist/{token-goat-chunk-UBUKHVYW.mjs → token-goat-chunk-IVKIZWAB.mjs} +3 -3
  61. package/dist/{token-goat-chunk-4JMWPWCS.mjs → token-goat-chunk-JB6QN6VF.mjs} +6 -4
  62. package/dist/{token-goat-chunk-Q4S3UQGO.mjs → token-goat-chunk-JDHE26RP.mjs} +10 -3
  63. package/dist/{token-goat-chunk-7R2XYKC5.mjs → token-goat-chunk-JDU3EXSU.mjs} +14 -10
  64. package/dist/token-goat-chunk-JDWCRD6M.mjs +253 -0
  65. package/dist/{token-goat-chunk-XBESNWEX.mjs → token-goat-chunk-JN4XMLSD.mjs} +7 -4
  66. package/dist/token-goat-chunk-JTQQGXZH.mjs +733 -0
  67. package/dist/token-goat-chunk-KKUFXAPD.mjs +25 -0
  68. package/dist/token-goat-chunk-KQNZDCBD.mjs +47 -0
  69. package/dist/{token-goat-chunk-4RN64ZND.mjs → token-goat-chunk-KWPNJBDH.mjs} +28 -3
  70. package/dist/token-goat-chunk-LOBGHXPB.mjs +242 -0
  71. package/dist/token-goat-chunk-MKPF4CL5.mjs +37 -0
  72. package/dist/token-goat-chunk-MNWKPRAL.mjs +13 -0
  73. package/dist/{token-goat-chunk-YWSP6IU7.mjs → token-goat-chunk-N2NMER56.mjs} +25 -15
  74. package/dist/token-goat-chunk-NYKZLXMK.mjs +218 -0
  75. package/dist/token-goat-chunk-OJBNYTJP.mjs +3087 -0
  76. package/dist/token-goat-chunk-P4QMM4WK.mjs +295 -0
  77. package/dist/token-goat-chunk-PD5VKH46.mjs +184 -0
  78. package/dist/token-goat-chunk-PEPTHRFF.mjs +129 -0
  79. package/dist/{token-goat-chunk-VWZKZPSR.mjs → token-goat-chunk-PU7V3FD6.mjs} +8752 -11098
  80. package/dist/token-goat-chunk-PY533T7F.mjs +46 -0
  81. package/dist/token-goat-chunk-Q5VTGRH7.mjs +761 -0
  82. package/dist/{token-goat-chunk-IHKZ3QNA.mjs → token-goat-chunk-QCLDAQTS.mjs} +33 -19
  83. package/dist/{token-goat-chunk-LKSXAMJB.mjs → token-goat-chunk-QSBRTGM2.mjs} +9 -2
  84. package/dist/{token-goat-chunk-4STDIGYC.mjs → token-goat-chunk-RC35RBUL.mjs} +7 -5
  85. package/dist/{token-goat-chunk-D5ICEPSB.mjs → token-goat-chunk-RHXKCZX3.mjs} +887 -507
  86. package/dist/{token-goat-chunk-RSS3TLXU.mjs → token-goat-chunk-RZRTDST7.mjs} +17 -7
  87. package/dist/{token-goat-chunk-MAMQPC43.mjs → token-goat-chunk-SJHWVNDQ.mjs} +15 -21
  88. package/dist/token-goat-chunk-SMVRN2HU.mjs +188 -0
  89. package/dist/{token-goat-chunk-EL7M26WP.mjs → token-goat-chunk-SQSSNQPE.mjs} +2100 -1442
  90. package/dist/{token-goat-chunk-OZRSREKR.mjs → token-goat-chunk-T4FK7VOV.mjs} +3 -3
  91. package/dist/token-goat-chunk-U4N3BN2W.mjs +92 -0
  92. package/dist/token-goat-chunk-UA5V6P3P.mjs +122 -0
  93. package/dist/{token-goat-chunk-XKY4VKJ4.mjs → token-goat-chunk-UQ5UK2T7.mjs} +15 -4
  94. package/dist/token-goat-chunk-USILZ3T3.mjs +53 -0
  95. package/dist/token-goat-chunk-VES7EL7O.mjs +205 -0
  96. package/dist/{token-goat-chunk-M56BWPBN.mjs → token-goat-chunk-VL3YIFHZ.mjs} +550 -49
  97. package/dist/{token-goat-chunk-IZXKVT4A.mjs → token-goat-chunk-VPBBTSJR.mjs} +362 -128
  98. package/dist/{token-goat-chunk-F2ARFHLJ.mjs → token-goat-chunk-W3QCJS6G.mjs} +10 -2
  99. package/dist/{token-goat-chunk-FSTWAOW6.mjs → token-goat-chunk-WY3L4DVT.mjs} +11 -5
  100. package/dist/{token-goat-chunk-OSUFN2FV.mjs → token-goat-chunk-XB5KKOCG.mjs} +5 -25
  101. package/dist/token-goat-chunk-XKI4SEMX.mjs +66 -0
  102. package/dist/token-goat-chunk-XU4P6Z24.mjs +133 -0
  103. package/dist/{token-goat-chunk-6CCQDAYY.mjs → token-goat-chunk-Y776AENC.mjs} +138 -33
  104. package/dist/token-goat-chunk-YARZFCZS.mjs +359 -0
  105. package/dist/{token-goat-chunk-EEIDFMEM.mjs → token-goat-chunk-YZAAZU2S.mjs} +12 -3
  106. package/dist/{token-goat-chunk-E3K3BTEQ.mjs → token-goat-chunk-Z44YO3QZ.mjs} +12 -6
  107. package/dist/token-goat-chunk-Z57YODA2.mjs +35 -0
  108. package/dist/{token-goat-chunk-DA43OE7L.mjs → token-goat-chunk-ZCDTCVIS.mjs} +49 -30
  109. package/dist/token-goat-chunk-ZEJVMUQH.mjs +48 -0
  110. package/dist/{token-goat-chunk-BGHSSJUA.mjs → token-goat-chunk-ZFOBKUWH.mjs} +1 -1
  111. package/dist/token-goat-chunk-ZMBL6UVV.mjs +110 -0
  112. package/dist/{token-goat-chunk-SJEKA7Y2.mjs → token-goat-chunk-ZQSJMO2R.mjs} +381 -201
  113. package/dist/token-goat-hook-client.cjs +539 -0
  114. package/dist/token-goat-hook-client.mjs +26 -0
  115. package/dist/token-goat-hook.mjs +48 -28
  116. package/dist/token-goat.core.mjs +10 -45
  117. package/docs/C4_RUNTIME_ARCHITECTURE.md +3 -3
  118. package/docs/cli.md +82 -47
  119. package/docs/install.md +58 -23
  120. package/docs/security.md +7 -7
  121. package/package.json +17 -7
  122. package/scripts/verify-native-dist.mjs +386 -0
  123. package/dist/token-goat-chunk-4JJBFT7V.mjs +0 -20
  124. package/dist/token-goat-chunk-5NNYIUGV.mjs +0 -143
  125. package/dist/token-goat-chunk-6DQNNFJ6.mjs +0 -294
  126. package/dist/token-goat-chunk-7MAFDRVR.mjs +0 -47
  127. package/dist/token-goat-chunk-BCN2YQC6.mjs +0 -32
  128. package/dist/token-goat-chunk-D7GHQKQD.mjs +0 -30
  129. package/dist/token-goat-chunk-GMOUBOX4.mjs +0 -386
  130. package/dist/token-goat-chunk-IFORDBGC.mjs +0 -192
  131. package/dist/token-goat-chunk-JXK2HQXS.mjs +0 -318
  132. package/dist/token-goat-chunk-L7SDVGBT.mjs +0 -430
  133. package/dist/token-goat-chunk-MMLMALWK.mjs +0 -1381
  134. package/dist/token-goat-chunk-MVSWBNMD.mjs +0 -1985
@@ -0,0 +1,25 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ init_define_import_meta_env
5
+ } from "./token-goat-chunk-A37V4PBF.mjs";
6
+
7
+ // src/types.ts
8
+ init_define_import_meta_env();
9
+ var HOOK_EVENTS = [
10
+ "pre_tool_use",
11
+ "post_tool_use",
12
+ "notification",
13
+ "stop",
14
+ "pre_compact",
15
+ "post_compact",
16
+ "user_prompt_submit",
17
+ "subagent_stop",
18
+ "subagent_start",
19
+ "session_start",
20
+ "post_tool_use_failure"
21
+ ];
22
+
23
+ export {
24
+ HOOK_EVENTS
25
+ };
@@ -0,0 +1,47 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ WorkerAlreadyRunningError,
5
+ WorkerDataDirUnwritableError,
6
+ appendWorkerErrorLog,
7
+ claimWorkerPidFile,
8
+ currentDaemonStamp,
9
+ dataDirWriteRefusal,
10
+ drainHeartbeatPathFor,
11
+ ensureWorkerAlive,
12
+ isWorkerRunning,
13
+ oneLogLine,
14
+ readPidFile,
15
+ resolvePollIntervalMs,
16
+ startDetachedWorker,
17
+ stopWorker,
18
+ workerErrorLogPath,
19
+ workerPidPath,
20
+ workerStampPath,
21
+ writeDrainHeartbeat
22
+ } from "./token-goat-chunk-5KDMCMF2.mjs";
23
+ import "./token-goat-chunk-GOLEOXZP.mjs";
24
+ import "./token-goat-chunk-AM5V6GSX.mjs";
25
+ import "./token-goat-chunk-FNFBKLRD.mjs";
26
+ import "./token-goat-chunk-VES7EL7O.mjs";
27
+ import "./token-goat-chunk-A37V4PBF.mjs";
28
+ export {
29
+ WorkerAlreadyRunningError,
30
+ WorkerDataDirUnwritableError,
31
+ appendWorkerErrorLog,
32
+ claimWorkerPidFile,
33
+ currentDaemonStamp,
34
+ dataDirWriteRefusal,
35
+ drainHeartbeatPathFor,
36
+ ensureWorkerAlive,
37
+ isWorkerRunning,
38
+ oneLogLine,
39
+ readPidFile,
40
+ resolvePollIntervalMs,
41
+ startDetachedWorker,
42
+ stopWorker,
43
+ workerErrorLogPath,
44
+ workerPidPath,
45
+ workerStampPath,
46
+ writeDrainHeartbeat
47
+ };
@@ -2,7 +2,7 @@ import { createRequire as __cjsRequire } from 'node:module';
2
2
  const require = __cjsRequire(import.meta.url);
3
3
  import {
4
4
  stripAnsiEscapes
5
- } from "./token-goat-chunk-MVSWBNMD.mjs";
5
+ } from "./token-goat-chunk-HAVAOB3S.mjs";
6
6
  import {
7
7
  init_define_import_meta_env
8
8
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -36,12 +36,24 @@ function clipWideLines(text, maxChars = INPUT_MAX_LINE_CHARS) {
36
36
  let clipped = 0;
37
37
  const out = text.split("\n").map((line) => {
38
38
  if (line.length <= maxChars) return line;
39
+ const marker = CLIPPED_MARKER_RE.exec(line);
40
+ if (marker && line.length - marker[0].length <= maxChars) return line;
39
41
  clipped += 1;
40
42
  const keep = Math.floor(maxChars / 2);
41
43
  return line.slice(0, keep) + ` ... [${line.length - maxChars} chars clipped] ... ` + line.slice(line.length - (maxChars - keep));
42
44
  });
43
45
  return clipped === 0 ? text : out.join("\n");
44
46
  }
47
+ function isWholeJsonDocument(text) {
48
+ const t = text.trim();
49
+ if (t[0] !== "{" && t[0] !== "[") return false;
50
+ try {
51
+ JSON.parse(t);
52
+ return true;
53
+ } catch {
54
+ return false;
55
+ }
56
+ }
45
57
  function clampKeepingEnds(text, maxBytes) {
46
58
  const buf = Buffer.from(text, "utf8");
47
59
  if (buf.length <= maxBytes) return null;
@@ -195,7 +207,7 @@ function dedupeConsecutive(lines, opts = {}) {
195
207
  let count = 0;
196
208
  const flush = () => {
197
209
  if (prev === null) return;
198
- if (count >= minRun) out.push(fmt(prev, count));
210
+ if (count >= minRun) out.push(prev.trim() === "" ? "" : fmt(prev, count));
199
211
  else for (let i = 0; i < count; i++) out.push(prev);
200
212
  };
201
213
  for (const line of lines) {
@@ -206,7 +218,7 @@ function dedupeConsecutive(lines, opts = {}) {
206
218
  out.push(line);
207
219
  continue;
208
220
  }
209
- if (line === prev) {
221
+ if (line === prev || prev !== null && prev.trim() === "" && line.trim() === "") {
210
222
  count += 1;
211
223
  continue;
212
224
  }
@@ -723,6 +735,7 @@ function shlexSplit(cmd) {
723
735
  if (has) tokens.push(cur);
724
736
  return tokens;
725
737
  }
738
+ var CLIP_MIN_OVERFLOW = 64;
726
739
  function capLongLines(lines, maxChars = FALLBACK_MAX_LINE_CHARS) {
727
740
  return lines.map((line) => {
728
741
  if (line.length <= maxChars) return line;
@@ -732,6 +745,7 @@ function capLongLines(lines, maxChars = FALLBACK_MAX_LINE_CHARS) {
732
745
  const high = line.charCodeAt(cut - 1);
733
746
  const low = line.charCodeAt(cut);
734
747
  if (high >= 55296 && high <= 56319 && low >= 56320 && low <= 57343) cut -= 1;
748
+ if (line.length - cut <= CLIP_MIN_OVERFLOW) return line;
735
749
  const carried = priorClip !== null && priorClip.index >= cut ? Number(priorClip[1]) - priorClip[0].length : 0;
736
750
  return `${line.slice(0, cut)} \u2026 [${line.length - cut + carried} chars elided]`;
737
751
  });
@@ -907,25 +921,34 @@ export {
907
921
  DEFAULT_MAX_LINES,
908
922
  DEFAULT_MAX_BYTES,
909
923
  MAX_INSPECT_BYTES,
924
+ DEFAULT_MAX_INPUT_BYTES,
925
+ FALLBACK_MAX_LINE_CHARS,
910
926
  LONG_LINE_MAX_CHARS,
911
927
  getMaxInputBytes,
912
928
  INPUT_MAX_LINE_CHARS,
913
929
  clipWideLines,
930
+ isWholeJsonDocument,
914
931
  clampKeepingEnds,
915
932
  compressionMarker,
916
933
  combineStreams,
917
934
  ERROR_SIGNAL_RE,
935
+ TABLE_ROW_ANOMALY_RE,
918
936
  TIMESTAMP_PREFIX_RE,
919
937
  REDIRECT_TOKEN_RE,
938
+ maskQuotedSpans,
920
939
  hasBareBackgroundOrNewline,
921
940
  hasBareBackground,
922
941
  isRedirectAmpersand,
923
942
  hasUnquotedOperator,
924
943
  splitOwnTrailingNotices,
925
944
  safeDecode,
945
+ sanitizeControlChars,
946
+ stripProgress,
926
947
  normalise,
927
948
  hasHighEntropyToken,
928
949
  dedupeConsecutive,
950
+ dedupeNumericRuns,
951
+ truncateMiddle,
929
952
  truncateMiddleSmart,
930
953
  capBytes,
931
954
  capTokens,
@@ -944,6 +967,8 @@ export {
944
967
  resolvePackageManagerScript,
945
968
  shlexSplit,
946
969
  capLongLines,
970
+ GREP_MAX_LINE_CHARS,
971
+ grepLiteralPattern,
947
972
  clipLongMatchLine,
948
973
  clipGrepLines,
949
974
  fallbackTruncate,
@@ -0,0 +1,242 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ configPath,
5
+ dataDir
6
+ } from "./token-goat-chunk-VES7EL7O.mjs";
7
+ import {
8
+ init_define_import_meta_env
9
+ } from "./token-goat-chunk-A37V4PBF.mjs";
10
+
11
+ // src/hook_ipc.ts
12
+ init_define_import_meta_env();
13
+ import * as crypto from "node:crypto";
14
+ import * as fs from "node:fs";
15
+ import * as os from "node:os";
16
+ import * as path from "node:path";
17
+ import { fileURLToPath } from "node:url";
18
+ var PROTOCOL_VERSION = 1;
19
+ var SERVER_SLOTS = 3;
20
+ var MAX_FRAME_BYTES = 64 * 1024 * 1024;
21
+ var KEY_BYTES = 32;
22
+ var HARNESS_PROTOCOL_VERSION = 2;
23
+ function challengeMacV2(key, nc, ns, harness, noop, noops) {
24
+ return mac(key, "S", nc, ns, harness, noop, ...noops.flat());
25
+ }
26
+ function requestMacV2(key, nc, ns, harness, body) {
27
+ return mac(key, "C", nc, ns, harness, body);
28
+ }
29
+ function outFrameMac(key, nc, ns, seq, data) {
30
+ return mac(key, "O", nc, ns, String(seq), data);
31
+ }
32
+ function doneFrameMac(key, nc, ns, stdout, exit, n) {
33
+ return mac(key, "D", nc, ns, stdout, String(exit), String(n));
34
+ }
35
+ function resolveBundleDir(dir) {
36
+ try {
37
+ return fs.realpathSync.native(dir);
38
+ } catch {
39
+ return dir;
40
+ }
41
+ }
42
+ function bundleDir() {
43
+ return resolveBundleDir(path.dirname(fileURLToPath(import.meta.url)));
44
+ }
45
+ function endpointId(dir, bundle) {
46
+ const fold = (p) => process.platform === "win32" ? p.toLowerCase() : p;
47
+ return crypto.createHash("sha256").update(`${fold(dir)}\0${fold(bundle)}`).digest("hex").slice(0, 16);
48
+ }
49
+ function endpointFor(slot, dir = dataDir(), bundle = bundleDir()) {
50
+ const id = `${endpointId(dir, bundle)}-${slot}`;
51
+ if (process.platform === "win32") return String.raw`\\.\pipe\token-goat-hooks-` + id;
52
+ const inData = path.join(dir, `hooks-${id}.sock`);
53
+ if (Buffer.byteLength(inData) < 100) return inData;
54
+ const own = privateTempDir();
55
+ return own === void 0 ? inData : path.join(own, `${id}.sock`);
56
+ }
57
+ function privateTempDir() {
58
+ const uid = process.getuid?.();
59
+ if (uid === void 0) return void 0;
60
+ const own = path.join(os.tmpdir(), `token-goat-${uid}`);
61
+ try {
62
+ fs.mkdirSync(own, { mode: 448 });
63
+ } catch {
64
+ }
65
+ try {
66
+ const st = fs.lstatSync(own);
67
+ return st.isDirectory() && st.uid === uid && (st.mode & 63) === 0 ? own : void 0;
68
+ } catch {
69
+ return void 0;
70
+ }
71
+ }
72
+ function serverKeyPath(dir = dataDir()) {
73
+ return path.join(dir, "hook-server.key");
74
+ }
75
+ function keyIsPrivate(st) {
76
+ if (process.platform === "win32") return true;
77
+ return (st.mode & 63) === 0 && (process.getuid === void 0 || st.uid === process.getuid());
78
+ }
79
+ function readServerKey(dir = dataDir()) {
80
+ try {
81
+ const p = serverKeyPath(dir);
82
+ if (!keyIsPrivate(fs.statSync(p))) return void 0;
83
+ const key = fs.readFileSync(p);
84
+ return key.length === KEY_BYTES ? key : void 0;
85
+ } catch {
86
+ return void 0;
87
+ }
88
+ }
89
+ function ensureServerKey(dir = dataDir()) {
90
+ const p = serverKeyPath(dir);
91
+ for (let attempt = 0; attempt < 50; attempt++) {
92
+ const existing = readServerKey(dir);
93
+ if (existing !== void 0) return existing;
94
+ const fresh = crypto.randomBytes(KEY_BYTES);
95
+ try {
96
+ fs.mkdirSync(dir, { recursive: true });
97
+ fs.writeFileSync(p, fresh, { flag: "wx", mode: 384 });
98
+ return fresh;
99
+ } catch (e) {
100
+ if (e.code !== "EEXIST") throw e;
101
+ try {
102
+ const st = fs.statSync(p);
103
+ if (!keyIsPrivate(st) || st.size !== 0 && st.size !== KEY_BYTES || Date.now() - st.mtimeMs > 1e3) fs.rmSync(p, { force: true });
104
+ } catch {
105
+ }
106
+ }
107
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 10);
108
+ }
109
+ throw new Error(`could not establish ${p}`);
110
+ }
111
+ function nonce() {
112
+ return crypto.randomBytes(16).toString("hex");
113
+ }
114
+ function mac(key, ...parts) {
115
+ const h = crypto.createHmac("sha256", key);
116
+ for (const part of parts) h.update(`${Buffer.byteLength(part)}:`).update(part);
117
+ return h.digest("hex");
118
+ }
119
+ function macMatches(expected, actual) {
120
+ if (typeof actual !== "string" || actual.length !== expected.length) return false;
121
+ const want = Buffer.from(expected);
122
+ const got = Buffer.from(actual);
123
+ return want.length === got.length && crypto.timingSafeEqual(want, got);
124
+ }
125
+ function writeFrame(socket, message) {
126
+ socket.write(encodeFrame(message));
127
+ }
128
+ function encodeFrame(message) {
129
+ const body = Buffer.from(JSON.stringify(message), "utf8");
130
+ const header = Buffer.alloc(4);
131
+ header.writeUInt32BE(body.length, 0);
132
+ return Buffer.concat([header, body]);
133
+ }
134
+ function frameFits(frame) {
135
+ return frame.length - 4 <= MAX_FRAME_BYTES;
136
+ }
137
+ function readFrames(socket, onFrame, onError) {
138
+ let buffered = Buffer.alloc(0);
139
+ socket.on("data", (chunk) => {
140
+ buffered = buffered.length === 0 ? chunk : Buffer.concat([buffered, chunk]);
141
+ while (buffered.length >= 4) {
142
+ const len = buffered.readUInt32BE(0);
143
+ if (len > MAX_FRAME_BYTES) {
144
+ onError(new Error(`frame of ${len} bytes exceeds ${MAX_FRAME_BYTES}`));
145
+ socket.destroy();
146
+ return;
147
+ }
148
+ if (buffered.length < 4 + len) return;
149
+ const body = buffered.subarray(4, 4 + len);
150
+ buffered = buffered.subarray(4 + len);
151
+ let message;
152
+ try {
153
+ message = JSON.parse(body.toString("utf8"));
154
+ } catch (e) {
155
+ onError(e);
156
+ socket.destroy();
157
+ return;
158
+ }
159
+ if (message === null || typeof message !== "object" || Array.isArray(message)) {
160
+ onError(new Error("frame is not a JSON object"));
161
+ socket.destroy();
162
+ return;
163
+ }
164
+ onFrame(message);
165
+ }
166
+ });
167
+ }
168
+ function envSnapshot() {
169
+ const env = {};
170
+ for (const [k, v] of Object.entries(process.env)) if (v !== void 0) env[k] = v;
171
+ return env;
172
+ }
173
+ function markerPath(name, dir = dataDir()) {
174
+ return path.join(dir, `hook-server.${name}`);
175
+ }
176
+ function markerAgeMs(name, dir = dataDir()) {
177
+ try {
178
+ return Date.now() - fs.statSync(markerPath(name, dir)).mtimeMs;
179
+ } catch {
180
+ return Infinity;
181
+ }
182
+ }
183
+ function touchMarker(name, content = String(process.pid), dir = dataDir()) {
184
+ try {
185
+ fs.mkdirSync(dir, { recursive: true });
186
+ fs.writeFileSync(markerPath(name, dir), content);
187
+ } catch {
188
+ }
189
+ }
190
+ function configStamp() {
191
+ try {
192
+ return String(fs.statSync(configPath()).mtimeMs);
193
+ } catch {
194
+ return "absent";
195
+ }
196
+ }
197
+ function readMarker(name, dir = dataDir()) {
198
+ try {
199
+ return fs.readFileSync(markerPath(name, dir), "utf8");
200
+ } catch {
201
+ return void 0;
202
+ }
203
+ }
204
+ function removeMarker(name, dir = dataDir()) {
205
+ fs.rmSync(markerPath(name, dir), { force: true });
206
+ }
207
+ function bundleEntryFiles() {
208
+ const dir = bundleDir();
209
+ return ["token-goat.core.mjs", "token-goat-hook.mjs", "token-goat-hook-client.mjs", "token-goat-hook-client.cjs"].map((f) => path.join(dir, f));
210
+ }
211
+ function launcherPath() {
212
+ return path.join(bundleDir(), "token-goat.mjs");
213
+ }
214
+
215
+ export {
216
+ PROTOCOL_VERSION,
217
+ SERVER_SLOTS,
218
+ HARNESS_PROTOCOL_VERSION,
219
+ challengeMacV2,
220
+ requestMacV2,
221
+ outFrameMac,
222
+ doneFrameMac,
223
+ endpointFor,
224
+ serverKeyPath,
225
+ readServerKey,
226
+ ensureServerKey,
227
+ nonce,
228
+ mac,
229
+ macMatches,
230
+ writeFrame,
231
+ encodeFrame,
232
+ frameFits,
233
+ readFrames,
234
+ envSnapshot,
235
+ markerAgeMs,
236
+ touchMarker,
237
+ configStamp,
238
+ readMarker,
239
+ removeMarker,
240
+ bundleEntryFiles,
241
+ launcherPath
242
+ };
@@ -0,0 +1,37 @@
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-FZ3NEW5O.mjs";
8
+ import "./token-goat-chunk-Q5VTGRH7.mjs";
9
+ import "./token-goat-chunk-Y776AENC.mjs";
10
+ import "./token-goat-chunk-SJHWVNDQ.mjs";
11
+ import "./token-goat-chunk-AFLYLHDH.mjs";
12
+ import "./token-goat-chunk-BPGCUMR7.mjs";
13
+ import "./token-goat-chunk-C63JQV5K.mjs";
14
+ import "./token-goat-chunk-JB6QN6VF.mjs";
15
+ import "./token-goat-chunk-EVMZJ27Z.mjs";
16
+ import "./token-goat-chunk-HYBFA5X3.mjs";
17
+ import "./token-goat-chunk-ARDNEC2U.mjs";
18
+ import "./token-goat-chunk-3Z5S4KGM.mjs";
19
+ import "./token-goat-chunk-VL3YIFHZ.mjs";
20
+ import "./token-goat-chunk-XB5KKOCG.mjs";
21
+ import "./token-goat-chunk-4FVIAHSI.mjs";
22
+ import "./token-goat-chunk-7IN2MKDS.mjs";
23
+ import "./token-goat-chunk-U4N3BN2W.mjs";
24
+ import "./token-goat-chunk-YZAAZU2S.mjs";
25
+ import "./token-goat-chunk-IVE6U7KV.mjs";
26
+ import "./token-goat-chunk-GOLEOXZP.mjs";
27
+ import "./token-goat-chunk-AM5V6GSX.mjs";
28
+ import "./token-goat-chunk-FNFBKLRD.mjs";
29
+ import "./token-goat-chunk-VES7EL7O.mjs";
30
+ import "./token-goat-chunk-KWPNJBDH.mjs";
31
+ import "./token-goat-chunk-HAVAOB3S.mjs";
32
+ import "./token-goat-chunk-A37V4PBF.mjs";
33
+ export {
34
+ MAX_RESUME_CHARS,
35
+ MAX_RESUME_TOKENS,
36
+ buildResumePacket
37
+ };
@@ -0,0 +1,13 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ init_define_import_meta_env
5
+ } from "./token-goat-chunk-A37V4PBF.mjs";
6
+
7
+ // src/delivering_deny.ts
8
+ init_define_import_meta_env();
9
+ var DELIVERS_CONTENT_RE = /is inlined below instead of the full body|headings below instead of the full body|in place of the full file/;
10
+
11
+ export {
12
+ DELIVERS_CONTENT_RE
13
+ };
@@ -4,14 +4,12 @@ import {
4
4
  parse
5
5
  } from "./token-goat-chunk-3BTK54F3.mjs";
6
6
  import {
7
+ compileGuardedRegexCached,
7
8
  filtersFilteredToEmptyNotice
8
- } from "./token-goat-chunk-L45ZQRT7.mjs";
9
+ } from "./token-goat-chunk-GOLEOXZP.mjs";
9
10
  import {
10
11
  displaySafeText
11
- } from "./token-goat-chunk-NMTKNYGF.mjs";
12
- import {
13
- compileGuardedRegexCached
14
- } from "./token-goat-chunk-GMOUBOX4.mjs";
12
+ } from "./token-goat-chunk-FNFBKLRD.mjs";
15
13
  import {
16
14
  init_define_import_meta_env
17
15
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -21,12 +19,11 @@ init_define_import_meta_env();
21
19
  var DELIMITER_CANDIDATES = [",", " ", ";", "|"];
22
20
  var DELIMITER_SAMPLE_ROWS = 5;
23
21
  function detectDelimiter(content) {
24
- const slice = content.slice(0, 1e4);
25
- if (slice.trim() === "") return ",";
22
+ if (content.trim() === "") return ",";
26
23
  for (const cand of DELIMITER_CANDIDATES) {
27
24
  let rows;
28
25
  try {
29
- rows = parse(slice, { columns: false, skip_empty_lines: true, trim: true, delimiter: cand, bom: true, relax_quotes: true, to: DELIMITER_SAMPLE_ROWS });
26
+ rows = parse(content, { columns: false, skip_empty_lines: true, trim: true, delimiter: cand, bom: true, relax_quotes: true, to: DELIMITER_SAMPLE_ROWS });
30
27
  } catch {
31
28
  continue;
32
29
  }
@@ -39,7 +36,9 @@ function parseRecords(content, opts) {
39
36
  const delimiter = opts.delimiter ?? detectDelimiter(content);
40
37
  if (opts.noHeader === true) {
41
38
  const rows = parse(content, { columns: false, skip_empty_lines: true, trim: true, delimiter, bom: true, relax_column_count: true, relax_quotes: true });
42
- return rows.map((row) => Object.fromEntries(row.map((cell, i) => [`col${i + 1}`, cell])));
39
+ const width = rows.reduce((max, row) => Math.max(max, row.length), 0);
40
+ const columns = Array.from({ length: width }, (_, i) => `col${i + 1}`);
41
+ return { records: rows.map((row) => Object.fromEntries(columns.map((name, i) => [name, row[i] ?? ""]))), columns };
43
42
  }
44
43
  const header = csvHeader(content, { ...opts, delimiter });
45
44
  const dupes = header.filter((name, i) => name !== "" && header.indexOf(name) !== i);
@@ -49,14 +48,25 @@ function parseRecords(content, opts) {
49
48
  `duplicate column ${unique.length === 1 ? "name" : "names"} in header: ${unique.join(", ")} \u2014 rename the duplicates or pass --no-header to address columns positionally as col1, col2, \u2026`
50
49
  );
51
50
  }
52
- return parse(content, { columns: true, skip_empty_lines: true, trim: true, delimiter, bom: true, relax_column_count: true, relax_quotes: true });
51
+ const records = parse(content, { columns: () => header, skip_empty_lines: true, trim: true, delimiter, bom: true, relax_column_count: true, relax_quotes: true });
52
+ return { records, columns: header };
53
+ }
54
+ function nameBlankHeaders(raw) {
55
+ const taken = new Set(raw.filter((name) => name !== ""));
56
+ return raw.map((name, i) => {
57
+ if (name !== "") return name;
58
+ let synth = `col${i + 1}`;
59
+ while (taken.has(synth)) synth += "_";
60
+ taken.add(synth);
61
+ return synth;
62
+ });
53
63
  }
54
64
  function csvHeader(content, opts) {
55
65
  if (opts.noHeader === true) return [];
56
66
  const delimiter = opts.delimiter ?? detectDelimiter(content);
57
67
  try {
58
68
  const rows = parse(content, { columns: false, skip_empty_lines: true, trim: true, delimiter, bom: true, to: 1, relax_quotes: true });
59
- return rows[0] ?? [];
69
+ return nameBlankHeaders(rows[0] ?? []);
60
70
  } catch {
61
71
  return [];
62
72
  }
@@ -128,8 +138,8 @@ function matchesWhere(row, where) {
128
138
  }
129
139
  }
130
140
  function queryCsv(content, opts) {
131
- const records = parseRecords(content, opts);
132
- const allColumns = records.length > 0 ? Object.keys(records[0]) : [];
141
+ const { records, columns: allHeader } = parseRecords(content, opts);
142
+ const allColumns = records.length > 0 ? allHeader : [];
133
143
  const realHeader = records.length > 0 ? allColumns : csvHeader(content, opts);
134
144
  const columns = opts.columns && opts.columns.length > 0 ? opts.columns : allColumns;
135
145
  for (const c of columns) {
@@ -172,8 +182,8 @@ function formatCsvTable(result, activeFilters = []) {
172
182
  return lines.join("\n");
173
183
  }
174
184
  function profileCsv(content, opts = {}) {
175
- const records = parseRecords(content, opts);
176
- const columns = records.length > 0 ? Object.keys(records[0]) : [];
185
+ const { records, columns: allHeader } = parseRecords(content, opts);
186
+ const columns = records.length > 0 ? allHeader : [];
177
187
  return columns.map((col) => {
178
188
  const values = records.map((r) => r[col] ?? "");
179
189
  const nullCount = values.filter((v) => v.trim() === "").length;