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
@@ -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) => {
@@ -74,16 +74,16 @@ class ProjectRegistryConflictError extends Error {
74
74
  }
75
75
  }
76
76
  exports.ProjectRegistryConflictError = ProjectRegistryConflictError;
77
- function loadRegistry() {
77
+ function loadRegistry(registryPath = REGISTRY_PATH) {
78
78
  let raw;
79
79
  try {
80
- raw = fs.readFileSync(REGISTRY_PATH, "utf-8");
80
+ raw = fs.readFileSync(registryPath, "utf-8");
81
81
  }
82
82
  catch (err) {
83
83
  if (err.code === "ENOENT")
84
84
  return [];
85
85
  const message = err instanceof Error ? err.message : String(err);
86
- throw new Error(`Failed to read project registry ${REGISTRY_PATH}: ${message}`);
86
+ throw new Error(`Failed to read project registry ${registryPath}: ${message}`);
87
87
  }
88
88
  let parsed;
89
89
  try {
@@ -91,14 +91,14 @@ function loadRegistry() {
91
91
  }
92
92
  catch (err) {
93
93
  const message = err instanceof Error ? err.message : String(err);
94
- throw new Error(`Invalid project registry JSON ${REGISTRY_PATH}: ${message}`);
94
+ throw new Error(`Invalid project registry JSON ${registryPath}: ${message}`);
95
95
  }
96
96
  if (!Array.isArray(parsed)) {
97
- throw new Error(`Invalid project registry ${REGISTRY_PATH}: expected an array`);
97
+ throw new Error(`Invalid project registry ${registryPath}: expected an array`);
98
98
  }
99
99
  for (const [index, entry] of parsed.entries()) {
100
100
  if (!isProjectEntry(entry)) {
101
- throw new Error(`Invalid project registry entry at index ${index} in ${REGISTRY_PATH}`);
101
+ throw new Error(`Invalid project registry entry at index ${index} in ${registryPath}`);
102
102
  }
103
103
  }
104
104
  return parsed;
@@ -455,8 +455,8 @@ function stampProjectFullSync(stamp) {
455
455
  return entry;
456
456
  });
457
457
  }
458
- function listProjects() {
459
- return loadRegistry();
458
+ function listProjects(home) {
459
+ return loadRegistry(home ? path.join(home, "projects.json") : undefined);
460
460
  }
461
461
  function getProject(root) {
462
462
  return loadRegistry().find((e) => e.root === root);
@@ -8,10 +8,28 @@ 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 __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
12
+ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
13
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
14
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
15
+ return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
16
+ function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
17
+ function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
18
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
19
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
20
+ function fulfill(value) { resume("next", value); }
21
+ function reject(value) { resume("throw", value); }
22
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
23
+ };
11
24
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.QueryTimeoutError = void 0;
25
+ exports.QueryTimeoutError = exports.QUERY_EXECUTION_OPTIONS = exports.QUERY_TIMEOUT_MS = void 0;
13
26
  exports.withQueryTimeout = withQueryTimeout;
14
- const DEFAULT_TIMEOUT_MS = Number(process.env.GMAX_QUERY_TIMEOUT_MS || "") || 15000;
27
+ exports.streamQueryRows = streamQueryRows;
28
+ const configuredTimeout = Number(process.env.GMAX_QUERY_TIMEOUT_MS);
29
+ exports.QUERY_TIMEOUT_MS = Number.isFinite(configuredTimeout) && configuredTimeout > 0
30
+ ? Math.max(1, Math.min(Math.floor(configuredTimeout), 2147483647))
31
+ : 15000;
32
+ exports.QUERY_EXECUTION_OPTIONS = { timeoutMs: exports.QUERY_TIMEOUT_MS };
15
33
  class QueryTimeoutError extends Error {
16
34
  constructor(label, ms) {
17
35
  super(`LanceDB query timed out after ${ms}ms (${label}). ` +
@@ -24,19 +42,13 @@ exports.QueryTimeoutError = QueryTimeoutError;
24
42
  * Race a LanceDB query against a wall-clock timeout so a native-layer deadlock
25
43
  * surfaces as a loud error instead of hanging the process forever.
26
44
  *
27
- * Known trigger (@lancedb/lancedb 0.27.x): a `content LIKE` scan with
28
- * `.limit(N)` where more than N rows match never resolves — the limit-pushdown
29
- * cancellation loses the completion (see lancedb/lancedb#2189 for the same
30
- * family of hangs). Callers should also avoid that query shape (scan without
31
- * a limit and cap in JS); this wrapper is the backstop for shapes we missed.
32
- *
33
- * The timed-out native promise is NOT cancelled — its tokio task may stay
34
- * parked. CLI commands exit via gracefulExit() (process.exit), so the leak is
35
- * bounded to the command's lifetime. Long-lived callers (daemon) should treat
36
- * a QueryTimeoutError as a signal that the connection may be wedged.
45
+ * This JavaScript backstop does not cancel its input. Native query callers
46
+ * must also pass QUERY_EXECUTION_OPTIONS to toArray/execute so Lance enforces
47
+ * an execution deadline. The historical 0.27 LIKE+limit hang has a native
48
+ * temporary-store regression on the pinned SDK.
37
49
  */
38
50
  function withQueryTimeout(promise_1, label_1) {
39
- return __awaiter(this, arguments, void 0, function* (promise, label, ms = DEFAULT_TIMEOUT_MS) {
51
+ return __awaiter(this, arguments, void 0, function* (promise, label, ms = exports.QUERY_TIMEOUT_MS) {
40
52
  let timer;
41
53
  const timeout = new Promise((_, reject) => {
42
54
  timer = setTimeout(() => reject(new QueryTimeoutError(label, ms)), ms);
@@ -50,3 +62,31 @@ function withQueryTimeout(promise_1, label_1) {
50
62
  }
51
63
  });
52
64
  }
65
+ /** Stream bounded Arrow batches with a native and overall wall-clock deadline.
66
+ * SDK 0.38 exposes execute(options) at runtime but marks it protected in its
67
+ * declarations. Keep this version-specific adapter here and cover it natively.
68
+ */
69
+ function streamQueryRows(query_1, label_1) {
70
+ return __asyncGenerator(this, arguments, function* streamQueryRows_1(query, label, ms = exports.QUERY_TIMEOUT_MS) {
71
+ var _a;
72
+ const streaming = query;
73
+ const iterator = streaming.execute({ timeoutMs: ms, maxBatchLength: 512 });
74
+ const deadline = Date.now() + ms;
75
+ try {
76
+ for (;;) {
77
+ const remaining = deadline - Date.now();
78
+ if (remaining <= 0)
79
+ throw new QueryTimeoutError(label, ms);
80
+ const batch = yield __await(withQueryTimeout(iterator.next(), label, remaining));
81
+ if (batch.done)
82
+ return yield __await(void 0);
83
+ for (const row of batch.value.toArray())
84
+ yield yield __await(row);
85
+ }
86
+ }
87
+ finally {
88
+ // Do not let a broken native iterator's pending next() hang cleanup.
89
+ void ((_a = iterator.return) === null || _a === void 0 ? void 0 : _a.call(iterator).catch(() => { }));
90
+ }
91
+ });
92
+ }
@@ -189,15 +189,14 @@ function classifyDaemonError(error) {
189
189
  *
190
190
  * Kept as a named predicate because it is the exact rule `search-run.ts` has
191
191
  * always applied (and re-exports); `unknown command` is deliberately NOT in the
192
- * set — see `isUnknownCommandError` for the version-skew allowance.
192
+ * set; an unsupported verb is a live daemon refusing the request.
193
193
  */
194
194
  function shouldFallbackFromDaemonError(error) {
195
195
  return classifyDaemonError(error) === "no-daemon";
196
196
  }
197
197
  /**
198
- * A daemon older than this CLI does not know a newly added verb. Treat that as
199
- * "no daemon" for one release so an unrestarted daemon does not break the
200
- * command, then remove the allowance. Mirrors the `search-v2` transition rule.
198
+ * An unsupported verb means a live daemon is outdated or incompatible. It must
199
+ * be restarted, never bypassed by opening a second reader.
201
200
  */
202
201
  function isUnknownCommandError(error) {
203
202
  return typeof error === "string" && error.startsWith("unknown command");
@@ -304,8 +303,10 @@ function withStoreRead(name, opts) {
304
303
  const cls = classifyDaemonError(resp.error);
305
304
  if (cls === "sandboxed")
306
305
  throw refuseStoreAccess("socket");
306
+ if (isUnknownCommandError(resp.error)) {
307
+ throw new Error(`${defaultDaemonErrorMessage(name, resp)}. The daemon is outdated or incompatible; run: gmax watch restart`);
308
+ }
307
309
  if (cls === "no-daemon" ||
308
- (opts.fallbackOnUnknownVerb && isUnknownCommandError(resp.error)) ||
309
310
  (opts.fallbackOnOversize && isOversizeError(resp.error)) ||
310
311
  ((_a = opts.extraFallback) === null || _a === void 0 ? void 0 : _a.call(opts, resp.error)) === true) {
311
312
  if (process.env.GMAX_DEBUG === "1") {
@@ -0,0 +1,102 @@
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.storeInventory = storeInventory;
37
+ exports.currentStoreContext = currentStoreContext;
38
+ exports.withStoreContext = withStoreContext;
39
+ const node_async_hooks_1 = require("node:async_hooks");
40
+ const fs = __importStar(require("node:fs"));
41
+ const path = __importStar(require("node:path"));
42
+ const config_1 = require("../../config");
43
+ const index_config_1 = require("../index/index-config");
44
+ const project_registry_1 = require("./project-registry");
45
+ const stores_1 = require("./stores");
46
+ /** Metadata only: an offline store is never opened or recreated. */
47
+ function storeInventory(stores = (0, stores_1.readStores)()) {
48
+ var _a;
49
+ const homes = new Map();
50
+ for (const store of stores) {
51
+ const home = path.resolve(store.home);
52
+ const prior = homes.get(home);
53
+ if (prior) {
54
+ prior.prefixes.push(store.prefix);
55
+ continue;
56
+ }
57
+ const volume = (_a = (0, stores_1.volumeOf)(home)) !== null && _a !== void 0 ? _a : (0, stores_1.volumeOf)(store.prefix);
58
+ const item = {
59
+ home,
60
+ prefixes: [store.prefix],
61
+ volume,
62
+ state: "mounted",
63
+ projects: [],
64
+ };
65
+ if (volume && !fs.existsSync(volume))
66
+ item.state = "offline";
67
+ else if (!fs.existsSync(home))
68
+ item.state = "uninitialized";
69
+ else {
70
+ try {
71
+ item.projects = (0, project_registry_1.listProjects)(home);
72
+ }
73
+ catch (error) {
74
+ item.state = "error";
75
+ item.error = String(error);
76
+ }
77
+ }
78
+ homes.set(home, item);
79
+ }
80
+ return [...homes.values()];
81
+ }
82
+ const contexts = new node_async_hooks_1.AsyncLocalStorage();
83
+ function currentStoreContext() {
84
+ return contexts.getStore();
85
+ }
86
+ function withStoreContext(root, fn) {
87
+ const match = (0, stores_1.matchStore)(root);
88
+ if (match.kind === "offline") {
89
+ throw new Error(`gmax: this project's index lives on ${match.volume}, which is not mounted (store ${match.store.home}). Connect the drive and run the command again.`);
90
+ }
91
+ const home = match.kind === "store" ? path.resolve(match.store.home) : config_1.PATHS.globalRoot;
92
+ const context = {
93
+ home,
94
+ root,
95
+ secondary: match.kind === "store" || process.env.GMAX_SECONDARY_STORE === "1",
96
+ projects: (0, project_registry_1.listProjects)(home),
97
+ config: (0, index_config_1.readGlobalConfig)(home),
98
+ lancedbDir: path.join(home, "lancedb"),
99
+ lmdbPath: path.join(home, "cache", "meta.lmdb"),
100
+ };
101
+ return contexts.run(context, () => fn(context));
102
+ }
@@ -110,7 +110,7 @@ function matchStore(target, stores = readStores()) {
110
110
  if (!stores.length)
111
111
  return { kind: "primary" };
112
112
  for (const cand of candidates(target)) {
113
- for (const store of stores) {
113
+ for (const store of [...stores].sort((a, b) => path.resolve(b.prefix).length - path.resolve(a.prefix).length)) {
114
114
  if (!within(cand, path.resolve(store.prefix)))
115
115
  continue;
116
116
  const volume = (_a = volumeOf(store.home)) !== null && _a !== void 0 ? _a : volumeOf(store.prefix);
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.