@deepagents/context 7.8.1 → 7.8.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/dist/index.js +13 -102
- package/dist/index.js.map +3 -3
- package/dist/lib/store/postgres.store.d.ts +5 -18
- package/dist/lib/store/postgres.store.d.ts.map +1 -1
- package/dist/lib/stream/postgres-notify-change-source.d.ts +3 -2
- package/dist/lib/stream/postgres-notify-change-source.d.ts.map +1 -1
- package/dist/lib/stream/postgres.stream-store.d.ts +3 -3
- package/dist/lib/stream/postgres.stream-store.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -11146,7 +11146,6 @@ async function postgresTransaction(pool, fn) {
|
|
|
11146
11146
|
}
|
|
11147
11147
|
|
|
11148
11148
|
// packages/context/src/lib/store/postgres.store.ts
|
|
11149
|
-
import { createRequire } from "node:module";
|
|
11150
11149
|
import { z as z14 } from "zod";
|
|
11151
11150
|
|
|
11152
11151
|
// packages/context/src/lib/store/ddl.postgres.ts
|
|
@@ -11360,7 +11359,6 @@ function toMessage2(row) {
|
|
|
11360
11359
|
var PostgresContextStore = class _PostgresContextStore extends ContextStore {
|
|
11361
11360
|
#pool;
|
|
11362
11361
|
#schema;
|
|
11363
|
-
#ownsPool;
|
|
11364
11362
|
constructor(options) {
|
|
11365
11363
|
super();
|
|
11366
11364
|
const schema = options.schema ?? "public";
|
|
@@ -11368,24 +11366,7 @@ var PostgresContextStore = class _PostgresContextStore extends ContextStore {
|
|
|
11368
11366
|
throw new Error(`Invalid schema name: "${schema}"`);
|
|
11369
11367
|
}
|
|
11370
11368
|
this.#schema = schema;
|
|
11371
|
-
|
|
11372
|
-
if (options.pool instanceof pg.Pool) {
|
|
11373
|
-
this.#pool = options.pool;
|
|
11374
|
-
this.#ownsPool = false;
|
|
11375
|
-
} else {
|
|
11376
|
-
this.#pool = typeof options.pool === "string" ? new pg.Pool({ connectionString: options.pool }) : new pg.Pool(options.pool);
|
|
11377
|
-
this.#ownsPool = true;
|
|
11378
|
-
}
|
|
11379
|
-
}
|
|
11380
|
-
static #requirePg() {
|
|
11381
|
-
try {
|
|
11382
|
-
const require2 = createRequire(import.meta.url);
|
|
11383
|
-
return require2("pg");
|
|
11384
|
-
} catch {
|
|
11385
|
-
throw new Error(
|
|
11386
|
-
'PostgresContextStore requires the "pg" package. Install it with: npm install pg'
|
|
11387
|
-
);
|
|
11388
|
-
}
|
|
11369
|
+
this.#pool = options.pool;
|
|
11389
11370
|
}
|
|
11390
11371
|
#t(name) {
|
|
11391
11372
|
return `"${this.#schema}"."${name}"`;
|
|
@@ -11393,12 +11374,7 @@ var PostgresContextStore = class _PostgresContextStore extends ContextStore {
|
|
|
11393
11374
|
/** Opens the store: creates its schema objects before it returns. */
|
|
11394
11375
|
static async create(options) {
|
|
11395
11376
|
const store = new _PostgresContextStore(options);
|
|
11396
|
-
|
|
11397
|
-
await store.#initialize();
|
|
11398
|
-
} catch (error) {
|
|
11399
|
-
await store.close();
|
|
11400
|
-
throw error;
|
|
11401
|
-
}
|
|
11377
|
+
await store.#initialize();
|
|
11402
11378
|
return store;
|
|
11403
11379
|
}
|
|
11404
11380
|
async #initialize() {
|
|
@@ -11417,15 +11393,6 @@ var PostgresContextStore = class _PostgresContextStore extends ContextStore {
|
|
|
11417
11393
|
async #rows(row, sql, params) {
|
|
11418
11394
|
return z14.array(row).parse(await this.#query(sql, params));
|
|
11419
11395
|
}
|
|
11420
|
-
/**
|
|
11421
|
-
* Close the pool connection.
|
|
11422
|
-
* Call this when done with the store.
|
|
11423
|
-
*/
|
|
11424
|
-
async close() {
|
|
11425
|
-
if (this.#ownsPool) {
|
|
11426
|
-
await this.#pool.end();
|
|
11427
|
-
}
|
|
11428
|
-
}
|
|
11429
11396
|
// ==========================================================================
|
|
11430
11397
|
// Chat Operations
|
|
11431
11398
|
// ==========================================================================
|
|
@@ -11887,7 +11854,7 @@ var PostgresContextStore = class _PostgresContextStore extends ContextStore {
|
|
|
11887
11854
|
};
|
|
11888
11855
|
|
|
11889
11856
|
// packages/context/src/lib/store/sqlserver.store.ts
|
|
11890
|
-
import { createRequire
|
|
11857
|
+
import { createRequire } from "node:module";
|
|
11891
11858
|
import { z as z15 } from "zod";
|
|
11892
11859
|
|
|
11893
11860
|
// packages/context/src/lib/store/ddl.sqlserver.ts
|
|
@@ -12168,7 +12135,7 @@ var SqlServerContextStore = class _SqlServerContextStore extends ContextStore {
|
|
|
12168
12135
|
}
|
|
12169
12136
|
static #requireMssql() {
|
|
12170
12137
|
try {
|
|
12171
|
-
const require2 =
|
|
12138
|
+
const require2 = createRequire(import.meta.url);
|
|
12172
12139
|
return require2("mssql");
|
|
12173
12140
|
} catch {
|
|
12174
12141
|
throw new Error(
|
|
@@ -13108,7 +13075,6 @@ function staticPartText(part, options) {
|
|
|
13108
13075
|
|
|
13109
13076
|
// packages/context/src/lib/stream/postgres-notify-change-source.ts
|
|
13110
13077
|
import { EventEmitter, on } from "node:events";
|
|
13111
|
-
import { createRequire as createRequire3 } from "node:module";
|
|
13112
13078
|
import pMemoize3 from "p-memoize";
|
|
13113
13079
|
import { z as z16 } from "zod";
|
|
13114
13080
|
|
|
@@ -13215,7 +13181,6 @@ var PostgresNotifyChangeSource = class _PostgresNotifyChangeSource {
|
|
|
13215
13181
|
#pool;
|
|
13216
13182
|
#schema;
|
|
13217
13183
|
#channel;
|
|
13218
|
-
#ownsPool;
|
|
13219
13184
|
/** Aborts when close() starts: every subscription ends, and no LISTEN connection opens. */
|
|
13220
13185
|
#closed = new AbortController();
|
|
13221
13186
|
/** Emits `stream:<id>` with a ChangeDelivery; `error` fails every subscription. */
|
|
@@ -13246,39 +13211,17 @@ var PostgresNotifyChangeSource = class _PostgresNotifyChangeSource {
|
|
|
13246
13211
|
assertIdentifier(channel, "channel");
|
|
13247
13212
|
this.#schema = schema;
|
|
13248
13213
|
this.#channel = channel;
|
|
13249
|
-
|
|
13250
|
-
if (options.pool instanceof pg.Pool) {
|
|
13251
|
-
this.#pool = options.pool;
|
|
13252
|
-
this.#ownsPool = false;
|
|
13253
|
-
} else {
|
|
13254
|
-
this.#pool = typeof options.pool === "string" ? new pg.Pool({ connectionString: options.pool }) : new pg.Pool(options.pool);
|
|
13255
|
-
this.#ownsPool = true;
|
|
13256
|
-
}
|
|
13257
|
-
}
|
|
13258
|
-
static #requirePg() {
|
|
13259
|
-
try {
|
|
13260
|
-
const require2 = createRequire3(import.meta.url);
|
|
13261
|
-
return require2("pg");
|
|
13262
|
-
} catch {
|
|
13263
|
-
throw new Error(
|
|
13264
|
-
'PostgresNotifyChangeSource requires the "pg" package. Install it with: npm install pg'
|
|
13265
|
-
);
|
|
13266
|
-
}
|
|
13214
|
+
this.#pool = options.pool;
|
|
13267
13215
|
}
|
|
13268
13216
|
/** Opens the source: installs the notify triggers before it returns. */
|
|
13269
13217
|
static async create(options) {
|
|
13270
13218
|
const source = new _PostgresNotifyChangeSource(options);
|
|
13271
|
-
|
|
13272
|
-
|
|
13273
|
-
|
|
13274
|
-
|
|
13275
|
-
|
|
13276
|
-
|
|
13277
|
-
);
|
|
13278
|
-
} catch (error) {
|
|
13279
|
-
await source.close();
|
|
13280
|
-
throw error;
|
|
13281
|
-
}
|
|
13219
|
+
await source.#pool.query(
|
|
13220
|
+
lockSchemaDDL(
|
|
13221
|
+
postgresStreamNotifyDDL(source.#schema, source.#channel),
|
|
13222
|
+
source.#schema
|
|
13223
|
+
)
|
|
13224
|
+
);
|
|
13282
13225
|
return source;
|
|
13283
13226
|
}
|
|
13284
13227
|
async *subscribe(streamId, signal) {
|
|
@@ -13314,9 +13257,6 @@ var PostgresNotifyChangeSource = class _PostgresNotifyChangeSource {
|
|
|
13314
13257
|
} catch {
|
|
13315
13258
|
}
|
|
13316
13259
|
await this.#releaseListener();
|
|
13317
|
-
if (this.#ownsPool) {
|
|
13318
|
-
await this.#pool.end();
|
|
13319
|
-
}
|
|
13320
13260
|
}
|
|
13321
13261
|
async #ensureListening() {
|
|
13322
13262
|
if (this.#listener instanceof Listening) return;
|
|
@@ -13391,7 +13331,6 @@ function assertIdentifier(value, label) {
|
|
|
13391
13331
|
}
|
|
13392
13332
|
|
|
13393
13333
|
// packages/context/src/lib/stream/postgres.stream-store.ts
|
|
13394
|
-
import { createRequire as createRequire4 } from "node:module";
|
|
13395
13334
|
import { z as z18 } from "zod";
|
|
13396
13335
|
|
|
13397
13336
|
// packages/context/src/lib/stream/ddl.stream.postgres.ts
|
|
@@ -13471,30 +13410,12 @@ var chunkRow = z18.object({
|
|
|
13471
13410
|
var PostgresStreamStore = class _PostgresStreamStore extends StreamStore {
|
|
13472
13411
|
#pool;
|
|
13473
13412
|
#schema;
|
|
13474
|
-
#ownsPool;
|
|
13475
13413
|
constructor(options) {
|
|
13476
13414
|
super();
|
|
13477
13415
|
const schema = options.schema ?? "public";
|
|
13478
13416
|
assertIdentifier2(schema, "schema");
|
|
13479
13417
|
this.#schema = schema;
|
|
13480
|
-
|
|
13481
|
-
if (options.pool instanceof pg.Pool) {
|
|
13482
|
-
this.#pool = options.pool;
|
|
13483
|
-
this.#ownsPool = false;
|
|
13484
|
-
} else {
|
|
13485
|
-
this.#pool = typeof options.pool === "string" ? new pg.Pool({ connectionString: options.pool }) : new pg.Pool(options.pool);
|
|
13486
|
-
this.#ownsPool = true;
|
|
13487
|
-
}
|
|
13488
|
-
}
|
|
13489
|
-
static #requirePg() {
|
|
13490
|
-
try {
|
|
13491
|
-
const require2 = createRequire4(import.meta.url);
|
|
13492
|
-
return require2("pg");
|
|
13493
|
-
} catch {
|
|
13494
|
-
throw new Error(
|
|
13495
|
-
'PostgresStreamStore requires the "pg" package. Install it with: npm install pg'
|
|
13496
|
-
);
|
|
13497
|
-
}
|
|
13418
|
+
this.#pool = options.pool;
|
|
13498
13419
|
}
|
|
13499
13420
|
#t(name) {
|
|
13500
13421
|
return `"${this.#schema}"."${name}"`;
|
|
@@ -13502,12 +13423,7 @@ var PostgresStreamStore = class _PostgresStreamStore extends StreamStore {
|
|
|
13502
13423
|
/** Opens the store: creates its tables before it returns. */
|
|
13503
13424
|
static async create(options) {
|
|
13504
13425
|
const store = new _PostgresStreamStore(options);
|
|
13505
|
-
|
|
13506
|
-
await store.#initialize();
|
|
13507
|
-
} catch (error) {
|
|
13508
|
-
await store.close();
|
|
13509
|
-
throw error;
|
|
13510
|
-
}
|
|
13426
|
+
await store.#initialize();
|
|
13511
13427
|
return store;
|
|
13512
13428
|
}
|
|
13513
13429
|
async #initialize() {
|
|
@@ -13515,11 +13431,6 @@ var PostgresStreamStore = class _PostgresStreamStore extends StreamStore {
|
|
|
13515
13431
|
lockSchemaDDL(postgresStreamDDL(this.#schema), this.#schema)
|
|
13516
13432
|
);
|
|
13517
13433
|
}
|
|
13518
|
-
async close() {
|
|
13519
|
-
if (this.#ownsPool && !this.#pool.ending) {
|
|
13520
|
-
await this.#pool.end();
|
|
13521
|
-
}
|
|
13522
|
-
}
|
|
13523
13434
|
async #query(sql, params) {
|
|
13524
13435
|
const result = await this.#pool.query(sql, params);
|
|
13525
13436
|
return result.rows;
|