@zero-library/chat-copilot 1.0.1 → 1.0.3
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.cjs.js +1038 -1017
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +91 -70
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +123 -68
- package/dist/index.d.ts +123 -68
- package/dist/index.esm.js +1004 -983
- package/dist/index.esm.js.map +1 -1
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import react__default from 'react';
|
|
2
|
+
import react__default, { ReactNode } from 'react';
|
|
3
|
+
import { BubbleProps } from '@ant-design/x-v2';
|
|
3
4
|
import { ButtonProps, ThemeConfig } from 'antd';
|
|
4
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
6
|
import { createRequest, RequestConfig, RenderControl } from '@zero-library/common';
|
|
@@ -66,10 +67,10 @@ interface AgentConfig {
|
|
|
66
67
|
}
|
|
67
68
|
interface AgentInfo {
|
|
68
69
|
id: string;
|
|
69
|
-
name
|
|
70
|
-
description
|
|
71
|
-
iconUrl
|
|
72
|
-
agentType
|
|
70
|
+
name?: string;
|
|
71
|
+
description?: string;
|
|
72
|
+
iconUrl?: string;
|
|
73
|
+
agentType?: AgentTypeEnum;
|
|
73
74
|
updatedAt?: string;
|
|
74
75
|
tagIds?: string[];
|
|
75
76
|
spec?: AgentSpec;
|
|
@@ -77,6 +78,65 @@ interface AgentInfo {
|
|
|
77
78
|
userInput?: Variable[];
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
/**
|
|
82
|
+
* ChatSender 组件暴露的方法接口
|
|
83
|
+
*/
|
|
84
|
+
interface ChatSenderHandle {
|
|
85
|
+
/** 聚焦输入框 */
|
|
86
|
+
focus: (options?: {
|
|
87
|
+
cursor?: 'start' | 'end';
|
|
88
|
+
}) => void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 文件上传配置接口
|
|
92
|
+
*/
|
|
93
|
+
interface FileUpload {
|
|
94
|
+
/** 上传时的额外参数 */
|
|
95
|
+
params?: ObjectType<any>;
|
|
96
|
+
/** 文件上传配置列表 */
|
|
97
|
+
config: FileUploadConfig;
|
|
98
|
+
/** 文件上传请求函数 */
|
|
99
|
+
request: AttachmentsProps['fileUpload'];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* ChatSender 组件属性接口
|
|
103
|
+
*/
|
|
104
|
+
interface SenderProps {
|
|
105
|
+
/** 输入框占位符 */
|
|
106
|
+
placeholder?: string;
|
|
107
|
+
/** 输入框内容 */
|
|
108
|
+
content?: string;
|
|
109
|
+
/** 文件列表 */
|
|
110
|
+
fileList?: InputFile[];
|
|
111
|
+
/** 是否打开文件选择头部 */
|
|
112
|
+
headerOpen?: boolean;
|
|
113
|
+
/** 是否正在发送消息 */
|
|
114
|
+
loading?: boolean;
|
|
115
|
+
/** 内容变化回调 */
|
|
116
|
+
onContentChange: (value: string) => void;
|
|
117
|
+
/** 文件列表变化回调 */
|
|
118
|
+
onFileListChange: (files: InputFile[]) => void;
|
|
119
|
+
/** 头部打开状态变化回调 */
|
|
120
|
+
onHeaderOpenChange: (open: boolean) => void;
|
|
121
|
+
/** 发送消息回调 */
|
|
122
|
+
onSend: () => void;
|
|
123
|
+
/** 取消发送回调 */
|
|
124
|
+
onCancel?: () => void;
|
|
125
|
+
/** 输入框聚焦回调 */
|
|
126
|
+
onFocus?: () => void;
|
|
127
|
+
/** 头部额外内容 */
|
|
128
|
+
extraHeader?: React.ReactNode;
|
|
129
|
+
/** 底部额外内容 */
|
|
130
|
+
extraFooter?: React.ReactNode;
|
|
131
|
+
/** 底部下方额外内容 */
|
|
132
|
+
extraFooterBelow?: React.ReactNode;
|
|
133
|
+
/** 发送按钮属性 */
|
|
134
|
+
sendBtnProps?: ButtonProps;
|
|
135
|
+
/** 文件上传配置 */
|
|
136
|
+
fileUpload?: FileUpload;
|
|
137
|
+
}
|
|
138
|
+
declare const _default$3: react.ForwardRefExoticComponent<SenderProps & react.RefAttributes<ChatSenderHandle>>;
|
|
139
|
+
|
|
80
140
|
interface UserInputType {
|
|
81
141
|
inputs: Variable[];
|
|
82
142
|
outputs: Variable[];
|
|
@@ -238,9 +298,13 @@ interface ConvMeta {
|
|
|
238
298
|
* 1 正常 2 debug
|
|
239
299
|
*/
|
|
240
300
|
mode?: number;
|
|
301
|
+
/** 项目或知识库ID */
|
|
241
302
|
libraryId?: string;
|
|
303
|
+
/** 会话来源 */
|
|
242
304
|
source?: number;
|
|
305
|
+
/** 项目或知识库类型 */
|
|
243
306
|
libraryType?: LibraryTypeEnum;
|
|
307
|
+
/** 技能会话ID */
|
|
244
308
|
skillConversationId?: string;
|
|
245
309
|
}
|
|
246
310
|
|
|
@@ -291,6 +355,18 @@ interface FileUrlType {
|
|
|
291
355
|
fileUrl?: string;
|
|
292
356
|
ext?: string;
|
|
293
357
|
}
|
|
358
|
+
interface FirstMessageRenderCtx {
|
|
359
|
+
index: number;
|
|
360
|
+
member: 1 | 2;
|
|
361
|
+
}
|
|
362
|
+
interface FirstMessage extends Omit<BubbleProps, 'content' | 'contentRender' | 'role' | 'placement'> {
|
|
363
|
+
/** 会话成员类型 */
|
|
364
|
+
member?: 1 | 2;
|
|
365
|
+
/** 直接传入要展示的节点 */
|
|
366
|
+
content?: ReactNode;
|
|
367
|
+
/** 动态生成要展示的节点 */
|
|
368
|
+
contentRender?: (ctx: FirstMessageRenderCtx) => ReactNode;
|
|
369
|
+
}
|
|
294
370
|
/**
|
|
295
371
|
* 消息引用类型
|
|
296
372
|
* 用于消息回复时的引用信息
|
|
@@ -300,8 +376,6 @@ interface MessageQuoteMsg {
|
|
|
300
376
|
id?: string;
|
|
301
377
|
/** 被引用的消息内容 */
|
|
302
378
|
msgContent?: string;
|
|
303
|
-
/** 被引用消息的附件文件列表 */
|
|
304
|
-
msgFiles?: InputFile[];
|
|
305
379
|
}
|
|
306
380
|
/**
|
|
307
381
|
* 引用内容接口
|
|
@@ -483,11 +557,17 @@ type MessageEvent = RunStartedEvent | TextEvent | FilesEvent | StepStartedEvent
|
|
|
483
557
|
* 定义智能体和用户之间的消息结构
|
|
484
558
|
*/
|
|
485
559
|
interface ConversationMessage {
|
|
560
|
+
/** 消息ID */
|
|
486
561
|
messageId: string;
|
|
562
|
+
/** 会话ID */
|
|
487
563
|
conversationId: string;
|
|
564
|
+
/** 执行ID */
|
|
488
565
|
executionId: string;
|
|
566
|
+
/** 角色:1-智能体 2-用户 */
|
|
489
567
|
role: number;
|
|
568
|
+
/** 消息内容 */
|
|
490
569
|
content: MessageEvent[];
|
|
570
|
+
/** 上传文件内容 */
|
|
491
571
|
files?: InputFile[];
|
|
492
572
|
/** 消息反馈:1-赞 2-踩 */
|
|
493
573
|
feedback?: number;
|
|
@@ -495,6 +575,7 @@ interface ConversationMessage {
|
|
|
495
575
|
params?: string;
|
|
496
576
|
/** 引用的消息信息 */
|
|
497
577
|
quoteMsg?: MessageQuoteMsg;
|
|
578
|
+
/** 创建时间 */
|
|
498
579
|
createdAt: string;
|
|
499
580
|
/** 是否被打断标志 */
|
|
500
581
|
stopFlag?: boolean;
|
|
@@ -563,6 +644,21 @@ interface ChatHandle {
|
|
|
563
644
|
* chatRef.current?.switchConversation(item)
|
|
564
645
|
*/
|
|
565
646
|
switchConversation: (id: ConversationType['id']) => Promise<void>;
|
|
647
|
+
/**
|
|
648
|
+
* 切换智能体会话
|
|
649
|
+
* 切换到指定的智能体并创建或获取会话
|
|
650
|
+
*
|
|
651
|
+
* @param agentId - 目标智能体ID
|
|
652
|
+
* @param strategy - 会话策略,1-使用最近会话,2-创建新会话
|
|
653
|
+
*
|
|
654
|
+
* @example
|
|
655
|
+
* // 切换到指定智能体并创建新会话
|
|
656
|
+
* chatRef.current?.switchAgentConversation('agent-001')
|
|
657
|
+
*
|
|
658
|
+
* @example
|
|
659
|
+
* // 切换到指定智能体并使用最近会话
|
|
660
|
+
* chatRef.current?.switchAgentConversation('agent-001', 1)
|
|
661
|
+
*/
|
|
566
662
|
/**
|
|
567
663
|
* 基于当前接收者创建新的会话
|
|
568
664
|
*
|
|
@@ -594,6 +690,7 @@ interface ChatHandle {
|
|
|
594
690
|
* // 清除引用
|
|
595
691
|
* chatRef.current?.setReferences()
|
|
596
692
|
*/
|
|
693
|
+
setReferences: (references?: ReferencesType) => void;
|
|
597
694
|
/**
|
|
598
695
|
* 直接设置输入框中的文本内容
|
|
599
696
|
*
|
|
@@ -1078,6 +1175,12 @@ interface ChatHooks {
|
|
|
1078
1175
|
* }
|
|
1079
1176
|
*/
|
|
1080
1177
|
onAppRightVerify?: (appKey: string) => boolean | Promise<boolean> | void;
|
|
1178
|
+
/**
|
|
1179
|
+
* 文件预览前回调函数
|
|
1180
|
+
* 在文件预览打开前调用,返回false可阻止预览
|
|
1181
|
+
* @param file - 被预览的文件对象, 如果不存在则表示正在关闭预览
|
|
1182
|
+
* @param isBuiltIn - 是否为内嵌布局
|
|
1183
|
+
*/
|
|
1081
1184
|
onBeforeFilePreview?: (file?: FileUrlType, isBuiltIn?: boolean) => boolean | Promise<boolean> | void;
|
|
1082
1185
|
/**
|
|
1083
1186
|
* 文件预览后的回调函数
|
|
@@ -1249,7 +1352,7 @@ interface ChatLayoutWelcomeMessage {
|
|
|
1249
1352
|
*/
|
|
1250
1353
|
interface ChatLayoutMessageList {
|
|
1251
1354
|
/** 首条消息配置 */
|
|
1252
|
-
firstMessages?:
|
|
1355
|
+
firstMessages?: FirstMessage[];
|
|
1253
1356
|
/** 头像显示控制:可以是全局布尔值或按成员类型分别控制 */
|
|
1254
1357
|
avatar?: boolean | Partial<Record<ConversationMemberEnum, boolean>>;
|
|
1255
1358
|
/** 智能体消息操作区渲染控制 */
|
|
@@ -1357,67 +1460,21 @@ interface AttachmentsProps {
|
|
|
1357
1460
|
/** 文件列表变化回调函数 */
|
|
1358
1461
|
onChange: (fileList: InputFile[]) => void;
|
|
1359
1462
|
}
|
|
1360
|
-
|
|
1361
1463
|
/**
|
|
1362
|
-
*
|
|
1363
|
-
|
|
1364
|
-
interface ChatSenderHandle {
|
|
1365
|
-
/** 聚焦输入框 */
|
|
1366
|
-
focus: (options?: {
|
|
1367
|
-
cursor?: 'start' | 'end';
|
|
1368
|
-
}) => void;
|
|
1369
|
-
}
|
|
1370
|
-
/**
|
|
1371
|
-
* 文件上传配置接口
|
|
1464
|
+
* 附件上传组件
|
|
1465
|
+
* 支持多文件上传、文件类型验证、文件大小限制等功能
|
|
1372
1466
|
*/
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
}
|
|
1381
|
-
/**
|
|
1382
|
-
* ChatSender 组件属性接口
|
|
1383
|
-
*/
|
|
1384
|
-
interface SenderProps {
|
|
1385
|
-
/** 输入框占位符 */
|
|
1386
|
-
placeholder?: string;
|
|
1387
|
-
/** 输入框内容 */
|
|
1388
|
-
content?: string;
|
|
1389
|
-
/** 文件列表 */
|
|
1390
|
-
fileList?: InputFile[];
|
|
1391
|
-
/** 是否打开文件选择头部 */
|
|
1392
|
-
headerOpen?: boolean;
|
|
1393
|
-
/** 是否正在发送消息 */
|
|
1394
|
-
loading?: boolean;
|
|
1395
|
-
/** 内容变化回调 */
|
|
1396
|
-
onContentChange: (value: string) => void;
|
|
1397
|
-
/** 文件列表变化回调 */
|
|
1398
|
-
onFileListChange: (files: InputFile[]) => void;
|
|
1399
|
-
/** 头部打开状态变化回调 */
|
|
1400
|
-
onHeaderOpenChange: (open: boolean) => void;
|
|
1401
|
-
/** 发送消息回调 */
|
|
1402
|
-
onSend: () => void;
|
|
1403
|
-
/** 取消发送回调 */
|
|
1404
|
-
onCancel?: () => void;
|
|
1405
|
-
/** 输入框聚焦回调 */
|
|
1406
|
-
onFocus?: () => void;
|
|
1407
|
-
/** 头部额外内容 */
|
|
1408
|
-
extraHeader?: React.ReactNode;
|
|
1409
|
-
/** 底部额外内容 */
|
|
1410
|
-
extraFooter?: React.ReactNode;
|
|
1411
|
-
/** 底部下方额外内容 */
|
|
1412
|
-
extraFooterBelow?: React.ReactNode;
|
|
1413
|
-
/** 发送按钮属性 */
|
|
1414
|
-
sendBtnProps?: ButtonProps;
|
|
1415
|
-
/** 文件上传配置 */
|
|
1416
|
-
fileUpload?: FileUpload;
|
|
1467
|
+
declare const _default$2: react.ForwardRefExoticComponent<AttachmentsProps & react.RefAttributes<unknown>>;
|
|
1468
|
+
|
|
1469
|
+
interface RoleContent {
|
|
1470
|
+
role: number;
|
|
1471
|
+
user: ConversationMemberEnum;
|
|
1472
|
+
placement: BubbleProps['placement'];
|
|
1473
|
+
avatar?: any;
|
|
1417
1474
|
}
|
|
1418
|
-
declare const _default$3: react.ForwardRefExoticComponent<SenderProps & react.RefAttributes<ChatSenderHandle>>;
|
|
1419
1475
|
|
|
1420
1476
|
interface MessageRenderProps {
|
|
1477
|
+
role: RoleContent;
|
|
1421
1478
|
message: ConversationMessage;
|
|
1422
1479
|
messageIndex?: number;
|
|
1423
1480
|
loading?: boolean;
|
|
@@ -1426,10 +1483,8 @@ interface MessageRenderProps {
|
|
|
1426
1483
|
/** message自定义标记渲染组件 */
|
|
1427
1484
|
customComponents?: ChatLayoutMessageList['customComponents'];
|
|
1428
1485
|
}
|
|
1429
|
-
declare const _default$
|
|
1430
|
-
|
|
1431
|
-
declare const _default$1: ({ firstMessages, welcomeMessage, avatar, agentActions, customComponents }: ChatLayoutMessageList) => react_jsx_runtime.JSX.Element;
|
|
1486
|
+
declare const _default$1: react__default.MemoExoticComponent<({ role, message, messageIndex, loading, containerRef, customComponents }: MessageRenderProps) => react_jsx_runtime.JSX.Element>;
|
|
1432
1487
|
|
|
1433
1488
|
declare const _default: react.ForwardRefExoticComponent<ChatProps & react.RefAttributes<ChatHandle>>;
|
|
1434
1489
|
|
|
1435
|
-
export { type AgentConfig, type AgentInfo, type AgentSpec, _default$
|
|
1490
|
+
export { type AgentConfig, type AgentInfo, type AgentSpec, _default$2 as Attachments, type AttachmentsProps, type ChatConfig, _default as ChatCopilot, type ChatHandle, type ChatHooks, type ChatLayout, type ChatParams, type ChatProps, _default$3 as ChatSender, type ChatServices, type ConversationMessage, type ConversationStrategy, type FileUploadConfig, type InputFile, _default$1 as MessageRender, type MessageRenderProps, type ReferencesType, type RequestInstance, type SenderProps };
|