@midscene/web 0.8.6 → 0.8.7
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/appium.js +81 -27
- package/dist/es/chrome-extension.js +73 -33
- package/dist/es/index.js +103 -33
- package/dist/es/midscene-playground.js +65 -23
- package/dist/es/playground.js +65 -23
- package/dist/es/playwright.js +71 -25
- package/dist/es/puppeteer.js +71 -25
- package/dist/es/ui-utils.js +7 -2
- package/dist/lib/appium.js +81 -27
- package/dist/lib/chrome-extension.js +73 -33
- package/dist/lib/index.js +103 -33
- package/dist/lib/midscene-playground.js +65 -23
- package/dist/lib/playground.js +65 -23
- package/dist/lib/playwright.js +71 -25
- package/dist/lib/puppeteer.js +71 -25
- package/dist/lib/ui-utils.js +7 -2
- package/dist/types/appium.d.ts +3 -3
- package/dist/types/chrome-extension.d.ts +4 -4
- package/dist/types/debug.d.ts +2 -2
- package/dist/types/index.d.ts +3 -3
- package/dist/types/{page-a10cd0ea.d.ts → page-b9196527.d.ts} +34 -14
- package/dist/types/playground.d.ts +4 -4
- package/dist/types/playwright.d.ts +4 -4
- package/dist/types/puppeteer.d.ts +3 -3
- package/dist/types/{tasks-15aa1c35.d.ts → tasks-969c0e3e.d.ts} +3 -3
- package/dist/types/utils.d.ts +2 -2
- package/package.json +3 -3
|
@@ -831,26 +831,42 @@ var PageTaskExecutor = class {
|
|
|
831
831
|
param: plan2.param,
|
|
832
832
|
thought: plan2.thought,
|
|
833
833
|
locate: plan2.locate,
|
|
834
|
-
executor: async (taskParam) => {
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
834
|
+
executor: async (taskParam, { element }) => {
|
|
835
|
+
if (element) {
|
|
836
|
+
await this.page.mouse.move(
|
|
837
|
+
element.center[0],
|
|
838
|
+
element.center[1]
|
|
839
|
+
);
|
|
840
|
+
}
|
|
841
|
+
const scrollToEventName = taskParam == null ? void 0 : taskParam.scrollType;
|
|
842
|
+
if (scrollToEventName === "untilTop") {
|
|
843
|
+
await this.page.scrollUntilTop();
|
|
844
|
+
} else if (scrollToEventName === "untilBottom") {
|
|
845
|
+
await this.page.scrollUntilBottom();
|
|
846
|
+
} else if (scrollToEventName === "untilRight") {
|
|
847
|
+
await this.page.scrollUntilRight();
|
|
848
|
+
} else if (scrollToEventName === "untilLeft") {
|
|
849
|
+
await this.page.scrollUntilLeft();
|
|
850
|
+
} else if (scrollToEventName === "once") {
|
|
851
|
+
if (taskParam.direction === "down") {
|
|
852
|
+
await this.page.scrollDown(taskParam.distance || void 0);
|
|
853
|
+
} else if (taskParam.direction === "up") {
|
|
854
|
+
await this.page.scrollUp(taskParam.distance || void 0);
|
|
855
|
+
} else if (taskParam.direction === "left") {
|
|
856
|
+
await this.page.scrollLeft(taskParam.distance || void 0);
|
|
857
|
+
} else if (taskParam.direction === "right") {
|
|
858
|
+
await this.page.scrollRight(taskParam.distance || void 0);
|
|
859
|
+
} else {
|
|
860
|
+
throw new Error(
|
|
861
|
+
`Unknown scroll direction: ${taskParam.direction}`
|
|
853
862
|
);
|
|
863
|
+
}
|
|
864
|
+
} else {
|
|
865
|
+
throw new Error(
|
|
866
|
+
`Unknown scroll event type: ${scrollToEventName}, taskParam: ${JSON.stringify(
|
|
867
|
+
taskParam
|
|
868
|
+
)}`
|
|
869
|
+
);
|
|
854
870
|
}
|
|
855
871
|
}
|
|
856
872
|
};
|
|
@@ -879,6 +895,17 @@ var PageTaskExecutor = class {
|
|
|
879
895
|
}
|
|
880
896
|
};
|
|
881
897
|
tasks.push(taskActionError);
|
|
898
|
+
} else if (plan2.type === "FalsyConditionStatement") {
|
|
899
|
+
const taskActionFalsyConditionStatement = {
|
|
900
|
+
type: "Action",
|
|
901
|
+
subType: "FalsyConditionStatement",
|
|
902
|
+
param: null,
|
|
903
|
+
thought: plan2.thought,
|
|
904
|
+
locate: plan2.locate,
|
|
905
|
+
executor: async () => {
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
tasks.push(taskActionFalsyConditionStatement);
|
|
882
909
|
} else {
|
|
883
910
|
throw new Error(`Unknown or unsupported task type: ${plan2.type}`);
|
|
884
911
|
}
|
|
@@ -998,6 +1025,9 @@ var PageTaskExecutor = class {
|
|
|
998
1025
|
const errorMsg = "Replanning too many times, please split the task into multiple steps";
|
|
999
1026
|
return this.appendErrorPlan(taskExecutor, errorMsg);
|
|
1000
1027
|
}
|
|
1028
|
+
if (replanCount > 0) {
|
|
1029
|
+
await (0, import_utils5.sleep)(300);
|
|
1030
|
+
}
|
|
1001
1031
|
await taskExecutor.append(planningTask);
|
|
1002
1032
|
const planResult = await taskExecutor.flush();
|
|
1003
1033
|
if (taskExecutor.isInErrorState()) {
|
|
@@ -1524,21 +1554,31 @@ var ChromeExtensionProxyPage = class {
|
|
|
1524
1554
|
async scrollUntilBottom() {
|
|
1525
1555
|
return this.mouse.wheel(0, 9999999);
|
|
1526
1556
|
}
|
|
1527
|
-
async
|
|
1528
|
-
|
|
1529
|
-
target: { tabId: this.tabId, allFrames: true },
|
|
1530
|
-
func: () => {
|
|
1531
|
-
window.scrollBy(0, -window.innerHeight * 0.7);
|
|
1532
|
-
}
|
|
1533
|
-
});
|
|
1557
|
+
async scrollUntilLeft() {
|
|
1558
|
+
return this.mouse.wheel(-9999999, 0);
|
|
1534
1559
|
}
|
|
1535
|
-
async
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1560
|
+
async scrollUntilRight() {
|
|
1561
|
+
return this.mouse.wheel(9999999, 0);
|
|
1562
|
+
}
|
|
1563
|
+
async scrollUp(distance) {
|
|
1564
|
+
const { height } = await this.size();
|
|
1565
|
+
const scrollDistance = distance || height * 0.7;
|
|
1566
|
+
return this.mouse.wheel(0, -scrollDistance);
|
|
1567
|
+
}
|
|
1568
|
+
async scrollDown(distance) {
|
|
1569
|
+
const { height } = await this.size();
|
|
1570
|
+
const scrollDistance = distance || height * 0.7;
|
|
1571
|
+
return this.mouse.wheel(0, scrollDistance);
|
|
1572
|
+
}
|
|
1573
|
+
async scrollLeft(distance) {
|
|
1574
|
+
const { width } = await this.size();
|
|
1575
|
+
const scrollDistance = distance || width * 0.7;
|
|
1576
|
+
return this.mouse.wheel(-scrollDistance, 0);
|
|
1577
|
+
}
|
|
1578
|
+
async scrollRight(distance) {
|
|
1579
|
+
const { width } = await this.size();
|
|
1580
|
+
const scrollDistance = distance || width * 0.7;
|
|
1581
|
+
return this.mouse.wheel(scrollDistance, 0);
|
|
1542
1582
|
}
|
|
1543
1583
|
async clearInput(element) {
|
|
1544
1584
|
if (!element) {
|
package/dist/lib/index.js
CHANGED
|
@@ -1243,26 +1243,42 @@ var PageTaskExecutor = class {
|
|
|
1243
1243
|
param: plan2.param,
|
|
1244
1244
|
thought: plan2.thought,
|
|
1245
1245
|
locate: plan2.locate,
|
|
1246
|
-
executor: async (taskParam) => {
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1246
|
+
executor: async (taskParam, { element }) => {
|
|
1247
|
+
if (element) {
|
|
1248
|
+
await this.page.mouse.move(
|
|
1249
|
+
element.center[0],
|
|
1250
|
+
element.center[1]
|
|
1251
|
+
);
|
|
1252
|
+
}
|
|
1253
|
+
const scrollToEventName = taskParam == null ? void 0 : taskParam.scrollType;
|
|
1254
|
+
if (scrollToEventName === "untilTop") {
|
|
1255
|
+
await this.page.scrollUntilTop();
|
|
1256
|
+
} else if (scrollToEventName === "untilBottom") {
|
|
1257
|
+
await this.page.scrollUntilBottom();
|
|
1258
|
+
} else if (scrollToEventName === "untilRight") {
|
|
1259
|
+
await this.page.scrollUntilRight();
|
|
1260
|
+
} else if (scrollToEventName === "untilLeft") {
|
|
1261
|
+
await this.page.scrollUntilLeft();
|
|
1262
|
+
} else if (scrollToEventName === "once") {
|
|
1263
|
+
if (taskParam.direction === "down") {
|
|
1264
|
+
await this.page.scrollDown(taskParam.distance || void 0);
|
|
1265
|
+
} else if (taskParam.direction === "up") {
|
|
1266
|
+
await this.page.scrollUp(taskParam.distance || void 0);
|
|
1267
|
+
} else if (taskParam.direction === "left") {
|
|
1268
|
+
await this.page.scrollLeft(taskParam.distance || void 0);
|
|
1269
|
+
} else if (taskParam.direction === "right") {
|
|
1270
|
+
await this.page.scrollRight(taskParam.distance || void 0);
|
|
1271
|
+
} else {
|
|
1272
|
+
throw new Error(
|
|
1273
|
+
`Unknown scroll direction: ${taskParam.direction}`
|
|
1265
1274
|
);
|
|
1275
|
+
}
|
|
1276
|
+
} else {
|
|
1277
|
+
throw new Error(
|
|
1278
|
+
`Unknown scroll event type: ${scrollToEventName}, taskParam: ${JSON.stringify(
|
|
1279
|
+
taskParam
|
|
1280
|
+
)}`
|
|
1281
|
+
);
|
|
1266
1282
|
}
|
|
1267
1283
|
}
|
|
1268
1284
|
};
|
|
@@ -1291,6 +1307,17 @@ var PageTaskExecutor = class {
|
|
|
1291
1307
|
}
|
|
1292
1308
|
};
|
|
1293
1309
|
tasks.push(taskActionError);
|
|
1310
|
+
} else if (plan2.type === "FalsyConditionStatement") {
|
|
1311
|
+
const taskActionFalsyConditionStatement = {
|
|
1312
|
+
type: "Action",
|
|
1313
|
+
subType: "FalsyConditionStatement",
|
|
1314
|
+
param: null,
|
|
1315
|
+
thought: plan2.thought,
|
|
1316
|
+
locate: plan2.locate,
|
|
1317
|
+
executor: async () => {
|
|
1318
|
+
}
|
|
1319
|
+
};
|
|
1320
|
+
tasks.push(taskActionFalsyConditionStatement);
|
|
1294
1321
|
} else {
|
|
1295
1322
|
throw new Error(`Unknown or unsupported task type: ${plan2.type}`);
|
|
1296
1323
|
}
|
|
@@ -1410,6 +1437,9 @@ var PageTaskExecutor = class {
|
|
|
1410
1437
|
const errorMsg = "Replanning too many times, please split the task into multiple steps";
|
|
1411
1438
|
return this.appendErrorPlan(taskExecutor, errorMsg);
|
|
1412
1439
|
}
|
|
1440
|
+
if (replanCount > 0) {
|
|
1441
|
+
await (0, import_utils3.sleep)(300);
|
|
1442
|
+
}
|
|
1413
1443
|
await taskExecutor.append(planningTask);
|
|
1414
1444
|
const planResult = await taskExecutor.flush();
|
|
1415
1445
|
if (taskExecutor.isInErrorState()) {
|
|
@@ -2095,15 +2125,31 @@ var Page = class {
|
|
|
2095
2125
|
scrollUntilBottom() {
|
|
2096
2126
|
return this.mouse.wheel(0, 9999999);
|
|
2097
2127
|
}
|
|
2098
|
-
|
|
2128
|
+
scrollUntilLeft() {
|
|
2129
|
+
return this.mouse.wheel(-9999999, 0);
|
|
2130
|
+
}
|
|
2131
|
+
scrollUntilRight() {
|
|
2132
|
+
return this.mouse.wheel(9999999, 0);
|
|
2133
|
+
}
|
|
2134
|
+
async scrollUp(distance) {
|
|
2099
2135
|
const innerHeight = await this.evaluate(() => window.innerHeight);
|
|
2100
|
-
const
|
|
2101
|
-
await this.mouse.wheel(0, -
|
|
2136
|
+
const scrollDistance = distance || innerHeight * 0.7;
|
|
2137
|
+
await this.mouse.wheel(0, -scrollDistance);
|
|
2102
2138
|
}
|
|
2103
|
-
async
|
|
2139
|
+
async scrollDown(distance) {
|
|
2104
2140
|
const innerHeight = await this.evaluate(() => window.innerHeight);
|
|
2105
|
-
const
|
|
2106
|
-
await this.mouse.wheel(0,
|
|
2141
|
+
const scrollDistance = distance || innerHeight * 0.7;
|
|
2142
|
+
await this.mouse.wheel(0, scrollDistance);
|
|
2143
|
+
}
|
|
2144
|
+
async scrollLeft(distance) {
|
|
2145
|
+
const innerWidth = await this.evaluate(() => window.innerWidth);
|
|
2146
|
+
const scrollDistance = distance || innerWidth * 0.7;
|
|
2147
|
+
await this.mouse.wheel(-scrollDistance, 0);
|
|
2148
|
+
}
|
|
2149
|
+
async scrollRight(distance) {
|
|
2150
|
+
const innerWidth = await this.evaluate(() => window.innerWidth);
|
|
2151
|
+
const scrollDistance = distance || innerWidth * 0.7;
|
|
2152
|
+
await this.mouse.wheel(scrollDistance, 0);
|
|
2107
2153
|
}
|
|
2108
2154
|
async destroy() {
|
|
2109
2155
|
}
|
|
@@ -2425,24 +2471,48 @@ var Page2 = class {
|
|
|
2425
2471
|
return "";
|
|
2426
2472
|
}
|
|
2427
2473
|
// Scroll to top element
|
|
2428
|
-
async scrollUntilTop() {
|
|
2474
|
+
async scrollUntilTop(distance) {
|
|
2429
2475
|
const { height } = await this.browser.getWindowSize();
|
|
2430
|
-
|
|
2476
|
+
const scrollDistance = distance || height * 0.7;
|
|
2477
|
+
await this.mouseWheel(0, -scrollDistance, 100);
|
|
2431
2478
|
}
|
|
2432
2479
|
// Scroll to bottom element
|
|
2433
|
-
async scrollUntilBottom() {
|
|
2480
|
+
async scrollUntilBottom(distance) {
|
|
2434
2481
|
const { height } = await this.browser.getWindowSize();
|
|
2435
|
-
|
|
2482
|
+
const scrollDistance = distance || height * 0.7;
|
|
2483
|
+
await this.mouseWheel(0, scrollDistance, 100);
|
|
2484
|
+
}
|
|
2485
|
+
async scrollUntilLeft(distance) {
|
|
2486
|
+
const { width } = await this.browser.getWindowSize();
|
|
2487
|
+
const scrollDistance = distance || width * 0.7;
|
|
2488
|
+
await this.mouseWheel(-scrollDistance, 0, 100);
|
|
2489
|
+
}
|
|
2490
|
+
async scrollUntilRight(distance) {
|
|
2491
|
+
const { width } = await this.browser.getWindowSize();
|
|
2492
|
+
const scrollDistance = distance || width * 0.7;
|
|
2493
|
+
await this.mouseWheel(scrollDistance, 0, 100);
|
|
2436
2494
|
}
|
|
2437
2495
|
// Scroll up one screen
|
|
2438
|
-
async
|
|
2496
|
+
async scrollUp(distance) {
|
|
2439
2497
|
const { height } = await this.browser.getWindowSize();
|
|
2440
|
-
|
|
2498
|
+
const scrollDistance = distance || height * 0.7;
|
|
2499
|
+
await this.mouseWheel(0, -scrollDistance, 1e3);
|
|
2441
2500
|
}
|
|
2442
2501
|
// Scroll down one screen
|
|
2443
|
-
async
|
|
2502
|
+
async scrollDown(distance) {
|
|
2444
2503
|
const { height } = await this.browser.getWindowSize();
|
|
2445
|
-
|
|
2504
|
+
const scrollDistance = distance || height * 0.7;
|
|
2505
|
+
await this.mouseWheel(0, scrollDistance, 1e3);
|
|
2506
|
+
}
|
|
2507
|
+
async scrollLeft(distance) {
|
|
2508
|
+
const { width } = await this.browser.getWindowSize();
|
|
2509
|
+
const scrollDistance = distance || width * 0.7;
|
|
2510
|
+
await this.mouseWheel(-scrollDistance, 0, 1e3);
|
|
2511
|
+
}
|
|
2512
|
+
async scrollRight(distance) {
|
|
2513
|
+
const { width } = await this.browser.getWindowSize();
|
|
2514
|
+
const scrollDistance = distance || width * 0.7;
|
|
2515
|
+
await this.mouseWheel(scrollDistance, 0, 1e3);
|
|
2446
2516
|
}
|
|
2447
2517
|
async keyboardType(text) {
|
|
2448
2518
|
const actions = [];
|
|
@@ -1168,26 +1168,42 @@ var PageTaskExecutor = class {
|
|
|
1168
1168
|
param: plan2.param,
|
|
1169
1169
|
thought: plan2.thought,
|
|
1170
1170
|
locate: plan2.locate,
|
|
1171
|
-
executor: async (taskParam) => {
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1171
|
+
executor: async (taskParam, { element }) => {
|
|
1172
|
+
if (element) {
|
|
1173
|
+
await this.page.mouse.move(
|
|
1174
|
+
element.center[0],
|
|
1175
|
+
element.center[1]
|
|
1176
|
+
);
|
|
1177
|
+
}
|
|
1178
|
+
const scrollToEventName = taskParam == null ? void 0 : taskParam.scrollType;
|
|
1179
|
+
if (scrollToEventName === "untilTop") {
|
|
1180
|
+
await this.page.scrollUntilTop();
|
|
1181
|
+
} else if (scrollToEventName === "untilBottom") {
|
|
1182
|
+
await this.page.scrollUntilBottom();
|
|
1183
|
+
} else if (scrollToEventName === "untilRight") {
|
|
1184
|
+
await this.page.scrollUntilRight();
|
|
1185
|
+
} else if (scrollToEventName === "untilLeft") {
|
|
1186
|
+
await this.page.scrollUntilLeft();
|
|
1187
|
+
} else if (scrollToEventName === "once") {
|
|
1188
|
+
if (taskParam.direction === "down") {
|
|
1189
|
+
await this.page.scrollDown(taskParam.distance || void 0);
|
|
1190
|
+
} else if (taskParam.direction === "up") {
|
|
1191
|
+
await this.page.scrollUp(taskParam.distance || void 0);
|
|
1192
|
+
} else if (taskParam.direction === "left") {
|
|
1193
|
+
await this.page.scrollLeft(taskParam.distance || void 0);
|
|
1194
|
+
} else if (taskParam.direction === "right") {
|
|
1195
|
+
await this.page.scrollRight(taskParam.distance || void 0);
|
|
1196
|
+
} else {
|
|
1197
|
+
throw new Error(
|
|
1198
|
+
`Unknown scroll direction: ${taskParam.direction}`
|
|
1190
1199
|
);
|
|
1200
|
+
}
|
|
1201
|
+
} else {
|
|
1202
|
+
throw new Error(
|
|
1203
|
+
`Unknown scroll event type: ${scrollToEventName}, taskParam: ${JSON.stringify(
|
|
1204
|
+
taskParam
|
|
1205
|
+
)}`
|
|
1206
|
+
);
|
|
1191
1207
|
}
|
|
1192
1208
|
}
|
|
1193
1209
|
};
|
|
@@ -1216,6 +1232,17 @@ var PageTaskExecutor = class {
|
|
|
1216
1232
|
}
|
|
1217
1233
|
};
|
|
1218
1234
|
tasks.push(taskActionError);
|
|
1235
|
+
} else if (plan2.type === "FalsyConditionStatement") {
|
|
1236
|
+
const taskActionFalsyConditionStatement = {
|
|
1237
|
+
type: "Action",
|
|
1238
|
+
subType: "FalsyConditionStatement",
|
|
1239
|
+
param: null,
|
|
1240
|
+
thought: plan2.thought,
|
|
1241
|
+
locate: plan2.locate,
|
|
1242
|
+
executor: async () => {
|
|
1243
|
+
}
|
|
1244
|
+
};
|
|
1245
|
+
tasks.push(taskActionFalsyConditionStatement);
|
|
1219
1246
|
} else {
|
|
1220
1247
|
throw new Error(`Unknown or unsupported task type: ${plan2.type}`);
|
|
1221
1248
|
}
|
|
@@ -1335,6 +1362,9 @@ var PageTaskExecutor = class {
|
|
|
1335
1362
|
const errorMsg = "Replanning too many times, please split the task into multiple steps";
|
|
1336
1363
|
return this.appendErrorPlan(taskExecutor, errorMsg);
|
|
1337
1364
|
}
|
|
1365
|
+
if (replanCount > 0) {
|
|
1366
|
+
await (0, import_utils5.sleep)(300);
|
|
1367
|
+
}
|
|
1338
1368
|
await taskExecutor.append(planningTask);
|
|
1339
1369
|
const planResult = await taskExecutor.flush();
|
|
1340
1370
|
if (taskExecutor.isInErrorState()) {
|
|
@@ -1704,11 +1734,23 @@ var StaticPage = class {
|
|
|
1704
1734
|
async scrollUntilBottom() {
|
|
1705
1735
|
return ThrowNotImplemented("scrollUntilBottom");
|
|
1706
1736
|
}
|
|
1707
|
-
async
|
|
1708
|
-
return ThrowNotImplemented("
|
|
1737
|
+
async scrollUntilLeft() {
|
|
1738
|
+
return ThrowNotImplemented("scrollUntilLeft");
|
|
1739
|
+
}
|
|
1740
|
+
async scrollUntilRight() {
|
|
1741
|
+
return ThrowNotImplemented("scrollUntilRight");
|
|
1742
|
+
}
|
|
1743
|
+
async scrollUp(distance) {
|
|
1744
|
+
return ThrowNotImplemented("scrollUp");
|
|
1745
|
+
}
|
|
1746
|
+
async scrollDown(distance) {
|
|
1747
|
+
return ThrowNotImplemented("scrollDown");
|
|
1748
|
+
}
|
|
1749
|
+
async scrollLeft(distance) {
|
|
1750
|
+
return ThrowNotImplemented("scrollLeft");
|
|
1709
1751
|
}
|
|
1710
|
-
async
|
|
1711
|
-
return ThrowNotImplemented("
|
|
1752
|
+
async scrollRight(distance) {
|
|
1753
|
+
return ThrowNotImplemented("scrollRight");
|
|
1712
1754
|
}
|
|
1713
1755
|
async clearInput() {
|
|
1714
1756
|
return ThrowNotImplemented("clearInput");
|
package/dist/lib/playground.js
CHANGED
|
@@ -831,26 +831,42 @@ var PageTaskExecutor = class {
|
|
|
831
831
|
param: plan2.param,
|
|
832
832
|
thought: plan2.thought,
|
|
833
833
|
locate: plan2.locate,
|
|
834
|
-
executor: async (taskParam) => {
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
834
|
+
executor: async (taskParam, { element }) => {
|
|
835
|
+
if (element) {
|
|
836
|
+
await this.page.mouse.move(
|
|
837
|
+
element.center[0],
|
|
838
|
+
element.center[1]
|
|
839
|
+
);
|
|
840
|
+
}
|
|
841
|
+
const scrollToEventName = taskParam == null ? void 0 : taskParam.scrollType;
|
|
842
|
+
if (scrollToEventName === "untilTop") {
|
|
843
|
+
await this.page.scrollUntilTop();
|
|
844
|
+
} else if (scrollToEventName === "untilBottom") {
|
|
845
|
+
await this.page.scrollUntilBottom();
|
|
846
|
+
} else if (scrollToEventName === "untilRight") {
|
|
847
|
+
await this.page.scrollUntilRight();
|
|
848
|
+
} else if (scrollToEventName === "untilLeft") {
|
|
849
|
+
await this.page.scrollUntilLeft();
|
|
850
|
+
} else if (scrollToEventName === "once") {
|
|
851
|
+
if (taskParam.direction === "down") {
|
|
852
|
+
await this.page.scrollDown(taskParam.distance || void 0);
|
|
853
|
+
} else if (taskParam.direction === "up") {
|
|
854
|
+
await this.page.scrollUp(taskParam.distance || void 0);
|
|
855
|
+
} else if (taskParam.direction === "left") {
|
|
856
|
+
await this.page.scrollLeft(taskParam.distance || void 0);
|
|
857
|
+
} else if (taskParam.direction === "right") {
|
|
858
|
+
await this.page.scrollRight(taskParam.distance || void 0);
|
|
859
|
+
} else {
|
|
860
|
+
throw new Error(
|
|
861
|
+
`Unknown scroll direction: ${taskParam.direction}`
|
|
853
862
|
);
|
|
863
|
+
}
|
|
864
|
+
} else {
|
|
865
|
+
throw new Error(
|
|
866
|
+
`Unknown scroll event type: ${scrollToEventName}, taskParam: ${JSON.stringify(
|
|
867
|
+
taskParam
|
|
868
|
+
)}`
|
|
869
|
+
);
|
|
854
870
|
}
|
|
855
871
|
}
|
|
856
872
|
};
|
|
@@ -879,6 +895,17 @@ var PageTaskExecutor = class {
|
|
|
879
895
|
}
|
|
880
896
|
};
|
|
881
897
|
tasks.push(taskActionError);
|
|
898
|
+
} else if (plan2.type === "FalsyConditionStatement") {
|
|
899
|
+
const taskActionFalsyConditionStatement = {
|
|
900
|
+
type: "Action",
|
|
901
|
+
subType: "FalsyConditionStatement",
|
|
902
|
+
param: null,
|
|
903
|
+
thought: plan2.thought,
|
|
904
|
+
locate: plan2.locate,
|
|
905
|
+
executor: async () => {
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
tasks.push(taskActionFalsyConditionStatement);
|
|
882
909
|
} else {
|
|
883
910
|
throw new Error(`Unknown or unsupported task type: ${plan2.type}`);
|
|
884
911
|
}
|
|
@@ -998,6 +1025,9 @@ var PageTaskExecutor = class {
|
|
|
998
1025
|
const errorMsg = "Replanning too many times, please split the task into multiple steps";
|
|
999
1026
|
return this.appendErrorPlan(taskExecutor, errorMsg);
|
|
1000
1027
|
}
|
|
1028
|
+
if (replanCount > 0) {
|
|
1029
|
+
await (0, import_utils5.sleep)(300);
|
|
1030
|
+
}
|
|
1001
1031
|
await taskExecutor.append(planningTask);
|
|
1002
1032
|
const planResult = await taskExecutor.flush();
|
|
1003
1033
|
if (taskExecutor.isInErrorState()) {
|
|
@@ -1367,11 +1397,23 @@ var StaticPage = class {
|
|
|
1367
1397
|
async scrollUntilBottom() {
|
|
1368
1398
|
return ThrowNotImplemented("scrollUntilBottom");
|
|
1369
1399
|
}
|
|
1370
|
-
async
|
|
1371
|
-
return ThrowNotImplemented("
|
|
1400
|
+
async scrollUntilLeft() {
|
|
1401
|
+
return ThrowNotImplemented("scrollUntilLeft");
|
|
1402
|
+
}
|
|
1403
|
+
async scrollUntilRight() {
|
|
1404
|
+
return ThrowNotImplemented("scrollUntilRight");
|
|
1405
|
+
}
|
|
1406
|
+
async scrollUp(distance) {
|
|
1407
|
+
return ThrowNotImplemented("scrollUp");
|
|
1408
|
+
}
|
|
1409
|
+
async scrollDown(distance) {
|
|
1410
|
+
return ThrowNotImplemented("scrollDown");
|
|
1411
|
+
}
|
|
1412
|
+
async scrollLeft(distance) {
|
|
1413
|
+
return ThrowNotImplemented("scrollLeft");
|
|
1372
1414
|
}
|
|
1373
|
-
async
|
|
1374
|
-
return ThrowNotImplemented("
|
|
1415
|
+
async scrollRight(distance) {
|
|
1416
|
+
return ThrowNotImplemented("scrollRight");
|
|
1375
1417
|
}
|
|
1376
1418
|
async clearInput() {
|
|
1377
1419
|
return ThrowNotImplemented("clearInput");
|