@midscene/visualizer 0.27.7-beta-20250905094830.0 → 0.27.7-beta-20250908085836.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
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
formatErrorMessage: ()=>formatErrorMessage,
|
|
28
|
-
validateStructuredParams: ()=>validateStructuredParams,
|
|
29
|
-
executeAction: ()=>executeAction
|
|
30
|
-
});
|
|
31
|
-
const ai_model_namespaceObject = require("@midscene/core/ai-model");
|
|
32
|
-
const formatErrorMessage = (e)=>{
|
|
33
|
-
const errorMessage = (null == e ? void 0 : e.message) || '';
|
|
34
|
-
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';
|
|
35
|
-
return errorMessage || 'Unknown error';
|
|
36
|
-
};
|
|
37
|
-
async function parseStructuredParams(action, params) {
|
|
38
|
-
let options = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
|
|
39
|
-
if (!(null == action ? void 0 : action.paramSchema) || !('shape' in action.paramSchema)) return [
|
|
40
|
-
params.prompt || '',
|
|
41
|
-
options
|
|
42
|
-
];
|
|
43
|
-
const schema = action.paramSchema;
|
|
44
|
-
const keys = Object.keys(schema.shape);
|
|
45
|
-
const paramObj = {
|
|
46
|
-
...options
|
|
47
|
-
};
|
|
48
|
-
keys.forEach((key)=>{
|
|
49
|
-
if (void 0 !== params[key] && null !== params[key] && '' !== params[key]) paramObj[key] = params[key];
|
|
50
|
-
});
|
|
51
|
-
return [
|
|
52
|
-
paramObj
|
|
53
|
-
];
|
|
54
|
-
}
|
|
55
|
-
function validateStructuredParams(value, action) {
|
|
56
|
-
if (!value.params) return {
|
|
57
|
-
valid: false,
|
|
58
|
-
errorMessage: 'Parameters are required'
|
|
59
|
-
};
|
|
60
|
-
if (!(null == action ? void 0 : action.paramSchema)) return {
|
|
61
|
-
valid: true
|
|
62
|
-
};
|
|
63
|
-
try {
|
|
64
|
-
var _action_paramSchema;
|
|
65
|
-
const paramsForValidation = {
|
|
66
|
-
...value.params
|
|
67
|
-
};
|
|
68
|
-
const schema = action.paramSchema;
|
|
69
|
-
if (schema) {
|
|
70
|
-
const locatorFieldKeys = (0, ai_model_namespaceObject.findAllMidsceneLocatorField)(schema);
|
|
71
|
-
locatorFieldKeys.forEach((key)=>{
|
|
72
|
-
if ('string' == typeof paramsForValidation[key]) paramsForValidation[key] = {
|
|
73
|
-
midscene_location_field_flag: true,
|
|
74
|
-
prompt: paramsForValidation[key],
|
|
75
|
-
center: [
|
|
76
|
-
0,
|
|
77
|
-
0
|
|
78
|
-
],
|
|
79
|
-
rect: {
|
|
80
|
-
left: 0,
|
|
81
|
-
top: 0,
|
|
82
|
-
width: 0,
|
|
83
|
-
height: 0
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
null == (_action_paramSchema = action.paramSchema) || _action_paramSchema.parse(paramsForValidation);
|
|
89
|
-
} catch (error) {
|
|
90
|
-
const zodError = error;
|
|
91
|
-
if (zodError.errors && zodError.errors.length > 0) {
|
|
92
|
-
const errorMessages = zodError.errors.filter((err)=>{
|
|
93
|
-
const path = err.path.join('.');
|
|
94
|
-
return !path.includes('center') && !path.includes('rect') && !path.includes('midscene_location_field_flag');
|
|
95
|
-
}).map((err)=>{
|
|
96
|
-
const field = err.path.join('.');
|
|
97
|
-
return `${field}: ${err.message}`;
|
|
98
|
-
});
|
|
99
|
-
if (errorMessages.length > 0) return {
|
|
100
|
-
valid: false,
|
|
101
|
-
errorMessage: `Validation error: ${errorMessages.join(', ')}`
|
|
102
|
-
};
|
|
103
|
-
} else {
|
|
104
|
-
const errorMsg = error instanceof Error ? error.message : 'Unknown validation error';
|
|
105
|
-
return {
|
|
106
|
-
valid: false,
|
|
107
|
-
errorMessage: `Parameter validation failed: ${errorMsg}`
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return {
|
|
112
|
-
valid: true
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
async function executeAction(activeAgent, actionType, actionSpace, value, options) {
|
|
116
|
-
const action = null == actionSpace ? void 0 : actionSpace.find((a)=>a.interfaceAlias === actionType || a.name === actionType);
|
|
117
|
-
if (action && 'function' == typeof activeAgent.callActionInActionSpace) if (!value.params) return await activeAgent.callActionInActionSpace(action.name, {
|
|
118
|
-
prompt: value.prompt,
|
|
119
|
-
...options
|
|
120
|
-
});
|
|
121
|
-
else {
|
|
122
|
-
const parsedParams = await parseStructuredParams(action, value.params, options);
|
|
123
|
-
return await activeAgent.callActionInActionSpace(action.name, parsedParams[0]);
|
|
124
|
-
}
|
|
125
|
-
{
|
|
126
|
-
const prompt = value.prompt;
|
|
127
|
-
if ('aiAssert' === actionType) {
|
|
128
|
-
var _activeAgent_aiAssert;
|
|
129
|
-
const { pass, thought } = await (null == activeAgent ? void 0 : null == (_activeAgent_aiAssert = activeAgent.aiAssert) ? void 0 : _activeAgent_aiAssert.call(activeAgent, prompt || '', void 0, {
|
|
130
|
-
keepRawResponse: true,
|
|
131
|
-
...options
|
|
132
|
-
})) || {};
|
|
133
|
-
return {
|
|
134
|
-
pass: pass || false,
|
|
135
|
-
thought: thought || ''
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
if (activeAgent && 'function' == typeof activeAgent[actionType]) return await activeAgent[actionType](prompt, options);
|
|
139
|
-
throw new Error(`Unknown action type: ${actionType}`);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
exports.executeAction = __webpack_exports__.executeAction;
|
|
143
|
-
exports.formatErrorMessage = __webpack_exports__.formatErrorMessage;
|
|
144
|
-
exports.validateStructuredParams = __webpack_exports__.validateStructuredParams;
|
|
145
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
146
|
-
"executeAction",
|
|
147
|
-
"formatErrorMessage",
|
|
148
|
-
"validateStructuredParams"
|
|
149
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
150
|
-
Object.defineProperty(exports, '__esModule', {
|
|
151
|
-
value: true
|
|
152
|
-
});
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { DeviceAction } from '@midscene/core';
|
|
2
|
-
import type { ExecutionOptions, FormValue, PlaygroundAgent, ValidationResult } from '@midscene/playground';
|
|
3
|
-
export declare const formatErrorMessage: (e: any) => string;
|
|
4
|
-
export declare function validateStructuredParams(value: FormValue, action: DeviceAction<unknown> | undefined): ValidationResult;
|
|
5
|
-
export declare function executeAction(activeAgent: PlaygroundAgent, actionType: string, actionSpace: DeviceAction<unknown>[], value: FormValue, options: ExecutionOptions): Promise<unknown>;
|