@alicloud/appflow-chat 0.0.1-beta.1

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 (40) hide show
  1. package/README-ZH.md +188 -0
  2. package/README.md +190 -0
  3. package/dist/appflow-chat.cjs.js +1903 -0
  4. package/dist/appflow-chat.esm.js +36965 -0
  5. package/dist/types/index.d.ts +862 -0
  6. package/package.json +87 -0
  7. package/src/components/DocReferences.tsx +64 -0
  8. package/src/components/HumanVerify/CustomParamsRenderer/ArrayField.tsx +394 -0
  9. package/src/components/HumanVerify/CustomParamsRenderer/FieldRenderer.tsx +202 -0
  10. package/src/components/HumanVerify/CustomParamsRenderer/ObjectField.tsx +126 -0
  11. package/src/components/HumanVerify/CustomParamsRenderer/index.tsx +166 -0
  12. package/src/components/HumanVerify/CustomParamsRenderer/types.ts +203 -0
  13. package/src/components/HumanVerify/HistoryCard.tsx +156 -0
  14. package/src/components/HumanVerify/HumanVerify.tsx +184 -0
  15. package/src/components/HumanVerify/index.ts +11 -0
  16. package/src/components/MarkdownRenderer.tsx +195 -0
  17. package/src/components/MessageBubble.tsx +400 -0
  18. package/src/components/RichMessageBubble.tsx +283 -0
  19. package/src/components/WebSearchPanel.tsx +68 -0
  20. package/src/context/RichBubble.tsx +21 -0
  21. package/src/core/BubbleContent.tsx +75 -0
  22. package/src/core/RichBubbleContent.tsx +324 -0
  23. package/src/core/SourceContent.tsx +285 -0
  24. package/src/core/WebSearchContent.tsx +219 -0
  25. package/src/core/index.ts +16 -0
  26. package/src/hooks/usePreSignUpload.ts +36 -0
  27. package/src/index.ts +80 -0
  28. package/src/markdown/components/Chart.tsx +120 -0
  29. package/src/markdown/components/Error.tsx +39 -0
  30. package/src/markdown/components/FileDisplay.tsx +246 -0
  31. package/src/markdown/components/Loading.tsx +41 -0
  32. package/src/markdown/components/SyntaxHighlight.tsx +182 -0
  33. package/src/markdown/index.tsx +250 -0
  34. package/src/markdown/styled.ts +234 -0
  35. package/src/markdown/utils/dataProcessor.ts +89 -0
  36. package/src/services/ChatService.ts +926 -0
  37. package/src/utils/fetchEventSource.ts +65 -0
  38. package/src/utils/loadEcharts.ts +32 -0
  39. package/src/utils/loadPrism.ts +156 -0
  40. package/src/vite-env.d.ts +1 -0
@@ -0,0 +1,862 @@
1
+ import { default as default_2 } from 'react';
2
+ import { Provider } from 'react';
3
+
4
+ /**
5
+ * BubbleContent - 消息气泡核心展示组件
6
+ *
7
+ * @example
8
+ * ```tsx
9
+ * <BubbleContent
10
+ * content="这是消息内容,支持**Markdown**"
11
+ * status="Success"
12
+ * role="bot"
13
+ * >
14
+ * <ChatBotSource items={references} />
15
+ * </BubbleContent>
16
+ * ```
17
+ */
18
+ export declare const BubbleContent: default_2.FC<BubbleContentProps>;
19
+
20
+ export declare interface BubbleContentProps {
21
+ /** 消息内容(Markdown格式) */
22
+ content: string;
23
+ /** 渲染状态 */
24
+ status?: 'Running' | 'Success' | 'Error';
25
+ /** 消息角色 */
26
+ role?: 'user' | 'bot';
27
+ /** 自定义类名 */
28
+ className?: string;
29
+ /** 自定义样式 */
30
+ style?: default_2.CSSProperties;
31
+ /** 自定义气泡样式(用于业务组件传入) */
32
+ bubbleStyle?: default_2.CSSProperties;
33
+ /** 子元素(如参考资料组件) */
34
+ children?: default_2.ReactNode;
35
+ /** 等待消息文本,由外层传入 */
36
+ waitingMessage?: string;
37
+ }
38
+
39
+ export declare interface ChatConfig {
40
+ welcome: string;
41
+ questions: string[];
42
+ models: ModelInfo[];
43
+ features: {
44
+ image: boolean;
45
+ file: boolean;
46
+ audio: boolean;
47
+ webSearch: boolean;
48
+ };
49
+ chatbotId: string;
50
+ integrateId: string;
51
+ }
52
+
53
+ export declare interface ChatMessage {
54
+ text?: string;
55
+ images?: string[];
56
+ files?: string[];
57
+ audio?: string;
58
+ modelId?: string;
59
+ webSearch?: boolean;
60
+ }
61
+
62
+ export declare class ChatService {
63
+ private config;
64
+ private setupConfig;
65
+ private sessionId;
66
+ private currentController;
67
+ private isInitialized;
68
+ /**
69
+ * 初始化SDK并返回配置信息
70
+ */
71
+ setup(config: SetupConfig): Promise<ChatConfig>;
72
+ /**
73
+ * 初始化认证票据
74
+ */
75
+ private initTicket;
76
+ /**
77
+ * 获取聊天机器人配置
78
+ */
79
+ private fetchConfig;
80
+ /**
81
+ * 获取请求令牌
82
+ */
83
+ private getRequestToken;
84
+ /**
85
+ * 发送消息(流式响应)
86
+ */
87
+ chat(message: ChatMessage): ChatStream;
88
+ /**
89
+ * 发送消息的内部实现
90
+ */
91
+ private sendMessage;
92
+ /**
93
+ * 上传文件
94
+ */
95
+ upload(file: File): Promise<string>;
96
+ /**
97
+ * 清除会话
98
+ */
99
+ clear(): void;
100
+ /**
101
+ * 取消当前请求
102
+ */
103
+ cancel(): void;
104
+ /**
105
+ * 获取当前配置
106
+ */
107
+ getConfig(): ChatConfig | null;
108
+ /**
109
+ * 获取当前会话ID
110
+ */
111
+ getSessionId(): string;
112
+ /**
113
+ * 获取指定模型的能力配置
114
+ * @param modelId 模型ID,不传则使用第一个模型
115
+ */
116
+ getModelCapabilities(modelId?: string): ModelCapabilities;
117
+ /**
118
+ * 检查指定模型是否支持某个功能
119
+ * @param capability 功能名称
120
+ * @param modelId 模型ID,不传则使用第一个模型
121
+ */
122
+ hasCapability(capability: 'image' | 'file' | 'audio' | 'webSearch', modelId?: string): boolean;
123
+ /**
124
+ * 设置当前会话ID
125
+ * @param sessionId 会话ID
126
+ */
127
+ setSessionId(sessionId: string): void;
128
+ /**
129
+ * 获取对话历史记录
130
+ * @param sessionId 会话ID,不传则使用当前会话ID
131
+ * @returns 历史消息列表
132
+ */
133
+ getHistory(sessionId?: string): Promise<HistoryMessage[]>;
134
+ /**
135
+ * 获取会话列表
136
+ * @returns 会话列表
137
+ */
138
+ getSessions(): Promise<ChatSession[]>;
139
+ /**
140
+ * 发送事件回调消息
141
+ * 用于 humanVerify、cardCallBack 等需要向服务端发送回调的场景
142
+ *
143
+ * @param data 回调数据
144
+ * @param data.sessionWebhook 会话 Webhook URL
145
+ * @param data.content 回调内容对象
146
+ * @returns Promise<void>
147
+ *
148
+ * @example
149
+ * ```typescript
150
+ * await chatService.sendEventCallback({
151
+ * sessionWebhook: 'https://...',
152
+ * content: {
153
+ * verifyId: 'xxx',
154
+ * status: 'approve',
155
+ * customParams: { ... }
156
+ * }
157
+ * });
158
+ * ```
159
+ */
160
+ sendEventCallback(data: {
161
+ sessionWebhook: string;
162
+ content: Record<string, any>;
163
+ }): Promise<void>;
164
+ /**
165
+ * 提交人工审核结果
166
+ * 这是 sendEventCallback 的便捷封装,专门用于 HumanVerify 场景
167
+ *
168
+ * @param data 审核数据
169
+ * @param data.verifyId 验证ID
170
+ * @param data.sessionWebhook 会话 Webhook URL
171
+ * @param data.status 审核状态 ('approve' | 'reject')
172
+ * @param data.customParams 自定义参数值
173
+ * @param data.customParamsKey 自定义参数的字段名,默认为 'customParams'
174
+ * @returns Promise<void>
175
+ *
176
+ * @example
177
+ * ```typescript
178
+ * await chatService.submitHumanVerify({
179
+ * verifyId: 'xxx',
180
+ * sessionWebhook: 'https://...',
181
+ * status: 'approve',
182
+ * customParams: { name: '张三', age: 25 },
183
+ * customParamsKey: 'formData'
184
+ * });
185
+ * ```
186
+ */
187
+ submitHumanVerify(data: {
188
+ verifyId: string;
189
+ sessionWebhook: string;
190
+ status: 'approve' | 'reject';
191
+ customParams?: Record<string, any>;
192
+ customParamsKey?: string;
193
+ }): Promise<void>;
194
+ }
195
+
196
+ export declare const chatService: ChatService;
197
+
198
+ export declare interface ChatSession {
199
+ id: string;
200
+ sessionId: string;
201
+ title: string;
202
+ gmtCreate?: string;
203
+ gmtModified?: string;
204
+ }
205
+
206
+ export declare interface ChatStream {
207
+ onMessage(callback: (content: string, done: boolean, meta?: any) => void): ChatStream;
208
+ onError(callback: (error: Error) => void): ChatStream;
209
+ }
210
+
211
+ export declare interface ChatStreamCallbacks {
212
+ onMessage?: (content: string, done: boolean, meta?: any) => void;
213
+ onError?: (error: Error) => void;
214
+ }
215
+
216
+ /**
217
+ * 将后端返回的小写 schema 转换为组件需要的大写格式
218
+ * @param schema 后端返回的 schema(小写字段名)
219
+ * @returns 转换后的 schema(大写字段名)
220
+ */
221
+ export declare const convertSchemaToUpperCase: (schema: any) => CustomParamSchema | undefined;
222
+
223
+ /**
224
+ * CustomParam 的 Schema 定义
225
+ */
226
+ export declare interface CustomParamSchema {
227
+ Type: ParamType;
228
+ Title?: string;
229
+ Description?: string;
230
+ Required?: string[];
231
+ Properties?: Record<string, CustomParamSchema>;
232
+ Items?: CustomParamSchema;
233
+ }
234
+
235
+ /**
236
+ * CustomParamsRenderer 组件
237
+ * 根据 CustomParam Schema 渲染表单
238
+ *
239
+ * @example
240
+ * ```tsx
241
+ * const schema: CustomParamSchema = {
242
+ * Type: 'object',
243
+ * Properties: {
244
+ * name: { Type: 'string', Title: '名称', Description: '请输入名称' },
245
+ * age: { Type: 'number', Title: '年龄' },
246
+ * enabled: { Type: 'boolean', Title: '是否启用' },
247
+ * tags: {
248
+ * Type: 'array',
249
+ * Title: '标签',
250
+ * Items: { Type: 'string' }
251
+ * },
252
+ * config: {
253
+ * Type: 'object',
254
+ * Title: '配置',
255
+ * Properties: {
256
+ * key: { Type: 'string', Title: '键' },
257
+ * value: { Type: 'string', Title: '值' }
258
+ * }
259
+ * }
260
+ * },
261
+ * Required: ['name']
262
+ * };
263
+ *
264
+ * <CustomParamsRenderer
265
+ * schema={schema}
266
+ * value={formValue}
267
+ * onChange={setFormValue}
268
+ * />
269
+ * ```
270
+ */
271
+ export declare const CustomParamsRenderer: default_2.FC<CustomParamsRendererProps>;
272
+
273
+ /**
274
+ * CustomParamsRenderer 组件的 Props
275
+ */
276
+ export declare interface CustomParamsRendererProps {
277
+ /** CustomParams 的 schema */
278
+ schema: CustomParamSchema;
279
+ /** 表单值 */
280
+ value?: Record<string, any>;
281
+ /** 值变化回调 */
282
+ onChange?: (value: Record<string, any>) => void;
283
+ /** 是否禁用 */
284
+ disabled?: boolean;
285
+ /** 字段名前缀(用于嵌套场景) */
286
+ namePrefix?: string;
287
+ /** 验证错误信息 */
288
+ errors?: Record<string, string>;
289
+ }
290
+
291
+ export declare type DocReferenceItem = SourceItem;
292
+
293
+ /**
294
+ * DocReferences - 参考资料组件
295
+ *
296
+ * @example
297
+ * ```tsx
298
+ * <DocReferences
299
+ * items={[
300
+ * { title: '参考文档1', text: '内容...', index: '1', type: 'rag' },
301
+ * { title: '搜索结果1', url: 'https://...', type: 'web_search' }
302
+ * ]}
303
+ * status="Success"
304
+ * onItemClick={(item) => console.log('点击了', item)}
305
+ * onWebSearchClick={(items) => console.log('网页搜索', items)}
306
+ * />
307
+ * ```
308
+ */
309
+ export declare const DocReferences: default_2.FC<DocReferencesProps>;
310
+
311
+ export declare interface DocReferencesProps {
312
+ /** 参考资料列表 */
313
+ items: DocReferenceItem[];
314
+ /** 渲染状态 */
315
+ status?: 'Running' | 'Success' | 'Error';
316
+ /** 点击参考资料回调 */
317
+ onItemClick?: (item: DocReferenceItem) => void;
318
+ /** 点击网页搜索结果回调 */
319
+ onWebSearchClick?: (items: DocReferenceItem[]) => void;
320
+ /** 自定义类名 */
321
+ className?: string;
322
+ /** 自定义样式 */
323
+ style?: default_2.CSSProperties;
324
+ }
325
+
326
+ /**
327
+ * HistoryCard 历史卡片组件 (SDK 版本)
328
+ * 用于展示历史对话中的 card 类型消息(只读模式)
329
+ *
330
+ * @example
331
+ * ```tsx
332
+ * <HistoryCard
333
+ * approvalStatus="approved"
334
+ * formValues={{ name: 'test', age: 18 }}
335
+ * formSchema={schema}
336
+ * />
337
+ * ```
338
+ */
339
+ export declare const HistoryCard: default_2.FC<HistoryCardProps>;
340
+
341
+ /** HistoryCard 相关数据 */
342
+ export declare interface HistoryCardData {
343
+ approvalStatus?: string;
344
+ formValues?: Record<string, any>;
345
+ formSchema?: CustomParamSchema;
346
+ }
347
+
348
+ export declare interface HistoryCardProps {
349
+ /** 审批状态 */
350
+ approvalStatus?: string;
351
+ /** 表单值 */
352
+ formValues?: Record<string, any>;
353
+ /** 表单 Schema */
354
+ formSchema?: CustomParamSchema;
355
+ }
356
+
357
+ export declare interface HistoryMessage {
358
+ id: string;
359
+ role: 'user' | 'assistant';
360
+ content: string;
361
+ messageType: string;
362
+ gmtCreate?: string;
363
+ sessionId?: string;
364
+ images?: string[];
365
+ files?: {
366
+ name: string;
367
+ url: string;
368
+ }[];
369
+ }
370
+
371
+ /**
372
+ * HumanVerify 人工审核组件 (SDK 版本)
373
+ * 用于展示需要人工审核的表单,并处理提交逻辑
374
+ *
375
+ * @example
376
+ * ```tsx
377
+ * <HumanVerify
378
+ * verifyId="xxx"
379
+ * sessionWebhook="https://..."
380
+ * approved={false}
381
+ * customParamsSchema={schema}
382
+ * customParamsKey="customParams"
383
+ * onSubmit={(data) => {
384
+ * bot.postMessage({
385
+ * msgType: 'cardCallBack',
386
+ * data: {
387
+ * sessionWebhook: data.sessionWebhook,
388
+ * content: JSON.stringify({
389
+ * verifyId: data.verifyId,
390
+ * status: data.status,
391
+ * [data.customParamsKey]: data.customParamsValue,
392
+ * }),
393
+ * },
394
+ * });
395
+ * }}
396
+ * />
397
+ * ```
398
+ */
399
+ export declare const HumanVerify: default_2.FC<HumanVerifyProps>;
400
+
401
+ /** HumanVerify 相关数据 */
402
+ export declare interface HumanVerifyData {
403
+ verifyId?: string;
404
+ sessionWebhook?: string;
405
+ approved?: boolean;
406
+ customParams?: CustomParamSchema;
407
+ customParamsKey?: string;
408
+ }
409
+
410
+ export declare interface HumanVerifyProps {
411
+ /** 验证ID */
412
+ verifyId?: string;
413
+ /** 会话 Webhook */
414
+ sessionWebhook?: string;
415
+ /** 是否已提交 */
416
+ approved?: boolean;
417
+ /** CustomParams 的 schema */
418
+ customParamsSchema?: CustomParamSchema;
419
+ /** CustomParams 的 key(用于提交时的字段名) */
420
+ customParamsKey?: string;
421
+ /** 提交回调函数 */
422
+ onSubmit?: (data: {
423
+ verifyId: string;
424
+ sessionWebhook: string;
425
+ status: string;
426
+ customParamsKey: string;
427
+ customParamsValue: Record<string, any>;
428
+ }) => void;
429
+ }
430
+
431
+ /** HumanVerify 提交数据类型 */
432
+ export declare interface HumanVerifySubmitData {
433
+ verifyId: string;
434
+ sessionWebhook: string;
435
+ status: string;
436
+ customParamsKey: string;
437
+ customParamsValue: Record<string, any>;
438
+ }
439
+
440
+ /**
441
+ * ECharts 按需加载函数
442
+ * 用于在需要渲染图表时动态加载 ECharts 库
443
+ */
444
+ export declare const loadEchartsScript: () => Promise<void>;
445
+
446
+ /**
447
+ * MarkdownRenderer - Markdown渲染组件
448
+ *
449
+ * @example
450
+ * ```tsx
451
+ * <MarkdownRenderer
452
+ * content="# 标题\n这是正文内容,支持**加粗**和*斜体*"
453
+ * status="Success"
454
+ * />
455
+ * ```
456
+ */
457
+ export declare const MarkdownRenderer: default_2.FC<MarkdownRendererProps>;
458
+
459
+ export declare interface MarkdownRendererProps {
460
+ /** Markdown内容 */
461
+ content: string;
462
+ /** 渲染状态,Running时显示加载动画 */
463
+ status?: 'Running' | 'Success' | 'Error';
464
+ /** 自定义类名 */
465
+ className?: string;
466
+ /** 自定义样式 */
467
+ style?: default_2.CSSProperties;
468
+ }
469
+
470
+ export declare const MarkdownView: default_2.FC<MarkdownViewProps>;
471
+
472
+ export declare interface MarkdownViewProps {
473
+ /** Markdown 内容 */
474
+ content: any;
475
+ /** 状态 */
476
+ status?: string;
477
+ /** 完整数据 */
478
+ fullData?: any;
479
+ /** 事件类型 */
480
+ eventType?: string;
481
+ /** 等待消息提示 */
482
+ waitingMessage?: string;
483
+ }
484
+
485
+ /**
486
+ * MessageBubble - 消息气泡组件
487
+ *
488
+ * @example
489
+ * ```tsx
490
+ * 使用默认交互
491
+ * <MessageBubble
492
+ * content="这是AI的回复,支持**Markdown**格式"
493
+ * role="bot"
494
+ * status="Success"
495
+ * references={[
496
+ * { title: '参考文档1', text: '文档内容...', type: 'rag' }
497
+ * ]}
498
+ * />
499
+ *
500
+ * // 自定义交互
501
+ * <MessageBubble
502
+ * content="这是AI的回复"
503
+ * references={references}
504
+ * onReferenceClick={(item) => console.log('自定义处理', item)}
505
+ * onWebSearchClick={(items) => console.log('自定义处理', items)}
506
+ * />
507
+ * ```
508
+ */
509
+ export declare const MessageBubble: default_2.FC<MessageBubbleProps>;
510
+
511
+ export declare interface MessageBubbleProps {
512
+ /** 消息内容(Markdown格式) */
513
+ content: string;
514
+ /** 消息角色 */
515
+ role?: 'user' | 'bot';
516
+ /** 渲染状态 */
517
+ status?: 'Running' | 'Success' | 'Error';
518
+ /** 参考资料列表 */
519
+ references?: DocReferenceItem[];
520
+ /** 自定义类名 */
521
+ className?: string;
522
+ /** 自定义样式 */
523
+ style?: default_2.CSSProperties;
524
+ /** 点击参考资料回调(不传则使用默认实现) */
525
+ onReferenceClick?: (item: DocReferenceItem) => void;
526
+ /** 点击网页搜索结果回调(不传则使用默认实现) */
527
+ onWebSearchClick?: (items: DocReferenceItem[]) => void;
528
+ /** 事件类型(用于特殊消息如 humanVerify、historyCard) */
529
+ eventType?: 'humanVerify' | 'historyCard';
530
+ /** HumanVerify 相关数据 */
531
+ humanVerifyData?: HumanVerifyData;
532
+ /** HistoryCard 相关数据(历史对话中的审核卡片) */
533
+ historyCardData?: HistoryCardData;
534
+ /** HumanVerify 提交回调 */
535
+ onHumanVerifySubmit?: (data: HumanVerifySubmitData) => void;
536
+ }
537
+
538
+ export declare interface ModelCapabilities {
539
+ image: boolean;
540
+ file: boolean;
541
+ audio: boolean;
542
+ webSearch: boolean;
543
+ fileConfig?: {
544
+ supportFileTypes?: string[];
545
+ limit?: number;
546
+ description?: string;
547
+ };
548
+ }
549
+
550
+ export declare interface ModelInfo {
551
+ id: string;
552
+ name: string;
553
+ config?: {
554
+ image?: boolean;
555
+ file?: boolean;
556
+ webSearch?: boolean;
557
+ fileConfig?: string;
558
+ };
559
+ }
560
+
561
+ declare type ParamType = 'string' | 'number' | 'boolean' | 'array' | 'object';
562
+
563
+ /**
564
+ * RichBubbleContent - 富文本消息气泡核心展示组件
565
+ *
566
+ * @example
567
+ * ```tsx
568
+ * // Markdown类型
569
+ * <RichBubbleContent
570
+ * content="# 标题\n正文内容"
571
+ * messageType="markdown"
572
+ * status="Success"
573
+ * />
574
+ *
575
+ * // Rich类型(包含多种内容)
576
+ * <RichBubbleContent
577
+ * content={JSON.stringify([
578
+ * { messageType: 'markdown', content: '# 分析结果' },
579
+ * { messageType: 'ant_table', content: JSON.stringify({ column: ['A', 'B'], data: [{A: 1, B: 2}] }) },
580
+ * { messageType: 'echart', content: JSON.stringify({ option: {...} }) }
581
+ * ])}
582
+ * messageType="rich"
583
+ * status="Success"
584
+ * >
585
+ * <DocReferences items={references} />
586
+ * </RichBubbleContent>
587
+ * ```
588
+ */
589
+ export declare const RichBubbleContent: default_2.FC<RichBubbleContentProps>;
590
+
591
+ export declare interface RichBubbleContentProps {
592
+ /** 消息内容 */
593
+ content: string;
594
+ /** 消息类型 */
595
+ messageType?: 'markdown' | 'rich';
596
+ /** 渲染状态 */
597
+ status?: 'Running' | 'Success' | 'Error';
598
+ /** 消息角色 */
599
+ role?: 'user' | 'bot';
600
+ /** 自定义类名 */
601
+ className?: string;
602
+ /** 自定义样式 */
603
+ style?: default_2.CSSProperties;
604
+ /** 子元素(如参考资料组件) */
605
+ children?: default_2.ReactNode;
606
+ /** 等待消息文本,由外层传入 */
607
+ waitingMessage?: string;
608
+ }
609
+
610
+ /**
611
+ * RichBubble 上下文
612
+ * 用于在 RichBubbleContent 和子组件(如 ECharts)之间共享折叠面板状态
613
+ */
614
+ export declare interface RichBubbleContextValue {
615
+ /** 当前激活的折叠面板 key */
616
+ activeKey: string | string[];
617
+ }
618
+
619
+ export declare const RichBubbleProvider: Provider<RichBubbleContextValue>;
620
+
621
+ /**
622
+ * RichMessageBubble - 富文本消息气泡组件
623
+ *
624
+ * @example
625
+ * ```tsx
626
+ * // 使用默认交互
627
+ * <RichMessageBubble
628
+ * content="# 标题\n正文内容"
629
+ * messageType="markdown"
630
+ * status="Success"
631
+ * references={[
632
+ * { title: '参考文档1', text: '文档内容...', type: 'rag' }
633
+ * ]}
634
+ * />
635
+ *
636
+ * // 自定义交互
637
+ * <RichMessageBubble
638
+ * content={JSON.stringify([
639
+ * { messageType: 'markdown', content: '# 分析结果' },
640
+ * { messageType: 'echart', content: JSON.stringify({ option: {...} }) }
641
+ * ])}
642
+ * messageType="rich"
643
+ * references={references}
644
+ * onReferenceClick={(item) => console.log('自定义处理', item)}
645
+ * onWebSearchClick={(items) => console.log('自定义处理', items)}
646
+ * />
647
+ * ```
648
+ */
649
+ export declare const RichMessageBubble: default_2.FC<RichMessageBubbleProps>;
650
+
651
+ export declare interface RichMessageBubbleProps {
652
+ /** 消息内容 */
653
+ content: string;
654
+ /** 消息类型 */
655
+ messageType?: 'markdown' | 'rich';
656
+ /** 渲染状态 */
657
+ status?: 'Running' | 'Success' | 'Error';
658
+ /** 参考资料列表 */
659
+ references?: DocReferenceItem[];
660
+ /** 自定义类名 */
661
+ className?: string;
662
+ /** 自定义样式 */
663
+ style?: default_2.CSSProperties;
664
+ /** 点击参考资料回调(不传则使用默认实现) */
665
+ onReferenceClick?: (item: DocReferenceItem) => void;
666
+ /** 点击网页搜索结果回调(不传则使用默认实现) */
667
+ onWebSearchClick?: (items: DocReferenceItem[]) => void;
668
+ }
669
+
670
+ /**
671
+ * ChatService - 独立的聊天服务类
672
+ * 用于自定义UI场景,不依赖React
673
+ */
674
+ export declare interface SetupConfig {
675
+ integrateId: string;
676
+ domain?: string;
677
+ access_session_token?: string;
678
+ }
679
+
680
+ /**
681
+ * SourceContent - 参考资料核心展示组件
682
+ *
683
+ * @example
684
+ * ```tsx
685
+ * <SourceContent
686
+ * items={[
687
+ * { title: '参考文档1', text: '内容...', index: '1', type: 'rag' },
688
+ * { title: '搜索结果1', url: 'https://...', type: 'web_search' }
689
+ * ]}
690
+ * status="Success"
691
+ * onItemClick={(item) => console.log('点击了', item)}
692
+ * onWebSearchClick={(items) => console.log('网页搜索', items)}
693
+ * />
694
+ * ```
695
+ */
696
+ export declare const SourceContent: default_2.FC<SourceContentProps>;
697
+
698
+ export declare interface SourceContentProps {
699
+ /** 参考资料列表 */
700
+ items: SourceItem[];
701
+ /** 渲染状态 */
702
+ status?: 'Running' | 'Success' | 'Error' | string;
703
+ /** 是否使用大写字段名(PageConfig模式) */
704
+ isPageConfig?: boolean;
705
+ /** 点击参考资料回调 */
706
+ onItemClick?: (item: SourceItem) => void;
707
+ /** 点击网页搜索结果回调 */
708
+ onWebSearchClick?: (items: SourceItem[]) => void;
709
+ /** 自定义类名 */
710
+ className?: string;
711
+ /** 自定义样式 */
712
+ style?: default_2.CSSProperties;
713
+ }
714
+
715
+ export declare interface SourceItem {
716
+ /** 标题 */
717
+ title?: string;
718
+ Title?: string;
719
+ /** 内容文本 */
720
+ text?: string;
721
+ Text?: string;
722
+ /** 索引序号 */
723
+ index?: string;
724
+ Index?: string;
725
+ /** 类型:rag-知识库, web_search-网页搜索 */
726
+ type?: 'rag' | 'web_search' | string;
727
+ Type?: string;
728
+ /** 图片列表 */
729
+ images?: string[];
730
+ Images?: string[];
731
+ /** 链接URL(网页搜索结果) */
732
+ url?: string;
733
+ Url?: string;
734
+ /** 文档ID */
735
+ doc_id?: string;
736
+ doc_name?: string;
737
+ index_id?: string;
738
+ }
739
+
740
+ /**
741
+ * 使用 CustomParamsRenderer 的 Hook
742
+ * 提供表单值管理和校验功能
743
+ */
744
+ export declare const useCustomParamsRenderer: (schema: CustomParamSchema) => {
745
+ value: Record<string, any>;
746
+ setValue: default_2.Dispatch<default_2.SetStateAction<Record<string, any>>>;
747
+ validate: () => ValidationResult;
748
+ reset: () => void;
749
+ setFieldValue: (fieldName: string, fieldValue: any) => void;
750
+ getFieldValue: (fieldName: string) => any;
751
+ };
752
+
753
+ export declare const useRichBubbleContext: () => RichBubbleContextValue;
754
+
755
+ /**
756
+ * 校验 CustomParams 的值
757
+ * @param schema Schema 定义
758
+ * @param value 表单值
759
+ * @param prefix 字段名前缀
760
+ * @returns 校验结果
761
+ */
762
+ export declare const validateCustomParams: (schema: CustomParamSchema, value: Record<string, any>, prefix?: string) => ValidationResult;
763
+
764
+ /**
765
+ * 校验错误信息
766
+ */
767
+ export declare interface ValidationError {
768
+ field: string;
769
+ message: string;
770
+ }
771
+
772
+ /**
773
+ * 校验结果
774
+ */
775
+ export declare interface ValidationResult {
776
+ valid: boolean;
777
+ errors: ValidationError[];
778
+ }
779
+
780
+ /**
781
+ * WebSearchContent - 网页搜索结果核心展示组件
782
+ *
783
+ * @example
784
+ * ```tsx
785
+ * <WebSearchContent
786
+ * items={[
787
+ * { title: '搜索结果1', text: '内容摘要...', url: 'https://...' }
788
+ * ]}
789
+ * open={true}
790
+ * onClose={() => setOpen(false)}
791
+ * />
792
+ * ```
793
+ */
794
+ export declare const WebSearchContent: default_2.FC<WebSearchContentProps>;
795
+
796
+ export declare interface WebSearchContentProps {
797
+ /** 搜索结果列表 */
798
+ items?: WebSearchItem[];
799
+ /** 是否显示 */
800
+ open?: boolean;
801
+ /** 关闭回调 */
802
+ onClose?: () => void;
803
+ /** 是否使用大写字段名(PageConfig模式) */
804
+ isPageConfig?: boolean;
805
+ /** 面板宽度 */
806
+ width?: number | string;
807
+ /** 挂载容器 */
808
+ getContainer?: () => HTMLElement;
809
+ /** 自定义类名 */
810
+ className?: string;
811
+ /** 自定义样式 */
812
+ style?: default_2.CSSProperties;
813
+ }
814
+
815
+ export declare interface WebSearchItem {
816
+ /** 标题 */
817
+ title?: string;
818
+ Title?: string;
819
+ /** 内容摘要 */
820
+ text?: string;
821
+ Text?: string;
822
+ /** 链接URL */
823
+ url?: string;
824
+ Url?: string;
825
+ }
826
+
827
+ /**
828
+ * WebSearchPanel - 网页搜索结果面板组件
829
+ *
830
+ * @example
831
+ * ```tsx
832
+ * const [open, setOpen] = useState(false);
833
+ * const [searchResults, setSearchResults] = useState([]);
834
+ *
835
+ * <WebSearchPanel
836
+ * items={searchResults}
837
+ * open={open}
838
+ * onClose={() => setOpen(false)}
839
+ * width={400}
840
+ * />
841
+ * ```
842
+ */
843
+ export declare const WebSearchPanel: default_2.FC<WebSearchPanelProps>;
844
+
845
+ export declare interface WebSearchPanelProps {
846
+ /** 搜索结果列表 */
847
+ items: WebSearchItem[];
848
+ /** 是否显示 */
849
+ open: boolean;
850
+ /** 关闭回调 */
851
+ onClose: () => void;
852
+ /** 面板宽度 */
853
+ width?: number | string;
854
+ /** 挂载容器 */
855
+ getContainer?: () => HTMLElement;
856
+ /** 自定义类名 */
857
+ className?: string;
858
+ /** 自定义样式 */
859
+ style?: default_2.CSSProperties;
860
+ }
861
+
862
+ export { }