@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/es/playwright.js
CHANGED
|
@@ -296,10 +296,7 @@ import { sleep } from "@midscene/core/utils";
|
|
|
296
296
|
import { UITarsModelVersion } from "@midscene/shared/env";
|
|
297
297
|
import { uiTarsModelVersion } from "@midscene/shared/env";
|
|
298
298
|
import { vlLocateMode } from "@midscene/shared/env";
|
|
299
|
-
import {
|
|
300
|
-
imageInfo,
|
|
301
|
-
resizeImgBase64 as resizeImgBase642
|
|
302
|
-
} from "@midscene/shared/img";
|
|
299
|
+
import { imageInfo, resizeImgBase64 as resizeImgBase642 } from "@midscene/shared/img";
|
|
303
300
|
import { getDebug as getDebug2 } from "@midscene/shared/logger";
|
|
304
301
|
import { assert as assert4 } from "@midscene/shared/utils";
|
|
305
302
|
|
|
@@ -1513,17 +1510,23 @@ var PageTaskExecutor = class {
|
|
|
1513
1510
|
executor: taskExecutor
|
|
1514
1511
|
};
|
|
1515
1512
|
}
|
|
1516
|
-
async
|
|
1517
|
-
const
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1513
|
+
async createTypeQueryTask(type, demand) {
|
|
1514
|
+
const taskExecutor = new Executor(
|
|
1515
|
+
taskTitleStr(
|
|
1516
|
+
type,
|
|
1517
|
+
typeof demand === "string" ? demand : JSON.stringify(demand)
|
|
1518
|
+
),
|
|
1519
|
+
{
|
|
1520
|
+
onTaskStart: this.onTaskStartCallback
|
|
1521
|
+
}
|
|
1522
|
+
);
|
|
1521
1523
|
const queryTask = {
|
|
1522
1524
|
type: "Insight",
|
|
1523
|
-
subType:
|
|
1525
|
+
subType: type,
|
|
1524
1526
|
locate: null,
|
|
1525
1527
|
param: {
|
|
1526
1528
|
dataDemand: demand
|
|
1529
|
+
// for user param presentation in report right sidebar
|
|
1527
1530
|
},
|
|
1528
1531
|
executor: async (param) => {
|
|
1529
1532
|
let insightDump;
|
|
@@ -1531,11 +1534,21 @@ var PageTaskExecutor = class {
|
|
|
1531
1534
|
insightDump = dump;
|
|
1532
1535
|
};
|
|
1533
1536
|
this.insight.onceDumpUpdatedFn = dumpCollector;
|
|
1534
|
-
const
|
|
1535
|
-
|
|
1536
|
-
)
|
|
1537
|
+
const ifTypeRestricted = type !== "Query";
|
|
1538
|
+
let demandInput = demand;
|
|
1539
|
+
if (ifTypeRestricted) {
|
|
1540
|
+
demandInput = {
|
|
1541
|
+
result: `${type}, ${demand}`
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1544
|
+
const { data, usage } = await this.insight.extract(demandInput);
|
|
1545
|
+
let outputResult = data;
|
|
1546
|
+
if (ifTypeRestricted) {
|
|
1547
|
+
assert4(data?.result !== void 0, "No result in query data");
|
|
1548
|
+
outputResult = data.result;
|
|
1549
|
+
}
|
|
1537
1550
|
return {
|
|
1538
|
-
output:
|
|
1551
|
+
output: outputResult,
|
|
1539
1552
|
log: { dump: insightDump },
|
|
1540
1553
|
usage
|
|
1541
1554
|
};
|
|
@@ -1548,6 +1561,18 @@ var PageTaskExecutor = class {
|
|
|
1548
1561
|
executor: taskExecutor
|
|
1549
1562
|
};
|
|
1550
1563
|
}
|
|
1564
|
+
async query(demand) {
|
|
1565
|
+
return this.createTypeQueryTask("Query", demand);
|
|
1566
|
+
}
|
|
1567
|
+
async boolean(prompt) {
|
|
1568
|
+
return this.createTypeQueryTask("Boolean", prompt);
|
|
1569
|
+
}
|
|
1570
|
+
async number(prompt) {
|
|
1571
|
+
return this.createTypeQueryTask("Number", prompt);
|
|
1572
|
+
}
|
|
1573
|
+
async string(prompt) {
|
|
1574
|
+
return this.createTypeQueryTask("String", prompt);
|
|
1575
|
+
}
|
|
1551
1576
|
async assert(assertion) {
|
|
1552
1577
|
const description = `assert: ${assertion}`;
|
|
1553
1578
|
const taskExecutor = new Executor(taskTitleStr("Assert", description), {
|
|
@@ -1734,6 +1759,16 @@ function buildPlans(type, locateParam, param) {
|
|
|
1734
1759
|
};
|
|
1735
1760
|
returnPlans = [sleepPlan];
|
|
1736
1761
|
}
|
|
1762
|
+
if (type === "Locate") {
|
|
1763
|
+
assert5(locateParam, `missing locate info for action "${type}"`);
|
|
1764
|
+
const locatePlan2 = {
|
|
1765
|
+
type,
|
|
1766
|
+
param: locateParam,
|
|
1767
|
+
locate: locateParam,
|
|
1768
|
+
thought: ""
|
|
1769
|
+
};
|
|
1770
|
+
returnPlans = [locatePlan2];
|
|
1771
|
+
}
|
|
1737
1772
|
if (returnPlans) {
|
|
1738
1773
|
debug3("buildPlans", returnPlans);
|
|
1739
1774
|
return returnPlans;
|
|
@@ -1933,6 +1968,35 @@ ${errorTask?.errorStack}`);
|
|
|
1933
1968
|
this.afterTaskRunning(executor);
|
|
1934
1969
|
return output;
|
|
1935
1970
|
}
|
|
1971
|
+
async aiBoolean(prompt) {
|
|
1972
|
+
const { output, executor } = await this.taskExecutor.boolean(prompt);
|
|
1973
|
+
this.afterTaskRunning(executor);
|
|
1974
|
+
return output;
|
|
1975
|
+
}
|
|
1976
|
+
async aiNumber(prompt) {
|
|
1977
|
+
const { output, executor } = await this.taskExecutor.number(prompt);
|
|
1978
|
+
this.afterTaskRunning(executor);
|
|
1979
|
+
return output;
|
|
1980
|
+
}
|
|
1981
|
+
async aiString(prompt) {
|
|
1982
|
+
const { output, executor } = await this.taskExecutor.string(prompt);
|
|
1983
|
+
this.afterTaskRunning(executor);
|
|
1984
|
+
return output;
|
|
1985
|
+
}
|
|
1986
|
+
async aiLocate(prompt, opt) {
|
|
1987
|
+
const detailedLocateParam = this.buildDetailedLocateParam(prompt, opt);
|
|
1988
|
+
const plans = buildPlans("Locate", detailedLocateParam);
|
|
1989
|
+
const { executor, output } = await this.taskExecutor.runPlans(
|
|
1990
|
+
taskTitleStr("Locate", locateParamStr(detailedLocateParam)),
|
|
1991
|
+
plans
|
|
1992
|
+
);
|
|
1993
|
+
this.afterTaskRunning(executor);
|
|
1994
|
+
const { element } = output;
|
|
1995
|
+
return {
|
|
1996
|
+
rect: element?.rect,
|
|
1997
|
+
center: element?.center
|
|
1998
|
+
};
|
|
1999
|
+
}
|
|
1936
2000
|
async aiAssert(assertion, msg, opt) {
|
|
1937
2001
|
const { output, executor } = await this.taskExecutor.assert(assertion);
|
|
1938
2002
|
this.afterTaskRunning(executor, true);
|
|
@@ -2467,6 +2531,38 @@ var PlaywrightAiFixture = (options) => {
|
|
|
2467
2531
|
use,
|
|
2468
2532
|
aiActionType: "aiWaitFor"
|
|
2469
2533
|
});
|
|
2534
|
+
},
|
|
2535
|
+
aiLocate: async ({ page }, use, testInfo) => {
|
|
2536
|
+
await generateAiFunction({
|
|
2537
|
+
page,
|
|
2538
|
+
testInfo,
|
|
2539
|
+
use,
|
|
2540
|
+
aiActionType: "aiLocate"
|
|
2541
|
+
});
|
|
2542
|
+
},
|
|
2543
|
+
aiNumber: async ({ page }, use, testInfo) => {
|
|
2544
|
+
await generateAiFunction({
|
|
2545
|
+
page,
|
|
2546
|
+
testInfo,
|
|
2547
|
+
use,
|
|
2548
|
+
aiActionType: "aiNumber"
|
|
2549
|
+
});
|
|
2550
|
+
},
|
|
2551
|
+
aiString: async ({ page }, use, testInfo) => {
|
|
2552
|
+
await generateAiFunction({
|
|
2553
|
+
page,
|
|
2554
|
+
testInfo,
|
|
2555
|
+
use,
|
|
2556
|
+
aiActionType: "aiString"
|
|
2557
|
+
});
|
|
2558
|
+
},
|
|
2559
|
+
aiBoolean: async ({ page }, use, testInfo) => {
|
|
2560
|
+
await generateAiFunction({
|
|
2561
|
+
page,
|
|
2562
|
+
testInfo,
|
|
2563
|
+
use,
|
|
2564
|
+
aiActionType: "aiBoolean"
|
|
2565
|
+
});
|
|
2470
2566
|
}
|
|
2471
2567
|
};
|
|
2472
2568
|
};
|