grepmax 0.26.42 → 0.26.44

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 (95) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/NOTICE +6 -0
  3. package/README.md +7 -1
  4. package/dist/bin.js +4 -0
  5. package/dist/commands/doctor.js +23 -33
  6. package/dist/commands/mcp.js +144 -67
  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 +35 -19
  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 +36 -9
  17. package/dist/lib/daemon/graph-handler.js +33 -33
  18. package/dist/lib/daemon/ipc-handler.js +11 -10
  19. package/dist/lib/daemon/rows-handler.js +13 -51
  20. package/dist/lib/daemon/vector-handler.js +18 -17
  21. package/dist/lib/graph/graph-builder.js +33 -16
  22. package/dist/lib/graph/impact.js +9 -8
  23. package/dist/lib/index/index-config.js +2 -2
  24. package/dist/lib/llm/config.js +9 -3
  25. package/dist/lib/llm/tools.js +5 -4
  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/compaction-result.js +35 -0
  30. package/dist/lib/store/lance-sdk.js +46 -0
  31. package/dist/lib/store/vector-db.js +118 -31
  32. package/dist/lib/utils/cross-project.js +2 -2
  33. package/dist/lib/utils/doctor-optimize.js +81 -0
  34. package/dist/lib/utils/project-registry.js +8 -8
  35. package/dist/lib/utils/query-timeout.js +53 -13
  36. package/dist/lib/utils/store-access.js +6 -5
  37. package/dist/lib/utils/store-context.js +102 -0
  38. package/dist/lib/utils/stores.js +1 -1
  39. package/dist/vendor/lancedb/LICENSE +202 -0
  40. package/dist/vendor/lancedb/NODEJS_THIRD_PARTY_LICENSES.md +668 -0
  41. package/dist/vendor/lancedb/RUST_THIRD_PARTY_LICENSES.html +14607 -0
  42. package/dist/vendor/lancedb/arrow.d.ts +296 -0
  43. package/dist/vendor/lancedb/arrow.js +1145 -0
  44. package/dist/vendor/lancedb/arrow_type.d.ts +9 -0
  45. package/dist/vendor/lancedb/arrow_type.js +29 -0
  46. package/dist/vendor/lancedb/connection.d.ts +508 -0
  47. package/dist/vendor/lancedb/connection.js +298 -0
  48. package/dist/vendor/lancedb/embedding/embedding_function.d.ts +103 -0
  49. package/dist/vendor/lancedb/embedding/embedding_function.js +192 -0
  50. package/dist/vendor/lancedb/embedding/index.d.ts +37 -0
  51. package/dist/vendor/lancedb/embedding/index.js +108 -0
  52. package/dist/vendor/lancedb/embedding/openai.d.ts +16 -0
  53. package/dist/vendor/lancedb/embedding/openai.js +81 -0
  54. package/dist/vendor/lancedb/embedding/registry.d.ts +94 -0
  55. package/dist/vendor/lancedb/embedding/registry.js +221 -0
  56. package/dist/vendor/lancedb/embedding/transformers.d.ts +36 -0
  57. package/dist/vendor/lancedb/embedding/transformers.js +110 -0
  58. package/dist/vendor/lancedb/header.d.ts +162 -0
  59. package/dist/vendor/lancedb/header.js +217 -0
  60. package/dist/vendor/lancedb/index.d.ts +246 -0
  61. package/dist/vendor/lancedb/index.js +176 -0
  62. package/dist/vendor/lancedb/indices.d.ts +721 -0
  63. package/dist/vendor/lancedb/indices.js +166 -0
  64. package/dist/vendor/lancedb/license_header.txt +2 -0
  65. package/dist/vendor/lancedb/materialized_view.d.ts +69 -0
  66. package/dist/vendor/lancedb/materialized_view.js +112 -0
  67. package/dist/vendor/lancedb/merge.d.ts +104 -0
  68. package/dist/vendor/lancedb/merge.js +120 -0
  69. package/dist/vendor/lancedb/native.d.ts +1193 -0
  70. package/dist/vendor/lancedb/native.js +688 -0
  71. package/dist/vendor/lancedb/oauth.d.ts +66 -0
  72. package/dist/vendor/lancedb/oauth.js +15 -0
  73. package/dist/vendor/lancedb/otel.d.ts +26 -0
  74. package/dist/vendor/lancedb/otel.js +114 -0
  75. package/dist/vendor/lancedb/permutation.d.ts +143 -0
  76. package/dist/vendor/lancedb/permutation.js +184 -0
  77. package/dist/vendor/lancedb/provenance.json +6 -0
  78. package/dist/vendor/lancedb/query.d.ts +663 -0
  79. package/dist/vendor/lancedb/query.js +966 -0
  80. package/dist/vendor/lancedb/rerankers/index.d.ts +5 -0
  81. package/dist/vendor/lancedb/rerankers/index.js +19 -0
  82. package/dist/vendor/lancedb/rerankers/rrf.d.ts +14 -0
  83. package/dist/vendor/lancedb/rerankers/rrf.js +28 -0
  84. package/dist/vendor/lancedb/sanitize.d.ts +32 -0
  85. package/dist/vendor/lancedb/sanitize.js +544 -0
  86. package/dist/vendor/lancedb/scannable.d.ts +92 -0
  87. package/dist/vendor/lancedb/scannable.js +200 -0
  88. package/dist/vendor/lancedb/schema.d.ts +16 -0
  89. package/dist/vendor/lancedb/schema.js +387 -0
  90. package/dist/vendor/lancedb/table.d.ts +1069 -0
  91. package/dist/vendor/lancedb/table.js +498 -0
  92. package/dist/vendor/lancedb/util.d.ts +14 -0
  93. package/dist/vendor/lancedb/util.js +77 -0
  94. package/package.json +19 -7
  95. package/plugins/grepmax/.claude-plugin/plugin.json +1 -1
@@ -1,36 +1,4 @@
1
1
  "use strict";
2
- /**
3
- * Daemon-side handlers for the `rows.*` read verbs.
4
- *
5
- * These serve the commands whose store work is a plain row select: `symbols`,
6
- * `project`, `extract`, `related`, `log`, `skeleton`. The daemon runs the query
7
- * against its already-warm VectorDB and returns the finished answer; the client
8
- * renders it and does anything tied to its own cwd, git, or filesystem.
9
- *
10
- * Every exported `run*` function is the *shared* implementation: the verb
11
- * handler calls it with the daemon's VectorDB, and the command's in-process
12
- * fallback calls the same function with a VectorDB it opened itself. That is
13
- * what makes the two paths byte-identical — there is only one implementation of
14
- * each query and each aggregation, and neither path can drift from the other.
15
- *
16
- * Two things are deliberately *not* raw row proxies:
17
- *
18
- * - `rows.symbols` returns the aggregated symbol table, not the 2000–10000 rows
19
- * the select produces. The aggregation is pure, so moving it daemon-side
20
- * cannot change the answer, and it turns a multi-megabyte JSON line into a
21
- * list bounded by `--limit`.
22
- * - `rows.project` likewise returns the overview, not the rows. `project.ts`
23
- * selects up to 200 000 rows including two symbol-array columns; on the
24
- * platform project (266 753 chunks) proxying those rows would push hundreds
25
- * of megabytes through the daemon's event loop for a summary that fits in a
26
- * few kilobytes. The plan's own reasoning — "verbs at the library-function
27
- * boundary, not a row proxy" — applies here more than anywhere.
28
- *
29
- * `rows.locate` *is* a row select, because its callers need the rows: extract
30
- * reads the file body at the returned line range, log feeds the paths to git,
31
- * related counts them. It is batched (an array of matchers, one response) so
32
- * `related`'s per-symbol loop costs one round trip instead of hundreds.
33
- */
34
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
35
3
  if (k2 === undefined) k2 = k;
36
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -92,13 +60,14 @@ exports.findFileBySymbol = findFileBySymbol;
92
60
  exports.readRows = readRows;
93
61
  exports.handleRowsSkeleton = handleRowsSkeleton;
94
62
  exports.registerRowsVerbs = registerRowsVerbs;
63
+ const query_timeout_1 = require("../utils/query-timeout");
95
64
  const callsites_1 = require("../graph/callsites");
96
65
  const retriever_1 = require("../skeleton/retriever");
97
66
  const arrow_1 = require("../utils/arrow");
98
67
  const filter_builder_1 = require("../utils/filter-builder");
99
68
  const path_containment_1 = require("../utils/path-containment");
100
69
  const project_registry_1 = require("../utils/project-registry");
101
- const query_timeout_1 = require("../utils/query-timeout");
70
+ const query_timeout_2 = require("../utils/query-timeout");
102
71
  const scope_filter_1 = require("../utils/scope-filter");
103
72
  const read_verbs_1 = require("./read-verbs");
104
73
  /**
@@ -109,10 +78,10 @@ const read_verbs_1 = require("./read-verbs");
109
78
  * only from a `withStoreRead` `inProcess` callback — i.e. only when nothing is
110
79
  * listening on the daemon socket.
111
80
  */
112
- function withLocalStore(lancedbDir, fn) {
81
+ function withLocalStore(lancedbDir, fn, vectorDim) {
113
82
  return __awaiter(this, void 0, void 0, function* () {
114
83
  const { VectorDB } = yield Promise.resolve().then(() => __importStar(require("../store/vector-db")));
115
- const db = new VectorDB(lancedbDir);
84
+ const db = new VectorDB(lancedbDir, vectorDim);
116
85
  try {
117
86
  return yield fn({ vectorDb: db });
118
87
  }
@@ -244,7 +213,7 @@ function runSymbols(deps, req) {
244
213
  if (req.pathPrefix) {
245
214
  query = query.where((0, filter_builder_1.pathStartsWith)((0, filter_builder_1.normalizePath)(req.pathPrefix)));
246
215
  }
247
- const rows = yield query.toArray();
216
+ const rows = yield query.toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
248
217
  const map = new Map();
249
218
  for (const row of rows) {
250
219
  const defs = toStringArray(row.defined_symbols);
@@ -321,7 +290,7 @@ function runProject(deps, projectRoot) {
321
290
  ])
322
291
  .where((0, filter_builder_1.pathStartsWith)(prefix))
323
292
  .limit(200000)
324
- .toArray();
293
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
325
294
  const nodePath = yield Promise.resolve().then(() => __importStar(require("node:path")));
326
295
  const files = new Set();
327
296
  const extCounts = new Map();
@@ -420,13 +389,7 @@ const LOCATE_COLUMNS = new Set([
420
389
  "id",
421
390
  ]);
422
391
  const ARRAY_COLUMNS = new Set(["defined_symbols", "referenced_symbols"]);
423
- /**
424
- * Upper bound on rows one matcher may return when the caller sets no limit.
425
- * `related`'s `content LIKE` scan deliberately has no `.limit()` — the limit
426
- * pushdown deadlocks on that shape (see query-timeout.ts) — and its JS loop
427
- * caps at `--limit` distinct paths, so a wire cap only bites on a query that
428
- * would already have been unreasonable to render.
429
- */
392
+ /** Upper bound applied by the native query before materialization/wire output. */
430
393
  exports.MAX_LOCATE_ROWS = 5000;
431
394
  function matchCondition(match) {
432
395
  switch (match.kind) {
@@ -477,7 +440,7 @@ function normalizeRow(row, select) {
477
440
  /** Run a batch of row selects, one result array per matcher, order preserved. */
478
441
  function runLocate(deps, req) {
479
442
  return __awaiter(this, void 0, void 0, function* () {
480
- var _a;
443
+ var _a, _b;
481
444
  const table = yield tableOf(deps);
482
445
  const scoped = req.scoped !== false;
483
446
  const pathScope = (0, scope_filter_1.buildScopeWhere)(req.scope);
@@ -488,11 +451,10 @@ function runLocate(deps, req) {
488
451
  .query()
489
452
  .select(req.select)
490
453
  .where(scoped ? `${where} AND ${pathScope}` : where);
491
- if (req.limit !== undefined)
492
- query = query.limit(req.limit);
493
- const rows = yield (0, query_timeout_1.withQueryTimeout)(query.toArray(), label);
454
+ query = query.limit((_a = req.limit) !== null && _a !== void 0 ? _a : exports.MAX_LOCATE_ROWS);
455
+ const rows = yield (0, query_timeout_2.withQueryTimeout)(query.toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS), label);
494
456
  results.push(rows
495
- .slice(0, (_a = req.limit) !== null && _a !== void 0 ? _a : exports.MAX_LOCATE_ROWS)
457
+ .slice(0, (_b = req.limit) !== null && _b !== void 0 ? _b : exports.MAX_LOCATE_ROWS)
496
458
  .map((row) => normalizeRow(row, req.select)));
497
459
  }
498
460
  return results;
@@ -579,7 +541,7 @@ function findFileBySymbol(db, symbol, projectRoot) {
579
541
  .search(symbol)
580
542
  .where((0, filter_builder_1.pathStartsWith)(`${projectRoot}/`))
581
543
  .limit(10)
582
- .toArray();
544
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
583
545
  for (const result of results) {
584
546
  const defined = result.defined_symbols;
585
547
  if ((0, arrow_1.toArr)(defined).includes(symbol)) {
@@ -623,7 +585,7 @@ function readRows(opts) {
623
585
  matches: opts.matches,
624
586
  limit: opts.limit,
625
587
  scoped: opts.scoped,
626
- })), fallbackOnUnknownVerb: true }, opts.fallback));
588
+ }), opts.vectorDim) }, opts.fallback));
627
589
  });
628
590
  }
629
591
  function handleRowsSkeleton(deps, payload) {
@@ -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)
@@ -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,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.skippedCompaction = skippedCompaction;
4
+ exports.parseCompactionResult = parseCompactionResult;
5
+ exports.formatCompactionStatus = formatCompactionStatus;
6
+ function skippedCompaction(reason) {
7
+ return {
8
+ status: "skipped",
9
+ reason,
10
+ at: Date.now(),
11
+ attempts: 0,
12
+ elapsedMs: 0,
13
+ };
14
+ }
15
+ function parseCompactionResult(value) {
16
+ if (!value || typeof value !== "object")
17
+ return undefined;
18
+ const r = value;
19
+ if (!["completed", "skipped", "failed"].includes(r.status) ||
20
+ !Number.isFinite(r.at) ||
21
+ Number.isNaN(new Date(r.at).getTime()) ||
22
+ !Number.isFinite(r.attempts) ||
23
+ !Number.isFinite(r.elapsedMs) ||
24
+ (r.reason !== undefined && typeof r.reason !== "string"))
25
+ return undefined;
26
+ return r;
27
+ }
28
+ function formatCompactionStatus(value) {
29
+ var _a;
30
+ const result = parseCompactionResult(value);
31
+ if (!result)
32
+ return undefined;
33
+ const reason = (_a = result.reason) === null || _a === void 0 ? void 0 : _a.replace(/[\r\n\t]/g, " ").slice(0, 512);
34
+ return `Last compaction: ${result.status} at ${new Date(result.at).toISOString()} (${result.attempts} attempts, ${result.elapsedMs}ms)${reason ? ` — ${reason}` : ""}`;
35
+ }
@@ -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;