testdriverai 4.2.4 → 4.2.5
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 +16 -7
- package/package.json +1 -1
package/agent.js
CHANGED
|
@@ -203,7 +203,7 @@ if (!commandHistory.length) {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
const exit = async (failed = true, shouldSave = false) => {
|
|
206
|
-
|
|
206
|
+
|
|
207
207
|
if (shouldSave) {
|
|
208
208
|
await save();
|
|
209
209
|
}
|
|
@@ -641,9 +641,7 @@ const actOnMarkdown = async (content, depth, pushToHistory = false) => {
|
|
|
641
641
|
}
|
|
642
642
|
};
|
|
643
643
|
|
|
644
|
-
|
|
645
|
-
// then call `promptUser()` to get the user input
|
|
646
|
-
const firstPrompt = async () => {
|
|
644
|
+
const newSession = async () => {
|
|
647
645
|
|
|
648
646
|
// should be start of new session
|
|
649
647
|
const sessionRes = await sdk.req("session/start", {
|
|
@@ -654,6 +652,14 @@ const firstPrompt = async () => {
|
|
|
654
652
|
|
|
655
653
|
session.set(sessionRes.data.id);
|
|
656
654
|
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
// simple function to backfill the chat history with a prompt and
|
|
658
|
+
// then call `promptUser()` to get the user input
|
|
659
|
+
const firstPrompt = async () => {
|
|
660
|
+
|
|
661
|
+
await newSession();
|
|
662
|
+
|
|
657
663
|
// readline is what allows us to get user input
|
|
658
664
|
rl = readline.createInterface({
|
|
659
665
|
terminal: true,
|
|
@@ -718,6 +724,8 @@ const firstPrompt = async () => {
|
|
|
718
724
|
// if file exists, load it
|
|
719
725
|
if (fs.existsSync(thisFile)) {
|
|
720
726
|
analytics.track("load");
|
|
727
|
+
|
|
728
|
+
// this will overwrite the session if we find one in the YML
|
|
721
729
|
let object = await generator.hydrateFromYML(
|
|
722
730
|
fs.readFileSync(thisFile, "utf-8"),
|
|
723
731
|
);
|
|
@@ -836,6 +844,7 @@ let summarize = async (error = null) => {
|
|
|
836
844
|
|
|
837
845
|
// this function is responsible for saving the regression test script to a file
|
|
838
846
|
let save = async ({ filepath = thisFile, silent = false } = {}) => {
|
|
847
|
+
|
|
839
848
|
analytics.track("save", { silent });
|
|
840
849
|
|
|
841
850
|
if (!silent) {
|
|
@@ -877,6 +886,8 @@ ${regression}
|
|
|
877
886
|
// generated by the AI in a single prompt
|
|
878
887
|
let run = async (file, shouldSave = false, shouldExit = true) => {
|
|
879
888
|
|
|
889
|
+
await newSession();
|
|
890
|
+
|
|
880
891
|
setTerminalWindowTransparency(true);
|
|
881
892
|
emitter.emit(events.interactive, false);
|
|
882
893
|
|
|
@@ -898,10 +909,8 @@ let run = async (file, shouldSave = false, shouldExit = true) => {
|
|
|
898
909
|
await exit(true);
|
|
899
910
|
}
|
|
900
911
|
|
|
901
|
-
let interpolationVars = JSON.parse(process.env["TD_INTERPOLATION_VARS"] || '{}');
|
|
902
|
-
|
|
903
912
|
// Inject environment variables into any ${VAR} strings
|
|
904
|
-
yml = parser.interpolate(yml,
|
|
913
|
+
yml = parser.interpolate(yml, process.env);
|
|
905
914
|
|
|
906
915
|
let ymlObj = null;
|
|
907
916
|
try {
|