@axiom-lattice/pg-stores 1.0.55 → 1.0.57
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 +16 -0
- package/dist/index.d.mts +44 -4
- package/dist/index.d.ts +44 -4
- package/dist/index.js +310 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +307 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +7 -0
- package/src/migrations/channel_bindings_migration.ts +49 -0
- package/src/migrations/channel_installations_alter_migration.ts +32 -0
- package/src/stores/ChannelBindingStore.ts +244 -0
- package/src/stores/PostgreSQLChannelInstallationStore.ts +43 -33
package/dist/index.js
CHANGED
|
@@ -30,9 +30,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
ChannelBindingStore: () => ChannelBindingStore,
|
|
33
34
|
ChannelIdentityMappingStore: () => ChannelIdentityMappingStore,
|
|
34
35
|
MigrationManager: () => MigrationManager,
|
|
35
|
-
Pool: () =>
|
|
36
|
+
Pool: () => import_pg18.Pool,
|
|
36
37
|
PostgreSQLAssistantStore: () => PostgreSQLAssistantStore,
|
|
37
38
|
PostgreSQLChannelInstallationStore: () => PostgreSQLChannelInstallationStore,
|
|
38
39
|
PostgreSQLDatabaseConfigStore: () => PostgreSQLDatabaseConfigStore,
|
|
@@ -53,10 +54,12 @@ __export(index_exports, {
|
|
|
53
54
|
addScheduleTenantId: () => addScheduleTenantId,
|
|
54
55
|
addSkillTenantId: () => addSkillTenantId,
|
|
55
56
|
addThreadTenantId: () => addThreadTenantId,
|
|
57
|
+
alterChannelInstallationsTable: () => alterChannelInstallationsTable,
|
|
56
58
|
changeAssistantPrimaryKey: () => changeAssistantPrimaryKey,
|
|
57
59
|
changeSkillPrimaryKey: () => changeSkillPrimaryKey,
|
|
58
60
|
changeThreadPrimaryKey: () => changeThreadPrimaryKey,
|
|
59
61
|
createAssistantsTable: () => createAssistantsTable,
|
|
62
|
+
createChannelBindingsTable: () => createChannelBindingsTable,
|
|
60
63
|
createChannelIdentityMappingTables: () => createChannelIdentityMappingTables,
|
|
61
64
|
createChannelInstallationsTable: () => createChannelInstallationsTable,
|
|
62
65
|
createDatabaseConfigsTable: () => createDatabaseConfigsTable,
|
|
@@ -80,7 +83,7 @@ __export(index_exports, {
|
|
|
80
83
|
getThreadMessageQueueStore: () => getThreadMessageQueueStore
|
|
81
84
|
});
|
|
82
85
|
module.exports = __toCommonJS(index_exports);
|
|
83
|
-
var
|
|
86
|
+
var import_pg18 = require("pg");
|
|
84
87
|
|
|
85
88
|
// src/stores/PostgreSQLThreadStore.ts
|
|
86
89
|
var import_pg = require("pg");
|
|
@@ -4177,6 +4180,82 @@ var createChannelInstallationsTable = {
|
|
|
4177
4180
|
}
|
|
4178
4181
|
};
|
|
4179
4182
|
|
|
4183
|
+
// src/migrations/channel_installations_alter_migration.ts
|
|
4184
|
+
var alterChannelInstallationsTable = {
|
|
4185
|
+
version: 109,
|
|
4186
|
+
name: "alter_channel_installations_add_columns",
|
|
4187
|
+
up: async (client) => {
|
|
4188
|
+
await client.query(`
|
|
4189
|
+
ALTER TABLE lattice_channel_installations
|
|
4190
|
+
ADD COLUMN IF NOT EXISTS enabled BOOLEAN NOT NULL DEFAULT true
|
|
4191
|
+
`);
|
|
4192
|
+
await client.query(`
|
|
4193
|
+
ALTER TABLE lattice_channel_installations
|
|
4194
|
+
ADD COLUMN IF NOT EXISTS fallback_agent_id VARCHAR(255)
|
|
4195
|
+
`);
|
|
4196
|
+
await client.query(`
|
|
4197
|
+
ALTER TABLE lattice_channel_installations
|
|
4198
|
+
ADD COLUMN IF NOT EXISTS reject_when_no_binding BOOLEAN NOT NULL DEFAULT true
|
|
4199
|
+
`);
|
|
4200
|
+
},
|
|
4201
|
+
down: async (client) => {
|
|
4202
|
+
await client.query(
|
|
4203
|
+
"ALTER TABLE lattice_channel_installations DROP COLUMN IF EXISTS reject_when_no_binding"
|
|
4204
|
+
);
|
|
4205
|
+
await client.query(
|
|
4206
|
+
"ALTER TABLE lattice_channel_installations DROP COLUMN IF EXISTS fallback_agent_id"
|
|
4207
|
+
);
|
|
4208
|
+
await client.query(
|
|
4209
|
+
"ALTER TABLE lattice_channel_installations DROP COLUMN IF EXISTS enabled"
|
|
4210
|
+
);
|
|
4211
|
+
}
|
|
4212
|
+
};
|
|
4213
|
+
|
|
4214
|
+
// src/migrations/channel_bindings_migration.ts
|
|
4215
|
+
var createChannelBindingsTable = {
|
|
4216
|
+
version: 110,
|
|
4217
|
+
name: "create_channel_bindings_table",
|
|
4218
|
+
up: async (client) => {
|
|
4219
|
+
await client.query(`
|
|
4220
|
+
CREATE TABLE IF NOT EXISTS lattice_channel_bindings (
|
|
4221
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
4222
|
+
channel VARCHAR(50) NOT NULL,
|
|
4223
|
+
channel_installation_id VARCHAR(255) NOT NULL,
|
|
4224
|
+
tenant_id VARCHAR(255) NOT NULL,
|
|
4225
|
+
sender_id VARCHAR(255) NOT NULL,
|
|
4226
|
+
agent_id VARCHAR(255) NOT NULL,
|
|
4227
|
+
thread_id VARCHAR(255),
|
|
4228
|
+
workspace_id VARCHAR(255),
|
|
4229
|
+
project_id VARCHAR(255),
|
|
4230
|
+
thread_mode VARCHAR(20) NOT NULL DEFAULT 'fixed'
|
|
4231
|
+
CHECK (thread_mode IN ('fixed', 'per_conversation')),
|
|
4232
|
+
sender_display_name VARCHAR(255),
|
|
4233
|
+
sender_metadata JSONB,
|
|
4234
|
+
enabled BOOLEAN NOT NULL DEFAULT true,
|
|
4235
|
+
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
|
4236
|
+
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
|
4237
|
+
UNIQUE (channel, channel_installation_id, tenant_id, sender_id)
|
|
4238
|
+
)
|
|
4239
|
+
`);
|
|
4240
|
+
await client.query(`
|
|
4241
|
+
CREATE INDEX IF NOT EXISTS idx_lattice_channel_bindings_lookup
|
|
4242
|
+
ON lattice_channel_bindings(channel, channel_installation_id, tenant_id, sender_id)
|
|
4243
|
+
`);
|
|
4244
|
+
await client.query(`
|
|
4245
|
+
CREATE INDEX IF NOT EXISTS idx_lattice_channel_bindings_agent
|
|
4246
|
+
ON lattice_channel_bindings(agent_id, tenant_id)
|
|
4247
|
+
`);
|
|
4248
|
+
await client.query(`
|
|
4249
|
+
CREATE INDEX IF NOT EXISTS idx_lattice_channel_bindings_enabled
|
|
4250
|
+
ON lattice_channel_bindings(enabled)
|
|
4251
|
+
WHERE enabled = true
|
|
4252
|
+
`);
|
|
4253
|
+
},
|
|
4254
|
+
down: async (client) => {
|
|
4255
|
+
await client.query("DROP TABLE IF EXISTS lattice_channel_bindings");
|
|
4256
|
+
}
|
|
4257
|
+
};
|
|
4258
|
+
|
|
4180
4259
|
// src/migrations/workflow_tracking_migrations.ts
|
|
4181
4260
|
var createWorkflowTrackingTables = {
|
|
4182
4261
|
name: "create_workflow_tracking_tables",
|
|
@@ -4250,6 +4329,190 @@ var createWorkflowTrackingTables = {
|
|
|
4250
4329
|
}
|
|
4251
4330
|
};
|
|
4252
4331
|
|
|
4332
|
+
// src/stores/ChannelBindingStore.ts
|
|
4333
|
+
var import_pg13 = require("pg");
|
|
4334
|
+
var ChannelBindingStore = class {
|
|
4335
|
+
constructor(options) {
|
|
4336
|
+
this.initialized = false;
|
|
4337
|
+
this.initPromise = null;
|
|
4338
|
+
this.pool = typeof options.poolConfig === "string" ? new import_pg13.Pool({ connectionString: options.poolConfig }) : new import_pg13.Pool(options.poolConfig);
|
|
4339
|
+
this.migrationManager = new MigrationManager(this.pool);
|
|
4340
|
+
this.migrationManager.register(createChannelBindingsTable);
|
|
4341
|
+
if (options.autoMigrate !== false) {
|
|
4342
|
+
this.initialize().catch((error) => {
|
|
4343
|
+
console.error("Failed to initialize ChannelBindingStore:", error);
|
|
4344
|
+
throw error;
|
|
4345
|
+
});
|
|
4346
|
+
}
|
|
4347
|
+
}
|
|
4348
|
+
async initialize() {
|
|
4349
|
+
if (this.initialized) return;
|
|
4350
|
+
if (this.initPromise) return this.initPromise;
|
|
4351
|
+
this.initPromise = (async () => {
|
|
4352
|
+
try {
|
|
4353
|
+
await this.migrationManager.migrate();
|
|
4354
|
+
this.initialized = true;
|
|
4355
|
+
} finally {
|
|
4356
|
+
this.initPromise = null;
|
|
4357
|
+
}
|
|
4358
|
+
})();
|
|
4359
|
+
return this.initPromise;
|
|
4360
|
+
}
|
|
4361
|
+
async resolve(params) {
|
|
4362
|
+
await this.ensureInitialized();
|
|
4363
|
+
const result = await this.pool.query(
|
|
4364
|
+
`SELECT * FROM lattice_channel_bindings
|
|
4365
|
+
WHERE channel = $1
|
|
4366
|
+
AND sender_id = $2
|
|
4367
|
+
AND channel_installation_id = $3
|
|
4368
|
+
AND tenant_id = $4
|
|
4369
|
+
AND enabled = true
|
|
4370
|
+
LIMIT 1`,
|
|
4371
|
+
[params.channel, params.senderId, params.channelInstallationId, params.tenantId]
|
|
4372
|
+
);
|
|
4373
|
+
if (result.rows.length === 0) return null;
|
|
4374
|
+
return this.mapRowToBinding(result.rows[0]);
|
|
4375
|
+
}
|
|
4376
|
+
async create(input) {
|
|
4377
|
+
await this.ensureInitialized();
|
|
4378
|
+
const result = await this.pool.query(
|
|
4379
|
+
`INSERT INTO lattice_channel_bindings
|
|
4380
|
+
(channel, channel_installation_id, tenant_id, sender_id, agent_id,
|
|
4381
|
+
thread_mode, sender_display_name, sender_metadata, workspace_id, project_id)
|
|
4382
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
|
4383
|
+
RETURNING *`,
|
|
4384
|
+
[
|
|
4385
|
+
input.channel,
|
|
4386
|
+
input.channelInstallationId,
|
|
4387
|
+
input.tenantId,
|
|
4388
|
+
input.senderId,
|
|
4389
|
+
input.agentId,
|
|
4390
|
+
input.threadMode || "fixed",
|
|
4391
|
+
input.senderDisplayName || null,
|
|
4392
|
+
input.senderMetadata ? JSON.stringify(input.senderMetadata) : null,
|
|
4393
|
+
input.workspaceId || null,
|
|
4394
|
+
input.projectId || null
|
|
4395
|
+
]
|
|
4396
|
+
);
|
|
4397
|
+
return this.mapRowToBinding(result.rows[0]);
|
|
4398
|
+
}
|
|
4399
|
+
async update(id, patch) {
|
|
4400
|
+
await this.ensureInitialized();
|
|
4401
|
+
const existing = await this.pool.query(
|
|
4402
|
+
`SELECT * FROM lattice_channel_bindings WHERE id = $1`,
|
|
4403
|
+
[id]
|
|
4404
|
+
);
|
|
4405
|
+
if (existing.rows.length === 0) {
|
|
4406
|
+
throw new Error(`Binding ${id} not found`);
|
|
4407
|
+
}
|
|
4408
|
+
const row = existing.rows[0];
|
|
4409
|
+
const updated = {
|
|
4410
|
+
channel: patch.channel ?? row.channel,
|
|
4411
|
+
channel_installation_id: patch.channelInstallationId ?? row.channel_installation_id,
|
|
4412
|
+
sender_id: patch.senderId ?? row.sender_id,
|
|
4413
|
+
agent_id: patch.agentId ?? row.agent_id,
|
|
4414
|
+
thread_id: patch.threadId !== void 0 ? patch.threadId : row.thread_id,
|
|
4415
|
+
workspace_id: patch.workspaceId !== void 0 ? patch.workspaceId : row.workspace_id,
|
|
4416
|
+
project_id: patch.projectId !== void 0 ? patch.projectId : row.project_id,
|
|
4417
|
+
thread_mode: patch.threadMode ?? row.thread_mode,
|
|
4418
|
+
sender_display_name: patch.senderDisplayName !== void 0 ? patch.senderDisplayName : row.sender_display_name,
|
|
4419
|
+
sender_metadata: patch.senderMetadata !== void 0 ? patch.senderMetadata : row.sender_metadata,
|
|
4420
|
+
enabled: patch.enabled ?? row.enabled
|
|
4421
|
+
};
|
|
4422
|
+
const result = await this.pool.query(
|
|
4423
|
+
`UPDATE lattice_channel_bindings SET
|
|
4424
|
+
channel = $1, channel_installation_id = $2, sender_id = $3,
|
|
4425
|
+
agent_id = $4, thread_id = $5, workspace_id = $6, project_id = $7,
|
|
4426
|
+
thread_mode = $8, sender_display_name = $9, sender_metadata = $10,
|
|
4427
|
+
enabled = $11, updated_at = NOW()
|
|
4428
|
+
WHERE id = $12
|
|
4429
|
+
RETURNING *`,
|
|
4430
|
+
[
|
|
4431
|
+
updated.channel,
|
|
4432
|
+
updated.channel_installation_id,
|
|
4433
|
+
updated.sender_id,
|
|
4434
|
+
updated.agent_id,
|
|
4435
|
+
updated.thread_id,
|
|
4436
|
+
updated.workspace_id,
|
|
4437
|
+
updated.project_id,
|
|
4438
|
+
updated.thread_mode,
|
|
4439
|
+
updated.sender_display_name,
|
|
4440
|
+
updated.sender_metadata ? JSON.stringify(updated.sender_metadata) : null,
|
|
4441
|
+
updated.enabled,
|
|
4442
|
+
id
|
|
4443
|
+
]
|
|
4444
|
+
);
|
|
4445
|
+
return this.mapRowToBinding(result.rows[0]);
|
|
4446
|
+
}
|
|
4447
|
+
async delete(id) {
|
|
4448
|
+
await this.ensureInitialized();
|
|
4449
|
+
await this.pool.query(`DELETE FROM lattice_channel_bindings WHERE id = $1`, [id]);
|
|
4450
|
+
}
|
|
4451
|
+
async list(params) {
|
|
4452
|
+
await this.ensureInitialized();
|
|
4453
|
+
const conditions = ["tenant_id = $1"];
|
|
4454
|
+
const values = [params.tenantId];
|
|
4455
|
+
let idx = 2;
|
|
4456
|
+
if (params.channel) {
|
|
4457
|
+
conditions.push(`channel = $${idx++}`);
|
|
4458
|
+
values.push(params.channel);
|
|
4459
|
+
}
|
|
4460
|
+
if (params.agentId) {
|
|
4461
|
+
conditions.push(`agent_id = $${idx++}`);
|
|
4462
|
+
values.push(params.agentId);
|
|
4463
|
+
}
|
|
4464
|
+
if (params.channelInstallationId) {
|
|
4465
|
+
conditions.push(`channel_installation_id = $${idx++}`);
|
|
4466
|
+
values.push(params.channelInstallationId);
|
|
4467
|
+
}
|
|
4468
|
+
const limit = params.limit ?? 50;
|
|
4469
|
+
const offset = params.offset ?? 0;
|
|
4470
|
+
values.push(limit, offset);
|
|
4471
|
+
const result = await this.pool.query(
|
|
4472
|
+
`SELECT * FROM lattice_channel_bindings
|
|
4473
|
+
WHERE ${conditions.join(" AND ")}
|
|
4474
|
+
ORDER BY created_at DESC
|
|
4475
|
+
LIMIT $${idx++} OFFSET $${idx}`,
|
|
4476
|
+
values
|
|
4477
|
+
);
|
|
4478
|
+
return result.rows.map((r) => this.mapRowToBinding(r));
|
|
4479
|
+
}
|
|
4480
|
+
async import(bindings) {
|
|
4481
|
+
const result = [];
|
|
4482
|
+
for (const input of bindings) {
|
|
4483
|
+
result.push(await this.create(input));
|
|
4484
|
+
}
|
|
4485
|
+
return result;
|
|
4486
|
+
}
|
|
4487
|
+
async export(params) {
|
|
4488
|
+
return this.list({ tenantId: params.tenantId, limit: 1e4, offset: 0 });
|
|
4489
|
+
}
|
|
4490
|
+
async ensureInitialized() {
|
|
4491
|
+
if (!this.initialized) {
|
|
4492
|
+
await this.initialize();
|
|
4493
|
+
}
|
|
4494
|
+
}
|
|
4495
|
+
mapRowToBinding(row) {
|
|
4496
|
+
return {
|
|
4497
|
+
id: row.id,
|
|
4498
|
+
channel: row.channel,
|
|
4499
|
+
channelInstallationId: row.channel_installation_id,
|
|
4500
|
+
tenantId: row.tenant_id,
|
|
4501
|
+
senderId: row.sender_id,
|
|
4502
|
+
agentId: row.agent_id,
|
|
4503
|
+
threadId: row.thread_id || void 0,
|
|
4504
|
+
workspaceId: row.workspace_id || void 0,
|
|
4505
|
+
projectId: row.project_id || void 0,
|
|
4506
|
+
threadMode: row.thread_mode,
|
|
4507
|
+
senderDisplayName: row.sender_display_name || void 0,
|
|
4508
|
+
senderMetadata: row.sender_metadata || void 0,
|
|
4509
|
+
enabled: row.enabled,
|
|
4510
|
+
createdAt: row.created_at,
|
|
4511
|
+
updatedAt: row.updated_at
|
|
4512
|
+
};
|
|
4513
|
+
}
|
|
4514
|
+
};
|
|
4515
|
+
|
|
4253
4516
|
// src/stores/ThreadMessageQueueStore.ts
|
|
4254
4517
|
var import_crypto = __toESM(require("crypto"));
|
|
4255
4518
|
|
|
@@ -4540,12 +4803,12 @@ var ThreadMessageQueueStore = class _ThreadMessageQueueStore {
|
|
|
4540
4803
|
var getThreadMessageQueueStore = () => ThreadMessageQueueStore.getInstance();
|
|
4541
4804
|
|
|
4542
4805
|
// src/stores/ChannelIdentityMappingStore.ts
|
|
4543
|
-
var
|
|
4806
|
+
var import_pg14 = require("pg");
|
|
4544
4807
|
var ChannelIdentityMappingStore = class {
|
|
4545
4808
|
constructor(options) {
|
|
4546
4809
|
this.initialized = false;
|
|
4547
4810
|
this.initPromise = null;
|
|
4548
|
-
this.pool = typeof options.poolConfig === "string" ? new
|
|
4811
|
+
this.pool = typeof options.poolConfig === "string" ? new import_pg14.Pool({ connectionString: options.poolConfig }) : new import_pg14.Pool(options.poolConfig);
|
|
4549
4812
|
this.migrationManager = new MigrationManager(this.pool);
|
|
4550
4813
|
this.migrationManager.register(createChannelIdentityMappingTables);
|
|
4551
4814
|
if (options.autoMigrate !== false) {
|
|
@@ -4758,15 +5021,16 @@ function mapRowToChannelIdentityMapping(row) {
|
|
|
4758
5021
|
}
|
|
4759
5022
|
|
|
4760
5023
|
// src/stores/PostgreSQLChannelInstallationStore.ts
|
|
4761
|
-
var
|
|
5024
|
+
var import_pg15 = require("pg");
|
|
4762
5025
|
var import_core4 = require("@axiom-lattice/core");
|
|
4763
5026
|
var PostgreSQLChannelInstallationStore = class {
|
|
4764
5027
|
constructor(options) {
|
|
4765
5028
|
this.initialized = false;
|
|
4766
5029
|
this.initPromise = null;
|
|
4767
|
-
this.pool = typeof options.poolConfig === "string" ? new
|
|
5030
|
+
this.pool = typeof options.poolConfig === "string" ? new import_pg15.Pool({ connectionString: options.poolConfig }) : new import_pg15.Pool(options.poolConfig);
|
|
4768
5031
|
this.migrationManager = new MigrationManager(this.pool);
|
|
4769
5032
|
this.migrationManager.register(createChannelInstallationsTable);
|
|
5033
|
+
this.migrationManager.register(alterChannelInstallationsTable);
|
|
4770
5034
|
if (options.autoMigrate !== false) {
|
|
4771
5035
|
this.initialize().catch((error) => {
|
|
4772
5036
|
console.error(
|
|
@@ -4798,7 +5062,7 @@ var PostgreSQLChannelInstallationStore = class {
|
|
|
4798
5062
|
await this.ensureInitialized();
|
|
4799
5063
|
const result = await this.pool.query(
|
|
4800
5064
|
`
|
|
4801
|
-
SELECT id, tenant_id, channel, name, config, created_at, updated_at
|
|
5065
|
+
SELECT id, tenant_id, channel, name, config, enabled, fallback_agent_id, reject_when_no_binding, created_at, updated_at
|
|
4802
5066
|
FROM lattice_channel_installations
|
|
4803
5067
|
WHERE id = $1
|
|
4804
5068
|
LIMIT 1
|
|
@@ -4814,7 +5078,7 @@ var PostgreSQLChannelInstallationStore = class {
|
|
|
4814
5078
|
await this.ensureInitialized();
|
|
4815
5079
|
const result = channel ? await this.pool.query(
|
|
4816
5080
|
`
|
|
4817
|
-
SELECT id, tenant_id, channel, name, config, created_at, updated_at
|
|
5081
|
+
SELECT id, tenant_id, channel, name, config, enabled, fallback_agent_id, reject_when_no_binding, created_at, updated_at
|
|
4818
5082
|
FROM lattice_channel_installations
|
|
4819
5083
|
WHERE tenant_id = $1 AND channel = $2
|
|
4820
5084
|
ORDER BY created_at DESC
|
|
@@ -4822,7 +5086,7 @@ var PostgreSQLChannelInstallationStore = class {
|
|
|
4822
5086
|
[tenantId, channel]
|
|
4823
5087
|
) : await this.pool.query(
|
|
4824
5088
|
`
|
|
4825
|
-
SELECT id, tenant_id, channel, name, config, created_at, updated_at
|
|
5089
|
+
SELECT id, tenant_id, channel, name, config, enabled, fallback_agent_id, reject_when_no_binding, created_at, updated_at
|
|
4826
5090
|
FROM lattice_channel_installations
|
|
4827
5091
|
WHERE tenant_id = $1
|
|
4828
5092
|
ORDER BY created_at DESC
|
|
@@ -4838,8 +5102,8 @@ var PostgreSQLChannelInstallationStore = class {
|
|
|
4838
5102
|
await this.pool.query(
|
|
4839
5103
|
`
|
|
4840
5104
|
INSERT INTO lattice_channel_installations (
|
|
4841
|
-
id, tenant_id, channel, name, config, created_at, updated_at
|
|
4842
|
-
) VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
5105
|
+
id, tenant_id, channel, name, config, enabled, fallback_agent_id, reject_when_no_binding, created_at, updated_at
|
|
5106
|
+
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
|
4843
5107
|
`,
|
|
4844
5108
|
[
|
|
4845
5109
|
installationId,
|
|
@@ -4847,6 +5111,9 @@ var PostgreSQLChannelInstallationStore = class {
|
|
|
4847
5111
|
data.channel,
|
|
4848
5112
|
data.name || null,
|
|
4849
5113
|
JSON.stringify(encryptedConfig),
|
|
5114
|
+
data.enabled ?? true,
|
|
5115
|
+
data.fallbackAgentId || null,
|
|
5116
|
+
data.rejectWhenNoBinding ?? true,
|
|
4850
5117
|
now,
|
|
4851
5118
|
now
|
|
4852
5119
|
]
|
|
@@ -4857,6 +5124,9 @@ var PostgreSQLChannelInstallationStore = class {
|
|
|
4857
5124
|
channel: data.channel,
|
|
4858
5125
|
name: data.name,
|
|
4859
5126
|
config: data.config,
|
|
5127
|
+
enabled: data.enabled ?? true,
|
|
5128
|
+
fallbackAgentId: data.fallbackAgentId,
|
|
5129
|
+
rejectWhenNoBinding: data.rejectWhenNoBinding ?? true,
|
|
4860
5130
|
createdAt: now,
|
|
4861
5131
|
updatedAt: now
|
|
4862
5132
|
};
|
|
@@ -4867,8 +5137,9 @@ var PostgreSQLChannelInstallationStore = class {
|
|
|
4867
5137
|
if (!existing || existing.tenantId !== tenantId) {
|
|
4868
5138
|
return null;
|
|
4869
5139
|
}
|
|
5140
|
+
const existingConfig = existing.config ?? {};
|
|
4870
5141
|
const mergedConfig = {
|
|
4871
|
-
...
|
|
5142
|
+
...existingConfig,
|
|
4872
5143
|
...updates.config || {}
|
|
4873
5144
|
};
|
|
4874
5145
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -4877,12 +5148,18 @@ var PostgreSQLChannelInstallationStore = class {
|
|
|
4877
5148
|
UPDATE lattice_channel_installations
|
|
4878
5149
|
SET name = $1,
|
|
4879
5150
|
config = $2,
|
|
4880
|
-
|
|
4881
|
-
|
|
5151
|
+
enabled = $3,
|
|
5152
|
+
fallback_agent_id = $4,
|
|
5153
|
+
reject_when_no_binding = $5,
|
|
5154
|
+
updated_at = $6
|
|
5155
|
+
WHERE tenant_id = $7 AND id = $8
|
|
4882
5156
|
`,
|
|
4883
5157
|
[
|
|
4884
5158
|
updates.name ?? existing.name ?? null,
|
|
4885
5159
|
JSON.stringify(this.encryptSecrets(mergedConfig)),
|
|
5160
|
+
updates.enabled ?? existing.enabled,
|
|
5161
|
+
updates.fallbackAgentId !== void 0 ? updates.fallbackAgentId : existing.fallbackAgentId ?? null,
|
|
5162
|
+
updates.rejectWhenNoBinding ?? existing.rejectWhenNoBinding,
|
|
4886
5163
|
now,
|
|
4887
5164
|
tenantId,
|
|
4888
5165
|
installationId
|
|
@@ -4892,6 +5169,9 @@ var PostgreSQLChannelInstallationStore = class {
|
|
|
4892
5169
|
...existing,
|
|
4893
5170
|
name: updates.name ?? existing.name,
|
|
4894
5171
|
config: mergedConfig,
|
|
5172
|
+
enabled: updates.enabled ?? existing.enabled,
|
|
5173
|
+
fallbackAgentId: updates.fallbackAgentId !== void 0 ? updates.fallbackAgentId : existing.fallbackAgentId,
|
|
5174
|
+
rejectWhenNoBinding: updates.rejectWhenNoBinding ?? existing.rejectWhenNoBinding,
|
|
4895
5175
|
updatedAt: now
|
|
4896
5176
|
};
|
|
4897
5177
|
}
|
|
@@ -4920,6 +5200,9 @@ var PostgreSQLChannelInstallationStore = class {
|
|
|
4920
5200
|
config: this.decryptSecrets(
|
|
4921
5201
|
typeof row.config === "string" ? JSON.parse(row.config) : row.config
|
|
4922
5202
|
),
|
|
5203
|
+
enabled: row.enabled,
|
|
5204
|
+
fallbackAgentId: row.fallback_agent_id || void 0,
|
|
5205
|
+
rejectWhenNoBinding: row.reject_when_no_binding,
|
|
4923
5206
|
createdAt: row.created_at,
|
|
4924
5207
|
updatedAt: row.updated_at
|
|
4925
5208
|
};
|
|
@@ -4934,28 +5217,24 @@ var PostgreSQLChannelInstallationStore = class {
|
|
|
4934
5217
|
}
|
|
4935
5218
|
decryptSecrets(config) {
|
|
4936
5219
|
return {
|
|
4937
|
-
|
|
4938
|
-
appSecret: typeof config.appSecret === "string" ? (0, import_core4.decrypt)(config.appSecret) :
|
|
4939
|
-
verificationToken: typeof config.verificationToken === "string" ? (0, import_core4.decrypt)(config.verificationToken) :
|
|
4940
|
-
encryptKey: typeof config.encryptKey === "string" ? (0, import_core4.decrypt)(config.encryptKey) :
|
|
4941
|
-
mappingMode: config.mappingMode === "user" || config.mappingMode === "group" || config.mappingMode === "hybrid" ? config.mappingMode : "hybrid",
|
|
4942
|
-
assistantId: String(config.assistantId || ""),
|
|
4943
|
-
workspaceId: typeof config.workspaceId === "string" ? config.workspaceId : void 0,
|
|
4944
|
-
projectId: typeof config.projectId === "string" ? config.projectId : void 0
|
|
5220
|
+
...config,
|
|
5221
|
+
appSecret: typeof config.appSecret === "string" ? (0, import_core4.decrypt)(config.appSecret) : config.appSecret,
|
|
5222
|
+
verificationToken: typeof config.verificationToken === "string" ? (0, import_core4.decrypt)(config.verificationToken) : config.verificationToken,
|
|
5223
|
+
encryptKey: typeof config.encryptKey === "string" ? (0, import_core4.decrypt)(config.encryptKey) : config.encryptKey
|
|
4945
5224
|
};
|
|
4946
5225
|
}
|
|
4947
5226
|
};
|
|
4948
5227
|
|
|
4949
5228
|
// src/stores/PostgreSQLWorkflowTrackingStore.ts
|
|
4950
|
-
var
|
|
5229
|
+
var import_pg16 = require("pg");
|
|
4951
5230
|
var PostgreSQLWorkflowTrackingStore = class {
|
|
4952
5231
|
constructor(options) {
|
|
4953
5232
|
this.initialized = false;
|
|
4954
5233
|
this.initPromise = null;
|
|
4955
5234
|
if (typeof options.poolConfig === "string") {
|
|
4956
|
-
this.pool = new
|
|
5235
|
+
this.pool = new import_pg16.Pool({ connectionString: options.poolConfig });
|
|
4957
5236
|
} else {
|
|
4958
|
-
this.pool = new
|
|
5237
|
+
this.pool = new import_pg16.Pool(options.poolConfig);
|
|
4959
5238
|
}
|
|
4960
5239
|
this.migrationManager = new MigrationManager(this.pool);
|
|
4961
5240
|
this.migrationManager.register(createWorkflowTrackingTables);
|
|
@@ -5222,7 +5501,7 @@ var PostgreSQLWorkflowTrackingStore = class {
|
|
|
5222
5501
|
};
|
|
5223
5502
|
|
|
5224
5503
|
// src/stores/PostgreSQLEvalStore.ts
|
|
5225
|
-
var
|
|
5504
|
+
var import_pg17 = require("pg");
|
|
5226
5505
|
|
|
5227
5506
|
// src/migrations/eval_migrations.ts
|
|
5228
5507
|
var createEvalProjectsTable = {
|
|
@@ -5422,9 +5701,9 @@ var PostgreSQLEvalStore = class {
|
|
|
5422
5701
|
this.ownsPool = true;
|
|
5423
5702
|
this.initPromise = null;
|
|
5424
5703
|
if (typeof options.poolConfig === "string") {
|
|
5425
|
-
this.pool = new
|
|
5704
|
+
this.pool = new import_pg17.Pool({ connectionString: options.poolConfig });
|
|
5426
5705
|
} else {
|
|
5427
|
-
this.pool = new
|
|
5706
|
+
this.pool = new import_pg17.Pool(options.poolConfig);
|
|
5428
5707
|
}
|
|
5429
5708
|
this.migrationManager = new MigrationManager(this.pool);
|
|
5430
5709
|
for (const m of evalMigrations) {
|
|
@@ -6143,6 +6422,7 @@ var PostgreSQLEvalStore = class {
|
|
|
6143
6422
|
};
|
|
6144
6423
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6145
6424
|
0 && (module.exports = {
|
|
6425
|
+
ChannelBindingStore,
|
|
6146
6426
|
ChannelIdentityMappingStore,
|
|
6147
6427
|
MigrationManager,
|
|
6148
6428
|
Pool,
|
|
@@ -6166,10 +6446,12 @@ var PostgreSQLEvalStore = class {
|
|
|
6166
6446
|
addScheduleTenantId,
|
|
6167
6447
|
addSkillTenantId,
|
|
6168
6448
|
addThreadTenantId,
|
|
6449
|
+
alterChannelInstallationsTable,
|
|
6169
6450
|
changeAssistantPrimaryKey,
|
|
6170
6451
|
changeSkillPrimaryKey,
|
|
6171
6452
|
changeThreadPrimaryKey,
|
|
6172
6453
|
createAssistantsTable,
|
|
6454
|
+
createChannelBindingsTable,
|
|
6173
6455
|
createChannelIdentityMappingTables,
|
|
6174
6456
|
createChannelInstallationsTable,
|
|
6175
6457
|
createDatabaseConfigsTable,
|