grepmax 0.26.43 → 0.26.45

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 (93) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/NOTICE +6 -0
  3. package/README.md +5 -1
  4. package/dist/bin.js +4 -0
  5. package/dist/commands/doctor.js +2 -1
  6. package/dist/commands/mcp.js +234 -93
  7. package/dist/commands/project.js +0 -1
  8. package/dist/commands/similar.js +0 -1
  9. package/dist/commands/skeleton.js +0 -1
  10. package/dist/commands/status.js +32 -18
  11. package/dist/commands/surprises.js +0 -1
  12. package/dist/commands/symbols.js +0 -1
  13. package/dist/commands/watch.js +2 -1
  14. package/dist/eval-like-limit-probe.js +60 -41
  15. package/dist/lib/analysis/surprising-connections.js +4 -3
  16. package/dist/lib/daemon/daemon.js +14 -2
  17. package/dist/lib/daemon/graph-handler.js +33 -33
  18. package/dist/lib/daemon/rows-handler.js +13 -51
  19. package/dist/lib/daemon/vector-handler.js +18 -17
  20. package/dist/lib/graph/graph-builder.js +33 -16
  21. package/dist/lib/graph/impact.js +9 -8
  22. package/dist/lib/index/index-config.js +2 -2
  23. package/dist/lib/llm/config.js +9 -3
  24. package/dist/lib/llm/tools.js +5 -4
  25. package/dist/lib/output/mcp-results.js +177 -0
  26. package/dist/lib/search/pagerank.js +2 -1
  27. package/dist/lib/search/searcher.js +5 -4
  28. package/dist/lib/skeleton/retriever.js +2 -1
  29. package/dist/lib/store/lance-sdk.js +46 -0
  30. package/dist/lib/store/vector-db.js +57 -16
  31. package/dist/lib/utils/cross-project.js +2 -2
  32. package/dist/lib/utils/project-registry.js +8 -8
  33. package/dist/lib/utils/query-timeout.js +53 -13
  34. package/dist/lib/utils/store-access.js +6 -5
  35. package/dist/lib/utils/store-context.js +102 -0
  36. package/dist/lib/utils/stores.js +1 -1
  37. package/dist/vendor/lancedb/LICENSE +202 -0
  38. package/dist/vendor/lancedb/NODEJS_THIRD_PARTY_LICENSES.md +668 -0
  39. package/dist/vendor/lancedb/RUST_THIRD_PARTY_LICENSES.html +14607 -0
  40. package/dist/vendor/lancedb/arrow.d.ts +296 -0
  41. package/dist/vendor/lancedb/arrow.js +1145 -0
  42. package/dist/vendor/lancedb/arrow_type.d.ts +9 -0
  43. package/dist/vendor/lancedb/arrow_type.js +29 -0
  44. package/dist/vendor/lancedb/connection.d.ts +508 -0
  45. package/dist/vendor/lancedb/connection.js +298 -0
  46. package/dist/vendor/lancedb/embedding/embedding_function.d.ts +103 -0
  47. package/dist/vendor/lancedb/embedding/embedding_function.js +192 -0
  48. package/dist/vendor/lancedb/embedding/index.d.ts +37 -0
  49. package/dist/vendor/lancedb/embedding/index.js +108 -0
  50. package/dist/vendor/lancedb/embedding/openai.d.ts +16 -0
  51. package/dist/vendor/lancedb/embedding/openai.js +81 -0
  52. package/dist/vendor/lancedb/embedding/registry.d.ts +94 -0
  53. package/dist/vendor/lancedb/embedding/registry.js +221 -0
  54. package/dist/vendor/lancedb/embedding/transformers.d.ts +36 -0
  55. package/dist/vendor/lancedb/embedding/transformers.js +110 -0
  56. package/dist/vendor/lancedb/header.d.ts +162 -0
  57. package/dist/vendor/lancedb/header.js +217 -0
  58. package/dist/vendor/lancedb/index.d.ts +246 -0
  59. package/dist/vendor/lancedb/index.js +176 -0
  60. package/dist/vendor/lancedb/indices.d.ts +721 -0
  61. package/dist/vendor/lancedb/indices.js +166 -0
  62. package/dist/vendor/lancedb/license_header.txt +2 -0
  63. package/dist/vendor/lancedb/materialized_view.d.ts +69 -0
  64. package/dist/vendor/lancedb/materialized_view.js +112 -0
  65. package/dist/vendor/lancedb/merge.d.ts +104 -0
  66. package/dist/vendor/lancedb/merge.js +120 -0
  67. package/dist/vendor/lancedb/native.d.ts +1193 -0
  68. package/dist/vendor/lancedb/native.js +688 -0
  69. package/dist/vendor/lancedb/oauth.d.ts +66 -0
  70. package/dist/vendor/lancedb/oauth.js +15 -0
  71. package/dist/vendor/lancedb/otel.d.ts +26 -0
  72. package/dist/vendor/lancedb/otel.js +114 -0
  73. package/dist/vendor/lancedb/permutation.d.ts +143 -0
  74. package/dist/vendor/lancedb/permutation.js +184 -0
  75. package/dist/vendor/lancedb/provenance.json +6 -0
  76. package/dist/vendor/lancedb/query.d.ts +663 -0
  77. package/dist/vendor/lancedb/query.js +966 -0
  78. package/dist/vendor/lancedb/rerankers/index.d.ts +5 -0
  79. package/dist/vendor/lancedb/rerankers/index.js +19 -0
  80. package/dist/vendor/lancedb/rerankers/rrf.d.ts +14 -0
  81. package/dist/vendor/lancedb/rerankers/rrf.js +28 -0
  82. package/dist/vendor/lancedb/sanitize.d.ts +32 -0
  83. package/dist/vendor/lancedb/sanitize.js +544 -0
  84. package/dist/vendor/lancedb/scannable.d.ts +92 -0
  85. package/dist/vendor/lancedb/scannable.js +200 -0
  86. package/dist/vendor/lancedb/schema.d.ts +16 -0
  87. package/dist/vendor/lancedb/schema.js +387 -0
  88. package/dist/vendor/lancedb/table.d.ts +1069 -0
  89. package/dist/vendor/lancedb/table.js +498 -0
  90. package/dist/vendor/lancedb/util.d.ts +14 -0
  91. package/dist/vendor/lancedb/util.js +77 -0
  92. package/package.json +19 -7
  93. package/plugins/grepmax/.claude-plugin/plugin.json +1 -1
@@ -1,4 +1,20 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.runSimilar = runSimilar;
13
+ exports.handleVectorSimilar = handleVectorSimilar;
14
+ exports.runSurprises = runSurprises;
15
+ exports.handleVectorSurprises = handleVectorSurprises;
16
+ exports.registerVectorVerbs = registerVectorVerbs;
17
+ const query_timeout_1 = require("../utils/query-timeout");
2
18
  /**
3
19
  * Daemon-side handlers for the `vector.*` read verbs — the two commands whose
4
20
  * store work is a vector scan rather than a row select.
@@ -16,21 +32,6 @@
16
32
  * the verb and the command's in-process fallback call, so the two paths cannot
17
33
  * produce different output.
18
34
  */
19
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
20
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
21
- return new (P || (P = Promise))(function (resolve, reject) {
22
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
23
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
25
- step((generator = generator.apply(thisArg, _arguments || [])).next());
26
- });
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.runSimilar = runSimilar;
30
- exports.handleVectorSimilar = handleVectorSimilar;
31
- exports.runSurprises = runSurprises;
32
- exports.handleVectorSurprises = handleVectorSurprises;
33
- exports.registerVectorVerbs = registerVectorVerbs;
34
35
  const surprising_connections_1 = require("../analysis/surprising-connections");
35
36
  const ann_config_1 = require("../store/ann-config");
36
37
  const arrow_1 = require("../utils/arrow");
@@ -55,7 +56,7 @@ function runSimilar(deps, req) {
55
56
  ? `path = '${(0, filter_builder_1.escapeSqlString)(req.absPath)}'`
56
57
  : `array_contains(defined_symbols, '${(0, filter_builder_1.escapeSqlString)((_b = req.symbol) !== null && _b !== void 0 ? _b : "")}') AND ${(0, filter_builder_1.pathStartsWith)(`${req.projectRoot}/`)}`)
57
58
  .limit(1)
58
- .toArray();
59
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
59
60
  if (sourceRows.length === 0)
60
61
  return { status: "not-found" };
61
62
  const source = sourceRows[0];
@@ -76,7 +77,7 @@ function runSimilar(deps, req) {
76
77
  ])
77
78
  .where(pathScope)
78
79
  .limit(req.limit + 5) // fetch extra to account for self-filtering
79
- .toArray();
80
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
80
81
  // Filter out self and apply threshold
81
82
  const filtered = results.filter((raw) => {
82
83
  const r = raw;
@@ -8,6 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
12
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
13
+ var m = o[Symbol.asyncIterator], i;
14
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
15
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
16
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
+ };
11
18
  Object.defineProperty(exports, "__esModule", { value: true });
12
19
  exports.GraphBuilder = void 0;
13
20
  const languages_1 = require("../core/languages");
@@ -83,7 +90,7 @@ class GraphBuilder {
83
90
  ])
84
91
  .where(this.scopeWhere(`(array_contains(referenced_symbols, '${escaped}') OR array_contains(type_referenced_symbols, '${escaped}'))`))
85
92
  .limit(100)
86
- .toArray();
93
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
87
94
  // Cross-language phantom-edge guard. When the anchor family is known, drop
88
95
  // callers from a *different known* family; callers we can't classify (unknown
89
96
  // extension) are kept so a real edge is never lost. No anchor → no filter.
@@ -133,7 +140,7 @@ class GraphBuilder {
133
140
  ])
134
141
  .where(this.scopeWhere(`array_contains(defined_symbols, '${escaped}')`))
135
142
  .limit(1)
136
- .toArray();
143
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
137
144
  if (rows.length === 0)
138
145
  return [];
139
146
  const record = rows[0];
@@ -145,7 +152,7 @@ class GraphBuilder {
145
152
  .query()
146
153
  .select(["defined_symbols"])
147
154
  .where(this.scopeWhere(`path = '${(0, filter_builder_1.escapeSqlString)(String(record.path))}'`))
148
- .toArray();
155
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
149
156
  localDefinitions = localRows.flatMap((row) => (0, arrow_1.toArr)(row.defined_symbols));
150
157
  }
151
158
  return (0, arrow_1.toArr)(record.referenced_symbols).filter((name) => {
@@ -183,7 +190,7 @@ class GraphBuilder {
183
190
  ])
184
191
  .where(this.scopeWhere(`array_contains(defined_symbols, '${escaped}')`))
185
192
  .limit(1)
186
- .toArray();
193
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
187
194
  const center = centerRows.length > 0
188
195
  ? this.mapRowToNode(centerRows[0], symbol, "center")
189
196
  : null;
@@ -214,7 +221,7 @@ class GraphBuilder {
214
221
  "complexity",
215
222
  ])
216
223
  .limit(25)
217
- .toArray();
224
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
218
225
  const memberNames = (0, arrow_1.toArr)((_a = centerRows[0]) === null || _a === void 0 ? void 0 : _a.member_referenced_symbols);
219
226
  const content = String((_c = (_b = centerRows[0]) === null || _b === void 0 ? void 0 : _b.content) !== null && _c !== void 0 ? _c : "");
220
227
  const bareCall = new RegExp(`(?<![\\w.$])${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*\\(`).test(content);
@@ -266,20 +273,30 @@ class GraphBuilder {
266
273
  }
267
274
  getImporters(symbol) {
268
275
  return __awaiter(this, void 0, void 0, function* () {
276
+ var _a, e_1, _b, _c;
269
277
  const table = yield this.db.ensureTable();
270
278
  const escaped = (0, filter_builder_1.escapeSqlString)(symbol);
271
- // No .limit() here: LIKE + limit deadlocks in @lancedb 0.27.x when more
272
- // rows match than the limit (verified). Unlimited scan is fast; cap in JS.
273
- const rows = yield (0, query_timeout_1.withQueryTimeout)(table
279
+ const rows = (0, query_timeout_1.streamQueryRows)(table
274
280
  .query()
275
281
  .select(["path"])
276
- .where(this.scopeWhere(`content LIKE '%import%${escaped}%'`))
277
- .toArray(), `content LIKE %import%${symbol}% (importers)`);
282
+ .where(this.scopeWhere(`content LIKE '%import%${escaped}%'`)), `content LIKE %import%${symbol}% (importers)`);
278
283
  const files = new Set();
279
- for (const row of rows) {
280
- files.add(String(row.path || ""));
281
- if (files.size >= 100)
282
- break;
284
+ try {
285
+ for (var _d = true, rows_1 = __asyncValues(rows), rows_1_1; rows_1_1 = yield rows_1.next(), _a = rows_1_1.done, !_a; _d = true) {
286
+ _c = rows_1_1.value;
287
+ _d = false;
288
+ const row = _c;
289
+ files.add(String(row.path || ""));
290
+ if (files.size >= 100)
291
+ break;
292
+ }
293
+ }
294
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
295
+ finally {
296
+ try {
297
+ if (!_d && !_a && (_b = rows_1.return)) yield _b.call(rows_1);
298
+ }
299
+ finally { if (e_1) throw e_1.error; }
283
300
  }
284
301
  return Array.from(files);
285
302
  });
@@ -411,7 +428,7 @@ class GraphBuilder {
411
428
  // No anchor → keep the cheap single-row fetch. With one, pull a few
412
429
  // candidates so we can pick the same-family definition instead of guessing.
413
430
  .limit(anchorFamily ? 25 : 1)
414
- .toArray();
431
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
415
432
  if (rows.length === 0)
416
433
  return null;
417
434
  let r = rows[0];
@@ -455,7 +472,7 @@ class GraphBuilder {
455
472
  .select(["path", "defined_symbols", "referenced_symbols"])
456
473
  .where(this.scopeWhere(`(${orClause})`))
457
474
  .limit(100000)
458
- .toArray();
475
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
459
476
  const toArray = (val) => {
460
477
  if (val && typeof val.toArray === "function")
461
478
  return val.toArray();
@@ -45,7 +45,7 @@ function resolveTargetSymbols(target, vectorDb, projectRoot) {
45
45
  .query()
46
46
  .select(["defined_symbols"])
47
47
  .where(`path = '${(0, filter_builder_1.escapeSqlString)(absPath)}'`)
48
- .toArray();
48
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
49
49
  const symbols = new Set();
50
50
  for (const chunk of chunks) {
51
51
  for (const s of (0, arrow_1.toArr)(chunk.defined_symbols)) {
@@ -88,7 +88,7 @@ function resolveSymbolFamilies(symbols, vectorDb, projectRoot, excludePrefixes,
88
88
  .select(["path"])
89
89
  .where(`array_contains(defined_symbols, '${(0, filter_builder_1.escapeSqlString)(sym)}') AND ${pathScope}`)
90
90
  .limit(25)
91
- .toArray();
91
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
92
92
  const file = String(((_a = rows[0]) === null || _a === void 0 ? void 0 : _a.path) || "");
93
93
  families.set(sym, file ? (0, languages_1.languageFamilyForPath)(file) : null);
94
94
  }
@@ -117,7 +117,7 @@ function expandFileSymbols(symbols, vectorDb, projectRoot, excludePrefixes) {
117
117
  .select(["path"])
118
118
  .where(where)
119
119
  .limit(1)
120
- .toArray();
120
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
121
121
  if (defRows.length === 0)
122
122
  return symbols;
123
123
  const filePath = String(defRows[0].path);
@@ -126,7 +126,7 @@ function expandFileSymbols(symbols, vectorDb, projectRoot, excludePrefixes) {
126
126
  .query()
127
127
  .select(["defined_symbols"])
128
128
  .where(`path = '${(0, filter_builder_1.escapeSqlString)(filePath)}'`)
129
- .toArray();
129
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
130
130
  const expanded = new Set(symbols);
131
131
  for (const row of fileRows) {
132
132
  for (const s of (0, arrow_1.toArr)(row.defined_symbols)) {
@@ -211,13 +211,14 @@ function findImportFallbackTests(originalSymbols, vectorDb, projectRoot, exclude
211
211
  // that mentions them, drowning the answer in false positives.
212
212
  for (const sym of originalSymbols) {
213
213
  const family = (_a = symbolFamilies === null || symbolFamilies === void 0 ? void 0 : symbolFamilies.get(sym)) !== null && _a !== void 0 ? _a : null;
214
- // No .limit() here: LIKE + limit deadlocks in @lancedb 0.27.x when more
215
- // rows match than the limit (verified). Unlimited scan is fast; cap in JS.
214
+ // The pinned SDK passes the native LIKE+limit regression; bound rows at
215
+ // the same cap the old unlimited scan applied after materializing them.
216
216
  const rows = yield (0, query_timeout_1.withQueryTimeout)(table
217
217
  .query()
218
218
  .select(["path"])
219
219
  .where(`content LIKE '%${(0, filter_builder_1.escapeSqlString)(sym)}%' AND ${pathScope}`)
220
- .toArray(), `content LIKE %${sym}% (test fallback)`);
220
+ .limit(500)
221
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS), `content LIKE %${sym}% (test fallback)`);
221
222
  for (const row of rows.slice(0, 500)) {
222
223
  const p = String(row.path || "");
223
224
  if (isTestPath(p) && familyMatchesPath(family, p))
@@ -286,7 +287,7 @@ function findDependentsDetailed(symbols_1, vectorDb_1, projectRoot_1, excludePat
286
287
  .select(["path"])
287
288
  .where(`(array_contains(referenced_symbols, '${(0, filter_builder_1.escapeSqlString)(sym)}') OR array_contains(type_referenced_symbols, '${(0, filter_builder_1.escapeSqlString)(sym)}')) AND ${pathScope}`)
288
289
  .limit(200)
289
- .toArray();
290
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
290
291
  for (const row of rows) {
291
292
  const p = String(row.path || "");
292
293
  if (excludePaths === null || excludePaths === void 0 ? void 0 : excludePaths.has(p))
@@ -50,10 +50,10 @@ const fs = __importStar(require("node:fs"));
50
50
  const path = __importStar(require("node:path"));
51
51
  const config_1 = require("../../config");
52
52
  const GLOBAL_CONFIG_PATH = path.join(config_1.PATHS.globalRoot, "config.json");
53
- function readGlobalConfig() {
53
+ function readGlobalConfig(home) {
54
54
  const defaultEmbedMode = process.arch === "arm64" && process.platform === "darwin" ? "gpu" : "cpu";
55
55
  try {
56
- const raw = fs.readFileSync(GLOBAL_CONFIG_PATH, "utf-8");
56
+ const raw = fs.readFileSync(home ? path.join(home, "config.json") : GLOBAL_CONFIG_PATH, "utf-8");
57
57
  const parsed = JSON.parse(raw);
58
58
  // Ensure embedMode has a default even if missing from stored config
59
59
  if (!parsed.embedMode)
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLlmConfig = getLlmConfig;
4
+ const node_net_1 = require("node:net");
4
5
  const DEFAULT_MODEL = "/Volumes/External/models/huggingface/hub/models--unsloth--Qwen3.5-35B-A3B-GGUF/Qwen3.5-35B-A3B-Q4_K_M.gguf";
5
6
  function envInt(key, fallback) {
6
7
  const v = process.env[key];
@@ -11,10 +12,15 @@ function envInt(key, fallback) {
11
12
  }
12
13
  function getLlmConfig() {
13
14
  var _a, _b, _c, _d;
15
+ const requestedHost = (_a = process.env.GMAX_LLM_HOST) !== null && _a !== void 0 ? _a : "127.0.0.1";
16
+ const host = requestedHost === "localhost" ? "127.0.0.1" : requestedHost;
17
+ if (!(host === "::1" || ((0, node_net_1.isIP)(host) === 4 && host.startsWith("127.")))) {
18
+ throw new Error("gmax is local-only: GMAX_LLM_HOST must be a loopback address");
19
+ }
14
20
  return {
15
- model: (_a = process.env.GMAX_LLM_MODEL) !== null && _a !== void 0 ? _a : DEFAULT_MODEL,
16
- binary: (_b = process.env.GMAX_LLM_BINARY) !== null && _b !== void 0 ? _b : "llama-server",
17
- host: (_c = process.env.GMAX_LLM_HOST) !== null && _c !== void 0 ? _c : "127.0.0.1",
21
+ model: (_b = process.env.GMAX_LLM_MODEL) !== null && _b !== void 0 ? _b : DEFAULT_MODEL,
22
+ binary: (_c = process.env.GMAX_LLM_BINARY) !== null && _c !== void 0 ? _c : "llama-server",
23
+ host,
18
24
  port: envInt("GMAX_LLM_PORT", 8079),
19
25
  ctxSize: envInt("GMAX_LLM_CTX_SIZE", 16384),
20
26
  ngl: envInt("GMAX_LLM_NGL", 99),
@@ -49,6 +49,7 @@ const path = __importStar(require("node:path"));
49
49
  const impact_1 = require("../graph/impact");
50
50
  const arrow_1 = require("../utils/arrow");
51
51
  const filter_builder_1 = require("../utils/filter-builder");
52
+ const query_timeout_1 = require("../utils/query-timeout");
52
53
  // ---------------------------------------------------------------------------
53
54
  // Tool definitions (OpenAI function-calling format)
54
55
  // ---------------------------------------------------------------------------
@@ -247,7 +248,7 @@ function executePeek(args, ctx) {
247
248
  .select(["is_exported", "start_line", "end_line"])
248
249
  .where(`array_contains(defined_symbols, '${(0, filter_builder_1.escapeSqlString)(symbol)}') AND ${(0, filter_builder_1.pathStartsWith)(prefix)}`)
249
250
  .limit(1)
250
- .toArray();
251
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
251
252
  const exported = metaRows.length > 0 && Boolean(metaRows[0].is_exported);
252
253
  const startLine = metaRows.length > 0
253
254
  ? Number(metaRows[0].start_line || 0)
@@ -333,7 +334,7 @@ function executeRelated(args, ctx) {
333
334
  "type_referenced_symbols",
334
335
  ])
335
336
  .where(`path = '${(0, filter_builder_1.escapeSqlString)(absPath)}'`)
336
- .toArray();
337
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
337
338
  if (fileChunks.length === 0)
338
339
  return "(file not indexed)";
339
340
  const definedHere = new Set();
@@ -356,7 +357,7 @@ function executeRelated(args, ctx) {
356
357
  .select(["path"])
357
358
  .where(`array_contains(defined_symbols, '${(0, filter_builder_1.escapeSqlString)(sym)}')`)
358
359
  .limit(3)
359
- .toArray();
360
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
360
361
  for (const row of rows) {
361
362
  const p = String(row.path || "");
362
363
  if (p === absPath)
@@ -372,7 +373,7 @@ function executeRelated(args, ctx) {
372
373
  .select(["path"])
373
374
  .where(`(array_contains(referenced_symbols, '${(0, filter_builder_1.escapeSqlString)(sym)}') OR array_contains(type_referenced_symbols, '${(0, filter_builder_1.escapeSqlString)(sym)}'))`)
374
375
  .limit(20)
375
- .toArray();
376
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
376
377
  for (const row of rows) {
377
378
  const p = String(row.path || "");
378
379
  if (p === absPath)
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MCP_READ_OUTPUT_SCHEMAS = exports.compactionSchema = void 0;
4
+ exports.traceResult = traceResult;
5
+ exports.deadResult = deadResult;
6
+ const zod_1 = require("zod");
7
+ const location = zod_1.z.object({
8
+ path: zod_1.z.string(),
9
+ line: zod_1.z.number().int().positive().describe("One-based source line"),
10
+ });
11
+ const graphNode = zod_1.z.object({
12
+ symbol: zod_1.z.string(),
13
+ location: location.nullable(),
14
+ role: zod_1.z.string(),
15
+ resolution: zod_1.z.enum(["indexed", "not_indexed", "ambiguous_member"]),
16
+ edgeKind: zod_1.z.enum(["free", "member", "type"]).optional(),
17
+ confidence: zod_1.z.enum(["EXTRACTED", "INFERRED"]).optional(),
18
+ });
19
+ const search = {
20
+ schemaVersion: zod_1.z.literal(1),
21
+ query: zod_1.z.string(),
22
+ roots: zod_1.z.array(zod_1.z.string()),
23
+ warnings: zod_1.z.array(zod_1.z.string()),
24
+ matches: zod_1.z
25
+ .array(zod_1.z.object({
26
+ path: zod_1.z.string(),
27
+ startLine: zod_1.z.number().int().positive(),
28
+ endLine: zod_1.z.number().int().positive(),
29
+ symbols: zod_1.z.array(zod_1.z.string()),
30
+ role: zod_1.z.string(),
31
+ score: zod_1.z
32
+ .number()
33
+ .nullable()
34
+ .describe("Search score; null when unavailable"),
35
+ }))
36
+ .max(50),
37
+ };
38
+ exports.compactionSchema = zod_1.z.object({
39
+ status: zod_1.z.enum(["completed", "skipped", "failed"]),
40
+ at: zod_1.z.number(),
41
+ attempts: zod_1.z.number(),
42
+ elapsedMs: zod_1.z.number(),
43
+ reason: zod_1.z.string().optional(),
44
+ logicalBytes: zod_1.z.number().optional(),
45
+ diskBytesBefore: zod_1.z.number().optional(),
46
+ diskBytesAfter: zod_1.z.number().optional(),
47
+ freeBytesBefore: zod_1.z.number().optional(),
48
+ freeBytesAfter: zod_1.z.number().optional(),
49
+ bytesReclaimed: zod_1.z.number().optional(),
50
+ });
51
+ const embedding = zod_1.z.object({
52
+ tier: zod_1.z.string(),
53
+ vectorDim: zod_1.z.number(),
54
+ fingerprint: zod_1.z.string(),
55
+ });
56
+ /** Only tools with a complete success contract advertise an output schema. */
57
+ exports.MCP_READ_OUTPUT_SCHEMAS = {
58
+ semantic_search: search,
59
+ trace_calls: {
60
+ schemaVersion: zod_1.z.literal(1),
61
+ symbol: zod_1.z.string(),
62
+ root: zod_1.z.string(),
63
+ found: zod_1.z.boolean(),
64
+ center: graphNode.nullable(),
65
+ callers: zod_1.z.array(zod_1.z.object({
66
+ node: graphNode,
67
+ depth: zod_1.z.number().int().positive(),
68
+ parentIndex: zod_1.z
69
+ .number()
70
+ .int()
71
+ .nonnegative()
72
+ .nullable()
73
+ .describe("Index of the parent in callers; null for a direct caller of center"),
74
+ })),
75
+ callees: zod_1.z.array(graphNode).max(15),
76
+ importers: zod_1.z.array(zod_1.z.string()).max(10),
77
+ omittedCallees: zod_1.z.number().int().nonnegative(),
78
+ omittedImporters: zod_1.z.number().int().nonnegative(),
79
+ approximate: zod_1.z.literal(true),
80
+ },
81
+ dead: {
82
+ schemaVersion: zod_1.z.literal(1),
83
+ symbol: zod_1.z.string(),
84
+ root: zod_1.z.string(),
85
+ status: zod_1.z.enum(["not_found", "public_export", "dead", "live"]),
86
+ definition: location.nullable(),
87
+ isExported: zod_1.z.boolean(),
88
+ callerCount: zod_1.z.number().int().nonnegative(),
89
+ callers: zod_1.z.array(location),
90
+ approximate: zod_1.z.literal(true),
91
+ },
92
+ index_status: {
93
+ schemaVersion: zod_1.z.literal(1),
94
+ root: zod_1.z.string(),
95
+ store: zod_1.z.string(),
96
+ secondary: zod_1.z.boolean(),
97
+ chunks: zod_1.z.number().int().nonnegative(),
98
+ files: zod_1.z.number().int().nonnegative(),
99
+ projects: zod_1.z.number().int().nonnegative(),
100
+ embedding: zod_1.z.object({
101
+ state: zod_1.z.string(),
102
+ configured: embedding,
103
+ built: embedding.nullable(),
104
+ }),
105
+ watcher: zod_1.z.object({
106
+ status: zod_1.z.string(),
107
+ indexState: zod_1.z
108
+ .object({
109
+ indexing: zod_1.z.boolean(),
110
+ pendingFiles: zod_1.z.number(),
111
+ verifying: zod_1.z.boolean().optional(),
112
+ failedFiles: zod_1.z.number().optional(),
113
+ degraded: zod_1.z.boolean().optional(),
114
+ watcherMode: zod_1.z.enum(["native", "polling", "recovering"]).optional(),
115
+ catchupRunning: zod_1.z.boolean().optional(),
116
+ lastReconciledAt: zod_1.z.number().optional(),
117
+ overflowCount: zod_1.z.number().optional(),
118
+ catchupMs: zod_1.z.number().optional(),
119
+ })
120
+ .nullable(),
121
+ }),
122
+ compaction: exports.compactionSchema.nullable(),
123
+ },
124
+ };
125
+ function nodeResult(node) {
126
+ return Object.assign(Object.assign({ symbol: node.symbol, location: node.file ? { path: node.file, line: node.line + 1 } : null, role: node.role, resolution: node.file
127
+ ? "indexed"
128
+ : node.resolution === "ambiguous-member"
129
+ ? "ambiguous_member"
130
+ : "not_indexed" }, (node.edgeKind ? { edgeKind: node.edgeKind } : {})), (node.confidence ? { confidence: node.confidence } : {}));
131
+ }
132
+ function traceResult(symbol, root, graph) {
133
+ const callers = [];
134
+ function visit(trees, depth, parentIndex) {
135
+ for (const tree of trees) {
136
+ const index = callers.length;
137
+ callers.push({ node: nodeResult(tree.node), depth, parentIndex });
138
+ visit(tree.callers, depth + 1, index);
139
+ }
140
+ }
141
+ visit(graph.callerTree, 1, null);
142
+ const importers = graph.importers.filter((p) => { var _a; return p !== ((_a = graph.center) === null || _a === void 0 ? void 0 : _a.file); });
143
+ return {
144
+ schemaVersion: 1,
145
+ symbol,
146
+ root,
147
+ found: graph.center !== null,
148
+ center: graph.center ? nodeResult(graph.center) : null,
149
+ callers,
150
+ callees: graph.callees.slice(0, 15).map(nodeResult),
151
+ importers: importers.slice(0, 10),
152
+ omittedCallees: Math.max(0, graph.callees.length - 15),
153
+ omittedImporters: Math.max(0, importers.length - 10),
154
+ approximate: true,
155
+ };
156
+ }
157
+ function deadResult(symbol, root, facts) {
158
+ return {
159
+ schemaVersion: 1,
160
+ symbol,
161
+ root,
162
+ status: !facts.found
163
+ ? "not_found"
164
+ : facts.callerCount > 0
165
+ ? "live"
166
+ : facts.isExported
167
+ ? "public_export"
168
+ : "dead",
169
+ definition: facts.found
170
+ ? { path: facts.defPath, line: facts.defLine + 1 }
171
+ : null,
172
+ isExported: facts.isExported,
173
+ callerCount: facts.callerCount,
174
+ callers: facts.topCallers.map((c) => ({ path: c.file, line: c.line + 1 })),
175
+ approximate: true,
176
+ };
177
+ }
@@ -56,6 +56,7 @@ const fs = __importStar(require("node:fs"));
56
56
  const path = __importStar(require("node:path"));
57
57
  const config_1 = require("../../config");
58
58
  const filter_builder_1 = require("../utils/filter-builder");
59
+ const query_timeout_1 = require("../utils/query-timeout");
59
60
  const DEFAULT_DAMPING = 0.85;
60
61
  const DEFAULT_MAX_ITER = 50;
61
62
  const DEFAULT_TOL = 1e-6;
@@ -195,7 +196,7 @@ function buildGraphFromDb(db, pathPrefix) {
195
196
  .select(["defined_symbols", "referenced_symbols"])
196
197
  .where((0, filter_builder_1.pathStartsWith)(prefix))
197
198
  .limit(exports.PAGERANK_ROW_LIMIT)
198
- .toArray();
199
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
199
200
  const nodes = new Set();
200
201
  const edges = new Map();
201
202
  for (const row of rows) {
@@ -16,6 +16,7 @@ const config_1 = require("../../config");
16
16
  const ann_config_1 = require("../store/ann-config");
17
17
  const filter_builder_1 = require("../utils/filter-builder");
18
18
  const logger_1 = require("../utils/logger");
19
+ const query_timeout_1 = require("../utils/query-timeout");
19
20
  const pool_1 = require("../workers/pool");
20
21
  const intent_1 = require("./intent");
21
22
  const pagerank_1 = require("./pagerank");
@@ -487,7 +488,7 @@ class Searcher {
487
488
  if (whereClause) {
488
489
  vectorQuery = vectorQuery.where(whereClause);
489
490
  }
490
- const vectorResults = (yield vectorQuery.toArray()).map((r) => (Object.assign({}, r)));
491
+ const vectorResults = (yield vectorQuery.toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS)).map((r) => (Object.assign({}, r)));
491
492
  let ftsResults = [];
492
493
  let ftsSearchFailed = false;
493
494
  if (this.ftsAvailable) {
@@ -499,7 +500,7 @@ class Searcher {
499
500
  if (whereClause) {
500
501
  ftsQuery = ftsQuery.where(whereClause);
501
502
  }
502
- ftsResults = (yield ftsQuery.toArray()).map((r) => (Object.assign({}, r)));
503
+ ftsResults = (yield ftsQuery.toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS)).map((r) => (Object.assign({}, r)));
503
504
  }
504
505
  catch (e) {
505
506
  ftsSearchFailed = true;
@@ -742,7 +743,7 @@ class Searcher {
742
743
  .select(["id", "colbert", "colbert_scale", "doc_token_ids"])
743
744
  .where(`id IN (${rerankIds.join(",")})`)
744
745
  .limit(rerankIds.length)
745
- .toArray();
746
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
746
747
  const colbertMap = new Map(colbertRows.map((r) => [r.id, r]));
747
748
  for (const doc of rerankCandidates) {
748
749
  const extra = colbertMap.get(doc.id);
@@ -876,7 +877,7 @@ class Searcher {
876
877
  ])
877
878
  .where(`id IN (${finalIds.join(",")})`)
878
879
  .limit(finalIds.length)
879
- .toArray();
880
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
880
881
  const displayMap = new Map(displayRows.map((r) => [r.id, r]));
881
882
  for (const item of diversified) {
882
883
  const extra = displayMap.get(item.record.id);
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getStoredSkeleton = getStoredSkeleton;
13
13
  const filter_builder_1 = require("../utils/filter-builder");
14
+ const query_timeout_1 = require("../utils/query-timeout");
14
15
  function getStoredSkeleton(db, filePath) {
15
16
  return __awaiter(this, void 0, void 0, function* () {
16
17
  try {
@@ -21,7 +22,7 @@ function getStoredSkeleton(db, filePath) {
21
22
  .select(["file_skeleton"])
22
23
  .where(`path = '${(0, filter_builder_1.escapeSqlString)(filePath)}' AND is_anchor = true`)
23
24
  .limit(1)
24
- .toArray();
25
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
25
26
  if (results.length > 0) {
26
27
  const skel = results[0].file_skeleton;
27
28
  if (typeof skel === "string" && skel.length > 0) {
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Session = exports.Index = exports.connect = void 0;
37
+ const path = __importStar(require("node:path"));
38
+ // Source tests use the pinned dev dependency. Compiled consumers use the
39
+ // unchanged official runtime copied at build time, with root native packages.
40
+ const base = path.resolve(__dirname, "../..");
41
+ const sdk = require(path.basename(base) === "src"
42
+ ? "@lancedb/lancedb"
43
+ : path.join(base, "vendor", "lancedb", "index.js"));
44
+ exports.connect = sdk.connect;
45
+ exports.Index = sdk.Index;
46
+ exports.Session = sdk.Session;