@midscene/web 0.11.1 → 0.11.3
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 +85 -39
- package/dist/es/bridge-mode-browser.js +58 -19
- package/dist/es/bridge-mode.js +62 -43
- package/dist/es/chrome-extension.js +105 -51
- package/dist/es/index.js +292 -218
- package/dist/es/midscene-playground.js +57 -38
- package/dist/es/playground.js +57 -38
- package/dist/es/playwright-report.js +4 -0
- package/dist/es/playwright.js +252 -203
- package/dist/es/puppeteer.js +86 -60
- package/dist/es/ui-utils.js +43 -0
- package/dist/lib/appium.js +85 -39
- package/dist/lib/bridge-mode-browser.js +58 -19
- package/dist/lib/bridge-mode.js +62 -43
- package/dist/lib/chrome-extension.js +105 -51
- package/dist/lib/index.js +292 -218
- package/dist/lib/midscene-playground.js +57 -38
- package/dist/lib/playground.js +57 -38
- package/dist/lib/playwright-report.js +4 -0
- package/dist/lib/playwright.js +252 -203
- package/dist/lib/puppeteer.js +86 -60
- package/dist/lib/ui-utils.js +43 -0
- package/dist/types/{tasks-d5a01262.d.ts → agent-ae110e80.d.ts} +43 -43
- package/dist/types/appium.d.ts +3 -3
- package/dist/types/bridge-mode-browser.d.ts +3 -3
- package/dist/types/bridge-mode.d.ts +4 -4
- package/dist/types/{browser-7d5614fb.d.ts → browser-9d620553.d.ts} +4 -4
- package/dist/types/chrome-extension.d.ts +4 -4
- package/dist/types/index.d.ts +8 -8
- package/dist/types/{page-77af8d5f.d.ts → page-97720803.d.ts} +34 -8
- package/dist/types/playground.d.ts +4 -4
- package/dist/types/playwright.d.ts +13 -7
- package/dist/types/puppeteer.d.ts +3 -3
- package/dist/types/ui-utils.d.ts +6 -1
- package/dist/types/{utils-1a3bc661.d.ts → utils-93b3f5f3.d.ts} +1 -1
- package/dist/types/utils.d.ts +2 -2
- package/dist/types/yaml.d.ts +4 -4
- package/package.json +6 -6
package/dist/lib/bridge-mode.js
CHANGED
|
@@ -3365,7 +3365,9 @@ var TaskCache = class {
|
|
|
3365
3365
|
if (!this.midscenePkgInfo) {
|
|
3366
3366
|
return void 0;
|
|
3367
3367
|
}
|
|
3368
|
-
|
|
3368
|
+
const jsonDataPkgVersion = jsonData.pkgVersion.split(".");
|
|
3369
|
+
const midscenePkgInfoPkgVersion = this.midscenePkgInfo.version.split(".");
|
|
3370
|
+
if (jsonDataPkgVersion[0] !== midscenePkgInfoPkgVersion[0] || jsonDataPkgVersion[1] !== midscenePkgInfoPkgVersion[1]) {
|
|
3369
3371
|
return void 0;
|
|
3370
3372
|
}
|
|
3371
3373
|
return jsonData;
|
|
@@ -3399,6 +3401,56 @@ var TaskCache = class {
|
|
|
3399
3401
|
}
|
|
3400
3402
|
};
|
|
3401
3403
|
|
|
3404
|
+
// src/common/ui-utils.ts
|
|
3405
|
+
function typeStr(task) {
|
|
3406
|
+
return task.subType ? `${task.type} / ${task.subType || ""}` : task.type;
|
|
3407
|
+
}
|
|
3408
|
+
function getKeyCommands(value) {
|
|
3409
|
+
const keys = Array.isArray(value) ? value : [value];
|
|
3410
|
+
return keys.reduce((acc, k) => {
|
|
3411
|
+
const includeMeta = keys.includes("Meta") || keys.includes("Control");
|
|
3412
|
+
if (includeMeta && (k === "a" || k === "A")) {
|
|
3413
|
+
return acc.concat([{ key: k, command: "SelectAll" }]);
|
|
3414
|
+
}
|
|
3415
|
+
if (includeMeta && (k === "c" || k === "C")) {
|
|
3416
|
+
return acc.concat([{ key: k, command: "Copy" }]);
|
|
3417
|
+
}
|
|
3418
|
+
if (includeMeta && (k === "v" || k === "V")) {
|
|
3419
|
+
return acc.concat([{ key: k, command: "Paste" }]);
|
|
3420
|
+
}
|
|
3421
|
+
return acc.concat([{ key: k }]);
|
|
3422
|
+
}, []);
|
|
3423
|
+
}
|
|
3424
|
+
function paramStr(task) {
|
|
3425
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
3426
|
+
let value;
|
|
3427
|
+
if (task.type === "Planning") {
|
|
3428
|
+
value = (_a = task == null ? void 0 : task.param) == null ? void 0 : _a.userPrompt;
|
|
3429
|
+
}
|
|
3430
|
+
if (task.type === "Insight") {
|
|
3431
|
+
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);
|
|
3432
|
+
}
|
|
3433
|
+
if (task.type === "Action") {
|
|
3434
|
+
const sleepMs = (_f = task == null ? void 0 : task.param) == null ? void 0 : _f.timeMs;
|
|
3435
|
+
const scrollType = (_g = task == null ? void 0 : task.param) == null ? void 0 : _g.scrollType;
|
|
3436
|
+
if (sleepMs) {
|
|
3437
|
+
value = `${sleepMs}ms`;
|
|
3438
|
+
} else if (scrollType) {
|
|
3439
|
+
const scrollDirection = (_h = task == null ? void 0 : task.param) == null ? void 0 : _h.direction;
|
|
3440
|
+
const scrollDistance = (_i = task == null ? void 0 : task.param) == null ? void 0 : _i.distance;
|
|
3441
|
+
value = `${scrollDirection || "down"}, ${scrollType || "once"}, ${scrollDistance || "distance-not-set"}`;
|
|
3442
|
+
} else {
|
|
3443
|
+
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);
|
|
3444
|
+
}
|
|
3445
|
+
if (!value) {
|
|
3446
|
+
value = task.thought;
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
if (typeof value === "undefined")
|
|
3450
|
+
return "";
|
|
3451
|
+
return typeof value === "string" ? value : JSON.stringify(value, void 0, 2);
|
|
3452
|
+
}
|
|
3453
|
+
|
|
3402
3454
|
// src/common/tasks.ts
|
|
3403
3455
|
var PageTaskExecutor = class {
|
|
3404
3456
|
constructor(page, insight, opts) {
|
|
@@ -3533,6 +3585,7 @@ var PageTaskExecutor = class {
|
|
|
3533
3585
|
output: {
|
|
3534
3586
|
element
|
|
3535
3587
|
},
|
|
3588
|
+
pageContext,
|
|
3536
3589
|
log: {
|
|
3537
3590
|
dump: insightDump
|
|
3538
3591
|
},
|
|
@@ -3612,8 +3665,8 @@ var PageTaskExecutor = class {
|
|
|
3612
3665
|
thought: plan2.thought,
|
|
3613
3666
|
locate: plan2.locate,
|
|
3614
3667
|
executor: async (taskParam) => {
|
|
3615
|
-
|
|
3616
|
-
await this.page.keyboard.press(
|
|
3668
|
+
const keys = getKeyCommands(taskParam.value);
|
|
3669
|
+
await this.page.keyboard.press(keys);
|
|
3617
3670
|
}
|
|
3618
3671
|
};
|
|
3619
3672
|
tasks.push(taskActionKeyboardPress);
|
|
@@ -4021,7 +4074,7 @@ var PageTaskExecutor = class {
|
|
|
4021
4074
|
const cacheGroup = this.taskCache.getCacheGroupByPrompt(userPrompt);
|
|
4022
4075
|
const isCompleted = false;
|
|
4023
4076
|
let currentActionNumber = 0;
|
|
4024
|
-
const maxActionNumber =
|
|
4077
|
+
const maxActionNumber = 40;
|
|
4025
4078
|
while (!isCompleted && currentActionNumber < maxActionNumber) {
|
|
4026
4079
|
currentActionNumber++;
|
|
4027
4080
|
const planningTask = this.planningTaskToGoal(
|
|
@@ -4241,40 +4294,6 @@ var WebElementInfo = class {
|
|
|
4241
4294
|
}
|
|
4242
4295
|
};
|
|
4243
4296
|
|
|
4244
|
-
// src/common/ui-utils.ts
|
|
4245
|
-
function typeStr(task) {
|
|
4246
|
-
return task.subType ? `${task.type} / ${task.subType || ""}` : task.type;
|
|
4247
|
-
}
|
|
4248
|
-
function paramStr(task) {
|
|
4249
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4250
|
-
let value;
|
|
4251
|
-
if (task.type === "Planning") {
|
|
4252
|
-
value = (_a = task == null ? void 0 : task.param) == null ? void 0 : _a.userPrompt;
|
|
4253
|
-
}
|
|
4254
|
-
if (task.type === "Insight") {
|
|
4255
|
-
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);
|
|
4256
|
-
}
|
|
4257
|
-
if (task.type === "Action") {
|
|
4258
|
-
const sleepMs = (_f = task == null ? void 0 : task.param) == null ? void 0 : _f.timeMs;
|
|
4259
|
-
const scrollType = (_g = task == null ? void 0 : task.param) == null ? void 0 : _g.scrollType;
|
|
4260
|
-
if (sleepMs) {
|
|
4261
|
-
value = `${sleepMs}ms`;
|
|
4262
|
-
} else if (scrollType) {
|
|
4263
|
-
const scrollDirection = (_h = task == null ? void 0 : task.param) == null ? void 0 : _h.direction;
|
|
4264
|
-
const scrollDistance = (_i = task == null ? void 0 : task.param) == null ? void 0 : _i.distance;
|
|
4265
|
-
value = `${scrollDirection || "down"}, ${scrollType || "once"}, ${scrollDistance || "distance-not-set"}`;
|
|
4266
|
-
} else {
|
|
4267
|
-
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);
|
|
4268
|
-
}
|
|
4269
|
-
if (!value) {
|
|
4270
|
-
value = task.thought;
|
|
4271
|
-
}
|
|
4272
|
-
}
|
|
4273
|
-
if (typeof value === "undefined")
|
|
4274
|
-
return "";
|
|
4275
|
-
return typeof value === "string" ? value : JSON.stringify(value, void 0, 2);
|
|
4276
|
-
}
|
|
4277
|
-
|
|
4278
4297
|
// src/common/utils.ts
|
|
4279
4298
|
var import_node_assert4 = __toESM(require("assert"));
|
|
4280
4299
|
var import_node_fs3 = require("fs");
|
|
@@ -4619,7 +4638,7 @@ var BridgeServer = class {
|
|
|
4619
4638
|
this.socket = socket;
|
|
4620
4639
|
const clientVersion = socket.handshake.query.version;
|
|
4621
4640
|
console.log(
|
|
4622
|
-
`Bridge connected, cli-side version v${"0.11.
|
|
4641
|
+
`Bridge connected, cli-side version v${"0.11.3"}, browser-side version v${clientVersion}`
|
|
4623
4642
|
);
|
|
4624
4643
|
socket.on("bridge-call-response" /* CallResponse */, (params) => {
|
|
4625
4644
|
const id = params.id;
|
|
@@ -4652,7 +4671,7 @@ var BridgeServer = class {
|
|
|
4652
4671
|
var _a;
|
|
4653
4672
|
(_a = this.onConnect) == null ? void 0 : _a.call(this);
|
|
4654
4673
|
const payload = {
|
|
4655
|
-
version: "0.11.
|
|
4674
|
+
version: "0.11.3"
|
|
4656
4675
|
};
|
|
4657
4676
|
socket.emit("bridge-connected" /* Connected */, payload);
|
|
4658
4677
|
Promise.resolve().then(() => {
|
|
@@ -4741,7 +4760,7 @@ var BridgeServer = class {
|
|
|
4741
4760
|
};
|
|
4742
4761
|
|
|
4743
4762
|
// src/bridge-mode/agent-cli-side.ts
|
|
4744
|
-
var
|
|
4763
|
+
var sleep3 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
4745
4764
|
var getBridgePageInCliSide = () => {
|
|
4746
4765
|
const server = new BridgeServer(DefaultBridgeServerPort);
|
|
4747
4766
|
server.listen();
|
|
@@ -4819,11 +4838,11 @@ var AgentOverChromeBridge = class extends PageAgent {
|
|
|
4819
4838
|
}
|
|
4820
4839
|
async connectNewTabWithUrl(url, options) {
|
|
4821
4840
|
await this.page.connectNewTabWithUrl(url, options);
|
|
4822
|
-
await
|
|
4841
|
+
await sleep3(500);
|
|
4823
4842
|
}
|
|
4824
4843
|
async connectCurrentTab(options) {
|
|
4825
4844
|
await this.page.connectCurrentTab(options);
|
|
4826
|
-
await
|
|
4845
|
+
await sleep3(500);
|
|
4827
4846
|
}
|
|
4828
4847
|
async aiAction(prompt, options) {
|
|
4829
4848
|
if (options) {
|
|
@@ -3497,7 +3497,9 @@ var TaskCache = class {
|
|
|
3497
3497
|
if (!this.midscenePkgInfo) {
|
|
3498
3498
|
return void 0;
|
|
3499
3499
|
}
|
|
3500
|
-
|
|
3500
|
+
const jsonDataPkgVersion = jsonData.pkgVersion.split(".");
|
|
3501
|
+
const midscenePkgInfoPkgVersion = this.midscenePkgInfo.version.split(".");
|
|
3502
|
+
if (jsonDataPkgVersion[0] !== midscenePkgInfoPkgVersion[0] || jsonDataPkgVersion[1] !== midscenePkgInfoPkgVersion[1]) {
|
|
3501
3503
|
return void 0;
|
|
3502
3504
|
}
|
|
3503
3505
|
return jsonData;
|
|
@@ -3531,6 +3533,79 @@ var TaskCache = class {
|
|
|
3531
3533
|
}
|
|
3532
3534
|
};
|
|
3533
3535
|
|
|
3536
|
+
// src/common/ui-utils.ts
|
|
3537
|
+
function typeStr(task) {
|
|
3538
|
+
return task.subType ? `${task.type} / ${task.subType || ""}` : task.type;
|
|
3539
|
+
}
|
|
3540
|
+
function getKeyCommands(value) {
|
|
3541
|
+
const keys = Array.isArray(value) ? value : [value];
|
|
3542
|
+
return keys.reduce((acc, k) => {
|
|
3543
|
+
const includeMeta = keys.includes("Meta") || keys.includes("Control");
|
|
3544
|
+
if (includeMeta && (k === "a" || k === "A")) {
|
|
3545
|
+
return acc.concat([{ key: k, command: "SelectAll" }]);
|
|
3546
|
+
}
|
|
3547
|
+
if (includeMeta && (k === "c" || k === "C")) {
|
|
3548
|
+
return acc.concat([{ key: k, command: "Copy" }]);
|
|
3549
|
+
}
|
|
3550
|
+
if (includeMeta && (k === "v" || k === "V")) {
|
|
3551
|
+
return acc.concat([{ key: k, command: "Paste" }]);
|
|
3552
|
+
}
|
|
3553
|
+
return acc.concat([{ key: k }]);
|
|
3554
|
+
}, []);
|
|
3555
|
+
}
|
|
3556
|
+
function paramStr(task) {
|
|
3557
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
3558
|
+
let value;
|
|
3559
|
+
if (task.type === "Planning") {
|
|
3560
|
+
value = (_a = task == null ? void 0 : task.param) == null ? void 0 : _a.userPrompt;
|
|
3561
|
+
}
|
|
3562
|
+
if (task.type === "Insight") {
|
|
3563
|
+
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);
|
|
3564
|
+
}
|
|
3565
|
+
if (task.type === "Action") {
|
|
3566
|
+
const sleepMs = (_f = task == null ? void 0 : task.param) == null ? void 0 : _f.timeMs;
|
|
3567
|
+
const scrollType = (_g = task == null ? void 0 : task.param) == null ? void 0 : _g.scrollType;
|
|
3568
|
+
if (sleepMs) {
|
|
3569
|
+
value = `${sleepMs}ms`;
|
|
3570
|
+
} else if (scrollType) {
|
|
3571
|
+
const scrollDirection = (_h = task == null ? void 0 : task.param) == null ? void 0 : _h.direction;
|
|
3572
|
+
const scrollDistance = (_i = task == null ? void 0 : task.param) == null ? void 0 : _i.distance;
|
|
3573
|
+
value = `${scrollDirection || "down"}, ${scrollType || "once"}, ${scrollDistance || "distance-not-set"}`;
|
|
3574
|
+
} else {
|
|
3575
|
+
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);
|
|
3576
|
+
}
|
|
3577
|
+
if (!value) {
|
|
3578
|
+
value = task.thought;
|
|
3579
|
+
}
|
|
3580
|
+
}
|
|
3581
|
+
if (typeof value === "undefined")
|
|
3582
|
+
return "";
|
|
3583
|
+
return typeof value === "string" ? value : JSON.stringify(value, void 0, 2);
|
|
3584
|
+
}
|
|
3585
|
+
var limitOpenNewTabScript = `
|
|
3586
|
+
if (!window.__MIDSCENE_NEW_TAB_INTERCEPTOR_INITIALIZED__) {
|
|
3587
|
+
window.__MIDSCENE_NEW_TAB_INTERCEPTOR_INITIALIZED__ = true;
|
|
3588
|
+
|
|
3589
|
+
// Intercept the window.open method (only once)
|
|
3590
|
+
window.open = function(url) {
|
|
3591
|
+
console.log('Blocked window.open:', url);
|
|
3592
|
+
window.location.href = url;
|
|
3593
|
+
return null;
|
|
3594
|
+
};
|
|
3595
|
+
|
|
3596
|
+
// Block all a tag clicks with target="_blank" (only once)
|
|
3597
|
+
document.addEventListener('click', function(e) {
|
|
3598
|
+
const target = e.target.closest('a');
|
|
3599
|
+
if (target && target.target === '_blank') {
|
|
3600
|
+
e.preventDefault();
|
|
3601
|
+
console.log('Blocked new tab:', target.href);
|
|
3602
|
+
window.location.href = target.href;
|
|
3603
|
+
target.removeAttribute('target');
|
|
3604
|
+
}
|
|
3605
|
+
}, true);
|
|
3606
|
+
}
|
|
3607
|
+
`;
|
|
3608
|
+
|
|
3534
3609
|
// src/common/tasks.ts
|
|
3535
3610
|
var PageTaskExecutor = class {
|
|
3536
3611
|
constructor(page, insight, opts) {
|
|
@@ -3665,6 +3740,7 @@ var PageTaskExecutor = class {
|
|
|
3665
3740
|
output: {
|
|
3666
3741
|
element
|
|
3667
3742
|
},
|
|
3743
|
+
pageContext,
|
|
3668
3744
|
log: {
|
|
3669
3745
|
dump: insightDump
|
|
3670
3746
|
},
|
|
@@ -3744,8 +3820,8 @@ var PageTaskExecutor = class {
|
|
|
3744
3820
|
thought: plan2.thought,
|
|
3745
3821
|
locate: plan2.locate,
|
|
3746
3822
|
executor: async (taskParam) => {
|
|
3747
|
-
|
|
3748
|
-
await this.page.keyboard.press(
|
|
3823
|
+
const keys = getKeyCommands(taskParam.value);
|
|
3824
|
+
await this.page.keyboard.press(keys);
|
|
3749
3825
|
}
|
|
3750
3826
|
};
|
|
3751
3827
|
tasks.push(taskActionKeyboardPress);
|
|
@@ -4153,7 +4229,7 @@ var PageTaskExecutor = class {
|
|
|
4153
4229
|
const cacheGroup = this.taskCache.getCacheGroupByPrompt(userPrompt);
|
|
4154
4230
|
const isCompleted = false;
|
|
4155
4231
|
let currentActionNumber = 0;
|
|
4156
|
-
const maxActionNumber =
|
|
4232
|
+
const maxActionNumber = 40;
|
|
4157
4233
|
while (!isCompleted && currentActionNumber < maxActionNumber) {
|
|
4158
4234
|
currentActionNumber++;
|
|
4159
4235
|
const planningTask = this.planningTaskToGoal(
|
|
@@ -4349,40 +4425,6 @@ var PageTaskExecutor = class {
|
|
|
4349
4425
|
}
|
|
4350
4426
|
};
|
|
4351
4427
|
|
|
4352
|
-
// src/common/ui-utils.ts
|
|
4353
|
-
function typeStr(task) {
|
|
4354
|
-
return task.subType ? `${task.type} / ${task.subType || ""}` : task.type;
|
|
4355
|
-
}
|
|
4356
|
-
function paramStr(task) {
|
|
4357
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4358
|
-
let value;
|
|
4359
|
-
if (task.type === "Planning") {
|
|
4360
|
-
value = (_a = task == null ? void 0 : task.param) == null ? void 0 : _a.userPrompt;
|
|
4361
|
-
}
|
|
4362
|
-
if (task.type === "Insight") {
|
|
4363
|
-
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);
|
|
4364
|
-
}
|
|
4365
|
-
if (task.type === "Action") {
|
|
4366
|
-
const sleepMs = (_f = task == null ? void 0 : task.param) == null ? void 0 : _f.timeMs;
|
|
4367
|
-
const scrollType = (_g = task == null ? void 0 : task.param) == null ? void 0 : _g.scrollType;
|
|
4368
|
-
if (sleepMs) {
|
|
4369
|
-
value = `${sleepMs}ms`;
|
|
4370
|
-
} else if (scrollType) {
|
|
4371
|
-
const scrollDirection = (_h = task == null ? void 0 : task.param) == null ? void 0 : _h.direction;
|
|
4372
|
-
const scrollDistance = (_i = task == null ? void 0 : task.param) == null ? void 0 : _i.distance;
|
|
4373
|
-
value = `${scrollDirection || "down"}, ${scrollType || "once"}, ${scrollDistance || "distance-not-set"}`;
|
|
4374
|
-
} else {
|
|
4375
|
-
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);
|
|
4376
|
-
}
|
|
4377
|
-
if (!value) {
|
|
4378
|
-
value = task.thought;
|
|
4379
|
-
}
|
|
4380
|
-
}
|
|
4381
|
-
if (typeof value === "undefined")
|
|
4382
|
-
return "";
|
|
4383
|
-
return typeof value === "string" ? value : JSON.stringify(value, void 0, 2);
|
|
4384
|
-
}
|
|
4385
|
-
|
|
4386
4428
|
// src/common/agent.ts
|
|
4387
4429
|
var PageAgent = class {
|
|
4388
4430
|
constructor(page, opts) {
|
|
@@ -4786,13 +4828,13 @@ var injectStopWaterFlowAnimation = async () => {
|
|
|
4786
4828
|
};
|
|
4787
4829
|
|
|
4788
4830
|
// src/chrome-extension/page.ts
|
|
4789
|
-
function
|
|
4831
|
+
function sleep3(ms) {
|
|
4790
4832
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
4791
4833
|
}
|
|
4792
4834
|
var ChromeExtensionProxyPage = class {
|
|
4793
|
-
constructor(
|
|
4835
|
+
constructor(forceSameTabNavigation) {
|
|
4794
4836
|
this.pageType = "chrome-extension-proxy";
|
|
4795
|
-
this.version = "0.11.
|
|
4837
|
+
this.version = "0.11.3";
|
|
4796
4838
|
this.activeTabId = null;
|
|
4797
4839
|
this.tabIdOfDebuggerAttached = null;
|
|
4798
4840
|
this.attachingDebugger = null;
|
|
@@ -4861,23 +4903,24 @@ var ChromeExtensionProxyPage = class {
|
|
|
4861
4903
|
});
|
|
4862
4904
|
await cdpKeyboard.type(text, { delay: 0 });
|
|
4863
4905
|
},
|
|
4864
|
-
press: async (
|
|
4906
|
+
press: async (action) => {
|
|
4865
4907
|
const cdpKeyboard = new CdpKeyboard({
|
|
4866
4908
|
send: this.sendCommandToDebugger.bind(this)
|
|
4867
4909
|
});
|
|
4868
|
-
const keys = Array.isArray(
|
|
4910
|
+
const keys = Array.isArray(action) ? action : [action];
|
|
4869
4911
|
for (const k of keys) {
|
|
4870
|
-
|
|
4912
|
+
const commands = k.command ? [k.command] : [];
|
|
4913
|
+
await cdpKeyboard.down(k.key, { commands });
|
|
4871
4914
|
}
|
|
4872
4915
|
for (const k of [...keys].reverse()) {
|
|
4873
|
-
await cdpKeyboard.up(k);
|
|
4916
|
+
await cdpKeyboard.up(k.key);
|
|
4874
4917
|
}
|
|
4875
4918
|
}
|
|
4876
4919
|
};
|
|
4877
|
-
this.
|
|
4920
|
+
this.forceSameTabNavigation = forceSameTabNavigation;
|
|
4878
4921
|
}
|
|
4879
4922
|
async getTabId() {
|
|
4880
|
-
if (this.activeTabId && !this.
|
|
4923
|
+
if (this.activeTabId && !this.forceSameTabNavigation) {
|
|
4881
4924
|
return this.activeTabId;
|
|
4882
4925
|
}
|
|
4883
4926
|
const tabId = await chrome.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
|
|
@@ -4919,7 +4962,7 @@ var ChromeExtensionProxyPage = class {
|
|
|
4919
4962
|
}
|
|
4920
4963
|
}
|
|
4921
4964
|
await chrome.debugger.attach({ tabId: currentTabId }, "1.3");
|
|
4922
|
-
await
|
|
4965
|
+
await sleep3(500);
|
|
4923
4966
|
this.tabIdOfDebuggerAttached = currentTabId;
|
|
4924
4967
|
await this.enableWaterFlowAnimation();
|
|
4925
4968
|
} catch (error) {
|
|
@@ -4959,11 +5002,20 @@ var ChromeExtensionProxyPage = class {
|
|
|
4959
5002
|
return;
|
|
4960
5003
|
}
|
|
4961
5004
|
await this.disableWaterFlowAnimation(tabIdToDetach);
|
|
4962
|
-
await
|
|
5005
|
+
await sleep3(200);
|
|
4963
5006
|
await chrome.debugger.detach({ tabId: tabIdToDetach });
|
|
4964
5007
|
this.tabIdOfDebuggerAttached = null;
|
|
4965
5008
|
}
|
|
4966
5009
|
async enableWaterFlowAnimation() {
|
|
5010
|
+
if (this.forceSameTabNavigation) {
|
|
5011
|
+
await chrome.debugger.sendCommand(
|
|
5012
|
+
{ tabId: this.tabIdOfDebuggerAttached },
|
|
5013
|
+
"Runtime.evaluate",
|
|
5014
|
+
{
|
|
5015
|
+
expression: limitOpenNewTabScript
|
|
5016
|
+
}
|
|
5017
|
+
);
|
|
5018
|
+
}
|
|
4967
5019
|
const script = await injectWaterFlowAnimation();
|
|
4968
5020
|
await chrome.debugger.sendCommand(
|
|
4969
5021
|
{ tabId: this.tabIdOfDebuggerAttached },
|
|
@@ -5149,8 +5201,10 @@ var ChromeExtensionProxyPage = class {
|
|
|
5149
5201
|
type: "keyUp",
|
|
5150
5202
|
commands: ["selectAll"]
|
|
5151
5203
|
});
|
|
5152
|
-
await
|
|
5153
|
-
await this.keyboard.press(
|
|
5204
|
+
await sleep3(100);
|
|
5205
|
+
await this.keyboard.press({
|
|
5206
|
+
key: "Backspace"
|
|
5207
|
+
});
|
|
5154
5208
|
}
|
|
5155
5209
|
async destroy() {
|
|
5156
5210
|
this.activeTabId = null;
|