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