paprflare-sdk 0.0.13 → 0.0.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
@@ -7,12 +7,35 @@ import EventEmitter from 'eventemitter3';
7
7
  interface DatabaseAdapter {
8
8
  createConversation(userId: string, metadata?: Record<string, unknown>): Promise<string>;
9
9
  getConversation(conversationId: string): Promise<Conversation | null>;
10
- listConversations(userId: string, limit?: number): Promise<Conversation[]>;
10
+ listConversations(userId: string, limit?: number, offset?: number): Promise<Conversation[]>;
11
+ updateConversation(conversationId: string, updates: Partial<Conversation>): Promise<void>;
11
12
  deleteConversation(conversationId: string): Promise<void>;
13
+ deleteAllConversations(userId: string): Promise<void>;
14
+ countConversations(userId: string): Promise<number>;
15
+ conversationExists(conversationId: string): Promise<boolean>;
16
+ searchConversations(userId: string, query: string): Promise<Conversation[]>;
12
17
  saveMessage(conversationId: string, message: Message): Promise<void>;
13
- getMessages(conversationId: string, limit?: number): Promise<Message[]>;
18
+ saveManyMessages(conversationId: string, messages: Message[]): Promise<void>;
19
+ getMessage(messageId: string): Promise<Message | null>;
20
+ getMessages(conversationId: string, limit?: number, offset?: number): Promise<Message[]>;
21
+ getMessagesByRole(conversationId: string, role: Message['role']): Promise<Message[]>;
14
22
  updateMessage(messageId: string, updates: Partial<Message>): Promise<void>;
23
+ deleteMessage(messageId: string): Promise<void>;
24
+ deleteAllMessages(conversationId: string): Promise<void>;
25
+ countMessages(conversationId: string): Promise<number>;
26
+ getLastMessage(conversationId: string): Promise<Message | null>;
27
+ searchMessages(conversationId: string, query: string): Promise<Message[]>;
15
28
  updateConversationMetadata(conversationId: string, metadata: Record<string, unknown>): Promise<void>;
29
+ getConversationMetadata(conversationId: string): Promise<Record<string, unknown> | null>;
30
+ deleteConversationMetadata(conversationId: string, keys: string[]): Promise<void>;
31
+ userExists(userId: string): Promise<boolean>;
32
+ deleteUser(userId: string): Promise<void>;
33
+ exportConversation(conversationId: string): Promise<ConversationExport>;
34
+ importConversation(userId: string, data: ConversationExport): Promise<string>;
35
+ connect(): Promise<void>;
36
+ disconnect(): Promise<void>;
37
+ healthCheck(): Promise<boolean>;
38
+ purge(): Promise<void>;
16
39
  }
17
40
  interface Conversation {
18
41
  id: string;
@@ -22,6 +45,11 @@ interface Conversation {
22
45
  createdAt: Date;
23
46
  updatedAt: Date;
24
47
  }
48
+ interface ConversationExport {
49
+ conversation: Conversation;
50
+ messages: Message[];
51
+ exportedAt: Date;
52
+ }
25
53
 
26
54
  /**
27
55
  * Drizzle ORM adapter
@@ -30,14 +58,37 @@ declare class DrizzleAdapter implements DatabaseAdapter {
30
58
  private db;
31
59
  private schema;
32
60
  constructor(db: any, schema: any);
61
+ connect(): Promise<void>;
62
+ disconnect(): Promise<void>;
63
+ healthCheck(): Promise<boolean>;
64
+ purge(): Promise<void>;
33
65
  createConversation(userId: string, metadata?: Record<string, unknown>): Promise<string>;
34
66
  getConversation(conversationId: string): Promise<Conversation | null>;
35
- listConversations(userId: string, limit?: number): Promise<Conversation[]>;
67
+ listConversations(userId: string, limit?: number, offset?: number): Promise<Conversation[]>;
68
+ updateConversation(conversationId: string, updates: Partial<Conversation>): Promise<void>;
36
69
  deleteConversation(conversationId: string): Promise<void>;
70
+ deleteAllConversations(userId: string): Promise<void>;
71
+ countConversations(userId: string): Promise<number>;
72
+ conversationExists(conversationId: string): Promise<boolean>;
73
+ searchConversations(userId: string, query: string): Promise<Conversation[]>;
37
74
  saveMessage(conversationId: string, message: Message): Promise<void>;
38
- getMessages(conversationId: string, limit?: number): Promise<Message[]>;
75
+ saveManyMessages(conversationId: string, messages: Message[]): Promise<void>;
76
+ getMessage(messageId: string): Promise<Message | null>;
77
+ getMessages(conversationId: string, limit?: number, offset?: number): Promise<Message[]>;
78
+ getMessagesByRole(conversationId: string, role: Message['role']): Promise<Message[]>;
39
79
  updateMessage(messageId: string, updates: Partial<Message>): Promise<void>;
80
+ deleteMessage(messageId: string): Promise<void>;
81
+ deleteAllMessages(conversationId: string): Promise<void>;
82
+ countMessages(conversationId: string): Promise<number>;
83
+ getLastMessage(conversationId: string): Promise<Message | null>;
84
+ searchMessages(conversationId: string, query: string): Promise<Message[]>;
40
85
  updateConversationMetadata(conversationId: string, metadata: Record<string, unknown>): Promise<void>;
86
+ getConversationMetadata(conversationId: string): Promise<Record<string, unknown> | null>;
87
+ deleteConversationMetadata(conversationId: string, keys: string[]): Promise<void>;
88
+ userExists(userId: string): Promise<boolean>;
89
+ deleteUser(userId: string): Promise<void>;
90
+ exportConversation(conversationId: string): Promise<ConversationExport>;
91
+ importConversation(userId: string, data: ConversationExport): Promise<string>;
41
92
  }
42
93
 
43
94
  /**
@@ -46,11 +97,37 @@ declare class DrizzleAdapter implements DatabaseAdapter {
46
97
  declare class DatabaseManager {
47
98
  private adapter;
48
99
  constructor(adapter: DatabaseAdapter);
49
- startConversation(userId: string, systemPrompt?: string): Promise<string>;
50
- addMessage(conversationId: string, message: Message): Promise<void>;
51
- getConversationHistory(conversationId: string, limit?: number): Promise<Message[]>;
100
+ connect(): Promise<void>;
101
+ disconnect(): Promise<void>;
102
+ healthCheck(): Promise<boolean>;
103
+ purge(): Promise<void>;
104
+ create(userId: string, systemPrompt?: string): Promise<string>;
105
+ getConversation(conversationId: string): Promise<Conversation | null>;
106
+ listConversations(userId: string, limit?: number, offset?: number): Promise<Conversation[]>;
107
+ updateConversation(conversationId: string, updates: Partial<Conversation>): Promise<void>;
52
108
  deleteConversation(conversationId: string): Promise<void>;
53
- getUserConversations(userId: string): Promise<Conversation[]>;
109
+ deleteAllConversations(userId: string): Promise<void>;
110
+ countConversations(userId: string): Promise<number>;
111
+ conversationExists(conversationId: string): Promise<boolean>;
112
+ searchConversations(userId: string, query: string): Promise<Conversation[]>;
113
+ addMessage(conversationId: string, message: Message): Promise<void>;
114
+ addManyMessages(conversationId: string, messages: Message[]): Promise<void>;
115
+ getMessage(messageId: string): Promise<Message | null>;
116
+ getConversationHistory(conversationId: string, limit?: number, offset?: number): Promise<Message[]>;
117
+ getMessagesByRole(conversationId: string, role: Message['role']): Promise<Message[]>;
118
+ updateMessage(messageId: string, updates: Partial<Message>): Promise<void>;
119
+ deleteMessage(messageId: string): Promise<void>;
120
+ deleteAllMessages(conversationId: string): Promise<void>;
121
+ countMessages(conversationId: string): Promise<number>;
122
+ getLastMessage(conversationId: string): Promise<Message | null>;
123
+ searchMessages(conversationId: string, query: string): Promise<Message[]>;
124
+ updateConversationMetadata(conversationId: string, metadata: Record<string, unknown>): Promise<void>;
125
+ getConversationMetadata(conversationId: string): Promise<Record<string, unknown> | null>;
126
+ deleteConversationMetadata(conversationId: string, keys: string[]): Promise<void>;
127
+ userExists(userId: string): Promise<boolean>;
128
+ deleteUser(userId: string): Promise<void>;
129
+ exportConversation(conversationId: string): Promise<ConversationExport>;
130
+ importConversation(userId: string, data: ConversationExport): Promise<string>;
54
131
  }
55
132
 
56
133
  /**
@@ -59,14 +136,37 @@ declare class DatabaseManager {
59
136
  declare class MemoryAdapter implements DatabaseAdapter {
60
137
  private conversations;
61
138
  private messages;
139
+ connect(): Promise<void>;
140
+ disconnect(): Promise<void>;
141
+ healthCheck(): Promise<boolean>;
142
+ purge(): Promise<void>;
62
143
  createConversation(userId: string, metadata?: Record<string, unknown>): Promise<string>;
63
144
  getConversation(conversationId: string): Promise<Conversation | null>;
64
- listConversations(userId: string, limit?: number): Promise<Conversation[]>;
145
+ listConversations(userId: string, limit?: number, offset?: number): Promise<Conversation[]>;
146
+ updateConversation(conversationId: string, updates: Partial<Conversation>): Promise<void>;
65
147
  deleteConversation(conversationId: string): Promise<void>;
148
+ deleteAllConversations(userId: string): Promise<void>;
149
+ countConversations(userId: string): Promise<number>;
150
+ conversationExists(conversationId: string): Promise<boolean>;
151
+ searchConversations(userId: string, query: string): Promise<Conversation[]>;
66
152
  saveMessage(conversationId: string, message: Message): Promise<void>;
67
- getMessages(conversationId: string, limit?: number): Promise<Message[]>;
153
+ saveManyMessages(conversationId: string, messages: Message[]): Promise<void>;
154
+ getMessage(messageId: string): Promise<Message | null>;
155
+ getMessages(conversationId: string, limit?: number, offset?: number): Promise<Message[]>;
156
+ getMessagesByRole(conversationId: string, role: Message['role']): Promise<Message[]>;
68
157
  updateMessage(messageId: string, updates: Partial<Message>): Promise<void>;
158
+ deleteMessage(messageId: string): Promise<void>;
159
+ deleteAllMessages(conversationId: string): Promise<void>;
160
+ countMessages(conversationId: string): Promise<number>;
161
+ getLastMessage(conversationId: string): Promise<Message | null>;
162
+ searchMessages(conversationId: string, query: string): Promise<Message[]>;
69
163
  updateConversationMetadata(conversationId: string, metadata: Record<string, unknown>): Promise<void>;
164
+ getConversationMetadata(conversationId: string): Promise<Record<string, unknown> | null>;
165
+ deleteConversationMetadata(conversationId: string, keys: string[]): Promise<void>;
166
+ userExists(userId: string): Promise<boolean>;
167
+ deleteUser(userId: string): Promise<void>;
168
+ exportConversation(conversationId: string): Promise<ConversationExport>;
169
+ importConversation(userId: string, data: ConversationExport): Promise<string>;
70
170
  }
71
171
 
72
172
  /**
@@ -75,14 +175,38 @@ declare class MemoryAdapter implements DatabaseAdapter {
75
175
  declare class PrismaAdapter implements DatabaseAdapter {
76
176
  private prisma;
77
177
  constructor(prisma: any);
178
+ connect(): Promise<void>;
179
+ disconnect(): Promise<void>;
180
+ healthCheck(): Promise<boolean>;
181
+ purge(): Promise<void>;
78
182
  createConversation(userId: string, metadata?: Record<string, unknown>): Promise<string>;
79
183
  getConversation(conversationId: string): Promise<Conversation | null>;
80
- listConversations(userId: string, limit?: number): Promise<Conversation[]>;
184
+ listConversations(userId: string, limit?: number, offset?: number): Promise<Conversation[]>;
185
+ updateConversation(conversationId: string, updates: Partial<Conversation>): Promise<void>;
81
186
  deleteConversation(conversationId: string): Promise<void>;
187
+ deleteAllConversations(userId: string): Promise<void>;
188
+ countConversations(userId: string): Promise<number>;
189
+ conversationExists(conversationId: string): Promise<boolean>;
190
+ searchConversations(userId: string, query: string): Promise<Conversation[]>;
191
+ private toMessage;
82
192
  saveMessage(conversationId: string, message: Message): Promise<void>;
83
- getMessages(conversationId: string, limit?: number): Promise<Message[]>;
193
+ saveManyMessages(conversationId: string, messages: Message[]): Promise<void>;
194
+ getMessage(messageId: string): Promise<Message | null>;
195
+ getMessages(conversationId: string, limit?: number, offset?: number): Promise<Message[]>;
196
+ getMessagesByRole(conversationId: string, role: Message['role']): Promise<Message[]>;
84
197
  updateMessage(messageId: string, updates: Partial<Message>): Promise<void>;
198
+ deleteMessage(messageId: string): Promise<void>;
199
+ deleteAllMessages(conversationId: string): Promise<void>;
200
+ countMessages(conversationId: string): Promise<number>;
201
+ getLastMessage(conversationId: string): Promise<Message | null>;
202
+ searchMessages(conversationId: string, query: string): Promise<Message[]>;
85
203
  updateConversationMetadata(conversationId: string, metadata: Record<string, unknown>): Promise<void>;
204
+ getConversationMetadata(conversationId: string): Promise<Record<string, unknown> | null>;
205
+ deleteConversationMetadata(conversationId: string, keys: string[]): Promise<void>;
206
+ userExists(userId: string): Promise<boolean>;
207
+ deleteUser(userId: string): Promise<void>;
208
+ exportConversation(conversationId: string): Promise<ConversationExport>;
209
+ importConversation(userId: string, data: ConversationExport): Promise<string>;
86
210
  }
87
211
 
88
212
  interface Message {
@@ -451,29 +575,163 @@ interface Thread {
451
575
  messages: Message[];
452
576
  config?: ChatConfig;
453
577
  metadata: Record<string, unknown>;
578
+ tags: string[];
579
+ title?: string;
454
580
  createdAt: number;
455
581
  updatedAt: number;
456
- status: 'active' | 'paused' | 'completed' | 'error';
582
+ lastActiveAt: number;
583
+ status: 'active' | 'paused' | 'completed' | 'error' | 'archived';
584
+ priority: 'low' | 'normal' | 'high';
585
+ messageCount: number;
586
+ tokenCount?: number;
587
+ errorCount: number;
588
+ lastError?: string;
589
+ }
590
+ /**
591
+ * Thread filter options
592
+ */
593
+ interface ThreadFilter {
594
+ status?: Thread['status'] | Thread['status'][];
595
+ priority?: Thread['priority'];
596
+ tags?: string[];
597
+ createdAfter?: number;
598
+ createdBefore?: number;
599
+ updatedAfter?: number;
600
+ search?: string;
601
+ }
602
+ /**
603
+ * Thread sort options
604
+ */
605
+ interface ThreadSortOptions {
606
+ field: 'createdAt' | 'updatedAt' | 'lastActiveAt' | 'messageCount' | 'priority';
607
+ direction: 'asc' | 'desc';
608
+ }
609
+ /**
610
+ * Thread pagination options
611
+ */
612
+ interface ThreadPaginationOptions {
613
+ limit?: number;
614
+ offset?: number;
615
+ sort?: ThreadSortOptions;
616
+ }
617
+ /**
618
+ * Thread statistics
619
+ */
620
+ interface ThreadStats {
621
+ total: number;
622
+ active: number;
623
+ paused: number;
624
+ completed: number;
625
+ error: number;
626
+ archived: number;
627
+ totalMessages: number;
628
+ totalTokens: number;
629
+ averageMessagesPerThread: number;
630
+ oldestThread?: number;
631
+ newestThread?: number;
632
+ }
633
+ /**
634
+ * Thread export format
635
+ */
636
+ interface ThreadExport {
637
+ thread: Thread;
638
+ messages: Message[];
639
+ exportedAt: number;
640
+ version: string;
457
641
  }
458
642
  /**
459
643
  * Thread events
460
644
  */
461
645
  type ThreadEvent = {
646
+ type: 'thread-created';
647
+ threadId: string;
648
+ thread: Thread;
649
+ } | {
650
+ type: 'thread-deleted';
651
+ threadId: string;
652
+ } | {
653
+ type: 'thread-archived';
654
+ threadId: string;
655
+ } | {
656
+ type: 'thread-restored';
657
+ threadId: string;
658
+ } | {
659
+ type: 'thread-cleared';
660
+ threadId: string;
661
+ } | {
662
+ type: 'thread-merged';
663
+ threadId: string;
664
+ sourceThreadId: string;
665
+ } | {
666
+ type: 'thread-forked';
667
+ threadId: string;
668
+ parentThreadId: string;
669
+ } | {
462
670
  type: 'message-added';
463
671
  threadId: string;
464
672
  message: Message;
673
+ } | {
674
+ type: 'message-updated';
675
+ threadId: string;
676
+ messageId: string;
677
+ updates: Partial<Message>;
678
+ } | {
679
+ type: 'message-deleted';
680
+ threadId: string;
681
+ messageId: string;
682
+ } | {
683
+ type: 'messages-cleared';
684
+ threadId: string;
685
+ } | {
686
+ type: 'stream-started';
687
+ threadId: string;
465
688
  } | {
466
689
  type: 'stream-event';
467
690
  threadId: string;
468
691
  event: StreamEvent;
692
+ } | {
693
+ type: 'stream-completed';
694
+ threadId: string;
695
+ message: Message;
696
+ } | {
697
+ type: 'stream-error';
698
+ threadId: string;
699
+ error: Error;
469
700
  } | {
470
701
  type: 'status-changed';
471
702
  threadId: string;
472
703
  status: Thread['status'];
704
+ previousStatus: Thread['status'];
705
+ } | {
706
+ type: 'priority-changed';
707
+ threadId: string;
708
+ priority: Thread['priority'];
709
+ } | {
710
+ type: 'metadata-updated';
711
+ threadId: string;
712
+ metadata: Record<string, unknown>;
713
+ } | {
714
+ type: 'tags-updated';
715
+ threadId: string;
716
+ tags: string[];
717
+ } | {
718
+ type: 'title-updated';
719
+ threadId: string;
720
+ title: string;
721
+ } | {
722
+ type: 'config-updated';
723
+ threadId: string;
724
+ config: ChatConfig;
473
725
  } | {
474
726
  type: 'error';
475
727
  threadId: string;
476
728
  error: Error;
729
+ } | {
730
+ type: 'cleanup';
731
+ deletedCount: number;
732
+ } | {
733
+ type: 'pool-stats';
734
+ stats: ThreadStats;
477
735
  };
478
736
 
479
737
  /**
@@ -482,79 +740,157 @@ type ThreadEvent = {
482
740
  */
483
741
  declare class ThreadManager extends EventEmitter {
484
742
  private client;
485
- private threads;
743
+ threads: Map<string, Thread>;
486
744
  constructor(client: PaprFlare);
745
+ createThread(userId: string, config?: ChatConfig, metadata?: Record<string, unknown>, options?: {
746
+ title?: string;
747
+ tags?: string[];
748
+ priority?: Thread['priority'];
749
+ }): Promise<string>;
487
750
  /**
488
- * Create a new thread
751
+ * Fork a thread — creates a new thread with a copy of messages up to a given point
489
752
  */
490
- createThread(userId: string, config?: ChatConfig, metadata?: Record<string, unknown>): Promise<string>;
753
+ forkThread(threadId: string, upToMessageId?: string): Promise<string>;
491
754
  /**
492
- * Get thread by ID
755
+ * Merge another thread's messages into this thread
493
756
  */
757
+ mergeThread(targetThreadId: string, sourceThreadId: string): Promise<void>;
494
758
  getThread(threadId: string): Thread | null;
759
+ threadExists(threadId: string): boolean;
760
+ getUserThreads(userId: string, options?: ThreadPaginationOptions): Thread[];
761
+ filterThreads(userId: string, filter: ThreadFilter, options?: ThreadPaginationOptions): Thread[];
762
+ countThreads(userId: string, filter?: ThreadFilter): number;
763
+ updateThreadStatus(threadId: string, status: Thread['status']): void;
764
+ updateThreadPriority(threadId: string, priority: Thread['priority']): void;
765
+ updateThreadMetadata(threadId: string, metadata: Record<string, unknown>): void;
766
+ setThreadTitle(threadId: string, title: string): void;
767
+ updateThreadConfig(threadId: string, config: Partial<ChatConfig>): void;
768
+ addTags(threadId: string, tags: string[]): void;
769
+ removeTags(threadId: string, tags: string[]): void;
770
+ setTags(threadId: string, tags: string[]): void;
771
+ addMessage(threadId: string, message: Message): Promise<void>;
772
+ addManyMessages(threadId: string, messages: Message[]): Promise<void>;
773
+ getMessage(threadId: string, messageId: string): Message | null;
774
+ getMessages(threadId: string, options?: {
775
+ limit?: number;
776
+ offset?: number;
777
+ role?: Message['role'];
778
+ }): Message[];
779
+ getLastMessage(threadId: string): Message | null;
780
+ updateMessage(threadId: string, messageId: string, updates: Partial<Message>): void;
781
+ deleteMessage(threadId: string, messageId: string): void;
782
+ searchMessages(threadId: string, query: string): Message[];
783
+ clearThread(threadId: string): void;
784
+ trimThread(threadId: string, keepLast: number): void;
785
+ archiveThread(threadId: string): void;
786
+ restoreThread(threadId: string): void;
787
+ pauseThread(threadId: string): void;
788
+ resumeThread(threadId: string): void;
789
+ completeThread(threadId: string): void;
790
+ markThreadError(threadId: string, error: Error): void;
791
+ deleteThread(threadId: string): void;
792
+ deleteAllThreads(userId: string): void;
793
+ getStats(userId?: string): ThreadStats;
794
+ exportThread(threadId: string): ThreadExport;
795
+ importThread(userId: string, data: ThreadExport): string;
796
+ cleanup(maxAge?: number): void;
797
+ private requireThread;
798
+ private sortThreads;
799
+ }
800
+
801
+ /**
802
+ * Thread pool for managing multiple threads across multiple users efficiently
803
+ */
804
+ declare class ThreadPool {
805
+ private client;
806
+ private managers;
807
+ constructor(client: PaprFlare);
495
808
  /**
496
- * List all threads for a user
809
+ * Get or create a thread manager for a user
497
810
  */
498
- getUserThreads(userId: string): Thread[];
811
+ getManager(userId: string): ThreadManager;
499
812
  /**
500
- * Add message to thread
813
+ * Check if a manager exists for a user
501
814
  */
502
- addMessage(threadId: string, message: Message): Promise<void>;
815
+ hasManager(userId: string): boolean;
503
816
  /**
504
- * Delete a thread
817
+ * Remove and destroy a user's thread manager
505
818
  */
506
- deleteThread(threadId: string): void;
819
+ removeManager(userId: string): void;
507
820
  /**
508
- * Clear all messages in a thread
821
+ * List all user IDs that have active managers
509
822
  */
510
- clearThread(threadId: string): void;
823
+ listUsers(): string[];
511
824
  /**
512
- * Update thread status
825
+ * Total number of managers (users) in the pool
513
826
  */
514
- private updateThreadStatus;
827
+ managerCount(): number;
515
828
  /**
516
- * Update thread metadata
829
+ * Get all threads across all users
517
830
  */
518
- updateThreadMetadata(threadId: string, metadata: Record<string, unknown>): void;
831
+ getAllThreads(): Thread[];
519
832
  /**
520
- * Get thread statistics
833
+ * Get all active threads across all users
521
834
  */
522
- getStats(): {
523
- total: number;
524
- active: number;
525
- paused: number;
526
- completed: number;
527
- error: number;
528
- };
835
+ getAllActiveThreads(): Thread[];
529
836
  /**
530
- * Cleanup inactive threads
837
+ * Get all threads matching a filter across all users
531
838
  */
532
- cleanup(maxAge?: number): void;
533
- }
534
-
535
- /**
536
- * Thread pool for managing multiple threads efficiently
537
- */
538
- declare class ThreadPool {
539
- private client;
540
- private managers;
541
- constructor(client: PaprFlare);
839
+ findThreads(filter: ThreadFilter, options?: ThreadPaginationOptions): Thread[];
542
840
  /**
543
- * Get or create thread manager for a user
841
+ * Find a specific thread by ID across all users
544
842
  */
545
- getManager(userId: string): ThreadManager;
843
+ findThread(threadId: string): Thread | null;
546
844
  /**
547
- * Remove thread manager for a user
845
+ * Find which user owns a thread
548
846
  */
549
- removeManager(userId: string): void;
847
+ findThreadOwner(threadId: string): string | null;
550
848
  /**
551
- * Get all active threads across all users
849
+ * Aggregate stats across all users
552
850
  */
553
- getAllActiveThreads(): Thread[];
851
+ getGlobalStats(): ThreadStats & {
852
+ userCount: number;
853
+ };
854
+ /**
855
+ * Get per-user stats summary
856
+ */
857
+ getUserStats(): Record<string, ThreadStats>;
554
858
  /**
555
- * Cleanup all inactive threads
859
+ * Total thread count across all users
860
+ */
861
+ totalThreadCount(): number;
862
+ /**
863
+ * Cleanup inactive threads across all managers
556
864
  */
557
865
  cleanupAll(maxAge?: number): void;
866
+ /**
867
+ * Archive all completed or errored threads older than maxAge
868
+ */
869
+ archiveStale(maxAge?: number): number;
870
+ /**
871
+ * Delete all threads and managers for a user
872
+ */
873
+ deleteUser(userId: string): void;
874
+ /**
875
+ * Delete all threads and managers across the entire pool
876
+ */
877
+ purge(): void;
878
+ /**
879
+ * Export a thread by ID, searching across all managers
880
+ */
881
+ exportThread(threadId: string): ThreadExport | null;
882
+ /**
883
+ * Import a thread for a user
884
+ */
885
+ importThread(userId: string, data: ThreadExport): string;
886
+ /**
887
+ * Export all threads for a user
888
+ */
889
+ exportUserThreads(userId: string): ThreadExport[];
890
+ /**
891
+ * Import multiple threads for a user
892
+ */
893
+ importUserThreads(userId: string, exports: ThreadExport[]): string[];
558
894
  }
559
895
 
560
896
  /**
@@ -1158,4 +1494,4 @@ declare function streamToConsole(stream: AsyncGenerator<StreamEvent>, options?:
1158
1494
  */
1159
1495
  declare function toHTTPResponse(stream: AsyncGenerator<StreamEvent>, target?: any): Promise<Response | void>;
1160
1496
 
1161
- export { type AnthropicConfig, AnthropicProvider, type Artifact, type ArtifactMetadata, type CacheConfig, CacheManager, type CacheOptions, type ChatConfig, type ChatOptions, type ChatResponse, type ChatState, type CloudModeConfig, type CommonConfig, type Conversation, type DatabaseAdapter, DatabaseManager, DrizzleAdapter, type GoogleConfig, GoogleProvider, type ICache, MemoryAdapter, MemoryCache, type Message, type OpenAIConfig, OpenAIProvider, PaprFlare, type PaprFlareConfig, PaprFlareError, PrismaAdapter, type ProviderCallback, type ProviderConfig, ProviderError, RateLimitError, RedisCache, type SarvamConfig, SarvamProvider, type SelfManagedConfig, type StreamEvent, type StreamHandlers, StreamWriter, type StreamingChatResponse, type Thread, type ThreadEvent, ThreadManager, ThreadPool, type TokenUsage, type Tool, type ToolCall, type ToolResult, type UIMessage, type UIStreamEvent, type UsePaprFlareConfig, ValidationError, batchStream, chunk, collectStream, collectText, createAnthropicProvider, createCacheKey, createGoogleProvider, createOpenAIProvider, createSarvamProvider, createStreamWriter, createUIMessageStream, debounce, deepMerge, filterStream, formatMessages, generateId, isPlainObject, measureTime, mergeStreams, parseSSEStream, pipeToResponse, processStream, retry, safeJsonParse, sleep, streamToArray, streamToConsole, structuredOutput, takeStream, throttle, toHTTPResponse, toReadableStream, toUIStream, transformStream };
1497
+ export { type AnthropicConfig, AnthropicProvider, type Artifact, type ArtifactMetadata, type CacheConfig, CacheManager, type CacheOptions, type ChatConfig, type ChatOptions, type ChatResponse, type ChatState, type CloudModeConfig, type CommonConfig, type Conversation, type ConversationExport, type DatabaseAdapter, DatabaseManager, DrizzleAdapter, type GoogleConfig, GoogleProvider, type ICache, MemoryAdapter, MemoryCache, type Message, type OpenAIConfig, OpenAIProvider, PaprFlare, type PaprFlareConfig, PaprFlareError, PrismaAdapter, type ProviderCallback, type ProviderConfig, ProviderError, RateLimitError, RedisCache, type SarvamConfig, SarvamProvider, type SelfManagedConfig, type StreamEvent, type StreamHandlers, StreamWriter, type StreamingChatResponse, type Thread, type ThreadEvent, type ThreadExport, type ThreadFilter, ThreadManager, type ThreadPaginationOptions, ThreadPool, type ThreadSortOptions, type ThreadStats, type TokenUsage, type Tool, type ToolCall, type ToolResult, type UIMessage, type UIStreamEvent, type UsePaprFlareConfig, ValidationError, batchStream, chunk, collectStream, collectText, createAnthropicProvider, createCacheKey, createGoogleProvider, createOpenAIProvider, createSarvamProvider, createStreamWriter, createUIMessageStream, debounce, deepMerge, filterStream, formatMessages, generateId, isPlainObject, measureTime, mergeStreams, parseSSEStream, pipeToResponse, processStream, retry, safeJsonParse, sleep, streamToArray, streamToConsole, structuredOutput, takeStream, throttle, toHTTPResponse, toReadableStream, toUIStream, transformStream };