paprflare-sdk 0.0.32 → 0.0.33
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 +3 -498
- package/dist/index.d.ts +3 -498
- package/dist/index.js +17 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import
|
|
2
|
+
import { EventEmitter } from 'eventemitter3';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Database adapter interface
|
|
@@ -51,164 +51,6 @@ interface ConversationExport {
|
|
|
51
51
|
exportedAt: Date;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
/**
|
|
55
|
-
* Drizzle ORM adapter
|
|
56
|
-
*/
|
|
57
|
-
declare class DrizzleAdapter implements DatabaseAdapter {
|
|
58
|
-
private db;
|
|
59
|
-
private schema;
|
|
60
|
-
constructor(db: any, schema: any);
|
|
61
|
-
connect(): Promise<void>;
|
|
62
|
-
disconnect(): Promise<void>;
|
|
63
|
-
healthCheck(): Promise<boolean>;
|
|
64
|
-
purge(): Promise<void>;
|
|
65
|
-
createConversation(userId: string, metadata?: Record<string, unknown>): Promise<string>;
|
|
66
|
-
getConversation(conversationId: string): Promise<Conversation | null>;
|
|
67
|
-
listConversations(userId: string, limit?: number, offset?: number): Promise<Conversation[]>;
|
|
68
|
-
updateConversation(conversationId: string, updates: Partial<Conversation>): Promise<void>;
|
|
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[]>;
|
|
74
|
-
saveMessage(conversationId: string, message: Message): Promise<void>;
|
|
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[]>;
|
|
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[]>;
|
|
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>;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Database manager with automatic persistence
|
|
96
|
-
*/
|
|
97
|
-
declare class DatabaseManager {
|
|
98
|
-
private adapter;
|
|
99
|
-
constructor(adapter: DatabaseAdapter);
|
|
100
|
-
connect(): Promise<void>;
|
|
101
|
-
disconnect(): Promise<void>;
|
|
102
|
-
healthCheck(): Promise<boolean>;
|
|
103
|
-
purge(): Promise<void>;
|
|
104
|
-
create(userId: 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>;
|
|
108
|
-
deleteConversation(conversationId: string): Promise<void>;
|
|
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>;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Simple in-memory adapter for development
|
|
135
|
-
*/
|
|
136
|
-
declare class MemoryAdapter implements DatabaseAdapter {
|
|
137
|
-
private conversations;
|
|
138
|
-
private messages;
|
|
139
|
-
connect(): Promise<void>;
|
|
140
|
-
disconnect(): Promise<void>;
|
|
141
|
-
healthCheck(): Promise<boolean>;
|
|
142
|
-
purge(): Promise<void>;
|
|
143
|
-
createConversation(userId: string, metadata?: Record<string, unknown>): Promise<string>;
|
|
144
|
-
getConversation(conversationId: string): Promise<Conversation | null>;
|
|
145
|
-
listConversations(userId: string, limit?: number, offset?: number): Promise<Conversation[]>;
|
|
146
|
-
updateConversation(conversationId: string, updates: Partial<Conversation>): Promise<void>;
|
|
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[]>;
|
|
152
|
-
saveMessage(conversationId: string, message: Message): Promise<void>;
|
|
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[]>;
|
|
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[]>;
|
|
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>;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Prisma database adapter
|
|
174
|
-
*/
|
|
175
|
-
declare class PrismaAdapter implements DatabaseAdapter {
|
|
176
|
-
private prisma;
|
|
177
|
-
constructor(prisma: any);
|
|
178
|
-
connect(): Promise<void>;
|
|
179
|
-
disconnect(): Promise<void>;
|
|
180
|
-
healthCheck(): Promise<boolean>;
|
|
181
|
-
purge(): Promise<void>;
|
|
182
|
-
createConversation(userId: string, metadata?: Record<string, unknown>): Promise<string>;
|
|
183
|
-
getConversation(conversationId: string): Promise<Conversation | null>;
|
|
184
|
-
listConversations(userId: string, limit?: number, offset?: number): Promise<Conversation[]>;
|
|
185
|
-
updateConversation(conversationId: string, updates: Partial<Conversation>): Promise<void>;
|
|
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;
|
|
192
|
-
saveMessage(conversationId: string, message: Message): Promise<void>;
|
|
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[]>;
|
|
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[]>;
|
|
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>;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
54
|
/**
|
|
213
55
|
* Logging System for PaprFlare SDK
|
|
214
56
|
* Structured logging with different levels and metadata
|
|
@@ -613,341 +455,12 @@ declare class CacheManager {
|
|
|
613
455
|
enable(): void;
|
|
614
456
|
}
|
|
615
457
|
|
|
616
|
-
/**
|
|
617
|
-
* Thread represents a conversation thread
|
|
618
|
-
*/
|
|
619
|
-
interface Thread {
|
|
620
|
-
id: string;
|
|
621
|
-
userId: string;
|
|
622
|
-
messages: Message[];
|
|
623
|
-
config?: ChatConfig;
|
|
624
|
-
metadata: Record<string, unknown>;
|
|
625
|
-
tags: string[];
|
|
626
|
-
title?: string;
|
|
627
|
-
createdAt: number;
|
|
628
|
-
updatedAt: number;
|
|
629
|
-
lastActiveAt: number;
|
|
630
|
-
status: 'active' | 'paused' | 'completed' | 'error' | 'archived';
|
|
631
|
-
priority: 'low' | 'normal' | 'high';
|
|
632
|
-
messageCount: number;
|
|
633
|
-
tokenCount?: number;
|
|
634
|
-
errorCount: number;
|
|
635
|
-
lastError?: string;
|
|
636
|
-
}
|
|
637
|
-
/**
|
|
638
|
-
* Thread filter options
|
|
639
|
-
*/
|
|
640
|
-
interface ThreadFilter {
|
|
641
|
-
status?: Thread['status'] | Thread['status'][];
|
|
642
|
-
priority?: Thread['priority'];
|
|
643
|
-
tags?: string[];
|
|
644
|
-
createdAfter?: number;
|
|
645
|
-
createdBefore?: number;
|
|
646
|
-
updatedAfter?: number;
|
|
647
|
-
search?: string;
|
|
648
|
-
}
|
|
649
|
-
/**
|
|
650
|
-
* Thread sort options
|
|
651
|
-
*/
|
|
652
|
-
interface ThreadSortOptions {
|
|
653
|
-
field: 'createdAt' | 'updatedAt' | 'lastActiveAt' | 'messageCount' | 'priority';
|
|
654
|
-
direction: 'asc' | 'desc';
|
|
655
|
-
}
|
|
656
|
-
/**
|
|
657
|
-
* Thread pagination options
|
|
658
|
-
*/
|
|
659
|
-
interface ThreadPaginationOptions {
|
|
660
|
-
limit?: number;
|
|
661
|
-
offset?: number;
|
|
662
|
-
sort?: ThreadSortOptions;
|
|
663
|
-
}
|
|
664
|
-
/**
|
|
665
|
-
* Thread statistics
|
|
666
|
-
*/
|
|
667
|
-
interface ThreadStats {
|
|
668
|
-
total: number;
|
|
669
|
-
active: number;
|
|
670
|
-
paused: number;
|
|
671
|
-
completed: number;
|
|
672
|
-
error: number;
|
|
673
|
-
archived: number;
|
|
674
|
-
totalMessages: number;
|
|
675
|
-
totalTokens: number;
|
|
676
|
-
averageMessagesPerThread: number;
|
|
677
|
-
oldestThread?: number;
|
|
678
|
-
newestThread?: number;
|
|
679
|
-
}
|
|
680
|
-
/**
|
|
681
|
-
* Thread export format
|
|
682
|
-
*/
|
|
683
|
-
interface ThreadExport {
|
|
684
|
-
thread: Thread;
|
|
685
|
-
messages: Message[];
|
|
686
|
-
exportedAt: number;
|
|
687
|
-
version: string;
|
|
688
|
-
}
|
|
689
|
-
/**
|
|
690
|
-
* Thread events
|
|
691
|
-
*/
|
|
692
|
-
type ThreadEvent = {
|
|
693
|
-
type: 'thread-created';
|
|
694
|
-
threadId: string;
|
|
695
|
-
thread: Thread;
|
|
696
|
-
} | {
|
|
697
|
-
type: 'thread-deleted';
|
|
698
|
-
threadId: string;
|
|
699
|
-
} | {
|
|
700
|
-
type: 'thread-archived';
|
|
701
|
-
threadId: string;
|
|
702
|
-
} | {
|
|
703
|
-
type: 'thread-restored';
|
|
704
|
-
threadId: string;
|
|
705
|
-
} | {
|
|
706
|
-
type: 'thread-cleared';
|
|
707
|
-
threadId: string;
|
|
708
|
-
} | {
|
|
709
|
-
type: 'thread-merged';
|
|
710
|
-
threadId: string;
|
|
711
|
-
sourceThreadId: string;
|
|
712
|
-
} | {
|
|
713
|
-
type: 'thread-forked';
|
|
714
|
-
threadId: string;
|
|
715
|
-
parentThreadId: string;
|
|
716
|
-
} | {
|
|
717
|
-
type: 'message-added';
|
|
718
|
-
threadId: string;
|
|
719
|
-
message: Message;
|
|
720
|
-
} | {
|
|
721
|
-
type: 'message-updated';
|
|
722
|
-
threadId: string;
|
|
723
|
-
messageId: string;
|
|
724
|
-
updates: Partial<Message>;
|
|
725
|
-
} | {
|
|
726
|
-
type: 'message-deleted';
|
|
727
|
-
threadId: string;
|
|
728
|
-
messageId: string;
|
|
729
|
-
} | {
|
|
730
|
-
type: 'messages-cleared';
|
|
731
|
-
threadId: string;
|
|
732
|
-
} | {
|
|
733
|
-
type: 'stream-started';
|
|
734
|
-
threadId: string;
|
|
735
|
-
} | {
|
|
736
|
-
type: 'stream-event';
|
|
737
|
-
threadId: string;
|
|
738
|
-
event: StreamEvent;
|
|
739
|
-
} | {
|
|
740
|
-
type: 'stream-completed';
|
|
741
|
-
threadId: string;
|
|
742
|
-
message: Message;
|
|
743
|
-
} | {
|
|
744
|
-
type: 'stream-error';
|
|
745
|
-
threadId: string;
|
|
746
|
-
error: Error;
|
|
747
|
-
} | {
|
|
748
|
-
type: 'status-changed';
|
|
749
|
-
threadId: string;
|
|
750
|
-
status: Thread['status'];
|
|
751
|
-
previousStatus: Thread['status'];
|
|
752
|
-
} | {
|
|
753
|
-
type: 'priority-changed';
|
|
754
|
-
threadId: string;
|
|
755
|
-
priority: Thread['priority'];
|
|
756
|
-
} | {
|
|
757
|
-
type: 'metadata-updated';
|
|
758
|
-
threadId: string;
|
|
759
|
-
metadata: Record<string, unknown>;
|
|
760
|
-
} | {
|
|
761
|
-
type: 'tags-updated';
|
|
762
|
-
threadId: string;
|
|
763
|
-
tags: string[];
|
|
764
|
-
} | {
|
|
765
|
-
type: 'title-updated';
|
|
766
|
-
threadId: string;
|
|
767
|
-
title: string;
|
|
768
|
-
} | {
|
|
769
|
-
type: 'config-updated';
|
|
770
|
-
threadId: string;
|
|
771
|
-
config: ChatConfig;
|
|
772
|
-
} | {
|
|
773
|
-
type: 'error';
|
|
774
|
-
threadId: string;
|
|
775
|
-
error: Error;
|
|
776
|
-
} | {
|
|
777
|
-
type: 'cleanup';
|
|
778
|
-
deletedCount: number;
|
|
779
|
-
} | {
|
|
780
|
-
type: 'pool-stats';
|
|
781
|
-
stats: ThreadStats;
|
|
782
|
-
};
|
|
783
|
-
|
|
784
|
-
/**
|
|
785
|
-
* Thread Manager for handling multiple concurrent conversations
|
|
786
|
-
* Optimized for high throughput with event-driven architecture
|
|
787
|
-
*/
|
|
788
|
-
declare class ThreadManager extends EventEmitter {
|
|
789
|
-
private client;
|
|
790
|
-
threads: Map<string, Thread>;
|
|
791
|
-
constructor(client: PaprFlare);
|
|
792
|
-
createThread(userId: string, config?: ChatConfig, metadata?: Record<string, unknown>, options?: {
|
|
793
|
-
title?: string;
|
|
794
|
-
tags?: string[];
|
|
795
|
-
priority?: Thread['priority'];
|
|
796
|
-
}): Promise<string>;
|
|
797
|
-
/**
|
|
798
|
-
* Fork a thread — creates a new thread with a copy of messages up to a given point
|
|
799
|
-
*/
|
|
800
|
-
forkThread(threadId: string, upToMessageId?: string): Promise<string>;
|
|
801
|
-
/**
|
|
802
|
-
* Merge another thread's messages into this thread
|
|
803
|
-
*/
|
|
804
|
-
mergeThread(targetThreadId: string, sourceThreadId: string): Promise<void>;
|
|
805
|
-
getThread(threadId: string): Thread | null;
|
|
806
|
-
threadExists(threadId: string): boolean;
|
|
807
|
-
getUserThreads(userId: string, options?: ThreadPaginationOptions): Thread[];
|
|
808
|
-
filterThreads(userId: string, filter: ThreadFilter, options?: ThreadPaginationOptions): Thread[];
|
|
809
|
-
countThreads(userId: string, filter?: ThreadFilter): number;
|
|
810
|
-
updateThreadStatus(threadId: string, status: Thread['status']): void;
|
|
811
|
-
updateThreadPriority(threadId: string, priority: Thread['priority']): void;
|
|
812
|
-
updateThreadMetadata(threadId: string, metadata: Record<string, unknown>): void;
|
|
813
|
-
setThreadTitle(threadId: string, title: string): void;
|
|
814
|
-
updateThreadConfig(threadId: string, config: Partial<ChatConfig>): void;
|
|
815
|
-
addTags(threadId: string, tags: string[]): void;
|
|
816
|
-
removeTags(threadId: string, tags: string[]): void;
|
|
817
|
-
setTags(threadId: string, tags: string[]): void;
|
|
818
|
-
addMessage(threadId: string, message: Message): Promise<void>;
|
|
819
|
-
addManyMessages(threadId: string, messages: Message[]): Promise<void>;
|
|
820
|
-
getMessage(threadId: string, messageId: string): Message | null;
|
|
821
|
-
getMessages(threadId: string, options?: {
|
|
822
|
-
limit?: number;
|
|
823
|
-
offset?: number;
|
|
824
|
-
role?: Message['role'];
|
|
825
|
-
}): Message[];
|
|
826
|
-
getLastMessage(threadId: string): Message | null;
|
|
827
|
-
updateMessage(threadId: string, messageId: string, updates: Partial<Message>): void;
|
|
828
|
-
deleteMessage(threadId: string, messageId: string): void;
|
|
829
|
-
searchMessages(threadId: string, query: string): Message[];
|
|
830
|
-
clearThread(threadId: string): void;
|
|
831
|
-
trimThread(threadId: string, keepLast: number): void;
|
|
832
|
-
archiveThread(threadId: string): void;
|
|
833
|
-
restoreThread(threadId: string): void;
|
|
834
|
-
pauseThread(threadId: string): void;
|
|
835
|
-
resumeThread(threadId: string): void;
|
|
836
|
-
completeThread(threadId: string): void;
|
|
837
|
-
markThreadError(threadId: string, error: Error): void;
|
|
838
|
-
deleteThread(threadId: string): void;
|
|
839
|
-
deleteAllThreads(userId: string): void;
|
|
840
|
-
getStats(userId?: string): ThreadStats;
|
|
841
|
-
exportThread(threadId: string): ThreadExport;
|
|
842
|
-
importThread(userId: string, data: ThreadExport): string;
|
|
843
|
-
cleanup(maxAge?: number): void;
|
|
844
|
-
private requireThread;
|
|
845
|
-
private sortThreads;
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
/**
|
|
849
|
-
* Thread pool for managing multiple threads across multiple users efficiently
|
|
850
|
-
*/
|
|
851
|
-
declare class ThreadPool {
|
|
852
|
-
private client;
|
|
853
|
-
private managers;
|
|
854
|
-
constructor(client: PaprFlare);
|
|
855
|
-
/**
|
|
856
|
-
* Get or create a thread manager for a user
|
|
857
|
-
*/
|
|
858
|
-
getManager(userId: string): ThreadManager;
|
|
859
|
-
/**
|
|
860
|
-
* Check if a manager exists for a user
|
|
861
|
-
*/
|
|
862
|
-
hasManager(userId: string): boolean;
|
|
863
|
-
/**
|
|
864
|
-
* Remove and destroy a user's thread manager
|
|
865
|
-
*/
|
|
866
|
-
removeManager(userId: string): void;
|
|
867
|
-
/**
|
|
868
|
-
* List all user IDs that have active managers
|
|
869
|
-
*/
|
|
870
|
-
listUsers(): string[];
|
|
871
|
-
/**
|
|
872
|
-
* Total number of managers (users) in the pool
|
|
873
|
-
*/
|
|
874
|
-
managerCount(): number;
|
|
875
|
-
/**
|
|
876
|
-
* Get all threads across all users
|
|
877
|
-
*/
|
|
878
|
-
getAllThreads(): Thread[];
|
|
879
|
-
/**
|
|
880
|
-
* Get all active threads across all users
|
|
881
|
-
*/
|
|
882
|
-
getAllActiveThreads(): Thread[];
|
|
883
|
-
/**
|
|
884
|
-
* Get all threads matching a filter across all users
|
|
885
|
-
*/
|
|
886
|
-
findThreads(filter: ThreadFilter, options?: ThreadPaginationOptions): Thread[];
|
|
887
|
-
/**
|
|
888
|
-
* Find a specific thread by ID across all users
|
|
889
|
-
*/
|
|
890
|
-
findThread(threadId: string): Thread | null;
|
|
891
|
-
/**
|
|
892
|
-
* Find which user owns a thread
|
|
893
|
-
*/
|
|
894
|
-
findThreadOwner(threadId: string): string | null;
|
|
895
|
-
/**
|
|
896
|
-
* Aggregate stats across all users
|
|
897
|
-
*/
|
|
898
|
-
getGlobalStats(): ThreadStats & {
|
|
899
|
-
userCount: number;
|
|
900
|
-
};
|
|
901
|
-
/**
|
|
902
|
-
* Get per-user stats summary
|
|
903
|
-
*/
|
|
904
|
-
getUserStats(): Record<string, ThreadStats>;
|
|
905
|
-
/**
|
|
906
|
-
* Total thread count across all users
|
|
907
|
-
*/
|
|
908
|
-
totalThreadCount(): number;
|
|
909
|
-
/**
|
|
910
|
-
* Cleanup inactive threads across all managers
|
|
911
|
-
*/
|
|
912
|
-
cleanupAll(maxAge?: number): void;
|
|
913
|
-
/**
|
|
914
|
-
* Archive all completed or errored threads older than maxAge
|
|
915
|
-
*/
|
|
916
|
-
archiveStale(maxAge?: number): number;
|
|
917
|
-
/**
|
|
918
|
-
* Delete all threads and managers for a user
|
|
919
|
-
*/
|
|
920
|
-
deleteUser(userId: string): void;
|
|
921
|
-
/**
|
|
922
|
-
* Delete all threads and managers across the entire pool
|
|
923
|
-
*/
|
|
924
|
-
purge(): void;
|
|
925
|
-
/**
|
|
926
|
-
* Export a thread by ID, searching across all managers
|
|
927
|
-
*/
|
|
928
|
-
exportThread(threadId: string): ThreadExport | null;
|
|
929
|
-
/**
|
|
930
|
-
* Import a thread for a user
|
|
931
|
-
*/
|
|
932
|
-
importThread(userId: string, data: ThreadExport): string;
|
|
933
|
-
/**
|
|
934
|
-
* Export all threads for a user
|
|
935
|
-
*/
|
|
936
|
-
exportUserThreads(userId: string): ThreadExport[];
|
|
937
|
-
/**
|
|
938
|
-
* Import multiple threads for a user
|
|
939
|
-
*/
|
|
940
|
-
importUserThreads(userId: string, exports: ThreadExport[]): string[];
|
|
941
|
-
}
|
|
942
|
-
|
|
943
458
|
/**
|
|
944
459
|
* Main PaprFlare client with automatic type inference
|
|
945
460
|
*/
|
|
946
461
|
declare class PaprFlare {
|
|
947
462
|
private providerCallback;
|
|
948
463
|
private cacheManager?;
|
|
949
|
-
private databaseManager?;
|
|
950
|
-
private threadManager?;
|
|
951
464
|
private queue;
|
|
952
465
|
private mutex;
|
|
953
466
|
private logger;
|
|
@@ -1010,14 +523,6 @@ declare class PaprFlare {
|
|
|
1010
523
|
* Validate configuration
|
|
1011
524
|
*/
|
|
1012
525
|
private validateConfig;
|
|
1013
|
-
/**
|
|
1014
|
-
* Get database manager
|
|
1015
|
-
*/
|
|
1016
|
-
get database(): DatabaseManager | undefined;
|
|
1017
|
-
/**
|
|
1018
|
-
* Get thread manager
|
|
1019
|
-
*/
|
|
1020
|
-
get threads(): ThreadManager;
|
|
1021
526
|
/**
|
|
1022
527
|
* Get queue statistics
|
|
1023
528
|
*/
|
|
@@ -1315,7 +820,7 @@ interface ChunkData {
|
|
|
1315
820
|
* StreamWriter for handling streaming text and tool execution
|
|
1316
821
|
* Provides real-time events for live UI updates
|
|
1317
822
|
*/
|
|
1318
|
-
declare class StreamWriter extends EventEmitter
|
|
823
|
+
declare class StreamWriter extends EventEmitter<StreamWriterEvents> {
|
|
1319
824
|
private events;
|
|
1320
825
|
private closed;
|
|
1321
826
|
private fullText;
|
|
@@ -1655,4 +1160,4 @@ declare function createStreamableValue<T = any>(initialValue?: T): {
|
|
|
1655
1160
|
error(error: string): void;
|
|
1656
1161
|
};
|
|
1657
1162
|
|
|
1658
|
-
export { type AnthropicConfig, AnthropicProvider, type Artifact, type ArtifactMetadata, type CacheConfig, CacheManager, type CacheOptions, type ChatConfig, type ChatOptions, type ChatResponse, type ChatState, type
|
|
1163
|
+
export { type AnthropicConfig, AnthropicProvider, type Artifact, type ArtifactMetadata, type CacheConfig, CacheManager, type CacheOptions, type ChatConfig, type ChatOptions, type ChatResponse, type ChatState, type GoogleConfig, GoogleProvider, type ICache, MemoryCache, type Message, type OpenAIConfig, OpenAIProvider, PaprFlare, type PaprFlareConfig, PaprFlareError, type ProviderCallback, type ProviderConfig, ProviderError, RateLimitError, RedisCache, type SarvamConfig, SarvamProvider, type StreamEvent, type StreamHandlers, StreamWriter, type StreamingChatResponse, 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, createStreamableValue, createUIMessageStream, debounce, deepMerge, filterStream, formatMessages, generateId, isPlainObject, measureTime, mergeStreams, parseSSEStream, pipeToResponse, processStream, retry, safeJsonParse, sleep, streamToArray, streamToConsole, structuredOutput, takeStream, throttle, toHTTPResponse, toReadableStream, toUIStream, transformStream };
|