@midscene/core 0.27.1-beta-20250822053848.0 → 0.27.1-beta-20250822103738.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/agent/agent.mjs +518 -0
- package/dist/es/agent/agent.mjs.map +1 -0
- package/dist/es/agent/index.mjs +6 -0
- package/dist/es/agent/task-cache.mjs +149 -0
- package/dist/es/agent/task-cache.mjs.map +1 -0
- package/dist/es/agent/tasks.mjs +767 -0
- package/dist/es/agent/tasks.mjs.map +1 -0
- package/dist/es/agent/ui-utils.mjs +89 -0
- package/dist/es/agent/ui-utils.mjs.map +1 -0
- package/dist/es/agent/utils.mjs +303 -0
- package/dist/es/agent/utils.mjs.map +1 -0
- package/dist/es/device/index.mjs +20 -0
- package/dist/es/device/index.mjs.map +1 -0
- package/dist/es/index.mjs +2 -1
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/types.mjs.map +1 -1
- package/dist/es/utils.mjs +2 -2
- package/dist/es/yaml/builder.mjs +13 -0
- package/dist/es/yaml/builder.mjs.map +1 -0
- package/dist/es/yaml/index.mjs +3 -0
- package/dist/es/yaml/player.mjs +375 -0
- package/dist/es/yaml/player.mjs.map +1 -0
- package/dist/es/yaml/utils.mjs +75 -0
- package/dist/es/yaml/utils.mjs.map +1 -0
- package/dist/lib/agent/agent.js +562 -0
- package/dist/lib/agent/agent.js.map +1 -0
- package/dist/lib/agent/index.js +84 -0
- package/dist/lib/agent/index.js.map +1 -0
- package/dist/lib/agent/task-cache.js +201 -0
- package/dist/lib/agent/task-cache.js.map +1 -0
- package/dist/lib/agent/tasks.js +804 -0
- package/dist/lib/agent/tasks.js.map +1 -0
- package/dist/lib/agent/ui-utils.js +141 -0
- package/dist/lib/agent/ui-utils.js.map +1 -0
- package/dist/lib/agent/utils.js +377 -0
- package/dist/lib/agent/utils.js.map +1 -0
- package/dist/lib/device/index.js +54 -0
- package/dist/lib/device/index.js.map +1 -0
- package/dist/lib/index.js +5 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/utils.js +2 -2
- package/dist/lib/yaml/builder.js +57 -0
- package/dist/lib/yaml/builder.js.map +1 -0
- package/dist/lib/yaml/index.js +80 -0
- package/dist/lib/yaml/index.js.map +1 -0
- package/dist/lib/yaml/player.js +409 -0
- package/dist/lib/yaml/player.js.map +1 -0
- package/dist/lib/yaml/utils.js +128 -0
- package/dist/lib/yaml/utils.js.map +1 -0
- package/dist/types/agent/agent.d.ts +123 -0
- package/dist/types/agent/index.d.ts +9 -0
- package/dist/types/agent/task-cache.d.ts +38 -0
- package/dist/types/agent/tasks.d.ts +56 -0
- package/dist/types/agent/ui-utils.d.ts +11 -0
- package/dist/types/agent/utils.d.ts +49 -0
- package/dist/types/device/index.d.ts +55 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types.d.ts +1 -0
- package/dist/types/yaml/builder.d.ts +2 -0
- package/dist/types/yaml/index.d.ts +3 -0
- package/dist/types/yaml/player.d.ts +34 -0
- package/dist/types/yaml/utils.d.ts +8 -0
- package/package.json +27 -3
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
commonContextParser: ()=>commonContextParser,
|
|
37
|
+
matchElementFromPlan: ()=>matchElementFromPlan,
|
|
38
|
+
trimContextByViewport: ()=>trimContextByViewport,
|
|
39
|
+
getReportFileName: ()=>getReportFileName,
|
|
40
|
+
matchElementFromCache: ()=>matchElementFromCache,
|
|
41
|
+
printReportMsg: ()=>printReportMsg,
|
|
42
|
+
generateCacheId: ()=>generateCacheId,
|
|
43
|
+
getMidsceneVersion: ()=>getMidsceneVersion,
|
|
44
|
+
commonWebActionsForWebPage: ()=>commonWebActionsForWebPage,
|
|
45
|
+
getCurrentExecutionFile: ()=>getCurrentExecutionFile,
|
|
46
|
+
parsePrompt: ()=>parsePrompt
|
|
47
|
+
});
|
|
48
|
+
const index_js_namespaceObject = require("../ai-model/index.js");
|
|
49
|
+
const external_index_js_namespaceObject = require("../index.js");
|
|
50
|
+
const external_utils_js_namespaceObject = require("../utils.js");
|
|
51
|
+
const env_namespaceObject = require("@midscene/shared/env");
|
|
52
|
+
const extractor_namespaceObject = require("@midscene/shared/extractor");
|
|
53
|
+
const img_namespaceObject = require("@midscene/shared/img");
|
|
54
|
+
const logger_namespaceObject = require("@midscene/shared/logger");
|
|
55
|
+
const utils_namespaceObject = require("@midscene/shared/utils");
|
|
56
|
+
const external_dayjs_namespaceObject = require("dayjs");
|
|
57
|
+
var external_dayjs_default = /*#__PURE__*/ __webpack_require__.n(external_dayjs_namespaceObject);
|
|
58
|
+
const external_task_cache_js_namespaceObject = require("./task-cache.js");
|
|
59
|
+
const external_ui_utils_js_namespaceObject = require("./ui-utils.js");
|
|
60
|
+
const debugProfile = (0, logger_namespaceObject.getDebug)('web:tool:profile');
|
|
61
|
+
(0, logger_namespaceObject.getDebug)('web:tool:utils');
|
|
62
|
+
async function commonContextParser(page) {
|
|
63
|
+
(0, utils_namespaceObject.assert)(page, 'page is required');
|
|
64
|
+
debugProfile('Getting page URL');
|
|
65
|
+
const url = await page.url();
|
|
66
|
+
debugProfile('URL end');
|
|
67
|
+
debugProfile('Uploading test info to server');
|
|
68
|
+
(0, external_utils_js_namespaceObject.uploadTestInfoToServer)({
|
|
69
|
+
testUrl: url
|
|
70
|
+
});
|
|
71
|
+
debugProfile('UploadTestInfoToServer end');
|
|
72
|
+
let screenshotBase64 = await page.screenshotBase64();
|
|
73
|
+
(0, utils_namespaceObject.assert)(screenshotBase64, 'screenshotBase64 is required');
|
|
74
|
+
const size = await page.size();
|
|
75
|
+
debugProfile(`size: ${size.width}x${size.height} dpr: ${size.dpr}`);
|
|
76
|
+
if (size.dpr && size.dpr > 1) {
|
|
77
|
+
debugProfile('Resizing screenshot for high DPR display');
|
|
78
|
+
screenshotBase64 = await (0, img_namespaceObject.resizeImgBase64)(screenshotBase64, {
|
|
79
|
+
width: size.width,
|
|
80
|
+
height: size.height
|
|
81
|
+
});
|
|
82
|
+
debugProfile('ResizeImgBase64 end');
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
tree: {
|
|
86
|
+
node: null,
|
|
87
|
+
children: []
|
|
88
|
+
},
|
|
89
|
+
size,
|
|
90
|
+
screenshotBase64: screenshotBase64,
|
|
91
|
+
url
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function getReportFileName(tag = 'web') {
|
|
95
|
+
const reportTagName = (0, env_namespaceObject.getAIConfig)(env_namespaceObject.MIDSCENE_REPORT_TAG_NAME);
|
|
96
|
+
const dateTimeInFileName = external_dayjs_default()().format('YYYY-MM-DD_HH-mm-ss');
|
|
97
|
+
const uniqueId = (0, utils_namespaceObject.uuid)().substring(0, 8);
|
|
98
|
+
return `${reportTagName || tag}-${dateTimeInFileName}-${uniqueId}`;
|
|
99
|
+
}
|
|
100
|
+
function printReportMsg(filepath) {
|
|
101
|
+
(0, utils_namespaceObject.logMsg)(`Midscene - report file updated: ${filepath}`);
|
|
102
|
+
}
|
|
103
|
+
function getCurrentExecutionFile(trace) {
|
|
104
|
+
const error = new Error();
|
|
105
|
+
const stackTrace = trace || error.stack;
|
|
106
|
+
const pkgDir = process.cwd() || '';
|
|
107
|
+
if (stackTrace) {
|
|
108
|
+
const stackLines = stackTrace.split('\n');
|
|
109
|
+
for (const line of stackLines)if (line.includes('.spec.') || line.includes('.test.') || line.includes('.ts') || line.includes('.js')) {
|
|
110
|
+
const match = line.match(/(?:at\s+)?(.*?\.(?:spec|test)\.[jt]s)/);
|
|
111
|
+
if (null == match ? void 0 : match[1]) {
|
|
112
|
+
const targetFileName = match[1].replace(pkgDir, '').trim().replace('at ', '');
|
|
113
|
+
return targetFileName;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
const testFileIndex = new Map();
|
|
120
|
+
function generateCacheId(fileName) {
|
|
121
|
+
let taskFile = fileName || getCurrentExecutionFile();
|
|
122
|
+
if (!taskFile) {
|
|
123
|
+
taskFile = (0, utils_namespaceObject.uuid)();
|
|
124
|
+
console.warn('Midscene - using random UUID for cache id. Cache may be invalid.');
|
|
125
|
+
}
|
|
126
|
+
if (testFileIndex.has(taskFile)) {
|
|
127
|
+
const currentIndex = testFileIndex.get(taskFile);
|
|
128
|
+
if (void 0 !== currentIndex) testFileIndex.set(taskFile, currentIndex + 1);
|
|
129
|
+
} else testFileIndex.set(taskFile, 1);
|
|
130
|
+
return `${taskFile}-${testFileIndex.get(taskFile)}`;
|
|
131
|
+
}
|
|
132
|
+
function matchElementFromPlan(planLocateParam, tree) {
|
|
133
|
+
if (!planLocateParam) return;
|
|
134
|
+
if (planLocateParam.id) return (0, extractor_namespaceObject.getNodeFromCacheList)(planLocateParam.id);
|
|
135
|
+
if (planLocateParam.bbox) {
|
|
136
|
+
const centerPosition = {
|
|
137
|
+
x: Math.floor((planLocateParam.bbox[0] + planLocateParam.bbox[2]) / 2),
|
|
138
|
+
y: Math.floor((planLocateParam.bbox[1] + planLocateParam.bbox[3]) / 2)
|
|
139
|
+
};
|
|
140
|
+
let element = (0, index_js_namespaceObject.elementByPositionWithElementInfo)(tree, centerPosition);
|
|
141
|
+
if (!element) element = (0, extractor_namespaceObject.generateElementByPosition)(centerPosition);
|
|
142
|
+
return element;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async function matchElementFromCache(taskExecutor, xpaths, cachePrompt, cacheable) {
|
|
146
|
+
try {
|
|
147
|
+
var _taskExecutor_taskCache;
|
|
148
|
+
if ((null == xpaths ? void 0 : xpaths.length) && (null == (_taskExecutor_taskCache = taskExecutor.taskCache) ? void 0 : _taskExecutor_taskCache.isCacheResultUsed) && false !== cacheable && taskExecutor.page.getElementInfoByXpath) for(let i = 0; i < xpaths.length; i++){
|
|
149
|
+
const element = await taskExecutor.page.getElementInfoByXpath(xpaths[i]);
|
|
150
|
+
if (null == element ? void 0 : element.id) {
|
|
151
|
+
(0, external_task_cache_js_namespaceObject.debug)('cache hit, prompt: %s', cachePrompt);
|
|
152
|
+
(0, external_task_cache_js_namespaceObject.debug)('found a new element with same xpath, xpath: %s, id: %s', xpaths[i], null == element ? void 0 : element.id);
|
|
153
|
+
return element;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
} catch (error) {
|
|
157
|
+
(0, external_task_cache_js_namespaceObject.debug)('get element info by xpath error: ', error);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function trimContextByViewport(execution) {
|
|
161
|
+
function filterVisibleTree(node) {
|
|
162
|
+
if (!node) return null;
|
|
163
|
+
const filteredChildren = Array.isArray(node.children) ? node.children.map(filterVisibleTree).filter((child)=>null !== child) : [];
|
|
164
|
+
if (node.node && true === node.node.isVisible) return {
|
|
165
|
+
...node,
|
|
166
|
+
children: filteredChildren
|
|
167
|
+
};
|
|
168
|
+
if (filteredChildren.length > 0) return {
|
|
169
|
+
node: null,
|
|
170
|
+
children: filteredChildren
|
|
171
|
+
};
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
...execution,
|
|
176
|
+
tasks: Array.isArray(execution.tasks) ? execution.tasks.map((task)=>{
|
|
177
|
+
var _task_pageContext;
|
|
178
|
+
const newTask = {
|
|
179
|
+
...task
|
|
180
|
+
};
|
|
181
|
+
if (null == (_task_pageContext = task.pageContext) ? void 0 : _task_pageContext.tree) newTask.pageContext = {
|
|
182
|
+
...task.pageContext,
|
|
183
|
+
tree: filterVisibleTree(task.pageContext.tree) || {
|
|
184
|
+
node: null,
|
|
185
|
+
children: []
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
return newTask;
|
|
189
|
+
}) : execution.tasks
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
const getMidsceneVersion = ()=>"0.27.1-beta-20250822103738.0";
|
|
193
|
+
const parsePrompt = (prompt)=>{
|
|
194
|
+
if ('string' == typeof prompt) return {
|
|
195
|
+
textPrompt: prompt,
|
|
196
|
+
multimodalPrompt: void 0
|
|
197
|
+
};
|
|
198
|
+
return {
|
|
199
|
+
textPrompt: prompt.prompt,
|
|
200
|
+
multimodalPrompt: prompt.images ? {
|
|
201
|
+
images: prompt.images,
|
|
202
|
+
convertHttpImage2Base64: !!prompt.convertHttpImage2Base64
|
|
203
|
+
} : void 0
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
const commonWebActionsForWebPage = (page)=>[
|
|
207
|
+
{
|
|
208
|
+
name: 'Tap',
|
|
209
|
+
description: 'Tap the element',
|
|
210
|
+
interfaceAlias: 'aiTap',
|
|
211
|
+
paramSchema: external_index_js_namespaceObject.z.object({
|
|
212
|
+
locate: (0, external_index_js_namespaceObject.getMidsceneLocationSchema)().describe('The element to be tapped')
|
|
213
|
+
}),
|
|
214
|
+
call: async (param)=>{
|
|
215
|
+
const element = param.locate;
|
|
216
|
+
(0, utils_namespaceObject.assert)(element, 'Element not found, cannot tap');
|
|
217
|
+
await page.mouse.click(element.center[0], element.center[1], {
|
|
218
|
+
button: 'left'
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: 'RightClick',
|
|
224
|
+
description: 'Right click the element',
|
|
225
|
+
interfaceAlias: 'aiRightClick',
|
|
226
|
+
paramSchema: external_index_js_namespaceObject.z.object({
|
|
227
|
+
locate: (0, external_index_js_namespaceObject.getMidsceneLocationSchema)().describe('The element to be right clicked')
|
|
228
|
+
}),
|
|
229
|
+
call: async (param)=>{
|
|
230
|
+
const element = param.locate;
|
|
231
|
+
(0, utils_namespaceObject.assert)(element, 'Element not found, cannot right click');
|
|
232
|
+
await page.mouse.click(element.center[0], element.center[1], {
|
|
233
|
+
button: 'right'
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: 'Hover',
|
|
239
|
+
description: 'Move the mouse to the element',
|
|
240
|
+
interfaceAlias: 'aiHover',
|
|
241
|
+
paramSchema: external_index_js_namespaceObject.z.object({
|
|
242
|
+
locate: (0, external_index_js_namespaceObject.getMidsceneLocationSchema)().describe('The element to be hovered')
|
|
243
|
+
}),
|
|
244
|
+
call: async (param)=>{
|
|
245
|
+
const element = param.locate;
|
|
246
|
+
(0, utils_namespaceObject.assert)(element, 'Element not found, cannot hover');
|
|
247
|
+
await page.mouse.move(element.center[0], element.center[1]);
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
name: 'Input',
|
|
252
|
+
description: 'Replace the input field with a new value. `value` is the final that should be filled in the input box. No matter what modifications are required, just provide the final value to replace the existing input value. Giving a blank string means clear the input field.',
|
|
253
|
+
interfaceAlias: 'aiInput',
|
|
254
|
+
paramSchema: external_index_js_namespaceObject.z.object({
|
|
255
|
+
value: external_index_js_namespaceObject.z.string().describe('The final value that should be filled in the input box'),
|
|
256
|
+
locate: (0, external_index_js_namespaceObject.getMidsceneLocationSchema)().describe('The input field to be filled').optional()
|
|
257
|
+
}),
|
|
258
|
+
call: async (param)=>{
|
|
259
|
+
const element = param.locate;
|
|
260
|
+
if (element) {
|
|
261
|
+
await page.clearInput(element);
|
|
262
|
+
if (!param || !param.value) return;
|
|
263
|
+
}
|
|
264
|
+
await page.keyboard.type(param.value);
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: 'KeyboardPress',
|
|
269
|
+
description: 'Press a function key, like "Enter", "Tab", "Escape". Do not use this to type text.',
|
|
270
|
+
interfaceAlias: 'aiKeyboardPress',
|
|
271
|
+
paramSchema: external_index_js_namespaceObject.z.object({
|
|
272
|
+
locate: (0, external_index_js_namespaceObject.getMidsceneLocationSchema)().describe('The element to be clicked before pressing the key').optional(),
|
|
273
|
+
keyName: external_index_js_namespaceObject.z.string().describe('The key to be pressed')
|
|
274
|
+
}),
|
|
275
|
+
call: async (param)=>{
|
|
276
|
+
const element = param.locate;
|
|
277
|
+
if (element) await page.mouse.click(element.center[0], element.center[1], {
|
|
278
|
+
button: 'left'
|
|
279
|
+
});
|
|
280
|
+
const keys = (0, external_ui_utils_js_namespaceObject.getKeyCommands)(param.keyName);
|
|
281
|
+
await page.keyboard.press(keys);
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
name: 'Scroll',
|
|
286
|
+
description: 'Scroll the page or an element. The direction to scroll, the scroll type, and the distance to scroll. The distance is the number of pixels to scroll. If not specified, use `down` direction, `once` scroll type, and `null` distance.',
|
|
287
|
+
interfaceAlias: 'aiScroll',
|
|
288
|
+
paramSchema: external_index_js_namespaceObject.z.object({
|
|
289
|
+
direction: external_index_js_namespaceObject.z["enum"]([
|
|
290
|
+
'down',
|
|
291
|
+
'up',
|
|
292
|
+
'right',
|
|
293
|
+
'left'
|
|
294
|
+
]).default('down').describe('The direction to scroll'),
|
|
295
|
+
scrollType: external_index_js_namespaceObject.z["enum"]([
|
|
296
|
+
'once',
|
|
297
|
+
'untilBottom',
|
|
298
|
+
'untilTop',
|
|
299
|
+
'untilRight',
|
|
300
|
+
'untilLeft'
|
|
301
|
+
]).default('once').describe('The scroll type'),
|
|
302
|
+
distance: external_index_js_namespaceObject.z.number().nullable().optional().describe('The distance in pixels to scroll'),
|
|
303
|
+
locate: (0, external_index_js_namespaceObject.getMidsceneLocationSchema)().optional().describe('The element to be scrolled')
|
|
304
|
+
}),
|
|
305
|
+
call: async (param)=>{
|
|
306
|
+
const element = param.locate;
|
|
307
|
+
const startingPoint = element ? {
|
|
308
|
+
left: element.center[0],
|
|
309
|
+
top: element.center[1]
|
|
310
|
+
} : void 0;
|
|
311
|
+
const scrollToEventName = null == param ? void 0 : param.scrollType;
|
|
312
|
+
if ('untilTop' === scrollToEventName) await page.scrollUntilTop(startingPoint);
|
|
313
|
+
else if ('untilBottom' === scrollToEventName) await page.scrollUntilBottom(startingPoint);
|
|
314
|
+
else if ('untilRight' === scrollToEventName) await page.scrollUntilRight(startingPoint);
|
|
315
|
+
else if ('untilLeft' === scrollToEventName) await page.scrollUntilLeft(startingPoint);
|
|
316
|
+
else if ('once' !== scrollToEventName && scrollToEventName) throw new Error(`Unknown scroll event type: ${scrollToEventName}, param: ${JSON.stringify(param)}`);
|
|
317
|
+
else {
|
|
318
|
+
if ((null == param ? void 0 : param.direction) !== 'down' && param && param.direction) if ('up' === param.direction) await page.scrollUp(param.distance || void 0, startingPoint);
|
|
319
|
+
else if ('left' === param.direction) await page.scrollLeft(param.distance || void 0, startingPoint);
|
|
320
|
+
else if ('right' === param.direction) await page.scrollRight(param.distance || void 0, startingPoint);
|
|
321
|
+
else throw new Error(`Unknown scroll direction: ${param.direction}`);
|
|
322
|
+
else await page.scrollDown((null == param ? void 0 : param.distance) || void 0, startingPoint);
|
|
323
|
+
await (0, external_utils_js_namespaceObject.sleep)(500);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: 'DragAndDrop',
|
|
329
|
+
description: 'Drag and drop the element',
|
|
330
|
+
paramSchema: external_index_js_namespaceObject.z.object({
|
|
331
|
+
from: (0, external_index_js_namespaceObject.getMidsceneLocationSchema)().describe('The position to be dragged'),
|
|
332
|
+
to: (0, external_index_js_namespaceObject.getMidsceneLocationSchema)().describe('The position to be dropped')
|
|
333
|
+
}),
|
|
334
|
+
call: async (param)=>{
|
|
335
|
+
const from = param.from;
|
|
336
|
+
const to = param.to;
|
|
337
|
+
(0, utils_namespaceObject.assert)(from, 'missing "from" param for drag and drop');
|
|
338
|
+
(0, utils_namespaceObject.assert)(to, 'missing "to" param for drag and drop');
|
|
339
|
+
await page.mouse.drag({
|
|
340
|
+
x: from.center[0],
|
|
341
|
+
y: from.center[1]
|
|
342
|
+
}, {
|
|
343
|
+
x: to.center[0],
|
|
344
|
+
y: to.center[1]
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
];
|
|
349
|
+
exports.commonContextParser = __webpack_exports__.commonContextParser;
|
|
350
|
+
exports.commonWebActionsForWebPage = __webpack_exports__.commonWebActionsForWebPage;
|
|
351
|
+
exports.generateCacheId = __webpack_exports__.generateCacheId;
|
|
352
|
+
exports.getCurrentExecutionFile = __webpack_exports__.getCurrentExecutionFile;
|
|
353
|
+
exports.getMidsceneVersion = __webpack_exports__.getMidsceneVersion;
|
|
354
|
+
exports.getReportFileName = __webpack_exports__.getReportFileName;
|
|
355
|
+
exports.matchElementFromCache = __webpack_exports__.matchElementFromCache;
|
|
356
|
+
exports.matchElementFromPlan = __webpack_exports__.matchElementFromPlan;
|
|
357
|
+
exports.parsePrompt = __webpack_exports__.parsePrompt;
|
|
358
|
+
exports.printReportMsg = __webpack_exports__.printReportMsg;
|
|
359
|
+
exports.trimContextByViewport = __webpack_exports__.trimContextByViewport;
|
|
360
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
361
|
+
"commonContextParser",
|
|
362
|
+
"commonWebActionsForWebPage",
|
|
363
|
+
"generateCacheId",
|
|
364
|
+
"getCurrentExecutionFile",
|
|
365
|
+
"getMidsceneVersion",
|
|
366
|
+
"getReportFileName",
|
|
367
|
+
"matchElementFromCache",
|
|
368
|
+
"matchElementFromPlan",
|
|
369
|
+
"parsePrompt",
|
|
370
|
+
"printReportMsg",
|
|
371
|
+
"trimContextByViewport"
|
|
372
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
373
|
+
Object.defineProperty(exports, '__esModule', {
|
|
374
|
+
value: true
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent/utils.js","sources":["webpack://@midscene/core/webpack/runtime/compat_get_default_export","webpack://@midscene/core/webpack/runtime/define_property_getters","webpack://@midscene/core/webpack/runtime/has_own_property","webpack://@midscene/core/webpack/runtime/make_namespace_object","webpack://@midscene/core/./src/agent/utils.ts"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { elementByPositionWithElementInfo } from '@/ai-model';\nimport type { AbstractPage } from '@/device';\nimport type {\n BaseElement,\n DetailedLocateParam,\n DeviceAction,\n ElementTreeNode,\n ExecutionDump,\n ExecutionTask,\n ExecutorContext,\n LocateOption,\n MidsceneLocationResultType,\n PlanningLocateParam,\n TMultimodalPrompt,\n TUserPrompt,\n UIContext,\n} from '@/index';\nimport { getMidsceneLocationSchema, z } from '@/index';\nimport { sleep, uploadTestInfoToServer } from '@/utils';\nimport { MIDSCENE_REPORT_TAG_NAME, getAIConfig } from '@midscene/shared/env';\nimport type { ElementInfo } from '@midscene/shared/extractor';\nimport {\n generateElementByPosition,\n getNodeFromCacheList,\n} from '@midscene/shared/extractor';\nimport { resizeImgBase64 } from '@midscene/shared/img';\nimport { getDebug } from '@midscene/shared/logger';\nimport { _keyDefinitions } from '@midscene/shared/us-keyboard-layout';\nimport { assert, logMsg, uuid } from '@midscene/shared/utils';\nimport dayjs from 'dayjs';\nimport { debug as cacheDebug } from './task-cache';\nimport type { PageTaskExecutor } from './tasks';\nimport { getKeyCommands } from './ui-utils';\n\nconst debugProfile = getDebug('web:tool:profile');\nconst debugUtils = getDebug('web:tool:utils');\n\nexport async function commonContextParser(\n page: AbstractPage,\n): Promise<UIContext> {\n assert(page, 'page is required');\n\n debugProfile('Getting page URL');\n const url = await page.url();\n debugProfile('URL end');\n\n debugProfile('Uploading test info to server');\n uploadTestInfoToServer({ testUrl: url });\n debugProfile('UploadTestInfoToServer end');\n\n let screenshotBase64 = await page.screenshotBase64();\n assert(screenshotBase64!, 'screenshotBase64 is required');\n\n const size = await page.size();\n debugProfile(`size: ${size.width}x${size.height} dpr: ${size.dpr}`);\n\n if (size.dpr && size.dpr > 1) {\n debugProfile('Resizing screenshot for high DPR display');\n screenshotBase64 = await resizeImgBase64(screenshotBase64, {\n width: size.width,\n height: size.height,\n });\n debugProfile('ResizeImgBase64 end');\n }\n\n return {\n tree: {\n node: null,\n children: [],\n },\n size,\n screenshotBase64: screenshotBase64!,\n url,\n };\n}\n\nexport function getReportFileName(tag = 'web') {\n const reportTagName = getAIConfig(MIDSCENE_REPORT_TAG_NAME);\n const dateTimeInFileName = dayjs().format('YYYY-MM-DD_HH-mm-ss');\n // ensure uniqueness at the same time\n const uniqueId = uuid().substring(0, 8);\n return `${reportTagName || tag}-${dateTimeInFileName}-${uniqueId}`;\n}\n\nexport function printReportMsg(filepath: string) {\n logMsg(`Midscene - report file updated: ${filepath}`);\n}\n\n/**\n * Get the current execution file name\n * @returns The name of the current execution file\n */\nexport function getCurrentExecutionFile(trace?: string): string | false {\n const error = new Error();\n const stackTrace = trace || error.stack;\n const pkgDir = process.cwd() || '';\n if (stackTrace) {\n const stackLines = stackTrace.split('\\n');\n for (const line of stackLines) {\n if (\n line.includes('.spec.') ||\n line.includes('.test.') ||\n line.includes('.ts') ||\n line.includes('.js')\n ) {\n const match = line.match(/(?:at\\s+)?(.*?\\.(?:spec|test)\\.[jt]s)/);\n if (match?.[1]) {\n const targetFileName = match[1]\n .replace(pkgDir, '')\n .trim()\n .replace('at ', '');\n return targetFileName;\n }\n }\n }\n }\n return false;\n}\n\nconst testFileIndex = new Map<string, number>();\n\nexport function generateCacheId(fileName?: string): string {\n let taskFile = fileName || getCurrentExecutionFile();\n if (!taskFile) {\n taskFile = uuid();\n console.warn(\n 'Midscene - using random UUID for cache id. Cache may be invalid.',\n );\n }\n\n if (testFileIndex.has(taskFile)) {\n const currentIndex = testFileIndex.get(taskFile);\n if (currentIndex !== undefined) {\n testFileIndex.set(taskFile, currentIndex + 1);\n }\n } else {\n testFileIndex.set(taskFile, 1);\n }\n return `${taskFile}-${testFileIndex.get(taskFile)}`;\n}\n\nexport function matchElementFromPlan(\n planLocateParam: PlanningLocateParam,\n tree: ElementTreeNode<BaseElement>,\n) {\n if (!planLocateParam) {\n return undefined;\n }\n if (planLocateParam.id) {\n return getNodeFromCacheList(planLocateParam.id);\n }\n\n if (planLocateParam.bbox) {\n const centerPosition = {\n x: Math.floor((planLocateParam.bbox[0] + planLocateParam.bbox[2]) / 2),\n y: Math.floor((planLocateParam.bbox[1] + planLocateParam.bbox[3]) / 2),\n };\n let element = elementByPositionWithElementInfo(tree, centerPosition);\n\n if (!element) {\n element = generateElementByPosition(centerPosition) as BaseElement;\n }\n\n return element;\n }\n\n return undefined;\n}\n\nexport async function matchElementFromCache(\n taskExecutor: PageTaskExecutor,\n xpaths: string[] | undefined,\n cachePrompt: TUserPrompt,\n cacheable: boolean | undefined,\n) {\n try {\n if (\n xpaths?.length &&\n taskExecutor.taskCache?.isCacheResultUsed &&\n cacheable !== false &&\n (taskExecutor.page as any).getElementInfoByXpath\n ) {\n // hit cache, use new id\n for (let i = 0; i < xpaths.length; i++) {\n const element = await (taskExecutor.page as any).getElementInfoByXpath(\n xpaths[i],\n );\n\n if (element?.id) {\n cacheDebug('cache hit, prompt: %s', cachePrompt);\n cacheDebug(\n 'found a new element with same xpath, xpath: %s, id: %s',\n xpaths[i],\n element?.id,\n );\n return element;\n }\n }\n }\n } catch (error) {\n cacheDebug('get element info by xpath error: ', error);\n }\n}\n\nexport function trimContextByViewport(execution: ExecutionDump) {\n function filterVisibleTree(\n node: ElementTreeNode<BaseElement>,\n ): ElementTreeNode<BaseElement> | null {\n if (!node) return null;\n\n // recursively process all children\n const filteredChildren = Array.isArray(node.children)\n ? (node.children\n .map(filterVisibleTree)\n .filter((child) => child !== null) as ElementTreeNode<BaseElement>[])\n : [];\n\n // if the current node is visible, keep it and the filtered children\n if (node.node && node.node.isVisible === true) {\n return {\n ...node,\n children: filteredChildren,\n };\n }\n\n // if the current node is invisible, but has visible children, create an empty node to include these children\n if (filteredChildren.length > 0) {\n return {\n node: null,\n children: filteredChildren,\n };\n }\n\n // if the current node is invisible and has no visible children, return null\n return null;\n }\n\n return {\n ...execution,\n tasks: Array.isArray(execution.tasks)\n ? execution.tasks.map((task: ExecutionTask) => {\n const newTask = { ...task };\n if (task.pageContext?.tree) {\n newTask.pageContext = {\n ...task.pageContext,\n tree: filterVisibleTree(task.pageContext.tree) || {\n node: null,\n children: [],\n },\n };\n }\n return newTask;\n })\n : execution.tasks,\n };\n}\n\ndeclare const __VERSION__: string | undefined;\n\nexport const getMidsceneVersion = (): string => {\n if (typeof __VERSION__ !== 'undefined') {\n return __VERSION__;\n } else if (\n process.env.__VERSION__ &&\n process.env.__VERSION__ !== 'undefined'\n ) {\n return process.env.__VERSION__;\n }\n throw new Error('__VERSION__ inject failed during build');\n};\n\nexport const parsePrompt = (\n prompt: TUserPrompt,\n): {\n textPrompt: string;\n multimodalPrompt?: TMultimodalPrompt;\n} => {\n if (typeof prompt === 'string') {\n return {\n textPrompt: prompt,\n multimodalPrompt: undefined,\n };\n }\n return {\n textPrompt: prompt.prompt,\n multimodalPrompt: prompt.images\n ? {\n images: prompt.images,\n convertHttpImage2Base64: !!prompt.convertHttpImage2Base64,\n }\n : undefined,\n };\n};\n\nexport const commonWebActionsForWebPage = <T extends AbstractPage>(\n page: T,\n): DeviceAction<any>[] => [\n {\n name: 'Tap',\n description: 'Tap the element',\n interfaceAlias: 'aiTap',\n paramSchema: z.object({\n locate: getMidsceneLocationSchema().describe('The element to be tapped'),\n }),\n call: async (param) => {\n const element = param.locate;\n assert(element, 'Element not found, cannot tap');\n await page.mouse.click(element.center[0], element.center[1], {\n button: 'left',\n });\n },\n } as DeviceAction<{\n locate: MidsceneLocationResultType;\n }>,\n {\n name: 'RightClick',\n description: 'Right click the element',\n interfaceAlias: 'aiRightClick',\n paramSchema: z.object({\n locate: getMidsceneLocationSchema().describe(\n 'The element to be right clicked',\n ),\n }),\n call: async (param) => {\n const element = param.locate;\n assert(element, 'Element not found, cannot right click');\n await page.mouse.click(element.center[0], element.center[1], {\n button: 'right',\n });\n },\n } as DeviceAction<{\n locate: MidsceneLocationResultType;\n }>,\n {\n name: 'Hover',\n description: 'Move the mouse to the element',\n interfaceAlias: 'aiHover',\n paramSchema: z.object({\n locate: getMidsceneLocationSchema().describe('The element to be hovered'),\n }),\n call: async (param) => {\n const element = param.locate;\n assert(element, 'Element not found, cannot hover');\n await page.mouse.move(element.center[0], element.center[1]);\n },\n } as DeviceAction<{\n locate: MidsceneLocationResultType;\n }>,\n {\n name: 'Input',\n description:\n 'Replace the input field with a new value. `value` is the final that should be filled in the input box. No matter what modifications are required, just provide the final value to replace the existing input value. Giving a blank string means clear the input field.',\n interfaceAlias: 'aiInput',\n paramSchema: z.object({\n value: z\n .string()\n .describe('The final value that should be filled in the input box'),\n locate: getMidsceneLocationSchema()\n .describe('The input field to be filled')\n .optional(),\n }),\n call: async (param) => {\n const element = param.locate;\n if (element) {\n await page.clearInput(element as unknown as ElementInfo);\n\n if (!param || !param.value) {\n return;\n }\n }\n\n // Note: there is another implementation in AndroidDevicePage, which is more complex\n await page.keyboard.type(param.value);\n },\n } as DeviceAction<{\n value: string;\n locate: MidsceneLocationResultType;\n }>,\n {\n name: 'KeyboardPress',\n description:\n 'Press a function key, like \"Enter\", \"Tab\", \"Escape\". Do not use this to type text.',\n interfaceAlias: 'aiKeyboardPress',\n paramSchema: z.object({\n locate: getMidsceneLocationSchema()\n .describe('The element to be clicked before pressing the key')\n .optional(),\n keyName: z.string().describe('The key to be pressed'),\n }),\n call: async (param) => {\n const element = param.locate;\n if (element) {\n await page.mouse.click(element.center[0], element.center[1], {\n button: 'left',\n });\n }\n\n const keys = getKeyCommands(param.keyName);\n await page.keyboard.press(keys as any); // TODO: fix this type error\n },\n } as DeviceAction<{\n keyName: string;\n locate: MidsceneLocationResultType;\n }>,\n {\n name: 'Scroll',\n description:\n 'Scroll the page or an element. The direction to scroll, the scroll type, and the distance to scroll. The distance is the number of pixels to scroll. If not specified, use `down` direction, `once` scroll type, and `null` distance.',\n interfaceAlias: 'aiScroll',\n paramSchema: z.object({\n direction: z\n .enum(['down', 'up', 'right', 'left'])\n .default('down')\n .describe('The direction to scroll'),\n scrollType: z\n .enum(['once', 'untilBottom', 'untilTop', 'untilRight', 'untilLeft'])\n .default('once')\n .describe('The scroll type'),\n distance: z\n .number()\n .nullable()\n .optional()\n .describe('The distance in pixels to scroll'),\n locate: getMidsceneLocationSchema()\n .optional()\n .describe('The element to be scrolled'),\n }),\n call: async (param) => {\n const element = param.locate;\n const startingPoint = element\n ? {\n left: element.center[0],\n top: element.center[1],\n }\n : undefined;\n const scrollToEventName = param?.scrollType;\n if (scrollToEventName === 'untilTop') {\n await page.scrollUntilTop(startingPoint);\n } else if (scrollToEventName === 'untilBottom') {\n await page.scrollUntilBottom(startingPoint);\n } else if (scrollToEventName === 'untilRight') {\n await page.scrollUntilRight(startingPoint);\n } else if (scrollToEventName === 'untilLeft') {\n await page.scrollUntilLeft(startingPoint);\n } else if (scrollToEventName === 'once' || !scrollToEventName) {\n if (param?.direction === 'down' || !param || !param.direction) {\n await page.scrollDown(param?.distance || undefined, startingPoint);\n } else if (param.direction === 'up') {\n await page.scrollUp(param.distance || undefined, startingPoint);\n } else if (param.direction === 'left') {\n await page.scrollLeft(param.distance || undefined, startingPoint);\n } else if (param.direction === 'right') {\n await page.scrollRight(param.distance || undefined, startingPoint);\n } else {\n throw new Error(`Unknown scroll direction: ${param.direction}`);\n }\n // until mouse event is done\n await sleep(500);\n } else {\n throw new Error(\n `Unknown scroll event type: ${scrollToEventName}, param: ${JSON.stringify(\n param,\n )}`,\n );\n }\n },\n } as DeviceAction<{\n scrollType:\n | 'once'\n | 'untilBottom'\n | 'untilTop'\n | 'untilRight'\n | 'untilLeft';\n direction: 'up' | 'down';\n distance?: number;\n duration?: number;\n locate: MidsceneLocationResultType;\n }>,\n {\n name: 'DragAndDrop',\n description: 'Drag and drop the element',\n paramSchema: z.object({\n from: getMidsceneLocationSchema().describe('The position to be dragged'),\n to: getMidsceneLocationSchema().describe('The position to be dropped'),\n }),\n call: async (param) => {\n const from = param.from;\n const to = param.to;\n assert(from, 'missing \"from\" param for drag and drop');\n assert(to, 'missing \"to\" param for drag and drop');\n await page.mouse.drag(\n {\n x: from.center[0],\n y: from.center[1],\n },\n {\n x: to.center[0],\n y: to.center[1],\n },\n );\n },\n } as DeviceAction<{\n from: MidsceneLocationResultType;\n to: MidsceneLocationResultType;\n }>,\n];\n"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol","debugProfile","getDebug","commonContextParser","page","assert","url","uploadTestInfoToServer","screenshotBase64","size","resizeImgBase64","getReportFileName","tag","reportTagName","getAIConfig","MIDSCENE_REPORT_TAG_NAME","dateTimeInFileName","dayjs","uniqueId","uuid","printReportMsg","filepath","logMsg","getCurrentExecutionFile","trace","error","Error","stackTrace","pkgDir","process","stackLines","line","match","targetFileName","testFileIndex","Map","generateCacheId","fileName","taskFile","console","currentIndex","undefined","matchElementFromPlan","planLocateParam","tree","getNodeFromCacheList","centerPosition","Math","element","elementByPositionWithElementInfo","generateElementByPosition","matchElementFromCache","taskExecutor","xpaths","cachePrompt","cacheable","_taskExecutor_taskCache","i","cacheDebug","trimContextByViewport","execution","filterVisibleTree","node","filteredChildren","Array","child","task","_task_pageContext","newTask","getMidsceneVersion","__VERSION__","parsePrompt","prompt","commonWebActionsForWebPage","z","getMidsceneLocationSchema","param","keys","getKeyCommands","startingPoint","scrollToEventName","JSON","sleep","from","to"],"mappings":";;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC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,kCAAAA,yBAAAA,AAAAA,IAA4B,QAAQ,CAAC;YAC3C;YACA,MAAM,OAAOC;gBACX,MAAMO,OAAOP,MAAM,IAAI;gBACvB,MAAMQ,KAAKR,MAAM,EAAE;gBACnBvE,IAAAA,sBAAAA,MAAAA,AAAAA,EAAO8E,MAAM;gBACb9E,IAAAA,sBAAAA,MAAAA,AAAAA,EAAO+E,IAAI;gBACX,MAAMhF,KAAK,KAAK,CAAC,IAAI,CACnB;oBACE,GAAG+E,KAAK,MAAM,CAAC,EAAE;oBACjB,GAAGA,KAAK,MAAM,CAAC,EAAE;gBACnB,GACA;oBACE,GAAGC,GAAG,MAAM,CAAC,EAAE;oBACf,GAAGA,GAAG,MAAM,CAAC,EAAE;gBACjB;YAEJ;QACF;KAID"}
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
AbstractPage: ()=>AbstractPage
|
|
28
|
+
});
|
|
29
|
+
class AbstractPage {
|
|
30
|
+
get mouse() {
|
|
31
|
+
return {
|
|
32
|
+
click: async (x, y, options)=>{},
|
|
33
|
+
wheel: async (deltaX, deltaY)=>{},
|
|
34
|
+
move: async (x, y)=>{},
|
|
35
|
+
drag: async (from, to)=>{}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
get keyboard() {
|
|
39
|
+
return {
|
|
40
|
+
type: async (text)=>{},
|
|
41
|
+
press: async (action)=>{}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async clearInput(element) {}
|
|
45
|
+
}
|
|
46
|
+
exports.AbstractPage = __webpack_exports__.AbstractPage;
|
|
47
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
48
|
+
"AbstractPage"
|
|
49
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
50
|
+
Object.defineProperty(exports, '__esModule', {
|
|
51
|
+
value: true
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device/index.js","sources":["webpack://@midscene/core/webpack/runtime/define_property_getters","webpack://@midscene/core/webpack/runtime/has_own_property","webpack://@midscene/core/webpack/runtime/make_namespace_object","webpack://@midscene/core/./src/device/index.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { ElementInfo, ElementNode } from '@midscene/shared/extractor';\nimport type { DeviceAction, Point, Size, UIContext } from '../types';\n\n// this is copied from puppeteer, but we don't want to import puppeteer here\nexport declare type KeyInput =\n | '0'\n | '1'\n | '2'\n | '3'\n | '4'\n | '5'\n | '6'\n | '7'\n | '8'\n | '9'\n | 'Power'\n | 'Eject'\n | 'Abort'\n | 'Help'\n | 'Backspace'\n | 'Tab'\n | 'Numpad5'\n | 'NumpadEnter'\n | 'Enter'\n | '\\r'\n | '\\n'\n | 'ShiftLeft'\n | 'ShiftRight'\n | 'ControlLeft'\n | 'ControlRight'\n | 'AltLeft'\n | 'AltRight'\n | 'Pause'\n | 'CapsLock'\n | 'Escape'\n | 'Convert'\n | 'NonConvert'\n | 'Space'\n | 'Numpad9'\n | 'PageUp'\n | 'Numpad3'\n | 'PageDown'\n | 'End'\n | 'Numpad1'\n | 'Home'\n | 'Numpad7'\n | 'ArrowLeft'\n | 'Numpad4'\n | 'Numpad8'\n | 'ArrowUp'\n | 'ArrowRight'\n | 'Numpad6'\n | 'Numpad2'\n | 'ArrowDown'\n | 'Select'\n | 'Open'\n | 'PrintScreen'\n | 'Insert'\n | 'Numpad0'\n | 'Delete'\n | 'NumpadDecimal'\n | 'Digit0'\n | 'Digit1'\n | 'Digit2'\n | 'Digit3'\n | 'Digit4'\n | 'Digit5'\n | 'Digit6'\n | 'Digit7'\n | 'Digit8'\n | 'Digit9'\n | 'KeyA'\n | 'KeyB'\n | 'KeyC'\n | 'KeyD'\n | 'KeyE'\n | 'KeyF'\n | 'KeyG'\n | 'KeyH'\n | 'KeyI'\n | 'KeyJ'\n | 'KeyK'\n | 'KeyL'\n | 'KeyM'\n | 'KeyN'\n | 'KeyO'\n | 'KeyP'\n | 'KeyQ'\n | 'KeyR'\n | 'KeyS'\n | 'KeyT'\n | 'KeyU'\n | 'KeyV'\n | 'KeyW'\n | 'KeyX'\n | 'KeyY'\n | 'KeyZ'\n | 'MetaLeft'\n | 'MetaRight'\n | 'ContextMenu'\n | 'NumpadMultiply'\n | 'NumpadAdd'\n | 'NumpadSubtract'\n | 'NumpadDivide'\n | 'F1'\n | 'F2'\n | 'F3'\n | 'F4'\n | 'F5'\n | 'F6'\n | 'F7'\n | 'F8'\n | 'F9'\n | 'F10'\n | 'F11'\n | 'F12'\n | 'F13'\n | 'F14'\n | 'F15'\n | 'F16'\n | 'F17'\n | 'F18'\n | 'F19'\n | 'F20'\n | 'F21'\n | 'F22'\n | 'F23'\n | 'F24'\n | 'NumLock'\n | 'ScrollLock'\n | 'AudioVolumeMute'\n | 'AudioVolumeDown'\n | 'AudioVolumeUp'\n | 'MediaTrackNext'\n | 'MediaTrackPrevious'\n | 'MediaStop'\n | 'MediaPlayPause'\n | 'Semicolon'\n | 'Equal'\n | 'NumpadEqual'\n | 'Comma'\n | 'Minus'\n | 'Period'\n | 'Slash'\n | 'Backquote'\n | 'BracketLeft'\n | 'Backslash'\n | 'BracketRight'\n | 'Quote'\n | 'AltGraph'\n | 'Props'\n | 'Cancel'\n | 'Clear'\n | 'Shift'\n | 'Control'\n | 'Alt'\n | 'Accept'\n | 'ModeChange'\n | ' '\n | 'Print'\n | 'Execute'\n | '\\u0000'\n | 'a'\n | 'b'\n | 'c'\n | 'd'\n | 'e'\n | 'f'\n | 'g'\n | 'h'\n | 'i'\n | 'j'\n | 'k'\n | 'l'\n | 'm'\n | 'n'\n | 'o'\n | 'p'\n | 'q'\n | 'r'\n | 's'\n | 't'\n | 'u'\n | 'v'\n | 'w'\n | 'x'\n | 'y'\n | 'z'\n | 'Meta'\n | '*'\n | '+'\n | '-'\n | '/'\n | ';'\n | '='\n | ','\n | '.'\n | '`'\n | '['\n | '\\\\'\n | ']'\n | \"'\"\n | 'Attn'\n | 'CrSel'\n | 'ExSel'\n | 'EraseEof'\n | 'Play'\n | 'ZoomOut'\n | ')'\n | '!'\n | '@'\n | '#'\n | '$'\n | '%'\n | '^'\n | '&'\n | '('\n | 'A'\n | 'B'\n | 'C'\n | 'D'\n | 'E'\n | 'F'\n | 'G'\n | 'H'\n | 'I'\n | 'J'\n | 'K'\n | 'L'\n | 'M'\n | 'N'\n | 'O'\n | 'P'\n | 'Q'\n | 'R'\n | 'S'\n | 'T'\n | 'U'\n | 'V'\n | 'W'\n | 'X'\n | 'Y'\n | 'Z'\n | ':'\n | '<'\n | '_'\n | '>'\n | '?'\n | '~'\n | '{'\n | '|'\n | '}'\n | '\"'\n | 'SoftLeft'\n | 'SoftRight'\n | 'Camera'\n | 'Call'\n | 'EndCall'\n | 'VolumeDown'\n | 'VolumeUp';\n\nexport type MouseButton = 'left' | 'right' | 'middle';\n\nexport interface MouseAction {\n click: (\n x: number,\n y: number,\n options: { button: MouseButton },\n ) => Promise<void>;\n wheel: (deltaX: number, deltaY: number) => Promise<void>;\n move: (x: number, y: number) => Promise<void>;\n drag: (\n from: { x: number; y: number },\n to: { x: number; y: number },\n ) => Promise<void>;\n}\n\nexport interface KeyboardAction {\n type: (text: string) => Promise<void>;\n press: (\n action:\n | { key: KeyInput; command?: string }\n | { key: KeyInput; command?: string }[],\n ) => Promise<void>;\n}\n\nexport interface ChromePageDestroyOptions {\n closeTab?: boolean; // should close the tab when the page object is destroyed\n}\n\nexport abstract class AbstractPage {\n abstract pageType: string;\n // @deprecated\n abstract getElementsInfo(): Promise<ElementInfo[]>;\n abstract getElementsNodeTree(): Promise<ElementNode>;\n abstract url(): string | Promise<string>;\n abstract screenshotBase64(): Promise<string>;\n abstract size(): Promise<Size>;\n abstract actionSpace(): DeviceAction[] | Promise<DeviceAction[]>;\n\n get mouse(): MouseAction {\n return {\n click: async (\n x: number,\n y: number,\n options: { button: MouseButton },\n ) => {},\n wheel: async (deltaX: number, deltaY: number) => {},\n move: async (x: number, y: number) => {},\n drag: async (\n from: { x: number; y: number },\n to: { x: number; y: number },\n ) => {},\n };\n }\n\n get keyboard(): KeyboardAction {\n return {\n type: async (text: string) => {},\n press: async (\n action:\n | { key: KeyInput; command?: string }\n | { key: KeyInput; command?: string }[],\n ) => {},\n };\n }\n\n async clearInput(element: ElementInfo): Promise<void> {}\n\n abstract scrollUntilTop(startingPoint?: Point): Promise<void>;\n abstract scrollUntilBottom(startingPoint?: Point): Promise<void>;\n abstract scrollUntilLeft(startingPoint?: Point): Promise<void>;\n abstract scrollUntilRight(startingPoint?: Point): Promise<void>;\n abstract scrollUp(distance?: number, startingPoint?: Point): Promise<void>;\n abstract scrollDown(distance?: number, startingPoint?: Point): Promise<void>;\n abstract scrollLeft(distance?: number, startingPoint?: Point): Promise<void>;\n abstract scrollRight(distance?: number, startingPoint?: Point): Promise<void>;\n\n abstract beforeAction?(): Promise<void>;\n\n abstract destroy(options?: ChromePageDestroyOptions): Promise<void>;\n\n abstract evaluateJavaScript?<T = any>(script: string): Promise<T>;\n\n abstract getContext?(): Promise<UIContext>;\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","AbstractPage","x","y","options","deltaX","deltaY","from","to","text","action","element"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;AC4RO,MAAeI;IAUpB,IAAI,QAAqB;QACvB,OAAO;YACL,OAAO,OACLC,GACAC,GACAC,WACI;YACN,OAAO,OAAOC,QAAgBC,UAAoB;YAClD,MAAM,OAAOJ,GAAWC,KAAe;YACvC,MAAM,OACJI,MACAC,MACI;QACR;IACF;IAEA,IAAI,WAA2B;QAC7B,OAAO;YACL,MAAM,OAAOC,QAAkB;YAC/B,OAAO,OACLC,UAGI;QACR;IACF;IAEA,MAAM,WAAWC,OAAoB,EAAiB,CAAC;AAkBzD"}
|
package/dist/lib/index.js
CHANGED
|
@@ -48,7 +48,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
48
48
|
Insight: ()=>index_js_default(),
|
|
49
49
|
describeUserPage: ()=>external_ai_model_index_js_namespaceObject.describeUserPage,
|
|
50
50
|
Executor: ()=>action_executor_js_namespaceObject.Executor,
|
|
51
|
-
getMidsceneLocationSchema: ()=>external_ai_model_index_js_namespaceObject.getMidsceneLocationSchema
|
|
51
|
+
getMidsceneLocationSchema: ()=>external_ai_model_index_js_namespaceObject.getMidsceneLocationSchema,
|
|
52
|
+
Agent: ()=>external_agent_index_js_namespaceObject.Agent
|
|
52
53
|
});
|
|
53
54
|
const external_zod_namespaceObject = require("zod");
|
|
54
55
|
const action_executor_js_namespaceObject = require("./ai-model/action-executor.js");
|
|
@@ -57,7 +58,9 @@ var index_js_default = /*#__PURE__*/ __webpack_require__.n(index_js_namespaceObj
|
|
|
57
58
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
58
59
|
const external_ai_model_index_js_namespaceObject = require("./ai-model/index.js");
|
|
59
60
|
const env_namespaceObject = require("@midscene/shared/env");
|
|
61
|
+
const external_agent_index_js_namespaceObject = require("./agent/index.js");
|
|
60
62
|
const src = index_js_default();
|
|
63
|
+
exports.Agent = __webpack_exports__.Agent;
|
|
61
64
|
exports.AiLocateElement = __webpack_exports__.AiLocateElement;
|
|
62
65
|
exports.Executor = __webpack_exports__.Executor;
|
|
63
66
|
exports.Insight = __webpack_exports__.Insight;
|
|
@@ -75,6 +78,7 @@ exports.getVersion = __webpack_exports__.getVersion;
|
|
|
75
78
|
exports.plan = __webpack_exports__.plan;
|
|
76
79
|
exports.z = __webpack_exports__.z;
|
|
77
80
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
81
|
+
"Agent",
|
|
78
82
|
"AiLocateElement",
|
|
79
83
|
"Executor",
|
|
80
84
|
"Insight",
|
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["webpack://@midscene/core/webpack/runtime/compat_get_default_export","webpack://@midscene/core/webpack/runtime/define_property_getters","webpack://@midscene/core/webpack/runtime/has_own_property","webpack://@midscene/core/webpack/runtime/make_namespace_object","webpack://@midscene/core/./src/index.ts"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { z } from 'zod';\nimport { Executor } from './ai-model/action-executor';\nimport Insight from './insight/index';\nimport { getVersion } from './utils';\n\nexport {\n plan,\n describeUserPage,\n AiLocateElement,\n getMidsceneLocationSchema,\n type MidsceneLocationResultType,\n PointSchema,\n SizeSchema,\n RectSchema,\n TMultimodalPromptSchema,\n TUserPromptSchema,\n type TMultimodalPrompt,\n type TUserPrompt,\n} from './ai-model/index';\n\nexport { getAIConfig, MIDSCENE_MODEL_NAME } from '@midscene/shared/env';\n\nexport type * from './types';\n\nexport { z };\n\nexport default Insight;\nexport { Executor, Insight, getVersion };\n\nexport type {\n MidsceneYamlScript,\n MidsceneYamlTask,\n MidsceneYamlFlowItem,\n MidsceneYamlFlowItemAIRightClick,\n MidsceneYamlConfigResult,\n LocateOption,\n DetailedLocateParam,\n} from './yaml';\n"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol","Insight"],"mappings":";;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAJ,oBAAoB,CAAC,GAAG,CAACM,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFP,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOQ,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D
|
|
1
|
+
{"version":3,"file":"index.js","sources":["webpack://@midscene/core/webpack/runtime/compat_get_default_export","webpack://@midscene/core/webpack/runtime/define_property_getters","webpack://@midscene/core/webpack/runtime/has_own_property","webpack://@midscene/core/webpack/runtime/make_namespace_object","webpack://@midscene/core/./src/index.ts"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { z } from 'zod';\nimport { Executor } from './ai-model/action-executor';\nimport Insight from './insight/index';\nimport { getVersion } from './utils';\n\nexport {\n plan,\n describeUserPage,\n AiLocateElement,\n getMidsceneLocationSchema,\n type MidsceneLocationResultType,\n PointSchema,\n SizeSchema,\n RectSchema,\n TMultimodalPromptSchema,\n TUserPromptSchema,\n type TMultimodalPrompt,\n type TUserPrompt,\n} from './ai-model/index';\n\nexport { getAIConfig, MIDSCENE_MODEL_NAME } from '@midscene/shared/env';\n\nexport type * from './types';\n\nexport { z };\n\nexport default Insight;\nexport { Executor, Insight, getVersion };\n\nexport type {\n MidsceneYamlScript,\n MidsceneYamlTask,\n MidsceneYamlFlowItem,\n MidsceneYamlFlowItemAIRightClick,\n MidsceneYamlConfigResult,\n LocateOption,\n DetailedLocateParam,\n} from './yaml';\n\nexport { Agent, type PageAgentOpt } from './agent';\n"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol","Insight"],"mappings":";;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAJ,oBAAoB,CAAC,GAAG,CAACM,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFP,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOQ,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACoBA,YAAeI"}
|