@agentscope-ai/chat 1.1.64 → 1.1.66

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.
Files changed (27) hide show
  1. package/components/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/Response/Builder.tsx +23 -1
  2. package/components/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/Response/Card.tsx +2 -0
  3. package/components/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/Response/Tool.tsx +28 -5
  4. package/components/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/types.tsx +2 -0
  5. package/lib/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/Response/Builder.js +27 -5
  6. package/lib/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/Response/Card.js +2 -0
  7. package/lib/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/Response/Tool.js +29 -4
  8. package/lib/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/types.d.ts +2 -0
  9. package/lib/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/types.js +2 -0
  10. package/package.json +1 -1
  11. package/bin/starter_webui/README.md +0 -75
  12. package/bin/starter_webui/eslint.config.js +0 -28
  13. package/bin/starter_webui/index.html +0 -12
  14. package/bin/starter_webui/package.json +0 -34
  15. package/bin/starter_webui/src/App.tsx +0 -20
  16. package/bin/starter_webui/src/components/Chat/OptionsPanel/FormItem.tsx +0 -37
  17. package/bin/starter_webui/src/components/Chat/OptionsPanel/OptionsEditor.tsx +0 -160
  18. package/bin/starter_webui/src/components/Chat/OptionsPanel/defaultConfig.ts +0 -41
  19. package/bin/starter_webui/src/components/Chat/OptionsPanel/index.tsx +0 -27
  20. package/bin/starter_webui/src/components/Chat/index.tsx +0 -45
  21. package/bin/starter_webui/src/components/Chat/sessionApi/index.ts +0 -53
  22. package/bin/starter_webui/src/main.tsx +0 -9
  23. package/bin/starter_webui/src/vite-env.d.ts +0 -4
  24. package/bin/starter_webui/tsconfig.app.json +0 -24
  25. package/bin/starter_webui/tsconfig.json +0 -7
  26. package/bin/starter_webui/tsconfig.node.json +0 -22
  27. package/bin/starter_webui/vite.config.ts +0 -11
@@ -61,6 +61,7 @@ class AgentScopeRuntimeResponseBuilder {
61
61
  return [
62
62
  AgentScopeRuntimeMessageType.FUNCTION_CALL_OUTPUT,
63
63
  AgentScopeRuntimeMessageType.PLUGIN_CALL_OUTPUT,
64
+ AgentScopeRuntimeMessageType.TOOL_CALL_OUTPUT,
64
65
  AgentScopeRuntimeMessageType.COMPONENT_CALL_OUTPUT,
65
66
  AgentScopeRuntimeMessageType.MCP_CALL_OUTPUT,
66
67
  ].includes(message.type);
@@ -70,6 +71,7 @@ class AgentScopeRuntimeResponseBuilder {
70
71
  return [
71
72
  AgentScopeRuntimeMessageType.FUNCTION_CALL,
72
73
  AgentScopeRuntimeMessageType.PLUGIN_CALL,
74
+ AgentScopeRuntimeMessageType.TOOL_CALL,
73
75
  AgentScopeRuntimeMessageType.COMPONENT_CALL,
74
76
  AgentScopeRuntimeMessageType.MCP_CALL,
75
77
  ].includes(message.type);
@@ -155,7 +157,27 @@ class AgentScopeRuntimeResponseBuilder {
155
157
  } else if (data.type === AgentScopeRuntimeContentType.IMAGE) {
156
158
  (lastContent as IImageContent).image_url = (data as IImageContent).image_url;
157
159
  } else if (data.type === AgentScopeRuntimeContentType.DATA) {
158
- (lastContent as IDataContent).data = (data as IDataContent).data;
160
+ const isStreamingToolInput = [
161
+ AgentScopeRuntimeMessageType.PLUGIN_CALL,
162
+ AgentScopeRuntimeMessageType.TOOL_CALL,
163
+ AgentScopeRuntimeMessageType.MCP_CALL,
164
+ ].includes(msg.type as AgentScopeRuntimeMessageType);
165
+
166
+ if (isStreamingToolInput) {
167
+ const oldData = (lastContent as IDataContent).data || {};
168
+ const newData = (data as IDataContent).data || {};
169
+ const merged: Record<string, any> = { ...oldData };
170
+ for (const [key, value] of Object.entries(newData)) {
171
+ if (typeof value === 'string' && typeof merged[key] === 'string') {
172
+ merged[key] = merged[key] + value;
173
+ } else {
174
+ merged[key] = value;
175
+ }
176
+ }
177
+ (lastContent as IDataContent).data = merged;
178
+ } else {
179
+ (lastContent as IDataContent).data = (data as IDataContent).data;
180
+ }
159
181
  }
160
182
  } else {
161
183
  msg.content.push(data);
@@ -36,6 +36,8 @@ export default function AgentScopeRuntimeResponseCard(props: {
36
36
  return <Message key={item.id} data={item} />
37
37
  case AgentScopeRuntimeMessageType.PLUGIN_CALL:
38
38
  case AgentScopeRuntimeMessageType.PLUGIN_CALL_OUTPUT:
39
+ case AgentScopeRuntimeMessageType.TOOL_CALL:
40
+ case AgentScopeRuntimeMessageType.TOOL_CALL_OUTPUT:
39
41
  case AgentScopeRuntimeMessageType.MCP_CALL:
40
42
  case AgentScopeRuntimeMessageType.MCP_CALL_OUTPUT:
41
43
  return <Tool key={item.id} data={item} />
@@ -1,12 +1,28 @@
1
- import React from "react";
2
- import { AgentScopeRuntimeRunStatus, IAgentScopeRuntimeMessage, IDataContent } from "../types";
1
+ import React, { useEffect, useState } from "react";
2
+ import { AgentScopeRuntimeMessageType, AgentScopeRuntimeRunStatus, IAgentScopeRuntimeMessage, IDataContent } from "../types";
3
3
  import { ToolCall } from '@agentscope-ai/chat';
4
4
  import { useChatAnywhereOptions } from "../../Context/ChatAnywhereOptionsContext";
5
5
  import Approval from "./Approval";
6
6
 
7
+ // output展示后,2s自动关闭
8
+ const OUTPUT_AUTO_COLLAPSE_MS = 2000;
9
+
7
10
  const Tool = React.memo(function ({ data, isApproval = false }: { data: IAgentScopeRuntimeMessage, isApproval?: boolean }) {
8
11
  const customToolRenderConfig = useChatAnywhereOptions(v => v.customToolRenderConfig) || {};
9
12
 
13
+ const isOutput = [
14
+ AgentScopeRuntimeMessageType.PLUGIN_CALL_OUTPUT,
15
+ AgentScopeRuntimeMessageType.TOOL_CALL_OUTPUT,
16
+ AgentScopeRuntimeMessageType.MCP_CALL_OUTPUT,
17
+ ].includes(data.type);
18
+
19
+ const [autoCollapsed, setAutoCollapsed] = useState(false);
20
+ useEffect(() => {
21
+ if (!isOutput || autoCollapsed) return;
22
+ const timer = setTimeout(() => setAutoCollapsed(true), OUTPUT_AUTO_COLLAPSE_MS);
23
+ return () => clearTimeout(timer);
24
+ }, [isOutput, autoCollapsed]);
25
+
10
26
  if (!data.content?.length) return null;
11
27
  const content = data.content as IDataContent<{
12
28
  name: string;
@@ -19,13 +35,21 @@ const Tool = React.memo(function ({ data, isApproval = false }: { data: IAgentSc
19
35
  const serverLabel = `${content[0].data.server_label ? content[0].data.server_label + ' / ' : ''}`
20
36
  const title = `${serverLabel}${toolName}`
21
37
 
38
+ const isInput = [
39
+ AgentScopeRuntimeMessageType.PLUGIN_CALL,
40
+ AgentScopeRuntimeMessageType.TOOL_CALL,
41
+ AgentScopeRuntimeMessageType.MCP_CALL,
42
+ ].includes(data.type);
43
+
44
+ const defaultOpen = isInput || (isOutput && !autoCollapsed);
45
+
22
46
  let node
23
47
 
24
48
  if (customToolRenderConfig[toolName]) {
25
49
  const C = customToolRenderConfig[toolName];
26
50
  node = <C data={data} />
27
51
  } else {
28
- node = <ToolCall loading={loading} defaultOpen={false} title={title === 'undefined' ? '' : title} input={content[0]?.data?.arguments} output={content[1]?.data?.output}></ToolCall>
52
+ node = <ToolCall key={autoCollapsed ? 'collapsed' : 'open'} loading={loading} defaultOpen={defaultOpen} title={title === 'undefined' ? '' : title} input={content[0]?.data?.arguments} output={content[1]?.data?.output}></ToolCall>
29
53
  }
30
54
 
31
55
  return <>
@@ -35,5 +59,4 @@ const Tool = React.memo(function ({ data, isApproval = false }: { data: IAgentSc
35
59
  })
36
60
 
37
61
 
38
- export default Tool;
39
-
62
+ export default Tool;
@@ -19,6 +19,8 @@ export enum AgentScopeRuntimeMessageType {
19
19
  REASONING = "reasoning",
20
20
  PLUGIN_CALL = "plugin_call",
21
21
  PLUGIN_CALL_OUTPUT = "plugin_call_output",
22
+ TOOL_CALL = "tool_call",
23
+ TOOL_CALL_OUTPUT = "tool_call_output",
22
24
  FUNCTION_CALL = "function_call",
23
25
  FUNCTION_CALL_OUTPUT = "function_call_output",
24
26
  COMPONENT_CALL = "component_call",
@@ -3,11 +3,15 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
3
3
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
4
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
5
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
6
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
9
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
10
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
15
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
16
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
13
17
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -85,7 +89,25 @@ var AgentScopeRuntimeResponseBuilder = /*#__PURE__*/function () {
85
89
  } else if (data.type === AgentScopeRuntimeContentType.IMAGE) {
86
90
  lastContent.image_url = data.image_url;
87
91
  } else if (data.type === AgentScopeRuntimeContentType.DATA) {
88
- lastContent.data = data.data;
92
+ var isStreamingToolInput = [AgentScopeRuntimeMessageType.PLUGIN_CALL, AgentScopeRuntimeMessageType.TOOL_CALL, AgentScopeRuntimeMessageType.MCP_CALL].includes(msg.type);
93
+ if (isStreamingToolInput) {
94
+ var oldData = lastContent.data || {};
95
+ var newData = data.data || {};
96
+ var merged = _objectSpread({}, oldData);
97
+ for (var _i = 0, _Object$entries = Object.entries(newData); _i < _Object$entries.length; _i++) {
98
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
99
+ key = _Object$entries$_i[0],
100
+ value = _Object$entries$_i[1];
101
+ if (typeof value === 'string' && typeof merged[key] === 'string') {
102
+ merged[key] = merged[key] + value;
103
+ } else {
104
+ merged[key] = value;
105
+ }
106
+ }
107
+ lastContent.data = merged;
108
+ } else {
109
+ lastContent.data = data.data;
110
+ }
89
111
  }
90
112
  } else {
91
113
  msg.content.push(data);
@@ -201,12 +223,12 @@ var AgentScopeRuntimeResponseBuilder = /*#__PURE__*/function () {
201
223
  }, {
202
224
  key: "maybeToolOutput",
203
225
  value: function maybeToolOutput(message) {
204
- return [AgentScopeRuntimeMessageType.FUNCTION_CALL_OUTPUT, AgentScopeRuntimeMessageType.PLUGIN_CALL_OUTPUT, AgentScopeRuntimeMessageType.COMPONENT_CALL_OUTPUT, AgentScopeRuntimeMessageType.MCP_CALL_OUTPUT].includes(message.type);
226
+ return [AgentScopeRuntimeMessageType.FUNCTION_CALL_OUTPUT, AgentScopeRuntimeMessageType.PLUGIN_CALL_OUTPUT, AgentScopeRuntimeMessageType.TOOL_CALL_OUTPUT, AgentScopeRuntimeMessageType.COMPONENT_CALL_OUTPUT, AgentScopeRuntimeMessageType.MCP_CALL_OUTPUT].includes(message.type);
205
227
  }
206
228
  }, {
207
229
  key: "maybeToolInput",
208
230
  value: function maybeToolInput(message) {
209
- return [AgentScopeRuntimeMessageType.FUNCTION_CALL, AgentScopeRuntimeMessageType.PLUGIN_CALL, AgentScopeRuntimeMessageType.COMPONENT_CALL, AgentScopeRuntimeMessageType.MCP_CALL].includes(message.type);
231
+ return [AgentScopeRuntimeMessageType.FUNCTION_CALL, AgentScopeRuntimeMessageType.PLUGIN_CALL, AgentScopeRuntimeMessageType.TOOL_CALL, AgentScopeRuntimeMessageType.COMPONENT_CALL, AgentScopeRuntimeMessageType.MCP_CALL].includes(message.type);
210
232
  }
211
233
  }, {
212
234
  key: "maybeGenerating",
@@ -49,6 +49,8 @@ export default function AgentScopeRuntimeResponseCard(props) {
49
49
  }, item.id);
50
50
  case AgentScopeRuntimeMessageType.PLUGIN_CALL:
51
51
  case AgentScopeRuntimeMessageType.PLUGIN_CALL_OUTPUT:
52
+ case AgentScopeRuntimeMessageType.TOOL_CALL:
53
+ case AgentScopeRuntimeMessageType.TOOL_CALL_OUTPUT:
52
54
  case AgentScopeRuntimeMessageType.MCP_CALL:
53
55
  case AgentScopeRuntimeMessageType.MCP_CALL_OUTPUT:
54
56
  return /*#__PURE__*/_jsx(Tool, {
@@ -1,11 +1,20 @@
1
- import React from "react";
2
- import { AgentScopeRuntimeRunStatus } from "../types";
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import React, { useEffect, useState } from "react";
8
+ import { AgentScopeRuntimeMessageType, AgentScopeRuntimeRunStatus } from "../types";
3
9
  import { ToolCall } from "../../../..";
4
10
  import { useChatAnywhereOptions } from "../../Context/ChatAnywhereOptionsContext";
5
11
  import Approval from "./Approval";
12
+
13
+ // output展示后,2s自动关闭
6
14
  import { jsx as _jsx } from "react/jsx-runtime";
7
15
  import { Fragment as _Fragment } from "react/jsx-runtime";
8
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
17
+ var OUTPUT_AUTO_COLLAPSE_MS = 2000;
9
18
  var Tool = /*#__PURE__*/React.memo(function (_ref) {
10
19
  var _data$content;
11
20
  var data = _ref.data,
@@ -14,12 +23,28 @@ var Tool = /*#__PURE__*/React.memo(function (_ref) {
14
23
  var customToolRenderConfig = useChatAnywhereOptions(function (v) {
15
24
  return v.customToolRenderConfig;
16
25
  }) || {};
26
+ var isOutput = [AgentScopeRuntimeMessageType.PLUGIN_CALL_OUTPUT, AgentScopeRuntimeMessageType.TOOL_CALL_OUTPUT, AgentScopeRuntimeMessageType.MCP_CALL_OUTPUT].includes(data.type);
27
+ var _useState = useState(false),
28
+ _useState2 = _slicedToArray(_useState, 2),
29
+ autoCollapsed = _useState2[0],
30
+ setAutoCollapsed = _useState2[1];
31
+ useEffect(function () {
32
+ if (!isOutput || autoCollapsed) return;
33
+ var timer = setTimeout(function () {
34
+ return setAutoCollapsed(true);
35
+ }, OUTPUT_AUTO_COLLAPSE_MS);
36
+ return function () {
37
+ return clearTimeout(timer);
38
+ };
39
+ }, [isOutput, autoCollapsed]);
17
40
  if (!((_data$content = data.content) !== null && _data$content !== void 0 && _data$content.length)) return null;
18
41
  var content = data.content;
19
42
  var loading = data.status === AgentScopeRuntimeRunStatus.InProgress;
20
43
  var toolName = content[0].data.name;
21
44
  var serverLabel = "".concat(content[0].data.server_label ? content[0].data.server_label + ' / ' : '');
22
45
  var title = "".concat(serverLabel).concat(toolName);
46
+ var isInput = [AgentScopeRuntimeMessageType.PLUGIN_CALL, AgentScopeRuntimeMessageType.TOOL_CALL, AgentScopeRuntimeMessageType.MCP_CALL].includes(data.type);
47
+ var defaultOpen = isInput || isOutput && !autoCollapsed;
23
48
  var node;
24
49
  if (customToolRenderConfig[toolName]) {
25
50
  var C = customToolRenderConfig[toolName];
@@ -30,11 +55,11 @@ var Tool = /*#__PURE__*/React.memo(function (_ref) {
30
55
  var _content$, _content$2;
31
56
  node = /*#__PURE__*/_jsx(ToolCall, {
32
57
  loading: loading,
33
- defaultOpen: false,
58
+ defaultOpen: defaultOpen,
34
59
  title: title === 'undefined' ? '' : title,
35
60
  input: (_content$ = content[0]) === null || _content$ === void 0 || (_content$ = _content$.data) === null || _content$ === void 0 ? void 0 : _content$.arguments,
36
61
  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
37
- });
62
+ }, autoCollapsed ? 'collapsed' : 'open');
38
63
  }
39
64
  return /*#__PURE__*/_jsxs(_Fragment, {
40
65
  children: [node, isApproval && /*#__PURE__*/_jsx(Approval, {
@@ -17,6 +17,8 @@ export declare enum AgentScopeRuntimeMessageType {
17
17
  REASONING = "reasoning",
18
18
  PLUGIN_CALL = "plugin_call",
19
19
  PLUGIN_CALL_OUTPUT = "plugin_call_output",
20
+ TOOL_CALL = "tool_call",
21
+ TOOL_CALL_OUTPUT = "tool_call_output",
20
22
  FUNCTION_CALL = "function_call",
21
23
  FUNCTION_CALL_OUTPUT = "function_call_output",
22
24
  COMPONENT_CALL = "component_call",
@@ -19,6 +19,8 @@ export var AgentScopeRuntimeMessageType = /*#__PURE__*/function (AgentScopeRunti
19
19
  AgentScopeRuntimeMessageType["REASONING"] = "reasoning";
20
20
  AgentScopeRuntimeMessageType["PLUGIN_CALL"] = "plugin_call";
21
21
  AgentScopeRuntimeMessageType["PLUGIN_CALL_OUTPUT"] = "plugin_call_output";
22
+ AgentScopeRuntimeMessageType["TOOL_CALL"] = "tool_call";
23
+ AgentScopeRuntimeMessageType["TOOL_CALL_OUTPUT"] = "tool_call_output";
22
24
  AgentScopeRuntimeMessageType["FUNCTION_CALL"] = "function_call";
23
25
  AgentScopeRuntimeMessageType["FUNCTION_CALL_OUTPUT"] = "function_call_output";
24
26
  AgentScopeRuntimeMessageType["COMPONENT_CALL"] = "component_call";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentscope-ai/chat",
3
- "version": "1.1.64",
3
+ "version": "1.1.66",
4
4
  "description": "a free and open-source chat framework for building excellent LLM-powered chat experiences",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": [
@@ -1,75 +0,0 @@
1
- # agentscope-runtime-starter-webui
2
-
3
- ## node version
4
-
5
- > =22
6
-
7
- ## install
8
-
9
- ```
10
- $ npm run install
11
- ```
12
-
13
- ## dev
14
-
15
- ```
16
- $ npm run dev
17
- ```
18
-
19
- ## build
20
-
21
- ```
22
- $ npm run build
23
- ```
24
-
25
- ## Core Code
26
- ```tsx
27
- import { AgentScopeRuntimeWebUI } from '@agentscope-ai/chat';
28
-
29
- const options = {
30
- theme: {
31
- colorPrimary: '#615CED',
32
- darkMode: true,
33
- prefix: 'agentscope-runtime-webui',
34
- leftHeader: {
35
- logo: 'https://img.alicdn.com/imgextra/i2/O1CN01lmoGYn1kjoXATy4PX_!!6000000004720-2-tps-200-200.png',
36
- title: 'Runtime WebUI',
37
- },
38
- },
39
- sender: {
40
- maxLength: 10000,
41
- disclaimer:
42
- 'AI can also make mistakes, so please check carefully and use it with caution',
43
- },
44
-
45
- welcome: {
46
- greeting: 'Hello, how can I help you today?',
47
- description:
48
- 'I am a helpful assistant that can help you with your questions.',
49
- avatar:
50
- 'https://img.alicdn.com/imgextra/i2/O1CN01lmoGYn1kjoXATy4PX_!!6000000004720-2-tps-200-200.png',
51
- prompts: [
52
- {
53
- value: 'Hello',
54
- },
55
- {
56
- value: 'How are you?',
57
- },
58
- {
59
- value: 'What can you do?',
60
- },
61
- ],
62
- },
63
- api: {
64
- baseURL: 'YOUR_API_URL',
65
- token: 'YOUR_API_TOKEN', // is not required
66
- },
67
- };
68
-
69
-
70
- <AgentScopeRuntimeWebUI
71
- options={options}
72
- />
73
-
74
-
75
- ```
@@ -1,28 +0,0 @@
1
- import js from '@eslint/js'
2
- import globals from 'globals'
3
- import reactHooks from 'eslint-plugin-react-hooks'
4
- import reactRefresh from 'eslint-plugin-react-refresh'
5
- import tseslint from 'typescript-eslint'
6
-
7
- export default tseslint.config(
8
- { ignores: ['dist'] },
9
- {
10
- extends: [js.configs.recommended, ...tseslint.configs.recommended],
11
- files: ['**/*.{ts,tsx}'],
12
- languageOptions: {
13
- ecmaVersion: 2020,
14
- globals: globals.browser,
15
- },
16
- plugins: {
17
- 'react-hooks': reactHooks,
18
- 'react-refresh': reactRefresh,
19
- },
20
- rules: {
21
- ...reactHooks.configs.recommended.rules,
22
- 'react-refresh/only-export-components': [
23
- 'warn',
24
- { allowConstantExport: true },
25
- ],
26
- },
27
- },
28
- )
@@ -1,12 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>AgentScope Runtime Starter WebUI</title>
7
- </head>
8
- <body>
9
- <div id="root"></div>
10
- <script type="module" src="/src/main.tsx"></script>
11
- </body>
12
- </html>
@@ -1,34 +0,0 @@
1
- {
2
- "name": "agentscope-runtime-starter-webui",
3
- "private": true,
4
- "version": "0.0.0",
5
- "type": "module",
6
- "scripts": {
7
- "dev": "vite --host",
8
- "build": "tsc -b && vite build",
9
- "lint": "eslint .",
10
- "preview": "vite preview"
11
- },
12
- "dependencies": {
13
- "@agentscope-ai/icons": "^1.0.46",
14
- "@agentscope-ai/chat": "^1.1.44",
15
- "@agentscope-ai/design": "^1.0.19",
16
- "antd": "^5.29.1",
17
- "antd-style": "^3.7.1",
18
- "react": "^18",
19
- "react-dom": "^18"
20
- },
21
- "devDependencies": {
22
- "@eslint/js": "^9.25.0",
23
- "@types/react": "^18",
24
- "@types/react-dom": "^18",
25
- "@vitejs/plugin-react": "^4.4.1",
26
- "eslint": "^9.25.0",
27
- "eslint-plugin-react-hooks": "^5.2.0",
28
- "eslint-plugin-react-refresh": "^0.4.19",
29
- "globals": "^16.0.0",
30
- "typescript": "~5.8.3",
31
- "typescript-eslint": "^8.30.1",
32
- "vite": "^6.3.5"
33
- }
34
- }
@@ -1,20 +0,0 @@
1
- import Chat from './components/Chat';
2
-
3
- import { createGlobalStyle } from 'antd-style';
4
-
5
-
6
- const GlobalStyle = createGlobalStyle`
7
- * {
8
- margin: 0;
9
- box-sizing: border-box;
10
- }
11
- `;
12
-
13
- function App() {
14
- return <>
15
- <GlobalStyle />
16
- <Chat />
17
- </>
18
- }
19
-
20
- export default App
@@ -1,37 +0,0 @@
1
- import { Form } from 'antd';
2
- import { createStyles } from 'antd-style';
3
-
4
-
5
- interface FormItemProps {
6
- name: string | string[];
7
- label: string;
8
- isList?: boolean;
9
- children: any;
10
- normalize?: (value: any) => any;
11
- }
12
-
13
-
14
- const useStyles = createStyles(({ token }) => ({
15
- label: {
16
- marginBottom: 6,
17
- fontSize: 12,
18
- color: token.colorTextSecondary,
19
- },
20
-
21
- }));
22
-
23
- export default function FormItem(props: FormItemProps) {
24
- const { styles } = useStyles();
25
-
26
-
27
- const node = props.isList ?
28
- <Form.List name={props.name}>{props.children}</Form.List> :
29
- <Form.Item name={props.name} normalize={props.normalize}>{props.children}</Form.Item>;
30
-
31
-
32
- return <div>
33
- {props.label && <div className={styles.label}>{props.label}</div>}
34
- {node}
35
- </div>
36
-
37
- }
@@ -1,160 +0,0 @@
1
- import React from 'react';
2
- import { Form, Input, ColorPicker, Flex, Divider, InputNumber } from 'antd';
3
- import { createStyles } from 'antd-style';
4
- import { Button, IconButton, Switch } from '@agentscope-ai/design'
5
- import { SparkDeleteLine, SparkPlusLine } from '@agentscope-ai/icons';
6
- import FormItem from './FormItem';
7
- import defaultConfig from './defaultConfig';
8
-
9
- const useStyles = createStyles(({ token }) => ({
10
- container: {
11
- height: '100%',
12
- display: 'flex',
13
- flexDirection: 'column',
14
- },
15
-
16
- form: {
17
- height: 0,
18
- flex: 1,
19
- padding: '8px 16px 16px 16px',
20
- overflow: 'auto',
21
- },
22
- actions: {
23
- padding: 16,
24
- display: 'flex',
25
- borderTop: `1px solid ${token.colorBorderSecondary}`,
26
- justifyContent: 'flex-end',
27
- gap: 16,
28
- }
29
-
30
- }));
31
-
32
- interface OptionsEditorProps {
33
- value?: any;
34
- onChange?: any;
35
- }
36
-
37
- const OptionsEditor: React.FC<OptionsEditorProps> = ({
38
- value,
39
- onChange,
40
- }) => {
41
- const { styles } = useStyles();
42
- const [form] = Form.useForm();
43
-
44
-
45
- const handleSave = () => {
46
- form.validateFields().then((values) => {
47
- onChange(values);
48
- });
49
- };
50
-
51
- const handleReset = () => {
52
- form.setFieldsValue(defaultConfig);
53
- };
54
-
55
- return (
56
- <div className={styles.container}>
57
- <Form
58
- className={styles.form}
59
- form={form}
60
- layout="vertical"
61
- initialValues={value}
62
- >
63
-
64
-
65
- <Divider orientation="left">Theme</Divider>
66
-
67
- <FormItem name={['theme', 'colorPrimary']} label="colorPrimary" normalize={value => value.toHexString()}>
68
- <ColorPicker />
69
- </FormItem>
70
-
71
- <FormItem name={['theme', 'colorBgBase']} label="colorBgBase" normalize={value => value.toHexString()}>
72
- <ColorPicker />
73
- </FormItem>
74
-
75
- <FormItem name={['theme', 'colorTextBase']} label="colorTextBase" normalize={value => value.toHexString()}>
76
- <ColorPicker />
77
- </FormItem>
78
-
79
- <FormItem name={['theme', 'darkMode']} label="darkMode" >
80
- <Switch />
81
- </FormItem>
82
-
83
- <FormItem name={['theme', 'leftHeader', 'logo']} label="leftHeader.logo" >
84
- <Input />
85
- </FormItem>
86
-
87
- <FormItem name={['theme', 'leftHeader', 'title']} label="leftHeader.title" >
88
- <Input />
89
- </FormItem>
90
-
91
- <Divider orientation="left">Sender</Divider>
92
-
93
-
94
- <FormItem name={['sender', 'disclaimer']} label="disclaimer" >
95
- <Input />
96
- </FormItem>
97
-
98
-
99
-
100
-
101
- <FormItem name={['sender', 'maxLength']} label="maxLength" >
102
- <InputNumber min={1000} />
103
- </FormItem>
104
-
105
- <Divider orientation="left">Welcome</Divider>
106
-
107
-
108
- <FormItem name={['welcome', 'greeting']} label="greeting" >
109
- <Input />
110
- </FormItem>
111
-
112
- <FormItem name={['welcome', 'description']} label="description" >
113
- <Input />
114
- </FormItem>
115
-
116
- <FormItem name={['welcome', 'avatar']} label="avatar" >
117
- <Input />
118
- </FormItem>
119
-
120
-
121
- <FormItem name={['welcome', 'prompts']} isList label="prompts" >
122
- {(fields: { key: string, name: string }[], { add, remove }: { add: (item: any) => void, remove: (name: string) => void }) => {
123
- return <div>
124
- {fields.map(field => {
125
- return <Flex key={field.key} gap={6}>
126
- <Form.Item style={{ flex: 1 }} key={field.key} name={[field.name, 'value']}>
127
- <Input />
128
- </Form.Item>
129
- <IconButton icon={<SparkPlusLine />} onClick={() => add({})}></IconButton>
130
- <IconButton icon={<SparkDeleteLine />} onClick={() => remove(field.name)}></IconButton>
131
- </Flex>
132
- })}
133
- </div>
134
- }}
135
- </FormItem>
136
-
137
-
138
- <Divider orientation="left">API</Divider>
139
-
140
- <FormItem name={['api', 'baseURL']} label="baseURL" >
141
- <Input />
142
- </FormItem>
143
-
144
- <FormItem name={['api', 'token']} label="token" >
145
- <Input />
146
- </FormItem>
147
- </Form>
148
-
149
- <div className={styles.actions}>
150
- <Button onClick={handleReset}>Reset</Button>
151
- <Button type="primary" onClick={handleSave}>
152
- Save & Copy
153
- </Button>
154
- </div>
155
- </div>
156
- );
157
- };
158
-
159
- export default OptionsEditor;
160
-
@@ -1,41 +0,0 @@
1
- export default {
2
- theme: {
3
- colorPrimary: '#615CED',
4
- darkMode: true,
5
- prefix: 'agentscope-runtime-webui',
6
- leftHeader: {
7
- logo: 'https://img.alicdn.com/imgextra/i2/O1CN01lmoGYn1kjoXATy4PX_!!6000000004720-2-tps-200-200.png',
8
- title: 'Runtime WebUI',
9
- },
10
- },
11
- sender: {
12
- attachments: false,
13
- maxLength: 10000,
14
- disclaimer:
15
- 'AI can also make mistakes, so please check carefully and use it with caution',
16
- },
17
-
18
- welcome: {
19
- greeting: 'Hello, how can I help you today?',
20
- description:
21
- 'I am a helpful assistant that can help you with your questions.',
22
- avatar:
23
- 'https://img.alicdn.com/imgextra/i2/O1CN01lmoGYn1kjoXATy4PX_!!6000000004720-2-tps-200-200.png',
24
- prompts: [
25
- {
26
- value: 'Hello',
27
- },
28
- {
29
- value: 'How are you?',
30
- },
31
- {
32
- value: 'What can you do?',
33
- },
34
- ],
35
- },
36
- api: {
37
- baseURL: BASE_URL,
38
- token: TOKEN,
39
- },
40
- };
41
-
@@ -1,27 +0,0 @@
1
- import { SparkSettingLine } from "@agentscope-ai/icons";
2
- import { IconButton, Drawer } from "@agentscope-ai/design";
3
- import { useState } from "react";
4
- import OptionsEditor from "./OptionsEditor";
5
-
6
- interface OptionsPanelProps {
7
- value?: any;
8
- onChange?: any;
9
- }
10
-
11
- export default function OptionsPanel(props: OptionsPanelProps) {
12
- const [open, setOpen] = useState(false);
13
-
14
- return <>
15
- <IconButton onClick={() => setOpen(true)} icon={<SparkSettingLine />} bordered={false} />
16
- <Drawer
17
- destroyOnHidden
18
- open={open}
19
- onClose={() => setOpen(false)}
20
- styles={{ body: { padding: 0 }, header: { padding: 8 } }}>
21
- <OptionsEditor value={props.value} onChange={(v: typeof props.value) => {
22
- setOpen(false);
23
- props.onChange(v);
24
- }} />
25
- </Drawer>
26
- </>
27
- }
@@ -1,45 +0,0 @@
1
- import { AgentScopeRuntimeWebUI, IAgentScopeRuntimeWebUIOptions } from '@agentscope-ai/chat';
2
- import OptionsPanel from './OptionsPanel';
3
- import { useMemo } from 'react';
4
- import sessionApi from './sessionApi';
5
- import { useLocalStorageState } from 'ahooks';
6
- import defaultConfig from './OptionsPanel/defaultConfig';
7
-
8
- export default function () {
9
- const [optionsConfig, setOptionsConfig] = useLocalStorageState('agent-scope-runtime-webui-options', {
10
- defaultValue: defaultConfig,
11
- listenStorageChange: true,
12
- });
13
-
14
- const options = useMemo(() => {
15
- const rightHeader = <OptionsPanel value={optionsConfig} onChange={(v: typeof optionsConfig) => {
16
- setOptionsConfig(prev => ({
17
- ...prev,
18
- ...v,
19
- }));
20
- }} />;
21
-
22
-
23
-
24
- return {
25
- ...optionsConfig,
26
- session: {
27
- multiple: true,
28
- api: sessionApi,
29
- },
30
- theme: {
31
- ...optionsConfig.theme,
32
- rightHeader,
33
- },
34
- };
35
- }, [optionsConfig]);
36
-
37
-
38
-
39
-
40
- return <div style={{ height: '100vh' }}>
41
- <AgentScopeRuntimeWebUI
42
- options={options as unknown as IAgentScopeRuntimeWebUIOptions}
43
- />
44
- </div>;
45
- }
@@ -1,53 +0,0 @@
1
- import {
2
- IAgentScopeRuntimeWebUISession,
3
- IAgentScopeRuntimeWebUISessionAPI,
4
- } from '@agentscope-ai/chat';
5
-
6
- class SessionApi implements IAgentScopeRuntimeWebUISessionAPI {
7
- private lsKey: string;
8
- private sessionList: IAgentScopeRuntimeWebUISession[];
9
-
10
- constructor() {
11
- this.lsKey = 'agent-scope-runtime-webui-sessions';
12
- this.sessionList = [];
13
- }
14
-
15
- async getSessionList() {
16
- this.sessionList = JSON.parse(localStorage.getItem(this.lsKey) || '[]');
17
- return [...this.sessionList];
18
- }
19
-
20
- async getSession(sessionId: string) {
21
- return this.sessionList.find((session) => session.id === sessionId) as IAgentScopeRuntimeWebUISession;
22
- }
23
-
24
- async updateSession(session: Partial<IAgentScopeRuntimeWebUISession>) {
25
- const index = this.sessionList.findIndex((item) => item.id === session.id);
26
- if (index > -1) {
27
- this.sessionList[index] = {
28
- ...this.sessionList[index],
29
- ...session,
30
- };
31
- localStorage.setItem(this.lsKey, JSON.stringify(this.sessionList));
32
- }
33
-
34
- return [...this.sessionList];
35
- }
36
-
37
- async createSession(session: Partial<IAgentScopeRuntimeWebUISession>) {
38
- session.id = Date.now().toString();
39
- this.sessionList.unshift(session as IAgentScopeRuntimeWebUISession);
40
- localStorage.setItem(this.lsKey, JSON.stringify(this.sessionList));
41
- return [...this.sessionList];
42
- }
43
-
44
- async removeSession(session: Partial<IAgentScopeRuntimeWebUISession>) {
45
- this.sessionList = this.sessionList.filter(
46
- (item) => item.id !== session.id,
47
- );
48
- localStorage.setItem(this.lsKey, JSON.stringify(this.sessionList));
49
- return [...this.sessionList];
50
- }
51
- }
52
-
53
- export default new SessionApi();
@@ -1,9 +0,0 @@
1
- import { StrictMode } from 'react'
2
- import { createRoot } from 'react-dom/client'
3
- import App from './App.tsx'
4
-
5
- createRoot(document.getElementById('root')!).render(
6
- <StrictMode>
7
- <App />
8
- </StrictMode>,
9
- )
@@ -1,4 +0,0 @@
1
- /// <reference types="vite/client" />
2
-
3
- declare const BASE_URL: string;
4
- declare const TOKEN: string;
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
- "target": "ES2020",
5
- "useDefineForClassFields": true,
6
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
7
- "module": "ESNext",
8
- "skipLibCheck": true,
9
-
10
- "moduleResolution": "bundler",
11
- "allowImportingTsExtensions": true,
12
- "moduleDetection": "force",
13
- "noEmit": true,
14
- "jsx": "react-jsx",
15
-
16
- "strict": true,
17
- "noUnusedLocals": true,
18
- "noUnusedParameters": true,
19
- "erasableSyntaxOnly": true,
20
- "noFallthroughCasesInSwitch": true,
21
- "noUncheckedSideEffectImports": true
22
- },
23
- "include": ["src"]
24
- }
@@ -1,7 +0,0 @@
1
- {
2
- "files": [],
3
- "references": [
4
- { "path": "./tsconfig.app.json" },
5
- { "path": "./tsconfig.node.json" }
6
- ]
7
- }
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4
- "target": "ES2022",
5
- "lib": ["ES2023"],
6
- "module": "ESNext",
7
- "skipLibCheck": true,
8
-
9
- "moduleResolution": "bundler",
10
- "allowImportingTsExtensions": true,
11
- "moduleDetection": "force",
12
- "noEmit": true,
13
-
14
- "strict": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "erasableSyntaxOnly": true,
18
- "noFallthroughCasesInSwitch": true,
19
- "noUncheckedSideEffectImports": true
20
- },
21
- "include": ["vite.config.ts"]
22
- }
@@ -1,11 +0,0 @@
1
- import { defineConfig } from 'vite'
2
- import react from '@vitejs/plugin-react'
3
-
4
- export default defineConfig({
5
- define: {
6
- BASE_URL: JSON.stringify(process.env.BASE_URL || ''),
7
- TOKEN: JSON.stringify(process.env.TOKEN || ''),
8
- MOBILE: false,
9
- },
10
- plugins: [react()],
11
- })