@midscene/web 0.24.1 → 0.24.2-beta-20250730123854.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.js +87 -2
- package/dist/es/agent.js.map +1 -1
- package/dist/es/bridge-mode-browser.js +14 -3
- package/dist/es/bridge-mode-browser.js.map +1 -1
- package/dist/es/bridge-mode.js +89 -4
- package/dist/es/bridge-mode.js.map +1 -1
- package/dist/es/chrome-extension.js +99 -3
- package/dist/es/chrome-extension.js.map +1 -1
- package/dist/es/index.js +93 -2
- package/dist/es/index.js.map +1 -1
- package/dist/es/midscene-playground.js +90 -2
- package/dist/es/midscene-playground.js.map +1 -1
- package/dist/es/midscene-server.js.map +1 -1
- package/dist/es/playground.js +90 -2
- package/dist/es/playground.js.map +1 -1
- package/dist/es/playwright-report.js +3 -4
- package/dist/es/playwright-report.js.map +1 -1
- package/dist/es/playwright-reporter.js +3 -4
- package/dist/es/playwright-reporter.js.map +1 -1
- package/dist/es/playwright.js +93 -2
- package/dist/es/playwright.js.map +1 -1
- package/dist/es/puppeteer-agent-launcher.js +93 -2
- package/dist/es/puppeteer-agent-launcher.js.map +1 -1
- package/dist/es/puppeteer.js +93 -2
- package/dist/es/puppeteer.js.map +1 -1
- package/dist/es/ui-utils.js +20 -0
- package/dist/es/ui-utils.js.map +1 -1
- package/dist/es/utils.js.map +1 -1
- package/dist/lib/agent.js +87 -2
- package/dist/lib/agent.js.map +1 -1
- package/dist/lib/bridge-mode-browser.js +14 -3
- package/dist/lib/bridge-mode-browser.js.map +1 -1
- package/dist/lib/bridge-mode.js +89 -4
- package/dist/lib/bridge-mode.js.map +1 -1
- package/dist/lib/chrome-extension.js +99 -3
- package/dist/lib/chrome-extension.js.map +1 -1
- package/dist/lib/index.js +93 -2
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/midscene-playground.js +90 -2
- package/dist/lib/midscene-playground.js.map +1 -1
- package/dist/lib/midscene-server.js.map +1 -1
- package/dist/lib/playground.js +90 -2
- package/dist/lib/playground.js.map +1 -1
- package/dist/lib/playwright-report.js +3 -4
- package/dist/lib/playwright-report.js.map +1 -1
- package/dist/lib/playwright-reporter.js +3 -4
- package/dist/lib/playwright-reporter.js.map +1 -1
- package/dist/lib/playwright.js +93 -2
- package/dist/lib/playwright.js.map +1 -1
- package/dist/lib/puppeteer-agent-launcher.js +93 -2
- package/dist/lib/puppeteer-agent-launcher.js.map +1 -1
- package/dist/lib/puppeteer.js +93 -2
- package/dist/lib/puppeteer.js.map +1 -1
- package/dist/lib/ui-utils.js +21 -0
- package/dist/lib/ui-utils.js.map +1 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/types/agent.d.ts +1 -1
- package/dist/types/bridge-mode-browser.d.ts +2 -2
- package/dist/types/bridge-mode.d.ts +2 -2
- package/dist/types/{browser-a44b28ea.d.ts → browser-e74eab47.d.ts} +1 -1
- package/dist/types/chrome-extension.d.ts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/midscene-server.d.ts +1 -1
- package/dist/types/{page-b8f0ca7d.d.ts → page-34780923.d.ts} +15 -0
- package/dist/types/playground.d.ts +2 -2
- package/dist/types/playwright-report.d.ts +5 -1
- package/dist/types/playwright.d.ts +1 -1
- package/dist/types/puppeteer-agent-launcher.d.ts +1 -1
- package/dist/types/puppeteer.d.ts +2 -2
- package/dist/types/ui-utils.d.ts +3 -2
- package/dist/types/{utils-fcd484e0.d.ts → utils-169da810.d.ts} +1 -1
- package/dist/types/utils.d.ts +1 -1
- package/dist/types/yaml.d.ts +2 -2
- package/package.json +3 -3
|
@@ -75,7 +75,7 @@ import yaml from "js-yaml";
|
|
|
75
75
|
import semver from "semver";
|
|
76
76
|
|
|
77
77
|
// package.json
|
|
78
|
-
var version = "0.24.
|
|
78
|
+
var version = "0.24.2-beta-20250730123854.0";
|
|
79
79
|
|
|
80
80
|
// src/common/task-cache.ts
|
|
81
81
|
var DEFAULT_CACHE_MAX_FILENAME_LENGTH = 200;
|
|
@@ -219,7 +219,18 @@ cache file: ${cacheFile}`
|
|
|
219
219
|
mkdirSync(dir, { recursive: true });
|
|
220
220
|
debug("created cache directory: %s", dir);
|
|
221
221
|
}
|
|
222
|
-
const
|
|
222
|
+
const sortedCaches = [...this.cache.caches].sort((a, b) => {
|
|
223
|
+
if (a.type === "plan" && b.type === "locate")
|
|
224
|
+
return -1;
|
|
225
|
+
if (a.type === "locate" && b.type === "plan")
|
|
226
|
+
return 1;
|
|
227
|
+
return 0;
|
|
228
|
+
});
|
|
229
|
+
const cacheToWrite = {
|
|
230
|
+
...this.cache,
|
|
231
|
+
caches: sortedCaches
|
|
232
|
+
};
|
|
233
|
+
const yamlData = yaml.dump(cacheToWrite);
|
|
223
234
|
writeFileSync(this.cacheFilePath, yamlData);
|
|
224
235
|
debug("cache flushed to file: %s", this.cacheFilePath);
|
|
225
236
|
} catch (err) {
|
|
@@ -857,6 +868,23 @@ function scrollParamStr(scrollParam) {
|
|
|
857
868
|
}
|
|
858
869
|
return `${scrollParam.direction || "down"}, ${scrollParam.scrollType || "once"}, ${scrollParam.distance || "distance-not-set"}`;
|
|
859
870
|
}
|
|
871
|
+
function pullParamStr(pullParam) {
|
|
872
|
+
if (!pullParam) {
|
|
873
|
+
return "";
|
|
874
|
+
}
|
|
875
|
+
const parts = [];
|
|
876
|
+
parts.push(`direction: ${pullParam.direction || "down"}`);
|
|
877
|
+
if (pullParam.startPoint) {
|
|
878
|
+
parts.push(`start: (${pullParam.startPoint.x}, ${pullParam.startPoint.y})`);
|
|
879
|
+
}
|
|
880
|
+
if (pullParam.distance) {
|
|
881
|
+
parts.push(`distance: ${pullParam.distance}`);
|
|
882
|
+
}
|
|
883
|
+
if (pullParam.duration) {
|
|
884
|
+
parts.push(`duration: ${pullParam.duration}ms`);
|
|
885
|
+
}
|
|
886
|
+
return parts.join(", ");
|
|
887
|
+
}
|
|
860
888
|
function taskTitleStr(type, prompt) {
|
|
861
889
|
if (prompt) {
|
|
862
890
|
return `${type} - ${prompt}`;
|
|
@@ -879,6 +907,8 @@ function paramStr(task) {
|
|
|
879
907
|
value = `${task?.param?.timeMs}ms`;
|
|
880
908
|
} else if (typeof task?.param?.scrollType === "string") {
|
|
881
909
|
value = scrollParamStr(task?.param);
|
|
910
|
+
} else if (typeof task?.param?.direction === "string" && task?.subType === "AndroidPull") {
|
|
911
|
+
value = pullParamStr(task?.param);
|
|
882
912
|
} else if (typeof task?.param?.value !== "undefined") {
|
|
883
913
|
value = task?.param?.value;
|
|
884
914
|
}
|
|
@@ -944,6 +974,16 @@ var PageTaskExecutor = class {
|
|
|
944
974
|
}
|
|
945
975
|
async getElementXpath(pageContext, element) {
|
|
946
976
|
let elementId = element?.id;
|
|
977
|
+
if (element?.isOrderSensitive !== void 0) {
|
|
978
|
+
const xpaths = await this.page.getXpathsByPoint(
|
|
979
|
+
{
|
|
980
|
+
left: element.center[0],
|
|
981
|
+
top: element.center[1]
|
|
982
|
+
},
|
|
983
|
+
element?.isOrderSensitive
|
|
984
|
+
);
|
|
985
|
+
return xpaths;
|
|
986
|
+
}
|
|
947
987
|
if (element?.attributes?.nodeType === NodeType.POSITION) {
|
|
948
988
|
await this.insight.contextRetrieverFn("locate");
|
|
949
989
|
const info = elementByPositionWithElementInfo2(
|
|
@@ -1438,6 +1478,51 @@ var PageTaskExecutor = class {
|
|
|
1438
1478
|
}
|
|
1439
1479
|
};
|
|
1440
1480
|
tasks.push(taskActionAndroidRecentAppsButton);
|
|
1481
|
+
} else if (plan2.type === "AndroidLongPress") {
|
|
1482
|
+
const taskActionAndroidLongPress = {
|
|
1483
|
+
type: "Action",
|
|
1484
|
+
subType: "AndroidLongPress",
|
|
1485
|
+
param: plan2.param,
|
|
1486
|
+
thought: plan2.thought,
|
|
1487
|
+
locate: plan2.locate,
|
|
1488
|
+
executor: async (param) => {
|
|
1489
|
+
assert5(
|
|
1490
|
+
isAndroidPage(this.page),
|
|
1491
|
+
"Cannot use long press on non-Android devices"
|
|
1492
|
+
);
|
|
1493
|
+
const { x, y, duration } = param;
|
|
1494
|
+
await this.page.longPress(x, y, duration);
|
|
1495
|
+
}
|
|
1496
|
+
};
|
|
1497
|
+
tasks.push(taskActionAndroidLongPress);
|
|
1498
|
+
} else if (plan2.type === "AndroidPull") {
|
|
1499
|
+
const taskActionAndroidPull = {
|
|
1500
|
+
type: "Action",
|
|
1501
|
+
subType: "AndroidPull",
|
|
1502
|
+
param: plan2.param,
|
|
1503
|
+
thought: plan2.thought,
|
|
1504
|
+
locate: plan2.locate,
|
|
1505
|
+
executor: async (param) => {
|
|
1506
|
+
assert5(
|
|
1507
|
+
isAndroidPage(this.page),
|
|
1508
|
+
"Cannot use pull action on non-Android devices"
|
|
1509
|
+
);
|
|
1510
|
+
const { direction, startPoint, distance, duration } = param;
|
|
1511
|
+
const convertedStartPoint = startPoint ? { left: startPoint.x, top: startPoint.y } : void 0;
|
|
1512
|
+
if (direction === "down") {
|
|
1513
|
+
await this.page.pullDown(
|
|
1514
|
+
convertedStartPoint,
|
|
1515
|
+
distance,
|
|
1516
|
+
duration
|
|
1517
|
+
);
|
|
1518
|
+
} else if (direction === "up") {
|
|
1519
|
+
await this.page.pullUp(convertedStartPoint, distance, duration);
|
|
1520
|
+
} else {
|
|
1521
|
+
throw new Error(`Unknown pull direction: ${direction}`);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
};
|
|
1525
|
+
tasks.push(taskActionAndroidPull);
|
|
1441
1526
|
} else {
|
|
1442
1527
|
throw new Error(`Unknown or unsupported task type: ${plan2.type}`);
|
|
1443
1528
|
}
|
|
@@ -2794,7 +2879,7 @@ function sleep2(ms) {
|
|
|
2794
2879
|
var ChromeExtensionProxyPage = class {
|
|
2795
2880
|
constructor(forceSameTabNavigation) {
|
|
2796
2881
|
this.pageType = "chrome-extension-proxy";
|
|
2797
|
-
this.version = "0.24.
|
|
2882
|
+
this.version = "0.24.2-beta-20250730123854.0";
|
|
2798
2883
|
this.activeTabId = null;
|
|
2799
2884
|
this.tabIdOfDebuggerAttached = null;
|
|
2800
2885
|
this.attachingDebugger = null;
|
|
@@ -3141,6 +3226,17 @@ var ChromeExtensionProxyPage = class {
|
|
|
3141
3226
|
});
|
|
3142
3227
|
return result.result.value;
|
|
3143
3228
|
}
|
|
3229
|
+
async getXpathsByPoint(point, isOrderSensitive) {
|
|
3230
|
+
const script = await getHtmlElementScript();
|
|
3231
|
+
await this.sendCommandToDebugger("Runtime.evaluate", {
|
|
3232
|
+
expression: script
|
|
3233
|
+
});
|
|
3234
|
+
const result = await this.sendCommandToDebugger("Runtime.evaluate", {
|
|
3235
|
+
expression: `window.midscene_element_inspector.getXpathsByPoint({left: ${point.left}, top: ${point.top}}, ${isOrderSensitive})`,
|
|
3236
|
+
returnByValue: true
|
|
3237
|
+
});
|
|
3238
|
+
return result.result.value;
|
|
3239
|
+
}
|
|
3144
3240
|
async getElementInfoByXpath(xpath) {
|
|
3145
3241
|
const script = await getHtmlElementScript();
|
|
3146
3242
|
await this.sendCommandToDebugger("Runtime.evaluate", {
|