@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/agent.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) {
|
|
@@ -897,6 +927,16 @@ var PageTaskExecutor = class {
|
|
|
897
927
|
}
|
|
898
928
|
async getElementXpath(pageContext, element) {
|
|
899
929
|
let elementId = element?.id;
|
|
930
|
+
if (element?.isOrderSensitive !== void 0) {
|
|
931
|
+
const xpaths = await this.page.getXpathsByPoint(
|
|
932
|
+
{
|
|
933
|
+
left: element.center[0],
|
|
934
|
+
top: element.center[1]
|
|
935
|
+
},
|
|
936
|
+
element?.isOrderSensitive
|
|
937
|
+
);
|
|
938
|
+
return xpaths;
|
|
939
|
+
}
|
|
900
940
|
if (element?.attributes?.nodeType === NodeType.POSITION) {
|
|
901
941
|
await this.insight.contextRetrieverFn("locate");
|
|
902
942
|
const info = elementByPositionWithElementInfo2(
|
|
@@ -1391,6 +1431,51 @@ var PageTaskExecutor = class {
|
|
|
1391
1431
|
}
|
|
1392
1432
|
};
|
|
1393
1433
|
tasks.push(taskActionAndroidRecentAppsButton);
|
|
1434
|
+
} else if (plan2.type === "AndroidLongPress") {
|
|
1435
|
+
const taskActionAndroidLongPress = {
|
|
1436
|
+
type: "Action",
|
|
1437
|
+
subType: "AndroidLongPress",
|
|
1438
|
+
param: plan2.param,
|
|
1439
|
+
thought: plan2.thought,
|
|
1440
|
+
locate: plan2.locate,
|
|
1441
|
+
executor: async (param) => {
|
|
1442
|
+
assert5(
|
|
1443
|
+
isAndroidPage(this.page),
|
|
1444
|
+
"Cannot use long press on non-Android devices"
|
|
1445
|
+
);
|
|
1446
|
+
const { x, y, duration } = param;
|
|
1447
|
+
await this.page.longPress(x, y, duration);
|
|
1448
|
+
}
|
|
1449
|
+
};
|
|
1450
|
+
tasks.push(taskActionAndroidLongPress);
|
|
1451
|
+
} else if (plan2.type === "AndroidPull") {
|
|
1452
|
+
const taskActionAndroidPull = {
|
|
1453
|
+
type: "Action",
|
|
1454
|
+
subType: "AndroidPull",
|
|
1455
|
+
param: plan2.param,
|
|
1456
|
+
thought: plan2.thought,
|
|
1457
|
+
locate: plan2.locate,
|
|
1458
|
+
executor: async (param) => {
|
|
1459
|
+
assert5(
|
|
1460
|
+
isAndroidPage(this.page),
|
|
1461
|
+
"Cannot use pull action on non-Android devices"
|
|
1462
|
+
);
|
|
1463
|
+
const { direction, startPoint, distance, duration } = param;
|
|
1464
|
+
const convertedStartPoint = startPoint ? { left: startPoint.x, top: startPoint.y } : void 0;
|
|
1465
|
+
if (direction === "down") {
|
|
1466
|
+
await this.page.pullDown(
|
|
1467
|
+
convertedStartPoint,
|
|
1468
|
+
distance,
|
|
1469
|
+
duration
|
|
1470
|
+
);
|
|
1471
|
+
} else if (direction === "up") {
|
|
1472
|
+
await this.page.pullUp(convertedStartPoint, distance, duration);
|
|
1473
|
+
} else {
|
|
1474
|
+
throw new Error(`Unknown pull direction: ${direction}`);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
};
|
|
1478
|
+
tasks.push(taskActionAndroidPull);
|
|
1394
1479
|
} else {
|
|
1395
1480
|
throw new Error(`Unknown or unsupported task type: ${plan2.type}`);
|
|
1396
1481
|
}
|