@agentscope-ai/chat 1.1.67 → 1.1.68-beta.1780473592529

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.
@@ -1,13 +1,19 @@
1
1
 
2
+ import React, { useMemo } from 'react';
2
3
  import { AgentScopeRuntimeContentType, IAgentScopeRuntimeRequest } from '../types';
3
- import { useMemo } from 'react';
4
4
  import { Bubble } from '@agentscope-ai/chat';
5
5
  import Actions from './Actions';
6
6
  import { useChatAnywhereOptions } from '../../Context/ChatAnywhereOptionsContext';
7
7
 
8
- export default function AgentScopeRuntimeRequestCard(props: {
9
- data: IAgentScopeRuntimeRequest;
10
- }) {
8
+ function sortByOrder<T extends { order?: number }>(arr: T[]): T[] {
9
+ return arr.slice().sort((a, b) => (a.order ?? 100) - (b.order ?? 100));
10
+ }
11
+
12
+ /**
13
+ * Default SDK rendering of the user request bubble, extracted so plugin
14
+ * `request.render` can opt into the original rendering via fallback().
15
+ */
16
+ function DefaultRequestRender(props: { data: IAgentScopeRuntimeRequest }) {
11
17
  const onFileCardClick = useChatAnywhereOptions(v => v.api?.onFileCardClick);
12
18
 
13
19
  const cards = useMemo(() => {
@@ -84,3 +90,40 @@ export default function AgentScopeRuntimeRequestCard(props: {
84
90
  </>;
85
91
  }
86
92
 
93
+ export default function AgentScopeRuntimeRequestCard(props: {
94
+ data: IAgentScopeRuntimeRequest;
95
+ }) {
96
+ const requestOptions = useChatAnywhereOptions(v => v.request);
97
+
98
+ const fallback = () => <DefaultRequestRender data={props.data} />;
99
+ const main = requestOptions?.render
100
+ ? requestOptions.render({ data: props.data, fallback })
101
+ : fallback();
102
+
103
+ const prependList = sortByOrder(requestOptions?.prepend ?? []);
104
+ const appendList = sortByOrder(requestOptions?.append ?? []);
105
+
106
+ if (
107
+ !requestOptions?.render &&
108
+ prependList.length === 0 &&
109
+ appendList.length === 0
110
+ ) {
111
+ // Hot path: zero customization → no Fragment wrapping overhead.
112
+ return fallback();
113
+ }
114
+
115
+ return <>
116
+ {prependList.map((e, i) => (
117
+ <React.Fragment key={e.id ?? `pre-${i}`}>
118
+ {e.render({ data: props.data })}
119
+ </React.Fragment>
120
+ ))}
121
+ {main}
122
+ {appendList.map((e, i) => (
123
+ <React.Fragment key={e.id ?? `post-${i}`}>
124
+ {e.render({ data: props.data })}
125
+ </React.Fragment>
126
+ ))}
127
+ </>;
128
+ }
129
+
@@ -1,4 +1,4 @@
1
- import { useMemo } from "react";
1
+ import React, { useMemo } from "react";
2
2
  import { AgentScopeRuntimeMessageType, IAgentScopeRuntimeResponse } from "../types";
3
3
  import AgentScopeRuntimeResponseBuilder from "./Builder";
4
4
  import Message from "./Message";
@@ -10,7 +10,15 @@ import Actions from "./Actions";
10
10
  import { Avatar, Flex } from 'antd';
11
11
  import { useChatAnywhereOptions } from "../../Context/ChatAnywhereOptionsContext";
12
12
 
13
- export default function AgentScopeRuntimeResponseCard(props: {
13
+ function sortByOrder<T extends { order?: number }>(arr: T[]): T[] {
14
+ return arr.slice().sort((a, b) => (a.order ?? 100) - (b.order ?? 100));
15
+ }
16
+
17
+ /**
18
+ * Default SDK rendering of the assistant response bubble, extracted so
19
+ * plugin `response.render` can opt back into the original via fallback().
20
+ */
21
+ function DefaultResponseRender(props: {
14
22
  data: IAgentScopeRuntimeResponse;
15
23
  isLast?: boolean;
16
24
  }) {
@@ -61,3 +69,47 @@ export default function AgentScopeRuntimeResponseCard(props: {
61
69
  <Actions {...props} />
62
70
  </>
63
71
  }
72
+
73
+ export default function AgentScopeRuntimeResponseCard(props: {
74
+ data: IAgentScopeRuntimeResponse;
75
+ isLast?: boolean;
76
+ }) {
77
+ const responseOptions = useChatAnywhereOptions(v => v.response);
78
+
79
+ const fallback = () => (
80
+ <DefaultResponseRender data={props.data} isLast={props.isLast} />
81
+ );
82
+
83
+ const main = responseOptions?.render
84
+ ? responseOptions.render({
85
+ data: props.data,
86
+ isLast: props.isLast,
87
+ fallback,
88
+ })
89
+ : fallback();
90
+
91
+ const prependList = sortByOrder(responseOptions?.prepend ?? []);
92
+ const appendList = sortByOrder(responseOptions?.append ?? []);
93
+
94
+ if (
95
+ !responseOptions?.render &&
96
+ prependList.length === 0 &&
97
+ appendList.length === 0
98
+ ) {
99
+ return fallback();
100
+ }
101
+
102
+ return <>
103
+ {prependList.map((e, i) => (
104
+ <React.Fragment key={e.id ?? `pre-${i}`}>
105
+ {e.render({ data: props.data, isLast: props.isLast })}
106
+ </React.Fragment>
107
+ ))}
108
+ {main}
109
+ {appendList.map((e, i) => (
110
+ <React.Fragment key={e.id ?? `post-${i}`}>
111
+ {e.render({ data: props.data, isLast: props.isLast })}
112
+ </React.Fragment>
113
+ ))}
114
+ </>
115
+ }
@@ -16,7 +16,13 @@ const Tool = React.memo(function ({ data, isApproval = false }: { data: IAgentSc
16
16
  AgentScopeRuntimeMessageType.MCP_CALL_OUTPUT,
17
17
  ].includes(data.type);
18
18
 
19
- const [autoCollapsed, setAutoCollapsed] = useState(false);
19
+ // Already-completed outputs start collapsed so the 2s auto-collapse timer
20
+ // below skips them entirely — otherwise every historical output would
21
+ // mount with key='open' and then unmount/remount to key='collapsed' 2s
22
+ // later, churning component instances on page load.
23
+ const [autoCollapsed, setAutoCollapsed] = useState(
24
+ () => data.status !== AgentScopeRuntimeRunStatus.InProgress,
25
+ );
20
26
  useEffect(() => {
21
27
  if (!isOutput || autoCollapsed) return;
22
28
  const timer = setTimeout(() => setAutoCollapsed(true), OUTPUT_AUTO_COLLAPSE_MS);
@@ -41,7 +47,13 @@ const Tool = React.memo(function ({ data, isApproval = false }: { data: IAgentSc
41
47
  AgentScopeRuntimeMessageType.MCP_CALL,
42
48
  ].includes(data.type);
43
49
 
44
- const defaultOpen = isInput || (isOutput && !autoCollapsed);
50
+ // Only the actively-running tool call shows its args/output expanded.
51
+ // Historical (completed) tool calls stay collapsed so OperateCard does
52
+ // not mount the body subtree — each input/output Block holds a
53
+ // CodeMirror EditorView (~380ms init); 30 historical tool calls would
54
+ // otherwise mount 60 editors at once, locking the UI for ~22s on long
55
+ // conversations. Users click the card header to view past args/output.
56
+ const defaultOpen = loading;
45
57
 
46
58
  let node
47
59
 
@@ -431,6 +431,87 @@ export interface IAgentScopeRuntimeWebUIOptions {
431
431
  * @descriptionEn Actions configuration (user messages)
432
432
  */
433
433
  requestActions?: IAgentScopeRuntimeWebUIRequestActionsOptions;
434
+
435
+ /**
436
+ * @description 用户请求气泡自定义槽。可整段替换或在气泡前后追加节点。
437
+ * @descriptionEn Customization slots for the user request bubble: whole-bubble render override and before/after slots.
438
+ */
439
+ request?: IAgentScopeRuntimeWebUIRequestOptions;
440
+
441
+ /**
442
+ * @description AI 响应气泡自定义槽。可整段替换或在气泡前后追加节点。
443
+ * @descriptionEn Customization slots for the assistant response bubble: whole-bubble render override and before/after slots.
444
+ */
445
+ response?: IAgentScopeRuntimeWebUIResponseOptions;
446
+ }
447
+
448
+ /**
449
+ * @description 用户请求气泡前后追加的插槽项
450
+ * @descriptionEn Prepend/append slot item rendered around the user request bubble.
451
+ */
452
+ export interface IAgentScopeRuntimeWebUIRequestSlot {
453
+ /** 稳定 id,用于 React key 与去重 / Stable id for React key + de-duplication. */
454
+ id?: string;
455
+ /** 排序权重,小在前;默认 100 / Order weight, smaller renders first; defaults to 100. */
456
+ order?: number;
457
+ /** 渲染函数,可访问当前请求数据;返回 null 表示该气泡不渲染本槽 / Render fn receiving the current request data; returning null skips this bubble. */
458
+ render: (ctx: { data: IAgentScopeRuntimeRequest }) => React.ReactNode;
459
+ }
460
+
461
+ /**
462
+ * @description 用户请求气泡自定义槽配置
463
+ * @descriptionEn Customization options for the user request bubble.
464
+ */
465
+ export interface IAgentScopeRuntimeWebUIRequestOptions {
466
+ /**
467
+ * @description 整段替换默认 user 气泡。调用 fallback() 可拿到 SDK 默认渲染。
468
+ * @descriptionEn Replace the default user bubble entirely. Call fallback() to obtain the SDK default render.
469
+ */
470
+ render?: (ctx: {
471
+ data: IAgentScopeRuntimeRequest;
472
+ fallback: () => React.ReactNode;
473
+ }) => React.ReactNode;
474
+ /**
475
+ * @description 在 user 气泡之前追加的插槽列表(按 order 排序)
476
+ * @descriptionEn Slots rendered above the user bubble (sorted by order).
477
+ */
478
+ prepend?: IAgentScopeRuntimeWebUIRequestSlot[];
479
+ /**
480
+ * @description 在 user 气泡之后追加的插槽列表(按 order 排序)
481
+ * @descriptionEn Slots rendered below the user bubble (sorted by order).
482
+ */
483
+ append?: IAgentScopeRuntimeWebUIRequestSlot[];
484
+ }
485
+
486
+ /**
487
+ * @description AI 响应气泡前后追加的插槽项
488
+ * @descriptionEn Prepend/append slot item rendered around the assistant response bubble.
489
+ */
490
+ export interface IAgentScopeRuntimeWebUIResponseSlot {
491
+ id?: string;
492
+ order?: number;
493
+ render: (ctx: {
494
+ data: IAgentScopeRuntimeResponse;
495
+ isLast?: boolean;
496
+ }) => React.ReactNode;
497
+ }
498
+
499
+ /**
500
+ * @description AI 响应气泡自定义槽配置
501
+ * @descriptionEn Customization options for the assistant response bubble.
502
+ */
503
+ export interface IAgentScopeRuntimeWebUIResponseOptions {
504
+ /**
505
+ * @description 整段替换默认 AI 气泡。调用 fallback() 可拿到 SDK 默认渲染。
506
+ * @descriptionEn Replace the default AI bubble entirely. Call fallback() to obtain the SDK default render.
507
+ */
508
+ render?: (ctx: {
509
+ data: IAgentScopeRuntimeResponse;
510
+ isLast?: boolean;
511
+ fallback: () => React.ReactNode;
512
+ }) => React.ReactNode;
513
+ prepend?: IAgentScopeRuntimeWebUIResponseSlot[];
514
+ append?: IAgentScopeRuntimeWebUIResponseSlot[];
434
515
  }
435
516
 
436
517
  export interface IAgentScopeRuntimeWebUIRequestActionsOptions {
@@ -1,12 +1,23 @@
1
+ import React, { useMemo } from 'react';
1
2
  import { AgentScopeRuntimeContentType } from "../types";
2
- import { useMemo } from 'react';
3
3
  import { Bubble } from "../../../..";
4
4
  import Actions from "./Actions";
5
5
  import { useChatAnywhereOptions } from "../../Context/ChatAnywhereOptionsContext";
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  import { Fragment as _Fragment } from "react/jsx-runtime";
8
8
  import { jsxs as _jsxs } from "react/jsx-runtime";
9
- export default function AgentScopeRuntimeRequestCard(props) {
9
+ function sortByOrder(arr) {
10
+ return arr.slice().sort(function (a, b) {
11
+ var _a$order, _b$order;
12
+ return ((_a$order = a.order) !== null && _a$order !== void 0 ? _a$order : 100) - ((_b$order = b.order) !== null && _b$order !== void 0 ? _b$order : 100);
13
+ });
14
+ }
15
+
16
+ /**
17
+ * Default SDK rendering of the user request bubble, extracted so plugin
18
+ * `request.render` can opt into the original rendering via fallback().
19
+ */
20
+ function DefaultRequestRender(props) {
10
21
  var onFileCardClick = useChatAnywhereOptions(function (v) {
11
22
  var _v$api;
12
23
  return (_v$api = v.api) === null || _v$api === void 0 ? void 0 : _v$api.onFileCardClick;
@@ -109,4 +120,42 @@ export default function AgentScopeRuntimeRequestCard(props) {
109
120
  data: props.data
110
121
  })]
111
122
  });
123
+ }
124
+ export default function AgentScopeRuntimeRequestCard(props) {
125
+ var _requestOptions$prepe, _requestOptions$appen;
126
+ var requestOptions = useChatAnywhereOptions(function (v) {
127
+ return v.request;
128
+ });
129
+ var fallback = function fallback() {
130
+ return /*#__PURE__*/_jsx(DefaultRequestRender, {
131
+ data: props.data
132
+ });
133
+ };
134
+ var main = requestOptions !== null && requestOptions !== void 0 && requestOptions.render ? requestOptions.render({
135
+ data: props.data,
136
+ fallback: fallback
137
+ }) : fallback();
138
+ var prependList = sortByOrder((_requestOptions$prepe = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.prepend) !== null && _requestOptions$prepe !== void 0 ? _requestOptions$prepe : []);
139
+ var appendList = sortByOrder((_requestOptions$appen = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.append) !== null && _requestOptions$appen !== void 0 ? _requestOptions$appen : []);
140
+ if (!(requestOptions !== null && requestOptions !== void 0 && requestOptions.render) && prependList.length === 0 && appendList.length === 0) {
141
+ // Hot path: zero customization → no Fragment wrapping overhead.
142
+ return fallback();
143
+ }
144
+ return /*#__PURE__*/_jsxs(_Fragment, {
145
+ children: [prependList.map(function (e, i) {
146
+ var _e$id;
147
+ return /*#__PURE__*/_jsx(React.Fragment, {
148
+ children: e.render({
149
+ data: props.data
150
+ })
151
+ }, (_e$id = e.id) !== null && _e$id !== void 0 ? _e$id : "pre-".concat(i));
152
+ }), main, appendList.map(function (e, i) {
153
+ var _e$id2;
154
+ return /*#__PURE__*/_jsx(React.Fragment, {
155
+ children: e.render({
156
+ data: props.data
157
+ })
158
+ }, (_e$id2 = e.id) !== null && _e$id2 !== void 0 ? _e$id2 : "post-".concat(i));
159
+ })]
160
+ });
112
161
  }
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
- import { useMemo } from "react";
7
+ import React, { useMemo } from "react";
8
8
  import { AgentScopeRuntimeMessageType } from "../types";
9
9
  import AgentScopeRuntimeResponseBuilder from "./Builder";
10
10
  import Message from "./Message";
@@ -18,7 +18,18 @@ import { useChatAnywhereOptions } from "../../Context/ChatAnywhereOptionsContext
18
18
  import { jsx as _jsx } from "react/jsx-runtime";
19
19
  import { jsxs as _jsxs } from "react/jsx-runtime";
20
20
  import { Fragment as _Fragment } from "react/jsx-runtime";
21
- export default function AgentScopeRuntimeResponseCard(props) {
21
+ function sortByOrder(arr) {
22
+ return arr.slice().sort(function (a, b) {
23
+ var _a$order, _b$order;
24
+ return ((_a$order = a.order) !== null && _a$order !== void 0 ? _a$order : 100) - ((_b$order = b.order) !== null && _b$order !== void 0 ? _b$order : 100);
25
+ });
26
+ }
27
+
28
+ /**
29
+ * Default SDK rendering of the assistant response bubble, extracted so
30
+ * plugin `response.render` can opt back into the original via fallback().
31
+ */
32
+ function DefaultResponseRender(props) {
22
33
  var avatar = useChatAnywhereOptions(function (v) {
23
34
  return v.welcome.avatar;
24
35
  });
@@ -79,4 +90,45 @@ export default function AgentScopeRuntimeResponseCard(props) {
79
90
  data: props.data.error
80
91
  }), /*#__PURE__*/_jsx(Actions, _objectSpread({}, props))]
81
92
  });
93
+ }
94
+ export default function AgentScopeRuntimeResponseCard(props) {
95
+ var _responseOptions$prep, _responseOptions$appe;
96
+ var responseOptions = useChatAnywhereOptions(function (v) {
97
+ return v.response;
98
+ });
99
+ var fallback = function fallback() {
100
+ return /*#__PURE__*/_jsx(DefaultResponseRender, {
101
+ data: props.data,
102
+ isLast: props.isLast
103
+ });
104
+ };
105
+ var main = responseOptions !== null && responseOptions !== void 0 && responseOptions.render ? responseOptions.render({
106
+ data: props.data,
107
+ isLast: props.isLast,
108
+ fallback: fallback
109
+ }) : fallback();
110
+ var prependList = sortByOrder((_responseOptions$prep = responseOptions === null || responseOptions === void 0 ? void 0 : responseOptions.prepend) !== null && _responseOptions$prep !== void 0 ? _responseOptions$prep : []);
111
+ var appendList = sortByOrder((_responseOptions$appe = responseOptions === null || responseOptions === void 0 ? void 0 : responseOptions.append) !== null && _responseOptions$appe !== void 0 ? _responseOptions$appe : []);
112
+ if (!(responseOptions !== null && responseOptions !== void 0 && responseOptions.render) && prependList.length === 0 && appendList.length === 0) {
113
+ return fallback();
114
+ }
115
+ return /*#__PURE__*/_jsxs(_Fragment, {
116
+ children: [prependList.map(function (e, i) {
117
+ var _e$id;
118
+ return /*#__PURE__*/_jsx(React.Fragment, {
119
+ children: e.render({
120
+ data: props.data,
121
+ isLast: props.isLast
122
+ })
123
+ }, (_e$id = e.id) !== null && _e$id !== void 0 ? _e$id : "pre-".concat(i));
124
+ }), main, appendList.map(function (e, i) {
125
+ var _e$id2;
126
+ return /*#__PURE__*/_jsx(React.Fragment, {
127
+ children: e.render({
128
+ data: props.data,
129
+ isLast: props.isLast
130
+ })
131
+ }, (_e$id2 = e.id) !== null && _e$id2 !== void 0 ? _e$id2 : "post-".concat(i));
132
+ })]
133
+ });
82
134
  }
@@ -24,7 +24,14 @@ var Tool = /*#__PURE__*/React.memo(function (_ref) {
24
24
  return v.customToolRenderConfig;
25
25
  }) || {};
26
26
  var isOutput = [AgentScopeRuntimeMessageType.PLUGIN_CALL_OUTPUT, AgentScopeRuntimeMessageType.TOOL_CALL_OUTPUT, AgentScopeRuntimeMessageType.MCP_CALL_OUTPUT].includes(data.type);
27
- var _useState = useState(false),
27
+
28
+ // Already-completed outputs start collapsed so the 2s auto-collapse timer
29
+ // below skips them entirely — otherwise every historical output would
30
+ // mount with key='open' and then unmount/remount to key='collapsed' 2s
31
+ // later, churning component instances on page load.
32
+ var _useState = useState(function () {
33
+ return data.status !== AgentScopeRuntimeRunStatus.InProgress;
34
+ }),
28
35
  _useState2 = _slicedToArray(_useState, 2),
29
36
  autoCollapsed = _useState2[0],
30
37
  setAutoCollapsed = _useState2[1];
@@ -44,7 +51,14 @@ var Tool = /*#__PURE__*/React.memo(function (_ref) {
44
51
  var serverLabel = "".concat(content[0].data.server_label ? content[0].data.server_label + ' / ' : '');
45
52
  var title = "".concat(serverLabel).concat(toolName);
46
53
  var isInput = [AgentScopeRuntimeMessageType.PLUGIN_CALL, AgentScopeRuntimeMessageType.TOOL_CALL, AgentScopeRuntimeMessageType.MCP_CALL].includes(data.type);
47
- var defaultOpen = isInput || isOutput && !autoCollapsed;
54
+
55
+ // Only the actively-running tool call shows its args/output expanded.
56
+ // Historical (completed) tool calls stay collapsed so OperateCard does
57
+ // not mount the body subtree — each input/output Block holds a
58
+ // CodeMirror EditorView (~380ms init); 30 historical tool calls would
59
+ // otherwise mount 60 editors at once, locking the UI for ~22s on long
60
+ // conversations. Users click the card header to view past args/output.
61
+ var defaultOpen = loading;
48
62
  var node;
49
63
  if (customToolRenderConfig[toolName]) {
50
64
  var C = customToolRenderConfig[toolName];
@@ -412,6 +412,83 @@ export interface IAgentScopeRuntimeWebUIOptions {
412
412
  * @descriptionEn Actions configuration (user messages)
413
413
  */
414
414
  requestActions?: IAgentScopeRuntimeWebUIRequestActionsOptions;
415
+ /**
416
+ * @description 用户请求气泡自定义槽。可整段替换或在气泡前后追加节点。
417
+ * @descriptionEn Customization slots for the user request bubble: whole-bubble render override and before/after slots.
418
+ */
419
+ request?: IAgentScopeRuntimeWebUIRequestOptions;
420
+ /**
421
+ * @description AI 响应气泡自定义槽。可整段替换或在气泡前后追加节点。
422
+ * @descriptionEn Customization slots for the assistant response bubble: whole-bubble render override and before/after slots.
423
+ */
424
+ response?: IAgentScopeRuntimeWebUIResponseOptions;
425
+ }
426
+ /**
427
+ * @description 用户请求气泡前后追加的插槽项
428
+ * @descriptionEn Prepend/append slot item rendered around the user request bubble.
429
+ */
430
+ export interface IAgentScopeRuntimeWebUIRequestSlot {
431
+ /** 稳定 id,用于 React key 与去重 / Stable id for React key + de-duplication. */
432
+ id?: string;
433
+ /** 排序权重,小在前;默认 100 / Order weight, smaller renders first; defaults to 100. */
434
+ order?: number;
435
+ /** 渲染函数,可访问当前请求数据;返回 null 表示该气泡不渲染本槽 / Render fn receiving the current request data; returning null skips this bubble. */
436
+ render: (ctx: {
437
+ data: IAgentScopeRuntimeRequest;
438
+ }) => React.ReactNode;
439
+ }
440
+ /**
441
+ * @description 用户请求气泡自定义槽配置
442
+ * @descriptionEn Customization options for the user request bubble.
443
+ */
444
+ export interface IAgentScopeRuntimeWebUIRequestOptions {
445
+ /**
446
+ * @description 整段替换默认 user 气泡。调用 fallback() 可拿到 SDK 默认渲染。
447
+ * @descriptionEn Replace the default user bubble entirely. Call fallback() to obtain the SDK default render.
448
+ */
449
+ render?: (ctx: {
450
+ data: IAgentScopeRuntimeRequest;
451
+ fallback: () => React.ReactNode;
452
+ }) => React.ReactNode;
453
+ /**
454
+ * @description 在 user 气泡之前追加的插槽列表(按 order 排序)
455
+ * @descriptionEn Slots rendered above the user bubble (sorted by order).
456
+ */
457
+ prepend?: IAgentScopeRuntimeWebUIRequestSlot[];
458
+ /**
459
+ * @description 在 user 气泡之后追加的插槽列表(按 order 排序)
460
+ * @descriptionEn Slots rendered below the user bubble (sorted by order).
461
+ */
462
+ append?: IAgentScopeRuntimeWebUIRequestSlot[];
463
+ }
464
+ /**
465
+ * @description AI 响应气泡前后追加的插槽项
466
+ * @descriptionEn Prepend/append slot item rendered around the assistant response bubble.
467
+ */
468
+ export interface IAgentScopeRuntimeWebUIResponseSlot {
469
+ id?: string;
470
+ order?: number;
471
+ render: (ctx: {
472
+ data: IAgentScopeRuntimeResponse;
473
+ isLast?: boolean;
474
+ }) => React.ReactNode;
475
+ }
476
+ /**
477
+ * @description AI 响应气泡自定义槽配置
478
+ * @descriptionEn Customization options for the assistant response bubble.
479
+ */
480
+ export interface IAgentScopeRuntimeWebUIResponseOptions {
481
+ /**
482
+ * @description 整段替换默认 AI 气泡。调用 fallback() 可拿到 SDK 默认渲染。
483
+ * @descriptionEn Replace the default AI bubble entirely. Call fallback() to obtain the SDK default render.
484
+ */
485
+ render?: (ctx: {
486
+ data: IAgentScopeRuntimeResponse;
487
+ isLast?: boolean;
488
+ fallback: () => React.ReactNode;
489
+ }) => React.ReactNode;
490
+ prepend?: IAgentScopeRuntimeWebUIResponseSlot[];
491
+ append?: IAgentScopeRuntimeWebUIResponseSlot[];
415
492
  }
416
493
  export interface IAgentScopeRuntimeWebUIRequestActionsOptions {
417
494
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentscope-ai/chat",
3
- "version": "1.1.67",
3
+ "version": "1.1.68-beta.1780473592529",
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": [