@axiom-lattice/core 2.1.12 → 2.1.14

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/dist/index.d.mts CHANGED
@@ -5,7 +5,7 @@ import { BaseChatModel, BaseChatModelCallOptions } from '@langchain/core/languag
5
5
  import { BaseLanguageModelInput } from '@langchain/core/language_models/base';
6
6
  import { CallbackManagerForLLMRun } from '@langchain/core/callbacks/manager';
7
7
  import { ChatResult } from '@langchain/core/outputs';
8
- import { LLMConfig, ToolConfig, ToolExecutor, AgentConfig, GraphBuildOptions, MessageChunk, QueueLatticeProtocol, QueueConfig, QueueClient, QueueResult, ThreadStore, AssistantStore, Thread, CreateThreadRequest, Assistant, CreateAssistantRequest } from '@axiom-lattice/protocols';
8
+ import { LLMConfig, ToolConfig, ToolExecutor, AgentConfig, GraphBuildOptions, MessageChunk, QueueLatticeProtocol, QueueConfig, QueueClient, QueueResult, ScheduleLatticeProtocol, ScheduleConfig, ScheduleClient, ScheduleStorage, TaskHandler, ScheduleOnceOptions, ScheduleCronOptions, ScheduledTaskDefinition, ScheduledTaskStatus, ScheduleExecutionType, ThreadStore, AssistantStore, Thread, CreateThreadRequest, Assistant, CreateAssistantRequest } from '@axiom-lattice/protocols';
9
9
  import * as protocols from '@axiom-lattice/protocols';
10
10
  export { protocols as Protocols };
11
11
  export { AgentConfig, AgentType, GraphBuildOptions, MemoryType } from '@axiom-lattice/protocols';
@@ -206,6 +206,168 @@ declare const modelLatticeManager: ModelLatticeManager;
206
206
  declare const registerModelLattice: (key: string, config: ModelConfig) => void;
207
207
  declare const getModelLattice: (key: string) => ModelLatticeInterface;
208
208
 
209
+ /**
210
+ * SQL Tool Types
211
+ * Type definitions for SQL database tools
212
+ */
213
+ /**
214
+ * Supported database types
215
+ */
216
+ type DatabaseType = "postgres" | "mysql" | "sqlite";
217
+ /**
218
+ * Database connection configuration
219
+ */
220
+ interface DatabaseConfig {
221
+ type: DatabaseType;
222
+ host?: string;
223
+ port?: number;
224
+ database: string;
225
+ user?: string;
226
+ password?: string;
227
+ connectionString?: string;
228
+ ssl?: boolean;
229
+ }
230
+ /**
231
+ * Table information
232
+ */
233
+ interface TableInfo {
234
+ name: string;
235
+ schema?: string;
236
+ }
237
+ /**
238
+ * Column information
239
+ */
240
+ interface ColumnInfo {
241
+ name: string;
242
+ type: string;
243
+ nullable: boolean;
244
+ default?: string;
245
+ isPrimaryKey: boolean;
246
+ isForeignKey: boolean;
247
+ foreignKeyRef?: string;
248
+ }
249
+ /**
250
+ * Table schema information
251
+ */
252
+ interface TableSchema {
253
+ tableName: string;
254
+ schema?: string;
255
+ columns: ColumnInfo[];
256
+ sampleRows?: Record<string, unknown>[];
257
+ }
258
+ /**
259
+ * Query result
260
+ */
261
+ interface QueryResult {
262
+ rows: Record<string, unknown>[];
263
+ rowCount: number;
264
+ fields?: string[];
265
+ }
266
+ /**
267
+ * SQL Database interface
268
+ * Defines the contract for database implementations
269
+ */
270
+ interface ISqlDatabase {
271
+ /**
272
+ * Connect to the database
273
+ */
274
+ connect(): Promise<void>;
275
+ /**
276
+ * Disconnect from the database
277
+ */
278
+ disconnect(): Promise<void>;
279
+ /**
280
+ * Get list of all tables in the database
281
+ */
282
+ listTables(): Promise<TableInfo[]>;
283
+ /**
284
+ * Get schema information for specified tables
285
+ * @param tables - Array of table names
286
+ */
287
+ getTableInfo(tables: string[]): Promise<TableSchema[]>;
288
+ /**
289
+ * Execute a SQL query
290
+ * @param query - SQL query string
291
+ */
292
+ executeQuery(query: string): Promise<QueryResult>;
293
+ /**
294
+ * Get the database type
295
+ */
296
+ getDatabaseType(): DatabaseType;
297
+ }
298
+
299
+ /**
300
+ * SQL Database Manager
301
+ * Singleton manager for SQL database connections
302
+ */
303
+
304
+ /**
305
+ * PostgreSQL Database Implementation
306
+ * Uses pg library for PostgreSQL connections
307
+ */
308
+ declare class PostgresDatabase implements ISqlDatabase {
309
+ private config;
310
+ private pool;
311
+ private connected;
312
+ constructor(config: DatabaseConfig);
313
+ connect(): Promise<void>;
314
+ disconnect(): Promise<void>;
315
+ listTables(): Promise<TableInfo[]>;
316
+ getTableInfo(tables: string[]): Promise<TableSchema[]>;
317
+ executeQuery(query: string): Promise<QueryResult>;
318
+ getDatabaseType(): DatabaseType;
319
+ private ensureConnected;
320
+ }
321
+ /**
322
+ * SQL Database Manager
323
+ * Manages database connections and provides a unified interface
324
+ */
325
+ declare class SqlDatabaseManager {
326
+ private static instance;
327
+ private databases;
328
+ private defaultDatabaseKey;
329
+ private constructor();
330
+ /**
331
+ * Get the singleton instance
332
+ */
333
+ static getInstance(): SqlDatabaseManager;
334
+ /**
335
+ * Register a database connection
336
+ * @param key - Unique identifier for the database
337
+ * @param config - Database configuration
338
+ */
339
+ registerDatabase(key: string, config: DatabaseConfig): void;
340
+ /**
341
+ * Set the default database
342
+ * @param key - Database key to set as default
343
+ */
344
+ setDefaultDatabase(key: string): void;
345
+ /**
346
+ * Get a database by key
347
+ * @param key - Database key (optional, uses default if not provided)
348
+ */
349
+ getDatabase(key?: string): ISqlDatabase;
350
+ /**
351
+ * Check if a database is registered
352
+ * @param key - Database key
353
+ */
354
+ hasDatabase(key: string): boolean;
355
+ /**
356
+ * Get all registered database keys
357
+ */
358
+ getDatabaseKeys(): string[];
359
+ /**
360
+ * Remove a database connection
361
+ * @param key - Database key
362
+ */
363
+ removeDatabase(key: string): Promise<void>;
364
+ /**
365
+ * Disconnect all databases
366
+ */
367
+ disconnectAll(): Promise<void>;
368
+ }
369
+ declare const sqlDatabaseManager: SqlDatabaseManager;
370
+
209
371
  type ToolDefinition = ToolConfig;
210
372
  interface ToolLattice {
211
373
  key: string;
@@ -751,6 +913,259 @@ declare class MemoryQueueClient implements QueueClient {
751
913
  }>;
752
914
  }
753
915
 
916
+ /**
917
+ * ScheduleLatticeManager
918
+ *
919
+ * Schedule Lattice manager for registering and managing schedule services
920
+ * Supports both one-time and cron-style recurring tasks
921
+ */
922
+
923
+ /**
924
+ * Schedule Lattice interface
925
+ */
926
+ interface ScheduleLattice extends ScheduleLatticeProtocol {
927
+ key: string;
928
+ config: ScheduleConfig;
929
+ client: ScheduleLatticeProtocol["client"];
930
+ }
931
+ /**
932
+ * ScheduleLatticeManager - Singleton schedule Lattice manager
933
+ * Responsible for registering and managing various schedule service Lattices
934
+ */
935
+ declare class ScheduleLatticeManager extends BaseLatticeManager<ScheduleLattice> {
936
+ private static _instance;
937
+ /**
938
+ * Get ScheduleLatticeManager singleton instance
939
+ */
940
+ static getInstance(): ScheduleLatticeManager;
941
+ /**
942
+ * Get Lattice type prefix
943
+ */
944
+ protected getLatticeType(): string;
945
+ /**
946
+ * Register schedule Lattice
947
+ * @param key Lattice key name
948
+ * @param config Schedule configuration
949
+ * @param client Optional schedule client. If not provided, will create based on config type.
950
+ */
951
+ registerLattice(key: string, config: ScheduleConfig, client?: ScheduleClient): void;
952
+ /**
953
+ * Get ScheduleLattice
954
+ * @param key Lattice key name
955
+ */
956
+ getScheduleLattice(key: string): ScheduleLattice;
957
+ /**
958
+ * Get all Lattices
959
+ */
960
+ getAllLattices(): ScheduleLattice[];
961
+ /**
962
+ * Check if Lattice exists
963
+ * @param key Lattice key name
964
+ */
965
+ hasLattice(key: string): boolean;
966
+ /**
967
+ * Remove Lattice
968
+ * @param key Lattice key name
969
+ */
970
+ removeLattice(key: string): boolean;
971
+ /**
972
+ * Clear all Lattices
973
+ */
974
+ clearLattices(): void;
975
+ /**
976
+ * Get Lattice count
977
+ */
978
+ getLatticeCount(): number;
979
+ /**
980
+ * Get Lattice key list
981
+ */
982
+ getLatticeKeys(): string[];
983
+ }
984
+ declare const scheduleLatticeManager: ScheduleLatticeManager;
985
+ declare const registerScheduleLattice: (key: string, config: ScheduleConfig, client?: ScheduleClient) => void;
986
+ declare const getScheduleLattice: (key: string) => ScheduleLattice;
987
+
988
+ /**
989
+ * DefaultScheduleClient
990
+ *
991
+ * Default schedule client implementation with full protocol support
992
+ * Core scheduling engine that handles timer management, cron parsing, and task execution
993
+ * Supports both one-time and cron-style recurring tasks
994
+ * Storage backend is pluggable - uses MemoryScheduleStorage by default
995
+ */
996
+
997
+ /**
998
+ * Default schedule client implementation
999
+ * Core scheduling engine with pluggable storage backend
1000
+ */
1001
+ declare class DefaultScheduleClient implements ScheduleClient {
1002
+ private static instance;
1003
+ private handlers;
1004
+ private timers;
1005
+ private storage;
1006
+ constructor(storage?: ScheduleStorage);
1007
+ /**
1008
+ * Get the singleton instance of DefaultScheduleClient
1009
+ */
1010
+ static getInstance(storage?: ScheduleStorage): DefaultScheduleClient;
1011
+ /**
1012
+ * Reset the singleton instance (useful for testing)
1013
+ */
1014
+ static resetInstance(): void;
1015
+ registerHandler(taskType: string, handler: TaskHandler): void;
1016
+ unregisterHandler(taskType: string): boolean;
1017
+ hasHandler(taskType: string): boolean;
1018
+ getHandlerTypes(): string[];
1019
+ scheduleOnce(taskId: string, taskType: string, payload: Record<string, any>, options: ScheduleOnceOptions): Promise<boolean>;
1020
+ scheduleCron(taskId: string, taskType: string, payload: Record<string, any>, options: ScheduleCronOptions): Promise<boolean>;
1021
+ cancel(taskId: string): Promise<boolean>;
1022
+ pause(taskId: string): Promise<boolean>;
1023
+ resume(taskId: string): Promise<boolean>;
1024
+ has(taskId: string): Promise<boolean>;
1025
+ getTask(taskId: string): Promise<ScheduledTaskDefinition | null>;
1026
+ getRemainingTime(taskId: string): Promise<number>;
1027
+ getActiveTaskCount(): Promise<number>;
1028
+ getActiveTaskIds(): Promise<string[]>;
1029
+ cancelAll(): Promise<void>;
1030
+ restore(): Promise<number>;
1031
+ setStorage(storage: ScheduleStorage): void;
1032
+ getStorage(): ScheduleStorage | null;
1033
+ private scheduleTimer;
1034
+ private executeTask;
1035
+ }
1036
+
1037
+ /**
1038
+ * MemoryScheduleStorage
1039
+ *
1040
+ * In-memory storage implementation for scheduled tasks
1041
+ * Useful for development and testing, not recommended for production
1042
+ * Data is lost on service restart
1043
+ */
1044
+
1045
+ /**
1046
+ * In-memory storage for scheduled tasks
1047
+ */
1048
+ declare class MemoryScheduleStorage implements ScheduleStorage {
1049
+ private tasks;
1050
+ /**
1051
+ * Save a new task
1052
+ */
1053
+ save(task: ScheduledTaskDefinition): Promise<void>;
1054
+ /**
1055
+ * Get task by ID
1056
+ */
1057
+ get(taskId: string): Promise<ScheduledTaskDefinition | null>;
1058
+ /**
1059
+ * Update task
1060
+ */
1061
+ update(taskId: string, updates: Partial<ScheduledTaskDefinition>): Promise<void>;
1062
+ /**
1063
+ * Delete task
1064
+ */
1065
+ delete(taskId: string): Promise<void>;
1066
+ /**
1067
+ * Get all active tasks (pending or paused)
1068
+ */
1069
+ getActiveTasks(): Promise<ScheduledTaskDefinition[]>;
1070
+ /**
1071
+ * Get tasks by type
1072
+ */
1073
+ getTasksByType(taskType: string): Promise<ScheduledTaskDefinition[]>;
1074
+ /**
1075
+ * Get tasks by status
1076
+ */
1077
+ getTasksByStatus(status: ScheduledTaskStatus): Promise<ScheduledTaskDefinition[]>;
1078
+ /**
1079
+ * Get tasks by execution type
1080
+ */
1081
+ getTasksByExecutionType(executionType: ScheduleExecutionType): Promise<ScheduledTaskDefinition[]>;
1082
+ /**
1083
+ * Get tasks by assistant ID
1084
+ */
1085
+ getTasksByAssistantId(assistantId: string): Promise<ScheduledTaskDefinition[]>;
1086
+ /**
1087
+ * Get tasks by thread ID
1088
+ */
1089
+ getTasksByThreadId(threadId: string): Promise<ScheduledTaskDefinition[]>;
1090
+ /**
1091
+ * Get all tasks with optional filters
1092
+ */
1093
+ getAllTasks(filters?: {
1094
+ status?: ScheduledTaskStatus;
1095
+ executionType?: ScheduleExecutionType;
1096
+ taskType?: string;
1097
+ assistantId?: string;
1098
+ threadId?: string;
1099
+ limit?: number;
1100
+ offset?: number;
1101
+ }): Promise<ScheduledTaskDefinition[]>;
1102
+ /**
1103
+ * Count tasks with optional filters
1104
+ */
1105
+ countTasks(filters?: {
1106
+ status?: ScheduledTaskStatus;
1107
+ executionType?: ScheduleExecutionType;
1108
+ taskType?: string;
1109
+ assistantId?: string;
1110
+ threadId?: string;
1111
+ }): Promise<number>;
1112
+ /**
1113
+ * Delete completed/cancelled tasks older than specified time
1114
+ */
1115
+ deleteOldTasks(olderThanMs: number): Promise<number>;
1116
+ /**
1117
+ * Clear all tasks (useful for testing)
1118
+ */
1119
+ clear(): void;
1120
+ /**
1121
+ * Get total task count (useful for debugging)
1122
+ */
1123
+ size(): number;
1124
+ }
1125
+
1126
+ /**
1127
+ * CronParser
1128
+ *
1129
+ * Simple cron expression parser for calculating next execution time
1130
+ * Supports standard 5-field cron format: minute hour day-of-month month day-of-week
1131
+ *
1132
+ * Field values:
1133
+ * minute: 0-59
1134
+ * hour: 0-23
1135
+ * day-of-month: 1-31
1136
+ * month: 1-12
1137
+ * day-of-week: 0-7 (0 and 7 are Sunday)
1138
+ *
1139
+ * Special characters:
1140
+ * asterisk (*) : any value
1141
+ * comma (,) : value list separator (1,3,5)
1142
+ * dash (-) : range of values (1-5)
1143
+ * slash (/) : step values (asterisk/5 = every 5)
1144
+ */
1145
+ interface CronFields {
1146
+ minute: number[];
1147
+ hour: number[];
1148
+ dayOfMonth: number[];
1149
+ month: number[];
1150
+ dayOfWeek: number[];
1151
+ }
1152
+ /**
1153
+ * Parse a cron expression into field arrays
1154
+ */
1155
+ declare function parseCronExpression(expression: string): CronFields;
1156
+ /**
1157
+ * Get the next execution time after the given date
1158
+ */
1159
+ declare function getNextCronTime(expression: string, after?: Date, timezone?: string): Date;
1160
+ /**
1161
+ * Validate a cron expression
1162
+ */
1163
+ declare function isValidCronExpression(expression: string): boolean;
1164
+ /**
1165
+ * Get a human-readable description of a cron expression
1166
+ */
1167
+ declare function describeCronExpression(expression: string): string;
1168
+
754
1169
  /**
755
1170
  * StoreLatticeManager
756
1171
  *
@@ -1143,4 +1558,4 @@ declare class AgentManager {
1143
1558
 
1144
1559
  declare const AGENT_TASK_EVENT = "agent:execute";
1145
1560
 
1146
- export { AGENT_TASK_EVENT, type AgentClient, type AgentLattice, AgentLatticeManager, AgentManager, type BufferStats, type Chunk, ChunkBuffer, ChunkBufferLatticeManager, type EmbeddingsLatticeInterface, EmbeddingsLatticeManager, InMemoryAssistantStore, InMemoryChunkBuffer, InMemoryThreadStore, MemoryLatticeManager, MemoryQueueClient, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, type QueueLattice, QueueLatticeManager, type StoreLattice, StoreLatticeManager, type StoreType, type StoreTypeMap, type ThreadBuffer, type ThreadBufferConfig, ThreadStatus, type ToolDefinition, type ToolLattice, ToolLatticeManager, type VectorStoreLatticeInterface, VectorStoreLatticeManager, agentLatticeManager, embeddingsLatticeManager, eventBus, eventBus as eventBusDefault, getAgentClient, getAgentConfig, getAgentLattice, getAllAgentConfigs, getAllToolDefinitions, getCheckpointSaver, getChunkBuffer, getEmbeddingsClient, getEmbeddingsLattice, getModelLattice, getQueueLattice, getStoreLattice, getToolClient, getToolDefinition, getToolLattice, getVectorStoreClient, getVectorStoreLattice, hasChunkBuffer, modelLatticeManager, queueLatticeManager, registerAgentLattice, registerAgentLattices, registerCheckpointSaver, registerChunkBuffer, registerEmbeddingsLattice, registerModelLattice, registerQueueLattice, registerStoreLattice, registerToolLattice, registerVectorStoreLattice, storeLatticeManager, toolLatticeManager, validateAgentInput, validateToolInput, vectorStoreLatticeManager };
1561
+ export { AGENT_TASK_EVENT, type AgentClient, type AgentLattice, AgentLatticeManager, AgentManager, type BufferStats, type Chunk, ChunkBuffer, ChunkBufferLatticeManager, type ColumnInfo, type CronFields, type DatabaseConfig, type DatabaseType, DefaultScheduleClient, type EmbeddingsLatticeInterface, EmbeddingsLatticeManager, type ISqlDatabase, InMemoryAssistantStore, InMemoryChunkBuffer, InMemoryThreadStore, MemoryLatticeManager, MemoryQueueClient, MemoryScheduleStorage, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, PostgresDatabase, type QueryResult, type QueueLattice, QueueLatticeManager, type ScheduleLattice, ScheduleLatticeManager, SqlDatabaseManager, type StoreLattice, StoreLatticeManager, type StoreType, type StoreTypeMap, type TableInfo, type TableSchema, type ThreadBuffer, type ThreadBufferConfig, ThreadStatus, type ToolDefinition, type ToolLattice, ToolLatticeManager, type VectorStoreLatticeInterface, VectorStoreLatticeManager, agentLatticeManager, describeCronExpression, embeddingsLatticeManager, eventBus, eventBus as eventBusDefault, getAgentClient, getAgentConfig, getAgentLattice, getAllAgentConfigs, getAllToolDefinitions, getCheckpointSaver, getChunkBuffer, getEmbeddingsClient, getEmbeddingsLattice, getModelLattice, getNextCronTime, getQueueLattice, getScheduleLattice, getStoreLattice, getToolClient, getToolDefinition, getToolLattice, getVectorStoreClient, getVectorStoreLattice, hasChunkBuffer, isValidCronExpression, modelLatticeManager, parseCronExpression, queueLatticeManager, registerAgentLattice, registerAgentLattices, registerCheckpointSaver, registerChunkBuffer, registerEmbeddingsLattice, registerModelLattice, registerQueueLattice, registerScheduleLattice, registerStoreLattice, registerToolLattice, registerVectorStoreLattice, scheduleLatticeManager, sqlDatabaseManager, storeLatticeManager, toolLatticeManager, validateAgentInput, validateToolInput, vectorStoreLatticeManager };