testdriverai 4.1.14 → 4.1.16

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
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+
2
3
  const os = require("os");
3
4
 
4
5
  // Get the current process ID
@@ -217,13 +218,15 @@ const exit = async (failed = true) => {
217
218
  // creates a new "thread" in which the AI is given an error
218
219
  // and responds. notice `actOnMarkdown` which will continue
219
220
  // the thread until there are no more codeblocks to execute
220
- const haveAIResolveError = async (error, markdown, depth = 0, undo = false) => {
221
+ const haveAIResolveError = async (error, markdown, depth = 0, undo = true) => {
222
+
223
+
221
224
  let eMessage = error.message ? error.message : error;
222
225
 
223
226
  let safeKey = JSON.stringify(eMessage);
224
227
  errorCounts[safeKey] = errorCounts[safeKey] ? errorCounts[safeKey] + 1 : 1;
225
228
 
226
- log.log("error", eMessage);
229
+ log.log("debug", eMessage);
227
230
 
228
231
  if (process.env["DEV"]) {
229
232
  console.log(error, eMessage);
@@ -256,11 +259,20 @@ const haveAIResolveError = async (error, markdown, depth = 0, undo = false) => {
256
259
  log.log("info", chalk.dim("thinking..."), true);
257
260
  log.log("info", "");
258
261
 
262
+ const mdStream = log.createMarkdownStreamLogger();
263
+
259
264
  let response = await sdk.req("error", {
260
265
  description: eMessage,
261
266
  markdown,
262
267
  image,
263
- });
268
+ },
269
+ (chunk) => {
270
+ if (chunk.type === "data") {
271
+ mdStream.log(chunk.data);
272
+ }
273
+ },
274
+ );
275
+ mdStream.end();
264
276
 
265
277
  if (response?.data) {
266
278
  return await actOnMarkdown(response.data, depth, true);
package/lib/commands.js CHANGED
@@ -129,7 +129,7 @@ const assert = async (assertion, shouldThrow = false, async = false) => {
129
129
  return true;
130
130
  } else {
131
131
  if (shouldThrow) {
132
- throw new AiError(`AI Assertion failed`, true);
132
+ throw new AiError(`AI Assertion failed`);
133
133
  } else {
134
134
  return false;
135
135
  }
@@ -256,7 +256,7 @@ let commands = {
256
256
  displayMultiple: 1,
257
257
  },
258
258
  (chunk) => {
259
- if (chunk.type === "data") {
259
+ if (chunk.type === "data" && chunk.data) {
260
260
  mdStream.log(chunk.data);
261
261
  } else if (chunk.type === "closeMatches") {
262
262
  emitter.emit(events.matches.show, chunk.data);
@@ -266,7 +266,7 @@ let commands = {
266
266
  mdStream.end();
267
267
 
268
268
  if (!response.data) {
269
- throw new AiError("No text on screen matches description", true);
269
+ throw new AiError("No text on screen matches description");
270
270
  } else {
271
271
  return response.data;
272
272
  }
@@ -295,7 +295,6 @@ let commands = {
295
295
  displayMultiple: 1,
296
296
  },
297
297
  (chunk) => {
298
-
299
298
  if (chunk.type === "data") {
300
299
  mdStream.log(chunk.data);
301
300
  } else if (chunk.type === "closeMatches") {
@@ -48,6 +48,7 @@ async function hideTerminal(appName) {
48
48
  try {
49
49
  if (platform() == "mac") {
50
50
  robot.keyTap('m', ['command']);
51
+ robot.keyToggle('command', 'up')
51
52
  } else if (platform() == "windows") {
52
53
  return runPwsh(appName, "Minimize");
53
54
  }
package/lib/logger.js CHANGED
@@ -48,8 +48,6 @@ const createMarkdownStreamLogger = () => {
48
48
  return {
49
49
  log: (chunk) => {
50
50
  if (typeof chunk !== "string") {
51
- log("error", "markdownStreamLogger's log method requires a string");
52
- log("error", chunk);
53
51
  return;
54
52
  }
55
53
 
package/lib/sdk.js CHANGED
@@ -11,14 +11,7 @@ const log = require('./logger');
11
11
  // let token = null;
12
12
 
13
13
  const outputError = async (error) => {
14
- if (error instanceof Response) {
15
- console.log(chalk.red(error.status), chalk.red(error.statusText));
16
- await parseBody(error)
17
- .then((body) => console.log(chalk.red(JSON.stringify(body, null, 2))))
18
- .catch(() => {});
19
- } else {
20
- console.error("Error:", error);
21
- }
14
+ console.log(chalk.red(error.status), chalk.red(error.statusText));
22
15
  };
23
16
 
24
17
  const parseBody = async (response, body) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "4.1.14",
3
+ "version": "4.1.16",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {