@axiom-lattice/protocols 2.1.6 → 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.6 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
- ESM dist/index.mjs 1.92 KB
12
- ESM dist/index.mjs.map 8.37 KB
13
- ESM ⚡️ Build success in 52ms
14
- CJS dist/index.js 3.20 KB
15
- CJS dist/index.js.map 9.08 KB
16
- CJS ⚡️ Build success in 53ms
11
+ ESM dist/index.mjs 2.87 KB
12
+ ESM dist/index.mjs.map 19.75 KB
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 2897ms
19
- DTS dist/index.d.ts 19.40 KB
20
- DTS dist/index.d.mts 19.40 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,17 @@
1
1
  # @axiom-lattice/protocols
2
2
 
3
+ ## 2.1.8
4
+
5
+ ### Patch Changes
6
+
7
+ - d43ea0b: add schedule task
8
+
9
+ ## 2.1.7
10
+
11
+ ### Patch Changes
12
+
13
+ - e26be9a: publish web
14
+
3
15
  ## 2.1.6
4
16
 
5
17
  ### 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
@@ -364,6 +379,291 @@ interface QueueLatticeProtocol extends BaseLatticeProtocol<QueueConfig, QueueCli
364
379
  }>;
365
380
  }
366
381
 
382
+ /**
383
+ * ScheduleLatticeProtocol
384
+ *
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
388
+ */
389
+
390
+ /**
391
+ * Schedule service type enumeration
392
+ */
393
+ declare enum ScheduleType {
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"
415
+ }
416
+ /**
417
+ * Schedule configuration interface
418
+ */
419
+ interface ScheduleConfig {
420
+ name: string;
421
+ description: string;
422
+ type: ScheduleType;
423
+ storage?: ScheduleStorage;
424
+ options?: Record<string, any>;
425
+ }
426
+ /**
427
+ * Scheduled task definition - fully serializable
428
+ * Supports both one-time and cron-style recurring tasks
429
+ */
430
+ interface ScheduledTaskDefinition {
431
+ taskId: string;
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>;
554
+ }
555
+ /**
556
+ * Schedule client interface
557
+ */
558
+ interface ScheduleClient {
559
+ /**
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
570
+ */
571
+ hasHandler(taskType: string): boolean;
572
+ /**
573
+ * Get all registered handler types
574
+ */
575
+ getHandlerTypes(): string[];
576
+ /**
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)
590
+ */
591
+ scheduleCron(taskId: string, taskType: string, payload: Record<string, any>, options: ScheduleCronOptions): Promise<boolean>;
592
+ /**
593
+ * Cancel a scheduled task
594
+ */
595
+ cancel(taskId: string): Promise<boolean>;
596
+ /**
597
+ * Pause a cron task (only for CRON type)
598
+ */
599
+ pause(taskId: string): Promise<boolean>;
600
+ /**
601
+ * Resume a paused cron task (only for CRON type)
602
+ */
603
+ resume(taskId: string): Promise<boolean>;
604
+ /**
605
+ * Check if a task exists
606
+ */
607
+ has(taskId: string): Promise<boolean>;
608
+ /**
609
+ * Get task information
610
+ */
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;
644
+ }
645
+ /**
646
+ * Schedule Lattice protocol interface
647
+ */
648
+ interface ScheduleLatticeProtocol extends BaseLatticeProtocol<ScheduleConfig, ScheduleClient> {
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>;
665
+ }
666
+
367
667
  /**
368
668
  * EmbeddingsLatticeProtocol
369
669
  *
@@ -773,4 +1073,4 @@ type Timestamp = number;
773
1073
  */
774
1074
  type Callback<T = any, R = void> = (data: T) => R | Promise<R>;
775
1075
 
776
- 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 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 };