testdriverai 5.1.1 → 5.1.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
@@ -31,7 +31,7 @@ const sanitizeFilename = require("sanitize-filename");
31
31
  const macScreenPerms = require("mac-screen-capture-permissions");
32
32
 
33
33
  // local modules
34
- const wss = require("./lib/websockets.js");
34
+ const websocketserver = require("./lib/websockets.js");
35
35
  const speak = require("./lib/speak.js");
36
36
  const analytics = require("./lib/analytics.js");
37
37
  const log = require("./lib/logger.js");
@@ -63,6 +63,7 @@ let checkCount = 0;
63
63
  let checkLimit = 7;
64
64
  let lastScreenshot = null;
65
65
  let rl;
66
+ let wss;
66
67
 
67
68
  // list of prompts that the user has given us
68
69
  let tasks = [];
@@ -837,7 +838,7 @@ const firstPrompt = async () => {
837
838
 
838
839
  rl.on("line", handleInput);
839
840
 
840
- wss.addEventListener("input", async (message) => {
841
+ config.TD_VM && wss.addEventListener("input", async (message) => {
841
842
  handleInput(message.data);
842
843
  });
843
844
 
@@ -1081,7 +1082,7 @@ ${yaml.dump(step)}
1081
1082
  };
1082
1083
 
1083
1084
  const promptUser = () => {
1084
- wss.sendToClients("done");
1085
+ config.TD_VM && wss.sendToClients("done");
1085
1086
  emitter.emit(events.interactive, true);
1086
1087
  rl.prompt(true);
1087
1088
  };
@@ -1144,6 +1145,9 @@ const embed = async (file, depth) => {
1144
1145
 
1145
1146
  const buildEnv = async () => {
1146
1147
  let win = await system.activeWin();
1148
+ if (config.TD_VM) {
1149
+ wss = websocketserver.create();
1150
+ }
1147
1151
  setTerminalApp(win);
1148
1152
  await ensureMacScreenPerms();
1149
1153
  await makeSandbox();
package/lib/logger.js CHANGED
@@ -10,6 +10,7 @@ const shouldLog =
10
10
  // responsible for rendering ai markdown output
11
11
  const { marked } = require("marked");
12
12
  const { markedTerminal } = require("marked-terminal");
13
+ const { config } = require("dotenv");
13
14
 
14
15
  const { printf } = winston.format;
15
16
 
@@ -84,7 +85,9 @@ const createMarkdownStreamLogger = () => {
84
85
  return;
85
86
  }
86
87
 
87
- websockets.sendToClients("output", chunk);
88
+ if (config.TD_VM) {
89
+ websockets.sendToClients("output", chunk);
90
+ }
88
91
 
89
92
  const previousConsoleOutput = markedParsePartial(buffer, 0, -1);
90
93
 
package/lib/speak.js CHANGED
@@ -6,7 +6,6 @@ const websockets = require("./websockets");
6
6
  module.exports = (message) => {
7
7
  if (config["TD_SPEAK"]) {
8
8
  say.stop();
9
- // websockets.sendToClients("output", message);
10
9
  if (process.platform === "darwin") {
11
10
  say.speak(message, "Fred", 1.2);
12
11
  } else {
package/lib/websockets.js CHANGED
@@ -1,7 +1,10 @@
1
1
  const WebSocket = require('ws');
2
+ const config = require('./config');
2
3
 
4
+ let instance;
3
5
  class WebSocketServerSingleton {
4
6
  constructor() {
7
+
5
8
  if (!WebSocketServerSingleton.instance) {
6
9
  this.wss = new WebSocket.Server({ port: 8080 }, () => {
7
10
  });
@@ -72,7 +75,11 @@ class WebSocketServerSingleton {
72
75
  }
73
76
  }
74
77
 
75
- const instance = new WebSocketServerSingleton();
76
- Object.freeze(instance);
77
78
 
78
- module.exports = instance;
79
+ module.exports = {
80
+ create: () => {
81
+ instance = new WebSocketServerSingleton();
82
+ Object.freeze(instance);
83
+ return instance;
84
+ }
85
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "5.1.1",
3
+ "version": "5.1.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": {