@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
|
@@ -497,6 +497,23 @@ function scrollParamStr(scrollParam) {
|
|
|
497
497
|
}
|
|
498
498
|
return `${scrollParam.direction || "down"}, ${scrollParam.scrollType || "once"}, ${scrollParam.distance || "distance-not-set"}`;
|
|
499
499
|
}
|
|
500
|
+
function pullParamStr(pullParam) {
|
|
501
|
+
if (!pullParam) {
|
|
502
|
+
return "";
|
|
503
|
+
}
|
|
504
|
+
const parts = [];
|
|
505
|
+
parts.push(`direction: ${pullParam.direction || "down"}`);
|
|
506
|
+
if (pullParam.startPoint) {
|
|
507
|
+
parts.push(`start: (${pullParam.startPoint.x}, ${pullParam.startPoint.y})`);
|
|
508
|
+
}
|
|
509
|
+
if (pullParam.distance) {
|
|
510
|
+
parts.push(`distance: ${pullParam.distance}`);
|
|
511
|
+
}
|
|
512
|
+
if (pullParam.duration) {
|
|
513
|
+
parts.push(`duration: ${pullParam.duration}ms`);
|
|
514
|
+
}
|
|
515
|
+
return parts.join(", ");
|
|
516
|
+
}
|
|
500
517
|
function taskTitleStr(type, prompt) {
|
|
501
518
|
if (prompt) {
|
|
502
519
|
return `${type} - ${prompt}`;
|
|
@@ -519,6 +536,8 @@ function paramStr(task) {
|
|
|
519
536
|
value = `${task?.param?.timeMs}ms`;
|
|
520
537
|
} else if (typeof task?.param?.scrollType === "string") {
|
|
521
538
|
value = scrollParamStr(task?.param);
|
|
539
|
+
} else if (typeof task?.param?.direction === "string" && task?.subType === "AndroidPull") {
|
|
540
|
+
value = pullParamStr(task?.param);
|
|
522
541
|
} else if (typeof task?.param?.value !== "undefined") {
|
|
523
542
|
value = task?.param?.value;
|
|
524
543
|
}
|
|
@@ -582,7 +601,7 @@ var import_js_yaml3 = __toESM(require("js-yaml"));
|
|
|
582
601
|
var import_semver = __toESM(require("semver"));
|
|
583
602
|
|
|
584
603
|
// package.json
|
|
585
|
-
var version = "0.24.
|
|
604
|
+
var version = "0.24.2-beta-20250730123854.0";
|
|
586
605
|
|
|
587
606
|
// src/common/task-cache.ts
|
|
588
607
|
var DEFAULT_CACHE_MAX_FILENAME_LENGTH = 200;
|
|
@@ -726,7 +745,18 @@ cache file: ${cacheFile}`
|
|
|
726
745
|
(0, import_node_fs2.mkdirSync)(dir, { recursive: true });
|
|
727
746
|
debug("created cache directory: %s", dir);
|
|
728
747
|
}
|
|
729
|
-
const
|
|
748
|
+
const sortedCaches = [...this.cache.caches].sort((a, b) => {
|
|
749
|
+
if (a.type === "plan" && b.type === "locate")
|
|
750
|
+
return -1;
|
|
751
|
+
if (a.type === "locate" && b.type === "plan")
|
|
752
|
+
return 1;
|
|
753
|
+
return 0;
|
|
754
|
+
});
|
|
755
|
+
const cacheToWrite = {
|
|
756
|
+
...this.cache,
|
|
757
|
+
caches: sortedCaches
|
|
758
|
+
};
|
|
759
|
+
const yamlData = import_js_yaml3.default.dump(cacheToWrite);
|
|
730
760
|
(0, import_node_fs2.writeFileSync)(this.cacheFilePath, yamlData);
|
|
731
761
|
debug("cache flushed to file: %s", this.cacheFilePath);
|
|
732
762
|
} catch (err) {
|
|
@@ -943,6 +973,16 @@ var PageTaskExecutor = class {
|
|
|
943
973
|
}
|
|
944
974
|
async getElementXpath(pageContext, element) {
|
|
945
975
|
let elementId = element?.id;
|
|
976
|
+
if (element?.isOrderSensitive !== void 0) {
|
|
977
|
+
const xpaths = await this.page.getXpathsByPoint(
|
|
978
|
+
{
|
|
979
|
+
left: element.center[0],
|
|
980
|
+
top: element.center[1]
|
|
981
|
+
},
|
|
982
|
+
element?.isOrderSensitive
|
|
983
|
+
);
|
|
984
|
+
return xpaths;
|
|
985
|
+
}
|
|
946
986
|
if (element?.attributes?.nodeType === import_constants.NodeType.POSITION) {
|
|
947
987
|
await this.insight.contextRetrieverFn("locate");
|
|
948
988
|
const info = (0, import_ai_model2.elementByPositionWithElementInfo)(
|
|
@@ -1437,6 +1477,51 @@ var PageTaskExecutor = class {
|
|
|
1437
1477
|
}
|
|
1438
1478
|
};
|
|
1439
1479
|
tasks.push(taskActionAndroidRecentAppsButton);
|
|
1480
|
+
} else if (plan2.type === "AndroidLongPress") {
|
|
1481
|
+
const taskActionAndroidLongPress = {
|
|
1482
|
+
type: "Action",
|
|
1483
|
+
subType: "AndroidLongPress",
|
|
1484
|
+
param: plan2.param,
|
|
1485
|
+
thought: plan2.thought,
|
|
1486
|
+
locate: plan2.locate,
|
|
1487
|
+
executor: async (param) => {
|
|
1488
|
+
(0, import_utils9.assert)(
|
|
1489
|
+
isAndroidPage(this.page),
|
|
1490
|
+
"Cannot use long press on non-Android devices"
|
|
1491
|
+
);
|
|
1492
|
+
const { x, y, duration } = param;
|
|
1493
|
+
await this.page.longPress(x, y, duration);
|
|
1494
|
+
}
|
|
1495
|
+
};
|
|
1496
|
+
tasks.push(taskActionAndroidLongPress);
|
|
1497
|
+
} else if (plan2.type === "AndroidPull") {
|
|
1498
|
+
const taskActionAndroidPull = {
|
|
1499
|
+
type: "Action",
|
|
1500
|
+
subType: "AndroidPull",
|
|
1501
|
+
param: plan2.param,
|
|
1502
|
+
thought: plan2.thought,
|
|
1503
|
+
locate: plan2.locate,
|
|
1504
|
+
executor: async (param) => {
|
|
1505
|
+
(0, import_utils9.assert)(
|
|
1506
|
+
isAndroidPage(this.page),
|
|
1507
|
+
"Cannot use pull action on non-Android devices"
|
|
1508
|
+
);
|
|
1509
|
+
const { direction, startPoint, distance, duration } = param;
|
|
1510
|
+
const convertedStartPoint = startPoint ? { left: startPoint.x, top: startPoint.y } : void 0;
|
|
1511
|
+
if (direction === "down") {
|
|
1512
|
+
await this.page.pullDown(
|
|
1513
|
+
convertedStartPoint,
|
|
1514
|
+
distance,
|
|
1515
|
+
duration
|
|
1516
|
+
);
|
|
1517
|
+
} else if (direction === "up") {
|
|
1518
|
+
await this.page.pullUp(convertedStartPoint, distance, duration);
|
|
1519
|
+
} else {
|
|
1520
|
+
throw new Error(`Unknown pull direction: ${direction}`);
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
};
|
|
1524
|
+
tasks.push(taskActionAndroidPull);
|
|
1440
1525
|
} else {
|
|
1441
1526
|
throw new Error(`Unknown or unsupported task type: ${plan2.type}`);
|
|
1442
1527
|
}
|
|
@@ -2651,6 +2736,12 @@ var Page = class {
|
|
|
2651
2736
|
`${elementInfosScriptContent}midscene_element_inspector.getXpathsById('${id}')`
|
|
2652
2737
|
);
|
|
2653
2738
|
}
|
|
2739
|
+
async getXpathsByPoint(point, isOrderSensitive) {
|
|
2740
|
+
const elementInfosScriptContent = (0, import_fs.getElementInfosScriptContent)();
|
|
2741
|
+
return this.evaluateJavaScript(
|
|
2742
|
+
`${elementInfosScriptContent}midscene_element_inspector.getXpathsByPoint({left: ${point.left}, top: ${point.top}}, ${isOrderSensitive})`
|
|
2743
|
+
);
|
|
2744
|
+
}
|
|
2654
2745
|
async getElementInfoByXpath(xpath) {
|
|
2655
2746
|
const elementInfosScriptContent = (0, import_fs.getElementInfosScriptContent)();
|
|
2656
2747
|
return this.evaluateJavaScript(
|