testdriverai 5.0.0-beta.8 → 5.0.2

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
@@ -130,8 +130,9 @@ const thisCommand = a.command;
130
130
  logger.info(chalk.green(`Howdy! I'm TestDriver v${package.version}`));
131
131
  logger.info(chalk.dim(`Working on ${thisFile}`));
132
132
  logger.info("");
133
- logger.info(chalk.yellow(`This is beta software!`));
134
- logger.info(`Join our Discord for help`);
133
+ logger.info(`This is beta software!`);
134
+ logger.info("");
135
+ logger.info(chalk.yellow(`Join our Discord for help`));
135
136
  logger.info(`https://discord.com/invite/cWDFW8DzPm`);
136
137
  logger.info("");
137
138
 
@@ -1145,14 +1146,17 @@ const start = async () => {
1145
1146
  if (thisCommand !== "run") {
1146
1147
  speak("Howdy! I am TestDriver version " + package.version);
1147
1148
 
1148
- logger.info(
1149
- chalk.red("Warning!") +
1150
- chalk.dim(" TestDriver sends screenshots of the desktop to our API."),
1151
- );
1152
- logger.info(
1153
- chalk.dim("https://docs.testdriver.ai/security-and-privacy/agent"),
1154
- );
1155
- logger.info("");
1149
+ if (!config.TD_VM) {
1150
+ logger.info(
1151
+ chalk.red("Warning!") +
1152
+ chalk.dim("Local mode sends screenshots of the desktop to our API."),
1153
+ );
1154
+ logger.info(
1155
+ chalk.dim("https://docs.testdriver.ai/security-and-privacy/agent"),
1156
+ );
1157
+ logger.info("");
1158
+ }
1159
+
1156
1160
  }
1157
1161
 
1158
1162
  analytics.track("command", { command: thisCommand, file: thisFile });
@@ -1174,23 +1178,31 @@ const makeSandbox = async () => {
1174
1178
 
1175
1179
  if (config.TD_VM) {
1176
1180
 
1177
- logger.info(chalk.gray(`- creating linux sandbox...`));
1178
- await sandbox.boot();
1179
- logger.info(chalk.gray(`- authenticating...`));
1180
- await sandbox.send({type: 'authenticate', apiKey: config.TD_API_KEY });
1181
- logger.info(chalk.gray(`- setting up...`));
1182
- await sandbox.send({type: 'create', resolution: [1024, 768]});
1183
- logger.info(chalk.gray(`- starting stream...`));
1184
- await sandbox.send({type: 'stream.start'});
1185
- let {url} = await sandbox.send({type: 'stream.getUrl'});
1186
- logger.info(chalk.gray(`- rendering...`));
1187
- await sandbox.send({type: 'ready'});
1188
- emitter.emit(events.vm.show, {url});
1189
- logger.info(chalk.gray(`- booting...`));
1190
- await new Promise(resolve => setTimeout(resolve, 3000));
1191
- logger.info(chalk.green(``));
1192
- logger.info(chalk.green(`sandbox runner ready!`));
1181
+ try {
1193
1182
 
1183
+ logger.info(chalk.gray(`- creating linux sandbox...`));
1184
+ await sandbox.boot();
1185
+ logger.info(chalk.gray(`- authenticating...`));
1186
+ await sandbox.send({type: 'authenticate', apiKey: config.TD_API_KEY });
1187
+ logger.info(chalk.gray(`- setting up...`));
1188
+ await sandbox.send({type: 'create', resolution: [1024, 768]});
1189
+ logger.info(chalk.gray(`- starting stream...`));
1190
+ await sandbox.send({type: 'stream.start'});
1191
+ let {url} = await sandbox.send({type: 'stream.getUrl'});
1192
+ logger.info(chalk.gray(`- rendering...`));
1193
+ await sandbox.send({type: 'ready'});
1194
+ emitter.emit(events.vm.show, {url});
1195
+ logger.info(chalk.gray(`- booting...`));
1196
+ await new Promise(resolve => setTimeout(resolve, 3000));
1197
+ logger.info(chalk.green(``));
1198
+ logger.info(chalk.green(`sandbox runner ready!`));
1199
+
1200
+ } catch (e) {
1201
+ logger.error(e)
1202
+ logger.error(chalk.red(`sandbox runner failed to start`));
1203
+ process.exit(1);
1204
+ }
1205
+
1194
1206
  }
1195
1207
 
1196
1208
  emitter.emit(events.interactive, false);
@@ -48,10 +48,10 @@ app.whenReady().then(() => {
48
48
  autoHideMenuBar: true,
49
49
  };
50
50
 
51
- }
51
+ if (process.platform !== 'darwin') {
52
+ windowOptions.fullscreen = true;
53
+ }
52
54
 
53
- if (process.platform !== 'darwin') {
54
- windowOptions.fullscreen = true;
55
55
  }
56
56
 
57
57
  const window = new BrowserWindow(windowOptions);
package/lib/commands.js CHANGED
@@ -10,7 +10,6 @@ const {
10
10
 
11
11
  const { focusApplication } = require("./focus-application");
12
12
  const fs = require("fs").promises; // Using the promises version for async operations
13
- const robot = require("robotjs");
14
13
  const { findTemplateImage } = require("./subimage/index");
15
14
  const { cwd } = require("node:process");
16
15
  const path = require("path");
@@ -20,11 +19,13 @@ const cliProgress = require("cli-progress");
20
19
  const redraw = require("./redraw");
21
20
  const sandbox = require("./sandbox.js");
22
21
  const config = require("./config.js");
22
+ let robot;
23
23
 
24
24
  let keymap;
25
25
  if (config.TD_VM) {
26
26
  keymap = require("./keymaps/sandbox.js");
27
27
  } else {
28
+ robot = require("robotjs");
28
29
  keymap = require("./keymaps/robot.js");
29
30
  }
30
31
 
package/lib/config.js CHANGED
@@ -26,7 +26,7 @@ const config = {
26
26
  TD_ANALYTICS: true,
27
27
  TD_NOTIFY: false,
28
28
  TD_MINIMIZE: true,
29
- TD_API_ROOT: "https://replayable-api-production.herokuapp.com",
29
+ TD_API_ROOT: "https://api.testdriver.ai",
30
30
  TD_API_KEY: null,
31
31
  TD_DEV: parseValue(process.env["DEV"]),
32
32
  TD_PROFILE: false,
@@ -3,9 +3,14 @@ const path = require("path");
3
3
  const { execSync } = require("child_process");
4
4
  const { platform } = require("./system");
5
5
  const scriptPath = path.join(__dirname, "focusWindow.ps1");
6
- const robot = require("robotjs");
7
6
  const { logger } = require("./logger");
8
7
  const sandbox = require("./sandbox");
8
+ const config = require("./config.js");
9
+ let robot;
10
+
11
+ if (!config.TD_VM) {
12
+ robot = require("robotjs");
13
+ }
9
14
 
10
15
  async function focusVSCode() {
11
16
 
package/lib/sandbox.js CHANGED
@@ -28,12 +28,18 @@ class Sandbox {
28
28
  this.socket = new WebSocket(`${config.TD_API_ROOT.replace('https://', 'wss://')}`);
29
29
 
30
30
  // handle errors
31
+ this.socket.on('close', (err) => {
32
+ console.log('Socket Closed. Check your API KEY (TD_API_KEY)');
33
+ clearInterval(this.heartbeat);
34
+ reject();
35
+ process.exit(1);
36
+ });
37
+
31
38
  this.socket.on('error', (err) => {
32
- console.log('Socket Closed');
33
- console.log('If this happens during setup, check your API Key (`TD_API_KEY` in `.env`).');
39
+ console.log('Socket Error');
34
40
  err && console.log(err);
35
41
  clearInterval(this.heartbeat);
36
- reject();
42
+ throw err;
37
43
  });
38
44
 
39
45
  this.socket.on('open', async () => {
package/lib/system.js CHANGED
@@ -3,11 +3,15 @@ const fs = require("fs");
3
3
  const os = require("os");
4
4
  const path = require("path");
5
5
  const si = require("systeminformation");
6
- const robot = require("robotjs");
7
6
  const sharp = require("sharp");
8
7
  const { emitter, events } = require("./events.js");
9
8
  const sandbox = require("./sandbox.js");
10
9
  const config = require("./config.js");
10
+ let robot;
11
+
12
+ if (!config.TD_VM) {
13
+ robot = require("robotjs");
14
+ }
11
15
 
12
16
  let scshotdesk;
13
17
  if (!config.TD_VM) {
@@ -179,7 +183,7 @@ const activeWin = async () => {
179
183
 
180
184
  const getMousePosition = async () => {
181
185
  // @todo vm does expose mouse position, add it back
182
- return config.TD_VM ? await robot.getMousePos() : null;
186
+ return !config.TD_VM ? await robot.getMousePos() : null;
183
187
  };
184
188
 
185
189
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "5.0.0-beta.8",
3
+ "version": "5.0.2",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {
package/postinstall.js CHANGED
@@ -1,5 +1,7 @@
1
1
  let platform = require("os").platform();
2
2
  let exec = require("child_process").exec;
3
+ const { execSync } = require("child_process");
4
+ const readline = require("readline");
3
5
 
4
6
  if (platform !== "darwin") {
5
7
  console.log("TestDriver Setup: Skipping codesign becasue not on Mac");
@@ -18,3 +20,25 @@ exec(signScript, (error, stdout, stderr) => {
18
20
  console.log(`stdout: ${stdout}`);
19
21
  console.error(`stderr: ${stderr}`);
20
22
  });
23
+
24
+ const rl = readline.createInterface({
25
+ input: process.stdin,
26
+ output: process.stdout
27
+ });
28
+
29
+ rl.question("Do you want to install Vue support? (y/n) ", (answer) => {
30
+ if (answer.toLowerCase() === "y") {
31
+ console.log("Installing Vue dependencies...");
32
+ execSync("npm install -g vue vue-router", { stdio: "inherit" });
33
+ }
34
+
35
+ rl.question("Do you want to install React support? (y/n) ", (answer2) => {
36
+ if (answer2.toLowerCase() === "y") {
37
+ console.log("Installing React dependencies...");
38
+ execSync("npm install -g react react-dom", { stdio: "inherit" });
39
+ }
40
+
41
+ console.log("Setup complete!");
42
+ rl.close();
43
+ });
44
+ });