@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.js
CHANGED
|
@@ -37,7 +37,7 @@ __export(index_exports, {
|
|
|
37
37
|
MenuStore: () => MenuStore,
|
|
38
38
|
MigrationManager: () => MigrationManager,
|
|
39
39
|
PGVectorStoreProvider: () => PGVectorStoreProvider,
|
|
40
|
-
Pool: () =>
|
|
40
|
+
Pool: () => import_pg30.Pool,
|
|
41
41
|
PostgreSQLA2AApiKeyStore: () => PostgreSQLA2AApiKeyStore,
|
|
42
42
|
PostgreSQLAgentWebAppStore: () => PostgreSQLAgentWebAppStore,
|
|
43
43
|
PostgreSQLAssistantStore: () => PostgreSQLAssistantStore,
|
|
@@ -49,6 +49,7 @@ __export(index_exports, {
|
|
|
49
49
|
PostgreSQLEvalStore: () => PostgreSQLEvalStore,
|
|
50
50
|
PostgreSQLMcpServerConfigStore: () => PostgreSQLMcpServerConfigStore,
|
|
51
51
|
PostgreSQLMetricsServerConfigStore: () => PostgreSQLMetricsServerConfigStore,
|
|
52
|
+
PostgreSQLOpenAuditStore: () => PostgreSQLOpenAuditStore,
|
|
52
53
|
PostgreSQLProjectBotMembershipStore: () => PostgreSQLProjectBotMembershipStore,
|
|
53
54
|
PostgreSQLProjectMembershipStore: () => PostgreSQLProjectMembershipStore,
|
|
54
55
|
PostgreSQLProjectRoomMessageStore: () => PostgreSQLProjectRoomMessageStore,
|
|
@@ -124,10 +125,10 @@ __export(index_exports, {
|
|
|
124
125
|
safeParse: () => safeParse
|
|
125
126
|
});
|
|
126
127
|
module.exports = __toCommonJS(index_exports);
|
|
127
|
-
var
|
|
128
|
+
var import_pg30 = require("pg");
|
|
128
129
|
|
|
129
130
|
// src/createPgStoreConfig.ts
|
|
130
|
-
var
|
|
131
|
+
var import_pg27 = require("pg");
|
|
131
132
|
|
|
132
133
|
// src/migrations/migration.ts
|
|
133
134
|
var MigrationManager = class {
|
|
@@ -6255,6 +6256,24 @@ var addA2AKeyAssistantIds = {
|
|
|
6255
6256
|
}
|
|
6256
6257
|
};
|
|
6257
6258
|
|
|
6259
|
+
// src/migrations/add_api_key_grants.ts
|
|
6260
|
+
var addApiKeyGrants = {
|
|
6261
|
+
version: 178,
|
|
6262
|
+
name: "add_api_key_grants",
|
|
6263
|
+
up: async (client) => {
|
|
6264
|
+
await client.query(`
|
|
6265
|
+
ALTER TABLE lattice_a2a_api_keys
|
|
6266
|
+
ADD COLUMN IF NOT EXISTS grants JSONB
|
|
6267
|
+
`);
|
|
6268
|
+
},
|
|
6269
|
+
down: async (client) => {
|
|
6270
|
+
await client.query(`
|
|
6271
|
+
ALTER TABLE lattice_a2a_api_keys
|
|
6272
|
+
DROP COLUMN IF EXISTS grants
|
|
6273
|
+
`);
|
|
6274
|
+
}
|
|
6275
|
+
};
|
|
6276
|
+
|
|
6258
6277
|
// src/stores/PostgreSQLA2AApiKeyStore.ts
|
|
6259
6278
|
var import_core5 = require("@axiom-lattice/core");
|
|
6260
6279
|
var import_crypto2 = require("crypto");
|
|
@@ -6268,6 +6287,7 @@ function mapRowToRecord(row) {
|
|
|
6268
6287
|
tenantId: row.tenant_id,
|
|
6269
6288
|
projectId: row.project_id,
|
|
6270
6289
|
assistantIds: row.assistant_ids ?? void 0,
|
|
6290
|
+
grants: row.grants ?? void 0,
|
|
6271
6291
|
label: row.label || void 0,
|
|
6272
6292
|
enabled: row.enabled,
|
|
6273
6293
|
createdAt: row.created_at,
|
|
@@ -6291,6 +6311,7 @@ var PostgreSQLA2AApiKeyStore = class {
|
|
|
6291
6311
|
this.migrationManager = new MigrationManager(this.pool);
|
|
6292
6312
|
this.migrationManager.register(createA2AApiKeysTable);
|
|
6293
6313
|
this.migrationManager.register(addA2AKeyAssistantIds);
|
|
6314
|
+
this.migrationManager.register(addApiKeyGrants);
|
|
6294
6315
|
if (options.autoMigrate !== false) {
|
|
6295
6316
|
this.initialize().catch((error) => {
|
|
6296
6317
|
console.error("Failed to initialize PostgreSQLA2AApiKeyStore:", error);
|
|
@@ -6319,13 +6340,28 @@ var PostgreSQLA2AApiKeyStore = class {
|
|
|
6319
6340
|
async ensureInitialized() {
|
|
6320
6341
|
if (!this.initialized) await this.initialize();
|
|
6321
6342
|
}
|
|
6343
|
+
/** Map rows that decrypt cleanly; skip rows under an unknown key. */
|
|
6344
|
+
safeMap(rows) {
|
|
6345
|
+
const out = [];
|
|
6346
|
+
for (const row of rows) {
|
|
6347
|
+
try {
|
|
6348
|
+
out.push(mapRowToRecord(row));
|
|
6349
|
+
} catch {
|
|
6350
|
+
}
|
|
6351
|
+
}
|
|
6352
|
+
return out;
|
|
6353
|
+
}
|
|
6322
6354
|
async findByKey(key) {
|
|
6323
6355
|
await this.ensureInitialized();
|
|
6324
6356
|
const all = await this.pool.query(
|
|
6325
6357
|
`SELECT * FROM lattice_a2a_api_keys WHERE enabled = true`
|
|
6326
6358
|
);
|
|
6327
6359
|
for (const row of all.rows) {
|
|
6328
|
-
|
|
6360
|
+
try {
|
|
6361
|
+
if ((0, import_core5.decrypt)(row.key_value) === key) return mapRowToRecord(row);
|
|
6362
|
+
} catch {
|
|
6363
|
+
continue;
|
|
6364
|
+
}
|
|
6329
6365
|
}
|
|
6330
6366
|
return null;
|
|
6331
6367
|
}
|
|
@@ -6335,7 +6371,12 @@ var PostgreSQLA2AApiKeyStore = class {
|
|
|
6335
6371
|
`SELECT * FROM lattice_a2a_api_keys WHERE id = $1`,
|
|
6336
6372
|
[id]
|
|
6337
6373
|
);
|
|
6338
|
-
|
|
6374
|
+
if (!result.rows[0]) return null;
|
|
6375
|
+
try {
|
|
6376
|
+
return mapRowToRecord(result.rows[0]);
|
|
6377
|
+
} catch {
|
|
6378
|
+
return null;
|
|
6379
|
+
}
|
|
6339
6380
|
}
|
|
6340
6381
|
async list(params) {
|
|
6341
6382
|
await this.ensureInitialized();
|
|
@@ -6346,26 +6387,67 @@ var PostgreSQLA2AApiKeyStore = class {
|
|
|
6346
6387
|
`SELECT * FROM lattice_a2a_api_keys WHERE tenant_id = $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3`,
|
|
6347
6388
|
[params.tenantId, limit, offset]
|
|
6348
6389
|
);
|
|
6349
|
-
return result2.rows
|
|
6390
|
+
return this.safeMap(result2.rows);
|
|
6350
6391
|
}
|
|
6351
6392
|
const result = await this.pool.query(
|
|
6352
6393
|
`SELECT * FROM lattice_a2a_api_keys ORDER BY created_at DESC LIMIT $1 OFFSET $2`,
|
|
6353
6394
|
[limit, offset]
|
|
6354
6395
|
);
|
|
6355
|
-
return result.rows
|
|
6396
|
+
return this.safeMap(result.rows);
|
|
6356
6397
|
}
|
|
6357
6398
|
async create(input) {
|
|
6358
6399
|
await this.ensureInitialized();
|
|
6359
6400
|
const key = generateApiKey();
|
|
6360
6401
|
const result = await this.pool.query(
|
|
6361
|
-
`INSERT INTO lattice_a2a_api_keys (key_value, tenant_id, project_id, assistant_ids, label)
|
|
6362
|
-
VALUES ($1, $2, $3, $4, $5) RETURNING *`,
|
|
6363
|
-
[
|
|
6402
|
+
`INSERT INTO lattice_a2a_api_keys (key_value, tenant_id, project_id, assistant_ids, grants, label)
|
|
6403
|
+
VALUES ($1, $2, $3, $4, $5, $6) RETURNING *`,
|
|
6404
|
+
[
|
|
6405
|
+
(0, import_core5.encrypt)(key),
|
|
6406
|
+
input.tenantId,
|
|
6407
|
+
input.projectId,
|
|
6408
|
+
input.assistantIds ? JSON.stringify(input.assistantIds) : null,
|
|
6409
|
+
input.grants ? JSON.stringify(input.grants) : null,
|
|
6410
|
+
input.label || null
|
|
6411
|
+
]
|
|
6364
6412
|
);
|
|
6365
6413
|
const record = mapRowToRecord(result.rows[0]);
|
|
6366
6414
|
record.key = key;
|
|
6367
6415
|
return record;
|
|
6368
6416
|
}
|
|
6417
|
+
async update(id, input) {
|
|
6418
|
+
await this.ensureInitialized();
|
|
6419
|
+
const sets = [];
|
|
6420
|
+
const values = [];
|
|
6421
|
+
if (input.label !== void 0) {
|
|
6422
|
+
values.push(input.label || null);
|
|
6423
|
+
sets.push(`label = $${values.length}`);
|
|
6424
|
+
}
|
|
6425
|
+
if (input.projectId !== void 0) {
|
|
6426
|
+
values.push(input.projectId);
|
|
6427
|
+
sets.push(`project_id = $${values.length}`);
|
|
6428
|
+
}
|
|
6429
|
+
if (input.assistantIds !== void 0) {
|
|
6430
|
+
values.push(input.assistantIds ? JSON.stringify(input.assistantIds) : null);
|
|
6431
|
+
sets.push(`assistant_ids = $${values.length}`);
|
|
6432
|
+
}
|
|
6433
|
+
if (input.grants !== void 0) {
|
|
6434
|
+
values.push(input.grants ? JSON.stringify(input.grants) : null);
|
|
6435
|
+
sets.push(`grants = $${values.length}`);
|
|
6436
|
+
}
|
|
6437
|
+
if (sets.length === 0) {
|
|
6438
|
+
const existing = await this.findById(id);
|
|
6439
|
+
if (!existing) throw new Error(`A2A API key not found: ${id}`);
|
|
6440
|
+
return existing;
|
|
6441
|
+
}
|
|
6442
|
+
sets.push("updated_at = NOW()");
|
|
6443
|
+
values.push(id);
|
|
6444
|
+
const result = await this.pool.query(
|
|
6445
|
+
`UPDATE lattice_a2a_api_keys SET ${sets.join(", ")} WHERE id = $${values.length} RETURNING *`,
|
|
6446
|
+
values
|
|
6447
|
+
);
|
|
6448
|
+
if (result.rows.length === 0) throw new Error(`A2A API key not found: ${id}`);
|
|
6449
|
+
return mapRowToRecord(result.rows[0]);
|
|
6450
|
+
}
|
|
6369
6451
|
async disable(id) {
|
|
6370
6452
|
await this.ensureInitialized();
|
|
6371
6453
|
const result = await this.pool.query(
|
|
@@ -6407,21 +6489,173 @@ var PostgreSQLA2AApiKeyStore = class {
|
|
|
6407
6489
|
);
|
|
6408
6490
|
const map2 = /* @__PURE__ */ new Map();
|
|
6409
6491
|
for (const row of result.rows) {
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
key,
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6492
|
+
try {
|
|
6493
|
+
const key = (0, import_core5.decrypt)(row.key_value);
|
|
6494
|
+
map2.set(key, {
|
|
6495
|
+
key,
|
|
6496
|
+
tenantId: row.tenant_id,
|
|
6497
|
+
projectId: row.project_id,
|
|
6498
|
+
assistantIds: row.assistant_ids ?? void 0,
|
|
6499
|
+
grants: row.grants ?? void 0
|
|
6500
|
+
});
|
|
6501
|
+
} catch {
|
|
6502
|
+
}
|
|
6417
6503
|
}
|
|
6418
6504
|
return map2;
|
|
6419
6505
|
}
|
|
6420
6506
|
};
|
|
6421
6507
|
|
|
6508
|
+
// src/stores/PostgreSQLOpenAuditStore.ts
|
|
6509
|
+
var import_pg17 = require("pg");
|
|
6510
|
+
|
|
6511
|
+
// src/migrations/create_open_audit_table.ts
|
|
6512
|
+
var createOpenAuditTable = {
|
|
6513
|
+
version: 179,
|
|
6514
|
+
name: "create_open_audit_table",
|
|
6515
|
+
up: async (client) => {
|
|
6516
|
+
await client.query(`
|
|
6517
|
+
CREATE TABLE IF NOT EXISTS lattice_open_audit (
|
|
6518
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
6519
|
+
tenant_id VARCHAR(255) NOT NULL,
|
|
6520
|
+
credential_id VARCHAR(255) NOT NULL,
|
|
6521
|
+
credential_kind VARCHAR(32) NOT NULL,
|
|
6522
|
+
project_id VARCHAR(255) NOT NULL,
|
|
6523
|
+
domain VARCHAR(255) NOT NULL,
|
|
6524
|
+
action VARCHAR(255) NOT NULL,
|
|
6525
|
+
args JSONB,
|
|
6526
|
+
status VARCHAR(16) NOT NULL,
|
|
6527
|
+
error_code VARCHAR(64),
|
|
6528
|
+
duration_ms INTEGER NOT NULL,
|
|
6529
|
+
created_at TIMESTAMP NOT NULL DEFAULT NOW()
|
|
6530
|
+
)
|
|
6531
|
+
`);
|
|
6532
|
+
await client.query(`
|
|
6533
|
+
CREATE INDEX IF NOT EXISTS idx_lattice_open_audit_tenant_created
|
|
6534
|
+
ON lattice_open_audit(tenant_id, created_at DESC)
|
|
6535
|
+
`);
|
|
6536
|
+
},
|
|
6537
|
+
down: async (client) => {
|
|
6538
|
+
await client.query("DROP TABLE IF EXISTS lattice_open_audit");
|
|
6539
|
+
}
|
|
6540
|
+
};
|
|
6541
|
+
|
|
6542
|
+
// src/stores/PostgreSQLOpenAuditStore.ts
|
|
6543
|
+
var PostgreSQLOpenAuditStore = class {
|
|
6544
|
+
constructor(options) {
|
|
6545
|
+
this.initialized = false;
|
|
6546
|
+
this.ownsPool = true;
|
|
6547
|
+
this.initPromise = null;
|
|
6548
|
+
if (options.pool) {
|
|
6549
|
+
this.pool = options.pool;
|
|
6550
|
+
this.ownsPool = false;
|
|
6551
|
+
this.initialized = true;
|
|
6552
|
+
return;
|
|
6553
|
+
}
|
|
6554
|
+
this.pool = typeof options.poolConfig === "string" ? new import_pg17.Pool({ connectionString: options.poolConfig }) : options.poolConfig ? new import_pg17.Pool(options.poolConfig) : (() => {
|
|
6555
|
+
throw new Error("Either pool or poolConfig must be provided");
|
|
6556
|
+
})();
|
|
6557
|
+
this.migrationManager = new MigrationManager(this.pool);
|
|
6558
|
+
this.migrationManager.register(createOpenAuditTable);
|
|
6559
|
+
if (options.autoMigrate !== false) {
|
|
6560
|
+
this.initialize().catch((error) => {
|
|
6561
|
+
console.error("Failed to initialize PostgreSQLOpenAuditStore:", error);
|
|
6562
|
+
throw error;
|
|
6563
|
+
});
|
|
6564
|
+
}
|
|
6565
|
+
}
|
|
6566
|
+
async initialize() {
|
|
6567
|
+
if (this.initialized) return;
|
|
6568
|
+
if (this.initPromise) return this.initPromise;
|
|
6569
|
+
this.initPromise = (async () => {
|
|
6570
|
+
try {
|
|
6571
|
+
await this.migrationManager.migrate();
|
|
6572
|
+
this.initialized = true;
|
|
6573
|
+
} finally {
|
|
6574
|
+
this.initPromise = null;
|
|
6575
|
+
}
|
|
6576
|
+
})();
|
|
6577
|
+
return this.initPromise;
|
|
6578
|
+
}
|
|
6579
|
+
async dispose() {
|
|
6580
|
+
if (this.ownsPool && this.pool) await this.pool.end();
|
|
6581
|
+
}
|
|
6582
|
+
async ensureInitialized() {
|
|
6583
|
+
if (!this.initialized) await this.initialize();
|
|
6584
|
+
}
|
|
6585
|
+
async query(params) {
|
|
6586
|
+
await this.ensureInitialized();
|
|
6587
|
+
const clauses = ["tenant_id = $1"];
|
|
6588
|
+
const values = [params.tenantId];
|
|
6589
|
+
if (params.credentialId) {
|
|
6590
|
+
values.push(params.credentialId);
|
|
6591
|
+
clauses.push(`credential_id = $${values.length}`);
|
|
6592
|
+
}
|
|
6593
|
+
if (params.domain) {
|
|
6594
|
+
values.push(params.domain);
|
|
6595
|
+
clauses.push(`domain = $${values.length}`);
|
|
6596
|
+
}
|
|
6597
|
+
if (params.status) {
|
|
6598
|
+
values.push(params.status);
|
|
6599
|
+
clauses.push(`status = $${values.length}`);
|
|
6600
|
+
}
|
|
6601
|
+
if (params.from) {
|
|
6602
|
+
values.push(params.from);
|
|
6603
|
+
clauses.push(`created_at >= $${values.length}`);
|
|
6604
|
+
}
|
|
6605
|
+
if (params.to) {
|
|
6606
|
+
values.push(params.to);
|
|
6607
|
+
clauses.push(`created_at < $${values.length}`);
|
|
6608
|
+
}
|
|
6609
|
+
const limit = params.limit ?? 100;
|
|
6610
|
+
const offset = params.offset ?? 0;
|
|
6611
|
+
values.push(limit, offset);
|
|
6612
|
+
const { rows } = await this.pool.query(
|
|
6613
|
+
`SELECT * FROM lattice_open_audit
|
|
6614
|
+
WHERE ${clauses.join(" AND ")}
|
|
6615
|
+
ORDER BY created_at DESC
|
|
6616
|
+
LIMIT $${values.length - 1} OFFSET $${values.length}`,
|
|
6617
|
+
values
|
|
6618
|
+
);
|
|
6619
|
+
return rows.map((row) => ({
|
|
6620
|
+
id: row.id,
|
|
6621
|
+
tenantId: row.tenant_id,
|
|
6622
|
+
credentialId: row.credential_id,
|
|
6623
|
+
credentialKind: row.credential_kind,
|
|
6624
|
+
projectId: row.project_id,
|
|
6625
|
+
domain: row.domain,
|
|
6626
|
+
action: row.action,
|
|
6627
|
+
args: row.args,
|
|
6628
|
+
status: row.status,
|
|
6629
|
+
errorCode: row.error_code ?? void 0,
|
|
6630
|
+
durationMs: row.duration_ms,
|
|
6631
|
+
createdAt: row.created_at
|
|
6632
|
+
}));
|
|
6633
|
+
}
|
|
6634
|
+
async append(record) {
|
|
6635
|
+
await this.ensureInitialized();
|
|
6636
|
+
await this.pool.query(
|
|
6637
|
+
`INSERT INTO lattice_open_audit
|
|
6638
|
+
(tenant_id, credential_id, credential_kind, project_id, domain, action, args, status, error_code, duration_ms)
|
|
6639
|
+
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)`,
|
|
6640
|
+
[
|
|
6641
|
+
record.tenantId,
|
|
6642
|
+
record.credentialId,
|
|
6643
|
+
record.credentialKind,
|
|
6644
|
+
record.projectId,
|
|
6645
|
+
record.domain,
|
|
6646
|
+
record.action,
|
|
6647
|
+
record.args === void 0 ? null : JSON.stringify(record.args),
|
|
6648
|
+
record.status,
|
|
6649
|
+
record.errorCode ?? null,
|
|
6650
|
+
Math.max(0, Math.round(record.durationMs))
|
|
6651
|
+
]
|
|
6652
|
+
);
|
|
6653
|
+
}
|
|
6654
|
+
};
|
|
6655
|
+
|
|
6422
6656
|
// src/stores/PostgreSQLAgentWebAppStore.ts
|
|
6423
6657
|
var import_crypto3 = require("crypto");
|
|
6424
|
-
var
|
|
6658
|
+
var import_pg18 = require("pg");
|
|
6425
6659
|
|
|
6426
6660
|
// src/migrations/agent_web_apps_migration.ts
|
|
6427
6661
|
var createAgentWebAppsTable = {
|
|
@@ -6534,7 +6768,7 @@ var PostgreSQLAgentWebAppStore = class {
|
|
|
6534
6768
|
this.initialized = true;
|
|
6535
6769
|
return;
|
|
6536
6770
|
}
|
|
6537
|
-
this.pool = typeof options.poolConfig === "string" ? new
|
|
6771
|
+
this.pool = typeof options.poolConfig === "string" ? new import_pg18.Pool({ connectionString: options.poolConfig }) : options.poolConfig ? new import_pg18.Pool(options.poolConfig) : (() => {
|
|
6538
6772
|
throw new Error("Either pool or poolConfig must be provided");
|
|
6539
6773
|
})();
|
|
6540
6774
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -6673,7 +6907,7 @@ var PostgreSQLAgentWebAppStore = class {
|
|
|
6673
6907
|
};
|
|
6674
6908
|
|
|
6675
6909
|
// src/stores/PostgreSQLScheduleStorage.ts
|
|
6676
|
-
var
|
|
6910
|
+
var import_pg19 = require("pg");
|
|
6677
6911
|
var import_protocols4 = require("@axiom-lattice/protocols");
|
|
6678
6912
|
|
|
6679
6913
|
// src/migrations/schedule_migrations.ts
|
|
@@ -6848,9 +7082,9 @@ var PostgreSQLScheduleStorage = class {
|
|
|
6848
7082
|
return;
|
|
6849
7083
|
}
|
|
6850
7084
|
if (typeof options.poolConfig === "string") {
|
|
6851
|
-
this.pool = new
|
|
7085
|
+
this.pool = new import_pg19.Pool({ connectionString: options.poolConfig });
|
|
6852
7086
|
} else if (options.poolConfig) {
|
|
6853
|
-
this.pool = new
|
|
7087
|
+
this.pool = new import_pg19.Pool(options.poolConfig);
|
|
6854
7088
|
} else {
|
|
6855
7089
|
throw new Error("Either pool or poolConfig must be provided");
|
|
6856
7090
|
}
|
|
@@ -7288,7 +7522,7 @@ var PostgreSQLScheduleStorage = class {
|
|
|
7288
7522
|
};
|
|
7289
7523
|
|
|
7290
7524
|
// src/stores/PostgreSQLTaskStore.ts
|
|
7291
|
-
var
|
|
7525
|
+
var import_pg20 = require("pg");
|
|
7292
7526
|
|
|
7293
7527
|
// src/migrations/task_migration.ts
|
|
7294
7528
|
var createTasksTable = {
|
|
@@ -7503,9 +7737,9 @@ var PostgreSQLTaskStore = class {
|
|
|
7503
7737
|
return;
|
|
7504
7738
|
}
|
|
7505
7739
|
if (typeof options.poolConfig === "string") {
|
|
7506
|
-
this.pool = new
|
|
7740
|
+
this.pool = new import_pg20.Pool({ connectionString: options.poolConfig });
|
|
7507
7741
|
} else if (options.poolConfig) {
|
|
7508
|
-
this.pool = new
|
|
7742
|
+
this.pool = new import_pg20.Pool(options.poolConfig);
|
|
7509
7743
|
} else {
|
|
7510
7744
|
throw new Error("Either pool or poolConfig must be provided");
|
|
7511
7745
|
}
|
|
@@ -8245,7 +8479,7 @@ var PostgreSQLTaskStore = class {
|
|
|
8245
8479
|
};
|
|
8246
8480
|
|
|
8247
8481
|
// src/stores/PostgreSQLTaskWorkItemStore.ts
|
|
8248
|
-
var
|
|
8482
|
+
var import_pg21 = require("pg");
|
|
8249
8483
|
var import_protocols5 = require("@axiom-lattice/protocols");
|
|
8250
8484
|
var import_uuid4 = require("uuid");
|
|
8251
8485
|
|
|
@@ -8379,7 +8613,7 @@ var PostgreSQLTaskWorkItemStore = class {
|
|
|
8379
8613
|
this.initialized = true;
|
|
8380
8614
|
return;
|
|
8381
8615
|
}
|
|
8382
|
-
this.pool = typeof options.poolConfig === "string" ? new
|
|
8616
|
+
this.pool = typeof options.poolConfig === "string" ? new import_pg21.Pool({ connectionString: options.poolConfig }) : options.poolConfig ? new import_pg21.Pool(options.poolConfig) : (() => {
|
|
8383
8617
|
throw new Error("Either pool or poolConfig must be provided");
|
|
8384
8618
|
})();
|
|
8385
8619
|
this.ownsPool = true;
|
|
@@ -8632,7 +8866,7 @@ var PostgreSQLTaskWorkItemStore = class {
|
|
|
8632
8866
|
};
|
|
8633
8867
|
|
|
8634
8868
|
// src/stores/MenuStore.ts
|
|
8635
|
-
var
|
|
8869
|
+
var import_pg22 = require("pg");
|
|
8636
8870
|
|
|
8637
8871
|
// src/migrations/menu_items_migration.ts
|
|
8638
8872
|
var createMenuItemsTable = {
|
|
@@ -8709,7 +8943,7 @@ var MenuStore = class {
|
|
|
8709
8943
|
this.initialized = true;
|
|
8710
8944
|
return;
|
|
8711
8945
|
}
|
|
8712
|
-
this.pool = typeof options.poolConfig === "string" ? new
|
|
8946
|
+
this.pool = typeof options.poolConfig === "string" ? new import_pg22.Pool({ connectionString: options.poolConfig }) : options.poolConfig ? new import_pg22.Pool(options.poolConfig) : (() => {
|
|
8713
8947
|
throw new Error("Either pool or poolConfig must be provided");
|
|
8714
8948
|
})();
|
|
8715
8949
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -8864,7 +9098,7 @@ var MenuStore = class {
|
|
|
8864
9098
|
};
|
|
8865
9099
|
|
|
8866
9100
|
// src/stores/PostgresSharedResourceStore.ts
|
|
8867
|
-
var
|
|
9101
|
+
var import_pg23 = require("pg");
|
|
8868
9102
|
|
|
8869
9103
|
// src/migrations/shared_resources_migration.ts
|
|
8870
9104
|
var createSharedResourcesTable = {
|
|
@@ -8918,7 +9152,7 @@ var PostgresSharedResourceStore = class {
|
|
|
8918
9152
|
this.initialized = true;
|
|
8919
9153
|
return;
|
|
8920
9154
|
}
|
|
8921
|
-
this.pool = typeof options.poolConfig === "string" ? new
|
|
9155
|
+
this.pool = typeof options.poolConfig === "string" ? new import_pg23.Pool({ connectionString: options.poolConfig }) : options.poolConfig ? new import_pg23.Pool(options.poolConfig) : (() => {
|
|
8922
9156
|
throw new Error("Either pool or poolConfig must be provided");
|
|
8923
9157
|
})();
|
|
8924
9158
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -8966,8 +9200,8 @@ var PostgresSharedResourceStore = class {
|
|
|
8966
9200
|
`INSERT INTO lattice_shared_resources
|
|
8967
9201
|
(token, address, title, created_by, tenant_id, workspace_id, project_id,
|
|
8968
9202
|
assistant_id, vm_isolation, visibility, password_hash,
|
|
8969
|
-
expires_at, max_access, revoked)
|
|
8970
|
-
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14)
|
|
9203
|
+
expires_at, max_access, open_grants, revoked)
|
|
9204
|
+
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15)
|
|
8971
9205
|
RETURNING *`,
|
|
8972
9206
|
[
|
|
8973
9207
|
record.token,
|
|
@@ -8983,6 +9217,7 @@ var PostgresSharedResourceStore = class {
|
|
|
8983
9217
|
record.passwordHash,
|
|
8984
9218
|
record.expiresAt ? record.expiresAt.toISOString() : null,
|
|
8985
9219
|
record.maxAccess,
|
|
9220
|
+
record.openGrants ? JSON.stringify(record.openGrants) : null,
|
|
8986
9221
|
record.revoked
|
|
8987
9222
|
]
|
|
8988
9223
|
);
|
|
@@ -9078,6 +9313,7 @@ var PostgresSharedResourceStore = class {
|
|
|
9078
9313
|
passwordHash: row.password_hash,
|
|
9079
9314
|
expiresAt: row.expires_at ? new Date(row.expires_at) : null,
|
|
9080
9315
|
maxAccess: row.max_access,
|
|
9316
|
+
openGrants: row.open_grants ?? void 0,
|
|
9081
9317
|
accessCount: row.access_count ?? 0,
|
|
9082
9318
|
revoked: row.revoked ?? false,
|
|
9083
9319
|
createdAt: new Date(row.created_at),
|
|
@@ -9087,7 +9323,7 @@ var PostgresSharedResourceStore = class {
|
|
|
9087
9323
|
};
|
|
9088
9324
|
|
|
9089
9325
|
// src/stores/PostgreSQLCollectionStore.ts
|
|
9090
|
-
var
|
|
9326
|
+
var import_pg24 = require("pg");
|
|
9091
9327
|
var PostgreSQLCollectionStore = class {
|
|
9092
9328
|
constructor(options) {
|
|
9093
9329
|
this.initialized = false;
|
|
@@ -9100,9 +9336,9 @@ var PostgreSQLCollectionStore = class {
|
|
|
9100
9336
|
return;
|
|
9101
9337
|
}
|
|
9102
9338
|
if (typeof options.poolConfig === "string") {
|
|
9103
|
-
this.pool = new
|
|
9339
|
+
this.pool = new import_pg24.Pool({ connectionString: options.poolConfig });
|
|
9104
9340
|
} else if (options.poolConfig) {
|
|
9105
|
-
this.pool = new
|
|
9341
|
+
this.pool = new import_pg24.Pool(options.poolConfig);
|
|
9106
9342
|
} else {
|
|
9107
9343
|
throw new Error("Either pool or poolConfig must be provided");
|
|
9108
9344
|
}
|
|
@@ -9217,7 +9453,7 @@ var PostgreSQLCollectionStore = class {
|
|
|
9217
9453
|
var import_langgraph_checkpoint_postgres = require("@langchain/langgraph-checkpoint-postgres");
|
|
9218
9454
|
|
|
9219
9455
|
// src/PGVectorStoreProvider.ts
|
|
9220
|
-
var
|
|
9456
|
+
var import_pg25 = require("pg");
|
|
9221
9457
|
var import_pgvector = require("@langchain/community/vectorstores/pgvector");
|
|
9222
9458
|
var import_documents = require("@langchain/core/documents");
|
|
9223
9459
|
var import_core6 = require("@axiom-lattice/core");
|
|
@@ -9291,7 +9527,7 @@ var PGVectorStoreProvider = class {
|
|
|
9291
9527
|
}
|
|
9292
9528
|
};
|
|
9293
9529
|
function createPGVectorStoreProvider(connectionString) {
|
|
9294
|
-
const pool = new
|
|
9530
|
+
const pool = new import_pg25.Pool({ connectionString });
|
|
9295
9531
|
return {
|
|
9296
9532
|
provider: new PGVectorStoreProvider(pool, connectionString),
|
|
9297
9533
|
pool
|
|
@@ -9546,6 +9782,24 @@ var createConnectionConfigsTable = {
|
|
|
9546
9782
|
}
|
|
9547
9783
|
};
|
|
9548
9784
|
|
|
9785
|
+
// src/migrations/add_share_open_grants.ts
|
|
9786
|
+
var addShareOpenGrants = {
|
|
9787
|
+
version: 180,
|
|
9788
|
+
name: "add_share_open_grants",
|
|
9789
|
+
up: async (client) => {
|
|
9790
|
+
await client.query(`
|
|
9791
|
+
ALTER TABLE lattice_shared_resources
|
|
9792
|
+
ADD COLUMN IF NOT EXISTS open_grants JSONB
|
|
9793
|
+
`);
|
|
9794
|
+
},
|
|
9795
|
+
down: async (client) => {
|
|
9796
|
+
await client.query(`
|
|
9797
|
+
ALTER TABLE lattice_shared_resources
|
|
9798
|
+
DROP COLUMN IF EXISTS open_grants
|
|
9799
|
+
`);
|
|
9800
|
+
}
|
|
9801
|
+
};
|
|
9802
|
+
|
|
9549
9803
|
// src/migrations/collection_migrations.ts
|
|
9550
9804
|
var createCollectionsTable = {
|
|
9551
9805
|
version: 137,
|
|
@@ -9749,7 +10003,7 @@ var createProjectRoomReadStates = {
|
|
|
9749
10003
|
|
|
9750
10004
|
// src/stores/PostgreSQLCapabilityBundleStore.ts
|
|
9751
10005
|
var import_crypto4 = require("crypto");
|
|
9752
|
-
var
|
|
10006
|
+
var import_pg26 = require("pg");
|
|
9753
10007
|
var duplicateMessage = "Capability bundle key already exists for tenant";
|
|
9754
10008
|
function map(row) {
|
|
9755
10009
|
return {
|
|
@@ -9782,7 +10036,7 @@ var PostgreSQLCapabilityBundleStore = class {
|
|
|
9782
10036
|
this.initialized = true;
|
|
9783
10037
|
return;
|
|
9784
10038
|
}
|
|
9785
|
-
this.pool = typeof options.poolConfig === "string" ? new
|
|
10039
|
+
this.pool = typeof options.poolConfig === "string" ? new import_pg26.Pool({ connectionString: options.poolConfig }) : options.poolConfig ? new import_pg26.Pool(options.poolConfig) : (() => {
|
|
9786
10040
|
throw new Error("Either pool or poolConfig must be provided");
|
|
9787
10041
|
})();
|
|
9788
10042
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -10458,6 +10712,22 @@ function mapRow5(row) {
|
|
|
10458
10712
|
createdAt: row.created_at
|
|
10459
10713
|
};
|
|
10460
10714
|
}
|
|
10715
|
+
function mapRowsTolerant(rows, scope) {
|
|
10716
|
+
const messages = [];
|
|
10717
|
+
for (const row of rows) {
|
|
10718
|
+
try {
|
|
10719
|
+
messages.push(mapRow5(row));
|
|
10720
|
+
} catch (error) {
|
|
10721
|
+
console.warn("[ProjectRoomMessageStore] Skipping invalid message row", {
|
|
10722
|
+
tenantId: scope.tenantId,
|
|
10723
|
+
roomId: scope.roomId,
|
|
10724
|
+
rowId: typeof row.id === "string" ? row.id : void 0,
|
|
10725
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
10726
|
+
});
|
|
10727
|
+
}
|
|
10728
|
+
}
|
|
10729
|
+
return messages;
|
|
10730
|
+
}
|
|
10461
10731
|
function isUniqueViolation2(error) {
|
|
10462
10732
|
return typeof error === "object" && error !== null && "code" in error && error.code === "23505";
|
|
10463
10733
|
}
|
|
@@ -10523,7 +10793,7 @@ var PostgreSQLProjectRoomMessageStore = class {
|
|
|
10523
10793
|
WHERE tenant_id = $1 AND room_id = $2 ORDER BY created_at DESC, id DESC LIMIT $3`,
|
|
10524
10794
|
[input.tenantId, input.roomId, limit]
|
|
10525
10795
|
);
|
|
10526
|
-
return result.rows.
|
|
10796
|
+
return mapRowsTolerant(result.rows, { tenantId: input.tenantId, roomId: input.roomId });
|
|
10527
10797
|
}
|
|
10528
10798
|
/** Finds a message by tenant-scoped ID. */
|
|
10529
10799
|
async findById(tenantId, id) {
|
|
@@ -10605,7 +10875,7 @@ var PostgreSQLProjectRoomReadStateStore = class {
|
|
|
10605
10875
|
|
|
10606
10876
|
// src/createPgStoreConfig.ts
|
|
10607
10877
|
async function createPgStoreConfig(connectionString) {
|
|
10608
|
-
const pool = new
|
|
10878
|
+
const pool = new import_pg27.Pool({ connectionString });
|
|
10609
10879
|
const mm = new MigrationManager(pool);
|
|
10610
10880
|
mm.register(createThreadsTable);
|
|
10611
10881
|
mm.register(createScheduledTasksTable);
|
|
@@ -10658,6 +10928,9 @@ async function createPgStoreConfig(connectionString) {
|
|
|
10658
10928
|
mm.register(addWorkflowRunsTenantStatusUpdatedIndex);
|
|
10659
10929
|
mm.register(addProjectKindColumn);
|
|
10660
10930
|
mm.register(addA2AKeyAssistantIds);
|
|
10931
|
+
mm.register(addApiKeyGrants);
|
|
10932
|
+
mm.register(createOpenAuditTable);
|
|
10933
|
+
mm.register(addShareOpenGrants);
|
|
10661
10934
|
mm.register(addTaskWorkItemEventKeyMigration);
|
|
10662
10935
|
mm.register(createAgentWebAppsTable);
|
|
10663
10936
|
mm.register(createCapabilityBundlesTable);
|
|
@@ -10694,6 +10967,7 @@ async function createPgStoreConfig(connectionString) {
|
|
|
10694
10967
|
task: new PostgreSQLTaskStore(opts),
|
|
10695
10968
|
taskWorkItem: taskWorkItemStore,
|
|
10696
10969
|
a2aApiKey: new PostgreSQLA2AApiKeyStore(opts),
|
|
10970
|
+
openAudit: new PostgreSQLOpenAuditStore(opts),
|
|
10697
10971
|
agentWebApp: new PostgreSQLAgentWebAppStore(opts),
|
|
10698
10972
|
capabilityBundle: new PostgreSQLCapabilityBundleStore(opts),
|
|
10699
10973
|
schedule: new PostgreSQLScheduleStorage(opts),
|
|
@@ -10711,7 +10985,7 @@ async function createPgStoreConfig(connectionString) {
|
|
|
10711
10985
|
}
|
|
10712
10986
|
|
|
10713
10987
|
// src/stores/PostgreSQLSkillStore.ts
|
|
10714
|
-
var
|
|
10988
|
+
var import_pg28 = require("pg");
|
|
10715
10989
|
var PostgreSQLSkillStore = class {
|
|
10716
10990
|
constructor(options) {
|
|
10717
10991
|
this.initialized = false;
|
|
@@ -10724,9 +10998,9 @@ var PostgreSQLSkillStore = class {
|
|
|
10724
10998
|
return;
|
|
10725
10999
|
}
|
|
10726
11000
|
if (typeof options.poolConfig === "string") {
|
|
10727
|
-
this.pool = new
|
|
11001
|
+
this.pool = new import_pg28.Pool({ connectionString: options.poolConfig });
|
|
10728
11002
|
} else if (options.poolConfig) {
|
|
10729
|
-
this.pool = new
|
|
11003
|
+
this.pool = new import_pg28.Pool(options.poolConfig);
|
|
10730
11004
|
} else {
|
|
10731
11005
|
throw new Error("Either pool or poolConfig must be provided");
|
|
10732
11006
|
}
|
|
@@ -11027,7 +11301,7 @@ var PostgreSQLSkillStore = class {
|
|
|
11027
11301
|
};
|
|
11028
11302
|
|
|
11029
11303
|
// src/stores/ChannelIdentityMappingStore.ts
|
|
11030
|
-
var
|
|
11304
|
+
var import_pg29 = require("pg");
|
|
11031
11305
|
var ChannelIdentityMappingStore = class {
|
|
11032
11306
|
constructor(options) {
|
|
11033
11307
|
this.initialized = false;
|
|
@@ -11039,7 +11313,7 @@ var ChannelIdentityMappingStore = class {
|
|
|
11039
11313
|
this.initialized = true;
|
|
11040
11314
|
return;
|
|
11041
11315
|
}
|
|
11042
|
-
this.pool = typeof options.poolConfig === "string" ? new
|
|
11316
|
+
this.pool = typeof options.poolConfig === "string" ? new import_pg29.Pool({ connectionString: options.poolConfig }) : options.poolConfig ? new import_pg29.Pool(options.poolConfig) : (() => {
|
|
11043
11317
|
throw new Error("Either pool or poolConfig must be provided");
|
|
11044
11318
|
})();
|
|
11045
11319
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -11278,6 +11552,7 @@ function mapRowToChannelIdentityMapping(row) {
|
|
|
11278
11552
|
PostgreSQLEvalStore,
|
|
11279
11553
|
PostgreSQLMcpServerConfigStore,
|
|
11280
11554
|
PostgreSQLMetricsServerConfigStore,
|
|
11555
|
+
PostgreSQLOpenAuditStore,
|
|
11281
11556
|
PostgreSQLProjectBotMembershipStore,
|
|
11282
11557
|
PostgreSQLProjectMembershipStore,
|
|
11283
11558
|
PostgreSQLProjectRoomMessageStore,
|