@tdesign-react/chat 1.0.0 → 1.0.2-alpha.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.
- package/es/_util/reactify.js +1 -1
- package/es/_util/useDynamicStyle.js +1 -1
- package/es/chat-actionbar/_example-js/base.d.ts +2 -0
- package/es/chat-actionbar/_example-js/custom.d.ts +2 -0
- package/es/chat-actionbar/_example-js/style.d.ts +2 -0
- package/es/chat-actionbar/index.js +1 -1
- package/es/chat-attachments/_example-js/base.d.ts +2 -0
- package/es/chat-attachments/_example-js/scroll-x.d.ts +2 -0
- package/es/chat-attachments/_example-js/scroll-y.d.ts +2 -0
- package/es/chat-attachments/index.js +1 -1
- package/es/chat-engine/_example-js/agui-basic.d.ts +10 -0
- package/es/chat-engine/_example-js/agui-comprehensive.d.ts +2 -0
- package/es/chat-engine/_example-js/agui-test.d.ts +11 -0
- package/es/chat-engine/_example-js/agui-toolcall.d.ts +5 -0
- package/es/chat-engine/_example-js/agui-videoclip.d.ts +8 -0
- package/es/chat-engine/_example-js/agui.d.ts +1 -0
- package/es/chat-engine/_example-js/basic.d.ts +9 -0
- package/es/chat-engine/_example-js/components/HotelCard.d.ts +3 -0
- package/es/chat-engine/_example-js/components/HumanInputForm.d.ts +6 -0
- package/es/chat-engine/_example-js/components/HumanInputResult.d.ts +3 -0
- package/es/chat-engine/_example-js/components/ItineraryCard.d.ts +3 -0
- package/es/chat-engine/_example-js/components/PlanningStatePanel.d.ts +4 -0
- package/es/chat-engine/_example-js/components/Toolcall.d.ts +4 -0
- package/es/chat-engine/_example-js/components/WeatherCard.d.ts +3 -0
- package/es/chat-engine/_example-js/components/login.d.ts +1 -0
- package/es/chat-engine/_example-js/comprehensive.d.ts +12 -0
- package/es/chat-engine/_example-js/custom-content.d.ts +1 -0
- package/es/chat-engine/_example-js/hookComponent.d.ts +1 -0
- package/es/chat-engine/_example-js/initial-messages.d.ts +9 -0
- package/es/chat-engine/_example-js/instance-methods.d.ts +13 -0
- package/es/chat-engine/_example-js/travel-actions.d.ts +91 -0
- package/es/chat-engine/_example-js/travelToolcall.d.ts +1 -0
- package/es/chat-engine/components/provider/agent-state.js +1 -1
- package/es/chat-engine/components/toolcall/index.js +1 -1
- package/es/chat-engine/components/toolcall/registry.js +1 -1
- package/es/chat-engine/components/toolcall/render.js +1 -1
- package/es/chat-engine/components/toolcall/types.d.ts +12 -4
- package/es/chat-engine/components/toolcall/types.js +1 -1
- package/es/chat-engine/components/toolcall/types.js.map +1 -1
- package/es/chat-engine/core/adapters/agui/event-mapper.d.ts +104 -0
- package/es/chat-engine/core/adapters/agui/event-mapper.js +348 -0
- package/es/chat-engine/core/adapters/agui/event-mapper.js.map +1 -0
- package/es/chat-engine/core/adapters/agui/events.d.ts +1394 -0
- package/es/chat-engine/core/adapters/agui/events.js +181 -0
- package/es/chat-engine/core/adapters/agui/events.js.map +1 -0
- package/es/chat-engine/core/adapters/agui/index.d.ts +75 -0
- package/es/chat-engine/core/adapters/agui/index.js +165 -0
- package/es/chat-engine/core/adapters/agui/index.js.map +1 -0
- package/es/chat-engine/core/adapters/agui/state-manager.d.ts +99 -0
- package/es/chat-engine/core/adapters/agui/state-manager.js +168 -0
- package/es/chat-engine/core/adapters/agui/state-manager.js.map +1 -0
- package/es/chat-engine/core/adapters/agui/types.d.ts +760 -0
- package/es/chat-engine/core/adapters/agui/types.js +89 -0
- package/es/chat-engine/core/adapters/agui/types.js.map +1 -0
- package/es/chat-engine/core/adapters/agui/utils.d.ts +180 -0
- package/es/chat-engine/core/adapters/agui/utils.js +302 -0
- package/es/chat-engine/core/adapters/agui/utils.js.map +1 -0
- package/es/chat-engine/core/index.d.ts +132 -0
- package/es/chat-engine/core/index.js +597 -0
- package/es/chat-engine/core/index.js.map +1 -0
- package/es/chat-engine/core/processor/index.d.ts +20 -0
- package/es/chat-engine/core/processor/index.js +146 -0
- package/es/chat-engine/core/processor/index.js.map +1 -0
- package/es/chat-engine/core/server/batch-client.d.ts +20 -0
- package/es/chat-engine/core/server/batch-client.js +114 -0
- package/es/chat-engine/core/server/batch-client.js.map +1 -0
- package/es/chat-engine/core/server/connection-manager.d.ts +39 -0
- package/es/chat-engine/core/server/connection-manager.js +84 -0
- package/es/chat-engine/core/server/connection-manager.js.map +1 -0
- package/es/chat-engine/core/server/errors.d.ts +22 -0
- package/es/chat-engine/core/server/errors.js +80 -0
- package/es/chat-engine/core/server/errors.js.map +1 -0
- package/es/chat-engine/core/server/index.d.ts +11 -0
- package/es/chat-engine/core/server/index.js +26 -0
- package/es/chat-engine/core/server/index.js.map +1 -0
- package/es/chat-engine/core/server/llm-service.d.ts +44 -0
- package/es/chat-engine/core/server/llm-service.js +198 -0
- package/es/chat-engine/core/server/llm-service.js.map +1 -0
- package/es/chat-engine/core/server/sse-client.d.ts +77 -0
- package/es/chat-engine/core/server/sse-client.js +362 -0
- package/es/chat-engine/core/server/sse-client.js.map +1 -0
- package/es/chat-engine/core/server/sse-parser.d.ts +49 -0
- package/es/chat-engine/core/server/sse-parser.js +116 -0
- package/es/chat-engine/core/server/sse-parser.js.map +1 -0
- package/es/chat-engine/core/server/types.d.ts +54 -0
- package/es/chat-engine/core/server/types.js +28 -0
- package/es/chat-engine/core/server/types.js.map +1 -0
- package/es/chat-engine/core/store/message.d.ts +27 -0
- package/es/chat-engine/core/store/message.js +263 -0
- package/es/chat-engine/core/store/message.js.map +1 -0
- package/es/chat-engine/core/store/model.d.ts +8 -0
- package/es/chat-engine/core/store/model.js +65 -0
- package/es/chat-engine/core/store/model.js.map +1 -0
- package/es/chat-engine/core/store/reactiveState.d.ts +52 -0
- package/es/chat-engine/core/store/reactiveState.js +1359 -0
- package/es/chat-engine/core/store/reactiveState.js.map +1 -0
- package/es/chat-engine/core/type.d.ts +248 -0
- package/es/chat-engine/core/type.js +7 -0
- package/es/chat-engine/core/type.js.map +1 -0
- package/es/chat-engine/core/utils/eventEmitter.d.ts +10 -0
- package/es/chat-engine/core/utils/eventEmitter.js +67 -0
- package/es/chat-engine/core/utils/eventEmitter.js.map +1 -0
- package/es/chat-engine/core/utils/index.d.ts +32 -0
- package/es/chat-engine/core/utils/index.js +996 -0
- package/es/chat-engine/core/utils/index.js.map +1 -0
- package/es/chat-engine/core/utils/logger.d.ts +30 -0
- package/es/chat-engine/core/utils/logger.js +87 -0
- package/es/chat-engine/core/utils/logger.js.map +1 -0
- package/es/chat-engine/hooks/useAgentState.js +1 -1
- package/es/chat-engine/hooks/useAgentToolcall.js +1 -1
- package/es/chat-engine/hooks/useChat.js +1 -1
- package/es/chat-engine/index.js +1 -1
- package/es/chat-filecard/_example-js/base.d.ts +1 -0
- package/es/chat-filecard/index.js +1 -1
- package/es/chat-loading/_example-js/base.d.ts +2 -0
- package/es/chat-loading/_example-js/text.d.ts +2 -0
- package/es/chat-loading/index.js +1 -1
- package/es/chat-markdown/_example-js/base.d.ts +1 -0
- package/es/chat-markdown/_example-js/custom.d.ts +2 -0
- package/es/chat-markdown/_example-js/event.d.ts +1 -0
- package/es/chat-markdown/_example-js/footnote.d.ts +2 -0
- package/es/chat-markdown/_example-js/plugin.d.ts +2 -0
- package/es/chat-markdown/_example-js/theme.d.ts +2 -0
- package/es/chat-markdown/index.js +1 -1
- package/es/chat-message/_example-js/action.d.ts +1 -0
- package/es/chat-message/_example-js/base.d.ts +1 -0
- package/es/chat-message/_example-js/configure.d.ts +1 -0
- package/es/chat-message/_example-js/content.d.ts +1 -0
- package/es/chat-message/_example-js/custom.d.ts +1 -0
- package/es/chat-message/_example-js/handle-actions.d.ts +7 -0
- package/es/chat-message/_example-js/status.d.ts +1 -0
- package/es/chat-message/_example-js/think.d.ts +1 -0
- package/es/chat-message/index.js +1 -1
- package/es/chat-sender/_example-js/attachment.d.ts +2 -0
- package/es/chat-sender/_example-js/base.d.ts +2 -0
- package/es/chat-sender/_example-js/custom.d.ts +2 -0
- package/es/chat-sender/index.js +1 -1
- package/es/chat-thinking/_example-js/base.d.ts +1 -0
- package/es/chat-thinking/_example-js/style.d.ts +1 -0
- package/es/chat-thinking/index.js +1 -1
- package/es/chatbot/_example-js/agent.d.ts +1 -0
- package/es/chatbot/_example-js/agui.d.ts +13 -0
- package/es/chatbot/_example-js/backup/travel.d.ts +1 -0
- package/es/chatbot/_example-js/basic.d.ts +1 -0
- package/es/chatbot/_example-js/code.d.ts +1 -0
- package/es/chatbot/_example-js/components/ItineraryCard.d.ts +3 -0
- package/es/chatbot/_example-js/components/login.d.ts +1 -0
- package/es/chatbot/_example-js/comprehensive.d.ts +1 -0
- package/es/chatbot/_example-js/custom-content.d.ts +1 -0
- package/es/chatbot/_example-js/custom-merge.d.ts +1 -0
- package/es/chatbot/_example-js/custom.d.ts +1 -0
- package/es/chatbot/_example-js/docs.d.ts +1 -0
- package/es/chatbot/_example-js/image.d.ts +1 -0
- package/es/chatbot/_example-js/initial-messages.d.ts +9 -0
- package/es/chatbot/_example-js/instance-methods.d.ts +14 -0
- package/es/chatbot/_example-js/nostream.d.ts +1 -0
- package/es/chatbot/_example-js/quick-start.d.ts +9 -0
- package/es/chatbot/_example-js/research.d.ts +1 -0
- package/es/chatbot/_example-js/role-message-config.d.ts +22 -0
- package/es/chatbot/_example-js/sender-config.d.ts +20 -0
- package/es/chatbot/_example-js/service-config.d.ts +17 -0
- package/es/chatbot/_example-js/simple.d.ts +1 -0
- package/es/chatbot/_example-js/utils/messageRenderer.d.ts +5 -0
- package/es/chatbot/index.js +1 -1
- package/es/index.d.ts +0 -1
- package/es/index.js +1 -1
- package/es/style/index.js +1 -1
- package/package.json +4 -6
package/es/_util/reactify.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AG-UI 协议基础示例
|
|
3
|
+
*
|
|
4
|
+
* 学习目标:
|
|
5
|
+
* - 开启 AG-UI 协议支持(protocol: 'agui')
|
|
6
|
+
* - 理解 AG-UI 协议的自动解析机制
|
|
7
|
+
* - 处理文本消息事件(TEXT_MESSAGE_*)
|
|
8
|
+
* - 初始化加载历史消息方法 AGUIAdapter.convertHistoryMessages
|
|
9
|
+
*/
|
|
10
|
+
export default function AguiBasicExample(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AG-UI 协议基础示例
|
|
3
|
+
*
|
|
4
|
+
* 学习目标:
|
|
5
|
+
* - 开启 AG-UI 协议支持(protocol: 'agui')
|
|
6
|
+
* - 理解 AG-UI 协议的自动解析机制
|
|
7
|
+
* - 处理文本消息事件(TEXT_MESSAGE_*)
|
|
8
|
+
* - 初始化加载历史消息方法 AGUIAdapter.convertHistoryMessages
|
|
9
|
+
* - 调试 ToolCall 组件状态问题
|
|
10
|
+
*/
|
|
11
|
+
export default function AguiBasicExample(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 使用状态订阅机制的视频剪辑Agent聊天组件
|
|
3
|
+
* 演示如何结合状态订阅和工具调用功能
|
|
4
|
+
*/
|
|
5
|
+
export default function VideoClipAgentChatWithSubscription(): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export function VideoClipSteps({ boundStateKey }: {
|
|
7
|
+
boundStateKey: any;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function ComponentsBuild(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function BaseForm(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function CustomContent(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function ComponentsBuild(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 实例方法示例
|
|
3
|
+
*
|
|
4
|
+
* 学习目标:
|
|
5
|
+
* - 通过 chatEngine 调用实例方法
|
|
6
|
+
* - 了解各种实例方法的使用场景
|
|
7
|
+
*
|
|
8
|
+
* 方法分类:
|
|
9
|
+
* 1. 消息设置:sendUserMessage、sendSystemMessage、setMessages
|
|
10
|
+
* 2. 发送控制: regenerateAIMessage、abortChat
|
|
11
|
+
* 3. 获取状态
|
|
12
|
+
*/
|
|
13
|
+
export default function InstanceMethods(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export namespace weatherForecastAction {
|
|
2
|
+
export let name: string;
|
|
3
|
+
export let description: string;
|
|
4
|
+
export let parameters: {
|
|
5
|
+
name: string;
|
|
6
|
+
type: string;
|
|
7
|
+
required: boolean;
|
|
8
|
+
}[];
|
|
9
|
+
export { WeatherDisplay as component };
|
|
10
|
+
}
|
|
11
|
+
export namespace itineraryPlanAction {
|
|
12
|
+
let name_1: string;
|
|
13
|
+
export { name_1 as name };
|
|
14
|
+
let description_1: string;
|
|
15
|
+
export { description_1 as description };
|
|
16
|
+
let parameters_1: {
|
|
17
|
+
name: string;
|
|
18
|
+
type: string;
|
|
19
|
+
required: boolean;
|
|
20
|
+
}[];
|
|
21
|
+
export { parameters_1 as parameters };
|
|
22
|
+
export { PlanItinerary as component };
|
|
23
|
+
export function handler(args: any, backendResult: any): Promise<any>;
|
|
24
|
+
}
|
|
25
|
+
export namespace hotelRecommendAction {
|
|
26
|
+
let name_2: string;
|
|
27
|
+
export { name_2 as name };
|
|
28
|
+
let description_2: string;
|
|
29
|
+
export { description_2 as description };
|
|
30
|
+
let parameters_2: {
|
|
31
|
+
name: string;
|
|
32
|
+
type: string;
|
|
33
|
+
required: boolean;
|
|
34
|
+
}[];
|
|
35
|
+
export { parameters_2 as parameters };
|
|
36
|
+
export { HotelRecommend as component };
|
|
37
|
+
}
|
|
38
|
+
export namespace travelPreferencesAction {
|
|
39
|
+
let name_3: string;
|
|
40
|
+
export { name_3 as name };
|
|
41
|
+
let description_3: string;
|
|
42
|
+
export { description_3 as description };
|
|
43
|
+
let parameters_3: {
|
|
44
|
+
name: string;
|
|
45
|
+
type: string;
|
|
46
|
+
required: boolean;
|
|
47
|
+
}[];
|
|
48
|
+
export { parameters_3 as parameters };
|
|
49
|
+
export { TravelPreferences as component };
|
|
50
|
+
}
|
|
51
|
+
export const travelActions: {
|
|
52
|
+
name: string;
|
|
53
|
+
description: string;
|
|
54
|
+
parameters: {
|
|
55
|
+
name: string;
|
|
56
|
+
type: string;
|
|
57
|
+
required: boolean;
|
|
58
|
+
}[];
|
|
59
|
+
component: ({ status, args, result, error }: {
|
|
60
|
+
status: any;
|
|
61
|
+
args: any;
|
|
62
|
+
result: any;
|
|
63
|
+
error: any;
|
|
64
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
}[];
|
|
66
|
+
declare function WeatherDisplay({ status, args, result, error }: {
|
|
67
|
+
status: any;
|
|
68
|
+
args: any;
|
|
69
|
+
result: any;
|
|
70
|
+
error: any;
|
|
71
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
72
|
+
declare function PlanItinerary({ status, args, result, error }: {
|
|
73
|
+
status: any;
|
|
74
|
+
args: any;
|
|
75
|
+
result: any;
|
|
76
|
+
error: any;
|
|
77
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
78
|
+
declare function HotelRecommend({ status, args, result, error }: {
|
|
79
|
+
status: any;
|
|
80
|
+
args: any;
|
|
81
|
+
result: any;
|
|
82
|
+
error: any;
|
|
83
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
84
|
+
declare function TravelPreferences({ status, args, result, error, respond }: {
|
|
85
|
+
status: any;
|
|
86
|
+
args: any;
|
|
87
|
+
result: any;
|
|
88
|
+
error: any;
|
|
89
|
+
respond: any;
|
|
90
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
91
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function TravelPlannerChat(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -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;;;;"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { AIMessageContent, SSEChunkData, ToolCall } from '../../type';
|
|
2
|
+
/**
|
|
3
|
+
* AGUIEventMapper
|
|
4
|
+
* 将AG-UI协议事件(SSEChunkData)转换为AIContentChunkUpdate
|
|
5
|
+
* 支持多轮对话、增量文本、工具调用、思考、状态快照、消息快照等基础事件
|
|
6
|
+
* 同时提供状态变更和步骤生命周期事件的分发机制
|
|
7
|
+
*/
|
|
8
|
+
export declare class AGUIEventMapper {
|
|
9
|
+
private toolCallMap;
|
|
10
|
+
private toolCallEnded;
|
|
11
|
+
private reasoningContext;
|
|
12
|
+
/**
|
|
13
|
+
* 主入口:将SSE事件转换为AIContentChunkUpdate
|
|
14
|
+
*
|
|
15
|
+
* @param chunk SSE数据块,其中data字段可能是字符串(需要解析)或已解析的对象
|
|
16
|
+
*/
|
|
17
|
+
mapEvent(chunk: SSEChunkData): AIMessageContent | AIMessageContent[] | null;
|
|
18
|
+
/**
|
|
19
|
+
* 获取当前所有工具调用
|
|
20
|
+
*/
|
|
21
|
+
getToolCalls(): ToolCall[];
|
|
22
|
+
/**
|
|
23
|
+
* 清除指定工具调用
|
|
24
|
+
*/
|
|
25
|
+
clearToolCall(toolCallId: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* 获取指定工具调用
|
|
28
|
+
*/
|
|
29
|
+
getToolCall(toolCallId: string): ToolCall | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* 检查工具调用是否已结束
|
|
32
|
+
*/
|
|
33
|
+
isToolCallEnded(toolCallId: string): boolean;
|
|
34
|
+
reset(): void;
|
|
35
|
+
/**
|
|
36
|
+
* 处理文本消息事件
|
|
37
|
+
*/
|
|
38
|
+
private handleTextMessageEvent;
|
|
39
|
+
/**
|
|
40
|
+
* 处理思考事件
|
|
41
|
+
*/
|
|
42
|
+
private handleThinkingEvent;
|
|
43
|
+
/**
|
|
44
|
+
* 处理工具调用事件
|
|
45
|
+
*/
|
|
46
|
+
private handleToolCallEvent;
|
|
47
|
+
/**
|
|
48
|
+
* 处理状态事件
|
|
49
|
+
*/
|
|
50
|
+
private handleStateEvent;
|
|
51
|
+
/**
|
|
52
|
+
* 处理其他事件
|
|
53
|
+
*/
|
|
54
|
+
private handleOtherEvent;
|
|
55
|
+
/**
|
|
56
|
+
* 处理思考开始事件
|
|
57
|
+
*/
|
|
58
|
+
private handleThinkingStart;
|
|
59
|
+
/**
|
|
60
|
+
* 处理思考文本开始事件
|
|
61
|
+
*/
|
|
62
|
+
private handleThinkingTextStart;
|
|
63
|
+
/**
|
|
64
|
+
* 处理思考文本内容事件
|
|
65
|
+
*/
|
|
66
|
+
private handleThinkingTextContent;
|
|
67
|
+
/**
|
|
68
|
+
* 处理思考文本结束事件
|
|
69
|
+
*/
|
|
70
|
+
private handleThinkingTextEnd;
|
|
71
|
+
/**
|
|
72
|
+
* 处理思考结束事件
|
|
73
|
+
*/
|
|
74
|
+
private handleThinkingEnd;
|
|
75
|
+
/**
|
|
76
|
+
* 处理工具调用开始事件
|
|
77
|
+
*/
|
|
78
|
+
private handleToolCallStart;
|
|
79
|
+
/**
|
|
80
|
+
* 处理工具调用参数事件
|
|
81
|
+
*/
|
|
82
|
+
private handleToolCallArgs;
|
|
83
|
+
/**
|
|
84
|
+
* 处理工具调用块事件
|
|
85
|
+
*/
|
|
86
|
+
private handleToolCallChunk;
|
|
87
|
+
/**
|
|
88
|
+
* 处理工具调用结果事件
|
|
89
|
+
*/
|
|
90
|
+
private handleToolCallResult;
|
|
91
|
+
/**
|
|
92
|
+
* 处理工具调用结束事件
|
|
93
|
+
*/
|
|
94
|
+
private handleToolCallEnd;
|
|
95
|
+
/**
|
|
96
|
+
* 在上下文中更新工具调用
|
|
97
|
+
*/
|
|
98
|
+
private updateToolCallInContext;
|
|
99
|
+
/**
|
|
100
|
+
* 重置 reasoning 上下文
|
|
101
|
+
*/
|
|
102
|
+
private resetReasoningContext;
|
|
103
|
+
}
|
|
104
|
+
export default AGUIEventMapper;
|