testdriverai 5.1.0 → 5.1.1

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
@@ -691,6 +691,26 @@ const actOnMarkdown = async (content, depth, pushToHistory = false, dry = false)
691
691
  }
692
692
  };
693
693
 
694
+ const ensureMacScreenPerms = async () => {
695
+
696
+ // if os is mac, check for screen capture permissions
697
+ if (
698
+ !config.TD_VM &&
699
+ process.platform === "darwin" &&
700
+ !macScreenPerms.hasScreenCapturePermission()
701
+ ) {
702
+ logger.info(chalk.red("Screen capture permissions not enabled."));
703
+ logger.info(
704
+ "You must enable screen capture permissions for the application calling `testdriverai`.",
705
+ );
706
+ logger.info(
707
+ "Read More: https://docs.testdriver.ai/faq/screen-recording-permissions-mac-only",
708
+ );
709
+ analytics.track("noMacPermissions");
710
+ return exit();
711
+ }
712
+ }
713
+
694
714
  const newSession = async () => {
695
715
  // should be start of new session
696
716
  const sessionRes = await sdk.req("session/start", {
@@ -1122,6 +1142,13 @@ const embed = async (file, depth) => {
1122
1142
  logger.info(`${file} (end)`);
1123
1143
  };
1124
1144
 
1145
+ const buildEnv = async () => {
1146
+ let win = await system.activeWin();
1147
+ setTerminalApp(win);
1148
+ await ensureMacScreenPerms();
1149
+ await makeSandbox();
1150
+ }
1151
+
1125
1152
  const start = async () => {
1126
1153
  // logger.info(await system.getPrimaryDisplay());
1127
1154
 
@@ -1135,28 +1162,12 @@ const start = async () => {
1135
1162
 
1136
1163
  // await sdk.auth();
1137
1164
 
1138
- // if os is mac, check for screen capture permissions
1139
- if (
1140
- process.platform === "darwin" &&
1141
- !macScreenPerms.hasScreenCapturePermission()
1142
- ) {
1143
- logger.info(chalk.red("Screen capture permissions not enabled."));
1144
- logger.info(
1145
- "You must enable screen capture permissions for the application calling `testdriverai`.",
1146
- );
1147
- logger.info(
1148
- "Read More: https://docs.testdriver.ai/faq/screen-recording-permissions-mac-only",
1149
- );
1150
- analytics.track("noMacPermissions");
1151
- return exit();
1152
- }
1153
-
1154
1165
  if (thisCommand !== "run") {
1155
1166
  speak("Howdy! I am TestDriver version " + package.version);
1156
1167
 
1157
1168
  if (!config.TD_VM) {
1158
1169
  logger.info(
1159
- chalk.red("Warning!") +
1170
+ chalk.red("Warning!" ) +
1160
1171
  chalk.dim("Local mode sends screenshots of the desktop to our API."),
1161
1172
  );
1162
1173
  logger.info(
@@ -1170,11 +1181,11 @@ const start = async () => {
1170
1181
  analytics.track("command", { command: thisCommand, file: thisFile });
1171
1182
 
1172
1183
  if (thisCommand == "edit") {
1173
- await makeSandbox();
1184
+ await buildEnv();
1174
1185
  firstPrompt();
1175
1186
  } else if (thisCommand == "run") {
1187
+ await buildEnv();
1176
1188
  errorLimit = 100;
1177
- await makeSandbox();
1178
1189
  run(thisFile);
1179
1190
  } else if (thisCommand == "init") {
1180
1191
  await init();
package/index.js CHANGED
@@ -10,11 +10,9 @@ if (process.argv[2] === "--help" || process.argv[2] === "-h") {
10
10
  }
11
11
 
12
12
  (async () => {
13
- let win = await system.activeWin();
14
13
 
15
14
  if (!config.TD_OVERLAY) {
16
15
  let agent = require("./agent.js");
17
- agent.setTerminalApp(win);
18
16
  agent.start();
19
17
  } else {
20
18
  // Intercept all stdout and stderr calls (works with console as well)
package/lib/logger.js CHANGED
@@ -19,6 +19,13 @@ const logFormat = printf(({ message }) => {
19
19
 
20
20
  let interpolationVars = JSON.parse(process.env.TD_INTERPOLATION_VARS || '{}');
21
21
 
22
+ // this handles local `TD_*` variables
23
+ for (const [key, value] of Object.entries(process.env)) {
24
+ if (key.startsWith("TD_") && key !== "TD_INTERPOLATION_VARS") {
25
+ interpolationVars[key] = value;
26
+ }
27
+ }
28
+
22
29
  const censorSensitiveData = (message) => {
23
30
  for (let value of Object.values(interpolationVars)) {
24
31
 
package/lib/system.js CHANGED
@@ -171,19 +171,10 @@ const initializeActiveWindow = async () => {
171
171
  const activeWin = async () => {
172
172
 
173
173
  if (config.TD_VM) {
174
-
175
- return "error getting active window, proceed normally";
176
-
174
+ return "error getting active window, proceed normally";
177
175
  } else {
178
-
179
- try {
180
- const activeWindow = await initializeActiveWindow();
181
- return await activeWindow();
182
- } catch (error) {
183
- logger.error('Error getting active window: %s', error);
184
- return null;
185
- }
186
-
176
+ const activeWindow = await initializeActiveWindow();
177
+ return await activeWindow();
187
178
  }
188
179
  };
189
180
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "5.1.0",
3
+ "version": "5.1.1",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {