testdriverai 4.1.26 → 4.1.27

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
@@ -215,11 +215,21 @@ const exit = async (failed = true) => {
215
215
  });
216
216
  };
217
217
 
218
+ const dieOnFatal = async (error) => {
219
+ console.log("");
220
+ log.log("info", chalk.red("Fatal Error") + `\n${error.message}`);
221
+ await summarize(error.message);
222
+ return await exit(true);
223
+ }
224
+
218
225
  // creates a new "thread" in which the AI is given an error
219
226
  // and responds. notice `actOnMarkdown` which will continue
220
227
  // the thread until there are no more codeblocks to execute
221
228
  const haveAIResolveError = async (error, markdown, depth = 0, undo = true) => {
222
-
229
+
230
+ if (thisCommand == "run" || error.fatal) {
231
+ return await dieOnFatal(error);
232
+ }
223
233
 
224
234
  let eMessage = error.message ? error.message : error;
225
235
 
@@ -350,19 +360,12 @@ const runCommand = async (command, depth) => {
350
360
  return await actOnMarkdown(response, depth);
351
361
  }
352
362
  } catch (error) {
353
- if (thisCommand == "run") {
354
- console.log("");
355
- log.log("info", chalk.red("Fatal Error") + `\n${error.message}`);
356
- await summarize(error.message);
357
- return await exit(true);
358
- } else {
359
- return await haveAIResolveError(
360
- error,
361
- yaml.dump({ commands: [yml] }),
362
- depth,
363
- true,
364
- );
365
- }
363
+ return await haveAIResolveError(
364
+ error,
365
+ yaml.dump({ commands: [yml] }),
366
+ depth,
367
+ true,
368
+ );
366
369
  }
367
370
  };
368
371
 
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`);
132
+ throw new AiError(`AI Assertion failed`, true);
133
133
  } else {
134
134
  return false;
135
135
  }
@@ -321,7 +321,7 @@ let commands = {
321
321
  mdStream.end();
322
322
 
323
323
  if (!response?.data) {
324
- throw new AiError("No text on screen matches description", true);
324
+ throw new AiError("No image or icon on screen matches description");
325
325
  } else {
326
326
  return response.data;
327
327
  }
@@ -335,7 +335,7 @@ let commands = {
335
335
  let result = await findImageOnScreen(relativePath, image);
336
336
 
337
337
  if (!result) {
338
- throw new AiError(`Image not found: ${relativePath}`);
338
+ throw new AiError(`Image not found: ${relativePath}`, true);
339
339
  } else {
340
340
  if (action === "click") {
341
341
  await click(result.centerX, result.centerY, action);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "4.1.26",
3
+ "version": "4.1.27",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {