@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
|
@@ -1540,17 +1540,23 @@ var PageTaskExecutor = class {
|
|
|
1540
1540
|
executor: taskExecutor
|
|
1541
1541
|
};
|
|
1542
1542
|
}
|
|
1543
|
-
async
|
|
1544
|
-
const
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1543
|
+
async createTypeQueryTask(type, demand) {
|
|
1544
|
+
const taskExecutor = new import_core.Executor(
|
|
1545
|
+
taskTitleStr(
|
|
1546
|
+
type,
|
|
1547
|
+
typeof demand === "string" ? demand : JSON.stringify(demand)
|
|
1548
|
+
),
|
|
1549
|
+
{
|
|
1550
|
+
onTaskStart: this.onTaskStartCallback
|
|
1551
|
+
}
|
|
1552
|
+
);
|
|
1548
1553
|
const queryTask = {
|
|
1549
1554
|
type: "Insight",
|
|
1550
|
-
subType:
|
|
1555
|
+
subType: type,
|
|
1551
1556
|
locate: null,
|
|
1552
1557
|
param: {
|
|
1553
1558
|
dataDemand: demand
|
|
1559
|
+
// for user param presentation in report right sidebar
|
|
1554
1560
|
},
|
|
1555
1561
|
executor: async (param) => {
|
|
1556
1562
|
let insightDump;
|
|
@@ -1558,11 +1564,21 @@ var PageTaskExecutor = class {
|
|
|
1558
1564
|
insightDump = dump;
|
|
1559
1565
|
};
|
|
1560
1566
|
this.insight.onceDumpUpdatedFn = dumpCollector;
|
|
1561
|
-
const
|
|
1562
|
-
|
|
1563
|
-
)
|
|
1567
|
+
const ifTypeRestricted = type !== "Query";
|
|
1568
|
+
let demandInput = demand;
|
|
1569
|
+
if (ifTypeRestricted) {
|
|
1570
|
+
demandInput = {
|
|
1571
|
+
result: `${type}, ${demand}`
|
|
1572
|
+
};
|
|
1573
|
+
}
|
|
1574
|
+
const { data, usage } = await this.insight.extract(demandInput);
|
|
1575
|
+
let outputResult = data;
|
|
1576
|
+
if (ifTypeRestricted) {
|
|
1577
|
+
(0, import_utils9.assert)(data?.result !== void 0, "No result in query data");
|
|
1578
|
+
outputResult = data.result;
|
|
1579
|
+
}
|
|
1564
1580
|
return {
|
|
1565
|
-
output:
|
|
1581
|
+
output: outputResult,
|
|
1566
1582
|
log: { dump: insightDump },
|
|
1567
1583
|
usage
|
|
1568
1584
|
};
|
|
@@ -1575,6 +1591,18 @@ var PageTaskExecutor = class {
|
|
|
1575
1591
|
executor: taskExecutor
|
|
1576
1592
|
};
|
|
1577
1593
|
}
|
|
1594
|
+
async query(demand) {
|
|
1595
|
+
return this.createTypeQueryTask("Query", demand);
|
|
1596
|
+
}
|
|
1597
|
+
async boolean(prompt) {
|
|
1598
|
+
return this.createTypeQueryTask("Boolean", prompt);
|
|
1599
|
+
}
|
|
1600
|
+
async number(prompt) {
|
|
1601
|
+
return this.createTypeQueryTask("Number", prompt);
|
|
1602
|
+
}
|
|
1603
|
+
async string(prompt) {
|
|
1604
|
+
return this.createTypeQueryTask("String", prompt);
|
|
1605
|
+
}
|
|
1578
1606
|
async assert(assertion) {
|
|
1579
1607
|
const description = `assert: ${assertion}`;
|
|
1580
1608
|
const taskExecutor = new import_core.Executor(taskTitleStr("Assert", description), {
|
|
@@ -1761,6 +1789,16 @@ function buildPlans(type, locateParam, param) {
|
|
|
1761
1789
|
};
|
|
1762
1790
|
returnPlans = [sleepPlan];
|
|
1763
1791
|
}
|
|
1792
|
+
if (type === "Locate") {
|
|
1793
|
+
(0, import_utils10.assert)(locateParam, `missing locate info for action "${type}"`);
|
|
1794
|
+
const locatePlan2 = {
|
|
1795
|
+
type,
|
|
1796
|
+
param: locateParam,
|
|
1797
|
+
locate: locateParam,
|
|
1798
|
+
thought: ""
|
|
1799
|
+
};
|
|
1800
|
+
returnPlans = [locatePlan2];
|
|
1801
|
+
}
|
|
1764
1802
|
if (returnPlans) {
|
|
1765
1803
|
debug3("buildPlans", returnPlans);
|
|
1766
1804
|
return returnPlans;
|
|
@@ -1960,6 +1998,35 @@ ${errorTask?.errorStack}`);
|
|
|
1960
1998
|
this.afterTaskRunning(executor);
|
|
1961
1999
|
return output;
|
|
1962
2000
|
}
|
|
2001
|
+
async aiBoolean(prompt) {
|
|
2002
|
+
const { output, executor } = await this.taskExecutor.boolean(prompt);
|
|
2003
|
+
this.afterTaskRunning(executor);
|
|
2004
|
+
return output;
|
|
2005
|
+
}
|
|
2006
|
+
async aiNumber(prompt) {
|
|
2007
|
+
const { output, executor } = await this.taskExecutor.number(prompt);
|
|
2008
|
+
this.afterTaskRunning(executor);
|
|
2009
|
+
return output;
|
|
2010
|
+
}
|
|
2011
|
+
async aiString(prompt) {
|
|
2012
|
+
const { output, executor } = await this.taskExecutor.string(prompt);
|
|
2013
|
+
this.afterTaskRunning(executor);
|
|
2014
|
+
return output;
|
|
2015
|
+
}
|
|
2016
|
+
async aiLocate(prompt, opt) {
|
|
2017
|
+
const detailedLocateParam = this.buildDetailedLocateParam(prompt, opt);
|
|
2018
|
+
const plans = buildPlans("Locate", detailedLocateParam);
|
|
2019
|
+
const { executor, output } = await this.taskExecutor.runPlans(
|
|
2020
|
+
taskTitleStr("Locate", locateParamStr(detailedLocateParam)),
|
|
2021
|
+
plans
|
|
2022
|
+
);
|
|
2023
|
+
this.afterTaskRunning(executor);
|
|
2024
|
+
const { element } = output;
|
|
2025
|
+
return {
|
|
2026
|
+
rect: element?.rect,
|
|
2027
|
+
center: element?.center
|
|
2028
|
+
};
|
|
2029
|
+
}
|
|
1963
2030
|
async aiAssert(assertion, msg, opt) {
|
|
1964
2031
|
const { output, executor } = await this.taskExecutor.assert(assertion);
|
|
1965
2032
|
this.afterTaskRunning(executor, true);
|