@deepagents/text2sql 7.1.1 → 7.1.2
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 +2 -4
- package/dist/index.js +40 -54
- package/dist/index.js.map +2 -2
- package/dist/lib/adapters/bigquery/constraint.bigquery.grounding.d.ts.map +1 -1
- package/dist/lib/adapters/bigquery/index.js +14 -17
- package/dist/lib/adapters/bigquery/index.js.map +2 -2
- package/dist/lib/adapters/bigquery/table.bigquery.grounding.d.ts +2 -2
- package/dist/lib/adapters/bigquery/table.bigquery.grounding.d.ts.map +1 -1
- package/dist/lib/adapters/clickhouse/clickhouse.sql-policy.d.ts.map +1 -1
- package/dist/lib/adapters/clickhouse/index.js +13 -9
- package/dist/lib/adapters/clickhouse/index.js.map +3 -3
- package/dist/lib/adapters/duckdb/duckdb.d.ts.map +1 -1
- package/dist/lib/adapters/duckdb/duckdb.sql-policy.d.ts.map +1 -1
- package/dist/lib/adapters/duckdb/index.js +12 -4
- package/dist/lib/adapters/duckdb/index.js.map +4 -4
- package/dist/lib/adapters/groundings/index.js +2 -2
- package/dist/lib/adapters/groundings/index.js.map +2 -2
- package/dist/lib/adapters/groundings/table.grounding.d.ts +2 -2
- package/dist/lib/adapters/groundings/table.grounding.d.ts.map +1 -1
- package/dist/lib/adapters/mysql/index.js +2 -2
- package/dist/lib/adapters/mysql/index.js.map +2 -2
- package/dist/lib/adapters/postgres/column-values.postgres.grounding.d.ts.map +1 -1
- package/dist/lib/adapters/postgres/index.js +17 -17
- package/dist/lib/adapters/postgres/index.js.map +2 -2
- package/dist/lib/adapters/spreadsheet/index.js +5 -3
- package/dist/lib/adapters/spreadsheet/index.js.map +2 -2
- package/dist/lib/adapters/spreadsheet/spreadsheet.d.ts.map +1 -1
- package/dist/lib/adapters/sqlite/index.js +2 -2
- package/dist/lib/adapters/sqlite/index.js.map +2 -2
- package/dist/lib/adapters/sqlserver/index.js +2 -2
- package/dist/lib/adapters/sqlserver/index.js.map +2 -2
- package/dist/lib/fs/mssql/mssql-fs.d.ts +3 -2
- package/dist/lib/fs/mssql/mssql-fs.d.ts.map +1 -1
- package/dist/lib/fs/postgres/postgres-fs.d.ts +3 -2
- package/dist/lib/fs/postgres/postgres-fs.d.ts.map +1 -1
- package/dist/lib/synthesis/decorators/filtered-producer.d.ts.map +1 -1
- package/dist/lib/synthesis/index.js +3 -3
- package/dist/lib/synthesis/index.js.map +2 -2
- package/package.json +18 -5
- package/dist/eval/src/evals/models.d.ts +0 -12
- package/dist/eval/src/evals/models.d.ts.map +0 -1
- package/dist/eval/src/evals/sql-create-context/sql-create-context.eval.d.ts +0 -2
- package/dist/eval/src/evals/sql-create-context/sql-create-context.eval.d.ts.map +0 -1
- package/dist/scripts/scripts/bigquery-test.d.ts +0 -2
- package/dist/scripts/scripts/bigquery-test.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -452,10 +452,8 @@ callers wait. When each waiter gets the key, its `index()` call reads the cache
|
|
|
452
452
|
that the first caller wrote.
|
|
453
453
|
|
|
454
454
|
`SqliteStore` shares keys between the processes on one host. For a fleet of
|
|
455
|
-
hosts, acquire the key from a service that all hosts share,
|
|
456
|
-
|
|
457
|
-
key and a `FileIndexCache` from `TEXT2SQL_INDEX_CACHE_DIR` /
|
|
458
|
-
`TEXT2SQL_INDEX_VERSION`.
|
|
455
|
+
hosts, acquire the key from a service that all hosts share, for example a
|
|
456
|
+
Postgres advisory lock, and give all hosts the same cache.
|
|
459
457
|
|
|
460
458
|
> On object-storage-backed volumes (GCS/S3 FUSE) `rename` is not atomic. The
|
|
461
459
|
> `FileIndexCache` parse-as-miss behavior tolerates a torn write: the next
|
package/dist/index.js
CHANGED
|
@@ -2347,7 +2347,6 @@ var MssqlFs = class _MssqlFs {
|
|
|
2347
2347
|
#root;
|
|
2348
2348
|
#schema;
|
|
2349
2349
|
#ownsPool;
|
|
2350
|
-
#isInitialized = false;
|
|
2351
2350
|
constructor(options) {
|
|
2352
2351
|
this.#chunkSize = options.chunkSize ?? 1024 * 1024;
|
|
2353
2352
|
const schema = options.schema ?? "dbo";
|
|
@@ -2379,7 +2378,18 @@ var MssqlFs = class _MssqlFs {
|
|
|
2379
2378
|
#t(name) {
|
|
2380
2379
|
return `[${this.#schema}].[${name}]`;
|
|
2381
2380
|
}
|
|
2382
|
-
|
|
2381
|
+
/** Opens the file system: creates its tables and its root directories. */
|
|
2382
|
+
static async create(options) {
|
|
2383
|
+
const fs = new _MssqlFs(options);
|
|
2384
|
+
try {
|
|
2385
|
+
await fs.#initialize();
|
|
2386
|
+
} catch (error) {
|
|
2387
|
+
await fs.close();
|
|
2388
|
+
throw error;
|
|
2389
|
+
}
|
|
2390
|
+
return fs;
|
|
2391
|
+
}
|
|
2392
|
+
async #initialize() {
|
|
2383
2393
|
if (this.#ownsPool) {
|
|
2384
2394
|
await this.#pool.connect();
|
|
2385
2395
|
}
|
|
@@ -2401,12 +2411,12 @@ var MssqlFs = class _MssqlFs {
|
|
|
2401
2411
|
}
|
|
2402
2412
|
const rootSlashExists = rowsOf(
|
|
2403
2413
|
existsRow,
|
|
2404
|
-
await this.#
|
|
2414
|
+
await this.#query(
|
|
2405
2415
|
`SELECT CASE WHEN EXISTS(SELECT 1 FROM ${this.#t("fs_entries")} WHERE path = '/') THEN 1 ELSE 0 END as [exists]`
|
|
2406
2416
|
)
|
|
2407
2417
|
);
|
|
2408
2418
|
if (rootSlashExists[0].exists === 0) {
|
|
2409
|
-
await this.#
|
|
2419
|
+
await this.#exec(
|
|
2410
2420
|
`INSERT INTO ${this.#t("fs_entries")} (path, type, mode, size, mtime) VALUES ('/', 'directory', 493, 0, @p0)`,
|
|
2411
2421
|
[Date.now()]
|
|
2412
2422
|
);
|
|
@@ -2415,26 +2425,18 @@ var MssqlFs = class _MssqlFs {
|
|
|
2415
2425
|
await this.#createParentDirs(this.#root);
|
|
2416
2426
|
const rootExists = rowsOf(
|
|
2417
2427
|
existsRow,
|
|
2418
|
-
await this.#
|
|
2428
|
+
await this.#query(
|
|
2419
2429
|
`SELECT CASE WHEN EXISTS(SELECT 1 FROM ${this.#t("fs_entries")} WHERE path = @p0) THEN 1 ELSE 0 END as [exists]`,
|
|
2420
2430
|
[this.#root]
|
|
2421
2431
|
)
|
|
2422
2432
|
);
|
|
2423
2433
|
if (rootExists[0].exists === 0) {
|
|
2424
|
-
await this.#
|
|
2434
|
+
await this.#exec(
|
|
2425
2435
|
`INSERT INTO ${this.#t("fs_entries")} (path, type, mode, size, mtime) VALUES (@p0, 'directory', 493, 0, @p1)`,
|
|
2426
2436
|
[this.#root, Date.now()]
|
|
2427
2437
|
);
|
|
2428
2438
|
}
|
|
2429
2439
|
}
|
|
2430
|
-
this.#isInitialized = true;
|
|
2431
|
-
}
|
|
2432
|
-
#ensureInitialized() {
|
|
2433
|
-
if (!this.#isInitialized) {
|
|
2434
|
-
throw new Error(
|
|
2435
|
-
"MssqlFs not initialized. Call await fs.initialize() after construction."
|
|
2436
|
-
);
|
|
2437
|
-
}
|
|
2438
2440
|
}
|
|
2439
2441
|
async #createParentDirs(p) {
|
|
2440
2442
|
const segments = p.split("/").filter(Boolean);
|
|
@@ -2443,27 +2445,27 @@ var MssqlFs = class _MssqlFs {
|
|
|
2443
2445
|
currentPath = path3.posix.join(currentPath, segments[i]);
|
|
2444
2446
|
const exists = rowsOf(
|
|
2445
2447
|
existsRow,
|
|
2446
|
-
await this.#
|
|
2448
|
+
await this.#query(
|
|
2447
2449
|
`SELECT CASE WHEN EXISTS(SELECT 1 FROM ${this.#t("fs_entries")} WHERE path = @p0) THEN 1 ELSE 0 END as [exists]`,
|
|
2448
2450
|
[currentPath]
|
|
2449
2451
|
)
|
|
2450
2452
|
);
|
|
2451
2453
|
if (exists[0].exists === 0) {
|
|
2452
|
-
await this.#
|
|
2454
|
+
await this.#exec(
|
|
2453
2455
|
`INSERT INTO ${this.#t("fs_entries")} (path, type, mode, size, mtime) VALUES (@p0, 'directory', 493, 0, @p1)`,
|
|
2454
2456
|
[currentPath, Date.now()]
|
|
2455
2457
|
);
|
|
2456
2458
|
}
|
|
2457
2459
|
}
|
|
2458
2460
|
}
|
|
2459
|
-
#
|
|
2461
|
+
#query(sql, params) {
|
|
2460
2462
|
const request = this.#pool.request();
|
|
2461
2463
|
params?.forEach((value, index2) => {
|
|
2462
2464
|
request.input(`p${index2}`, value);
|
|
2463
2465
|
});
|
|
2464
2466
|
return request.query(sql);
|
|
2465
2467
|
}
|
|
2466
|
-
async #
|
|
2468
|
+
async #exec(sql, params) {
|
|
2467
2469
|
const request = this.#pool.request();
|
|
2468
2470
|
params?.forEach((value, index2) => {
|
|
2469
2471
|
request.input(`p${index2}`, value);
|
|
@@ -2471,16 +2473,7 @@ var MssqlFs = class _MssqlFs {
|
|
|
2471
2473
|
const result = await request.query(sql);
|
|
2472
2474
|
return result.rowsAffected[0] ?? 0;
|
|
2473
2475
|
}
|
|
2474
|
-
async #query(sql, params) {
|
|
2475
|
-
this.#ensureInitialized();
|
|
2476
|
-
return this.#rawQuery(sql, params);
|
|
2477
|
-
}
|
|
2478
|
-
async #exec(sql, params) {
|
|
2479
|
-
this.#ensureInitialized();
|
|
2480
|
-
return this.#rawExec(sql, params);
|
|
2481
|
-
}
|
|
2482
2476
|
async #useTransaction(fn) {
|
|
2483
|
-
this.#ensureInitialized();
|
|
2484
2477
|
const mssql = _MssqlFs.#requireMssql();
|
|
2485
2478
|
const transaction = new mssql.Transaction(this.#pool);
|
|
2486
2479
|
try {
|
|
@@ -3433,7 +3426,6 @@ var PostgresFs = class _PostgresFs {
|
|
|
3433
3426
|
#root;
|
|
3434
3427
|
#schema;
|
|
3435
3428
|
#ownsPool;
|
|
3436
|
-
#isInitialized = false;
|
|
3437
3429
|
constructor(options) {
|
|
3438
3430
|
this.#chunkSize = options.chunkSize ?? 1024 * 1024;
|
|
3439
3431
|
const schema = options.schema ?? "public";
|
|
@@ -3465,17 +3457,28 @@ var PostgresFs = class _PostgresFs {
|
|
|
3465
3457
|
#t(name) {
|
|
3466
3458
|
return `"${this.#schema}"."${name}"`;
|
|
3467
3459
|
}
|
|
3468
|
-
|
|
3460
|
+
/** Opens the file system: creates its tables and its root directories. */
|
|
3461
|
+
static async create(options) {
|
|
3462
|
+
const fs = new _PostgresFs(options);
|
|
3463
|
+
try {
|
|
3464
|
+
await fs.#initialize();
|
|
3465
|
+
} catch (error) {
|
|
3466
|
+
await fs.close();
|
|
3467
|
+
throw error;
|
|
3468
|
+
}
|
|
3469
|
+
return fs;
|
|
3470
|
+
}
|
|
3471
|
+
async #initialize() {
|
|
3469
3472
|
const ddl = postgresFsDDL(this.#schema);
|
|
3470
3473
|
await this.#pool.query(ddl);
|
|
3471
3474
|
const rootSlashExists = rowsOf2(
|
|
3472
3475
|
existsRow2,
|
|
3473
|
-
await this.#
|
|
3476
|
+
await this.#query(
|
|
3474
3477
|
`SELECT EXISTS(SELECT 1 FROM ${this.#t("fs_entries")} WHERE path = '/') AS exists`
|
|
3475
3478
|
)
|
|
3476
3479
|
);
|
|
3477
3480
|
if (!rootSlashExists[0].exists) {
|
|
3478
|
-
await this.#
|
|
3481
|
+
await this.#exec(
|
|
3479
3482
|
`INSERT INTO ${this.#t("fs_entries")} (path, type, mode, size, mtime) VALUES ('/', 'directory', 493, 0, $1)`,
|
|
3480
3483
|
[Date.now()]
|
|
3481
3484
|
);
|
|
@@ -3484,26 +3487,18 @@ var PostgresFs = class _PostgresFs {
|
|
|
3484
3487
|
await this.#createParentDirs(this.#root);
|
|
3485
3488
|
const rootExists = rowsOf2(
|
|
3486
3489
|
existsRow2,
|
|
3487
|
-
await this.#
|
|
3490
|
+
await this.#query(
|
|
3488
3491
|
`SELECT EXISTS(SELECT 1 FROM ${this.#t("fs_entries")} WHERE path = $1) AS exists`,
|
|
3489
3492
|
[this.#root]
|
|
3490
3493
|
)
|
|
3491
3494
|
);
|
|
3492
3495
|
if (!rootExists[0].exists) {
|
|
3493
|
-
await this.#
|
|
3496
|
+
await this.#exec(
|
|
3494
3497
|
`INSERT INTO ${this.#t("fs_entries")} (path, type, mode, size, mtime) VALUES ($1, 'directory', 493, 0, $2)`,
|
|
3495
3498
|
[this.#root, Date.now()]
|
|
3496
3499
|
);
|
|
3497
3500
|
}
|
|
3498
3501
|
}
|
|
3499
|
-
this.#isInitialized = true;
|
|
3500
|
-
}
|
|
3501
|
-
#ensureInitialized() {
|
|
3502
|
-
if (!this.#isInitialized) {
|
|
3503
|
-
throw new Error(
|
|
3504
|
-
"PostgresFs not initialized. Call await fs.initialize() after construction."
|
|
3505
|
-
);
|
|
3506
|
-
}
|
|
3507
3502
|
}
|
|
3508
3503
|
async #createParentDirs(p) {
|
|
3509
3504
|
const segments = p.split("/").filter(Boolean);
|
|
@@ -3512,36 +3507,27 @@ var PostgresFs = class _PostgresFs {
|
|
|
3512
3507
|
currentPath = path4.posix.join(currentPath, segments[i]);
|
|
3513
3508
|
const exists = rowsOf2(
|
|
3514
3509
|
existsRow2,
|
|
3515
|
-
await this.#
|
|
3510
|
+
await this.#query(
|
|
3516
3511
|
`SELECT EXISTS(SELECT 1 FROM ${this.#t("fs_entries")} WHERE path = $1) AS exists`,
|
|
3517
3512
|
[currentPath]
|
|
3518
3513
|
)
|
|
3519
3514
|
);
|
|
3520
3515
|
if (!exists[0].exists) {
|
|
3521
|
-
await this.#
|
|
3516
|
+
await this.#exec(
|
|
3522
3517
|
`INSERT INTO ${this.#t("fs_entries")} (path, type, mode, size, mtime) VALUES ($1, 'directory', 493, 0, $2)`,
|
|
3523
3518
|
[currentPath, Date.now()]
|
|
3524
3519
|
);
|
|
3525
3520
|
}
|
|
3526
3521
|
}
|
|
3527
3522
|
}
|
|
3528
|
-
#
|
|
3523
|
+
#query(sql, params) {
|
|
3529
3524
|
return this.#pool.query(sql, params);
|
|
3530
3525
|
}
|
|
3531
|
-
async #
|
|
3526
|
+
async #exec(sql, params) {
|
|
3532
3527
|
const result = await this.#pool.query(sql, params);
|
|
3533
3528
|
return result.rowCount ?? 0;
|
|
3534
3529
|
}
|
|
3535
|
-
async #query(sql, params) {
|
|
3536
|
-
this.#ensureInitialized();
|
|
3537
|
-
return this.#rawQuery(sql, params);
|
|
3538
|
-
}
|
|
3539
|
-
async #exec(sql, params) {
|
|
3540
|
-
this.#ensureInitialized();
|
|
3541
|
-
return this.#rawExec(sql, params);
|
|
3542
|
-
}
|
|
3543
3530
|
async #useTransaction(fn) {
|
|
3544
|
-
this.#ensureInitialized();
|
|
3545
3531
|
const client = await this.#pool.connect();
|
|
3546
3532
|
try {
|
|
3547
3533
|
await client.query("BEGIN");
|