testdriverai 4.0.13 → 4.0.15

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/index.js +25 -15
  2. package/package.json +2 -1
package/index.js CHANGED
@@ -16,6 +16,7 @@ const http = require('http');
16
16
  const path = require('path');
17
17
  const chalk = require('chalk')
18
18
  const yaml = require('js-yaml');
19
+ const macScreenPerms = require('mac-screen-capture-permissions');
19
20
 
20
21
  // local modules
21
22
  const speak = require('./lib/speak');
@@ -72,8 +73,8 @@ let getArgs = () => {
72
73
  }
73
74
 
74
75
  // turn args[file] into local path
75
- if (args[file] && args[file].indexOf('/') == -file) {
76
- args[file] = `${__dirname}/${args[file]}`
76
+ if (args[file]) {
77
+ args[file] = `${process.cwd()}/${args[file]}`
77
78
  if (!args[file].endsWith('.yml')) {
78
79
  args[file] += '.yml';
79
80
  }
@@ -88,20 +89,12 @@ const thisFile = a.file;
88
89
  const thisCommand = a.command;
89
90
 
90
91
  log.log('info', chalk.green(`Howdy! I'm TestDriver v${package.version}`))
92
+ log.log('info', chalk.dim(`Working on ${thisFile}`))
91
93
  console.log('')
92
94
  log.log('info', `Join our Discord for help`);
93
95
  log.log('info', chalk.yellow(`https://discord.com/invite/cWDFW8DzPm`));
94
96
  console.log('')
95
97
 
96
- if (a.command !== 'run') {
97
- speak('Howdy! I am TestDriver version ' + package.version);
98
-
99
- console.log(chalk.red('Warning!') + chalk.dim(' TestDriver sends screenshots of the desktop to our API.'));
100
- console.log(chalk.dim('https://docs.testdriver.ai/security-and-privacy/agent'));
101
- console.log('')
102
-
103
- }
104
-
105
98
  // individual run ID for this session
106
99
  let runID = new Date().getTime();
107
100
 
@@ -134,8 +127,8 @@ const exit = async (failed = true) => {
134
127
 
135
128
  // we purposly never resolve this promise so the process will hang
136
129
  return new Promise(async () => {
137
- rl.close()
138
- rl.removeAllListeners()
130
+ rl?.close()
131
+ rl?.removeAllListeners()
139
132
  process.exit(failed ? 1 : 0);
140
133
  });
141
134
  }
@@ -826,6 +819,25 @@ const embed = async (file, depth) => {
826
819
 
827
820
  // await sdk.auth();
828
821
 
822
+
823
+ // if os is mac, check for screen capture permissions
824
+ if (process.platform === 'darwin' && !macScreenPerms.hasScreenCapturePermission()) {
825
+ log.log('info', chalk.red('Screen capture permissions not enabled.'))
826
+ log.log('info', 'You must enable screen capture permissions for the application calling `testdriverai`.')
827
+ log.log('info', 'Read More: https://docs.testdriver.ai/faq/screen-recording-permissions-mac-only')
828
+ analytics.track('noMacPermissions');
829
+ return exit();
830
+ }
831
+
832
+ if (thisCommand !== 'run') {
833
+ speak('Howdy! I am TestDriver version ' + package.version);
834
+
835
+ console.log(chalk.red('Warning!') + chalk.dim(' TestDriver sends screenshots of the desktop to our API.'));
836
+ console.log(chalk.dim('https://docs.testdriver.ai/security-and-privacy/agent'));
837
+ console.log('')
838
+
839
+ }
840
+
829
841
  let win = await system.activeWin();
830
842
  terminalApp = win?.owner?.name || "";
831
843
 
@@ -855,7 +867,6 @@ process.on('uncaughtException', async (err) => {
855
867
  analytics.track('uncaughtException', {err});
856
868
  console.error('Uncaught Exception:', err);
857
869
  // You might want to exit the process after handling the error
858
- await summarize(err);
859
870
  await exit(true);
860
871
  });
861
872
 
@@ -863,6 +874,5 @@ process.on('unhandledRejection', async (reason, promise) => {
863
874
  analytics.track('unhandledRejection', {reason, promise});
864
875
  console.error('Unhandled Rejection at:', promise, 'reason:', reason);
865
876
  // Optionally, you might want to exit the process
866
- await summarize(reason)
867
877
  await exit(true);
868
878
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "4.0.13",
3
+ "version": "4.0.15",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -26,6 +26,7 @@
26
26
  "dotenv": "^16.4.5",
27
27
  "jimp": "^0.22.12",
28
28
  "js-yaml": "^4.1.0",
29
+ "mac-screen-capture-permissions": "^2.1.0",
29
30
  "markdown-parser": "0.0.8",
30
31
  "marked": "^12.0.1",
31
32
  "marked-terminal": "^7.0.0",