@tdesign-react/chat 1.0.0 → 1.0.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.
|
@@ -4,7 +4,7 @@ import React from 'react';
|
|
|
4
4
|
*/
|
|
5
5
|
export interface ToolcallComponentProps<TArgs extends object = any, TResult = any, TResponse = any> {
|
|
6
6
|
/** 组件的当前渲染状态 */
|
|
7
|
-
status: 'idle' | '
|
|
7
|
+
status: 'idle' | 'executing' | 'complete' | 'error';
|
|
8
8
|
/** Agent 调用时传入的初始参数 */
|
|
9
9
|
args: TArgs;
|
|
10
10
|
/** 当 status 为 'complete' 时,包含 Toolcall 的最终执行结果 */
|
|
@@ -20,8 +20,12 @@ export interface ToolcallComponentProps<TArgs extends object = any, TResult = an
|
|
|
20
20
|
}
|
|
21
21
|
interface NonInteractiveToolcallConfig<TArgs extends object, TResult> {
|
|
22
22
|
name: string;
|
|
23
|
-
description
|
|
24
|
-
parameters
|
|
23
|
+
description?: string;
|
|
24
|
+
parameters?: Array<{
|
|
25
|
+
name: string;
|
|
26
|
+
type: string;
|
|
27
|
+
required?: boolean;
|
|
28
|
+
}>;
|
|
25
29
|
/** 业务逻辑执行器,支持可选的后端结果作为第二个参数 */
|
|
26
30
|
handler: (args: TArgs, backendResult?: any) => Promise<TResult>;
|
|
27
31
|
/** 状态显示组件 */
|
|
@@ -32,7 +36,11 @@ interface NonInteractiveToolcallConfig<TArgs extends object, TResult> {
|
|
|
32
36
|
interface InteractiveToolcallConfig<TArgs extends object, TResult, TResponse> {
|
|
33
37
|
name: string;
|
|
34
38
|
description: string;
|
|
35
|
-
parameters?:
|
|
39
|
+
parameters?: Array<{
|
|
40
|
+
name: string;
|
|
41
|
+
type: string;
|
|
42
|
+
required?: boolean;
|
|
43
|
+
}>;
|
|
36
44
|
/** 交互式UI组件 */
|
|
37
45
|
component: React.FC<ToolcallComponentProps<TArgs, TResult, TResponse>>;
|
|
38
46
|
/** handler 属性不存在,以此作为区分标志 */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../../../pro-components/chat/chat-engine/components/toolcall/types.ts"],"sourcesContent":["import React from 'react';\n\n/**\n * 智能体可交互组件的标准 Props 接口\n */\nexport interface ToolcallComponentProps<TArgs extends object = any, TResult = any, TResponse = any> {\n /** 组件的当前渲染状态 */\n status: 'idle' | '
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../../pro-components/chat/chat-engine/components/toolcall/types.ts"],"sourcesContent":["import React from 'react';\n\n/**\n * 智能体可交互组件的标准 Props 接口\n */\nexport interface ToolcallComponentProps<TArgs extends object = any, TResult = any, TResponse = any> {\n /** 组件的当前渲染状态 */\n status: 'idle' | 'executing' | 'complete' | 'error';\n /** Agent 调用时传入的初始参数 */\n args: TArgs;\n /** 当 status 为 'complete' 时,包含 Toolcall 的最终执行结果 */\n result?: TResult;\n /** 当 status 为 'error' 时,包含错误信息 */\n error?: Error;\n /**\n * 【交互核心】一个回调函数,用于将用户的交互结果返回给宿主环境。\n * 仅在\"交互式\"场景下由宿主提供。\n */\n respond?: (response: TResponse) => void;\n agentState?: Record<string, any>;\n}\n\n// 场景一:非交互式 Toolcall 的配置 (有 handler)\ninterface NonInteractiveToolcallConfig<TArgs extends object, TResult> {\n name: string;\n description?: string;\n parameters?: Array<{ name: string; type: string; required?: boolean }>;\n /** 业务逻辑执行器,支持可选的后端结果作为第二个参数 */\n handler: (args: TArgs, backendResult?: any) => Promise<TResult>;\n /** 状态显示组件 */\n component: React.FC<ToolcallComponentProps<TArgs, TResult>>;\n /** 订阅statekey提取函数 */\n subscribeKey?: (props: ToolcallComponentProps<TArgs, TResult>) => string | undefined;\n}\n\n// 场景二:交互式 Toolcall 的配置 (无 handler)\ninterface InteractiveToolcallConfig<TArgs extends object, TResult, TResponse> {\n name: string;\n description: string;\n parameters?: Array<{ name: string; type: string; required?: boolean }>;\n /** 交互式UI组件 */\n component: React.FC<ToolcallComponentProps<TArgs, TResult, TResponse>>;\n /** handler 属性不存在,以此作为区分标志 */\n handler?: never;\n /** 订阅statekey提取函数 */\n subscribeKey?: (props: ToolcallComponentProps<TArgs, TResult>) => string | undefined;\n}\n\n// 最终的配置类型\nexport type AgentToolcallConfig<TArgs extends object = any, TResult = any, TResponse = any> =\n | NonInteractiveToolcallConfig<TArgs, TResult>\n | InteractiveToolcallConfig<TArgs, TResult, TResponse>;\n\n// 类型守卫:判断是否为非交互式配置\nexport function isNonInteractive<TArgs extends object, TResult>(\n config: AgentToolcallConfig<TArgs, TResult, any>,\n): config is NonInteractiveToolcallConfig<TArgs, TResult> {\n return typeof (config as any).handler === 'function';\n}\n\n// Agent Toolcall 注册表\nexport interface AgentToolcallRegistry {\n [ToolcallName: string]: AgentToolcallConfig;\n}\n\n// 内部状态管理\nexport interface AgentToolcallState<TArgs extends object = any, TResult = any> {\n status: ToolcallComponentProps['status'];\n args?: TArgs;\n result?: TResult;\n error?: Error;\n}\n\n// 类型守卫函数\nexport const isNonInteractiveConfig = (cfg: AgentToolcallConfig): cfg is AgentToolcallConfig & { handler: Function } =>\n typeof (cfg as any).handler === 'function';\n"],"names":["isNonInteractive","config","handler","isNonInteractiveConfig","cfg"],"mappings":";;;;;;AAsDO,SAASA,iBACdC,MACwD,EAAA;AACjD,EAAA,OAAA,OAAQA,OAAeC,OAAY,KAAA,UAAA,CAAA;AAC5C,CAAA;IAgBaC,sBAAyB,GAAA,SAAzBA,sBAAyBA,CAACC,GACrC,EAAA;AAAA,EAAA,OAAA,OAAQA,IAAYF,OAAY,KAAA,UAAA,CAAA;AAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tdesign-react/chat",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"title": "@tdesign-react/chat",
|
|
5
5
|
"description": "TDesign Pro Component for AIGC",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@babel/runtime": "~7.26.7",
|
|
54
|
-
"tdesign-web-components": "1.2.
|
|
54
|
+
"tdesign-web-components": "1.2.6",
|
|
55
55
|
"classnames": "~2.5.1",
|
|
56
56
|
"lodash-es": "^4.17.21",
|
|
57
57
|
"zod": "^3.24.2",
|