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
@@ -11,9 +11,9 @@ import {
11
11
  openReadonlySqlite,
12
12
  runReadOnlySqliteQuery,
13
13
  validateReadOnlySelect
14
- } from "./token-goat-chunk-DA43OE7L.mjs";
15
- import "./token-goat-chunk-OSUFN2FV.mjs";
16
- import "./token-goat-chunk-NMTKNYGF.mjs";
14
+ } from "./token-goat-chunk-ZCDTCVIS.mjs";
15
+ import "./token-goat-chunk-XB5KKOCG.mjs";
16
+ import "./token-goat-chunk-FNFBKLRD.mjs";
17
17
  import "./token-goat-chunk-A37V4PBF.mjs";
18
18
  export {
19
19
  SQLITE_QUERY_ROW_CAP,
@@ -0,0 +1,92 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ registerReset
5
+ } from "./token-goat-chunk-YZAAZU2S.mjs";
6
+ import {
7
+ ENV_KEYS
8
+ } from "./token-goat-chunk-VES7EL7O.mjs";
9
+ import {
10
+ init_define_import_meta_env
11
+ } from "./token-goat-chunk-A37V4PBF.mjs";
12
+
13
+ // src/bridges/registry.ts
14
+ init_define_import_meta_env();
15
+ var KNOWN_HARNESS_NAMES = /* @__PURE__ */ new Set([
16
+ "claudecode",
17
+ "codex",
18
+ "opencode",
19
+ "gemini",
20
+ "hermes",
21
+ "openclaw",
22
+ "pi",
23
+ "copilot_cli",
24
+ "grok",
25
+ "qwen",
26
+ "kimi",
27
+ "vscode",
28
+ "antigravity",
29
+ "visualstudio",
30
+ "generic"
31
+ ]);
32
+ var relaySeededSessionIdValue;
33
+ function setRelaySeededSessionId(id) {
34
+ relaySeededSessionIdValue = id;
35
+ }
36
+ function relaySeededSessionId() {
37
+ return relaySeededSessionIdValue;
38
+ }
39
+ function detectHarness() {
40
+ const env = process.env;
41
+ const override = (env[ENV_KEYS.HARNESS_OVERRIDE] ?? "").toLowerCase().trim();
42
+ if (override && KNOWN_HARNESS_NAMES.has(override)) {
43
+ return override;
44
+ }
45
+ if (env["HERMES_SESSION_ID"] || env["HERMES_HOME"]) {
46
+ return "hermes";
47
+ }
48
+ if (env["TERM_PROGRAM"] === "claude-code" || env["CLAUDE_CODE_VERSION"] !== void 0 || env["CLAUDE_CODE_SESSION_ID"] && env["CLAUDE_CODE_SESSION_ID"] !== relaySeededSessionIdValue) {
49
+ return "claudecode";
50
+ }
51
+ if (env["CODEX_SESSION_ID"] !== void 0 || env["CODEX_SESSION"]) {
52
+ return "codex";
53
+ }
54
+ if (env["OPENCODE_SESSION_ID"] !== void 0 || env["OPENCODE_SESSION"]) {
55
+ return "opencode";
56
+ }
57
+ if (env["GROK_SESSION_ID"] !== void 0) {
58
+ return "grok";
59
+ }
60
+ if (env["OPENCLAW_SESSION_ID"] !== void 0) {
61
+ return "openclaw";
62
+ }
63
+ if (env["ANTHROPIC_API_KEY"]) {
64
+ return "claudecode";
65
+ }
66
+ if (env["OPENAI_API_KEY"] && !env["ANTHROPIC_API_KEY"]) {
67
+ return "codex";
68
+ }
69
+ if ((env["GEMINI_API_KEY"] || env["GOOGLE_API_KEY"]) && !env["ANTHROPIC_API_KEY"]) {
70
+ return "gemini";
71
+ }
72
+ return "generic";
73
+ }
74
+ var _cached = null;
75
+ function getHarnessName() {
76
+ if (_cached === null) {
77
+ _cached = detectHarness();
78
+ }
79
+ return _cached;
80
+ }
81
+ function resetHarnessCache() {
82
+ _cached = null;
83
+ }
84
+ registerReset(resetHarnessCache, { perRequest: true });
85
+
86
+ export {
87
+ KNOWN_HARNESS_NAMES,
88
+ setRelaySeededSessionId,
89
+ relaySeededSessionId,
90
+ detectHarness,
91
+ getHarnessName
92
+ };
@@ -0,0 +1,122 @@
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/image_isobmff.ts
8
+ init_define_import_meta_env();
9
+ var AVIF_BRANDS = /* @__PURE__ */ new Set(["avif", "avis"]);
10
+ var HEIC_BRANDS = /* @__PURE__ */ new Set(["heic", "heix", "hevc", "heim", "heis", "hevm", "hevs"]);
11
+ var HEIF_GENERIC_BRANDS = /* @__PURE__ */ new Set(["mif1", "msf1"]);
12
+ var FULLBOX_PREFIX = 4;
13
+ function readBoxes(buf, start, end) {
14
+ const boxes = [];
15
+ const limit = Math.min(end, buf.length);
16
+ let pos = start;
17
+ while (pos + 8 <= limit) {
18
+ let size = buf.readUInt32BE(pos);
19
+ const type = buf.toString("latin1", pos + 4, pos + 8);
20
+ let header = 8;
21
+ if (size === 1) {
22
+ if (pos + 16 > limit) break;
23
+ const large = buf.readBigUInt64BE(pos + 8);
24
+ if (large > BigInt(limit - pos)) break;
25
+ size = Number(large);
26
+ header = 16;
27
+ } else if (size === 0) {
28
+ size = limit - pos;
29
+ }
30
+ if (size < header || pos + size > limit) break;
31
+ boxes.push({ type, body: pos + header, end: pos + size });
32
+ pos += size;
33
+ }
34
+ return boxes;
35
+ }
36
+ function findBox(boxes, type) {
37
+ return boxes.find((b) => b.type === type);
38
+ }
39
+ function classifyBrands(buf, ftyp) {
40
+ if (ftyp.end - ftyp.body < 8) return null;
41
+ const brands = [buf.toString("latin1", ftyp.body, ftyp.body + 4)];
42
+ for (let p = ftyp.body + 8; p + 4 <= ftyp.end; p += 4) brands.push(buf.toString("latin1", p, p + 4));
43
+ if (brands.some((b) => AVIF_BRANDS.has(b))) return "avif";
44
+ if (brands.some((b) => HEIC_BRANDS.has(b))) return "heic";
45
+ if (brands.some((b) => HEIF_GENERIC_BRANDS.has(b))) return "heif";
46
+ return null;
47
+ }
48
+ function primaryItemId(buf, children) {
49
+ const pitm = findBox(children, "pitm");
50
+ if (pitm === void 0 || pitm.end - pitm.body < FULLBOX_PREFIX + 2) return null;
51
+ const version = buf[pitm.body];
52
+ if (version === 0) return buf.readUInt16BE(pitm.body + FULLBOX_PREFIX);
53
+ if (pitm.end - pitm.body < FULLBOX_PREFIX + 4) return null;
54
+ return buf.readUInt32BE(pitm.body + FULLBOX_PREFIX);
55
+ }
56
+ function itemProperties(buf, ipma, itemId) {
57
+ if (ipma.end - ipma.body < FULLBOX_PREFIX + 4) return null;
58
+ const version = buf[ipma.body];
59
+ const wide = (buf.readUIntBE(ipma.body + 1, 3) & 1) === 1;
60
+ const entryCount = buf.readUInt32BE(ipma.body + FULLBOX_PREFIX);
61
+ let pos = ipma.body + FULLBOX_PREFIX + 4;
62
+ const idBytes = version < 1 ? 2 : 4;
63
+ const assocBytes = wide ? 2 : 1;
64
+ for (let e = 0; e < entryCount; e++) {
65
+ if (pos + idBytes + 1 > ipma.end) return null;
66
+ const id = idBytes === 2 ? buf.readUInt16BE(pos) : buf.readUInt32BE(pos);
67
+ const count = buf[pos + idBytes];
68
+ pos += idBytes + 1;
69
+ if (pos + count * assocBytes > ipma.end) return null;
70
+ if (id === itemId) {
71
+ const out = [];
72
+ for (let a = 0; a < count; a++) {
73
+ const at = pos + a * assocBytes;
74
+ out.push(wide ? buf.readUInt16BE(at) & 32767 : buf[at] & 127);
75
+ }
76
+ return out;
77
+ }
78
+ pos += count * assocBytes;
79
+ }
80
+ return null;
81
+ }
82
+ function probeIsoBmffMeta(buf) {
83
+ if (buf.length < 16 || buf.toString("latin1", 4, 8) !== "ftyp") return null;
84
+ const top = readBoxes(buf, 0, buf.length);
85
+ const ftyp = top[0];
86
+ if (ftyp === void 0 || ftyp.type !== "ftyp") return null;
87
+ const format = classifyBrands(buf, ftyp);
88
+ if (format === null) return null;
89
+ const meta = findBox(top, "meta");
90
+ if (meta === void 0 || meta.end - meta.body < FULLBOX_PREFIX) return null;
91
+ const metaChildren = readBoxes(buf, meta.body + FULLBOX_PREFIX, meta.end);
92
+ const iprp = findBox(metaChildren, "iprp");
93
+ if (iprp === void 0) return null;
94
+ const iprpChildren = readBoxes(buf, iprp.body, iprp.end);
95
+ const ipco = findBox(iprpChildren, "ipco");
96
+ if (ipco === void 0) return null;
97
+ const props = readBoxes(buf, ipco.body, ipco.end);
98
+ const ipma = findBox(iprpChildren, "ipma");
99
+ const itemId = primaryItemId(buf, metaChildren);
100
+ const wanted = ipma !== void 0 && itemId !== null ? itemProperties(buf, ipma, itemId) : null;
101
+ const candidates = wanted === null ? props : wanted.map((index) => props[index - 1]).filter((b) => b !== void 0);
102
+ let width = 0;
103
+ let height = 0;
104
+ let rotated = false;
105
+ for (const prop of candidates) {
106
+ if (prop.type === "ispe" && prop.end - prop.body >= FULLBOX_PREFIX + 8) {
107
+ const w = buf.readUInt32BE(prop.body + FULLBOX_PREFIX);
108
+ const h = buf.readUInt32BE(prop.body + FULLBOX_PREFIX + 4);
109
+ if (wanted !== null || w * h > width * height) {
110
+ width = w;
111
+ height = h;
112
+ }
113
+ } else if (prop.type === "irot" && prop.end - prop.body >= 1 && wanted !== null) {
114
+ rotated = (buf[prop.body] & 3) % 2 === 1;
115
+ }
116
+ }
117
+ if (width <= 0 || height <= 0) return null;
118
+ return rotated ? { width: height, height: width, format } : { width, height, format };
119
+ }
120
+ export {
121
+ probeIsoBmffMeta
122
+ };
@@ -11,10 +11,10 @@ import {
11
11
  ooxmlPartBudget,
12
12
  parseOoxmlPart,
13
13
  readOoxmlZip
14
- } from "./token-goat-chunk-UBUKHVYW.mjs";
14
+ } from "./token-goat-chunk-IVKIZWAB.mjs";
15
15
  import {
16
16
  displaySafeText
17
- } from "./token-goat-chunk-NMTKNYGF.mjs";
17
+ } from "./token-goat-chunk-FNFBKLRD.mjs";
18
18
  import {
19
19
  init_define_import_meta_env
20
20
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -24,6 +24,11 @@ init_define_import_meta_env();
24
24
  function paragraphStyleVal(p) {
25
25
  return p["w:pPr"]?.["w:pStyle"]?.["@_w:val"];
26
26
  }
27
+ function gridSpanOf(tc) {
28
+ const raw = tc["w:tcPr"]?.["w:gridSpan"]?.["@_w:val"];
29
+ const n = raw === void 0 ? 1 : parseInt(String(raw), 10);
30
+ return Number.isFinite(n) && n > 1 ? Math.min(n, 64) : 1;
31
+ }
27
32
  function headingLevel(styleVal) {
28
33
  if (styleVal === void 0) return null;
29
34
  if (/^title$/i.test(styleVal)) return 1;
@@ -53,10 +58,14 @@ async function docxOutline(filePath) {
53
58
  }
54
59
  return out;
55
60
  }
56
- async function docxText(filePath) {
61
+ async function docxText(filePath, opts = {}) {
57
62
  const parsed = await loadDocumentBody(filePath);
58
63
  const paragraphs = collectElements(parsed, "w:p");
59
- const lines = paragraphs.map((p) => collectTextRuns(p, "w:t").join("")).filter((t) => t.trim().length > 0);
64
+ const lines = paragraphs.map((p) => {
65
+ const text = collectTextRuns(p, "w:t").join("");
66
+ const level = opts.markdownHeadings === true ? headingLevel(paragraphStyleVal(p)) : null;
67
+ return level !== null && text.trim().length > 0 ? `${"#".repeat(level)} ${text.trim()}` : text;
68
+ }).filter((t) => t.trim().length > 0);
60
69
  return lines.join("\n\n");
61
70
  }
62
71
  async function docxTables(filePath) {
@@ -72,8 +81,10 @@ async function docxTables(filePath) {
72
81
  const tcElements = collectElements(tr, "w:tc");
73
82
  const rowCells = [];
74
83
  for (const tc of tcElements) {
84
+ const span = gridSpanOf(tc);
75
85
  const cellText = collectParagraphTexts(tc, "w:p", "w:t", ["w:tbl"]).map((t) => t.replace(/\r?\n/g, " ").trim()).filter((t) => t.length > 0).join(" ");
76
86
  rowCells.push(cellText);
87
+ for (let k = 1; k < span; k++) rowCells.push("");
77
88
  }
78
89
  if (rowCells.length > maxCols) maxCols = rowCells.length;
79
90
  rows.push(rowCells);
@@ -0,0 +1,53 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ anchorStatus
5
+ } from "./token-goat-chunk-Z57YODA2.mjs";
6
+ import "./token-goat-chunk-PU7V3FD6.mjs";
7
+ import "./token-goat-chunk-XKI4SEMX.mjs";
8
+ import "./token-goat-chunk-4JJS54TR.mjs";
9
+ import "./token-goat-chunk-RC35RBUL.mjs";
10
+ import "./token-goat-chunk-YARZFCZS.mjs";
11
+ import "./token-goat-chunk-FBNQNSJK.mjs";
12
+ import "./token-goat-chunk-MNWKPRAL.mjs";
13
+ import "./token-goat-chunk-67TQJ76B.mjs";
14
+ import "./token-goat-chunk-H2PHHGM5.mjs";
15
+ import "./token-goat-chunk-P4QMM4WK.mjs";
16
+ import "./token-goat-chunk-5KDMCMF2.mjs";
17
+ import "./token-goat-chunk-ATCPY7EQ.mjs";
18
+ import "./token-goat-chunk-VPBBTSJR.mjs";
19
+ import "./token-goat-chunk-Y776AENC.mjs";
20
+ import "./token-goat-chunk-SJHWVNDQ.mjs";
21
+ import "./token-goat-chunk-AFLYLHDH.mjs";
22
+ import "./token-goat-chunk-BPGCUMR7.mjs";
23
+ import "./token-goat-chunk-C63JQV5K.mjs";
24
+ import "./token-goat-chunk-JB6QN6VF.mjs";
25
+ import "./token-goat-chunk-RHXKCZX3.mjs";
26
+ import "./token-goat-chunk-EVMZJ27Z.mjs";
27
+ import "./token-goat-chunk-HYBFA5X3.mjs";
28
+ import "./token-goat-chunk-5Y6ZYL6U.mjs";
29
+ import "./token-goat-chunk-ARDNEC2U.mjs";
30
+ import "./token-goat-chunk-3Z5S4KGM.mjs";
31
+ import "./token-goat-chunk-VL3YIFHZ.mjs";
32
+ import "./token-goat-chunk-XB5KKOCG.mjs";
33
+ import "./token-goat-chunk-QSBRTGM2.mjs";
34
+ import "./token-goat-chunk-N2NMER56.mjs";
35
+ import "./token-goat-chunk-3BTK54F3.mjs";
36
+ import "./token-goat-chunk-4FVIAHSI.mjs";
37
+ import "./token-goat-chunk-7IN2MKDS.mjs";
38
+ import "./token-goat-chunk-U4N3BN2W.mjs";
39
+ import "./token-goat-chunk-YZAAZU2S.mjs";
40
+ import "./token-goat-chunk-IVE6U7KV.mjs";
41
+ import "./token-goat-chunk-XTQAOTSO.mjs";
42
+ import "./token-goat-chunk-AH6QILZM.mjs";
43
+ import "./token-goat-chunk-Y4AFKTHK.mjs";
44
+ import "./token-goat-chunk-GOLEOXZP.mjs";
45
+ import "./token-goat-chunk-AM5V6GSX.mjs";
46
+ import "./token-goat-chunk-FNFBKLRD.mjs";
47
+ import "./token-goat-chunk-VES7EL7O.mjs";
48
+ import "./token-goat-chunk-KWPNJBDH.mjs";
49
+ import "./token-goat-chunk-HAVAOB3S.mjs";
50
+ import "./token-goat-chunk-A37V4PBF.mjs";
51
+ export {
52
+ anchorStatus
53
+ };
@@ -0,0 +1,205 @@
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/version.ts
8
+ init_define_import_meta_env();
9
+ import { createRequire } from "node:module";
10
+ function readManifest() {
11
+ if (true) return JSON.parse('{"version":"2.9.30","name":"token-goat","bugs":{"url":"https://github.com/DFKHelper/token-goat/issues"}}');
12
+ try {
13
+ return createRequire(import.meta.url)("../package.json");
14
+ } catch {
15
+ return {};
16
+ }
17
+ }
18
+ var manifest = readManifest();
19
+ var VERSION = manifest.version ?? "0.0.0";
20
+ var PACKAGE_NAME = manifest.name !== void 0 && manifest.name !== "" ? manifest.name : "token-goat";
21
+ var ISSUES_URL = manifest.bugs?.url !== void 0 && manifest.bugs.url !== "" ? manifest.bugs.url : "https://github.com/DFKHelper/token-goat/issues";
22
+ var SUPPORT_EMAIL = "token-goat@dfkhelper.com";
23
+ function supportRequestLine(what) {
24
+ return `To ask for ${what} support, open an issue at ${ISSUES_URL} or email ${SUPPORT_EMAIL}.`;
25
+ }
26
+
27
+ // src/constants.ts
28
+ init_define_import_meta_env();
29
+ import * as fs from "node:fs";
30
+ import * as os from "node:os";
31
+ import * as path from "node:path";
32
+ function safeEnvDir(value) {
33
+ const stripped = value.trim();
34
+ if (stripped === "") return void 0;
35
+ if (!path.isAbsolute(stripped)) return void 0;
36
+ if (process.platform === "win32") {
37
+ const root = path.parse(stripped).root;
38
+ if (root === "" || root === "\\" || root === "/") return void 0;
39
+ }
40
+ return stripped;
41
+ }
42
+ function dataDirForHome(homeDir) {
43
+ const platform = process.platform;
44
+ if (platform === "win32") {
45
+ return path.join(homeDir, "AppData", "Local", "dfk-helper", "token-goat");
46
+ }
47
+ if (platform === "darwin") {
48
+ return path.join(homeDir, "Library", "Application Support", "token-goat");
49
+ }
50
+ return path.join(homeDir, ".local", "share", "token-goat");
51
+ }
52
+ function homeFallbackOrGuard() {
53
+ const inVitest = process.env["VITEST_WORKER_ID"] !== void 0 || process.env["VITEST"] === "true";
54
+ if (inVitest && process.env["VITEST_ALLOW_REAL_DATA_DIR"] !== "1") {
55
+ throw new Error(
56
+ "token-goat: refusing to resolve DATA_DIR against the real home directory inside a Vitest worker (LOCALAPPDATA/XDG_DATA_HOME is unset). This would read or write the developer's real global.db/config.toml. Set LOCALAPPDATA/XDG_DATA_HOME explicitly for this process, or VITEST_ALLOW_REAL_DATA_DIR=1 if this is an intentional mocked-home test."
57
+ );
58
+ }
59
+ return dataDirForHome(os.homedir());
60
+ }
61
+ function defaultDataDir() {
62
+ const platform = process.platform;
63
+ if (platform === "win32") {
64
+ const raw = process.env["LOCALAPPDATA"] ?? "";
65
+ const base2 = raw ? safeEnvDir(raw) : void 0;
66
+ if (base2 !== void 0) {
67
+ return path.join(base2, "dfk-helper", "token-goat");
68
+ }
69
+ return homeFallbackOrGuard();
70
+ }
71
+ if (platform === "darwin") {
72
+ const raw = process.env["XDG_DATA_HOME"] ?? "";
73
+ const base2 = raw ? safeEnvDir(raw) : void 0;
74
+ if (base2 !== void 0) {
75
+ return path.join(base2, "token-goat");
76
+ }
77
+ return homeFallbackOrGuard();
78
+ }
79
+ const xdg = process.env["XDG_DATA_HOME"] ?? "";
80
+ const base = xdg ? safeEnvDir(xdg) : void 0;
81
+ if (base !== void 0) {
82
+ return path.join(base, "token-goat");
83
+ }
84
+ return homeFallbackOrGuard();
85
+ }
86
+ var DATA_DIR = defaultDataDir();
87
+ function dataDir() {
88
+ return DATA_DIR;
89
+ }
90
+ var dataDirHardened = false;
91
+ function ensureDataDirPrivate() {
92
+ if (dataDirHardened) return;
93
+ try {
94
+ fs.mkdirSync(path.dirname(DATA_DIR), { recursive: true });
95
+ fs.mkdirSync(DATA_DIR, { recursive: true, mode: 448 });
96
+ if (process.platform !== "win32") {
97
+ const current = fs.statSync(DATA_DIR).mode & 511;
98
+ if ((current & 63) !== 0) fs.chmodSync(DATA_DIR, current & 448);
99
+ }
100
+ dataDirHardened = true;
101
+ } catch {
102
+ }
103
+ }
104
+ function tokenGoatHome() {
105
+ const override = safeEnvDir(process.env["TOKEN_GOAT_HOME"] ?? "");
106
+ if (override !== void 0) return override;
107
+ return path.join(os.homedir(), ".token-goat");
108
+ }
109
+ var hardenedHomes = /* @__PURE__ */ new Set();
110
+ function ensureHomeDirPrivate() {
111
+ const home = tokenGoatHome();
112
+ if (hardenedHomes.has(home)) return;
113
+ try {
114
+ fs.mkdirSync(path.dirname(home), { recursive: true });
115
+ fs.mkdirSync(home, { recursive: true, mode: 448 });
116
+ if (process.platform !== "win32") {
117
+ const current = fs.statSync(home).mode & 511;
118
+ if ((current & 63) !== 0) fs.chmodSync(home, current & 448);
119
+ }
120
+ hardenedHomes.add(home);
121
+ } catch {
122
+ }
123
+ }
124
+ function isUnderRoot(child, parent) {
125
+ const rel = path.relative(parent, child);
126
+ return rel === "" || !rel.startsWith("..") && !path.isAbsolute(rel);
127
+ }
128
+ function isTokenGoatStorage(p) {
129
+ return isUnderRoot(p, DATA_DIR) || isUnderRoot(p, tokenGoatHome());
130
+ }
131
+ function ensureStorageRootPrivate(dir) {
132
+ if (isUnderRoot(dir, DATA_DIR)) ensureDataDirPrivate();
133
+ if (isUnderRoot(dir, tokenGoatHome())) ensureHomeDirPrivate();
134
+ }
135
+ function _resetDataDirCacheForTesting() {
136
+ DATA_DIR = defaultDataDir();
137
+ dataDirHardened = false;
138
+ hardenedHomes.clear();
139
+ }
140
+ function globalDbPath() {
141
+ return path.join(DATA_DIR, "global.db");
142
+ }
143
+ function configPath() {
144
+ return path.join(DATA_DIR, "config.toml");
145
+ }
146
+ var PROJECT_CONFIG_FILENAME = ".token-goat.toml";
147
+ function projectConfigPath(projectRoot) {
148
+ return path.join(projectRoot, PROJECT_CONFIG_FILENAME);
149
+ }
150
+ var ENV_KEYS = {
151
+ COMPACT_ASSIST: "TOKEN_GOAT_COMPACT_ASSIST",
152
+ COMPACT_ASSIST_LEGACY: "TOKENWISE_COMPACT_ASSIST",
153
+ BASH_COMPRESS: "TOKEN_GOAT_BASH_COMPRESS",
154
+ SESSION_BRIEF: "TOKEN_GOAT_SESSION_BRIEF",
155
+ SKILL_PRESERVATION: "TOKEN_GOAT_SKILL_PRESERVATION",
156
+ ORPHAN_SWEEP: "TOKEN_GOAT_ORPHAN_SWEEP",
157
+ HINT_BUDGET: "TOKEN_GOAT_HINT_BUDGET",
158
+ HINT_JSON_SIDECAR: "TOKEN_GOAT_HINT_JSON_SIDECAR",
159
+ BASH_DEDUP_MIN_BYTES: "TOKEN_GOAT_BASH_DEDUP_MIN_BYTES",
160
+ WEB_DEDUP_MIN_BYTES: "TOKEN_GOAT_WEB_DEDUP_MIN_BYTES",
161
+ GREP_DEDUP_MIN_MATCHES: "TOKEN_GOAT_GREP_DEDUP_MIN_MATCHES",
162
+ GLOB_DEDUP_MIN_MATCHES: "TOKEN_GOAT_GLOB_DEDUP_MIN_MATCHES",
163
+ LARGE_READ_BYTES: "TOKEN_GOAT_LARGE_READ_BYTES",
164
+ REPOMAP_COMPACT_THRESHOLD: "TOKEN_GOAT_REPOMAP_COMPACT_THRESHOLD",
165
+ WEB_CACHE_MAX_FILES: "TOKEN_GOAT_WEB_CACHE_MAX_FILES",
166
+ WEB_CACHE_MAX_BYTES: "TOKEN_GOAT_WEB_CACHE_MAX_BYTES",
167
+ WEB_COMPRESS: "TOKEN_GOAT_WEB_COMPRESS",
168
+ BASH_CACHE_MIN_BYTES: "TOKEN_GOAT_BASH_CACHE_MIN_BYTES",
169
+ BASH_CACHE_MAX_FILES: "TOKEN_GOAT_BASH_CACHE_MAX_FILES",
170
+ BASH_CACHE_MAX_BYTES: "TOKEN_GOAT_BASH_CACHE_MAX_BYTES",
171
+ BASH_CACHE_MAX_BYTES_PER_OUTPUT: "TOKEN_GOAT_BASH_CACHE_MAX_BYTES_PER_OUTPUT",
172
+ WORKER_WATCHDOG: "TOKEN_GOAT_WORKER_WATCHDOG",
173
+ WORKER_MAX_POOL: "TOKEN_GOAT_WORKER_MAX_POOL",
174
+ COMPRESS_PROFILE: "TOKEN_GOAT_COMPRESS_PROFILE",
175
+ SKILL_COMPRESS: "TOKEN_GOAT_SKILL_COMPRESS",
176
+ SERVE_DIFF_ON_REREAD: "TOKEN_GOAT_SERVE_DIFF_ON_REREAD",
177
+ ELIDE_SERVED_LINES: "TOKEN_GOAT_ELIDE_SERVED_LINES",
178
+ OVERFLOW_GUARD: "TOKEN_GOAT_OVERFLOW_GUARD",
179
+ OVERFLOW_MAX_TOKENS: "TOKEN_GOAT_OVERFLOW_MAX_TOKENS",
180
+ HARNESS_OVERRIDE: "TOKEN_GOAT_HARNESS_OVERRIDE",
181
+ RECONCILE: "TOKEN_GOAT_RECONCILE",
182
+ RECONCILE_BUDGET_MS: "TOKEN_GOAT_RECONCILE_BUDGET_MS",
183
+ MCP_TOOLS: "TOKEN_GOAT_MCP_TOOLS"
184
+ };
185
+ var SYMBOL_BODY_CHAR_CAP = 128 * 1024;
186
+ var SKELETON_SYMBOL_CAP = 5e3;
187
+
188
+ export {
189
+ VERSION,
190
+ PACKAGE_NAME,
191
+ supportRequestLine,
192
+ dataDirForHome,
193
+ dataDir,
194
+ ensureDataDirPrivate,
195
+ tokenGoatHome,
196
+ isTokenGoatStorage,
197
+ ensureStorageRootPrivate,
198
+ _resetDataDirCacheForTesting,
199
+ globalDbPath,
200
+ configPath,
201
+ projectConfigPath,
202
+ ENV_KEYS,
203
+ SYMBOL_BODY_CHAR_CAP,
204
+ SKELETON_SYMBOL_CAP
205
+ };