@midscene/web 0.11.2 → 0.11.4-beta-20250219074605.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/appium.js +110 -76
- package/dist/es/bridge-mode-browser.js +3 -3
- package/dist/es/bridge-mode.js +114 -80
- package/dist/es/chrome-extension.js +108 -74
- package/dist/es/index.js +114 -78
- package/dist/es/midscene-playground.js +107 -73
- package/dist/es/playground.js +107 -73
- package/dist/es/playwright-report.js +4 -0
- package/dist/es/playwright.js +112 -78
- package/dist/es/puppeteer.js +112 -78
- package/dist/es/ui-utils.js +1 -1
- package/dist/es/utils.js +7 -5
- package/dist/es/yaml.js +6 -2
- package/dist/lib/appium.js +110 -76
- package/dist/lib/bridge-mode-browser.js +3 -3
- package/dist/lib/bridge-mode.js +114 -80
- package/dist/lib/chrome-extension.js +108 -74
- package/dist/lib/index.js +114 -78
- package/dist/lib/midscene-playground.js +107 -73
- package/dist/lib/playground.js +107 -73
- package/dist/lib/playwright-report.js +4 -0
- package/dist/lib/playwright.js +112 -78
- package/dist/lib/puppeteer.js +112 -78
- package/dist/lib/ui-utils.js +1 -1
- package/dist/lib/utils.js +7 -5
- package/dist/lib/yaml.js +6 -2
- package/dist/types/{agent-ac363fa3.d.ts → agent-e2bbb4e3.d.ts} +3 -3
- 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-eae1a5c1.d.ts → browser-348ab173.d.ts} +1 -1
- package/dist/types/chrome-extension.d.ts +4 -4
- package/dist/types/index.d.ts +4 -4
- package/dist/types/{page-cf0f892e.d.ts → page-edfbc6b7.d.ts} +2 -2
- package/dist/types/playground.d.ts +4 -4
- package/dist/types/playwright.d.ts +3 -3
- package/dist/types/puppeteer.d.ts +3 -3
- package/dist/types/{utils-9a29bfa0.d.ts → utils-80dea51c.d.ts} +1 -1
- package/dist/types/utils.d.ts +2 -2
- package/dist/types/yaml.d.ts +4 -4
- package/package.json +3 -3
package/dist/es/appium.js
CHANGED
|
@@ -452,11 +452,15 @@ var ScriptPlayer = class {
|
|
|
452
452
|
} else if (flowItem.sleep) {
|
|
453
453
|
const sleepTask = flowItem;
|
|
454
454
|
const ms = sleepTask.sleep;
|
|
455
|
+
let msNumber = ms;
|
|
456
|
+
if (typeof ms === "string") {
|
|
457
|
+
msNumber = Number.parseInt(ms, 10);
|
|
458
|
+
}
|
|
455
459
|
(0, import_node_assert.default)(
|
|
456
|
-
|
|
460
|
+
msNumber && msNumber > 0,
|
|
457
461
|
`ms for sleep must be greater than 0, but got ${ms}`
|
|
458
462
|
);
|
|
459
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
463
|
+
await new Promise((resolve) => setTimeout(resolve, msNumber));
|
|
460
464
|
} else {
|
|
461
465
|
throw new Error(`unknown flowItem: ${JSON.stringify(flowItem)}`);
|
|
462
466
|
}
|
|
@@ -3243,13 +3247,15 @@ function parseYamlScript(content, filePath, ignoreCheckingTarget) {
|
|
|
3243
3247
|
}
|
|
3244
3248
|
|
|
3245
3249
|
// src/common/agent.ts
|
|
3246
|
-
var
|
|
3250
|
+
var import_env5 = require("@midscene/core/env");
|
|
3247
3251
|
var import_utils6 = require("@midscene/core/utils");
|
|
3248
3252
|
|
|
3249
3253
|
// src/common/tasks.ts
|
|
3250
3254
|
var import_node_assert3 = __toESM(require("assert"));
|
|
3251
3255
|
var import_core = require("@midscene/core");
|
|
3252
3256
|
var import_ai_model = require("@midscene/core/ai-model");
|
|
3257
|
+
var import_env2 = require("@midscene/core/env");
|
|
3258
|
+
var import_env3 = require("@midscene/core/env");
|
|
3253
3259
|
var import_utils3 = require("@midscene/core/utils");
|
|
3254
3260
|
|
|
3255
3261
|
// src/common/task-cache.ts
|
|
@@ -3422,7 +3428,7 @@ function paramStr(task) {
|
|
|
3422
3428
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
3423
3429
|
let value;
|
|
3424
3430
|
if (task.type === "Planning") {
|
|
3425
|
-
value = (_a = task == null ? void 0 : task.param) == null ? void 0 : _a.
|
|
3431
|
+
value = (_a = task == null ? void 0 : task.param) == null ? void 0 : _a.userInstruction;
|
|
3426
3432
|
}
|
|
3427
3433
|
if (task.type === "Insight") {
|
|
3428
3434
|
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);
|
|
@@ -3449,6 +3455,7 @@ function paramStr(task) {
|
|
|
3449
3455
|
}
|
|
3450
3456
|
|
|
3451
3457
|
// src/common/tasks.ts
|
|
3458
|
+
var replanningCountLimit = 10;
|
|
3452
3459
|
var PageTaskExecutor = class {
|
|
3453
3460
|
constructor(page, insight, opts) {
|
|
3454
3461
|
this.conversationHistory = [];
|
|
@@ -3507,9 +3514,9 @@ var PageTaskExecutor = class {
|
|
|
3507
3514
|
async convertPlanToExecutable(plans, cacheGroup) {
|
|
3508
3515
|
const tasks = [];
|
|
3509
3516
|
plans.forEach((plan2) => {
|
|
3510
|
-
var _a, _b;
|
|
3517
|
+
var _a, _b, _c;
|
|
3511
3518
|
if (plan2.type === "Locate") {
|
|
3512
|
-
if (((_a = plan2.locate) == null ? void 0 : _a.id) === null || ((_b = plan2.locate) == null ? void 0 : _b.id) === "null") {
|
|
3519
|
+
if (plan2.locate === null || ((_a = plan2.locate) == null ? void 0 : _a.id) === null || ((_b = plan2.locate) == null ? void 0 : _b.id) === "null") {
|
|
3513
3520
|
return;
|
|
3514
3521
|
}
|
|
3515
3522
|
const taskFind = {
|
|
@@ -3521,12 +3528,15 @@ var PageTaskExecutor = class {
|
|
|
3521
3528
|
executor: async (param, taskContext) => {
|
|
3522
3529
|
const { task } = taskContext;
|
|
3523
3530
|
(0, import_node_assert3.default)(
|
|
3524
|
-
(param == null ? void 0 : param.prompt) || (param == null ? void 0 : param.id) || (param == null ? void 0 : param.position),
|
|
3525
|
-
"No prompt or id or position to locate"
|
|
3531
|
+
(param == null ? void 0 : param.prompt) || (param == null ? void 0 : param.id) || (param == null ? void 0 : param.position) || (param == null ? void 0 : param.bbox),
|
|
3532
|
+
"No prompt or id or position or bbox to locate"
|
|
3526
3533
|
);
|
|
3527
3534
|
let insightDump;
|
|
3535
|
+
let usage;
|
|
3528
3536
|
const dumpCollector = (dump2) => {
|
|
3537
|
+
var _a2;
|
|
3529
3538
|
insightDump = dump2;
|
|
3539
|
+
usage = (_a2 = dump2 == null ? void 0 : dump2.taskInfo) == null ? void 0 : _a2.usage;
|
|
3530
3540
|
};
|
|
3531
3541
|
this.insight.onceDumpUpdatedFn = dumpCollector;
|
|
3532
3542
|
const shotTime = Date.now();
|
|
@@ -3546,7 +3556,8 @@ var PageTaskExecutor = class {
|
|
|
3546
3556
|
const callAI = this.insight.aiVendorFn;
|
|
3547
3557
|
const quickAnswer = {
|
|
3548
3558
|
id: param == null ? void 0 : param.id,
|
|
3549
|
-
position: param == null ? void 0 : param.position
|
|
3559
|
+
position: param == null ? void 0 : param.position,
|
|
3560
|
+
bbox: param == null ? void 0 : param.bbox
|
|
3550
3561
|
};
|
|
3551
3562
|
const startTime = Date.now();
|
|
3552
3563
|
const element = await this.insight.locate(param.prompt, {
|
|
@@ -3556,8 +3567,8 @@ var PageTaskExecutor = class {
|
|
|
3556
3567
|
locateResult = locateCache;
|
|
3557
3568
|
return Promise.resolve({ content: locateCache });
|
|
3558
3569
|
}
|
|
3559
|
-
const { content: aiResult, usage } = await callAI(...message);
|
|
3560
|
-
return { content: aiResult, usage };
|
|
3570
|
+
const { content: aiResult, usage: usage2 } = await callAI(...message);
|
|
3571
|
+
return { content: aiResult, usage: usage2 };
|
|
3561
3572
|
}
|
|
3562
3573
|
});
|
|
3563
3574
|
const aiCost = Date.now() - startTime;
|
|
@@ -3582,6 +3593,7 @@ var PageTaskExecutor = class {
|
|
|
3582
3593
|
output: {
|
|
3583
3594
|
element
|
|
3584
3595
|
},
|
|
3596
|
+
pageContext,
|
|
3585
3597
|
log: {
|
|
3586
3598
|
dump: insightDump
|
|
3587
3599
|
},
|
|
@@ -3589,7 +3601,8 @@ var PageTaskExecutor = class {
|
|
|
3589
3601
|
hit: Boolean(locateCache)
|
|
3590
3602
|
},
|
|
3591
3603
|
recorder: [recordItem],
|
|
3592
|
-
aiCost
|
|
3604
|
+
aiCost,
|
|
3605
|
+
usage
|
|
3593
3606
|
};
|
|
3594
3607
|
}
|
|
3595
3608
|
};
|
|
@@ -3788,12 +3801,12 @@ var PageTaskExecutor = class {
|
|
|
3788
3801
|
}
|
|
3789
3802
|
};
|
|
3790
3803
|
tasks.push(taskActionError);
|
|
3791
|
-
} else if (plan2.type === "
|
|
3804
|
+
} else if (plan2.type === "ExpectedFalsyCondition") {
|
|
3792
3805
|
const taskActionFalsyConditionStatement = {
|
|
3793
3806
|
type: "Action",
|
|
3794
|
-
subType: "
|
|
3807
|
+
subType: "ExpectedFalsyCondition",
|
|
3795
3808
|
param: null,
|
|
3796
|
-
thought: plan2.
|
|
3809
|
+
thought: (_c = plan2.param) == null ? void 0 : _c.reason,
|
|
3797
3810
|
locate: plan2.locate,
|
|
3798
3811
|
executor: async () => {
|
|
3799
3812
|
}
|
|
@@ -3829,14 +3842,13 @@ var PageTaskExecutor = class {
|
|
|
3829
3842
|
tasks: wrappedTasks
|
|
3830
3843
|
};
|
|
3831
3844
|
}
|
|
3832
|
-
planningTaskFromPrompt(
|
|
3845
|
+
planningTaskFromPrompt(userInstruction, cacheGroup, log) {
|
|
3833
3846
|
const task = {
|
|
3834
3847
|
type: "Planning",
|
|
3835
3848
|
locate: null,
|
|
3836
3849
|
param: {
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
originalPrompt
|
|
3850
|
+
userInstruction,
|
|
3851
|
+
log
|
|
3840
3852
|
},
|
|
3841
3853
|
executor: async (param, executorContext) => {
|
|
3842
3854
|
const shotTime = Date.now();
|
|
@@ -3849,80 +3861,101 @@ var PageTaskExecutor = class {
|
|
|
3849
3861
|
};
|
|
3850
3862
|
executorContext.task.recorder = [recordItem];
|
|
3851
3863
|
executorContext.task.pageContext = pageContext;
|
|
3852
|
-
const
|
|
3864
|
+
const qwenMode = (0, import_env2.getAIConfigInBoolean)(import_env3.MIDSCENE_USE_QWEN_VL);
|
|
3865
|
+
const planCache = cacheGroup.readCache(
|
|
3866
|
+
pageContext,
|
|
3867
|
+
"plan",
|
|
3868
|
+
param.userInstruction
|
|
3869
|
+
);
|
|
3853
3870
|
let planResult;
|
|
3854
|
-
if (planCache) {
|
|
3871
|
+
if (planCache && !qwenMode) {
|
|
3855
3872
|
planResult = planCache;
|
|
3856
3873
|
} else {
|
|
3857
|
-
planResult = await (0, import_core.plan)(param.
|
|
3874
|
+
planResult = await (0, import_core.plan)(param.userInstruction, {
|
|
3858
3875
|
context: pageContext,
|
|
3859
|
-
|
|
3860
|
-
originalPrompt: param.originalPrompt
|
|
3876
|
+
log: param.log
|
|
3861
3877
|
});
|
|
3862
3878
|
}
|
|
3863
|
-
const { actions,
|
|
3879
|
+
const { actions, log: log2, finish, error, usage, rawResponse, sleep: sleep3 } = planResult;
|
|
3864
3880
|
let stopCollecting = false;
|
|
3881
|
+
let bboxCollected = false;
|
|
3882
|
+
let planParsingError = "";
|
|
3865
3883
|
const finalActions = actions.reduce(
|
|
3866
3884
|
(acc, planningAction) => {
|
|
3867
3885
|
if (stopCollecting) {
|
|
3868
3886
|
return acc;
|
|
3869
3887
|
}
|
|
3870
3888
|
if (planningAction.locate) {
|
|
3889
|
+
if (bboxCollected && planningAction.locate.bbox) {
|
|
3890
|
+
delete planningAction.locate.bbox;
|
|
3891
|
+
}
|
|
3892
|
+
if (planningAction.locate.bbox) {
|
|
3893
|
+
bboxCollected = true;
|
|
3894
|
+
}
|
|
3871
3895
|
acc.push({
|
|
3872
3896
|
type: "Locate",
|
|
3873
3897
|
locate: planningAction.locate,
|
|
3874
|
-
// remove id from planning, since the result is not accurate
|
|
3875
|
-
// locate: {
|
|
3876
|
-
// prompt: planningAction.locate.prompt,
|
|
3877
|
-
// },
|
|
3878
3898
|
param: null,
|
|
3879
3899
|
thought: planningAction.locate.prompt
|
|
3880
3900
|
});
|
|
3881
3901
|
} else if (["Tap", "Hover", "Input"].includes(planningAction.type)) {
|
|
3902
|
+
planParsingError = `invalid planning response: ${JSON.stringify(planningAction)}`;
|
|
3882
3903
|
stopCollecting = true;
|
|
3883
3904
|
return acc;
|
|
3884
3905
|
}
|
|
3885
3906
|
acc.push(planningAction);
|
|
3907
|
+
if (planResult.sleep) {
|
|
3908
|
+
acc.push({
|
|
3909
|
+
type: "Sleep",
|
|
3910
|
+
param: {
|
|
3911
|
+
timeMs: planResult.sleep
|
|
3912
|
+
},
|
|
3913
|
+
locate: null
|
|
3914
|
+
});
|
|
3915
|
+
}
|
|
3886
3916
|
return acc;
|
|
3887
3917
|
},
|
|
3888
3918
|
[]
|
|
3889
3919
|
);
|
|
3890
|
-
(0
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3920
|
+
if (finalActions.length === 0) {
|
|
3921
|
+
(0, import_node_assert3.default)(
|
|
3922
|
+
finish,
|
|
3923
|
+
error ? `Failed to plan: ${error}` : planParsingError || "No plan found"
|
|
3924
|
+
);
|
|
3925
|
+
}
|
|
3894
3926
|
cacheGroup.saveCache({
|
|
3895
3927
|
type: "plan",
|
|
3896
3928
|
pageContext: {
|
|
3897
3929
|
url: pageContext.url,
|
|
3898
3930
|
size: pageContext.size
|
|
3899
3931
|
},
|
|
3900
|
-
prompt:
|
|
3932
|
+
prompt: userInstruction,
|
|
3901
3933
|
response: planResult
|
|
3902
3934
|
});
|
|
3903
3935
|
return {
|
|
3904
3936
|
output: {
|
|
3905
3937
|
actions: finalActions,
|
|
3906
|
-
|
|
3907
|
-
|
|
3938
|
+
finish,
|
|
3939
|
+
log: log2
|
|
3908
3940
|
},
|
|
3909
3941
|
cache: {
|
|
3910
3942
|
hit: Boolean(planCache)
|
|
3911
3943
|
},
|
|
3912
3944
|
pageContext,
|
|
3913
|
-
|
|
3914
|
-
|
|
3945
|
+
recorder: [recordItem],
|
|
3946
|
+
usage,
|
|
3947
|
+
rawResponse
|
|
3915
3948
|
};
|
|
3916
3949
|
}
|
|
3917
3950
|
};
|
|
3918
3951
|
return task;
|
|
3919
3952
|
}
|
|
3920
|
-
planningTaskToGoal(
|
|
3953
|
+
planningTaskToGoal(userInstruction, cacheGroup) {
|
|
3921
3954
|
const task = {
|
|
3922
3955
|
type: "Planning",
|
|
3923
3956
|
locate: null,
|
|
3924
3957
|
param: {
|
|
3925
|
-
|
|
3958
|
+
userInstruction
|
|
3926
3959
|
},
|
|
3927
3960
|
executor: async (param, executorContext) => {
|
|
3928
3961
|
var _a;
|
|
@@ -3951,14 +3984,14 @@ var PageTaskExecutor = class {
|
|
|
3951
3984
|
const planCache = cacheGroup.readCache(
|
|
3952
3985
|
pageContext,
|
|
3953
3986
|
"ui-tars-plan",
|
|
3954
|
-
|
|
3987
|
+
userInstruction
|
|
3955
3988
|
);
|
|
3956
3989
|
let planResult;
|
|
3957
3990
|
if (planCache) {
|
|
3958
3991
|
planResult = planCache;
|
|
3959
3992
|
} else {
|
|
3960
3993
|
planResult = await (0, import_ai_model.vlmPlanning)({
|
|
3961
|
-
userInstruction: param.
|
|
3994
|
+
userInstruction: param.userInstruction,
|
|
3962
3995
|
conversationHistory: this.conversationHistory,
|
|
3963
3996
|
size: pageContext.size
|
|
3964
3997
|
});
|
|
@@ -3969,7 +4002,7 @@ var PageTaskExecutor = class {
|
|
|
3969
4002
|
url: pageContext.url,
|
|
3970
4003
|
size: pageContext.size
|
|
3971
4004
|
},
|
|
3972
|
-
prompt:
|
|
4005
|
+
prompt: userInstruction,
|
|
3973
4006
|
response: planResult
|
|
3974
4007
|
});
|
|
3975
4008
|
const aiCost = Date.now() - startTime;
|
|
@@ -3983,11 +4016,8 @@ var PageTaskExecutor = class {
|
|
|
3983
4016
|
actions,
|
|
3984
4017
|
thought: (_a = actions[0]) == null ? void 0 : _a.thought,
|
|
3985
4018
|
actionType: actions[0].type,
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
whatToDoNext: "",
|
|
3989
|
-
whatHaveDone: ""
|
|
3990
|
-
}
|
|
4019
|
+
finish: false,
|
|
4020
|
+
log: ""
|
|
3991
4021
|
},
|
|
3992
4022
|
cache: {
|
|
3993
4023
|
hit: Boolean(planCache)
|
|
@@ -3999,23 +4029,19 @@ var PageTaskExecutor = class {
|
|
|
3999
4029
|
return task;
|
|
4000
4030
|
}
|
|
4001
4031
|
async action(userPrompt, options) {
|
|
4002
|
-
var _a;
|
|
4003
4032
|
const taskExecutor = new import_core.Executor(userPrompt, void 0, void 0, {
|
|
4004
4033
|
onTaskStart: options == null ? void 0 : options.onTaskStart
|
|
4005
4034
|
});
|
|
4006
4035
|
const cacheGroup = this.taskCache.getCacheGroupByPrompt(userPrompt);
|
|
4007
|
-
|
|
4008
|
-
let planningTask = this.planningTaskFromPrompt(originalPrompt, cacheGroup);
|
|
4036
|
+
let planningTask = this.planningTaskFromPrompt(userPrompt, cacheGroup);
|
|
4009
4037
|
let result;
|
|
4010
4038
|
let replanCount = 0;
|
|
4039
|
+
const logLog = [];
|
|
4011
4040
|
while (planningTask) {
|
|
4012
|
-
if (replanCount >
|
|
4041
|
+
if (replanCount > replanningCountLimit) {
|
|
4013
4042
|
const errorMsg = "Replanning too many times, please split the task into multiple steps";
|
|
4014
4043
|
return this.appendErrorPlan(taskExecutor, errorMsg);
|
|
4015
4044
|
}
|
|
4016
|
-
if (replanCount > 0) {
|
|
4017
|
-
await (0, import_utils3.sleep)(300);
|
|
4018
|
-
}
|
|
4019
4045
|
await taskExecutor.append(planningTask);
|
|
4020
4046
|
const planResult = await taskExecutor.flush();
|
|
4021
4047
|
if (taskExecutor.isInErrorState()) {
|
|
@@ -4044,18 +4070,19 @@ var PageTaskExecutor = class {
|
|
|
4044
4070
|
executor: taskExecutor
|
|
4045
4071
|
};
|
|
4046
4072
|
}
|
|
4047
|
-
if (
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
planResult.furtherPlan.whatHaveDone,
|
|
4052
|
-
originalPrompt
|
|
4053
|
-
);
|
|
4054
|
-
replanCount++;
|
|
4055
|
-
} else {
|
|
4073
|
+
if (planResult == null ? void 0 : planResult.log) {
|
|
4074
|
+
logLog.push(planResult.log);
|
|
4075
|
+
}
|
|
4076
|
+
if (planResult.finish) {
|
|
4056
4077
|
planningTask = null;
|
|
4057
4078
|
break;
|
|
4058
4079
|
}
|
|
4080
|
+
planningTask = this.planningTaskFromPrompt(
|
|
4081
|
+
userPrompt,
|
|
4082
|
+
cacheGroup,
|
|
4083
|
+
logLog.join("\n")
|
|
4084
|
+
);
|
|
4085
|
+
replanCount++;
|
|
4059
4086
|
}
|
|
4060
4087
|
return {
|
|
4061
4088
|
output: result,
|
|
@@ -4209,7 +4236,9 @@ var PageTaskExecutor = class {
|
|
|
4209
4236
|
}
|
|
4210
4237
|
async waitFor(assertion, opt) {
|
|
4211
4238
|
const description = `waitFor: ${assertion}`;
|
|
4212
|
-
const taskExecutor = new import_core.Executor(description
|
|
4239
|
+
const taskExecutor = new import_core.Executor(description, void 0, void 0, {
|
|
4240
|
+
onTaskStart: opt.onTaskStart
|
|
4241
|
+
});
|
|
4213
4242
|
const { timeoutMs, checkIntervalMs } = opt;
|
|
4214
4243
|
(0, import_node_assert3.default)(assertion, "No assertion for waitFor");
|
|
4215
4244
|
(0, import_node_assert3.default)(timeoutMs, "No timeoutMs for waitFor");
|
|
@@ -4294,7 +4323,7 @@ var WebElementInfo = class {
|
|
|
4294
4323
|
var import_node_assert4 = __toESM(require("assert"));
|
|
4295
4324
|
var import_node_fs3 = require("fs");
|
|
4296
4325
|
var import_node_path3 = __toESM(require("path"));
|
|
4297
|
-
var
|
|
4326
|
+
var import_env4 = require("@midscene/core/env");
|
|
4298
4327
|
var import_utils4 = require("@midscene/core/utils");
|
|
4299
4328
|
var import_constants = require("@midscene/shared/constants");
|
|
4300
4329
|
var import_extractor = require("@midscene/shared/extractor");
|
|
@@ -4341,14 +4370,16 @@ async function parseContextFromWebPage(page, _opt) {
|
|
|
4341
4370
|
}
|
|
4342
4371
|
);
|
|
4343
4372
|
const size = await page.size();
|
|
4373
|
+
if (size.dpr && size.dpr > 1) {
|
|
4374
|
+
screenshotBase64 = await (0, import_img.resizeImgBase64)(screenshotBase64, {
|
|
4375
|
+
width: size.width,
|
|
4376
|
+
height: size.height
|
|
4377
|
+
});
|
|
4378
|
+
}
|
|
4344
4379
|
let screenshotBase64WithElementMarker = screenshotBase64;
|
|
4345
|
-
if (!(0,
|
|
4380
|
+
if (!(0, import_env4.getAIConfig)(import_env4.MIDSCENE_USE_VLM_UI_TARS)) {
|
|
4346
4381
|
if (_opt == null ? void 0 : _opt.ignoreMarker) {
|
|
4347
|
-
screenshotBase64WithElementMarker =
|
|
4348
|
-
inputImgBase64: screenshotBase64,
|
|
4349
|
-
elementsPositionInfo: [],
|
|
4350
|
-
size
|
|
4351
|
-
});
|
|
4382
|
+
screenshotBase64WithElementMarker = screenshotBase64;
|
|
4352
4383
|
} else {
|
|
4353
4384
|
screenshotBase64WithElementMarker = await (0, import_img.compositeElementInfoImg)({
|
|
4354
4385
|
inputImgBase64: screenshotBase64,
|
|
@@ -4367,7 +4398,7 @@ async function parseContextFromWebPage(page, _opt) {
|
|
|
4367
4398
|
};
|
|
4368
4399
|
}
|
|
4369
4400
|
function reportFileName(tag = "web") {
|
|
4370
|
-
const reportTagName = (0,
|
|
4401
|
+
const reportTagName = (0, import_env4.getAIConfig)(import_env4.MIDSCENE_REPORT_TAG_NAME);
|
|
4371
4402
|
const dateTimeInFileName = (0, import_dayjs.default)().format("YYYY-MM-DD_HH-mm-ss-SSS");
|
|
4372
4403
|
return `${reportTagName || tag}-${dateTimeInFileName}`;
|
|
4373
4404
|
}
|
|
@@ -4420,7 +4451,9 @@ var PageAgent = class {
|
|
|
4420
4451
|
ignoreMarker: true
|
|
4421
4452
|
});
|
|
4422
4453
|
}
|
|
4423
|
-
return await parseContextFromWebPage(this.page
|
|
4454
|
+
return await parseContextFromWebPage(this.page, {
|
|
4455
|
+
ignoreMarker: (0, import_env5.getAIConfigInBoolean)(import_env5.MATCH_BY_POSITION)
|
|
4456
|
+
});
|
|
4424
4457
|
}
|
|
4425
4458
|
resetDump() {
|
|
4426
4459
|
this.dump = {
|
|
@@ -4467,7 +4500,7 @@ var PageAgent = class {
|
|
|
4467
4500
|
}
|
|
4468
4501
|
}
|
|
4469
4502
|
async aiAction(taskPrompt) {
|
|
4470
|
-
if ((0,
|
|
4503
|
+
if ((0, import_env5.getAIConfig)(import_env5.MIDSCENE_USE_VLM_UI_TARS)) {
|
|
4471
4504
|
const { executor } = await this.taskExecutor.actionToGoal(taskPrompt, {
|
|
4472
4505
|
onTaskStart: this.callbackOnTaskStartTip.bind(this)
|
|
4473
4506
|
});
|
|
@@ -4525,7 +4558,8 @@ ${reasonMsg}`);
|
|
|
4525
4558
|
const { executor } = await this.taskExecutor.waitFor(assertion, {
|
|
4526
4559
|
timeoutMs: (opt == null ? void 0 : opt.timeoutMs) || 15 * 1e3,
|
|
4527
4560
|
checkIntervalMs: (opt == null ? void 0 : opt.checkIntervalMs) || 3 * 1e3,
|
|
4528
|
-
assertion
|
|
4561
|
+
assertion,
|
|
4562
|
+
onTaskStart: this.callbackOnTaskStartTip.bind(this)
|
|
4529
4563
|
});
|
|
4530
4564
|
this.appendExecutionDump(executor.dump());
|
|
4531
4565
|
this.writeOutActionDumps();
|
|
@@ -291,7 +291,7 @@ function sleep(ms) {
|
|
|
291
291
|
var ChromeExtensionProxyPage = class {
|
|
292
292
|
constructor(forceSameTabNavigation) {
|
|
293
293
|
this.pageType = "chrome-extension-proxy";
|
|
294
|
-
this.version = "0.11.
|
|
294
|
+
this.version = "0.11.4-beta-20250219074605.0";
|
|
295
295
|
this.activeTabId = null;
|
|
296
296
|
this.tabIdOfDebuggerAttached = null;
|
|
297
297
|
this.attachingDebugger = null;
|
|
@@ -690,7 +690,7 @@ var BridgeClient = class {
|
|
|
690
690
|
this.socket = (0, import_socket.io)(this.endpoint, {
|
|
691
691
|
reconnection: false,
|
|
692
692
|
query: {
|
|
693
|
-
version: "0.11.
|
|
693
|
+
version: "0.11.4-beta-20250219074605.0"
|
|
694
694
|
}
|
|
695
695
|
});
|
|
696
696
|
const timeout = setTimeout(() => {
|
|
@@ -812,7 +812,7 @@ var ChromeExtensionPageBrowserSide = class extends ChromeExtensionProxyPage {
|
|
|
812
812
|
);
|
|
813
813
|
await this.bridgeClient.connect();
|
|
814
814
|
this.onLogMessage(
|
|
815
|
-
`Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v${"0.11.
|
|
815
|
+
`Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v${"0.11.4-beta-20250219074605.0"}`,
|
|
816
816
|
"log"
|
|
817
817
|
);
|
|
818
818
|
}
|