@midscene/visualizer 1.0.1-beta-20251209024153.0 → 1.0.1-beta-20251211095502.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/es/component/player/index.mjs +2 -2
- package/dist/es/component/playground/index.css +0 -9
- package/dist/es/component/playground-result/index.css +0 -9
- package/dist/es/component/playground-result/index.mjs +12 -5
- package/dist/es/component/shiny-text/index.css +20 -3
- package/dist/es/component/shiny-text/index.mjs +3 -2
- package/dist/es/component/universal-playground/index.css +0 -1
- package/dist/es/component/universal-playground/index.mjs +46 -59
- package/dist/es/component/universal-playground/providers/indexeddb-storage-provider.mjs +13 -18
- package/dist/es/component/universal-playground/providers/storage-provider.mjs +2 -2
- package/dist/es/hooks/usePlaygroundExecution.mjs +108 -34
- package/dist/es/index.mjs +2 -2
- package/dist/es/store/store.mjs +23 -2
- package/dist/lib/component/player/index.js +1 -1
- package/dist/lib/component/playground/index.css +0 -9
- package/dist/lib/component/playground-result/index.css +0 -9
- package/dist/lib/component/playground-result/index.js +12 -5
- package/dist/lib/component/shiny-text/index.css +20 -3
- package/dist/lib/component/shiny-text/index.js +3 -2
- package/dist/lib/component/universal-playground/index.css +0 -1
- package/dist/lib/component/universal-playground/index.js +46 -58
- package/dist/lib/component/universal-playground/providers/indexeddb-storage-provider.js +13 -18
- package/dist/lib/component/universal-playground/providers/storage-provider.js +2 -2
- package/dist/lib/hooks/usePlaygroundExecution.js +108 -34
- package/dist/lib/index.js +3 -0
- package/dist/lib/store/store.js +26 -5
- package/dist/types/hooks/usePlaygroundExecution.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/store/store.d.ts +5 -1
- package/dist/types/types.d.ts +8 -2
- package/package.json +5 -5
|
@@ -9,7 +9,7 @@ import { CaretRightOutlined, DownloadOutlined, ExportOutlined, LoadingOutlined }
|
|
|
9
9
|
import { Dropdown, Spin, Switch, Tooltip, message } from "antd";
|
|
10
10
|
import global_perspective from "../../icons/global-perspective.mjs";
|
|
11
11
|
import player_setting from "../../icons/player-setting.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import { useGlobalPreference } from "../../store/store.mjs";
|
|
13
13
|
import { getTextureFromCache, loadTexture } from "../../utils/pixi-loader.mjs";
|
|
14
14
|
import { rectMarkForItem } from "../blackboard/index.mjs";
|
|
15
15
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -190,7 +190,7 @@ function Player(props) {
|
|
|
190
190
|
var _scripts_;
|
|
191
191
|
const [titleText, setTitleText] = useState('');
|
|
192
192
|
const [subTitleText, setSubTitleText] = useState('');
|
|
193
|
-
const { autoZoom, setAutoZoom } =
|
|
193
|
+
const { autoZoom, setAutoZoom } = useGlobalPreference();
|
|
194
194
|
useEffect(()=>{
|
|
195
195
|
if ((null == props ? void 0 : props.autoZoom) !== void 0) setAutoZoom(props.autoZoom);
|
|
196
196
|
}, [
|
|
@@ -32,15 +32,6 @@
|
|
|
32
32
|
overflow: scroll;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
[data-theme="dark"] .result-wrapper .loading-container .loading-progress-text {
|
|
36
|
-
color: #f8fafd;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
[data-theme="dark"] .result-wrapper pre {
|
|
40
|
-
color: #f8fafd;
|
|
41
|
-
background: #141414;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
35
|
.prompt-input-wrapper {
|
|
45
36
|
width: 100%;
|
|
46
37
|
}
|
|
@@ -29,11 +29,18 @@ const PlaygroundResultView = ({ result, loading, serverValid, serviceMode, repla
|
|
|
29
29
|
})
|
|
30
30
|
]
|
|
31
31
|
});
|
|
32
|
-
else if (replayScriptsInfo)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
else if (replayScriptsInfo) {
|
|
33
|
+
const reportContent = ('In-Browser-Extension' === serviceMode || 'Server' === serviceMode) && (null == result ? void 0 : result.reportHTML) ? null == result ? void 0 : result.reportHTML : null;
|
|
34
|
+
resultDataToShow = /*#__PURE__*/ jsx(Player, {
|
|
35
|
+
replayScripts: replayScriptsInfo.scripts,
|
|
36
|
+
imageWidth: replayScriptsInfo.width,
|
|
37
|
+
imageHeight: replayScriptsInfo.height,
|
|
38
|
+
reportFileContent: reportContent,
|
|
39
|
+
fitMode: fitMode,
|
|
40
|
+
autoZoom: autoZoom
|
|
41
|
+
}, replayCounter);
|
|
42
|
+
} else if ((null == result ? void 0 : result.reportHTML) && ('In-Browser-Extension' === serviceMode || 'Server' === serviceMode)) resultDataToShow = /*#__PURE__*/ jsx(Player, {
|
|
43
|
+
reportFileContent: result.reportHTML,
|
|
37
44
|
fitMode: fitMode,
|
|
38
45
|
autoZoom: autoZoom
|
|
39
46
|
}, replayCounter);
|
|
@@ -13,6 +13,23 @@
|
|
|
13
13
|
overflow: hidden;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
.shiny-text.theme-blue {
|
|
17
|
+
background-image: linear-gradient(45deg, #2b83ff, #6a11cb, #2575fc, #4481eb);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.shiny-text.theme-purple {
|
|
21
|
+
background-image: linear-gradient(45deg, #667eea, #764ba2, #b06ab3, #9d50bb);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.shiny-text.theme-green {
|
|
25
|
+
background-image: linear-gradient(45deg, #11998e, #38ef7d, #2dd4bf, #10b981);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.shiny-text.theme-rainbow {
|
|
29
|
+
background-image: linear-gradient(45deg, #ff0080, #ff8c00, #40e0d0, #9d50bb, #ff0080);
|
|
30
|
+
background-size: 400%;
|
|
31
|
+
}
|
|
32
|
+
|
|
16
33
|
.shiny-text:after {
|
|
17
34
|
content: "";
|
|
18
35
|
width: 120%;
|
|
@@ -28,9 +45,9 @@
|
|
|
28
45
|
}
|
|
29
46
|
|
|
30
47
|
.shiny-text.disabled {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
color: #000;
|
|
49
|
+
background: none;
|
|
50
|
+
font-weight: normal;
|
|
34
51
|
animation: none;
|
|
35
52
|
}
|
|
36
53
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import "./index.css";
|
|
3
|
-
const ShinyText = ({ text, disabled = false, speed = 5, className = '' })=>{
|
|
3
|
+
const ShinyText = ({ text, disabled = false, speed = 5, className = '', colorTheme = 'blue' })=>{
|
|
4
4
|
const style = {
|
|
5
5
|
'--animation-duration': `${speed}s`
|
|
6
6
|
};
|
|
7
|
+
const themeClass = `theme-${colorTheme}`;
|
|
7
8
|
return /*#__PURE__*/ jsx("div", {
|
|
8
|
-
className: `shiny-text ${disabled ? 'disabled' : ''} ${className}`,
|
|
9
|
+
className: `shiny-text ${themeClass} ${disabled ? 'disabled' : ''} ${className}`,
|
|
9
10
|
style: style,
|
|
10
11
|
children: text
|
|
11
12
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import icons, { ArrowDownOutlined, ClearOutlined, LoadingOutlined } from "@ant-design/icons";
|
|
3
|
-
import { Button, Form, List,
|
|
3
|
+
import { Alert, Button, Form, List, Typography, message } from "antd";
|
|
4
4
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
5
5
|
import { usePlaygroundExecution } from "../../hooks/usePlaygroundExecution.mjs";
|
|
6
6
|
import { usePlaygroundState } from "../../hooks/usePlaygroundState.mjs";
|
|
@@ -12,6 +12,7 @@ import "./index.css";
|
|
|
12
12
|
import avatar from "../../icons/avatar.mjs";
|
|
13
13
|
import { defaultMainButtons } from "../../utils/constants.mjs";
|
|
14
14
|
import { PromptInput } from "../prompt-input/index.mjs";
|
|
15
|
+
import shiny_text from "../shiny-text/index.mjs";
|
|
15
16
|
import { createStorageProvider, detectBestStorageType } from "./providers/storage-provider.mjs";
|
|
16
17
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
17
18
|
try {
|
|
@@ -46,21 +47,16 @@ function getSDKId(sdk) {
|
|
|
46
47
|
}
|
|
47
48
|
function ErrorMessage({ error }) {
|
|
48
49
|
if (!error) return null;
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
const cleanError = error.replace(/^(Error:\s*)+/, 'Error: ');
|
|
51
|
+
return /*#__PURE__*/ jsx(Alert, {
|
|
52
|
+
message: /*#__PURE__*/ jsx("span", {
|
|
51
53
|
style: {
|
|
52
|
-
|
|
53
|
-
wordBreak: 'break-all'
|
|
54
|
+
color: '#ff4d4f'
|
|
54
55
|
},
|
|
55
|
-
children:
|
|
56
|
+
children: cleanError
|
|
56
57
|
}),
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
children: [
|
|
61
|
-
"Error: ",
|
|
62
|
-
error.split('\n')[0]
|
|
63
|
-
]
|
|
58
|
+
type: "error",
|
|
59
|
+
showIcon: true
|
|
64
60
|
});
|
|
65
61
|
}
|
|
66
62
|
function UniversalPlayground({ playgroundSDK, storage, contextProvider, config: componentConfig = {}, branding = {}, className = '', dryMode = false, showContextPreview = true }) {
|
|
@@ -103,7 +99,7 @@ function UniversalPlayground({ playgroundSDK, storage, contextProvider, config:
|
|
|
103
99
|
playgroundSDK
|
|
104
100
|
]);
|
|
105
101
|
const { loading, setLoading, infoList, setInfoList, actionSpace, actionSpaceLoading, uiContextPreview, setUiContextPreview, showScrollToBottomButton, verticalMode, replayCounter, setReplayCounter, infoListRef, currentRunningIdRef, interruptedFlagRef, clearInfoList, handleScrollToBottom } = usePlaygroundState(playgroundSDK, effectiveStorage, contextProvider);
|
|
106
|
-
const { handleRun: executeAction, handleStop, canStop } = usePlaygroundExecution(playgroundSDK, effectiveStorage, actionSpace, loading, setLoading,
|
|
102
|
+
const { handleRun: executeAction, handleStop, canStop } = usePlaygroundExecution(playgroundSDK, effectiveStorage, actionSpace, loading, setLoading, setInfoList, replayCounter, setReplayCounter, verticalMode, currentRunningIdRef, interruptedFlagRef);
|
|
107
103
|
useEffect(()=>{
|
|
108
104
|
if ((null == playgroundSDK ? void 0 : playgroundSDK.overrideConfig) && config) playgroundSDK.overrideConfig(config).catch((error)=>{
|
|
109
105
|
console.error('Failed to override SDK config:', error);
|
|
@@ -126,6 +122,12 @@ function UniversalPlayground({ playgroundSDK, storage, contextProvider, config:
|
|
|
126
122
|
const configAlreadySet = Object.keys(config || {}).length >= 1;
|
|
127
123
|
const runButtonEnabled = componentConfig.serverMode || !dryMode && !actionSpaceLoading && configAlreadySet;
|
|
128
124
|
const selectedType = Form.useWatch('type', form);
|
|
125
|
+
const serviceMode = useMemo(()=>{
|
|
126
|
+
if (!playgroundSDK || 'function' != typeof playgroundSDK.getServiceMode) return 'Server';
|
|
127
|
+
return playgroundSDK.getServiceMode();
|
|
128
|
+
}, [
|
|
129
|
+
playgroundSDK
|
|
130
|
+
]);
|
|
129
131
|
const finalShowContextPreview = showContextPreview && false !== componentConfig.showContextPreview;
|
|
130
132
|
const layout = componentConfig.layout || 'vertical';
|
|
131
133
|
const showVersionInfo = false !== componentConfig.showVersionInfo;
|
|
@@ -164,9 +166,7 @@ function UniversalPlayground({ playgroundSDK, storage, contextProvider, config:
|
|
|
164
166
|
children: /*#__PURE__*/ jsx(List, {
|
|
165
167
|
itemLayout: "vertical",
|
|
166
168
|
dataSource: infoList,
|
|
167
|
-
renderItem: (item)
|
|
168
|
-
var _item_result;
|
|
169
|
-
return /*#__PURE__*/ jsx(List.Item, {
|
|
169
|
+
renderItem: (item)=>/*#__PURE__*/ jsx(List.Item, {
|
|
170
170
|
className: "list-item",
|
|
171
171
|
children: 'user' === item.type ? /*#__PURE__*/ jsx("div", {
|
|
172
172
|
className: "user-message-container",
|
|
@@ -199,9 +199,10 @@ function UniversalPlayground({ playgroundSDK, storage, contextProvider, config:
|
|
|
199
199
|
]
|
|
200
200
|
}),
|
|
201
201
|
description && /*#__PURE__*/ jsx("div", {
|
|
202
|
-
children: /*#__PURE__*/ jsx(
|
|
202
|
+
children: /*#__PURE__*/ jsx(shiny_text, {
|
|
203
|
+
text: description,
|
|
203
204
|
className: "progress-description",
|
|
204
|
-
|
|
205
|
+
disabled: !shouldShowLoading
|
|
205
206
|
})
|
|
206
207
|
}),
|
|
207
208
|
(null == (_item_result2 = item.result) ? void 0 : _item_result2.error) && /*#__PURE__*/ jsx(ErrorMessage, {
|
|
@@ -243,50 +244,36 @@ function UniversalPlayground({ playgroundSDK, storage, contextProvider, config:
|
|
|
243
244
|
})
|
|
244
245
|
]
|
|
245
246
|
}),
|
|
246
|
-
(item.content || item.result) && /*#__PURE__*/
|
|
247
|
+
(item.content || item.result) && /*#__PURE__*/ jsx("div", {
|
|
247
248
|
className: "system-message-content",
|
|
248
|
-
children:
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
verticalMode: item.verticalMode || false,
|
|
269
|
-
fitMode: "width"
|
|
270
|
-
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
271
|
-
children: [
|
|
272
|
-
/*#__PURE__*/ jsx("div", {
|
|
273
|
-
className: "system-message-text",
|
|
274
|
-
children: item.content
|
|
275
|
-
}),
|
|
276
|
-
item.loading && item.loadingProgressText && /*#__PURE__*/ jsx("div", {
|
|
277
|
-
className: "loading-progress-text",
|
|
278
|
-
children: /*#__PURE__*/ jsx("span", {
|
|
279
|
-
children: item.loadingProgressText
|
|
280
|
-
})
|
|
249
|
+
children: 'result' === item.type ? /*#__PURE__*/ jsx(PlaygroundResultView, {
|
|
250
|
+
result: item.result || null,
|
|
251
|
+
loading: item.loading || false,
|
|
252
|
+
serverValid: true,
|
|
253
|
+
serviceMode: serviceMode,
|
|
254
|
+
replayScriptsInfo: item.replayScriptsInfo || null,
|
|
255
|
+
replayCounter: item.replayCounter || 0,
|
|
256
|
+
loadingProgressText: item.loadingProgressText || '',
|
|
257
|
+
verticalMode: item.verticalMode || false,
|
|
258
|
+
fitMode: "width"
|
|
259
|
+
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
260
|
+
children: [
|
|
261
|
+
/*#__PURE__*/ jsx("div", {
|
|
262
|
+
className: "system-message-text",
|
|
263
|
+
children: item.content
|
|
264
|
+
}),
|
|
265
|
+
item.loading && item.loadingProgressText && /*#__PURE__*/ jsx("div", {
|
|
266
|
+
className: "loading-progress-text",
|
|
267
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
268
|
+
children: item.loadingProgressText
|
|
281
269
|
})
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
270
|
+
})
|
|
271
|
+
]
|
|
272
|
+
})
|
|
285
273
|
})
|
|
286
274
|
]
|
|
287
275
|
})
|
|
288
|
-
}, item.id)
|
|
289
|
-
}
|
|
276
|
+
}, item.id)
|
|
290
277
|
})
|
|
291
278
|
}),
|
|
292
279
|
showScrollToBottomButton && false !== componentConfig.enableScrollToBottom && /*#__PURE__*/ jsx(Button, {
|
|
@@ -306,7 +293,7 @@ function UniversalPlayground({ playgroundSDK, storage, contextProvider, config:
|
|
|
306
293
|
/*#__PURE__*/ jsx(PromptInput, {
|
|
307
294
|
runButtonEnabled: runButtonEnabled,
|
|
308
295
|
form: form,
|
|
309
|
-
serviceMode:
|
|
296
|
+
serviceMode: serviceMode,
|
|
310
297
|
selectedType: selectedType,
|
|
311
298
|
dryMode: dryMode,
|
|
312
299
|
stoppable: canStop,
|
|
@@ -81,7 +81,7 @@ class IndexedDBStorageProvider {
|
|
|
81
81
|
const messagesToSave = messages.slice(-MAX_STORED_MESSAGES);
|
|
82
82
|
yield Promise.all(messagesToSave.map((msg, index)=>{
|
|
83
83
|
const lightMessage = _object_spread_props(_object_spread({}, msg), {
|
|
84
|
-
result: void 0
|
|
84
|
+
result: 'result' === msg.type ? void 0 : msg.result
|
|
85
85
|
});
|
|
86
86
|
const data = {
|
|
87
87
|
id: msg.id || `msg-${index}`,
|
|
@@ -153,28 +153,23 @@ class IndexedDBStorageProvider {
|
|
|
153
153
|
}
|
|
154
154
|
compressResultForStorage(result) {
|
|
155
155
|
var _result_result_dump, _result_result;
|
|
156
|
-
if (!(null == (_result_result = result.result) ? void 0 : null == (_result_result_dump = _result_result.dump) ? void 0 : _result_result_dump.
|
|
157
|
-
const
|
|
158
|
-
var
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
recorder: null == (_task_recorder = task.recorder) ? void 0 : _task_recorder.map((record)=>_object_spread_props(_object_spread({}, record), {
|
|
168
|
-
screenshot: this.compressScreenshotIfNeeded(record.screenshot)
|
|
169
|
-
}))
|
|
170
|
-
});
|
|
171
|
-
})) || []
|
|
156
|
+
if (!(null == (_result_result = result.result) ? void 0 : null == (_result_result_dump = _result_result.dump) ? void 0 : _result_result_dump.tasks)) return result;
|
|
157
|
+
const compressedTasks = result.result.dump.tasks.map((task)=>{
|
|
158
|
+
var _task_recorder;
|
|
159
|
+
var _this_compressScreenshotIfNeeded;
|
|
160
|
+
return _object_spread_props(_object_spread({}, task), {
|
|
161
|
+
uiContext: task.uiContext ? _object_spread_props(_object_spread({}, task.uiContext), {
|
|
162
|
+
screenshotBase64: null != (_this_compressScreenshotIfNeeded = this.compressScreenshotIfNeeded(task.uiContext.screenshotBase64)) ? _this_compressScreenshotIfNeeded : task.uiContext.screenshotBase64
|
|
163
|
+
}) : task.uiContext,
|
|
164
|
+
recorder: null == (_task_recorder = task.recorder) ? void 0 : _task_recorder.map((record)=>_object_spread_props(_object_spread({}, record), {
|
|
165
|
+
screenshot: this.compressScreenshotIfNeeded(record.screenshot)
|
|
166
|
+
}))
|
|
172
167
|
});
|
|
173
168
|
});
|
|
174
169
|
return _object_spread_props(_object_spread({}, result), {
|
|
175
170
|
result: _object_spread_props(_object_spread({}, result.result), {
|
|
176
171
|
dump: _object_spread_props(_object_spread({}, result.result.dump), {
|
|
177
|
-
|
|
172
|
+
tasks: compressedTasks
|
|
178
173
|
})
|
|
179
174
|
})
|
|
180
175
|
});
|
|
@@ -88,7 +88,7 @@ class LocalStorageProvider {
|
|
|
88
88
|
}
|
|
89
89
|
const messagesToSave = messages.slice(-this.maxStorageItems);
|
|
90
90
|
const lightMessages = messagesToSave.map((msg)=>_object_spread_props(_object_spread({}, msg), {
|
|
91
|
-
result: void 0
|
|
91
|
+
result: 'result' === msg.type ? void 0 : msg.result
|
|
92
92
|
}));
|
|
93
93
|
const messageData = JSON.stringify(lightMessages);
|
|
94
94
|
localStorage.setItem(this.messagesKey, messageData);
|
|
@@ -99,7 +99,7 @@ class LocalStorageProvider {
|
|
|
99
99
|
try {
|
|
100
100
|
const recentMessages = messages.slice(-10);
|
|
101
101
|
const lightRecentMessages = recentMessages.map((msg)=>_object_spread_props(_object_spread({}, msg), {
|
|
102
|
-
result: void 0
|
|
102
|
+
result: 'result' === msg.type ? void 0 : msg.result
|
|
103
103
|
}));
|
|
104
104
|
const messageData = JSON.stringify(lightRecentMessages);
|
|
105
105
|
localStorage.setItem(this.messagesKey, messageData);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { paramStr, typeStr } from "@midscene/core/agent";
|
|
1
2
|
import { useCallback } from "react";
|
|
2
3
|
import { useEnvConfig } from "../store/store.mjs";
|
|
3
4
|
import { noReplayAPIs } from "@midscene/playground";
|
|
@@ -71,8 +72,34 @@ function _object_spread_props(target, source) {
|
|
|
71
72
|
});
|
|
72
73
|
return target;
|
|
73
74
|
}
|
|
74
|
-
function
|
|
75
|
-
const
|
|
75
|
+
function buildProgressContent(task) {
|
|
76
|
+
const action = typeStr(task);
|
|
77
|
+
const description = paramStr(task);
|
|
78
|
+
return description ? `${action} - ${description}` : action;
|
|
79
|
+
}
|
|
80
|
+
function wrapExecutionDumpForReplay(dump) {
|
|
81
|
+
const modelBriefsSet = new Set();
|
|
82
|
+
if ((null == dump ? void 0 : dump.tasks) && Array.isArray(dump.tasks)) dump.tasks.forEach((task)=>{
|
|
83
|
+
if (task.usage) {
|
|
84
|
+
const { model_name, model_description, intent } = task.usage;
|
|
85
|
+
if (intent && model_name) modelBriefsSet.add(model_description ? `${intent}/${model_name}(${model_description})` : `${intent}/${model_name}`);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
else console.warn('[wrapExecutionDumpForReplay] Invalid dump structure:', dump);
|
|
89
|
+
const modelBriefs = [
|
|
90
|
+
...modelBriefsSet
|
|
91
|
+
];
|
|
92
|
+
return {
|
|
93
|
+
sdkVersion: '',
|
|
94
|
+
groupName: 'Playground Execution',
|
|
95
|
+
modelBriefs,
|
|
96
|
+
executions: [
|
|
97
|
+
dump
|
|
98
|
+
]
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, setLoading, setInfoList, replayCounter, setReplayCounter, verticalMode, currentRunningIdRef, interruptedFlagRef) {
|
|
102
|
+
const { deepThink, screenshotIncluded, domIncluded } = useEnvConfig();
|
|
76
103
|
const handleRun = useCallback((value)=>_async_to_generator(function*() {
|
|
77
104
|
if (!playgroundSDK) return void console.warn('PlaygroundSDK is not available');
|
|
78
105
|
const thisRunningId = Date.now();
|
|
@@ -105,36 +132,38 @@ function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, se
|
|
|
105
132
|
try {
|
|
106
133
|
currentRunningIdRef.current = thisRunningId;
|
|
107
134
|
interruptedFlagRef.current[thisRunningId] = false;
|
|
108
|
-
if (playgroundSDK.
|
|
109
|
-
|
|
110
|
-
if (interruptedFlagRef.current[thisRunningId]) return;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
id: `progress-${thisRunningId}-${Date.now()}`,
|
|
135
|
+
if (playgroundSDK.onDumpUpdate) playgroundSDK.onDumpUpdate((_, executionDump)=>{
|
|
136
|
+
var _executionDump_tasks;
|
|
137
|
+
if (interruptedFlagRef.current[thisRunningId] || !(null == executionDump ? void 0 : null == (_executionDump_tasks = executionDump.tasks) ? void 0 : _executionDump_tasks.length)) return;
|
|
138
|
+
const progressItems = executionDump.tasks.map((task, index)=>{
|
|
139
|
+
var _task_timing;
|
|
140
|
+
return {
|
|
141
|
+
id: `progress-${thisRunningId}-task-${index}`,
|
|
116
142
|
type: 'progress',
|
|
117
|
-
content:
|
|
118
|
-
timestamp: new Date()
|
|
143
|
+
content: buildProgressContent(task),
|
|
144
|
+
timestamp: new Date((null == (_task_timing = task.timing) ? void 0 : _task_timing.start) || Date.now()),
|
|
145
|
+
result: task.error ? {
|
|
146
|
+
error: String(task.error),
|
|
147
|
+
result: null
|
|
148
|
+
} : void 0
|
|
119
149
|
};
|
|
150
|
+
});
|
|
151
|
+
setInfoList((prev)=>{
|
|
152
|
+
const systemItemIndex = prev.findIndex((item)=>item.id === `system-${thisRunningId}`);
|
|
153
|
+
if (-1 === systemItemIndex) return prev;
|
|
154
|
+
const listWithoutCurrentProgress = prev.filter((item)=>!('progress' === item.type && item.id.startsWith(`progress-${thisRunningId}-`)));
|
|
120
155
|
return [
|
|
121
|
-
...
|
|
122
|
-
|
|
156
|
+
...listWithoutCurrentProgress.slice(0, systemItemIndex + 1),
|
|
157
|
+
...progressItems,
|
|
158
|
+
...listWithoutCurrentProgress.slice(systemItemIndex + 1)
|
|
123
159
|
];
|
|
124
160
|
});
|
|
125
161
|
});
|
|
126
|
-
const deviceOptionsToSend = {
|
|
127
|
-
imeStrategy,
|
|
128
|
-
autoDismissKeyboard,
|
|
129
|
-
keyboardDismissStrategy,
|
|
130
|
-
alwaysRefreshScreenInfo
|
|
131
|
-
};
|
|
132
162
|
result.result = yield playgroundSDK.executeAction(actionType, value, {
|
|
133
163
|
requestId: thisRunningId.toString(),
|
|
134
164
|
deepThink,
|
|
135
165
|
screenshotIncluded,
|
|
136
|
-
domIncluded
|
|
137
|
-
deviceOptions: deviceOptionsToSend
|
|
166
|
+
domIncluded
|
|
138
167
|
});
|
|
139
168
|
if ('object' == typeof result.result && null !== result.result) {
|
|
140
169
|
const resultObj = result.result;
|
|
@@ -146,6 +175,10 @@ function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, se
|
|
|
146
175
|
} catch (e) {
|
|
147
176
|
result.error = (null == e ? void 0 : e.message) || String(e);
|
|
148
177
|
console.error('Playground execution error:', e);
|
|
178
|
+
if ('object' == typeof e && null !== e) {
|
|
179
|
+
if (e.dump) result.dump = e.dump;
|
|
180
|
+
if (e.reportHTML) result.reportHTML = e.reportHTML;
|
|
181
|
+
}
|
|
149
182
|
}
|
|
150
183
|
if (interruptedFlagRef.current[thisRunningId]) return;
|
|
151
184
|
setLoading(false);
|
|
@@ -153,10 +186,13 @@ function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, se
|
|
|
153
186
|
let replayInfo = null;
|
|
154
187
|
let counter = replayCounter;
|
|
155
188
|
if ((null == result ? void 0 : result.dump) && !noReplayAPIs.includes(actionType)) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
189
|
+
if (result.dump.tasks && Array.isArray(result.dump.tasks)) {
|
|
190
|
+
const groupedDump = wrapExecutionDumpForReplay(result.dump);
|
|
191
|
+
const info = allScriptsFromDump(groupedDump);
|
|
192
|
+
setReplayCounter((c)=>c + 1);
|
|
193
|
+
replayInfo = info;
|
|
194
|
+
counter = replayCounter + 1;
|
|
195
|
+
}
|
|
160
196
|
}
|
|
161
197
|
setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` ? _object_spread_props(_object_spread({}, item), {
|
|
162
198
|
content: '',
|
|
@@ -207,24 +243,60 @@ function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, se
|
|
|
207
243
|
interruptedFlagRef,
|
|
208
244
|
deepThink,
|
|
209
245
|
screenshotIncluded,
|
|
210
|
-
domIncluded
|
|
211
|
-
imeStrategy,
|
|
212
|
-
autoDismissKeyboard,
|
|
213
|
-
keyboardDismissStrategy,
|
|
214
|
-
alwaysRefreshScreenInfo
|
|
246
|
+
domIncluded
|
|
215
247
|
]);
|
|
216
248
|
const handleStop = useCallback(()=>_async_to_generator(function*() {
|
|
217
249
|
const thisRunningId = currentRunningIdRef.current;
|
|
218
250
|
if (thisRunningId && playgroundSDK && playgroundSDK.cancelExecution) try {
|
|
251
|
+
let executionData = null;
|
|
252
|
+
if (playgroundSDK.getCurrentExecutionData) try {
|
|
253
|
+
executionData = yield playgroundSDK.getCurrentExecutionData();
|
|
254
|
+
} catch (error) {
|
|
255
|
+
console.error('Failed to get execution data before stop:', error);
|
|
256
|
+
}
|
|
219
257
|
yield playgroundSDK.cancelExecution(thisRunningId.toString());
|
|
220
258
|
interruptedFlagRef.current[thisRunningId] = true;
|
|
221
259
|
setLoading(false);
|
|
222
260
|
if (playgroundSDK.onProgressUpdate) playgroundSDK.onProgressUpdate(()=>{});
|
|
223
|
-
|
|
224
|
-
|
|
261
|
+
if (playgroundSDK.onDumpUpdate) playgroundSDK.onDumpUpdate(()=>{});
|
|
262
|
+
setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` ? _object_spread_props(_object_spread({}, item), {
|
|
263
|
+
content: '',
|
|
225
264
|
loading: false,
|
|
226
265
|
loadingProgressText: ''
|
|
227
266
|
}) : item));
|
|
267
|
+
if (executionData && (executionData.dump || executionData.reportHTML)) {
|
|
268
|
+
const resultItem = {
|
|
269
|
+
id: `stop-result-${thisRunningId}`,
|
|
270
|
+
type: 'result',
|
|
271
|
+
content: 'Execution stopped by user',
|
|
272
|
+
timestamp: new Date(),
|
|
273
|
+
result: {
|
|
274
|
+
result: null,
|
|
275
|
+
dump: executionData.dump,
|
|
276
|
+
reportHTML: executionData.reportHTML,
|
|
277
|
+
error: null
|
|
278
|
+
},
|
|
279
|
+
loading: false,
|
|
280
|
+
verticalMode,
|
|
281
|
+
replayCounter
|
|
282
|
+
};
|
|
283
|
+
setInfoList((prev)=>[
|
|
284
|
+
...prev,
|
|
285
|
+
resultItem
|
|
286
|
+
]);
|
|
287
|
+
} else {
|
|
288
|
+
const stopItem = {
|
|
289
|
+
id: `stop-${thisRunningId}`,
|
|
290
|
+
type: 'system',
|
|
291
|
+
content: 'Operation stopped',
|
|
292
|
+
timestamp: new Date(),
|
|
293
|
+
loading: false
|
|
294
|
+
};
|
|
295
|
+
setInfoList((prev)=>[
|
|
296
|
+
...prev,
|
|
297
|
+
stopItem
|
|
298
|
+
]);
|
|
299
|
+
}
|
|
228
300
|
const separatorItem = {
|
|
229
301
|
id: `separator-${thisRunningId}`,
|
|
230
302
|
type: 'separator',
|
|
@@ -243,7 +315,9 @@ function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, se
|
|
|
243
315
|
currentRunningIdRef,
|
|
244
316
|
interruptedFlagRef,
|
|
245
317
|
setLoading,
|
|
246
|
-
setInfoList
|
|
318
|
+
setInfoList,
|
|
319
|
+
verticalMode,
|
|
320
|
+
replayCounter
|
|
247
321
|
]);
|
|
248
322
|
const canStop = loading && !!currentRunningIdRef.current && !!playgroundSDK && !!playgroundSDK.cancelExecution;
|
|
249
323
|
return {
|
package/dist/es/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { allScriptsFromDump, generateAnimationScripts } from "./utils/replay-scripts.mjs";
|
|
2
|
-
import { useEnvConfig } from "./store/store.mjs";
|
|
2
|
+
import { useEnvConfig, useGlobalPreference } from "./store/store.mjs";
|
|
3
3
|
import { colorForName, globalThemeConfig, highlightColorForType } from "./utils/color.mjs";
|
|
4
4
|
import { EnvConfig } from "./component/env-config/index.mjs";
|
|
5
5
|
import { EnvConfigReminder } from "./component/env-config-reminder/index.mjs";
|
|
@@ -22,4 +22,4 @@ import shiny_text from "./component/shiny-text/index.mjs";
|
|
|
22
22
|
import universal_playground, { UniversalPlayground } from "./component/universal-playground/index.mjs";
|
|
23
23
|
import { IndexedDBStorageProvider, LocalStorageProvider, MemoryStorageProvider, NoOpStorageProvider, StorageType, createStorageProvider, detectBestStorageType } from "./component/universal-playground/providers/storage-provider.mjs";
|
|
24
24
|
import { AgentContextProvider, BaseContextProvider, NoOpContextProvider, StaticContextProvider } from "./component/universal-playground/providers/context-provider.mjs";
|
|
25
|
-
export { AgentContextProvider, BaseContextProvider, Blackboard, ContextPreview, EnvConfig, EnvConfigReminder, IndexedDBStorageProvider, LocalStorageProvider, Logo, MemoryStorageProvider, NavActions, NoOpContextProvider, NoOpStorageProvider, Player, PlaygroundResultView, PromptInput, screenshot_viewer as ScreenshotViewer, ServiceModeControl, shiny_text as ShinyText, StaticContextProvider, StorageType, UniversalPlayground, universal_playground as UniversalPlaygroundDefault, actionNameForType, allScriptsFromDump, colorForName, createStorageProvider, detectBestStorageType, filterBase64Value, generateAnimationScripts, getPlaceholderForType, globalThemeConfig, highlightColorForType, iconForStatus, safeOverrideAIConfig, staticAgentFromContext, timeCostStrElement, timeStr, useEnvConfig, useSafeOverrideAIConfig, useServerValid, useTheme };
|
|
25
|
+
export { AgentContextProvider, BaseContextProvider, Blackboard, ContextPreview, EnvConfig, EnvConfigReminder, IndexedDBStorageProvider, LocalStorageProvider, Logo, MemoryStorageProvider, NavActions, NoOpContextProvider, NoOpStorageProvider, Player, PlaygroundResultView, PromptInput, screenshot_viewer as ScreenshotViewer, ServiceModeControl, shiny_text as ShinyText, StaticContextProvider, StorageType, UniversalPlayground, universal_playground as UniversalPlaygroundDefault, actionNameForType, allScriptsFromDump, colorForName, createStorageProvider, detectBestStorageType, filterBase64Value, generateAnimationScripts, getPlaceholderForType, globalThemeConfig, highlightColorForType, iconForStatus, safeOverrideAIConfig, staticAgentFromContext, timeCostStrElement, timeStr, useEnvConfig, useGlobalPreference, useSafeOverrideAIConfig, useServerValid, useTheme };
|