@ant-design/agentic-ui 2.0.28 → 2.1.0
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/dist/MarkdownEditor/editor/store.d.ts +4 -0
- package/dist/MarkdownEditor/editor/store.js +110 -1
- package/dist/ToolUseBar/ToolUseBarItem.js +43 -30
- package/dist/ToolUseBar/ToolUseBarItemComponents.js +53 -8
- package/dist/ToolUseBar/style.js +3 -1
- package/dist/ToolUseBar/thinkStyle.js +9 -1
- package/package.json +3 -2
|
@@ -488,7 +488,116 @@ var EditorStore = class {
|
|
|
488
488
|
* @private
|
|
489
489
|
*/
|
|
490
490
|
_splitMarkdown(md, separator) {
|
|
491
|
-
|
|
491
|
+
if (!md) {
|
|
492
|
+
return [];
|
|
493
|
+
}
|
|
494
|
+
const separatorMatches = this._collectSeparatorMatches(md, separator);
|
|
495
|
+
if (separatorMatches.length === 0) {
|
|
496
|
+
return [md];
|
|
497
|
+
}
|
|
498
|
+
const chunks = [];
|
|
499
|
+
let start = 0;
|
|
500
|
+
let currentMatchIndex = 0;
|
|
501
|
+
let insideFence = false;
|
|
502
|
+
let activeFence = null;
|
|
503
|
+
let index = 0;
|
|
504
|
+
while (index < md.length) {
|
|
505
|
+
if (this._isLineStart(md, index)) {
|
|
506
|
+
const fence = this._matchFence(md, index);
|
|
507
|
+
if (fence) {
|
|
508
|
+
if (!insideFence) {
|
|
509
|
+
insideFence = true;
|
|
510
|
+
activeFence = fence.marker;
|
|
511
|
+
} else if (activeFence === fence.marker) {
|
|
512
|
+
insideFence = false;
|
|
513
|
+
activeFence = null;
|
|
514
|
+
}
|
|
515
|
+
index = fence.end;
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
const match = separatorMatches[currentMatchIndex];
|
|
520
|
+
if (!insideFence && match && index === match.index) {
|
|
521
|
+
const chunk = md.slice(start, index);
|
|
522
|
+
if (chunk.length > 0) {
|
|
523
|
+
chunks.push(chunk);
|
|
524
|
+
}
|
|
525
|
+
start = index + match.length;
|
|
526
|
+
currentMatchIndex += 1;
|
|
527
|
+
index = start;
|
|
528
|
+
continue;
|
|
529
|
+
}
|
|
530
|
+
index += 1;
|
|
531
|
+
}
|
|
532
|
+
const tail = md.slice(start);
|
|
533
|
+
if (tail.length > 0) {
|
|
534
|
+
chunks.push(tail);
|
|
535
|
+
}
|
|
536
|
+
return chunks.length > 0 ? chunks : [md];
|
|
537
|
+
}
|
|
538
|
+
_collectSeparatorMatches(md, separator) {
|
|
539
|
+
if (typeof separator === "string") {
|
|
540
|
+
const matches2 = [];
|
|
541
|
+
let searchIndex = md.indexOf(separator);
|
|
542
|
+
while (searchIndex !== -1) {
|
|
543
|
+
matches2.push({ index: searchIndex, length: separator.length });
|
|
544
|
+
searchIndex = md.indexOf(separator, searchIndex + separator.length);
|
|
545
|
+
}
|
|
546
|
+
return matches2;
|
|
547
|
+
}
|
|
548
|
+
const flags = separator.flags.includes("g") ? separator.flags : `${separator.flags}g`;
|
|
549
|
+
const globalRegex = new RegExp(separator.source, flags);
|
|
550
|
+
const matches = [];
|
|
551
|
+
let match;
|
|
552
|
+
while ((match = globalRegex.exec(md)) !== null) {
|
|
553
|
+
const matchedText = match[0];
|
|
554
|
+
matches.push({ index: match.index, length: matchedText.length });
|
|
555
|
+
if (matchedText.length === 0) {
|
|
556
|
+
globalRegex.lastIndex += 1;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return matches;
|
|
560
|
+
}
|
|
561
|
+
_isLineStart(content, position) {
|
|
562
|
+
if (position === 0) {
|
|
563
|
+
return true;
|
|
564
|
+
}
|
|
565
|
+
return content[position - 1] === "\n";
|
|
566
|
+
}
|
|
567
|
+
_matchFence(content, position) {
|
|
568
|
+
let cursor = position;
|
|
569
|
+
let spaces = 0;
|
|
570
|
+
while (cursor < content.length && content[cursor] === " " && spaces < 3) {
|
|
571
|
+
cursor += 1;
|
|
572
|
+
spaces += 1;
|
|
573
|
+
}
|
|
574
|
+
if (cursor >= content.length) {
|
|
575
|
+
return null;
|
|
576
|
+
}
|
|
577
|
+
const char = content[cursor];
|
|
578
|
+
if (char !== "`" && char !== "~") {
|
|
579
|
+
return null;
|
|
580
|
+
}
|
|
581
|
+
let fenceLength = 0;
|
|
582
|
+
while (cursor < content.length && content[cursor] === char) {
|
|
583
|
+
cursor += 1;
|
|
584
|
+
fenceLength += 1;
|
|
585
|
+
}
|
|
586
|
+
if (fenceLength < 3) {
|
|
587
|
+
return null;
|
|
588
|
+
}
|
|
589
|
+
const lineEnd = this._findLineEnd(content, cursor);
|
|
590
|
+
return { marker: char, end: lineEnd };
|
|
591
|
+
}
|
|
592
|
+
_findLineEnd(content, position) {
|
|
593
|
+
let cursor = position;
|
|
594
|
+
while (cursor < content.length && content[cursor] !== "\n") {
|
|
595
|
+
cursor += 1;
|
|
596
|
+
}
|
|
597
|
+
if (cursor < content.length && content[cursor] === "\n") {
|
|
598
|
+
return cursor + 1;
|
|
599
|
+
}
|
|
600
|
+
return cursor;
|
|
492
601
|
}
|
|
493
602
|
/**
|
|
494
603
|
* 获取当前编辑器内容作为节点列表
|
|
@@ -83,52 +83,65 @@ var ToolUseBarItemComponent = ({
|
|
|
83
83
|
}
|
|
84
84
|
);
|
|
85
85
|
}
|
|
86
|
-
return /* @__PURE__ */ React.createElement(
|
|
86
|
+
return /* @__PURE__ */ React.createElement(
|
|
87
87
|
"div",
|
|
88
88
|
{
|
|
89
|
-
|
|
90
|
-
"data-testid": "
|
|
91
|
-
|
|
89
|
+
key: tool.id,
|
|
90
|
+
"data-testid": "ToolUserItem",
|
|
91
|
+
className: classnames(toolClassName, {
|
|
92
|
+
[`${prefixCls}-tool-collapsed`]: !showContent
|
|
93
|
+
})
|
|
92
94
|
},
|
|
93
95
|
/* @__PURE__ */ React.createElement(
|
|
94
96
|
"div",
|
|
95
97
|
{
|
|
96
|
-
className:
|
|
97
|
-
|
|
98
|
+
className: classnames(toolBarClassName, {
|
|
99
|
+
[`${prefixCls}-tool-bar-collapsed`]: !showContent
|
|
100
|
+
}),
|
|
101
|
+
"data-testid": "tool-user-item-tool-bar",
|
|
102
|
+
onClick: handleClick
|
|
98
103
|
},
|
|
99
|
-
/* @__PURE__ */ React.createElement(
|
|
104
|
+
/* @__PURE__ */ React.createElement(
|
|
105
|
+
"div",
|
|
106
|
+
{
|
|
107
|
+
className: toolHeaderClassName,
|
|
108
|
+
"data-testid": "tool-user-item-tool-header"
|
|
109
|
+
},
|
|
110
|
+
/* @__PURE__ */ React.createElement(ToolImage, { tool, prefixCls, hashId })
|
|
111
|
+
),
|
|
112
|
+
/* @__PURE__ */ React.createElement(
|
|
113
|
+
ToolHeaderRight,
|
|
114
|
+
{
|
|
115
|
+
tool,
|
|
116
|
+
prefixCls,
|
|
117
|
+
hashId,
|
|
118
|
+
light
|
|
119
|
+
}
|
|
120
|
+
),
|
|
121
|
+
/* @__PURE__ */ React.createElement(ToolTime, { tool, prefixCls, hashId }),
|
|
122
|
+
/* @__PURE__ */ React.createElement(
|
|
123
|
+
ToolExpand,
|
|
124
|
+
{
|
|
125
|
+
showContent,
|
|
126
|
+
expanded,
|
|
127
|
+
prefixCls,
|
|
128
|
+
hashId,
|
|
129
|
+
onExpandClick: handleExpandClick
|
|
130
|
+
}
|
|
131
|
+
)
|
|
100
132
|
),
|
|
101
133
|
/* @__PURE__ */ React.createElement(
|
|
102
|
-
|
|
134
|
+
ToolContent,
|
|
103
135
|
{
|
|
104
136
|
tool,
|
|
105
137
|
prefixCls,
|
|
106
138
|
hashId,
|
|
107
|
-
light
|
|
108
|
-
}
|
|
109
|
-
),
|
|
110
|
-
/* @__PURE__ */ React.createElement(ToolTime, { tool, prefixCls, hashId }),
|
|
111
|
-
/* @__PURE__ */ React.createElement(
|
|
112
|
-
ToolExpand,
|
|
113
|
-
{
|
|
139
|
+
light,
|
|
114
140
|
showContent,
|
|
115
|
-
expanded
|
|
116
|
-
prefixCls,
|
|
117
|
-
hashId,
|
|
118
|
-
onExpandClick: handleExpandClick
|
|
141
|
+
expanded
|
|
119
142
|
}
|
|
120
143
|
)
|
|
121
|
-
)
|
|
122
|
-
ToolContent,
|
|
123
|
-
{
|
|
124
|
-
tool,
|
|
125
|
-
prefixCls,
|
|
126
|
-
hashId,
|
|
127
|
-
light,
|
|
128
|
-
showContent,
|
|
129
|
-
expanded
|
|
130
|
-
}
|
|
131
|
-
));
|
|
144
|
+
);
|
|
132
145
|
};
|
|
133
146
|
var ToolUseBarItem = memo(ToolUseBarItemComponent);
|
|
134
147
|
export {
|
|
@@ -18,7 +18,7 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
// src/ToolUseBar/ToolUseBarItemComponents.tsx
|
|
19
19
|
import { Api, ChevronUp, X } from "@sofa-design/icons";
|
|
20
20
|
import classnames from "classnames";
|
|
21
|
-
import { motion } from "framer-motion";
|
|
21
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
22
22
|
import React, { memo, useCallback, useMemo } from "react";
|
|
23
23
|
var ToolImageComponent = ({
|
|
24
24
|
tool,
|
|
@@ -217,20 +217,65 @@ var ToolContentComponent = ({
|
|
|
217
217
|
const contentDom = useMemo(() => {
|
|
218
218
|
return tool.content ? /* @__PURE__ */ React.createElement("div", { className: contentClassName }, tool.content) : null;
|
|
219
219
|
}, [tool.content, contentClassName]);
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
220
|
+
const contentVariants = useMemo(
|
|
221
|
+
() => ({
|
|
222
|
+
expanded: {
|
|
223
|
+
height: "auto",
|
|
224
|
+
opacity: 1
|
|
225
|
+
},
|
|
226
|
+
collapsed: {
|
|
227
|
+
height: 0,
|
|
228
|
+
opacity: 0
|
|
229
|
+
}
|
|
230
|
+
}),
|
|
231
|
+
[]
|
|
232
|
+
);
|
|
233
|
+
const contentTransition = useMemo(
|
|
234
|
+
() => ({
|
|
235
|
+
height: {
|
|
236
|
+
duration: 0.26,
|
|
237
|
+
ease: [0.4, 0, 0.2, 1]
|
|
238
|
+
},
|
|
239
|
+
opacity: {
|
|
240
|
+
duration: 0.26,
|
|
241
|
+
ease: [0.4, 0, 0.2, 1]
|
|
242
|
+
}
|
|
243
|
+
}),
|
|
244
|
+
[]
|
|
245
|
+
);
|
|
246
|
+
if (!showContent || !expanded) {
|
|
223
247
|
return /* @__PURE__ */ React.createElement(
|
|
224
248
|
"div",
|
|
225
249
|
{
|
|
226
|
-
|
|
227
|
-
|
|
250
|
+
style: {
|
|
251
|
+
overflow: "hidden",
|
|
252
|
+
height: 1,
|
|
253
|
+
opacity: 0,
|
|
254
|
+
visibility: "hidden"
|
|
255
|
+
},
|
|
256
|
+
role: "presentation",
|
|
257
|
+
"aria-hidden": "true"
|
|
228
258
|
},
|
|
229
259
|
contentDom,
|
|
230
260
|
errorDom
|
|
231
261
|
);
|
|
232
|
-
}
|
|
233
|
-
return
|
|
262
|
+
}
|
|
263
|
+
return /* @__PURE__ */ React.createElement(AnimatePresence, { initial: false, mode: "sync" }, expanded ? /* @__PURE__ */ React.createElement(
|
|
264
|
+
motion.div,
|
|
265
|
+
{
|
|
266
|
+
key: "tool-content",
|
|
267
|
+
className: toolContainerClassName,
|
|
268
|
+
"data-testid": "tool-user-item-tool-container",
|
|
269
|
+
variants: contentVariants,
|
|
270
|
+
initial: "collapsed",
|
|
271
|
+
animate: "expanded",
|
|
272
|
+
exit: "collapsed",
|
|
273
|
+
transition: contentTransition,
|
|
274
|
+
style: { overflow: "hidden" }
|
|
275
|
+
},
|
|
276
|
+
contentDom,
|
|
277
|
+
errorDom
|
|
278
|
+
) : null);
|
|
234
279
|
};
|
|
235
280
|
var ToolContent = memo(ToolContentComponent);
|
|
236
281
|
export {
|
package/dist/ToolUseBar/style.js
CHANGED
|
@@ -40,12 +40,13 @@ var genStyle = (token) => {
|
|
|
40
40
|
border: "var(--color-gray-border-light)",
|
|
41
41
|
boxShadow: "var(--shadow-border-base)",
|
|
42
42
|
minHeight: "20px",
|
|
43
|
+
backdropFilter: "blur(8px)",
|
|
43
44
|
width: "max-content",
|
|
44
45
|
transition: "padding 0.2s ease",
|
|
45
46
|
display: "flex",
|
|
46
47
|
alignItems: "center",
|
|
47
48
|
flexDirection: "column",
|
|
48
|
-
gap:
|
|
49
|
+
gap: 0,
|
|
49
50
|
zIndex: 1,
|
|
50
51
|
maxWidth: "min(800px,100%)",
|
|
51
52
|
padding: "2px",
|
|
@@ -64,6 +65,7 @@ var genStyle = (token) => {
|
|
|
64
65
|
"&-expanded": {
|
|
65
66
|
borderRadius: "14px",
|
|
66
67
|
padding: 4,
|
|
68
|
+
gap: 8,
|
|
67
69
|
outline: "none",
|
|
68
70
|
"&:hover": {
|
|
69
71
|
background: "var(--color-gray-bg-card-light)",
|
|
@@ -22,6 +22,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
22
22
|
import {
|
|
23
23
|
useEditorStyleRegister
|
|
24
24
|
} from "../Hooks/useStyle";
|
|
25
|
+
var LIGHT_MODE_BACKGROUND = "rgba(255, 255, 255, 0.65)";
|
|
26
|
+
var LIGHT_MODE_BACKDROP_FILTER = "blur(12px)";
|
|
25
27
|
var genStyle = (token) => {
|
|
26
28
|
return {
|
|
27
29
|
[token.componentCls]: {
|
|
@@ -69,6 +71,9 @@ var genStyle = (token) => {
|
|
|
69
71
|
border: "none",
|
|
70
72
|
borderRadius: "14px",
|
|
71
73
|
padding: 4,
|
|
74
|
+
background: LIGHT_MODE_BACKGROUND,
|
|
75
|
+
backdropFilter: LIGHT_MODE_BACKDROP_FILTER,
|
|
76
|
+
WebkitBackdropFilter: LIGHT_MODE_BACKDROP_FILTER,
|
|
72
77
|
"&:hover": {
|
|
73
78
|
background: "none",
|
|
74
79
|
boxShadow: "none",
|
|
@@ -226,7 +231,10 @@ var genStyle = (token) => {
|
|
|
226
231
|
borderLeft: "1px solid var(--color-gray-border-light)",
|
|
227
232
|
paddingLeft: 12,
|
|
228
233
|
marginLeft: 16,
|
|
229
|
-
marginTop: -10
|
|
234
|
+
marginTop: -10,
|
|
235
|
+
background: LIGHT_MODE_BACKGROUND,
|
|
236
|
+
backdropFilter: LIGHT_MODE_BACKDROP_FILTER,
|
|
237
|
+
WebkitBackdropFilter: LIGHT_MODE_BACKDROP_FILTER
|
|
230
238
|
}
|
|
231
239
|
},
|
|
232
240
|
"&-container-loading": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ant-design/agentic-ui",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
|
|
5
5
|
"repository": "git@github.com:ant-design/agentic-ui.git",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"start": "npm run dev",
|
|
28
28
|
"test": "vitest --run",
|
|
29
29
|
"test:coverage": "vitest --run --coverage",
|
|
30
|
-
"tsc": "tsc --noEmit"
|
|
30
|
+
"tsc": "tsc --noEmit",
|
|
31
|
+
"version": "node scripts/bumpVersion.js"
|
|
31
32
|
},
|
|
32
33
|
"lint-staged": {
|
|
33
34
|
"*.{js,jsx,ts,tsx}": [
|