@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/index.js
CHANGED
|
@@ -1538,17 +1538,23 @@ var PageTaskExecutor = class {
|
|
|
1538
1538
|
executor: taskExecutor
|
|
1539
1539
|
};
|
|
1540
1540
|
}
|
|
1541
|
-
async
|
|
1542
|
-
const
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1541
|
+
async createTypeQueryTask(type, demand) {
|
|
1542
|
+
const taskExecutor = new import_core.Executor(
|
|
1543
|
+
taskTitleStr(
|
|
1544
|
+
type,
|
|
1545
|
+
typeof demand === "string" ? demand : JSON.stringify(demand)
|
|
1546
|
+
),
|
|
1547
|
+
{
|
|
1548
|
+
onTaskStart: this.onTaskStartCallback
|
|
1549
|
+
}
|
|
1550
|
+
);
|
|
1546
1551
|
const queryTask = {
|
|
1547
1552
|
type: "Insight",
|
|
1548
|
-
subType:
|
|
1553
|
+
subType: type,
|
|
1549
1554
|
locate: null,
|
|
1550
1555
|
param: {
|
|
1551
1556
|
dataDemand: demand
|
|
1557
|
+
// for user param presentation in report right sidebar
|
|
1552
1558
|
},
|
|
1553
1559
|
executor: async (param) => {
|
|
1554
1560
|
let insightDump;
|
|
@@ -1556,11 +1562,21 @@ var PageTaskExecutor = class {
|
|
|
1556
1562
|
insightDump = dump;
|
|
1557
1563
|
};
|
|
1558
1564
|
this.insight.onceDumpUpdatedFn = dumpCollector;
|
|
1559
|
-
const
|
|
1560
|
-
|
|
1561
|
-
)
|
|
1565
|
+
const ifTypeRestricted = type !== "Query";
|
|
1566
|
+
let demandInput = demand;
|
|
1567
|
+
if (ifTypeRestricted) {
|
|
1568
|
+
demandInput = {
|
|
1569
|
+
result: `${type}, ${demand}`
|
|
1570
|
+
};
|
|
1571
|
+
}
|
|
1572
|
+
const { data, usage } = await this.insight.extract(demandInput);
|
|
1573
|
+
let outputResult = data;
|
|
1574
|
+
if (ifTypeRestricted) {
|
|
1575
|
+
(0, import_utils9.assert)(data?.result !== void 0, "No result in query data");
|
|
1576
|
+
outputResult = data.result;
|
|
1577
|
+
}
|
|
1562
1578
|
return {
|
|
1563
|
-
output:
|
|
1579
|
+
output: outputResult,
|
|
1564
1580
|
log: { dump: insightDump },
|
|
1565
1581
|
usage
|
|
1566
1582
|
};
|
|
@@ -1573,6 +1589,18 @@ var PageTaskExecutor = class {
|
|
|
1573
1589
|
executor: taskExecutor
|
|
1574
1590
|
};
|
|
1575
1591
|
}
|
|
1592
|
+
async query(demand) {
|
|
1593
|
+
return this.createTypeQueryTask("Query", demand);
|
|
1594
|
+
}
|
|
1595
|
+
async boolean(prompt) {
|
|
1596
|
+
return this.createTypeQueryTask("Boolean", prompt);
|
|
1597
|
+
}
|
|
1598
|
+
async number(prompt) {
|
|
1599
|
+
return this.createTypeQueryTask("Number", prompt);
|
|
1600
|
+
}
|
|
1601
|
+
async string(prompt) {
|
|
1602
|
+
return this.createTypeQueryTask("String", prompt);
|
|
1603
|
+
}
|
|
1576
1604
|
async assert(assertion) {
|
|
1577
1605
|
const description = `assert: ${assertion}`;
|
|
1578
1606
|
const taskExecutor = new import_core.Executor(taskTitleStr("Assert", description), {
|
|
@@ -1759,6 +1787,16 @@ function buildPlans(type, locateParam, param) {
|
|
|
1759
1787
|
};
|
|
1760
1788
|
returnPlans = [sleepPlan];
|
|
1761
1789
|
}
|
|
1790
|
+
if (type === "Locate") {
|
|
1791
|
+
(0, import_utils10.assert)(locateParam, `missing locate info for action "${type}"`);
|
|
1792
|
+
const locatePlan2 = {
|
|
1793
|
+
type,
|
|
1794
|
+
param: locateParam,
|
|
1795
|
+
locate: locateParam,
|
|
1796
|
+
thought: ""
|
|
1797
|
+
};
|
|
1798
|
+
returnPlans = [locatePlan2];
|
|
1799
|
+
}
|
|
1762
1800
|
if (returnPlans) {
|
|
1763
1801
|
debug3("buildPlans", returnPlans);
|
|
1764
1802
|
return returnPlans;
|
|
@@ -1958,6 +1996,35 @@ ${errorTask?.errorStack}`);
|
|
|
1958
1996
|
this.afterTaskRunning(executor);
|
|
1959
1997
|
return output;
|
|
1960
1998
|
}
|
|
1999
|
+
async aiBoolean(prompt) {
|
|
2000
|
+
const { output, executor } = await this.taskExecutor.boolean(prompt);
|
|
2001
|
+
this.afterTaskRunning(executor);
|
|
2002
|
+
return output;
|
|
2003
|
+
}
|
|
2004
|
+
async aiNumber(prompt) {
|
|
2005
|
+
const { output, executor } = await this.taskExecutor.number(prompt);
|
|
2006
|
+
this.afterTaskRunning(executor);
|
|
2007
|
+
return output;
|
|
2008
|
+
}
|
|
2009
|
+
async aiString(prompt) {
|
|
2010
|
+
const { output, executor } = await this.taskExecutor.string(prompt);
|
|
2011
|
+
this.afterTaskRunning(executor);
|
|
2012
|
+
return output;
|
|
2013
|
+
}
|
|
2014
|
+
async aiLocate(prompt, opt) {
|
|
2015
|
+
const detailedLocateParam = this.buildDetailedLocateParam(prompt, opt);
|
|
2016
|
+
const plans = buildPlans("Locate", detailedLocateParam);
|
|
2017
|
+
const { executor, output } = await this.taskExecutor.runPlans(
|
|
2018
|
+
taskTitleStr("Locate", locateParamStr(detailedLocateParam)),
|
|
2019
|
+
plans
|
|
2020
|
+
);
|
|
2021
|
+
this.afterTaskRunning(executor);
|
|
2022
|
+
const { element } = output;
|
|
2023
|
+
return {
|
|
2024
|
+
rect: element?.rect,
|
|
2025
|
+
center: element?.center
|
|
2026
|
+
};
|
|
2027
|
+
}
|
|
1961
2028
|
async aiAssert(assertion, msg, opt) {
|
|
1962
2029
|
const { output, executor } = await this.taskExecutor.assert(assertion);
|
|
1963
2030
|
this.afterTaskRunning(executor, true);
|
|
@@ -2492,6 +2559,38 @@ var PlaywrightAiFixture = (options) => {
|
|
|
2492
2559
|
use,
|
|
2493
2560
|
aiActionType: "aiWaitFor"
|
|
2494
2561
|
});
|
|
2562
|
+
},
|
|
2563
|
+
aiLocate: async ({ page }, use, testInfo) => {
|
|
2564
|
+
await generateAiFunction({
|
|
2565
|
+
page,
|
|
2566
|
+
testInfo,
|
|
2567
|
+
use,
|
|
2568
|
+
aiActionType: "aiLocate"
|
|
2569
|
+
});
|
|
2570
|
+
},
|
|
2571
|
+
aiNumber: async ({ page }, use, testInfo) => {
|
|
2572
|
+
await generateAiFunction({
|
|
2573
|
+
page,
|
|
2574
|
+
testInfo,
|
|
2575
|
+
use,
|
|
2576
|
+
aiActionType: "aiNumber"
|
|
2577
|
+
});
|
|
2578
|
+
},
|
|
2579
|
+
aiString: async ({ page }, use, testInfo) => {
|
|
2580
|
+
await generateAiFunction({
|
|
2581
|
+
page,
|
|
2582
|
+
testInfo,
|
|
2583
|
+
use,
|
|
2584
|
+
aiActionType: "aiString"
|
|
2585
|
+
});
|
|
2586
|
+
},
|
|
2587
|
+
aiBoolean: async ({ page }, use, testInfo) => {
|
|
2588
|
+
await generateAiFunction({
|
|
2589
|
+
page,
|
|
2590
|
+
testInfo,
|
|
2591
|
+
use,
|
|
2592
|
+
aiActionType: "aiBoolean"
|
|
2593
|
+
});
|
|
2495
2594
|
}
|
|
2496
2595
|
};
|
|
2497
2596
|
};
|