@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
package/dist/es/index.js
CHANGED
|
@@ -472,6 +472,23 @@ function scrollParamStr(scrollParam) {
|
|
|
472
472
|
}
|
|
473
473
|
return `${scrollParam.direction || "down"}, ${scrollParam.scrollType || "once"}, ${scrollParam.distance || "distance-not-set"}`;
|
|
474
474
|
}
|
|
475
|
+
function pullParamStr(pullParam) {
|
|
476
|
+
if (!pullParam) {
|
|
477
|
+
return "";
|
|
478
|
+
}
|
|
479
|
+
const parts = [];
|
|
480
|
+
parts.push(`direction: ${pullParam.direction || "down"}`);
|
|
481
|
+
if (pullParam.startPoint) {
|
|
482
|
+
parts.push(`start: (${pullParam.startPoint.x}, ${pullParam.startPoint.y})`);
|
|
483
|
+
}
|
|
484
|
+
if (pullParam.distance) {
|
|
485
|
+
parts.push(`distance: ${pullParam.distance}`);
|
|
486
|
+
}
|
|
487
|
+
if (pullParam.duration) {
|
|
488
|
+
parts.push(`duration: ${pullParam.duration}ms`);
|
|
489
|
+
}
|
|
490
|
+
return parts.join(", ");
|
|
491
|
+
}
|
|
475
492
|
function taskTitleStr(type, prompt) {
|
|
476
493
|
if (prompt) {
|
|
477
494
|
return `${type} - ${prompt}`;
|
|
@@ -494,6 +511,8 @@ function paramStr(task) {
|
|
|
494
511
|
value = `${task?.param?.timeMs}ms`;
|
|
495
512
|
} else if (typeof task?.param?.scrollType === "string") {
|
|
496
513
|
value = scrollParamStr(task?.param);
|
|
514
|
+
} else if (typeof task?.param?.direction === "string" && task?.subType === "AndroidPull") {
|
|
515
|
+
value = pullParamStr(task?.param);
|
|
497
516
|
} else if (typeof task?.param?.value !== "undefined") {
|
|
498
517
|
value = task?.param?.value;
|
|
499
518
|
}
|
|
@@ -564,7 +583,7 @@ import yaml3 from "js-yaml";
|
|
|
564
583
|
import semver from "semver";
|
|
565
584
|
|
|
566
585
|
// package.json
|
|
567
|
-
var version = "0.24.
|
|
586
|
+
var version = "0.24.2-beta-20250730123854.0";
|
|
568
587
|
|
|
569
588
|
// src/common/task-cache.ts
|
|
570
589
|
var DEFAULT_CACHE_MAX_FILENAME_LENGTH = 200;
|
|
@@ -708,7 +727,18 @@ cache file: ${cacheFile}`
|
|
|
708
727
|
mkdirSync2(dir, { recursive: true });
|
|
709
728
|
debug("created cache directory: %s", dir);
|
|
710
729
|
}
|
|
711
|
-
const
|
|
730
|
+
const sortedCaches = [...this.cache.caches].sort((a, b) => {
|
|
731
|
+
if (a.type === "plan" && b.type === "locate")
|
|
732
|
+
return -1;
|
|
733
|
+
if (a.type === "locate" && b.type === "plan")
|
|
734
|
+
return 1;
|
|
735
|
+
return 0;
|
|
736
|
+
});
|
|
737
|
+
const cacheToWrite = {
|
|
738
|
+
...this.cache,
|
|
739
|
+
caches: sortedCaches
|
|
740
|
+
};
|
|
741
|
+
const yamlData = yaml3.dump(cacheToWrite);
|
|
712
742
|
writeFileSync2(this.cacheFilePath, yamlData);
|
|
713
743
|
debug("cache flushed to file: %s", this.cacheFilePath);
|
|
714
744
|
} catch (err) {
|
|
@@ -925,6 +955,16 @@ var PageTaskExecutor = class {
|
|
|
925
955
|
}
|
|
926
956
|
async getElementXpath(pageContext, element) {
|
|
927
957
|
let elementId = element?.id;
|
|
958
|
+
if (element?.isOrderSensitive !== void 0) {
|
|
959
|
+
const xpaths = await this.page.getXpathsByPoint(
|
|
960
|
+
{
|
|
961
|
+
left: element.center[0],
|
|
962
|
+
top: element.center[1]
|
|
963
|
+
},
|
|
964
|
+
element?.isOrderSensitive
|
|
965
|
+
);
|
|
966
|
+
return xpaths;
|
|
967
|
+
}
|
|
928
968
|
if (element?.attributes?.nodeType === NodeType.POSITION) {
|
|
929
969
|
await this.insight.contextRetrieverFn("locate");
|
|
930
970
|
const info = elementByPositionWithElementInfo2(
|
|
@@ -1419,6 +1459,51 @@ var PageTaskExecutor = class {
|
|
|
1419
1459
|
}
|
|
1420
1460
|
};
|
|
1421
1461
|
tasks.push(taskActionAndroidRecentAppsButton);
|
|
1462
|
+
} else if (plan2.type === "AndroidLongPress") {
|
|
1463
|
+
const taskActionAndroidLongPress = {
|
|
1464
|
+
type: "Action",
|
|
1465
|
+
subType: "AndroidLongPress",
|
|
1466
|
+
param: plan2.param,
|
|
1467
|
+
thought: plan2.thought,
|
|
1468
|
+
locate: plan2.locate,
|
|
1469
|
+
executor: async (param) => {
|
|
1470
|
+
assert5(
|
|
1471
|
+
isAndroidPage(this.page),
|
|
1472
|
+
"Cannot use long press on non-Android devices"
|
|
1473
|
+
);
|
|
1474
|
+
const { x, y, duration } = param;
|
|
1475
|
+
await this.page.longPress(x, y, duration);
|
|
1476
|
+
}
|
|
1477
|
+
};
|
|
1478
|
+
tasks.push(taskActionAndroidLongPress);
|
|
1479
|
+
} else if (plan2.type === "AndroidPull") {
|
|
1480
|
+
const taskActionAndroidPull = {
|
|
1481
|
+
type: "Action",
|
|
1482
|
+
subType: "AndroidPull",
|
|
1483
|
+
param: plan2.param,
|
|
1484
|
+
thought: plan2.thought,
|
|
1485
|
+
locate: plan2.locate,
|
|
1486
|
+
executor: async (param) => {
|
|
1487
|
+
assert5(
|
|
1488
|
+
isAndroidPage(this.page),
|
|
1489
|
+
"Cannot use pull action on non-Android devices"
|
|
1490
|
+
);
|
|
1491
|
+
const { direction, startPoint, distance, duration } = param;
|
|
1492
|
+
const convertedStartPoint = startPoint ? { left: startPoint.x, top: startPoint.y } : void 0;
|
|
1493
|
+
if (direction === "down") {
|
|
1494
|
+
await this.page.pullDown(
|
|
1495
|
+
convertedStartPoint,
|
|
1496
|
+
distance,
|
|
1497
|
+
duration
|
|
1498
|
+
);
|
|
1499
|
+
} else if (direction === "up") {
|
|
1500
|
+
await this.page.pullUp(convertedStartPoint, distance, duration);
|
|
1501
|
+
} else {
|
|
1502
|
+
throw new Error(`Unknown pull direction: ${direction}`);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
};
|
|
1506
|
+
tasks.push(taskActionAndroidPull);
|
|
1422
1507
|
} else {
|
|
1423
1508
|
throw new Error(`Unknown or unsupported task type: ${plan2.type}`);
|
|
1424
1509
|
}
|
|
@@ -2636,6 +2721,12 @@ var Page = class {
|
|
|
2636
2721
|
`${elementInfosScriptContent}midscene_element_inspector.getXpathsById('${id}')`
|
|
2637
2722
|
);
|
|
2638
2723
|
}
|
|
2724
|
+
async getXpathsByPoint(point, isOrderSensitive) {
|
|
2725
|
+
const elementInfosScriptContent = getElementInfosScriptContent();
|
|
2726
|
+
return this.evaluateJavaScript(
|
|
2727
|
+
`${elementInfosScriptContent}midscene_element_inspector.getXpathsByPoint({left: ${point.left}, top: ${point.top}}, ${isOrderSensitive})`
|
|
2728
|
+
);
|
|
2729
|
+
}
|
|
2639
2730
|
async getElementInfoByXpath(xpath) {
|
|
2640
2731
|
const elementInfosScriptContent = getElementInfosScriptContent();
|
|
2641
2732
|
return this.evaluateJavaScript(
|