testdriverai 4.1.9 → 4.1.11
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/agent.js +3 -0
- package/electron/overlay.html +10 -4
- package/lib/redraw.js +15 -22
- package/lib/sdk.js +13 -3
- package/lib/system.js +14 -13
- package/package.json +1 -1
package/agent.js
CHANGED
|
@@ -646,6 +646,8 @@ const firstPrompt = async () => {
|
|
|
646
646
|
// notice that the AI is only called if the input is not a command
|
|
647
647
|
rl.on("line", async (input) => {
|
|
648
648
|
if (!isInteractive) return;
|
|
649
|
+
if (!input.trim().length) return promptUser();
|
|
650
|
+
|
|
649
651
|
emitter.emit(events.interactive, false);
|
|
650
652
|
await setTerminalApp();
|
|
651
653
|
// setTerminalWindowTransparency(true);
|
|
@@ -936,6 +938,7 @@ const promptUser = () => {
|
|
|
936
938
|
};
|
|
937
939
|
|
|
938
940
|
const setTerminalApp = async () => {
|
|
941
|
+
if (terminalApp) return;
|
|
939
942
|
let win = await system.activeWin();
|
|
940
943
|
if (process.platform === "win32") {
|
|
941
944
|
terminalApp = win?.title || "";
|
package/electron/overlay.html
CHANGED
|
@@ -151,10 +151,10 @@
|
|
|
151
151
|
|
|
152
152
|
#terminal-wrapper {
|
|
153
153
|
position: absolute;
|
|
154
|
-
left: calc(100vw -
|
|
154
|
+
left: calc(100vw - 700px);
|
|
155
155
|
top: 0px;
|
|
156
156
|
height: 100vh;
|
|
157
|
-
width:
|
|
157
|
+
width: 700px;
|
|
158
158
|
background: black;
|
|
159
159
|
opacity: 0;
|
|
160
160
|
z-index: -1;
|
|
@@ -228,12 +228,18 @@
|
|
|
228
228
|
|
|
229
229
|
|
|
230
230
|
ipcRenderer.on(events.screenCapture.start, (event, data) => {
|
|
231
|
+
if (data?.silent) return
|
|
231
232
|
// Hide everything whlie the app takes the screenshot
|
|
232
|
-
|
|
233
233
|
container.style.opacity = 0;
|
|
234
234
|
});
|
|
235
235
|
|
|
236
|
+
ipcRenderer.on(events.screenCapture.error, (event, data) => {
|
|
237
|
+
if (data?.silent) return
|
|
238
|
+
container.style.opacity = 1
|
|
239
|
+
});
|
|
240
|
+
|
|
236
241
|
ipcRenderer.on(events.screenCapture.end, (event, data) => {
|
|
242
|
+
if (data?.silent) return
|
|
237
243
|
screenshotElement.classList.remove('screenshot');
|
|
238
244
|
// Force reflow
|
|
239
245
|
void screenshotElement.offsetWidth;
|
|
@@ -299,4 +305,4 @@
|
|
|
299
305
|
</script>
|
|
300
306
|
</body>
|
|
301
307
|
|
|
302
|
-
</html>
|
|
308
|
+
</html>
|
package/lib/redraw.js
CHANGED
|
@@ -7,14 +7,17 @@ const { compare } = require("odiff-bin");
|
|
|
7
7
|
const si = require('systeminformation');
|
|
8
8
|
const chalk = require('chalk');
|
|
9
9
|
|
|
10
|
-
const networkCooldownMs = 5000;
|
|
11
10
|
const redrawThresholdPercent = 3;
|
|
11
|
+
const networkUpdateInterval = 2000;
|
|
12
12
|
|
|
13
13
|
let lastTxBytes = null;
|
|
14
14
|
let lastRxBytes = null;
|
|
15
|
+
|
|
16
|
+
let diffRxBytes = 0;
|
|
17
|
+
let diffTxBytes = 0;
|
|
18
|
+
|
|
15
19
|
let measurements = [];
|
|
16
20
|
let networkSettled = true;
|
|
17
|
-
let lastUnsettled = null;
|
|
18
21
|
let screenHasRedrawn = null;
|
|
19
22
|
|
|
20
23
|
async function resetState() {
|
|
@@ -22,7 +25,6 @@ async function resetState() {
|
|
|
22
25
|
lastRxBytes = null;
|
|
23
26
|
measurements = [];
|
|
24
27
|
networkSettled = true;
|
|
25
|
-
lastUnsettled = null;
|
|
26
28
|
screenHasRedrawn = false;
|
|
27
29
|
}
|
|
28
30
|
|
|
@@ -31,8 +33,8 @@ async function updateNetwork() {
|
|
|
31
33
|
let thisRxBytes = data[0].rx_bytes;
|
|
32
34
|
let thisTxBytes = data[0].tx_bytes;
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
diffRxBytes = lastRxBytes !== null ? thisRxBytes - lastRxBytes : 0;
|
|
37
|
+
diffTxBytes = lastTxBytes !== null ? thisTxBytes - lastTxBytes : 0;
|
|
36
38
|
|
|
37
39
|
lastRxBytes = thisRxBytes;
|
|
38
40
|
lastTxBytes = thisTxBytes;
|
|
@@ -52,20 +54,11 @@ async function updateNetwork() {
|
|
|
52
54
|
let zIndexRx = stdDevRx !== 0 ? (diffRxBytes - avgRx) / stdDevRx : 0;
|
|
53
55
|
let zIndexTx = stdDevTx !== 0 ? (diffTxBytes - avgTx) / stdDevTx : 0;
|
|
54
56
|
|
|
55
|
-
// log time since unsettlement
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
networkSettled = false;
|
|
57
|
+
// log time since unsettlement
|
|
58
|
+
if ((zIndexRx < 0 && zIndexTx < 0) ) {
|
|
59
|
+
networkSettled = true;
|
|
59
60
|
} else {
|
|
60
|
-
|
|
61
|
-
if ((zIndexRx < 0 && zIndexTx < 0) ) {
|
|
62
|
-
lastUnsettled = null;
|
|
63
|
-
networkSettled = true;
|
|
64
|
-
} else {
|
|
65
|
-
lastUnsettled = new Date().getTime();
|
|
66
|
-
networkSettled = false;
|
|
67
|
-
}
|
|
68
|
-
|
|
61
|
+
networkSettled = false;
|
|
69
62
|
}
|
|
70
63
|
|
|
71
64
|
if (process.env["DEV"]) {
|
|
@@ -125,11 +118,11 @@ async function checkCondition(resolve, startTime, timeoutMs) {
|
|
|
125
118
|
if (!screenHasRedrawn) {
|
|
126
119
|
diffPercent = await imageDiffPercent(startImage, nowImage);
|
|
127
120
|
screenHasRedrawn = diffPercent > redrawThresholdPercent;
|
|
128
|
-
}
|
|
129
|
-
|
|
121
|
+
};
|
|
122
|
+
|
|
130
123
|
// // log redraw as output
|
|
131
124
|
let redrawText = screenHasRedrawn ? chalk.green(`y`) : chalk.dim(`${diffPercent}/${redrawThresholdPercent}%`);
|
|
132
|
-
let networkText = networkSettled ? chalk.green(`y`) : chalk.dim(`${Math.
|
|
125
|
+
let networkText = networkSettled ? chalk.green(`y`) : chalk.dim(`${Math.trunc((diffRxBytes + diffTxBytes) / networkUpdateInterval)}b/s`);
|
|
133
126
|
let timeoutText = isTimeout ? chalk.green(`y`) : chalk.dim(`${Math.floor((timeElapsed)/1000)}/${(timeoutMs / 1000)}s`);
|
|
134
127
|
|
|
135
128
|
console.log(` `, chalk.dim('redraw='), redrawText, chalk.dim('network='), networkText, chalk.dim('timeout='), timeoutText);
|
|
@@ -150,6 +143,6 @@ function wait(timeoutMs) {
|
|
|
150
143
|
});
|
|
151
144
|
}
|
|
152
145
|
|
|
153
|
-
setInterval(updateNetwork,
|
|
146
|
+
setInterval(updateNetwork, networkUpdateInterval);
|
|
154
147
|
|
|
155
148
|
module.exports = { start, wait };
|
package/lib/sdk.js
CHANGED
|
@@ -128,9 +128,12 @@ const req = async (path, data, onChunk) => {
|
|
|
128
128
|
if (onChunk) {
|
|
129
129
|
result = "";
|
|
130
130
|
let lastLineIndex = -1;
|
|
131
|
-
const reader = response.body.getReader();
|
|
131
|
+
const reader = response.clone().body.getReader();
|
|
132
132
|
while (true) {
|
|
133
|
-
const { done, value } = await reader.read()
|
|
133
|
+
const { done, value } = await reader.read().catch((err) => {
|
|
134
|
+
console.error("Body read failed with error:", err);
|
|
135
|
+
return { done: true };
|
|
136
|
+
});
|
|
134
137
|
if (done) {
|
|
135
138
|
break;
|
|
136
139
|
}
|
|
@@ -165,7 +168,14 @@ const req = async (path, data, onChunk) => {
|
|
|
165
168
|
}
|
|
166
169
|
}
|
|
167
170
|
|
|
168
|
-
|
|
171
|
+
const value = await parseBody(response, result);
|
|
172
|
+
if (!value) {
|
|
173
|
+
throw new Error("Unexpected empty response body");
|
|
174
|
+
}
|
|
175
|
+
if (!path.includes("analytics") && !("data" in value)) {
|
|
176
|
+
throw new Error("Missing data property in response body");
|
|
177
|
+
}
|
|
178
|
+
return value;
|
|
169
179
|
} catch (error) {
|
|
170
180
|
await outputError(error);
|
|
171
181
|
}
|
package/lib/system.js
CHANGED
|
@@ -38,6 +38,7 @@ const captureAndResize = async (scale = 1, silent = false) => {
|
|
|
38
38
|
if (!silent) {
|
|
39
39
|
emitter.emit(events.screenCapture.start, {
|
|
40
40
|
scale,
|
|
41
|
+
silent,
|
|
41
42
|
display: primaryDisplay,
|
|
42
43
|
});
|
|
43
44
|
}
|
|
@@ -66,21 +67,21 @@ const captureAndResize = async (scale = 1, silent = false) => {
|
|
|
66
67
|
// composite the mouse image ontop
|
|
67
68
|
.composite([{ input: cursorPath, left: mousePos.x, top: mousePos.y }])
|
|
68
69
|
.toFile(step2);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
70
|
+
|
|
71
|
+
emitter.emit(events.screenCapture.end, {
|
|
72
|
+
scale,
|
|
73
|
+
silent,
|
|
74
|
+
display: primaryDisplay,
|
|
75
|
+
});
|
|
76
|
+
|
|
75
77
|
return step2;
|
|
76
78
|
} catch (error) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
79
|
+
emitter.emit(events.screenCapture.error, {
|
|
80
|
+
error,
|
|
81
|
+
scale,
|
|
82
|
+
silent,
|
|
83
|
+
display: primaryDisplay,
|
|
84
|
+
});
|
|
84
85
|
throw error;
|
|
85
86
|
}
|
|
86
87
|
};
|