testdriverai 4.1.44 → 4.1.45

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
@@ -644,6 +644,16 @@ const actOnMarkdown = async (content, depth, pushToHistory = false) => {
644
644
  // simple function to backfill the chat history with a prompt and
645
645
  // then call `promptUser()` to get the user input
646
646
  const firstPrompt = async () => {
647
+
648
+ // should be start of new session
649
+ const sessionRes = await sdk.req("session/start", {
650
+ systemInformationOsInfo: await system.getSystemInformationOsInfo(),
651
+ mousePosition: await system.getMousePosition(),
652
+ activeWindow: await system.activeWin(),
653
+ });
654
+
655
+ session.set(sessionRes.data.id);
656
+
647
657
  // readline is what allows us to get user input
648
658
  rl = readline.createInterface({
649
659
  terminal: true,
@@ -708,7 +718,7 @@ const firstPrompt = async () => {
708
718
  // if file exists, load it
709
719
  if (fs.existsSync(thisFile)) {
710
720
  analytics.track("load");
711
- let object = await generator.ymlToHistory(
721
+ let object = await generator.hydrateFromYML(
712
722
  fs.readFileSync(thisFile, "utf-8"),
713
723
  );
714
724
 
@@ -838,7 +848,7 @@ let save = async ({ filepath = thisFile, silent = false } = {}) => {
838
848
  }
839
849
 
840
850
  // write reply to /tmp/oiResult.log.log
841
- let regression = await generator.historyToYml(executionHistory);
851
+ let regression = await generator.dumpToYML(executionHistory);
842
852
  try {
843
853
  fs.writeFileSync(filepath, regression);
844
854
  } catch (e) {
@@ -868,6 +878,7 @@ ${regression}
868
878
  let run = async (file, shouldSave = false, shouldExit = true) => {
869
879
 
870
880
  setTerminalWindowTransparency(true);
881
+ emitter.emit(events.interactive, false);
871
882
 
872
883
  log.log("info", chalk.cyan(`running ${file}...`));
873
884
 
@@ -942,6 +953,7 @@ ${yaml.dump(step)}
942
953
  }
943
954
 
944
955
  setTerminalWindowTransparency(false);
956
+ emitter.emit(events.interactive, true);
945
957
 
946
958
  if (shouldExit || shouldExit == "true") {
947
959
  await summarize();
@@ -1059,15 +1071,6 @@ const start = async () => {
1059
1071
  console.log("");
1060
1072
  }
1061
1073
 
1062
- // should be start of new session
1063
- const sessionRes = await sdk.req("session/start", {
1064
- systemInformationOsInfo: await system.getSystemInformationOsInfo(),
1065
- mousePosition: await system.getMousePosition(),
1066
- activeWindow: await system.activeWin(),
1067
- });
1068
-
1069
- session.set(sessionRes.data);
1070
-
1071
1074
  analytics.track("command", { command: thisCommand, file: thisFile });
1072
1075
 
1073
1076
  if (thisCommand == "edit") {
package/lib/commands.js CHANGED
@@ -160,15 +160,12 @@ const assert = async (assertion, shouldThrow = false, async = false) => {
160
160
  return handleAssertResponse(response.data);
161
161
  }
162
162
  };
163
- const scroll = async (direction = "down", amount = 300, method = "keyboard") => {
163
+ const scroll = async (direction = "down", amount = 300, method = "mouse") => {
164
164
  await redraw.start();
165
165
 
166
166
  amount = parseInt(amount);
167
167
 
168
168
  if (method === "mouse") {
169
- // after experimenting, 200 is a good default for mouse, mostly as mouse will be called only when the user asks for it
170
- // and that happens when keyboard scrolling cannot do things when there's a pop up that needs to be scrolled over and
171
- // pop ups are usually smaller and needs a smaller amount of scrolling
172
169
  amount = 200;
173
170
  }
174
171
 
package/lib/generator.js CHANGED
@@ -2,6 +2,7 @@
2
2
  const yaml = require("js-yaml");
3
3
  const chalk = require("chalk");
4
4
  const package = require("../package.json");
5
+ const session = require("./session");
5
6
  // do the actual parsing
6
7
  // this library is very strict
7
8
  // note that errors are sent to the AI will it may self-heal
@@ -52,25 +53,30 @@ const jsonToManual = function (json, colors = true) {
52
53
  return params;
53
54
  };
54
55
 
55
- const historyToYml = async function (inputArray) {
56
+ const dumpToYML = async function (inputArray) {
57
+
56
58
  // use yml dump to convert json to yml
57
59
  let yml = await yaml.dump({
58
60
  version: package.version,
61
+ session: session.get(),
59
62
  steps: inputArray,
60
63
  });
61
64
 
62
65
  return yml;
63
66
  };
64
67
 
65
- const ymlToHistory = async function (yml) {
68
+ const hydrateFromYML = async function (yml) {
66
69
  // use yml load to convert yml to json
67
70
  let json = await yaml.load(yml);
71
+
72
+ session.set(json.session);
73
+
68
74
  return json;
69
75
  };
70
76
 
71
77
  module.exports = {
72
78
  manualToYml,
73
- historyToYml,
74
- ymlToHistory,
79
+ dumpToYML,
80
+ hydrateFromYML,
75
81
  jsonToManual,
76
82
  };
package/lib/sdk.js CHANGED
@@ -106,7 +106,7 @@ const req = async (path, data, onChunk) => {
106
106
  responseType: typeof onChunk === "function" ? "stream" : "json",
107
107
  data: {
108
108
  ...data,
109
- session: session.get()?.id,
109
+ session: session.get(),
110
110
  stream: typeof onChunk === "function",
111
111
  },
112
112
  };
package/lib/session.js CHANGED
@@ -5,6 +5,8 @@ module.exports = {
5
5
  return session;
6
6
  },
7
7
  set: (s) => {
8
- session = s;
8
+ if (s) {
9
+ session = s;
10
+ }
9
11
  },
10
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "4.1.44",
3
+ "version": "4.1.45",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {