@midscene/visualizer 0.27.7-beta-20250905091950.0 → 0.27.7-beta-20250908084857.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/FormField.mjs +41 -2
- package/dist/es/component/playground/PromptInput.mjs +38 -21
- package/dist/es/component/playground/ServiceModeControl.mjs +7 -2
- package/dist/es/component/playground/playground-utils.mjs +2 -94
- package/dist/es/component/playground/types.mjs +8 -7
- package/dist/es/component/playground/useServerValid.mjs +5 -2
- package/dist/es/index.mjs +2 -3
- package/dist/lib/component/playground/FormField.js +44 -2
- package/dist/lib/component/playground/PromptInput.js +37 -20
- package/dist/lib/component/playground/ServiceModeControl.js +7 -2
- package/dist/lib/component/playground/playground-utils.js +5 -124
- package/dist/lib/component/playground/types.js +8 -7
- package/dist/lib/component/playground/useServerValid.js +5 -2
- package/dist/lib/index.js +10 -41
- package/dist/types/component/playground/FormField.d.ts +1 -0
- package/dist/types/component/playground/playground-utils.d.ts +2 -22
- package/dist/types/component/playground/types.d.ts +15 -1
- package/dist/types/index.d.ts +1 -2
- package/package.json +5 -4
- package/dist/es/component/playground/playground-execution.mjs +0 -112
- package/dist/lib/component/playground/playground-execution.js +0 -152
- package/dist/types/component/playground/playground-execution.d.ts +0 -5
|
@@ -24,103 +24,13 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
formatErrorMessage: ()=>formatErrorMessage,
|
|
29
|
-
serverBase: ()=>serverBase,
|
|
27
|
+
staticAgentFromContext: ()=>staticAgentFromContext,
|
|
30
28
|
actionNameForType: ()=>actionNameForType,
|
|
31
29
|
isRunButtonEnabled: ()=>isRunButtonEnabled,
|
|
32
|
-
getPlaceholderForType: ()=>getPlaceholderForType
|
|
33
|
-
cancelTask: ()=>cancelTask,
|
|
34
|
-
requestPlaygroundServer: ()=>requestPlaygroundServer,
|
|
35
|
-
staticAgentFromContext: ()=>staticAgentFromContext,
|
|
36
|
-
checkServerStatus: ()=>checkServerStatus,
|
|
37
|
-
getActionSpace: ()=>getActionSpace,
|
|
38
|
-
overrideServerConfig: ()=>overrideServerConfig,
|
|
39
|
-
getTaskProgress: ()=>getTaskProgress
|
|
30
|
+
getPlaceholderForType: ()=>getPlaceholderForType
|
|
40
31
|
});
|
|
41
|
-
const
|
|
42
|
-
const constants_namespaceObject = require("@midscene/shared/constants");
|
|
32
|
+
const static_namespaceObject = require("@midscene/web/static");
|
|
43
33
|
const external_types_js_namespaceObject = require("./types.js");
|
|
44
|
-
const serverBase = `http://localhost:${constants_namespaceObject.PLAYGROUND_SERVER_PORT}`;
|
|
45
|
-
const checkServerStatus = async ()=>{
|
|
46
|
-
try {
|
|
47
|
-
const res = await fetch(`${serverBase}/status`);
|
|
48
|
-
return 200 === res.status;
|
|
49
|
-
} catch (e) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const requestPlaygroundServer = async function(context, type, prompt) {
|
|
54
|
-
let { requestId, deepThink, params, screenshotIncluded, domIncluded } = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {};
|
|
55
|
-
const payload = {
|
|
56
|
-
context,
|
|
57
|
-
type,
|
|
58
|
-
prompt
|
|
59
|
-
};
|
|
60
|
-
if (requestId) payload.requestId = requestId;
|
|
61
|
-
if (deepThink) payload.deepThink = deepThink;
|
|
62
|
-
if (void 0 !== screenshotIncluded) payload.screenshotIncluded = screenshotIncluded;
|
|
63
|
-
if (void 0 !== domIncluded) payload.domIncluded = domIncluded;
|
|
64
|
-
if (params) payload.params = params;
|
|
65
|
-
const res = await fetch(`${serverBase}/execute`, {
|
|
66
|
-
method: 'POST',
|
|
67
|
-
headers: {
|
|
68
|
-
'Content-Type': 'application/json'
|
|
69
|
-
},
|
|
70
|
-
body: JSON.stringify(payload)
|
|
71
|
-
});
|
|
72
|
-
return res.json();
|
|
73
|
-
};
|
|
74
|
-
const overrideServerConfig = async (aiConfig)=>fetch(`${serverBase}/config`, {
|
|
75
|
-
method: 'POST',
|
|
76
|
-
headers: {
|
|
77
|
-
'Content-Type': 'application/json'
|
|
78
|
-
},
|
|
79
|
-
body: JSON.stringify({
|
|
80
|
-
aiConfig
|
|
81
|
-
})
|
|
82
|
-
});
|
|
83
|
-
const cancelTask = async (requestId)=>{
|
|
84
|
-
try {
|
|
85
|
-
const res = await fetch(`${serverBase}/cancel/${requestId}`);
|
|
86
|
-
return res.json();
|
|
87
|
-
} catch (error) {
|
|
88
|
-
console.error('Failed to cancel task:', error);
|
|
89
|
-
return {
|
|
90
|
-
error: 'Failed to cancel task'
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
const getTaskProgress = async (requestId)=>{
|
|
95
|
-
try {
|
|
96
|
-
const response = await fetch(`${serverBase}/task-progress/${requestId}`);
|
|
97
|
-
return await response.json();
|
|
98
|
-
} catch (error) {
|
|
99
|
-
console.error('Failed to poll task progress:', error);
|
|
100
|
-
return {
|
|
101
|
-
tip: null
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
const getActionSpace = async (context)=>{
|
|
106
|
-
try {
|
|
107
|
-
if (!context) return [];
|
|
108
|
-
const response = await fetch(`${serverBase}/action-space`, {
|
|
109
|
-
method: 'POST',
|
|
110
|
-
headers: {
|
|
111
|
-
'Content-Type': 'application/json'
|
|
112
|
-
},
|
|
113
|
-
body: JSON.stringify({
|
|
114
|
-
context
|
|
115
|
-
})
|
|
116
|
-
});
|
|
117
|
-
if (response.ok) return await response.json();
|
|
118
|
-
return [];
|
|
119
|
-
} catch (error) {
|
|
120
|
-
console.error('Failed to get action space:', error);
|
|
121
|
-
return [];
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
34
|
const actionNameForType = (type)=>{
|
|
125
35
|
const typeWithoutAi = type.startsWith('ai') ? type.slice(2) : type;
|
|
126
36
|
const fullName = typeWithoutAi.replace(/([A-Z])/g, ' $1').trim();
|
|
@@ -129,13 +39,8 @@ const actionNameForType = (type)=>{
|
|
|
129
39
|
return fullName;
|
|
130
40
|
};
|
|
131
41
|
const staticAgentFromContext = (context)=>{
|
|
132
|
-
const page = new
|
|
133
|
-
return new
|
|
134
|
-
};
|
|
135
|
-
const formatErrorMessage = (e)=>{
|
|
136
|
-
const errorMessage = (null == e ? void 0 : e.message) || '';
|
|
137
|
-
if (errorMessage.includes('of different extension')) return 'Conflicting extension detected. Please disable the suspicious plugins and refresh the page. Guide: https://midscenejs.com/quick-experience.html#faq';
|
|
138
|
-
return errorMessage || 'Unknown error';
|
|
42
|
+
const page = new static_namespaceObject.StaticPage(context);
|
|
43
|
+
return new static_namespaceObject.StaticPageAgent(page);
|
|
139
44
|
};
|
|
140
45
|
const getPlaceholderForType = (type)=>{
|
|
141
46
|
if ('aiQuery' === type) return 'What do you want to query?';
|
|
@@ -155,12 +60,6 @@ const getPlaceholderForType = (type)=>{
|
|
|
155
60
|
if ('aiWaitFor' === type) return 'What condition do you want to wait for?';
|
|
156
61
|
return 'What do you want to do?';
|
|
157
62
|
};
|
|
158
|
-
const blankResult = {
|
|
159
|
-
result: null,
|
|
160
|
-
dump: null,
|
|
161
|
-
reportHTML: null,
|
|
162
|
-
error: null
|
|
163
|
-
};
|
|
164
63
|
const isRunButtonEnabled = (runButtonEnabled, needsStructuredParams, params, actionSpace, selectedType, promptValue)=>{
|
|
165
64
|
if (!runButtonEnabled) return false;
|
|
166
65
|
const needsAnyInput = (()=>{
|
|
@@ -196,31 +95,13 @@ const isRunButtonEnabled = (runButtonEnabled, needsStructuredParams, params, act
|
|
|
196
95
|
return promptValue.trim().length > 0;
|
|
197
96
|
};
|
|
198
97
|
exports.actionNameForType = __webpack_exports__.actionNameForType;
|
|
199
|
-
exports.blankResult = __webpack_exports__.blankResult;
|
|
200
|
-
exports.cancelTask = __webpack_exports__.cancelTask;
|
|
201
|
-
exports.checkServerStatus = __webpack_exports__.checkServerStatus;
|
|
202
|
-
exports.formatErrorMessage = __webpack_exports__.formatErrorMessage;
|
|
203
|
-
exports.getActionSpace = __webpack_exports__.getActionSpace;
|
|
204
98
|
exports.getPlaceholderForType = __webpack_exports__.getPlaceholderForType;
|
|
205
|
-
exports.getTaskProgress = __webpack_exports__.getTaskProgress;
|
|
206
99
|
exports.isRunButtonEnabled = __webpack_exports__.isRunButtonEnabled;
|
|
207
|
-
exports.overrideServerConfig = __webpack_exports__.overrideServerConfig;
|
|
208
|
-
exports.requestPlaygroundServer = __webpack_exports__.requestPlaygroundServer;
|
|
209
|
-
exports.serverBase = __webpack_exports__.serverBase;
|
|
210
100
|
exports.staticAgentFromContext = __webpack_exports__.staticAgentFromContext;
|
|
211
101
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
212
102
|
"actionNameForType",
|
|
213
|
-
"blankResult",
|
|
214
|
-
"cancelTask",
|
|
215
|
-
"checkServerStatus",
|
|
216
|
-
"formatErrorMessage",
|
|
217
|
-
"getActionSpace",
|
|
218
103
|
"getPlaceholderForType",
|
|
219
|
-
"getTaskProgress",
|
|
220
104
|
"isRunButtonEnabled",
|
|
221
|
-
"overrideServerConfig",
|
|
222
|
-
"requestPlaygroundServer",
|
|
223
|
-
"serverBase",
|
|
224
105
|
"staticAgentFromContext"
|
|
225
106
|
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
226
107
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -38,7 +38,8 @@ const VALIDATION_CONSTANTS = {
|
|
|
38
38
|
OBJECT: 'ZodObject',
|
|
39
39
|
ENUM: 'ZodEnum',
|
|
40
40
|
NUMBER: 'ZodNumber',
|
|
41
|
-
STRING: 'ZodString'
|
|
41
|
+
STRING: 'ZodString',
|
|
42
|
+
BOOLEAN: 'ZodBoolean'
|
|
42
43
|
},
|
|
43
44
|
FIELD_FLAGS: {
|
|
44
45
|
LOCATION: 'midscene_location_field_flag'
|
|
@@ -52,24 +53,24 @@ const VALIDATION_CONSTANTS = {
|
|
|
52
53
|
const isZodObjectSchema = (schema)=>'object' == typeof schema && null !== schema && ('shape' in schema || 'ZodObject' === schema.type);
|
|
53
54
|
const isLocateField = (field)=>{
|
|
54
55
|
var _field__def;
|
|
55
|
-
const
|
|
56
|
+
const fieldWithRuntime = field;
|
|
56
57
|
if ((null == (_field__def = field._def) ? void 0 : _field__def.typeName) === VALIDATION_CONSTANTS.ZOD_TYPES.OBJECT) {
|
|
57
58
|
var _field__def1;
|
|
58
59
|
let shape;
|
|
59
60
|
if (field._def.shape) shape = 'function' == typeof field._def.shape ? field._def.shape() : field._def.shape;
|
|
60
|
-
if (!shape &&
|
|
61
|
+
if (!shape && fieldWithRuntime.shape) shape = fieldWithRuntime.shape;
|
|
61
62
|
if (shape && VALIDATION_CONSTANTS.FIELD_FLAGS.LOCATION in shape) return true;
|
|
62
|
-
const description = (null == (_field__def1 = field._def) ? void 0 : _field__def1.description) ||
|
|
63
|
+
const description = (null == (_field__def1 = field._def) ? void 0 : _field__def1.description) || fieldWithRuntime.description || '';
|
|
63
64
|
if ('string' == typeof description && description.toLowerCase().includes('input field')) return true;
|
|
64
65
|
}
|
|
65
66
|
if ('object' == typeof field && null !== field) {
|
|
66
|
-
var
|
|
67
|
-
const description =
|
|
67
|
+
var _fieldWithRuntime__def;
|
|
68
|
+
const description = fieldWithRuntime.description || (null == (_fieldWithRuntime__def = fieldWithRuntime._def) ? void 0 : _fieldWithRuntime__def.description) || '';
|
|
68
69
|
if ('string' == typeof description) {
|
|
69
70
|
const desc = description.toLowerCase();
|
|
70
71
|
if (desc.includes('input field') || desc.includes('element') || desc.includes('locate')) return true;
|
|
71
72
|
}
|
|
72
|
-
if ('ZodObject' ===
|
|
73
|
+
if ('ZodObject' === fieldWithRuntime.typeName || 'ZodObject' === fieldWithRuntime.type) return 'string' == typeof description && description.toLowerCase().includes('input field');
|
|
73
74
|
}
|
|
74
75
|
return false;
|
|
75
76
|
};
|
|
@@ -26,9 +26,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
useServerValid: ()=>useServerValid
|
|
28
28
|
});
|
|
29
|
+
const playground_namespaceObject = require("@midscene/playground");
|
|
29
30
|
const external_react_namespaceObject = require("react");
|
|
30
31
|
const store_js_namespaceObject = require("../store/store.js");
|
|
31
|
-
const external_playground_utils_js_namespaceObject = require("./playground-utils.js");
|
|
32
32
|
const useServerValid = function() {
|
|
33
33
|
let shouldRun = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : true;
|
|
34
34
|
const [serverValid, setServerValid] = (0, external_react_namespaceObject.useState)(true);
|
|
@@ -38,7 +38,10 @@ const useServerValid = function() {
|
|
|
38
38
|
if (!shouldRun) return;
|
|
39
39
|
Promise.resolve((async ()=>{
|
|
40
40
|
while(!interruptFlag){
|
|
41
|
-
const
|
|
41
|
+
const playgroundSDK = new playground_namespaceObject.PlaygroundSDK({
|
|
42
|
+
type: 'remote-execution'
|
|
43
|
+
});
|
|
44
|
+
const status = await playgroundSDK.checkStatus();
|
|
42
45
|
status ? setServerValid(true) : setServerValid(false);
|
|
43
46
|
await new Promise((resolve)=>setTimeout(resolve, 1000));
|
|
44
47
|
}
|
package/dist/lib/index.js
CHANGED
|
@@ -39,34 +39,24 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
39
39
|
timeStr: ()=>external_utils_js_namespaceObject.timeStr,
|
|
40
40
|
EnvConfig: ()=>env_config_js_namespaceObject.EnvConfig,
|
|
41
41
|
allScriptsFromDump: ()=>replay_scripts_js_namespaceObject.allScriptsFromDump,
|
|
42
|
-
|
|
42
|
+
PromptInput: ()=>PromptInput_js_namespaceObject.PromptInput,
|
|
43
|
+
ContextPreview: ()=>ContextPreview_js_namespaceObject.ContextPreview,
|
|
43
44
|
generateAnimationScripts: ()=>replay_scripts_js_namespaceObject.generateAnimationScripts,
|
|
44
|
-
getPlaceholderForType: ()=>playground_utils_js_namespaceObject.getPlaceholderForType,
|
|
45
45
|
ShinyText: ()=>shiny_text_js_default(),
|
|
46
|
-
|
|
46
|
+
Blackboard: ()=>blackboard_js_namespaceObject.Blackboard,
|
|
47
|
+
getPlaceholderForType: ()=>playground_utils_js_namespaceObject.getPlaceholderForType,
|
|
47
48
|
staticAgentFromContext: ()=>playground_utils_js_namespaceObject.staticAgentFromContext,
|
|
49
|
+
useEnvConfig: ()=>store_js_namespaceObject.useEnvConfig,
|
|
48
50
|
useServerValid: ()=>useServerValid_js_namespaceObject.useServerValid,
|
|
51
|
+
Player: ()=>player_js_namespaceObject.Player,
|
|
49
52
|
ServiceModeControl: ()=>ServiceModeControl_js_namespaceObject.ServiceModeControl,
|
|
53
|
+
filterBase64Value: ()=>external_utils_js_namespaceObject.filterBase64Value,
|
|
50
54
|
colorForName: ()=>color_js_namespaceObject.colorForName,
|
|
51
|
-
validateStructuredParams: ()=>playground_execution_js_namespaceObject.validateStructuredParams,
|
|
52
55
|
GithubStar: ()=>github_star_js_namespaceObject.GithubStar,
|
|
53
56
|
Logo: ()=>logo_js_namespaceObject.Logo,
|
|
54
|
-
checkServerStatus: ()=>playground_utils_js_namespaceObject.checkServerStatus,
|
|
55
|
-
blankResult: ()=>playground_utils_js_namespaceObject.blankResult,
|
|
56
|
-
useEnvConfig: ()=>store_js_namespaceObject.useEnvConfig,
|
|
57
|
-
executeAction: ()=>playground_execution_js_namespaceObject.executeAction,
|
|
58
|
-
PromptInput: ()=>PromptInput_js_namespaceObject.PromptInput,
|
|
59
|
-
ContextPreview: ()=>ContextPreview_js_namespaceObject.ContextPreview,
|
|
60
|
-
requestPlaygroundServer: ()=>playground_utils_js_namespaceObject.requestPlaygroundServer,
|
|
61
|
-
Blackboard: ()=>blackboard_js_namespaceObject.Blackboard,
|
|
62
|
-
overrideServerConfig: ()=>playground_utils_js_namespaceObject.overrideServerConfig,
|
|
63
|
-
formatErrorMessage: ()=>playground_execution_js_namespaceObject.formatErrorMessage,
|
|
64
|
-
Player: ()=>player_js_namespaceObject.Player,
|
|
65
|
-
filterBase64Value: ()=>external_utils_js_namespaceObject.filterBase64Value,
|
|
66
|
-
highlightColorForType: ()=>color_js_namespaceObject.highlightColorForType,
|
|
67
|
-
iconForStatus: ()=>misc_js_namespaceObject.iconForStatus,
|
|
68
57
|
globalThemeConfig: ()=>color_js_namespaceObject.globalThemeConfig,
|
|
69
|
-
|
|
58
|
+
highlightColorForType: ()=>color_js_namespaceObject.highlightColorForType,
|
|
59
|
+
iconForStatus: ()=>misc_js_namespaceObject.iconForStatus
|
|
70
60
|
});
|
|
71
61
|
require("./component/playground/index.css");
|
|
72
62
|
const replay_scripts_js_namespaceObject = require("./component/replay-scripts.js");
|
|
@@ -84,7 +74,6 @@ const player_js_namespaceObject = require("./component/player.js");
|
|
|
84
74
|
const blackboard_js_namespaceObject = require("./component/blackboard.js");
|
|
85
75
|
const github_star_js_namespaceObject = require("./component/github-star.js");
|
|
86
76
|
const playground_utils_js_namespaceObject = require("./component/playground/playground-utils.js");
|
|
87
|
-
const playground_execution_js_namespaceObject = require("./component/playground/playground-execution.js");
|
|
88
77
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
89
78
|
const shiny_text_js_namespaceObject = require("./component/shiny-text.js");
|
|
90
79
|
var shiny_text_js_default = /*#__PURE__*/ __webpack_require__.n(shiny_text_js_namespaceObject);
|
|
@@ -100,28 +89,18 @@ exports.ServiceModeControl = __webpack_exports__.ServiceModeControl;
|
|
|
100
89
|
exports.ShinyText = __webpack_exports__.ShinyText;
|
|
101
90
|
exports.actionNameForType = __webpack_exports__.actionNameForType;
|
|
102
91
|
exports.allScriptsFromDump = __webpack_exports__.allScriptsFromDump;
|
|
103
|
-
exports.blankResult = __webpack_exports__.blankResult;
|
|
104
|
-
exports.cancelTask = __webpack_exports__.cancelTask;
|
|
105
|
-
exports.checkServerStatus = __webpack_exports__.checkServerStatus;
|
|
106
92
|
exports.colorForName = __webpack_exports__.colorForName;
|
|
107
|
-
exports.executeAction = __webpack_exports__.executeAction;
|
|
108
93
|
exports.filterBase64Value = __webpack_exports__.filterBase64Value;
|
|
109
|
-
exports.formatErrorMessage = __webpack_exports__.formatErrorMessage;
|
|
110
94
|
exports.generateAnimationScripts = __webpack_exports__.generateAnimationScripts;
|
|
111
|
-
exports.getActionSpace = __webpack_exports__.getActionSpace;
|
|
112
95
|
exports.getPlaceholderForType = __webpack_exports__.getPlaceholderForType;
|
|
113
|
-
exports.getTaskProgress = __webpack_exports__.getTaskProgress;
|
|
114
96
|
exports.globalThemeConfig = __webpack_exports__.globalThemeConfig;
|
|
115
97
|
exports.highlightColorForType = __webpack_exports__.highlightColorForType;
|
|
116
98
|
exports.iconForStatus = __webpack_exports__.iconForStatus;
|
|
117
|
-
exports.overrideServerConfig = __webpack_exports__.overrideServerConfig;
|
|
118
|
-
exports.requestPlaygroundServer = __webpack_exports__.requestPlaygroundServer;
|
|
119
99
|
exports.staticAgentFromContext = __webpack_exports__.staticAgentFromContext;
|
|
120
100
|
exports.timeCostStrElement = __webpack_exports__.timeCostStrElement;
|
|
121
101
|
exports.timeStr = __webpack_exports__.timeStr;
|
|
122
102
|
exports.useEnvConfig = __webpack_exports__.useEnvConfig;
|
|
123
103
|
exports.useServerValid = __webpack_exports__.useServerValid;
|
|
124
|
-
exports.validateStructuredParams = __webpack_exports__.validateStructuredParams;
|
|
125
104
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
126
105
|
"Blackboard",
|
|
127
106
|
"ContextPreview",
|
|
@@ -135,28 +114,18 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
|
135
114
|
"ShinyText",
|
|
136
115
|
"actionNameForType",
|
|
137
116
|
"allScriptsFromDump",
|
|
138
|
-
"blankResult",
|
|
139
|
-
"cancelTask",
|
|
140
|
-
"checkServerStatus",
|
|
141
117
|
"colorForName",
|
|
142
|
-
"executeAction",
|
|
143
118
|
"filterBase64Value",
|
|
144
|
-
"formatErrorMessage",
|
|
145
119
|
"generateAnimationScripts",
|
|
146
|
-
"getActionSpace",
|
|
147
120
|
"getPlaceholderForType",
|
|
148
|
-
"getTaskProgress",
|
|
149
121
|
"globalThemeConfig",
|
|
150
122
|
"highlightColorForType",
|
|
151
123
|
"iconForStatus",
|
|
152
|
-
"overrideServerConfig",
|
|
153
|
-
"requestPlaygroundServer",
|
|
154
124
|
"staticAgentFromContext",
|
|
155
125
|
"timeCostStrElement",
|
|
156
126
|
"timeStr",
|
|
157
127
|
"useEnvConfig",
|
|
158
|
-
"useServerValid"
|
|
159
|
-
"validateStructuredParams"
|
|
128
|
+
"useServerValid"
|
|
160
129
|
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
161
130
|
Object.defineProperty(exports, '__esModule', {
|
|
162
131
|
value: true
|
|
@@ -13,4 +13,5 @@ export declare const TextField: React.FC<Omit<FormFieldProps, 'isLocateField'>>;
|
|
|
13
13
|
export declare const LocateField: React.FC<Omit<FormFieldProps, 'isLocateField'>>;
|
|
14
14
|
export declare const EnumField: React.FC<Omit<FormFieldProps, 'isLocateField'>>;
|
|
15
15
|
export declare const NumberField: React.FC<Omit<FormFieldProps, 'isLocateField'>>;
|
|
16
|
+
export declare const BooleanField: React.FC<Omit<FormFieldProps, 'isLocateField'>>;
|
|
16
17
|
export {};
|
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { StaticPageAgent } from '@midscene/
|
|
3
|
-
export declare const serverBase = "http://localhost:5800";
|
|
4
|
-
export declare const checkServerStatus: () => Promise<boolean>;
|
|
5
|
-
export declare const requestPlaygroundServer: (context: UIContext | string, type: string, prompt: string, { requestId, deepThink, params, screenshotIncluded, domIncluded, }?: {
|
|
6
|
-
requestId?: string;
|
|
7
|
-
deepThink?: boolean;
|
|
8
|
-
params?: any;
|
|
9
|
-
screenshotIncluded?: boolean;
|
|
10
|
-
domIncluded?: boolean | "visible-only";
|
|
11
|
-
}) => Promise<any>;
|
|
12
|
-
export declare const overrideServerConfig: (aiConfig: any) => Promise<Response>;
|
|
13
|
-
export declare const cancelTask: (requestId: string) => Promise<any>;
|
|
14
|
-
export declare const getTaskProgress: (requestId: string) => Promise<any>;
|
|
15
|
-
export declare const getActionSpace: (context?: string) => Promise<any>;
|
|
1
|
+
import type { WebUIContext } from '@midscene/core';
|
|
2
|
+
import { StaticPageAgent } from '@midscene/web/static';
|
|
16
3
|
export declare const actionNameForType: (type: string) => string;
|
|
17
4
|
export declare const staticAgentFromContext: (context: WebUIContext) => StaticPageAgent;
|
|
18
|
-
export declare const formatErrorMessage: (e: any) => string;
|
|
19
5
|
export declare const getPlaceholderForType: (type: string) => string;
|
|
20
|
-
export declare const blankResult: {
|
|
21
|
-
result: null;
|
|
22
|
-
dump: null;
|
|
23
|
-
reportHTML: null;
|
|
24
|
-
error: null;
|
|
25
|
-
};
|
|
26
6
|
export declare const isRunButtonEnabled: (runButtonEnabled: boolean, needsStructuredParams: boolean, params: any, actionSpace: any[] | undefined, selectedType: string, promptValue: string) => boolean;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { DeviceAction } from '@midscene/core';
|
|
2
2
|
export interface ZodType {
|
|
3
3
|
_def?: {
|
|
4
|
-
typeName: 'ZodOptional' | 'ZodDefault' | 'ZodNullable' | 'ZodObject' | 'ZodEnum' | 'ZodNumber' | 'ZodString';
|
|
4
|
+
typeName: 'ZodOptional' | 'ZodDefault' | 'ZodNullable' | 'ZodObject' | 'ZodEnum' | 'ZodNumber' | 'ZodString' | 'ZodBoolean';
|
|
5
5
|
innerType?: ZodType;
|
|
6
6
|
defaultValue?: () => unknown;
|
|
7
7
|
shape?: () => Record<string, ZodType>;
|
|
8
8
|
values?: string[];
|
|
9
|
+
description?: string;
|
|
9
10
|
};
|
|
11
|
+
description?: string;
|
|
10
12
|
}
|
|
11
13
|
export interface ZodObjectSchema extends ZodType {
|
|
12
14
|
shape: Record<string, ZodType>;
|
|
@@ -23,6 +25,17 @@ export interface ZodNumberSchema extends ZodType {
|
|
|
23
25
|
typeName: 'ZodNumber';
|
|
24
26
|
};
|
|
25
27
|
}
|
|
28
|
+
export interface ZodBooleanSchema extends ZodType {
|
|
29
|
+
_def: {
|
|
30
|
+
typeName: 'ZodBoolean';
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface ZodRuntimeAccess extends ZodType {
|
|
34
|
+
shape?: Record<string, ZodType>;
|
|
35
|
+
description?: string;
|
|
36
|
+
typeName?: string;
|
|
37
|
+
type?: string;
|
|
38
|
+
}
|
|
26
39
|
export interface ActionSpaceItem extends Omit<DeviceAction<any>, 'paramSchema'> {
|
|
27
40
|
paramSchema?: ZodObjectSchema;
|
|
28
41
|
}
|
|
@@ -38,6 +51,7 @@ export declare const VALIDATION_CONSTANTS: {
|
|
|
38
51
|
readonly ENUM: "ZodEnum";
|
|
39
52
|
readonly NUMBER: "ZodNumber";
|
|
40
53
|
readonly STRING: "ZodString";
|
|
54
|
+
readonly BOOLEAN: "ZodBoolean";
|
|
41
55
|
};
|
|
42
56
|
readonly FIELD_FLAGS: {
|
|
43
57
|
readonly LOCATION: "midscene_location_field_flag";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ export { PromptInput } from './component/playground/PromptInput';
|
|
|
14
14
|
export { Player } from './component/player';
|
|
15
15
|
export { Blackboard } from './component/blackboard';
|
|
16
16
|
export { GithubStar } from './component/github-star';
|
|
17
|
-
export {
|
|
18
|
-
export { executeAction, validateStructuredParams, formatErrorMessage, } from './component/playground/playground-execution';
|
|
17
|
+
export { actionNameForType, staticAgentFromContext, getPlaceholderForType, } from './component/playground/playground-utils';
|
|
19
18
|
export { timeStr, filterBase64Value } from './utils';
|
|
20
19
|
export { default as ShinyText } from './component/shiny-text';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/visualizer",
|
|
3
|
-
"version": "0.27.7-beta-
|
|
3
|
+
"version": "0.27.7-beta-20250908084857.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,10 @@
|
|
|
70
70
|
"antd": "^5.21.6",
|
|
71
71
|
"buffer": "6.0.3",
|
|
72
72
|
"dayjs": "^1.11.11",
|
|
73
|
-
"@midscene/
|
|
74
|
-
"@midscene/
|
|
75
|
-
"@midscene/
|
|
73
|
+
"@midscene/playground": "0.27.7-beta-20250908084857.0",
|
|
74
|
+
"@midscene/core": "0.27.7-beta-20250908084857.0",
|
|
75
|
+
"@midscene/shared": "0.27.7-beta-20250908084857.0",
|
|
76
|
+
"@midscene/web": "0.27.7-beta-20250908084857.0"
|
|
76
77
|
},
|
|
77
78
|
"license": "MIT",
|
|
78
79
|
"scripts": {
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { findAllMidsceneLocatorField } from "@midscene/core/ai-model";
|
|
2
|
-
const formatErrorMessage = (e)=>{
|
|
3
|
-
const errorMessage = (null == e ? void 0 : e.message) || '';
|
|
4
|
-
if (errorMessage.includes('of different extension')) return 'Conflicting extension detected. Please disable the suspicious plugins and refresh the page. Guide: https://midscenejs.com/quick-experience.html#faq';
|
|
5
|
-
return errorMessage || 'Unknown error';
|
|
6
|
-
};
|
|
7
|
-
async function parseStructuredParams(action, params) {
|
|
8
|
-
let options = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
|
|
9
|
-
if (!(null == action ? void 0 : action.paramSchema) || !('shape' in action.paramSchema)) return [
|
|
10
|
-
params.prompt || '',
|
|
11
|
-
options
|
|
12
|
-
];
|
|
13
|
-
const schema = action.paramSchema;
|
|
14
|
-
const keys = Object.keys(schema.shape);
|
|
15
|
-
const paramObj = {
|
|
16
|
-
...options
|
|
17
|
-
};
|
|
18
|
-
keys.forEach((key)=>{
|
|
19
|
-
if (void 0 !== params[key] && null !== params[key] && '' !== params[key]) paramObj[key] = params[key];
|
|
20
|
-
});
|
|
21
|
-
return [
|
|
22
|
-
paramObj
|
|
23
|
-
];
|
|
24
|
-
}
|
|
25
|
-
function validateStructuredParams(value, action) {
|
|
26
|
-
if (!value.params) return {
|
|
27
|
-
valid: false,
|
|
28
|
-
errorMessage: 'Parameters are required'
|
|
29
|
-
};
|
|
30
|
-
if (!(null == action ? void 0 : action.paramSchema)) return {
|
|
31
|
-
valid: true
|
|
32
|
-
};
|
|
33
|
-
try {
|
|
34
|
-
var _action_paramSchema;
|
|
35
|
-
const paramsForValidation = {
|
|
36
|
-
...value.params
|
|
37
|
-
};
|
|
38
|
-
const schema = action.paramSchema;
|
|
39
|
-
if (schema) {
|
|
40
|
-
const locatorFieldKeys = findAllMidsceneLocatorField(schema);
|
|
41
|
-
locatorFieldKeys.forEach((key)=>{
|
|
42
|
-
if ('string' == typeof paramsForValidation[key]) paramsForValidation[key] = {
|
|
43
|
-
midscene_location_field_flag: true,
|
|
44
|
-
prompt: paramsForValidation[key],
|
|
45
|
-
center: [
|
|
46
|
-
0,
|
|
47
|
-
0
|
|
48
|
-
],
|
|
49
|
-
rect: {
|
|
50
|
-
left: 0,
|
|
51
|
-
top: 0,
|
|
52
|
-
width: 0,
|
|
53
|
-
height: 0
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
null == (_action_paramSchema = action.paramSchema) || _action_paramSchema.parse(paramsForValidation);
|
|
59
|
-
} catch (error) {
|
|
60
|
-
const zodError = error;
|
|
61
|
-
if (zodError.errors && zodError.errors.length > 0) {
|
|
62
|
-
const errorMessages = zodError.errors.filter((err)=>{
|
|
63
|
-
const path = err.path.join('.');
|
|
64
|
-
return !path.includes('center') && !path.includes('rect') && !path.includes('midscene_location_field_flag');
|
|
65
|
-
}).map((err)=>{
|
|
66
|
-
const field = err.path.join('.');
|
|
67
|
-
return `${field}: ${err.message}`;
|
|
68
|
-
});
|
|
69
|
-
if (errorMessages.length > 0) return {
|
|
70
|
-
valid: false,
|
|
71
|
-
errorMessage: `Validation error: ${errorMessages.join(', ')}`
|
|
72
|
-
};
|
|
73
|
-
} else {
|
|
74
|
-
const errorMsg = error instanceof Error ? error.message : 'Unknown validation error';
|
|
75
|
-
return {
|
|
76
|
-
valid: false,
|
|
77
|
-
errorMessage: `Parameter validation failed: ${errorMsg}`
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
valid: true
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
async function executeAction(activeAgent, actionType, actionSpace, value, options) {
|
|
86
|
-
const action = null == actionSpace ? void 0 : actionSpace.find((a)=>a.interfaceAlias === actionType || a.name === actionType);
|
|
87
|
-
if (action && 'function' == typeof activeAgent.callActionInActionSpace) if (!value.params) return await activeAgent.callActionInActionSpace(action.name, {
|
|
88
|
-
prompt: value.prompt,
|
|
89
|
-
...options
|
|
90
|
-
});
|
|
91
|
-
else {
|
|
92
|
-
const parsedParams = await parseStructuredParams(action, value.params, options);
|
|
93
|
-
return await activeAgent.callActionInActionSpace(action.name, parsedParams[0]);
|
|
94
|
-
}
|
|
95
|
-
{
|
|
96
|
-
const prompt = value.prompt;
|
|
97
|
-
if ('aiAssert' === actionType) {
|
|
98
|
-
var _activeAgent_aiAssert;
|
|
99
|
-
const { pass, thought } = await (null == activeAgent ? void 0 : null == (_activeAgent_aiAssert = activeAgent.aiAssert) ? void 0 : _activeAgent_aiAssert.call(activeAgent, prompt || '', void 0, {
|
|
100
|
-
keepRawResponse: true,
|
|
101
|
-
...options
|
|
102
|
-
})) || {};
|
|
103
|
-
return {
|
|
104
|
-
pass: pass || false,
|
|
105
|
-
thought: thought || ''
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
if (activeAgent && 'function' == typeof activeAgent[actionType]) return await activeAgent[actionType](prompt, options);
|
|
109
|
-
throw new Error(`Unknown action type: ${actionType}`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
export { executeAction, formatErrorMessage, validateStructuredParams };
|