@tdesign-react/chat 1.0.2-alpha.5 → 1.0.2-alpha.7
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.d.ts +2 -1
- package/es/_util/reactify.js +231 -81
- package/es/_util/reactify.js.map +1 -1
- package/es/_util/useDynamicStyle.js +1 -1
- package/es/attachments/index.js +6 -4
- package/es/attachments/index.js.map +1 -1
- package/es/chat-actionbar/index.js +6 -4
- package/es/chat-actionbar/index.js.map +1 -1
- package/es/chat-attachments/index.js +1 -3
- package/es/chat-attachments/index.js.map +1 -1
- 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 +12 -12
- package/es/chat-engine/components/toolcall/render.js.map +1 -1
- package/es/chat-engine/components/toolcall/types.js +1 -1
- 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/index.js +6 -4
- package/es/chat-filecard/index.js.map +1 -1
- package/es/chat-loading/index.js +6 -4
- package/es/chat-loading/index.js.map +1 -1
- package/es/chat-markdown/index.js +6 -4
- package/es/chat-markdown/index.js.map +1 -1
- package/es/chat-message/index.js +6 -4
- package/es/chat-message/index.js.map +1 -1
- package/es/chat-sender/index.js +6 -4
- package/es/chat-sender/index.js.map +1 -1
- package/es/chat-thinking/index.js +6 -4
- package/es/chat-thinking/index.js.map +1 -1
- package/es/chatbot/components/provider/agent-state.d.ts +5 -0
- package/es/chatbot/components/provider/agent-state.js +28 -0
- package/es/chatbot/components/provider/agent-state.js.map +1 -0
- package/es/chatbot/components/toolcall/index.d.ts +3 -0
- package/es/chatbot/components/toolcall/index.js +19 -0
- package/es/chatbot/components/toolcall/index.js.map +1 -0
- package/es/chatbot/components/toolcall/registry.d.ts +35 -0
- package/es/chatbot/components/toolcall/registry.js +75 -0
- package/es/chatbot/components/toolcall/registry.js.map +1 -0
- package/es/chatbot/components/toolcall/render.d.ts +13 -0
- package/es/chatbot/components/toolcall/render.js +207 -0
- package/es/chatbot/components/toolcall/render.js.map +1 -0
- package/es/chatbot/components/toolcall/types.d.ts +57 -0
- package/es/chatbot/components/toolcall/types.js +15 -0
- package/es/chatbot/components/toolcall/types.js.map +1 -0
- package/es/chatbot/hooks/useAgentState.d.ts +40 -0
- package/es/chatbot/hooks/useAgentState.js +76 -0
- package/es/chatbot/hooks/useAgentState.js.map +1 -0
- package/es/chatbot/hooks/useAgentToolcall.d.ts +28 -0
- package/es/chatbot/hooks/useAgentToolcall.js +78 -0
- package/es/chatbot/hooks/useAgentToolcall.js.map +1 -0
- package/es/chatbot/hooks/useChat.d.ts +11 -0
- package/es/chatbot/hooks/useChat.js +66 -0
- package/es/chatbot/hooks/useChat.js.map +1 -0
- package/es/chatbot/index.js +6 -4
- package/es/chatbot/index.js.map +1 -1
- package/es/index.js +6 -5
- package/es/index.js.map +1 -1
- package/es/style/index.js +1 -1
- package/package.json +2 -2
- package/es/chat-actionbar/_example-js/base.d.ts +0 -2
- package/es/chat-actionbar/_example-js/custom.d.ts +0 -2
- package/es/chat-actionbar/_example-js/style.d.ts +0 -2
- package/es/chat-attachments/_example-js/base.d.ts +0 -2
- package/es/chat-attachments/_example-js/scroll-x.d.ts +0 -2
- package/es/chat-attachments/_example-js/scroll-y.d.ts +0 -2
- package/es/chat-engine/_example-js/agui-basic.d.ts +0 -10
- package/es/chat-engine/_example-js/agui-comprehensive.d.ts +0 -2
- package/es/chat-engine/_example-js/agui-test.d.ts +0 -11
- package/es/chat-engine/_example-js/agui-toolcall.d.ts +0 -5
- package/es/chat-engine/_example-js/agui-videoclip.d.ts +0 -8
- package/es/chat-engine/_example-js/agui.d.ts +0 -1
- package/es/chat-engine/_example-js/basic.d.ts +0 -9
- package/es/chat-engine/_example-js/components/HotelCard.d.ts +0 -3
- package/es/chat-engine/_example-js/components/HumanInputForm.d.ts +0 -6
- package/es/chat-engine/_example-js/components/HumanInputResult.d.ts +0 -3
- package/es/chat-engine/_example-js/components/ItineraryCard.d.ts +0 -3
- package/es/chat-engine/_example-js/components/PlanningStatePanel.d.ts +0 -4
- package/es/chat-engine/_example-js/components/Toolcall.d.ts +0 -4
- package/es/chat-engine/_example-js/components/WeatherCard.d.ts +0 -3
- package/es/chat-engine/_example-js/components/login.d.ts +0 -1
- package/es/chat-engine/_example-js/comprehensive.d.ts +0 -12
- package/es/chat-engine/_example-js/custom-content.d.ts +0 -1
- package/es/chat-engine/_example-js/hookComponent.d.ts +0 -1
- package/es/chat-engine/_example-js/initial-messages.d.ts +0 -9
- package/es/chat-engine/_example-js/instance-methods.d.ts +0 -13
- package/es/chat-engine/_example-js/travel-actions.d.ts +0 -91
- package/es/chat-engine/_example-js/travelToolcall.d.ts +0 -1
- package/es/chat-filecard/_example-js/base.d.ts +0 -1
- package/es/chat-loading/_example-js/base.d.ts +0 -2
- package/es/chat-loading/_example-js/text.d.ts +0 -2
- package/es/chat-markdown/_example-js/base.d.ts +0 -1
- package/es/chat-markdown/_example-js/custom.d.ts +0 -2
- package/es/chat-markdown/_example-js/event.d.ts +0 -1
- package/es/chat-markdown/_example-js/footnote.d.ts +0 -2
- package/es/chat-markdown/_example-js/plugin.d.ts +0 -2
- package/es/chat-markdown/_example-js/theme.d.ts +0 -2
- package/es/chat-message/_example-js/action.d.ts +0 -1
- package/es/chat-message/_example-js/base.d.ts +0 -1
- package/es/chat-message/_example-js/configure.d.ts +0 -1
- package/es/chat-message/_example-js/content.d.ts +0 -1
- package/es/chat-message/_example-js/custom.d.ts +0 -1
- package/es/chat-message/_example-js/handle-actions.d.ts +0 -7
- package/es/chat-message/_example-js/status.d.ts +0 -1
- package/es/chat-message/_example-js/think.d.ts +0 -1
- package/es/chat-sender/_example-js/attachment.d.ts +0 -2
- package/es/chat-sender/_example-js/base.d.ts +0 -2
- package/es/chat-sender/_example-js/custom.d.ts +0 -2
- package/es/chat-thinking/_example-js/base.d.ts +0 -1
- package/es/chat-thinking/_example-js/style.d.ts +0 -1
- package/es/chatbot/_example-js/agent.d.ts +0 -1
- package/es/chatbot/_example-js/agui-toolcall.d.ts +0 -11
- package/es/chatbot/_example-js/agui.d.ts +0 -13
- package/es/chatbot/_example-js/backup/travel.d.ts +0 -1
- package/es/chatbot/_example-js/basic.d.ts +0 -1
- package/es/chatbot/_example-js/code.d.ts +0 -1
- package/es/chatbot/_example-js/components/ItineraryCard.d.ts +0 -3
- package/es/chatbot/_example-js/components/login.d.ts +0 -1
- package/es/chatbot/_example-js/comprehensive.d.ts +0 -1
- package/es/chatbot/_example-js/custom-content.d.ts +0 -1
- package/es/chatbot/_example-js/custom-merge.d.ts +0 -1
- package/es/chatbot/_example-js/custom.d.ts +0 -1
- package/es/chatbot/_example-js/docs.d.ts +0 -1
- package/es/chatbot/_example-js/image.d.ts +0 -1
- package/es/chatbot/_example-js/initial-messages.d.ts +0 -9
- package/es/chatbot/_example-js/instance-methods.d.ts +0 -14
- package/es/chatbot/_example-js/nostream.d.ts +0 -1
- package/es/chatbot/_example-js/quick-start.d.ts +0 -9
- package/es/chatbot/_example-js/research.d.ts +0 -1
- package/es/chatbot/_example-js/role-message-config.d.ts +0 -22
- package/es/chatbot/_example-js/sender-config.d.ts +0 -20
- package/es/chatbot/_example-js/service-config.d.ts +0 -17
- package/es/chatbot/_example-js/simple.d.ts +0 -1
- package/es/chatbot/_example-js/utils/messageRenderer.d.ts +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../pro-components/chat/chat-actionbar/index.tsx"],"sourcesContent":["import { TdChatActionProps } from 'tdesign-web-components';\nimport 'tdesign-web-components/lib/chat-action';\nimport reactify from '../_util/reactify';\n\nexport const ChatActionBar: React.ForwardRefExoticComponent<\n Omit<TdChatActionProps, 'ref'> &\n React.RefAttributes<HTMLElement | undefined> & {\n [key: string]: any;\n }\n> = reactify<TdChatActionProps>('t-chat-action');\n\nexport default ChatActionBar;\nexport type { TdChatActionProps, TdChatActionsName } from 'tdesign-web-components';\n\n// 方案1\n// import { reactifyLazy } from './_util/reactifyLazy';\n// const ChatActionBar = reactifyLazy<{\n// size: 'small' | 'medium' | 'large',\n// variant: 'primary' | 'secondary' | 'outline'\n// }>(\n// 't-chat-action',\n// 'tdesign-web-components/esm/chat-action'\n// );\n\n// import ChatAction from 'tdesign-web-components/esm/chat-action';\n// import React, { forwardRef, useEffect } from 'react';\n\n// // 注册Web Components组件\n// const registerChatAction = () => {\n// if (!customElements.get('t-chat-action')) {\n// customElements.define('t-chat-action', ChatAction);\n// }\n// };\n\n// // 在组件挂载时注册\n// const useRegisterWebComponent = () => {\n// useEffect(() => {\n// registerChatAction();\n// }, []);\n// };\n\n// // 使用reactify创建React组件\n// const BaseChatActionBar = reactify<TdChatActionProps>('t-chat-action');\n\n// // 包装组件,确保Web Components已注册\n// export const ChatActionBar2 = forwardRef<\n// HTMLElement | undefined,\n// Omit<TdChatActionProps, 'ref'> & { [key: string]: any }\n// >((props, ref) => {\n// useRegisterWebComponent();\n// return <BaseChatActionBar {...props} ref={ref} />;\n// });\n"],"names":["ChatActionBar","reactify"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../pro-components/chat/chat-actionbar/index.tsx"],"sourcesContent":["import { TdChatActionProps } from 'tdesign-web-components';\nimport 'tdesign-web-components/lib/chat-action';\nimport reactify from '../_util/reactify';\n\nexport const ChatActionBar: React.ForwardRefExoticComponent<\n Omit<TdChatActionProps, 'ref'> &\n React.RefAttributes<HTMLElement | undefined> & {\n [key: string]: any;\n }\n> = reactify<TdChatActionProps>('t-chat-action');\n\nexport default ChatActionBar;\nexport type { TdChatActionProps, TdChatActionsName } from 'tdesign-web-components';\n\n// 方案1\n// import { reactifyLazy } from './_util/reactifyLazy';\n// const ChatActionBar = reactifyLazy<{\n// size: 'small' | 'medium' | 'large',\n// variant: 'primary' | 'secondary' | 'outline'\n// }>(\n// 't-chat-action',\n// 'tdesign-web-components/esm/chat-action'\n// );\n\n// import ChatAction from 'tdesign-web-components/esm/chat-action';\n// import React, { forwardRef, useEffect } from 'react';\n\n// // 注册Web Components组件\n// const registerChatAction = () => {\n// if (!customElements.get('t-chat-action')) {\n// customElements.define('t-chat-action', ChatAction);\n// }\n// };\n\n// // 在组件挂载时注册\n// const useRegisterWebComponent = () => {\n// useEffect(() => {\n// registerChatAction();\n// }, []);\n// };\n\n// // 使用reactify创建React组件\n// const BaseChatActionBar = reactify<TdChatActionProps>('t-chat-action');\n\n// // 包装组件,确保Web Components已注册\n// export const ChatActionBar2 = forwardRef<\n// HTMLElement | undefined,\n// Omit<TdChatActionProps, 'ref'> & { [key: string]: any }\n// >((props, ref) => {\n// useRegisterWebComponent();\n// return <BaseChatActionBar {...props} ref={ref} />;\n// });\n"],"names":["ChatActionBar","reactify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAIaA,aAAA,GAKTC,SAA4B,eAAe;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tdesign v1.0.
|
|
2
|
+
* tdesign v1.0.0-beta.4
|
|
3
3
|
* (c) 2025 tdesign
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -17,8 +17,6 @@ import '@babel/runtime/helpers/defineProperty';
|
|
|
17
17
|
import '@babel/runtime/helpers/slicedToArray';
|
|
18
18
|
import '@babel/runtime/helpers/typeof';
|
|
19
19
|
import 'react';
|
|
20
|
-
import 'react-dom';
|
|
21
|
-
import 'react-dom/client';
|
|
22
20
|
|
|
23
21
|
var Attachments = reactify("t-attachments");
|
|
24
22
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../pro-components/chat/chat-attachments/index.ts"],"sourcesContent":["import { TdAttachmentsProps } from 'tdesign-web-components';\nimport 'tdesign-web-components/lib/attachments';\nimport reactify from '../_util/reactify';\n\nexport const Attachments: React.ForwardRefExoticComponent<\n Omit<TdAttachmentsProps, 'ref'> & React.RefAttributes<HTMLElement | undefined>\n> = reactify<TdAttachmentsProps>('t-attachments');\n\nexport default Attachments;\n\nexport type { TdAttachmentsProps, TdAttachmentItem } from 'tdesign-web-components';\n"],"names":["Attachments","reactify"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../pro-components/chat/chat-attachments/index.ts"],"sourcesContent":["import { TdAttachmentsProps } from 'tdesign-web-components';\nimport 'tdesign-web-components/lib/attachments';\nimport reactify from '../_util/reactify';\n\nexport const Attachments: React.ForwardRefExoticComponent<\n Omit<TdAttachmentsProps, 'ref'> & React.RefAttributes<HTMLElement | undefined>\n> = reactify<TdAttachmentsProps>('t-attachments');\n\nexport default Attachments;\n\nexport type { TdAttachmentsProps, TdAttachmentItem } from 'tdesign-web-components';\n"],"names":["Attachments","reactify"],"mappings":";;;;;;;;;;;;;;;;;;;;IAIaA,WAAA,GAETC,SAA6B,eAAe;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tdesign v1.0.2-alpha.
|
|
2
|
+
* tdesign v1.0.2-alpha.0
|
|
3
3
|
* (c) 2026 tdesign
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -61,8 +61,8 @@ var ToolCallRenderer = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
61
61
|
if (isNonInteractiveConfig(config)) {
|
|
62
62
|
var executeHandler = /*#__PURE__*/function () {
|
|
63
63
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
64
|
-
var backendResult, result
|
|
65
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
64
|
+
var backendResult, result;
|
|
65
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
66
66
|
while (1) switch (_context.prev = _context.next) {
|
|
67
67
|
case 0:
|
|
68
68
|
_context.prev = 0;
|
|
@@ -77,28 +77,28 @@ var ToolCallRenderer = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
77
77
|
backendResult = toolCall.result;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
_context.next =
|
|
80
|
+
_context.next = 5;
|
|
81
81
|
return config.handler(args, backendResult);
|
|
82
|
-
case
|
|
82
|
+
case 5:
|
|
83
83
|
result = _context.sent;
|
|
84
84
|
setActionState({
|
|
85
85
|
status: "complete",
|
|
86
86
|
result: result
|
|
87
87
|
});
|
|
88
|
-
_context.next =
|
|
88
|
+
_context.next = 12;
|
|
89
89
|
break;
|
|
90
|
-
case
|
|
91
|
-
_context.prev =
|
|
92
|
-
|
|
90
|
+
case 9:
|
|
91
|
+
_context.prev = 9;
|
|
92
|
+
_context.t0 = _context["catch"](0);
|
|
93
93
|
setActionState({
|
|
94
94
|
status: "error",
|
|
95
|
-
error:
|
|
95
|
+
error: _context.t0
|
|
96
96
|
});
|
|
97
|
-
case
|
|
97
|
+
case 12:
|
|
98
98
|
case "end":
|
|
99
99
|
return _context.stop();
|
|
100
100
|
}
|
|
101
|
-
}, _callee, null, [[0,
|
|
101
|
+
}, _callee, null, [[0, 9]]);
|
|
102
102
|
}));
|
|
103
103
|
return function executeHandler() {
|
|
104
104
|
return _ref2.apply(this, arguments);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sources":["../../../../../pro-components/chat/chat-engine/components/toolcall/render.tsx"],"sourcesContent":["import React, { useState, useEffect, useCallback, useMemo } from 'react';\nimport type { ToolCall } from 'tdesign-web-components/lib/chat-engine';\nimport { isNonInteractiveConfig, type ToolcallComponentProps } from './types';\nimport { agentToolcallRegistry } from './registry';\nimport { AgentStateContext, useAgentStateDataByKey } from '../../hooks/useAgentState';\n\ninterface ToolCallRendererProps {\n toolCall: ToolCall;\n onRespond?: (toolCall: ToolCall, response: any) => void;\n}\n\nexport const ToolCallRenderer = React.memo<ToolCallRendererProps>(\n ({ toolCall, onRespond }) => {\n const [actionState, setActionState] = useState<{\n status: ToolcallComponentProps['status'];\n result?: any;\n error?: Error;\n }>({\n status: 'idle',\n });\n\n // 缓存配置获取\n const config = useMemo(() => {\n const cfg = agentToolcallRegistry.get(toolCall.toolCallName);\n return cfg;\n }, [toolCall.toolCallName]);\n\n // 添加注册状态监听\n const [isRegistered, setIsRegistered] = useState(\n () => !!agentToolcallRegistry.getRenderFunction(toolCall.toolCallName),\n );\n\n // 缓存参数解析\n const args = useMemo(() => {\n try {\n return toolCall.args ? JSON.parse(toolCall.args) : {};\n } catch (error) {\n console.error('解析工具调用参数失败:', error);\n return {};\n }\n }, [toolCall.args]);\n\n const handleRespond = useCallback(\n (response: any) => {\n if (onRespond) {\n onRespond(toolCall, response);\n setActionState((prev) => ({\n ...prev,\n status: 'complete',\n result: response,\n }));\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [toolCall.toolCallId, onRespond],\n );\n\n // 执行 handler(如果存在)- 必须在条件判断之前调用\n useEffect(() => {\n if (!config) return;\n\n if (isNonInteractiveConfig(config)) {\n // 非交互式:执行 handler\n const executeHandler = async () => {\n try {\n setActionState({ status: 'executing' });\n\n // 解析后端返回的结果作为 handler 的第二个参数\n let backendResult;\n if (toolCall.result) {\n try {\n backendResult = JSON.parse(toolCall.result);\n } catch (error) {\n console.warn('解析后端结果失败,使用原始字符串:', error);\n backendResult = toolCall.result;\n }\n }\n\n // 调用 handler,传入 args 和 backendResult\n const result = await config.handler(args, backendResult);\n setActionState({\n status: 'complete',\n result,\n });\n } catch (error) {\n setActionState({\n status: 'error',\n error: error as Error,\n });\n }\n };\n\n executeHandler();\n } else if (toolCall.result) {\n // 交互式:已有结果,显示完成状态\n try {\n const result = JSON.parse(toolCall.result);\n setActionState({\n status: 'complete',\n result,\n });\n } catch (error) {\n setActionState({\n status: 'error',\n error: error as Error,\n });\n }\n } else {\n // 等待用户交互\n setActionState({ status: 'executing' });\n }\n }, [config, args, toolCall.result]);\n\n // 从配置中获取 subscribeKey 提取函数\n const subscribeKeyExtractor = useMemo(() => config?.subscribeKey, [config]);\n\n // 使用配置的提取函数来获取 targetStateKey\n const targetStateKey = useMemo(() => {\n if (!subscribeKeyExtractor) return undefined;\n\n // 构造完整的 props 对象传给提取函数\n const fullProps = {\n status: actionState.status,\n args,\n result: actionState.result,\n error: actionState.error,\n respond: handleRespond,\n };\n\n return subscribeKeyExtractor(fullProps);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [subscribeKeyExtractor, args, actionState]);\n\n // 监听组件注册事件, 无论何时注册,都能正确触发重新渲染\n useEffect(() => {\n if (!isRegistered) {\n const handleRegistered = (event: CustomEvent) => {\n if (event.detail?.name === toolCall.toolCallName) {\n setIsRegistered(true);\n }\n };\n\n // 添加事件监听\n window.addEventListener('toolcall-registered', handleRegistered as EventListener);\n\n return () => {\n window.removeEventListener('toolcall-registered', handleRegistered as EventListener);\n };\n }\n }, [toolCall.toolCallName, isRegistered]);\n\n // 使用精确订阅\n const agentState = useAgentStateDataByKey(targetStateKey);\n\n // 缓存组件 props\n const componentProps = useMemo<ToolcallComponentProps>(\n () => ({\n status: actionState.status,\n args,\n result: actionState.result,\n error: actionState.error,\n respond: handleRespond,\n agentState,\n }),\n [actionState.status, args, actionState.result, actionState.error, handleRespond, agentState],\n );\n\n // 使用registry的缓存渲染函数\n const MemoizedComponent = useMemo(\n () => agentToolcallRegistry.getRenderFunction(toolCall.toolCallName),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [toolCall.toolCallName, isRegistered],\n );\n\n if (!MemoizedComponent) {\n return null;\n }\n\n return <MemoizedComponent {...componentProps} />;\n },\n (prevProps, nextProps) =>\n prevProps.toolCall.toolCallId === nextProps.toolCall.toolCallId &&\n prevProps.toolCall.toolCallName === nextProps.toolCall.toolCallName &&\n prevProps.toolCall.args === nextProps.toolCall.args &&\n prevProps.toolCall.result === nextProps.toolCall.result &&\n prevProps.onRespond === nextProps.onRespond,\n);\n// 用于调试,可以在控制台查看每次渲染的参数\n// (prevProps, nextProps) => {\n// const toolCallIdSame = prevProps.toolCall.toolCallId === nextProps.toolCall.toolCallId;\n// const toolCallNameSame = prevProps.toolCall.toolCallName === nextProps.toolCall.toolCallName;\n// const argsSame = prevProps.toolCall.args === nextProps.toolCall.args;\n// const resultSame = prevProps.toolCall.result === nextProps.toolCall.result;\n// const onRespondSame = prevProps.onRespond === nextProps.onRespond;\n\n// console.log(`ToolCallRenderer memo 详细检查 [${prevProps.toolCall.toolCallName}]:`, {\n// toolCallIdSame,\n// toolCallNameSame,\n// argsSame,\n// resultSame,\n// onRespondSame,\n// prevToolCallId: prevProps.toolCall.toolCallId,\n// nextToolCallId: nextProps.toolCall.toolCallId,\n// prevOnRespond: prevProps.onRespond,\n// nextOnRespond: nextProps.onRespond,\n// });\n\n// const shouldSkip = toolCallIdSame && toolCallNameSame && argsSame && resultSame && onRespondSame;\n\n// console.log(`ToolCallRenderer memo 检查 [${prevProps.toolCall.toolCallName}]:`, shouldSkip ? '跳过渲染' : '需要重新渲染');\n// return shouldSkip\n// },\n// );\n\n// 定义增强后的 Props 类型\ntype WithAgentStateProps<P> = P & { agentState?: Record<string, any> };\n\nexport const withAgentStateToolcall1 = <P extends object>(\n Component: React.ComponentType<WithAgentStateProps<P>>,\n): React.ComponentType<P> => {\n const WrappedComponent: React.FC<P> = (props: P) => (\n <AgentStateContext.Consumer>\n {(context) => {\n if (!context) {\n console.warn('AgentStateContext not found, component will render without state');\n return <Component {...props} />;\n }\n\n return <Component {...props} agentState={context.stateMap} />;\n }}\n </AgentStateContext.Consumer>\n );\n\n WrappedComponent.displayName = `withAgentState(${Component.displayName || Component.name || 'Component'})`;\n return React.memo(WrappedComponent);\n};\n\nexport const withAgentStateToolcall = <P extends object>(\n Component: React.ComponentType<WithAgentStateProps<P>>,\n subscribeKeyExtractor?: (props: P) => string | undefined,\n): React.ComponentType<P> => {\n const WrappedComponent: React.FC<P> = (props: P) => {\n // 计算需要订阅的 stateKey\n const targetStateKey = useMemo(() => (subscribeKeyExtractor ? subscribeKeyExtractor(props) : undefined), [props]);\n\n const agentState = useAgentStateDataByKey(targetStateKey);\n\n return <Component {...props} agentState={agentState} />;\n };\n\n WrappedComponent.displayName = `withAgentState(${Component.displayName || Component.name || 'Component'})`;\n return React.memo(WrappedComponent);\n};\n"],"names":["ToolCallRenderer","React","memo","_ref","toolCall","onRespond","_useState","useState","status","_useState2","_slicedToArray","actionState","setActionState","config","useMemo","cfg","agentToolcallRegistry","get","toolCallName","_useState3","getRenderFunction","_useState4","isRegistered","setIsRegistered","args","JSON","parse","error","console","handleRespond","useCallback","response","prev","_objectSpread","result","toolCallId","useEffect","isNonInteractiveConfig","executeHandler","_callee","backendResult","_t","_regeneratorRuntime","wrap","_context","next","warn","handler","sent","stop","subscribeKeyExtractor","subscribeKey","targetStateKey","fullProps","respond","handleRegistered","event","_event$detail","detail","name","window","addEventListener","removeEventListener","agentState","useAgentStateDataByKey","componentProps","MemoizedComponent","createElement","prevProps","nextProps","withAgentStateToolcall1","Component","WrappedComponent","props","AgentStateContext","Consumer","context","stateMap","displayName","concat","withAgentStateToolcall"],"mappings":";;;;;;;;;;;;;;;;;;;;AAWO,IAAMA,gCAAmBC,KAAM,CAAAC,IAAA,CACpC,UAAAC,IAAA,EAA6B;AAAA,EAAA,IAA1BC,QAAU,GAAAD,IAAA,CAAVC,QAAU;IAAAC,SAAA,GAAAF,IAAA,CAAAE,SAAA,CAAA;EACX,IAAAC,SAAA,GAAsCC,QAInC,CAAA;AACDC,MAAAA,MAAQ,EAAA,MAAA;AACV,KAAC,CAAA;IAAAC,UAAA,GAAAC,cAAA,CAAAJ,SAAA,EAAA,CAAA,CAAA;AANMK,IAAAA,WAAA,GAAAF,UAAA,CAAA,CAAA,CAAA;AAAaG,IAAAA,cAAc,GAAAH,UAAA,CAAA,CAAA,CAAA,CAAA;AAS5B,EAAA,IAAAI,MAAA,GAASC,QAAQ,YAAM;IAC3B,IAAMC,GAAM,GAAAC,qBAAA,CAA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AsB,gBAAA,GAAgC,SAAhCA,gBAAAA,CAAiCC,KAAa,EAAA;IAE5C,IAAArB,cAAA,GAAiBtC,OAAQ,CAAA,YAAA;MAAA,OAAOoC,qBAAwB,GAAAA,qBAAA,CAAsBuB,KAAK,CAAI,GAAA,KAAA,CAAA,CAAA;KAAY,EAAA,CAACA,KAAK,CAAC,CAAA,CAAA;AAE1G,IAAA,IAAAV,UAAA,GAAaC,uBAAuBZ,cAAc,CAAA,CAAA;IAExD,sBAAQnD,KAAA,CAAAkE,aAAA,CAAAI,SAAA,EAAAtC,aAAA,CAAAA,aAAA,CAAA,EAAA,EAAcwC,KAAA,CAAA,EAAA,EAAA,EAAA;AAAOV,MAAAA,UAAA,EAAAA,UAAAA;AAAA,KAAA,CAAwB,CAAA,CAAA;GACvD,CAAA;AAEAS,EAAAA,gBAAA,CAAiBM,WAAc,GAAAC,iBAAAA,CAAAA,MAAA,CAAkBR,SAAU,CAAAO,WAAA,IAAeP,UAAUZ,IAAQ,IAAA,WAAA,EAAA,GAAA,CAAA,CAAA;AACrF,EAAA,oBAAA1D,KAAA,CAAMC,KAAKsE,gBAAgB,CAAA,CAAA;AACpC;;;;"}
|
|
1
|
+
{"version":3,"file":"render.js","sources":["../../../../../pro-components/chat/chat-engine/components/toolcall/render.tsx"],"sourcesContent":["import React, { useState, useEffect, useCallback, useMemo } from 'react';\nimport type { ToolCall } from 'tdesign-web-components/lib/chat-engine';\nimport { isNonInteractiveConfig, type ToolcallComponentProps } from './types';\nimport { agentToolcallRegistry } from './registry';\nimport { AgentStateContext, useAgentStateDataByKey } from '../../hooks/useAgentState';\n\ninterface ToolCallRendererProps {\n toolCall: ToolCall;\n onRespond?: (toolCall: ToolCall, response: any) => void;\n}\n\nexport const ToolCallRenderer = React.memo<ToolCallRendererProps>(\n ({ toolCall, onRespond }) => {\n const [actionState, setActionState] = useState<{\n status: ToolcallComponentProps['status'];\n result?: any;\n error?: Error;\n }>({\n status: 'idle',\n });\n\n // 缓存配置获取\n const config = useMemo(() => {\n const cfg = agentToolcallRegistry.get(toolCall.toolCallName);\n return cfg;\n }, [toolCall.toolCallName]);\n\n // 添加注册状态监听\n const [isRegistered, setIsRegistered] = useState(\n () => !!agentToolcallRegistry.getRenderFunction(toolCall.toolCallName),\n );\n\n // 缓存参数解析\n const args = useMemo(() => {\n try {\n return toolCall.args ? JSON.parse(toolCall.args) : {};\n } catch (error) {\n console.error('解析工具调用参数失败:', error);\n return {};\n }\n }, [toolCall.args]);\n\n const handleRespond = useCallback(\n (response: any) => {\n if (onRespond) {\n onRespond(toolCall, response);\n setActionState((prev) => ({\n ...prev,\n status: 'complete',\n result: response,\n }));\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [toolCall.toolCallId, onRespond],\n );\n\n // 执行 handler(如果存在)- 必须在条件判断之前调用\n useEffect(() => {\n if (!config) return;\n\n if (isNonInteractiveConfig(config)) {\n // 非交互式:执行 handler\n const executeHandler = async () => {\n try {\n setActionState({ status: 'executing' });\n\n // 解析后端返回的结果作为 handler 的第二个参数\n let backendResult;\n if (toolCall.result) {\n try {\n backendResult = JSON.parse(toolCall.result);\n } catch (error) {\n console.warn('解析后端结果失败,使用原始字符串:', error);\n backendResult = toolCall.result;\n }\n }\n\n // 调用 handler,传入 args 和 backendResult\n const result = await config.handler(args, backendResult);\n setActionState({\n status: 'complete',\n result,\n });\n } catch (error) {\n setActionState({\n status: 'error',\n error: error as Error,\n });\n }\n };\n\n executeHandler();\n } else if (toolCall.result) {\n // 交互式:已有结果,显示完成状态\n try {\n const result = JSON.parse(toolCall.result);\n setActionState({\n status: 'complete',\n result,\n });\n } catch (error) {\n setActionState({\n status: 'error',\n error: error as Error,\n });\n }\n } else {\n // 等待用户交互\n setActionState({ status: 'executing' });\n }\n }, [config, args, toolCall.result]);\n\n // 从配置中获取 subscribeKey 提取函数\n const subscribeKeyExtractor = useMemo(() => config?.subscribeKey, [config]);\n\n // 使用配置的提取函数来获取 targetStateKey\n const targetStateKey = useMemo(() => {\n if (!subscribeKeyExtractor) return undefined;\n\n // 构造完整的 props 对象传给提取函数\n const fullProps = {\n status: actionState.status,\n args,\n result: actionState.result,\n error: actionState.error,\n respond: handleRespond,\n };\n\n return subscribeKeyExtractor(fullProps);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [subscribeKeyExtractor, args, actionState]);\n\n // 监听组件注册事件, 无论何时注册,都能正确触发重新渲染\n useEffect(() => {\n if (!isRegistered) {\n const handleRegistered = (event: CustomEvent) => {\n if (event.detail?.name === toolCall.toolCallName) {\n setIsRegistered(true);\n }\n };\n\n // 添加事件监听\n window.addEventListener('toolcall-registered', handleRegistered as EventListener);\n\n return () => {\n window.removeEventListener('toolcall-registered', handleRegistered as EventListener);\n };\n }\n }, [toolCall.toolCallName, isRegistered]);\n\n // 使用精确订阅\n const agentState = useAgentStateDataByKey(targetStateKey);\n\n // 缓存组件 props\n const componentProps = useMemo<ToolcallComponentProps>(\n () => ({\n status: actionState.status,\n args,\n result: actionState.result,\n error: actionState.error,\n respond: handleRespond,\n agentState,\n }),\n [actionState.status, args, actionState.result, actionState.error, handleRespond, agentState],\n );\n\n // 使用registry的缓存渲染函数\n const MemoizedComponent = useMemo(\n () => agentToolcallRegistry.getRenderFunction(toolCall.toolCallName),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [toolCall.toolCallName, isRegistered],\n );\n\n if (!MemoizedComponent) {\n return null;\n }\n\n return <MemoizedComponent {...componentProps} />;\n },\n (prevProps, nextProps) =>\n prevProps.toolCall.toolCallId === nextProps.toolCall.toolCallId &&\n prevProps.toolCall.toolCallName === nextProps.toolCall.toolCallName &&\n prevProps.toolCall.args === nextProps.toolCall.args &&\n prevProps.toolCall.result === nextProps.toolCall.result &&\n prevProps.onRespond === nextProps.onRespond,\n);\n// 用于调试,可以在控制台查看每次渲染的参数\n// (prevProps, nextProps) => {\n// const toolCallIdSame = prevProps.toolCall.toolCallId === nextProps.toolCall.toolCallId;\n// const toolCallNameSame = prevProps.toolCall.toolCallName === nextProps.toolCall.toolCallName;\n// const argsSame = prevProps.toolCall.args === nextProps.toolCall.args;\n// const resultSame = prevProps.toolCall.result === nextProps.toolCall.result;\n// const onRespondSame = prevProps.onRespond === nextProps.onRespond;\n\n// console.log(`ToolCallRenderer memo 详细检查 [${prevProps.toolCall.toolCallName}]:`, {\n// toolCallIdSame,\n// toolCallNameSame,\n// argsSame,\n// resultSame,\n// onRespondSame,\n// prevToolCallId: prevProps.toolCall.toolCallId,\n// nextToolCallId: nextProps.toolCall.toolCallId,\n// prevOnRespond: prevProps.onRespond,\n// nextOnRespond: nextProps.onRespond,\n// });\n\n// const shouldSkip = toolCallIdSame && toolCallNameSame && argsSame && resultSame && onRespondSame;\n\n// console.log(`ToolCallRenderer memo 检查 [${prevProps.toolCall.toolCallName}]:`, shouldSkip ? '跳过渲染' : '需要重新渲染');\n// return shouldSkip\n// },\n// );\n\n// 定义增强后的 Props 类型\ntype WithAgentStateProps<P> = P & { agentState?: Record<string, any> };\n\nexport const withAgentStateToolcall1 = <P extends object>(\n Component: React.ComponentType<WithAgentStateProps<P>>,\n): React.ComponentType<P> => {\n const WrappedComponent: React.FC<P> = (props: P) => (\n <AgentStateContext.Consumer>\n {(context) => {\n if (!context) {\n console.warn('AgentStateContext not found, component will render without state');\n return <Component {...props} />;\n }\n\n return <Component {...props} agentState={context.stateMap} />;\n }}\n </AgentStateContext.Consumer>\n );\n\n WrappedComponent.displayName = `withAgentState(${Component.displayName || Component.name || 'Component'})`;\n return React.memo(WrappedComponent);\n};\n\nexport const withAgentStateToolcall = <P extends object>(\n Component: React.ComponentType<WithAgentStateProps<P>>,\n subscribeKeyExtractor?: (props: P) => string | undefined,\n): React.ComponentType<P> => {\n const WrappedComponent: React.FC<P> = (props: P) => {\n // 计算需要订阅的 stateKey\n const targetStateKey = useMemo(() => (subscribeKeyExtractor ? subscribeKeyExtractor(props) : undefined), [props]);\n\n const agentState = useAgentStateDataByKey(targetStateKey);\n\n return <Component {...props} agentState={agentState} />;\n };\n\n WrappedComponent.displayName = `withAgentState(${Component.displayName || Component.name || 'Component'})`;\n return React.memo(WrappedComponent);\n};\n"],"names":["ToolCallRenderer","React","memo","_ref","toolCall","onRespond","_useState","useState","status","_useState2","_slicedToArray","actionState","setActionState","config","useMemo","cfg","agentToolcallRegistry","get","toolCallName","_useState3","getRenderFunction","_useState4","isRegistered","setIsRegistered","args","JSON","parse","error","console","handleRespond","useCallback","response","prev","_objectSpread","result","toolCallId","useEffect","isNonInteractiveConfig","executeHandler","_callee","backendResult","_regeneratorRuntime","wrap","_callee$","_context","next","warn","handler","sent","t0","stop","subscribeKeyExtractor","subscribeKey","targetStateKey","fullProps","respond","handleRegistered","event","_event$detail","detail","name","window","addEventListener","removeEventListener","agentState","useAgentStateDataByKey","componentProps","MemoizedComponent","createElement","prevProps","nextProps","withAgentStateToolcall1","Component","WrappedComponent","props","AgentStateContext","Consumer","context","stateMap","displayName","concat","withAgentStateToolcall"],"mappings":";;;;;;;;;;;;;;;;;;;;AAWO,IAAMA,gCAAmBC,KAAM,CAAAC,IAAA,CACpC,UAAAC,IAAA,EAA6B;AAAA,EAAA,IAA1BC,QAAU,GAAAD,IAAA,CAAVC,QAAU;IAAAC,SAAA,GAAAF,IAAA,CAAAE,SAAA,CAAA;EACX,IAAAC,SAAA,GAAsCC,QAInC,CAAA;AACDC,MAAAA,MAAQ,EAAA,MAAA;AACV,KAAC,CAAA;IAAAC,UAAA,GAAAC,cAAA,CAAAJ,SAAA,EAAA,CAAA,CAAA;AANMK,IAAAA,WAAA,GAAAF,UAAA,CAAA,CAAA,CAAA;AAAaG,IAAAA,cAAc,GAAAH,UAAA,CAAA,CAAA,CAAA,CAAA;AAS5B,EAAA,IAAAI,MAAA,GAASC,QAAQ,YAAM;IAC3B,IAAMC,GAAM,GAAAC,qBAAA,CAAsBC,GAAI,CAAAb,QAAA,CAASc,YAAY,CAAA,CAAA;AACpD,IAAA,OAAAH,GAAA,CAAA;AACT,GAAG,EAAA,CAACX,QA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AAA,OAAOqC,qBAAwB,GAAAA,qBAAA,CAAsBuB,KAAK,CAAI,GAAA,KAAA,CAAA,CAAA;KAAY,EAAA,CAACA,KAAK,CAAC,CAAA,CAAA;AAE1G,IAAA,IAAAV,UAAA,GAAaC,uBAAuBZ,cAAc,CAAA,CAAA;IAExD,sBAAQpD,KAAA,CAAAmE,aAAA,CAAAI,SAAA,EAAAvC,aAAA,CAAAA,aAAA,CAAA,EAAA,EAAcyC,KAAA,CAAA,EAAA,EAAA,EAAA;AAAOV,MAAAA,UAAA,EAAAA,UAAAA;AAAA,KAAA,CAAwB,CAAA,CAAA;GACvD,CAAA;AAEAS,EAAAA,gBAAA,CAAiBM,WAAc,GAAAC,iBAAAA,CAAAA,MAAA,CAAkBR,SAAU,CAAAO,WAAA,IAAeP,UAAUZ,IAAQ,IAAA,WAAA,EAAA,GAAA,CAAA,CAAA;AACrF,EAAA,oBAAA3D,KAAA,CAAMC,KAAKuE,gBAAgB,CAAA,CAAA;AACpC;;;;"}
|
package/es/chat-engine/index.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tdesign v1.0.2-alpha.
|
|
2
|
+
* tdesign v1.0.2-alpha.0
|
|
3
3
|
* (c) 2026 tdesign
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import 'tdesign-web-components/lib/filecard';
|
|
8
8
|
import reactify from '../_util/reactify.js';
|
|
9
|
-
import '@babel/runtime/helpers/defineProperty';
|
|
10
9
|
import '@babel/runtime/helpers/objectWithoutProperties';
|
|
11
|
-
import '@babel/runtime/helpers/
|
|
12
|
-
import '@babel/runtime/helpers/slicedToArray';
|
|
10
|
+
import '@babel/runtime/helpers/toConsumableArray';
|
|
13
11
|
import '@babel/runtime/helpers/classCallCheck';
|
|
14
12
|
import '@babel/runtime/helpers/createClass';
|
|
15
13
|
import '@babel/runtime/helpers/possibleConstructorReturn';
|
|
16
14
|
import '@babel/runtime/helpers/getPrototypeOf';
|
|
17
15
|
import '@babel/runtime/helpers/inherits';
|
|
16
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
17
|
+
import '@babel/runtime/helpers/slicedToArray';
|
|
18
|
+
import '@babel/runtime/helpers/typeof';
|
|
18
19
|
import 'react';
|
|
20
|
+
import 'react-dom';
|
|
19
21
|
import 'react-dom/client';
|
|
20
22
|
|
|
21
23
|
var Filecard = reactify("t-filecard");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../pro-components/chat/chat-filecard/index.ts"],"sourcesContent":["import { TdFileCardProps } from 'tdesign-web-components';\nimport 'tdesign-web-components/lib/filecard';\nimport reactify from '../_util/reactify';\n\nexport const Filecard: React.ForwardRefExoticComponent<\n Omit<TdFileCardProps, 'ref'> & React.RefAttributes<HTMLElement | undefined>\n> = reactify<TdFileCardProps>('t-filecard');\n\nexport default Filecard;\nexport type { TdFileCardProps } from 'tdesign-web-components';\n"],"names":["Filecard","reactify"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../pro-components/chat/chat-filecard/index.ts"],"sourcesContent":["import { TdFileCardProps } from 'tdesign-web-components';\nimport 'tdesign-web-components/lib/filecard';\nimport reactify from '../_util/reactify';\n\nexport const Filecard: React.ForwardRefExoticComponent<\n Omit<TdFileCardProps, 'ref'> & React.RefAttributes<HTMLElement | undefined>\n> = reactify<TdFileCardProps>('t-filecard');\n\nexport default Filecard;\nexport type { TdFileCardProps } from 'tdesign-web-components';\n"],"names":["Filecard","reactify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAIaA,QAAA,GAETC,SAA0B,YAAY;;;;"}
|
package/es/chat-loading/index.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tdesign v1.0.2-alpha.
|
|
2
|
+
* tdesign v1.0.2-alpha.0
|
|
3
3
|
* (c) 2026 tdesign
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import 'tdesign-web-components/lib/chat-loading';
|
|
8
8
|
import reactify from '../_util/reactify.js';
|
|
9
|
-
import '@babel/runtime/helpers/defineProperty';
|
|
10
9
|
import '@babel/runtime/helpers/objectWithoutProperties';
|
|
11
|
-
import '@babel/runtime/helpers/
|
|
12
|
-
import '@babel/runtime/helpers/slicedToArray';
|
|
10
|
+
import '@babel/runtime/helpers/toConsumableArray';
|
|
13
11
|
import '@babel/runtime/helpers/classCallCheck';
|
|
14
12
|
import '@babel/runtime/helpers/createClass';
|
|
15
13
|
import '@babel/runtime/helpers/possibleConstructorReturn';
|
|
16
14
|
import '@babel/runtime/helpers/getPrototypeOf';
|
|
17
15
|
import '@babel/runtime/helpers/inherits';
|
|
16
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
17
|
+
import '@babel/runtime/helpers/slicedToArray';
|
|
18
|
+
import '@babel/runtime/helpers/typeof';
|
|
18
19
|
import 'react';
|
|
20
|
+
import 'react-dom';
|
|
19
21
|
import 'react-dom/client';
|
|
20
22
|
|
|
21
23
|
var ChatLoading = reactify("t-chat-loading");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../pro-components/chat/chat-loading/index.ts"],"sourcesContent":["import { TdChatLoadingProps } from 'tdesign-web-components';\nimport 'tdesign-web-components/lib/chat-loading';\nimport reactify from '../_util/reactify';\n\nexport const ChatLoading: React.ForwardRefExoticComponent<\n Omit<TdChatLoadingProps, 'ref'> & React.RefAttributes<HTMLElement | undefined>\n> = reactify<TdChatLoadingProps>('t-chat-loading');\n\nexport default ChatLoading;\nexport type { TdChatLoadingProps, ChatLoadingAnimationType } from 'tdesign-web-components';\n"],"names":["ChatLoading","reactify"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../pro-components/chat/chat-loading/index.ts"],"sourcesContent":["import { TdChatLoadingProps } from 'tdesign-web-components';\nimport 'tdesign-web-components/lib/chat-loading';\nimport reactify from '../_util/reactify';\n\nexport const ChatLoading: React.ForwardRefExoticComponent<\n Omit<TdChatLoadingProps, 'ref'> & React.RefAttributes<HTMLElement | undefined>\n> = reactify<TdChatLoadingProps>('t-chat-loading');\n\nexport default ChatLoading;\nexport type { TdChatLoadingProps, ChatLoadingAnimationType } from 'tdesign-web-components';\n"],"names":["ChatLoading","reactify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAIaA,WAAA,GAETC,SAA6B,gBAAgB;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tdesign v1.0.2-alpha.
|
|
2
|
+
* tdesign v1.0.2-alpha.0
|
|
3
3
|
* (c) 2026 tdesign
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -7,16 +7,18 @@
|
|
|
7
7
|
import { TdMarkdownEngine } from 'tdesign-web-components';
|
|
8
8
|
import reactify from '../_util/reactify.js';
|
|
9
9
|
import 'tdesign-web-components/lib/chat-message/content/markdown-content';
|
|
10
|
-
import '@babel/runtime/helpers/defineProperty';
|
|
11
10
|
import '@babel/runtime/helpers/objectWithoutProperties';
|
|
12
|
-
import '@babel/runtime/helpers/
|
|
13
|
-
import '@babel/runtime/helpers/slicedToArray';
|
|
11
|
+
import '@babel/runtime/helpers/toConsumableArray';
|
|
14
12
|
import '@babel/runtime/helpers/classCallCheck';
|
|
15
13
|
import '@babel/runtime/helpers/createClass';
|
|
16
14
|
import '@babel/runtime/helpers/possibleConstructorReturn';
|
|
17
15
|
import '@babel/runtime/helpers/getPrototypeOf';
|
|
18
16
|
import '@babel/runtime/helpers/inherits';
|
|
17
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
18
|
+
import '@babel/runtime/helpers/slicedToArray';
|
|
19
|
+
import '@babel/runtime/helpers/typeof';
|
|
19
20
|
import 'react';
|
|
21
|
+
import 'react-dom';
|
|
20
22
|
import 'react-dom/client';
|
|
21
23
|
|
|
22
24
|
var MarkdownEngine = TdMarkdownEngine;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../pro-components/chat/chat-markdown/index.ts"],"sourcesContent":["import { TdChatMarkdownContentProps, TdMarkdownEngine } from 'tdesign-web-components';\nimport reactify from '../_util/reactify';\n\nexport const MarkdownEngine: typeof TdMarkdownEngine = TdMarkdownEngine;\nexport const ChatMarkdown: React.ForwardRefExoticComponent<\n Omit<TdChatMarkdownContentProps, 'ref'> & React.RefAttributes<HTMLElement | undefined>\n> = reactify<TdChatMarkdownContentProps>('t-chat-md-content');\n\n// eslint-disable-next-line import/first\nimport 'tdesign-web-components/lib/chat-message/content/markdown-content';\n\nexport default ChatMarkdown;\nexport type { TdChatMarkdownContentProps } from 'tdesign-web-components';\n"],"names":["MarkdownEngine","TdMarkdownEngine","ChatMarkdown","reactify"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../pro-components/chat/chat-markdown/index.ts"],"sourcesContent":["import { TdChatMarkdownContentProps, TdMarkdownEngine } from 'tdesign-web-components';\nimport reactify from '../_util/reactify';\n\nexport const MarkdownEngine: typeof TdMarkdownEngine = TdMarkdownEngine;\nexport const ChatMarkdown: React.ForwardRefExoticComponent<\n Omit<TdChatMarkdownContentProps, 'ref'> & React.RefAttributes<HTMLElement | undefined>\n> = reactify<TdChatMarkdownContentProps>('t-chat-md-content');\n\n// eslint-disable-next-line import/first\nimport 'tdesign-web-components/lib/chat-message/content/markdown-content';\n\nexport default ChatMarkdown;\nexport type { TdChatMarkdownContentProps } from 'tdesign-web-components';\n"],"names":["MarkdownEngine","TdMarkdownEngine","ChatMarkdown","reactify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAMA,cAA0C,GAAAC,iBAAA;IAC1CC,YAAA,GAETC,SAAqC,mBAAmB;;;;"}
|
package/es/chat-message/index.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tdesign v1.0.2-alpha.
|
|
2
|
+
* tdesign v1.0.2-alpha.0
|
|
3
3
|
* (c) 2026 tdesign
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import 'tdesign-web-components/lib/chat-message';
|
|
8
8
|
import reactify from '../_util/reactify.js';
|
|
9
|
-
import '@babel/runtime/helpers/defineProperty';
|
|
10
9
|
import '@babel/runtime/helpers/objectWithoutProperties';
|
|
11
|
-
import '@babel/runtime/helpers/
|
|
12
|
-
import '@babel/runtime/helpers/slicedToArray';
|
|
10
|
+
import '@babel/runtime/helpers/toConsumableArray';
|
|
13
11
|
import '@babel/runtime/helpers/classCallCheck';
|
|
14
12
|
import '@babel/runtime/helpers/createClass';
|
|
15
13
|
import '@babel/runtime/helpers/possibleConstructorReturn';
|
|
16
14
|
import '@babel/runtime/helpers/getPrototypeOf';
|
|
17
15
|
import '@babel/runtime/helpers/inherits';
|
|
16
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
17
|
+
import '@babel/runtime/helpers/slicedToArray';
|
|
18
|
+
import '@babel/runtime/helpers/typeof';
|
|
18
19
|
import 'react';
|
|
20
|
+
import 'react-dom';
|
|
19
21
|
import 'react-dom/client';
|
|
20
22
|
|
|
21
23
|
var ChatMessage = reactify("t-chat-item");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../pro-components/chat/chat-message/index.ts"],"sourcesContent":["import { type TdChatMessageProps } from 'tdesign-web-components';\nimport 'tdesign-web-components/lib/chat-message';\nimport reactify from '../_util/reactify';\n\nexport const ChatMessage: React.ForwardRefExoticComponent<\n Omit<TdChatMessageProps & React.PropsWithChildren, 'ref'> & React.RefAttributes<HTMLElement | undefined>\n> = reactify<TdChatMessageProps>('t-chat-item');\n\nexport default ChatMessage;\n\nexport type { TdChatMessageProps } from 'tdesign-web-components';\n"],"names":["ChatMessage","reactify"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../pro-components/chat/chat-message/index.ts"],"sourcesContent":["import { type TdChatMessageProps } from 'tdesign-web-components';\nimport 'tdesign-web-components/lib/chat-message';\nimport reactify from '../_util/reactify';\n\nexport const ChatMessage: React.ForwardRefExoticComponent<\n Omit<TdChatMessageProps & React.PropsWithChildren, 'ref'> & React.RefAttributes<HTMLElement | undefined>\n> = reactify<TdChatMessageProps>('t-chat-item');\n\nexport default ChatMessage;\n\nexport type { TdChatMessageProps } from 'tdesign-web-components';\n"],"names":["ChatMessage","reactify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAIaA,WAAA,GAETC,SAA6B,aAAa;;;;"}
|
package/es/chat-sender/index.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tdesign v1.0.2-alpha.
|
|
2
|
+
* tdesign v1.0.2-alpha.0
|
|
3
3
|
* (c) 2026 tdesign
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import 'tdesign-web-components/lib/chat-sender';
|
|
8
8
|
import reactify from '../_util/reactify.js';
|
|
9
|
-
import '@babel/runtime/helpers/defineProperty';
|
|
10
9
|
import '@babel/runtime/helpers/objectWithoutProperties';
|
|
11
|
-
import '@babel/runtime/helpers/
|
|
12
|
-
import '@babel/runtime/helpers/slicedToArray';
|
|
10
|
+
import '@babel/runtime/helpers/toConsumableArray';
|
|
13
11
|
import '@babel/runtime/helpers/classCallCheck';
|
|
14
12
|
import '@babel/runtime/helpers/createClass';
|
|
15
13
|
import '@babel/runtime/helpers/possibleConstructorReturn';
|
|
16
14
|
import '@babel/runtime/helpers/getPrototypeOf';
|
|
17
15
|
import '@babel/runtime/helpers/inherits';
|
|
16
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
17
|
+
import '@babel/runtime/helpers/slicedToArray';
|
|
18
|
+
import '@babel/runtime/helpers/typeof';
|
|
18
19
|
import 'react';
|
|
20
|
+
import 'react-dom';
|
|
19
21
|
import 'react-dom/client';
|
|
20
22
|
|
|
21
23
|
var ChatSender = reactify("t-chat-sender");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../pro-components/chat/chat-sender/index.ts"],"sourcesContent":["import { TdChatSenderProps } from 'tdesign-web-components';\nimport 'tdesign-web-components/lib/chat-sender';\nimport reactify from '../_util/reactify';\n\nexport const ChatSender: React.ForwardRefExoticComponent<\n Omit<TdChatSenderProps & React.PropsWithChildren, 'ref'> & React.RefAttributes<HTMLElement | undefined>\n> = reactify<TdChatSenderProps>('t-chat-sender');\n\nexport default ChatSender;\nexport type * from 'tdesign-web-components/lib/chat-sender/type';\n"],"names":["ChatSender","reactify"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../pro-components/chat/chat-sender/index.ts"],"sourcesContent":["import { TdChatSenderProps } from 'tdesign-web-components';\nimport 'tdesign-web-components/lib/chat-sender';\nimport reactify from '../_util/reactify';\n\nexport const ChatSender: React.ForwardRefExoticComponent<\n Omit<TdChatSenderProps & React.PropsWithChildren, 'ref'> & React.RefAttributes<HTMLElement | undefined>\n> = reactify<TdChatSenderProps>('t-chat-sender');\n\nexport default ChatSender;\nexport type * from 'tdesign-web-components/lib/chat-sender/type';\n"],"names":["ChatSender","reactify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAIaA,UAAA,GAETC,SAA4B,eAAe;;;;"}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tdesign v1.0.2-alpha.
|
|
2
|
+
* tdesign v1.0.2-alpha.0
|
|
3
3
|
* (c) 2026 tdesign
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import 'tdesign-web-components/lib/chat-message/content/thinking-content';
|
|
8
8
|
import reactify from '../_util/reactify.js';
|
|
9
|
-
import '@babel/runtime/helpers/defineProperty';
|
|
10
9
|
import '@babel/runtime/helpers/objectWithoutProperties';
|
|
11
|
-
import '@babel/runtime/helpers/
|
|
12
|
-
import '@babel/runtime/helpers/slicedToArray';
|
|
10
|
+
import '@babel/runtime/helpers/toConsumableArray';
|
|
13
11
|
import '@babel/runtime/helpers/classCallCheck';
|
|
14
12
|
import '@babel/runtime/helpers/createClass';
|
|
15
13
|
import '@babel/runtime/helpers/possibleConstructorReturn';
|
|
16
14
|
import '@babel/runtime/helpers/getPrototypeOf';
|
|
17
15
|
import '@babel/runtime/helpers/inherits';
|
|
16
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
17
|
+
import '@babel/runtime/helpers/slicedToArray';
|
|
18
|
+
import '@babel/runtime/helpers/typeof';
|
|
18
19
|
import 'react';
|
|
20
|
+
import 'react-dom';
|
|
19
21
|
import 'react-dom/client';
|
|
20
22
|
|
|
21
23
|
var ChatThinkContent = reactify("t-chat-thinking-content");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../pro-components/chat/chat-thinking/index.ts"],"sourcesContent":["import { TdChatThinkContentProps } from 'tdesign-web-components';\nimport 'tdesign-web-components/lib/chat-message/content/thinking-content';\nimport reactify from '../_util/reactify';\n\nconst ChatThinkContent: React.ForwardRefExoticComponent<\n Omit<TdChatThinkContentProps, 'ref'> & React.RefAttributes<HTMLElement | undefined>\n> = reactify<TdChatThinkContentProps>('t-chat-thinking-content');\n\nexport const ChatThinking = ChatThinkContent;\n\nexport default ChatThinking;\n\nexport type { TdChatThinkContentProps } from 'tdesign-web-components';\n"],"names":["ChatThinkContent","reactify","ChatThinking"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../pro-components/chat/chat-thinking/index.ts"],"sourcesContent":["import { TdChatThinkContentProps } from 'tdesign-web-components';\nimport 'tdesign-web-components/lib/chat-message/content/thinking-content';\nimport reactify from '../_util/reactify';\n\nconst ChatThinkContent: React.ForwardRefExoticComponent<\n Omit<TdChatThinkContentProps, 'ref'> & React.RefAttributes<HTMLElement | undefined>\n> = reactify<TdChatThinkContentProps>('t-chat-thinking-content');\n\nexport const ChatThinking = ChatThinkContent;\n\nexport default ChatThinking;\n\nexport type { TdChatThinkContentProps } from 'tdesign-web-components';\n"],"names":["ChatThinkContent","reactify","ChatThinking"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAIA,IAAMA,gBAAA,GAEFC,SAAkC,yBAAyB,CAAA,CAAA;AAExD,IAAMC,YAAe,GAAAF;;;;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StateActionOptions } from '../../hooks/useAgentState';
|
|
3
|
+
export declare const AgentStateProvider: ({ children, initialState, subscribeKey }: StateActionOptions & {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tdesign v1.0.0-beta.4
|
|
3
|
+
* (c) 2025 tdesign
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { useAgentState, AgentStateContext } from '../../hooks/useAgentState.js';
|
|
9
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
10
|
+
import '@babel/runtime/helpers/slicedToArray';
|
|
11
|
+
import 'tdesign-web-components/lib/chat-engine';
|
|
12
|
+
|
|
13
|
+
var AgentStateProvider = function AgentStateProvider(_ref) {
|
|
14
|
+
var children = _ref.children,
|
|
15
|
+
_ref$initialState = _ref.initialState,
|
|
16
|
+
initialState = _ref$initialState === void 0 ? {} : _ref$initialState,
|
|
17
|
+
subscribeKey = _ref.subscribeKey;
|
|
18
|
+
var agentStateResult = useAgentState({
|
|
19
|
+
initialState: initialState,
|
|
20
|
+
subscribeKey: subscribeKey
|
|
21
|
+
});
|
|
22
|
+
return /* @__PURE__ */React.createElement(AgentStateContext.Provider, {
|
|
23
|
+
value: agentStateResult
|
|
24
|
+
}, children);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { AgentStateProvider };
|
|
28
|
+
//# sourceMappingURL=agent-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-state.js","sources":["../../../../../pro-components/chat/chatbot/components/provider/agent-state.tsx"],"sourcesContent":["import React from 'react';\nimport { AgentStateContext, type StateActionOptions, useAgentState } from '../../hooks/useAgentState';\n\n// 导出 Provider 组件\nexport const AgentStateProvider = ({ children, initialState = {}, subscribeKey }: StateActionOptions & {\n children: React.ReactNode;\n}) => {\n const agentStateResult = useAgentState({\n initialState,\n subscribeKey,\n });\n\n return (\n <AgentStateContext.Provider value={agentStateResult}>\n {children}\n </AgentStateContext.Provider>\n );\n};\n"],"names":["AgentStateProvider","_ref","children","_ref$initialState","initialState","subscribeKey","agentStateResult","useAgentState","React","createElement","AgentStateContext","Provider","value"],"mappings":";;;;;;;;;;;;IAIaA,kBAAA,GAAqB,SAArBA,kBAAAA,CAAAC,IAAA,EAEP;AAAA,EAAA,IAF+BC,QAAA,GAAAD,IAAA,CAAAC,QAAA;IAAAC,iBAAA,GAAAF,IAAA,CAAUG;AAAAA,IAAAA,8CAAe,EAAC,GAAAD,iBAAA;IAAGE,oBAAAA;EAGhE,IAAMC,mBAAmBC,aAAc,CAAA;AACrCH,IAAAA,YAAA,EAAAA,YAAA;AACAC,IAAAA,YAAA,EAAAA,YAAAA;AACF,GAAC,CAAA,CAAA;EAGC,sBAAAG,KAAA,CAAAC,aAAA,CAACC,kBAAkBC,QAAlB,EAAA;AAA2BC,IAAAA,KAAO,EAAAN,gBAAAA;GAAA,EAChCJ,QACH,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tdesign v1.0.0-beta.4
|
|
3
|
+
* (c) 2025 tdesign
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export { isNonInteractive, isNonInteractiveConfig } from './types.js';
|
|
8
|
+
export { agentToolcallRegistry } from './registry.js';
|
|
9
|
+
export { ToolCallRenderer, withAgentStateToolcall, withAgentStateToolcall1 } from './render.js';
|
|
10
|
+
import '@babel/runtime/helpers/classCallCheck';
|
|
11
|
+
import '@babel/runtime/helpers/createClass';
|
|
12
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
13
|
+
import 'react';
|
|
14
|
+
import '@babel/runtime/helpers/asyncToGenerator';
|
|
15
|
+
import '@babel/runtime/helpers/slicedToArray';
|
|
16
|
+
import '@babel/runtime/regenerator';
|
|
17
|
+
import '../../hooks/useAgentState.js';
|
|
18
|
+
import 'tdesign-web-components/lib/chat-engine';
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { AgentToolcallConfig, AgentToolcallRegistry, ToolcallComponentProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 全局 Agent Toolcall 注册表
|
|
5
|
+
*/
|
|
6
|
+
declare class AgentToolcallRegistryManager {
|
|
7
|
+
private registry;
|
|
8
|
+
private renderFunctionCache;
|
|
9
|
+
/**
|
|
10
|
+
* 注册一个 Agent Toolcall
|
|
11
|
+
*/
|
|
12
|
+
register<TArgs extends object = any, TResult = any, TResponse = any>(config: AgentToolcallConfig<TArgs, TResult, TResponse>): void;
|
|
13
|
+
/**
|
|
14
|
+
* 获取指定名称的 Agent Toolcall 配置
|
|
15
|
+
*/
|
|
16
|
+
get(name: string): AgentToolcallConfig | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* 获取或创建缓存的组件渲染函数
|
|
19
|
+
*/
|
|
20
|
+
getRenderFunction(name: string): React.MemoExoticComponent<React.ComponentType<ToolcallComponentProps>> | null;
|
|
21
|
+
/**
|
|
22
|
+
* 获取所有已注册的 Agent Toolcall
|
|
23
|
+
*/
|
|
24
|
+
getAll(): AgentToolcallRegistry;
|
|
25
|
+
/**
|
|
26
|
+
* 取消注册指定的 Agent Toolcall
|
|
27
|
+
*/
|
|
28
|
+
unregister(name: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* 清空所有注册的 Agent Toolcall
|
|
31
|
+
*/
|
|
32
|
+
clear(): void;
|
|
33
|
+
}
|
|
34
|
+
export declare const agentToolcallRegistry: AgentToolcallRegistryManager;
|
|
35
|
+
export {};
|