@midscene/web 0.16.5 → 0.16.6
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 +78 -14
- package/dist/es/agent.js.map +1 -1
- package/dist/es/bridge-mode-browser.js +3 -3
- package/dist/es/bridge-mode-browser.js.map +1 -1
- package/dist/es/bridge-mode.js +100 -21
- package/dist/es/bridge-mode.js.map +1 -1
- package/dist/es/chrome-extension.js +79 -15
- package/dist/es/chrome-extension.js.map +1 -1
- package/dist/es/index.js +110 -14
- package/dist/es/index.js.map +1 -1
- package/dist/es/midscene-playground.js +78 -14
- package/dist/es/midscene-playground.js.map +1 -1
- package/dist/es/playground.js +78 -14
- package/dist/es/playground.js.map +1 -1
- package/dist/es/playwright.js +110 -14
- package/dist/es/playwright.js.map +1 -1
- package/dist/es/puppeteer-agent-launcher.js +78 -14
- package/dist/es/puppeteer-agent-launcher.js.map +1 -1
- package/dist/es/puppeteer.js +78 -14
- package/dist/es/puppeteer.js.map +1 -1
- package/dist/es/ui-utils.js.map +1 -1
- package/dist/lib/agent.js +77 -10
- package/dist/lib/agent.js.map +1 -1
- package/dist/lib/bridge-mode-browser.js +3 -3
- package/dist/lib/bridge-mode-browser.js.map +1 -1
- package/dist/lib/bridge-mode.js +99 -18
- package/dist/lib/bridge-mode.js.map +1 -1
- package/dist/lib/chrome-extension.js +78 -11
- package/dist/lib/chrome-extension.js.map +1 -1
- package/dist/lib/index.js +109 -10
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/midscene-playground.js +77 -10
- package/dist/lib/midscene-playground.js.map +1 -1
- package/dist/lib/playground.js +77 -10
- package/dist/lib/playground.js.map +1 -1
- package/dist/lib/playwright.js +109 -10
- package/dist/lib/playwright.js.map +1 -1
- package/dist/lib/puppeteer-agent-launcher.js +77 -10
- package/dist/lib/puppeteer-agent-launcher.js.map +1 -1
- package/dist/lib/puppeteer.js +77 -10
- package/dist/lib/puppeteer.js.map +1 -1
- package/dist/lib/ui-utils.js.map +1 -1
- package/dist/types/agent.d.ts +8 -0
- package/dist/types/bridge-mode-browser.d.ts +1 -1
- package/dist/types/bridge-mode.d.ts +1 -2
- package/dist/types/{browser-0beaa7a7.d.ts → browser-a8afbca5.d.ts} +1 -2
- package/dist/types/playwright.d.ts +16 -0
- package/dist/types/ui-utils.d.ts +1 -1
- package/package.json +4 -3
package/dist/es/agent.js
CHANGED
|
@@ -296,10 +296,7 @@ import { sleep } from "@midscene/core/utils";
|
|
|
296
296
|
import { UITarsModelVersion } from "@midscene/shared/env";
|
|
297
297
|
import { uiTarsModelVersion } from "@midscene/shared/env";
|
|
298
298
|
import { vlLocateMode } from "@midscene/shared/env";
|
|
299
|
-
import {
|
|
300
|
-
imageInfo,
|
|
301
|
-
resizeImgBase64 as resizeImgBase642
|
|
302
|
-
} from "@midscene/shared/img";
|
|
299
|
+
import { imageInfo, resizeImgBase64 as resizeImgBase642 } from "@midscene/shared/img";
|
|
303
300
|
import { getDebug as getDebug2 } from "@midscene/shared/logger";
|
|
304
301
|
import { assert as assert4 } from "@midscene/shared/utils";
|
|
305
302
|
|
|
@@ -1485,17 +1482,23 @@ var PageTaskExecutor = class {
|
|
|
1485
1482
|
executor: taskExecutor
|
|
1486
1483
|
};
|
|
1487
1484
|
}
|
|
1488
|
-
async
|
|
1489
|
-
const
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1485
|
+
async createTypeQueryTask(type, demand) {
|
|
1486
|
+
const taskExecutor = new Executor(
|
|
1487
|
+
taskTitleStr(
|
|
1488
|
+
type,
|
|
1489
|
+
typeof demand === "string" ? demand : JSON.stringify(demand)
|
|
1490
|
+
),
|
|
1491
|
+
{
|
|
1492
|
+
onTaskStart: this.onTaskStartCallback
|
|
1493
|
+
}
|
|
1494
|
+
);
|
|
1493
1495
|
const queryTask = {
|
|
1494
1496
|
type: "Insight",
|
|
1495
|
-
subType:
|
|
1497
|
+
subType: type,
|
|
1496
1498
|
locate: null,
|
|
1497
1499
|
param: {
|
|
1498
1500
|
dataDemand: demand
|
|
1501
|
+
// for user param presentation in report right sidebar
|
|
1499
1502
|
},
|
|
1500
1503
|
executor: async (param) => {
|
|
1501
1504
|
let insightDump;
|
|
@@ -1503,11 +1506,21 @@ var PageTaskExecutor = class {
|
|
|
1503
1506
|
insightDump = dump;
|
|
1504
1507
|
};
|
|
1505
1508
|
this.insight.onceDumpUpdatedFn = dumpCollector;
|
|
1506
|
-
const
|
|
1507
|
-
|
|
1508
|
-
)
|
|
1509
|
+
const ifTypeRestricted = type !== "Query";
|
|
1510
|
+
let demandInput = demand;
|
|
1511
|
+
if (ifTypeRestricted) {
|
|
1512
|
+
demandInput = {
|
|
1513
|
+
result: `${type}, ${demand}`
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
const { data, usage } = await this.insight.extract(demandInput);
|
|
1517
|
+
let outputResult = data;
|
|
1518
|
+
if (ifTypeRestricted) {
|
|
1519
|
+
assert4(data?.result !== void 0, "No result in query data");
|
|
1520
|
+
outputResult = data.result;
|
|
1521
|
+
}
|
|
1509
1522
|
return {
|
|
1510
|
-
output:
|
|
1523
|
+
output: outputResult,
|
|
1511
1524
|
log: { dump: insightDump },
|
|
1512
1525
|
usage
|
|
1513
1526
|
};
|
|
@@ -1520,6 +1533,18 @@ var PageTaskExecutor = class {
|
|
|
1520
1533
|
executor: taskExecutor
|
|
1521
1534
|
};
|
|
1522
1535
|
}
|
|
1536
|
+
async query(demand) {
|
|
1537
|
+
return this.createTypeQueryTask("Query", demand);
|
|
1538
|
+
}
|
|
1539
|
+
async boolean(prompt) {
|
|
1540
|
+
return this.createTypeQueryTask("Boolean", prompt);
|
|
1541
|
+
}
|
|
1542
|
+
async number(prompt) {
|
|
1543
|
+
return this.createTypeQueryTask("Number", prompt);
|
|
1544
|
+
}
|
|
1545
|
+
async string(prompt) {
|
|
1546
|
+
return this.createTypeQueryTask("String", prompt);
|
|
1547
|
+
}
|
|
1523
1548
|
async assert(assertion) {
|
|
1524
1549
|
const description = `assert: ${assertion}`;
|
|
1525
1550
|
const taskExecutor = new Executor(taskTitleStr("Assert", description), {
|
|
@@ -1706,6 +1731,16 @@ function buildPlans(type, locateParam, param) {
|
|
|
1706
1731
|
};
|
|
1707
1732
|
returnPlans = [sleepPlan];
|
|
1708
1733
|
}
|
|
1734
|
+
if (type === "Locate") {
|
|
1735
|
+
assert5(locateParam, `missing locate info for action "${type}"`);
|
|
1736
|
+
const locatePlan2 = {
|
|
1737
|
+
type,
|
|
1738
|
+
param: locateParam,
|
|
1739
|
+
locate: locateParam,
|
|
1740
|
+
thought: ""
|
|
1741
|
+
};
|
|
1742
|
+
returnPlans = [locatePlan2];
|
|
1743
|
+
}
|
|
1709
1744
|
if (returnPlans) {
|
|
1710
1745
|
debug3("buildPlans", returnPlans);
|
|
1711
1746
|
return returnPlans;
|
|
@@ -1905,6 +1940,35 @@ ${errorTask?.errorStack}`);
|
|
|
1905
1940
|
this.afterTaskRunning(executor);
|
|
1906
1941
|
return output;
|
|
1907
1942
|
}
|
|
1943
|
+
async aiBoolean(prompt) {
|
|
1944
|
+
const { output, executor } = await this.taskExecutor.boolean(prompt);
|
|
1945
|
+
this.afterTaskRunning(executor);
|
|
1946
|
+
return output;
|
|
1947
|
+
}
|
|
1948
|
+
async aiNumber(prompt) {
|
|
1949
|
+
const { output, executor } = await this.taskExecutor.number(prompt);
|
|
1950
|
+
this.afterTaskRunning(executor);
|
|
1951
|
+
return output;
|
|
1952
|
+
}
|
|
1953
|
+
async aiString(prompt) {
|
|
1954
|
+
const { output, executor } = await this.taskExecutor.string(prompt);
|
|
1955
|
+
this.afterTaskRunning(executor);
|
|
1956
|
+
return output;
|
|
1957
|
+
}
|
|
1958
|
+
async aiLocate(prompt, opt) {
|
|
1959
|
+
const detailedLocateParam = this.buildDetailedLocateParam(prompt, opt);
|
|
1960
|
+
const plans = buildPlans("Locate", detailedLocateParam);
|
|
1961
|
+
const { executor, output } = await this.taskExecutor.runPlans(
|
|
1962
|
+
taskTitleStr("Locate", locateParamStr(detailedLocateParam)),
|
|
1963
|
+
plans
|
|
1964
|
+
);
|
|
1965
|
+
this.afterTaskRunning(executor);
|
|
1966
|
+
const { element } = output;
|
|
1967
|
+
return {
|
|
1968
|
+
rect: element?.rect,
|
|
1969
|
+
center: element?.center
|
|
1970
|
+
};
|
|
1971
|
+
}
|
|
1908
1972
|
async aiAssert(assertion, msg, opt) {
|
|
1909
1973
|
const { output, executor } = await this.taskExecutor.assert(assertion);
|
|
1910
1974
|
this.afterTaskRunning(executor, true);
|