testdriverai 4.1.9 → 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 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 || "";
@@ -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/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
- return parseBody(response, result);
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
- if (!silent) {
70
- emitter.emit(events.screenCapture.end, {
71
- scale,
72
- display: primaryDisplay,
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
- if (!silent) {
78
- emitter.emit(events.screenCapture.error, {
79
- error,
80
- scale,
81
- display: primaryDisplay,
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "4.1.9",
3
+ "version": "4.1.10",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {