@axiom-lattice/core 1.0.46 → 1.0.50

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/README.md CHANGED
@@ -7,6 +7,8 @@
7
7
  - 模型格子管理 (ModelLatticeManager)
8
8
  - 工具格子管理 (ToolLatticeManager)
9
9
  - 代理格子管理 (AgentLatticeManager)
10
+ - 记忆格子管理 (MemoryLatticeManager)
11
+ - 流式缓冲管理 (ChunkBufferLatticeManager)
10
12
  - DeepAgent 实现
11
13
  - 工具类和辅助函数
12
14
 
@@ -30,11 +32,53 @@ pnpm test
30
32
 
31
33
  ## 使用示例
32
34
 
35
+ ### Model Lattice
36
+
33
37
  ```typescript
34
- import { ModelLatticeManager } from "lattice_core";
38
+ import { ModelLatticeManager } from "@axiom-lattice/core";
35
39
 
36
40
  // 创建模型格子管理器
37
- const modelLattice = new ModelLatticeManager();
41
+ const modelLattice = ModelLatticeManager.getInstance();
42
+ ```
43
+
44
+ ### ChunkBuffer - Streaming Chunk Management
45
+
46
+ ```typescript
47
+ import {
48
+ InMemoryChunkBuffer,
49
+ registerChunkBuffer
50
+ } from "@axiom-lattice/core";
51
+
52
+ // Create buffer with 30-minute TTL and optional periodic cleanup
53
+ const buffer = new InMemoryChunkBuffer({
54
+ ttl: 30 * 60 * 1000, // 30 minutes
55
+ cleanupInterval: 5 * 60 * 1000 // Clean every 5 minutes (optional)
56
+ });
57
+
58
+ // Register in Lattice system
59
+ registerChunkBuffer('default', buffer);
60
+
61
+ // Add chunks as they arrive
62
+ await buffer.addChunk('thread-123', 'msg-1', 'Hello ');
63
+ await buffer.addChunk('thread-123', 'msg-1', 'world!');
64
+ await buffer.addChunk('thread-123', 'msg-2', ' How are you?');
65
+
66
+ // Get accumulated content
67
+ const content = await buffer.getAccumulatedContent('thread-123');
68
+ // => "Hello world! How are you?"
69
+
70
+ // Check thread status
71
+ const isActive = await buffer.isThreadActive('thread-123'); // true
72
+
73
+ // Explicitly complete the thread
74
+ await buffer.completeThread('thread-123');
75
+
76
+ // Get buffer statistics
77
+ const stats = buffer.getStats();
78
+ console.log(stats);
79
+
80
+ // Cleanup
81
+ buffer.dispose();
38
82
  ```
39
83
 
40
84
  ## 目录结构
@@ -43,5 +87,63 @@ const modelLattice = new ModelLatticeManager();
43
87
  - `src/model_lattice/`: 模型格子相关实现
44
88
  - `src/tool_lattice/`: 工具格子相关实现
45
89
  - `src/agent_lattice/`: 代理格子相关实现
90
+ - `src/memory_lattice/`: 记忆格子相关实现
91
+ - `src/chunk_buffer_lattice/`: 流式缓冲管理实现
46
92
  - `src/deep_agent/`: DeepAgent 实现
47
93
  - `src/util/`: 工具类和辅助函数
94
+
95
+ ## ChunkBuffer 详细说明
96
+
97
+ ChunkBuffer 模块提供了一个高效的流式数据缓冲解决方案,用于管理按线程(thread)组织的消息块(chunk)。
98
+
99
+ ### 核心特性
100
+
101
+ 1. **Thread-based Organization**: 每个 thread 维护独立的 chunk 缓冲区
102
+ 2. **Sequential Chunk Storage**: Chunks 按到达顺序存储,无需唯一 ID
103
+ 3. **Explicit Status Management**: Thread 状态通过显式调用管理(active/completed/aborted)
104
+ 4. **Hybrid Cleanup Strategy**:
105
+ - 懒清理(Lazy Cleanup): 访问时自动清除过期 thread
106
+ - 可选周期清理: 后台定时器定期清理过期 thread
107
+ 5. **TTL Auto-Extension**: 有新 chunk 加入时自动延长 TTL
108
+
109
+ ### API Overview
110
+
111
+ ```typescript
112
+ // Core operations
113
+ addChunk(threadId, messageId, content) // Add chunk to thread
114
+ getChunks(threadId) // Get all chunks for a thread
115
+ getAccumulatedContent(threadId) // Get concatenated content
116
+ getChunksByMessageId(threadId, messageId) // Get chunks for specific message
117
+
118
+ // Thread status management
119
+ completeThread(threadId) // Mark thread as completed
120
+ abortThread(threadId) // Mark thread as aborted
121
+ isThreadActive(threadId) // Check if thread is active
122
+ getThreadStatus(threadId) // Get thread status
123
+
124
+ // Thread lifecycle
125
+ clearThread(threadId) // Remove specific thread
126
+ cleanupExpiredThreads() // Manual cleanup of expired threads
127
+ extendThreadTTL(threadId, additionalMs) // Extend thread expiration time
128
+
129
+ // Query operations
130
+ getActiveThreads() // Get all active thread IDs
131
+ getAllThreads() // Get all thread IDs
132
+ getStats() // Get buffer statistics
133
+ ```
134
+
135
+ ### Configuration Options
136
+
137
+ ```typescript
138
+ interface ThreadBufferConfig {
139
+ ttl?: number; // Time-to-live in ms (default: 1 hour)
140
+ cleanupInterval?: number; // Optional periodic cleanup interval in ms
141
+ }
142
+ ```
143
+
144
+ ### Use Cases
145
+
146
+ - **Streaming AI Responses**: Buffer streaming responses from LLM models
147
+ - **Real-time Data Processing**: Collect and organize real-time data streams
148
+ - **Message Aggregation**: Aggregate fragmented messages by thread
149
+ - **Temporary Cache**: Short-term caching with automatic expiration
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 } from '@axiom-lattice/protocols';
8
+ import { LLMConfig, ToolConfig, ToolExecutor, AgentConfig, GraphBuildOptions, MessageChunk } 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';
@@ -442,4 +442,233 @@ declare class MemoryLatticeManager extends BaseLatticeManager {
442
442
  declare const getCheckpointSaver: (key: string) => BaseCheckpointSaver<number>;
443
443
  declare const registerCheckpointSaver: (key: string, saver: BaseCheckpointSaver) => void;
444
444
 
445
- export { type AgentClient, type AgentLattice, AgentLatticeManager, MemoryLatticeManager, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, type ToolDefinition, type ToolLattice, ToolLatticeManager, agentLatticeManager, getAgentClient, getAgentConfig, getAgentLattice, getAllAgentConfigs, getAllToolDefinitions, getCheckpointSaver, getModelLattice, getToolClient, getToolDefinition, getToolLattice, modelLatticeManager, registerAgentLattice, registerAgentLattices, registerCheckpointSaver, registerModelLattice, registerToolLattice, toolLatticeManager, validateAgentInput, validateToolInput };
445
+ /**
446
+ * ChunkBuffer Types
447
+ *
448
+ * Defines types for managing streaming chunks organized by thread
449
+ */
450
+
451
+ /**
452
+ * Represents a single chunk of data
453
+ * Chunks are identified by their position in the sequence (no unique ID)
454
+ */
455
+ interface Chunk {
456
+ messageId: string;
457
+ content: MessageChunk;
458
+ }
459
+ /**
460
+ * Thread status - requires explicit state transitions
461
+ */
462
+ declare enum ThreadStatus {
463
+ ACTIVE = "active",
464
+ COMPLETED = "completed",
465
+ ABORTED = "aborted"
466
+ }
467
+ /**
468
+ * Thread buffer configuration
469
+ */
470
+ interface ThreadBufferConfig {
471
+ ttl?: number;
472
+ cleanupInterval?: number;
473
+ }
474
+ /**
475
+ * Thread buffer state
476
+ */
477
+ interface ThreadBuffer {
478
+ threadId: string;
479
+ chunks: MessageChunk[];
480
+ status: ThreadStatus;
481
+ createdAt: number;
482
+ updatedAt: number;
483
+ expiresAt: number;
484
+ }
485
+ /**
486
+ * Buffer statistics
487
+ */
488
+ interface BufferStats {
489
+ totalThreads: number;
490
+ activeThreads: number;
491
+ completedThreads: number;
492
+ abortedThreads: number;
493
+ totalChunks: number;
494
+ config: Required<ThreadBufferConfig>;
495
+ }
496
+
497
+ /**
498
+ * ChunkBuffer Abstract Base Class
499
+ *
500
+ * Defines the interface for chunk buffer implementations
501
+ */
502
+
503
+ declare abstract class ChunkBuffer {
504
+ /**
505
+ * Add a chunk to a thread (creates thread if not exists)
506
+ * Chunks are appended in order
507
+ */
508
+ abstract addChunk(threadId: string, content: MessageChunk): Promise<void>;
509
+ /**
510
+ * Get all chunks for a thread in order
511
+ */
512
+ abstract getChunks(threadId: string): Promise<MessageChunk[]>;
513
+ /**
514
+ * Get accumulated content for a thread (all chunks concatenated)
515
+ */
516
+ abstract getAccumulatedContent(threadId: string): Promise<string>;
517
+ /**
518
+ * Get chunks for a specific message within a thread
519
+ */
520
+ abstract getChunksByMessageId(threadId: string, messageId: string): Promise<MessageChunk[]>;
521
+ /**
522
+ * Mark thread as completed (explicit call)
523
+ */
524
+ abstract completeThread(threadId: string): Promise<void>;
525
+ /**
526
+ * Mark thread as aborted (explicit call)
527
+ */
528
+ abstract abortThread(threadId: string): Promise<void>;
529
+ /**
530
+ * Check if thread is still active
531
+ */
532
+ abstract isThreadActive(threadId: string): Promise<boolean>;
533
+ /**
534
+ * Get thread status (returns undefined if thread doesn't exist)
535
+ */
536
+ abstract getThreadStatus(threadId: string): Promise<ThreadStatus | undefined>;
537
+ /**
538
+ * Get thread buffer info including metadata
539
+ */
540
+ abstract getThreadBuffer(threadId: string): Promise<ThreadBuffer | undefined>;
541
+ /**
542
+ * Clear specific thread buffer
543
+ */
544
+ abstract clearThread(threadId: string): Promise<void>;
545
+ /**
546
+ * Get all active thread IDs
547
+ */
548
+ abstract getActiveThreads(): Promise<string[]>;
549
+ /**
550
+ * Get all thread IDs (regardless of status)
551
+ */
552
+ abstract getAllThreads(): Promise<string[]>;
553
+ /**
554
+ * Manually trigger cleanup of expired threads
555
+ * Returns number of threads cleaned up
556
+ */
557
+ abstract cleanupExpiredThreads(): Promise<number>;
558
+ /**
559
+ * Extend thread TTL (reset expiration time)
560
+ */
561
+ abstract extendThreadTTL(threadId: string, additionalMs?: number): Promise<void>;
562
+ /**
563
+ * Check if a thread exists (valid or expired)
564
+ */
565
+ abstract hasThread(threadId: string): Promise<boolean>;
566
+ /**
567
+ * Get new chunks since known content
568
+ * Used for resuming streams from a known position
569
+ * Matches the known content and returns chunks after that position
570
+ */
571
+ abstract getNewChunksSinceContent(threadId: string, messageId: string, knownContent: string): AsyncGenerator<MessageChunk>;
572
+ }
573
+
574
+ /**
575
+ * InMemoryChunkBuffer
576
+ *
577
+ * In-memory implementation of ChunkBuffer with hybrid cleanup strategy:
578
+ * - Lazy cleanup: expired threads are removed on access
579
+ * - Optional periodic cleanup: background timer to clean expired threads
580
+ */
581
+
582
+ declare class InMemoryChunkBuffer extends ChunkBuffer {
583
+ private buffers;
584
+ private config;
585
+ private cleanupTimer?;
586
+ constructor(config?: ThreadBufferConfig);
587
+ /**
588
+ * Start automatic periodic cleanup timer
589
+ */
590
+ private startCleanupTimer;
591
+ /**
592
+ * Stop cleanup timer (for cleanup/shutdown)
593
+ */
594
+ stopCleanupTimer(): void;
595
+ /**
596
+ * Check if a buffer is expired (lazy cleanup helper)
597
+ */
598
+ private isExpired;
599
+ /**
600
+ * Get buffer if valid, perform lazy cleanup if expired
601
+ */
602
+ private getBufferIfValid;
603
+ /**
604
+ * Create or get thread buffer
605
+ */
606
+ private getOrCreateBuffer;
607
+ addChunk(threadId: string, content: MessageChunk): Promise<void>;
608
+ getChunks(threadId: string): Promise<MessageChunk[]>;
609
+ getAccumulatedContent(threadId: string): Promise<string>;
610
+ getChunksByMessageId(threadId: string, messageId: string): Promise<MessageChunk[]>;
611
+ completeThread(threadId: string): Promise<void>;
612
+ abortThread(threadId: string): Promise<void>;
613
+ isThreadActive(threadId: string): Promise<boolean>;
614
+ getThreadStatus(threadId: string): Promise<ThreadStatus | undefined>;
615
+ getThreadBuffer(threadId: string): Promise<ThreadBuffer | undefined>;
616
+ clearThread(threadId: string): Promise<void>;
617
+ getActiveThreads(): Promise<string[]>;
618
+ getAllThreads(): Promise<string[]>;
619
+ hasThread(threadId: string): Promise<boolean>;
620
+ /**
621
+ * Cleanup expired threads based on TTL
622
+ * Returns number of threads cleaned up
623
+ */
624
+ cleanupExpiredThreads(): Promise<number>;
625
+ /**
626
+ * Extend thread TTL
627
+ */
628
+ extendThreadTTL(threadId: string, additionalMs?: number): Promise<void>;
629
+ /**
630
+ * Get new chunks since known content
631
+ * Used for resuming streams from a known position
632
+ * Matches the known content and returns chunks after that position
633
+ * Continues to yield new chunks as they are added until thread completes/aborts
634
+ */
635
+ getNewChunksSinceContent(threadId: string, messageId: string, knownContent: string): AsyncGenerator<MessageChunk>;
636
+ /**
637
+ * Get statistics about the buffer
638
+ */
639
+ getStats(): BufferStats;
640
+ /**
641
+ * Cleanup method for graceful shutdown
642
+ */
643
+ dispose(): void;
644
+ }
645
+
646
+ /**
647
+ * ChunkBufferLatticeManager
648
+ *
649
+ * Manages ChunkBuffer instances following the Lattice pattern
650
+ */
651
+
652
+ /**
653
+ * ChunkBuffer Lattice Manager
654
+ */
655
+ declare class ChunkBufferLatticeManager extends BaseLatticeManager<ChunkBuffer> {
656
+ private static instance;
657
+ /**
658
+ * Private constructor for singleton pattern
659
+ */
660
+ private constructor();
661
+ /**
662
+ * Get singleton instance
663
+ */
664
+ static getInstance(): ChunkBufferLatticeManager;
665
+ /**
666
+ * Get Lattice type identifier
667
+ */
668
+ protected getLatticeType(): string;
669
+ }
670
+ declare const getChunkBuffer: (key: string) => ChunkBuffer | undefined;
671
+ declare const registerChunkBuffer: (key: string, buffer: ChunkBuffer) => void;
672
+ declare const hasChunkBuffer: (key: string) => boolean;
673
+
674
+ export { type AgentClient, type AgentLattice, AgentLatticeManager, type BufferStats, type Chunk, ChunkBuffer, ChunkBufferLatticeManager, InMemoryChunkBuffer, MemoryLatticeManager, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, type ThreadBuffer, type ThreadBufferConfig, ThreadStatus, type ToolDefinition, type ToolLattice, ToolLatticeManager, agentLatticeManager, getAgentClient, getAgentConfig, getAgentLattice, getAllAgentConfigs, getAllToolDefinitions, getCheckpointSaver, getChunkBuffer, getModelLattice, getToolClient, getToolDefinition, getToolLattice, hasChunkBuffer, modelLatticeManager, registerAgentLattice, registerAgentLattices, registerCheckpointSaver, registerChunkBuffer, registerModelLattice, registerToolLattice, toolLatticeManager, validateAgentInput, validateToolInput };
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 } from '@axiom-lattice/protocols';
8
+ import { LLMConfig, ToolConfig, ToolExecutor, AgentConfig, GraphBuildOptions, MessageChunk } 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';
@@ -442,4 +442,233 @@ declare class MemoryLatticeManager extends BaseLatticeManager {
442
442
  declare const getCheckpointSaver: (key: string) => BaseCheckpointSaver<number>;
443
443
  declare const registerCheckpointSaver: (key: string, saver: BaseCheckpointSaver) => void;
444
444
 
445
- export { type AgentClient, type AgentLattice, AgentLatticeManager, MemoryLatticeManager, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, type ToolDefinition, type ToolLattice, ToolLatticeManager, agentLatticeManager, getAgentClient, getAgentConfig, getAgentLattice, getAllAgentConfigs, getAllToolDefinitions, getCheckpointSaver, getModelLattice, getToolClient, getToolDefinition, getToolLattice, modelLatticeManager, registerAgentLattice, registerAgentLattices, registerCheckpointSaver, registerModelLattice, registerToolLattice, toolLatticeManager, validateAgentInput, validateToolInput };
445
+ /**
446
+ * ChunkBuffer Types
447
+ *
448
+ * Defines types for managing streaming chunks organized by thread
449
+ */
450
+
451
+ /**
452
+ * Represents a single chunk of data
453
+ * Chunks are identified by their position in the sequence (no unique ID)
454
+ */
455
+ interface Chunk {
456
+ messageId: string;
457
+ content: MessageChunk;
458
+ }
459
+ /**
460
+ * Thread status - requires explicit state transitions
461
+ */
462
+ declare enum ThreadStatus {
463
+ ACTIVE = "active",
464
+ COMPLETED = "completed",
465
+ ABORTED = "aborted"
466
+ }
467
+ /**
468
+ * Thread buffer configuration
469
+ */
470
+ interface ThreadBufferConfig {
471
+ ttl?: number;
472
+ cleanupInterval?: number;
473
+ }
474
+ /**
475
+ * Thread buffer state
476
+ */
477
+ interface ThreadBuffer {
478
+ threadId: string;
479
+ chunks: MessageChunk[];
480
+ status: ThreadStatus;
481
+ createdAt: number;
482
+ updatedAt: number;
483
+ expiresAt: number;
484
+ }
485
+ /**
486
+ * Buffer statistics
487
+ */
488
+ interface BufferStats {
489
+ totalThreads: number;
490
+ activeThreads: number;
491
+ completedThreads: number;
492
+ abortedThreads: number;
493
+ totalChunks: number;
494
+ config: Required<ThreadBufferConfig>;
495
+ }
496
+
497
+ /**
498
+ * ChunkBuffer Abstract Base Class
499
+ *
500
+ * Defines the interface for chunk buffer implementations
501
+ */
502
+
503
+ declare abstract class ChunkBuffer {
504
+ /**
505
+ * Add a chunk to a thread (creates thread if not exists)
506
+ * Chunks are appended in order
507
+ */
508
+ abstract addChunk(threadId: string, content: MessageChunk): Promise<void>;
509
+ /**
510
+ * Get all chunks for a thread in order
511
+ */
512
+ abstract getChunks(threadId: string): Promise<MessageChunk[]>;
513
+ /**
514
+ * Get accumulated content for a thread (all chunks concatenated)
515
+ */
516
+ abstract getAccumulatedContent(threadId: string): Promise<string>;
517
+ /**
518
+ * Get chunks for a specific message within a thread
519
+ */
520
+ abstract getChunksByMessageId(threadId: string, messageId: string): Promise<MessageChunk[]>;
521
+ /**
522
+ * Mark thread as completed (explicit call)
523
+ */
524
+ abstract completeThread(threadId: string): Promise<void>;
525
+ /**
526
+ * Mark thread as aborted (explicit call)
527
+ */
528
+ abstract abortThread(threadId: string): Promise<void>;
529
+ /**
530
+ * Check if thread is still active
531
+ */
532
+ abstract isThreadActive(threadId: string): Promise<boolean>;
533
+ /**
534
+ * Get thread status (returns undefined if thread doesn't exist)
535
+ */
536
+ abstract getThreadStatus(threadId: string): Promise<ThreadStatus | undefined>;
537
+ /**
538
+ * Get thread buffer info including metadata
539
+ */
540
+ abstract getThreadBuffer(threadId: string): Promise<ThreadBuffer | undefined>;
541
+ /**
542
+ * Clear specific thread buffer
543
+ */
544
+ abstract clearThread(threadId: string): Promise<void>;
545
+ /**
546
+ * Get all active thread IDs
547
+ */
548
+ abstract getActiveThreads(): Promise<string[]>;
549
+ /**
550
+ * Get all thread IDs (regardless of status)
551
+ */
552
+ abstract getAllThreads(): Promise<string[]>;
553
+ /**
554
+ * Manually trigger cleanup of expired threads
555
+ * Returns number of threads cleaned up
556
+ */
557
+ abstract cleanupExpiredThreads(): Promise<number>;
558
+ /**
559
+ * Extend thread TTL (reset expiration time)
560
+ */
561
+ abstract extendThreadTTL(threadId: string, additionalMs?: number): Promise<void>;
562
+ /**
563
+ * Check if a thread exists (valid or expired)
564
+ */
565
+ abstract hasThread(threadId: string): Promise<boolean>;
566
+ /**
567
+ * Get new chunks since known content
568
+ * Used for resuming streams from a known position
569
+ * Matches the known content and returns chunks after that position
570
+ */
571
+ abstract getNewChunksSinceContent(threadId: string, messageId: string, knownContent: string): AsyncGenerator<MessageChunk>;
572
+ }
573
+
574
+ /**
575
+ * InMemoryChunkBuffer
576
+ *
577
+ * In-memory implementation of ChunkBuffer with hybrid cleanup strategy:
578
+ * - Lazy cleanup: expired threads are removed on access
579
+ * - Optional periodic cleanup: background timer to clean expired threads
580
+ */
581
+
582
+ declare class InMemoryChunkBuffer extends ChunkBuffer {
583
+ private buffers;
584
+ private config;
585
+ private cleanupTimer?;
586
+ constructor(config?: ThreadBufferConfig);
587
+ /**
588
+ * Start automatic periodic cleanup timer
589
+ */
590
+ private startCleanupTimer;
591
+ /**
592
+ * Stop cleanup timer (for cleanup/shutdown)
593
+ */
594
+ stopCleanupTimer(): void;
595
+ /**
596
+ * Check if a buffer is expired (lazy cleanup helper)
597
+ */
598
+ private isExpired;
599
+ /**
600
+ * Get buffer if valid, perform lazy cleanup if expired
601
+ */
602
+ private getBufferIfValid;
603
+ /**
604
+ * Create or get thread buffer
605
+ */
606
+ private getOrCreateBuffer;
607
+ addChunk(threadId: string, content: MessageChunk): Promise<void>;
608
+ getChunks(threadId: string): Promise<MessageChunk[]>;
609
+ getAccumulatedContent(threadId: string): Promise<string>;
610
+ getChunksByMessageId(threadId: string, messageId: string): Promise<MessageChunk[]>;
611
+ completeThread(threadId: string): Promise<void>;
612
+ abortThread(threadId: string): Promise<void>;
613
+ isThreadActive(threadId: string): Promise<boolean>;
614
+ getThreadStatus(threadId: string): Promise<ThreadStatus | undefined>;
615
+ getThreadBuffer(threadId: string): Promise<ThreadBuffer | undefined>;
616
+ clearThread(threadId: string): Promise<void>;
617
+ getActiveThreads(): Promise<string[]>;
618
+ getAllThreads(): Promise<string[]>;
619
+ hasThread(threadId: string): Promise<boolean>;
620
+ /**
621
+ * Cleanup expired threads based on TTL
622
+ * Returns number of threads cleaned up
623
+ */
624
+ cleanupExpiredThreads(): Promise<number>;
625
+ /**
626
+ * Extend thread TTL
627
+ */
628
+ extendThreadTTL(threadId: string, additionalMs?: number): Promise<void>;
629
+ /**
630
+ * Get new chunks since known content
631
+ * Used for resuming streams from a known position
632
+ * Matches the known content and returns chunks after that position
633
+ * Continues to yield new chunks as they are added until thread completes/aborts
634
+ */
635
+ getNewChunksSinceContent(threadId: string, messageId: string, knownContent: string): AsyncGenerator<MessageChunk>;
636
+ /**
637
+ * Get statistics about the buffer
638
+ */
639
+ getStats(): BufferStats;
640
+ /**
641
+ * Cleanup method for graceful shutdown
642
+ */
643
+ dispose(): void;
644
+ }
645
+
646
+ /**
647
+ * ChunkBufferLatticeManager
648
+ *
649
+ * Manages ChunkBuffer instances following the Lattice pattern
650
+ */
651
+
652
+ /**
653
+ * ChunkBuffer Lattice Manager
654
+ */
655
+ declare class ChunkBufferLatticeManager extends BaseLatticeManager<ChunkBuffer> {
656
+ private static instance;
657
+ /**
658
+ * Private constructor for singleton pattern
659
+ */
660
+ private constructor();
661
+ /**
662
+ * Get singleton instance
663
+ */
664
+ static getInstance(): ChunkBufferLatticeManager;
665
+ /**
666
+ * Get Lattice type identifier
667
+ */
668
+ protected getLatticeType(): string;
669
+ }
670
+ declare const getChunkBuffer: (key: string) => ChunkBuffer | undefined;
671
+ declare const registerChunkBuffer: (key: string, buffer: ChunkBuffer) => void;
672
+ declare const hasChunkBuffer: (key: string) => boolean;
673
+
674
+ export { type AgentClient, type AgentLattice, AgentLatticeManager, type BufferStats, type Chunk, ChunkBuffer, ChunkBufferLatticeManager, InMemoryChunkBuffer, MemoryLatticeManager, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, type ThreadBuffer, type ThreadBufferConfig, ThreadStatus, type ToolDefinition, type ToolLattice, ToolLatticeManager, agentLatticeManager, getAgentClient, getAgentConfig, getAgentLattice, getAllAgentConfigs, getAllToolDefinitions, getCheckpointSaver, getChunkBuffer, getModelLattice, getToolClient, getToolDefinition, getToolLattice, hasChunkBuffer, modelLatticeManager, registerAgentLattice, registerAgentLattices, registerCheckpointSaver, registerChunkBuffer, registerModelLattice, registerToolLattice, toolLatticeManager, validateAgentInput, validateToolInput };