@midscene/visualizer 0.27.5-beta-20250827031507.0 → 0.27.5-beta-20250827160628.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/playground/ConfigSelector.mjs +57 -5
- package/dist/es/component/playground/PromptInput.mjs +37 -18
- package/dist/es/component/playground/playground-constants.mjs +3 -1
- package/dist/es/component/playground/playground-utils.mjs +3 -1
- package/dist/es/component/store/store.mjs +18 -0
- package/dist/lib/component/playground/ConfigSelector.js +54 -2
- package/dist/lib/component/playground/PromptInput.js +37 -18
- package/dist/lib/component/playground/playground-constants.js +10 -2
- package/dist/lib/component/playground/playground-utils.js +3 -1
- package/dist/lib/component/store/store.js +18 -0
- package/dist/types/component/playground/ConfigSelector.d.ts +2 -0
- package/dist/types/component/playground/PromptInput.d.ts +1 -0
- package/dist/types/component/playground/playground-constants.d.ts +2 -0
- package/dist/types/component/playground/playground-utils.d.ts +3 -1
- package/dist/types/component/store/store.d.ts +4 -0
- package/package.json +4 -4
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Checkbox, Dropdown } from "antd";
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Checkbox, Dropdown, Radio } from "antd";
|
|
3
3
|
import setting from "../../icons/setting.mjs";
|
|
4
4
|
import { useEnvConfig } from "../store/store.mjs";
|
|
5
|
-
import { deepThinkTip, trackingTip } from "./playground-constants.mjs";
|
|
5
|
+
import { deepThinkTip, domIncludedTip, screenshotIncludedTip, trackingTip } from "./playground-constants.mjs";
|
|
6
6
|
import "./index.css";
|
|
7
7
|
const ConfigSelector = (param)=>{
|
|
8
|
-
let { showDeepThinkOption = false, enableTracking = false } = param;
|
|
8
|
+
let { showDeepThinkOption = false, enableTracking = false, showDataExtractionOptions = false, hideDomAndScreenshotOptions = false } = param;
|
|
9
9
|
const forceSameTabNavigation = useEnvConfig((state)=>state.forceSameTabNavigation);
|
|
10
10
|
const setForceSameTabNavigation = useEnvConfig((state)=>state.setForceSameTabNavigation);
|
|
11
11
|
const deepThink = useEnvConfig((state)=>state.deepThink);
|
|
12
12
|
const setDeepThink = useEnvConfig((state)=>state.setDeepThink);
|
|
13
|
-
|
|
13
|
+
const screenshotIncluded = useEnvConfig((state)=>state.screenshotIncluded);
|
|
14
|
+
const setScreenshotIncluded = useEnvConfig((state)=>state.setScreenshotIncluded);
|
|
15
|
+
const domIncluded = useEnvConfig((state)=>state.domIncluded);
|
|
16
|
+
const setDomIncluded = useEnvConfig((state)=>state.setDomIncluded);
|
|
17
|
+
if (!enableTracking && !showDeepThinkOption && !showDataExtractionOptions) return null;
|
|
14
18
|
const configItems = buildConfigItems();
|
|
15
19
|
return /*#__PURE__*/ jsx("div", {
|
|
16
20
|
className: "selector-trigger",
|
|
@@ -47,6 +51,54 @@ const ConfigSelector = (param)=>{
|
|
|
47
51
|
}),
|
|
48
52
|
key: 'deep-think-config'
|
|
49
53
|
});
|
|
54
|
+
if (showDataExtractionOptions && !hideDomAndScreenshotOptions) {
|
|
55
|
+
items.push({
|
|
56
|
+
label: /*#__PURE__*/ jsx(Checkbox, {
|
|
57
|
+
onChange: (e)=>{
|
|
58
|
+
setScreenshotIncluded(e.target.checked);
|
|
59
|
+
},
|
|
60
|
+
checked: screenshotIncluded,
|
|
61
|
+
children: screenshotIncludedTip
|
|
62
|
+
}),
|
|
63
|
+
key: 'screenshot-included-config'
|
|
64
|
+
});
|
|
65
|
+
items.push({
|
|
66
|
+
label: /*#__PURE__*/ jsxs("div", {
|
|
67
|
+
style: {
|
|
68
|
+
padding: '4px 0'
|
|
69
|
+
},
|
|
70
|
+
children: [
|
|
71
|
+
/*#__PURE__*/ jsx("div", {
|
|
72
|
+
style: {
|
|
73
|
+
marginBottom: '4px',
|
|
74
|
+
fontSize: '14px'
|
|
75
|
+
},
|
|
76
|
+
children: domIncludedTip
|
|
77
|
+
}),
|
|
78
|
+
/*#__PURE__*/ jsxs(Radio.Group, {
|
|
79
|
+
size: "small",
|
|
80
|
+
value: domIncluded,
|
|
81
|
+
onChange: (e)=>setDomIncluded(e.target.value),
|
|
82
|
+
children: [
|
|
83
|
+
/*#__PURE__*/ jsx(Radio, {
|
|
84
|
+
value: false,
|
|
85
|
+
children: "Off"
|
|
86
|
+
}),
|
|
87
|
+
/*#__PURE__*/ jsx(Radio, {
|
|
88
|
+
value: true,
|
|
89
|
+
children: "All"
|
|
90
|
+
}),
|
|
91
|
+
/*#__PURE__*/ jsx(Radio, {
|
|
92
|
+
value: 'visible-only',
|
|
93
|
+
children: "Visible only"
|
|
94
|
+
})
|
|
95
|
+
]
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
}),
|
|
99
|
+
key: 'dom-included-config'
|
|
100
|
+
});
|
|
101
|
+
}
|
|
50
102
|
return items;
|
|
51
103
|
}
|
|
52
104
|
};
|
|
@@ -12,12 +12,13 @@ import { extractDefaultValue, isLocateField, isZodObjectSchema, unwrapZodType }
|
|
|
12
12
|
import "./index.css";
|
|
13
13
|
const { TextArea } = Input;
|
|
14
14
|
const PromptInput = (param)=>{
|
|
15
|
-
let { runButtonEnabled, form, serviceMode, selectedType, dryMode, stoppable, loading, onRun, onStop, clearPromptAfterRun = true, actionSpace } = param;
|
|
15
|
+
let { runButtonEnabled, form, serviceMode, selectedType, dryMode, stoppable, loading, onRun, onStop, clearPromptAfterRun = true, actionSpace, hideDomAndScreenshotOptions = false } = param;
|
|
16
16
|
const [hoveringSettings, setHoveringSettings] = useState(false);
|
|
17
17
|
const [promptValue, setPromptValue] = useState('');
|
|
18
18
|
const placeholder = getPlaceholderForType(selectedType);
|
|
19
19
|
const textAreaRef = useRef(null);
|
|
20
20
|
const params = Form.useWatch('params', form);
|
|
21
|
+
const lastHistoryRef = useRef(null);
|
|
21
22
|
const history = useHistoryStore((state)=>state.history);
|
|
22
23
|
const lastSelectedType = useHistoryStore((state)=>state.lastSelectedType);
|
|
23
24
|
const addHistory = useHistoryStore((state)=>state.addHistory);
|
|
@@ -29,13 +30,28 @@ const PromptInput = (param)=>{
|
|
|
29
30
|
const needsStructuredParams = useMemo(()=>{
|
|
30
31
|
if (actionSpace) {
|
|
31
32
|
const action = actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
|
|
32
|
-
return null == action ? void 0 : action.paramSchema;
|
|
33
|
+
return !!(null == action ? void 0 : action.paramSchema);
|
|
33
34
|
}
|
|
35
|
+
return false;
|
|
34
36
|
}, [
|
|
35
37
|
selectedType,
|
|
36
38
|
actionSpace
|
|
37
39
|
]);
|
|
40
|
+
const showDataExtractionOptions = useMemo(()=>{
|
|
41
|
+
const dataExtractionMethods = [
|
|
42
|
+
'aiQuery',
|
|
43
|
+
'aiBoolean',
|
|
44
|
+
'aiNumber',
|
|
45
|
+
'aiString',
|
|
46
|
+
'aiAsk',
|
|
47
|
+
'aiAssert'
|
|
48
|
+
];
|
|
49
|
+
return dataExtractionMethods.includes(selectedType);
|
|
50
|
+
}, [
|
|
51
|
+
selectedType
|
|
52
|
+
]);
|
|
38
53
|
const showDeepThinkOption = useMemo(()=>{
|
|
54
|
+
if ('aiLocate' === selectedType) return true;
|
|
39
55
|
if (actionSpace) {
|
|
40
56
|
const action = actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
|
|
41
57
|
if ((null == action ? void 0 : action.paramSchema) && isZodObjectSchema(action.paramSchema)) {
|
|
@@ -46,15 +62,8 @@ const PromptInput = (param)=>{
|
|
|
46
62
|
return isLocateField(actualField);
|
|
47
63
|
});
|
|
48
64
|
}
|
|
49
|
-
return false;
|
|
50
65
|
}
|
|
51
|
-
return
|
|
52
|
-
'aiTap',
|
|
53
|
-
'aiHover',
|
|
54
|
-
'aiInput',
|
|
55
|
-
'aiRightClick',
|
|
56
|
-
'aiLocate'
|
|
57
|
-
].includes(selectedType);
|
|
66
|
+
return false;
|
|
58
67
|
}, [
|
|
59
68
|
selectedType,
|
|
60
69
|
actionSpace
|
|
@@ -93,6 +102,7 @@ const PromptInput = (param)=>{
|
|
|
93
102
|
]);
|
|
94
103
|
useEffect(()=>{
|
|
95
104
|
const lastHistory = historyForSelectedType[0];
|
|
105
|
+
if (lastHistory && lastHistoryRef.current && lastHistory.timestamp === lastHistoryRef.current.timestamp) return;
|
|
96
106
|
if (lastHistory) {
|
|
97
107
|
form.setFieldsValue({
|
|
98
108
|
type: lastHistory.type,
|
|
@@ -100,6 +110,7 @@ const PromptInput = (param)=>{
|
|
|
100
110
|
params: lastHistory.params
|
|
101
111
|
});
|
|
102
112
|
setPromptValue(lastHistory.prompt || '');
|
|
113
|
+
lastHistoryRef.current = lastHistory;
|
|
103
114
|
} else {
|
|
104
115
|
const defaultParams = getDefaultParams();
|
|
105
116
|
form.setFieldsValue({
|
|
@@ -107,6 +118,7 @@ const PromptInput = (param)=>{
|
|
|
107
118
|
params: defaultParams
|
|
108
119
|
});
|
|
109
120
|
setPromptValue('');
|
|
121
|
+
lastHistoryRef.current = null;
|
|
110
122
|
}
|
|
111
123
|
}, [
|
|
112
124
|
selectedType,
|
|
@@ -114,6 +126,13 @@ const PromptInput = (param)=>{
|
|
|
114
126
|
form,
|
|
115
127
|
getDefaultParams
|
|
116
128
|
]);
|
|
129
|
+
const formPromptValue = Form.useWatch('prompt', form);
|
|
130
|
+
useEffect(()=>{
|
|
131
|
+
if (formPromptValue !== promptValue) setPromptValue(formPromptValue || '');
|
|
132
|
+
}, [
|
|
133
|
+
formPromptValue,
|
|
134
|
+
promptValue
|
|
135
|
+
]);
|
|
117
136
|
const handleSelectHistory = useCallback((historyItem)=>{
|
|
118
137
|
form.setFieldsValue({
|
|
119
138
|
prompt: historyItem.prompt,
|
|
@@ -127,10 +146,7 @@ const PromptInput = (param)=>{
|
|
|
127
146
|
const handlePromptChange = useCallback((e)=>{
|
|
128
147
|
const value = e.target.value;
|
|
129
148
|
setPromptValue(value);
|
|
130
|
-
|
|
131
|
-
}, [
|
|
132
|
-
form
|
|
133
|
-
]);
|
|
149
|
+
}, []);
|
|
134
150
|
const hasSingleStructuredParam = useMemo(()=>{
|
|
135
151
|
if (!needsStructuredParams || !actionSpace) return false;
|
|
136
152
|
const action = actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
|
|
@@ -175,14 +191,16 @@ const PromptInput = (param)=>{
|
|
|
175
191
|
historyPrompt = locateValue ? `${mainPart} | ${locateValue}` : mainPart;
|
|
176
192
|
} else historyPrompt = values.prompt || '';
|
|
177
193
|
} else historyPrompt = values.prompt || '';
|
|
178
|
-
|
|
194
|
+
const newHistoryItem = {
|
|
179
195
|
type: values.type,
|
|
180
196
|
prompt: historyPrompt,
|
|
181
197
|
params: values.params,
|
|
182
198
|
timestamp: Date.now()
|
|
183
|
-
}
|
|
199
|
+
};
|
|
200
|
+
addHistory(newHistoryItem);
|
|
184
201
|
onRun();
|
|
185
202
|
if (clearPromptAfterRun) {
|
|
203
|
+
lastHistoryRef.current = newHistoryItem;
|
|
186
204
|
setPromptValue('');
|
|
187
205
|
if (needsStructuredParams) {
|
|
188
206
|
const defaultParams = getDefaultParams();
|
|
@@ -483,7 +501,9 @@ const PromptInput = (param)=>{
|
|
|
483
501
|
onMouseLeave: handleMouseLeave,
|
|
484
502
|
children: /*#__PURE__*/ jsx(ConfigSelector, {
|
|
485
503
|
enableTracking: 'In-Browser-Extension' === serviceMode,
|
|
486
|
-
showDeepThinkOption: showDeepThinkOption
|
|
504
|
+
showDeepThinkOption: showDeepThinkOption,
|
|
505
|
+
showDataExtractionOptions: showDataExtractionOptions,
|
|
506
|
+
hideDomAndScreenshotOptions: hideDomAndScreenshotOptions
|
|
487
507
|
})
|
|
488
508
|
})
|
|
489
509
|
]
|
|
@@ -509,7 +529,6 @@ const PromptInput = (param)=>{
|
|
|
509
529
|
autoFocus: true,
|
|
510
530
|
onKeyDown: handleKeyDown,
|
|
511
531
|
onChange: handlePromptChange,
|
|
512
|
-
value: promptValue,
|
|
513
532
|
ref: textAreaRef
|
|
514
533
|
})
|
|
515
534
|
}),
|
|
@@ -42,6 +42,8 @@ const emptyResultTip = /*#__PURE__*/ jsx("div", {
|
|
|
42
42
|
});
|
|
43
43
|
const trackingTip = 'limit popup to current tab';
|
|
44
44
|
const deepThinkTip = 'deep think';
|
|
45
|
+
const screenshotIncludedTip = 'include screenshot in request';
|
|
46
|
+
const domIncludedTip = 'include DOM info in request';
|
|
45
47
|
const apiMetadata = {
|
|
46
48
|
aiAction: {
|
|
47
49
|
group: 'interaction',
|
|
@@ -110,4 +112,4 @@ const defaultMainButtons = [
|
|
|
110
112
|
'aiQuery',
|
|
111
113
|
'aiAssert'
|
|
112
114
|
];
|
|
113
|
-
export { apiMetadata, deepThinkTip, defaultMainButtons, emptyResultTip, errorMessageServerNotReady, serverLaunchTip, trackingTip };
|
|
115
|
+
export { apiMetadata, deepThinkTip, defaultMainButtons, domIncludedTip, emptyResultTip, errorMessageServerNotReady, screenshotIncludedTip, serverLaunchTip, trackingTip };
|
|
@@ -11,7 +11,7 @@ const checkServerStatus = async ()=>{
|
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
const requestPlaygroundServer = async function(context, type, prompt) {
|
|
14
|
-
let { requestId, deepThink } = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {};
|
|
14
|
+
let { requestId, deepThink, screenshotIncluded, domIncluded } = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {};
|
|
15
15
|
const payload = {
|
|
16
16
|
context,
|
|
17
17
|
type,
|
|
@@ -19,6 +19,8 @@ const requestPlaygroundServer = async function(context, type, prompt) {
|
|
|
19
19
|
};
|
|
20
20
|
if (requestId) payload.requestId = requestId;
|
|
21
21
|
if (deepThink) payload.deepThink = deepThink;
|
|
22
|
+
if (void 0 !== screenshotIncluded) payload.screenshotIncluded = screenshotIncluded;
|
|
23
|
+
if (void 0 !== domIncluded) payload.domIncluded = domIncluded;
|
|
22
24
|
const res = await fetch(`${serverBase}/execute`, {
|
|
23
25
|
method: 'POST',
|
|
24
26
|
headers: {
|
|
@@ -62,6 +62,8 @@ const CONFIG_KEY = 'midscene-env-config';
|
|
|
62
62
|
const SERVICE_MODE_KEY = 'midscene-service-mode';
|
|
63
63
|
const TRACKING_ACTIVE_TAB_KEY = 'midscene-tracking-active-tab';
|
|
64
64
|
const DEEP_THINK_KEY = 'midscene-deep-think';
|
|
65
|
+
const SCREENSHOT_INCLUDED_KEY = 'midscene-screenshot-included';
|
|
66
|
+
const DOM_INCLUDED_KEY = 'midscene-dom-included';
|
|
65
67
|
const getConfigStringFromLocalStorage = ()=>{
|
|
66
68
|
const configString = localStorage.getItem(CONFIG_KEY);
|
|
67
69
|
return configString || '';
|
|
@@ -90,6 +92,8 @@ const useEnvConfig = store_create((set, get)=>{
|
|
|
90
92
|
const savedServiceMode = localStorage.getItem(SERVICE_MODE_KEY);
|
|
91
93
|
const savedForceSameTabNavigation = 'false' !== localStorage.getItem(TRACKING_ACTIVE_TAB_KEY);
|
|
92
94
|
const savedDeepThink = 'true' === localStorage.getItem(DEEP_THINK_KEY);
|
|
95
|
+
const savedScreenshotIncluded = 'false' !== localStorage.getItem(SCREENSHOT_INCLUDED_KEY);
|
|
96
|
+
const savedDomIncluded = localStorage.getItem(DOM_INCLUDED_KEY) || 'false';
|
|
93
97
|
return {
|
|
94
98
|
serviceMode: ifInExtension ? 'In-Browser-Extension' : savedServiceMode || 'Server',
|
|
95
99
|
setServiceMode: (serviceMode)=>{
|
|
@@ -134,6 +138,20 @@ const useEnvConfig = store_create((set, get)=>{
|
|
|
134
138
|
});
|
|
135
139
|
localStorage.setItem(DEEP_THINK_KEY, deepThink.toString());
|
|
136
140
|
},
|
|
141
|
+
screenshotIncluded: savedScreenshotIncluded,
|
|
142
|
+
setScreenshotIncluded: (screenshotIncluded)=>{
|
|
143
|
+
set({
|
|
144
|
+
screenshotIncluded
|
|
145
|
+
});
|
|
146
|
+
localStorage.setItem(SCREENSHOT_INCLUDED_KEY, screenshotIncluded.toString());
|
|
147
|
+
},
|
|
148
|
+
domIncluded: 'visible-only' === savedDomIncluded ? 'visible-only' : 'true' === savedDomIncluded,
|
|
149
|
+
setDomIncluded: (domIncluded)=>{
|
|
150
|
+
set({
|
|
151
|
+
domIncluded
|
|
152
|
+
});
|
|
153
|
+
localStorage.setItem(DOM_INCLUDED_KEY, domIncluded.toString());
|
|
154
|
+
},
|
|
137
155
|
popupTab: 'playground',
|
|
138
156
|
setPopupTab: (tab)=>{
|
|
139
157
|
set({
|
|
@@ -43,12 +43,16 @@ const store_js_namespaceObject = require("../store/store.js");
|
|
|
43
43
|
const external_playground_constants_js_namespaceObject = require("./playground-constants.js");
|
|
44
44
|
require("./index.css");
|
|
45
45
|
const ConfigSelector = (param)=>{
|
|
46
|
-
let { showDeepThinkOption = false, enableTracking = false } = param;
|
|
46
|
+
let { showDeepThinkOption = false, enableTracking = false, showDataExtractionOptions = false, hideDomAndScreenshotOptions = false } = param;
|
|
47
47
|
const forceSameTabNavigation = (0, store_js_namespaceObject.useEnvConfig)((state)=>state.forceSameTabNavigation);
|
|
48
48
|
const setForceSameTabNavigation = (0, store_js_namespaceObject.useEnvConfig)((state)=>state.setForceSameTabNavigation);
|
|
49
49
|
const deepThink = (0, store_js_namespaceObject.useEnvConfig)((state)=>state.deepThink);
|
|
50
50
|
const setDeepThink = (0, store_js_namespaceObject.useEnvConfig)((state)=>state.setDeepThink);
|
|
51
|
-
|
|
51
|
+
const screenshotIncluded = (0, store_js_namespaceObject.useEnvConfig)((state)=>state.screenshotIncluded);
|
|
52
|
+
const setScreenshotIncluded = (0, store_js_namespaceObject.useEnvConfig)((state)=>state.setScreenshotIncluded);
|
|
53
|
+
const domIncluded = (0, store_js_namespaceObject.useEnvConfig)((state)=>state.domIncluded);
|
|
54
|
+
const setDomIncluded = (0, store_js_namespaceObject.useEnvConfig)((state)=>state.setDomIncluded);
|
|
55
|
+
if (!enableTracking && !showDeepThinkOption && !showDataExtractionOptions) return null;
|
|
52
56
|
const configItems = buildConfigItems();
|
|
53
57
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
54
58
|
className: "selector-trigger",
|
|
@@ -85,6 +89,54 @@ const ConfigSelector = (param)=>{
|
|
|
85
89
|
}),
|
|
86
90
|
key: 'deep-think-config'
|
|
87
91
|
});
|
|
92
|
+
if (showDataExtractionOptions && !hideDomAndScreenshotOptions) {
|
|
93
|
+
items.push({
|
|
94
|
+
label: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Checkbox, {
|
|
95
|
+
onChange: (e)=>{
|
|
96
|
+
setScreenshotIncluded(e.target.checked);
|
|
97
|
+
},
|
|
98
|
+
checked: screenshotIncluded,
|
|
99
|
+
children: external_playground_constants_js_namespaceObject.screenshotIncludedTip
|
|
100
|
+
}),
|
|
101
|
+
key: 'screenshot-included-config'
|
|
102
|
+
});
|
|
103
|
+
items.push({
|
|
104
|
+
label: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
105
|
+
style: {
|
|
106
|
+
padding: '4px 0'
|
|
107
|
+
},
|
|
108
|
+
children: [
|
|
109
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
110
|
+
style: {
|
|
111
|
+
marginBottom: '4px',
|
|
112
|
+
fontSize: '14px'
|
|
113
|
+
},
|
|
114
|
+
children: external_playground_constants_js_namespaceObject.domIncludedTip
|
|
115
|
+
}),
|
|
116
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_antd_namespaceObject.Radio.Group, {
|
|
117
|
+
size: "small",
|
|
118
|
+
value: domIncluded,
|
|
119
|
+
onChange: (e)=>setDomIncluded(e.target.value),
|
|
120
|
+
children: [
|
|
121
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Radio, {
|
|
122
|
+
value: false,
|
|
123
|
+
children: "Off"
|
|
124
|
+
}),
|
|
125
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Radio, {
|
|
126
|
+
value: true,
|
|
127
|
+
children: "All"
|
|
128
|
+
}),
|
|
129
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Radio, {
|
|
130
|
+
value: 'visible-only',
|
|
131
|
+
children: "Visible only"
|
|
132
|
+
})
|
|
133
|
+
]
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
}),
|
|
137
|
+
key: 'dom-included-config'
|
|
138
|
+
});
|
|
139
|
+
}
|
|
88
140
|
return items;
|
|
89
141
|
}
|
|
90
142
|
};
|
|
@@ -50,12 +50,13 @@ const external_types_js_namespaceObject = require("./types.js");
|
|
|
50
50
|
require("./index.css");
|
|
51
51
|
const { TextArea } = external_antd_namespaceObject.Input;
|
|
52
52
|
const PromptInput = (param)=>{
|
|
53
|
-
let { runButtonEnabled, form, serviceMode, selectedType, dryMode, stoppable, loading, onRun, onStop, clearPromptAfterRun = true, actionSpace } = param;
|
|
53
|
+
let { runButtonEnabled, form, serviceMode, selectedType, dryMode, stoppable, loading, onRun, onStop, clearPromptAfterRun = true, actionSpace, hideDomAndScreenshotOptions = false } = param;
|
|
54
54
|
const [hoveringSettings, setHoveringSettings] = (0, external_react_namespaceObject.useState)(false);
|
|
55
55
|
const [promptValue, setPromptValue] = (0, external_react_namespaceObject.useState)('');
|
|
56
56
|
const placeholder = (0, external_playground_utils_js_namespaceObject.getPlaceholderForType)(selectedType);
|
|
57
57
|
const textAreaRef = (0, external_react_namespaceObject.useRef)(null);
|
|
58
58
|
const params = external_antd_namespaceObject.Form.useWatch('params', form);
|
|
59
|
+
const lastHistoryRef = (0, external_react_namespaceObject.useRef)(null);
|
|
59
60
|
const history = (0, history_js_namespaceObject.useHistoryStore)((state)=>state.history);
|
|
60
61
|
const lastSelectedType = (0, history_js_namespaceObject.useHistoryStore)((state)=>state.lastSelectedType);
|
|
61
62
|
const addHistory = (0, history_js_namespaceObject.useHistoryStore)((state)=>state.addHistory);
|
|
@@ -67,13 +68,28 @@ const PromptInput = (param)=>{
|
|
|
67
68
|
const needsStructuredParams = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
68
69
|
if (actionSpace) {
|
|
69
70
|
const action = actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
|
|
70
|
-
return null == action ? void 0 : action.paramSchema;
|
|
71
|
+
return !!(null == action ? void 0 : action.paramSchema);
|
|
71
72
|
}
|
|
73
|
+
return false;
|
|
72
74
|
}, [
|
|
73
75
|
selectedType,
|
|
74
76
|
actionSpace
|
|
75
77
|
]);
|
|
78
|
+
const showDataExtractionOptions = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
79
|
+
const dataExtractionMethods = [
|
|
80
|
+
'aiQuery',
|
|
81
|
+
'aiBoolean',
|
|
82
|
+
'aiNumber',
|
|
83
|
+
'aiString',
|
|
84
|
+
'aiAsk',
|
|
85
|
+
'aiAssert'
|
|
86
|
+
];
|
|
87
|
+
return dataExtractionMethods.includes(selectedType);
|
|
88
|
+
}, [
|
|
89
|
+
selectedType
|
|
90
|
+
]);
|
|
76
91
|
const showDeepThinkOption = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
92
|
+
if ('aiLocate' === selectedType) return true;
|
|
77
93
|
if (actionSpace) {
|
|
78
94
|
const action = actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
|
|
79
95
|
if ((null == action ? void 0 : action.paramSchema) && (0, external_types_js_namespaceObject.isZodObjectSchema)(action.paramSchema)) {
|
|
@@ -84,15 +100,8 @@ const PromptInput = (param)=>{
|
|
|
84
100
|
return (0, external_types_js_namespaceObject.isLocateField)(actualField);
|
|
85
101
|
});
|
|
86
102
|
}
|
|
87
|
-
return false;
|
|
88
103
|
}
|
|
89
|
-
return
|
|
90
|
-
'aiTap',
|
|
91
|
-
'aiHover',
|
|
92
|
-
'aiInput',
|
|
93
|
-
'aiRightClick',
|
|
94
|
-
'aiLocate'
|
|
95
|
-
].includes(selectedType);
|
|
104
|
+
return false;
|
|
96
105
|
}, [
|
|
97
106
|
selectedType,
|
|
98
107
|
actionSpace
|
|
@@ -131,6 +140,7 @@ const PromptInput = (param)=>{
|
|
|
131
140
|
]);
|
|
132
141
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
133
142
|
const lastHistory = historyForSelectedType[0];
|
|
143
|
+
if (lastHistory && lastHistoryRef.current && lastHistory.timestamp === lastHistoryRef.current.timestamp) return;
|
|
134
144
|
if (lastHistory) {
|
|
135
145
|
form.setFieldsValue({
|
|
136
146
|
type: lastHistory.type,
|
|
@@ -138,6 +148,7 @@ const PromptInput = (param)=>{
|
|
|
138
148
|
params: lastHistory.params
|
|
139
149
|
});
|
|
140
150
|
setPromptValue(lastHistory.prompt || '');
|
|
151
|
+
lastHistoryRef.current = lastHistory;
|
|
141
152
|
} else {
|
|
142
153
|
const defaultParams = getDefaultParams();
|
|
143
154
|
form.setFieldsValue({
|
|
@@ -145,6 +156,7 @@ const PromptInput = (param)=>{
|
|
|
145
156
|
params: defaultParams
|
|
146
157
|
});
|
|
147
158
|
setPromptValue('');
|
|
159
|
+
lastHistoryRef.current = null;
|
|
148
160
|
}
|
|
149
161
|
}, [
|
|
150
162
|
selectedType,
|
|
@@ -152,6 +164,13 @@ const PromptInput = (param)=>{
|
|
|
152
164
|
form,
|
|
153
165
|
getDefaultParams
|
|
154
166
|
]);
|
|
167
|
+
const formPromptValue = external_antd_namespaceObject.Form.useWatch('prompt', form);
|
|
168
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
169
|
+
if (formPromptValue !== promptValue) setPromptValue(formPromptValue || '');
|
|
170
|
+
}, [
|
|
171
|
+
formPromptValue,
|
|
172
|
+
promptValue
|
|
173
|
+
]);
|
|
155
174
|
const handleSelectHistory = (0, external_react_namespaceObject.useCallback)((historyItem)=>{
|
|
156
175
|
form.setFieldsValue({
|
|
157
176
|
prompt: historyItem.prompt,
|
|
@@ -165,10 +184,7 @@ const PromptInput = (param)=>{
|
|
|
165
184
|
const handlePromptChange = (0, external_react_namespaceObject.useCallback)((e)=>{
|
|
166
185
|
const value = e.target.value;
|
|
167
186
|
setPromptValue(value);
|
|
168
|
-
|
|
169
|
-
}, [
|
|
170
|
-
form
|
|
171
|
-
]);
|
|
187
|
+
}, []);
|
|
172
188
|
const hasSingleStructuredParam = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
173
189
|
if (!needsStructuredParams || !actionSpace) return false;
|
|
174
190
|
const action = actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
|
|
@@ -213,14 +229,16 @@ const PromptInput = (param)=>{
|
|
|
213
229
|
historyPrompt = locateValue ? `${mainPart} | ${locateValue}` : mainPart;
|
|
214
230
|
} else historyPrompt = values.prompt || '';
|
|
215
231
|
} else historyPrompt = values.prompt || '';
|
|
216
|
-
|
|
232
|
+
const newHistoryItem = {
|
|
217
233
|
type: values.type,
|
|
218
234
|
prompt: historyPrompt,
|
|
219
235
|
params: values.params,
|
|
220
236
|
timestamp: Date.now()
|
|
221
|
-
}
|
|
237
|
+
};
|
|
238
|
+
addHistory(newHistoryItem);
|
|
222
239
|
onRun();
|
|
223
240
|
if (clearPromptAfterRun) {
|
|
241
|
+
lastHistoryRef.current = newHistoryItem;
|
|
224
242
|
setPromptValue('');
|
|
225
243
|
if (needsStructuredParams) {
|
|
226
244
|
const defaultParams = getDefaultParams();
|
|
@@ -521,7 +539,9 @@ const PromptInput = (param)=>{
|
|
|
521
539
|
onMouseLeave: handleMouseLeave,
|
|
522
540
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ConfigSelector_js_namespaceObject.ConfigSelector, {
|
|
523
541
|
enableTracking: 'In-Browser-Extension' === serviceMode,
|
|
524
|
-
showDeepThinkOption: showDeepThinkOption
|
|
542
|
+
showDeepThinkOption: showDeepThinkOption,
|
|
543
|
+
showDataExtractionOptions: showDataExtractionOptions,
|
|
544
|
+
hideDomAndScreenshotOptions: hideDomAndScreenshotOptions
|
|
525
545
|
})
|
|
526
546
|
})
|
|
527
547
|
]
|
|
@@ -547,7 +567,6 @@ const PromptInput = (param)=>{
|
|
|
547
567
|
autoFocus: true,
|
|
548
568
|
onKeyDown: handleKeyDown,
|
|
549
569
|
onChange: handlePromptChange,
|
|
550
|
-
value: promptValue,
|
|
551
570
|
ref: textAreaRef
|
|
552
571
|
})
|
|
553
572
|
}),
|
|
@@ -33,12 +33,14 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
|
|
36
|
+
screenshotIncludedTip: ()=>screenshotIncludedTip,
|
|
37
37
|
errorMessageServerNotReady: ()=>errorMessageServerNotReady,
|
|
38
38
|
serverLaunchTip: ()=>serverLaunchTip,
|
|
39
39
|
defaultMainButtons: ()=>defaultMainButtons,
|
|
40
|
-
|
|
40
|
+
apiMetadata: ()=>apiMetadata,
|
|
41
41
|
trackingTip: ()=>trackingTip,
|
|
42
|
+
deepThinkTip: ()=>deepThinkTip,
|
|
43
|
+
domIncludedTip: ()=>domIncludedTip,
|
|
42
44
|
emptyResultTip: ()=>emptyResultTip
|
|
43
45
|
});
|
|
44
46
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
@@ -86,6 +88,8 @@ const emptyResultTip = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div",
|
|
|
86
88
|
});
|
|
87
89
|
const trackingTip = 'limit popup to current tab';
|
|
88
90
|
const deepThinkTip = 'deep think';
|
|
91
|
+
const screenshotIncludedTip = 'include screenshot in request';
|
|
92
|
+
const domIncludedTip = 'include DOM info in request';
|
|
89
93
|
const apiMetadata = {
|
|
90
94
|
aiAction: {
|
|
91
95
|
group: 'interaction',
|
|
@@ -157,16 +161,20 @@ const defaultMainButtons = [
|
|
|
157
161
|
exports.apiMetadata = __webpack_exports__.apiMetadata;
|
|
158
162
|
exports.deepThinkTip = __webpack_exports__.deepThinkTip;
|
|
159
163
|
exports.defaultMainButtons = __webpack_exports__.defaultMainButtons;
|
|
164
|
+
exports.domIncludedTip = __webpack_exports__.domIncludedTip;
|
|
160
165
|
exports.emptyResultTip = __webpack_exports__.emptyResultTip;
|
|
161
166
|
exports.errorMessageServerNotReady = __webpack_exports__.errorMessageServerNotReady;
|
|
167
|
+
exports.screenshotIncludedTip = __webpack_exports__.screenshotIncludedTip;
|
|
162
168
|
exports.serverLaunchTip = __webpack_exports__.serverLaunchTip;
|
|
163
169
|
exports.trackingTip = __webpack_exports__.trackingTip;
|
|
164
170
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
165
171
|
"apiMetadata",
|
|
166
172
|
"deepThinkTip",
|
|
167
173
|
"defaultMainButtons",
|
|
174
|
+
"domIncludedTip",
|
|
168
175
|
"emptyResultTip",
|
|
169
176
|
"errorMessageServerNotReady",
|
|
177
|
+
"screenshotIncludedTip",
|
|
170
178
|
"serverLaunchTip",
|
|
171
179
|
"trackingTip"
|
|
172
180
|
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
@@ -50,7 +50,7 @@ const checkServerStatus = async ()=>{
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
const requestPlaygroundServer = async function(context, type, prompt) {
|
|
53
|
-
let { requestId, deepThink } = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {};
|
|
53
|
+
let { requestId, deepThink, screenshotIncluded, domIncluded } = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {};
|
|
54
54
|
const payload = {
|
|
55
55
|
context,
|
|
56
56
|
type,
|
|
@@ -58,6 +58,8 @@ const requestPlaygroundServer = async function(context, type, prompt) {
|
|
|
58
58
|
};
|
|
59
59
|
if (requestId) payload.requestId = requestId;
|
|
60
60
|
if (deepThink) payload.deepThink = deepThink;
|
|
61
|
+
if (void 0 !== screenshotIncluded) payload.screenshotIncluded = screenshotIncluded;
|
|
62
|
+
if (void 0 !== domIncluded) payload.domIncluded = domIncluded;
|
|
61
63
|
const res = await fetch(`${serverBase}/execute`, {
|
|
62
64
|
method: 'POST',
|
|
63
65
|
headers: {
|
|
@@ -64,6 +64,8 @@ const CONFIG_KEY = 'midscene-env-config';
|
|
|
64
64
|
const SERVICE_MODE_KEY = 'midscene-service-mode';
|
|
65
65
|
const TRACKING_ACTIVE_TAB_KEY = 'midscene-tracking-active-tab';
|
|
66
66
|
const DEEP_THINK_KEY = 'midscene-deep-think';
|
|
67
|
+
const SCREENSHOT_INCLUDED_KEY = 'midscene-screenshot-included';
|
|
68
|
+
const DOM_INCLUDED_KEY = 'midscene-dom-included';
|
|
67
69
|
const getConfigStringFromLocalStorage = ()=>{
|
|
68
70
|
const configString = localStorage.getItem(CONFIG_KEY);
|
|
69
71
|
return configString || '';
|
|
@@ -92,6 +94,8 @@ const useEnvConfig = create((set, get)=>{
|
|
|
92
94
|
const savedServiceMode = localStorage.getItem(SERVICE_MODE_KEY);
|
|
93
95
|
const savedForceSameTabNavigation = 'false' !== localStorage.getItem(TRACKING_ACTIVE_TAB_KEY);
|
|
94
96
|
const savedDeepThink = 'true' === localStorage.getItem(DEEP_THINK_KEY);
|
|
97
|
+
const savedScreenshotIncluded = 'false' !== localStorage.getItem(SCREENSHOT_INCLUDED_KEY);
|
|
98
|
+
const savedDomIncluded = localStorage.getItem(DOM_INCLUDED_KEY) || 'false';
|
|
95
99
|
return {
|
|
96
100
|
serviceMode: ifInExtension ? 'In-Browser-Extension' : savedServiceMode || 'Server',
|
|
97
101
|
setServiceMode: (serviceMode)=>{
|
|
@@ -136,6 +140,20 @@ const useEnvConfig = create((set, get)=>{
|
|
|
136
140
|
});
|
|
137
141
|
localStorage.setItem(DEEP_THINK_KEY, deepThink.toString());
|
|
138
142
|
},
|
|
143
|
+
screenshotIncluded: savedScreenshotIncluded,
|
|
144
|
+
setScreenshotIncluded: (screenshotIncluded)=>{
|
|
145
|
+
set({
|
|
146
|
+
screenshotIncluded
|
|
147
|
+
});
|
|
148
|
+
localStorage.setItem(SCREENSHOT_INCLUDED_KEY, screenshotIncluded.toString());
|
|
149
|
+
},
|
|
150
|
+
domIncluded: 'visible-only' === savedDomIncluded ? 'visible-only' : 'true' === savedDomIncluded,
|
|
151
|
+
setDomIncluded: (domIncluded)=>{
|
|
152
|
+
set({
|
|
153
|
+
domIncluded
|
|
154
|
+
});
|
|
155
|
+
localStorage.setItem(DOM_INCLUDED_KEY, domIncluded.toString());
|
|
156
|
+
},
|
|
139
157
|
popupTab: 'playground',
|
|
140
158
|
setPopupTab: (tab)=>{
|
|
141
159
|
set({
|
|
@@ -3,6 +3,8 @@ import './index.less';
|
|
|
3
3
|
interface ConfigSelectorProps {
|
|
4
4
|
showDeepThinkOption: boolean;
|
|
5
5
|
enableTracking: boolean;
|
|
6
|
+
showDataExtractionOptions: boolean;
|
|
7
|
+
hideDomAndScreenshotOptions?: boolean;
|
|
6
8
|
}
|
|
7
9
|
export declare const ConfigSelector: React.FC<ConfigSelectorProps>;
|
|
8
10
|
export {};
|
|
@@ -5,6 +5,8 @@ export declare const serverLaunchTip: (notReadyMessage?: React.ReactNode | strin
|
|
|
5
5
|
export declare const emptyResultTip: React.JSX.Element;
|
|
6
6
|
export declare const trackingTip = "limit popup to current tab";
|
|
7
7
|
export declare const deepThinkTip = "deep think";
|
|
8
|
+
export declare const screenshotIncludedTip = "include screenshot in request";
|
|
9
|
+
export declare const domIncludedTip = "include DOM info in request";
|
|
8
10
|
export declare const apiMetadata: {
|
|
9
11
|
aiAction: {
|
|
10
12
|
group: string;
|
|
@@ -3,9 +3,11 @@ import type { WebUIContext } from '@midscene/web';
|
|
|
3
3
|
import { StaticPageAgent } from '@midscene/web/playground';
|
|
4
4
|
export declare const serverBase = "http://localhost:5800";
|
|
5
5
|
export declare const checkServerStatus: () => Promise<boolean>;
|
|
6
|
-
export declare const requestPlaygroundServer: (context: UIContext | string, type: string, prompt: string, { requestId, deepThink, }?: {
|
|
6
|
+
export declare const requestPlaygroundServer: (context: UIContext | string, type: string, prompt: string, { requestId, deepThink, screenshotIncluded, domIncluded, }?: {
|
|
7
7
|
requestId?: string;
|
|
8
8
|
deepThink?: boolean;
|
|
9
|
+
screenshotIncluded?: boolean;
|
|
10
|
+
domIncluded?: boolean | "visible-only";
|
|
9
11
|
}) => Promise<any>;
|
|
10
12
|
export declare const overrideServerConfig: (aiConfig: any) => Promise<Response>;
|
|
11
13
|
export declare const cancelTask: (requestId: string) => Promise<any>;
|
|
@@ -27,6 +27,10 @@ export declare const useEnvConfig: Z.UseBoundStore<Z.StoreApi<{
|
|
|
27
27
|
setForceSameTabNavigation: (forceSameTabNavigation: boolean) => void;
|
|
28
28
|
deepThink: boolean;
|
|
29
29
|
setDeepThink: (deepThink: boolean) => void;
|
|
30
|
+
screenshotIncluded: boolean;
|
|
31
|
+
setScreenshotIncluded: (screenshotIncluded: boolean) => void;
|
|
32
|
+
domIncluded: boolean | "visible-only";
|
|
33
|
+
setDomIncluded: (domIncluded: boolean | "visible-only") => void;
|
|
30
34
|
popupTab: "playground" | "bridge" | "recorder";
|
|
31
35
|
setPopupTab: (tab: "playground" | "bridge" | "recorder") => void;
|
|
32
36
|
}>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/visualizer",
|
|
3
|
-
"version": "0.27.5-beta-
|
|
3
|
+
"version": "0.27.5-beta-20250827160628.0",
|
|
4
4
|
"repository": "https://github.com/web-infra-dev/midscene",
|
|
5
5
|
"homepage": "https://midscenejs.com/",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"antd": "^5.21.6",
|
|
71
71
|
"buffer": "6.0.3",
|
|
72
72
|
"dayjs": "^1.11.11",
|
|
73
|
-
"@midscene/
|
|
74
|
-
"@midscene/
|
|
75
|
-
"@midscene/web": "0.27.5-beta-
|
|
73
|
+
"@midscene/shared": "0.27.5-beta-20250827160628.0",
|
|
74
|
+
"@midscene/core": "0.27.5-beta-20250827160628.0",
|
|
75
|
+
"@midscene/web": "0.27.5-beta-20250827160628.0"
|
|
76
76
|
},
|
|
77
77
|
"license": "MIT",
|
|
78
78
|
"scripts": {
|