@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
|
@@ -1490,17 +1490,23 @@ var PageTaskExecutor = class {
|
|
|
1490
1490
|
executor: taskExecutor
|
|
1491
1491
|
};
|
|
1492
1492
|
}
|
|
1493
|
-
async
|
|
1494
|
-
const
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1493
|
+
async createTypeQueryTask(type, demand) {
|
|
1494
|
+
const taskExecutor = new import_core.Executor(
|
|
1495
|
+
taskTitleStr(
|
|
1496
|
+
type,
|
|
1497
|
+
typeof demand === "string" ? demand : JSON.stringify(demand)
|
|
1498
|
+
),
|
|
1499
|
+
{
|
|
1500
|
+
onTaskStart: this.onTaskStartCallback
|
|
1501
|
+
}
|
|
1502
|
+
);
|
|
1498
1503
|
const queryTask = {
|
|
1499
1504
|
type: "Insight",
|
|
1500
|
-
subType:
|
|
1505
|
+
subType: type,
|
|
1501
1506
|
locate: null,
|
|
1502
1507
|
param: {
|
|
1503
1508
|
dataDemand: demand
|
|
1509
|
+
// for user param presentation in report right sidebar
|
|
1504
1510
|
},
|
|
1505
1511
|
executor: async (param) => {
|
|
1506
1512
|
let insightDump;
|
|
@@ -1508,11 +1514,21 @@ var PageTaskExecutor = class {
|
|
|
1508
1514
|
insightDump = dump;
|
|
1509
1515
|
};
|
|
1510
1516
|
this.insight.onceDumpUpdatedFn = dumpCollector;
|
|
1511
|
-
const
|
|
1512
|
-
|
|
1513
|
-
)
|
|
1517
|
+
const ifTypeRestricted = type !== "Query";
|
|
1518
|
+
let demandInput = demand;
|
|
1519
|
+
if (ifTypeRestricted) {
|
|
1520
|
+
demandInput = {
|
|
1521
|
+
result: `${type}, ${demand}`
|
|
1522
|
+
};
|
|
1523
|
+
}
|
|
1524
|
+
const { data, usage } = await this.insight.extract(demandInput);
|
|
1525
|
+
let outputResult = data;
|
|
1526
|
+
if (ifTypeRestricted) {
|
|
1527
|
+
(0, import_utils9.assert)(data?.result !== void 0, "No result in query data");
|
|
1528
|
+
outputResult = data.result;
|
|
1529
|
+
}
|
|
1514
1530
|
return {
|
|
1515
|
-
output:
|
|
1531
|
+
output: outputResult,
|
|
1516
1532
|
log: { dump: insightDump },
|
|
1517
1533
|
usage
|
|
1518
1534
|
};
|
|
@@ -1525,6 +1541,18 @@ var PageTaskExecutor = class {
|
|
|
1525
1541
|
executor: taskExecutor
|
|
1526
1542
|
};
|
|
1527
1543
|
}
|
|
1544
|
+
async query(demand) {
|
|
1545
|
+
return this.createTypeQueryTask("Query", demand);
|
|
1546
|
+
}
|
|
1547
|
+
async boolean(prompt) {
|
|
1548
|
+
return this.createTypeQueryTask("Boolean", prompt);
|
|
1549
|
+
}
|
|
1550
|
+
async number(prompt) {
|
|
1551
|
+
return this.createTypeQueryTask("Number", prompt);
|
|
1552
|
+
}
|
|
1553
|
+
async string(prompt) {
|
|
1554
|
+
return this.createTypeQueryTask("String", prompt);
|
|
1555
|
+
}
|
|
1528
1556
|
async assert(assertion) {
|
|
1529
1557
|
const description = `assert: ${assertion}`;
|
|
1530
1558
|
const taskExecutor = new import_core.Executor(taskTitleStr("Assert", description), {
|
|
@@ -1711,6 +1739,16 @@ function buildPlans(type, locateParam, param) {
|
|
|
1711
1739
|
};
|
|
1712
1740
|
returnPlans = [sleepPlan];
|
|
1713
1741
|
}
|
|
1742
|
+
if (type === "Locate") {
|
|
1743
|
+
(0, import_utils10.assert)(locateParam, `missing locate info for action "${type}"`);
|
|
1744
|
+
const locatePlan2 = {
|
|
1745
|
+
type,
|
|
1746
|
+
param: locateParam,
|
|
1747
|
+
locate: locateParam,
|
|
1748
|
+
thought: ""
|
|
1749
|
+
};
|
|
1750
|
+
returnPlans = [locatePlan2];
|
|
1751
|
+
}
|
|
1714
1752
|
if (returnPlans) {
|
|
1715
1753
|
debug3("buildPlans", returnPlans);
|
|
1716
1754
|
return returnPlans;
|
|
@@ -1910,6 +1948,35 @@ ${errorTask?.errorStack}`);
|
|
|
1910
1948
|
this.afterTaskRunning(executor);
|
|
1911
1949
|
return output;
|
|
1912
1950
|
}
|
|
1951
|
+
async aiBoolean(prompt) {
|
|
1952
|
+
const { output, executor } = await this.taskExecutor.boolean(prompt);
|
|
1953
|
+
this.afterTaskRunning(executor);
|
|
1954
|
+
return output;
|
|
1955
|
+
}
|
|
1956
|
+
async aiNumber(prompt) {
|
|
1957
|
+
const { output, executor } = await this.taskExecutor.number(prompt);
|
|
1958
|
+
this.afterTaskRunning(executor);
|
|
1959
|
+
return output;
|
|
1960
|
+
}
|
|
1961
|
+
async aiString(prompt) {
|
|
1962
|
+
const { output, executor } = await this.taskExecutor.string(prompt);
|
|
1963
|
+
this.afterTaskRunning(executor);
|
|
1964
|
+
return output;
|
|
1965
|
+
}
|
|
1966
|
+
async aiLocate(prompt, opt) {
|
|
1967
|
+
const detailedLocateParam = this.buildDetailedLocateParam(prompt, opt);
|
|
1968
|
+
const plans = buildPlans("Locate", detailedLocateParam);
|
|
1969
|
+
const { executor, output } = await this.taskExecutor.runPlans(
|
|
1970
|
+
taskTitleStr("Locate", locateParamStr(detailedLocateParam)),
|
|
1971
|
+
plans
|
|
1972
|
+
);
|
|
1973
|
+
this.afterTaskRunning(executor);
|
|
1974
|
+
const { element } = output;
|
|
1975
|
+
return {
|
|
1976
|
+
rect: element?.rect,
|
|
1977
|
+
center: element?.center
|
|
1978
|
+
};
|
|
1979
|
+
}
|
|
1913
1980
|
async aiAssert(assertion, msg, opt) {
|
|
1914
1981
|
const { output, executor } = await this.taskExecutor.assert(assertion);
|
|
1915
1982
|
this.afterTaskRunning(executor, true);
|