@deepagents/text2sql 7.1.3 → 7.2.0

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.
package/README.md CHANGED
@@ -438,7 +438,8 @@ To let only one caller introspect, acquire a key around `index()`. This example
438
438
  uses [`@zukhruf/mutex`](https://www.npmjs.com/package/@zukhruf/mutex):
439
439
 
440
440
  ```typescript
441
- import { Mutex, SqliteStore } from '@zukhruf/mutex';
441
+ import { Mutex } from '@zukhruf/mutex';
442
+ import { SqliteStore } from '@zukhruf/mutex/sqlite';
442
443
 
443
444
  const mutex = new Mutex(new SqliteStore('/var/lib/my-app/locks'));
444
445
 
package/dist/index.js CHANGED
@@ -548,9 +548,9 @@ SQL: ${sql.trim()}`,
548
548
  return "";
549
549
  }
550
550
  };
551
- function filterTablesByName(tables, filter) {
552
- if (!filter) return tables;
553
- return tables.filter((table2) => matchesFilter(table2.name, filter));
551
+ function filterTablesByName(tables2, filter) {
552
+ if (!filter) return tables2;
553
+ return tables2.filter((table2) => matchesFilter(table2.name, filter));
554
554
  }
555
555
  function filterRelationshipsByTables(relationships, tableNames) {
556
556
  if (tableNames === void 0) {
@@ -563,15 +563,15 @@ function filterRelationshipsByTables(relationships, tableNames) {
563
563
  (it) => tableNames.has(it.table) || tableNames.has(it.referenced_table)
564
564
  );
565
565
  }
566
- function applyTablesFilter(tables, relationships, filter) {
566
+ function applyTablesFilter(tables2, relationships, filter) {
567
567
  if (!filter) {
568
- return { tables, relationships };
568
+ return { tables: tables2, relationships };
569
569
  }
570
570
  const allowedNames = new Set(
571
- getTablesWithRelated(tables, relationships, filter)
571
+ getTablesWithRelated(tables2, relationships, filter)
572
572
  );
573
573
  return {
574
- tables: tables.filter((table2) => allowedNames.has(table2.name)),
574
+ tables: tables2.filter((table2) => allowedNames.has(table2.name)),
575
575
  relationships: filterRelationshipsByTables(relationships, allowedNames)
576
576
  };
577
577
  }
@@ -1545,6 +1545,7 @@ function hashConfig(config) {
1545
1545
  }
1546
1546
 
1547
1547
  // packages/text2sql/src/lib/fs/sqlite/sqlite-fs.ts
1548
+ import { Declaration } from "@zukhruf/sqlite-drift";
1548
1549
  import { transaction } from "@zukhruf/sqlite-transaction";
1549
1550
  import * as path2 from "node:path";
1550
1551
  import { DatabaseSync } from "node:sqlite";
@@ -1555,10 +1556,38 @@ import z5 from "zod";
1555
1556
  var entryType = z5.enum(["file", "directory", "symlink"]);
1556
1557
  var bigintColumn = z5.union([z5.number(), z5.string().regex(/^-?\d+$/)]).transform(Number);
1557
1558
 
1558
- // packages/text2sql/src/lib/fs/sqlite/ddl.sqlite-fs.sql
1559
- var ddl_sqlite_fs_default = "-- SQLite-based filesystem schema for artifact storage\n-- Tables: fs_entries (file/directory metadata), fs_chunks (file content)\n\n-- Performance PRAGMAs (session-level, run on each connection)\nPRAGMA journal_mode = WAL;\nPRAGMA synchronous = NORMAL;\nPRAGMA cache_size = -64000;\nPRAGMA temp_store = MEMORY;\nPRAGMA mmap_size = 268435456;\n\n-- Integrity\nPRAGMA foreign_keys = ON;\n\n-- Filesystem entries table (files, directories, symlinks)\nCREATE TABLE IF NOT EXISTS fs_entries (\n path TEXT PRIMARY KEY, -- Normalized absolute path (e.g., '/results/uuid.json')\n type TEXT NOT NULL, -- 'file' | 'directory' | 'symlink'\n mode INTEGER NOT NULL, -- Unix permissions (e.g., 0o644 = 420)\n size INTEGER NOT NULL, -- File size in bytes (0 for directories)\n mtime INTEGER NOT NULL, -- Modified time (milliseconds since epoch)\n symlinkTarget TEXT -- Target path for symlinks (NULL for files/dirs)\n);\n\nCREATE INDEX IF NOT EXISTS idx_fs_entries_type ON fs_entries(type);\n\n-- File content chunks table (for handling large files)\n-- Files are split into 1MB chunks to avoid SQLite BLOB performance issues\nCREATE TABLE IF NOT EXISTS fs_chunks (\n path TEXT NOT NULL, -- Reference to fs_entries.path\n chunkIndex INTEGER NOT NULL, -- 0-based chunk sequence\n data BLOB NOT NULL, -- Chunk content (up to 1MB default)\n PRIMARY KEY (path, chunkIndex),\n FOREIGN KEY (path) REFERENCES fs_entries(path) ON DELETE CASCADE ON UPDATE CASCADE\n);\n";
1559
+ // packages/text2sql/src/lib/fs/sqlite/ddl.sqlite-fs.ts
1560
+ var SETUP = `
1561
+ PRAGMA journal_mode = WAL;
1562
+ PRAGMA synchronous = NORMAL;
1563
+ PRAGMA cache_size = -64000;
1564
+ PRAGMA temp_store = MEMORY;
1565
+ PRAGMA mmap_size = 268435456;
1566
+ `;
1567
+ var statements = [
1568
+ // Filesystem entries table (files, directories, symlinks)
1569
+ `CREATE TABLE fs_entries (
1570
+ path TEXT PRIMARY KEY, -- Normalized absolute path (e.g., '/results/uuid.json')
1571
+ type TEXT NOT NULL, -- 'file' | 'directory' | 'symlink'
1572
+ mode INTEGER NOT NULL, -- Unix permissions (e.g., 0o644 = 420)
1573
+ size INTEGER NOT NULL, -- File size in bytes (0 for directories)
1574
+ mtime INTEGER NOT NULL, -- Modified time (milliseconds since epoch)
1575
+ symlinkTarget TEXT -- Target path for symlinks (NULL for files/dirs)
1576
+ )`,
1577
+ `CREATE INDEX idx_fs_entries_type ON fs_entries(type)`,
1578
+ // File content chunks table (for handling large files)
1579
+ // Files are split into 1MB chunks to avoid SQLite BLOB performance issues
1580
+ `CREATE TABLE fs_chunks (
1581
+ path TEXT NOT NULL, -- Reference to fs_entries.path
1582
+ chunkIndex INTEGER NOT NULL, -- 0-based chunk sequence
1583
+ data BLOB NOT NULL, -- Chunk content (up to 1MB default)
1584
+ PRIMARY KEY (path, chunkIndex),
1585
+ FOREIGN KEY (path) REFERENCES fs_entries(path) ON DELETE CASCADE ON UPDATE CASCADE
1586
+ )`
1587
+ ];
1560
1588
 
1561
1589
  // packages/text2sql/src/lib/fs/sqlite/sqlite-fs.ts
1590
+ var tables = new Declaration(statements, { rows: "keep" });
1562
1591
  var entryRow = z6.object({
1563
1592
  path: z6.string(),
1564
1593
  type: entryType,
@@ -1592,7 +1621,8 @@ var SqliteFs = class {
1592
1621
  const normalizedRoot = this.#normalizeRoot(options.root);
1593
1622
  this.#root = normalizedRoot === "/" ? "" : normalizedRoot;
1594
1623
  this.#db = new DatabaseSync(options.dbPath);
1595
- this.#db.exec(ddl_sqlite_fs_default);
1624
+ this.#db.exec(SETUP);
1625
+ tables.apply(this.#db);
1596
1626
  this.#sql = this.#db.createTagStore();
1597
1627
  const rootSlashExists = this.#sql.get`SELECT 1 FROM fs_entries WHERE path = '/'`;
1598
1628
  if (!rootSlashExists) {
@@ -4760,8 +4790,8 @@ function cloneInspectionContext(context) {
4760
4790
  function scriptContainsBlockedCommand(script, context, mode = "blocked-only") {
4761
4791
  return statementsContainBlockedCommand(script.statements, context, mode);
4762
4792
  }
4763
- function statementsContainBlockedCommand(statements, context, mode) {
4764
- for (const statement of statements) {
4793
+ function statementsContainBlockedCommand(statements2, context, mode) {
4794
+ for (const statement of statements2) {
4765
4795
  if (statementContainsBlockedCommand(statement, context, mode)) {
4766
4796
  return true;
4767
4797
  }
@@ -5426,9 +5456,9 @@ function rewriteSqlCommandsInList(commands, ast) {
5426
5456
  }
5427
5457
  return rewritten;
5428
5458
  }
5429
- function rewriteSqlCommandsInStatements(statements, ast) {
5459
+ function rewriteSqlCommandsInStatements(statements2, ast) {
5430
5460
  let rewritten = false;
5431
- for (const statement of statements) {
5461
+ for (const statement of statements2) {
5432
5462
  for (const pipeline of statement.pipelines) {
5433
5463
  if (rewriteSqlCommandsInList(pipeline.commands, ast)) {
5434
5464
  rewritten = true;