@midscene/web 0.11.1 → 0.11.3
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/appium.js +85 -39
- package/dist/es/bridge-mode-browser.js +58 -19
- package/dist/es/bridge-mode.js +62 -43
- package/dist/es/chrome-extension.js +105 -51
- package/dist/es/index.js +292 -218
- package/dist/es/midscene-playground.js +57 -38
- package/dist/es/playground.js +57 -38
- package/dist/es/playwright-report.js +4 -0
- package/dist/es/playwright.js +252 -203
- package/dist/es/puppeteer.js +86 -60
- package/dist/es/ui-utils.js +43 -0
- package/dist/lib/appium.js +85 -39
- package/dist/lib/bridge-mode-browser.js +58 -19
- package/dist/lib/bridge-mode.js +62 -43
- package/dist/lib/chrome-extension.js +105 -51
- package/dist/lib/index.js +292 -218
- package/dist/lib/midscene-playground.js +57 -38
- package/dist/lib/playground.js +57 -38
- package/dist/lib/playwright-report.js +4 -0
- package/dist/lib/playwright.js +252 -203
- package/dist/lib/puppeteer.js +86 -60
- package/dist/lib/ui-utils.js +43 -0
- package/dist/types/{tasks-d5a01262.d.ts → agent-ae110e80.d.ts} +43 -43
- package/dist/types/appium.d.ts +3 -3
- package/dist/types/bridge-mode-browser.d.ts +3 -3
- package/dist/types/bridge-mode.d.ts +4 -4
- package/dist/types/{browser-7d5614fb.d.ts → browser-9d620553.d.ts} +4 -4
- package/dist/types/chrome-extension.d.ts +4 -4
- package/dist/types/index.d.ts +8 -8
- package/dist/types/{page-77af8d5f.d.ts → page-97720803.d.ts} +34 -8
- package/dist/types/playground.d.ts +4 -4
- package/dist/types/playwright.d.ts +13 -7
- package/dist/types/puppeteer.d.ts +3 -3
- package/dist/types/ui-utils.d.ts +6 -1
- package/dist/types/{utils-1a3bc661.d.ts → utils-93b3f5f3.d.ts} +1 -1
- package/dist/types/utils.d.ts +2 -2
- package/dist/types/yaml.d.ts +4 -4
- package/package.json +6 -6
package/dist/lib/puppeteer.js
CHANGED
|
@@ -3364,7 +3364,9 @@ var TaskCache = class {
|
|
|
3364
3364
|
if (!this.midscenePkgInfo) {
|
|
3365
3365
|
return void 0;
|
|
3366
3366
|
}
|
|
3367
|
-
|
|
3367
|
+
const jsonDataPkgVersion = jsonData.pkgVersion.split(".");
|
|
3368
|
+
const midscenePkgInfoPkgVersion = this.midscenePkgInfo.version.split(".");
|
|
3369
|
+
if (jsonDataPkgVersion[0] !== midscenePkgInfoPkgVersion[0] || jsonDataPkgVersion[1] !== midscenePkgInfoPkgVersion[1]) {
|
|
3368
3370
|
return void 0;
|
|
3369
3371
|
}
|
|
3370
3372
|
return jsonData;
|
|
@@ -3398,6 +3400,56 @@ var TaskCache = class {
|
|
|
3398
3400
|
}
|
|
3399
3401
|
};
|
|
3400
3402
|
|
|
3403
|
+
// src/common/ui-utils.ts
|
|
3404
|
+
function typeStr(task) {
|
|
3405
|
+
return task.subType ? `${task.type} / ${task.subType || ""}` : task.type;
|
|
3406
|
+
}
|
|
3407
|
+
function getKeyCommands(value) {
|
|
3408
|
+
const keys = Array.isArray(value) ? value : [value];
|
|
3409
|
+
return keys.reduce((acc, k) => {
|
|
3410
|
+
const includeMeta = keys.includes("Meta") || keys.includes("Control");
|
|
3411
|
+
if (includeMeta && (k === "a" || k === "A")) {
|
|
3412
|
+
return acc.concat([{ key: k, command: "SelectAll" }]);
|
|
3413
|
+
}
|
|
3414
|
+
if (includeMeta && (k === "c" || k === "C")) {
|
|
3415
|
+
return acc.concat([{ key: k, command: "Copy" }]);
|
|
3416
|
+
}
|
|
3417
|
+
if (includeMeta && (k === "v" || k === "V")) {
|
|
3418
|
+
return acc.concat([{ key: k, command: "Paste" }]);
|
|
3419
|
+
}
|
|
3420
|
+
return acc.concat([{ key: k }]);
|
|
3421
|
+
}, []);
|
|
3422
|
+
}
|
|
3423
|
+
function paramStr(task) {
|
|
3424
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
3425
|
+
let value;
|
|
3426
|
+
if (task.type === "Planning") {
|
|
3427
|
+
value = (_a = task == null ? void 0 : task.param) == null ? void 0 : _a.userPrompt;
|
|
3428
|
+
}
|
|
3429
|
+
if (task.type === "Insight") {
|
|
3430
|
+
value = ((_b = task == null ? void 0 : task.param) == null ? void 0 : _b.prompt) || ((_c = task == null ? void 0 : task.param) == null ? void 0 : _c.id) || ((_d = task == null ? void 0 : task.param) == null ? void 0 : _d.dataDemand) || ((_e = task == null ? void 0 : task.param) == null ? void 0 : _e.assertion);
|
|
3431
|
+
}
|
|
3432
|
+
if (task.type === "Action") {
|
|
3433
|
+
const sleepMs = (_f = task == null ? void 0 : task.param) == null ? void 0 : _f.timeMs;
|
|
3434
|
+
const scrollType = (_g = task == null ? void 0 : task.param) == null ? void 0 : _g.scrollType;
|
|
3435
|
+
if (sleepMs) {
|
|
3436
|
+
value = `${sleepMs}ms`;
|
|
3437
|
+
} else if (scrollType) {
|
|
3438
|
+
const scrollDirection = (_h = task == null ? void 0 : task.param) == null ? void 0 : _h.direction;
|
|
3439
|
+
const scrollDistance = (_i = task == null ? void 0 : task.param) == null ? void 0 : _i.distance;
|
|
3440
|
+
value = `${scrollDirection || "down"}, ${scrollType || "once"}, ${scrollDistance || "distance-not-set"}`;
|
|
3441
|
+
} else {
|
|
3442
|
+
value = ((_j = task == null ? void 0 : task.param) == null ? void 0 : _j.value) || ((_k = task == null ? void 0 : task.param) == null ? void 0 : _k.scrollType);
|
|
3443
|
+
}
|
|
3444
|
+
if (!value) {
|
|
3445
|
+
value = task.thought;
|
|
3446
|
+
}
|
|
3447
|
+
}
|
|
3448
|
+
if (typeof value === "undefined")
|
|
3449
|
+
return "";
|
|
3450
|
+
return typeof value === "string" ? value : JSON.stringify(value, void 0, 2);
|
|
3451
|
+
}
|
|
3452
|
+
|
|
3401
3453
|
// src/common/tasks.ts
|
|
3402
3454
|
var PageTaskExecutor = class {
|
|
3403
3455
|
constructor(page, insight, opts) {
|
|
@@ -3532,6 +3584,7 @@ var PageTaskExecutor = class {
|
|
|
3532
3584
|
output: {
|
|
3533
3585
|
element
|
|
3534
3586
|
},
|
|
3587
|
+
pageContext,
|
|
3535
3588
|
log: {
|
|
3536
3589
|
dump: insightDump
|
|
3537
3590
|
},
|
|
@@ -3611,8 +3664,8 @@ var PageTaskExecutor = class {
|
|
|
3611
3664
|
thought: plan2.thought,
|
|
3612
3665
|
locate: plan2.locate,
|
|
3613
3666
|
executor: async (taskParam) => {
|
|
3614
|
-
|
|
3615
|
-
await this.page.keyboard.press(
|
|
3667
|
+
const keys = getKeyCommands(taskParam.value);
|
|
3668
|
+
await this.page.keyboard.press(keys);
|
|
3616
3669
|
}
|
|
3617
3670
|
};
|
|
3618
3671
|
tasks.push(taskActionKeyboardPress);
|
|
@@ -4020,7 +4073,7 @@ var PageTaskExecutor = class {
|
|
|
4020
4073
|
const cacheGroup = this.taskCache.getCacheGroupByPrompt(userPrompt);
|
|
4021
4074
|
const isCompleted = false;
|
|
4022
4075
|
let currentActionNumber = 0;
|
|
4023
|
-
const maxActionNumber =
|
|
4076
|
+
const maxActionNumber = 40;
|
|
4024
4077
|
while (!isCompleted && currentActionNumber < maxActionNumber) {
|
|
4025
4078
|
currentActionNumber++;
|
|
4026
4079
|
const planningTask = this.planningTaskToGoal(
|
|
@@ -4240,40 +4293,6 @@ var WebElementInfo = class {
|
|
|
4240
4293
|
}
|
|
4241
4294
|
};
|
|
4242
4295
|
|
|
4243
|
-
// src/common/ui-utils.ts
|
|
4244
|
-
function typeStr(task) {
|
|
4245
|
-
return task.subType ? `${task.type} / ${task.subType || ""}` : task.type;
|
|
4246
|
-
}
|
|
4247
|
-
function paramStr(task) {
|
|
4248
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4249
|
-
let value;
|
|
4250
|
-
if (task.type === "Planning") {
|
|
4251
|
-
value = (_a = task == null ? void 0 : task.param) == null ? void 0 : _a.userPrompt;
|
|
4252
|
-
}
|
|
4253
|
-
if (task.type === "Insight") {
|
|
4254
|
-
value = ((_b = task == null ? void 0 : task.param) == null ? void 0 : _b.prompt) || ((_c = task == null ? void 0 : task.param) == null ? void 0 : _c.id) || ((_d = task == null ? void 0 : task.param) == null ? void 0 : _d.dataDemand) || ((_e = task == null ? void 0 : task.param) == null ? void 0 : _e.assertion);
|
|
4255
|
-
}
|
|
4256
|
-
if (task.type === "Action") {
|
|
4257
|
-
const sleepMs = (_f = task == null ? void 0 : task.param) == null ? void 0 : _f.timeMs;
|
|
4258
|
-
const scrollType = (_g = task == null ? void 0 : task.param) == null ? void 0 : _g.scrollType;
|
|
4259
|
-
if (sleepMs) {
|
|
4260
|
-
value = `${sleepMs}ms`;
|
|
4261
|
-
} else if (scrollType) {
|
|
4262
|
-
const scrollDirection = (_h = task == null ? void 0 : task.param) == null ? void 0 : _h.direction;
|
|
4263
|
-
const scrollDistance = (_i = task == null ? void 0 : task.param) == null ? void 0 : _i.distance;
|
|
4264
|
-
value = `${scrollDirection || "down"}, ${scrollType || "once"}, ${scrollDistance || "distance-not-set"}`;
|
|
4265
|
-
} else {
|
|
4266
|
-
value = ((_j = task == null ? void 0 : task.param) == null ? void 0 : _j.value) || ((_k = task == null ? void 0 : task.param) == null ? void 0 : _k.scrollType);
|
|
4267
|
-
}
|
|
4268
|
-
if (!value) {
|
|
4269
|
-
value = task.thought;
|
|
4270
|
-
}
|
|
4271
|
-
}
|
|
4272
|
-
if (typeof value === "undefined")
|
|
4273
|
-
return "";
|
|
4274
|
-
return typeof value === "string" ? value : JSON.stringify(value, void 0, 2);
|
|
4275
|
-
}
|
|
4276
|
-
|
|
4277
4296
|
// src/common/utils.ts
|
|
4278
4297
|
var import_node_assert4 = __toESM(require("assert"));
|
|
4279
4298
|
var import_node_fs3 = require("fs");
|
|
@@ -4581,12 +4600,19 @@ var Page = class {
|
|
|
4581
4600
|
this.underlyingPage = underlyingPage;
|
|
4582
4601
|
this.pageType = pageType;
|
|
4583
4602
|
}
|
|
4603
|
+
async waitForNavigation() {
|
|
4604
|
+
if (this.pageType === "puppeteer" || this.pageType === "playwright") {
|
|
4605
|
+
await this.underlyingPage.waitForSelector("html");
|
|
4606
|
+
}
|
|
4607
|
+
}
|
|
4584
4608
|
// @deprecated
|
|
4585
4609
|
async getElementsInfo() {
|
|
4610
|
+
await this.waitForNavigation();
|
|
4586
4611
|
const tree = await this.getElementsNodeTree();
|
|
4587
4612
|
return (0, import_extractor2.treeToList)(tree);
|
|
4588
4613
|
}
|
|
4589
4614
|
async getElementsNodeTree() {
|
|
4615
|
+
await this.waitForNavigation();
|
|
4590
4616
|
const scripts = await getExtraReturnLogic(true);
|
|
4591
4617
|
const captureElementSnapshot = await this.evaluate(scripts);
|
|
4592
4618
|
return captureElementSnapshot;
|
|
@@ -4607,6 +4633,7 @@ var Page = class {
|
|
|
4607
4633
|
async screenshotBase64() {
|
|
4608
4634
|
const imgType = "jpeg";
|
|
4609
4635
|
const path2 = (0, import_utils9.getTmpFile)(imgType);
|
|
4636
|
+
await this.waitForNavigation();
|
|
4610
4637
|
await this.underlyingPage.screenshot({
|
|
4611
4638
|
path: path2,
|
|
4612
4639
|
type: imgType,
|
|
@@ -4664,13 +4691,14 @@ var Page = class {
|
|
|
4664
4691
|
get keyboard() {
|
|
4665
4692
|
return {
|
|
4666
4693
|
type: async (text) => this.underlyingPage.keyboard.type(text, { delay: 80 }),
|
|
4667
|
-
press: async (
|
|
4668
|
-
const keys = Array.isArray(
|
|
4669
|
-
for (const
|
|
4670
|
-
|
|
4694
|
+
press: async (action) => {
|
|
4695
|
+
const keys = Array.isArray(action) ? action : [action];
|
|
4696
|
+
for (const k of keys) {
|
|
4697
|
+
const commands = k.command ? [k.command] : [];
|
|
4698
|
+
await this.underlyingPage.keyboard.down(k.key, { commands });
|
|
4671
4699
|
}
|
|
4672
|
-
for (const
|
|
4673
|
-
await this.underlyingPage.keyboard.up(
|
|
4700
|
+
for (const k of [...keys].reverse()) {
|
|
4701
|
+
await this.underlyingPage.keyboard.up(k.key);
|
|
4674
4702
|
}
|
|
4675
4703
|
},
|
|
4676
4704
|
down: async (key) => {
|
|
@@ -4705,7 +4733,7 @@ var Page = class {
|
|
|
4705
4733
|
await this.underlyingPage.keyboard.up("Control");
|
|
4706
4734
|
}
|
|
4707
4735
|
await (0, import_utils9.sleep)(100);
|
|
4708
|
-
await this.keyboard.press("Backspace");
|
|
4736
|
+
await this.keyboard.press([{ key: "Backspace" }]);
|
|
4709
4737
|
}
|
|
4710
4738
|
async moveToPoint(point) {
|
|
4711
4739
|
if (point) {
|
|
@@ -4893,7 +4921,7 @@ async function puppeteerAgentForTarget(target, preference) {
|
|
|
4893
4921
|
const agent = new PuppeteerAgent(page, {
|
|
4894
4922
|
autoPrintReportMsg: false,
|
|
4895
4923
|
testId: preference == null ? void 0 : preference.testId,
|
|
4896
|
-
|
|
4924
|
+
forceSameTabNavigation: typeof target.forceSameTabNavigation !== "undefined" ? target.forceSameTabNavigation : true
|
|
4897
4925
|
// true for default in yaml script
|
|
4898
4926
|
});
|
|
4899
4927
|
freeFn.push({
|
|
@@ -4908,21 +4936,19 @@ var PuppeteerAgent = class extends PageAgent {
|
|
|
4908
4936
|
constructor(page, opts) {
|
|
4909
4937
|
const webPage = new WebPage(page);
|
|
4910
4938
|
super(webPage, opts);
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
if (
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
);
|
|
4920
|
-
return;
|
|
4921
|
-
}
|
|
4922
|
-
const midscenePage = new WebPage(targetPage);
|
|
4923
|
-
this.page = midscenePage;
|
|
4924
|
-
this.taskExecutor.page = midscenePage;
|
|
4939
|
+
const { forceSameTabNavigation = true } = opts != null ? opts : {};
|
|
4940
|
+
if (forceSameTabNavigation) {
|
|
4941
|
+
page.on("popup", async (popup) => {
|
|
4942
|
+
if (!popup) {
|
|
4943
|
+
console.warn(
|
|
4944
|
+
"got a popup event, but the popup is not ready yet, skip"
|
|
4945
|
+
);
|
|
4946
|
+
return;
|
|
4925
4947
|
}
|
|
4948
|
+
const url = await popup.url();
|
|
4949
|
+
console.log(`Popup opened: ${url}`);
|
|
4950
|
+
await popup.close();
|
|
4951
|
+
await page.goto(url);
|
|
4926
4952
|
});
|
|
4927
4953
|
}
|
|
4928
4954
|
}
|
package/dist/lib/ui-utils.js
CHANGED
|
@@ -20,6 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/common/ui-utils.ts
|
|
21
21
|
var ui_utils_exports = {};
|
|
22
22
|
__export(ui_utils_exports, {
|
|
23
|
+
getKeyCommands: () => getKeyCommands,
|
|
24
|
+
limitOpenNewTabScript: () => limitOpenNewTabScript,
|
|
23
25
|
paramStr: () => paramStr,
|
|
24
26
|
typeStr: () => typeStr
|
|
25
27
|
});
|
|
@@ -27,6 +29,22 @@ module.exports = __toCommonJS(ui_utils_exports);
|
|
|
27
29
|
function typeStr(task) {
|
|
28
30
|
return task.subType ? `${task.type} / ${task.subType || ""}` : task.type;
|
|
29
31
|
}
|
|
32
|
+
function getKeyCommands(value) {
|
|
33
|
+
const keys = Array.isArray(value) ? value : [value];
|
|
34
|
+
return keys.reduce((acc, k) => {
|
|
35
|
+
const includeMeta = keys.includes("Meta") || keys.includes("Control");
|
|
36
|
+
if (includeMeta && (k === "a" || k === "A")) {
|
|
37
|
+
return acc.concat([{ key: k, command: "SelectAll" }]);
|
|
38
|
+
}
|
|
39
|
+
if (includeMeta && (k === "c" || k === "C")) {
|
|
40
|
+
return acc.concat([{ key: k, command: "Copy" }]);
|
|
41
|
+
}
|
|
42
|
+
if (includeMeta && (k === "v" || k === "V")) {
|
|
43
|
+
return acc.concat([{ key: k, command: "Paste" }]);
|
|
44
|
+
}
|
|
45
|
+
return acc.concat([{ key: k }]);
|
|
46
|
+
}, []);
|
|
47
|
+
}
|
|
30
48
|
function paramStr(task) {
|
|
31
49
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
32
50
|
let value;
|
|
@@ -56,8 +74,33 @@ function paramStr(task) {
|
|
|
56
74
|
return "";
|
|
57
75
|
return typeof value === "string" ? value : JSON.stringify(value, void 0, 2);
|
|
58
76
|
}
|
|
77
|
+
var limitOpenNewTabScript = `
|
|
78
|
+
if (!window.__MIDSCENE_NEW_TAB_INTERCEPTOR_INITIALIZED__) {
|
|
79
|
+
window.__MIDSCENE_NEW_TAB_INTERCEPTOR_INITIALIZED__ = true;
|
|
80
|
+
|
|
81
|
+
// Intercept the window.open method (only once)
|
|
82
|
+
window.open = function(url) {
|
|
83
|
+
console.log('Blocked window.open:', url);
|
|
84
|
+
window.location.href = url;
|
|
85
|
+
return null;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// Block all a tag clicks with target="_blank" (only once)
|
|
89
|
+
document.addEventListener('click', function(e) {
|
|
90
|
+
const target = e.target.closest('a');
|
|
91
|
+
if (target && target.target === '_blank') {
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
console.log('Blocked new tab:', target.href);
|
|
94
|
+
window.location.href = target.href;
|
|
95
|
+
target.removeAttribute('target');
|
|
96
|
+
}
|
|
97
|
+
}, true);
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
59
100
|
// Annotate the CommonJS export names for ESM import in node:
|
|
60
101
|
0 && (module.exports = {
|
|
102
|
+
getKeyCommands,
|
|
103
|
+
limitOpenNewTabScript,
|
|
61
104
|
paramStr,
|
|
62
105
|
typeStr
|
|
63
106
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { c as WebUIContext, W as WebPage, d as WebElementInfo } from './page-
|
|
3
|
-
import { PlanningAIResponse, AIElementIdResponse, Insight,
|
|
1
|
+
import * as _midscene_core_dist_lib_types_types_95b0888e from '@midscene/core/dist/lib/types/types-95b0888e';
|
|
2
|
+
import { c as WebUIContext, W as WebPage, d as WebElementInfo } from './page-97720803.js';
|
|
3
|
+
import { PlanningAIResponse, AIElementIdResponse, Insight, ExecutionTaskProgressOptions, Executor, InsightExtractParam, InsightAssertionResponse, PlanningActionParamWaitFor, OnTaskStartTip, GroupedActionDump, InsightAction, ExecutionDump, AgentAssertOpt, AgentWaitForOpt } from '@midscene/core';
|
|
4
4
|
import { vlmPlanning, ChatCompletionMessageParam } from '@midscene/core/ai-model';
|
|
5
5
|
import { getRunningPkgInfo } from '@midscene/shared/fs';
|
|
6
6
|
|
|
@@ -92,8 +92,46 @@ declare class TaskCache {
|
|
|
92
92
|
writeCacheToFile(): void;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
interface ExecutionResult<OutputType = any> {
|
|
96
|
+
output: OutputType;
|
|
97
|
+
executor: Executor;
|
|
98
|
+
}
|
|
99
|
+
declare class PageTaskExecutor {
|
|
100
|
+
page: WebPage;
|
|
101
|
+
insight: Insight<WebElementInfo, WebUIContext>;
|
|
102
|
+
taskCache: TaskCache;
|
|
103
|
+
conversationHistory: ChatCompletionMessageParam[];
|
|
104
|
+
constructor(page: WebPage, insight: Insight<WebElementInfo, WebUIContext>, opts: {
|
|
105
|
+
cacheId: string | undefined;
|
|
106
|
+
});
|
|
107
|
+
private recordScreenshot;
|
|
108
|
+
private prependExecutorWithScreenshot;
|
|
109
|
+
private convertPlanToExecutable;
|
|
110
|
+
private planningTaskFromPrompt;
|
|
111
|
+
private planningTaskToGoal;
|
|
112
|
+
action(userPrompt: string, options?: ExecutionTaskProgressOptions): Promise<ExecutionResult>;
|
|
113
|
+
actionToGoal(userPrompt: string, options?: ExecutionTaskProgressOptions): Promise<{
|
|
114
|
+
output: any;
|
|
115
|
+
executor: Executor;
|
|
116
|
+
}>;
|
|
117
|
+
query(demand: InsightExtractParam, options?: ExecutionTaskProgressOptions): Promise<ExecutionResult>;
|
|
118
|
+
assert(assertion: string, options?: ExecutionTaskProgressOptions): Promise<ExecutionResult<InsightAssertionResponse>>;
|
|
119
|
+
/**
|
|
120
|
+
* Append a message to the conversation history
|
|
121
|
+
* For user messages with images:
|
|
122
|
+
* - Keep max 4 user image messages in history
|
|
123
|
+
* - Remove oldest user image message when limit reached
|
|
124
|
+
* For assistant messages:
|
|
125
|
+
* - Simply append to history
|
|
126
|
+
* @param conversationHistory Message to append
|
|
127
|
+
*/
|
|
128
|
+
private appendConversationHistory;
|
|
129
|
+
private appendErrorPlan;
|
|
130
|
+
waitFor(assertion: string, opt: PlanningActionParamWaitFor): Promise<ExecutionResult<void>>;
|
|
131
|
+
}
|
|
132
|
+
|
|
95
133
|
interface PageAgentOpt {
|
|
96
|
-
|
|
134
|
+
forceSameTabNavigation?: boolean;
|
|
97
135
|
testId?: string;
|
|
98
136
|
cacheId?: string;
|
|
99
137
|
groupName?: string;
|
|
@@ -125,7 +163,7 @@ declare class PageAgent<PageType extends WebPage = WebPage> {
|
|
|
125
163
|
private callbackOnTaskStartTip;
|
|
126
164
|
aiAction(taskPrompt: string): Promise<void>;
|
|
127
165
|
aiQuery(demand: any): Promise<any>;
|
|
128
|
-
aiAssert(assertion: string, msg?: string, opt?: AgentAssertOpt): Promise<
|
|
166
|
+
aiAssert(assertion: string, msg?: string, opt?: AgentAssertOpt): Promise<_midscene_core_dist_lib_types_types_95b0888e.o | undefined>;
|
|
129
167
|
aiWaitFor(assertion: string, opt?: AgentWaitForOpt): Promise<void>;
|
|
130
168
|
ai(taskPrompt: string, type?: string): Promise<any>;
|
|
131
169
|
runYaml(yamlScriptContent: string): Promise<{
|
|
@@ -134,42 +172,4 @@ declare class PageAgent<PageType extends WebPage = WebPage> {
|
|
|
134
172
|
destroy(): Promise<void>;
|
|
135
173
|
}
|
|
136
174
|
|
|
137
|
-
interface ExecutionResult<OutputType = any> {
|
|
138
|
-
output: OutputType;
|
|
139
|
-
executor: Executor;
|
|
140
|
-
}
|
|
141
|
-
declare class PageTaskExecutor {
|
|
142
|
-
page: WebPage;
|
|
143
|
-
insight: Insight<WebElementInfo, WebUIContext>;
|
|
144
|
-
taskCache: TaskCache;
|
|
145
|
-
conversationHistory: ChatCompletionMessageParam[];
|
|
146
|
-
constructor(page: WebPage, insight: Insight<WebElementInfo, WebUIContext>, opts: {
|
|
147
|
-
cacheId: string | undefined;
|
|
148
|
-
});
|
|
149
|
-
private recordScreenshot;
|
|
150
|
-
private prependExecutorWithScreenshot;
|
|
151
|
-
private convertPlanToExecutable;
|
|
152
|
-
private planningTaskFromPrompt;
|
|
153
|
-
private planningTaskToGoal;
|
|
154
|
-
action(userPrompt: string, options?: ExecutionTaskProgressOptions): Promise<ExecutionResult>;
|
|
155
|
-
actionToGoal(userPrompt: string, options?: ExecutionTaskProgressOptions): Promise<{
|
|
156
|
-
output: any;
|
|
157
|
-
executor: Executor;
|
|
158
|
-
}>;
|
|
159
|
-
query(demand: InsightExtractParam, options?: ExecutionTaskProgressOptions): Promise<ExecutionResult>;
|
|
160
|
-
assert(assertion: string, options?: ExecutionTaskProgressOptions): Promise<ExecutionResult<InsightAssertionResponse>>;
|
|
161
|
-
/**
|
|
162
|
-
* Append a message to the conversation history
|
|
163
|
-
* For user messages with images:
|
|
164
|
-
* - Keep max 4 user image messages in history
|
|
165
|
-
* - Remove oldest user image message when limit reached
|
|
166
|
-
* For assistant messages:
|
|
167
|
-
* - Simply append to history
|
|
168
|
-
* @param conversationHistory Message to append
|
|
169
|
-
*/
|
|
170
|
-
private appendConversationHistory;
|
|
171
|
-
private appendErrorPlan;
|
|
172
|
-
waitFor(assertion: string, opt: PlanningActionParamWaitFor): Promise<ExecutionResult<void>>;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
175
|
export { PageAgent as P, type PageAgentOpt as a, PageTaskExecutor as b };
|
package/dist/types/appium.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { P as AppiumAgent } from './
|
|
2
|
-
export { P as AppiumPage } from './page-
|
|
3
|
-
import '@midscene/core/dist/lib/types/types-
|
|
1
|
+
export { P as AppiumAgent } from './agent-ae110e80.js';
|
|
2
|
+
export { P as AppiumPage } from './page-97720803.js';
|
|
3
|
+
import '@midscene/core/dist/lib/types/types-95b0888e';
|
|
4
4
|
import '@midscene/core';
|
|
5
5
|
import '@midscene/core/ai-model';
|
|
6
6
|
import '@midscene/shared/fs';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { C as ChromeExtensionPageBrowserSide } from './browser-
|
|
2
|
-
import './page-
|
|
1
|
+
export { C as ChromeExtensionPageBrowserSide } from './browser-9d620553.js';
|
|
2
|
+
import './page-97720803.js';
|
|
3
3
|
import 'playwright';
|
|
4
4
|
import '@midscene/core';
|
|
5
5
|
import '@midscene/shared/extractor';
|
|
6
6
|
import 'puppeteer';
|
|
7
7
|
import '@midscene/shared/constants';
|
|
8
|
-
import '@midscene/core/dist/lib/types/types-
|
|
8
|
+
import '@midscene/core/dist/lib/types/types-95b0888e';
|
|
9
9
|
import 'webdriverio';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { P as PageAgent, a as PageAgentOpt } from './
|
|
2
|
-
import { B as BridgeConnectTabOptions, C as ChromeExtensionPageBrowserSide } from './browser-
|
|
1
|
+
import { P as PageAgent, a as PageAgentOpt } from './agent-ae110e80.js';
|
|
2
|
+
import { B as BridgeConnectTabOptions, C as ChromeExtensionPageBrowserSide } from './browser-9d620553.js';
|
|
3
3
|
export { overrideAIConfig } from '@midscene/core/env';
|
|
4
|
-
import '@midscene/core/dist/lib/types/types-
|
|
5
|
-
import './page-
|
|
4
|
+
import '@midscene/core/dist/lib/types/types-95b0888e';
|
|
5
|
+
import './page-97720803.js';
|
|
6
6
|
import 'playwright';
|
|
7
7
|
import '@midscene/core';
|
|
8
8
|
import '@midscene/shared/extractor';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { C as ChromeExtensionProxyPage } from './page-
|
|
1
|
+
import { C as ChromeExtensionProxyPage } from './page-97720803.js';
|
|
2
2
|
|
|
3
3
|
interface BridgeConnectTabOptions {
|
|
4
4
|
/**
|
|
5
5
|
* If true, the page will always track the active tab.
|
|
6
|
-
* @default
|
|
6
|
+
* @default true
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
forceSameTabNavigation?: boolean;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
declare class BridgeClient {
|
|
@@ -23,7 +23,7 @@ declare class ChromeExtensionPageBrowserSide extends ChromeExtensionProxyPage {
|
|
|
23
23
|
onDisconnect: () => void;
|
|
24
24
|
onLogMessage: (message: string, type: 'log' | 'status') => void;
|
|
25
25
|
bridgeClient: BridgeClient | null;
|
|
26
|
-
constructor(onDisconnect?: () => void, onLogMessage?: (message: string, type: 'log' | 'status') => void,
|
|
26
|
+
constructor(onDisconnect?: () => void, onLogMessage?: (message: string, type: 'log' | 'status') => void, forceSameTabNavigation?: boolean);
|
|
27
27
|
private setupBridgeClient;
|
|
28
28
|
connect(): Promise<void>;
|
|
29
29
|
connectNewTabWithUrl(url: string, options?: BridgeConnectTabOptions): Promise<void>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { C as ChromeExtensionProxyPage } from './page-
|
|
2
|
-
export { E as ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED } from './page-
|
|
3
|
-
import { P as PageAgent } from './
|
|
1
|
+
import { C as ChromeExtensionProxyPage } from './page-97720803.js';
|
|
2
|
+
export { E as ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED } from './page-97720803.js';
|
|
3
|
+
import { P as PageAgent } from './agent-ae110e80.js';
|
|
4
4
|
import 'playwright';
|
|
5
5
|
import '@midscene/core';
|
|
6
6
|
import '@midscene/shared/extractor';
|
|
7
7
|
import 'puppeteer';
|
|
8
8
|
import '@midscene/shared/constants';
|
|
9
|
-
import '@midscene/core/dist/lib/types/types-
|
|
9
|
+
import '@midscene/core/dist/lib/types/types-95b0888e';
|
|
10
10
|
import 'webdriverio';
|
|
11
11
|
import '@midscene/core/ai-model';
|
|
12
12
|
import '@midscene/shared/fs';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export { PlayWrightAiFixtureType, PlaywrightAiFixture } from './playwright.js';
|
|
2
|
-
export { P as
|
|
3
|
-
export { P as AppiumPage, W as WebPage } from './page-77af8d5f.js';
|
|
1
|
+
export { PlayWrightAiFixtureType, PlaywrightAgent, PlaywrightAiFixture } from './playwright.js';
|
|
2
|
+
export { P as AppiumPage, W as WebPage } from './page-97720803.js';
|
|
4
3
|
export { PuppeteerAgent } from './puppeteer.js';
|
|
4
|
+
export { P as AppiumAgent } from './agent-ae110e80.js';
|
|
5
5
|
export { StaticPageAgent } from './playground.js';
|
|
6
|
-
export { S as ScriptPlayer, f as flowItemBrief, p as parseYamlScript } from './utils-
|
|
6
|
+
export { S as ScriptPlayer, f as flowItemBrief, p as parseYamlScript } from './utils-93b3f5f3.js';
|
|
7
|
+
import 'playwright';
|
|
7
8
|
import '@midscene/core';
|
|
8
9
|
import '@playwright/test';
|
|
9
|
-
import 'playwright';
|
|
10
10
|
import '@midscene/core/env';
|
|
11
|
-
import '@midscene/core/dist/lib/types/types-4eebf154';
|
|
12
|
-
import '@midscene/core/ai-model';
|
|
13
|
-
import '@midscene/shared/fs';
|
|
14
11
|
import '@midscene/shared/extractor';
|
|
15
12
|
import 'puppeteer';
|
|
16
13
|
import '@midscene/shared/constants';
|
|
14
|
+
import '@midscene/core/dist/lib/types/types-95b0888e';
|
|
17
15
|
import 'webdriverio';
|
|
16
|
+
import '@midscene/core/ai-model';
|
|
17
|
+
import '@midscene/shared/fs';
|
|
@@ -3,7 +3,7 @@ import { BaseElement, Rect, UIContext, PlaywrightParserOpt, Size, Point, Element
|
|
|
3
3
|
import { ElementInfo, ElementNode } from '@midscene/shared/extractor';
|
|
4
4
|
import { KeyInput, Page as Page$2 } from 'puppeteer';
|
|
5
5
|
import { NodeType } from '@midscene/shared/constants';
|
|
6
|
-
import * as
|
|
6
|
+
import * as _midscene_core_dist_lib_types_types_95b0888e from '@midscene/core/dist/lib/types/types-95b0888e';
|
|
7
7
|
import { Browser } from 'webdriverio';
|
|
8
8
|
|
|
9
9
|
declare class WebElementInfo implements BaseElement {
|
|
@@ -62,7 +62,13 @@ interface MouseAction {
|
|
|
62
62
|
}
|
|
63
63
|
interface KeyboardAction {
|
|
64
64
|
type: (text: string) => Promise<void>;
|
|
65
|
-
press: (
|
|
65
|
+
press: (action: {
|
|
66
|
+
key: WebKeyInput;
|
|
67
|
+
command?: string;
|
|
68
|
+
} | {
|
|
69
|
+
key: WebKeyInput;
|
|
70
|
+
command?: string;
|
|
71
|
+
}[]) => Promise<void>;
|
|
66
72
|
}
|
|
67
73
|
declare abstract class AbstractPage {
|
|
68
74
|
abstract pageType: string;
|
|
@@ -115,7 +121,13 @@ declare class Page$1 implements AbstractPage {
|
|
|
115
121
|
};
|
|
116
122
|
get keyboard(): {
|
|
117
123
|
type: (text: string) => Promise<void>;
|
|
118
|
-
press: (
|
|
124
|
+
press: (action: {
|
|
125
|
+
key: WebKeyInput$1;
|
|
126
|
+
command?: string;
|
|
127
|
+
} | {
|
|
128
|
+
key: WebKeyInput$1;
|
|
129
|
+
command?: string;
|
|
130
|
+
}[]) => Promise<void>;
|
|
119
131
|
};
|
|
120
132
|
clearInput(element: ElementInfo): Promise<void>;
|
|
121
133
|
url(): string;
|
|
@@ -129,6 +141,7 @@ declare class Page$1 implements AbstractPage {
|
|
|
129
141
|
scrollRight(distance?: number, startingPoint?: Point): Promise<void>;
|
|
130
142
|
private keyboardType;
|
|
131
143
|
private keyboardPress;
|
|
144
|
+
private keyboardPressAction;
|
|
132
145
|
private mouseClick;
|
|
133
146
|
private mouseMove;
|
|
134
147
|
private mouseDrag;
|
|
@@ -138,14 +151,14 @@ declare class Page$1 implements AbstractPage {
|
|
|
138
151
|
|
|
139
152
|
declare class ChromeExtensionProxyPage implements AbstractPage {
|
|
140
153
|
pageType: string;
|
|
141
|
-
|
|
154
|
+
forceSameTabNavigation: boolean;
|
|
142
155
|
private version;
|
|
143
156
|
private viewportSize?;
|
|
144
157
|
private activeTabId;
|
|
145
158
|
private tabIdOfDebuggerAttached;
|
|
146
159
|
private attachingDebugger;
|
|
147
160
|
private destroyed;
|
|
148
|
-
constructor(
|
|
161
|
+
constructor(forceSameTabNavigation: boolean);
|
|
149
162
|
getTabId(): Promise<number>;
|
|
150
163
|
private attachDebugger;
|
|
151
164
|
private showMousePointer;
|
|
@@ -184,7 +197,13 @@ declare class ChromeExtensionProxyPage implements AbstractPage {
|
|
|
184
197
|
};
|
|
185
198
|
keyboard: {
|
|
186
199
|
type: (text: string) => Promise<void>;
|
|
187
|
-
press: (
|
|
200
|
+
press: (action: {
|
|
201
|
+
key: WebKeyInput;
|
|
202
|
+
command?: string;
|
|
203
|
+
} | {
|
|
204
|
+
key: WebKeyInput;
|
|
205
|
+
command?: string;
|
|
206
|
+
}[]) => Promise<void>;
|
|
188
207
|
};
|
|
189
208
|
destroy(): Promise<void>;
|
|
190
209
|
}
|
|
@@ -195,7 +214,7 @@ declare class StaticPage implements AbstractPage {
|
|
|
195
214
|
constructor(uiContext: WebUIContext);
|
|
196
215
|
getElementsInfo(): Promise<any>;
|
|
197
216
|
getElementsNodeTree(): Promise<any>;
|
|
198
|
-
size(): Promise<
|
|
217
|
+
size(): Promise<_midscene_core_dist_lib_types_types_95b0888e.S>;
|
|
199
218
|
screenshotBase64(): Promise<string>;
|
|
200
219
|
url(): Promise<string>;
|
|
201
220
|
scrollUntilTop(startingPoint?: Point): Promise<any>;
|
|
@@ -227,6 +246,7 @@ declare class Page<AgentType extends 'puppeteer' | 'playwright', PageType extend
|
|
|
227
246
|
pageType: AgentType;
|
|
228
247
|
private evaluate;
|
|
229
248
|
constructor(underlyingPage: PageType, pageType: AgentType);
|
|
249
|
+
waitForNavigation(): Promise<void>;
|
|
230
250
|
getElementsInfo(): Promise<ElementInfo[]>;
|
|
231
251
|
getElementsNodeTree(): Promise<ElementTreeNode<ElementInfo>>;
|
|
232
252
|
size(): Promise<Size>;
|
|
@@ -249,7 +269,13 @@ declare class Page<AgentType extends 'puppeteer' | 'playwright', PageType extend
|
|
|
249
269
|
};
|
|
250
270
|
get keyboard(): {
|
|
251
271
|
type: (text: string) => Promise<void>;
|
|
252
|
-
press: (
|
|
272
|
+
press: (action: {
|
|
273
|
+
key: WebKeyInput;
|
|
274
|
+
command?: string;
|
|
275
|
+
} | {
|
|
276
|
+
key: WebKeyInput;
|
|
277
|
+
command?: string;
|
|
278
|
+
}[]) => Promise<void>;
|
|
253
279
|
down: (key: WebKeyInput) => Promise<void>;
|
|
254
280
|
up: (key: WebKeyInput) => Promise<void>;
|
|
255
281
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { S as StaticPage } from './page-
|
|
2
|
-
export { E as ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED } from './page-
|
|
3
|
-
import { P as PageAgent } from './
|
|
1
|
+
import { S as StaticPage } from './page-97720803.js';
|
|
2
|
+
export { E as ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED } from './page-97720803.js';
|
|
3
|
+
import { P as PageAgent } from './agent-ae110e80.js';
|
|
4
4
|
import 'playwright';
|
|
5
5
|
import '@midscene/core';
|
|
6
6
|
import '@midscene/shared/extractor';
|
|
7
7
|
import 'puppeteer';
|
|
8
8
|
import '@midscene/shared/constants';
|
|
9
|
-
import '@midscene/core/dist/lib/types/types-
|
|
9
|
+
import '@midscene/core/dist/lib/types/types-95b0888e';
|
|
10
10
|
import 'webdriverio';
|
|
11
11
|
import '@midscene/core/ai-model';
|
|
12
12
|
import '@midscene/shared/fs';
|