testdriverai 5.7.36 → 5.7.37

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.
Files changed (2) hide show
  1. package/agent.js +29 -32
  2. package/package.json +1 -1
package/agent.js CHANGED
@@ -225,7 +225,6 @@ const haveAIResolveError = async (
225
225
  undo = true,
226
226
  shouldSave,
227
227
  ) => {
228
-
229
228
  if (error.fatal) {
230
229
  return await dieOnFatal(error);
231
230
  }
@@ -234,7 +233,7 @@ const haveAIResolveError = async (
234
233
 
235
234
  let safeKey = JSON.stringify(eMessage);
236
235
  errorCounts[safeKey] = errorCounts[safeKey] ? errorCounts[safeKey] + 1 : 1;
237
-
236
+
238
237
  logger.error(chalk.red("Error detected"));
239
238
 
240
239
  log.prettyMarkdown(eMessage);
@@ -383,7 +382,6 @@ const executeCommands = async (
383
382
  ) => {
384
383
  if (commands?.length) {
385
384
  for (const command of commands) {
386
-
387
385
  if (pushToHistory) {
388
386
  executionHistory[executionHistory.length - 1]?.commands.push(command);
389
387
  }
@@ -754,17 +752,10 @@ const actOnMarkdown = async (
754
752
  };
755
753
 
756
754
  const ensureMacScreenPerms = async () => {
757
-
758
755
  // if os is mac, check for screen capture permissions
759
- if (
760
- !config.TD_OVERLAY_ID &&
761
- !config.TD_VM &&
762
- process.platform === "darwin"
763
- ) {
764
-
756
+ if (!config.TD_OVERLAY_ID && !config.TD_VM && process.platform === "darwin") {
765
757
  const macScreenPerms = require("mac-screen-capture-permissions");
766
758
  if (!macScreenPerms.hasScreenCapturePermission()) {
767
-
768
759
  logger.info(chalk.red("Screen capture permissions not enabled."));
769
760
  logger.info(
770
761
  "You must enable screen capture permissions for this terminal application within System Settings.",
@@ -774,16 +765,13 @@ const ensureMacScreenPerms = async () => {
774
765
  );
775
766
  analytics.track("noMacPermissions");
776
767
  return exit();
777
-
778
768
  }
779
-
780
769
  }
781
770
  };
782
771
 
783
772
  // simple function to backfill the chat history with a prompt and
784
773
  // then call `promptUser()` to get the user input
785
774
  const firstPrompt = async () => {
786
-
787
775
  // readline is what allows us to get user input
788
776
  rl = readline.createInterface({
789
777
  terminal: true,
@@ -879,7 +867,12 @@ const firstPrompt = async () => {
879
867
  logger.error(result.error.result.stdout);
880
868
  }
881
869
  } else {
882
- await exploratoryLoop(input.replace(/^\/explore\s+/, ""), false, true, true );
870
+ await exploratoryLoop(
871
+ input.replace(/^\/explore\s+/, ""),
872
+ false,
873
+ true,
874
+ true,
875
+ );
883
876
  }
884
877
 
885
878
  setTerminalWindowTransparency(false);
@@ -907,15 +900,13 @@ const firstPrompt = async () => {
907
900
  let yml = fs.readFileSync(thisFile, "utf-8");
908
901
 
909
902
  if (yml) {
910
-
911
903
  let markdown = `\`\`\`yaml
912
904
  ${yml}\`\`\``;
913
-
905
+
914
906
  logger.info(`Loaded test script ${thisFile}\n`);
915
907
  log.prettyMarkdown(markdown);
916
- logger.info("New commands will be appended.")
917
- console.log('')
918
-
908
+ logger.info("New commands will be appended.");
909
+ console.log("");
919
910
  }
920
911
  }
921
912
 
@@ -1068,7 +1059,12 @@ let runRawYML = async (yml) => {
1068
1059
  // this will load a regression test from a file location
1069
1060
  // it parses the markdown file and executes the codeblocks exactly as if they were
1070
1061
  // generated by the AI in a single prompt
1071
- let run = async (file = thisFile, shouldSave = false, shouldExit = true, pushToHistory = true) => {
1062
+ let run = async (
1063
+ file = thisFile,
1064
+ shouldSave = false,
1065
+ shouldExit = true,
1066
+ pushToHistory = true,
1067
+ ) => {
1072
1068
  setTerminalWindowTransparency(true);
1073
1069
  emitter.emit(events.interactive, false);
1074
1070
 
@@ -1079,10 +1075,12 @@ let run = async (file = thisFile, shouldSave = false, shouldExit = true, pushToH
1079
1075
  if (ymlObj.version) {
1080
1076
  let valid = isValidVersion(ymlObj.version);
1081
1077
  if (!valid) {
1082
- console.log("")
1078
+ console.log("");
1083
1079
  logger.warn(chalk.red(`Version mismatch detected!`));
1084
1080
  logger.warn(chalk.red(`Running a test created with v${ymlObj.version}.`));
1085
- logger.warn(chalk.red(`The current testdriverai version is v${package.version}.`));
1081
+ logger.warn(
1082
+ chalk.red(`The current testdriverai version is v${package.version}.`),
1083
+ );
1086
1084
  }
1087
1085
  }
1088
1086
 
@@ -1106,7 +1104,6 @@ let run = async (file = thisFile, shouldSave = false, shouldExit = true, pushToH
1106
1104
  logger.info(chalk.yellow("No commands found, running exploratory"));
1107
1105
  await exploratoryLoop(step.prompt, false, true, false);
1108
1106
  } else {
1109
-
1110
1107
  let markdown = `\`\`\`yaml
1111
1108
  ${yaml.dump(step)}
1112
1109
  \`\`\``;
@@ -1118,7 +1115,6 @@ ${yaml.dump(step)}
1118
1115
  await actOnMarkdown(markdown, 0, true, false, shouldSave);
1119
1116
  }
1120
1117
 
1121
-
1122
1118
  if (shouldSave) {
1123
1119
  await save({ silent: true });
1124
1120
  }
@@ -1207,7 +1203,6 @@ const buildEnv = async () => {
1207
1203
  };
1208
1204
 
1209
1205
  const start = async () => {
1210
-
1211
1206
  let a = getArgs();
1212
1207
 
1213
1208
  thisFile = a.file;
@@ -1223,14 +1218,10 @@ const start = async () => {
1223
1218
  // make testdriver directory if it doesn't exist
1224
1219
  let testdriverFolder = path.join(workingDir, "testdriver");
1225
1220
  if (!fs.existsSync(testdriverFolder)) {
1226
-
1227
1221
  fs.mkdirSync(testdriverFolder);
1228
1222
  // log
1229
1223
  logger.info(chalk.dim(`Created testdriver directory`));
1230
- console.log(
1231
- chalk.dim(`Created testdriver directory: ${testdriverFolder}`),
1232
- );
1233
-
1224
+ console.log(chalk.dim(`Created testdriver directory: ${testdriverFolder}`));
1234
1225
  }
1235
1226
 
1236
1227
  // if the directory for thisFile doesn't exist, create it
@@ -1258,7 +1249,7 @@ const start = async () => {
1258
1249
  logger.info(chalk.dim(`Working on ${thisFile}`));
1259
1250
  console.log("");
1260
1251
 
1261
- loadYML(thisFile)
1252
+ loadYML(thisFile);
1262
1253
 
1263
1254
  if (!config.TD_VM) {
1264
1255
  logger.info(
@@ -1343,6 +1334,12 @@ const newSession = async () => {
1343
1334
  activeWindow: await system.activeWin(),
1344
1335
  });
1345
1336
 
1337
+ if (!sessionRes) {
1338
+ throw new Error(
1339
+ "Unable to start TestDriver session. Check your network connection or restart the CLI.",
1340
+ );
1341
+ }
1342
+
1346
1343
  session.set(sessionRes.data.id);
1347
1344
  };
1348
1345
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "5.7.36",
3
+ "version": "5.7.37",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {