testdriverai 4.1.8 → 4.1.10
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 +8 -11
- package/electron/overlay.html +8 -2
- package/lib/redraw.js +3 -3
- package/lib/sdk.js +13 -3
- package/lib/system.js +14 -13
- package/package.json +1 -1
package/agent.js
CHANGED
|
@@ -62,6 +62,11 @@ let rl;
|
|
|
62
62
|
// list of prompts that the user has given us
|
|
63
63
|
let tasks = [];
|
|
64
64
|
|
|
65
|
+
let isInteractive = false;
|
|
66
|
+
emitter.on(events.interactive, (data) => {
|
|
67
|
+
isInteractive = data;
|
|
68
|
+
});
|
|
69
|
+
|
|
65
70
|
// get args from terminal
|
|
66
71
|
const args = process.argv.slice(2);
|
|
67
72
|
|
|
@@ -641,6 +646,8 @@ const firstPrompt = async () => {
|
|
|
641
646
|
// notice that the AI is only called if the input is not a command
|
|
642
647
|
rl.on("line", async (input) => {
|
|
643
648
|
if (!isInteractive) return;
|
|
649
|
+
if (!input.trim().length) return promptUser();
|
|
650
|
+
|
|
644
651
|
emitter.emit(events.interactive, false);
|
|
645
652
|
await setTerminalApp();
|
|
646
653
|
// setTerminalWindowTransparency(true);
|
|
@@ -931,6 +938,7 @@ const promptUser = () => {
|
|
|
931
938
|
};
|
|
932
939
|
|
|
933
940
|
const setTerminalApp = async () => {
|
|
941
|
+
if (terminalApp) return;
|
|
934
942
|
let win = await system.activeWin();
|
|
935
943
|
if (process.platform === "win32") {
|
|
936
944
|
terminalApp = win?.title || "";
|
|
@@ -991,17 +999,6 @@ const embed = async (file, depth) => {
|
|
|
991
999
|
log.log("info", `${file} (end)`);
|
|
992
1000
|
};
|
|
993
1001
|
|
|
994
|
-
let isInteractive = false;
|
|
995
|
-
emitter.on(events.interactive, (data) => {
|
|
996
|
-
isInteractive = data;
|
|
997
|
-
if (!terminalApp) return;
|
|
998
|
-
if (isInteractive) {
|
|
999
|
-
showTerminal(terminalApp);
|
|
1000
|
-
} else {
|
|
1001
|
-
hideTerminal(terminalApp);
|
|
1002
|
-
}
|
|
1003
|
-
});
|
|
1004
|
-
|
|
1005
1002
|
(async () => {
|
|
1006
1003
|
// console.log(await system.getPrimaryDisplay());
|
|
1007
1004
|
|
package/electron/overlay.html
CHANGED
|
@@ -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
|
@@ -128,9 +128,9 @@ async function checkCondition(resolve, startTime, timeoutMs) {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
// // log redraw as output
|
|
131
|
-
let redrawText = screenHasRedrawn ? chalk.green(
|
|
132
|
-
let networkText = networkSettled ? chalk.green(
|
|
133
|
-
let timeoutText = isTimeout ? chalk.green(
|
|
131
|
+
let redrawText = screenHasRedrawn ? chalk.green(`y`) : chalk.dim(`${diffPercent}/${redrawThresholdPercent}%`);
|
|
132
|
+
let networkText = networkSettled ? chalk.green(`y`) : chalk.dim(`${Math.floor((networkCooldownMs - (Date.now() - lastUnsettled)) / 1000)}/${Math.floor(networkCooldownMs/1000)}s`);
|
|
133
|
+
let timeoutText = isTimeout ? chalk.green(`y`) : chalk.dim(`${Math.floor((timeElapsed)/1000)}/${(timeoutMs / 1000)}s`);
|
|
134
134
|
|
|
135
135
|
console.log(` `, chalk.dim('redraw='), redrawText, chalk.dim('network='), networkText, chalk.dim('timeout='), timeoutText);
|
|
136
136
|
|
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
|
};
|