@axiom-lattice/core 2.1.12 → 2.1.13

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, ScheduledTaskInfo, 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';
@@ -751,6 +751,145 @@ declare class MemoryQueueClient implements QueueClient {
751
751
  }>;
752
752
  }
753
753
 
754
+ /**
755
+ * ScheduleLatticeManager
756
+ *
757
+ * Schedule Lattice manager for registering and managing schedule services
758
+ */
759
+
760
+ /**
761
+ * Schedule Lattice interface
762
+ */
763
+ interface ScheduleLattice extends ScheduleLatticeProtocol {
764
+ key: string;
765
+ config: ScheduleConfig;
766
+ client: ScheduleLatticeProtocol["client"];
767
+ }
768
+ /**
769
+ * ScheduleLatticeManager - Singleton schedule Lattice manager
770
+ * Responsible for registering and managing various schedule service Lattices
771
+ */
772
+ declare class ScheduleLatticeManager extends BaseLatticeManager<ScheduleLattice> {
773
+ private static _instance;
774
+ /**
775
+ * Get ScheduleLatticeManager singleton instance
776
+ */
777
+ static getInstance(): ScheduleLatticeManager;
778
+ /**
779
+ * Get Lattice type prefix
780
+ */
781
+ protected getLatticeType(): string;
782
+ /**
783
+ * Register schedule Lattice
784
+ * @param key Lattice key name
785
+ * @param config Schedule configuration
786
+ * @param client Optional schedule client. If not provided, will create based on config type.
787
+ */
788
+ registerLattice(key: string, config: ScheduleConfig, client?: ScheduleClient): void;
789
+ /**
790
+ * Get ScheduleLattice
791
+ * @param key Lattice key name
792
+ */
793
+ getScheduleLattice(key: string): ScheduleLattice;
794
+ /**
795
+ * Get all Lattices
796
+ */
797
+ getAllLattices(): ScheduleLattice[];
798
+ /**
799
+ * Check if Lattice exists
800
+ * @param key Lattice key name
801
+ */
802
+ hasLattice(key: string): boolean;
803
+ /**
804
+ * Remove Lattice
805
+ * @param key Lattice key name
806
+ */
807
+ removeLattice(key: string): boolean;
808
+ /**
809
+ * Clear all Lattices
810
+ */
811
+ clearLattices(): void;
812
+ /**
813
+ * Get Lattice count
814
+ */
815
+ getLatticeCount(): number;
816
+ /**
817
+ * Get Lattice key list
818
+ */
819
+ getLatticeKeys(): string[];
820
+ }
821
+ declare const scheduleLatticeManager: ScheduleLatticeManager;
822
+ declare const registerScheduleLattice: (key: string, config: ScheduleConfig, client?: ScheduleClient) => void;
823
+ declare const getScheduleLattice: (key: string) => ScheduleLattice;
824
+
825
+ /**
826
+ * MemoryScheduleClient
827
+ *
828
+ * In-memory schedule service implementation (default)
829
+ * A singleton class for managing delayed function execution
830
+ * Registers functions with timeout and automatically executes and cleans up when time expires
831
+ */
832
+
833
+ /**
834
+ * Memory-based schedule client implementation
835
+ */
836
+ declare class MemoryScheduleClient implements ScheduleClient {
837
+ private static instance;
838
+ private tasks;
839
+ constructor();
840
+ /**
841
+ * Get the singleton instance of MemoryScheduleClient
842
+ */
843
+ static getInstance(): MemoryScheduleClient;
844
+ /**
845
+ * Register a function to be executed after the specified timeout
846
+ * @param taskId - Unique identifier for the task
847
+ * @param callback - Function to execute when timeout expires
848
+ * @param timeoutMs - Delay in milliseconds before execution
849
+ * @returns true if registered successfully
850
+ */
851
+ register(taskId: string, callback: () => void | Promise<void>, timeoutMs: number): boolean;
852
+ /**
853
+ * Cancel a scheduled task by its ID
854
+ * @param taskId - The task identifier to cancel
855
+ * @returns true if task was found and cancelled, false otherwise
856
+ */
857
+ cancel(taskId: string): boolean;
858
+ /**
859
+ * Check if a task is currently scheduled
860
+ * @param taskId - The task identifier to check
861
+ */
862
+ has(taskId: string): boolean;
863
+ /**
864
+ * Get the remaining time in milliseconds for a scheduled task
865
+ * @param taskId - The task identifier
866
+ * @returns Remaining time in ms, or -1 if task not found
867
+ */
868
+ getRemainingTime(taskId: string): number;
869
+ /**
870
+ * Get the count of currently scheduled tasks
871
+ */
872
+ getTaskCount(): number;
873
+ /**
874
+ * Get all scheduled task IDs
875
+ */
876
+ getTaskIds(): string[];
877
+ /**
878
+ * Cancel all scheduled tasks
879
+ */
880
+ cancelAll(): void;
881
+ /**
882
+ * Get task information
883
+ * @param taskId - The task identifier
884
+ * @returns Task info or null if not found
885
+ */
886
+ getTaskInfo(taskId: string): ScheduledTaskInfo | null;
887
+ /**
888
+ * Reset the singleton instance (useful for testing)
889
+ */
890
+ static resetInstance(): void;
891
+ }
892
+
754
893
  /**
755
894
  * StoreLatticeManager
756
895
  *
@@ -1143,4 +1282,4 @@ declare class AgentManager {
1143
1282
 
1144
1283
  declare const AGENT_TASK_EVENT = "agent:execute";
1145
1284
 
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 };
1285
+ export { AGENT_TASK_EVENT, type AgentClient, type AgentLattice, AgentLatticeManager, AgentManager, type BufferStats, type Chunk, ChunkBuffer, ChunkBufferLatticeManager, type EmbeddingsLatticeInterface, EmbeddingsLatticeManager, InMemoryAssistantStore, InMemoryChunkBuffer, InMemoryThreadStore, MemoryLatticeManager, MemoryQueueClient, MemoryScheduleClient, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, type QueueLattice, QueueLatticeManager, type ScheduleLattice, ScheduleLatticeManager, 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, getScheduleLattice, getStoreLattice, getToolClient, getToolDefinition, getToolLattice, getVectorStoreClient, getVectorStoreLattice, hasChunkBuffer, modelLatticeManager, queueLatticeManager, registerAgentLattice, registerAgentLattices, registerCheckpointSaver, registerChunkBuffer, registerEmbeddingsLattice, registerModelLattice, registerQueueLattice, registerScheduleLattice, registerStoreLattice, registerToolLattice, registerVectorStoreLattice, scheduleLatticeManager, storeLatticeManager, toolLatticeManager, validateAgentInput, validateToolInput, vectorStoreLatticeManager };
package/dist/index.d.ts 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, ScheduledTaskInfo, 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';
@@ -751,6 +751,145 @@ declare class MemoryQueueClient implements QueueClient {
751
751
  }>;
752
752
  }
753
753
 
754
+ /**
755
+ * ScheduleLatticeManager
756
+ *
757
+ * Schedule Lattice manager for registering and managing schedule services
758
+ */
759
+
760
+ /**
761
+ * Schedule Lattice interface
762
+ */
763
+ interface ScheduleLattice extends ScheduleLatticeProtocol {
764
+ key: string;
765
+ config: ScheduleConfig;
766
+ client: ScheduleLatticeProtocol["client"];
767
+ }
768
+ /**
769
+ * ScheduleLatticeManager - Singleton schedule Lattice manager
770
+ * Responsible for registering and managing various schedule service Lattices
771
+ */
772
+ declare class ScheduleLatticeManager extends BaseLatticeManager<ScheduleLattice> {
773
+ private static _instance;
774
+ /**
775
+ * Get ScheduleLatticeManager singleton instance
776
+ */
777
+ static getInstance(): ScheduleLatticeManager;
778
+ /**
779
+ * Get Lattice type prefix
780
+ */
781
+ protected getLatticeType(): string;
782
+ /**
783
+ * Register schedule Lattice
784
+ * @param key Lattice key name
785
+ * @param config Schedule configuration
786
+ * @param client Optional schedule client. If not provided, will create based on config type.
787
+ */
788
+ registerLattice(key: string, config: ScheduleConfig, client?: ScheduleClient): void;
789
+ /**
790
+ * Get ScheduleLattice
791
+ * @param key Lattice key name
792
+ */
793
+ getScheduleLattice(key: string): ScheduleLattice;
794
+ /**
795
+ * Get all Lattices
796
+ */
797
+ getAllLattices(): ScheduleLattice[];
798
+ /**
799
+ * Check if Lattice exists
800
+ * @param key Lattice key name
801
+ */
802
+ hasLattice(key: string): boolean;
803
+ /**
804
+ * Remove Lattice
805
+ * @param key Lattice key name
806
+ */
807
+ removeLattice(key: string): boolean;
808
+ /**
809
+ * Clear all Lattices
810
+ */
811
+ clearLattices(): void;
812
+ /**
813
+ * Get Lattice count
814
+ */
815
+ getLatticeCount(): number;
816
+ /**
817
+ * Get Lattice key list
818
+ */
819
+ getLatticeKeys(): string[];
820
+ }
821
+ declare const scheduleLatticeManager: ScheduleLatticeManager;
822
+ declare const registerScheduleLattice: (key: string, config: ScheduleConfig, client?: ScheduleClient) => void;
823
+ declare const getScheduleLattice: (key: string) => ScheduleLattice;
824
+
825
+ /**
826
+ * MemoryScheduleClient
827
+ *
828
+ * In-memory schedule service implementation (default)
829
+ * A singleton class for managing delayed function execution
830
+ * Registers functions with timeout and automatically executes and cleans up when time expires
831
+ */
832
+
833
+ /**
834
+ * Memory-based schedule client implementation
835
+ */
836
+ declare class MemoryScheduleClient implements ScheduleClient {
837
+ private static instance;
838
+ private tasks;
839
+ constructor();
840
+ /**
841
+ * Get the singleton instance of MemoryScheduleClient
842
+ */
843
+ static getInstance(): MemoryScheduleClient;
844
+ /**
845
+ * Register a function to be executed after the specified timeout
846
+ * @param taskId - Unique identifier for the task
847
+ * @param callback - Function to execute when timeout expires
848
+ * @param timeoutMs - Delay in milliseconds before execution
849
+ * @returns true if registered successfully
850
+ */
851
+ register(taskId: string, callback: () => void | Promise<void>, timeoutMs: number): boolean;
852
+ /**
853
+ * Cancel a scheduled task by its ID
854
+ * @param taskId - The task identifier to cancel
855
+ * @returns true if task was found and cancelled, false otherwise
856
+ */
857
+ cancel(taskId: string): boolean;
858
+ /**
859
+ * Check if a task is currently scheduled
860
+ * @param taskId - The task identifier to check
861
+ */
862
+ has(taskId: string): boolean;
863
+ /**
864
+ * Get the remaining time in milliseconds for a scheduled task
865
+ * @param taskId - The task identifier
866
+ * @returns Remaining time in ms, or -1 if task not found
867
+ */
868
+ getRemainingTime(taskId: string): number;
869
+ /**
870
+ * Get the count of currently scheduled tasks
871
+ */
872
+ getTaskCount(): number;
873
+ /**
874
+ * Get all scheduled task IDs
875
+ */
876
+ getTaskIds(): string[];
877
+ /**
878
+ * Cancel all scheduled tasks
879
+ */
880
+ cancelAll(): void;
881
+ /**
882
+ * Get task information
883
+ * @param taskId - The task identifier
884
+ * @returns Task info or null if not found
885
+ */
886
+ getTaskInfo(taskId: string): ScheduledTaskInfo | null;
887
+ /**
888
+ * Reset the singleton instance (useful for testing)
889
+ */
890
+ static resetInstance(): void;
891
+ }
892
+
754
893
  /**
755
894
  * StoreLatticeManager
756
895
  *
@@ -1143,4 +1282,4 @@ declare class AgentManager {
1143
1282
 
1144
1283
  declare const AGENT_TASK_EVENT = "agent:execute";
1145
1284
 
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 };
1285
+ export { AGENT_TASK_EVENT, type AgentClient, type AgentLattice, AgentLatticeManager, AgentManager, type BufferStats, type Chunk, ChunkBuffer, ChunkBufferLatticeManager, type EmbeddingsLatticeInterface, EmbeddingsLatticeManager, InMemoryAssistantStore, InMemoryChunkBuffer, InMemoryThreadStore, MemoryLatticeManager, MemoryQueueClient, MemoryScheduleClient, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, type QueueLattice, QueueLatticeManager, type ScheduleLattice, ScheduleLatticeManager, 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, getScheduleLattice, getStoreLattice, getToolClient, getToolDefinition, getToolLattice, getVectorStoreClient, getVectorStoreLattice, hasChunkBuffer, modelLatticeManager, queueLatticeManager, registerAgentLattice, registerAgentLattices, registerCheckpointSaver, registerChunkBuffer, registerEmbeddingsLattice, registerModelLattice, registerQueueLattice, registerScheduleLattice, registerStoreLattice, registerToolLattice, registerVectorStoreLattice, scheduleLatticeManager, storeLatticeManager, toolLatticeManager, validateAgentInput, validateToolInput, vectorStoreLatticeManager };
package/dist/index.js CHANGED
@@ -44,10 +44,12 @@ __export(index_exports, {
44
44
  InMemoryThreadStore: () => InMemoryThreadStore,
45
45
  MemoryLatticeManager: () => MemoryLatticeManager,
46
46
  MemoryQueueClient: () => MemoryQueueClient,
47
+ MemoryScheduleClient: () => MemoryScheduleClient,
47
48
  MemoryType: () => import_protocols2.MemoryType,
48
49
  ModelLatticeManager: () => ModelLatticeManager,
49
50
  Protocols: () => Protocols,
50
51
  QueueLatticeManager: () => QueueLatticeManager,
52
+ ScheduleLatticeManager: () => ScheduleLatticeManager,
51
53
  StoreLatticeManager: () => StoreLatticeManager,
52
54
  ThreadStatus: () => ThreadStatus,
53
55
  ToolLatticeManager: () => ToolLatticeManager,
@@ -67,6 +69,7 @@ __export(index_exports, {
67
69
  getEmbeddingsLattice: () => getEmbeddingsLattice,
68
70
  getModelLattice: () => getModelLattice,
69
71
  getQueueLattice: () => getQueueLattice,
72
+ getScheduleLattice: () => getScheduleLattice,
70
73
  getStoreLattice: () => getStoreLattice,
71
74
  getToolClient: () => getToolClient,
72
75
  getToolDefinition: () => getToolDefinition,
@@ -83,9 +86,11 @@ __export(index_exports, {
83
86
  registerEmbeddingsLattice: () => registerEmbeddingsLattice,
84
87
  registerModelLattice: () => registerModelLattice,
85
88
  registerQueueLattice: () => registerQueueLattice,
89
+ registerScheduleLattice: () => registerScheduleLattice,
86
90
  registerStoreLattice: () => registerStoreLattice,
87
91
  registerToolLattice: () => registerToolLattice,
88
92
  registerVectorStoreLattice: () => registerVectorStoreLattice,
93
+ scheduleLatticeManager: () => scheduleLatticeManager,
89
94
  storeLatticeManager: () => storeLatticeManager,
90
95
  toolLatticeManager: () => toolLatticeManager,
91
96
  validateAgentInput: () => validateAgentInput,
@@ -3275,6 +3280,260 @@ var getChunkBuffer = (key) => ChunkBufferLatticeManager.getInstance().get(key);
3275
3280
  var registerChunkBuffer = (key, buffer) => ChunkBufferLatticeManager.getInstance().register(key, buffer);
3276
3281
  var hasChunkBuffer = (key) => ChunkBufferLatticeManager.getInstance().has(key);
3277
3282
 
3283
+ // src/schedule_lattice/ScheduleLatticeManager.ts
3284
+ var import_protocols5 = require("@axiom-lattice/protocols");
3285
+
3286
+ // src/schedule_lattice/MemoryScheduleClient.ts
3287
+ var _MemoryScheduleClient = class _MemoryScheduleClient {
3288
+ constructor() {
3289
+ this.tasks = /* @__PURE__ */ new Map();
3290
+ }
3291
+ /**
3292
+ * Get the singleton instance of MemoryScheduleClient
3293
+ */
3294
+ static getInstance() {
3295
+ if (!_MemoryScheduleClient.instance) {
3296
+ _MemoryScheduleClient.instance = new _MemoryScheduleClient();
3297
+ }
3298
+ return _MemoryScheduleClient.instance;
3299
+ }
3300
+ /**
3301
+ * Register a function to be executed after the specified timeout
3302
+ * @param taskId - Unique identifier for the task
3303
+ * @param callback - Function to execute when timeout expires
3304
+ * @param timeoutMs - Delay in milliseconds before execution
3305
+ * @returns true if registered successfully
3306
+ */
3307
+ register(taskId, callback, timeoutMs) {
3308
+ if (this.tasks.has(taskId)) {
3309
+ this.cancel(taskId);
3310
+ }
3311
+ const timerId = setTimeout(async () => {
3312
+ try {
3313
+ console.log("scheduler callback", taskId, "start");
3314
+ await callback();
3315
+ console.log("scheduler callback", taskId, "success");
3316
+ } catch (error) {
3317
+ console.error(`Scheduler: Error executing task "${taskId}":`, error);
3318
+ } finally {
3319
+ this.tasks.delete(taskId);
3320
+ console.log("scheduler callback", taskId, "end");
3321
+ }
3322
+ }, timeoutMs);
3323
+ this.tasks.set(taskId, {
3324
+ timerId,
3325
+ callback,
3326
+ scheduledAt: Date.now(),
3327
+ timeoutMs
3328
+ });
3329
+ console.log("scheduler register", taskId);
3330
+ return true;
3331
+ }
3332
+ /**
3333
+ * Cancel a scheduled task by its ID
3334
+ * @param taskId - The task identifier to cancel
3335
+ * @returns true if task was found and cancelled, false otherwise
3336
+ */
3337
+ cancel(taskId) {
3338
+ console.log("scheduler cancel", taskId);
3339
+ const task = this.tasks.get(taskId);
3340
+ if (task) {
3341
+ clearTimeout(task.timerId);
3342
+ this.tasks.delete(taskId);
3343
+ return true;
3344
+ }
3345
+ return false;
3346
+ }
3347
+ /**
3348
+ * Check if a task is currently scheduled
3349
+ * @param taskId - The task identifier to check
3350
+ */
3351
+ has(taskId) {
3352
+ return this.tasks.has(taskId);
3353
+ }
3354
+ /**
3355
+ * Get the remaining time in milliseconds for a scheduled task
3356
+ * @param taskId - The task identifier
3357
+ * @returns Remaining time in ms, or -1 if task not found
3358
+ */
3359
+ getRemainingTime(taskId) {
3360
+ const task = this.tasks.get(taskId);
3361
+ if (!task) {
3362
+ return -1;
3363
+ }
3364
+ const elapsed = Date.now() - task.scheduledAt;
3365
+ return Math.max(0, task.timeoutMs - elapsed);
3366
+ }
3367
+ /**
3368
+ * Get the count of currently scheduled tasks
3369
+ */
3370
+ getTaskCount() {
3371
+ return this.tasks.size;
3372
+ }
3373
+ /**
3374
+ * Get all scheduled task IDs
3375
+ */
3376
+ getTaskIds() {
3377
+ return Array.from(this.tasks.keys());
3378
+ }
3379
+ /**
3380
+ * Cancel all scheduled tasks
3381
+ */
3382
+ cancelAll() {
3383
+ for (const [taskId, task] of this.tasks) {
3384
+ clearTimeout(task.timerId);
3385
+ }
3386
+ this.tasks.clear();
3387
+ }
3388
+ /**
3389
+ * Get task information
3390
+ * @param taskId - The task identifier
3391
+ * @returns Task info or null if not found
3392
+ */
3393
+ getTaskInfo(taskId) {
3394
+ const task = this.tasks.get(taskId);
3395
+ if (!task) {
3396
+ return null;
3397
+ }
3398
+ return {
3399
+ taskId,
3400
+ scheduledAt: task.scheduledAt,
3401
+ timeoutMs: task.timeoutMs,
3402
+ remainingMs: this.getRemainingTime(taskId)
3403
+ };
3404
+ }
3405
+ /**
3406
+ * Reset the singleton instance (useful for testing)
3407
+ */
3408
+ static resetInstance() {
3409
+ if (_MemoryScheduleClient.instance) {
3410
+ _MemoryScheduleClient.instance.cancelAll();
3411
+ _MemoryScheduleClient.instance = null;
3412
+ }
3413
+ }
3414
+ };
3415
+ _MemoryScheduleClient.instance = null;
3416
+ var MemoryScheduleClient = _MemoryScheduleClient;
3417
+
3418
+ // src/schedule_lattice/ScheduleLatticeManager.ts
3419
+ var ScheduleLatticeManager = class _ScheduleLatticeManager extends BaseLatticeManager {
3420
+ /**
3421
+ * Get ScheduleLatticeManager singleton instance
3422
+ */
3423
+ static getInstance() {
3424
+ if (!_ScheduleLatticeManager._instance) {
3425
+ _ScheduleLatticeManager._instance = new _ScheduleLatticeManager();
3426
+ }
3427
+ return _ScheduleLatticeManager._instance;
3428
+ }
3429
+ /**
3430
+ * Get Lattice type prefix
3431
+ */
3432
+ getLatticeType() {
3433
+ return "schedules";
3434
+ }
3435
+ /**
3436
+ * Register schedule Lattice
3437
+ * @param key Lattice key name
3438
+ * @param config Schedule configuration
3439
+ * @param client Optional schedule client. If not provided, will create based on config type.
3440
+ */
3441
+ registerLattice(key, config, client) {
3442
+ let scheduleClient;
3443
+ if (client) {
3444
+ scheduleClient = client;
3445
+ } else {
3446
+ if (config.type === import_protocols5.ScheduleType.MEMORY) {
3447
+ scheduleClient = MemoryScheduleClient.getInstance();
3448
+ } else {
3449
+ scheduleClient = MemoryScheduleClient.getInstance();
3450
+ }
3451
+ }
3452
+ const scheduleLattice = {
3453
+ key,
3454
+ config,
3455
+ client: scheduleClient,
3456
+ register: (taskId, callback, timeoutMs) => {
3457
+ return scheduleClient.register(taskId, callback, timeoutMs);
3458
+ },
3459
+ cancel: (taskId) => {
3460
+ return scheduleClient.cancel(taskId);
3461
+ },
3462
+ has: (taskId) => {
3463
+ return scheduleClient.has(taskId);
3464
+ },
3465
+ getRemainingTime: (taskId) => {
3466
+ return scheduleClient.getRemainingTime(taskId);
3467
+ },
3468
+ getTaskCount: () => {
3469
+ return scheduleClient.getTaskCount();
3470
+ },
3471
+ getTaskIds: () => {
3472
+ return scheduleClient.getTaskIds();
3473
+ },
3474
+ cancelAll: () => {
3475
+ return scheduleClient.cancelAll();
3476
+ },
3477
+ getTaskInfo: scheduleClient.getTaskInfo ? (taskId) => {
3478
+ return scheduleClient.getTaskInfo(taskId);
3479
+ } : void 0
3480
+ };
3481
+ this.register(key, scheduleLattice);
3482
+ }
3483
+ /**
3484
+ * Get ScheduleLattice
3485
+ * @param key Lattice key name
3486
+ */
3487
+ getScheduleLattice(key) {
3488
+ const scheduleLattice = this.get(key);
3489
+ if (!scheduleLattice) {
3490
+ throw new Error(`ScheduleLattice ${key} not found`);
3491
+ }
3492
+ return scheduleLattice;
3493
+ }
3494
+ /**
3495
+ * Get all Lattices
3496
+ */
3497
+ getAllLattices() {
3498
+ return this.getAll();
3499
+ }
3500
+ /**
3501
+ * Check if Lattice exists
3502
+ * @param key Lattice key name
3503
+ */
3504
+ hasLattice(key) {
3505
+ return this.has(key);
3506
+ }
3507
+ /**
3508
+ * Remove Lattice
3509
+ * @param key Lattice key name
3510
+ */
3511
+ removeLattice(key) {
3512
+ return this.remove(key);
3513
+ }
3514
+ /**
3515
+ * Clear all Lattices
3516
+ */
3517
+ clearLattices() {
3518
+ this.clear();
3519
+ }
3520
+ /**
3521
+ * Get Lattice count
3522
+ */
3523
+ getLatticeCount() {
3524
+ return this.count();
3525
+ }
3526
+ /**
3527
+ * Get Lattice key list
3528
+ */
3529
+ getLatticeKeys() {
3530
+ return this.keys();
3531
+ }
3532
+ };
3533
+ var scheduleLatticeManager = ScheduleLatticeManager.getInstance();
3534
+ var registerScheduleLattice = (key, config, client) => scheduleLatticeManager.registerLattice(key, config, client);
3535
+ var getScheduleLattice = (key) => scheduleLatticeManager.getScheduleLattice(key);
3536
+
3278
3537
  // src/store_lattice/InMemoryThreadStore.ts
3279
3538
  var InMemoryThreadStore = class {
3280
3539
  constructor() {
@@ -3785,10 +4044,12 @@ var Protocols = __toESM(require("@axiom-lattice/protocols"));
3785
4044
  InMemoryThreadStore,
3786
4045
  MemoryLatticeManager,
3787
4046
  MemoryQueueClient,
4047
+ MemoryScheduleClient,
3788
4048
  MemoryType,
3789
4049
  ModelLatticeManager,
3790
4050
  Protocols,
3791
4051
  QueueLatticeManager,
4052
+ ScheduleLatticeManager,
3792
4053
  StoreLatticeManager,
3793
4054
  ThreadStatus,
3794
4055
  ToolLatticeManager,
@@ -3808,6 +4069,7 @@ var Protocols = __toESM(require("@axiom-lattice/protocols"));
3808
4069
  getEmbeddingsLattice,
3809
4070
  getModelLattice,
3810
4071
  getQueueLattice,
4072
+ getScheduleLattice,
3811
4073
  getStoreLattice,
3812
4074
  getToolClient,
3813
4075
  getToolDefinition,
@@ -3824,9 +4086,11 @@ var Protocols = __toESM(require("@axiom-lattice/protocols"));
3824
4086
  registerEmbeddingsLattice,
3825
4087
  registerModelLattice,
3826
4088
  registerQueueLattice,
4089
+ registerScheduleLattice,
3827
4090
  registerStoreLattice,
3828
4091
  registerToolLattice,
3829
4092
  registerVectorStoreLattice,
4093
+ scheduleLatticeManager,
3830
4094
  storeLatticeManager,
3831
4095
  toolLatticeManager,
3832
4096
  validateAgentInput,