@empiricalrun/test-gen 0.58.0 → 0.60.0
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/CHANGELOG.md +73 -0
- package/dist/agent/browsing/run.d.ts +9 -2
- package/dist/agent/browsing/run.d.ts.map +1 -1
- package/dist/agent/browsing/run.js +30 -30
- package/dist/agent/browsing/utils.d.ts +1 -14
- package/dist/agent/browsing/utils.d.ts.map +1 -1
- package/dist/agent/browsing/utils.js +1 -58
- package/dist/agent/chat/agent-loop.d.ts +2 -1
- package/dist/agent/chat/agent-loop.d.ts.map +1 -1
- package/dist/agent/chat/agent-loop.js +42 -34
- package/dist/agent/chat/exports.d.ts +5 -6
- package/dist/agent/chat/exports.d.ts.map +1 -1
- package/dist/agent/chat/exports.js +13 -42
- package/dist/agent/chat/index.d.ts +2 -1
- package/dist/agent/chat/index.d.ts.map +1 -1
- package/dist/agent/chat/index.js +23 -8
- package/dist/agent/chat/models.d.ts +6 -0
- package/dist/agent/chat/models.d.ts.map +1 -0
- package/dist/agent/chat/models.js +37 -0
- package/dist/agent/chat/prompt.d.ts.map +1 -1
- package/dist/agent/chat/prompt.js +37 -8
- package/dist/agent/chat/state.d.ts +31 -10
- package/dist/agent/chat/state.d.ts.map +1 -1
- package/dist/agent/chat/state.js +132 -27
- package/dist/agent/chat/types.d.ts +2 -3
- package/dist/agent/chat/types.d.ts.map +1 -1
- package/dist/agent/chat/utils.d.ts +14 -0
- package/dist/agent/chat/utils.d.ts.map +1 -0
- package/dist/agent/chat/utils.js +50 -0
- package/dist/agent/master/browser-tests/index.spec.js +6 -6
- package/dist/bin/index.js +12 -2
- package/dist/bin/utils/index.d.ts +1 -0
- package/dist/bin/utils/index.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/test-build/index.js +1 -1
- package/dist/tool-call-service/index.d.ts +2 -1
- package/dist/tool-call-service/index.d.ts.map +1 -1
- package/dist/tool-call-service/index.js +51 -71
- package/dist/tool-call-service/utils.d.ts +10 -0
- package/dist/tool-call-service/utils.d.ts.map +1 -0
- package/dist/tool-call-service/utils.js +23 -0
- package/dist/tools/download-build.d.ts +9 -0
- package/dist/tools/download-build.d.ts.map +1 -1
- package/dist/tools/download-build.js +5 -4
- package/dist/tools/str_replace_editor.d.ts.map +1 -1
- package/dist/tools/str_replace_editor.js +24 -7
- package/dist/tools/test-gen-browser.d.ts.map +1 -1
- package/dist/tools/test-gen-browser.js +26 -19
- package/dist/tools/test-run.d.ts.map +1 -1
- package/dist/tools/test-run.js +8 -13
- package/dist/utils/checkpoint.d.ts.map +1 -1
- package/dist/utils/checkpoint.js +3 -1
- package/dist/utils/exec.d.ts +2 -2
- package/dist/utils/exec.d.ts.map +1 -1
- package/dist/utils/exec.js +5 -4
- package/package.json +5 -4
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,78 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.60.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 296c662: feat: implemented check for tool call existence and tool result non existence for tool execution
|
|
8
|
+
- 255db12: feat: new linear client, Requests api routes, and fetch calls
|
|
9
|
+
- 8544d9d: feat: ChatStateError integration in ChatState for better error handling & retry
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- b183b76: fix: remove tsx config reader in test-gen tool call
|
|
14
|
+
- c4855ff: fix: file view tool does not read binary files
|
|
15
|
+
- f821310: fix: ensure all text editor tools use 1-indexed line numbers
|
|
16
|
+
- 06d3a2a: fix: skippped download build for failed build downloads
|
|
17
|
+
- cff296d: fix: wrap tsx playwright config reader in a try-catch
|
|
18
|
+
- 24d672a: feat: use playwright --list to get project names
|
|
19
|
+
- Updated dependencies [24d672a]
|
|
20
|
+
- @empiricalrun/test-run@0.9.1
|
|
21
|
+
- @empiricalrun/llm@0.16.0
|
|
22
|
+
|
|
23
|
+
## 0.59.0
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- e2b0318: feat: dashboard session migration from CLI working
|
|
28
|
+
- 894c5b5: fix: stricter types for tool call args in canonical message
|
|
29
|
+
- 919e7df: fix: session create, duplicate user message, add Model Options
|
|
30
|
+
- 045e370: feat: stateless build download for tool execution
|
|
31
|
+
- f2d5859: feat: canonical migration for claude and openai
|
|
32
|
+
- e2b0318: feat: migrate dashboard chat sessions to canonical chat state
|
|
33
|
+
- 4d3b46a: feat: migrate to new chat state version in cli run
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- 72f4577: feat: stop marking files as only and move to cmd builder approach
|
|
38
|
+
- 82b3373: test: remove irrelevant or flaky tests
|
|
39
|
+
- 3dbd4ff: fix: remove teardown skip since we interrupt agent with SIGINT
|
|
40
|
+
- 7c77600: refactor: move test-gen file changes to prepare for removal
|
|
41
|
+
- 562c25d: fix: update chat agent system prompt for using try/catch
|
|
42
|
+
- 43656bf: refactor: split tool call execute into 2 methods
|
|
43
|
+
- 51a9975: fix: unit tests for test-gen tool call
|
|
44
|
+
- 772b93c: feat: gemini message transformer into canonical message type
|
|
45
|
+
- 0c935ce: chore: chat model types are moved to shared-types pkg
|
|
46
|
+
- 050fbd3: fix: model selection is ignored while creating a new session
|
|
47
|
+
- ddfd009: fix: refactor chat agent and session list UI
|
|
48
|
+
- 28682e2: feat: use test-run cmd builder in test-gen, remove test.only marking
|
|
49
|
+
- 6b2ed6d: chore: use function args to tell if tool execution is remote
|
|
50
|
+
- 511dbb1: test: skip tests for the old master agent
|
|
51
|
+
- 7145e34: test: add new agent-loop test for openai canonical model
|
|
52
|
+
- 43fb70f: feat: add retry functionality for chat sessions and update ChatAgent …
|
|
53
|
+
- d1d1055: feat: integrate askUserForInput state into session handling
|
|
54
|
+
- ef491c0: fix: incorrect build url getter
|
|
55
|
+
- Updated dependencies [72f4577]
|
|
56
|
+
- Updated dependencies [97cef16]
|
|
57
|
+
- Updated dependencies [e2b0318]
|
|
58
|
+
- Updated dependencies [772b93c]
|
|
59
|
+
- Updated dependencies [894c5b5]
|
|
60
|
+
- Updated dependencies [0c935ce]
|
|
61
|
+
- Updated dependencies [919e7df]
|
|
62
|
+
- Updated dependencies [045e370]
|
|
63
|
+
- Updated dependencies [f2d5859]
|
|
64
|
+
- Updated dependencies [919e7df]
|
|
65
|
+
- Updated dependencies [ddfd009]
|
|
66
|
+
- Updated dependencies [e2b0318]
|
|
67
|
+
- Updated dependencies [28682e2]
|
|
68
|
+
- Updated dependencies [b415e29]
|
|
69
|
+
- Updated dependencies [09291a8]
|
|
70
|
+
- Updated dependencies [aab69ae]
|
|
71
|
+
- Updated dependencies [4d3b46a]
|
|
72
|
+
- Updated dependencies [bc5996d]
|
|
73
|
+
- @empiricalrun/test-run@0.9.0
|
|
74
|
+
- @empiricalrun/llm@0.16.0
|
|
75
|
+
|
|
3
76
|
## 0.58.0
|
|
4
77
|
|
|
5
78
|
### Minor Changes
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
type GenerateTestsType = {
|
|
2
|
+
testCaseName: string;
|
|
3
|
+
testCaseSuites: string[];
|
|
2
4
|
testFilePath: string;
|
|
3
5
|
filePathToUpdate: string;
|
|
4
|
-
|
|
6
|
+
projectName: string;
|
|
5
7
|
testGenToken: string;
|
|
6
8
|
repoDir: string;
|
|
7
9
|
traceId?: string;
|
|
8
10
|
editFileWithGeneratedCode: boolean;
|
|
9
11
|
};
|
|
10
|
-
export declare function
|
|
12
|
+
export declare function convertProjectsFilterToProject({ pwProjectsFilter, repoDir, testFilePath, }: {
|
|
13
|
+
pwProjectsFilter: string[];
|
|
14
|
+
repoDir: string;
|
|
15
|
+
testFilePath: string;
|
|
16
|
+
}): Promise<string>;
|
|
17
|
+
export declare function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, testFilePath, filePathToUpdate, projectName, testGenToken, repoDir, traceId, editFileWithGeneratedCode, }: GenerateTestsType): Promise<{
|
|
11
18
|
isError: boolean;
|
|
12
19
|
error: string;
|
|
13
20
|
actionsSummary?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"AAcA,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yBAAyB,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF,wBAAsB,8BAA8B,CAAC,EACnD,gBAAgB,EAChB,OAAO,EACP,YAAY,GACb,EAAE;IACD,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,MAAM,CAAC,CAQlB;AAED,wBAAsB,6BAA6B,CAAC,EAClD,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,OAAO,EACP,OAAO,EACP,yBAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC,CAiFD"}
|
|
@@ -3,14 +3,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.convertProjectsFilterToProject = convertProjectsFilterToProject;
|
|
6
7
|
exports.generateTestsUsingMasterAgent = generateTestsUsingMasterAgent;
|
|
8
|
+
const test_run_1 = require("@empiricalrun/test-run");
|
|
7
9
|
const detect_port_1 = __importDefault(require("detect-port"));
|
|
8
10
|
const fs_1 = __importDefault(require("fs"));
|
|
9
11
|
const web_1 = require("../../bin/utils/platform/web");
|
|
10
12
|
const server_1 = require("../../file/server");
|
|
11
13
|
const exec_1 = require("../../utils/exec");
|
|
12
14
|
const utils_1 = require("./utils");
|
|
13
|
-
async function
|
|
15
|
+
async function convertProjectsFilterToProject({ pwProjectsFilter, repoDir, testFilePath, }) {
|
|
16
|
+
const playwrightConfig = await (0, utils_1.readPlaywrightConfig)(repoDir);
|
|
17
|
+
const project = await (0, utils_1.detectProjectName)(testFilePath, playwrightConfig, pwProjectsFilter);
|
|
18
|
+
return project;
|
|
19
|
+
}
|
|
20
|
+
async function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, testFilePath, filePathToUpdate, projectName, testGenToken, repoDir, traceId, editFileWithGeneratedCode, }) {
|
|
14
21
|
if (!fs_1.default.existsSync(testFilePath)) {
|
|
15
22
|
throw new Error(`File for master agent to run not found: ${testFilePath}`);
|
|
16
23
|
}
|
|
@@ -26,30 +33,29 @@ async function generateTestsUsingMasterAgent({ testFilePath, filePathToUpdate, p
|
|
|
26
33
|
});
|
|
27
34
|
await fileServer.startFileService();
|
|
28
35
|
fileServer.setFilePath(filePathToUpdate);
|
|
29
|
-
// read playwright config from ./playwright.config.ts of source repo
|
|
30
|
-
const playwrightConfig = await (0, utils_1.readPlaywrightConfig)(repoDir);
|
|
31
|
-
// detect the playwright project name for the given test file and playwright config
|
|
32
|
-
const project = await (0, utils_1.detectProjectName)(testFilePath, playwrightConfig, pwProjectsFilter);
|
|
33
36
|
const pageVar = await (0, web_1.getPageVariableNameFromCreateTest)(filePathToUpdate);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
const testsDir = "tests";
|
|
38
|
+
const cmd = await (0, test_run_1.runSpecificTestsCmd)({
|
|
39
|
+
tests: [
|
|
40
|
+
{
|
|
41
|
+
name: testCaseName,
|
|
42
|
+
dir: testsDir,
|
|
43
|
+
filePath: testFilePath,
|
|
44
|
+
suites: testCaseSuites,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
projects: [projectName],
|
|
48
|
+
passthroughArgs: "--retries 0 --timeout 0",
|
|
49
|
+
//@ts-ignore
|
|
50
|
+
platform: "web",
|
|
51
|
+
});
|
|
52
|
+
let error = undefined;
|
|
44
53
|
try {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
await pm.execute(command.split(" "), {
|
|
54
|
+
console.log(`[generateTestsUsingMasterAgent] Running command: ${cmd.command} ${cmd.args.join(" ")}`);
|
|
55
|
+
await pm.execute(cmd.command, cmd.args, {
|
|
49
56
|
env: {
|
|
50
57
|
IPC_FILE_SERVICE_PORT: availablePort.toString(),
|
|
51
58
|
PW_TEST_HTML_REPORT_OPEN: "never",
|
|
52
|
-
// pass the test gen token so that the agent has the same configuration as cli
|
|
53
59
|
TEST_GEN_TOKEN: testGenToken,
|
|
54
60
|
PAGE_VAR_NAME: pageVar || "page",
|
|
55
61
|
DISPLAY: ":99",
|
|
@@ -60,15 +66,9 @@ async function generateTestsUsingMasterAgent({ testFilePath, filePathToUpdate, p
|
|
|
60
66
|
catch (e) {
|
|
61
67
|
error = `Failed to generate test using master agent ${e}`;
|
|
62
68
|
console.error(error);
|
|
63
|
-
isError = true;
|
|
64
|
-
}
|
|
65
|
-
finally {
|
|
66
|
-
// Remove process listeners before unskipping files
|
|
67
|
-
removeListeners?.();
|
|
68
|
-
teardowns.unskipAll();
|
|
69
69
|
}
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
if (error) {
|
|
71
|
+
// clean up the file if there is any error
|
|
72
72
|
try {
|
|
73
73
|
const fileContent = fs_1.default.readFileSync(filePathToUpdate, "utf-8");
|
|
74
74
|
const updatedContent = (0, web_1.replaceCreateTestWithNewCode)(filePathToUpdate, fileContent, "");
|
|
@@ -83,8 +83,8 @@ async function generateTestsUsingMasterAgent({ testFilePath, filePathToUpdate, p
|
|
|
83
83
|
await (0, web_1.removeTestOnly)(testFilePath);
|
|
84
84
|
await fileServer.stop();
|
|
85
85
|
return {
|
|
86
|
-
isError,
|
|
87
|
-
error,
|
|
86
|
+
isError: !!error,
|
|
87
|
+
error: error || "",
|
|
88
88
|
actionsSummary: fileServer.getActionsSummary(),
|
|
89
89
|
};
|
|
90
90
|
}
|
|
@@ -4,11 +4,7 @@ import { Page } from "playwright";
|
|
|
4
4
|
import { PlaywrightTestConfig } from "playwright/test";
|
|
5
5
|
export declare function isRegExp(obj: any): obj is RegExp;
|
|
6
6
|
export declare function prepareBrowsingAgentTask(steps: string[]): string;
|
|
7
|
-
export declare function replaceTodoWithCreateTest(
|
|
8
|
-
testFilePath: string;
|
|
9
|
-
testCaseName: string;
|
|
10
|
-
testCaseSuites: string[];
|
|
11
|
-
}): Promise<void>;
|
|
7
|
+
export declare function replaceTodoWithCreateTest(testFilePath: string): Promise<void>;
|
|
12
8
|
export declare function markTestAsOnly({ testCaseName, testCaseSuites, specPath, }: {
|
|
13
9
|
testCaseName: string;
|
|
14
10
|
testCaseSuites: string[];
|
|
@@ -33,13 +29,4 @@ export declare function getValidProjectNames(playwrightConfig: PlaywrightTestCon
|
|
|
33
29
|
* @returns
|
|
34
30
|
*/
|
|
35
31
|
export declare function detectProjectName(testFilePath: string, playwrightConfig: PlaywrightTestConfig, pwProjectsFilter?: string[]): Promise<string>;
|
|
36
|
-
export declare class TeardownManager {
|
|
37
|
-
private directory;
|
|
38
|
-
constructor(directory: string);
|
|
39
|
-
private teardownFiles;
|
|
40
|
-
private getAllTeardownFiles;
|
|
41
|
-
private skipTeardownFile;
|
|
42
|
-
skipAll(): Promise<() => void>;
|
|
43
|
-
unskipAll(): void;
|
|
44
|
-
}
|
|
45
32
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAI3D,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAsBvD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAIvD;AAiFD,wBAAsB,yBAAyB,CAAC,YAAY,EAAE,MAAM,iBAsBnE;AAED,wBAAsB,cAAc,CAAC,EACnC,YAAY,EACZ,cAAc,EACd,QAAQ,GACT,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;CAClB,iBAoBA;AAED,wBAAsB,yBAAyB,CAAC,EAC9C,QAAQ,EACR,QAAQ,EACR,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC,MAAM,CAAC,CAyDlB;AAyBD,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,IAAI,iBA2HxD;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC,CA2B/B;AAWD,wBAAsB,oBAAoB,CACxC,gBAAgB,EAAE,oBAAoB,GACrC,OAAO,CAAC,MAAM,EAAE,CAAC,CAQnB;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,oBAAoB,EACtC,gBAAgB,GAAE,MAAM,EAAU,GACjC,OAAO,CAAC,MAAM,CAAC,CA+CjB"}
|
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TeardownManager = void 0;
|
|
7
6
|
exports.isRegExp = isRegExp;
|
|
8
7
|
exports.prepareBrowsingAgentTask = prepareBrowsingAgentTask;
|
|
9
8
|
exports.replaceTodoWithCreateTest = replaceTodoWithCreateTest;
|
|
@@ -16,12 +15,10 @@ exports.detectProjectName = detectProjectName;
|
|
|
16
15
|
const fs_1 = __importDefault(require("fs"));
|
|
17
16
|
const minimatch_1 = require("minimatch");
|
|
18
17
|
const path_1 = __importDefault(require("path"));
|
|
19
|
-
const ts_morph_1 = require("ts-morph");
|
|
20
18
|
// For TypeScript type safety
|
|
21
19
|
let tsxImport = null;
|
|
22
20
|
const logger_1 = require("../../bin/logger");
|
|
23
21
|
const context_1 = require("../../bin/utils/context");
|
|
24
|
-
const fs_2 = require("../../bin/utils/fs");
|
|
25
22
|
const web_1 = require("../../bin/utils/platform/web");
|
|
26
23
|
const create_test_block_1 = require("../codegen/create-test-block");
|
|
27
24
|
const fix_ts_errors_1 = require("../codegen/fix-ts-errors");
|
|
@@ -96,7 +93,7 @@ async function prepareFileForUpdateScenario({ testCase, specPath, trace, }) {
|
|
|
96
93
|
});
|
|
97
94
|
return createTestFilePath;
|
|
98
95
|
}
|
|
99
|
-
async function replaceTodoWithCreateTest(
|
|
96
|
+
async function replaceTodoWithCreateTest(testFilePath) {
|
|
100
97
|
// This method is an alternative to prepareFileForUpdateScenario
|
|
101
98
|
// TODO: Does not support scoped variables and updates in POM files
|
|
102
99
|
const fileContent = fs_1.default.readFileSync(testFilePath, "utf-8");
|
|
@@ -109,11 +106,6 @@ async function replaceTodoWithCreateTest({ testFilePath, testCaseName, testCaseS
|
|
|
109
106
|
const pageVariable = pageVarName || "page"; // Default to "page" if not specified
|
|
110
107
|
fs_1.default.writeFileSync(testFilePath, fileContent.replace(todoRegex, (_, __, todoText) => `await createTest("${todoText.replace(/"/g, '\\"')}", ${pageVariable});`));
|
|
111
108
|
await addImportForCreateTest(testFilePath);
|
|
112
|
-
await markTestAsOnly({
|
|
113
|
-
testCaseName,
|
|
114
|
-
testCaseSuites,
|
|
115
|
-
specPath: testFilePath,
|
|
116
|
-
});
|
|
117
109
|
}
|
|
118
110
|
async function markTestAsOnly({ testCaseName, testCaseSuites, specPath, }) {
|
|
119
111
|
const testFileContent = fs_1.default.readFileSync(specPath, "utf-8");
|
|
@@ -388,52 +380,3 @@ async function detectProjectName(testFilePath, playwrightConfig, pwProjectsFilte
|
|
|
388
380
|
}
|
|
389
381
|
return filteredProjectNames[0];
|
|
390
382
|
}
|
|
391
|
-
class TeardownManager {
|
|
392
|
-
directory;
|
|
393
|
-
constructor(directory) {
|
|
394
|
-
this.directory = directory;
|
|
395
|
-
}
|
|
396
|
-
teardownFiles = [];
|
|
397
|
-
async getAllTeardownFiles() {
|
|
398
|
-
const teardownFileRegex = /.*\.teardown\.ts/;
|
|
399
|
-
const teardownFiles = await (0, fs_2.readFilesInDirectory)(this.directory, (fileName) => teardownFileRegex.test(fileName));
|
|
400
|
-
return teardownFiles;
|
|
401
|
-
}
|
|
402
|
-
async skipTeardownFile(filePath) {
|
|
403
|
-
const project = new ts_morph_1.Project();
|
|
404
|
-
const sourceFile = project.addSourceFileAtPath(filePath);
|
|
405
|
-
sourceFile
|
|
406
|
-
.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression)
|
|
407
|
-
.forEach((callExpression) => {
|
|
408
|
-
const expression = callExpression.getExpression();
|
|
409
|
-
if (expression.getText() === "teardown") {
|
|
410
|
-
expression.replaceWithText("teardown.skip");
|
|
411
|
-
}
|
|
412
|
-
else if (expression.getText() === "test") {
|
|
413
|
-
expression.replaceWithText("test.skip");
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
// Save the modified file
|
|
417
|
-
sourceFile.save().catch((error) => {
|
|
418
|
-
console.error(`Error updating the file: ${filePath}`, error);
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
async skipAll() {
|
|
422
|
-
this.teardownFiles = await this.getAllTeardownFiles();
|
|
423
|
-
await Promise.all(this.teardownFiles.map(async ({ filePath }) => await this.skipTeardownFile(filePath)));
|
|
424
|
-
const setupProcessListeners = (cleanup) => {
|
|
425
|
-
const events = ["beforeExit", "exit", "SIGINT", "SIGTERM"];
|
|
426
|
-
events.forEach((event) => process.on(event, cleanup));
|
|
427
|
-
return () => {
|
|
428
|
-
events.forEach((event) => process.removeListener(event, cleanup));
|
|
429
|
-
};
|
|
430
|
-
};
|
|
431
|
-
return setupProcessListeners(this.unskipAll.bind(this));
|
|
432
|
-
}
|
|
433
|
-
unskipAll() {
|
|
434
|
-
this.teardownFiles.forEach(({ filePath, content }) => {
|
|
435
|
-
fs_1.default.writeFileSync(filePath, content, "utf-8");
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
exports.TeardownManager = TeardownManager;
|
|
@@ -3,12 +3,13 @@ import { IChatModel, SupportedChatModels } from "@empiricalrun/llm/chat";
|
|
|
3
3
|
import { ToolCallService } from "../../tool-call-service";
|
|
4
4
|
import { FileInfo } from "../../types";
|
|
5
5
|
import { ReporterFunction } from "./types";
|
|
6
|
-
export declare function chatAgentLoop({ chatModel, selectedModel, reporter, trace, toolCallService, fileInfo, }: {
|
|
6
|
+
export declare function chatAgentLoop({ chatModel, selectedModel, reporter, trace, toolCallService, fileInfo, isToolExecutionRemote, }: {
|
|
7
7
|
chatModel: IChatModel<any>;
|
|
8
8
|
selectedModel: SupportedChatModels;
|
|
9
9
|
toolCallService: ToolCallService;
|
|
10
10
|
reporter: ReporterFunction;
|
|
11
11
|
trace?: TraceClient;
|
|
12
12
|
fileInfo: FileInfo;
|
|
13
|
+
isToolExecutionRemote: boolean;
|
|
13
14
|
}): Promise<void>;
|
|
14
15
|
//# sourceMappingURL=agent-loop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-loop.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/agent-loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,UAAU,EACV,mBAAmB,EAEpB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-loop.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/agent-loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,UAAU,EACV,mBAAmB,EAEpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAG3C,wBAAsB,aAAa,CAAC,EAClC,SAAS,EACT,aAAa,EACb,QAAQ,EACR,KAAK,EACL,eAAe,EACf,QAAQ,EACR,qBAAqB,GACtB,EAAE;IACD,SAAS,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IAC3B,aAAa,EAAE,mBAAmB,CAAC;IACnC,eAAe,EAAE,eAAe,CAAC;IACjC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,qBAAqB,EAAE,OAAO,CAAC;CAChC,iBAqDA"}
|
|
@@ -2,48 +2,56 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.chatAgentLoop = chatAgentLoop;
|
|
4
4
|
const chat_1 = require("@empiricalrun/llm/chat");
|
|
5
|
-
const picocolors_1 = require("picocolors");
|
|
6
5
|
const prompt_1 = require("./prompt");
|
|
7
6
|
const state_1 = require("./state");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return "Claude";
|
|
11
|
-
if (model.startsWith("gemini"))
|
|
12
|
-
return "Gemini";
|
|
13
|
-
if (model.startsWith("o4"))
|
|
14
|
-
return "o4";
|
|
15
|
-
return "AI";
|
|
16
|
-
}
|
|
17
|
-
const log = (...args) => {
|
|
18
|
-
console.log((0, picocolors_1.gray)(args.join(" ")));
|
|
19
|
-
};
|
|
20
|
-
const isRemote = process.env.TOOL_EXECUTION_IS_REMOTE === "true" || false;
|
|
21
|
-
async function chatAgentLoop({ chatModel, selectedModel, reporter, trace, toolCallService, fileInfo, }) {
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
async function chatAgentLoop({ chatModel, selectedModel, reporter, trace, toolCallService, fileInfo, isToolExecutionRemote, }) {
|
|
22
9
|
const systemPrompt = await (0, prompt_1.buildSystemPrompt)(fileInfo);
|
|
23
10
|
trace?.update({ input: { systemPrompt } });
|
|
24
11
|
const { tools } = await toolCallService.getTools();
|
|
25
12
|
while (!chatModel.askUserForInput) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
try {
|
|
14
|
+
const toolCalls = chatModel.getPendingToolCalls();
|
|
15
|
+
if (toolCalls.length) {
|
|
16
|
+
if (isToolExecutionRemote) {
|
|
17
|
+
await toolCallService.sendToQueue(toolCalls);
|
|
18
|
+
(0, utils_1.log)(`Tool call remote execution in progress`);
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const toolResults = await toolCallService.execute(toolCalls, trace);
|
|
23
|
+
chatModel.pushToolResultsMessage(toolCalls, toolResults);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
(0, utils_1.log)(`${(0, utils_1.getModelName)(selectedModel)} is working...`);
|
|
27
|
+
let response = null;
|
|
28
|
+
response = await chatModel.getLLMResponse({
|
|
29
|
+
systemPrompt,
|
|
30
|
+
tools: tools.map((tool) => (0, chat_1.zodToOpenAITool)(tool.schema)),
|
|
31
|
+
selectedModel,
|
|
32
|
+
trace,
|
|
33
|
+
});
|
|
34
|
+
if (!response) {
|
|
35
|
+
throw new Error("Error getting response from LLM");
|
|
32
36
|
}
|
|
33
|
-
chatModel.
|
|
37
|
+
chatModel.pushMessage(response);
|
|
38
|
+
const latest = chatModel.getHumanReadableLatestMessage();
|
|
39
|
+
await reporter((0, state_1.chatStateFromModel)({
|
|
40
|
+
chatModel,
|
|
41
|
+
selectedModel,
|
|
42
|
+
error: null,
|
|
43
|
+
}), latest);
|
|
34
44
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
catch (error) {
|
|
46
|
+
await (0, utils_1.handleAgentError)({
|
|
47
|
+
context: "chatAgentLoop",
|
|
48
|
+
error,
|
|
49
|
+
chatModel,
|
|
50
|
+
selectedModel,
|
|
51
|
+
reporter,
|
|
52
|
+
trace,
|
|
53
|
+
});
|
|
54
|
+
throw error;
|
|
44
55
|
}
|
|
45
|
-
chatModel.pushMessage(response);
|
|
46
|
-
const latest = chatModel.getHumanReadableLatestMessage();
|
|
47
|
-
await reporter((0, state_1.chatStateFromModel)(chatModel, selectedModel), latest);
|
|
48
56
|
}
|
|
49
57
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { createChatModel, IChatModel
|
|
1
|
+
import { createChatModel, IChatModel } from "@empiricalrun/llm/chat";
|
|
2
2
|
import { FileInfo } from "../../types";
|
|
3
3
|
import { chatAgentLoop } from "./agent-loop";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
4
|
+
import { defaultModel, SUPPORTED_CHAT_MODELS, SupportedChatModels } from "./models";
|
|
5
|
+
import { CHAT_STATE_VERSIONS_MIGRATIONS_MAP, chatStateFromModel, createChatState, createChatStateForMessages, fetchToolCallAvailability, getLatestDownloadBuildUrl, LATEST_CHAT_STATE_VERSION, migrateChatState } from "./state";
|
|
6
6
|
import { ReporterFunction } from "./types";
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
export type { ChatStateOnDisk, FileInfo, IChatModel, ReporterFunction, SupportedChatModels, };
|
|
7
|
+
export { CHAT_STATE_VERSIONS_MIGRATIONS_MAP, chatAgentLoop, chatStateFromModel, createChatModel, createChatState, createChatStateForMessages, defaultModel, fetchToolCallAvailability, getLatestDownloadBuildUrl, LATEST_CHAT_STATE_VERSION, migrateChatState, SUPPORTED_CHAT_MODELS, };
|
|
8
|
+
export type { FileInfo, IChatModel, ReporterFunction, SupportedChatModels };
|
|
10
9
|
//# sourceMappingURL=exports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/exports.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,kCAAkC,EAClC,kBAAkB,EAClB,eAAe,EACf,0BAA0B,EAC1B,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EACL,kCAAkC,EAClC,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,0BAA0B,EAC1B,YAAY,EACZ,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,gBAAgB,EAChB,qBAAqB,GACtB,CAAC;AAEF,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1,48 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
3
|
+
exports.SUPPORTED_CHAT_MODELS = exports.migrateChatState = exports.LATEST_CHAT_STATE_VERSION = exports.getLatestDownloadBuildUrl = exports.fetchToolCallAvailability = exports.defaultModel = exports.createChatStateForMessages = exports.createChatState = exports.createChatModel = exports.chatStateFromModel = exports.chatAgentLoop = exports.CHAT_STATE_VERSIONS_MIGRATIONS_MAP = void 0;
|
|
37
4
|
const chat_1 = require("@empiricalrun/llm/chat");
|
|
38
5
|
Object.defineProperty(exports, "createChatModel", { enumerable: true, get: function () { return chat_1.createChatModel; } });
|
|
39
6
|
const agent_loop_1 = require("./agent-loop");
|
|
40
7
|
Object.defineProperty(exports, "chatAgentLoop", { enumerable: true, get: function () { return agent_loop_1.chatAgentLoop; } });
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
exports.
|
|
44
|
-
|
|
45
|
-
exports.
|
|
46
|
-
exports.
|
|
47
|
-
exports.
|
|
48
|
-
exports.
|
|
8
|
+
const models_1 = require("./models");
|
|
9
|
+
Object.defineProperty(exports, "defaultModel", { enumerable: true, get: function () { return models_1.defaultModel; } });
|
|
10
|
+
Object.defineProperty(exports, "SUPPORTED_CHAT_MODELS", { enumerable: true, get: function () { return models_1.SUPPORTED_CHAT_MODELS; } });
|
|
11
|
+
const state_1 = require("./state");
|
|
12
|
+
Object.defineProperty(exports, "CHAT_STATE_VERSIONS_MIGRATIONS_MAP", { enumerable: true, get: function () { return state_1.CHAT_STATE_VERSIONS_MIGRATIONS_MAP; } });
|
|
13
|
+
Object.defineProperty(exports, "chatStateFromModel", { enumerable: true, get: function () { return state_1.chatStateFromModel; } });
|
|
14
|
+
Object.defineProperty(exports, "createChatState", { enumerable: true, get: function () { return state_1.createChatState; } });
|
|
15
|
+
Object.defineProperty(exports, "createChatStateForMessages", { enumerable: true, get: function () { return state_1.createChatStateForMessages; } });
|
|
16
|
+
Object.defineProperty(exports, "fetchToolCallAvailability", { enumerable: true, get: function () { return state_1.fetchToolCallAvailability; } });
|
|
17
|
+
Object.defineProperty(exports, "getLatestDownloadBuildUrl", { enumerable: true, get: function () { return state_1.getLatestDownloadBuildUrl; } });
|
|
18
|
+
Object.defineProperty(exports, "LATEST_CHAT_STATE_VERSION", { enumerable: true, get: function () { return state_1.LATEST_CHAT_STATE_VERSION; } });
|
|
19
|
+
Object.defineProperty(exports, "migrateChatState", { enumerable: true, get: function () { return state_1.migrateChatState; } });
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SupportedChatModels } from "@empiricalrun/llm/chat";
|
|
2
|
-
export declare function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialPromptContent, }: {
|
|
2
|
+
export declare function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialPromptContent, withRetry, }: {
|
|
3
3
|
selectedModel: SupportedChatModels;
|
|
4
4
|
useDiskForChatState: boolean;
|
|
5
5
|
initialPromptContent: string | undefined;
|
|
6
|
+
withRetry?: boolean;
|
|
6
7
|
}): Promise<void>;
|
|
7
8
|
export declare function runChatAgentForDashboard({ chatSessionId, selectedModel, }: {
|
|
8
9
|
selectedModel: SupportedChatModels;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/index.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/index.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAyChC,wBAAsB,kBAAkB,CAAC,EACvC,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,SAAS,GACV,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,iBAgHA;AAuBD,wBAAsB,wBAAwB,CAAC,EAC7C,aAAa,EACb,aAAa,GACd,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB,iBAsDA"}
|