@axiom-lattice/pg-stores 1.0.33 → 1.0.35
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 +8 -8
- package/CHANGELOG.md +16 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +78 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/ThreadMessageQueueStore.test.ts +97 -2
- package/src/migrations/add_custom_run_config_column.ts +25 -0
- package/src/migrations/alter_message_queue_id_column.ts +41 -0
- package/src/stores/PostgreSQLThreadStore.ts +17 -2
- package/src/stores/ThreadMessageQueueStore.ts +21 -24
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @axiom-lattice/pg-stores@1.0.
|
|
2
|
+
> @axiom-lattice/pg-stores@1.0.35 build /home/runner/work/agentic/agentic/packages/pg-stores
|
|
3
3
|
> tsup src/index.ts --format cjs,esm --dts --sourcemap
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
[34mCLI[39m Target: es2020
|
|
9
9
|
[34mCJS[39m Build start
|
|
10
10
|
[34mESM[39m Build start
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
11
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m129.31 KB[39m
|
|
12
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m247.58 KB[39m
|
|
13
|
+
[32mESM[39m ⚡️ Build success in 343ms
|
|
14
|
+
[32mCJS[39m [1mdist/index.js [22m[32m133.26 KB[39m
|
|
15
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m247.65 KB[39m
|
|
16
|
+
[32mCJS[39m ⚡️ Build success in 357ms
|
|
17
17
|
[34mDTS[39m Build start
|
|
18
|
-
[32mDTS[39m ⚡️ Build success in
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 11746ms
|
|
19
19
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m34.53 KB[39m
|
|
20
20
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m34.53 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @axiom-lattice/pg-stores
|
|
2
2
|
|
|
3
|
+
## 1.0.35
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4c4ca60: fix subagent state issue
|
|
8
|
+
- Updated dependencies [4c4ca60]
|
|
9
|
+
- @axiom-lattice/core@2.1.45
|
|
10
|
+
|
|
11
|
+
## 1.0.34
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- e8fc7ec: fix subagent issue
|
|
16
|
+
- Updated dependencies [e8fc7ec]
|
|
17
|
+
- @axiom-lattice/core@2.1.44
|
|
18
|
+
|
|
3
19
|
## 1.0.33
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -50,7 +50,7 @@ declare class PostgreSQLThreadStore implements ThreadStore {
|
|
|
50
50
|
/**
|
|
51
51
|
* Get all threads for a specific tenant and assistant
|
|
52
52
|
*/
|
|
53
|
-
getThreadsByAssistantId(tenantId: string, assistantId: string): Promise<Thread[]>;
|
|
53
|
+
getThreadsByAssistantId(tenantId: string, assistantId: string, metadataFilter?: Record<string, string>): Promise<Thread[]>;
|
|
54
54
|
/**
|
|
55
55
|
* Get a thread by ID for a specific tenant
|
|
56
56
|
*/
|
|
@@ -1113,7 +1113,7 @@ declare class ThreadMessageQueueStore implements IMessageQueueStore {
|
|
|
1113
1113
|
* Add message at head of queue (high priority, e.g., STEER/Command messages)
|
|
1114
1114
|
* Uses priority=100 to ensure message is processed first
|
|
1115
1115
|
*/
|
|
1116
|
-
addMessageAtHead(
|
|
1116
|
+
addMessageAtHead(params: AddMessageParams): Promise<PendingMessage>;
|
|
1117
1117
|
/**
|
|
1118
1118
|
* Get pending messages for thread
|
|
1119
1119
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ declare class PostgreSQLThreadStore implements ThreadStore {
|
|
|
50
50
|
/**
|
|
51
51
|
* Get all threads for a specific tenant and assistant
|
|
52
52
|
*/
|
|
53
|
-
getThreadsByAssistantId(tenantId: string, assistantId: string): Promise<Thread[]>;
|
|
53
|
+
getThreadsByAssistantId(tenantId: string, assistantId: string, metadataFilter?: Record<string, string>): Promise<Thread[]>;
|
|
54
54
|
/**
|
|
55
55
|
* Get a thread by ID for a specific tenant
|
|
56
56
|
*/
|
|
@@ -1113,7 +1113,7 @@ declare class ThreadMessageQueueStore implements IMessageQueueStore {
|
|
|
1113
1113
|
* Add message at head of queue (high priority, e.g., STEER/Command messages)
|
|
1114
1114
|
* Uses priority=100 to ensure message is processed first
|
|
1115
1115
|
*/
|
|
1116
|
-
addMessageAtHead(
|
|
1116
|
+
addMessageAtHead(params: AddMessageParams): Promise<PendingMessage>;
|
|
1117
1117
|
/**
|
|
1118
1118
|
* Get pending messages for thread
|
|
1119
1119
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -398,7 +408,7 @@ var PostgreSQLThreadStore = class {
|
|
|
398
408
|
/**
|
|
399
409
|
* Get all threads for a specific tenant and assistant
|
|
400
410
|
*/
|
|
401
|
-
async getThreadsByAssistantId(tenantId, assistantId) {
|
|
411
|
+
async getThreadsByAssistantId(tenantId, assistantId, metadataFilter) {
|
|
402
412
|
await this.ensureInitialized();
|
|
403
413
|
const result = await this.pool.query(
|
|
404
414
|
`
|
|
@@ -409,7 +419,15 @@ var PostgreSQLThreadStore = class {
|
|
|
409
419
|
`,
|
|
410
420
|
[tenantId, assistantId]
|
|
411
421
|
);
|
|
412
|
-
|
|
422
|
+
let threads = result.rows.map(this.mapRowToThread);
|
|
423
|
+
if (metadataFilter && Object.keys(metadataFilter).length > 0) {
|
|
424
|
+
threads = threads.filter(
|
|
425
|
+
(thread) => Object.entries(metadataFilter).every(
|
|
426
|
+
([key, value]) => thread.metadata?.[key] === value
|
|
427
|
+
)
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
return threads;
|
|
413
431
|
}
|
|
414
432
|
/**
|
|
415
433
|
* Get a thread by ID for a specific tenant
|
|
@@ -4067,6 +4085,7 @@ var createThreadMessageQueueTable = {
|
|
|
4067
4085
|
};
|
|
4068
4086
|
|
|
4069
4087
|
// src/stores/ThreadMessageQueueStore.ts
|
|
4088
|
+
var import_crypto = __toESM(require("crypto"));
|
|
4070
4089
|
var import_core4 = require("@axiom-lattice/core");
|
|
4071
4090
|
|
|
4072
4091
|
// src/migrations/add_priority_command_columns.ts
|
|
@@ -4094,6 +4113,48 @@ var addPriorityAndCommandColumns = {
|
|
|
4094
4113
|
}
|
|
4095
4114
|
};
|
|
4096
4115
|
|
|
4116
|
+
// src/migrations/add_custom_run_config_column.ts
|
|
4117
|
+
var addCustomRunConfigColumn = {
|
|
4118
|
+
version: 102,
|
|
4119
|
+
name: "add_custom_run_config_column",
|
|
4120
|
+
up: async (client) => {
|
|
4121
|
+
await client.query(`
|
|
4122
|
+
ALTER TABLE lattice_thread_message_queue
|
|
4123
|
+
ADD COLUMN IF NOT EXISTS custom_run_config JSONB
|
|
4124
|
+
`);
|
|
4125
|
+
},
|
|
4126
|
+
down: async (client) => {
|
|
4127
|
+
await client.query(
|
|
4128
|
+
"ALTER TABLE lattice_thread_message_queue DROP COLUMN IF EXISTS custom_run_config"
|
|
4129
|
+
);
|
|
4130
|
+
}
|
|
4131
|
+
};
|
|
4132
|
+
|
|
4133
|
+
// src/migrations/alter_message_queue_id_column.ts
|
|
4134
|
+
var alterMessageQueueIdColumn = {
|
|
4135
|
+
version: 102,
|
|
4136
|
+
name: "alter_message_queue_id_column",
|
|
4137
|
+
up: async (client) => {
|
|
4138
|
+
await client.query(`
|
|
4139
|
+
ALTER TABLE lattice_thread_message_queue
|
|
4140
|
+
ALTER COLUMN id DROP DEFAULT
|
|
4141
|
+
`);
|
|
4142
|
+
await client.query(`
|
|
4143
|
+
COMMENT ON COLUMN lattice_thread_message_queue.id IS
|
|
4144
|
+
'Message ID - must be provided explicitly (UUID format). Used for consistent ID across client and server.'
|
|
4145
|
+
`);
|
|
4146
|
+
},
|
|
4147
|
+
down: async (client) => {
|
|
4148
|
+
await client.query(`
|
|
4149
|
+
ALTER TABLE lattice_thread_message_queue
|
|
4150
|
+
ALTER COLUMN id SET DEFAULT gen_random_uuid()
|
|
4151
|
+
`);
|
|
4152
|
+
await client.query(`
|
|
4153
|
+
COMMENT ON COLUMN lattice_thread_message_queue.id IS NULL
|
|
4154
|
+
`);
|
|
4155
|
+
}
|
|
4156
|
+
};
|
|
4157
|
+
|
|
4097
4158
|
// src/stores/ThreadMessageQueueStore.ts
|
|
4098
4159
|
var ThreadMessageQueueStore = class _ThreadMessageQueueStore {
|
|
4099
4160
|
constructor() {
|
|
@@ -4117,6 +4178,8 @@ var ThreadMessageQueueStore = class _ThreadMessageQueueStore {
|
|
|
4117
4178
|
const migrationManager = new MigrationManager(pool);
|
|
4118
4179
|
migrationManager.register(createThreadMessageQueueTable);
|
|
4119
4180
|
migrationManager.register(addPriorityAndCommandColumns);
|
|
4181
|
+
migrationManager.register(addCustomRunConfigColumn);
|
|
4182
|
+
migrationManager.register(alterMessageQueueIdColumn);
|
|
4120
4183
|
await migrationManager.migrate();
|
|
4121
4184
|
this.initialized = true;
|
|
4122
4185
|
}
|
|
@@ -4132,7 +4195,7 @@ var ThreadMessageQueueStore = class _ThreadMessageQueueStore {
|
|
|
4132
4195
|
*/
|
|
4133
4196
|
async addMessage(params) {
|
|
4134
4197
|
const pool = this.getPool();
|
|
4135
|
-
const { threadId, tenantId, assistantId, content, type = "human", priority = 0, command } = params;
|
|
4198
|
+
const { threadId, tenantId, assistantId, content, type = "human", priority = 0, command, custom_run_config, id } = params;
|
|
4136
4199
|
const seqResult = await pool.query(
|
|
4137
4200
|
`SELECT COALESCE(MAX(sequence_order), 0) + 1 as next_seq
|
|
4138
4201
|
FROM lattice_thread_message_queue
|
|
@@ -4142,10 +4205,10 @@ var ThreadMessageQueueStore = class _ThreadMessageQueueStore {
|
|
|
4142
4205
|
const nextSeq = seqResult.rows[0].next_seq;
|
|
4143
4206
|
const result = await pool.query(
|
|
4144
4207
|
`INSERT INTO lattice_thread_message_queue
|
|
4145
|
-
(thread_id, tenant_id, assistant_id, message_content, message_type, sequence_order, priority, command)
|
|
4146
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
4208
|
+
(id, thread_id, tenant_id, assistant_id, message_content, message_type, sequence_order, priority, command, custom_run_config)
|
|
4209
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
|
4147
4210
|
RETURNING *`,
|
|
4148
|
-
[threadId, tenantId, assistantId, JSON.stringify(content), type, nextSeq, priority, command ? JSON.stringify(command) : null]
|
|
4211
|
+
[id || import_crypto.default.randomUUID(), threadId, tenantId, assistantId, JSON.stringify(content), type, nextSeq, priority, command ? JSON.stringify(command) : null, custom_run_config ? JSON.stringify(custom_run_config) : null]
|
|
4149
4212
|
);
|
|
4150
4213
|
return this.rowToMessage(result.rows[0]);
|
|
4151
4214
|
}
|
|
@@ -4153,21 +4216,11 @@ var ThreadMessageQueueStore = class _ThreadMessageQueueStore {
|
|
|
4153
4216
|
* Add message at head of queue (high priority, e.g., STEER/Command messages)
|
|
4154
4217
|
* Uses priority=100 to ensure message is processed first
|
|
4155
4218
|
*/
|
|
4156
|
-
async addMessageAtHead(
|
|
4219
|
+
async addMessageAtHead(params) {
|
|
4157
4220
|
const pool = this.getPool();
|
|
4158
|
-
const
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
WHERE thread_id = $1
|
|
4162
|
-
LIMIT 1`,
|
|
4163
|
-
[threadId]
|
|
4164
|
-
);
|
|
4165
|
-
let tenantId = "default";
|
|
4166
|
-
let assistantId = "";
|
|
4167
|
-
if (threadResult.rows.length > 0) {
|
|
4168
|
-
tenantId = threadResult.rows[0].tenant_id;
|
|
4169
|
-
assistantId = threadResult.rows[0].assistant_id;
|
|
4170
|
-
}
|
|
4221
|
+
const { threadId, tenantId, assistantId, content, type = "human", command, custom_run_config, id } = params;
|
|
4222
|
+
const resolvedTenantId = tenantId;
|
|
4223
|
+
const resolvedAssistantId = assistantId;
|
|
4171
4224
|
const seqResult = await pool.query(
|
|
4172
4225
|
`SELECT COALESCE(MAX(sequence_order), 0) + 1 as next_seq
|
|
4173
4226
|
FROM lattice_thread_message_queue
|
|
@@ -4177,10 +4230,10 @@ var ThreadMessageQueueStore = class _ThreadMessageQueueStore {
|
|
|
4177
4230
|
const nextSeq = seqResult.rows[0].next_seq;
|
|
4178
4231
|
const result = await pool.query(
|
|
4179
4232
|
`INSERT INTO lattice_thread_message_queue
|
|
4180
|
-
(thread_id, tenant_id, assistant_id, message_content, message_type, sequence_order, priority)
|
|
4181
|
-
VALUES ($1, $2, $3, $4, $5, $6, 100)
|
|
4233
|
+
(id, thread_id, tenant_id, assistant_id, message_content, message_type, sequence_order, priority, command, custom_run_config)
|
|
4234
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, 100, $8, $9)
|
|
4182
4235
|
RETURNING *`,
|
|
4183
|
-
[threadId,
|
|
4236
|
+
[id || import_crypto.default.randomUUID(), threadId, resolvedTenantId, resolvedAssistantId, JSON.stringify(content), type, nextSeq, command ? JSON.stringify(command) : null, custom_run_config ? JSON.stringify(custom_run_config) : null]
|
|
4184
4237
|
);
|
|
4185
4238
|
return this.rowToMessage(result.rows[0]);
|
|
4186
4239
|
}
|
|
@@ -4314,7 +4367,8 @@ var ThreadMessageQueueStore = class _ThreadMessageQueueStore {
|
|
|
4314
4367
|
sequence: row.sequence_order,
|
|
4315
4368
|
createdAt: new Date(row.created_at),
|
|
4316
4369
|
priority: row.priority || 0,
|
|
4317
|
-
command: row.command ? typeof row.command === "string" ? JSON.parse(row.command) : row.command : void 0
|
|
4370
|
+
command: row.command ? typeof row.command === "string" ? JSON.parse(row.command) : row.command : void 0,
|
|
4371
|
+
custom_run_config: row.custom_run_config ? typeof row.custom_run_config === "string" ? JSON.parse(row.custom_run_config) : row.custom_run_config : void 0
|
|
4318
4372
|
};
|
|
4319
4373
|
}
|
|
4320
4374
|
};
|