grepmax 0.26.43 → 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 (92) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/NOTICE +6 -0
  3. package/README.md +3 -1
  4. package/dist/bin.js +4 -0
  5. package/dist/commands/doctor.js +2 -1
  6. package/dist/commands/mcp.js +142 -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 +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/search/pagerank.js +2 -1
  26. package/dist/lib/search/searcher.js +5 -4
  27. package/dist/lib/skeleton/retriever.js +2 -1
  28. package/dist/lib/store/lance-sdk.js +46 -0
  29. package/dist/lib/store/vector-db.js +57 -16
  30. package/dist/lib/utils/cross-project.js +2 -2
  31. package/dist/lib/utils/project-registry.js +8 -8
  32. package/dist/lib/utils/query-timeout.js +53 -13
  33. package/dist/lib/utils/store-access.js +6 -5
  34. package/dist/lib/utils/store-context.js +102 -0
  35. package/dist/lib/utils/stores.js +1 -1
  36. package/dist/vendor/lancedb/LICENSE +202 -0
  37. package/dist/vendor/lancedb/NODEJS_THIRD_PARTY_LICENSES.md +668 -0
  38. package/dist/vendor/lancedb/RUST_THIRD_PARTY_LICENSES.html +14607 -0
  39. package/dist/vendor/lancedb/arrow.d.ts +296 -0
  40. package/dist/vendor/lancedb/arrow.js +1145 -0
  41. package/dist/vendor/lancedb/arrow_type.d.ts +9 -0
  42. package/dist/vendor/lancedb/arrow_type.js +29 -0
  43. package/dist/vendor/lancedb/connection.d.ts +508 -0
  44. package/dist/vendor/lancedb/connection.js +298 -0
  45. package/dist/vendor/lancedb/embedding/embedding_function.d.ts +103 -0
  46. package/dist/vendor/lancedb/embedding/embedding_function.js +192 -0
  47. package/dist/vendor/lancedb/embedding/index.d.ts +37 -0
  48. package/dist/vendor/lancedb/embedding/index.js +108 -0
  49. package/dist/vendor/lancedb/embedding/openai.d.ts +16 -0
  50. package/dist/vendor/lancedb/embedding/openai.js +81 -0
  51. package/dist/vendor/lancedb/embedding/registry.d.ts +94 -0
  52. package/dist/vendor/lancedb/embedding/registry.js +221 -0
  53. package/dist/vendor/lancedb/embedding/transformers.d.ts +36 -0
  54. package/dist/vendor/lancedb/embedding/transformers.js +110 -0
  55. package/dist/vendor/lancedb/header.d.ts +162 -0
  56. package/dist/vendor/lancedb/header.js +217 -0
  57. package/dist/vendor/lancedb/index.d.ts +246 -0
  58. package/dist/vendor/lancedb/index.js +176 -0
  59. package/dist/vendor/lancedb/indices.d.ts +721 -0
  60. package/dist/vendor/lancedb/indices.js +166 -0
  61. package/dist/vendor/lancedb/license_header.txt +2 -0
  62. package/dist/vendor/lancedb/materialized_view.d.ts +69 -0
  63. package/dist/vendor/lancedb/materialized_view.js +112 -0
  64. package/dist/vendor/lancedb/merge.d.ts +104 -0
  65. package/dist/vendor/lancedb/merge.js +120 -0
  66. package/dist/vendor/lancedb/native.d.ts +1193 -0
  67. package/dist/vendor/lancedb/native.js +688 -0
  68. package/dist/vendor/lancedb/oauth.d.ts +66 -0
  69. package/dist/vendor/lancedb/oauth.js +15 -0
  70. package/dist/vendor/lancedb/otel.d.ts +26 -0
  71. package/dist/vendor/lancedb/otel.js +114 -0
  72. package/dist/vendor/lancedb/permutation.d.ts +143 -0
  73. package/dist/vendor/lancedb/permutation.js +184 -0
  74. package/dist/vendor/lancedb/provenance.json +6 -0
  75. package/dist/vendor/lancedb/query.d.ts +663 -0
  76. package/dist/vendor/lancedb/query.js +966 -0
  77. package/dist/vendor/lancedb/rerankers/index.d.ts +5 -0
  78. package/dist/vendor/lancedb/rerankers/index.js +19 -0
  79. package/dist/vendor/lancedb/rerankers/rrf.d.ts +14 -0
  80. package/dist/vendor/lancedb/rerankers/rrf.js +28 -0
  81. package/dist/vendor/lancedb/sanitize.d.ts +32 -0
  82. package/dist/vendor/lancedb/sanitize.js +544 -0
  83. package/dist/vendor/lancedb/scannable.d.ts +92 -0
  84. package/dist/vendor/lancedb/scannable.js +200 -0
  85. package/dist/vendor/lancedb/schema.d.ts +16 -0
  86. package/dist/vendor/lancedb/schema.js +387 -0
  87. package/dist/vendor/lancedb/table.d.ts +1069 -0
  88. package/dist/vendor/lancedb/table.js +498 -0
  89. package/dist/vendor/lancedb/util.d.ts +14 -0
  90. package/dist/vendor/lancedb/util.js +77 -0
  91. package/package.json +19 -7
  92. 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)
@@ -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;
@@ -41,6 +41,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
41
41
  step((generator = generator.apply(thisArg, _arguments || [])).next());
42
42
  });
43
43
  };
44
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
45
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
46
+ var m = o[Symbol.asyncIterator], i;
47
+ 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);
48
+ 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); }); }; }
49
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
50
+ };
44
51
  Object.defineProperty(exports, "__esModule", { value: true });
45
52
  exports.VectorDB = exports.DiskPressureError = void 0;
46
53
  exports.findStaleLanceTempFiles = findStaleLanceTempFiles;
@@ -48,7 +55,6 @@ exports.sweepStaleLanceTempFiles = sweepStaleLanceTempFiles;
48
55
  exports.isLanceCorruptionError = isLanceCorruptionError;
49
56
  exports.isMissingTableError = isMissingTableError;
50
57
  const fs = __importStar(require("node:fs"));
51
- const lancedb = __importStar(require("@lancedb/lancedb"));
52
58
  const apache_arrow_1 = require("apache-arrow");
53
59
  const config_1 = require("../../config");
54
60
  const embedding_reuse_1 = require("../index/embedding-reuse");
@@ -56,8 +62,10 @@ const index_config_1 = require("../index/index-config");
56
62
  const cleanup_1 = require("../utils/cleanup");
57
63
  const filter_builder_1 = require("../utils/filter-builder");
58
64
  const logger_1 = require("../utils/logger");
65
+ const query_timeout_1 = require("../utils/query-timeout");
59
66
  const ann_config_1 = require("./ann-config");
60
67
  const compaction_result_1 = require("./compaction-result");
68
+ const lancedb = __importStar(require("./lance-sdk"));
61
69
  const store_lease_1 = require("./store-lease");
62
70
  /**
63
71
  * Find abandoned Lance scratch files under `<lancedbDir>/ *.lance/data`.
@@ -369,7 +377,11 @@ class VectorDB {
369
377
  if (!this.db) {
370
378
  fs.mkdirSync(this.lancedbDir, { recursive: true });
371
379
  this.session = createLanceSession();
372
- this.db = yield lancedb.connect(this.lancedbDir, {}, this.session);
380
+ // 0.38 accepts the legacy third argument in its types but drops it in
381
+ // the JS wrapper. Put the session in native ConnectionOptions instead.
382
+ this.db = yield lancedb.connect(this.lancedbDir, {
383
+ session: this.session,
384
+ });
373
385
  }
374
386
  return this.db;
375
387
  });
@@ -1457,7 +1469,11 @@ class VectorDB {
1457
1469
  hasAnyRows() {
1458
1470
  return __awaiter(this, void 0, void 0, function* () {
1459
1471
  const table = yield this.ensureTable();
1460
- const rows = yield table.query().select(["id"]).limit(1).toArray();
1472
+ const rows = yield table
1473
+ .query()
1474
+ .select(["id"])
1475
+ .limit(1)
1476
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
1461
1477
  return rows.length > 0;
1462
1478
  });
1463
1479
  }
@@ -1470,7 +1486,7 @@ class VectorDB {
1470
1486
  .select(["id"])
1471
1487
  .where((0, filter_builder_1.pathStartsWith)(prefix))
1472
1488
  .limit(1)
1473
- .toArray();
1489
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
1474
1490
  return rows.length > 0;
1475
1491
  });
1476
1492
  }
@@ -1488,16 +1504,25 @@ class VectorDB {
1488
1504
  }
1489
1505
  getDistinctPathsForPrefix(pathPrefix) {
1490
1506
  return __awaiter(this, void 0, void 0, function* () {
1507
+ var _a, e_1, _b, _c;
1491
1508
  const table = yield this.ensureTable();
1492
1509
  const prefix = pathPrefix.endsWith("/") ? pathPrefix : `${pathPrefix}/`;
1493
- const rows = yield table
1494
- .query()
1495
- .select(["path"])
1496
- .where((0, filter_builder_1.pathStartsWith)(prefix))
1497
- .toArray();
1510
+ const rows = (0, query_timeout_1.streamQueryRows)(table.query().select(["path"]).where((0, filter_builder_1.pathStartsWith)(prefix)), "distinct project paths");
1498
1511
  const unique = new Set();
1499
- for (const r of rows) {
1500
- unique.add(String(r.path));
1512
+ try {
1513
+ 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) {
1514
+ _c = rows_1_1.value;
1515
+ _d = false;
1516
+ const r = _c;
1517
+ unique.add(String(r.path));
1518
+ }
1519
+ }
1520
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1521
+ finally {
1522
+ try {
1523
+ if (!_d && !_a && (_b = rows_1.return)) yield _b.call(rows_1);
1524
+ }
1525
+ finally { if (e_1) throw e_1.error; }
1501
1526
  }
1502
1527
  return unique;
1503
1528
  });
@@ -1522,7 +1547,7 @@ class VectorDB {
1522
1547
  "doc_token_ids",
1523
1548
  ])
1524
1549
  .where(`path = '${(0, filter_builder_1.escapeSqlString)(filePath)}'`)
1525
- .toArray();
1550
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
1526
1551
  const reusable = new Map();
1527
1552
  for (const row of rows) {
1528
1553
  const vector = (0, embedding_reuse_1.toFloat32)(row.vector);
@@ -1556,9 +1581,25 @@ class VectorDB {
1556
1581
  }
1557
1582
  getDistinctFileCount() {
1558
1583
  return __awaiter(this, void 0, void 0, function* () {
1584
+ var _a, e_2, _b, _c;
1559
1585
  const table = yield this.ensureTable();
1560
- const rows = yield table.query().select(["path"]).toArray();
1561
- return new Set(rows.map((r) => r.path)).size;
1586
+ const paths = new Set();
1587
+ try {
1588
+ for (var _d = true, _e = __asyncValues((0, query_timeout_1.streamQueryRows)(table.query().select(["path"]), "distinct file count")), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
1589
+ _c = _f.value;
1590
+ _d = false;
1591
+ const row = _c;
1592
+ paths.add(String(row.path));
1593
+ }
1594
+ }
1595
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1596
+ finally {
1597
+ try {
1598
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
1599
+ }
1600
+ finally { if (e_2) throw e_2.error; }
1601
+ }
1602
+ return paths.size;
1562
1603
  });
1563
1604
  }
1564
1605
  deletePaths(paths) {
@@ -1581,7 +1622,7 @@ class VectorDB {
1581
1622
  .select(["id"])
1582
1623
  .where(where)
1583
1624
  .limit(1)
1584
- .toArray();
1625
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
1585
1626
  if (existing.length > 0) {
1586
1627
  yield table.delete(where);
1587
1628
  this.markWriteCommitted();
@@ -1630,7 +1671,7 @@ class VectorDB {
1630
1671
  .select(["id"])
1631
1672
  .where(where)
1632
1673
  .limit(1)
1633
- .toArray();
1674
+ .toArray(query_timeout_1.QUERY_EXECUTION_OPTIONS);
1634
1675
  if (existing.length > 0) {
1635
1676
  yield table.delete(where);
1636
1677
  this.markWriteCommitted();
@@ -15,13 +15,13 @@ exports.resolveCrossProjectScope = resolveCrossProjectScope;
15
15
  exports.projectForPath = projectForPath;
16
16
  exports.groupResultsByProject = groupResultsByProject;
17
17
  const project_registry_1 = require("./project-registry");
18
- function resolveCrossProjectScope(opts) {
18
+ function resolveCrossProjectScope(opts, registeredProjects = (0, project_registry_1.listProjects)()) {
19
19
  const active = !!(opts.allProjects || opts.projects);
20
20
  if (!active) {
21
21
  return { active: false, roots: [], projectRoots: [], warnings: [] };
22
22
  }
23
23
  // Ignore "error"-status projects: the daemon won't search them anyway.
24
- const all = (0, project_registry_1.listProjects)().filter((p) => p.status !== "error");
24
+ const all = registeredProjects.filter((p) => p.status !== "error");
25
25
  const byName = new Map(all.map((p) => [p.name, p]));
26
26
  const warnings = [];
27
27
  const resolveNames = (csv) => {