@midscene/web 0.11.1 → 0.11.2
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 +84 -39
- package/dist/es/bridge-mode-browser.js +58 -19
- package/dist/es/bridge-mode.js +61 -43
- package/dist/es/chrome-extension.js +104 -51
- package/dist/es/index.js +291 -218
- package/dist/es/midscene-playground.js +56 -38
- package/dist/es/playground.js +56 -38
- package/dist/es/playwright.js +251 -203
- package/dist/es/puppeteer.js +85 -60
- package/dist/es/ui-utils.js +43 -0
- package/dist/lib/appium.js +84 -39
- package/dist/lib/bridge-mode-browser.js +58 -19
- package/dist/lib/bridge-mode.js +61 -43
- package/dist/lib/chrome-extension.js +104 -51
- package/dist/lib/index.js +291 -218
- package/dist/lib/midscene-playground.js +56 -38
- package/dist/lib/playground.js +56 -38
- package/dist/lib/playwright.js +251 -203
- package/dist/lib/puppeteer.js +85 -60
- package/dist/lib/ui-utils.js +43 -0
- package/dist/types/{tasks-d5a01262.d.ts → agent-ac363fa3.d.ts} +41 -41
- package/dist/types/appium.d.ts +2 -2
- package/dist/types/bridge-mode-browser.d.ts +2 -2
- package/dist/types/bridge-mode.d.ts +3 -3
- package/dist/types/{browser-7d5614fb.d.ts → browser-eae1a5c1.d.ts} +4 -4
- package/dist/types/chrome-extension.d.ts +3 -3
- package/dist/types/index.d.ts +8 -8
- package/dist/types/{page-77af8d5f.d.ts → page-cf0f892e.d.ts} +32 -6
- package/dist/types/playground.d.ts +3 -3
- package/dist/types/playwright.d.ts +12 -6
- package/dist/types/puppeteer.d.ts +2 -2
- package/dist/types/ui-utils.d.ts +6 -1
- package/dist/types/{utils-1a3bc661.d.ts → utils-9a29bfa0.d.ts} +1 -1
- package/dist/types/utils.d.ts +1 -1
- package/dist/types/yaml.d.ts +3 -3
- package/package.json +6 -6
|
@@ -3812,7 +3812,9 @@ var TaskCache = class {
|
|
|
3812
3812
|
if (!this.midscenePkgInfo) {
|
|
3813
3813
|
return void 0;
|
|
3814
3814
|
}
|
|
3815
|
-
|
|
3815
|
+
const jsonDataPkgVersion = jsonData.pkgVersion.split(".");
|
|
3816
|
+
const midscenePkgInfoPkgVersion = this.midscenePkgInfo.version.split(".");
|
|
3817
|
+
if (jsonDataPkgVersion[0] !== midscenePkgInfoPkgVersion[0] || jsonDataPkgVersion[1] !== midscenePkgInfoPkgVersion[1]) {
|
|
3816
3818
|
return void 0;
|
|
3817
3819
|
}
|
|
3818
3820
|
return jsonData;
|
|
@@ -3846,6 +3848,56 @@ var TaskCache = class {
|
|
|
3846
3848
|
}
|
|
3847
3849
|
};
|
|
3848
3850
|
|
|
3851
|
+
// src/common/ui-utils.ts
|
|
3852
|
+
function typeStr(task) {
|
|
3853
|
+
return task.subType ? `${task.type} / ${task.subType || ""}` : task.type;
|
|
3854
|
+
}
|
|
3855
|
+
function getKeyCommands(value) {
|
|
3856
|
+
const keys = Array.isArray(value) ? value : [value];
|
|
3857
|
+
return keys.reduce((acc, k) => {
|
|
3858
|
+
const includeMeta = keys.includes("Meta") || keys.includes("Control");
|
|
3859
|
+
if (includeMeta && (k === "a" || k === "A")) {
|
|
3860
|
+
return acc.concat([{ key: k, command: "SelectAll" }]);
|
|
3861
|
+
}
|
|
3862
|
+
if (includeMeta && (k === "c" || k === "C")) {
|
|
3863
|
+
return acc.concat([{ key: k, command: "Copy" }]);
|
|
3864
|
+
}
|
|
3865
|
+
if (includeMeta && (k === "v" || k === "V")) {
|
|
3866
|
+
return acc.concat([{ key: k, command: "Paste" }]);
|
|
3867
|
+
}
|
|
3868
|
+
return acc.concat([{ key: k }]);
|
|
3869
|
+
}, []);
|
|
3870
|
+
}
|
|
3871
|
+
function paramStr(task) {
|
|
3872
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
3873
|
+
let value;
|
|
3874
|
+
if (task.type === "Planning") {
|
|
3875
|
+
value = (_a = task == null ? void 0 : task.param) == null ? void 0 : _a.userPrompt;
|
|
3876
|
+
}
|
|
3877
|
+
if (task.type === "Insight") {
|
|
3878
|
+
value = ((_b = task == null ? void 0 : task.param) == null ? void 0 : _b.prompt) || ((_c = task == null ? void 0 : task.param) == null ? void 0 : _c.id) || ((_d = task == null ? void 0 : task.param) == null ? void 0 : _d.dataDemand) || ((_e = task == null ? void 0 : task.param) == null ? void 0 : _e.assertion);
|
|
3879
|
+
}
|
|
3880
|
+
if (task.type === "Action") {
|
|
3881
|
+
const sleepMs = (_f = task == null ? void 0 : task.param) == null ? void 0 : _f.timeMs;
|
|
3882
|
+
const scrollType = (_g = task == null ? void 0 : task.param) == null ? void 0 : _g.scrollType;
|
|
3883
|
+
if (sleepMs) {
|
|
3884
|
+
value = `${sleepMs}ms`;
|
|
3885
|
+
} else if (scrollType) {
|
|
3886
|
+
const scrollDirection = (_h = task == null ? void 0 : task.param) == null ? void 0 : _h.direction;
|
|
3887
|
+
const scrollDistance = (_i = task == null ? void 0 : task.param) == null ? void 0 : _i.distance;
|
|
3888
|
+
value = `${scrollDirection || "down"}, ${scrollType || "once"}, ${scrollDistance || "distance-not-set"}`;
|
|
3889
|
+
} else {
|
|
3890
|
+
value = ((_j = task == null ? void 0 : task.param) == null ? void 0 : _j.value) || ((_k = task == null ? void 0 : task.param) == null ? void 0 : _k.scrollType);
|
|
3891
|
+
}
|
|
3892
|
+
if (!value) {
|
|
3893
|
+
value = task.thought;
|
|
3894
|
+
}
|
|
3895
|
+
}
|
|
3896
|
+
if (typeof value === "undefined")
|
|
3897
|
+
return "";
|
|
3898
|
+
return typeof value === "string" ? value : JSON.stringify(value, void 0, 2);
|
|
3899
|
+
}
|
|
3900
|
+
|
|
3849
3901
|
// src/common/tasks.ts
|
|
3850
3902
|
var PageTaskExecutor = class {
|
|
3851
3903
|
constructor(page, insight, opts) {
|
|
@@ -4059,8 +4111,8 @@ var PageTaskExecutor = class {
|
|
|
4059
4111
|
thought: plan2.thought,
|
|
4060
4112
|
locate: plan2.locate,
|
|
4061
4113
|
executor: async (taskParam) => {
|
|
4062
|
-
|
|
4063
|
-
await this.page.keyboard.press(
|
|
4114
|
+
const keys = getKeyCommands(taskParam.value);
|
|
4115
|
+
await this.page.keyboard.press(keys);
|
|
4064
4116
|
}
|
|
4065
4117
|
};
|
|
4066
4118
|
tasks.push(taskActionKeyboardPress);
|
|
@@ -4468,7 +4520,7 @@ var PageTaskExecutor = class {
|
|
|
4468
4520
|
const cacheGroup = this.taskCache.getCacheGroupByPrompt(userPrompt);
|
|
4469
4521
|
const isCompleted = false;
|
|
4470
4522
|
let currentActionNumber = 0;
|
|
4471
|
-
const maxActionNumber =
|
|
4523
|
+
const maxActionNumber = 40;
|
|
4472
4524
|
while (!isCompleted && currentActionNumber < maxActionNumber) {
|
|
4473
4525
|
currentActionNumber++;
|
|
4474
4526
|
const planningTask = this.planningTaskToGoal(
|
|
@@ -4664,40 +4716,6 @@ var PageTaskExecutor = class {
|
|
|
4664
4716
|
}
|
|
4665
4717
|
};
|
|
4666
4718
|
|
|
4667
|
-
// src/common/ui-utils.ts
|
|
4668
|
-
function typeStr(task) {
|
|
4669
|
-
return task.subType ? `${task.type} / ${task.subType || ""}` : task.type;
|
|
4670
|
-
}
|
|
4671
|
-
function paramStr(task) {
|
|
4672
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4673
|
-
let value;
|
|
4674
|
-
if (task.type === "Planning") {
|
|
4675
|
-
value = (_a = task == null ? void 0 : task.param) == null ? void 0 : _a.userPrompt;
|
|
4676
|
-
}
|
|
4677
|
-
if (task.type === "Insight") {
|
|
4678
|
-
value = ((_b = task == null ? void 0 : task.param) == null ? void 0 : _b.prompt) || ((_c = task == null ? void 0 : task.param) == null ? void 0 : _c.id) || ((_d = task == null ? void 0 : task.param) == null ? void 0 : _d.dataDemand) || ((_e = task == null ? void 0 : task.param) == null ? void 0 : _e.assertion);
|
|
4679
|
-
}
|
|
4680
|
-
if (task.type === "Action") {
|
|
4681
|
-
const sleepMs = (_f = task == null ? void 0 : task.param) == null ? void 0 : _f.timeMs;
|
|
4682
|
-
const scrollType = (_g = task == null ? void 0 : task.param) == null ? void 0 : _g.scrollType;
|
|
4683
|
-
if (sleepMs) {
|
|
4684
|
-
value = `${sleepMs}ms`;
|
|
4685
|
-
} else if (scrollType) {
|
|
4686
|
-
const scrollDirection = (_h = task == null ? void 0 : task.param) == null ? void 0 : _h.direction;
|
|
4687
|
-
const scrollDistance = (_i = task == null ? void 0 : task.param) == null ? void 0 : _i.distance;
|
|
4688
|
-
value = `${scrollDirection || "down"}, ${scrollType || "once"}, ${scrollDistance || "distance-not-set"}`;
|
|
4689
|
-
} else {
|
|
4690
|
-
value = ((_j = task == null ? void 0 : task.param) == null ? void 0 : _j.value) || ((_k = task == null ? void 0 : task.param) == null ? void 0 : _k.scrollType);
|
|
4691
|
-
}
|
|
4692
|
-
if (!value) {
|
|
4693
|
-
value = task.thought;
|
|
4694
|
-
}
|
|
4695
|
-
}
|
|
4696
|
-
if (typeof value === "undefined")
|
|
4697
|
-
return "";
|
|
4698
|
-
return typeof value === "string" ? value : JSON.stringify(value, void 0, 2);
|
|
4699
|
-
}
|
|
4700
|
-
|
|
4701
4719
|
// src/common/agent.ts
|
|
4702
4720
|
var PageAgent = class {
|
|
4703
4721
|
constructor(page, opts) {
|
package/dist/lib/playground.js
CHANGED
|
@@ -3475,7 +3475,9 @@ var TaskCache = class {
|
|
|
3475
3475
|
if (!this.midscenePkgInfo) {
|
|
3476
3476
|
return void 0;
|
|
3477
3477
|
}
|
|
3478
|
-
|
|
3478
|
+
const jsonDataPkgVersion = jsonData.pkgVersion.split(".");
|
|
3479
|
+
const midscenePkgInfoPkgVersion = this.midscenePkgInfo.version.split(".");
|
|
3480
|
+
if (jsonDataPkgVersion[0] !== midscenePkgInfoPkgVersion[0] || jsonDataPkgVersion[1] !== midscenePkgInfoPkgVersion[1]) {
|
|
3479
3481
|
return void 0;
|
|
3480
3482
|
}
|
|
3481
3483
|
return jsonData;
|
|
@@ -3509,6 +3511,56 @@ var TaskCache = class {
|
|
|
3509
3511
|
}
|
|
3510
3512
|
};
|
|
3511
3513
|
|
|
3514
|
+
// src/common/ui-utils.ts
|
|
3515
|
+
function typeStr(task) {
|
|
3516
|
+
return task.subType ? `${task.type} / ${task.subType || ""}` : task.type;
|
|
3517
|
+
}
|
|
3518
|
+
function getKeyCommands(value) {
|
|
3519
|
+
const keys = Array.isArray(value) ? value : [value];
|
|
3520
|
+
return keys.reduce((acc, k) => {
|
|
3521
|
+
const includeMeta = keys.includes("Meta") || keys.includes("Control");
|
|
3522
|
+
if (includeMeta && (k === "a" || k === "A")) {
|
|
3523
|
+
return acc.concat([{ key: k, command: "SelectAll" }]);
|
|
3524
|
+
}
|
|
3525
|
+
if (includeMeta && (k === "c" || k === "C")) {
|
|
3526
|
+
return acc.concat([{ key: k, command: "Copy" }]);
|
|
3527
|
+
}
|
|
3528
|
+
if (includeMeta && (k === "v" || k === "V")) {
|
|
3529
|
+
return acc.concat([{ key: k, command: "Paste" }]);
|
|
3530
|
+
}
|
|
3531
|
+
return acc.concat([{ key: k }]);
|
|
3532
|
+
}, []);
|
|
3533
|
+
}
|
|
3534
|
+
function paramStr(task) {
|
|
3535
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
3536
|
+
let value;
|
|
3537
|
+
if (task.type === "Planning") {
|
|
3538
|
+
value = (_a = task == null ? void 0 : task.param) == null ? void 0 : _a.userPrompt;
|
|
3539
|
+
}
|
|
3540
|
+
if (task.type === "Insight") {
|
|
3541
|
+
value = ((_b = task == null ? void 0 : task.param) == null ? void 0 : _b.prompt) || ((_c = task == null ? void 0 : task.param) == null ? void 0 : _c.id) || ((_d = task == null ? void 0 : task.param) == null ? void 0 : _d.dataDemand) || ((_e = task == null ? void 0 : task.param) == null ? void 0 : _e.assertion);
|
|
3542
|
+
}
|
|
3543
|
+
if (task.type === "Action") {
|
|
3544
|
+
const sleepMs = (_f = task == null ? void 0 : task.param) == null ? void 0 : _f.timeMs;
|
|
3545
|
+
const scrollType = (_g = task == null ? void 0 : task.param) == null ? void 0 : _g.scrollType;
|
|
3546
|
+
if (sleepMs) {
|
|
3547
|
+
value = `${sleepMs}ms`;
|
|
3548
|
+
} else if (scrollType) {
|
|
3549
|
+
const scrollDirection = (_h = task == null ? void 0 : task.param) == null ? void 0 : _h.direction;
|
|
3550
|
+
const scrollDistance = (_i = task == null ? void 0 : task.param) == null ? void 0 : _i.distance;
|
|
3551
|
+
value = `${scrollDirection || "down"}, ${scrollType || "once"}, ${scrollDistance || "distance-not-set"}`;
|
|
3552
|
+
} else {
|
|
3553
|
+
value = ((_j = task == null ? void 0 : task.param) == null ? void 0 : _j.value) || ((_k = task == null ? void 0 : task.param) == null ? void 0 : _k.scrollType);
|
|
3554
|
+
}
|
|
3555
|
+
if (!value) {
|
|
3556
|
+
value = task.thought;
|
|
3557
|
+
}
|
|
3558
|
+
}
|
|
3559
|
+
if (typeof value === "undefined")
|
|
3560
|
+
return "";
|
|
3561
|
+
return typeof value === "string" ? value : JSON.stringify(value, void 0, 2);
|
|
3562
|
+
}
|
|
3563
|
+
|
|
3512
3564
|
// src/common/tasks.ts
|
|
3513
3565
|
var PageTaskExecutor = class {
|
|
3514
3566
|
constructor(page, insight, opts) {
|
|
@@ -3722,8 +3774,8 @@ var PageTaskExecutor = class {
|
|
|
3722
3774
|
thought: plan2.thought,
|
|
3723
3775
|
locate: plan2.locate,
|
|
3724
3776
|
executor: async (taskParam) => {
|
|
3725
|
-
|
|
3726
|
-
await this.page.keyboard.press(
|
|
3777
|
+
const keys = getKeyCommands(taskParam.value);
|
|
3778
|
+
await this.page.keyboard.press(keys);
|
|
3727
3779
|
}
|
|
3728
3780
|
};
|
|
3729
3781
|
tasks.push(taskActionKeyboardPress);
|
|
@@ -4131,7 +4183,7 @@ var PageTaskExecutor = class {
|
|
|
4131
4183
|
const cacheGroup = this.taskCache.getCacheGroupByPrompt(userPrompt);
|
|
4132
4184
|
const isCompleted = false;
|
|
4133
4185
|
let currentActionNumber = 0;
|
|
4134
|
-
const maxActionNumber =
|
|
4186
|
+
const maxActionNumber = 40;
|
|
4135
4187
|
while (!isCompleted && currentActionNumber < maxActionNumber) {
|
|
4136
4188
|
currentActionNumber++;
|
|
4137
4189
|
const planningTask = this.planningTaskToGoal(
|
|
@@ -4327,40 +4379,6 @@ var PageTaskExecutor = class {
|
|
|
4327
4379
|
}
|
|
4328
4380
|
};
|
|
4329
4381
|
|
|
4330
|
-
// src/common/ui-utils.ts
|
|
4331
|
-
function typeStr(task) {
|
|
4332
|
-
return task.subType ? `${task.type} / ${task.subType || ""}` : task.type;
|
|
4333
|
-
}
|
|
4334
|
-
function paramStr(task) {
|
|
4335
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4336
|
-
let value;
|
|
4337
|
-
if (task.type === "Planning") {
|
|
4338
|
-
value = (_a = task == null ? void 0 : task.param) == null ? void 0 : _a.userPrompt;
|
|
4339
|
-
}
|
|
4340
|
-
if (task.type === "Insight") {
|
|
4341
|
-
value = ((_b = task == null ? void 0 : task.param) == null ? void 0 : _b.prompt) || ((_c = task == null ? void 0 : task.param) == null ? void 0 : _c.id) || ((_d = task == null ? void 0 : task.param) == null ? void 0 : _d.dataDemand) || ((_e = task == null ? void 0 : task.param) == null ? void 0 : _e.assertion);
|
|
4342
|
-
}
|
|
4343
|
-
if (task.type === "Action") {
|
|
4344
|
-
const sleepMs = (_f = task == null ? void 0 : task.param) == null ? void 0 : _f.timeMs;
|
|
4345
|
-
const scrollType = (_g = task == null ? void 0 : task.param) == null ? void 0 : _g.scrollType;
|
|
4346
|
-
if (sleepMs) {
|
|
4347
|
-
value = `${sleepMs}ms`;
|
|
4348
|
-
} else if (scrollType) {
|
|
4349
|
-
const scrollDirection = (_h = task == null ? void 0 : task.param) == null ? void 0 : _h.direction;
|
|
4350
|
-
const scrollDistance = (_i = task == null ? void 0 : task.param) == null ? void 0 : _i.distance;
|
|
4351
|
-
value = `${scrollDirection || "down"}, ${scrollType || "once"}, ${scrollDistance || "distance-not-set"}`;
|
|
4352
|
-
} else {
|
|
4353
|
-
value = ((_j = task == null ? void 0 : task.param) == null ? void 0 : _j.value) || ((_k = task == null ? void 0 : task.param) == null ? void 0 : _k.scrollType);
|
|
4354
|
-
}
|
|
4355
|
-
if (!value) {
|
|
4356
|
-
value = task.thought;
|
|
4357
|
-
}
|
|
4358
|
-
}
|
|
4359
|
-
if (typeof value === "undefined")
|
|
4360
|
-
return "";
|
|
4361
|
-
return typeof value === "string" ? value : JSON.stringify(value, void 0, 2);
|
|
4362
|
-
}
|
|
4363
|
-
|
|
4364
4382
|
// src/common/agent.ts
|
|
4365
4383
|
var PageAgent = class {
|
|
4366
4384
|
constructor(page, opts) {
|