@huyooo/ai-chat-frontend-react 0.1.4 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +368 -0
  2. package/dist/index.css +2575 -0
  3. package/dist/index.css.map +1 -0
  4. package/dist/index.d.ts +378 -135
  5. package/dist/index.js +3954 -1044
  6. package/dist/index.js.map +1 -1
  7. package/dist/style.css +48 -987
  8. package/package.json +7 -4
  9. package/src/adapter.ts +10 -70
  10. package/src/components/ChatPanel.tsx +373 -117
  11. package/src/components/common/ConfirmDialog.css +136 -0
  12. package/src/components/common/ConfirmDialog.tsx +91 -0
  13. package/src/components/common/CopyButton.css +22 -0
  14. package/src/components/common/CopyButton.tsx +46 -0
  15. package/src/components/common/IndexingSettings.css +207 -0
  16. package/src/components/common/IndexingSettings.tsx +398 -0
  17. package/src/components/common/SettingsPanel.css +256 -0
  18. package/src/components/common/SettingsPanel.tsx +120 -0
  19. package/src/components/common/Toast.css +50 -0
  20. package/src/components/common/Toast.tsx +38 -0
  21. package/src/components/common/ToggleSwitch.css +52 -0
  22. package/src/components/common/ToggleSwitch.tsx +20 -0
  23. package/src/components/header/ChatHeader.css +285 -0
  24. package/src/components/header/ChatHeader.tsx +376 -0
  25. package/src/components/input/AtFilePicker.css +147 -0
  26. package/src/components/input/AtFilePicker.tsx +519 -0
  27. package/src/components/input/ChatInput.css +204 -0
  28. package/src/components/input/ChatInput.tsx +506 -0
  29. package/src/components/input/DropdownSelector.css +159 -0
  30. package/src/components/input/DropdownSelector.tsx +195 -0
  31. package/src/components/input/ImagePreviewModal.css +124 -0
  32. package/src/components/input/ImagePreviewModal.tsx +118 -0
  33. package/src/components/input/at-views/AtBranchView.tsx +34 -0
  34. package/src/components/input/at-views/AtBrowserView.tsx +34 -0
  35. package/src/components/input/at-views/AtChatsView.tsx +34 -0
  36. package/src/components/input/at-views/AtDocsView.tsx +34 -0
  37. package/src/components/input/at-views/AtFilesView.tsx +168 -0
  38. package/src/components/input/at-views/AtTerminalsView.tsx +34 -0
  39. package/src/components/input/at-views/AtViewStyles.css +143 -0
  40. package/src/components/input/at-views/index.ts +9 -0
  41. package/src/components/message/ContentRenderer.css +9 -0
  42. package/src/components/message/ContentRenderer.tsx +63 -0
  43. package/src/components/message/MessageBubble.css +190 -0
  44. package/src/components/message/MessageBubble.tsx +231 -0
  45. package/src/components/message/PartsRenderer.css +4 -0
  46. package/src/components/message/PartsRenderer.tsx +114 -0
  47. package/src/components/message/ToolResultRenderer.tsx +21 -0
  48. package/src/components/message/WelcomeMessage.css +221 -0
  49. package/src/components/message/WelcomeMessage.tsx +93 -0
  50. package/src/components/message/blocks/CodeBlock.tsx +60 -0
  51. package/src/components/message/blocks/TextBlock.tsx +15 -0
  52. package/src/components/message/blocks/blocks.css +141 -0
  53. package/src/components/message/blocks/index.ts +6 -0
  54. package/src/components/message/parts/CollapsibleCard.css +78 -0
  55. package/src/components/message/parts/CollapsibleCard.tsx +77 -0
  56. package/src/components/message/parts/ErrorPart.css +9 -0
  57. package/src/components/message/parts/ErrorPart.tsx +40 -0
  58. package/src/components/message/parts/ImagePart.css +50 -0
  59. package/src/components/message/parts/ImagePart.tsx +54 -0
  60. package/src/components/message/parts/SearchPart.css +44 -0
  61. package/src/components/message/parts/SearchPart.tsx +63 -0
  62. package/src/components/message/parts/TextPart.css +10 -0
  63. package/src/components/message/parts/TextPart.tsx +20 -0
  64. package/src/components/message/parts/ThinkingPart.css +9 -0
  65. package/src/components/message/parts/ThinkingPart.tsx +48 -0
  66. package/src/components/message/parts/ToolCallPart.css +220 -0
  67. package/src/components/message/parts/ToolCallPart.tsx +285 -0
  68. package/src/components/message/parts/ToolResultPart.css +68 -0
  69. package/src/components/message/parts/ToolResultPart.tsx +96 -0
  70. package/src/components/message/parts/index.ts +11 -0
  71. package/src/components/message/tool-results/DefaultToolResult.tsx +26 -0
  72. package/src/components/message/tool-results/SearchResults.tsx +69 -0
  73. package/src/components/message/tool-results/WeatherCard.tsx +63 -0
  74. package/src/components/message/tool-results/index.ts +7 -0
  75. package/src/components/message/tool-results/tool-results.css +179 -0
  76. package/src/components/message/welcome-types.ts +46 -0
  77. package/src/context/AutoRunConfigContext.tsx +13 -0
  78. package/src/context/ChatAdapterContext.tsx +8 -0
  79. package/src/context/ChatInputContext.tsx +40 -0
  80. package/src/context/RenderersContext.tsx +41 -0
  81. package/src/hooks/useChat.ts +855 -237
  82. package/src/hooks/useImageUpload.ts +253 -0
  83. package/src/index.ts +99 -42
  84. package/src/styles.css +48 -987
  85. package/src/types/index.ts +172 -103
  86. package/src/utils/fileIcon.ts +49 -0
  87. package/src/components/ChatInput.tsx +0 -368
  88. package/src/components/chat/messages/ExecutionSteps.tsx +0 -234
  89. package/src/components/chat/messages/MessageBubble.tsx +0 -130
  90. package/src/components/chat/ui/ChatHeader.tsx +0 -301
  91. package/src/components/chat/ui/WelcomeMessage.tsx +0 -107
package/dist/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
- import { ChatMode as ChatMode$1, ThinkingMode, ChatAdapter, ModelConfig as ModelConfig$1, SessionRecord as SessionRecord$1 } from '@huyooo/ai-chat-bridge-electron/renderer';
2
- export { ChatAdapter, ChatMode, ChatOptions, ChatProgress, ChatProgressType, MessageRecord, ModelConfig, ModelProvider, SessionRecord, ThinkingMode, createElectronAdapter } from '@huyooo/ai-chat-bridge-electron/renderer';
3
- import { FC, ReactNode } from 'react';
1
+ import { ChatMode as ChatMode$1, ThinkingMode, ModelOption as ModelOption$1, SessionRecord as SessionRecord$1, ChatAdapter, AutoRunConfig } from '@huyooo/ai-chat-bridge-electron/renderer';
2
+ export { ChatAdapter, ChatEvent, ChatEventType, ChatMode, ChatOptions, MessageRecord, ModelOption, ProviderType, SessionRecord, ThinkingMode } from '@huyooo/ai-chat-bridge-electron/renderer';
3
+ import * as react from 'react';
4
+ import { FC, ReactNode, ComponentType } from 'react';
5
+ import { ContentBlock, ToolRendererProps, TextBlock as TextBlock$1, CodeBlock as CodeBlock$1 } from '@huyooo/ai-chat-shared';
6
+ export { CodeBlock as CodeBlockType, ContentBlock, ContentBlockType, SearchResultItem, TextBlock as TextBlockType, ToolRendererProps, WeatherData, getLanguageDisplayName, highlightCode, parseContent, renderMarkdown } from '@huyooo/ai-chat-shared';
4
7
 
5
8
  /**
6
9
  * Chat Adapter 辅助类型和工具
@@ -32,6 +35,7 @@ interface SendMessageOptions {
32
35
  mode: ChatMode$1;
33
36
  model: string;
34
37
  enableWebSearch: boolean;
38
+ /** 深度思考开关(每个 provider 内部使用最优参数) */
35
39
  thinkingMode: ThinkingMode;
36
40
  }
37
41
  /** 创建会话选项 */
@@ -51,114 +55,170 @@ interface SaveMessageOptions {
51
55
  sessionId: string;
52
56
  role: 'user' | 'assistant';
53
57
  content: string;
54
- thinking?: string;
55
- toolCalls?: string;
56
- searchResults?: string;
58
+ /** 执行步骤列表 JSON */
59
+ steps?: string;
60
+ operationIds?: string;
57
61
  }
58
- /**
59
- * 创建空 Adapter(用于测试或无后端场景)
60
- * 返回一个最小实现的 ChatAdapter
61
- */
62
- declare function createNullAdapter(): ChatAdapter;
63
62
 
64
63
  /**
65
64
  * AI Chat 前端类型定义
66
- * 核心类型(ChatAdapter, SessionRecord, MessageRecord 等)从 bridge-electron 导出
67
- * 这里只定义前端特有的类型
65
+ * 核心类型从 bridge-electron 导出,保持类型一致性
66
+ *
67
+ * 架构:消息内容使用 ContentPart 数组,支持流式渲染和自定义 UI
68
68
  */
69
69
 
70
70
  type ChatMode = ChatMode$1;
71
- type ModelConfig = ModelConfig$1;
72
71
  type SessionRecord = SessionRecord$1;
72
+ type ModelOption = ModelOption$1;
73
73
  /** 搜索结果 */
74
74
  interface SearchResult {
75
75
  title: string;
76
76
  url: string;
77
77
  snippet: string;
78
78
  }
79
- /** 工具调用 */
80
- interface ToolCall {
79
+ /** 文本内容 Part */
80
+ interface TextPart {
81
+ type: 'text';
82
+ text: string;
83
+ }
84
+ /** 思考过程 Part */
85
+ interface ThinkingPart {
86
+ type: 'thinking';
87
+ text: string;
88
+ status: 'running' | 'done';
89
+ duration?: number;
90
+ }
91
+ /** 搜索 Part */
92
+ interface SearchPart {
93
+ type: 'search';
94
+ query?: string;
95
+ results?: SearchResult[];
96
+ status: 'running' | 'done';
97
+ }
98
+ /** 工具调用 Part */
99
+ interface ToolCallPart {
100
+ type: 'tool_call';
101
+ id: string;
102
+ name: string;
103
+ args?: Record<string, unknown>;
104
+ status: 'pending' | 'running' | 'done' | 'error' | 'cancelled' | 'skipped';
105
+ result: unknown | null;
106
+ }
107
+ /** 工具结果 Part - 用于自定义 UI 渲染(备用,主要使用 ToolCallPart) */
108
+ interface ToolResultPart {
109
+ type: 'tool_result';
110
+ id: string;
81
111
  name: string;
82
112
  args?: Record<string, unknown>;
83
- result?: string;
84
- status: 'running' | 'success' | 'error';
113
+ result: unknown;
114
+ status: 'done' | 'error' | 'cancelled' | 'skipped';
115
+ }
116
+ /** 图片 Part */
117
+ interface ImagePart {
118
+ type: 'image';
119
+ url: string;
120
+ }
121
+ /** 错误 Part */
122
+ interface ErrorPart {
123
+ type: 'error';
124
+ message: string;
125
+ category?: string;
126
+ retryable?: boolean;
85
127
  }
86
- /** 聊天消息(前端显示用) */
128
+ /** 内容 Part 联合类型 */
129
+ type ContentPart = TextPart | ThinkingPart | SearchPart | ToolCallPart | ToolResultPart | ImagePart | ErrorPart;
130
+ /** 内容 Part 类型字符串 */
131
+ type ContentPartType = ContentPart['type'];
132
+ /** 错误详情(结构化错误信息) */
133
+ interface ErrorDetails {
134
+ category?: string;
135
+ message: string;
136
+ code?: string;
137
+ statusCode?: number;
138
+ retryable?: boolean;
139
+ retryAfter?: number;
140
+ }
141
+ /** 聊天消息(前端显示用)- 新架构:基于 parts 数组 */
87
142
  interface ChatMessage {
88
143
  id: string;
89
144
  role: 'user' | 'assistant';
90
- content: string;
145
+ /** 内容 parts 数组 - 核心渲染数据 */
146
+ parts: ContentPart[];
147
+ /** 生成此消息时使用的模型 */
148
+ model?: string;
149
+ /** 生成此消息时使用的模式 (ask/agent) */
150
+ mode?: string;
151
+ /** 生成此消息时是否启用 web 搜索 */
152
+ webSearchEnabled?: boolean;
153
+ /** 生成此消息时是否启用深度思考 */
154
+ thinkingEnabled?: boolean;
155
+ /** 用户上传的图片(仅用户消息) */
91
156
  images?: string[];
92
- thinking?: string;
93
- thinkingComplete?: boolean;
94
- searchResults?: SearchResult[];
95
- searching?: boolean;
96
- toolCalls?: ToolCall[];
97
- copied?: boolean;
157
+ /** 是否正在加载 */
98
158
  loading?: boolean;
159
+ /** 是否已复制 */
160
+ copied?: boolean;
161
+ /** 消息时间戳 */
99
162
  timestamp?: Date;
163
+ /** 错误详情(如果有错误) */
164
+ error?: ErrorDetails;
165
+ /** 是否被用户中止 */
166
+ aborted?: boolean;
100
167
  }
101
- /** 默认模型列表 */
102
- declare const DEFAULT_MODELS: ModelConfig$1[];
103
- /** @deprecated 使用 SessionRecord */
104
- interface ChatSession {
105
- id: string;
106
- title: string;
107
- messages: ChatMessage[];
108
- createdAt: Date;
109
- updatedAt: Date;
110
- }
111
- /** 音视频操作类型 */
112
- interface MediaOperation {
113
- id: string;
114
- type: 'clip' | 'transcode' | 'merge' | 'extract_audio' | 'add_subtitle' | 'analyze';
115
- description: string;
116
- sourceFiles: string[];
117
- targetFile?: string;
118
- parameters?: Record<string, unknown>;
119
- status?: 'pending' | 'applied' | 'rejected';
120
- preview?: string;
121
- }
122
- /** @deprecated 使用字符串枚举 */
123
- type AiModel = 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview';
124
- declare enum FileType {
125
- FOLDER = "folder",
126
- IMAGE = "image",
127
- VIDEO = "video",
128
- AUDIO = "audio",
129
- TEXT = "text",
130
- PDF = "pdf",
131
- CODE = "code",
132
- ARCHIVE = "archive",
133
- OTHER = "other"
134
- }
135
- interface DiffStat {
136
- file: string;
137
- additions: number;
138
- deletions: number;
139
- type: 'modified' | 'added' | 'deleted';
168
+ /** 获取消息的纯文本内容(用于复制、保存等) */
169
+ declare function getMessageText(message: ChatMessage): string;
170
+ /** 输入区配置快照(用于历史回溯/重发) */
171
+ interface ChatInputOptions {
172
+ mode: ChatMode;
173
+ model: string;
174
+ webSearchEnabled: boolean;
175
+ thinkingEnabled: boolean;
140
176
  }
141
177
 
142
178
  /**
143
179
  * useChat Hook
144
180
  * 管理聊天状态和与后端的通信
145
- * 使用 Adapter 模式解耦后端通信
146
181
  *
147
- * 与 Vue 版本 useChat composable 保持一致
182
+ * 新架构:
183
+ * - 使用 Map 存储每个会话的独立状态
184
+ * - 多会话可同时进行,互不干扰
185
+ * - 切换 tab 不会停止正在进行的请求
186
+ * - ContentPart 数组存储消息内容,支持流式渲染和自定义 UI
148
187
  */
149
188
 
189
+ /** 副作用定义 */
190
+ interface SideEffect {
191
+ type: string;
192
+ success: boolean;
193
+ data?: unknown;
194
+ message?: string;
195
+ }
196
+ /** 工具完成事件数据 */
197
+ interface ToolCompleteEvent {
198
+ name: string;
199
+ result: unknown;
200
+ /**
201
+ * 工具声明的副作用列表
202
+ * 前端可根据此字段处理通知、刷新文件列表等
203
+ */
204
+ sideEffects?: SideEffect[];
205
+ }
150
206
  interface UseChatOptions {
151
- /** Adapter 实例 */
152
- adapter?: ChatAdapter;
153
- /** 默认模型 */
207
+ adapter: ChatAdapter;
154
208
  defaultModel?: string;
155
- /** 默认模式 */
156
209
  defaultMode?: ChatMode$1;
210
+ onToolComplete?: (event: ToolCompleteEvent) => void;
211
+ autoRunConfig?: AutoRunConfig;
157
212
  }
158
213
  /**
159
214
  * 聊天状态管理 Hook
215
+ *
216
+ * 核心架构:
217
+ * - sessionStatesRef: Map<sessionId, SessionState> 存储每个会话的独立状态
218
+ * - 多会话可同时进行请求,互不干扰
219
+ * - 切换 tab 不会停止任何正在进行的请求
160
220
  */
161
- declare function useChat(options?: UseChatOptions): {
221
+ declare function useChat(options: UseChatOptions): {
162
222
  sessions: SessionRecord$1[];
163
223
  currentSessionId: string | null;
164
224
  messages: ChatMessage[];
@@ -172,72 +232,268 @@ declare function useChat(options?: UseChatOptions): {
172
232
  createNewSession: () => Promise<void>;
173
233
  deleteSession: (sessionId: string) => Promise<void>;
174
234
  deleteCurrentSession: () => Promise<void>;
235
+ hideSession: (sessionId: string, hidden: boolean) => Promise<void>;
236
+ clearAllSessions: () => Promise<void>;
237
+ hideOtherSessions: () => Promise<void>;
238
+ exportCurrentSession: () => string | null;
175
239
  sendMessage: (text: string, images?: string[]) => Promise<void>;
176
240
  cancelRequest: () => void;
177
241
  copyMessage: (messageId: string) => Promise<void>;
178
242
  regenerateMessage: (messageIndex: number) => void;
243
+ resendFromIndex: (index: number, text: string) => void;
179
244
  setMode: (value: ChatMode$1) => void;
180
245
  setModel: (value: string) => void;
181
246
  setWebSearch: (value: boolean) => void;
182
247
  setThinking: (value: boolean) => void;
183
248
  setWorkingDirectory: (dir: string) => void;
249
+ autoRunConfig: AutoRunConfig;
250
+ loadAutoRunConfig: () => Promise<void>;
251
+ saveAutoRunConfig: (config: AutoRunConfig) => Promise<void>;
184
252
  };
185
253
 
186
254
  /**
187
- * ChatPanel Component
188
- * Vue 版本 ChatPanel.vue 保持一致
255
+ * 全局 ChatInput 状态 Context
256
+ * 用于在 MessageBubble 中的 ChatInput 共享和修改全局状态
189
257
  */
190
258
 
259
+ interface ChatInputContextValue {
260
+ mode: ChatMode;
261
+ model: string;
262
+ models: ModelOption[];
263
+ webSearch: boolean;
264
+ thinking: boolean;
265
+ isLoading: boolean;
266
+ /** Electron adapter(用于 @ 文件选择) */
267
+ adapter?: ChatAdapter;
268
+ setMode: (value: ChatMode) => void;
269
+ setModel: (value: string) => void;
270
+ setWebSearch: (value: boolean) => void;
271
+ setThinking: (value: boolean) => void;
272
+ }
273
+ interface ChatInputProviderProps {
274
+ value: ChatInputContextValue;
275
+ children: ReactNode;
276
+ }
277
+ declare const ChatInputProvider: FC<ChatInputProviderProps>;
278
+ declare function useChatInputContext(): ChatInputContextValue | null;
279
+
280
+ /** 块渲染器映射 */
281
+ type BlockRenderers = Record<string, ComponentType<{
282
+ block: ContentBlock;
283
+ }>>;
284
+ /** 工具结果渲染器映射 */
285
+ type ToolRenderers = Record<string, ComponentType<ToolRendererProps>>;
286
+ /** 块渲染器上下文 */
287
+ declare const BlockRenderersContext: react.Context<BlockRenderers>;
288
+ /** 工具结果渲染器上下文 */
289
+ declare const ToolRenderersContext: react.Context<ToolRenderers>;
290
+ /** 渲染器 Provider Props */
291
+ interface RenderersProviderProps {
292
+ blockRenderers?: BlockRenderers;
293
+ toolRenderers?: ToolRenderers;
294
+ children: ReactNode;
295
+ }
296
+ /** 渲染器 Provider */
297
+ declare const RenderersProvider: FC<RenderersProviderProps>;
298
+
299
+ /** 功能项 */
300
+ interface WelcomeFeature {
301
+ name: string;
302
+ icon: string;
303
+ }
304
+ /** 快捷任务 */
305
+ interface WelcomeTask {
306
+ name: string;
307
+ desc: string;
308
+ prompt: string;
309
+ icon: string;
310
+ }
311
+ /** 欢迎页配置 */
312
+ interface WelcomeConfig {
313
+ /** 标题 */
314
+ title: string;
315
+ /** 副标题 */
316
+ subtitle: string;
317
+ /** 图标 */
318
+ icon: string;
319
+ /** 功能列表 */
320
+ features: WelcomeFeature[];
321
+ /** 快捷任务 */
322
+ tasks: WelcomeTask[];
323
+ }
324
+ /** 默认配置 */
325
+ declare const defaultWelcomeConfig: WelcomeConfig;
326
+
327
+ /** ChatPanel 暴露给外部的方法 */
328
+ interface ChatPanelHandle {
329
+ /** 设置输入框内容 */
330
+ setInputText: (text: string) => void;
331
+ /** 在光标位置插入文本(用于 @ 上下文) */
332
+ insertInputText: (text: string) => void;
333
+ /** 聚焦输入框 */
334
+ focusInput: () => void;
335
+ /** 发送消息 */
336
+ sendMessage: (text: string) => void;
337
+ /** 设置当前工作目录 */
338
+ setCwd: (dir: string) => void;
339
+ }
191
340
  interface ChatPanelProps {
192
341
  /** Adapter 实例 */
193
- adapter?: ChatAdapter;
194
- /** 工作目录 */
195
- workingDir?: string;
342
+ adapter: ChatAdapter;
196
343
  /** 默认模型 */
197
344
  defaultModel?: string;
198
345
  /** 默认模式 */
199
346
  defaultMode?: ChatMode$1;
200
347
  /** 可用模型列表 */
201
- models?: ModelConfig$1[];
348
+ models?: ModelOption$1[];
202
349
  /** 隐藏标题栏 */
203
350
  hideHeader?: boolean;
204
351
  /** 关闭回调(有此属性时显示关闭按钮) */
205
352
  onClose?: () => void;
353
+ /** 工具执行完成回调 */
354
+ onToolComplete?: (event: ToolCompleteEvent) => void;
206
355
  /** 自定义类名 */
207
356
  className?: string;
208
- /** 自定义 Markdown 渲染器 */
209
- renderMarkdown?: (content: string) => ReactNode;
357
+ /** 欢迎页配置 */
358
+ welcomeConfig?: Partial<WelcomeConfig>;
359
+ /** 自定义工具结果渲染器 - 根据工具名称选择渲染组件 */
360
+ toolRenderers?: Record<string, ComponentType<ToolRendererProps>>;
361
+ /**
362
+ * 执行步骤折叠模式
363
+ * - 'open': 始终展开
364
+ * - 'close': 始终折叠
365
+ * - 'auto': 执行时展开,完成后折叠
366
+ */
367
+ stepsExpandedType?: 'open' | 'close' | 'auto';
210
368
  }
211
- declare const ChatPanel: FC<ChatPanelProps>;
369
+ declare const ChatPanel: react.ForwardRefExoticComponent<ChatPanelProps & react.RefAttributes<ChatPanelHandle>>;
212
370
 
213
371
  /**
214
- * ChatInput Component
215
- * Vue 版本 ChatInput.vue 保持一致
372
+ * MessageBubble Component
373
+ * 新架构:使用 ContentPart 数组渲染消息内容
216
374
  */
217
375
 
376
+ interface MessageBubbleProps {
377
+ role: 'user' | 'assistant';
378
+ /** 内容 parts 数组 - 新架构核心 */
379
+ parts: ContentPart[];
380
+ /** 生成此消息时使用的模型 */
381
+ model?: string;
382
+ /** 生成此消息时使用的模式 (ask/agent) */
383
+ mode?: string;
384
+ /** 用户上传的图片 */
385
+ images?: string[];
386
+ /** 是否正在加载 */
387
+ loading?: boolean;
388
+ /** 是否已复制 */
389
+ copied?: boolean;
390
+ /** 消息时间戳 */
391
+ timestamp?: Date | string | number;
392
+ onCopy?: () => void;
393
+ onRegenerate?: () => void;
394
+ /** 编辑用户消息后重新发送 */
395
+ onSend?: (text: string) => void;
396
+ /** 步骤折叠模式 */
397
+ stepsExpandedType?: 'open' | 'close' | 'auto';
398
+ /** 工具调用相关 - 通过 props 传递 */
399
+ adapter?: ChatAdapter;
400
+ autoRunConfig?: AutoRunConfig;
401
+ onSaveConfig?: (config: AutoRunConfig) => Promise<void>;
402
+ }
403
+ declare const MessageBubble: FC<MessageBubbleProps>;
404
+
405
+ /**
406
+ * 内容渲染器
407
+ * 将原始文本解析为内容块并渲染
408
+ */
409
+
410
+ interface ContentRendererProps {
411
+ /** 原始文本内容 */
412
+ content: string;
413
+ /** 预解析的块列表(可选,用于流式更新) */
414
+ blocks?: ContentBlock[];
415
+ /** 代码复制事件 */
416
+ onCodeCopy?: (code: string) => void;
417
+ }
418
+ declare const ContentRenderer: FC<ContentRendererProps>;
419
+
420
+ /**
421
+ * 文本块组件
422
+ */
423
+
424
+ interface TextBlockProps {
425
+ block: TextBlock$1;
426
+ }
427
+ declare const TextBlock: FC<TextBlockProps>;
428
+
429
+ /**
430
+ * 代码块组件
431
+ */
432
+
433
+ interface CodeBlockProps {
434
+ block: CodeBlock$1;
435
+ onCopy?: (code: string) => void;
436
+ }
437
+ declare const CodeBlock: FC<CodeBlockProps>;
438
+
439
+ /**
440
+ * 工具结果渲染器
441
+ * 根据工具名称选择合适的渲染组件
442
+ */
443
+
444
+ declare const ToolResultRenderer: FC<ToolRendererProps>;
445
+
446
+ /**
447
+ * 默认工具结果渲染器
448
+ */
449
+
450
+ declare const DefaultToolResult: FC<ToolRendererProps>;
451
+
452
+ /**
453
+ * 天气卡片渲染器
454
+ */
455
+
456
+ declare const WeatherCard: FC<ToolRendererProps>;
457
+
458
+ /**
459
+ * 搜索结果渲染器
460
+ */
461
+
462
+ declare const SearchResults: FC<ToolRendererProps>;
463
+
464
+ /** ChatInput 暴露给外部的方法 */
465
+ interface ChatInputHandle {
466
+ /** 设置输入框内容 */
467
+ setText: (text: string) => void;
468
+ /** 聚焦输入框 */
469
+ focus: () => void;
470
+ /** 清空输入框 */
471
+ clear: () => void;
472
+ /** 在光标位置插入文本(用于 @ 上下文) */
473
+ insertText: (text: string) => void;
474
+ /** 添加图片 */
475
+ addImages: (files: File[]) => void;
476
+ }
218
477
  interface ChatInputProps {
219
478
  /** 变体模式:input-底部输入框,message-历史消息 */
220
479
  variant?: 'input' | 'message';
221
480
  /** 受控值(用于历史消息编辑) */
222
481
  value?: string;
223
- selectedImages?: string[];
224
482
  isLoading?: boolean;
225
483
  mode?: ChatMode;
226
484
  model?: string;
227
- models?: ModelConfig[];
485
+ models?: ModelOption[];
228
486
  webSearchEnabled?: boolean;
229
487
  thinkingEnabled?: boolean;
230
- onSend?: (text: string) => void;
231
- onRemoveImage?: (index: number) => void;
488
+ onSend?: (text: string, images?: ImageData[]) => void;
232
489
  onCancel?: () => void;
233
- onUploadImage?: () => void;
234
490
  onAtContext?: () => void;
235
491
  onModeChange?: (mode: ChatMode) => void;
236
492
  onModelChange?: (model: string) => void;
237
493
  onWebSearchChange?: (enabled: boolean) => void;
238
494
  onThinkingChange?: (enabled: boolean) => void;
239
495
  }
240
- declare const ChatInput: FC<ChatInputProps>;
496
+ declare const ChatInput: react.ForwardRefExoticComponent<ChatInputProps & react.RefAttributes<ChatInputHandle>>;
241
497
 
242
498
  /**
243
499
  * ChatHeader Component
@@ -257,6 +513,8 @@ interface ChatHeaderProps {
257
513
  onSwitchSession?: (sessionId: string) => void;
258
514
  /** 删除会话 */
259
515
  onDeleteSession?: (sessionId: string) => void;
516
+ /** 隐藏/显示会话(在 tab 栏关闭但不删除) */
517
+ onHideSession?: (sessionId: string, hidden: boolean) => void;
260
518
  /** 关闭面板 */
261
519
  onClose?: () => void;
262
520
  /** 清空所有对话 */
@@ -280,60 +538,45 @@ declare const ChatHeader: FC<ChatHeaderProps>;
280
538
  */
281
539
 
282
540
  interface WelcomeMessageProps {
541
+ /** 欢迎页配置(可部分配置,未配置项使用默认值) */
542
+ config?: Partial<WelcomeConfig>;
283
543
  /** 快捷操作回调 */
284
544
  onQuickAction: (text: string) => void;
285
545
  }
286
546
  declare const WelcomeMessage: FC<WelcomeMessageProps>;
287
547
 
288
548
  /**
289
- * MessageBubble Component
290
- * 与 Vue 版本 MessageBubble.vue 保持一致
549
+ * ConfirmDialog Component
550
+ * 自定义确认弹窗组件
291
551
  */
292
552
 
293
- interface MessageBubbleProps {
294
- role: 'user' | 'assistant';
295
- content: string;
296
- images?: string[];
297
- thinking?: string;
298
- thinkingComplete?: boolean;
299
- thinkingDuration?: number;
300
- searchResults?: SearchResult[];
301
- searching?: boolean;
302
- toolCalls?: ToolCall[];
303
- copied?: boolean;
304
- loading?: boolean;
305
- onCopy?: () => void;
306
- onRegenerate?: () => void;
307
- /** 编辑用户消息后重新发送 */
308
- onSend?: (text: string) => void;
309
- /** 自定义 Markdown 渲染器 */
310
- renderMarkdown?: (content: string) => ReactNode;
553
+ interface ConfirmDialogProps {
554
+ /** 是否显示 */
555
+ visible: boolean;
556
+ /** 标题 */
557
+ title?: string;
558
+ /** 消息内容 */
559
+ message: string;
560
+ /** 类型:info | warning | danger */
561
+ type?: 'info' | 'warning' | 'danger';
562
+ /** 确认按钮文字 */
563
+ confirmText?: string;
564
+ /** 取消按钮文字 */
565
+ cancelText?: string;
566
+ /** 确认回调 */
567
+ onConfirm?: () => void;
568
+ /** 取消回调 */
569
+ onCancel?: () => void;
311
570
  }
312
- declare const MessageBubble: FC<MessageBubbleProps>;
571
+ declare const ConfirmDialog: FC<ConfirmDialogProps>;
313
572
 
314
- /**
315
- * ExecutionSteps Component
316
- * 与 Vue 版本 ExecutionSteps.vue 保持一致
317
- */
573
+ interface ToastProps {
574
+ visible: boolean;
575
+ message: string;
576
+ type?: 'info' | 'success' | 'warning' | 'error';
577
+ duration?: number;
578
+ onClose: () => void;
579
+ }
580
+ declare const Toast: FC<ToastProps>;
318
581
 
319
- interface ExecutionStepsProps {
320
- /** 是否正在加载 */
321
- loading?: boolean;
322
- /** 是否有消息内容 */
323
- hasContent?: boolean;
324
- /** 思考内容 */
325
- thinking?: string;
326
- /** 思考是否完成 */
327
- thinkingComplete?: boolean;
328
- /** 思考耗时 */
329
- thinkingDuration?: number;
330
- /** 是否正在搜索 */
331
- searching?: boolean;
332
- /** 搜索结果 */
333
- searchResults?: SearchResult[];
334
- /** 工具调用列表 */
335
- toolCalls?: ToolCall[];
336
- }
337
- declare const ExecutionSteps: FC<ExecutionStepsProps>;
338
-
339
- export { type AiModel, ChatHeader, ChatInput, type ChatMessage, ChatPanel, type ChatSession, type CreateSessionOptions, DEFAULT_MODELS, type DiffStat, ExecutionSteps, FileType, type ImageData, type MediaOperation, MessageBubble, type SaveMessageOptions, type SearchResult, type SendMessageOptions, type ThinkingData, type ToolCall, type ToolCallData, type ToolResultData, type UpdateSessionOptions, type UseChatOptions, WelcomeMessage, createNullAdapter, useChat };
582
+ export { type BlockRenderers, BlockRenderersContext, ChatHeader, ChatInput, type ChatInputContextValue, type ChatInputOptions, ChatInputProvider, type ChatMessage, ChatPanel, type ChatPanelHandle, CodeBlock, ConfirmDialog, type ContentPart, type ContentPartType, ContentRenderer, type CreateSessionOptions, DefaultToolResult, type ErrorDetails, type ErrorPart, type ImageData, type ImagePart, MessageBubble, RenderersProvider, type SaveMessageOptions, type SearchPart, type SearchResult, SearchResults, type SendMessageOptions, type SideEffect, TextBlock, type TextPart, type ThinkingData, type ThinkingPart, Toast, type ToolCallData, type ToolCallPart, type ToolCompleteEvent, type ToolRenderers, ToolRenderersContext, type ToolResultData, type ToolResultPart, ToolResultRenderer, type UpdateSessionOptions, type UseChatOptions, WeatherCard, type WelcomeConfig, type WelcomeFeature, WelcomeMessage, type WelcomeTask, defaultWelcomeConfig, getMessageText, useChat, useChatInputContext };