@midscene/web 0.5.1 → 0.5.2-beta-20240929094445.0

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/appium.js CHANGED
@@ -1188,6 +1188,7 @@ var PageTaskExecutor = class {
1188
1188
  let locateResult;
1189
1189
  const callAI = this.insight.aiVendorFn;
1190
1190
  const element = await this.insight.locate(param.prompt, {
1191
+ quickAnswer: plan2.quickAnswer,
1191
1192
  callAI: async (...message) => {
1192
1193
  if (locateCache) {
1193
1194
  locateResult = locateCache;
@@ -1707,7 +1708,7 @@ function getNodeAttributes2(node) {
1707
1708
  }
1708
1709
  return attrs;
1709
1710
  }
1710
- function getRect(attributes) {
1711
+ function getRect2(attributes) {
1711
1712
  var _a, _b, _c, _d;
1712
1713
  const x = Math.round(Number.parseFloat((_a = attributes.x) != null ? _a : "0"));
1713
1714
  const y = Math.round(Number.parseFloat((_b = attributes.y) != null ? _b : "0"));
@@ -1795,7 +1796,7 @@ function extractTextWithPosition2(initNode) {
1795
1796
  }
1796
1797
  function collectElementInfo(node) {
1797
1798
  const attributes = getNodeAttributes2(node);
1798
- const rect = getRect(attributes);
1799
+ const rect = getRect2(attributes);
1799
1800
  const nodeHashId = midsceneGenerateHash(attributes.placeholder, rect);
1800
1801
  const text = validTextNodeContent(node);
1801
1802
  let nodeType;
@@ -1842,7 +1843,6 @@ function extractTextWithPosition2(initNode) {
1842
1843
  Math.round(rect.top + rect.height / 2)
1843
1844
  ],
1844
1845
  nodeType,
1845
- htmlNode: null,
1846
1846
  nodePath: ""
1847
1847
  };
1848
1848
  if (elementInfo.nodeType !== NodeType2.CONTAINER) {
package/dist/es/debug.js CHANGED
@@ -49,6 +49,11 @@ async function generateExtractData(page, targetDir, saveImgType) {
49
49
  inputImgBase64
50
50
  });
51
51
  const resizeImgBase64 = await resizeImg(inputImgBase64);
52
+ const existingSnapshot = existsSync(snapshotJsonPath) ? JSON.parse(readFileSync(snapshotJsonPath, "utf-8")) : null;
53
+ if (existingSnapshot && JSON.stringify(existingSnapshot) === JSON.stringify(captureElementSnapshot)) {
54
+ console.log("skip save snapshot for ", targetDir);
55
+ return;
56
+ }
52
57
  if (!(saveImgType == null ? void 0 : saveImgType.disableSnapshot)) {
53
58
  writeFileSyncWithDir(
54
59
  snapshotJsonPath,
@@ -84,7 +89,7 @@ function generateTestDataPath(testDataName) {
84
89
  const modulePath = __require.resolve("@midscene/core").replace("dist/lib/index.js", "");
85
90
  const midsceneTestDataPath = path.join(
86
91
  modulePath,
87
- `tests/ai/inspector/test-data/${testDataName}`
92
+ `tests/ai/evaluate/test-data/${testDataName}`
88
93
  );
89
94
  return midsceneTestDataPath;
90
95
  }
package/dist/es/index.js CHANGED
@@ -1198,6 +1198,7 @@ var PageTaskExecutor = class {
1198
1198
  let locateResult;
1199
1199
  const callAI = this.insight.aiVendorFn;
1200
1200
  const element = await this.insight.locate(param.prompt, {
1201
+ quickAnswer: plan2.quickAnswer,
1201
1202
  callAI: async (...message) => {
1202
1203
  if (locateCache) {
1203
1204
  locateResult = locateCache;
@@ -1725,7 +1726,7 @@ var PlaywrightAiFixture = () => {
1725
1726
  async (taskPrompt, opts) => {
1726
1727
  return new Promise((resolve, reject) => {
1727
1728
  test.step(`ai - ${taskPrompt}`, async () => {
1728
- await page.waitForLoadState("networkidle");
1729
+ await waitForNetworkIdle(page);
1729
1730
  const actionType = (opts == null ? void 0 : opts.type) || "action";
1730
1731
  const result = await agent.ai(taskPrompt, actionType);
1731
1732
  resolve(result);
@@ -1739,7 +1740,7 @@ var PlaywrightAiFixture = () => {
1739
1740
  const agent = agentForPage(page, testInfo);
1740
1741
  await use(async (taskPrompt) => {
1741
1742
  test.step(`aiAction - ${taskPrompt}`, async () => {
1742
- await page.waitForLoadState("networkidle");
1743
+ await waitForNetworkIdle(page);
1743
1744
  await agent.aiAction(taskPrompt);
1744
1745
  });
1745
1746
  });
@@ -1750,7 +1751,7 @@ var PlaywrightAiFixture = () => {
1750
1751
  await use(async (demand) => {
1751
1752
  return new Promise((resolve, reject) => {
1752
1753
  test.step(`aiQuery - ${JSON.stringify(demand)}`, async () => {
1753
- await page.waitForLoadState("networkidle");
1754
+ await waitForNetworkIdle(page);
1754
1755
  const result = await agent.aiQuery(demand);
1755
1756
  resolve(result);
1756
1757
  });
@@ -1763,7 +1764,7 @@ var PlaywrightAiFixture = () => {
1763
1764
  await use(async (assertion, errorMsg) => {
1764
1765
  return new Promise((resolve, reject) => {
1765
1766
  test.step(`aiAssert - ${assertion}`, async () => {
1766
- await page.waitForLoadState("networkidle");
1767
+ await waitForNetworkIdle(page);
1767
1768
  await agent.aiAssert(assertion, errorMsg);
1768
1769
  resolve(null);
1769
1770
  });
@@ -1785,6 +1786,13 @@ var PlaywrightAiFixture = () => {
1785
1786
  }
1786
1787
  };
1787
1788
  };
1789
+ function waitForNetworkIdle(page) {
1790
+ const timeout = 20 * 1e3;
1791
+ return Promise.race([
1792
+ page.waitForLoadState("networkidle"),
1793
+ new Promise((resolve) => setTimeout(resolve, timeout))
1794
+ ]);
1795
+ }
1788
1796
 
1789
1797
  // src/puppeteer/base-page.ts
1790
1798
  import { readFileSync as readFileSync3, writeFileSync } from "fs";
@@ -1817,8 +1825,7 @@ var Page = class {
1817
1825
  const path3 = getTmpFile("jpeg");
1818
1826
  await this.page.screenshot({
1819
1827
  path: path3,
1820
- type: "jpeg",
1821
- quality: 75
1828
+ type: "png"
1822
1829
  });
1823
1830
  let buf;
1824
1831
  if (viewportSize.deviceScaleFactor > 1) {
@@ -1963,7 +1970,7 @@ function getNodeAttributes2(node) {
1963
1970
  }
1964
1971
  return attrs;
1965
1972
  }
1966
- function getRect(attributes) {
1973
+ function getRect2(attributes) {
1967
1974
  var _a, _b, _c, _d;
1968
1975
  const x = Math.round(Number.parseFloat((_a = attributes.x) != null ? _a : "0"));
1969
1976
  const y = Math.round(Number.parseFloat((_b = attributes.y) != null ? _b : "0"));
@@ -2051,7 +2058,7 @@ function extractTextWithPosition2(initNode) {
2051
2058
  }
2052
2059
  function collectElementInfo(node) {
2053
2060
  const attributes = getNodeAttributes2(node);
2054
- const rect = getRect(attributes);
2061
+ const rect = getRect2(attributes);
2055
2062
  const nodeHashId = midsceneGenerateHash(attributes.placeholder, rect);
2056
2063
  const text = validTextNodeContent(node);
2057
2064
  let nodeType;
@@ -2098,7 +2105,6 @@ function extractTextWithPosition2(initNode) {
2098
2105
  Math.round(rect.top + rect.height / 2)
2099
2106
  ],
2100
2107
  nodeType,
2101
- htmlNode: null,
2102
2108
  nodePath: ""
2103
2109
  };
2104
2110
  if (elementInfo.nodeType !== NodeType2.CONTAINER) {
@@ -2323,6 +2329,11 @@ async function generateExtractData(page, targetDir, saveImgType) {
2323
2329
  inputImgBase64
2324
2330
  });
2325
2331
  const resizeImgBase64 = await resizeImg3(inputImgBase64);
2332
+ const existingSnapshot = existsSync2(snapshotJsonPath) ? JSON.parse(readFileSync4(snapshotJsonPath, "utf-8")) : null;
2333
+ if (existingSnapshot && JSON.stringify(existingSnapshot) === JSON.stringify(captureElementSnapshot)) {
2334
+ console.log("skip save snapshot for ", targetDir);
2335
+ return;
2336
+ }
2326
2337
  if (!(saveImgType == null ? void 0 : saveImgType.disableSnapshot)) {
2327
2338
  writeFileSyncWithDir(
2328
2339
  snapshotJsonPath,
@@ -672,6 +672,7 @@ var PageTaskExecutor = class {
672
672
  let locateResult;
673
673
  const callAI = this.insight.aiVendorFn;
674
674
  const element = await this.insight.locate(param.prompt, {
675
+ quickAnswer: plan2.quickAnswer,
675
676
  callAI: async (...message) => {
676
677
  if (locateCache) {
677
678
  locateResult = locateCache;
@@ -1199,7 +1200,7 @@ var PlaywrightAiFixture = () => {
1199
1200
  async (taskPrompt, opts) => {
1200
1201
  return new Promise((resolve, reject) => {
1201
1202
  test.step(`ai - ${taskPrompt}`, async () => {
1202
- await page.waitForLoadState("networkidle");
1203
+ await waitForNetworkIdle(page);
1203
1204
  const actionType = (opts == null ? void 0 : opts.type) || "action";
1204
1205
  const result = await agent.ai(taskPrompt, actionType);
1205
1206
  resolve(result);
@@ -1213,7 +1214,7 @@ var PlaywrightAiFixture = () => {
1213
1214
  const agent = agentForPage(page, testInfo);
1214
1215
  await use(async (taskPrompt) => {
1215
1216
  test.step(`aiAction - ${taskPrompt}`, async () => {
1216
- await page.waitForLoadState("networkidle");
1217
+ await waitForNetworkIdle(page);
1217
1218
  await agent.aiAction(taskPrompt);
1218
1219
  });
1219
1220
  });
@@ -1224,7 +1225,7 @@ var PlaywrightAiFixture = () => {
1224
1225
  await use(async (demand) => {
1225
1226
  return new Promise((resolve, reject) => {
1226
1227
  test.step(`aiQuery - ${JSON.stringify(demand)}`, async () => {
1227
- await page.waitForLoadState("networkidle");
1228
+ await waitForNetworkIdle(page);
1228
1229
  const result = await agent.aiQuery(demand);
1229
1230
  resolve(result);
1230
1231
  });
@@ -1237,7 +1238,7 @@ var PlaywrightAiFixture = () => {
1237
1238
  await use(async (assertion, errorMsg) => {
1238
1239
  return new Promise((resolve, reject) => {
1239
1240
  test.step(`aiAssert - ${assertion}`, async () => {
1240
- await page.waitForLoadState("networkidle");
1241
+ await waitForNetworkIdle(page);
1241
1242
  await agent.aiAssert(assertion, errorMsg);
1242
1243
  resolve(null);
1243
1244
  });
@@ -1259,6 +1260,13 @@ var PlaywrightAiFixture = () => {
1259
1260
  }
1260
1261
  };
1261
1262
  };
1263
+ function waitForNetworkIdle(page) {
1264
+ const timeout = 20 * 1e3;
1265
+ return Promise.race([
1266
+ page.waitForLoadState("networkidle"),
1267
+ new Promise((resolve) => setTimeout(resolve, timeout))
1268
+ ]);
1269
+ }
1262
1270
 
1263
1271
  // src/puppeteer/base-page.ts
1264
1272
  import { readFileSync as readFileSync3, writeFileSync } from "fs";
@@ -1291,8 +1299,7 @@ var Page = class {
1291
1299
  const path2 = getTmpFile("jpeg");
1292
1300
  await this.page.screenshot({
1293
1301
  path: path2,
1294
- type: "jpeg",
1295
- quality: 75
1302
+ type: "png"
1296
1303
  });
1297
1304
  let buf;
1298
1305
  if (viewportSize.deviceScaleFactor > 1) {
@@ -669,6 +669,7 @@ var PageTaskExecutor = class {
669
669
  let locateResult;
670
670
  const callAI = this.insight.aiVendorFn;
671
671
  const element = await this.insight.locate(param.prompt, {
672
+ quickAnswer: plan2.quickAnswer,
672
673
  callAI: async (...message) => {
673
674
  if (locateCache) {
674
675
  locateResult = locateCache;
@@ -1167,8 +1168,7 @@ var Page = class {
1167
1168
  const path2 = getTmpFile("jpeg");
1168
1169
  await this.page.screenshot({
1169
1170
  path: path2,
1170
- type: "jpeg",
1171
- quality: 75
1171
+ type: "png"
1172
1172
  });
1173
1173
  let buf;
1174
1174
  if (viewportSize.deviceScaleFactor > 1) {
@@ -1184,6 +1184,7 @@ var PageTaskExecutor = class {
1184
1184
  let locateResult;
1185
1185
  const callAI = this.insight.aiVendorFn;
1186
1186
  const element = await this.insight.locate(param.prompt, {
1187
+ quickAnswer: plan2.quickAnswer,
1187
1188
  callAI: async (...message) => {
1188
1189
  if (locateCache) {
1189
1190
  locateResult = locateCache;
@@ -1695,7 +1696,7 @@ function getNodeAttributes2(node) {
1695
1696
  }
1696
1697
  return attrs;
1697
1698
  }
1698
- function getRect(attributes) {
1699
+ function getRect2(attributes) {
1699
1700
  var _a, _b, _c, _d;
1700
1701
  const x = Math.round(Number.parseFloat((_a = attributes.x) != null ? _a : "0"));
1701
1702
  const y = Math.round(Number.parseFloat((_b = attributes.y) != null ? _b : "0"));
@@ -1783,7 +1784,7 @@ function extractTextWithPosition2(initNode) {
1783
1784
  }
1784
1785
  function collectElementInfo(node) {
1785
1786
  const attributes = getNodeAttributes2(node);
1786
- const rect = getRect(attributes);
1787
+ const rect = getRect2(attributes);
1787
1788
  const nodeHashId = midsceneGenerateHash(attributes.placeholder, rect);
1788
1789
  const text = validTextNodeContent(node);
1789
1790
  let nodeType;
@@ -1830,7 +1831,6 @@ function extractTextWithPosition2(initNode) {
1830
1831
  Math.round(rect.top + rect.height / 2)
1831
1832
  ],
1832
1833
  nodeType,
1833
- htmlNode: null,
1834
1834
  nodePath: ""
1835
1835
  };
1836
1836
  if (elementInfo.nodeType !== import_constants2.NodeType.CONTAINER) {
package/dist/lib/debug.js CHANGED
@@ -70,6 +70,11 @@ async function generateExtractData(page, targetDir, saveImgType) {
70
70
  inputImgBase64
71
71
  });
72
72
  const resizeImgBase64 = await (0, import_img.resizeImg)(inputImgBase64);
73
+ const existingSnapshot = (0, import_node_fs.existsSync)(snapshotJsonPath) ? JSON.parse((0, import_node_fs.readFileSync)(snapshotJsonPath, "utf-8")) : null;
74
+ if (existingSnapshot && JSON.stringify(existingSnapshot) === JSON.stringify(captureElementSnapshot)) {
75
+ console.log("skip save snapshot for ", targetDir);
76
+ return;
77
+ }
73
78
  if (!(saveImgType == null ? void 0 : saveImgType.disableSnapshot)) {
74
79
  writeFileSyncWithDir(
75
80
  snapshotJsonPath,
@@ -105,7 +110,7 @@ function generateTestDataPath(testDataName) {
105
110
  const modulePath = require.resolve("@midscene/core").replace("dist/lib/index.js", "");
106
111
  const midsceneTestDataPath = import_node_path.default.join(
107
112
  modulePath,
108
- `tests/ai/inspector/test-data/${testDataName}`
113
+ `tests/ai/evaluate/test-data/${testDataName}`
109
114
  );
110
115
  return midsceneTestDataPath;
111
116
  }
package/dist/lib/index.js CHANGED
@@ -1198,6 +1198,7 @@ var PageTaskExecutor = class {
1198
1198
  let locateResult;
1199
1199
  const callAI = this.insight.aiVendorFn;
1200
1200
  const element = await this.insight.locate(param.prompt, {
1201
+ quickAnswer: plan2.quickAnswer,
1201
1202
  callAI: async (...message) => {
1202
1203
  if (locateCache) {
1203
1204
  locateResult = locateCache;
@@ -1725,7 +1726,7 @@ var PlaywrightAiFixture = () => {
1725
1726
  async (taskPrompt, opts) => {
1726
1727
  return new Promise((resolve, reject) => {
1727
1728
  import_test.test.step(`ai - ${taskPrompt}`, async () => {
1728
- await page.waitForLoadState("networkidle");
1729
+ await waitForNetworkIdle(page);
1729
1730
  const actionType = (opts == null ? void 0 : opts.type) || "action";
1730
1731
  const result = await agent.ai(taskPrompt, actionType);
1731
1732
  resolve(result);
@@ -1739,7 +1740,7 @@ var PlaywrightAiFixture = () => {
1739
1740
  const agent = agentForPage(page, testInfo);
1740
1741
  await use(async (taskPrompt) => {
1741
1742
  import_test.test.step(`aiAction - ${taskPrompt}`, async () => {
1742
- await page.waitForLoadState("networkidle");
1743
+ await waitForNetworkIdle(page);
1743
1744
  await agent.aiAction(taskPrompt);
1744
1745
  });
1745
1746
  });
@@ -1750,7 +1751,7 @@ var PlaywrightAiFixture = () => {
1750
1751
  await use(async (demand) => {
1751
1752
  return new Promise((resolve, reject) => {
1752
1753
  import_test.test.step(`aiQuery - ${JSON.stringify(demand)}`, async () => {
1753
- await page.waitForLoadState("networkidle");
1754
+ await waitForNetworkIdle(page);
1754
1755
  const result = await agent.aiQuery(demand);
1755
1756
  resolve(result);
1756
1757
  });
@@ -1763,7 +1764,7 @@ var PlaywrightAiFixture = () => {
1763
1764
  await use(async (assertion, errorMsg) => {
1764
1765
  return new Promise((resolve, reject) => {
1765
1766
  import_test.test.step(`aiAssert - ${assertion}`, async () => {
1766
- await page.waitForLoadState("networkidle");
1767
+ await waitForNetworkIdle(page);
1767
1768
  await agent.aiAssert(assertion, errorMsg);
1768
1769
  resolve(null);
1769
1770
  });
@@ -1785,6 +1786,13 @@ var PlaywrightAiFixture = () => {
1785
1786
  }
1786
1787
  };
1787
1788
  };
1789
+ function waitForNetworkIdle(page) {
1790
+ const timeout = 20 * 1e3;
1791
+ return Promise.race([
1792
+ page.waitForLoadState("networkidle"),
1793
+ new Promise((resolve) => setTimeout(resolve, timeout))
1794
+ ]);
1795
+ }
1788
1796
 
1789
1797
  // src/puppeteer/base-page.ts
1790
1798
  var import_node_fs3 = require("fs");
@@ -1817,8 +1825,7 @@ var Page = class {
1817
1825
  const path3 = (0, import_utils7.getTmpFile)("jpeg");
1818
1826
  await this.page.screenshot({
1819
1827
  path: path3,
1820
- type: "jpeg",
1821
- quality: 75
1828
+ type: "png"
1822
1829
  });
1823
1830
  let buf;
1824
1831
  if (viewportSize.deviceScaleFactor > 1) {
@@ -1955,7 +1962,7 @@ function getNodeAttributes2(node) {
1955
1962
  }
1956
1963
  return attrs;
1957
1964
  }
1958
- function getRect(attributes) {
1965
+ function getRect2(attributes) {
1959
1966
  var _a, _b, _c, _d;
1960
1967
  const x = Math.round(Number.parseFloat((_a = attributes.x) != null ? _a : "0"));
1961
1968
  const y = Math.round(Number.parseFloat((_b = attributes.y) != null ? _b : "0"));
@@ -2043,7 +2050,7 @@ function extractTextWithPosition2(initNode) {
2043
2050
  }
2044
2051
  function collectElementInfo(node) {
2045
2052
  const attributes = getNodeAttributes2(node);
2046
- const rect = getRect(attributes);
2053
+ const rect = getRect2(attributes);
2047
2054
  const nodeHashId = midsceneGenerateHash(attributes.placeholder, rect);
2048
2055
  const text = validTextNodeContent(node);
2049
2056
  let nodeType;
@@ -2090,7 +2097,6 @@ function extractTextWithPosition2(initNode) {
2090
2097
  Math.round(rect.top + rect.height / 2)
2091
2098
  ],
2092
2099
  nodeType,
2093
- htmlNode: null,
2094
2100
  nodePath: ""
2095
2101
  };
2096
2102
  if (elementInfo.nodeType !== import_constants2.NodeType.CONTAINER) {
@@ -2311,6 +2317,11 @@ async function generateExtractData(page, targetDir, saveImgType) {
2311
2317
  inputImgBase64
2312
2318
  });
2313
2319
  const resizeImgBase64 = await (0, import_img5.resizeImg)(inputImgBase64);
2320
+ const existingSnapshot = (0, import_node_fs5.existsSync)(snapshotJsonPath) ? JSON.parse((0, import_node_fs5.readFileSync)(snapshotJsonPath, "utf-8")) : null;
2321
+ if (existingSnapshot && JSON.stringify(existingSnapshot) === JSON.stringify(captureElementSnapshot)) {
2322
+ console.log("skip save snapshot for ", targetDir);
2323
+ return;
2324
+ }
2314
2325
  if (!(saveImgType == null ? void 0 : saveImgType.disableSnapshot)) {
2315
2326
  writeFileSyncWithDir(
2316
2327
  snapshotJsonPath,
@@ -676,6 +676,7 @@ var PageTaskExecutor = class {
676
676
  let locateResult;
677
677
  const callAI = this.insight.aiVendorFn;
678
678
  const element = await this.insight.locate(param.prompt, {
679
+ quickAnswer: plan2.quickAnswer,
679
680
  callAI: async (...message) => {
680
681
  if (locateCache) {
681
682
  locateResult = locateCache;
@@ -1203,7 +1204,7 @@ var PlaywrightAiFixture = () => {
1203
1204
  async (taskPrompt, opts) => {
1204
1205
  return new Promise((resolve, reject) => {
1205
1206
  import_test.test.step(`ai - ${taskPrompt}`, async () => {
1206
- await page.waitForLoadState("networkidle");
1207
+ await waitForNetworkIdle(page);
1207
1208
  const actionType = (opts == null ? void 0 : opts.type) || "action";
1208
1209
  const result = await agent.ai(taskPrompt, actionType);
1209
1210
  resolve(result);
@@ -1217,7 +1218,7 @@ var PlaywrightAiFixture = () => {
1217
1218
  const agent = agentForPage(page, testInfo);
1218
1219
  await use(async (taskPrompt) => {
1219
1220
  import_test.test.step(`aiAction - ${taskPrompt}`, async () => {
1220
- await page.waitForLoadState("networkidle");
1221
+ await waitForNetworkIdle(page);
1221
1222
  await agent.aiAction(taskPrompt);
1222
1223
  });
1223
1224
  });
@@ -1228,7 +1229,7 @@ var PlaywrightAiFixture = () => {
1228
1229
  await use(async (demand) => {
1229
1230
  return new Promise((resolve, reject) => {
1230
1231
  import_test.test.step(`aiQuery - ${JSON.stringify(demand)}`, async () => {
1231
- await page.waitForLoadState("networkidle");
1232
+ await waitForNetworkIdle(page);
1232
1233
  const result = await agent.aiQuery(demand);
1233
1234
  resolve(result);
1234
1235
  });
@@ -1241,7 +1242,7 @@ var PlaywrightAiFixture = () => {
1241
1242
  await use(async (assertion, errorMsg) => {
1242
1243
  return new Promise((resolve, reject) => {
1243
1244
  import_test.test.step(`aiAssert - ${assertion}`, async () => {
1244
- await page.waitForLoadState("networkidle");
1245
+ await waitForNetworkIdle(page);
1245
1246
  await agent.aiAssert(assertion, errorMsg);
1246
1247
  resolve(null);
1247
1248
  });
@@ -1263,6 +1264,13 @@ var PlaywrightAiFixture = () => {
1263
1264
  }
1264
1265
  };
1265
1266
  };
1267
+ function waitForNetworkIdle(page) {
1268
+ const timeout = 20 * 1e3;
1269
+ return Promise.race([
1270
+ page.waitForLoadState("networkidle"),
1271
+ new Promise((resolve) => setTimeout(resolve, timeout))
1272
+ ]);
1273
+ }
1266
1274
 
1267
1275
  // src/puppeteer/base-page.ts
1268
1276
  var import_node_fs3 = require("fs");
@@ -1295,8 +1303,7 @@ var Page = class {
1295
1303
  const path2 = (0, import_utils7.getTmpFile)("jpeg");
1296
1304
  await this.page.screenshot({
1297
1305
  path: path2,
1298
- type: "jpeg",
1299
- quality: 75
1306
+ type: "png"
1300
1307
  });
1301
1308
  let buf;
1302
1309
  if (viewportSize.deviceScaleFactor > 1) {
@@ -672,6 +672,7 @@ var PageTaskExecutor = class {
672
672
  let locateResult;
673
673
  const callAI = this.insight.aiVendorFn;
674
674
  const element = await this.insight.locate(param.prompt, {
675
+ quickAnswer: plan2.quickAnswer,
675
676
  callAI: async (...message) => {
676
677
  if (locateCache) {
677
678
  locateResult = locateCache;
@@ -1170,8 +1171,7 @@ var Page = class {
1170
1171
  const path2 = (0, import_utils7.getTmpFile)("jpeg");
1171
1172
  await this.page.screenshot({
1172
1173
  path: path2,
1173
- type: "jpeg",
1174
- quality: 75
1174
+ type: "png"
1175
1175
  });
1176
1176
  let buf;
1177
1177
  if (viewportSize.deviceScaleFactor > 1) {