@midscene/visualizer 0.30.9 → 0.30.11-beta-20251218071621.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/blackboard/index.css +8 -0
- package/dist/es/component/blackboard/index.mjs +137 -68
- package/dist/es/component/config-selector/index.mjs +102 -4
- package/dist/es/component/context-preview/index.mjs +1 -2
- package/dist/es/component/env-config/index.mjs +1 -2
- package/dist/es/component/env-config-reminder/index.css +8 -0
- package/dist/es/component/env-config-reminder/index.mjs +1 -2
- package/dist/es/component/form-field/index.mjs +5 -10
- package/dist/es/component/history-selector/index.css +38 -1
- package/dist/es/component/history-selector/index.mjs +1 -2
- package/dist/es/component/logo/index.mjs +7 -3
- package/dist/es/component/misc/index.mjs +1 -4
- package/dist/es/component/nav-actions/index.mjs +1 -2
- package/dist/es/component/nav-actions/style.css +1 -1
- package/dist/es/component/player/index.css +26 -0
- package/dist/es/component/player/index.mjs +376 -364
- package/dist/es/component/playground/index.css +291 -31
- package/dist/es/component/playground-result/index.css +10 -0
- package/dist/es/component/playground-result/index.mjs +129 -10
- package/dist/es/component/prompt-input/index.css +281 -31
- package/dist/es/component/prompt-input/index.mjs +83 -25
- package/dist/es/component/screenshot-viewer/index.css +214 -0
- package/dist/es/component/screenshot-viewer/index.mjs +282 -0
- package/dist/es/component/service-mode-control/index.mjs +1 -2
- package/dist/es/component/shiny-text/index.css +35 -3
- package/dist/es/component/shiny-text/index.mjs +3 -3
- package/dist/es/component/universal-playground/index.css +61 -1
- package/dist/es/component/universal-playground/index.mjs +106 -83
- package/dist/es/component/universal-playground/providers/context-provider.mjs +56 -18
- package/dist/es/component/universal-playground/providers/indexeddb-storage-provider.mjs +213 -139
- package/dist/es/component/universal-playground/providers/storage-provider.mjs +199 -121
- package/dist/es/hooks/usePlaygroundExecution.mjs +297 -146
- package/dist/es/hooks/usePlaygroundState.mjs +141 -75
- package/dist/es/hooks/useSafeOverrideAIConfig.mjs +2 -6
- package/dist/es/hooks/useServerValid.mjs +37 -12
- package/dist/es/hooks/useTheme.mjs +25 -0
- package/dist/es/icons/avatar.mjs +46 -4
- package/dist/es/icons/close.mjs +46 -4
- package/dist/es/icons/global-perspective.mjs +47 -5
- package/dist/es/icons/history.mjs +48 -6
- package/dist/es/icons/magnifying-glass.mjs +47 -5
- package/dist/es/icons/player-setting.mjs +48 -6
- package/dist/es/icons/setting.mjs +47 -5
- package/dist/es/icons/show-marker.mjs +47 -5
- package/dist/es/index.mjs +4 -4
- package/dist/es/store/history.mjs +46 -7
- package/dist/es/store/store.mjs +68 -2
- package/dist/es/types.mjs +1 -1
- package/dist/es/utils/constants.mjs +7 -3
- package/dist/es/utils/index.mjs +4 -1
- package/dist/es/utils/pixi-loader.mjs +37 -11
- package/dist/es/utils/replay-scripts.mjs +160 -111
- package/dist/lib/component/blackboard/index.css +8 -0
- package/dist/lib/component/blackboard/index.js +139 -70
- package/dist/lib/component/config-selector/index.js +103 -5
- package/dist/lib/component/context-preview/index.js +3 -4
- package/dist/lib/component/env-config/index.js +3 -4
- package/dist/lib/component/env-config-reminder/index.css +8 -0
- package/dist/lib/component/env-config-reminder/index.js +3 -4
- package/dist/lib/component/form-field/index.js +10 -15
- package/dist/lib/component/history-selector/index.css +38 -1
- package/dist/lib/component/history-selector/index.js +3 -4
- package/dist/lib/component/index.js +6 -8
- package/dist/lib/component/logo/index.js +9 -5
- package/dist/lib/component/misc/index.js +6 -9
- package/dist/lib/component/nav-actions/index.js +3 -4
- package/dist/lib/component/nav-actions/style.css +1 -1
- package/dist/lib/component/player/index.css +26 -0
- package/dist/lib/component/player/index.js +376 -365
- package/dist/lib/component/playground/index.css +291 -31
- package/dist/lib/component/playground/index.js +31 -33
- package/dist/lib/component/playground-result/index.css +10 -0
- package/dist/lib/component/playground-result/index.js +131 -12
- package/dist/lib/component/prompt-input/index.css +281 -31
- package/dist/lib/component/prompt-input/index.js +84 -26
- package/dist/lib/component/screenshot-viewer/index.css +214 -0
- package/dist/lib/component/screenshot-viewer/index.js +316 -0
- package/dist/lib/component/service-mode-control/index.js +3 -4
- package/dist/lib/component/shiny-text/index.css +35 -3
- package/dist/lib/component/shiny-text/index.js +5 -5
- package/dist/lib/component/universal-playground/index.css +61 -1
- package/dist/lib/component/universal-playground/index.js +108 -84
- package/dist/lib/component/universal-playground/providers/context-provider.js +58 -20
- package/dist/lib/component/universal-playground/providers/indexeddb-storage-provider.js +217 -143
- package/dist/lib/component/universal-playground/providers/storage-provider.js +207 -129
- package/dist/lib/hooks/usePlaygroundExecution.js +299 -148
- package/dist/lib/hooks/usePlaygroundState.js +143 -77
- package/dist/lib/hooks/useSafeOverrideAIConfig.js +4 -8
- package/dist/lib/hooks/useServerValid.js +39 -14
- package/dist/lib/hooks/useTheme.js +59 -0
- package/dist/lib/icons/avatar.js +48 -6
- package/dist/lib/icons/close.js +48 -6
- package/dist/lib/icons/global-perspective.js +49 -7
- package/dist/lib/icons/history.js +50 -8
- package/dist/lib/icons/magnifying-glass.js +49 -7
- package/dist/lib/icons/player-setting.js +50 -8
- package/dist/lib/icons/setting.js +49 -7
- package/dist/lib/icons/show-marker.js +49 -7
- package/dist/lib/index.js +44 -34
- package/dist/lib/store/history.js +48 -9
- package/dist/lib/store/store.js +74 -8
- package/dist/lib/types.js +3 -3
- package/dist/lib/utils/color.js +2 -2
- package/dist/lib/utils/constants.js +20 -4
- package/dist/lib/utils/index.js +10 -4
- package/dist/lib/utils/pixi-loader.js +41 -15
- package/dist/lib/utils/playground-utils.js +4 -4
- package/dist/lib/utils/replay-scripts.js +164 -115
- package/dist/types/component/config-selector/index.d.ts +2 -0
- package/dist/types/component/player/index.d.ts +0 -1
- package/dist/types/component/playground-result/index.d.ts +1 -0
- package/dist/types/component/prompt-input/index.d.ts +2 -1
- package/dist/types/component/screenshot-viewer/index.d.ts +15 -0
- package/dist/types/hooks/usePlaygroundExecution.d.ts +1 -1
- package/dist/types/hooks/usePlaygroundState.d.ts +3 -3
- package/dist/types/hooks/useTheme.d.ts +7 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/store/store.d.ts +18 -1
- package/dist/types/types.d.ts +14 -4
- package/dist/types/utils/constants.d.ts +5 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/replay-scripts.d.ts +1 -1
- package/package.json +12 -22
|
@@ -1,128 +1,237 @@
|
|
|
1
|
+
import { paramStr, typeStr } from "@midscene/core/agent";
|
|
1
2
|
import { useCallback } from "react";
|
|
2
3
|
import { useEnvConfig } from "../store/store.mjs";
|
|
3
|
-
import { noReplayAPIs } from "@midscene/playground";
|
|
4
4
|
import { BLANK_RESULT } from "../utils/constants.mjs";
|
|
5
5
|
import { allScriptsFromDump } from "../utils/replay-scripts.mjs";
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const result = {
|
|
25
|
-
...BLANK_RESULT
|
|
26
|
-
};
|
|
27
|
-
const systemItem = {
|
|
28
|
-
id: `system-${thisRunningId}`,
|
|
29
|
-
type: 'system',
|
|
30
|
-
content: '',
|
|
31
|
-
timestamp: new Date(),
|
|
32
|
-
loading: true,
|
|
33
|
-
loadingProgressText: ''
|
|
34
|
-
};
|
|
35
|
-
setInfoList((prev)=>[
|
|
36
|
-
...prev,
|
|
37
|
-
systemItem
|
|
38
|
-
]);
|
|
39
|
-
try {
|
|
40
|
-
currentRunningIdRef.current = thisRunningId;
|
|
41
|
-
interruptedFlagRef.current[thisRunningId] = false;
|
|
42
|
-
if (playgroundSDK.onProgressUpdate) playgroundSDK.onProgressUpdate(()=>{});
|
|
43
|
-
if (playgroundSDK.onProgressUpdate) playgroundSDK.onProgressUpdate((tip)=>{
|
|
44
|
-
if (interruptedFlagRef.current[thisRunningId]) return;
|
|
45
|
-
setInfoList((prev)=>{
|
|
46
|
-
const lastItem = prev[prev.length - 1];
|
|
47
|
-
if (lastItem && 'progress' === lastItem.type && lastItem.content === tip) return prev;
|
|
48
|
-
const progressItem = {
|
|
49
|
-
id: `progress-${thisRunningId}-${Date.now()}`,
|
|
50
|
-
type: 'progress',
|
|
51
|
-
content: tip,
|
|
52
|
-
timestamp: new Date()
|
|
53
|
-
};
|
|
54
|
-
return [
|
|
55
|
-
...prev,
|
|
56
|
-
progressItem
|
|
57
|
-
];
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
result.result = await playgroundSDK.executeAction(actionType, value, {
|
|
61
|
-
requestId: thisRunningId.toString(),
|
|
62
|
-
deepThink,
|
|
63
|
-
screenshotIncluded,
|
|
64
|
-
domIncluded
|
|
65
|
-
});
|
|
66
|
-
if ('object' == typeof result.result && null !== result.result) {
|
|
67
|
-
const resultObj = result.result;
|
|
68
|
-
if (resultObj.dump) result.dump = resultObj.dump;
|
|
69
|
-
if (resultObj.reportHTML) result.reportHTML = resultObj.reportHTML;
|
|
70
|
-
if (resultObj.error) result.error = resultObj.error;
|
|
71
|
-
if (void 0 !== resultObj.result) result.result = resultObj.result;
|
|
6
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
7
|
+
try {
|
|
8
|
+
var info = gen[key](arg);
|
|
9
|
+
var value = info.value;
|
|
10
|
+
} catch (error) {
|
|
11
|
+
reject(error);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (info.done) resolve(value);
|
|
15
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
16
|
+
}
|
|
17
|
+
function _async_to_generator(fn) {
|
|
18
|
+
return function() {
|
|
19
|
+
var self = this, args = arguments;
|
|
20
|
+
return new Promise(function(resolve, reject) {
|
|
21
|
+
var gen = fn.apply(self, args);
|
|
22
|
+
function _next(value) {
|
|
23
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
72
24
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
25
|
+
function _throw(err) {
|
|
26
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
27
|
+
}
|
|
28
|
+
_next(void 0);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function _define_property(obj, key, value) {
|
|
33
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
34
|
+
value: value,
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true
|
|
38
|
+
});
|
|
39
|
+
else obj[key] = value;
|
|
40
|
+
return obj;
|
|
41
|
+
}
|
|
42
|
+
function _object_spread(target) {
|
|
43
|
+
for(var i = 1; i < arguments.length; i++){
|
|
44
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
45
|
+
var ownKeys = Object.keys(source);
|
|
46
|
+
if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
47
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
48
|
+
}));
|
|
49
|
+
ownKeys.forEach(function(key) {
|
|
50
|
+
_define_property(target, key, source[key]);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return target;
|
|
54
|
+
}
|
|
55
|
+
function usePlaygroundExecution_ownKeys(object, enumerableOnly) {
|
|
56
|
+
var keys = Object.keys(object);
|
|
57
|
+
if (Object.getOwnPropertySymbols) {
|
|
58
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
59
|
+
if (enumerableOnly) symbols = symbols.filter(function(sym) {
|
|
60
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
61
|
+
});
|
|
62
|
+
keys.push.apply(keys, symbols);
|
|
63
|
+
}
|
|
64
|
+
return keys;
|
|
65
|
+
}
|
|
66
|
+
function _object_spread_props(target, source) {
|
|
67
|
+
source = null != source ? source : {};
|
|
68
|
+
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
69
|
+
else usePlaygroundExecution_ownKeys(Object(source)).forEach(function(key) {
|
|
70
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
71
|
+
});
|
|
72
|
+
return target;
|
|
73
|
+
}
|
|
74
|
+
function buildProgressContent(task) {
|
|
75
|
+
const action = typeStr(task);
|
|
76
|
+
const description = paramStr(task);
|
|
77
|
+
return description ? `${action} - ${description}` : action;
|
|
78
|
+
}
|
|
79
|
+
function wrapExecutionDumpForReplay(dump) {
|
|
80
|
+
const modelBriefsSet = new Set();
|
|
81
|
+
if ((null == dump ? void 0 : dump.tasks) && Array.isArray(dump.tasks)) dump.tasks.forEach((task)=>{
|
|
82
|
+
if (task.usage) {
|
|
83
|
+
const { model_name, model_description, intent } = task.usage;
|
|
84
|
+
if (intent && model_name) modelBriefsSet.add(model_description ? `${intent}/${model_name}(${model_description})` : `${intent}/${model_name}`);
|
|
114
85
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
86
|
+
});
|
|
87
|
+
else console.warn('[wrapExecutionDumpForReplay] Invalid dump structure:', dump);
|
|
88
|
+
const modelBriefs = [
|
|
89
|
+
...modelBriefsSet
|
|
90
|
+
];
|
|
91
|
+
return {
|
|
92
|
+
sdkVersion: '',
|
|
93
|
+
groupName: 'Playground Execution',
|
|
94
|
+
modelBriefs,
|
|
95
|
+
executions: [
|
|
96
|
+
dump
|
|
97
|
+
]
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, setLoading, setInfoList, replayCounter, setReplayCounter, verticalMode, currentRunningIdRef, interruptedFlagRef) {
|
|
101
|
+
const { deepThink, screenshotIncluded, domIncluded, planningStrategy } = useEnvConfig();
|
|
102
|
+
const handleRun = useCallback((value)=>_async_to_generator(function*() {
|
|
103
|
+
if (!playgroundSDK) return void console.warn('PlaygroundSDK is not available');
|
|
104
|
+
const thisRunningId = Date.now();
|
|
105
|
+
const actionType = value.type;
|
|
106
|
+
const displayContent = `${value.type}: ${value.prompt || JSON.stringify(value.params)}`;
|
|
107
|
+
const userItem = {
|
|
108
|
+
id: `user-${Date.now()}`,
|
|
109
|
+
type: 'user',
|
|
110
|
+
content: displayContent,
|
|
111
|
+
timestamp: new Date()
|
|
112
|
+
};
|
|
113
|
+
setInfoList((prev)=>[
|
|
114
|
+
...prev,
|
|
115
|
+
userItem
|
|
116
|
+
]);
|
|
117
|
+
setLoading(true);
|
|
118
|
+
const result = _object_spread({}, BLANK_RESULT);
|
|
119
|
+
const systemItem = {
|
|
120
|
+
id: `system-${thisRunningId}`,
|
|
121
|
+
type: 'system',
|
|
122
|
+
content: '',
|
|
123
|
+
timestamp: new Date(),
|
|
124
|
+
loading: true,
|
|
125
|
+
loadingProgressText: ''
|
|
126
|
+
};
|
|
127
|
+
setInfoList((prev)=>[
|
|
128
|
+
...prev,
|
|
129
|
+
systemItem
|
|
130
|
+
]);
|
|
131
|
+
try {
|
|
132
|
+
currentRunningIdRef.current = thisRunningId;
|
|
133
|
+
interruptedFlagRef.current[thisRunningId] = false;
|
|
134
|
+
if (playgroundSDK.onDumpUpdate) playgroundSDK.onDumpUpdate((_, executionDump)=>{
|
|
135
|
+
var _executionDump_tasks;
|
|
136
|
+
if (interruptedFlagRef.current[thisRunningId] || !(null == executionDump ? void 0 : null == (_executionDump_tasks = executionDump.tasks) ? void 0 : _executionDump_tasks.length)) return;
|
|
137
|
+
const progressItems = executionDump.tasks.map((task, index)=>{
|
|
138
|
+
var _task_timing;
|
|
139
|
+
return {
|
|
140
|
+
id: `progress-${thisRunningId}-task-${index}`,
|
|
141
|
+
type: 'progress',
|
|
142
|
+
content: buildProgressContent(task),
|
|
143
|
+
timestamp: new Date((null == (_task_timing = task.timing) ? void 0 : _task_timing.start) || Date.now()),
|
|
144
|
+
result: task.error ? {
|
|
145
|
+
error: String(task.error),
|
|
146
|
+
result: null
|
|
147
|
+
} : void 0
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
setInfoList((prev)=>{
|
|
151
|
+
const systemItemIndex = prev.findIndex((item)=>item.id === `system-${thisRunningId}`);
|
|
152
|
+
if (-1 === systemItemIndex) return prev;
|
|
153
|
+
const listWithoutCurrentProgress = prev.filter((item)=>!('progress' === item.type && item.id.startsWith(`progress-${thisRunningId}-`)));
|
|
154
|
+
return [
|
|
155
|
+
...listWithoutCurrentProgress.slice(0, systemItemIndex + 1),
|
|
156
|
+
...progressItems,
|
|
157
|
+
...listWithoutCurrentProgress.slice(systemItemIndex + 1)
|
|
158
|
+
];
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
result.result = yield playgroundSDK.executeAction(actionType, value, {
|
|
162
|
+
requestId: thisRunningId.toString(),
|
|
163
|
+
deepThink,
|
|
164
|
+
planningStrategy,
|
|
165
|
+
screenshotIncluded,
|
|
166
|
+
domIncluded
|
|
167
|
+
});
|
|
168
|
+
if ('object' == typeof result.result && null !== result.result) {
|
|
169
|
+
const resultObj = result.result;
|
|
170
|
+
if (resultObj.dump) result.dump = resultObj.dump;
|
|
171
|
+
if (resultObj.reportHTML) result.reportHTML = resultObj.reportHTML;
|
|
172
|
+
if (resultObj.error) result.error = resultObj.error;
|
|
173
|
+
if (void 0 !== resultObj.result) result.result = resultObj.result;
|
|
174
|
+
}
|
|
175
|
+
} catch (e) {
|
|
176
|
+
result.error = (null == e ? void 0 : e.message) || String(e);
|
|
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
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (interruptedFlagRef.current[thisRunningId]) return;
|
|
184
|
+
setLoading(false);
|
|
185
|
+
currentRunningIdRef.current = null;
|
|
186
|
+
let replayInfo = null;
|
|
187
|
+
let counter = replayCounter;
|
|
188
|
+
if (null == result ? void 0 : result.dump) {
|
|
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
|
+
}
|
|
196
|
+
}
|
|
197
|
+
setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` ? _object_spread_props(_object_spread({}, item), {
|
|
198
|
+
content: '',
|
|
199
|
+
loading: false,
|
|
200
|
+
loadingProgressText: ''
|
|
201
|
+
}) : item));
|
|
202
|
+
const resultItem = {
|
|
203
|
+
id: `result-${thisRunningId}`,
|
|
204
|
+
type: 'result',
|
|
205
|
+
content: 'Execution result',
|
|
206
|
+
timestamp: new Date(),
|
|
207
|
+
result: result,
|
|
208
|
+
loading: false,
|
|
209
|
+
replayScriptsInfo: replayInfo,
|
|
210
|
+
replayCounter: counter,
|
|
211
|
+
loadingProgressText: '',
|
|
212
|
+
verticalMode: verticalMode,
|
|
213
|
+
actionType: actionType
|
|
214
|
+
};
|
|
215
|
+
setInfoList((prev)=>[
|
|
216
|
+
...prev,
|
|
217
|
+
resultItem
|
|
218
|
+
]);
|
|
219
|
+
if (null == storage ? void 0 : storage.saveResult) try {
|
|
220
|
+
yield storage.saveResult(resultItem.id, resultItem);
|
|
221
|
+
} catch (error) {
|
|
222
|
+
console.error('Failed to save result:', error);
|
|
223
|
+
}
|
|
224
|
+
const separatorItem = {
|
|
225
|
+
id: `separator-${thisRunningId}`,
|
|
226
|
+
type: 'separator',
|
|
227
|
+
content: 'New Session',
|
|
228
|
+
timestamp: new Date()
|
|
229
|
+
};
|
|
230
|
+
setInfoList((prev)=>[
|
|
231
|
+
...prev,
|
|
232
|
+
separatorItem
|
|
233
|
+
]);
|
|
234
|
+
})(), [
|
|
126
235
|
playgroundSDK,
|
|
127
236
|
storage,
|
|
128
237
|
actionSpace,
|
|
@@ -134,41 +243,83 @@ function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, se
|
|
|
134
243
|
currentRunningIdRef,
|
|
135
244
|
interruptedFlagRef,
|
|
136
245
|
deepThink,
|
|
246
|
+
planningStrategy,
|
|
137
247
|
screenshotIncluded,
|
|
138
248
|
domIncluded
|
|
139
249
|
]);
|
|
140
|
-
const handleStop = useCallback(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
250
|
+
const handleStop = useCallback(()=>_async_to_generator(function*() {
|
|
251
|
+
const thisRunningId = currentRunningIdRef.current;
|
|
252
|
+
if (thisRunningId && playgroundSDK && playgroundSDK.cancelExecution) try {
|
|
253
|
+
let executionData = null;
|
|
254
|
+
if (playgroundSDK.getCurrentExecutionData) try {
|
|
255
|
+
executionData = yield playgroundSDK.getCurrentExecutionData();
|
|
256
|
+
} catch (error) {
|
|
257
|
+
console.error('Failed to get execution data before stop:', error);
|
|
258
|
+
}
|
|
259
|
+
yield playgroundSDK.cancelExecution(thisRunningId.toString());
|
|
260
|
+
interruptedFlagRef.current[thisRunningId] = true;
|
|
261
|
+
setLoading(false);
|
|
262
|
+
if (playgroundSDK.onProgressUpdate) playgroundSDK.onProgressUpdate(()=>{});
|
|
263
|
+
if (playgroundSDK.onDumpUpdate) playgroundSDK.onDumpUpdate(()=>{});
|
|
264
|
+
setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` ? _object_spread_props(_object_spread({}, item), {
|
|
265
|
+
content: '',
|
|
266
|
+
loading: false,
|
|
267
|
+
loadingProgressText: ''
|
|
268
|
+
}) : item));
|
|
269
|
+
if (executionData && (executionData.dump || executionData.reportHTML)) {
|
|
270
|
+
const resultItem = {
|
|
271
|
+
id: `stop-result-${thisRunningId}`,
|
|
272
|
+
type: 'result',
|
|
273
|
+
content: 'Execution stopped by user',
|
|
274
|
+
timestamp: new Date(),
|
|
275
|
+
result: {
|
|
276
|
+
result: null,
|
|
277
|
+
dump: executionData.dump,
|
|
278
|
+
reportHTML: executionData.reportHTML,
|
|
279
|
+
error: null
|
|
280
|
+
},
|
|
150
281
|
loading: false,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
282
|
+
verticalMode,
|
|
283
|
+
replayCounter
|
|
284
|
+
};
|
|
285
|
+
setInfoList((prev)=>[
|
|
286
|
+
...prev,
|
|
287
|
+
resultItem
|
|
288
|
+
]);
|
|
289
|
+
} else {
|
|
290
|
+
const stopItem = {
|
|
291
|
+
id: `stop-${thisRunningId}`,
|
|
292
|
+
type: 'system',
|
|
293
|
+
content: 'Operation stopped',
|
|
294
|
+
timestamp: new Date(),
|
|
295
|
+
loading: false
|
|
296
|
+
};
|
|
297
|
+
setInfoList((prev)=>[
|
|
298
|
+
...prev,
|
|
299
|
+
stopItem
|
|
300
|
+
]);
|
|
301
|
+
}
|
|
302
|
+
const separatorItem = {
|
|
303
|
+
id: `separator-${thisRunningId}`,
|
|
304
|
+
type: 'separator',
|
|
305
|
+
content: 'New Session',
|
|
306
|
+
timestamp: new Date()
|
|
307
|
+
};
|
|
308
|
+
setInfoList((prev)=>[
|
|
309
|
+
...prev,
|
|
310
|
+
separatorItem
|
|
311
|
+
]);
|
|
312
|
+
} catch (error) {
|
|
313
|
+
console.error('Failed to stop execution:', error);
|
|
314
|
+
}
|
|
315
|
+
})(), [
|
|
167
316
|
playgroundSDK,
|
|
168
317
|
currentRunningIdRef,
|
|
169
318
|
interruptedFlagRef,
|
|
170
319
|
setLoading,
|
|
171
|
-
setInfoList
|
|
320
|
+
setInfoList,
|
|
321
|
+
verticalMode,
|
|
322
|
+
replayCounter
|
|
172
323
|
]);
|
|
173
324
|
const canStop = loading && !!currentRunningIdRef.current && !!playgroundSDK && !!playgroundSDK.cancelExecution;
|
|
174
325
|
return {
|