@deepagents/text2sql 7.1.0 → 7.1.1

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 (47) hide show
  1. package/README.md +63 -76
  2. package/dist/bin/sql.js +42 -584
  3. package/dist/eval/src/evals/models.d.ts +12 -0
  4. package/dist/eval/src/evals/models.d.ts.map +1 -0
  5. package/dist/eval/src/evals/sql-create-context/sql-create-context.eval.d.ts +2 -0
  6. package/dist/eval/src/evals/sql-create-context/sql-create-context.eval.d.ts.map +1 -0
  7. package/dist/index.d.ts +0 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +130 -211
  10. package/dist/index.js.map +4 -4
  11. package/dist/lib/adapter-index.d.ts +0 -2
  12. package/dist/lib/adapter-index.d.ts.map +1 -1
  13. package/dist/lib/adapters/posthog/index.js.map +2 -2
  14. package/dist/lib/adapters/posthog/posthog.d.ts.map +1 -1
  15. package/dist/lib/adapters/posthog/schema.posthog.grounding.d.ts.map +1 -1
  16. package/dist/lib/adapters/spreadsheet/index.js +4 -4
  17. package/dist/lib/adapters/spreadsheet/index.js.map +2 -2
  18. package/dist/lib/adapters/sqlite/index.js +0 -3
  19. package/dist/lib/adapters/sqlite/index.js.map +2 -2
  20. package/dist/lib/adapters/sqlite/sqlite.d.ts.map +1 -1
  21. package/dist/lib/adapters/sqlserver/index.js +43 -59
  22. package/dist/lib/adapters/sqlserver/index.js.map +2 -2
  23. package/dist/lib/adapters/sqlserver/table.sqlserver.grounding.d.ts +1 -1
  24. package/dist/lib/adapters/sqlserver/table.sqlserver.grounding.d.ts.map +1 -1
  25. package/dist/lib/agents/question.agent.d.ts.map +1 -1
  26. package/dist/lib/agents/suggestions.agents.d.ts.map +1 -1
  27. package/dist/lib/fs/sqlite/sqlite-fs.d.ts.map +1 -1
  28. package/dist/lib/index-cache.d.ts +2 -3
  29. package/dist/lib/index-cache.d.ts.map +1 -1
  30. package/dist/lib/sql-command.d.ts +1 -4
  31. package/dist/lib/sql-command.d.ts.map +1 -1
  32. package/dist/lib/sql.d.ts +0 -5
  33. package/dist/lib/sql.d.ts.map +1 -1
  34. package/dist/lib/synthesis/extractors/base-contextual-extractor.d.ts.map +1 -1
  35. package/dist/lib/synthesis/extractors/segmented-context-extractor.d.ts.map +1 -1
  36. package/dist/lib/synthesis/extractors/sql-extractor.d.ts.map +1 -1
  37. package/dist/lib/synthesis/index.js.map +2 -2
  38. package/dist/lib/synthesis/synthesizers/breadth-evolver.d.ts.map +1 -1
  39. package/dist/lib/synthesis/synthesizers/depth-evolver.d.ts.map +1 -1
  40. package/dist/lib/synthesis/synthesizers/persona-generator.d.ts.map +1 -1
  41. package/dist/scripts/scripts/bigquery-test.d.ts +2 -0
  42. package/dist/scripts/scripts/bigquery-test.d.ts.map +1 -0
  43. package/package.json +4 -6
  44. package/dist/lib/index-lock.d.ts +0 -60
  45. package/dist/lib/index-lock.d.ts.map +0 -1
  46. package/dist/lib/prompt.d.ts +0 -2
  47. package/dist/lib/prompt.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -486,15 +486,15 @@ SQL: ${sql.trim()}`,
486
486
  */
487
487
  rowsFrom(result, paths) {
488
488
  if (Array.isArray(result)) return result;
489
- for (const path7 of paths) {
490
- const rows = path7.split(".").reduce(
489
+ for (const path6 of paths) {
490
+ const rows = path6.split(".").reduce(
491
491
  (value, key) => typeof value === "object" && value !== null ? Reflect.get(value, key) : void 0,
492
492
  result
493
493
  );
494
494
  if (Array.isArray(rows)) return rows;
495
495
  }
496
496
  throw new Error(
497
- `${this.constructor.name} execute() must return an array of rows or an object holding one at ${paths.map((path7) => `result.${path7}`).join(", ")}.`
497
+ `${this.constructor.name} execute() must return an array of rows or an object holding one at ${paths.map((path6) => `result.${path6}`).join(", ")}.`
498
498
  );
499
499
  }
500
500
  /**
@@ -1203,51 +1203,6 @@ function isFragmentList(value) {
1203
1203
  return Array.isArray(value) && value.every((item) => isFragment(item) && isFragmentData(item));
1204
1204
  }
1205
1205
 
1206
- // packages/text2sql/src/lib/index-lock.ts
1207
- import { createHash as createHash2 } from "node:crypto";
1208
- import { mkdir as mkdir2 } from "node:fs/promises";
1209
- import { tmpdir as tmpdir2 } from "node:os";
1210
- import * as path2 from "node:path";
1211
- import { lock as acquireLock } from "proper-lockfile";
1212
- var DEFAULT_STALE_MS = 3e4;
1213
- var DEFAULT_RETRIES = {
1214
- retries: 10,
1215
- factor: 2,
1216
- minTimeout: 100,
1217
- maxTimeout: 2e3
1218
- };
1219
- var FileIndexLock = class {
1220
- #dir;
1221
- #namespace;
1222
- #stale;
1223
- #retries;
1224
- constructor(options = {}) {
1225
- this.#dir = options.dir ?? tmpdir2();
1226
- this.#namespace = options.namespace;
1227
- this.#stale = options.stale ?? DEFAULT_STALE_MS;
1228
- this.#retries = options.retries ?? DEFAULT_RETRIES;
1229
- }
1230
- async run(key, fn) {
1231
- await mkdir2(this.#dir, { recursive: true });
1232
- const release = await acquireLock(this.#lockPathFor(key), {
1233
- realpath: false,
1234
- stale: this.#stale,
1235
- retries: this.#retries
1236
- });
1237
- try {
1238
- return await fn();
1239
- } finally {
1240
- await release().catch(() => {
1241
- });
1242
- }
1243
- }
1244
- #lockPathFor(key) {
1245
- const watermark = this.#namespace ? `${this.#namespace}-${key}` : key;
1246
- const hash2 = createHash2("md5").update(watermark).digest("hex");
1247
- return path2.join(this.#dir, `text2sql-lock-${hash2}`);
1248
- }
1249
- };
1250
-
1251
1206
  // packages/text2sql/src/lib/adapter-index.ts
1252
1207
  var TEXT2SQL_INDEX_PROGRESS_CHUNK = "data-text2sql-index-progress";
1253
1208
  var noopProgressHandler = () => {
@@ -1267,7 +1222,6 @@ function databaseNameFragment(name) {
1267
1222
  var AdapterIndexer = class {
1268
1223
  #adapters;
1269
1224
  #cache;
1270
- #lock;
1271
1225
  constructor(options) {
1272
1226
  const adapterNames = Object.keys(options.adapters);
1273
1227
  if (adapterNames.length === 0) {
@@ -1276,7 +1230,6 @@ var AdapterIndexer = class {
1276
1230
  validateAdapterNames(adapterNames);
1277
1231
  this.#adapters = options.adapters;
1278
1232
  this.#cache = options.cache;
1279
- this.#lock = options.lock;
1280
1233
  }
1281
1234
  async index(options = {}) {
1282
1235
  const progress = timestampProgressHandler(options.onProgress);
@@ -1334,41 +1287,15 @@ var AdapterIndexer = class {
1334
1287
  message: `Indexing adapter "${name}"...`
1335
1288
  });
1336
1289
  const cache = this.#cache;
1337
- const key = name;
1338
- const emitCacheHit = () => progress({
1339
- type: "adapter:cache-hit",
1340
- adapter: name,
1341
- message: `Using cached index for adapter "${name}".`,
1342
- cached: true
1343
- });
1344
- const emitCacheMiss = () => progress({
1345
- type: "adapter:cache-miss",
1346
- adapter: name,
1347
- message: `No cached index for adapter "${name}".`,
1348
- cached: false
1349
- });
1350
- const introspect = async () => {
1351
- const ctx = createGroundingContext({
1352
- onProgress: (event) => progress(adapterProgressEvent(name, event))
1353
- });
1354
- const fragments = await adapter.introspect(ctx);
1355
- await cache?.write(key, fragments);
1356
- return fragments;
1357
- };
1358
- let servedFromCache = false;
1359
- const populate = async () => {
1360
- const recheck = await cache?.read(key);
1361
- if (recheck) {
1362
- servedFromCache = true;
1363
- return recheck;
1364
- }
1365
- if (cache) emitCacheMiss();
1366
- return introspect();
1367
- };
1368
1290
  try {
1369
- const cached = await cache?.read(key);
1291
+ const cached = await cache?.read(name);
1370
1292
  if (cached) {
1371
- emitCacheHit();
1293
+ progress({
1294
+ type: "adapter:cache-hit",
1295
+ adapter: name,
1296
+ message: `Using cached index for adapter "${name}".`,
1297
+ cached: true
1298
+ });
1372
1299
  progress({
1373
1300
  type: "adapter:end",
1374
1301
  adapter: name,
@@ -1377,13 +1304,24 @@ var AdapterIndexer = class {
1377
1304
  });
1378
1305
  return cached;
1379
1306
  }
1380
- const fragments = await this.#lock.run(key, populate);
1381
- if (servedFromCache) emitCacheHit();
1307
+ if (cache) {
1308
+ progress({
1309
+ type: "adapter:cache-miss",
1310
+ adapter: name,
1311
+ message: `No cached index for adapter "${name}".`,
1312
+ cached: false
1313
+ });
1314
+ }
1315
+ const ctx = createGroundingContext({
1316
+ onProgress: (event) => progress(adapterProgressEvent(name, event))
1317
+ });
1318
+ const fragments = await adapter.introspect(ctx);
1319
+ await cache?.write(name, fragments);
1382
1320
  progress({
1383
1321
  type: "adapter:end",
1384
1322
  adapter: name,
1385
1323
  message: `Finished indexing adapter "${name}".`,
1386
- cached: servedFromCache
1324
+ cached: false
1387
1325
  });
1388
1326
  return fragments;
1389
1327
  } catch (error) {
@@ -1429,7 +1367,7 @@ function errorMessage(error) {
1429
1367
  }
1430
1368
 
1431
1369
  // packages/text2sql/src/lib/checkpoint.ts
1432
- import { createHash as createHash3 } from "node:crypto";
1370
+ import { createHash as createHash2 } from "node:crypto";
1433
1371
  import { existsSync as existsSync2, readFileSync, renameSync, writeFileSync } from "node:fs";
1434
1372
  import pLimit from "p-limit";
1435
1373
  import z4 from "zod";
@@ -1450,9 +1388,9 @@ var Checkpoint = class _Checkpoint {
1450
1388
  points;
1451
1389
  path;
1452
1390
  configHash;
1453
- constructor(path7, configHash, points) {
1391
+ constructor(path6, configHash, points) {
1454
1392
  this.points = points;
1455
- this.path = path7;
1393
+ this.path = path6;
1456
1394
  this.configHash = configHash;
1457
1395
  }
1458
1396
  /**
@@ -1460,14 +1398,14 @@ var Checkpoint = class _Checkpoint {
1460
1398
  * Handles corrupted files and config changes gracefully.
1461
1399
  */
1462
1400
  static async load(options) {
1463
- const { path: path7, configHash } = options;
1464
- if (existsSync2(path7)) {
1401
+ const { path: path6, configHash } = options;
1402
+ if (existsSync2(path6)) {
1465
1403
  try {
1466
- const content = readFileSync(path7, "utf-8");
1404
+ const content = readFileSync(path6, "utf-8");
1467
1405
  const file = checkpointFile.parse(JSON.parse(content));
1468
1406
  if (configHash && file.configHash && file.configHash !== configHash) {
1469
1407
  console.log("\u26A0 Config changed, starting fresh");
1470
- return new _Checkpoint(path7, configHash, {});
1408
+ return new _Checkpoint(path6, configHash, {});
1471
1409
  }
1472
1410
  const points = file.points;
1473
1411
  const totalEntries = Object.values(points).reduce(
@@ -1475,14 +1413,14 @@ var Checkpoint = class _Checkpoint {
1475
1413
  0
1476
1414
  );
1477
1415
  console.log(`\u2713 Resuming from checkpoint (${totalEntries} entries)`);
1478
- return new _Checkpoint(path7, configHash, points);
1416
+ return new _Checkpoint(path6, configHash, points);
1479
1417
  } catch {
1480
1418
  console.log("\u26A0 Checkpoint corrupted, starting fresh");
1481
- return new _Checkpoint(path7, configHash, {});
1419
+ return new _Checkpoint(path6, configHash, {});
1482
1420
  }
1483
1421
  }
1484
1422
  console.log("Starting new checkpoint");
1485
- return new _Checkpoint(path7, configHash, {});
1423
+ return new _Checkpoint(path6, configHash, {});
1486
1424
  }
1487
1425
  /**
1488
1426
  * Run a single computation with checkpointing.
@@ -1558,7 +1496,7 @@ var Checkpoint = class _Checkpoint {
1558
1496
  }
1559
1497
  };
1560
1498
  function hash(value) {
1561
- return createHash3("md5").update(JSON.stringify(value)).digest("hex");
1499
+ return createHash2("md5").update(JSON.stringify(value)).digest("hex");
1562
1500
  }
1563
1501
  var Point = class {
1564
1502
  #stored;
@@ -1603,11 +1541,11 @@ var Point = class {
1603
1541
  }
1604
1542
  };
1605
1543
  function hashConfig(config) {
1606
- return createHash3("md5").update(JSON.stringify(config)).digest("hex");
1544
+ return createHash2("md5").update(JSON.stringify(config)).digest("hex");
1607
1545
  }
1608
1546
 
1609
1547
  // packages/text2sql/src/lib/fs/sqlite/sqlite-fs.ts
1610
- import * as path3 from "node:path";
1548
+ import * as path2 from "node:path";
1611
1549
  import { DatabaseSync } from "node:sqlite";
1612
1550
  import z6 from "zod";
1613
1551
 
@@ -1684,7 +1622,7 @@ var SqliteFs = class {
1684
1622
  const segments = p.split("/").filter(Boolean);
1685
1623
  let currentPath = "/";
1686
1624
  for (let i = 0; i < segments.length - 1; i++) {
1687
- currentPath = path3.posix.join(currentPath, segments[i]);
1625
+ currentPath = path2.posix.join(currentPath, segments[i]);
1688
1626
  const exists = this.#stmt("SELECT 1 FROM fs_entries WHERE path = ?").get(
1689
1627
  currentPath
1690
1628
  );
@@ -1705,7 +1643,7 @@ var SqliteFs = class {
1705
1643
  return stmt;
1706
1644
  }
1707
1645
  #normalizeRoot(root) {
1708
- return path3.posix.resolve("/", root.trim());
1646
+ return path2.posix.resolve("/", root.trim());
1709
1647
  }
1710
1648
  #prefixPath(p) {
1711
1649
  if (!this.#root) {
@@ -1714,7 +1652,7 @@ var SqliteFs = class {
1714
1652
  if (p === "/") {
1715
1653
  return this.#root;
1716
1654
  }
1717
- return path3.posix.join(this.#root, p);
1655
+ return path2.posix.join(this.#root, p);
1718
1656
  }
1719
1657
  #unprefixPath(p) {
1720
1658
  if (!this.#root) {
@@ -1735,15 +1673,18 @@ var SqliteFs = class {
1735
1673
  this.#db.exec("COMMIT");
1736
1674
  return result;
1737
1675
  } catch (error) {
1738
- this.#db.exec("ROLLBACK");
1676
+ try {
1677
+ this.#db.exec("ROLLBACK");
1678
+ } catch {
1679
+ }
1739
1680
  throw error;
1740
1681
  }
1741
1682
  }
1742
1683
  #normalizePath(p) {
1743
- return path3.posix.resolve("/", p);
1684
+ return path2.posix.resolve("/", p);
1744
1685
  }
1745
1686
  #dirname(p) {
1746
- const dir = path3.posix.dirname(p);
1687
+ const dir = path2.posix.dirname(p);
1747
1688
  return dir === "" ? "/" : dir;
1748
1689
  }
1749
1690
  #ensureParentExists(filePath) {
@@ -1817,7 +1758,7 @@ var SqliteFs = class {
1817
1758
  }
1818
1759
  seen.add(p);
1819
1760
  const target = this.#normalizePath(
1820
- path3.posix.resolve(this.#dirname(p), entry.symlinkTarget)
1761
+ path2.posix.resolve(this.#dirname(p), entry.symlinkTarget)
1821
1762
  );
1822
1763
  return this.#resolveSymlink(target, seen);
1823
1764
  }
@@ -1970,11 +1911,11 @@ var SqliteFs = class {
1970
1911
  this.#useTransaction(() => {
1971
1912
  if (options?.recursive) {
1972
1913
  const rootPath = this.#root || "/";
1973
- const relativePath = path3.posix.relative(rootPath, prefixed);
1914
+ const relativePath = path2.posix.relative(rootPath, prefixed);
1974
1915
  const segments = relativePath.split("/").filter(Boolean);
1975
1916
  let currentPath = rootPath;
1976
1917
  for (const segment of segments) {
1977
- currentPath = path3.posix.join(currentPath, segment);
1918
+ currentPath = path2.posix.join(currentPath, segment);
1978
1919
  const exists = typeRow.optional().parse(
1979
1920
  this.#stmt("SELECT type FROM fs_entries WHERE path = ?").get(
1980
1921
  currentPath
@@ -2031,7 +1972,7 @@ var SqliteFs = class {
2031
1972
  AND path NOT LIKE ? || '%/%'`
2032
1973
  ).all(prefix, resolved, prefix)
2033
1974
  );
2034
- return rows.map((row) => path3.posix.basename(row.path));
1975
+ return rows.map((row) => path2.posix.basename(row.path));
2035
1976
  }
2036
1977
  async readdirWithFileTypes(dirPath) {
2037
1978
  const normalized = this.#normalizePath(dirPath);
@@ -2056,7 +1997,7 @@ var SqliteFs = class {
2056
1997
  ).all(prefix, resolved, prefix)
2057
1998
  );
2058
1999
  return rows.map((row) => ({
2059
- name: path3.posix.basename(row.path),
2000
+ name: path2.posix.basename(row.path),
2060
2001
  isFile: row.type === "file",
2061
2002
  isDirectory: row.type === "directory",
2062
2003
  isSymbolicLink: row.type === "symlink"
@@ -2113,8 +2054,8 @@ var SqliteFs = class {
2113
2054
  ).all(srcPrefixed, srcPrefixed)
2114
2055
  );
2115
2056
  for (const entry of allEntries) {
2116
- const relativePath = path3.posix.relative(srcPrefixed, entry.path);
2117
- const newPath = path3.posix.join(destPrefixed, relativePath);
2057
+ const relativePath = path2.posix.relative(srcPrefixed, entry.path);
2058
+ const newPath = path2.posix.join(destPrefixed, relativePath);
2118
2059
  this.#stmt(
2119
2060
  `INSERT OR REPLACE INTO fs_entries (path, type, mode, size, mtime, symlinkTarget)
2120
2061
  VALUES (?, ?, ?, ?, ?, ?)`
@@ -2179,8 +2120,8 @@ var SqliteFs = class {
2179
2120
  ).all(srcPrefixed, srcPrefixed)
2180
2121
  );
2181
2122
  for (const entry of [...allEntries].reverse()) {
2182
- const relativePath = path3.posix.relative(srcPrefixed, entry.path);
2183
- const newPath = path3.posix.join(destPrefixed, relativePath);
2123
+ const relativePath = path2.posix.relative(srcPrefixed, entry.path);
2124
+ const newPath = path2.posix.join(destPrefixed, relativePath);
2184
2125
  this.#stmt(
2185
2126
  `INSERT INTO fs_entries (path, type, mode, size, mtime, symlinkTarget)
2186
2127
  VALUES (?, ?, ?, ?, ?, ?)`
@@ -2229,7 +2170,7 @@ var SqliteFs = class {
2229
2170
  });
2230
2171
  }
2231
2172
  resolvePath(base, relativePath) {
2232
- return path3.posix.resolve(base, relativePath);
2173
+ return path2.posix.resolve(base, relativePath);
2233
2174
  }
2234
2175
  getAllPaths() {
2235
2176
  const rows = z6.array(pathRow).parse(this.#stmt("SELECT path FROM fs_entries ORDER BY path").all());
@@ -2339,7 +2280,7 @@ var SqliteFs = class {
2339
2280
 
2340
2281
  // packages/text2sql/src/lib/fs/mssql/mssql-fs.ts
2341
2282
  import { createRequire } from "node:module";
2342
- import * as path4 from "node:path";
2283
+ import * as path3 from "node:path";
2343
2284
  import z7 from "zod";
2344
2285
 
2345
2286
  // packages/text2sql/src/lib/fs/mssql/ddl.mssql-fs.ts
@@ -2499,7 +2440,7 @@ var MssqlFs = class _MssqlFs {
2499
2440
  const segments = p.split("/").filter(Boolean);
2500
2441
  let currentPath = "/";
2501
2442
  for (let i = 0; i < segments.length - 1; i++) {
2502
- currentPath = path4.posix.join(currentPath, segments[i]);
2443
+ currentPath = path3.posix.join(currentPath, segments[i]);
2503
2444
  const exists = rowsOf(
2504
2445
  existsRow,
2505
2446
  await this.#rawQuery(
@@ -2553,7 +2494,7 @@ var MssqlFs = class _MssqlFs {
2553
2494
  }
2554
2495
  }
2555
2496
  #normalizeRoot(root) {
2556
- return path4.posix.resolve("/", root.trim());
2497
+ return path3.posix.resolve("/", root.trim());
2557
2498
  }
2558
2499
  #prefixPath(p) {
2559
2500
  if (!this.#root) {
@@ -2562,7 +2503,7 @@ var MssqlFs = class _MssqlFs {
2562
2503
  if (p === "/") {
2563
2504
  return this.#root;
2564
2505
  }
2565
- return path4.posix.join(this.#root, p);
2506
+ return path3.posix.join(this.#root, p);
2566
2507
  }
2567
2508
  #unprefixPath(p) {
2568
2509
  if (!this.#root) {
@@ -2577,10 +2518,10 @@ var MssqlFs = class _MssqlFs {
2577
2518
  return p;
2578
2519
  }
2579
2520
  #normalizePath(p) {
2580
- return path4.posix.resolve("/", p);
2521
+ return path3.posix.resolve("/", p);
2581
2522
  }
2582
2523
  #dirname(p) {
2583
- const dir = path4.posix.dirname(p);
2524
+ const dir = path3.posix.dirname(p);
2584
2525
  return dir === "" ? "/" : dir;
2585
2526
  }
2586
2527
  async #ensureParentExists(filePath, transaction) {
@@ -2664,7 +2605,7 @@ var MssqlFs = class _MssqlFs {
2664
2605
  }
2665
2606
  seen.add(p);
2666
2607
  const target = this.#normalizePath(
2667
- path4.posix.resolve(this.#dirname(p), entry.symlinkTarget)
2608
+ path3.posix.resolve(this.#dirname(p), entry.symlinkTarget)
2668
2609
  );
2669
2610
  return this.#resolveSymlink(target, seen);
2670
2611
  }
@@ -2861,11 +2802,11 @@ var MssqlFs = class _MssqlFs {
2861
2802
  await this.#useTransaction(async (transaction) => {
2862
2803
  if (options?.recursive) {
2863
2804
  const rootPath = this.#root || "/";
2864
- const relativePath = path4.posix.relative(rootPath, prefixed);
2805
+ const relativePath = path3.posix.relative(rootPath, prefixed);
2865
2806
  const segments = relativePath.split("/").filter(Boolean);
2866
2807
  let currentPath = rootPath;
2867
2808
  for (const segment of segments) {
2868
- currentPath = path4.posix.join(currentPath, segment);
2809
+ currentPath = path3.posix.join(currentPath, segment);
2869
2810
  const checkReq = transaction.request();
2870
2811
  checkReq.input("p0", currentPath);
2871
2812
  const [exists] = rowsOf(
@@ -2938,7 +2879,7 @@ var MssqlFs = class _MssqlFs {
2938
2879
  [prefix, resolved]
2939
2880
  )
2940
2881
  );
2941
- return rows.map((row) => path4.posix.basename(row.path));
2882
+ return rows.map((row) => path3.posix.basename(row.path));
2942
2883
  }
2943
2884
  async readdirWithFileTypes(dirPath) {
2944
2885
  const normalized = this.#normalizePath(dirPath);
@@ -2969,7 +2910,7 @@ var MssqlFs = class _MssqlFs {
2969
2910
  )
2970
2911
  );
2971
2912
  return rows.map((row) => ({
2972
- name: path4.posix.basename(row.path),
2913
+ name: path3.posix.basename(row.path),
2973
2914
  isFile: row.type === "file",
2974
2915
  isDirectory: row.type === "directory",
2975
2916
  isSymbolicLink: row.type === "symlink"
@@ -3048,8 +2989,8 @@ var MssqlFs = class _MssqlFs {
3048
2989
  )
3049
2990
  );
3050
2991
  for (const entry of allEntries) {
3051
- const relativePath = path4.posix.relative(srcPrefixed, entry.path);
3052
- const newPath = path4.posix.join(destPrefixed, relativePath);
2992
+ const relativePath = path3.posix.relative(srcPrefixed, entry.path);
2993
+ const newPath = path3.posix.join(destPrefixed, relativePath);
3053
2994
  const insertReq = transaction.request();
3054
2995
  insertReq.input("p0", newPath);
3055
2996
  insertReq.input("p1", entry.type);
@@ -3169,8 +3110,8 @@ var MssqlFs = class _MssqlFs {
3169
3110
  `DELETE FROM ${this.#t("fs_entries")} WHERE path = @dp0 OR path LIKE @dp0 + '/%'`
3170
3111
  );
3171
3112
  for (const entry of [...allEntries].reverse()) {
3172
- const relativePath = path4.posix.relative(srcPrefixed, entry.path);
3173
- const newPath = path4.posix.join(destPrefixed, relativePath);
3113
+ const relativePath = path3.posix.relative(srcPrefixed, entry.path);
3114
+ const newPath = path3.posix.join(destPrefixed, relativePath);
3174
3115
  const insertReq = transaction.request();
3175
3116
  insertReq.input("p0", newPath);
3176
3117
  insertReq.input("p1", entry.type);
@@ -3269,7 +3210,7 @@ var MssqlFs = class _MssqlFs {
3269
3210
  });
3270
3211
  }
3271
3212
  resolvePath(base, relativePath) {
3272
- return path4.posix.resolve(base, relativePath);
3213
+ return path3.posix.resolve(base, relativePath);
3273
3214
  }
3274
3215
  getAllPaths() {
3275
3216
  throw new Error(
@@ -3429,7 +3370,7 @@ var MssqlFs = class _MssqlFs {
3429
3370
 
3430
3371
  // packages/text2sql/src/lib/fs/postgres/postgres-fs.ts
3431
3372
  import { createRequire as createRequire2 } from "node:module";
3432
- import * as path5 from "node:path";
3373
+ import * as path4 from "node:path";
3433
3374
  import z8 from "zod";
3434
3375
 
3435
3376
  // packages/text2sql/src/lib/fs/postgres/ddl.postgres-fs.ts
@@ -3568,7 +3509,7 @@ var PostgresFs = class _PostgresFs {
3568
3509
  const segments = p.split("/").filter(Boolean);
3569
3510
  let currentPath = "/";
3570
3511
  for (let i = 0; i < segments.length - 1; i++) {
3571
- currentPath = path5.posix.join(currentPath, segments[i]);
3512
+ currentPath = path4.posix.join(currentPath, segments[i]);
3572
3513
  const exists = rowsOf2(
3573
3514
  existsRow2,
3574
3515
  await this.#rawQuery(
@@ -3615,7 +3556,7 @@ var PostgresFs = class _PostgresFs {
3615
3556
  }
3616
3557
  }
3617
3558
  #normalizeRoot(root) {
3618
- return path5.posix.resolve("/", root.trim());
3559
+ return path4.posix.resolve("/", root.trim());
3619
3560
  }
3620
3561
  #prefixPath(p) {
3621
3562
  if (!this.#root) {
@@ -3624,7 +3565,7 @@ var PostgresFs = class _PostgresFs {
3624
3565
  if (p === "/") {
3625
3566
  return this.#root;
3626
3567
  }
3627
- return path5.posix.join(this.#root, p);
3568
+ return path4.posix.join(this.#root, p);
3628
3569
  }
3629
3570
  #unprefixPath(p) {
3630
3571
  if (!this.#root) {
@@ -3639,10 +3580,10 @@ var PostgresFs = class _PostgresFs {
3639
3580
  return p;
3640
3581
  }
3641
3582
  #normalizePath(p) {
3642
- return path5.posix.resolve("/", p);
3583
+ return path4.posix.resolve("/", p);
3643
3584
  }
3644
3585
  #dirname(p) {
3645
- const dir = path5.posix.dirname(p);
3586
+ const dir = path4.posix.dirname(p);
3646
3587
  return dir === "" ? "/" : dir;
3647
3588
  }
3648
3589
  async #ensureParentExists(filePath, client) {
@@ -3718,7 +3659,7 @@ var PostgresFs = class _PostgresFs {
3718
3659
  }
3719
3660
  seen.add(p);
3720
3661
  const target = this.#normalizePath(
3721
- path5.posix.resolve(this.#dirname(p), entry.symlink_target)
3662
+ path4.posix.resolve(this.#dirname(p), entry.symlink_target)
3722
3663
  );
3723
3664
  return this.#resolveSymlink(target, seen);
3724
3665
  }
@@ -3898,11 +3839,11 @@ var PostgresFs = class _PostgresFs {
3898
3839
  await this.#useTransaction(async (client) => {
3899
3840
  if (options?.recursive) {
3900
3841
  const rootPath = this.#root || "/";
3901
- const relativePath = path5.posix.relative(rootPath, prefixed);
3842
+ const relativePath = path4.posix.relative(rootPath, prefixed);
3902
3843
  const segments = relativePath.split("/").filter(Boolean);
3903
3844
  let currentPath = rootPath;
3904
3845
  for (const segment of segments) {
3905
- currentPath = path5.posix.join(currentPath, segment);
3846
+ currentPath = path4.posix.join(currentPath, segment);
3906
3847
  const [exists] = rowsOf2(
3907
3848
  typeRow3,
3908
3849
  await client.query(
@@ -3969,7 +3910,7 @@ var PostgresFs = class _PostgresFs {
3969
3910
  [prefix, resolved]
3970
3911
  )
3971
3912
  );
3972
- return rows.map((row) => path5.posix.basename(row.path));
3913
+ return rows.map((row) => path4.posix.basename(row.path));
3973
3914
  }
3974
3915
  async readdirWithFileTypes(dirPath) {
3975
3916
  const normalized = this.#normalizePath(dirPath);
@@ -4000,7 +3941,7 @@ var PostgresFs = class _PostgresFs {
4000
3941
  )
4001
3942
  );
4002
3943
  return rows.map((row) => ({
4003
- name: path5.posix.basename(row.path),
3944
+ name: path4.posix.basename(row.path),
4004
3945
  isFile: row.type === "file",
4005
3946
  isDirectory: row.type === "directory",
4006
3947
  isSymbolicLink: row.type === "symlink"
@@ -4075,8 +4016,8 @@ var PostgresFs = class _PostgresFs {
4075
4016
  )
4076
4017
  );
4077
4018
  for (const entry of allEntries) {
4078
- const relativePath = path5.posix.relative(srcPrefixed, entry.path);
4079
- const newPath = path5.posix.join(destPrefixed, relativePath);
4019
+ const relativePath = path4.posix.relative(srcPrefixed, entry.path);
4020
+ const newPath = path4.posix.join(destPrefixed, relativePath);
4080
4021
  await client.query(
4081
4022
  `INSERT INTO ${this.#t("fs_entries")} (path, type, mode, size, mtime, symlink_target)
4082
4023
  VALUES ($1, $2, $3, $4, $5, $6)
@@ -4176,8 +4117,8 @@ var PostgresFs = class _PostgresFs {
4176
4117
  [destPrefixed]
4177
4118
  );
4178
4119
  for (const entry of [...allEntries].reverse()) {
4179
- const relativePath = path5.posix.relative(srcPrefixed, entry.path);
4180
- const newPath = path5.posix.join(destPrefixed, relativePath);
4120
+ const relativePath = path4.posix.relative(srcPrefixed, entry.path);
4121
+ const newPath = path4.posix.join(destPrefixed, relativePath);
4181
4122
  await client.query(
4182
4123
  `INSERT INTO ${this.#t("fs_entries")} (path, type, mode, size, mtime, symlink_target)
4183
4124
  VALUES ($1, $2, $3, $4, $5, $6)
@@ -4256,7 +4197,7 @@ var PostgresFs = class _PostgresFs {
4256
4197
  });
4257
4198
  }
4258
4199
  resolvePath(base, relativePath) {
4259
- return path5.posix.resolve(base, relativePath);
4200
+ return path4.posix.resolve(base, relativePath);
4260
4201
  }
4261
4202
  getAllPaths() {
4262
4203
  throw new Error(
@@ -4411,29 +4352,29 @@ var ScopedFs = class {
4411
4352
  this.#base = options.base;
4412
4353
  this.#prefix = options.prefix.replace(/\/$/, "");
4413
4354
  }
4414
- #scope(path7) {
4415
- return `${this.#prefix}${path7}`;
4355
+ #scope(path6) {
4356
+ return `${this.#prefix}${path6}`;
4416
4357
  }
4417
- #unscope(path7) {
4418
- if (path7 === this.#prefix) {
4358
+ #unscope(path6) {
4359
+ if (path6 === this.#prefix) {
4419
4360
  return "/";
4420
4361
  }
4421
- if (path7.startsWith(this.#prefix + "/")) {
4422
- return path7.slice(this.#prefix.length) || "/";
4362
+ if (path6.startsWith(this.#prefix + "/")) {
4363
+ return path6.slice(this.#prefix.length) || "/";
4423
4364
  }
4424
- return path7;
4365
+ return path6;
4425
4366
  }
4426
- async writeFile(path7, content, options) {
4427
- await this.#base.writeFile(this.#scope(path7), content, options);
4367
+ async writeFile(path6, content, options) {
4368
+ await this.#base.writeFile(this.#scope(path6), content, options);
4428
4369
  }
4429
- async appendFile(path7, content, options) {
4430
- await this.#base.appendFile(this.#scope(path7), content, options);
4370
+ async appendFile(path6, content, options) {
4371
+ await this.#base.appendFile(this.#scope(path6), content, options);
4431
4372
  }
4432
- async mkdir(path7, options) {
4433
- return this.#base.mkdir(this.#scope(path7), options);
4373
+ async mkdir(path6, options) {
4374
+ return this.#base.mkdir(this.#scope(path6), options);
4434
4375
  }
4435
- async rm(path7, options) {
4436
- await this.#base.rm(this.#scope(path7), options);
4376
+ async rm(path6, options) {
4377
+ await this.#base.rm(this.#scope(path6), options);
4437
4378
  }
4438
4379
  async cp(src, dest, options) {
4439
4380
  await this.#base.cp(this.#scope(src), this.#scope(dest), options);
@@ -4441,8 +4382,8 @@ var ScopedFs = class {
4441
4382
  async mv(src, dest) {
4442
4383
  await this.#base.mv(this.#scope(src), this.#scope(dest));
4443
4384
  }
4444
- async chmod(path7, mode) {
4445
- return this.#base.chmod(this.#scope(path7), mode);
4385
+ async chmod(path6, mode) {
4386
+ return this.#base.chmod(this.#scope(path6), mode);
4446
4387
  }
4447
4388
  async symlink(target, linkPath) {
4448
4389
  await this.#base.symlink(target, this.#scope(linkPath));
@@ -4450,35 +4391,35 @@ var ScopedFs = class {
4450
4391
  async link(existingPath, newPath) {
4451
4392
  await this.#base.link(this.#scope(existingPath), this.#scope(newPath));
4452
4393
  }
4453
- readFile(path7, options) {
4454
- return this.#base.readFile(this.#scope(path7), options);
4394
+ readFile(path6, options) {
4395
+ return this.#base.readFile(this.#scope(path6), options);
4455
4396
  }
4456
- readFileBuffer(path7) {
4457
- return this.#base.readFileBuffer(this.#scope(path7));
4397
+ readFileBuffer(path6) {
4398
+ return this.#base.readFileBuffer(this.#scope(path6));
4458
4399
  }
4459
- stat(path7) {
4460
- return this.#base.stat(this.#scope(path7));
4400
+ stat(path6) {
4401
+ return this.#base.stat(this.#scope(path6));
4461
4402
  }
4462
- lstat(path7) {
4463
- return this.#base.lstat(this.#scope(path7));
4403
+ lstat(path6) {
4404
+ return this.#base.lstat(this.#scope(path6));
4464
4405
  }
4465
- readdir(path7) {
4466
- return this.#base.readdir(this.#scope(path7));
4406
+ readdir(path6) {
4407
+ return this.#base.readdir(this.#scope(path6));
4467
4408
  }
4468
- readdirWithFileTypes(path7) {
4469
- return this.#base.readdirWithFileTypes(this.#scope(path7));
4409
+ readdirWithFileTypes(path6) {
4410
+ return this.#base.readdirWithFileTypes(this.#scope(path6));
4470
4411
  }
4471
- exists(path7) {
4472
- return this.#base.exists(this.#scope(path7));
4412
+ exists(path6) {
4413
+ return this.#base.exists(this.#scope(path6));
4473
4414
  }
4474
- readlink(path7) {
4475
- return this.#base.readlink(this.#scope(path7));
4415
+ readlink(path6) {
4416
+ return this.#base.readlink(this.#scope(path6));
4476
4417
  }
4477
- realpath(path7) {
4478
- return this.#base.realpath(this.#scope(path7)).then((p) => this.#unscope(p));
4418
+ realpath(path6) {
4419
+ return this.#base.realpath(this.#scope(path6)).then((p) => this.#unscope(p));
4479
4420
  }
4480
- utimes(path7, atime, mtime) {
4481
- return this.#base.utimes(this.#scope(path7), atime, mtime);
4421
+ utimes(path6, atime, mtime) {
4422
+ return this.#base.utimes(this.#scope(path6), atime, mtime);
4482
4423
  }
4483
4424
  resolvePath(base, relativePath) {
4484
4425
  return this.#base.resolvePath(base, relativePath);
@@ -4901,8 +4842,8 @@ import { BashTransformPipeline } from "just-bash";
4901
4842
 
4902
4843
  // packages/text2sql/src/lib/agents/sql-transform-plugins.ts
4903
4844
  import { parse as parse2, serialize } from "just-bash";
4904
- import { createHash as createHash4 } from "node:crypto";
4905
- import * as path6 from "node:path";
4845
+ import { createHash as createHash3 } from "node:crypto";
4846
+ import * as path5 from "node:path";
4906
4847
  import {
4907
4848
  BashException,
4908
4849
  asStaticWordText as asStaticWordText2
@@ -5397,7 +5338,7 @@ function isBlockedSimpleCommand(command, context, mode, options) {
5397
5338
  if (!commandName) {
5398
5339
  return false;
5399
5340
  }
5400
- const normalizedName = path6.posix.basename(commandName).toLowerCase();
5341
+ const normalizedName = path5.posix.basename(commandName).toLowerCase();
5401
5342
  if (BLOCKED_DB_CLIENT_COMMANDS.has(normalizedName)) {
5402
5343
  return true;
5403
5344
  }
@@ -5575,7 +5516,7 @@ function rewriteSqlCommand(cmd, ast) {
5575
5516
  const dbName = asStaticWordText2(cmd.args[1]);
5576
5517
  const sqlArgs = cmd.args.slice(2);
5577
5518
  const unquotedSql = extractSqlText(sqlArgs);
5578
- const hash2 = createHash4("sha256").update(serialize(ast)).digest("hex").slice(0, 12);
5519
+ const hash2 = createHash3("sha256").update(serialize(ast)).digest("hex").slice(0, 12);
5579
5520
  const sqlPath = `/tmp/sql-inline-${subcommand}-${hash2}.sql`;
5580
5521
  const heredocTag = `SQL_${hash2.toUpperCase()}`;
5581
5522
  const groupScript = [
@@ -5687,7 +5628,6 @@ import {
5687
5628
  } from "@deepagents/context";
5688
5629
 
5689
5630
  // packages/text2sql/src/lib/sql.ts
5690
- import "@deepagents/agent";
5691
5631
  var text2SqlValidationMarker = /* @__PURE__ */ Symbol("Text2SqlValidationError");
5692
5632
  var text2SqlUnknownAdapterMarker = /* @__PURE__ */ Symbol("Text2SqlUnknownAdapterError");
5693
5633
  var Text2SqlValidationError = class _Text2SqlValidationError extends Error {
@@ -5748,8 +5688,7 @@ var Text2Sql = class {
5748
5688
  this.#config = config;
5749
5689
  this.#indexer = new AdapterIndexer({
5750
5690
  adapters: config.adapters,
5751
- cache: config.cache,
5752
- lock: config.lock
5691
+ cache: config.cache
5753
5692
  });
5754
5693
  }
5755
5694
  #requireAdapter(name) {
@@ -5759,13 +5698,6 @@ var Text2Sql = class {
5759
5698
  }
5760
5699
  return adapter;
5761
5700
  }
5762
- #requireModel(op) {
5763
- const model = this.#config.model;
5764
- if (!model) {
5765
- throw new Error(`Text2Sql.${op}() requires a model in Text2SqlConfig`);
5766
- }
5767
- return model;
5768
- }
5769
5701
  adapterNames() {
5770
5702
  return Object.keys(this.#config.adapters);
5771
5703
  }
@@ -5824,18 +5756,6 @@ var Text2Sql = class {
5824
5756
  onProgress: options.onProgress
5825
5757
  });
5826
5758
  }
5827
- async toSql(input, adapterName) {
5828
- const adapter = this.#requireAdapter(adapterName);
5829
- const model = this.#requireModel("toSql");
5830
- const fragments = await this.#indexer.indexAdapter(adapterName);
5831
- const result = await toSql({
5832
- input,
5833
- adapter,
5834
- fragments,
5835
- model
5836
- });
5837
- return result.sql;
5838
- }
5839
5759
  async toPairs(adapterName, factory) {
5840
5760
  const adapter = this.#requireAdapter(adapterName);
5841
5761
  const producer = factory(adapter);
@@ -6011,7 +5931,6 @@ export {
6011
5931
  Checkpoint,
6012
5932
  FileCache,
6013
5933
  FileIndexCache,
6014
- FileIndexLock,
6015
5934
  JsonCache,
6016
5935
  MssqlFs,
6017
5936
  Point,