@agentscope-ai/chat 1.1.41 → 1.1.42-beta.1765200748507
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/components/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/Response/Builder.tsx +7 -2
- package/components/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/Response/Card.tsx +2 -0
- package/components/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/Response/Tool.tsx +1 -1
- package/components/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/types.tsx +2 -1
- package/components/ChatAnywhere/Input/index.tsx +1 -1
- package/lib/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/Response/Builder.js +7 -3
- package/lib/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/Response/Card.js +2 -0
- package/lib/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/Response/Tool.js +3 -2
- package/lib/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/types.d.ts +2 -1
- package/lib/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/types.js +2 -1
- package/lib/ChatAnywhere/Input/index.js +1 -1
- package/package.json +1 -1
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Request/Builder.tsx +0 -82
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Request/Card.tsx +0 -52
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Actions.tsx +0 -39
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Builder.tsx +0 -205
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Card.tsx +0 -44
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Error.tsx +0 -7
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Message.tsx +0 -23
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Reasoning.tsx +0 -16
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Tool.tsx +0 -19
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/index.tsx +0 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/types.tsx +0 -100
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Input/index.tsx +0 -75
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Input/useAttachments.tsx +0 -53
- package/components/AgentScopeRuntimeWebUI/lib/Chat/MessageList/index.tsx +0 -30
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Welcome/index.tsx +0 -66
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Welcome/styles.ts +0 -51
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/index.tsx +0 -5
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatController.tsx +0 -130
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatMessageHandler.tsx +0 -87
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatRequest.tsx +0 -114
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatSessionHandler.tsx +0 -50
- package/components/AgentScopeRuntimeWebUI/lib/Chat/index.tsx +0 -18
- package/components/AgentScopeRuntimeWebUI/lib/Chat/styles.tsx +0 -59
- package/components/AgentScopeRuntimeWebUI/lib/ChatAnywhere/ComposedProvider.tsx +0 -27
- package/components/AgentScopeRuntimeWebUI/lib/ChatAnywhere/index.tsx +0 -29
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereControl.tsx +0 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereInputContext.tsx +0 -27
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereLayoutContext.tsx +0 -27
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereMessagesContext.tsx +0 -82
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereOptionsContext.tsx +0 -76
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereSessionsContext.tsx +0 -111
- package/components/AgentScopeRuntimeWebUI/lib/Context/useChatAnywhereEventEmitter.tsx +0 -30
- package/components/AgentScopeRuntimeWebUI/lib/Header/index.tsx +0 -45
- package/components/AgentScopeRuntimeWebUI/lib/Header/styles.ts +0 -23
- package/components/AgentScopeRuntimeWebUI/lib/Layout/index.tsx +0 -45
- package/components/AgentScopeRuntimeWebUI/lib/Layout/styles.tsx +0 -104
- package/components/AgentScopeRuntimeWebUI/lib/Sessions/index.tsx +0 -114
- package/components/AgentScopeRuntimeWebUI/lib/Sessions/styles.tsx +0 -0
- package/components/AgentScopeRuntimeWebUI/lib/types/IChatAnywhere.ts +0 -358
- package/components/AgentScopeRuntimeWebUI/lib/types/IMessages.tsx +0 -52
- package/components/AgentScopeRuntimeWebUI/lib/types/ISessions.tsx +0 -29
- package/components/AgentScopeRuntimeWebUI/lib/types/index.tsx +0 -3
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Request/Builder.d.ts +0 -13
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Request/Builder.js +0 -84
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Request/Card.d.ts +0 -4
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Request/Card.js +0 -61
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Actions.d.ts +0 -5
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Actions.js +0 -29
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Builder.d.ts +0 -21
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Builder.js +0 -194
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Card.d.ts +0 -5
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Card.js +0 -52
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Error.d.ts +0 -4
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Error.js +0 -10
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Message.d.ts +0 -6
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Message.js +0 -26
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Reasoning.d.ts +0 -4
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Reasoning.js +0 -14
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Tool.d.ts +0 -6
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Tool.js +0 -16
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/index.d.ts +0 -0
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/index.js +0 -0
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/types.d.ts +0 -89
- package/lib/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/types.js +0 -41
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/Input/index.d.ts +0 -6
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/Input/index.js +0 -107
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/Input/useAttachments.d.ts +0 -17
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/Input/useAttachments.js +0 -54
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/MessageList/index.d.ts +0 -6
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/MessageList/index.js +0 -36
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/Welcome/index.d.ts +0 -6
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/Welcome/index.js +0 -82
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/Welcome/styles.d.ts +0 -3
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/Welcome/styles.js +0 -21
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/hooks/index.d.ts +0 -4
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/hooks/index.js +0 -4
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatController.d.ts +0 -7
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatController.js +0 -182
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatMessageHandler.d.ts +0 -24
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatMessageHandler.js +0 -74
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatRequest.d.ts +0 -19
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatRequest.js +0 -167
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatSessionHandler.d.ts +0 -10
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatSessionHandler.js +0 -100
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/index.d.ts +0 -1
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/index.js +0 -25
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/styles.d.ts +0 -3
- package/lib/AgentScopeRuntimeWebUI/lib/Chat/styles.js +0 -22
- package/lib/AgentScopeRuntimeWebUI/lib/ChatAnywhere/ComposedProvider.d.ts +0 -6
- package/lib/AgentScopeRuntimeWebUI/lib/ChatAnywhere/ComposedProvider.js +0 -40
- package/lib/AgentScopeRuntimeWebUI/lib/ChatAnywhere/index.d.ts +0 -6
- package/lib/AgentScopeRuntimeWebUI/lib/ChatAnywhere/index.js +0 -31
- package/lib/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereControl.d.ts +0 -0
- package/lib/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereControl.js +0 -0
- package/lib/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereInputContext.d.ts +0 -7
- package/lib/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereInputContext.js +0 -47
- package/lib/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereLayoutContext.d.ts +0 -8
- package/lib/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereLayoutContext.js +0 -30
- package/lib/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereMessagesContext.d.ts +0 -15
- package/lib/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereMessagesContext.js +0 -91
- package/lib/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereOptionsContext.d.ts +0 -9
- package/lib/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereOptionsContext.js +0 -66
- package/lib/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereSessionsContext.d.ts +0 -19
- package/lib/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereSessionsContext.js +0 -230
- package/lib/AgentScopeRuntimeWebUI/lib/Context/useChatAnywhereEventEmitter.d.ts +0 -10
- package/lib/AgentScopeRuntimeWebUI/lib/Context/useChatAnywhereEventEmitter.js +0 -16
- package/lib/AgentScopeRuntimeWebUI/lib/Header/index.d.ts +0 -1
- package/lib/AgentScopeRuntimeWebUI/lib/Header/index.js +0 -52
- package/lib/AgentScopeRuntimeWebUI/lib/Header/styles.d.ts +0 -3
- package/lib/AgentScopeRuntimeWebUI/lib/Header/styles.js +0 -8
- package/lib/AgentScopeRuntimeWebUI/lib/Layout/index.d.ts +0 -8
- package/lib/AgentScopeRuntimeWebUI/lib/Layout/index.js +0 -45
- package/lib/AgentScopeRuntimeWebUI/lib/Layout/styles.d.ts +0 -3
- package/lib/AgentScopeRuntimeWebUI/lib/Layout/styles.js +0 -22
- package/lib/AgentScopeRuntimeWebUI/lib/Sessions/index.d.ts +0 -13
- package/lib/AgentScopeRuntimeWebUI/lib/Sessions/index.js +0 -178
- package/lib/AgentScopeRuntimeWebUI/lib/Sessions/styles.d.ts +0 -0
- package/lib/AgentScopeRuntimeWebUI/lib/Sessions/styles.js +0 -0
- package/lib/AgentScopeRuntimeWebUI/lib/types/IChatAnywhere.d.ts +0 -350
- package/lib/AgentScopeRuntimeWebUI/lib/types/IChatAnywhere.js +0 -1
- package/lib/AgentScopeRuntimeWebUI/lib/types/IMessages.d.ts +0 -50
- package/lib/AgentScopeRuntimeWebUI/lib/types/IMessages.js +0 -1
- package/lib/AgentScopeRuntimeWebUI/lib/types/ISessions.d.ts +0 -26
- package/lib/AgentScopeRuntimeWebUI/lib/types/ISessions.js +0 -1
- package/lib/AgentScopeRuntimeWebUI/lib/types/index.d.ts +0 -3
- package/lib/AgentScopeRuntimeWebUI/lib/types/index.js +0 -3
- /package/components/AIGC/{components → core}/Info/index.tsx +0 -0
- /package/components/AIGC/{components → core}/Info/style.ts +0 -0
- /package/components/AIGC/{components → core}/SenderHeader/index.tsx +0 -0
- /package/components/AIGC/{components → core}/SenderHeader/style.ts +0 -0
- /package/components/AIGC/{components → core}/Upload/index.tsx +0 -0
- /package/components/AIGC/{components → core}/Upload/style.ts +0 -0
- /package/lib/AIGC/{components → core}/Info/index.d.ts +0 -0
- /package/lib/AIGC/{components → core}/Info/index.js +0 -0
- /package/lib/AIGC/{components → core}/Info/style.d.ts +0 -0
- /package/lib/AIGC/{components → core}/Info/style.js +0 -0
- /package/lib/AIGC/{components → core}/SenderHeader/index.d.ts +0 -0
- /package/lib/AIGC/{components → core}/SenderHeader/index.js +0 -0
- /package/lib/AIGC/{components → core}/SenderHeader/style.d.ts +0 -0
- /package/lib/AIGC/{components → core}/SenderHeader/style.js +0 -0
- /package/lib/AIGC/{components → core}/Upload/index.d.ts +0 -0
- /package/lib/AIGC/{components → core}/Upload/index.js +0 -0
- /package/lib/AIGC/{components → core}/Upload/style.d.ts +0 -0
- /package/lib/AIGC/{components → core}/Upload/style.js +0 -0
|
@@ -48,6 +48,7 @@ class AgentScopeRuntimeResponseBuilder {
|
|
|
48
48
|
AgentScopeRuntimeMessageType.FUNCTION_CALL_OUTPUT,
|
|
49
49
|
AgentScopeRuntimeMessageType.PLUGIN_CALL_OUTPUT,
|
|
50
50
|
AgentScopeRuntimeMessageType.COMPONENT_CALL_OUTPUT,
|
|
51
|
+
AgentScopeRuntimeMessageType.MCP_CALL_OUTPUT,
|
|
51
52
|
].includes(message.type);
|
|
52
53
|
}
|
|
53
54
|
|
|
@@ -56,6 +57,7 @@ class AgentScopeRuntimeResponseBuilder {
|
|
|
56
57
|
AgentScopeRuntimeMessageType.FUNCTION_CALL,
|
|
57
58
|
AgentScopeRuntimeMessageType.PLUGIN_CALL,
|
|
58
59
|
AgentScopeRuntimeMessageType.COMPONENT_CALL,
|
|
60
|
+
AgentScopeRuntimeMessageType.MCP_CALL,
|
|
59
61
|
].includes(message.type);
|
|
60
62
|
}
|
|
61
63
|
|
|
@@ -99,7 +101,6 @@ class AgentScopeRuntimeResponseBuilder {
|
|
|
99
101
|
handleMessage(data: IAgentScopeRuntimeMessage) {
|
|
100
102
|
this.data = produce(this.data, (draft) => {
|
|
101
103
|
|
|
102
|
-
|
|
103
104
|
if (!draft.output) {
|
|
104
105
|
draft.output = [];
|
|
105
106
|
}
|
|
@@ -146,8 +147,12 @@ class AgentScopeRuntimeResponseBuilder {
|
|
|
146
147
|
msg.content.push(data);
|
|
147
148
|
}
|
|
148
149
|
} else {
|
|
149
|
-
Object.assign(msg.content[msg.content.length - 1], data);
|
|
150
150
|
|
|
151
|
+
if (msg.content.length > 0) {
|
|
152
|
+
Object.assign(msg.content[msg.content.length - 1], data);
|
|
153
|
+
} else {
|
|
154
|
+
msg.content.push(data);
|
|
155
|
+
}
|
|
151
156
|
}
|
|
152
157
|
});
|
|
153
158
|
}
|
|
@@ -26,6 +26,8 @@ export default function AgentScopeRuntimeResponseCard(props: {
|
|
|
26
26
|
return <Message key={item.id} data={item} />
|
|
27
27
|
case AgentScopeRuntimeMessageType.PLUGIN_CALL:
|
|
28
28
|
case AgentScopeRuntimeMessageType.PLUGIN_CALL_OUTPUT:
|
|
29
|
+
case AgentScopeRuntimeMessageType.MCP_CALL:
|
|
30
|
+
case AgentScopeRuntimeMessageType.MCP_CALL_OUTPUT:
|
|
29
31
|
return <Tool key={item.id} data={item} />
|
|
30
32
|
case AgentScopeRuntimeMessageType.REASONING:
|
|
31
33
|
return <Reasoning key={item.id} data={item} />
|
|
@@ -12,7 +12,7 @@ const Tool = React.memo(function ({ data }: { data: IAgentScopeRuntimeMessage })
|
|
|
12
12
|
}>[];
|
|
13
13
|
const toolName = content[0].data.name;
|
|
14
14
|
|
|
15
|
-
return <ToolCall title={toolName} input={content[0]
|
|
15
|
+
return <ToolCall title={toolName} input={content[0]?.data?.arguments} output={content[1]?.data?.output}></ToolCall>
|
|
16
16
|
})
|
|
17
17
|
|
|
18
18
|
export default Tool;
|
|
@@ -25,7 +25,8 @@ export enum AgentScopeRuntimeMessageType {
|
|
|
25
25
|
COMPONENT_CALL_OUTPUT = "component_call_output",
|
|
26
26
|
MCP_LIST_TOOLS = "mcp_list_tools",
|
|
27
27
|
MCP_APPROVAL_REQUEST = "mcp_approval_request",
|
|
28
|
-
|
|
28
|
+
MCP_CALL = "mcp_call",
|
|
29
|
+
MCP_CALL_OUTPUT = "mcp_call_output",
|
|
29
30
|
MCP_APPROVAL_RESPONSE = "mcp_approval_response",
|
|
30
31
|
HEARTBEAT = "heartbeat",
|
|
31
32
|
ERROR = "error",
|
|
@@ -6,7 +6,7 @@ import { useInput } from '../hooks/useInput';
|
|
|
6
6
|
import { Button, GetProp, Space, Upload } from 'antd';
|
|
7
7
|
import Style from './style';
|
|
8
8
|
import { IconButton } from '@agentscope-ai/design';
|
|
9
|
-
import SenderHeader from '@agentscope-ai/chat/AIGC/
|
|
9
|
+
import SenderHeader from '@agentscope-ai/chat/AIGC/core/SenderHeader';
|
|
10
10
|
import { useClickAway, useFocusWithin } from 'ahooks';
|
|
11
11
|
|
|
12
12
|
type AttachedFiles = GetProp<typeof Attachments, 'items'>;
|
|
@@ -88,7 +88,11 @@ var AgentScopeRuntimeResponseBuilder = /*#__PURE__*/function () {
|
|
|
88
88
|
msg.content.push(data);
|
|
89
89
|
}
|
|
90
90
|
} else {
|
|
91
|
-
|
|
91
|
+
if (msg.content.length > 0) {
|
|
92
|
+
Object.assign(msg.content[msg.content.length - 1], data);
|
|
93
|
+
} else {
|
|
94
|
+
msg.content.push(data);
|
|
95
|
+
}
|
|
92
96
|
}
|
|
93
97
|
});
|
|
94
98
|
}
|
|
@@ -173,12 +177,12 @@ var AgentScopeRuntimeResponseBuilder = /*#__PURE__*/function () {
|
|
|
173
177
|
}, {
|
|
174
178
|
key: "maybeToolOutput",
|
|
175
179
|
value: function maybeToolOutput(message) {
|
|
176
|
-
return [AgentScopeRuntimeMessageType.FUNCTION_CALL_OUTPUT, AgentScopeRuntimeMessageType.PLUGIN_CALL_OUTPUT, AgentScopeRuntimeMessageType.COMPONENT_CALL_OUTPUT].includes(message.type);
|
|
180
|
+
return [AgentScopeRuntimeMessageType.FUNCTION_CALL_OUTPUT, AgentScopeRuntimeMessageType.PLUGIN_CALL_OUTPUT, AgentScopeRuntimeMessageType.COMPONENT_CALL_OUTPUT, AgentScopeRuntimeMessageType.MCP_CALL_OUTPUT].includes(message.type);
|
|
177
181
|
}
|
|
178
182
|
}, {
|
|
179
183
|
key: "maybeToolInput",
|
|
180
184
|
value: function maybeToolInput(message) {
|
|
181
|
-
return [AgentScopeRuntimeMessageType.FUNCTION_CALL, AgentScopeRuntimeMessageType.PLUGIN_CALL, AgentScopeRuntimeMessageType.COMPONENT_CALL].includes(message.type);
|
|
185
|
+
return [AgentScopeRuntimeMessageType.FUNCTION_CALL, AgentScopeRuntimeMessageType.PLUGIN_CALL, AgentScopeRuntimeMessageType.COMPONENT_CALL, AgentScopeRuntimeMessageType.MCP_CALL].includes(message.type);
|
|
182
186
|
}
|
|
183
187
|
}, {
|
|
184
188
|
key: "maybeGenerating",
|
|
@@ -30,6 +30,8 @@ export default function AgentScopeRuntimeResponseCard(props) {
|
|
|
30
30
|
}, item.id);
|
|
31
31
|
case AgentScopeRuntimeMessageType.PLUGIN_CALL:
|
|
32
32
|
case AgentScopeRuntimeMessageType.PLUGIN_CALL_OUTPUT:
|
|
33
|
+
case AgentScopeRuntimeMessageType.MCP_CALL:
|
|
34
|
+
case AgentScopeRuntimeMessageType.MCP_CALL_OUTPUT:
|
|
33
35
|
return /*#__PURE__*/_jsx(Tool, {
|
|
34
36
|
data: item
|
|
35
37
|
}, item.id);
|
|
@@ -3,14 +3,15 @@ import { AgentScopeRuntimeRunStatus } from "../types";
|
|
|
3
3
|
import { ToolCall } from "../../../..";
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
5
|
var Tool = /*#__PURE__*/React.memo(function (_ref) {
|
|
6
|
+
var _content$, _content$2;
|
|
6
7
|
var data = _ref.data;
|
|
7
8
|
if (data.status === AgentScopeRuntimeRunStatus.InProgress || data.status === AgentScopeRuntimeRunStatus.Created) return null;
|
|
8
9
|
var content = data.content;
|
|
9
10
|
var toolName = content[0].data.name;
|
|
10
11
|
return /*#__PURE__*/_jsx(ToolCall, {
|
|
11
12
|
title: toolName,
|
|
12
|
-
input: content[0]
|
|
13
|
-
output: content[1].data.output
|
|
13
|
+
input: (_content$ = content[0]) === null || _content$ === void 0 || (_content$ = _content$.data) === null || _content$ === void 0 ? void 0 : _content$.arguments,
|
|
14
|
+
output: (_content$2 = content[1]) === null || _content$2 === void 0 || (_content$2 = _content$2.data) === null || _content$2 === void 0 ? void 0 : _content$2.output
|
|
14
15
|
});
|
|
15
16
|
});
|
|
16
17
|
export default Tool;
|
|
@@ -23,7 +23,8 @@ export declare enum AgentScopeRuntimeMessageType {
|
|
|
23
23
|
COMPONENT_CALL_OUTPUT = "component_call_output",
|
|
24
24
|
MCP_LIST_TOOLS = "mcp_list_tools",
|
|
25
25
|
MCP_APPROVAL_REQUEST = "mcp_approval_request",
|
|
26
|
-
|
|
26
|
+
MCP_CALL = "mcp_call",
|
|
27
|
+
MCP_CALL_OUTPUT = "mcp_call_output",
|
|
27
28
|
MCP_APPROVAL_RESPONSE = "mcp_approval_response",
|
|
28
29
|
HEARTBEAT = "heartbeat",
|
|
29
30
|
ERROR = "error"
|
|
@@ -25,7 +25,8 @@ export var AgentScopeRuntimeMessageType = /*#__PURE__*/function (AgentScopeRunti
|
|
|
25
25
|
AgentScopeRuntimeMessageType["COMPONENT_CALL_OUTPUT"] = "component_call_output";
|
|
26
26
|
AgentScopeRuntimeMessageType["MCP_LIST_TOOLS"] = "mcp_list_tools";
|
|
27
27
|
AgentScopeRuntimeMessageType["MCP_APPROVAL_REQUEST"] = "mcp_approval_request";
|
|
28
|
-
AgentScopeRuntimeMessageType["
|
|
28
|
+
AgentScopeRuntimeMessageType["MCP_CALL"] = "mcp_call";
|
|
29
|
+
AgentScopeRuntimeMessageType["MCP_CALL_OUTPUT"] = "mcp_call_output";
|
|
29
30
|
AgentScopeRuntimeMessageType["MCP_APPROVAL_RESPONSE"] = "mcp_approval_response";
|
|
30
31
|
AgentScopeRuntimeMessageType["HEARTBEAT"] = "heartbeat";
|
|
31
32
|
AgentScopeRuntimeMessageType["ERROR"] = "error";
|
|
@@ -21,7 +21,7 @@ import { useInput } from "../hooks/useInput";
|
|
|
21
21
|
import { Upload } from 'antd';
|
|
22
22
|
import Style from "./style";
|
|
23
23
|
import { IconButton } from '@agentscope-ai/design';
|
|
24
|
-
import SenderHeader from "../../AIGC/
|
|
24
|
+
import SenderHeader from "../../AIGC/core/SenderHeader";
|
|
25
25
|
import { useClickAway, useFocusWithin } from 'ahooks';
|
|
26
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
27
|
import { createElement as _createElement } from "react";
|
package/package.json
CHANGED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { IAgentScopeRuntimeWebUIInputData } from "@agentscope-ai/chat";
|
|
2
|
-
import { IAgentScopeRuntimeWebUIMessage } from "@agentscope-ai/chat";
|
|
3
|
-
import { AgentScopeRuntimeContentType, AgentScopeRuntimeMessageType, AgentScopeRuntimeRunStatus, IAgentScopeRuntimeRequest, IContent, IFileContent, IImageContent, ITextContent } from "../types";
|
|
4
|
-
|
|
5
|
-
class AgentScopeRuntimeRequestBuilder {
|
|
6
|
-
data: IAgentScopeRuntimeRequest;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
static getHistoryMessages(messages: IAgentScopeRuntimeWebUIMessage[]) {
|
|
10
|
-
return messages.reduce((p, c) => {
|
|
11
|
-
if (!c.cards?.length) {
|
|
12
|
-
return p;
|
|
13
|
-
} else {
|
|
14
|
-
return p.concat(c.cards[0].data.input || c.cards[0].data.output)
|
|
15
|
-
}
|
|
16
|
-
}, [])
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
isImageFile(file: IAgentScopeRuntimeWebUIInputData['fileList'][number]) {
|
|
21
|
-
return file.type.indexOf('image/') === 0;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
buildImageContent(imageFile: IAgentScopeRuntimeWebUIInputData['fileList'][number]): IImageContent {
|
|
26
|
-
return {
|
|
27
|
-
type: AgentScopeRuntimeContentType.IMAGE,
|
|
28
|
-
image_url: imageFile.response?.url,
|
|
29
|
-
status: AgentScopeRuntimeRunStatus.Created,
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
buildTextContent(text: string): ITextContent {
|
|
34
|
-
return {
|
|
35
|
-
type: AgentScopeRuntimeContentType.TEXT,
|
|
36
|
-
text: text,
|
|
37
|
-
status: AgentScopeRuntimeRunStatus.Created,
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
buildFileContent(file: IAgentScopeRuntimeWebUIInputData['fileList'][number]): IFileContent {
|
|
42
|
-
return {
|
|
43
|
-
type: AgentScopeRuntimeContentType.FILE,
|
|
44
|
-
file_url: file.response?.url,
|
|
45
|
-
file_name: file.name,
|
|
46
|
-
file_size: file.size,
|
|
47
|
-
status: AgentScopeRuntimeRunStatus.Created,
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
constructor(data: IAgentScopeRuntimeWebUIInputData) {
|
|
54
|
-
const content: IContent[] = [
|
|
55
|
-
this.buildTextContent(data.query),
|
|
56
|
-
];
|
|
57
|
-
|
|
58
|
-
if (data.fileList?.length) {
|
|
59
|
-
data.fileList.forEach(item => {
|
|
60
|
-
if (this.isImageFile(item)) {
|
|
61
|
-
content.push(this.buildImageContent(item));
|
|
62
|
-
} else {
|
|
63
|
-
content.push(this.buildFileContent(item));
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
this.data = {
|
|
69
|
-
input: [
|
|
70
|
-
{
|
|
71
|
-
role: 'user',
|
|
72
|
-
type: AgentScopeRuntimeMessageType.MESSAGE,
|
|
73
|
-
content: content,
|
|
74
|
-
}
|
|
75
|
-
],
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
export default AgentScopeRuntimeRequestBuilder;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { AgentScopeRuntimeContentType, IAgentScopeRuntimeRequest } from '../types';
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
|
-
import { Bubble } from '@agentscope-ai/chat';
|
|
5
|
-
|
|
6
|
-
export default function AgentScopeRuntimeRequestCard(props: {
|
|
7
|
-
data: IAgentScopeRuntimeRequest;
|
|
8
|
-
}) {
|
|
9
|
-
|
|
10
|
-
const cards = useMemo(() => {
|
|
11
|
-
|
|
12
|
-
return props.data.input[0].content.reduce<any>((p, c) => {
|
|
13
|
-
if (c.type === AgentScopeRuntimeContentType.TEXT) {
|
|
14
|
-
p.push({
|
|
15
|
-
code: 'Text',
|
|
16
|
-
data: {
|
|
17
|
-
content: c.text,
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (c.type === AgentScopeRuntimeContentType.IMAGE) {
|
|
23
|
-
const imageCard = p.find((item: any) => item.code === 'Image');
|
|
24
|
-
if (!imageCard) {
|
|
25
|
-
p.push({
|
|
26
|
-
code: 'Images',
|
|
27
|
-
data: [{ url: c.image_url }],
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
} else {
|
|
31
|
-
imageCard.data.push({ url: c.image_url });
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (c.type === AgentScopeRuntimeContentType.FILE) {
|
|
36
|
-
const fileCard = p.find((item: any) => item.code === 'Files');
|
|
37
|
-
if (!fileCard) {
|
|
38
|
-
p.push({
|
|
39
|
-
code: 'Files',
|
|
40
|
-
data: [{ url: c.file_url, name: c.file_name, size: c.file_size }],
|
|
41
|
-
});
|
|
42
|
-
} else {
|
|
43
|
-
fileCard.data.push({ url: c.file_url, name: c.file_name, size: c.file_size });
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return p;
|
|
47
|
-
}, []);
|
|
48
|
-
}, [props.data.input]);
|
|
49
|
-
|
|
50
|
-
return <Bubble role="user" cards={cards}></Bubble>;
|
|
51
|
-
}
|
|
52
|
-
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { SparkCopyLine, SparkReplaceLine } from "@agentscope-ai/icons";
|
|
2
|
-
import { IAgentScopeRuntimeResponse } from "../types";
|
|
3
|
-
import AgentScopeRuntimeResponseBuilder from "./Builder";
|
|
4
|
-
import { Bubble } from "@agentscope-ai/chat";
|
|
5
|
-
import { copy, message } from "@agentscope-ai/design";
|
|
6
|
-
import compact from 'lodash/compact';
|
|
7
|
-
import { emit } from "../../Context/useChatAnywhereEventEmitter";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export default function Tools(props: {
|
|
11
|
-
data: IAgentScopeRuntimeResponse
|
|
12
|
-
isLast?: boolean;
|
|
13
|
-
}) {
|
|
14
|
-
|
|
15
|
-
const actions = compact([
|
|
16
|
-
{
|
|
17
|
-
icon: <SparkCopyLine />,
|
|
18
|
-
onClick: () => {
|
|
19
|
-
copy(JSON.stringify(props.data));
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
props.isLast ? {
|
|
23
|
-
icon: <SparkReplaceLine />,
|
|
24
|
-
onClick: () => {
|
|
25
|
-
emit({
|
|
26
|
-
type: 'handleReplace',
|
|
27
|
-
data: props,
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
} : null,
|
|
31
|
-
]);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (!AgentScopeRuntimeResponseBuilder.maybeDone(props.data)) return null;
|
|
35
|
-
return <Bubble.Footer
|
|
36
|
-
left={<Bubble.Footer.Actions data={actions} />}
|
|
37
|
-
/>
|
|
38
|
-
}
|
|
39
|
-
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { produce } from "immer";
|
|
3
|
-
import { IAgentScopeRuntimeResponse, AgentScopeRuntimeRunStatus, IAgentScopeRuntimeMessage, IContent, AgentScopeRuntimeContentType, ITextContent, IImageContent, IDataContent, AgentScopeRuntimeMessageType } from "../types";
|
|
4
|
-
import { uuid } from "@agentscope-ai/chat";
|
|
5
|
-
|
|
6
|
-
class AgentScopeRuntimeResponseBuilder {
|
|
7
|
-
|
|
8
|
-
static mergeToolMessages(messages: IAgentScopeRuntimeMessage[]) {
|
|
9
|
-
|
|
10
|
-
const bufferMessagesMap = new Map<string, IDataContent>();
|
|
11
|
-
return messages.reduce<IAgentScopeRuntimeMessage[]>((p, c) => {
|
|
12
|
-
|
|
13
|
-
if (AgentScopeRuntimeResponseBuilder.maybeToolInput(c) && c.content?.length) {
|
|
14
|
-
const content = c.content[0] as IDataContent<{
|
|
15
|
-
name: string;
|
|
16
|
-
}>;
|
|
17
|
-
bufferMessagesMap.set(content.data.name, content);
|
|
18
|
-
return p;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (AgentScopeRuntimeResponseBuilder.maybeToolOutput(c)) {
|
|
22
|
-
const content = c.content[0] as IDataContent<{
|
|
23
|
-
name: string;
|
|
24
|
-
}>;
|
|
25
|
-
|
|
26
|
-
const bufferContent = bufferMessagesMap.get(content.data.name);
|
|
27
|
-
|
|
28
|
-
if (bufferContent) {
|
|
29
|
-
bufferMessagesMap.delete(content.data.name);
|
|
30
|
-
return [...p, { ...c, content: [bufferContent, ...c.content] }];
|
|
31
|
-
} else {
|
|
32
|
-
return p;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return [...p, c]
|
|
38
|
-
}, []);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
static maybeToolOutput(message: IAgentScopeRuntimeMessage) {
|
|
43
|
-
return [
|
|
44
|
-
AgentScopeRuntimeMessageType.FUNCTION_CALL_OUTPUT,
|
|
45
|
-
AgentScopeRuntimeMessageType.PLUGIN_CALL_OUTPUT,
|
|
46
|
-
AgentScopeRuntimeMessageType.COMPONENT_CALL_OUTPUT,
|
|
47
|
-
].includes(message.type);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
static maybeToolInput(message: IAgentScopeRuntimeMessage) {
|
|
51
|
-
return [
|
|
52
|
-
AgentScopeRuntimeMessageType.FUNCTION_CALL,
|
|
53
|
-
AgentScopeRuntimeMessageType.PLUGIN_CALL,
|
|
54
|
-
AgentScopeRuntimeMessageType.COMPONENT_CALL,
|
|
55
|
-
].includes(message.type);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
static maybeGenerating(data: { status: AgentScopeRuntimeRunStatus }) {
|
|
59
|
-
return [
|
|
60
|
-
AgentScopeRuntimeRunStatus.InProgress,
|
|
61
|
-
AgentScopeRuntimeRunStatus.Created,
|
|
62
|
-
].includes(data.status);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
static maybeDone(data: { status: AgentScopeRuntimeRunStatus }) {
|
|
66
|
-
return [
|
|
67
|
-
AgentScopeRuntimeRunStatus.Completed,
|
|
68
|
-
AgentScopeRuntimeRunStatus.Canceled,
|
|
69
|
-
AgentScopeRuntimeRunStatus.Failed,
|
|
70
|
-
].includes(data.status);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
data: IAgentScopeRuntimeResponse;
|
|
75
|
-
|
|
76
|
-
constructor({ id, status, created_at }: Pick<IAgentScopeRuntimeResponse, 'id' | 'status' | 'created_at'>) {
|
|
77
|
-
this.data = {
|
|
78
|
-
id: id,
|
|
79
|
-
output: [],
|
|
80
|
-
object: 'response',
|
|
81
|
-
status: status || AgentScopeRuntimeRunStatus.Created,
|
|
82
|
-
created_at: created_at || Date.now(),
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
handleResponse(data: IAgentScopeRuntimeResponse) {
|
|
87
|
-
this.data = produce(this.data, (draft) => {
|
|
88
|
-
if (!data.output) {
|
|
89
|
-
data.output = [];
|
|
90
|
-
}
|
|
91
|
-
Object.assign(draft, data);
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
handleMessage(data: IAgentScopeRuntimeMessage) {
|
|
96
|
-
this.data = produce(this.data, (draft) => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (!draft.output) {
|
|
100
|
-
draft.output = [];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const existingIndex = draft.output.findIndex(msg => msg.id === data.id);
|
|
104
|
-
|
|
105
|
-
if (existingIndex >= 0) {
|
|
106
|
-
const existingContent = draft.output[existingIndex].content;
|
|
107
|
-
Object.assign(draft.output[existingIndex], data);
|
|
108
|
-
if (!data.content || data.content.length === 0) {
|
|
109
|
-
draft.output[existingIndex].content = existingContent;
|
|
110
|
-
}
|
|
111
|
-
} else {
|
|
112
|
-
draft.output.push(data);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
handleContent(data: IContent) {
|
|
118
|
-
this.data = produce(this.data, (draft) => {
|
|
119
|
-
const msg = draft.output.find(m => m.id === data.msg_id);
|
|
120
|
-
|
|
121
|
-
if (!msg) {
|
|
122
|
-
console.warn('Message not found for content:', data.msg_id);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (!msg.content) {
|
|
127
|
-
msg.content = [];
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (data.delta) {
|
|
131
|
-
const lastContent = msg.content[msg.content.length - 1];
|
|
132
|
-
|
|
133
|
-
if (lastContent && lastContent.delta) {
|
|
134
|
-
if (data.type === AgentScopeRuntimeContentType.TEXT && lastContent.type === AgentScopeRuntimeContentType.TEXT) {
|
|
135
|
-
(lastContent as ITextContent).text += (data as ITextContent).text;
|
|
136
|
-
} else if (data.type === AgentScopeRuntimeContentType.IMAGE) {
|
|
137
|
-
(lastContent as IImageContent).image_url = (data as IImageContent).image_url;
|
|
138
|
-
} else if (data.type === AgentScopeRuntimeContentType.DATA) {
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
} else {
|
|
142
|
-
msg.content.push(data);
|
|
143
|
-
}
|
|
144
|
-
} else {
|
|
145
|
-
Object.assign(msg.content[msg.content.length - 1], data);
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
handleError(data: IAgentScopeRuntimeMessage) {
|
|
152
|
-
this.data = produce(this.data, (draft) => {
|
|
153
|
-
draft.status = AgentScopeRuntimeRunStatus.Failed;
|
|
154
|
-
|
|
155
|
-
draft.output.push({
|
|
156
|
-
status: AgentScopeRuntimeRunStatus.Failed,
|
|
157
|
-
type: AgentScopeRuntimeMessageType.ERROR,
|
|
158
|
-
content: [],
|
|
159
|
-
id: uuid(),
|
|
160
|
-
role: 'assistant',
|
|
161
|
-
code: data.code,
|
|
162
|
-
message: typeof data.message === 'string' ? data.message : JSON.stringify(data.message),
|
|
163
|
-
})
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
handle(data: IAgentScopeRuntimeResponse | IAgentScopeRuntimeMessage | IContent) {
|
|
168
|
-
if (data.object === 'response') {
|
|
169
|
-
this.handleResponse(data);
|
|
170
|
-
} else if (data.object === 'message') {
|
|
171
|
-
this.handleMessage(data);
|
|
172
|
-
} else if (data.object === 'content') {
|
|
173
|
-
this.handleContent(data);
|
|
174
|
-
} else {
|
|
175
|
-
this.handleError(data);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return this.data;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
cancel() {
|
|
182
|
-
this.data = produce(this.data, (draft) => {
|
|
183
|
-
if (AgentScopeRuntimeResponseBuilder.maybeGenerating(draft)) {
|
|
184
|
-
draft.status = AgentScopeRuntimeRunStatus.Canceled;
|
|
185
|
-
}
|
|
186
|
-
draft.output.forEach(msg => {
|
|
187
|
-
if (AgentScopeRuntimeResponseBuilder.maybeGenerating(msg)) {
|
|
188
|
-
msg.status = AgentScopeRuntimeRunStatus.Canceled;
|
|
189
|
-
msg.content.forEach(content => {
|
|
190
|
-
if (AgentScopeRuntimeResponseBuilder.maybeGenerating(content)) {
|
|
191
|
-
content.status = AgentScopeRuntimeRunStatus.Canceled;
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
return this.data;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
export default AgentScopeRuntimeResponseBuilder;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
import { AgentScopeRuntimeMessageType, IAgentScopeRuntimeResponse } from "../types";
|
|
3
|
-
import AgentScopeRuntimeResponseBuilder from "./Builder";
|
|
4
|
-
import Message from "./Message";
|
|
5
|
-
import Tool from "./Tool";
|
|
6
|
-
import Reasoning from "./Reasoning";
|
|
7
|
-
import Error from "./Error";
|
|
8
|
-
import { Bubble } from "@agentscope-ai/chat";
|
|
9
|
-
import Actions from "./Actions";
|
|
10
|
-
|
|
11
|
-
export default function AgentScopeRuntimeResponseCard(props: {
|
|
12
|
-
data: IAgentScopeRuntimeResponse;
|
|
13
|
-
isLast?: boolean;
|
|
14
|
-
}) {
|
|
15
|
-
const messages = useMemo(() => {
|
|
16
|
-
return AgentScopeRuntimeResponseBuilder.mergeToolMessages(props.data.output);
|
|
17
|
-
}, [props.data.output])
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (!messages?.length && AgentScopeRuntimeResponseBuilder.maybeGenerating(props.data)) return <Bubble.Spin />;
|
|
21
|
-
|
|
22
|
-
return <>{
|
|
23
|
-
messages.map(item => {
|
|
24
|
-
switch (item.type) {
|
|
25
|
-
case AgentScopeRuntimeMessageType.MESSAGE:
|
|
26
|
-
return <Message key={item.id} data={item} />
|
|
27
|
-
case AgentScopeRuntimeMessageType.PLUGIN_CALL:
|
|
28
|
-
case AgentScopeRuntimeMessageType.PLUGIN_CALL_OUTPUT:
|
|
29
|
-
return <Tool key={item.id} data={item} />
|
|
30
|
-
case AgentScopeRuntimeMessageType.REASONING:
|
|
31
|
-
return <Reasoning key={item.id} data={item} />
|
|
32
|
-
case AgentScopeRuntimeMessageType.ERROR:
|
|
33
|
-
return <Error key={item.id} data={item} />
|
|
34
|
-
case AgentScopeRuntimeMessageType.HEARTBEAT:
|
|
35
|
-
return null;
|
|
36
|
-
default:
|
|
37
|
-
console.warn(`[WIP] Unknown message type: ${item.type}`);
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
<Actions {...props} />
|
|
43
|
-
</>
|
|
44
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { IAgentScopeRuntimeMessage } from "../types";
|
|
2
|
-
import { Bubble } from "@agentscope-ai/chat";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export default function Error({ data }: { data: IAgentScopeRuntimeMessage }) {
|
|
6
|
-
return <Bubble.Interrupted type="error" title={data.code} desc={data.message} />;
|
|
7
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Markdown } from '@agentscope-ai/chat';
|
|
3
|
-
import { AgentScopeRuntimeContentType, AgentScopeRuntimeRunStatus, IAgentScopeRuntimeMessage } from "../types";
|
|
4
|
-
|
|
5
|
-
const Message = React.memo(function ({ data }: { data: IAgentScopeRuntimeMessage }) {
|
|
6
|
-
if (!data.content?.length) return null;
|
|
7
|
-
|
|
8
|
-
return <>
|
|
9
|
-
{
|
|
10
|
-
data.content.map((item, index) => {
|
|
11
|
-
switch (item.type) {
|
|
12
|
-
case AgentScopeRuntimeContentType.TEXT:
|
|
13
|
-
return <Markdown key={index} content={item.text} cursor={item.status === AgentScopeRuntimeRunStatus.InProgress ? true : false}></Markdown>
|
|
14
|
-
default:
|
|
15
|
-
return <div key={index}>{JSON.stringify(item)}</div>
|
|
16
|
-
}
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
</>
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
export default Message;
|
|
23
|
-
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { AgentScopeRuntimeRunStatus, IAgentScopeRuntimeMessage, ITextContent } from "../types";
|
|
2
|
-
import { Thinking } from "@agentscope-ai/chat";
|
|
3
|
-
|
|
4
|
-
export default function Reasoning({ data }: { data: IAgentScopeRuntimeMessage }) {
|
|
5
|
-
|
|
6
|
-
if (data.status === AgentScopeRuntimeRunStatus.Created) return null;
|
|
7
|
-
|
|
8
|
-
const content = data?.content?.[0] as ITextContent;
|
|
9
|
-
if (!content) return null;
|
|
10
|
-
|
|
11
|
-
return <Thinking
|
|
12
|
-
title="Thinking"
|
|
13
|
-
content={content.text}
|
|
14
|
-
|
|
15
|
-
></Thinking>;
|
|
16
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { AgentScopeRuntimeRunStatus, IAgentScopeRuntimeMessage, IDataContent } from "../types";
|
|
3
|
-
import { Bubble, ToolCall } from '@agentscope-ai/chat';
|
|
4
|
-
|
|
5
|
-
const Tool = React.memo(function ({ data }: { data: IAgentScopeRuntimeMessage }) {
|
|
6
|
-
|
|
7
|
-
if (data.status === AgentScopeRuntimeRunStatus.InProgress || data.status === AgentScopeRuntimeRunStatus.Created) return null;
|
|
8
|
-
const content = data.content as IDataContent<{
|
|
9
|
-
name: string;
|
|
10
|
-
arguments: Record<string, any>;
|
|
11
|
-
output: Record<string, any>;
|
|
12
|
-
}>[];
|
|
13
|
-
const toolName = content[0].data.name;
|
|
14
|
-
|
|
15
|
-
return <ToolCall title={toolName} input={content[0].data.arguments} output={content[1].data.output}></ToolCall>
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
export default Tool;
|
|
19
|
-
|
|
File without changes
|