@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
package/dist/lib/puppeteer.js
CHANGED
|
@@ -1533,17 +1533,23 @@ var PageTaskExecutor = class {
|
|
|
1533
1533
|
executor: taskExecutor
|
|
1534
1534
|
};
|
|
1535
1535
|
}
|
|
1536
|
-
async
|
|
1537
|
-
const
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1536
|
+
async createTypeQueryTask(type, demand) {
|
|
1537
|
+
const taskExecutor = new import_core.Executor(
|
|
1538
|
+
taskTitleStr(
|
|
1539
|
+
type,
|
|
1540
|
+
typeof demand === "string" ? demand : JSON.stringify(demand)
|
|
1541
|
+
),
|
|
1542
|
+
{
|
|
1543
|
+
onTaskStart: this.onTaskStartCallback
|
|
1544
|
+
}
|
|
1545
|
+
);
|
|
1541
1546
|
const queryTask = {
|
|
1542
1547
|
type: "Insight",
|
|
1543
|
-
subType:
|
|
1548
|
+
subType: type,
|
|
1544
1549
|
locate: null,
|
|
1545
1550
|
param: {
|
|
1546
1551
|
dataDemand: demand
|
|
1552
|
+
// for user param presentation in report right sidebar
|
|
1547
1553
|
},
|
|
1548
1554
|
executor: async (param) => {
|
|
1549
1555
|
let insightDump;
|
|
@@ -1551,11 +1557,21 @@ var PageTaskExecutor = class {
|
|
|
1551
1557
|
insightDump = dump;
|
|
1552
1558
|
};
|
|
1553
1559
|
this.insight.onceDumpUpdatedFn = dumpCollector;
|
|
1554
|
-
const
|
|
1555
|
-
|
|
1556
|
-
)
|
|
1560
|
+
const ifTypeRestricted = type !== "Query";
|
|
1561
|
+
let demandInput = demand;
|
|
1562
|
+
if (ifTypeRestricted) {
|
|
1563
|
+
demandInput = {
|
|
1564
|
+
result: `${type}, ${demand}`
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1567
|
+
const { data, usage } = await this.insight.extract(demandInput);
|
|
1568
|
+
let outputResult = data;
|
|
1569
|
+
if (ifTypeRestricted) {
|
|
1570
|
+
(0, import_utils9.assert)(data?.result !== void 0, "No result in query data");
|
|
1571
|
+
outputResult = data.result;
|
|
1572
|
+
}
|
|
1557
1573
|
return {
|
|
1558
|
-
output:
|
|
1574
|
+
output: outputResult,
|
|
1559
1575
|
log: { dump: insightDump },
|
|
1560
1576
|
usage
|
|
1561
1577
|
};
|
|
@@ -1568,6 +1584,18 @@ var PageTaskExecutor = class {
|
|
|
1568
1584
|
executor: taskExecutor
|
|
1569
1585
|
};
|
|
1570
1586
|
}
|
|
1587
|
+
async query(demand) {
|
|
1588
|
+
return this.createTypeQueryTask("Query", demand);
|
|
1589
|
+
}
|
|
1590
|
+
async boolean(prompt) {
|
|
1591
|
+
return this.createTypeQueryTask("Boolean", prompt);
|
|
1592
|
+
}
|
|
1593
|
+
async number(prompt) {
|
|
1594
|
+
return this.createTypeQueryTask("Number", prompt);
|
|
1595
|
+
}
|
|
1596
|
+
async string(prompt) {
|
|
1597
|
+
return this.createTypeQueryTask("String", prompt);
|
|
1598
|
+
}
|
|
1571
1599
|
async assert(assertion) {
|
|
1572
1600
|
const description = `assert: ${assertion}`;
|
|
1573
1601
|
const taskExecutor = new import_core.Executor(taskTitleStr("Assert", description), {
|
|
@@ -1754,6 +1782,16 @@ function buildPlans(type, locateParam, param) {
|
|
|
1754
1782
|
};
|
|
1755
1783
|
returnPlans = [sleepPlan];
|
|
1756
1784
|
}
|
|
1785
|
+
if (type === "Locate") {
|
|
1786
|
+
(0, import_utils10.assert)(locateParam, `missing locate info for action "${type}"`);
|
|
1787
|
+
const locatePlan2 = {
|
|
1788
|
+
type,
|
|
1789
|
+
param: locateParam,
|
|
1790
|
+
locate: locateParam,
|
|
1791
|
+
thought: ""
|
|
1792
|
+
};
|
|
1793
|
+
returnPlans = [locatePlan2];
|
|
1794
|
+
}
|
|
1757
1795
|
if (returnPlans) {
|
|
1758
1796
|
debug3("buildPlans", returnPlans);
|
|
1759
1797
|
return returnPlans;
|
|
@@ -1953,6 +1991,35 @@ ${errorTask?.errorStack}`);
|
|
|
1953
1991
|
this.afterTaskRunning(executor);
|
|
1954
1992
|
return output;
|
|
1955
1993
|
}
|
|
1994
|
+
async aiBoolean(prompt) {
|
|
1995
|
+
const { output, executor } = await this.taskExecutor.boolean(prompt);
|
|
1996
|
+
this.afterTaskRunning(executor);
|
|
1997
|
+
return output;
|
|
1998
|
+
}
|
|
1999
|
+
async aiNumber(prompt) {
|
|
2000
|
+
const { output, executor } = await this.taskExecutor.number(prompt);
|
|
2001
|
+
this.afterTaskRunning(executor);
|
|
2002
|
+
return output;
|
|
2003
|
+
}
|
|
2004
|
+
async aiString(prompt) {
|
|
2005
|
+
const { output, executor } = await this.taskExecutor.string(prompt);
|
|
2006
|
+
this.afterTaskRunning(executor);
|
|
2007
|
+
return output;
|
|
2008
|
+
}
|
|
2009
|
+
async aiLocate(prompt, opt) {
|
|
2010
|
+
const detailedLocateParam = this.buildDetailedLocateParam(prompt, opt);
|
|
2011
|
+
const plans = buildPlans("Locate", detailedLocateParam);
|
|
2012
|
+
const { executor, output } = await this.taskExecutor.runPlans(
|
|
2013
|
+
taskTitleStr("Locate", locateParamStr(detailedLocateParam)),
|
|
2014
|
+
plans
|
|
2015
|
+
);
|
|
2016
|
+
this.afterTaskRunning(executor);
|
|
2017
|
+
const { element } = output;
|
|
2018
|
+
return {
|
|
2019
|
+
rect: element?.rect,
|
|
2020
|
+
center: element?.center
|
|
2021
|
+
};
|
|
2022
|
+
}
|
|
1956
2023
|
async aiAssert(assertion, msg, opt) {
|
|
1957
2024
|
const { output, executor } = await this.taskExecutor.assert(assertion);
|
|
1958
2025
|
this.afterTaskRunning(executor, true);
|