@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
|
@@ -52,7 +52,7 @@ import yaml from "js-yaml";
|
|
|
52
52
|
import semver from "semver";
|
|
53
53
|
|
|
54
54
|
// package.json
|
|
55
|
-
var version = "0.24.
|
|
55
|
+
var version = "0.24.2-beta-20250730123854.0";
|
|
56
56
|
|
|
57
57
|
// src/common/task-cache.ts
|
|
58
58
|
var DEFAULT_CACHE_MAX_FILENAME_LENGTH = 200;
|
|
@@ -196,7 +196,18 @@ cache file: ${cacheFile}`
|
|
|
196
196
|
mkdirSync(dir, { recursive: true });
|
|
197
197
|
debug("created cache directory: %s", dir);
|
|
198
198
|
}
|
|
199
|
-
const
|
|
199
|
+
const sortedCaches = [...this.cache.caches].sort((a, b) => {
|
|
200
|
+
if (a.type === "plan" && b.type === "locate")
|
|
201
|
+
return -1;
|
|
202
|
+
if (a.type === "locate" && b.type === "plan")
|
|
203
|
+
return 1;
|
|
204
|
+
return 0;
|
|
205
|
+
});
|
|
206
|
+
const cacheToWrite = {
|
|
207
|
+
...this.cache,
|
|
208
|
+
caches: sortedCaches
|
|
209
|
+
};
|
|
210
|
+
const yamlData = yaml.dump(cacheToWrite);
|
|
200
211
|
writeFileSync(this.cacheFilePath, yamlData);
|
|
201
212
|
debug("cache flushed to file: %s", this.cacheFilePath);
|
|
202
213
|
} catch (err) {
|
|
@@ -834,6 +845,23 @@ function scrollParamStr(scrollParam) {
|
|
|
834
845
|
}
|
|
835
846
|
return `${scrollParam.direction || "down"}, ${scrollParam.scrollType || "once"}, ${scrollParam.distance || "distance-not-set"}`;
|
|
836
847
|
}
|
|
848
|
+
function pullParamStr(pullParam) {
|
|
849
|
+
if (!pullParam) {
|
|
850
|
+
return "";
|
|
851
|
+
}
|
|
852
|
+
const parts = [];
|
|
853
|
+
parts.push(`direction: ${pullParam.direction || "down"}`);
|
|
854
|
+
if (pullParam.startPoint) {
|
|
855
|
+
parts.push(`start: (${pullParam.startPoint.x}, ${pullParam.startPoint.y})`);
|
|
856
|
+
}
|
|
857
|
+
if (pullParam.distance) {
|
|
858
|
+
parts.push(`distance: ${pullParam.distance}`);
|
|
859
|
+
}
|
|
860
|
+
if (pullParam.duration) {
|
|
861
|
+
parts.push(`duration: ${pullParam.duration}ms`);
|
|
862
|
+
}
|
|
863
|
+
return parts.join(", ");
|
|
864
|
+
}
|
|
837
865
|
function taskTitleStr(type, prompt) {
|
|
838
866
|
if (prompt) {
|
|
839
867
|
return `${type} - ${prompt}`;
|
|
@@ -856,6 +884,8 @@ function paramStr(task) {
|
|
|
856
884
|
value = `${task?.param?.timeMs}ms`;
|
|
857
885
|
} else if (typeof task?.param?.scrollType === "string") {
|
|
858
886
|
value = scrollParamStr(task?.param);
|
|
887
|
+
} else if (typeof task?.param?.direction === "string" && task?.subType === "AndroidPull") {
|
|
888
|
+
value = pullParamStr(task?.param);
|
|
859
889
|
} else if (typeof task?.param?.value !== "undefined") {
|
|
860
890
|
value = task?.param?.value;
|
|
861
891
|
}
|
|
@@ -898,6 +928,16 @@ var PageTaskExecutor = class {
|
|
|
898
928
|
}
|
|
899
929
|
async getElementXpath(pageContext, element) {
|
|
900
930
|
let elementId = element?.id;
|
|
931
|
+
if (element?.isOrderSensitive !== void 0) {
|
|
932
|
+
const xpaths = await this.page.getXpathsByPoint(
|
|
933
|
+
{
|
|
934
|
+
left: element.center[0],
|
|
935
|
+
top: element.center[1]
|
|
936
|
+
},
|
|
937
|
+
element?.isOrderSensitive
|
|
938
|
+
);
|
|
939
|
+
return xpaths;
|
|
940
|
+
}
|
|
901
941
|
if (element?.attributes?.nodeType === NodeType.POSITION) {
|
|
902
942
|
await this.insight.contextRetrieverFn("locate");
|
|
903
943
|
const info = elementByPositionWithElementInfo2(
|
|
@@ -1392,6 +1432,51 @@ var PageTaskExecutor = class {
|
|
|
1392
1432
|
}
|
|
1393
1433
|
};
|
|
1394
1434
|
tasks.push(taskActionAndroidRecentAppsButton);
|
|
1435
|
+
} else if (plan2.type === "AndroidLongPress") {
|
|
1436
|
+
const taskActionAndroidLongPress = {
|
|
1437
|
+
type: "Action",
|
|
1438
|
+
subType: "AndroidLongPress",
|
|
1439
|
+
param: plan2.param,
|
|
1440
|
+
thought: plan2.thought,
|
|
1441
|
+
locate: plan2.locate,
|
|
1442
|
+
executor: async (param) => {
|
|
1443
|
+
assert5(
|
|
1444
|
+
isAndroidPage(this.page),
|
|
1445
|
+
"Cannot use long press on non-Android devices"
|
|
1446
|
+
);
|
|
1447
|
+
const { x, y, duration } = param;
|
|
1448
|
+
await this.page.longPress(x, y, duration);
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
tasks.push(taskActionAndroidLongPress);
|
|
1452
|
+
} else if (plan2.type === "AndroidPull") {
|
|
1453
|
+
const taskActionAndroidPull = {
|
|
1454
|
+
type: "Action",
|
|
1455
|
+
subType: "AndroidPull",
|
|
1456
|
+
param: plan2.param,
|
|
1457
|
+
thought: plan2.thought,
|
|
1458
|
+
locate: plan2.locate,
|
|
1459
|
+
executor: async (param) => {
|
|
1460
|
+
assert5(
|
|
1461
|
+
isAndroidPage(this.page),
|
|
1462
|
+
"Cannot use pull action on non-Android devices"
|
|
1463
|
+
);
|
|
1464
|
+
const { direction, startPoint, distance, duration } = param;
|
|
1465
|
+
const convertedStartPoint = startPoint ? { left: startPoint.x, top: startPoint.y } : void 0;
|
|
1466
|
+
if (direction === "down") {
|
|
1467
|
+
await this.page.pullDown(
|
|
1468
|
+
convertedStartPoint,
|
|
1469
|
+
distance,
|
|
1470
|
+
duration
|
|
1471
|
+
);
|
|
1472
|
+
} else if (direction === "up") {
|
|
1473
|
+
await this.page.pullUp(convertedStartPoint, distance, duration);
|
|
1474
|
+
} else {
|
|
1475
|
+
throw new Error(`Unknown pull direction: ${direction}`);
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
};
|
|
1479
|
+
tasks.push(taskActionAndroidPull);
|
|
1395
1480
|
} else {
|
|
1396
1481
|
throw new Error(`Unknown or unsupported task type: ${plan2.type}`);
|
|
1397
1482
|
}
|
|
@@ -2582,6 +2667,9 @@ var StaticPage = class {
|
|
|
2582
2667
|
async getXpathsById(id) {
|
|
2583
2668
|
return ThrowNotImplemented("getXpathsById");
|
|
2584
2669
|
}
|
|
2670
|
+
async getXpathsByPoint(point) {
|
|
2671
|
+
return ThrowNotImplemented("getXpathsByPoint");
|
|
2672
|
+
}
|
|
2585
2673
|
async getElementInfoByXpath(xpath) {
|
|
2586
2674
|
return ThrowNotImplemented("getElementInfoByXpath");
|
|
2587
2675
|
}
|