@axiom-lattice/protocols 2.1.7 → 2.1.8

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @axiom-lattice/protocols@2.1.7 build /home/runner/work/agentic/agentic/packages/protocols
2
+ > @axiom-lattice/protocols@2.1.8 build /home/runner/work/agentic/agentic/packages/protocols
3
3
  > tsup src/index.ts --format cjs,esm --dts --sourcemap
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,13 +8,13 @@
8
8
  CLI Target: es2020
9
9
  CJS Build start
10
10
  ESM Build start
11
- CJS dist/index.js 3.42 KB
12
- CJS dist/index.js.map 12.14 KB
13
- CJS ⚡️ Build success in 44ms
14
- ESM dist/index.mjs 2.11 KB
15
- ESM dist/index.mjs.map 11.38 KB
11
+ ESM dist/index.mjs 2.87 KB
12
+ ESM dist/index.mjs.map 19.75 KB
16
13
  ESM ⚡️ Build success in 45ms
14
+ CJS dist/index.js 4.28 KB
15
+ CJS dist/index.js.map 20.52 KB
16
+ CJS ⚡️ Build success in 47ms
17
17
  DTS Build start
18
- DTS ⚡️ Build success in 2322ms
19
- DTS dist/index.d.ts 22.08 KB
20
- DTS dist/index.d.mts 22.08 KB
18
+ DTS ⚡️ Build success in 2410ms
19
+ DTS dist/index.d.ts 28.62 KB
20
+ DTS dist/index.d.mts 28.62 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @axiom-lattice/protocols
2
2
 
3
+ ## 2.1.8
4
+
5
+ ### Patch Changes
6
+
7
+ - d43ea0b: add schedule task
8
+
3
9
  ## 2.1.7
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -126,6 +126,16 @@ declare enum AgentType {
126
126
  PLAN_EXECUTE = "plan_execute",
127
127
  SEQUENTIAL = "sequential"
128
128
  }
129
+ /**
130
+ * Runtime configuration that will be injected into LangGraphRunnableConfig.configurable
131
+ * Tools can access these values via config.configurable.runConfig
132
+ */
133
+ interface AgentRunConfig {
134
+ /** Database key for SQL tools (registered via sqlDatabaseManager) */
135
+ databaseKey?: string;
136
+ /** Any additional runtime configuration */
137
+ [key: string]: any;
138
+ }
129
139
  /**
130
140
  * Base agent configuration shared by all agent types
131
141
  */
@@ -136,6 +146,11 @@ interface BaseAgentConfig {
136
146
  prompt: string;
137
147
  schema?: ZodObject<any, any, any, any, any>;
138
148
  modelKey?: string;
149
+ /**
150
+ * Runtime configuration to inject into tool execution context
151
+ * Will be available in tools via config.configurable.runConfig
152
+ */
153
+ runConfig?: AgentRunConfig;
139
154
  }
140
155
  /**
141
156
  * REACT agent configuration
@@ -367,14 +382,36 @@ interface QueueLatticeProtocol extends BaseLatticeProtocol<QueueConfig, QueueCli
367
382
  /**
368
383
  * ScheduleLatticeProtocol
369
384
  *
370
- * Schedule Lattice protocol for delayed task execution management
385
+ * Schedule Lattice protocol for delayed and recurring task execution management
386
+ * Supports persistence and recovery after service restart
387
+ * Supports both one-time delayed tasks and cron-style recurring tasks
371
388
  */
372
389
 
373
390
  /**
374
391
  * Schedule service type enumeration
375
392
  */
376
393
  declare enum ScheduleType {
377
- MEMORY = "memory"
394
+ MEMORY = "memory",
395
+ POSTGRES = "postgres",
396
+ REDIS = "redis"
397
+ }
398
+ /**
399
+ * Schedule execution type - one-time or recurring
400
+ */
401
+ declare enum ScheduleExecutionType {
402
+ ONCE = "once",// Execute once at specified time
403
+ CRON = "cron"
404
+ }
405
+ /**
406
+ * Task status enumeration
407
+ */
408
+ declare enum ScheduledTaskStatus {
409
+ PENDING = "pending",// Waiting to be executed
410
+ RUNNING = "running",// Currently executing
411
+ COMPLETED = "completed",// Successfully completed (for ONCE type)
412
+ FAILED = "failed",// Execution failed
413
+ CANCELLED = "cancelled",// Manually cancelled
414
+ PAUSED = "paused"
378
415
  }
379
416
  /**
380
417
  * Schedule configuration interface
@@ -383,77 +420,248 @@ interface ScheduleConfig {
383
420
  name: string;
384
421
  description: string;
385
422
  type: ScheduleType;
423
+ storage?: ScheduleStorage;
386
424
  options?: Record<string, any>;
387
425
  }
388
426
  /**
389
- * Scheduled task information interface
427
+ * Scheduled task definition - fully serializable
428
+ * Supports both one-time and cron-style recurring tasks
390
429
  */
391
- interface ScheduledTaskInfo {
430
+ interface ScheduledTaskDefinition {
392
431
  taskId: string;
393
- scheduledAt: number;
394
- timeoutMs: number;
395
- remainingMs: number;
432
+ taskType: string;
433
+ payload: Record<string, any>;
434
+ assistantId?: string;
435
+ threadId?: string;
436
+ executionType: ScheduleExecutionType;
437
+ executeAt?: number;
438
+ delayMs?: number;
439
+ cronExpression?: string;
440
+ timezone?: string;
441
+ nextRunAt?: number;
442
+ lastRunAt?: number;
443
+ status: ScheduledTaskStatus;
444
+ runCount: number;
445
+ maxRuns?: number;
446
+ retryCount: number;
447
+ maxRetries: number;
448
+ lastError?: string;
449
+ createdAt: number;
450
+ updatedAt: number;
451
+ expiresAt?: number;
452
+ metadata?: Record<string, any>;
453
+ }
454
+ /**
455
+ * Task handler function type
456
+ */
457
+ type TaskHandler = (payload: Record<string, any>, taskInfo: ScheduledTaskDefinition) => void | Promise<void>;
458
+ /**
459
+ * Options for scheduling a one-time task
460
+ */
461
+ interface ScheduleOnceOptions {
462
+ executeAt?: number;
463
+ delayMs?: number;
464
+ maxRetries?: number;
465
+ assistantId?: string;
466
+ threadId?: string;
467
+ metadata?: Record<string, any>;
468
+ }
469
+ /**
470
+ * Options for scheduling a cron task
471
+ */
472
+ interface ScheduleCronOptions {
473
+ cronExpression: string;
474
+ timezone?: string;
475
+ maxRuns?: number;
476
+ expiresAt?: number;
477
+ maxRetries?: number;
478
+ assistantId?: string;
479
+ threadId?: string;
480
+ metadata?: Record<string, any>;
481
+ }
482
+ /**
483
+ * Schedule storage interface for persistence
484
+ */
485
+ interface ScheduleStorage {
486
+ /**
487
+ * Save a new task
488
+ */
489
+ save(task: ScheduledTaskDefinition): Promise<void>;
490
+ /**
491
+ * Get task by ID
492
+ */
493
+ get(taskId: string): Promise<ScheduledTaskDefinition | null>;
494
+ /**
495
+ * Update task
496
+ */
497
+ update(taskId: string, updates: Partial<ScheduledTaskDefinition>): Promise<void>;
498
+ /**
499
+ * Delete task
500
+ */
501
+ delete(taskId: string): Promise<void>;
502
+ /**
503
+ * Get all pending/active tasks (for recovery)
504
+ * Returns tasks with status: PENDING or PAUSED
505
+ */
506
+ getActiveTasks(): Promise<ScheduledTaskDefinition[]>;
507
+ /**
508
+ * Get tasks by type
509
+ */
510
+ getTasksByType(taskType: string): Promise<ScheduledTaskDefinition[]>;
511
+ /**
512
+ * Get tasks by status
513
+ */
514
+ getTasksByStatus(status: ScheduledTaskStatus): Promise<ScheduledTaskDefinition[]>;
515
+ /**
516
+ * Get tasks by execution type
517
+ */
518
+ getTasksByExecutionType(executionType: ScheduleExecutionType): Promise<ScheduledTaskDefinition[]>;
519
+ /**
520
+ * Get tasks by assistant ID
521
+ */
522
+ getTasksByAssistantId(assistantId: string): Promise<ScheduledTaskDefinition[]>;
523
+ /**
524
+ * Get tasks by thread ID
525
+ */
526
+ getTasksByThreadId(threadId: string): Promise<ScheduledTaskDefinition[]>;
527
+ /**
528
+ * Get all tasks (with optional filters)
529
+ */
530
+ getAllTasks(filters?: {
531
+ status?: ScheduledTaskStatus;
532
+ executionType?: ScheduleExecutionType;
533
+ taskType?: string;
534
+ assistantId?: string;
535
+ threadId?: string;
536
+ limit?: number;
537
+ offset?: number;
538
+ }): Promise<ScheduledTaskDefinition[]>;
539
+ /**
540
+ * Count tasks (with optional filters)
541
+ */
542
+ countTasks(filters?: {
543
+ status?: ScheduledTaskStatus;
544
+ executionType?: ScheduleExecutionType;
545
+ taskType?: string;
546
+ assistantId?: string;
547
+ threadId?: string;
548
+ }): Promise<number>;
549
+ /**
550
+ * Delete completed/cancelled tasks older than specified time
551
+ * Useful for cleanup
552
+ */
553
+ deleteOldTasks(olderThanMs: number): Promise<number>;
396
554
  }
397
555
  /**
398
556
  * Schedule client interface
399
557
  */
400
558
  interface ScheduleClient {
401
559
  /**
402
- * Register a function to be executed after the specified timeout
403
- * @param taskId - Unique identifier for the task
404
- * @param callback - Function to execute when timeout expires
405
- * @param timeoutMs - Delay in milliseconds before execution
406
- * @returns true if registered successfully
560
+ * Register a handler for a task type
561
+ * Must be called before scheduling tasks of this type
562
+ */
563
+ registerHandler(taskType: string, handler: TaskHandler): void;
564
+ /**
565
+ * Unregister a handler
566
+ */
567
+ unregisterHandler(taskType: string): boolean;
568
+ /**
569
+ * Check if a handler is registered
407
570
  */
408
- register: (taskId: string, callback: () => void | Promise<void>, timeoutMs: number) => boolean;
571
+ hasHandler(taskType: string): boolean;
409
572
  /**
410
- * Cancel a scheduled task by its ID
411
- * @param taskId - The task identifier to cancel
412
- * @returns true if task was found and cancelled, false otherwise
573
+ * Get all registered handler types
413
574
  */
414
- cancel: (taskId: string) => boolean;
575
+ getHandlerTypes(): string[];
415
576
  /**
416
- * Check if a task is currently scheduled
417
- * @param taskId - The task identifier to check
577
+ * Schedule a one-time task
578
+ * @param taskId - Unique identifier for the task
579
+ * @param taskType - Type of task (must have a registered handler)
580
+ * @param payload - Data to pass to the handler (must be JSON-serializable)
581
+ * @param options - Execution options (executeAt or delayMs required)
582
+ */
583
+ scheduleOnce(taskId: string, taskType: string, payload: Record<string, any>, options: ScheduleOnceOptions): Promise<boolean>;
584
+ /**
585
+ * Schedule a recurring cron task
586
+ * @param taskId - Unique identifier for the task
587
+ * @param taskType - Type of task (must have a registered handler)
588
+ * @param payload - Data to pass to the handler (must be JSON-serializable)
589
+ * @param options - Cron options (cronExpression required)
418
590
  */
419
- has: (taskId: string) => boolean;
591
+ scheduleCron(taskId: string, taskType: string, payload: Record<string, any>, options: ScheduleCronOptions): Promise<boolean>;
420
592
  /**
421
- * Get the remaining time in milliseconds for a scheduled task
422
- * @param taskId - The task identifier
423
- * @returns Remaining time in ms, or -1 if task not found
593
+ * Cancel a scheduled task
424
594
  */
425
- getRemainingTime: (taskId: string) => number;
595
+ cancel(taskId: string): Promise<boolean>;
426
596
  /**
427
- * Get the count of currently scheduled tasks
597
+ * Pause a cron task (only for CRON type)
428
598
  */
429
- getTaskCount: () => number;
599
+ pause(taskId: string): Promise<boolean>;
430
600
  /**
431
- * Get all scheduled task IDs
601
+ * Resume a paused cron task (only for CRON type)
432
602
  */
433
- getTaskIds: () => string[];
603
+ resume(taskId: string): Promise<boolean>;
434
604
  /**
435
- * Cancel all scheduled tasks
605
+ * Check if a task exists
436
606
  */
437
- cancelAll: () => void;
607
+ has(taskId: string): Promise<boolean>;
438
608
  /**
439
609
  * Get task information
440
- * @param taskId - The task identifier
441
- * @returns Task info or null if not found
442
610
  */
443
- getTaskInfo?: (taskId: string) => ScheduledTaskInfo | null;
611
+ getTask(taskId: string): Promise<ScheduledTaskDefinition | null>;
612
+ /**
613
+ * Get remaining time until next execution
614
+ * Returns -1 if task not found or already executed
615
+ */
616
+ getRemainingTime(taskId: string): Promise<number>;
617
+ /**
618
+ * Get count of active tasks (pending + paused)
619
+ */
620
+ getActiveTaskCount(): Promise<number>;
621
+ /**
622
+ * Get all active task IDs
623
+ */
624
+ getActiveTaskIds(): Promise<string[]>;
625
+ /**
626
+ * Cancel all active tasks
627
+ */
628
+ cancelAll(): Promise<void>;
629
+ /**
630
+ * Restore active tasks from storage (call on service startup)
631
+ * Re-schedules all pending tasks with their remaining time
632
+ * Re-schedules all cron tasks for their next run
633
+ * @returns Number of tasks restored
634
+ */
635
+ restore(): Promise<number>;
636
+ /**
637
+ * Set the storage backend
638
+ */
639
+ setStorage(storage: ScheduleStorage): void;
640
+ /**
641
+ * Get current storage backend
642
+ */
643
+ getStorage(): ScheduleStorage | null;
444
644
  }
445
645
  /**
446
646
  * Schedule Lattice protocol interface
447
647
  */
448
648
  interface ScheduleLatticeProtocol extends BaseLatticeProtocol<ScheduleConfig, ScheduleClient> {
449
- register: (taskId: string, callback: () => void | Promise<void>, timeoutMs: number) => boolean;
450
- cancel: (taskId: string) => boolean;
451
- has: (taskId: string) => boolean;
452
- getRemainingTime: (taskId: string) => number;
453
- getTaskCount: () => number;
454
- getTaskIds: () => string[];
455
- cancelAll: () => void;
456
- getTaskInfo?: (taskId: string) => ScheduledTaskInfo | null;
649
+ registerHandler: (taskType: string, handler: TaskHandler) => void;
650
+ unregisterHandler: (taskType: string) => boolean;
651
+ hasHandler: (taskType: string) => boolean;
652
+ getHandlerTypes: () => string[];
653
+ scheduleOnce: (taskId: string, taskType: string, payload: Record<string, any>, options: ScheduleOnceOptions) => Promise<boolean>;
654
+ scheduleCron: (taskId: string, taskType: string, payload: Record<string, any>, options: ScheduleCronOptions) => Promise<boolean>;
655
+ cancel: (taskId: string) => Promise<boolean>;
656
+ pause: (taskId: string) => Promise<boolean>;
657
+ resume: (taskId: string) => Promise<boolean>;
658
+ has: (taskId: string) => Promise<boolean>;
659
+ getTask: (taskId: string) => Promise<ScheduledTaskDefinition | null>;
660
+ getRemainingTime: (taskId: string) => Promise<number>;
661
+ getActiveTaskCount: () => Promise<number>;
662
+ getActiveTaskIds: () => Promise<string[]>;
663
+ cancelAll: () => Promise<void>;
664
+ restore: () => Promise<number>;
457
665
  }
458
666
 
459
667
  /**
@@ -865,4 +1073,4 @@ type Timestamp = number;
865
1073
  */
866
1074
  type Callback<T = any, R = void> = (data: T) => R | Promise<R>;
867
1075
 
868
- export { type AgentClient, type AgentConfig, type AgentConfigWithTools, type AgentLatticeProtocol, AgentType, type Assistant, type AssistantMessage, type AssistantStore, type BaseLatticeProtocol, type BaseMessage, type Callback, type CreateAssistantRequest, type CreateThreadRequest, type DeepAgentConfig, type DeveloperMessage, type EmbeddingsConfig, type EmbeddingsLatticeProtocol, type FilterCondition, type GraphBuildOptions, type ID, type InterruptMessage, type LLMConfig, type LatticeError, type LatticeEventBus, type LatticeMessage, type MemoryClient, type MemoryConfig, type MemoryLatticeProtocol, MemoryType, type Message, type MessageChunk, type ModelLatticeProtocol, type PaginatedResult, type PaginationParams, type PlanExecuteAgentConfig, type QueryParams, type QueueClient, type QueueConfig, type QueueLatticeProtocol, type QueueResult, QueueType, type ReactAgentConfig, type Result, type ScheduleClient, type ScheduleConfig, type ScheduleLatticeProtocol, ScheduleType, type ScheduledTaskInfo, type SequentialAgentConfig, type SystemMessage, type Thread, type ThreadStore, type Timestamp, type ToolCall, type ToolConfig, type ToolExecutor, type ToolLatticeProtocol, type ToolMessage, type UIComponent, UIComponentType, type UIConfig, type UILatticeProtocol, type UserMessage, type VectorStoreConfig, type VectorStoreLatticeProtocol, getSubAgentsFromConfig, getToolsFromConfig, hasTools, isDeepAgentConfig };
1076
+ export { type AgentClient, type AgentConfig, type AgentConfigWithTools, type AgentLatticeProtocol, type AgentRunConfig, AgentType, type Assistant, type AssistantMessage, type AssistantStore, type BaseLatticeProtocol, type BaseMessage, type Callback, type CreateAssistantRequest, type CreateThreadRequest, type DeepAgentConfig, type DeveloperMessage, type EmbeddingsConfig, type EmbeddingsLatticeProtocol, type FilterCondition, type GraphBuildOptions, type ID, type InterruptMessage, type LLMConfig, type LatticeError, type LatticeEventBus, type LatticeMessage, type MemoryClient, type MemoryConfig, type MemoryLatticeProtocol, MemoryType, type Message, type MessageChunk, type ModelLatticeProtocol, type PaginatedResult, type PaginationParams, type PlanExecuteAgentConfig, type QueryParams, type QueueClient, type QueueConfig, type QueueLatticeProtocol, type QueueResult, QueueType, type ReactAgentConfig, type Result, type ScheduleClient, type ScheduleConfig, type ScheduleCronOptions, ScheduleExecutionType, type ScheduleLatticeProtocol, type ScheduleOnceOptions, type ScheduleStorage, ScheduleType, type ScheduledTaskDefinition, ScheduledTaskStatus, type SequentialAgentConfig, type SystemMessage, type TaskHandler, type Thread, type ThreadStore, type Timestamp, type ToolCall, type ToolConfig, type ToolExecutor, type ToolLatticeProtocol, type ToolMessage, type UIComponent, UIComponentType, type UIConfig, type UILatticeProtocol, type UserMessage, type VectorStoreConfig, type VectorStoreLatticeProtocol, getSubAgentsFromConfig, getToolsFromConfig, hasTools, isDeepAgentConfig };