testdriverai 4.1.43 → 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 +22 -16
- package/lib/commands.js +1 -4
- package/lib/generator.js +10 -4
- package/lib/sdk.js +1 -1
- package/lib/session.js +3 -1
- package/package.json +1 -1
package/agent.js
CHANGED
|
@@ -202,8 +202,11 @@ if (!commandHistory.length) {
|
|
|
202
202
|
];
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
const exit = async (failed = true) => {
|
|
206
|
-
|
|
205
|
+
const exit = async (failed = true, shouldSave = false) => {
|
|
206
|
+
|
|
207
|
+
if (shouldSave) {
|
|
208
|
+
await save();
|
|
209
|
+
}
|
|
207
210
|
|
|
208
211
|
analytics.track("exit", { failed });
|
|
209
212
|
|
|
@@ -641,6 +644,16 @@ const actOnMarkdown = async (content, depth, pushToHistory = false) => {
|
|
|
641
644
|
// simple function to backfill the chat history with a prompt and
|
|
642
645
|
// then call `promptUser()` to get the user input
|
|
643
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
|
+
|
|
644
657
|
// readline is what allows us to get user input
|
|
645
658
|
rl = readline.createInterface({
|
|
646
659
|
terminal: true,
|
|
@@ -681,7 +694,7 @@ const firstPrompt = async () => {
|
|
|
681
694
|
if (input.indexOf("/summarize") == 0) {
|
|
682
695
|
await summarize();
|
|
683
696
|
} else if (input.indexOf("/quit") == 0) {
|
|
684
|
-
await exit();
|
|
697
|
+
await exit(false, true);
|
|
685
698
|
} else if (input.indexOf("/save") == 0) {
|
|
686
699
|
await save({ filepath: commands[1] });
|
|
687
700
|
} else if (input.indexOf("/undo") == 0) {
|
|
@@ -705,7 +718,7 @@ const firstPrompt = async () => {
|
|
|
705
718
|
// if file exists, load it
|
|
706
719
|
if (fs.existsSync(thisFile)) {
|
|
707
720
|
analytics.track("load");
|
|
708
|
-
let object = await generator.
|
|
721
|
+
let object = await generator.hydrateFromYML(
|
|
709
722
|
fs.readFileSync(thisFile, "utf-8"),
|
|
710
723
|
);
|
|
711
724
|
|
|
@@ -835,7 +848,7 @@ let save = async ({ filepath = thisFile, silent = false } = {}) => {
|
|
|
835
848
|
}
|
|
836
849
|
|
|
837
850
|
// write reply to /tmp/oiResult.log.log
|
|
838
|
-
let regression = await generator.
|
|
851
|
+
let regression = await generator.dumpToYML(executionHistory);
|
|
839
852
|
try {
|
|
840
853
|
fs.writeFileSync(filepath, regression);
|
|
841
854
|
} catch (e) {
|
|
@@ -862,9 +875,10 @@ ${regression}
|
|
|
862
875
|
// this will load a regression test from a file location
|
|
863
876
|
// it parses the markdown file and executes the codeblocks exactly as if they were
|
|
864
877
|
// generated by the AI in a single prompt
|
|
865
|
-
let run = async (file,
|
|
878
|
+
let run = async (file, shouldSave = false, shouldExit = true) => {
|
|
866
879
|
|
|
867
880
|
setTerminalWindowTransparency(true);
|
|
881
|
+
emitter.emit(events.interactive, false);
|
|
868
882
|
|
|
869
883
|
log.log("info", chalk.cyan(`running ${file}...`));
|
|
870
884
|
|
|
@@ -934,11 +948,12 @@ ${yaml.dump(step)}
|
|
|
934
948
|
await actOnMarkdown(markdown, 0, true);
|
|
935
949
|
}
|
|
936
950
|
|
|
937
|
-
if (
|
|
951
|
+
if (shouldSave || shouldSave == "true") {
|
|
938
952
|
await save({ filepath: file });
|
|
939
953
|
}
|
|
940
954
|
|
|
941
955
|
setTerminalWindowTransparency(false);
|
|
956
|
+
emitter.emit(events.interactive, true);
|
|
942
957
|
|
|
943
958
|
if (shouldExit || shouldExit == "true") {
|
|
944
959
|
await summarize();
|
|
@@ -1056,15 +1071,6 @@ const start = async () => {
|
|
|
1056
1071
|
console.log("");
|
|
1057
1072
|
}
|
|
1058
1073
|
|
|
1059
|
-
// should be start of new session
|
|
1060
|
-
const sessionRes = await sdk.req("session/start", {
|
|
1061
|
-
systemInformationOsInfo: await system.getSystemInformationOsInfo(),
|
|
1062
|
-
mousePosition: await system.getMousePosition(),
|
|
1063
|
-
activeWindow: await system.activeWin(),
|
|
1064
|
-
});
|
|
1065
|
-
|
|
1066
|
-
session.set(sessionRes.data);
|
|
1067
|
-
|
|
1068
1074
|
analytics.track("command", { command: thisCommand, file: thisFile });
|
|
1069
1075
|
|
|
1070
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 = "
|
|
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
|
|
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
|
|
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
|
-
|
|
74
|
-
|
|
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()
|
|
109
|
+
session: session.get(),
|
|
110
110
|
stream: typeof onChunk === "function",
|
|
111
111
|
},
|
|
112
112
|
};
|
package/lib/session.js
CHANGED