token-goat 2.9.29 → 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 (131) hide show
  1. package/README.md +34 -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-PGTH2U4C.mjs → token-goat-chunk-4JJS54TR.mjs} +4 -3
  11. package/dist/token-goat-chunk-4LCCNRTG.mjs +313 -0
  12. package/dist/{token-goat-chunk-L7H3U27L.mjs → token-goat-chunk-54K3EUV3.mjs} +1 -1
  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-GLXRTTLE.mjs → token-goat-chunk-64FBPDTK.mjs} +12 -8
  19. package/dist/{token-goat-chunk-G23DWHV4.mjs → token-goat-chunk-664RTTUV.mjs} +28 -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-IVWI2OCK.mjs → token-goat-chunk-7F2UBPD3.mjs} +40 -11
  24. package/dist/{token-goat-chunk-TGOXNAHW.mjs → token-goat-chunk-7IN2MKDS.mjs} +682 -501
  25. package/dist/token-goat-chunk-7NADEDKJ.mjs +124 -0
  26. package/dist/{token-goat-chunk-KOPIR3KZ.mjs → token-goat-chunk-A3CK6N5Z.mjs} +618 -72
  27. package/dist/{token-goat-chunk-O6I2XU4P.mjs → token-goat-chunk-AFLYLHDH.mjs} +44 -31
  28. package/dist/{token-goat-chunk-TCQANXYC.mjs → token-goat-chunk-AM5V6GSX.mjs} +18 -2
  29. package/dist/{token-goat-chunk-E4ZOJIZK.mjs → token-goat-chunk-APGZXSPS.mjs} +39 -146
  30. package/dist/{token-goat-chunk-D4ETHJD6.mjs → token-goat-chunk-ARDNEC2U.mjs} +9 -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-BGYOZ6DO.mjs → token-goat-chunk-B45VMIIH.mjs} +6 -7
  34. package/dist/token-goat-chunk-BPGCUMR7.mjs +30 -0
  35. package/dist/{token-goat-chunk-TDUT2CL6.mjs → token-goat-chunk-C63JQV5K.mjs} +45 -6
  36. package/dist/{token-goat-chunk-ZER6EAXZ.mjs → token-goat-chunk-COBQGL5S.mjs} +2661 -2440
  37. package/dist/token-goat-chunk-COTXZHTS.mjs +39 -0
  38. package/dist/{token-goat-chunk-RQGGMPCR.mjs → token-goat-chunk-CYCEYAEO.mjs} +76 -16
  39. package/dist/token-goat-chunk-CZ3LUXYZ.mjs +4115 -0
  40. package/dist/{token-goat-chunk-ASLWOQ3I.mjs → token-goat-chunk-DZX2YDPT.mjs} +2 -1
  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-RTMVLHWX.mjs → token-goat-chunk-FBNQNSJK.mjs} +2555 -5127
  47. package/dist/{token-goat-chunk-NMTKNYGF.mjs → token-goat-chunk-FNFBKLRD.mjs} +74 -9
  48. package/dist/{token-goat-chunk-RLP6J7WR.mjs → token-goat-chunk-FZ3NEW5O.mjs} +33 -19
  49. package/dist/token-goat-chunk-G5PJ7AGM.mjs +36 -0
  50. package/dist/{token-goat-chunk-DNRPXHYH.mjs → token-goat-chunk-GFBSN7BD.mjs} +29 -401
  51. package/dist/{token-goat-chunk-XYWPOSCN.mjs → token-goat-chunk-GOLEOXZP.mjs} +763 -211
  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-HUYUHODZ.mjs → token-goat-chunk-HOJLCGDP.mjs} +12965 -11748
  57. package/dist/{token-goat-chunk-435UQTKD.mjs → token-goat-chunk-HYBFA5X3.mjs} +118 -19
  58. package/dist/token-goat-chunk-IVALLT3S.mjs +48 -0
  59. package/dist/{token-goat-chunk-UXSXQQIY.mjs → token-goat-chunk-IVKIZWAB.mjs} +3 -3
  60. package/dist/{token-goat-chunk-52NSDWYY.mjs → token-goat-chunk-JB6QN6VF.mjs} +6 -4
  61. package/dist/{token-goat-chunk-HNFZZHFW.mjs → token-goat-chunk-JDHE26RP.mjs} +10 -3
  62. package/dist/{token-goat-chunk-FTP4U4QA.mjs → token-goat-chunk-JDU3EXSU.mjs} +12 -11
  63. package/dist/token-goat-chunk-JDWCRD6M.mjs +253 -0
  64. package/dist/{token-goat-chunk-6AK46ZT7.mjs → token-goat-chunk-JN4XMLSD.mjs} +5 -1
  65. package/dist/token-goat-chunk-JTQQGXZH.mjs +733 -0
  66. package/dist/token-goat-chunk-KKUFXAPD.mjs +25 -0
  67. package/dist/token-goat-chunk-KQNZDCBD.mjs +47 -0
  68. package/dist/{token-goat-chunk-2WOUYWLM.mjs → token-goat-chunk-KWPNJBDH.mjs} +27 -3
  69. package/dist/{token-goat-chunk-DPNLUJWB.mjs → token-goat-chunk-LOBGHXPB.mjs} +30 -8
  70. package/dist/token-goat-chunk-MKPF4CL5.mjs +37 -0
  71. package/dist/token-goat-chunk-MNWKPRAL.mjs +13 -0
  72. package/dist/{token-goat-chunk-DNSPXQXQ.mjs → token-goat-chunk-N2NMER56.mjs} +25 -15
  73. package/dist/token-goat-chunk-NYKZLXMK.mjs +218 -0
  74. package/dist/token-goat-chunk-OJBNYTJP.mjs +3087 -0
  75. package/dist/token-goat-chunk-P4QMM4WK.mjs +295 -0
  76. package/dist/token-goat-chunk-PD5VKH46.mjs +184 -0
  77. package/dist/token-goat-chunk-PEPTHRFF.mjs +129 -0
  78. package/dist/{token-goat-chunk-NMBWLRHW.mjs → token-goat-chunk-PU7V3FD6.mjs} +8721 -11104
  79. package/dist/token-goat-chunk-PY533T7F.mjs +46 -0
  80. package/dist/token-goat-chunk-Q5VTGRH7.mjs +761 -0
  81. package/dist/{token-goat-chunk-67BNIKKO.mjs → token-goat-chunk-QCLDAQTS.mjs} +31 -20
  82. package/dist/{token-goat-chunk-SE6E4BKJ.mjs → token-goat-chunk-QSBRTGM2.mjs} +9 -2
  83. package/dist/{token-goat-chunk-VZQEWRVH.mjs → token-goat-chunk-RC35RBUL.mjs} +4 -4
  84. package/dist/{token-goat-chunk-VMFWNHGR.mjs → token-goat-chunk-RHXKCZX3.mjs} +873 -504
  85. package/dist/{token-goat-chunk-PYSUADX4.mjs → token-goat-chunk-RZRTDST7.mjs} +17 -7
  86. package/dist/{token-goat-chunk-ONXH6NZ5.mjs → token-goat-chunk-SJHWVNDQ.mjs} +15 -21
  87. package/dist/token-goat-chunk-SMVRN2HU.mjs +188 -0
  88. package/dist/{token-goat-chunk-QO3LXVVR.mjs → token-goat-chunk-SQSSNQPE.mjs} +2295 -1718
  89. package/dist/{token-goat-chunk-2AWQ2R5X.mjs → token-goat-chunk-T4FK7VOV.mjs} +2 -2
  90. package/dist/token-goat-chunk-U4N3BN2W.mjs +92 -0
  91. package/dist/token-goat-chunk-UA5V6P3P.mjs +122 -0
  92. package/dist/{token-goat-chunk-UA5BKWWQ.mjs → token-goat-chunk-UQ5UK2T7.mjs} +15 -4
  93. package/dist/token-goat-chunk-USILZ3T3.mjs +53 -0
  94. package/dist/{token-goat-chunk-MELOKFDJ.mjs → token-goat-chunk-VES7EL7O.mjs} +7 -1
  95. package/dist/{token-goat-chunk-7CPMDFGB.mjs → token-goat-chunk-VL3YIFHZ.mjs} +389 -14
  96. package/dist/{token-goat-chunk-E5TK5DNO.mjs → token-goat-chunk-VPBBTSJR.mjs} +356 -129
  97. package/dist/{token-goat-chunk-YOOVFPTP.mjs → token-goat-chunk-W3QCJS6G.mjs} +10 -2
  98. package/dist/{token-goat-chunk-LZNBQTDK.mjs → token-goat-chunk-WY3L4DVT.mjs} +11 -7
  99. package/dist/token-goat-chunk-XKI4SEMX.mjs +66 -0
  100. package/dist/token-goat-chunk-XU4P6Z24.mjs +133 -0
  101. package/dist/{token-goat-chunk-H5J3C56Q.mjs → token-goat-chunk-Y776AENC.mjs} +112 -26
  102. package/dist/token-goat-chunk-YARZFCZS.mjs +359 -0
  103. package/dist/{token-goat-chunk-S4VSXURL.mjs → token-goat-chunk-Z44YO3QZ.mjs} +4 -0
  104. package/dist/token-goat-chunk-Z57YODA2.mjs +35 -0
  105. package/dist/{token-goat-chunk-PQ53BSCF.mjs → token-goat-chunk-ZCDTCVIS.mjs} +48 -29
  106. package/dist/token-goat-chunk-ZEJVMUQH.mjs +48 -0
  107. package/dist/{token-goat-chunk-BGHSSJUA.mjs → token-goat-chunk-ZFOBKUWH.mjs} +1 -1
  108. package/dist/token-goat-chunk-ZMBL6UVV.mjs +110 -0
  109. package/dist/{token-goat-chunk-PKRWMHVP.mjs → token-goat-chunk-ZQSJMO2R.mjs} +338 -170
  110. package/dist/token-goat-hook-client.cjs +87 -23
  111. package/dist/token-goat-hook-client.mjs +3 -3
  112. package/dist/token-goat-hook.mjs +46 -30
  113. package/dist/token-goat.core.mjs +6 -6
  114. package/docs/C4_RUNTIME_ARCHITECTURE.md +1 -1
  115. package/docs/cli.md +80 -46
  116. package/docs/install.md +47 -14
  117. package/docs/security.md +7 -7
  118. package/package.json +17 -7
  119. package/scripts/verify-native-dist.mjs +386 -0
  120. package/dist/token-goat-chunk-2NNUA2LR.mjs +0 -143
  121. package/dist/token-goat-chunk-44BM7DDQ.mjs +0 -294
  122. package/dist/token-goat-chunk-C5YPNZKQ.mjs +0 -318
  123. package/dist/token-goat-chunk-CIQ2FTY3.mjs +0 -1990
  124. package/dist/token-goat-chunk-EUSDXRXU.mjs +0 -1429
  125. package/dist/token-goat-chunk-G7IWXCFF.mjs +0 -456
  126. package/dist/token-goat-chunk-JTKCQMQA.mjs +0 -418
  127. package/dist/token-goat-chunk-ORNFMIER.mjs +0 -295
  128. package/dist/token-goat-chunk-VQ6F6T7X.mjs +0 -36
  129. package/dist/token-goat-chunk-YAGLESS3.mjs +0 -23
  130. package/dist/token-goat-chunk-YKSRAWUU.mjs +0 -33
  131. package/dist/token-goat-chunk-Z6KBMOBI.mjs +0 -53
@@ -0,0 +1,39 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ DownloadCooldownError,
5
+ DownloadFailedError,
6
+ MODEL_DOWNLOAD_HOST,
7
+ RUNTIME_DOWNLOAD_HOST,
8
+ activeDownloadCooldown,
9
+ clearDownloadFailure,
10
+ describeCause,
11
+ downloadFailureRecordPath,
12
+ downloadHoldMs,
13
+ failedAtOf,
14
+ isExplicitDownload,
15
+ lastDownloadFailure,
16
+ recordDownloadFailure,
17
+ withExplicitDownload
18
+ } from "./token-goat-chunk-SMVRN2HU.mjs";
19
+ import "./token-goat-chunk-GOLEOXZP.mjs";
20
+ import "./token-goat-chunk-AM5V6GSX.mjs";
21
+ import "./token-goat-chunk-FNFBKLRD.mjs";
22
+ import "./token-goat-chunk-VES7EL7O.mjs";
23
+ import "./token-goat-chunk-A37V4PBF.mjs";
24
+ export {
25
+ DownloadCooldownError,
26
+ DownloadFailedError,
27
+ MODEL_DOWNLOAD_HOST,
28
+ RUNTIME_DOWNLOAD_HOST,
29
+ activeDownloadCooldown,
30
+ clearDownloadFailure,
31
+ describeCause,
32
+ downloadFailureRecordPath,
33
+ downloadHoldMs,
34
+ failedAtOf,
35
+ isExplicitDownload,
36
+ lastDownloadFailure,
37
+ recordDownloadFailure,
38
+ withExplicitDownload
39
+ };
@@ -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-LOBGHXPB.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];