testdriverai 4.0.74 → 4.0.75

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/index.js CHANGED
@@ -57,7 +57,8 @@ let executionHistory = [];
57
57
  let errorCounts = {};
58
58
  let errorLimit = 3;
59
59
  let checkCount = 0;
60
- let checkLimit = 10;
60
+ let checkLimit = 3;
61
+ let lastScreenshot = null;
61
62
  let rl;
62
63
 
63
64
  // list of prompts that the user has given us
@@ -279,11 +280,17 @@ const check = async () => {
279
280
 
280
281
  console.log("");
281
282
  log.log("info", chalk.dim("checking..."), "testdriver");
282
- let image = await system.captureScreenBase64();
283
+
284
+ let thisScreenshot =await system.captureScreenBase64();
285
+ let images = [lastScreenshot, thisScreenshot];
283
286
  let mousePosition = await system.getMousePosition();
284
287
  let activeWindow = await system.activeWin();
285
288
 
286
- return await sdk.req("check", { tasks, image, mousePosition, activeWindow });
289
+ let response = await sdk.req("check", { tasks, images, mousePosition, activeWindow });
290
+
291
+ lastScreenshot = thisScreenshot;
292
+
293
+ return response;
287
294
  };
288
295
 
289
296
  // command is transformed from a single yml entry generated by the AI into a JSON object
@@ -458,7 +465,8 @@ const humanInput = async (currentTask, validateAndLoop = false) => {
458
465
 
459
466
  log.log("info", "");
460
467
 
461
- let image = await system.captureScreenBase64();
468
+ lastScreenshot = await system.captureScreenBase64();
469
+
462
470
  const mdStream = log.createMarkdownStreamLogger();
463
471
  let message = await sdk.req(
464
472
  "input",
@@ -466,7 +474,7 @@ const humanInput = async (currentTask, validateAndLoop = false) => {
466
474
  input: currentTask,
467
475
  mousePosition: await system.getMousePosition(),
468
476
  activeWindow: await system.activeWin(),
469
- image,
477
+ image: lastScreenshot,
470
478
  },
471
479
  (chunk) => mdStream.log(chunk),
472
480
  );
package/lib/redraw.js CHANGED
@@ -12,8 +12,9 @@ let measurements = [];
12
12
  let networkSettled = true;
13
13
  let lastUnsettled = null;
14
14
  let watchNetwork = null;
15
+ let screenHasRedrawn = null;
15
16
 
16
- async function resetNetwork() {
17
+ async function resetState() {
17
18
  lastTxBytes = null;
18
19
  lastRxBytes = null;
19
20
  measurements = [];
@@ -87,7 +88,7 @@ async function imageIsDifferent(image1Url, image2Url) {
87
88
  tmpImage,
88
89
  {
89
90
  failOnLayoutDiff: false,
90
- outputDiffMask: false,
91
+ outputDiffMask: false
91
92
  },
92
93
  );
93
94
 
@@ -95,7 +96,7 @@ async function imageIsDifferent(image1Url, image2Url) {
95
96
  return false;
96
97
  } else {
97
98
  if (reason === "pixel-diff") {
98
- if (diffPercentage > 15) {
99
+ if (diffPercentage > 5) {
99
100
  return true;
100
101
  } else {
101
102
  return false;
@@ -109,26 +110,43 @@ async function imageIsDifferent(image1Url, image2Url) {
109
110
  let startImage = null;
110
111
 
111
112
  async function start() {
112
- resetNetwork();
113
+ resetState();
113
114
  watchNetwork = setInterval(updateNetwork, 500);
114
115
  startImage = await captureScreenPNG();
115
116
  return startImage;
116
117
  }
117
118
 
118
119
  async function checkCondition(resolve, startTime, timeoutMs) {
120
+
119
121
  let nowImage = await captureScreenPNG();
120
- let screenDiff = await imageIsDifferent(startImage, nowImage);
122
+ let timeElapsed = Date.now() - startTime;
123
+
124
+ if (!screenHasRedrawn) {
125
+ screenHasRedrawn = await imageIsDifferent(startImage, nowImage);
126
+ }
121
127
 
122
- if (screenDiff && networkSettled) {
128
+ if (screenHasRedrawn && networkSettled) {
123
129
  clearInterval(watchNetwork);
124
130
  resolve("Condition met");
125
- } else if (Date.now() - startTime >= timeoutMs) {
131
+ } else if (Date.now() - timeElapsed > timeoutMs) {
126
132
  clearInterval(watchNetwork);
127
133
  resolve("Timeout reached");
128
134
  } else {
135
+
136
+ if (timeElapsed > 3000) {
137
+
138
+ if (!screenHasRedrawn) {
139
+ console.log(chalk.dim(` waiting for screen redraw...`));
140
+ }
141
+ if (!networkSettled) {
142
+ console.log(chalk.dim(` waiting for network to settle...`));
143
+ }
144
+
145
+ }
146
+
129
147
  setTimeout(() => {
130
148
  checkCondition(resolve, startTime, timeoutMs);
131
- }, 250);
149
+ }, 1000);
132
150
  }
133
151
  }
134
152
 
package/lib/system.js CHANGED
@@ -37,6 +37,10 @@ const captureAndResize = async (scale = 1) => {
37
37
  let step1 = tmpFilename();
38
38
  let step2 = tmpFilename();
39
39
 
40
+ if (process.env["DEV"]) {
41
+ console.log(step2)
42
+ }
43
+
40
44
  await screenshot({ filename: step1, format: "png" });
41
45
 
42
46
  // resize to 1:1 px ratio
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "4.0.74",
3
+ "version": "4.0.75",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {