@leeoohoo/aichat 1.0.0
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 +274 -0
- package/dist/index.cjs.js +70 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.css +10 -0
- package/dist/index.d.ts +746 -0
- package/dist/index.esm.js +15617 -0
- package/dist/index.esm.js.map +1 -0
- package/package.json +190 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,746 @@
|
|
|
1
|
+
import { ClassValue } from 'clsx';
|
|
2
|
+
import { Component } from 'react';
|
|
3
|
+
import { default as default_2 } from 'react';
|
|
4
|
+
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
5
|
+
import { PersistOptions } from 'zustand/middleware';
|
|
6
|
+
import { ReactNode } from 'react';
|
|
7
|
+
import { StoreApi } from 'zustand';
|
|
8
|
+
import { UseBoundStore } from 'zustand';
|
|
9
|
+
import { WritableDraft } from 'immer';
|
|
10
|
+
|
|
11
|
+
export declare interface AiClientConfig {
|
|
12
|
+
apiKey: string;
|
|
13
|
+
baseUrl?: string;
|
|
14
|
+
model: string;
|
|
15
|
+
temperature: number;
|
|
16
|
+
maxTokens: number;
|
|
17
|
+
systemPrompt?: string;
|
|
18
|
+
enableStreaming: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export declare interface AiModelConfig {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
base_url: string;
|
|
25
|
+
api_key: string;
|
|
26
|
+
model_name: string;
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
createdAt: Date;
|
|
29
|
+
updatedAt: Date;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export declare const AiModelManager: default_2.FC<AiModelManagerProps>;
|
|
33
|
+
|
|
34
|
+
declare interface AiModelManagerProps {
|
|
35
|
+
onClose: () => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 错误处理工具
|
|
40
|
+
*/
|
|
41
|
+
export declare class AppError extends Error {
|
|
42
|
+
readonly code: string;
|
|
43
|
+
readonly statusCode: number;
|
|
44
|
+
constructor(message: string, code?: string, statusCode?: number);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export declare interface Attachment {
|
|
48
|
+
id: string;
|
|
49
|
+
messageId: string;
|
|
50
|
+
type: AttachmentType;
|
|
51
|
+
name: string;
|
|
52
|
+
url: string;
|
|
53
|
+
size: number;
|
|
54
|
+
mimeType: string;
|
|
55
|
+
createdAt: Date;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export declare const AttachmentRenderer: default_2.FC<AttachmentRendererProps>;
|
|
59
|
+
|
|
60
|
+
declare interface AttachmentRendererProps {
|
|
61
|
+
attachment: Attachment;
|
|
62
|
+
customRenderer?: (attachment: Attachment) => default_2.ReactNode;
|
|
63
|
+
className?: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export declare type AttachmentType = 'image' | 'file' | 'audio';
|
|
67
|
+
|
|
68
|
+
declare interface ChatActions {
|
|
69
|
+
loadSessions: () => Promise<void>;
|
|
70
|
+
createSession: (title?: string) => Promise<string>;
|
|
71
|
+
selectSession: (sessionId: string) => Promise<void>;
|
|
72
|
+
updateSession: (sessionId: string, updates: Partial<Session>) => Promise<void>;
|
|
73
|
+
deleteSession: (sessionId: string) => Promise<void>;
|
|
74
|
+
loadMessages: (sessionId: string) => Promise<void>;
|
|
75
|
+
sendMessage: (content: string, attachments?: any[]) => Promise<void>;
|
|
76
|
+
updateMessage: (messageId: string, updates: Partial<Message>) => Promise<void>;
|
|
77
|
+
deleteMessage: (messageId: string) => Promise<void>;
|
|
78
|
+
startStreaming: (messageId: string) => void;
|
|
79
|
+
updateStreamingMessage: (content: string) => void;
|
|
80
|
+
stopStreaming: () => void;
|
|
81
|
+
toggleSidebar: () => void;
|
|
82
|
+
setTheme: (theme: Theme) => void;
|
|
83
|
+
updateChatConfig: (config: Partial<ChatConfig>) => Promise<void>;
|
|
84
|
+
loadMcpConfigs: () => Promise<void>;
|
|
85
|
+
updateMcpConfig: (config: McpConfig) => Promise<void>;
|
|
86
|
+
deleteMcpConfig: (id: string) => Promise<void>;
|
|
87
|
+
loadAiModelConfigs: () => Promise<void>;
|
|
88
|
+
updateAiModelConfig: (config: AiModelConfig) => Promise<void>;
|
|
89
|
+
deleteAiModelConfig: (id: string) => Promise<void>;
|
|
90
|
+
setSelectedModel: (modelId: string | null) => void;
|
|
91
|
+
loadSystemContext: () => Promise<void>;
|
|
92
|
+
updateSystemContext: (content: string) => Promise<void>;
|
|
93
|
+
setError: (error: string | null) => void;
|
|
94
|
+
clearError: () => void;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export declare interface ChatConfig {
|
|
98
|
+
model: string;
|
|
99
|
+
temperature: number;
|
|
100
|
+
maxTokens: number;
|
|
101
|
+
systemPrompt: string;
|
|
102
|
+
enableMcp: boolean;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 聊天配置接口
|
|
107
|
+
*/
|
|
108
|
+
declare interface ChatConfig_2 {
|
|
109
|
+
model: string;
|
|
110
|
+
temperature: number;
|
|
111
|
+
maxTokens: number;
|
|
112
|
+
apiKey: string;
|
|
113
|
+
baseUrl: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export declare interface ChatError {
|
|
117
|
+
code: string;
|
|
118
|
+
message: string;
|
|
119
|
+
details?: Record<string, any>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export declare interface ChatEvents {
|
|
123
|
+
onMessageReceived: (message: Message) => void;
|
|
124
|
+
onMessageUpdated: (message: Message) => void;
|
|
125
|
+
onSessionCreated: (session: Session) => void;
|
|
126
|
+
onSessionUpdated: (session: Session) => void;
|
|
127
|
+
onError: (error: ChatError) => void;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export declare const ChatIcon: default_2.FC<{
|
|
131
|
+
className?: string;
|
|
132
|
+
}>;
|
|
133
|
+
|
|
134
|
+
export declare const ChatInterface: default_2.FC<ChatInterfaceProps>;
|
|
135
|
+
|
|
136
|
+
export declare interface ChatInterfaceProps {
|
|
137
|
+
className?: string;
|
|
138
|
+
onSessionChange?: (sessionId: string) => void;
|
|
139
|
+
onMessageSend?: (content: string, attachments?: Attachment[]) => void;
|
|
140
|
+
customRenderer?: {
|
|
141
|
+
renderMessage?: (message: Message) => ReactNode;
|
|
142
|
+
renderAttachment?: (attachment: Attachment) => ReactNode;
|
|
143
|
+
renderToolCall?: (toolCall: ToolCall) => ReactNode;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export declare interface ChatPlugin {
|
|
148
|
+
name: string;
|
|
149
|
+
version: string;
|
|
150
|
+
initialize: (config: Record<string, any>) => Promise<void>;
|
|
151
|
+
destroy: () => Promise<void>;
|
|
152
|
+
onMessage?: (message: Message) => Promise<Message | null>;
|
|
153
|
+
onToolCall?: (toolCall: ToolCall) => Promise<any>;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* 聊天服务管理器
|
|
158
|
+
*/
|
|
159
|
+
export declare class ChatService {
|
|
160
|
+
private currentAiClient;
|
|
161
|
+
private dbService;
|
|
162
|
+
constructor();
|
|
163
|
+
/**
|
|
164
|
+
* 发送消息并处理AI响应
|
|
165
|
+
*/
|
|
166
|
+
sendMessage(sessionId: string, content: string, _attachments?: any[], callbacks?: ChatServiceCallbacks, modelConfig?: {
|
|
167
|
+
model_name: string;
|
|
168
|
+
temperature: number;
|
|
169
|
+
max_tokens: number;
|
|
170
|
+
api_key: string;
|
|
171
|
+
base_url: string;
|
|
172
|
+
}): Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* 中止当前对话
|
|
175
|
+
*/
|
|
176
|
+
abortCurrentConversation(): void;
|
|
177
|
+
/**
|
|
178
|
+
* 获取聊天配置
|
|
179
|
+
*/
|
|
180
|
+
getChatConfig(): Promise<ChatConfig_2>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export declare const chatService: ChatService;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* 聊天服务回调类型
|
|
187
|
+
*/
|
|
188
|
+
export declare interface ChatServiceCallbacks {
|
|
189
|
+
onChunk?: (data: {
|
|
190
|
+
type: string;
|
|
191
|
+
content: string;
|
|
192
|
+
accumulated?: string;
|
|
193
|
+
}) => void;
|
|
194
|
+
onToolCall?: (toolCalls: any[]) => void;
|
|
195
|
+
onToolResult?: (results: any[]) => void;
|
|
196
|
+
onToolStreamChunk?: (data: {
|
|
197
|
+
toolCallId: string;
|
|
198
|
+
chunk: string;
|
|
199
|
+
}) => void;
|
|
200
|
+
onComplete?: (message: any) => void;
|
|
201
|
+
onError?: (error: Error) => void;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
declare interface ChatState {
|
|
205
|
+
sessions: Session[];
|
|
206
|
+
currentSessionId: string | null;
|
|
207
|
+
currentSession: Session | null;
|
|
208
|
+
messages: Message[];
|
|
209
|
+
isLoading: boolean;
|
|
210
|
+
isStreaming: boolean;
|
|
211
|
+
streamingMessageId: string | null;
|
|
212
|
+
sidebarOpen: boolean;
|
|
213
|
+
theme: Theme;
|
|
214
|
+
chatConfig: ChatConfig;
|
|
215
|
+
mcpConfigs: McpConfig[];
|
|
216
|
+
aiModelConfigs: AiModelConfig[];
|
|
217
|
+
selectedModelId: string | null;
|
|
218
|
+
systemContext: string | null;
|
|
219
|
+
error: string | null;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export declare const CheckIcon: default_2.FC<{
|
|
223
|
+
className?: string;
|
|
224
|
+
}>;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* 清理HTML内容
|
|
228
|
+
*/
|
|
229
|
+
export declare function cleanHtmlContent(content: string): string;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* 合并 Tailwind CSS 类名
|
|
233
|
+
*/
|
|
234
|
+
export declare function cn(...inputs: ClassValue[]): string;
|
|
235
|
+
|
|
236
|
+
export declare interface ContentSegment {
|
|
237
|
+
content: string | ToolCall;
|
|
238
|
+
type: 'text' | 'tool_call';
|
|
239
|
+
toolCallId?: string;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export declare const conversationsApi: {
|
|
243
|
+
getDetails(conversationId: string): Promise<{
|
|
244
|
+
data: {
|
|
245
|
+
conversation: {
|
|
246
|
+
id: any;
|
|
247
|
+
title: any;
|
|
248
|
+
created_at: any;
|
|
249
|
+
updated_at: any;
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
}>;
|
|
253
|
+
getAssistant(_conversationId: string): Promise<{
|
|
254
|
+
data: {
|
|
255
|
+
assistant: {
|
|
256
|
+
id: any;
|
|
257
|
+
name: any;
|
|
258
|
+
model_config: {
|
|
259
|
+
model_name: any;
|
|
260
|
+
temperature: number;
|
|
261
|
+
max_tokens: number;
|
|
262
|
+
api_key: any;
|
|
263
|
+
base_url: any;
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
}>;
|
|
268
|
+
getMcpServers(_conversationId?: string): Promise<{
|
|
269
|
+
data: {
|
|
270
|
+
mcp_servers: any;
|
|
271
|
+
};
|
|
272
|
+
}>;
|
|
273
|
+
saveMessage(conversationId: string, message: any): Promise<{
|
|
274
|
+
data: {
|
|
275
|
+
message: any;
|
|
276
|
+
};
|
|
277
|
+
}>;
|
|
278
|
+
getMessages(conversationId: string, _params?: any): Promise<{
|
|
279
|
+
data: {
|
|
280
|
+
messages: any;
|
|
281
|
+
};
|
|
282
|
+
}>;
|
|
283
|
+
addMessage(conversationId: string, message: any): Promise<{
|
|
284
|
+
data: {
|
|
285
|
+
message: any;
|
|
286
|
+
};
|
|
287
|
+
}>;
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* 复制文本到剪贴板
|
|
292
|
+
*/
|
|
293
|
+
export declare function copyToClipboard(text: string): Promise<boolean>;
|
|
294
|
+
|
|
295
|
+
export declare interface DatabaseOperations {
|
|
296
|
+
createSession: (title: string) => Promise<Session>;
|
|
297
|
+
getSession: (id: string) => Promise<Session | null>;
|
|
298
|
+
updateSession: (id: string, updates: Partial<Session>) => Promise<void>;
|
|
299
|
+
deleteSession: (id: string) => Promise<void>;
|
|
300
|
+
listSessions: () => Promise<Session[]>;
|
|
301
|
+
createMessage: (message: Omit<Message, 'id' | 'createdAt'>) => Promise<Message>;
|
|
302
|
+
getMessage: (id: string) => Promise<Message | null>;
|
|
303
|
+
updateMessage: (id: string, updates: Partial<Message>) => Promise<void>;
|
|
304
|
+
deleteMessage: (id: string) => Promise<void>;
|
|
305
|
+
getSessionMessages: (sessionId: string) => Promise<Message[]>;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
declare class DatabaseService {
|
|
309
|
+
constructor();
|
|
310
|
+
createSession(data: Omit<Session_2, 'id'>): Promise<Session_2>;
|
|
311
|
+
getSession(id: string): Promise<Session_2 | null>;
|
|
312
|
+
getAllSessions(): Promise<Session_2[]>;
|
|
313
|
+
updateSession(_id: string, _updates: Partial<Session_2>): Promise<Session_2 | null>;
|
|
314
|
+
deleteSession(id: string): Promise<boolean>;
|
|
315
|
+
createMessage(data: Omit<Message_2, 'id'>): Promise<Message_2>;
|
|
316
|
+
getSessionMessages(sessionId: string): Promise<Message_2[]>;
|
|
317
|
+
updateMessage(_id: string, _updates: Partial<Message_2>): Promise<Message_2 | null>;
|
|
318
|
+
deleteMessage(_id: string): Promise<boolean>;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export declare const databaseService: DatabaseService;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* 防抖函数
|
|
325
|
+
*/
|
|
326
|
+
export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void;
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* 深拷贝对象
|
|
330
|
+
*/
|
|
331
|
+
export declare function deepClone<T>(obj: T): T;
|
|
332
|
+
|
|
333
|
+
export declare const DotsVerticalIcon: default_2.FC<{
|
|
334
|
+
className?: string;
|
|
335
|
+
}>;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* 下载文件
|
|
339
|
+
*/
|
|
340
|
+
export declare function downloadFile(content: string, filename: string, mimeType?: string): void;
|
|
341
|
+
|
|
342
|
+
export declare class ErrorBoundary extends Component<Props, State> {
|
|
343
|
+
constructor(props: Props);
|
|
344
|
+
static getDerivedStateFromError(error: Error): State;
|
|
345
|
+
componentDidCatch(error: Error, errorInfo: any): void;
|
|
346
|
+
render(): string | number | boolean | Iterable<ReactNode> | JSX_2.Element | null | undefined;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* 格式化日期
|
|
351
|
+
*/
|
|
352
|
+
export declare function formatDate(date: Date | string | undefined): string;
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* 格式化日期时间
|
|
356
|
+
*/
|
|
357
|
+
export declare function formatDateTime(date: Date | string | undefined): string;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* 计算文件大小
|
|
361
|
+
*/
|
|
362
|
+
export declare function formatFileSize(bytes: number): string;
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* 格式化相对时间
|
|
366
|
+
*/
|
|
367
|
+
export declare function formatRelativeTime(date: Date | string | undefined): string;
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* 格式化时间
|
|
371
|
+
*/
|
|
372
|
+
export declare function formatTime(date: Date | string | undefined): string;
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* 生成唯一ID
|
|
376
|
+
*/
|
|
377
|
+
export declare function generateId(): string;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* 生成随机颜色
|
|
381
|
+
*/
|
|
382
|
+
export declare function generateRandomColor(): string;
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* 获取文件扩展名
|
|
386
|
+
*/
|
|
387
|
+
export declare function getFileExtension(filename: string): string;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* 获取操作系统
|
|
391
|
+
*/
|
|
392
|
+
export declare function getOS(): string;
|
|
393
|
+
|
|
394
|
+
export declare const InputArea: default_2.FC<InputAreaProps>;
|
|
395
|
+
|
|
396
|
+
export declare interface InputAreaProps {
|
|
397
|
+
onSend: (content: string, attachments?: File[]) => void;
|
|
398
|
+
disabled?: boolean;
|
|
399
|
+
placeholder?: string;
|
|
400
|
+
maxLength?: number;
|
|
401
|
+
allowAttachments?: boolean;
|
|
402
|
+
supportedFileTypes?: string[];
|
|
403
|
+
showModelSelector?: boolean;
|
|
404
|
+
selectedModelId?: string | null;
|
|
405
|
+
availableModels?: AiModelConfig[];
|
|
406
|
+
onModelChange?: (modelId: string | null) => void;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* 检查是否为图片文件
|
|
411
|
+
*/
|
|
412
|
+
export declare function isImageFile(filename: string): boolean;
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* 检查是否为移动设备
|
|
416
|
+
*/
|
|
417
|
+
export declare function isMobile(): boolean;
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* 验证邮箱格式
|
|
421
|
+
*/
|
|
422
|
+
export declare function isValidEmail(email: string): boolean;
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* 验证URL格式
|
|
426
|
+
*/
|
|
427
|
+
export declare function isValidUrl(url: string): boolean;
|
|
428
|
+
|
|
429
|
+
export declare const LoadingSpinner: default_2.FC<LoadingSpinnerProps>;
|
|
430
|
+
|
|
431
|
+
declare interface LoadingSpinnerProps {
|
|
432
|
+
size?: 'sm' | 'md' | 'lg';
|
|
433
|
+
className?: string;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export declare const MarkdownRenderer: default_2.FC<MarkdownRendererProps>;
|
|
437
|
+
|
|
438
|
+
declare interface MarkdownRendererProps {
|
|
439
|
+
content: string;
|
|
440
|
+
isStreaming?: boolean;
|
|
441
|
+
className?: string;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
export declare interface McpConfig {
|
|
445
|
+
id: string;
|
|
446
|
+
name: string;
|
|
447
|
+
serverUrl: string;
|
|
448
|
+
enabled: boolean;
|
|
449
|
+
config?: any;
|
|
450
|
+
createdAt: Date;
|
|
451
|
+
updatedAt: Date;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export declare const McpManager: default_2.FC<McpManagerProps>;
|
|
455
|
+
|
|
456
|
+
declare interface McpManagerProps {
|
|
457
|
+
onClose?: () => void;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
export declare interface McpToolConfig {
|
|
461
|
+
name: string;
|
|
462
|
+
serverUrl: string;
|
|
463
|
+
enabled: boolean;
|
|
464
|
+
timeout: number;
|
|
465
|
+
retryCount: number;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export declare interface Message {
|
|
469
|
+
id: string;
|
|
470
|
+
sessionId: string;
|
|
471
|
+
role: MessageRole;
|
|
472
|
+
content: string;
|
|
473
|
+
rawContent?: string;
|
|
474
|
+
summary?: string;
|
|
475
|
+
tokensUsed?: number;
|
|
476
|
+
status: MessageStatus;
|
|
477
|
+
createdAt: Date;
|
|
478
|
+
updatedAt?: Date;
|
|
479
|
+
metadata?: {
|
|
480
|
+
attachments?: Attachment[];
|
|
481
|
+
toolCalls?: ToolCall[];
|
|
482
|
+
contentSegments?: ContentSegment[];
|
|
483
|
+
currentSegmentIndex?: number;
|
|
484
|
+
model?: string;
|
|
485
|
+
summary?: string;
|
|
486
|
+
[key: string]: any;
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
declare interface Message_2 {
|
|
491
|
+
id: string;
|
|
492
|
+
sessionId: string;
|
|
493
|
+
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
494
|
+
content: string;
|
|
495
|
+
rawContent?: string;
|
|
496
|
+
tokensUsed?: number;
|
|
497
|
+
status: 'pending' | 'streaming' | 'completed' | 'error';
|
|
498
|
+
createdAt: Date;
|
|
499
|
+
updatedAt?: Date;
|
|
500
|
+
toolCallId?: string;
|
|
501
|
+
metadata?: {
|
|
502
|
+
attachments?: any[];
|
|
503
|
+
toolCalls?: any[];
|
|
504
|
+
model?: string;
|
|
505
|
+
[key: string]: any;
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
export declare const MessageItem: default_2.FC<MessageItemProps>;
|
|
510
|
+
|
|
511
|
+
declare interface MessageItemProps {
|
|
512
|
+
message: Message;
|
|
513
|
+
isLast?: boolean;
|
|
514
|
+
isStreaming?: boolean;
|
|
515
|
+
onEdit?: (messageId: string, content: string) => void;
|
|
516
|
+
onDelete?: (messageId: string) => void;
|
|
517
|
+
allMessages?: Message[];
|
|
518
|
+
customRenderer?: {
|
|
519
|
+
renderMessage?: (message: Message) => default_2.ReactNode;
|
|
520
|
+
renderAttachment?: (attachment: Attachment) => default_2.ReactNode;
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
export declare const MessageList: default_2.FC<MessageListProps>;
|
|
525
|
+
|
|
526
|
+
export declare interface MessageListProps {
|
|
527
|
+
messages: Message[];
|
|
528
|
+
isLoading?: boolean;
|
|
529
|
+
isStreaming?: boolean;
|
|
530
|
+
onMessageEdit?: (messageId: string, content: string) => void;
|
|
531
|
+
onMessageDelete?: (messageId: string) => void;
|
|
532
|
+
customRenderer?: {
|
|
533
|
+
renderMessage?: (message: Message) => ReactNode;
|
|
534
|
+
renderAttachment?: (attachment: Attachment) => ReactNode;
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
export declare type MessageRole = 'user' | 'assistant' | 'system' | 'tool';
|
|
539
|
+
|
|
540
|
+
export declare type MessageStatus = 'pending' | 'streaming' | 'completed' | 'error';
|
|
541
|
+
|
|
542
|
+
export declare const PencilIcon: default_2.FC<{
|
|
543
|
+
className?: string;
|
|
544
|
+
}>;
|
|
545
|
+
|
|
546
|
+
export declare const PlusIcon: default_2.FC<{
|
|
547
|
+
className?: string;
|
|
548
|
+
}>;
|
|
549
|
+
|
|
550
|
+
declare interface Props {
|
|
551
|
+
children: ReactNode;
|
|
552
|
+
fallback?: ReactNode;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
export declare interface QueryOptions {
|
|
556
|
+
limit?: number;
|
|
557
|
+
offset?: number;
|
|
558
|
+
sortBy?: string;
|
|
559
|
+
sortOrder?: 'asc' | 'desc';
|
|
560
|
+
filters?: Record<string, any>;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
export { ReactNode }
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* 重试函数
|
|
567
|
+
*/
|
|
568
|
+
export declare function retry<T>(fn: () => Promise<T>, maxAttempts?: number, delay?: number): Promise<T>;
|
|
569
|
+
|
|
570
|
+
export declare interface SearchResult<T> {
|
|
571
|
+
items: T[];
|
|
572
|
+
total: number;
|
|
573
|
+
hasMore: boolean;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
export declare interface Session {
|
|
577
|
+
id: string;
|
|
578
|
+
title: string;
|
|
579
|
+
createdAt: Date;
|
|
580
|
+
updatedAt: Date;
|
|
581
|
+
messageCount: number;
|
|
582
|
+
tokenUsage: number;
|
|
583
|
+
tags?: string | null;
|
|
584
|
+
pinned: boolean;
|
|
585
|
+
archived: boolean;
|
|
586
|
+
metadata?: string | null;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
declare interface Session_2 {
|
|
590
|
+
id: string;
|
|
591
|
+
title: string;
|
|
592
|
+
createdAt: Date;
|
|
593
|
+
updatedAt: Date;
|
|
594
|
+
messageCount: number;
|
|
595
|
+
tokenUsage: number;
|
|
596
|
+
tags?: string | null;
|
|
597
|
+
pinned: boolean;
|
|
598
|
+
archived: boolean;
|
|
599
|
+
metadata?: string | null;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
export declare const SessionList: default_2.FC<SessionListProps_2>;
|
|
603
|
+
|
|
604
|
+
export declare interface SessionListProps {
|
|
605
|
+
sessions: Session[];
|
|
606
|
+
currentSessionId?: string;
|
|
607
|
+
onSessionSelect: (sessionId: string) => void;
|
|
608
|
+
onSessionCreate: () => void;
|
|
609
|
+
onSessionDelete: (sessionId: string) => void;
|
|
610
|
+
onSessionRename: (sessionId: string, title: string) => void;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
declare interface SessionListProps_2 {
|
|
614
|
+
onClose?: () => void;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* 完全独立的聊天界面组件
|
|
619
|
+
* 支持自定义API端口和基础URL
|
|
620
|
+
*/
|
|
621
|
+
declare const StandaloneChatInterface: default_2.FC<StandaloneChatInterfaceProps>;
|
|
622
|
+
export { StandaloneChatInterface }
|
|
623
|
+
export default StandaloneChatInterface;
|
|
624
|
+
|
|
625
|
+
export declare interface StandaloneChatInterfaceProps {
|
|
626
|
+
className?: string;
|
|
627
|
+
apiBaseUrl?: string;
|
|
628
|
+
port?: number;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
declare interface State {
|
|
632
|
+
hasError: boolean;
|
|
633
|
+
error?: Error;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* 本地存储工具
|
|
638
|
+
*/
|
|
639
|
+
export declare const storage: {
|
|
640
|
+
get: <T>(key: string, defaultValue?: T) => T | null;
|
|
641
|
+
set: (key: string, value: any) => void;
|
|
642
|
+
remove: (key: string) => void;
|
|
643
|
+
clear: () => void;
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
export declare interface StreamResponse {
|
|
647
|
+
content: string;
|
|
648
|
+
done: boolean;
|
|
649
|
+
error?: string;
|
|
650
|
+
metadata?: Record<string, any>;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
export declare const SystemContextEditor: default_2.FC<SystemContextEditorProps>;
|
|
654
|
+
|
|
655
|
+
declare interface SystemContextEditorProps {
|
|
656
|
+
onClose?: () => void;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
export declare type Theme = 'light' | 'dark' | 'auto';
|
|
660
|
+
|
|
661
|
+
declare type Theme_2 = 'light' | 'dark' | 'system';
|
|
662
|
+
|
|
663
|
+
export declare const ThemeToggle: default_2.FC<ThemeToggleProps>;
|
|
664
|
+
|
|
665
|
+
declare interface ThemeToggleProps {
|
|
666
|
+
className?: string;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* 节流函数
|
|
671
|
+
*/
|
|
672
|
+
export declare function throttle<T extends (...args: any[]) => any>(func: T, limit: number): (...args: Parameters<T>) => void;
|
|
673
|
+
|
|
674
|
+
export declare interface ToolCall {
|
|
675
|
+
id: string;
|
|
676
|
+
messageId: string;
|
|
677
|
+
name: string;
|
|
678
|
+
arguments: Record<string, any>;
|
|
679
|
+
result?: any;
|
|
680
|
+
error?: string;
|
|
681
|
+
createdAt: Date;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
export declare const ToolCallRenderer: default_2.FC<ToolCallRendererProps>;
|
|
685
|
+
|
|
686
|
+
declare interface ToolCallRendererProps {
|
|
687
|
+
toolCall: ToolCall;
|
|
688
|
+
allMessages?: Message[];
|
|
689
|
+
className?: string;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
export declare const TrashIcon: default_2.FC<{
|
|
693
|
+
className?: string;
|
|
694
|
+
}>;
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* 截断文本
|
|
698
|
+
*/
|
|
699
|
+
export declare function truncateText(text: string, maxLength: number): string;
|
|
700
|
+
|
|
701
|
+
export declare const useChatStore: UseBoundStore<Omit<Omit<Omit<StoreApi<ChatState & ChatActions>, "subscribe"> & {
|
|
702
|
+
subscribe: {
|
|
703
|
+
(listener: (selectedState: ChatState & ChatActions, previousSelectedState: ChatState & ChatActions) => void): () => void;
|
|
704
|
+
<U>(selector: (state: ChatState & ChatActions) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
705
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
706
|
+
fireImmediately?: boolean;
|
|
707
|
+
} | undefined): () => void;
|
|
708
|
+
};
|
|
709
|
+
}, "setState"> & {
|
|
710
|
+
setState(nextStateOrUpdater: (ChatState & ChatActions) | Partial<ChatState & ChatActions> | ((state: WritableDraft<ChatState & ChatActions>) => void), shouldReplace?: boolean | undefined): void;
|
|
711
|
+
}, "persist"> & {
|
|
712
|
+
persist: {
|
|
713
|
+
setOptions: (options: Partial<PersistOptions<ChatState & ChatActions, {
|
|
714
|
+
theme: Theme;
|
|
715
|
+
sidebarOpen: boolean;
|
|
716
|
+
chatConfig: ChatConfig;
|
|
717
|
+
selectedModelId: string | null;
|
|
718
|
+
}>>) => void;
|
|
719
|
+
clearStorage: () => void;
|
|
720
|
+
rehydrate: () => Promise<void> | void;
|
|
721
|
+
hasHydrated: () => boolean;
|
|
722
|
+
onHydrate: (fn: (state: ChatState & ChatActions) => void) => () => void;
|
|
723
|
+
onFinishHydration: (fn: (state: ChatState & ChatActions) => void) => () => void;
|
|
724
|
+
getOptions: () => Partial<PersistOptions<ChatState & ChatActions, {
|
|
725
|
+
theme: Theme;
|
|
726
|
+
sidebarOpen: boolean;
|
|
727
|
+
chatConfig: ChatConfig;
|
|
728
|
+
selectedModelId: string | null;
|
|
729
|
+
}>>;
|
|
730
|
+
};
|
|
731
|
+
}>;
|
|
732
|
+
|
|
733
|
+
export declare const useTheme: () => {
|
|
734
|
+
theme: Theme_2;
|
|
735
|
+
actualTheme: "light" | "dark";
|
|
736
|
+
setTheme: (newTheme: Theme_2) => void;
|
|
737
|
+
toggleTheme: () => void;
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
export declare const version = "1.0.0";
|
|
741
|
+
|
|
742
|
+
export declare const XIcon: default_2.FC<{
|
|
743
|
+
className?: string;
|
|
744
|
+
}>;
|
|
745
|
+
|
|
746
|
+
export { }
|