@empiricalrun/test-gen 0.63.0 → 0.64.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 +14 -0
- package/dist/agent/browsing/run.d.ts.map +1 -1
- package/dist/agent/browsing/run.js +10 -5
- package/dist/agent/browsing/utils.d.ts +1 -1
- package/dist/agent/browsing/utils.d.ts.map +1 -1
- package/dist/agent/browsing/utils.js +5 -4
- package/dist/agent/cua/computer.d.ts.map +1 -1
- package/dist/agent/cua/computer.js +40 -23
- package/dist/agent/cua/pw-codegen/element-from-point.d.ts +3 -1
- package/dist/agent/cua/pw-codegen/element-from-point.d.ts.map +1 -1
- package/dist/agent/cua/pw-codegen/element-from-point.js +19 -14
- package/dist/agent/cua/pw-codegen/types.d.ts +2 -1
- package/dist/agent/cua/pw-codegen/types.d.ts.map +1 -1
- package/dist/file/server.js +1 -1
- package/dist/tool-call-service/index.js +7 -1
- package/dist/tools/commit-and-create-pr.d.ts.map +1 -1
- package/dist/tools/commit-and-create-pr.js +1 -1
- package/dist/tools/diagnosis-fetcher.d.ts.map +1 -1
- package/dist/tools/diagnosis-fetcher.js +1 -1
- package/dist/tools/download-build.d.ts.map +1 -1
- package/dist/tools/download-build.js +1 -1
- package/dist/tools/environment-crud.d.ts.map +1 -1
- package/dist/tools/environment-crud.js +1 -1
- package/dist/tools/grep/index.d.ts.map +1 -1
- package/dist/tools/grep/index.js +1 -1
- package/dist/tools/str_replace_editor.d.ts +4 -1
- package/dist/tools/str_replace_editor.d.ts.map +1 -1
- package/dist/tools/str_replace_editor.js +34 -22
- package/dist/tools/test-gen-browser.d.ts.map +1 -1
- package/dist/tools/test-gen-browser.js +19 -8
- package/dist/tools/test-run-fetcher/index.d.ts.map +1 -1
- package/dist/tools/test-run-fetcher/index.js +1 -1
- package/dist/tools/test-run.d.ts.map +1 -1
- package/dist/tools/test-run.js +1 -1
- package/package.json +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/tools/codegen-agent.d.ts +0 -3
- package/dist/tools/codegen-agent.d.ts.map +0 -1
- package/dist/tools/codegen-agent.js +0 -40
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.64.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1a5ec8d: feat: stateless tool execution and named args for tool execute fn
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- e5b9f7e: feat: consume repoPath in browser agent
|
|
12
|
+
- 43dc453: fix: record locators before execution for more reliable codegen
|
|
13
|
+
- 24d9415: fix: error message in browser agent tool call + removed unused code
|
|
14
|
+
- Updated dependencies [1a5ec8d]
|
|
15
|
+
- @empiricalrun/llm@0.17.2
|
|
16
|
+
|
|
3
17
|
## 0.63.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAe3D,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;IACxB,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;CAC7B,CAAC,CA2FD"}
|
|
@@ -8,6 +8,7 @@ exports.generateTestsUsingMasterAgent = generateTestsUsingMasterAgent;
|
|
|
8
8
|
const test_run_1 = require("@empiricalrun/test-run");
|
|
9
9
|
const detect_port_1 = __importDefault(require("detect-port"));
|
|
10
10
|
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
11
12
|
const web_1 = require("../../bin/utils/platform/web");
|
|
12
13
|
const server_1 = require("../../file/server");
|
|
13
14
|
const exec_1 = require("../../utils/exec");
|
|
@@ -18,8 +19,10 @@ async function convertProjectsFilterToProject({ pwProjectsFilter, repoDir, testF
|
|
|
18
19
|
return project;
|
|
19
20
|
}
|
|
20
21
|
async function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, testFilePath, filePathToUpdate, projectName, testGenToken, repoDir, traceId, editFileWithGeneratedCode, }) {
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
const absTestFilePath = path_1.default.join(repoDir, testFilePath);
|
|
23
|
+
if (!fs_1.default.existsSync(absTestFilePath)) {
|
|
24
|
+
const errorMsg = `File for master agent to run not found: ${testFilePath}`;
|
|
25
|
+
throw new Error(errorMsg);
|
|
23
26
|
}
|
|
24
27
|
const pm = new exec_1.ProcessManager();
|
|
25
28
|
const availablePort = await (0, detect_port_1.default)(3030);
|
|
@@ -32,7 +35,8 @@ async function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, tes
|
|
|
32
35
|
});
|
|
33
36
|
await fileServer.startFileService();
|
|
34
37
|
fileServer.setFilePath(filePathToUpdate);
|
|
35
|
-
const
|
|
38
|
+
const absFilePathToUpdate = path_1.default.join(repoDir, filePathToUpdate);
|
|
39
|
+
const pageVar = await (0, web_1.getPageVariableNameFromCreateTest)(absFilePathToUpdate);
|
|
36
40
|
const testsDir = "tests";
|
|
37
41
|
const cmd = await (0, test_run_1.runSpecificTestsCmd)({
|
|
38
42
|
tests: [
|
|
@@ -66,11 +70,12 @@ async function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, tes
|
|
|
66
70
|
// Enable this for the page.pause approach in codegen
|
|
67
71
|
PW_CODEGEN_NO_INSPECTOR: "1",
|
|
68
72
|
},
|
|
73
|
+
cwd: repoDir,
|
|
69
74
|
});
|
|
70
75
|
}
|
|
71
76
|
catch (e) {
|
|
72
77
|
error = `Failed to generate test using master agent ${e}`;
|
|
73
|
-
console.error(error);
|
|
78
|
+
console.error(`[generateTestsUsingMasterAgent] ${error}`);
|
|
74
79
|
}
|
|
75
80
|
if (error) {
|
|
76
81
|
// Clean up the file if there is any error
|
|
@@ -81,7 +86,7 @@ async function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, tes
|
|
|
81
86
|
await (0, web_1.lintErrors)(filePathToUpdate);
|
|
82
87
|
}
|
|
83
88
|
catch (e) {
|
|
84
|
-
console.error(
|
|
89
|
+
console.error(`[generateTestsUsingMasterAgent] Failed to remove extra scripts from files post test gen error:`, e);
|
|
85
90
|
}
|
|
86
91
|
}
|
|
87
92
|
await fileServer.stop();
|
|
@@ -4,7 +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(testFilePath: string): Promise<void>;
|
|
7
|
+
export declare function replaceTodoWithCreateTest(testFilePath: string, repoDir: string): Promise<void>;
|
|
8
8
|
export declare function markTestAsOnly({ testCaseName, testCaseSuites, specPath, }: {
|
|
9
9
|
testCaseName: string;
|
|
10
10
|
testCaseSuites: string[];
|
|
@@ -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,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,
|
|
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,CAC7C,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,iBAwBhB;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,iBA8HxD;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"}
|
|
@@ -93,10 +93,11 @@ async function prepareFileForUpdateScenario({ testCase, specPath, trace, }) {
|
|
|
93
93
|
});
|
|
94
94
|
return createTestFilePath;
|
|
95
95
|
}
|
|
96
|
-
async function replaceTodoWithCreateTest(testFilePath) {
|
|
96
|
+
async function replaceTodoWithCreateTest(testFilePath, repoDir) {
|
|
97
97
|
// This method is an alternative to prepareFileForUpdateScenario
|
|
98
98
|
// TODO: Does not support scoped variables and updates in POM files
|
|
99
|
-
const
|
|
99
|
+
const absoluteTestFilePath = path_1.default.join(repoDir, testFilePath);
|
|
100
|
+
const fileContent = fs_1.default.readFileSync(absoluteTestFilePath, "utf-8");
|
|
100
101
|
const todoRegex = /\/\/ TODO\(agent(?:\s+on\s+(\w+))?\):\s*(.*)/;
|
|
101
102
|
const todoMatch = fileContent.match(todoRegex);
|
|
102
103
|
if (!todoMatch) {
|
|
@@ -104,8 +105,8 @@ async function replaceTodoWithCreateTest(testFilePath) {
|
|
|
104
105
|
}
|
|
105
106
|
const [, pageVarName] = todoMatch;
|
|
106
107
|
const pageVariable = pageVarName || "page"; // Default to "page" if not specified
|
|
107
|
-
fs_1.default.writeFileSync(
|
|
108
|
-
await addImportForCreateTest(
|
|
108
|
+
fs_1.default.writeFileSync(absoluteTestFilePath, fileContent.replace(todoRegex, (_, __, todoText) => `await createTest("${todoText.replace(/"/g, '\\"')}", ${pageVariable});`));
|
|
109
|
+
await addImportForCreateTest(absoluteTestFilePath);
|
|
109
110
|
}
|
|
110
111
|
async function markTestAsOnly({ testCaseName, testCaseSuites, specPath, }) {
|
|
111
112
|
const testFileContent = fs_1.default.readFileSync(specPath, "utf-8");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computer.d.ts","sourceRoot":"","sources":["../../../src/agent/cua/computer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACpF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,KAAK,oBAAoB,GACrB,wBAAwB,CAAC,KAAK,GAC9B,wBAAwB,CAAC,WAAW,GACpC,wBAAwB,CAAC,IAAI,GAC7B,wBAAwB,CAAC,QAAQ,GACjC,wBAAwB,CAAC,IAAI,GAC7B,wBAAwB,CAAC,UAAU,GACnC,wBAAwB,CAAC,MAAM,GAC/B,wBAAwB,CAAC,IAAI,GAC7B,wBAAwB,CAAC,IAAI,CAAC;AAElC,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,mBAG7C;AAgCD,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,oBAAoB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAC5D,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC;IACT,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC,
|
|
1
|
+
{"version":3,"file":"computer.d.ts","sourceRoot":"","sources":["../../../src/agent/cua/computer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACpF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,KAAK,oBAAoB,GACrB,wBAAwB,CAAC,KAAK,GAC9B,wBAAwB,CAAC,WAAW,GACpC,wBAAwB,CAAC,IAAI,GAC7B,wBAAwB,CAAC,QAAQ,GACjC,wBAAwB,CAAC,IAAI,GAC7B,wBAAwB,CAAC,UAAU,GACnC,wBAAwB,CAAC,MAAM,GAC/B,wBAAwB,CAAC,IAAI,GAC7B,wBAAwB,CAAC,IAAI,CAAC;AAElC,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,mBAG7C;AAgCD,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,oBAAoB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAC5D,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC;IACT,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC,CAmKD"}
|
|
@@ -40,14 +40,21 @@ async function executeModelAction(page, action, codegen) {
|
|
|
40
40
|
let actionCode = "";
|
|
41
41
|
let actionSummary = "";
|
|
42
42
|
try {
|
|
43
|
+
// For every action, this method:
|
|
44
|
+
// 1. Record the action in codegen
|
|
45
|
+
// -> This allows codegen to find locators for the element
|
|
46
|
+
// before the action is executed - execution can be a destructive
|
|
47
|
+
// operation that modifies the DOM
|
|
48
|
+
// 2. Execute the action
|
|
49
|
+
// 3. Add to action summary
|
|
50
|
+
// 4. Add to action code
|
|
43
51
|
switch (actionType) {
|
|
44
|
-
// For every action, this method 1. executes the action,
|
|
45
|
-
// 2. adds to action summary, and 3. adds to action code
|
|
46
52
|
case "goto": {
|
|
47
53
|
const { url } = action;
|
|
54
|
+
await codegen.recordAction({ type: "goto", url });
|
|
48
55
|
await page.goto(url);
|
|
49
56
|
actionSummary = `Navigated page to ${url}`;
|
|
50
|
-
actionCode = await codegen.
|
|
57
|
+
actionCode = await codegen.getCodeForLastAction();
|
|
51
58
|
break;
|
|
52
59
|
}
|
|
53
60
|
case "click": {
|
|
@@ -61,20 +68,23 @@ async function executeModelAction(page, action, codegen) {
|
|
|
61
68
|
pwButton = "middle";
|
|
62
69
|
}
|
|
63
70
|
if (pwButton) {
|
|
71
|
+
await codegen.recordAction({ type: "click", x, y });
|
|
64
72
|
await page.mouse.click(x, y, { button: pwButton });
|
|
65
|
-
actionCode = await codegen.codeForAction({ type: "click", x, y });
|
|
66
73
|
actionSummary = `Click at (${x}, ${y}) with button '${button}'`;
|
|
74
|
+
actionCode = await codegen.getCodeForLastAction();
|
|
67
75
|
}
|
|
68
76
|
if (button === "back" || button === "forward") {
|
|
69
77
|
if (button === "back") {
|
|
78
|
+
await codegen.recordAction({ type: "back" });
|
|
70
79
|
await page.goBack();
|
|
71
|
-
actionCode = await codegen.codeForAction({ type: "back" });
|
|
72
80
|
actionSummary = `Navigated page back`;
|
|
81
|
+
actionCode = await codegen.getCodeForLastAction();
|
|
73
82
|
}
|
|
74
83
|
else if (button === "forward") {
|
|
84
|
+
await codegen.recordAction({ type: "forward" });
|
|
75
85
|
await page.goForward();
|
|
76
|
-
actionCode = await codegen.codeForAction({ type: "forward" });
|
|
77
86
|
actionSummary = `Navigated page forward`;
|
|
87
|
+
actionCode = await codegen.getCodeForLastAction();
|
|
78
88
|
}
|
|
79
89
|
}
|
|
80
90
|
break;
|
|
@@ -82,17 +92,28 @@ async function executeModelAction(page, action, codegen) {
|
|
|
82
92
|
case "double_click": {
|
|
83
93
|
const { x, y } = action;
|
|
84
94
|
console.log(`Action: doubleclick at (${x}, ${y})`);
|
|
95
|
+
await codegen.recordAction({ type: "doubleclick", x, y });
|
|
85
96
|
await page.mouse.dblclick(x, y, { button: "left" });
|
|
86
97
|
actionSummary = `Double click at (${x}, ${y})`;
|
|
87
|
-
actionCode = await codegen.
|
|
98
|
+
actionCode = await codegen.getCodeForLastAction();
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case "type": {
|
|
102
|
+
const { text } = action;
|
|
103
|
+
console.log(`Action: type text '${text}'`);
|
|
104
|
+
await codegen.recordAction({ type: "type", text });
|
|
105
|
+
await page.keyboard.type(text);
|
|
106
|
+
actionSummary = `Type text '${text}'`;
|
|
107
|
+
actionCode = await codegen.getCodeForLastAction();
|
|
88
108
|
break;
|
|
89
109
|
}
|
|
90
110
|
case "move": {
|
|
91
111
|
const { x, y } = action;
|
|
92
112
|
console.log(`Action: mouse move to (${x}, ${y})`);
|
|
113
|
+
await codegen.recordAction({ type: "move", x, y });
|
|
93
114
|
await page.mouse.move(x, y);
|
|
94
115
|
actionSummary = `Mouse move to (${x}, ${y})`;
|
|
95
|
-
actionCode = await codegen.
|
|
116
|
+
actionCode = await codegen.getCodeForLastAction();
|
|
96
117
|
break;
|
|
97
118
|
}
|
|
98
119
|
case "drag": {
|
|
@@ -102,32 +123,35 @@ async function executeModelAction(page, action, codegen) {
|
|
|
102
123
|
if (!path || path.length === 0) {
|
|
103
124
|
break;
|
|
104
125
|
}
|
|
126
|
+
await codegen.recordAction({ type: "drag", path });
|
|
105
127
|
await page.mouse.move(path[0].x, path[0].y);
|
|
106
128
|
await page.mouse.down();
|
|
107
129
|
for (let i = 1; i < path.length; i++) {
|
|
108
130
|
await page.mouse.move(path[i].x, path[i].y);
|
|
109
131
|
}
|
|
110
132
|
await page.mouse.up();
|
|
111
|
-
actionCode = await codegen.
|
|
133
|
+
actionCode = await codegen.getCodeForLastAction();
|
|
112
134
|
break;
|
|
113
135
|
}
|
|
114
136
|
case "scroll": {
|
|
115
137
|
const { x, y, scroll_x, scroll_y } = action;
|
|
116
138
|
console.log(`Action: scroll at (${x}, ${y}) with offsets (scroll_x=${scroll_x}, scroll_y=${scroll_y})`);
|
|
117
|
-
await
|
|
118
|
-
await page.evaluate(`window.scrollBy(${scroll_x}, ${scroll_y})`);
|
|
119
|
-
actionSummary = `Scroll at (${x}, ${y}) with offsets (scroll_x=${scroll_x}, scroll_y=${scroll_y})`;
|
|
120
|
-
actionCode = await codegen.codeForAction({
|
|
139
|
+
await codegen.recordAction({
|
|
121
140
|
type: "scroll",
|
|
122
141
|
x,
|
|
123
142
|
y,
|
|
124
143
|
scroll_x,
|
|
125
144
|
scroll_y,
|
|
126
145
|
});
|
|
146
|
+
await page.mouse.move(x, y);
|
|
147
|
+
await page.evaluate(`window.scrollBy(${scroll_x}, ${scroll_y})`);
|
|
148
|
+
actionSummary = `Scroll at (${x}, ${y}) with offsets (scroll_x=${scroll_x}, scroll_y=${scroll_y})`;
|
|
149
|
+
actionCode = await codegen.getCodeForLastAction();
|
|
127
150
|
break;
|
|
128
151
|
}
|
|
129
152
|
case "keypress": {
|
|
130
153
|
const { keys } = action;
|
|
154
|
+
await codegen.recordAction({ type: "keypress", keys });
|
|
131
155
|
const mappedKeys = keys.map((k) => {
|
|
132
156
|
return CUA_KEY_TO_PLAYWRIGHT_KEY[k.toLowerCase()] || k;
|
|
133
157
|
});
|
|
@@ -135,22 +159,15 @@ async function executeModelAction(page, action, codegen) {
|
|
|
135
159
|
console.log(`Action: keypress for keys ${keys} -> '${mappedKey}'`);
|
|
136
160
|
await page.keyboard.press(mappedKey);
|
|
137
161
|
actionSummary = `Keypress for keys ${keys} (mapped to '${mappedKey}' for Playwright)`;
|
|
138
|
-
actionCode = await codegen.
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
case "type": {
|
|
142
|
-
const { text } = action;
|
|
143
|
-
console.log(`Action: type text '${text}'`);
|
|
144
|
-
await page.keyboard.type(text);
|
|
145
|
-
actionSummary = `Type text '${text}'`;
|
|
146
|
-
actionCode = await codegen.codeForAction({ type: "type", text });
|
|
162
|
+
actionCode = await codegen.getCodeForLastAction();
|
|
147
163
|
break;
|
|
148
164
|
}
|
|
149
165
|
case "wait": {
|
|
150
166
|
console.log(`Action: wait`);
|
|
167
|
+
await codegen.recordAction({ type: "wait" });
|
|
151
168
|
await page.waitForTimeout(2000);
|
|
152
169
|
actionSummary = `Wait for 2 seconds`;
|
|
153
|
-
actionCode = await codegen.
|
|
170
|
+
actionCode = await codegen.getCodeForLastAction();
|
|
154
171
|
break;
|
|
155
172
|
}
|
|
156
173
|
case "screenshot": {
|
|
@@ -2,7 +2,9 @@ import type { Page } from "playwright";
|
|
|
2
2
|
import { Action, BasePlaywrightCodegen } from "./types";
|
|
3
3
|
export declare class ElementFromPointCodegen implements BasePlaywrightCodegen {
|
|
4
4
|
private page;
|
|
5
|
+
private codeForLastAction;
|
|
5
6
|
initialize(page: Page): Promise<void>;
|
|
6
|
-
|
|
7
|
+
recordAction(action: Action): Promise<void>;
|
|
8
|
+
getCodeForLastAction(): Promise<string>;
|
|
7
9
|
}
|
|
8
10
|
//# sourceMappingURL=element-from-point.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element-from-point.d.ts","sourceRoot":"","sources":["../../../../src/agent/cua/pw-codegen/element-from-point.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AA4DxD,qBAAa,uBAAwB,YAAW,qBAAqB;IACnE,OAAO,CAAC,IAAI,CAAmB;
|
|
1
|
+
{"version":3,"file":"element-from-point.d.ts","sourceRoot":"","sources":["../../../../src/agent/cua/pw-codegen/element-from-point.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AA4DxD,qBAAa,uBAAwB,YAAW,qBAAqB;IACnE,OAAO,CAAC,IAAI,CAAmB;IAC/B,OAAO,CAAC,iBAAiB,CAAqB;IAExC,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA4D3C,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;CAG9C"}
|
|
@@ -51,35 +51,38 @@ async function getLocatorForFill(page) {
|
|
|
51
51
|
}
|
|
52
52
|
class ElementFromPointCodegen {
|
|
53
53
|
page;
|
|
54
|
+
codeForLastAction;
|
|
54
55
|
async initialize(page) {
|
|
55
56
|
this.page = page;
|
|
56
57
|
await (0, utils_1.injectPwLocatorGenerator)(page);
|
|
57
58
|
}
|
|
58
|
-
async
|
|
59
|
+
async recordAction(action) {
|
|
59
60
|
try {
|
|
60
61
|
if (action.type === "goto") {
|
|
61
|
-
|
|
62
|
+
this.codeForLastAction = `await page.goto("${action.url}");\n`;
|
|
62
63
|
}
|
|
63
64
|
if (action.type === "click") {
|
|
64
65
|
const { x, y } = action;
|
|
65
66
|
if (!this.page) {
|
|
66
67
|
throw new Error("Page is not initialized");
|
|
67
68
|
}
|
|
69
|
+
// TODO: Need execption handling
|
|
68
70
|
const locator = await getLocatorForClick(this.page, { x, y });
|
|
69
|
-
|
|
71
|
+
this.codeForLastAction = `await page.${locator}.click();\n`;
|
|
70
72
|
}
|
|
71
73
|
if (action.type === "type") {
|
|
72
74
|
if (!this.page) {
|
|
73
75
|
throw new Error("Page is not initialized");
|
|
74
76
|
}
|
|
77
|
+
// TODO: Need execption handling
|
|
75
78
|
const locator = await getLocatorForFill(this.page);
|
|
76
|
-
|
|
79
|
+
this.codeForLastAction = `await page.${locator}.fill("${action.text}");\n`;
|
|
77
80
|
}
|
|
78
81
|
if (action.type === "back") {
|
|
79
|
-
|
|
82
|
+
this.codeForLastAction = `await page.goBack();\n`;
|
|
80
83
|
}
|
|
81
84
|
if (action.type === "forward") {
|
|
82
|
-
|
|
85
|
+
this.codeForLastAction = `await page.goForward();\n`;
|
|
83
86
|
}
|
|
84
87
|
if (action.type === "doubleclick") {
|
|
85
88
|
const { x, y } = action;
|
|
@@ -87,32 +90,34 @@ class ElementFromPointCodegen {
|
|
|
87
90
|
throw new Error("Page is not initialized");
|
|
88
91
|
}
|
|
89
92
|
const locator = await getLocatorForClick(this.page, { x, y });
|
|
90
|
-
|
|
93
|
+
this.codeForLastAction = `await page.${locator}.dblclick();\n`;
|
|
91
94
|
}
|
|
92
95
|
if (action.type === "move") {
|
|
93
96
|
const { x, y } = action;
|
|
94
|
-
|
|
97
|
+
this.codeForLastAction = `await page.mouse.move(${x}, ${y});\n`;
|
|
95
98
|
}
|
|
96
99
|
if (action.type === "drag") {
|
|
97
100
|
// const { path } = action;
|
|
98
101
|
// TODO: This needs to be fixed
|
|
99
|
-
|
|
102
|
+
this.codeForLastAction = `No code generated: drag action not supported by code generation`;
|
|
100
103
|
}
|
|
101
104
|
if (action.type === "scroll") {
|
|
102
|
-
|
|
105
|
+
this.codeForLastAction = `No code to generate: will rely on Playwright's ability to auto-wait`;
|
|
103
106
|
}
|
|
104
107
|
if (action.type === "keypress") {
|
|
105
108
|
const { keys } = action;
|
|
106
|
-
|
|
109
|
+
this.codeForLastAction = `await page.keyboard.press("${keys.join("+")}");\n`;
|
|
107
110
|
}
|
|
108
111
|
if (action.type === "wait") {
|
|
109
|
-
|
|
112
|
+
this.codeForLastAction = `No code to generate: will rely on Playwright's ability to auto-wait`;
|
|
110
113
|
}
|
|
111
|
-
throw new Error(`Unsupported action: ${JSON.stringify(action)}`);
|
|
112
114
|
}
|
|
113
115
|
catch (e) {
|
|
114
|
-
|
|
116
|
+
this.codeForLastAction = `Error generating code for action: ${e.message || e.toString()}`;
|
|
115
117
|
}
|
|
116
118
|
}
|
|
119
|
+
async getCodeForLastAction() {
|
|
120
|
+
return this.codeForLastAction || "No code generated for the last action";
|
|
121
|
+
}
|
|
117
122
|
}
|
|
118
123
|
exports.ElementFromPointCodegen = ElementFromPointCodegen;
|
|
@@ -41,6 +41,7 @@ export type Action = {
|
|
|
41
41
|
};
|
|
42
42
|
export interface BasePlaywrightCodegen {
|
|
43
43
|
initialize(page: Page): Promise<void>;
|
|
44
|
-
|
|
44
|
+
recordAction(action: Action): Promise<void>;
|
|
45
|
+
getCodeForLastAction(): Promise<string>;
|
|
45
46
|
}
|
|
46
47
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/agent/cua/pw-codegen/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,MAAM,MAAM,GACd;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/agent/cua/pw-codegen/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,MAAM,MAAM,GACd;IAEE,IAAI,EAAE,OAAO,CAAC;IACd,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,GACD;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,GACD;IACE,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,SAAS,CAAC;CACjB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAClC,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb,GACD;IACE,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEN,MAAM,WAAW,qBAAqB;IACpC,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACzC"}
|
package/dist/file/server.js
CHANGED
|
@@ -31,7 +31,7 @@ class FileServiceServer {
|
|
|
31
31
|
return this.artifactsInputs;
|
|
32
32
|
}
|
|
33
33
|
setFilePath(filePath) {
|
|
34
|
-
this.filePath = filePath;
|
|
34
|
+
this.filePath = path_1.default.resolve(this.repoDir, filePath);
|
|
35
35
|
}
|
|
36
36
|
async startFileService() {
|
|
37
37
|
const app = (0, express_1.default)();
|
|
@@ -101,7 +101,13 @@ class ToolCallService {
|
|
|
101
101
|
throw new Error("API key is required for tool execution");
|
|
102
102
|
}
|
|
103
103
|
try {
|
|
104
|
-
const result = await toolExecutor(
|
|
104
|
+
const result = await toolExecutor({
|
|
105
|
+
input: toolCall.input,
|
|
106
|
+
repoPath: this.repoPath,
|
|
107
|
+
apiKey: this.apiKey,
|
|
108
|
+
trace: this.trace,
|
|
109
|
+
collectArtifacts: collectArtifactsFn,
|
|
110
|
+
});
|
|
105
111
|
const artifacts = await uploadArtifactsQueue.waitForCompletion();
|
|
106
112
|
toolResults.push({ ...result, artifacts });
|
|
107
113
|
span?.end({ output: result });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commit-and-create-pr.d.ts","sourceRoot":"","sources":["../../src/tools/commit-and-create-pr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAOnD,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAiB1D;AA2CD,eAAO,MAAM,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"commit-and-create-pr.d.ts","sourceRoot":"","sources":["../../src/tools/commit-and-create-pr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAOnD,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAiB1D;AA2CD,eAAO,MAAM,qBAAqB,EAAE,IA0FnC,CAAC"}
|
|
@@ -55,7 +55,7 @@ Don't ask the user for this information, just come up with it yourself.
|
|
|
55
55
|
`,
|
|
56
56
|
parameters: createPullRequestSchema,
|
|
57
57
|
},
|
|
58
|
-
execute: async (input, repoPath, apiKey) => {
|
|
58
|
+
execute: async ({ input, repoPath, apiKey, }) => {
|
|
59
59
|
try {
|
|
60
60
|
const { pullRequestTitle, pullRequestDescription } = input;
|
|
61
61
|
const branchName = await (0, git_1.getCurrentBranchName)(repoPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnosis-fetcher.d.ts","sourceRoot":"","sources":["../../src/tools/diagnosis-fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAenD,eAAO,MAAM,wBAAwB,EAAE,
|
|
1
|
+
{"version":3,"file":"diagnosis-fetcher.d.ts","sourceRoot":"","sources":["../../src/tools/diagnosis-fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAenD,eAAO,MAAM,wBAAwB,EAAE,IAyFtC,CAAC"}
|
|
@@ -19,7 +19,7 @@ exports.fetchDiagnosisReportTool = {
|
|
|
19
19
|
description: "Fetch details about a test case diagnosis using its URL or slug",
|
|
20
20
|
parameters: DiagnosisSchema,
|
|
21
21
|
},
|
|
22
|
-
execute: async (input, repoPath, apiKey) => {
|
|
22
|
+
execute: async ({ input, repoPath, apiKey, }) => {
|
|
23
23
|
const { diagnosisUrl } = input;
|
|
24
24
|
// Extract the slug from the URL - it's the part after the last '--'
|
|
25
25
|
const slug = diagnosisUrl.split("--").pop();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download-build.d.ts","sourceRoot":"","sources":["../../src/tools/download-build.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,uBAAuB;;;;;;EAElC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE7E,eAAO,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"download-build.d.ts","sourceRoot":"","sources":["../../src/tools/download-build.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,uBAAuB;;;;;;EAElC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE7E,eAAO,MAAM,iBAAiB,EAAE,IAsC/B,CAAC"}
|
|
@@ -14,7 +14,7 @@ have a build URL, you can try getting the environment details with the getEnviro
|
|
|
14
14
|
Environment details will include the build URL.`,
|
|
15
15
|
parameters: exports.downloadBuildToolSchema,
|
|
16
16
|
},
|
|
17
|
-
execute: async (input, repoPath, apiKey) => {
|
|
17
|
+
execute: async ({ input, repoPath, apiKey, }) => {
|
|
18
18
|
if (!(await (0, test_build_1.hasDownloadScript)(repoPath))) {
|
|
19
19
|
return {
|
|
20
20
|
isError: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment-crud.d.ts","sourceRoot":"","sources":["../../src/tools/environment-crud.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AA6DnD,eAAO,MAAM,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"environment-crud.d.ts","sourceRoot":"","sources":["../../src/tools/environment-crud.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AA6DnD,eAAO,MAAM,kBAAkB,EAAE,IAiFhC,CAAC;AAGF,eAAO,MAAM,gBAAgB,EAAE,IAAI,EAAyB,CAAC"}
|
|
@@ -31,7 +31,7 @@ exports.getEnvironmentTool = {
|
|
|
31
31
|
description: "Fetch details of an existing environment",
|
|
32
32
|
parameters: GetEnvironmentSchema,
|
|
33
33
|
},
|
|
34
|
-
execute: async (input, repoPath, apiKey) => {
|
|
34
|
+
execute: async ({ input, repoPath, apiKey, }) => {
|
|
35
35
|
// Get project repo name
|
|
36
36
|
let projectRepoName;
|
|
37
37
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/grep/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,wBAAwB,CAAC;AA6H/D,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/grep/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,wBAAwB,CAAC;AA6H/D,eAAO,MAAM,QAAQ,EAAE,IAuBtB,CAAC"}
|
package/dist/tools/grep/index.js
CHANGED
|
@@ -123,7 +123,7 @@ If ripgrep is not available, it will fall back to using system grep.
|
|
|
123
123
|
Search is case insensitive and regex patterns are not supported.`,
|
|
124
124
|
parameters: GrepInputSchema,
|
|
125
125
|
},
|
|
126
|
-
execute: async (input, repoPath) => {
|
|
126
|
+
execute: async ({ input, repoPath, }) => {
|
|
127
127
|
if ((0, ripgrep_1.isRgAvailable)()) {
|
|
128
128
|
return usingRipgrep(input, repoPath);
|
|
129
129
|
}
|
|
@@ -17,7 +17,10 @@ export declare function cleanupBackupFiles(repoDir: string): number;
|
|
|
17
17
|
* Our implementation of Claude's built-in text editor tool
|
|
18
18
|
* https://docs.anthropic.com/en/docs/build-with-claude/tool-use/text-editor-tool
|
|
19
19
|
*/
|
|
20
|
-
export declare function strReplaceEditorExecutor(input
|
|
20
|
+
export declare function strReplaceEditorExecutor({ input, repoPath, }: {
|
|
21
|
+
input: StrReplaceInput;
|
|
22
|
+
repoPath: string;
|
|
23
|
+
}): Promise<ToolResult>;
|
|
21
24
|
export declare const textEditorTools: Tool[];
|
|
22
25
|
export {};
|
|
23
26
|
//# sourceMappingURL=str_replace_editor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"str_replace_editor.d.ts","sourceRoot":"","sources":["../../src/tools/str_replace_editor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AA2B1D,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAqED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAwC1D;AAMD;;;GAGG;AACH,wBAAsB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"str_replace_editor.d.ts","sourceRoot":"","sources":["../../src/tools/str_replace_editor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AA2B1D,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAqED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAwC1D;AAMD;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,EAC7C,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,eAAe,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,UAAU,CAAC,CAkNtB;AAmID,eAAO,MAAM,eAAe,EAAE,IAAI,EAKjC,CAAC"}
|
|
@@ -139,7 +139,7 @@ function escapeRegExp(text) {
|
|
|
139
139
|
* Our implementation of Claude's built-in text editor tool
|
|
140
140
|
* https://docs.anthropic.com/en/docs/build-with-claude/tool-use/text-editor-tool
|
|
141
141
|
*/
|
|
142
|
-
async function strReplaceEditorExecutor(input, repoPath) {
|
|
142
|
+
async function strReplaceEditorExecutor({ input, repoPath, }) {
|
|
143
143
|
const repoDir = repoPath;
|
|
144
144
|
const { path: filePath } = input;
|
|
145
145
|
const absoluteFilePath = path_1.default.join(repoDir, filePath);
|
|
@@ -343,11 +343,14 @@ File contents are returned with line numbers, starting from 1.
|
|
|
343
343
|
path: zod_1.z.string().describe("The path to the file or directory to view."),
|
|
344
344
|
}),
|
|
345
345
|
},
|
|
346
|
-
execute: async (input, repoPath) => {
|
|
346
|
+
execute: async ({ input, repoPath, }) => {
|
|
347
347
|
return strReplaceEditorExecutor({
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
348
|
+
input: {
|
|
349
|
+
command: "view",
|
|
350
|
+
path: input.path,
|
|
351
|
+
},
|
|
352
|
+
repoPath,
|
|
353
|
+
});
|
|
351
354
|
},
|
|
352
355
|
};
|
|
353
356
|
const fileCreateTool = {
|
|
@@ -359,12 +362,15 @@ const fileCreateTool = {
|
|
|
359
362
|
file_text: zod_1.z.string().describe("The contents of the new file."),
|
|
360
363
|
}),
|
|
361
364
|
},
|
|
362
|
-
execute: async (input, repoPath) => {
|
|
365
|
+
execute: async ({ input, repoPath, }) => {
|
|
363
366
|
return strReplaceEditorExecutor({
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
367
|
+
input: {
|
|
368
|
+
command: "create",
|
|
369
|
+
path: input.path,
|
|
370
|
+
file_text: input.file_text,
|
|
371
|
+
},
|
|
372
|
+
repoPath,
|
|
373
|
+
});
|
|
368
374
|
},
|
|
369
375
|
};
|
|
370
376
|
const stringReplaceTool = {
|
|
@@ -378,13 +384,16 @@ in the file. If old_str is not unique, the tool will return an error.`,
|
|
|
378
384
|
new_str: zod_1.z.string().describe("The string to replace old_str with."),
|
|
379
385
|
}),
|
|
380
386
|
},
|
|
381
|
-
execute: async (input, repoPath) => {
|
|
387
|
+
execute: async ({ input, repoPath, }) => {
|
|
382
388
|
return strReplaceEditorExecutor({
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
389
|
+
input: {
|
|
390
|
+
command: "str_replace",
|
|
391
|
+
path: input.path,
|
|
392
|
+
old_str: input.old_str,
|
|
393
|
+
new_str: input.new_str,
|
|
394
|
+
},
|
|
395
|
+
repoPath,
|
|
396
|
+
});
|
|
388
397
|
},
|
|
389
398
|
};
|
|
390
399
|
const stringInsertTool = {
|
|
@@ -403,13 +412,16 @@ To insert a string at the end of the file, you should use insert_line = (total l
|
|
|
403
412
|
new_str: zod_1.z.string().describe("The string to insert."),
|
|
404
413
|
}),
|
|
405
414
|
},
|
|
406
|
-
execute: async (input, repoPath) => {
|
|
415
|
+
execute: async ({ input, repoPath, }) => {
|
|
407
416
|
return strReplaceEditorExecutor({
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
417
|
+
input: {
|
|
418
|
+
command: "insert",
|
|
419
|
+
path: input.path,
|
|
420
|
+
insert_line: input.insert_line,
|
|
421
|
+
new_str: input.new_str,
|
|
422
|
+
},
|
|
423
|
+
repoPath,
|
|
424
|
+
});
|
|
413
425
|
},
|
|
414
426
|
};
|
|
415
427
|
exports.textEditorTools = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-gen-browser.d.ts","sourceRoot":"","sources":["../../src/tools/test-gen-browser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"test-gen-browser.d.ts","sourceRoot":"","sources":["../../src/tools/test-gen-browser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AA4FnD,eAAO,MAAM,4BAA4B,EAAE,IA+H1C,CAAC"}
|
|
@@ -5,7 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.generateTestWithBrowserAgent = void 0;
|
|
7
7
|
const test_run_1 = require("@empiricalrun/test-run");
|
|
8
|
-
const
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
9
10
|
const zod_1 = require("zod");
|
|
10
11
|
const run_1 = require("../agent/browsing/run");
|
|
11
12
|
const utils_1 = require("../agent/browsing/utils");
|
|
@@ -88,12 +89,12 @@ exports.generateTestWithBrowserAgent = {
|
|
|
88
89
|
description: BROWSER_AGENT_DESCRIPTION,
|
|
89
90
|
parameters: BrowserAgentSchema,
|
|
90
91
|
},
|
|
91
|
-
execute: async (input, repoPath,
|
|
92
|
+
execute: async ({ input, repoPath, trace, collectArtifacts, }) => {
|
|
92
93
|
const repoDir = repoPath;
|
|
93
94
|
const { testName, testSuites, fileName, changeToMake, project } = input;
|
|
95
|
+
const absoluteFilePath = path_1.default.join(repoDir, fileName);
|
|
94
96
|
try {
|
|
95
97
|
const { projects } = await (0, test_run_1.getAllPlaywrightProjects)(repoDir);
|
|
96
|
-
// TODO: Check that file path is valid for this project
|
|
97
98
|
if (!projects.includes(project)) {
|
|
98
99
|
return {
|
|
99
100
|
isError: true,
|
|
@@ -108,20 +109,30 @@ exports.generateTestWithBrowserAgent = {
|
|
|
108
109
|
result: `Error reading playwright config: ${error}`,
|
|
109
110
|
};
|
|
110
111
|
}
|
|
111
|
-
if (!
|
|
112
|
+
if (!fs_1.default.existsSync(absoluteFilePath)) {
|
|
113
|
+
return {
|
|
114
|
+
isError: true,
|
|
115
|
+
result: `Could not find file in repository: ${fileName}. Did you use the full path relative to the root of the repository?`,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (!(0, web_1.hasTestBlock)({
|
|
119
|
+
testName,
|
|
120
|
+
testSuites,
|
|
121
|
+
filePath: absoluteFilePath,
|
|
122
|
+
})) {
|
|
112
123
|
return {
|
|
113
124
|
isError: true,
|
|
114
125
|
result: `Test block not found for test name: "${testName}" in file: "${fileName}" with describe blocks: "${testSuites.join(", ")}"`,
|
|
115
126
|
};
|
|
116
127
|
}
|
|
117
128
|
// Prepare the file for the browser agent
|
|
118
|
-
const fileBackup =
|
|
129
|
+
const fileBackup = fs_1.default.readFileSync(absoluteFilePath, "utf-8");
|
|
119
130
|
try {
|
|
120
|
-
await (0, utils_1.replaceTodoWithCreateTest)(fileName);
|
|
131
|
+
await (0, utils_1.replaceTodoWithCreateTest)(fileName, repoDir);
|
|
121
132
|
}
|
|
122
133
|
catch (error) {
|
|
123
134
|
// Undo the TODO -> createTest and test.only changes
|
|
124
|
-
|
|
135
|
+
fs_1.default.writeFileSync(absoluteFilePath, fileBackup, "utf-8");
|
|
125
136
|
return {
|
|
126
137
|
isError: true,
|
|
127
138
|
result: `Error running tool: ${error}`,
|
|
@@ -150,7 +161,7 @@ exports.generateTestWithBrowserAgent = {
|
|
|
150
161
|
});
|
|
151
162
|
// Cleanup: Undo the TODO -> createTest changes
|
|
152
163
|
await (0, pw_pause_1.revertToOriginalPwCode)(repoDir);
|
|
153
|
-
|
|
164
|
+
fs_1.default.writeFileSync(absoluteFilePath, fileBackup, "utf-8");
|
|
154
165
|
const { isError, error, actionsSummary, artifacts } = toolResult;
|
|
155
166
|
if (artifacts) {
|
|
156
167
|
void collectArtifacts?.(artifacts);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/test-run-fetcher/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAcnD,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOnE;AAED,eAAO,MAAM,sBAAsB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/test-run-fetcher/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAcnD,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOnE;AAED,eAAO,MAAM,sBAAsB,EAAE,IA+HpC,CAAC"}
|
|
@@ -24,7 +24,7 @@ exports.fetchTestRunReportTool = {
|
|
|
24
24
|
description: "Fetch details about a test run using its URL",
|
|
25
25
|
parameters: TestRunSchema,
|
|
26
26
|
},
|
|
27
|
-
execute: async (input,
|
|
27
|
+
execute: async ({ input, apiKey, }) => {
|
|
28
28
|
const { testRunUrl } = input;
|
|
29
29
|
// Remove query parameters if they exist
|
|
30
30
|
const urlWithoutParams = testRunUrl.split("?")[0] || testRunUrl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-run.d.ts","sourceRoot":"","sources":["../../src/tools/test-run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-run.d.ts","sourceRoot":"","sources":["../../src/tools/test-run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,wBAAwB,CAAC;AA4C/D,eAAO,MAAM,WAAW,EAAE,IAmEzB,CAAC"}
|
package/dist/tools/test-run.js
CHANGED
|
@@ -34,7 +34,7 @@ exports.runTestTool = {
|
|
|
34
34
|
description: "Run a test",
|
|
35
35
|
parameters: RunTestSchema,
|
|
36
36
|
},
|
|
37
|
-
execute: async (input, repoPath,
|
|
37
|
+
execute: async ({ input, repoPath, collectArtifacts, }) => {
|
|
38
38
|
let reportUrl = undefined;
|
|
39
39
|
let envOverrides = undefined;
|
|
40
40
|
if ((0, artifacts_1.isArtifactCollectionEnabled)()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.64.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"tsx": "^4.16.2",
|
|
63
63
|
"typescript": "^5.3.3",
|
|
64
64
|
"zod": "^3.23.8",
|
|
65
|
-
"@empiricalrun/llm": "^0.17.
|
|
65
|
+
"@empiricalrun/llm": "^0.17.2",
|
|
66
66
|
"@empiricalrun/r2-uploader": "^0.3.9",
|
|
67
67
|
"@empiricalrun/test-run": "^0.9.4"
|
|
68
68
|
},
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/index.ts","./src/actions/assert.ts","./src/actions/click.ts","./src/actions/done.ts","./src/actions/fill.ts","./src/actions/goto.ts","./src/actions/hover.ts","./src/actions/index.ts","./src/actions/next-task.ts","./src/actions/press.ts","./src/actions/skill.ts","./src/actions/text-content.ts","./src/actions/constants/index.ts","./src/actions/utils/index.ts","./src/agent/browsing/index.ts","./src/agent/browsing/run.ts","./src/agent/browsing/utils.ts","./src/agent/chat/agent-loop.ts","./src/agent/chat/exports.ts","./src/agent/chat/index.ts","./src/agent/chat/models.ts","./src/agent/chat/prompt.ts","./src/agent/chat/repo.ts","./src/agent/chat/state.ts","./src/agent/chat/types.ts","./src/agent/chat/utils.ts","./src/agent/codegen/create-test-block.ts","./src/agent/codegen/fix-ts-errors.ts","./src/agent/codegen/generate-code-apply-changes.ts","./src/agent/codegen/lexical-scoped-vars.ts","./src/agent/codegen/repo-edit.ts","./src/agent/codegen/run.ts","./src/agent/codegen/skills-retriever.ts","./src/agent/codegen/test-update-feedback.ts","./src/agent/codegen/types.ts","./src/agent/codegen/update-flow.ts","./src/agent/codegen/use-skill.ts","./src/agent/codegen/utils.ts","./src/agent/cua/computer.ts","./src/agent/cua/index.ts","./src/agent/cua/model.ts","./src/agent/cua/pw-codegen/element-from-point.ts","./src/agent/cua/pw-codegen/types.ts","./src/agent/cua/pw-codegen/pw-pause/index.ts","./src/agent/cua/pw-codegen/pw-pause/utils.ts","./src/agent/diagnosis-agent/index.ts","./src/agent/diagnosis-agent/strict-mode-violation.ts","./src/agent/enrich-prompt/index.ts","./src/agent/enrich-prompt/utils.ts","./src/agent/infer-agent/index.ts","./src/agent/master/action-tool-calls.ts","./src/agent/master/element-annotation.ts","./src/agent/master/execute-browser-action.ts","./src/agent/master/execute-skill-action.ts","./src/agent/master/next-action.ts","./src/agent/master/planner.ts","./src/agent/master/run.ts","./src/agent/master/scroller.ts","./src/agent/master/with-hints.ts","./src/agent/master/browser-tests/cua.spec.ts","./src/agent/master/browser-tests/fixtures.ts","./src/agent/master/browser-tests/index.spec.ts","./src/agent/master/browser-tests/skills.spec.ts","./src/agent/master/icon-descriptor/index.ts","./src/agent/master/icon-descriptor/normalize-svg.ts","./src/agent/planner/run-time-planner.ts","./src/agent/planner/run.ts","./src/artifacts/index.ts","./src/bin/index.ts","./src/bin/logger/index.ts","./src/bin/utils/context.ts","./src/bin/utils/index.ts","./src/bin/utils/fs/index.ts","./src/bin/utils/platform/web/index.ts","./src/bin/utils/platform/web/test-files/ts-path-import-validate.ts","./src/bin/utils/scenarios/index.ts","./src/browser-injected-scripts/annotate-elements.spec.ts","./src/constants/index.ts","./src/errors/index.ts","./src/evals/add-scenario-agent.evals.ts","./src/evals/append-create-test-agent.evals.ts","./src/evals/fetch-pom-skills-agent.evals.ts","./src/evals/infer-master-or-code-agent.evals.ts","./src/evals/master-agent.evals.ts","./src/evals/type.ts","./src/evals/update-scenario-agent.evals.ts","./src/file/client.ts","./src/file/server.ts","./src/human-in-the-loop/cli.ts","./src/human-in-the-loop/index.ts","./src/human-in-the-loop/ipc.ts","./src/page/index.ts","./src/prompts/lib/ts-transformer.ts","./src/reporter/index.ts","./src/reporter/lib.ts","./src/session/index.ts","./src/test-build/index.ts","./src/tool-call-service/index.ts","./src/tool-call-service/utils.ts","./src/tools/
|
|
1
|
+
{"root":["./src/index.ts","./src/actions/assert.ts","./src/actions/click.ts","./src/actions/done.ts","./src/actions/fill.ts","./src/actions/goto.ts","./src/actions/hover.ts","./src/actions/index.ts","./src/actions/next-task.ts","./src/actions/press.ts","./src/actions/skill.ts","./src/actions/text-content.ts","./src/actions/constants/index.ts","./src/actions/utils/index.ts","./src/agent/browsing/index.ts","./src/agent/browsing/run.ts","./src/agent/browsing/utils.ts","./src/agent/chat/agent-loop.ts","./src/agent/chat/exports.ts","./src/agent/chat/index.ts","./src/agent/chat/models.ts","./src/agent/chat/prompt.ts","./src/agent/chat/repo.ts","./src/agent/chat/state.ts","./src/agent/chat/types.ts","./src/agent/chat/utils.ts","./src/agent/codegen/create-test-block.ts","./src/agent/codegen/fix-ts-errors.ts","./src/agent/codegen/generate-code-apply-changes.ts","./src/agent/codegen/lexical-scoped-vars.ts","./src/agent/codegen/repo-edit.ts","./src/agent/codegen/run.ts","./src/agent/codegen/skills-retriever.ts","./src/agent/codegen/test-update-feedback.ts","./src/agent/codegen/types.ts","./src/agent/codegen/update-flow.ts","./src/agent/codegen/use-skill.ts","./src/agent/codegen/utils.ts","./src/agent/cua/computer.ts","./src/agent/cua/index.ts","./src/agent/cua/model.ts","./src/agent/cua/pw-codegen/element-from-point.ts","./src/agent/cua/pw-codegen/types.ts","./src/agent/cua/pw-codegen/pw-pause/index.ts","./src/agent/cua/pw-codegen/pw-pause/utils.ts","./src/agent/diagnosis-agent/index.ts","./src/agent/diagnosis-agent/strict-mode-violation.ts","./src/agent/enrich-prompt/index.ts","./src/agent/enrich-prompt/utils.ts","./src/agent/infer-agent/index.ts","./src/agent/master/action-tool-calls.ts","./src/agent/master/element-annotation.ts","./src/agent/master/execute-browser-action.ts","./src/agent/master/execute-skill-action.ts","./src/agent/master/next-action.ts","./src/agent/master/planner.ts","./src/agent/master/run.ts","./src/agent/master/scroller.ts","./src/agent/master/with-hints.ts","./src/agent/master/browser-tests/cua.spec.ts","./src/agent/master/browser-tests/fixtures.ts","./src/agent/master/browser-tests/index.spec.ts","./src/agent/master/browser-tests/skills.spec.ts","./src/agent/master/icon-descriptor/index.ts","./src/agent/master/icon-descriptor/normalize-svg.ts","./src/agent/planner/run-time-planner.ts","./src/agent/planner/run.ts","./src/artifacts/index.ts","./src/bin/index.ts","./src/bin/logger/index.ts","./src/bin/utils/context.ts","./src/bin/utils/index.ts","./src/bin/utils/fs/index.ts","./src/bin/utils/platform/web/index.ts","./src/bin/utils/platform/web/test-files/ts-path-import-validate.ts","./src/bin/utils/scenarios/index.ts","./src/browser-injected-scripts/annotate-elements.spec.ts","./src/constants/index.ts","./src/errors/index.ts","./src/evals/add-scenario-agent.evals.ts","./src/evals/append-create-test-agent.evals.ts","./src/evals/fetch-pom-skills-agent.evals.ts","./src/evals/infer-master-or-code-agent.evals.ts","./src/evals/master-agent.evals.ts","./src/evals/type.ts","./src/evals/update-scenario-agent.evals.ts","./src/file/client.ts","./src/file/server.ts","./src/human-in-the-loop/cli.ts","./src/human-in-the-loop/index.ts","./src/human-in-the-loop/ipc.ts","./src/page/index.ts","./src/prompts/lib/ts-transformer.ts","./src/reporter/index.ts","./src/reporter/lib.ts","./src/session/index.ts","./src/test-build/index.ts","./src/tool-call-service/index.ts","./src/tool-call-service/utils.ts","./src/tools/commit-and-create-pr.ts","./src/tools/diagnosis-fetcher.ts","./src/tools/download-build.ts","./src/tools/environment-crud.ts","./src/tools/str_replace_editor.ts","./src/tools/test-gen-browser.ts","./src/tools/test-run.ts","./src/tools/grep/index.ts","./src/tools/grep/ripgrep/index.ts","./src/tools/grep/ripgrep/types.ts","./src/tools/test-run-fetcher/index.ts","./src/tools/test-run-fetcher/types.ts","./src/tools/utils/index.ts","./src/types/handlebars.d.ts","./src/types/index.ts","./src/uploader/index.ts","./src/uploader/utils.ts","./src/utils/checkpoint.ts","./src/utils/env.ts","./src/utils/exec.ts","./src/utils/file-tree.ts","./src/utils/file.ts","./src/utils/git.ts","./src/utils/html.ts","./src/utils/index.ts","./src/utils/repo-tree.ts","./src/utils/slug.ts","./src/utils/string.ts","./src/utils/stripAnsi.ts"],"version":"5.8.3"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codegen-agent.d.ts","sourceRoot":"","sources":["../../src/tools/codegen-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAmBnD,eAAO,MAAM,WAAW,EAAE,IAyBzB,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.codegenTool = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const run_1 = require("../agent/codegen/run");
|
|
6
|
-
const CodegenSchema = zod_1.z.object({
|
|
7
|
-
testName: zod_1.z.string().describe("The name of the test to create or modify"),
|
|
8
|
-
testSuites: zod_1.z
|
|
9
|
-
.array(zod_1.z.string())
|
|
10
|
-
.describe("The suites (describe blocks) where the test is located"),
|
|
11
|
-
fileName: zod_1.z
|
|
12
|
-
.string()
|
|
13
|
-
.describe("The name of the file where the test is located. File name must end with .spec.ts"),
|
|
14
|
-
changeToMake: zod_1.z.string().describe("The change to make to the test"),
|
|
15
|
-
});
|
|
16
|
-
exports.codegenTool = {
|
|
17
|
-
schema: {
|
|
18
|
-
name: "generateTestWithCodegen",
|
|
19
|
-
description: "Create or modify a test case with code generation. This is useful when modifications can be done with TypeScript only, and don't require any browser interactions or element selectors.",
|
|
20
|
-
parameters: CodegenSchema,
|
|
21
|
-
},
|
|
22
|
-
execute: async (input) => {
|
|
23
|
-
const { testName, testSuites, fileName, changeToMake } = input;
|
|
24
|
-
const testCase = {
|
|
25
|
-
id: 0,
|
|
26
|
-
name: testName,
|
|
27
|
-
filePath: fileName,
|
|
28
|
-
suites: testSuites,
|
|
29
|
-
steps: [changeToMake],
|
|
30
|
-
};
|
|
31
|
-
const result = await (0, run_1.generateTestWithCodegen)({
|
|
32
|
-
testCase,
|
|
33
|
-
file: fileName,
|
|
34
|
-
});
|
|
35
|
-
return {
|
|
36
|
-
result: JSON.stringify(result),
|
|
37
|
-
isError: false,
|
|
38
|
-
};
|
|
39
|
-
},
|
|
40
|
-
};
|