token-goat 2.9.29 → 2.9.31

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 (197) hide show
  1. package/README.md +53 -42
  2. package/SECURITY.md +37 -11
  3. package/THIRD_PARTY_NOTICES.md +41 -4
  4. package/dist/native/linux-arm64/tg-hook +0 -0
  5. package/dist/native/linux-x64/tg-hook +0 -0
  6. package/dist/native/win32-arm64/tg-hook.exe +0 -0
  7. package/dist/native/win32-x64/tg-hook.exe +0 -0
  8. package/dist/ort-wasm-simd-threaded.mjs +59 -0
  9. package/dist/{token-goat-chunk-SE6E4BKJ.mjs → token-goat-chunk-25TRAWET.mjs} +23 -6
  10. package/dist/token-goat-chunk-2KXO6V2B.mjs +203 -0
  11. package/dist/{token-goat-chunk-UXSXQQIY.mjs → token-goat-chunk-2M7E4PF7.mjs} +43 -14
  12. package/dist/token-goat-chunk-2UPZGKKY.mjs +188 -0
  13. package/dist/token-goat-chunk-2WLPWKHV.mjs +135 -0
  14. package/dist/token-goat-chunk-2XBMMDBD.mjs +126 -0
  15. package/dist/token-goat-chunk-32ZOY4N5.mjs +23 -0
  16. package/dist/token-goat-chunk-3EZRNKTK.mjs +188 -0
  17. package/dist/token-goat-chunk-4ADZHI7J.mjs +63 -0
  18. package/dist/token-goat-chunk-4GBVPH3D.mjs +242 -0
  19. package/dist/{token-goat-chunk-2WOUYWLM.mjs → token-goat-chunk-4GILLLWY.mjs} +34 -7
  20. package/dist/token-goat-chunk-4NAPX7BA.mjs +90 -0
  21. package/dist/{token-goat-chunk-NMBWLRHW.mjs → token-goat-chunk-4SC7UJYV.mjs} +9981 -11563
  22. package/dist/token-goat-chunk-4SMRO4TO.mjs +366 -0
  23. package/dist/{token-goat-chunk-O6I2XU4P.mjs → token-goat-chunk-4ZBFWLXF.mjs} +310 -441
  24. package/dist/token-goat-chunk-57BIAXJL.mjs +286 -0
  25. package/dist/token-goat-chunk-5AC66HNP.mjs +115 -0
  26. package/dist/token-goat-chunk-5IMLKSOP.mjs +145 -0
  27. package/dist/token-goat-chunk-5RG5SBL6.mjs +221 -0
  28. package/dist/{token-goat-chunk-RRNZMM3A.mjs → token-goat-chunk-5Y6ZYL6U.mjs} +21 -2
  29. package/dist/token-goat-chunk-646E6U44.mjs +398 -0
  30. package/dist/token-goat-chunk-65N4RHP4.mjs +33 -0
  31. package/dist/{token-goat-chunk-6AK46ZT7.mjs → token-goat-chunk-6DG6HWP3.mjs} +13 -3
  32. package/dist/token-goat-chunk-6ENQSNRZ.mjs +573 -0
  33. package/dist/token-goat-chunk-6ZY4GNF2.mjs +91 -0
  34. package/dist/{token-goat-chunk-E5TK5DNO.mjs → token-goat-chunk-76FGDLRO.mjs} +574 -340
  35. package/dist/{token-goat-chunk-TGOXNAHW.mjs → token-goat-chunk-7EZTZOMC.mjs} +780 -767
  36. package/dist/token-goat-chunk-7MAOA6X4.mjs +3647 -0
  37. package/dist/token-goat-chunk-7R2ZVVAX.mjs +218 -0
  38. package/dist/{token-goat-chunk-TCQANXYC.mjs → token-goat-chunk-AM5V6GSX.mjs} +18 -2
  39. package/dist/token-goat-chunk-AUNGYYQX.mjs +184 -0
  40. package/dist/token-goat-chunk-AUQYRMMH.mjs +2985 -0
  41. package/dist/token-goat-chunk-B3PEKBYG.mjs +128 -0
  42. package/dist/{token-goat-chunk-KOPIR3KZ.mjs → token-goat-chunk-BA4HI6BW.mjs} +1910 -165
  43. package/dist/{token-goat-chunk-52NSDWYY.mjs → token-goat-chunk-BFCWY73P.mjs} +58 -20
  44. package/dist/token-goat-chunk-BPGCUMR7.mjs +30 -0
  45. package/dist/token-goat-chunk-BWGFUZZE.mjs +25 -0
  46. package/dist/token-goat-chunk-C75NA7PL.mjs +322 -0
  47. package/dist/token-goat-chunk-CBIQ7WTD.mjs +87 -0
  48. package/dist/token-goat-chunk-CETM74KC.mjs +307 -0
  49. package/dist/token-goat-chunk-CIMQ2BB3.mjs +233 -0
  50. package/dist/{token-goat-chunk-DNSPXQXQ.mjs → token-goat-chunk-CJLS3CDL.mjs} +70 -18
  51. package/dist/{token-goat-chunk-MELOKFDJ.mjs → token-goat-chunk-CO3UYX6G.mjs} +7 -1
  52. package/dist/token-goat-chunk-COPNXRJM.mjs +154 -0
  53. package/dist/token-goat-chunk-CSJ5L3NL.mjs +479 -0
  54. package/dist/token-goat-chunk-CVCEVUGK.mjs +315 -0
  55. package/dist/token-goat-chunk-CXHOFN7R.mjs +371 -0
  56. package/dist/token-goat-chunk-D735C4QM.mjs +603 -0
  57. package/dist/{token-goat-chunk-E4ZOJIZK.mjs → token-goat-chunk-DGS2LVNA.mjs} +70 -160
  58. package/dist/{token-goat-chunk-L7H3U27L.mjs → token-goat-chunk-DOWRSMWO.mjs} +1 -1
  59. package/dist/token-goat-chunk-E45INMY3.mjs +71 -0
  60. package/dist/token-goat-chunk-EC5F37F4.mjs +244 -0
  61. package/dist/{token-goat-chunk-XTQAOTSO.mjs → token-goat-chunk-EDBDRVH5.mjs} +4 -1
  62. package/dist/token-goat-chunk-EELTBKDM.mjs +613 -0
  63. package/dist/token-goat-chunk-EVMZJ27Z.mjs +147 -0
  64. package/dist/token-goat-chunk-EXKGNHEG.mjs +2096 -0
  65. package/dist/{token-goat-chunk-YOOVFPTP.mjs → token-goat-chunk-F4HYL64R.mjs} +12 -2
  66. package/dist/token-goat-chunk-F6PAUIEK.mjs +624 -0
  67. package/dist/token-goat-chunk-FDSREWLX.mjs +692 -0
  68. package/dist/{token-goat-chunk-NMTKNYGF.mjs → token-goat-chunk-FNFBKLRD.mjs} +74 -9
  69. package/dist/token-goat-chunk-G5PJ7AGM.mjs +36 -0
  70. package/dist/token-goat-chunk-GGGG7RWB.mjs +236 -0
  71. package/dist/{token-goat-chunk-TDUT2CL6.mjs → token-goat-chunk-GL3ETKSC.mjs} +276 -19
  72. package/dist/{token-goat-chunk-7CPMDFGB.mjs → token-goat-chunk-GVB2MUST.mjs} +265 -1567
  73. package/dist/token-goat-chunk-GWFLAUMQ.mjs +307 -0
  74. package/dist/token-goat-chunk-HAVAOB3S.mjs +87 -0
  75. package/dist/token-goat-chunk-HLPW63A7.mjs +48 -0
  76. package/dist/token-goat-chunk-HU4TORC5.mjs +1377 -0
  77. package/dist/token-goat-chunk-I7VKZZAW.mjs +35 -0
  78. package/dist/token-goat-chunk-IA6XSPE3.mjs +218 -0
  79. package/dist/token-goat-chunk-IAGXMHIK.mjs +863 -0
  80. package/dist/{token-goat-chunk-435UQTKD.mjs → token-goat-chunk-IK2DRMFX.mjs} +129 -74
  81. package/dist/{token-goat-chunk-ZER6EAXZ.mjs → token-goat-chunk-INNPTRUX.mjs} +2954 -2783
  82. package/dist/token-goat-chunk-JJ5BX4F4.mjs +129 -0
  83. package/dist/token-goat-chunk-JVFSHVFJ.mjs +129 -0
  84. package/dist/token-goat-chunk-KGEFFSHD.mjs +50 -0
  85. package/dist/token-goat-chunk-KKUFXAPD.mjs +25 -0
  86. package/dist/token-goat-chunk-KQBLRPBN.mjs +433 -0
  87. package/dist/token-goat-chunk-LCNQ2CNN.mjs +497 -0
  88. package/dist/token-goat-chunk-M3LFJDPU.mjs +58 -0
  89. package/dist/token-goat-chunk-M52KPT3C.mjs +87 -0
  90. package/dist/token-goat-chunk-MBEG42H7.mjs +150 -0
  91. package/dist/{token-goat-chunk-EVC4TOLE.mjs → token-goat-chunk-METECDOH.mjs} +3 -12
  92. package/dist/{token-goat-chunk-2AWQ2R5X.mjs → token-goat-chunk-MHX7XCC3.mjs} +3 -2
  93. package/dist/token-goat-chunk-MNWKPRAL.mjs +13 -0
  94. package/dist/token-goat-chunk-N5LSOVSU.mjs +137 -0
  95. package/dist/{token-goat-chunk-DPNLUJWB.mjs → token-goat-chunk-N5MMR2IW.mjs} +30 -8
  96. package/dist/token-goat-chunk-N7B3JQ2C.mjs +160 -0
  97. package/dist/{token-goat-chunk-VMFWNHGR.mjs → token-goat-chunk-NISNMD7T.mjs} +2545 -2953
  98. package/dist/token-goat-chunk-NMD42SFQ.mjs +434 -0
  99. package/dist/token-goat-chunk-NOSS5VWY.mjs +174 -0
  100. package/dist/token-goat-chunk-NSNSPPBG.mjs +69 -0
  101. package/dist/token-goat-chunk-OBOFIHKN.mjs +38 -0
  102. package/dist/token-goat-chunk-OBRFJ5O5.mjs +76 -0
  103. package/dist/token-goat-chunk-ODBT2USM.mjs +800 -0
  104. package/dist/token-goat-chunk-OS5EM5PP.mjs +107 -0
  105. package/dist/token-goat-chunk-OUKDTVNU.mjs +1178 -0
  106. package/dist/token-goat-chunk-OXFMP75N.mjs +566 -0
  107. package/dist/{token-goat-chunk-ASLWOQ3I.mjs → token-goat-chunk-OYIYKDDT.mjs} +2 -1
  108. package/dist/{token-goat-chunk-67BNIKKO.mjs → token-goat-chunk-P6HQSWQ3.mjs} +55 -47
  109. package/dist/token-goat-chunk-P6VGNTQT.mjs +71 -0
  110. package/dist/token-goat-chunk-PFWIMH2E.mjs +261 -0
  111. package/dist/token-goat-chunk-PJZXIS3G.mjs +39 -0
  112. package/dist/token-goat-chunk-PUO5INXP.mjs +606 -0
  113. package/dist/token-goat-chunk-PX5PQWTY.mjs +462 -0
  114. package/dist/token-goat-chunk-Q5QDBC6O.mjs +111 -0
  115. package/dist/token-goat-chunk-QFNQXSDT.mjs +40 -0
  116. package/dist/token-goat-chunk-QH7YVYOY.mjs +3957 -0
  117. package/dist/token-goat-chunk-QLMUHEPB.mjs +43 -0
  118. package/dist/{token-goat-chunk-PYSUADX4.mjs → token-goat-chunk-QQOJIHL3.mjs} +50 -14
  119. package/dist/token-goat-chunk-QQTWJY2O.mjs +85 -0
  120. package/dist/token-goat-chunk-QYHO5CPH.mjs +93 -0
  121. package/dist/token-goat-chunk-RELAVWAD.mjs +27 -0
  122. package/dist/token-goat-chunk-RSLPOBKQ.mjs +339 -0
  123. package/dist/token-goat-chunk-SAMFDIS2.mjs +712 -0
  124. package/dist/token-goat-chunk-SDELXLDM.mjs +48 -0
  125. package/dist/{token-goat-chunk-PGTH2U4C.mjs → token-goat-chunk-SOAFZNNZ.mjs} +164 -40
  126. package/dist/{token-goat-chunk-G23DWHV4.mjs → token-goat-chunk-SRTHT7KV.mjs} +33 -15
  127. package/dist/token-goat-chunk-T5P5ACNQ.mjs +212 -0
  128. package/dist/token-goat-chunk-T5YGG4V3.mjs +45 -0
  129. package/dist/token-goat-chunk-TAUZ4OFS.mjs +110 -0
  130. package/dist/token-goat-chunk-TM6MC754.mjs +40 -0
  131. package/dist/token-goat-chunk-TWUKBOMP.mjs +72 -0
  132. package/dist/token-goat-chunk-U2KSB4SG.mjs +56 -0
  133. package/dist/token-goat-chunk-U4WHMG6Y.mjs +898 -0
  134. package/dist/token-goat-chunk-UA5V6P3P.mjs +122 -0
  135. package/dist/token-goat-chunk-UGJHGR5A.mjs +52 -0
  136. package/dist/{token-goat-chunk-RQGGMPCR.mjs → token-goat-chunk-UOUDVA5U.mjs} +76 -16
  137. package/dist/{token-goat-chunk-HNFZZHFW.mjs → token-goat-chunk-URRJ33GR.mjs} +22 -4
  138. package/dist/token-goat-chunk-UZOROKIS.mjs +165 -0
  139. package/dist/token-goat-chunk-VIHGGGEI.mjs +4234 -0
  140. package/dist/token-goat-chunk-VTJLAA7P.mjs +21 -0
  141. package/dist/token-goat-chunk-VWDXLT4F.mjs +678 -0
  142. package/dist/token-goat-chunk-VWZA2H4P.mjs +368 -0
  143. package/dist/{token-goat-chunk-QO3LXVVR.mjs → token-goat-chunk-VXEXMJDL.mjs} +2964 -3153
  144. package/dist/token-goat-chunk-WBA5SKT4.mjs +547 -0
  145. package/dist/{token-goat-chunk-ONXH6NZ5.mjs → token-goat-chunk-WDH44VAU.mjs} +19 -22
  146. package/dist/token-goat-chunk-X2SUP3EI.mjs +107 -0
  147. package/dist/token-goat-chunk-X3BELZSJ.mjs +125 -0
  148. package/dist/{token-goat-chunk-RLP6J7WR.mjs → token-goat-chunk-XLRBNZCC.mjs} +40 -21
  149. package/dist/{token-goat-chunk-S4VSXURL.mjs → token-goat-chunk-XRKUX6CM.mjs} +4 -0
  150. package/dist/token-goat-chunk-XX6O25RN.mjs +82 -0
  151. package/dist/token-goat-chunk-XZSUHBVS.mjs +65 -0
  152. package/dist/token-goat-chunk-Y2ZTQOCL.mjs +35 -0
  153. package/dist/{token-goat-chunk-UA5BKWWQ.mjs → token-goat-chunk-YB4VMGK2.mjs} +15 -4
  154. package/dist/token-goat-chunk-YBIIY3HR.mjs +51 -0
  155. package/dist/{token-goat-chunk-PKRWMHVP.mjs → token-goat-chunk-YHVDKQBR.mjs} +389 -221
  156. package/dist/token-goat-chunk-YJB5XLWI.mjs +26 -0
  157. package/dist/{token-goat-chunk-PQ53BSCF.mjs → token-goat-chunk-YKB6AQG3.mjs} +53 -31
  158. package/dist/token-goat-chunk-YMTG2YA5.mjs +35 -0
  159. package/dist/token-goat-chunk-YPBZYQRV.mjs +40 -0
  160. package/dist/{token-goat-chunk-HUYUHODZ.mjs → token-goat-chunk-YY6AVUFL.mjs} +13246 -12247
  161. package/dist/token-goat-chunk-Z7N5OMMP.mjs +98 -0
  162. package/dist/{token-goat-chunk-BGHSSJUA.mjs → token-goat-chunk-ZFOBKUWH.mjs} +1 -1
  163. package/dist/token-goat-chunk-ZMBL6UVV.mjs +110 -0
  164. package/dist/token-goat-chunk-ZNMNUPAZ.mjs +938 -0
  165. package/dist/token-goat-hook-client.cjs +87 -23
  166. package/dist/token-goat-hook-client.mjs +3 -3
  167. package/dist/token-goat-hook.mjs +76 -31
  168. package/dist/token-goat.core.mjs +6 -6
  169. package/docs/C4_RUNTIME_ARCHITECTURE.md +2 -2
  170. package/docs/cli.md +113 -60
  171. package/docs/install.md +63 -20
  172. package/docs/security.md +10 -8
  173. package/package.json +18 -7
  174. package/scripts/verify-native-dist.mjs +386 -0
  175. package/dist/token-goat-chunk-2NNUA2LR.mjs +0 -143
  176. package/dist/token-goat-chunk-44BM7DDQ.mjs +0 -294
  177. package/dist/token-goat-chunk-BGYOZ6DO.mjs +0 -24
  178. package/dist/token-goat-chunk-C5YPNZKQ.mjs +0 -318
  179. package/dist/token-goat-chunk-CIQ2FTY3.mjs +0 -1990
  180. package/dist/token-goat-chunk-D4ETHJD6.mjs +0 -246
  181. package/dist/token-goat-chunk-DNRPXHYH.mjs +0 -1062
  182. package/dist/token-goat-chunk-EUSDXRXU.mjs +0 -1429
  183. package/dist/token-goat-chunk-FTP4U4QA.mjs +0 -64
  184. package/dist/token-goat-chunk-G7IWXCFF.mjs +0 -456
  185. package/dist/token-goat-chunk-GLXRTTLE.mjs +0 -36
  186. package/dist/token-goat-chunk-H5J3C56Q.mjs +0 -1511
  187. package/dist/token-goat-chunk-IVWI2OCK.mjs +0 -368
  188. package/dist/token-goat-chunk-JTKCQMQA.mjs +0 -418
  189. package/dist/token-goat-chunk-LZNBQTDK.mjs +0 -26
  190. package/dist/token-goat-chunk-ORNFMIER.mjs +0 -295
  191. package/dist/token-goat-chunk-RTMVLHWX.mjs +0 -7113
  192. package/dist/token-goat-chunk-VQ6F6T7X.mjs +0 -36
  193. package/dist/token-goat-chunk-VZQEWRVH.mjs +0 -312
  194. package/dist/token-goat-chunk-XYWPOSCN.mjs +0 -807
  195. package/dist/token-goat-chunk-YAGLESS3.mjs +0 -23
  196. package/dist/token-goat-chunk-YKSRAWUU.mjs +0 -33
  197. package/dist/token-goat-chunk-Z6KBMOBI.mjs +0 -53
@@ -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
+ };
@@ -0,0 +1,52 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ CODEX_GATE_BEGIN,
5
+ CODEX_GATE_END,
6
+ INSTRUCTION_GATE_BEGIN,
7
+ INSTRUCTION_GATE_END,
8
+ checkHarnessCacheEfficiency,
9
+ checkInstructionGates,
10
+ findActiveGlobalGates,
11
+ findInstructionGateCandidates,
12
+ repairInstructionGates
13
+ } from "./token-goat-chunk-IA6XSPE3.mjs";
14
+ import "./token-goat-chunk-7MAOA6X4.mjs";
15
+ import "./token-goat-chunk-CXHOFN7R.mjs";
16
+ import "./token-goat-chunk-QQTWJY2O.mjs";
17
+ import "./token-goat-chunk-G5PJ7AGM.mjs";
18
+ import "./token-goat-chunk-BPGCUMR7.mjs";
19
+ import "./token-goat-chunk-C75NA7PL.mjs";
20
+ import "./token-goat-chunk-CBIQ7WTD.mjs";
21
+ import "./token-goat-chunk-76FGDLRO.mjs";
22
+ import "./token-goat-chunk-U4WHMG6Y.mjs";
23
+ import "./token-goat-chunk-GVB2MUST.mjs";
24
+ import "./token-goat-chunk-XB5KKOCG.mjs";
25
+ import "./token-goat-chunk-OUKDTVNU.mjs";
26
+ import "./token-goat-chunk-BFCWY73P.mjs";
27
+ import "./token-goat-chunk-KGEFFSHD.mjs";
28
+ import "./token-goat-chunk-XX6O25RN.mjs";
29
+ import "./token-goat-chunk-HAVAOB3S.mjs";
30
+ import "./token-goat-chunk-T5P5ACNQ.mjs";
31
+ import "./token-goat-chunk-7EZTZOMC.mjs";
32
+ import "./token-goat-chunk-QYHO5CPH.mjs";
33
+ import "./token-goat-chunk-4GBVPH3D.mjs";
34
+ import "./token-goat-chunk-YZAAZU2S.mjs";
35
+ import "./token-goat-chunk-IVE6U7KV.mjs";
36
+ import "./token-goat-chunk-HU4TORC5.mjs";
37
+ import "./token-goat-chunk-GGGG7RWB.mjs";
38
+ import "./token-goat-chunk-AM5V6GSX.mjs";
39
+ import "./token-goat-chunk-FNFBKLRD.mjs";
40
+ import "./token-goat-chunk-CO3UYX6G.mjs";
41
+ import "./token-goat-chunk-A37V4PBF.mjs";
42
+ export {
43
+ CODEX_GATE_BEGIN,
44
+ CODEX_GATE_END,
45
+ INSTRUCTION_GATE_BEGIN,
46
+ INSTRUCTION_GATE_END,
47
+ checkHarnessCacheEfficiency,
48
+ checkInstructionGates,
49
+ findActiveGlobalGates,
50
+ findInstructionGateCandidates,
51
+ repairInstructionGates
52
+ };
@@ -18,7 +18,7 @@ import {
18
18
  readServerKey,
19
19
  touchMarker,
20
20
  writeFrame
21
- } from "./token-goat-chunk-DPNLUJWB.mjs";
21
+ } from "./token-goat-chunk-N5MMR2IW.mjs";
22
22
  import {
23
23
  envBool
24
24
  } from "./token-goat-chunk-IVE6U7KV.mjs";
@@ -31,13 +31,15 @@ init_define_import_meta_env();
31
31
  import { spawn } from "node:child_process";
32
32
  import * as fs from "node:fs";
33
33
  import * as net from "node:net";
34
+ import * as os from "node:os";
34
35
  var HANDSHAKE_TIMEOUT_MS = 150;
35
36
  var FIND_BUDGET_MS = 300;
37
+ var HEDGE_MS = 40;
36
38
  var RESPONSE_TIMEOUT_MS = 12e4;
37
39
  var CONTROL_WAIT_MS = 1e4;
38
40
  var SPAWN_RETRY_MS = 3e4;
39
41
  var DISABLED_MARKER_TTL_MS = 10 * 6e4;
40
- function attempt(slot, key, request, handshakeMs, dir) {
42
+ function attempt(slot, key, request, handshakeMs, dir, race) {
41
43
  return new Promise((resolve) => {
42
44
  const socket = net.connect(endpointFor(slot, dir));
43
45
  const nc = nonce();
@@ -51,6 +53,10 @@ function attempt(slot, key, request, handshakeMs, dir) {
51
53
  resolve(outcome);
52
54
  };
53
55
  let timer = setTimeout(() => finish({ kind: "busy" }), handshakeMs);
56
+ const cancel = () => {
57
+ if (!dispatched) finish({ kind: "busy" });
58
+ };
59
+ race?.onCancel(cancel);
54
60
  socket.on("error", (e) => {
55
61
  if (dispatched) finish({ kind: "lost" });
56
62
  else finish({ kind: e.code === "ENOENT" || e.code === "ECONNREFUSED" ? "absent" : "refused" });
@@ -70,9 +76,10 @@ function attempt(slot, key, request, handshakeMs, dir) {
70
76
  const body = JSON.stringify(request);
71
77
  const frame = encodeFrame({ t: "req", mac: mac(key, "C", nc, ns, body), body });
72
78
  if (!frameFits(frame)) return finish({ kind: "oversize" });
79
+ if (race !== void 0 && !race.claim(cancel)) return finish({ kind: "busy" });
73
80
  dispatched = true;
74
81
  clearTimeout(timer);
75
- timer = setTimeout(() => finish({ kind: "lost" }), RESPONSE_TIMEOUT_MS);
82
+ if (request.kind !== "cli") timer = setTimeout(() => finish({ kind: "lost" }), RESPONSE_TIMEOUT_MS);
76
83
  socket.write(frame);
77
84
  return;
78
85
  }
@@ -97,7 +104,9 @@ function startServer(slot) {
97
104
  if (disabled || markerAgeMs(`spawn-${slot}`) < SPAWN_RETRY_MS || !fs.existsSync(launcher)) return;
98
105
  touchMarker(`spawn-${slot}`);
99
106
  try {
100
- spawn(process.execPath, [launcher, "hook-server", "run", "--slot", String(slot)], { detached: true, stdio: "ignore", windowsHide: true }).unref();
107
+ const child = spawn(process.execPath, [launcher, "hook-server", "run", "--slot", String(slot)], { cwd: os.tmpdir(), detached: true, stdio: "ignore", windowsHide: true });
108
+ child.on("error", () => void 0);
109
+ child.unref();
101
110
  } catch {
102
111
  }
103
112
  }
@@ -113,17 +122,56 @@ async function callServer(request, opts = {}) {
113
122
  return void 0;
114
123
  }
115
124
  const deadline = Date.now() + FIND_BUDGET_MS;
116
- for (let slot = 0; slot < SERVER_SLOTS && Date.now() < deadline; slot++) {
117
- const outcome = await attempt(slot, key, request, opts.handshakeMs ?? HANDSHAKE_TIMEOUT_MS);
118
- if (outcome.kind === "served") return outcome.reply;
119
- if (outcome.kind === "lost") return "lost";
120
- if (outcome.kind === "absent") {
121
- if (autostart) startServer(slot);
122
- return void 0;
123
- }
124
- if (outcome.kind === "stale" || outcome.kind === "oversize") return void 0;
125
- }
126
- return void 0;
125
+ const handshakeMs = opts.handshakeMs ?? HANDSHAKE_TIMEOUT_MS;
126
+ return new Promise((resolve) => {
127
+ let claimed = false;
128
+ let settled = false;
129
+ let exhausted = false;
130
+ let next = 0;
131
+ let pending = 0;
132
+ let hedge;
133
+ const cancels = [];
134
+ const settle = (value) => {
135
+ if (settled) return;
136
+ settled = true;
137
+ clearTimeout(hedge);
138
+ for (const cancel of cancels) cancel();
139
+ resolve(value);
140
+ };
141
+ const race = {
142
+ claim: (self) => {
143
+ if (claimed || settled) return false;
144
+ claimed = true;
145
+ clearTimeout(hedge);
146
+ for (const cancel of cancels) if (cancel !== self) cancel();
147
+ return true;
148
+ },
149
+ onCancel: (cancel) => cancels.push(cancel)
150
+ };
151
+ const askNext = () => {
152
+ clearTimeout(hedge);
153
+ if (settled || claimed || exhausted || next >= SERVER_SLOTS || Date.now() >= deadline) {
154
+ if (pending === 0 && !claimed) settle(void 0);
155
+ return;
156
+ }
157
+ const slot = next++;
158
+ pending++;
159
+ void attempt(slot, key, request, handshakeMs, void 0, race).then((outcome) => {
160
+ pending--;
161
+ if (outcome.kind === "served") return settle(outcome.reply);
162
+ if (outcome.kind === "lost") return settle("lost");
163
+ if (claimed) return;
164
+ if (outcome.kind === "stale" || outcome.kind === "oversize") return settle(void 0);
165
+ if (outcome.kind === "absent") {
166
+ if (autostart) startServer(slot);
167
+ exhausted = true;
168
+ }
169
+ askNext();
170
+ });
171
+ if (next < SERVER_SLOTS) hedge = setTimeout(askNext, HEDGE_MS);
172
+ };
173
+ askNext();
174
+ });
127
175
  }
128
176
  async function relayViaServer(event, input, harnessWaitMs) {
129
177
  try {
@@ -147,17 +195,29 @@ async function relayViaServer(event, input, harnessWaitMs) {
147
195
  var WARM_CLI_COMMANDS = /* @__PURE__ */ new Set([
148
196
  "answer",
149
197
  "brief",
198
+ "call-chain",
199
+ "callers",
150
200
  "changed",
201
+ "context-for",
202
+ "dead",
203
+ "deps",
151
204
  "exports",
205
+ "find",
206
+ "impact",
152
207
  "imports",
208
+ "locate",
153
209
  "map",
154
210
  "outline",
155
211
  "read",
156
212
  "refs",
213
+ "scope",
157
214
  "section",
158
215
  "semantic",
216
+ "similar",
159
217
  "skeleton",
160
- "symbol"
218
+ "symbol",
219
+ "test-for",
220
+ "types"
161
221
  ]);
162
222
  function warmCliEligible(argv) {
163
223
  const command = argv[2];
@@ -1,5 +1,11 @@
1
1
  import { createRequire as __cjsRequire } from 'node:module';
2
2
  const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ redactSecrets
5
+ } from "./token-goat-chunk-T5P5ACNQ.mjs";
6
+ import {
7
+ loadConfig
8
+ } from "./token-goat-chunk-7EZTZOMC.mjs";
3
9
  import {
4
10
  NotAnOfficeDocumentError,
5
11
  assertOoxmlWithinDeadline,
@@ -12,10 +18,13 @@ import {
12
18
  parseOoxmlPart,
13
19
  readOoxmlZip,
14
20
  sortNumberedParts
15
- } from "./token-goat-chunk-UXSXQQIY.mjs";
21
+ } from "./token-goat-chunk-2M7E4PF7.mjs";
22
+ import {
23
+ findOpenTags
24
+ } from "./token-goat-chunk-E45INMY3.mjs";
16
25
  import {
17
26
  compileGuardedRegex
18
- } from "./token-goat-chunk-JTKCQMQA.mjs";
27
+ } from "./token-goat-chunk-HU4TORC5.mjs";
19
28
  import {
20
29
  init_define_import_meta_env
21
30
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -109,7 +118,14 @@ async function notesPathFor(entries, slidePath, budget) {
109
118
  return null;
110
119
  }
111
120
  function inlineSlideMath(xml) {
112
- return inlineMathRuns(xml, '<a:r><a:t xml:space="preserve">', "</a:t></a:r>").replace(/<a14:m(?:\s[^>]*)?>/g, "").replace(/<\/a14:m>/g, "");
121
+ const withRuns = inlineMathRuns(xml, '<a:r><a:t xml:space="preserve">', "</a:t></a:r>");
122
+ let bare = "";
123
+ let pos = 0;
124
+ for (const tag of findOpenTags(withRuns, /<a14:m(?=[\s>])/g)) {
125
+ bare += withRuns.slice(pos, tag.start);
126
+ pos = tag.end;
127
+ }
128
+ return (bare + withRuns.slice(pos)).replace(/<\/a14:m>/g, "");
113
129
  }
114
130
  async function parseSlide(entries, path, budget) {
115
131
  const xml = decodeZipEntry(entries, path, budget);
@@ -194,10 +210,11 @@ async function pptxTextGrep(filePath, pattern, deadline = ooxmlWorkDeadline()) {
194
210
  if (!guarded.ok) throw new Error(`invalid --grep pattern: ${pattern} -- the pattern ${guarded.reason}`);
195
211
  const re = guarded.re;
196
212
  const out = [];
213
+ const config = loadConfig();
197
214
  for (let i = 0; i < slidePaths.length; i++) {
198
215
  assertOoxmlWithinDeadline(deadline, "Narrow the read to specific slides with pptx-slide, or use a smaller deck.");
199
216
  const parsed = await parseSlide(entries, slidePaths[i], budget);
200
- const text = flatSlideText(parsed);
217
+ const text = redactSecrets(flatSlideText(parsed), config).text;
201
218
  if (re.test(text)) {
202
219
  const idx = text.search(re);
203
220
  const snippet = text.slice(Math.max(0, idx - 40), idx + 80).trim();
@@ -208,6 +225,7 @@ async function pptxTextGrep(filePath, pattern, deadline = ooxmlWorkDeadline()) {
208
225
  }
209
226
 
210
227
  export {
228
+ inlineSlideMath,
211
229
  pptxOutline,
212
230
  pptxSlideText,
213
231
  pptxAllSlidesText,
@@ -0,0 +1,165 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ isIndexedRoot,
5
+ recordIndexedRoot
6
+ } from "./token-goat-chunk-M3LFJDPU.mjs";
7
+ import {
8
+ MAX_FILES_SCANNED,
9
+ walkProject
10
+ } from "./token-goat-chunk-ZNMNUPAZ.mjs";
11
+ import {
12
+ reconcileProject
13
+ } from "./token-goat-chunk-PFWIMH2E.mjs";
14
+ import {
15
+ getTrackedFiles
16
+ } from "./token-goat-chunk-OBOFIHKN.mjs";
17
+ import {
18
+ isDotenvPath
19
+ } from "./token-goat-chunk-GVB2MUST.mjs";
20
+ import {
21
+ loadConfig
22
+ } from "./token-goat-chunk-7EZTZOMC.mjs";
23
+ import {
24
+ findProject,
25
+ isUnderSystemTemp
26
+ } from "./token-goat-chunk-4GBVPH3D.mjs";
27
+ import {
28
+ envBool
29
+ } from "./token-goat-chunk-IVE6U7KV.mjs";
30
+ import {
31
+ countNoun,
32
+ extractErrorMessage,
33
+ isUnderBlockedRoot,
34
+ runGit
35
+ } from "./token-goat-chunk-HU4TORC5.mjs";
36
+ import {
37
+ echoedValue
38
+ } from "./token-goat-chunk-GGGG7RWB.mjs";
39
+ import {
40
+ canonicalize,
41
+ foldPath
42
+ } from "./token-goat-chunk-AM5V6GSX.mjs";
43
+ import {
44
+ normalizePath
45
+ } from "./token-goat-chunk-FNFBKLRD.mjs";
46
+ import {
47
+ init_define_import_meta_env
48
+ } from "./token-goat-chunk-A37V4PBF.mjs";
49
+
50
+ // src/install_index.ts
51
+ init_define_import_meta_env();
52
+ import * as fs2 from "node:fs";
53
+
54
+ // src/walk_index.ts
55
+ init_define_import_meta_env();
56
+ import * as fs from "node:fs";
57
+ import * as os from "node:os";
58
+ import * as path from "node:path";
59
+ function isWalkExcluded(file) {
60
+ if (isDotenvPath(file)) return true;
61
+ const base = path.basename(file).toLowerCase();
62
+ if (base.endsWith(".d.ts")) return true;
63
+ return false;
64
+ }
65
+ function assertWalkableRoot(root) {
66
+ let resolved = path.resolve(root);
67
+ try {
68
+ resolved = fs.realpathSync.native(resolved);
69
+ } catch {
70
+ }
71
+ const norm = foldPath(normalizePath(resolved));
72
+ const fsRoot = foldPath(normalizePath(path.parse(resolved).root));
73
+ if (norm === fsRoot) {
74
+ throw new Error(`refusing to walk-index a filesystem root: ${resolved}`);
75
+ }
76
+ const home = os.homedir();
77
+ if (home) {
78
+ const normHome = foldPath(normalizePath(path.resolve(home)));
79
+ if (norm === normHome) {
80
+ throw new Error(`refusing to walk-index the home directory: ${resolved}`);
81
+ }
82
+ const boundary = norm.endsWith("/") ? norm : `${norm}/`;
83
+ if (normHome.startsWith(boundary)) {
84
+ throw new Error(`refusing to walk-index ${echoedValue(resolved)} \u2014 it contains the home directory`);
85
+ }
86
+ }
87
+ }
88
+ var MAX_FILES_SCANNED_FORCED = 5e5;
89
+ function collectWalkIndexFiles(root, opts = {}) {
90
+ const resolved = path.resolve(root);
91
+ assertWalkableRoot(resolved);
92
+ const force = opts.force === true;
93
+ const ceiling = force ? MAX_FILES_SCANNED_FORCED : MAX_FILES_SCANNED;
94
+ const { files } = walkProject(resolved, { includeEmbeddableDocuments: true, maxFiles: ceiling });
95
+ if (files.length >= ceiling) {
96
+ throw new Error(
97
+ `${echoedValue(resolved)} has too many source files (walk stopped at ${ceiling}; the real total is at least that). ` + (force ? "Even --force-walk will not walk a tree this large \u2014 point at a narrower path." : `Index a git repo, point at a narrower path, or pass --force-walk to raise the cap to ${MAX_FILES_SCANNED_FORCED}.`)
98
+ );
99
+ }
100
+ return files.filter((f) => !isWalkExcluded(f));
101
+ }
102
+
103
+ // src/install_index.ts
104
+ var INSTALL_INDEX_BUDGET_MS = 1e4;
105
+ var INSTALL_INDEX_ENV = "TOKEN_GOAT_INSTALL_INDEX";
106
+ function isOwnGitToplevel(root) {
107
+ const toplevel = runGit(["rev-parse", "--show-toplevel"], { cwd: root });
108
+ if (toplevel.exitCode !== 0 || toplevel.stdout.trim() === "") return false;
109
+ return foldPath(canonicalize(fs2.realpathSync(toplevel.stdout.trim()))) === foldPath(canonicalize(fs2.realpathSync(root)));
110
+ }
111
+ function queueInstallIndex(cwd, opts = {}) {
112
+ try {
113
+ if (opts.enabled === false || !envBool(INSTALL_INDEX_ENV, true)) return { status: "skipped", reason: "disabled" };
114
+ const project = findProject(cwd);
115
+ if (project === null) return { status: "skipped", reason: "no-project" };
116
+ const root = project.root;
117
+ try {
118
+ assertWalkableRoot(root);
119
+ } catch {
120
+ return { status: "skipped", reason: "broad-root", root };
121
+ }
122
+ if (isUnderSystemTemp(root)) return { status: "skipped", reason: "temp", root };
123
+ if (isUnderBlockedRoot(root, loadConfig().worker.blocked_roots)) return { status: "skipped", reason: "blocked", root };
124
+ if (isIndexedRoot(root)) return { status: "skipped", reason: "indexed", root };
125
+ if (getTrackedFiles(root).length === 0) return { status: "skipped", reason: isOwnGitToplevel(root) ? "untracked" : "not-git", root };
126
+ const result = reconcileProject({ cwd: root, budgetMs: INSTALL_INDEX_BUDGET_MS });
127
+ recordIndexedRoot(root);
128
+ if (result.enqueued === 0) return { status: "skipped", reason: "nothing-queued", root };
129
+ return { status: "queued", root, files: result.enqueued };
130
+ } catch (e) {
131
+ return { status: "failed", error: extractErrorMessage(e) };
132
+ }
133
+ }
134
+ function formatInstallIndexResult(result) {
135
+ if (result.status === "queued") {
136
+ return `Indexing ${result.root} in the background (${countNoun(result.files, "file")} queued); \`token-goat doctor\` shows progress.`;
137
+ }
138
+ if (result.status === "failed") {
139
+ return `Could not queue this project for indexing (${result.error}); run \`token-goat index\` inside it instead.`;
140
+ }
141
+ switch (result.reason) {
142
+ case "no-project":
143
+ return "No project here to index. Run `token-goat index` inside a project, or start a session in one after it has been indexed.";
144
+ case "broad-root":
145
+ return `${result.root ?? "This folder"} is too broad to index automatically (a home or drive root); run \`token-goat index\` inside a specific project.`;
146
+ case "temp":
147
+ return `${result.root ?? "This folder"} is under the system temp directory, so install does not index it automatically; run \`token-goat index\` there to index it.`;
148
+ case "not-git":
149
+ return `${result.root ?? "This folder"} is not a git repository, so it was not indexed. Run \`token-goat index --walk\` inside it to index it anyway.`;
150
+ case "untracked":
151
+ return `${result.root ?? "This folder"} is a git repository with no tracked files yet, so it was not indexed. Run \`token-goat index --walk\` inside it, or \`git add\` the files and run \`token-goat index\`.`;
152
+ case "blocked":
153
+ return `${result.root ?? "This folder"} is excluded by worker.blocked_roots, so it was not indexed.`;
154
+ default:
155
+ return null;
156
+ }
157
+ }
158
+
159
+ export {
160
+ MAX_FILES_SCANNED_FORCED,
161
+ collectWalkIndexFiles,
162
+ INSTALL_INDEX_ENV,
163
+ queueInstallIndex,
164
+ formatInstallIndexResult
165
+ };