@axiom-lattice/pg-stores 3.1.8 → 3.1.9
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +9 -0
- package/dist/index.d.mts +26 -2
- package/dist/index.d.ts +26 -2
- package/dist/index.js +322 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +321 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/PostgreSQLA2AApiKeyStore.migrations.test.ts +2 -1
- package/src/__tests__/PostgreSQLA2AApiKeyStore.test.ts +45 -0
- package/src/__tests__/PostgreSQLOpenAuditStore.test.ts +100 -0
- package/src/__tests__/PostgreSQLProjectRoomMessageStore.test.ts +14 -0
- package/src/__tests__/PostgresSharedResourceStore.openGrants.test.ts +62 -0
- package/src/__tests__/create_open_audit_table.test.ts +40 -0
- package/src/createPgStoreConfig.ts +8 -0
- package/src/index.ts +1 -0
- package/src/migrations/add_api_key_grants.ts +25 -0
- package/src/migrations/add_share_open_grants.ts +23 -0
- package/src/migrations/create_open_audit_table.ts +36 -0
- package/src/stores/PostgreSQLA2AApiKeyStore.ts +90 -14
- package/src/stores/PostgreSQLOpenAuditStore.ts +143 -0
- package/src/stores/PostgreSQLProjectRoomMessageStore.ts +20 -1
- package/src/stores/PostgresSharedResourceStore.ts +5 -2
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { Pool as
|
|
2
|
+
import { Pool as Pool30 } from "pg";
|
|
3
3
|
|
|
4
4
|
// src/createPgStoreConfig.ts
|
|
5
|
-
import { Pool as
|
|
5
|
+
import { Pool as Pool27 } from "pg";
|
|
6
6
|
|
|
7
7
|
// src/migrations/migration.ts
|
|
8
8
|
var MigrationManager = class {
|
|
@@ -6137,6 +6137,24 @@ var addA2AKeyAssistantIds = {
|
|
|
6137
6137
|
}
|
|
6138
6138
|
};
|
|
6139
6139
|
|
|
6140
|
+
// src/migrations/add_api_key_grants.ts
|
|
6141
|
+
var addApiKeyGrants = {
|
|
6142
|
+
version: 178,
|
|
6143
|
+
name: "add_api_key_grants",
|
|
6144
|
+
up: async (client) => {
|
|
6145
|
+
await client.query(`
|
|
6146
|
+
ALTER TABLE lattice_a2a_api_keys
|
|
6147
|
+
ADD COLUMN IF NOT EXISTS grants JSONB
|
|
6148
|
+
`);
|
|
6149
|
+
},
|
|
6150
|
+
down: async (client) => {
|
|
6151
|
+
await client.query(`
|
|
6152
|
+
ALTER TABLE lattice_a2a_api_keys
|
|
6153
|
+
DROP COLUMN IF EXISTS grants
|
|
6154
|
+
`);
|
|
6155
|
+
}
|
|
6156
|
+
};
|
|
6157
|
+
|
|
6140
6158
|
// src/stores/PostgreSQLA2AApiKeyStore.ts
|
|
6141
6159
|
import { encrypt as encrypt5, decrypt as decrypt5 } from "@axiom-lattice/core";
|
|
6142
6160
|
import { randomUUID } from "crypto";
|
|
@@ -6150,6 +6168,7 @@ function mapRowToRecord(row) {
|
|
|
6150
6168
|
tenantId: row.tenant_id,
|
|
6151
6169
|
projectId: row.project_id,
|
|
6152
6170
|
assistantIds: row.assistant_ids ?? void 0,
|
|
6171
|
+
grants: row.grants ?? void 0,
|
|
6153
6172
|
label: row.label || void 0,
|
|
6154
6173
|
enabled: row.enabled,
|
|
6155
6174
|
createdAt: row.created_at,
|
|
@@ -6173,6 +6192,7 @@ var PostgreSQLA2AApiKeyStore = class {
|
|
|
6173
6192
|
this.migrationManager = new MigrationManager(this.pool);
|
|
6174
6193
|
this.migrationManager.register(createA2AApiKeysTable);
|
|
6175
6194
|
this.migrationManager.register(addA2AKeyAssistantIds);
|
|
6195
|
+
this.migrationManager.register(addApiKeyGrants);
|
|
6176
6196
|
if (options.autoMigrate !== false) {
|
|
6177
6197
|
this.initialize().catch((error) => {
|
|
6178
6198
|
console.error("Failed to initialize PostgreSQLA2AApiKeyStore:", error);
|
|
@@ -6201,13 +6221,28 @@ var PostgreSQLA2AApiKeyStore = class {
|
|
|
6201
6221
|
async ensureInitialized() {
|
|
6202
6222
|
if (!this.initialized) await this.initialize();
|
|
6203
6223
|
}
|
|
6224
|
+
/** Map rows that decrypt cleanly; skip rows under an unknown key. */
|
|
6225
|
+
safeMap(rows) {
|
|
6226
|
+
const out = [];
|
|
6227
|
+
for (const row of rows) {
|
|
6228
|
+
try {
|
|
6229
|
+
out.push(mapRowToRecord(row));
|
|
6230
|
+
} catch {
|
|
6231
|
+
}
|
|
6232
|
+
}
|
|
6233
|
+
return out;
|
|
6234
|
+
}
|
|
6204
6235
|
async findByKey(key) {
|
|
6205
6236
|
await this.ensureInitialized();
|
|
6206
6237
|
const all = await this.pool.query(
|
|
6207
6238
|
`SELECT * FROM lattice_a2a_api_keys WHERE enabled = true`
|
|
6208
6239
|
);
|
|
6209
6240
|
for (const row of all.rows) {
|
|
6210
|
-
|
|
6241
|
+
try {
|
|
6242
|
+
if (decrypt5(row.key_value) === key) return mapRowToRecord(row);
|
|
6243
|
+
} catch {
|
|
6244
|
+
continue;
|
|
6245
|
+
}
|
|
6211
6246
|
}
|
|
6212
6247
|
return null;
|
|
6213
6248
|
}
|
|
@@ -6217,7 +6252,12 @@ var PostgreSQLA2AApiKeyStore = class {
|
|
|
6217
6252
|
`SELECT * FROM lattice_a2a_api_keys WHERE id = $1`,
|
|
6218
6253
|
[id]
|
|
6219
6254
|
);
|
|
6220
|
-
|
|
6255
|
+
if (!result.rows[0]) return null;
|
|
6256
|
+
try {
|
|
6257
|
+
return mapRowToRecord(result.rows[0]);
|
|
6258
|
+
} catch {
|
|
6259
|
+
return null;
|
|
6260
|
+
}
|
|
6221
6261
|
}
|
|
6222
6262
|
async list(params) {
|
|
6223
6263
|
await this.ensureInitialized();
|
|
@@ -6228,26 +6268,67 @@ var PostgreSQLA2AApiKeyStore = class {
|
|
|
6228
6268
|
`SELECT * FROM lattice_a2a_api_keys WHERE tenant_id = $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3`,
|
|
6229
6269
|
[params.tenantId, limit, offset]
|
|
6230
6270
|
);
|
|
6231
|
-
return result2.rows
|
|
6271
|
+
return this.safeMap(result2.rows);
|
|
6232
6272
|
}
|
|
6233
6273
|
const result = await this.pool.query(
|
|
6234
6274
|
`SELECT * FROM lattice_a2a_api_keys ORDER BY created_at DESC LIMIT $1 OFFSET $2`,
|
|
6235
6275
|
[limit, offset]
|
|
6236
6276
|
);
|
|
6237
|
-
return result.rows
|
|
6277
|
+
return this.safeMap(result.rows);
|
|
6238
6278
|
}
|
|
6239
6279
|
async create(input) {
|
|
6240
6280
|
await this.ensureInitialized();
|
|
6241
6281
|
const key = generateApiKey();
|
|
6242
6282
|
const result = await this.pool.query(
|
|
6243
|
-
`INSERT INTO lattice_a2a_api_keys (key_value, tenant_id, project_id, assistant_ids, label)
|
|
6244
|
-
VALUES ($1, $2, $3, $4, $5) RETURNING *`,
|
|
6245
|
-
[
|
|
6283
|
+
`INSERT INTO lattice_a2a_api_keys (key_value, tenant_id, project_id, assistant_ids, grants, label)
|
|
6284
|
+
VALUES ($1, $2, $3, $4, $5, $6) RETURNING *`,
|
|
6285
|
+
[
|
|
6286
|
+
encrypt5(key),
|
|
6287
|
+
input.tenantId,
|
|
6288
|
+
input.projectId,
|
|
6289
|
+
input.assistantIds ? JSON.stringify(input.assistantIds) : null,
|
|
6290
|
+
input.grants ? JSON.stringify(input.grants) : null,
|
|
6291
|
+
input.label || null
|
|
6292
|
+
]
|
|
6246
6293
|
);
|
|
6247
6294
|
const record = mapRowToRecord(result.rows[0]);
|
|
6248
6295
|
record.key = key;
|
|
6249
6296
|
return record;
|
|
6250
6297
|
}
|
|
6298
|
+
async update(id, input) {
|
|
6299
|
+
await this.ensureInitialized();
|
|
6300
|
+
const sets = [];
|
|
6301
|
+
const values = [];
|
|
6302
|
+
if (input.label !== void 0) {
|
|
6303
|
+
values.push(input.label || null);
|
|
6304
|
+
sets.push(`label = $${values.length}`);
|
|
6305
|
+
}
|
|
6306
|
+
if (input.projectId !== void 0) {
|
|
6307
|
+
values.push(input.projectId);
|
|
6308
|
+
sets.push(`project_id = $${values.length}`);
|
|
6309
|
+
}
|
|
6310
|
+
if (input.assistantIds !== void 0) {
|
|
6311
|
+
values.push(input.assistantIds ? JSON.stringify(input.assistantIds) : null);
|
|
6312
|
+
sets.push(`assistant_ids = $${values.length}`);
|
|
6313
|
+
}
|
|
6314
|
+
if (input.grants !== void 0) {
|
|
6315
|
+
values.push(input.grants ? JSON.stringify(input.grants) : null);
|
|
6316
|
+
sets.push(`grants = $${values.length}`);
|
|
6317
|
+
}
|
|
6318
|
+
if (sets.length === 0) {
|
|
6319
|
+
const existing = await this.findById(id);
|
|
6320
|
+
if (!existing) throw new Error(`A2A API key not found: ${id}`);
|
|
6321
|
+
return existing;
|
|
6322
|
+
}
|
|
6323
|
+
sets.push("updated_at = NOW()");
|
|
6324
|
+
values.push(id);
|
|
6325
|
+
const result = await this.pool.query(
|
|
6326
|
+
`UPDATE lattice_a2a_api_keys SET ${sets.join(", ")} WHERE id = $${values.length} RETURNING *`,
|
|
6327
|
+
values
|
|
6328
|
+
);
|
|
6329
|
+
if (result.rows.length === 0) throw new Error(`A2A API key not found: ${id}`);
|
|
6330
|
+
return mapRowToRecord(result.rows[0]);
|
|
6331
|
+
}
|
|
6251
6332
|
async disable(id) {
|
|
6252
6333
|
await this.ensureInitialized();
|
|
6253
6334
|
const result = await this.pool.query(
|
|
@@ -6289,21 +6370,173 @@ var PostgreSQLA2AApiKeyStore = class {
|
|
|
6289
6370
|
);
|
|
6290
6371
|
const map2 = /* @__PURE__ */ new Map();
|
|
6291
6372
|
for (const row of result.rows) {
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
key,
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6373
|
+
try {
|
|
6374
|
+
const key = decrypt5(row.key_value);
|
|
6375
|
+
map2.set(key, {
|
|
6376
|
+
key,
|
|
6377
|
+
tenantId: row.tenant_id,
|
|
6378
|
+
projectId: row.project_id,
|
|
6379
|
+
assistantIds: row.assistant_ids ?? void 0,
|
|
6380
|
+
grants: row.grants ?? void 0
|
|
6381
|
+
});
|
|
6382
|
+
} catch {
|
|
6383
|
+
}
|
|
6299
6384
|
}
|
|
6300
6385
|
return map2;
|
|
6301
6386
|
}
|
|
6302
6387
|
};
|
|
6303
6388
|
|
|
6389
|
+
// src/stores/PostgreSQLOpenAuditStore.ts
|
|
6390
|
+
import { Pool as Pool17 } from "pg";
|
|
6391
|
+
|
|
6392
|
+
// src/migrations/create_open_audit_table.ts
|
|
6393
|
+
var createOpenAuditTable = {
|
|
6394
|
+
version: 179,
|
|
6395
|
+
name: "create_open_audit_table",
|
|
6396
|
+
up: async (client) => {
|
|
6397
|
+
await client.query(`
|
|
6398
|
+
CREATE TABLE IF NOT EXISTS lattice_open_audit (
|
|
6399
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
6400
|
+
tenant_id VARCHAR(255) NOT NULL,
|
|
6401
|
+
credential_id VARCHAR(255) NOT NULL,
|
|
6402
|
+
credential_kind VARCHAR(32) NOT NULL,
|
|
6403
|
+
project_id VARCHAR(255) NOT NULL,
|
|
6404
|
+
domain VARCHAR(255) NOT NULL,
|
|
6405
|
+
action VARCHAR(255) NOT NULL,
|
|
6406
|
+
args JSONB,
|
|
6407
|
+
status VARCHAR(16) NOT NULL,
|
|
6408
|
+
error_code VARCHAR(64),
|
|
6409
|
+
duration_ms INTEGER NOT NULL,
|
|
6410
|
+
created_at TIMESTAMP NOT NULL DEFAULT NOW()
|
|
6411
|
+
)
|
|
6412
|
+
`);
|
|
6413
|
+
await client.query(`
|
|
6414
|
+
CREATE INDEX IF NOT EXISTS idx_lattice_open_audit_tenant_created
|
|
6415
|
+
ON lattice_open_audit(tenant_id, created_at DESC)
|
|
6416
|
+
`);
|
|
6417
|
+
},
|
|
6418
|
+
down: async (client) => {
|
|
6419
|
+
await client.query("DROP TABLE IF EXISTS lattice_open_audit");
|
|
6420
|
+
}
|
|
6421
|
+
};
|
|
6422
|
+
|
|
6423
|
+
// src/stores/PostgreSQLOpenAuditStore.ts
|
|
6424
|
+
var PostgreSQLOpenAuditStore = class {
|
|
6425
|
+
constructor(options) {
|
|
6426
|
+
this.initialized = false;
|
|
6427
|
+
this.ownsPool = true;
|
|
6428
|
+
this.initPromise = null;
|
|
6429
|
+
if (options.pool) {
|
|
6430
|
+
this.pool = options.pool;
|
|
6431
|
+
this.ownsPool = false;
|
|
6432
|
+
this.initialized = true;
|
|
6433
|
+
return;
|
|
6434
|
+
}
|
|
6435
|
+
this.pool = typeof options.poolConfig === "string" ? new Pool17({ connectionString: options.poolConfig }) : options.poolConfig ? new Pool17(options.poolConfig) : (() => {
|
|
6436
|
+
throw new Error("Either pool or poolConfig must be provided");
|
|
6437
|
+
})();
|
|
6438
|
+
this.migrationManager = new MigrationManager(this.pool);
|
|
6439
|
+
this.migrationManager.register(createOpenAuditTable);
|
|
6440
|
+
if (options.autoMigrate !== false) {
|
|
6441
|
+
this.initialize().catch((error) => {
|
|
6442
|
+
console.error("Failed to initialize PostgreSQLOpenAuditStore:", error);
|
|
6443
|
+
throw error;
|
|
6444
|
+
});
|
|
6445
|
+
}
|
|
6446
|
+
}
|
|
6447
|
+
async initialize() {
|
|
6448
|
+
if (this.initialized) return;
|
|
6449
|
+
if (this.initPromise) return this.initPromise;
|
|
6450
|
+
this.initPromise = (async () => {
|
|
6451
|
+
try {
|
|
6452
|
+
await this.migrationManager.migrate();
|
|
6453
|
+
this.initialized = true;
|
|
6454
|
+
} finally {
|
|
6455
|
+
this.initPromise = null;
|
|
6456
|
+
}
|
|
6457
|
+
})();
|
|
6458
|
+
return this.initPromise;
|
|
6459
|
+
}
|
|
6460
|
+
async dispose() {
|
|
6461
|
+
if (this.ownsPool && this.pool) await this.pool.end();
|
|
6462
|
+
}
|
|
6463
|
+
async ensureInitialized() {
|
|
6464
|
+
if (!this.initialized) await this.initialize();
|
|
6465
|
+
}
|
|
6466
|
+
async query(params) {
|
|
6467
|
+
await this.ensureInitialized();
|
|
6468
|
+
const clauses = ["tenant_id = $1"];
|
|
6469
|
+
const values = [params.tenantId];
|
|
6470
|
+
if (params.credentialId) {
|
|
6471
|
+
values.push(params.credentialId);
|
|
6472
|
+
clauses.push(`credential_id = $${values.length}`);
|
|
6473
|
+
}
|
|
6474
|
+
if (params.domain) {
|
|
6475
|
+
values.push(params.domain);
|
|
6476
|
+
clauses.push(`domain = $${values.length}`);
|
|
6477
|
+
}
|
|
6478
|
+
if (params.status) {
|
|
6479
|
+
values.push(params.status);
|
|
6480
|
+
clauses.push(`status = $${values.length}`);
|
|
6481
|
+
}
|
|
6482
|
+
if (params.from) {
|
|
6483
|
+
values.push(params.from);
|
|
6484
|
+
clauses.push(`created_at >= $${values.length}`);
|
|
6485
|
+
}
|
|
6486
|
+
if (params.to) {
|
|
6487
|
+
values.push(params.to);
|
|
6488
|
+
clauses.push(`created_at < $${values.length}`);
|
|
6489
|
+
}
|
|
6490
|
+
const limit = params.limit ?? 100;
|
|
6491
|
+
const offset = params.offset ?? 0;
|
|
6492
|
+
values.push(limit, offset);
|
|
6493
|
+
const { rows } = await this.pool.query(
|
|
6494
|
+
`SELECT * FROM lattice_open_audit
|
|
6495
|
+
WHERE ${clauses.join(" AND ")}
|
|
6496
|
+
ORDER BY created_at DESC
|
|
6497
|
+
LIMIT $${values.length - 1} OFFSET $${values.length}`,
|
|
6498
|
+
values
|
|
6499
|
+
);
|
|
6500
|
+
return rows.map((row) => ({
|
|
6501
|
+
id: row.id,
|
|
6502
|
+
tenantId: row.tenant_id,
|
|
6503
|
+
credentialId: row.credential_id,
|
|
6504
|
+
credentialKind: row.credential_kind,
|
|
6505
|
+
projectId: row.project_id,
|
|
6506
|
+
domain: row.domain,
|
|
6507
|
+
action: row.action,
|
|
6508
|
+
args: row.args,
|
|
6509
|
+
status: row.status,
|
|
6510
|
+
errorCode: row.error_code ?? void 0,
|
|
6511
|
+
durationMs: row.duration_ms,
|
|
6512
|
+
createdAt: row.created_at
|
|
6513
|
+
}));
|
|
6514
|
+
}
|
|
6515
|
+
async append(record) {
|
|
6516
|
+
await this.ensureInitialized();
|
|
6517
|
+
await this.pool.query(
|
|
6518
|
+
`INSERT INTO lattice_open_audit
|
|
6519
|
+
(tenant_id, credential_id, credential_kind, project_id, domain, action, args, status, error_code, duration_ms)
|
|
6520
|
+
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)`,
|
|
6521
|
+
[
|
|
6522
|
+
record.tenantId,
|
|
6523
|
+
record.credentialId,
|
|
6524
|
+
record.credentialKind,
|
|
6525
|
+
record.projectId,
|
|
6526
|
+
record.domain,
|
|
6527
|
+
record.action,
|
|
6528
|
+
record.args === void 0 ? null : JSON.stringify(record.args),
|
|
6529
|
+
record.status,
|
|
6530
|
+
record.errorCode ?? null,
|
|
6531
|
+
Math.max(0, Math.round(record.durationMs))
|
|
6532
|
+
]
|
|
6533
|
+
);
|
|
6534
|
+
}
|
|
6535
|
+
};
|
|
6536
|
+
|
|
6304
6537
|
// src/stores/PostgreSQLAgentWebAppStore.ts
|
|
6305
6538
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
6306
|
-
import { Pool as
|
|
6539
|
+
import { Pool as Pool18 } from "pg";
|
|
6307
6540
|
|
|
6308
6541
|
// src/migrations/agent_web_apps_migration.ts
|
|
6309
6542
|
var createAgentWebAppsTable = {
|
|
@@ -6416,7 +6649,7 @@ var PostgreSQLAgentWebAppStore = class {
|
|
|
6416
6649
|
this.initialized = true;
|
|
6417
6650
|
return;
|
|
6418
6651
|
}
|
|
6419
|
-
this.pool = typeof options.poolConfig === "string" ? new
|
|
6652
|
+
this.pool = typeof options.poolConfig === "string" ? new Pool18({ connectionString: options.poolConfig }) : options.poolConfig ? new Pool18(options.poolConfig) : (() => {
|
|
6420
6653
|
throw new Error("Either pool or poolConfig must be provided");
|
|
6421
6654
|
})();
|
|
6422
6655
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -6555,7 +6788,7 @@ var PostgreSQLAgentWebAppStore = class {
|
|
|
6555
6788
|
};
|
|
6556
6789
|
|
|
6557
6790
|
// src/stores/PostgreSQLScheduleStorage.ts
|
|
6558
|
-
import { Pool as
|
|
6791
|
+
import { Pool as Pool19 } from "pg";
|
|
6559
6792
|
import {
|
|
6560
6793
|
ScheduledTaskStatus
|
|
6561
6794
|
} from "@axiom-lattice/protocols";
|
|
@@ -6732,9 +6965,9 @@ var PostgreSQLScheduleStorage = class {
|
|
|
6732
6965
|
return;
|
|
6733
6966
|
}
|
|
6734
6967
|
if (typeof options.poolConfig === "string") {
|
|
6735
|
-
this.pool = new
|
|
6968
|
+
this.pool = new Pool19({ connectionString: options.poolConfig });
|
|
6736
6969
|
} else if (options.poolConfig) {
|
|
6737
|
-
this.pool = new
|
|
6970
|
+
this.pool = new Pool19(options.poolConfig);
|
|
6738
6971
|
} else {
|
|
6739
6972
|
throw new Error("Either pool or poolConfig must be provided");
|
|
6740
6973
|
}
|
|
@@ -7172,7 +7405,7 @@ var PostgreSQLScheduleStorage = class {
|
|
|
7172
7405
|
};
|
|
7173
7406
|
|
|
7174
7407
|
// src/stores/PostgreSQLTaskStore.ts
|
|
7175
|
-
import { Pool as
|
|
7408
|
+
import { Pool as Pool20 } from "pg";
|
|
7176
7409
|
|
|
7177
7410
|
// src/migrations/task_migration.ts
|
|
7178
7411
|
var createTasksTable = {
|
|
@@ -7387,9 +7620,9 @@ var PostgreSQLTaskStore = class {
|
|
|
7387
7620
|
return;
|
|
7388
7621
|
}
|
|
7389
7622
|
if (typeof options.poolConfig === "string") {
|
|
7390
|
-
this.pool = new
|
|
7623
|
+
this.pool = new Pool20({ connectionString: options.poolConfig });
|
|
7391
7624
|
} else if (options.poolConfig) {
|
|
7392
|
-
this.pool = new
|
|
7625
|
+
this.pool = new Pool20(options.poolConfig);
|
|
7393
7626
|
} else {
|
|
7394
7627
|
throw new Error("Either pool or poolConfig must be provided");
|
|
7395
7628
|
}
|
|
@@ -8129,7 +8362,7 @@ var PostgreSQLTaskStore = class {
|
|
|
8129
8362
|
};
|
|
8130
8363
|
|
|
8131
8364
|
// src/stores/PostgreSQLTaskWorkItemStore.ts
|
|
8132
|
-
import { Pool as
|
|
8365
|
+
import { Pool as Pool21 } from "pg";
|
|
8133
8366
|
import { MAX_PENDING_EXECUTION_RESULTS_LIMIT } from "@axiom-lattice/protocols";
|
|
8134
8367
|
import { v4 } from "uuid";
|
|
8135
8368
|
|
|
@@ -8263,7 +8496,7 @@ var PostgreSQLTaskWorkItemStore = class {
|
|
|
8263
8496
|
this.initialized = true;
|
|
8264
8497
|
return;
|
|
8265
8498
|
}
|
|
8266
|
-
this.pool = typeof options.poolConfig === "string" ? new
|
|
8499
|
+
this.pool = typeof options.poolConfig === "string" ? new Pool21({ connectionString: options.poolConfig }) : options.poolConfig ? new Pool21(options.poolConfig) : (() => {
|
|
8267
8500
|
throw new Error("Either pool or poolConfig must be provided");
|
|
8268
8501
|
})();
|
|
8269
8502
|
this.ownsPool = true;
|
|
@@ -8516,7 +8749,7 @@ var PostgreSQLTaskWorkItemStore = class {
|
|
|
8516
8749
|
};
|
|
8517
8750
|
|
|
8518
8751
|
// src/stores/MenuStore.ts
|
|
8519
|
-
import { Pool as
|
|
8752
|
+
import { Pool as Pool22 } from "pg";
|
|
8520
8753
|
|
|
8521
8754
|
// src/migrations/menu_items_migration.ts
|
|
8522
8755
|
var createMenuItemsTable = {
|
|
@@ -8593,7 +8826,7 @@ var MenuStore = class {
|
|
|
8593
8826
|
this.initialized = true;
|
|
8594
8827
|
return;
|
|
8595
8828
|
}
|
|
8596
|
-
this.pool = typeof options.poolConfig === "string" ? new
|
|
8829
|
+
this.pool = typeof options.poolConfig === "string" ? new Pool22({ connectionString: options.poolConfig }) : options.poolConfig ? new Pool22(options.poolConfig) : (() => {
|
|
8597
8830
|
throw new Error("Either pool or poolConfig must be provided");
|
|
8598
8831
|
})();
|
|
8599
8832
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -8748,7 +8981,7 @@ var MenuStore = class {
|
|
|
8748
8981
|
};
|
|
8749
8982
|
|
|
8750
8983
|
// src/stores/PostgresSharedResourceStore.ts
|
|
8751
|
-
import { Pool as
|
|
8984
|
+
import { Pool as Pool23 } from "pg";
|
|
8752
8985
|
|
|
8753
8986
|
// src/migrations/shared_resources_migration.ts
|
|
8754
8987
|
var createSharedResourcesTable = {
|
|
@@ -8802,7 +9035,7 @@ var PostgresSharedResourceStore = class {
|
|
|
8802
9035
|
this.initialized = true;
|
|
8803
9036
|
return;
|
|
8804
9037
|
}
|
|
8805
|
-
this.pool = typeof options.poolConfig === "string" ? new
|
|
9038
|
+
this.pool = typeof options.poolConfig === "string" ? new Pool23({ connectionString: options.poolConfig }) : options.poolConfig ? new Pool23(options.poolConfig) : (() => {
|
|
8806
9039
|
throw new Error("Either pool or poolConfig must be provided");
|
|
8807
9040
|
})();
|
|
8808
9041
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -8850,8 +9083,8 @@ var PostgresSharedResourceStore = class {
|
|
|
8850
9083
|
`INSERT INTO lattice_shared_resources
|
|
8851
9084
|
(token, address, title, created_by, tenant_id, workspace_id, project_id,
|
|
8852
9085
|
assistant_id, vm_isolation, visibility, password_hash,
|
|
8853
|
-
expires_at, max_access, revoked)
|
|
8854
|
-
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14)
|
|
9086
|
+
expires_at, max_access, open_grants, revoked)
|
|
9087
|
+
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15)
|
|
8855
9088
|
RETURNING *`,
|
|
8856
9089
|
[
|
|
8857
9090
|
record.token,
|
|
@@ -8867,6 +9100,7 @@ var PostgresSharedResourceStore = class {
|
|
|
8867
9100
|
record.passwordHash,
|
|
8868
9101
|
record.expiresAt ? record.expiresAt.toISOString() : null,
|
|
8869
9102
|
record.maxAccess,
|
|
9103
|
+
record.openGrants ? JSON.stringify(record.openGrants) : null,
|
|
8870
9104
|
record.revoked
|
|
8871
9105
|
]
|
|
8872
9106
|
);
|
|
@@ -8962,6 +9196,7 @@ var PostgresSharedResourceStore = class {
|
|
|
8962
9196
|
passwordHash: row.password_hash,
|
|
8963
9197
|
expiresAt: row.expires_at ? new Date(row.expires_at) : null,
|
|
8964
9198
|
maxAccess: row.max_access,
|
|
9199
|
+
openGrants: row.open_grants ?? void 0,
|
|
8965
9200
|
accessCount: row.access_count ?? 0,
|
|
8966
9201
|
revoked: row.revoked ?? false,
|
|
8967
9202
|
createdAt: new Date(row.created_at),
|
|
@@ -8971,7 +9206,7 @@ var PostgresSharedResourceStore = class {
|
|
|
8971
9206
|
};
|
|
8972
9207
|
|
|
8973
9208
|
// src/stores/PostgreSQLCollectionStore.ts
|
|
8974
|
-
import { Pool as
|
|
9209
|
+
import { Pool as Pool24 } from "pg";
|
|
8975
9210
|
var PostgreSQLCollectionStore = class {
|
|
8976
9211
|
constructor(options) {
|
|
8977
9212
|
this.initialized = false;
|
|
@@ -8984,9 +9219,9 @@ var PostgreSQLCollectionStore = class {
|
|
|
8984
9219
|
return;
|
|
8985
9220
|
}
|
|
8986
9221
|
if (typeof options.poolConfig === "string") {
|
|
8987
|
-
this.pool = new
|
|
9222
|
+
this.pool = new Pool24({ connectionString: options.poolConfig });
|
|
8988
9223
|
} else if (options.poolConfig) {
|
|
8989
|
-
this.pool = new
|
|
9224
|
+
this.pool = new Pool24(options.poolConfig);
|
|
8990
9225
|
} else {
|
|
8991
9226
|
throw new Error("Either pool or poolConfig must be provided");
|
|
8992
9227
|
}
|
|
@@ -9101,7 +9336,7 @@ var PostgreSQLCollectionStore = class {
|
|
|
9101
9336
|
import { PostgresSaver } from "@langchain/langgraph-checkpoint-postgres";
|
|
9102
9337
|
|
|
9103
9338
|
// src/PGVectorStoreProvider.ts
|
|
9104
|
-
import { Pool as
|
|
9339
|
+
import { Pool as Pool25 } from "pg";
|
|
9105
9340
|
import { PGVectorStore } from "@langchain/community/vectorstores/pgvector";
|
|
9106
9341
|
import { Document } from "@langchain/core/documents";
|
|
9107
9342
|
import { embeddingsLatticeManager } from "@axiom-lattice/core";
|
|
@@ -9175,7 +9410,7 @@ var PGVectorStoreProvider = class {
|
|
|
9175
9410
|
}
|
|
9176
9411
|
};
|
|
9177
9412
|
function createPGVectorStoreProvider(connectionString) {
|
|
9178
|
-
const pool = new
|
|
9413
|
+
const pool = new Pool25({ connectionString });
|
|
9179
9414
|
return {
|
|
9180
9415
|
provider: new PGVectorStoreProvider(pool, connectionString),
|
|
9181
9416
|
pool
|
|
@@ -9430,6 +9665,24 @@ var createConnectionConfigsTable = {
|
|
|
9430
9665
|
}
|
|
9431
9666
|
};
|
|
9432
9667
|
|
|
9668
|
+
// src/migrations/add_share_open_grants.ts
|
|
9669
|
+
var addShareOpenGrants = {
|
|
9670
|
+
version: 180,
|
|
9671
|
+
name: "add_share_open_grants",
|
|
9672
|
+
up: async (client) => {
|
|
9673
|
+
await client.query(`
|
|
9674
|
+
ALTER TABLE lattice_shared_resources
|
|
9675
|
+
ADD COLUMN IF NOT EXISTS open_grants JSONB
|
|
9676
|
+
`);
|
|
9677
|
+
},
|
|
9678
|
+
down: async (client) => {
|
|
9679
|
+
await client.query(`
|
|
9680
|
+
ALTER TABLE lattice_shared_resources
|
|
9681
|
+
DROP COLUMN IF EXISTS open_grants
|
|
9682
|
+
`);
|
|
9683
|
+
}
|
|
9684
|
+
};
|
|
9685
|
+
|
|
9433
9686
|
// src/migrations/collection_migrations.ts
|
|
9434
9687
|
var createCollectionsTable = {
|
|
9435
9688
|
version: 137,
|
|
@@ -9633,7 +9886,7 @@ var createProjectRoomReadStates = {
|
|
|
9633
9886
|
|
|
9634
9887
|
// src/stores/PostgreSQLCapabilityBundleStore.ts
|
|
9635
9888
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
9636
|
-
import { Pool as
|
|
9889
|
+
import { Pool as Pool26 } from "pg";
|
|
9637
9890
|
var duplicateMessage = "Capability bundle key already exists for tenant";
|
|
9638
9891
|
function map(row) {
|
|
9639
9892
|
return {
|
|
@@ -9666,7 +9919,7 @@ var PostgreSQLCapabilityBundleStore = class {
|
|
|
9666
9919
|
this.initialized = true;
|
|
9667
9920
|
return;
|
|
9668
9921
|
}
|
|
9669
|
-
this.pool = typeof options.poolConfig === "string" ? new
|
|
9922
|
+
this.pool = typeof options.poolConfig === "string" ? new Pool26({ connectionString: options.poolConfig }) : options.poolConfig ? new Pool26(options.poolConfig) : (() => {
|
|
9670
9923
|
throw new Error("Either pool or poolConfig must be provided");
|
|
9671
9924
|
})();
|
|
9672
9925
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -10342,6 +10595,22 @@ function mapRow5(row) {
|
|
|
10342
10595
|
createdAt: row.created_at
|
|
10343
10596
|
};
|
|
10344
10597
|
}
|
|
10598
|
+
function mapRowsTolerant(rows, scope) {
|
|
10599
|
+
const messages = [];
|
|
10600
|
+
for (const row of rows) {
|
|
10601
|
+
try {
|
|
10602
|
+
messages.push(mapRow5(row));
|
|
10603
|
+
} catch (error) {
|
|
10604
|
+
console.warn("[ProjectRoomMessageStore] Skipping invalid message row", {
|
|
10605
|
+
tenantId: scope.tenantId,
|
|
10606
|
+
roomId: scope.roomId,
|
|
10607
|
+
rowId: typeof row.id === "string" ? row.id : void 0,
|
|
10608
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
10609
|
+
});
|
|
10610
|
+
}
|
|
10611
|
+
}
|
|
10612
|
+
return messages;
|
|
10613
|
+
}
|
|
10345
10614
|
function isUniqueViolation2(error) {
|
|
10346
10615
|
return typeof error === "object" && error !== null && "code" in error && error.code === "23505";
|
|
10347
10616
|
}
|
|
@@ -10407,7 +10676,7 @@ var PostgreSQLProjectRoomMessageStore = class {
|
|
|
10407
10676
|
WHERE tenant_id = $1 AND room_id = $2 ORDER BY created_at DESC, id DESC LIMIT $3`,
|
|
10408
10677
|
[input.tenantId, input.roomId, limit]
|
|
10409
10678
|
);
|
|
10410
|
-
return result.rows.
|
|
10679
|
+
return mapRowsTolerant(result.rows, { tenantId: input.tenantId, roomId: input.roomId });
|
|
10411
10680
|
}
|
|
10412
10681
|
/** Finds a message by tenant-scoped ID. */
|
|
10413
10682
|
async findById(tenantId, id) {
|
|
@@ -10489,7 +10758,7 @@ var PostgreSQLProjectRoomReadStateStore = class {
|
|
|
10489
10758
|
|
|
10490
10759
|
// src/createPgStoreConfig.ts
|
|
10491
10760
|
async function createPgStoreConfig(connectionString) {
|
|
10492
|
-
const pool = new
|
|
10761
|
+
const pool = new Pool27({ connectionString });
|
|
10493
10762
|
const mm = new MigrationManager(pool);
|
|
10494
10763
|
mm.register(createThreadsTable);
|
|
10495
10764
|
mm.register(createScheduledTasksTable);
|
|
@@ -10542,6 +10811,9 @@ async function createPgStoreConfig(connectionString) {
|
|
|
10542
10811
|
mm.register(addWorkflowRunsTenantStatusUpdatedIndex);
|
|
10543
10812
|
mm.register(addProjectKindColumn);
|
|
10544
10813
|
mm.register(addA2AKeyAssistantIds);
|
|
10814
|
+
mm.register(addApiKeyGrants);
|
|
10815
|
+
mm.register(createOpenAuditTable);
|
|
10816
|
+
mm.register(addShareOpenGrants);
|
|
10545
10817
|
mm.register(addTaskWorkItemEventKeyMigration);
|
|
10546
10818
|
mm.register(createAgentWebAppsTable);
|
|
10547
10819
|
mm.register(createCapabilityBundlesTable);
|
|
@@ -10578,6 +10850,7 @@ async function createPgStoreConfig(connectionString) {
|
|
|
10578
10850
|
task: new PostgreSQLTaskStore(opts),
|
|
10579
10851
|
taskWorkItem: taskWorkItemStore,
|
|
10580
10852
|
a2aApiKey: new PostgreSQLA2AApiKeyStore(opts),
|
|
10853
|
+
openAudit: new PostgreSQLOpenAuditStore(opts),
|
|
10581
10854
|
agentWebApp: new PostgreSQLAgentWebAppStore(opts),
|
|
10582
10855
|
capabilityBundle: new PostgreSQLCapabilityBundleStore(opts),
|
|
10583
10856
|
schedule: new PostgreSQLScheduleStorage(opts),
|
|
@@ -10595,7 +10868,7 @@ async function createPgStoreConfig(connectionString) {
|
|
|
10595
10868
|
}
|
|
10596
10869
|
|
|
10597
10870
|
// src/stores/PostgreSQLSkillStore.ts
|
|
10598
|
-
import { Pool as
|
|
10871
|
+
import { Pool as Pool28 } from "pg";
|
|
10599
10872
|
var PostgreSQLSkillStore = class {
|
|
10600
10873
|
constructor(options) {
|
|
10601
10874
|
this.initialized = false;
|
|
@@ -10608,9 +10881,9 @@ var PostgreSQLSkillStore = class {
|
|
|
10608
10881
|
return;
|
|
10609
10882
|
}
|
|
10610
10883
|
if (typeof options.poolConfig === "string") {
|
|
10611
|
-
this.pool = new
|
|
10884
|
+
this.pool = new Pool28({ connectionString: options.poolConfig });
|
|
10612
10885
|
} else if (options.poolConfig) {
|
|
10613
|
-
this.pool = new
|
|
10886
|
+
this.pool = new Pool28(options.poolConfig);
|
|
10614
10887
|
} else {
|
|
10615
10888
|
throw new Error("Either pool or poolConfig must be provided");
|
|
10616
10889
|
}
|
|
@@ -10911,7 +11184,7 @@ var PostgreSQLSkillStore = class {
|
|
|
10911
11184
|
};
|
|
10912
11185
|
|
|
10913
11186
|
// src/stores/ChannelIdentityMappingStore.ts
|
|
10914
|
-
import { Pool as
|
|
11187
|
+
import { Pool as Pool29 } from "pg";
|
|
10915
11188
|
var ChannelIdentityMappingStore = class {
|
|
10916
11189
|
constructor(options) {
|
|
10917
11190
|
this.initialized = false;
|
|
@@ -10923,7 +11196,7 @@ var ChannelIdentityMappingStore = class {
|
|
|
10923
11196
|
this.initialized = true;
|
|
10924
11197
|
return;
|
|
10925
11198
|
}
|
|
10926
|
-
this.pool = typeof options.poolConfig === "string" ? new
|
|
11199
|
+
this.pool = typeof options.poolConfig === "string" ? new Pool29({ connectionString: options.poolConfig }) : options.poolConfig ? new Pool29(options.poolConfig) : (() => {
|
|
10927
11200
|
throw new Error("Either pool or poolConfig must be provided");
|
|
10928
11201
|
})();
|
|
10929
11202
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -11149,7 +11422,7 @@ export {
|
|
|
11149
11422
|
MenuStore,
|
|
11150
11423
|
MigrationManager,
|
|
11151
11424
|
PGVectorStoreProvider,
|
|
11152
|
-
|
|
11425
|
+
Pool30 as Pool,
|
|
11153
11426
|
PostgreSQLA2AApiKeyStore,
|
|
11154
11427
|
PostgreSQLAgentWebAppStore,
|
|
11155
11428
|
PostgreSQLAssistantStore,
|
|
@@ -11161,6 +11434,7 @@ export {
|
|
|
11161
11434
|
PostgreSQLEvalStore,
|
|
11162
11435
|
PostgreSQLMcpServerConfigStore,
|
|
11163
11436
|
PostgreSQLMetricsServerConfigStore,
|
|
11437
|
+
PostgreSQLOpenAuditStore,
|
|
11164
11438
|
PostgreSQLProjectBotMembershipStore,
|
|
11165
11439
|
PostgreSQLProjectMembershipStore,
|
|
11166
11440
|
PostgreSQLProjectRoomMessageStore,
|