@axiom-lattice/pg-stores 1.0.2 → 1.0.4
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 +17 -0
- package/dist/index.d.mts +126 -3
- package/dist/index.d.ts +126 -3
- package/dist/index.js +545 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +545 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +7 -0
- package/src/migrations/schedule_migrations.ts +116 -0
- package/src/stores/PostgreSQLScheduleStorage.ts +591 -0
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.4 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
|
+
[32mCJS[39m [1mdist/index.js [22m[32m34.68 KB[39m
|
|
12
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m61.72 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 199ms
|
|
14
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m33.20 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m60.64 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 200ms
|
|
17
17
|
[34mDTS[39m Build start
|
|
18
|
-
[32mDTS[39m ⚡️ Build success in
|
|
19
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
20
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 6520ms
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m8.83 KB[39m
|
|
20
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m8.83 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @axiom-lattice/pg-stores
|
|
2
2
|
|
|
3
|
+
## 1.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [ef0fb84]
|
|
8
|
+
- @axiom-lattice/protocols@2.1.9
|
|
9
|
+
- @axiom-lattice/core@2.1.15
|
|
10
|
+
|
|
11
|
+
## 1.0.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- d43ea0b: add schedule task
|
|
16
|
+
- Updated dependencies [d43ea0b]
|
|
17
|
+
- @axiom-lattice/protocols@2.1.8
|
|
18
|
+
- @axiom-lattice/core@2.1.14
|
|
19
|
+
|
|
3
20
|
## 1.0.2
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PoolConfig, PoolClient, Pool } from 'pg';
|
|
2
|
-
import { ThreadStore, Thread, CreateThreadRequest, AssistantStore, Assistant, CreateAssistantRequest } from '@axiom-lattice/protocols';
|
|
3
|
-
export { Assistant, AssistantStore, CreateAssistantRequest, CreateThreadRequest, Thread, ThreadStore } from '@axiom-lattice/protocols';
|
|
2
|
+
import { ThreadStore, Thread, CreateThreadRequest, AssistantStore, Assistant, CreateAssistantRequest, ScheduleStorage, ScheduledTaskDefinition, ScheduledTaskStatus, ScheduleExecutionType } from '@axiom-lattice/protocols';
|
|
3
|
+
export { Assistant, AssistantStore, CreateAssistantRequest, CreateThreadRequest, ScheduleExecutionType, ScheduleStorage, ScheduledTaskDefinition, ScheduledTaskStatus, Thread, ThreadStore } from '@axiom-lattice/protocols';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* PostgreSQL implementation of ThreadStore
|
|
@@ -144,6 +144,120 @@ declare class PostgreSQLAssistantStore implements AssistantStore {
|
|
|
144
144
|
private mapRowToAssistant;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
/**
|
|
148
|
+
* PostgreSQL implementation of ScheduleStorage
|
|
149
|
+
*
|
|
150
|
+
* Provides persistent storage for scheduled tasks
|
|
151
|
+
* Data survives service restarts
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* PostgreSQL ScheduleStorage options
|
|
156
|
+
*/
|
|
157
|
+
interface PostgreSQLScheduleStorageOptions {
|
|
158
|
+
/**
|
|
159
|
+
* PostgreSQL connection pool configuration
|
|
160
|
+
* Can be a connection string or PoolConfig object
|
|
161
|
+
*/
|
|
162
|
+
poolConfig: string | PoolConfig;
|
|
163
|
+
/**
|
|
164
|
+
* Whether to run migrations automatically on initialization
|
|
165
|
+
* @default true
|
|
166
|
+
*/
|
|
167
|
+
autoMigrate?: boolean;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* PostgreSQL implementation of ScheduleStorage
|
|
171
|
+
*/
|
|
172
|
+
declare class PostgreSQLScheduleStorage implements ScheduleStorage {
|
|
173
|
+
private pool;
|
|
174
|
+
private migrationManager;
|
|
175
|
+
private initialized;
|
|
176
|
+
constructor(options: PostgreSQLScheduleStorageOptions);
|
|
177
|
+
/**
|
|
178
|
+
* Dispose resources and close the connection pool
|
|
179
|
+
*/
|
|
180
|
+
dispose(): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Initialize the store and run migrations
|
|
183
|
+
*/
|
|
184
|
+
initialize(): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Ensure store is initialized
|
|
187
|
+
*/
|
|
188
|
+
private ensureInitialized;
|
|
189
|
+
/**
|
|
190
|
+
* Save a new task
|
|
191
|
+
*/
|
|
192
|
+
save(task: ScheduledTaskDefinition): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Get task by ID
|
|
195
|
+
*/
|
|
196
|
+
get(taskId: string): Promise<ScheduledTaskDefinition | null>;
|
|
197
|
+
/**
|
|
198
|
+
* Update task
|
|
199
|
+
*/
|
|
200
|
+
update(taskId: string, updates: Partial<ScheduledTaskDefinition>): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* Delete task
|
|
203
|
+
*/
|
|
204
|
+
delete(taskId: string): Promise<void>;
|
|
205
|
+
/**
|
|
206
|
+
* Get all active tasks (pending or paused)
|
|
207
|
+
*/
|
|
208
|
+
getActiveTasks(): Promise<ScheduledTaskDefinition[]>;
|
|
209
|
+
/**
|
|
210
|
+
* Get tasks by type
|
|
211
|
+
*/
|
|
212
|
+
getTasksByType(taskType: string): Promise<ScheduledTaskDefinition[]>;
|
|
213
|
+
/**
|
|
214
|
+
* Get tasks by status
|
|
215
|
+
*/
|
|
216
|
+
getTasksByStatus(status: ScheduledTaskStatus): Promise<ScheduledTaskDefinition[]>;
|
|
217
|
+
/**
|
|
218
|
+
* Get tasks by execution type
|
|
219
|
+
*/
|
|
220
|
+
getTasksByExecutionType(executionType: ScheduleExecutionType): Promise<ScheduledTaskDefinition[]>;
|
|
221
|
+
/**
|
|
222
|
+
* Get tasks by assistant ID
|
|
223
|
+
*/
|
|
224
|
+
getTasksByAssistantId(assistantId: string): Promise<ScheduledTaskDefinition[]>;
|
|
225
|
+
/**
|
|
226
|
+
* Get tasks by thread ID
|
|
227
|
+
*/
|
|
228
|
+
getTasksByThreadId(threadId: string): Promise<ScheduledTaskDefinition[]>;
|
|
229
|
+
/**
|
|
230
|
+
* Get all tasks with optional filters
|
|
231
|
+
*/
|
|
232
|
+
getAllTasks(filters?: {
|
|
233
|
+
status?: ScheduledTaskStatus;
|
|
234
|
+
executionType?: ScheduleExecutionType;
|
|
235
|
+
taskType?: string;
|
|
236
|
+
assistantId?: string;
|
|
237
|
+
threadId?: string;
|
|
238
|
+
limit?: number;
|
|
239
|
+
offset?: number;
|
|
240
|
+
}): Promise<ScheduledTaskDefinition[]>;
|
|
241
|
+
/**
|
|
242
|
+
* Count tasks with optional filters
|
|
243
|
+
*/
|
|
244
|
+
countTasks(filters?: {
|
|
245
|
+
status?: ScheduledTaskStatus;
|
|
246
|
+
executionType?: ScheduleExecutionType;
|
|
247
|
+
taskType?: string;
|
|
248
|
+
assistantId?: string;
|
|
249
|
+
threadId?: string;
|
|
250
|
+
}): Promise<number>;
|
|
251
|
+
/**
|
|
252
|
+
* Delete completed/cancelled/failed tasks older than specified time
|
|
253
|
+
*/
|
|
254
|
+
deleteOldTasks(olderThanMs: number): Promise<number>;
|
|
255
|
+
/**
|
|
256
|
+
* Map database row to ScheduledTaskDefinition
|
|
257
|
+
*/
|
|
258
|
+
private mapRowToTask;
|
|
259
|
+
}
|
|
260
|
+
|
|
147
261
|
/**
|
|
148
262
|
* Migration system for database schema management
|
|
149
263
|
*/
|
|
@@ -208,4 +322,13 @@ declare const createThreadsTable: Migration;
|
|
|
208
322
|
*/
|
|
209
323
|
declare const createAssistantsTable: Migration;
|
|
210
324
|
|
|
211
|
-
|
|
325
|
+
/**
|
|
326
|
+
* PostgreSQL migrations for scheduled tasks table
|
|
327
|
+
*/
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Create the scheduled_tasks table
|
|
331
|
+
*/
|
|
332
|
+
declare const createScheduledTasksTable: Migration;
|
|
333
|
+
|
|
334
|
+
export { type Migration, MigrationManager, PostgreSQLAssistantStore, type PostgreSQLAssistantStoreOptions, PostgreSQLScheduleStorage, type PostgreSQLScheduleStorageOptions, PostgreSQLThreadStore, type PostgreSQLThreadStoreOptions, createAssistantsTable, createScheduledTasksTable, createThreadsTable };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PoolConfig, PoolClient, Pool } from 'pg';
|
|
2
|
-
import { ThreadStore, Thread, CreateThreadRequest, AssistantStore, Assistant, CreateAssistantRequest } from '@axiom-lattice/protocols';
|
|
3
|
-
export { Assistant, AssistantStore, CreateAssistantRequest, CreateThreadRequest, Thread, ThreadStore } from '@axiom-lattice/protocols';
|
|
2
|
+
import { ThreadStore, Thread, CreateThreadRequest, AssistantStore, Assistant, CreateAssistantRequest, ScheduleStorage, ScheduledTaskDefinition, ScheduledTaskStatus, ScheduleExecutionType } from '@axiom-lattice/protocols';
|
|
3
|
+
export { Assistant, AssistantStore, CreateAssistantRequest, CreateThreadRequest, ScheduleExecutionType, ScheduleStorage, ScheduledTaskDefinition, ScheduledTaskStatus, Thread, ThreadStore } from '@axiom-lattice/protocols';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* PostgreSQL implementation of ThreadStore
|
|
@@ -144,6 +144,120 @@ declare class PostgreSQLAssistantStore implements AssistantStore {
|
|
|
144
144
|
private mapRowToAssistant;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
/**
|
|
148
|
+
* PostgreSQL implementation of ScheduleStorage
|
|
149
|
+
*
|
|
150
|
+
* Provides persistent storage for scheduled tasks
|
|
151
|
+
* Data survives service restarts
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* PostgreSQL ScheduleStorage options
|
|
156
|
+
*/
|
|
157
|
+
interface PostgreSQLScheduleStorageOptions {
|
|
158
|
+
/**
|
|
159
|
+
* PostgreSQL connection pool configuration
|
|
160
|
+
* Can be a connection string or PoolConfig object
|
|
161
|
+
*/
|
|
162
|
+
poolConfig: string | PoolConfig;
|
|
163
|
+
/**
|
|
164
|
+
* Whether to run migrations automatically on initialization
|
|
165
|
+
* @default true
|
|
166
|
+
*/
|
|
167
|
+
autoMigrate?: boolean;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* PostgreSQL implementation of ScheduleStorage
|
|
171
|
+
*/
|
|
172
|
+
declare class PostgreSQLScheduleStorage implements ScheduleStorage {
|
|
173
|
+
private pool;
|
|
174
|
+
private migrationManager;
|
|
175
|
+
private initialized;
|
|
176
|
+
constructor(options: PostgreSQLScheduleStorageOptions);
|
|
177
|
+
/**
|
|
178
|
+
* Dispose resources and close the connection pool
|
|
179
|
+
*/
|
|
180
|
+
dispose(): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Initialize the store and run migrations
|
|
183
|
+
*/
|
|
184
|
+
initialize(): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Ensure store is initialized
|
|
187
|
+
*/
|
|
188
|
+
private ensureInitialized;
|
|
189
|
+
/**
|
|
190
|
+
* Save a new task
|
|
191
|
+
*/
|
|
192
|
+
save(task: ScheduledTaskDefinition): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Get task by ID
|
|
195
|
+
*/
|
|
196
|
+
get(taskId: string): Promise<ScheduledTaskDefinition | null>;
|
|
197
|
+
/**
|
|
198
|
+
* Update task
|
|
199
|
+
*/
|
|
200
|
+
update(taskId: string, updates: Partial<ScheduledTaskDefinition>): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* Delete task
|
|
203
|
+
*/
|
|
204
|
+
delete(taskId: string): Promise<void>;
|
|
205
|
+
/**
|
|
206
|
+
* Get all active tasks (pending or paused)
|
|
207
|
+
*/
|
|
208
|
+
getActiveTasks(): Promise<ScheduledTaskDefinition[]>;
|
|
209
|
+
/**
|
|
210
|
+
* Get tasks by type
|
|
211
|
+
*/
|
|
212
|
+
getTasksByType(taskType: string): Promise<ScheduledTaskDefinition[]>;
|
|
213
|
+
/**
|
|
214
|
+
* Get tasks by status
|
|
215
|
+
*/
|
|
216
|
+
getTasksByStatus(status: ScheduledTaskStatus): Promise<ScheduledTaskDefinition[]>;
|
|
217
|
+
/**
|
|
218
|
+
* Get tasks by execution type
|
|
219
|
+
*/
|
|
220
|
+
getTasksByExecutionType(executionType: ScheduleExecutionType): Promise<ScheduledTaskDefinition[]>;
|
|
221
|
+
/**
|
|
222
|
+
* Get tasks by assistant ID
|
|
223
|
+
*/
|
|
224
|
+
getTasksByAssistantId(assistantId: string): Promise<ScheduledTaskDefinition[]>;
|
|
225
|
+
/**
|
|
226
|
+
* Get tasks by thread ID
|
|
227
|
+
*/
|
|
228
|
+
getTasksByThreadId(threadId: string): Promise<ScheduledTaskDefinition[]>;
|
|
229
|
+
/**
|
|
230
|
+
* Get all tasks with optional filters
|
|
231
|
+
*/
|
|
232
|
+
getAllTasks(filters?: {
|
|
233
|
+
status?: ScheduledTaskStatus;
|
|
234
|
+
executionType?: ScheduleExecutionType;
|
|
235
|
+
taskType?: string;
|
|
236
|
+
assistantId?: string;
|
|
237
|
+
threadId?: string;
|
|
238
|
+
limit?: number;
|
|
239
|
+
offset?: number;
|
|
240
|
+
}): Promise<ScheduledTaskDefinition[]>;
|
|
241
|
+
/**
|
|
242
|
+
* Count tasks with optional filters
|
|
243
|
+
*/
|
|
244
|
+
countTasks(filters?: {
|
|
245
|
+
status?: ScheduledTaskStatus;
|
|
246
|
+
executionType?: ScheduleExecutionType;
|
|
247
|
+
taskType?: string;
|
|
248
|
+
assistantId?: string;
|
|
249
|
+
threadId?: string;
|
|
250
|
+
}): Promise<number>;
|
|
251
|
+
/**
|
|
252
|
+
* Delete completed/cancelled/failed tasks older than specified time
|
|
253
|
+
*/
|
|
254
|
+
deleteOldTasks(olderThanMs: number): Promise<number>;
|
|
255
|
+
/**
|
|
256
|
+
* Map database row to ScheduledTaskDefinition
|
|
257
|
+
*/
|
|
258
|
+
private mapRowToTask;
|
|
259
|
+
}
|
|
260
|
+
|
|
147
261
|
/**
|
|
148
262
|
* Migration system for database schema management
|
|
149
263
|
*/
|
|
@@ -208,4 +322,13 @@ declare const createThreadsTable: Migration;
|
|
|
208
322
|
*/
|
|
209
323
|
declare const createAssistantsTable: Migration;
|
|
210
324
|
|
|
211
|
-
|
|
325
|
+
/**
|
|
326
|
+
* PostgreSQL migrations for scheduled tasks table
|
|
327
|
+
*/
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Create the scheduled_tasks table
|
|
331
|
+
*/
|
|
332
|
+
declare const createScheduledTasksTable: Migration;
|
|
333
|
+
|
|
334
|
+
export { type Migration, MigrationManager, PostgreSQLAssistantStore, type PostgreSQLAssistantStoreOptions, PostgreSQLScheduleStorage, type PostgreSQLScheduleStorageOptions, PostgreSQLThreadStore, type PostgreSQLThreadStoreOptions, createAssistantsTable, createScheduledTasksTable, createThreadsTable };
|