@ant-design/agentic-ui 2.5.0 → 2.6.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.
|
@@ -42,6 +42,25 @@ var genStyle = (token) => {
|
|
|
42
42
|
"&::-webkit-scrollbar": {
|
|
43
43
|
width: "var(--padding-1-5x)"
|
|
44
44
|
},
|
|
45
|
+
// 小屏幕模式下横向滑动
|
|
46
|
+
"@media (max-width: 768px)": {
|
|
47
|
+
flexWrap: "nowrap",
|
|
48
|
+
overflowX: "auto",
|
|
49
|
+
overflowY: "hidden",
|
|
50
|
+
maxHeight: "none",
|
|
51
|
+
marginRight: "0",
|
|
52
|
+
padding: "var(--padding-2x)",
|
|
53
|
+
"&::-webkit-scrollbar": {
|
|
54
|
+
height: "var(--padding-1x)"
|
|
55
|
+
},
|
|
56
|
+
"&::-webkit-scrollbar-thumb": {
|
|
57
|
+
background: "var(--color-gray-border-default)",
|
|
58
|
+
borderRadius: "var(--radius-base)"
|
|
59
|
+
},
|
|
60
|
+
"&::-webkit-scrollbar-track": {
|
|
61
|
+
background: "transparent"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
45
64
|
"&-close-icon": {
|
|
46
65
|
width: "var(--height-control-xs)",
|
|
47
66
|
height: "var(--height-control-xs)",
|
|
@@ -73,6 +92,11 @@ var genStyle = (token) => {
|
|
|
73
92
|
cursor: "pointer",
|
|
74
93
|
gap: "var(--margin-2x)",
|
|
75
94
|
position: "relative",
|
|
95
|
+
// 小屏幕模式下固定宽度,防止收缩
|
|
96
|
+
"@media (max-width: 768px)": {
|
|
97
|
+
flexShrink: 0,
|
|
98
|
+
minWidth: "168px"
|
|
99
|
+
},
|
|
76
100
|
"&:hover": {
|
|
77
101
|
[`${token.componentCls}-item-close-icon`]: {
|
|
78
102
|
display: "flex"
|
|
@@ -182,6 +206,10 @@ var genStyle = (token) => {
|
|
|
182
206
|
transition: "transform 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
183
207
|
"&:hover": {
|
|
184
208
|
transform: "scale(1.05)"
|
|
209
|
+
},
|
|
210
|
+
// 小屏幕模式下常驻展示
|
|
211
|
+
"@media (max-width: 768px)": {
|
|
212
|
+
display: "flex"
|
|
185
213
|
}
|
|
186
214
|
},
|
|
187
215
|
"&-uploading-icon": {
|
|
@@ -483,11 +483,6 @@ var ChartRender = (props) => {
|
|
|
483
483
|
})
|
|
484
484
|
);
|
|
485
485
|
}
|
|
486
|
-
console.log(
|
|
487
|
-
"isRuntimeLoading || !isIntersecting",
|
|
488
|
-
isRuntimeLoading || !isIntersecting,
|
|
489
|
-
isIntersecting
|
|
490
|
-
);
|
|
491
486
|
if (!runtime && shouldLoadRuntime) {
|
|
492
487
|
const height = (config == null ? void 0 : config.height) || 240;
|
|
493
488
|
if (runtimeError) {
|
|
@@ -103,14 +103,18 @@ export declare class ProxySandbox {
|
|
|
103
103
|
private isObviousInfiniteLoop;
|
|
104
104
|
/**
|
|
105
105
|
* 带超时的普通执行
|
|
106
|
+
* 注意:对于同步死循环,setTimeout 无法中断,需要使用 Worker 或指令计数
|
|
107
|
+
* 这个方法只适用于不包含死循环的代码
|
|
106
108
|
*/
|
|
107
109
|
private executeWithTimeout;
|
|
108
110
|
/**
|
|
109
111
|
* 使用指令计数限制执行时间
|
|
112
|
+
* 这是处理同步死循环的唯一方法(在不使用 Worker 的情况下)
|
|
110
113
|
*/
|
|
111
114
|
private executeWithInstructionLimit;
|
|
112
115
|
/**
|
|
113
116
|
* 在代码中注入指令计数器
|
|
117
|
+
* 在循环体内部注入检查点,确保死循环能够被检测到
|
|
114
118
|
*/
|
|
115
119
|
private instrumentCode;
|
|
116
120
|
/**
|
|
@@ -643,12 +643,16 @@ var ProxySandbox = class {
|
|
|
643
643
|
/while\s*\(\s*true\s*\)/,
|
|
644
644
|
/for\s*\(\s*;\s*;\s*\)/,
|
|
645
645
|
/while\s*\(\s*1\s*\)/,
|
|
646
|
-
/while\s*\(\s*!false\s*\)
|
|
646
|
+
/while\s*\(\s*!false\s*\)/,
|
|
647
|
+
/do\s*\{[^}]*\}\s*while\s*\(\s*true\s*\)/,
|
|
648
|
+
/do\s*\{[^}]*\}\s*while\s*\(\s*1\s*\)/
|
|
647
649
|
];
|
|
648
650
|
return infiniteLoopPatterns.some((pattern) => pattern.test(code));
|
|
649
651
|
}
|
|
650
652
|
/**
|
|
651
653
|
* 带超时的普通执行
|
|
654
|
+
* 注意:对于同步死循环,setTimeout 无法中断,需要使用 Worker 或指令计数
|
|
655
|
+
* 这个方法只适用于不包含死循环的代码
|
|
652
656
|
*/
|
|
653
657
|
executeWithTimeout(code, injectedParams) {
|
|
654
658
|
return __async(this, null, function* () {
|
|
@@ -671,13 +675,15 @@ var ProxySandbox = class {
|
|
|
671
675
|
}
|
|
672
676
|
/**
|
|
673
677
|
* 使用指令计数限制执行时间
|
|
678
|
+
* 这是处理同步死循环的唯一方法(在不使用 Worker 的情况下)
|
|
674
679
|
*/
|
|
675
680
|
executeWithInstructionLimit(code, injectedParams) {
|
|
676
681
|
return __async(this, null, function* () {
|
|
677
682
|
return new Promise((resolve, reject) => {
|
|
678
|
-
const maxInstructions =
|
|
683
|
+
const maxInstructions = 1e4;
|
|
679
684
|
let instructionCount = 0;
|
|
680
685
|
const startTime = performance.now();
|
|
686
|
+
let timeoutId = null;
|
|
681
687
|
const instrumentedCode = this.instrumentCode(code);
|
|
682
688
|
const originalGlobal = this.sandboxGlobal.__checkInstructions;
|
|
683
689
|
this.sandboxGlobal.__checkInstructions = () => {
|
|
@@ -688,14 +694,25 @@ var ProxySandbox = class {
|
|
|
688
694
|
`Code execution timeout after ${this.config.timeout}ms`
|
|
689
695
|
);
|
|
690
696
|
}
|
|
691
|
-
if (instructionCount > maxInstructions
|
|
692
|
-
throw new Error(
|
|
697
|
+
if (instructionCount > maxInstructions) {
|
|
698
|
+
throw new Error(
|
|
699
|
+
`Code execution exceeded maximum instruction limit (${maxInstructions})`
|
|
700
|
+
);
|
|
693
701
|
}
|
|
694
702
|
};
|
|
703
|
+
timeoutId = setTimeout(() => {
|
|
704
|
+
reject(
|
|
705
|
+
new Error(`Code execution timeout after ${this.config.timeout}ms`)
|
|
706
|
+
);
|
|
707
|
+
}, this.config.timeout);
|
|
695
708
|
try {
|
|
696
709
|
const result = this.executeCode(instrumentedCode, injectedParams);
|
|
710
|
+
if (timeoutId)
|
|
711
|
+
clearTimeout(timeoutId);
|
|
697
712
|
resolve(result);
|
|
698
713
|
} catch (error) {
|
|
714
|
+
if (timeoutId)
|
|
715
|
+
clearTimeout(timeoutId);
|
|
699
716
|
reject(error);
|
|
700
717
|
} finally {
|
|
701
718
|
if (originalGlobal) {
|
|
@@ -709,6 +726,7 @@ var ProxySandbox = class {
|
|
|
709
726
|
}
|
|
710
727
|
/**
|
|
711
728
|
* 在代码中注入指令计数器
|
|
729
|
+
* 在循环体内部注入检查点,确保死循环能够被检测到
|
|
712
730
|
*/
|
|
713
731
|
instrumentCode(code) {
|
|
714
732
|
let instrumented = code;
|
|
@@ -774,12 +792,11 @@ ${instrumented}`;
|
|
|
774
792
|
* 回退到同步执行
|
|
775
793
|
*/
|
|
776
794
|
fallbackToSyncExecution(code, injectedParams, resolve, reject) {
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
} catch (error) {
|
|
781
|
-
reject(error);
|
|
795
|
+
if (this.isObviousInfiniteLoop(code)) {
|
|
796
|
+
this.executeWithInstructionLimit(code, injectedParams).then(resolve).catch(reject);
|
|
797
|
+
return;
|
|
782
798
|
}
|
|
799
|
+
this.executeWithTimeout(code, injectedParams).then(resolve).catch(reject);
|
|
783
800
|
}
|
|
784
801
|
/**
|
|
785
802
|
* 创建 Worker 实例
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ant-design/agentic-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
|
|
5
5
|
"repository": "git@github.com:ant-design/agentic-ui.git",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"prettier": "prettier --write \"{src,docs,test}/**/*.{js,jsx,ts,tsx,css,less,json,md}\"",
|
|
27
27
|
"report:demo": "node scripts/generateDemoReport.js",
|
|
28
28
|
"start": "npm run dev",
|
|
29
|
-
"test": "echo
|
|
29
|
+
"test": "echo \"No test specified\"",
|
|
30
30
|
"test:coverage": "vitest --run --coverage",
|
|
31
31
|
"tsc": "tsc --noEmit"
|
|
32
32
|
},
|
|
@@ -130,6 +130,7 @@
|
|
|
130
130
|
"@umijs/lint": "^4.5.3",
|
|
131
131
|
"@vitejs/plugin-react": "^4.7.0",
|
|
132
132
|
"@vitest/coverage-istanbul": "^2.1.9",
|
|
133
|
+
"@vitest/ui": "2.1.9",
|
|
133
134
|
"dumi": "^2.4.21",
|
|
134
135
|
"dumi-theme-antd-style": "^0.31.1",
|
|
135
136
|
"eslint": "^8.57.1",
|