@midscene/web 0.17.4-beta-20250528162713.0 → 0.17.4
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 +57 -29
- package/dist/es/agent.js.map +1 -1
- package/dist/es/bridge-mode-browser.js +10 -9
- package/dist/es/bridge-mode-browser.js.map +1 -1
- package/dist/es/bridge-mode.js +59 -31
- package/dist/es/bridge-mode.js.map +1 -1
- package/dist/es/chrome-extension.js +65 -36
- package/dist/es/chrome-extension.js.map +1 -1
- package/dist/es/index.js +57 -29
- package/dist/es/index.js.map +1 -1
- package/dist/es/midscene-playground.js +57 -29
- package/dist/es/midscene-playground.js.map +1 -1
- package/dist/es/midscene-server.js.map +1 -1
- package/dist/es/playground.js +57 -29
- package/dist/es/playground.js.map +1 -1
- package/dist/es/playwright-report.js.map +1 -1
- package/dist/es/playwright.js +57 -29
- package/dist/es/playwright.js.map +1 -1
- package/dist/es/puppeteer-agent-launcher.js +57 -29
- package/dist/es/puppeteer-agent-launcher.js.map +1 -1
- package/dist/es/puppeteer.js +57 -29
- package/dist/es/puppeteer.js.map +1 -1
- package/dist/es/utils.js +6 -3
- package/dist/es/utils.js.map +1 -1
- package/dist/es/yaml.js +23 -6
- package/dist/es/yaml.js.map +1 -1
- package/dist/lib/agent.js +57 -29
- package/dist/lib/agent.js.map +1 -1
- package/dist/lib/bridge-mode-browser.js +10 -9
- package/dist/lib/bridge-mode-browser.js.map +1 -1
- package/dist/lib/bridge-mode.js +59 -31
- package/dist/lib/bridge-mode.js.map +1 -1
- package/dist/lib/chrome-extension.js +65 -36
- package/dist/lib/chrome-extension.js.map +1 -1
- package/dist/lib/index.js +57 -29
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/midscene-playground.js +57 -29
- package/dist/lib/midscene-playground.js.map +1 -1
- package/dist/lib/midscene-server.js.map +1 -1
- package/dist/lib/playground.js +57 -29
- package/dist/lib/playground.js.map +1 -1
- package/dist/lib/playwright-report.js.map +1 -1
- package/dist/lib/playwright.js +57 -29
- package/dist/lib/playwright.js.map +1 -1
- package/dist/lib/puppeteer-agent-launcher.js +57 -29
- package/dist/lib/puppeteer-agent-launcher.js.map +1 -1
- package/dist/lib/puppeteer.js +57 -29
- package/dist/lib/puppeteer.js.map +1 -1
- package/dist/lib/utils.js +6 -3
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/yaml.js +23 -6
- package/dist/lib/yaml.js.map +1 -1
- package/dist/types/agent.d.ts +10 -10
- package/dist/types/bridge-mode-browser.d.ts +2 -2
- package/dist/types/bridge-mode.d.ts +2 -2
- package/dist/types/{browser-6f60e23c.d.ts → browser-24f8d317.d.ts} +1 -1
- package/dist/types/chrome-extension.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/midscene-server.d.ts +1 -1
- package/dist/types/{page-25a629c6.d.ts → page-a6fe2d96.d.ts} +7 -2
- package/dist/types/playground.d.ts +2 -2
- package/dist/types/playwright.d.ts +1 -1
- package/dist/types/puppeteer-agent-launcher.d.ts +1 -1
- package/dist/types/puppeteer.d.ts +1 -1
- package/dist/types/utils.d.ts +1 -1
- package/dist/types/yaml.d.ts +1 -1
- package/iife-script/htmlElement.js +51 -73
- package/iife-script/htmlElementDebug.js +33 -54
- package/package.json +3 -3
package/dist/es/agent.js
CHANGED
|
@@ -19,10 +19,11 @@ var ScriptPlayer = class {
|
|
|
19
19
|
this.unnamedResultIndex = 0;
|
|
20
20
|
this.pageAgent = null;
|
|
21
21
|
this.result = {};
|
|
22
|
+
const target = script.target || script.web || script.android;
|
|
22
23
|
if (ifInBrowser) {
|
|
23
24
|
this.output = void 0;
|
|
24
|
-
} else if (
|
|
25
|
-
this.output = resolve(process.cwd(),
|
|
25
|
+
} else if (target?.output) {
|
|
26
|
+
this.output = resolve(process.cwd(), target.output);
|
|
26
27
|
} else {
|
|
27
28
|
this.output = join(getMidsceneRunSubDir("output"), `${process.pid}.json`);
|
|
28
29
|
}
|
|
@@ -106,42 +107,58 @@ var ScriptPlayer = class {
|
|
|
106
107
|
} else if ("aiQuery" in flowItem) {
|
|
107
108
|
const queryTask = flowItem;
|
|
108
109
|
const prompt = queryTask.aiQuery;
|
|
110
|
+
const options = {
|
|
111
|
+
domIncluded: queryTask.domIncluded,
|
|
112
|
+
screenshotIncluded: queryTask.screenshotIncluded
|
|
113
|
+
};
|
|
109
114
|
assert(prompt, "missing prompt for aiQuery");
|
|
110
115
|
assert(
|
|
111
116
|
typeof prompt === "string",
|
|
112
117
|
"prompt for aiQuery must be a string"
|
|
113
118
|
);
|
|
114
|
-
const queryResult = await agent.aiQuery(prompt);
|
|
119
|
+
const queryResult = await agent.aiQuery(prompt, options);
|
|
115
120
|
this.setResult(queryTask.name, queryResult);
|
|
116
121
|
} else if ("aiNumber" in flowItem) {
|
|
117
122
|
const numberTask = flowItem;
|
|
118
123
|
const prompt = numberTask.aiNumber;
|
|
124
|
+
const options = {
|
|
125
|
+
domIncluded: numberTask.domIncluded,
|
|
126
|
+
screenshotIncluded: numberTask.screenshotIncluded
|
|
127
|
+
};
|
|
119
128
|
assert(prompt, "missing prompt for number");
|
|
120
129
|
assert(
|
|
121
130
|
typeof prompt === "string",
|
|
122
131
|
"prompt for number must be a string"
|
|
123
132
|
);
|
|
124
|
-
const numberResult = await agent.aiNumber(prompt);
|
|
133
|
+
const numberResult = await agent.aiNumber(prompt, options);
|
|
125
134
|
this.setResult(numberTask.name, numberResult);
|
|
126
135
|
} else if ("aiString" in flowItem) {
|
|
127
136
|
const stringTask = flowItem;
|
|
128
137
|
const prompt = stringTask.aiString;
|
|
138
|
+
const options = {
|
|
139
|
+
domIncluded: stringTask.domIncluded,
|
|
140
|
+
screenshotIncluded: stringTask.screenshotIncluded
|
|
141
|
+
};
|
|
129
142
|
assert(prompt, "missing prompt for string");
|
|
130
143
|
assert(
|
|
131
144
|
typeof prompt === "string",
|
|
132
145
|
"prompt for string must be a string"
|
|
133
146
|
);
|
|
134
|
-
const stringResult = await agent.aiString(prompt);
|
|
147
|
+
const stringResult = await agent.aiString(prompt, options);
|
|
135
148
|
this.setResult(stringTask.name, stringResult);
|
|
136
149
|
} else if ("aiBoolean" in flowItem) {
|
|
137
150
|
const booleanTask = flowItem;
|
|
138
151
|
const prompt = booleanTask.aiBoolean;
|
|
152
|
+
const options = {
|
|
153
|
+
domIncluded: booleanTask.domIncluded,
|
|
154
|
+
screenshotIncluded: booleanTask.screenshotIncluded
|
|
155
|
+
};
|
|
139
156
|
assert(prompt, "missing prompt for boolean");
|
|
140
157
|
assert(
|
|
141
158
|
typeof prompt === "string",
|
|
142
159
|
"prompt for boolean must be a string"
|
|
143
160
|
);
|
|
144
|
-
const booleanResult = await agent.aiBoolean(prompt);
|
|
161
|
+
const booleanResult = await agent.aiBoolean(prompt, options);
|
|
145
162
|
this.setResult(booleanTask.name, booleanResult);
|
|
146
163
|
} else if ("aiLocate" in flowItem) {
|
|
147
164
|
const locateTask = flowItem;
|
|
@@ -471,7 +488,8 @@ var WebElementInfo = class {
|
|
|
471
488
|
id,
|
|
472
489
|
attributes,
|
|
473
490
|
indexId,
|
|
474
|
-
xpaths
|
|
491
|
+
xpaths,
|
|
492
|
+
isVisible
|
|
475
493
|
}) {
|
|
476
494
|
this.content = content;
|
|
477
495
|
this.rect = rect;
|
|
@@ -484,6 +502,7 @@ var WebElementInfo = class {
|
|
|
484
502
|
this.attributes = attributes;
|
|
485
503
|
this.indexId = indexId;
|
|
486
504
|
this.xpaths = xpaths;
|
|
505
|
+
this.isVisible = isVisible;
|
|
487
506
|
}
|
|
488
507
|
};
|
|
489
508
|
|
|
@@ -506,14 +525,15 @@ async function parseContextFromWebPage(page, _opt) {
|
|
|
506
525
|
})
|
|
507
526
|
]);
|
|
508
527
|
const webTree = traverseTree(tree, (elementInfo) => {
|
|
509
|
-
const { rect, id, content, attributes, locator, indexId } = elementInfo;
|
|
528
|
+
const { rect, id, content, attributes, locator, indexId, isVisible } = elementInfo;
|
|
510
529
|
return new WebElementInfo({
|
|
511
530
|
rect,
|
|
512
531
|
locator,
|
|
513
532
|
id,
|
|
514
533
|
content,
|
|
515
534
|
attributes,
|
|
516
|
-
indexId
|
|
535
|
+
indexId,
|
|
536
|
+
isVisible
|
|
517
537
|
});
|
|
518
538
|
});
|
|
519
539
|
assert3(screenshotBase64, "screenshotBase64 is required");
|
|
@@ -1405,7 +1425,7 @@ var PageTaskExecutor = class {
|
|
|
1405
1425
|
executor: taskExecutor
|
|
1406
1426
|
};
|
|
1407
1427
|
}
|
|
1408
|
-
async createTypeQueryTask(type, demand) {
|
|
1428
|
+
async createTypeQueryTask(type, demand, opt) {
|
|
1409
1429
|
const taskExecutor = new Executor(
|
|
1410
1430
|
taskTitleStr(
|
|
1411
1431
|
type,
|
|
@@ -1436,7 +1456,10 @@ var PageTaskExecutor = class {
|
|
|
1436
1456
|
result: `${type}, ${demand}`
|
|
1437
1457
|
};
|
|
1438
1458
|
}
|
|
1439
|
-
const { data, usage } = await this.insight.extract(
|
|
1459
|
+
const { data, usage } = await this.insight.extract(
|
|
1460
|
+
demandInput,
|
|
1461
|
+
opt
|
|
1462
|
+
);
|
|
1440
1463
|
let outputResult = data;
|
|
1441
1464
|
if (ifTypeRestricted) {
|
|
1442
1465
|
assert4(data?.result !== void 0, "No result in query data");
|
|
@@ -1456,17 +1479,17 @@ var PageTaskExecutor = class {
|
|
|
1456
1479
|
executor: taskExecutor
|
|
1457
1480
|
};
|
|
1458
1481
|
}
|
|
1459
|
-
async query(demand) {
|
|
1460
|
-
return this.createTypeQueryTask("Query", demand);
|
|
1482
|
+
async query(demand, opt) {
|
|
1483
|
+
return this.createTypeQueryTask("Query", demand, opt);
|
|
1461
1484
|
}
|
|
1462
|
-
async boolean(prompt) {
|
|
1463
|
-
return this.createTypeQueryTask("Boolean", prompt);
|
|
1485
|
+
async boolean(prompt, opt) {
|
|
1486
|
+
return this.createTypeQueryTask("Boolean", prompt, opt);
|
|
1464
1487
|
}
|
|
1465
|
-
async number(prompt) {
|
|
1466
|
-
return this.createTypeQueryTask("Number", prompt);
|
|
1488
|
+
async number(prompt, opt) {
|
|
1489
|
+
return this.createTypeQueryTask("Number", prompt, opt);
|
|
1467
1490
|
}
|
|
1468
|
-
async string(prompt) {
|
|
1469
|
-
return this.createTypeQueryTask("String", prompt);
|
|
1491
|
+
async string(prompt, opt) {
|
|
1492
|
+
return this.createTypeQueryTask("String", prompt, opt);
|
|
1470
1493
|
}
|
|
1471
1494
|
async assert(assertion) {
|
|
1472
1495
|
const description = `assert: ${assertion}`;
|
|
@@ -1682,7 +1705,7 @@ import yaml3 from "js-yaml";
|
|
|
1682
1705
|
import semver from "semver";
|
|
1683
1706
|
|
|
1684
1707
|
// package.json
|
|
1685
|
-
var version = "0.17.4
|
|
1708
|
+
var version = "0.17.4";
|
|
1686
1709
|
|
|
1687
1710
|
// src/common/task-cache.ts
|
|
1688
1711
|
var debug3 = getDebug3("cache");
|
|
@@ -1852,6 +1875,10 @@ var includedInRect = (point, rect) => {
|
|
|
1852
1875
|
const { left, top, width, height } = rect;
|
|
1853
1876
|
return x >= left && x <= left + width && y >= top && y <= top + height;
|
|
1854
1877
|
};
|
|
1878
|
+
var defaultInsightExtractOption = {
|
|
1879
|
+
domIncluded: false,
|
|
1880
|
+
screenshotIncluded: true
|
|
1881
|
+
};
|
|
1855
1882
|
var PageAgent = class {
|
|
1856
1883
|
constructor(page, opts) {
|
|
1857
1884
|
/**
|
|
@@ -1995,7 +2022,8 @@ ${errorTask?.errorStack}`);
|
|
|
1995
2022
|
const plans = buildPlans("RightClick", detailedLocateParam);
|
|
1996
2023
|
const { executor, output } = await this.taskExecutor.runPlans(
|
|
1997
2024
|
taskTitleStr("RightClick", locateParamStr(detailedLocateParam)),
|
|
1998
|
-
plans
|
|
2025
|
+
plans,
|
|
2026
|
+
{ cacheable: opt?.cacheable }
|
|
1999
2027
|
);
|
|
2000
2028
|
this.afterTaskRunning(executor);
|
|
2001
2029
|
return output;
|
|
@@ -2100,23 +2128,23 @@ ${errorTask?.errorStack}`);
|
|
|
2100
2128
|
this.afterTaskRunning(executor);
|
|
2101
2129
|
return output;
|
|
2102
2130
|
}
|
|
2103
|
-
async aiQuery(demand) {
|
|
2104
|
-
const { output, executor } = await this.taskExecutor.query(demand);
|
|
2131
|
+
async aiQuery(demand, opt = defaultInsightExtractOption) {
|
|
2132
|
+
const { output, executor } = await this.taskExecutor.query(demand, opt);
|
|
2105
2133
|
this.afterTaskRunning(executor);
|
|
2106
2134
|
return output;
|
|
2107
2135
|
}
|
|
2108
|
-
async aiBoolean(prompt) {
|
|
2109
|
-
const { output, executor } = await this.taskExecutor.boolean(prompt);
|
|
2136
|
+
async aiBoolean(prompt, opt = defaultInsightExtractOption) {
|
|
2137
|
+
const { output, executor } = await this.taskExecutor.boolean(prompt, opt);
|
|
2110
2138
|
this.afterTaskRunning(executor);
|
|
2111
2139
|
return output;
|
|
2112
2140
|
}
|
|
2113
|
-
async aiNumber(prompt) {
|
|
2114
|
-
const { output, executor } = await this.taskExecutor.number(prompt);
|
|
2141
|
+
async aiNumber(prompt, opt = defaultInsightExtractOption) {
|
|
2142
|
+
const { output, executor } = await this.taskExecutor.number(prompt, opt);
|
|
2115
2143
|
this.afterTaskRunning(executor);
|
|
2116
2144
|
return output;
|
|
2117
2145
|
}
|
|
2118
|
-
async aiString(prompt) {
|
|
2119
|
-
const { output, executor } = await this.taskExecutor.string(prompt);
|
|
2146
|
+
async aiString(prompt, opt = defaultInsightExtractOption) {
|
|
2147
|
+
const { output, executor } = await this.taskExecutor.string(prompt, opt);
|
|
2120
2148
|
this.afterTaskRunning(executor);
|
|
2121
2149
|
return output;
|
|
2122
2150
|
}
|