@empiricalrun/test-gen 0.71.2 → 0.72.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 +38 -0
- package/dist/agent/chat/agent-loop.d.ts +11 -9
- package/dist/agent/chat/agent-loop.d.ts.map +1 -1
- package/dist/agent/chat/agent-loop.js +20 -10
- package/dist/agent/chat/exports.d.ts +2 -2
- package/dist/agent/chat/exports.d.ts.map +1 -1
- package/dist/agent/chat/exports.js +6 -1
- package/dist/agent/chat/index.d.ts.map +1 -1
- package/dist/agent/chat/index.js +48 -13
- package/dist/agent/chat/prompt/index.d.ts +2 -2
- package/dist/agent/chat/prompt/index.d.ts.map +1 -1
- package/dist/agent/chat/prompt/index.js +2 -2
- package/dist/agent/chat/prompt/repo.d.ts +2 -2
- package/dist/agent/chat/prompt/repo.d.ts.map +1 -1
- package/dist/agent/chat/prompt/repo.js +20 -11
- package/dist/agent/chat/state.d.ts +2 -2
- package/dist/agent/chat/state.d.ts.map +1 -1
- package/dist/agent/chat/types.d.ts +0 -6
- package/dist/agent/chat/types.d.ts.map +1 -1
- package/dist/agent/chat/utils/tool-calls.d.ts +21 -0
- package/dist/agent/chat/utils/tool-calls.d.ts.map +1 -0
- package/dist/agent/chat/utils/tool-calls.js +64 -0
- package/dist/agent/chat/utils.d.ts +2 -4
- package/dist/agent/chat/utils.d.ts.map +1 -1
- package/dist/agent/chat/utils.js +5 -11
- package/dist/agent/master/browser-tests/index.spec.js +1 -1
- package/dist/auth/api-client.d.ts.map +1 -1
- package/dist/auth/api-client.js +6 -2
- package/dist/bin/environments.d.ts +1 -1
- package/dist/bin/environments.d.ts.map +1 -1
- package/dist/bin/environments.js +70 -36
- package/dist/bin/index.js +1 -1
- package/dist/bin/setup.d.ts.map +1 -1
- package/dist/bin/setup.js +10 -10
- package/dist/dashboard/index.d.ts +21 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +83 -0
- package/dist/dashboard/totp.d.ts +2 -0
- package/dist/dashboard/totp.d.ts.map +1 -0
- package/dist/dashboard/totp.js +18 -0
- package/dist/file-info/file-system.d.ts +3 -0
- package/dist/file-info/file-system.d.ts.map +1 -0
- package/dist/{utils/file-tree.js → file-info/file-system.js} +2 -8
- package/dist/file-info/github.d.ts +3 -0
- package/dist/file-info/github.d.ts.map +1 -0
- package/dist/file-info/github.js +108 -0
- package/dist/tools/commit-and-create-pr.js +2 -2
- package/dist/tools/definitions/index.d.ts +22 -0
- package/dist/tools/definitions/index.d.ts.map +1 -0
- package/dist/tools/definitions/index.js +61 -0
- package/dist/tools/definitions/run-test.d.ts +23 -0
- package/dist/tools/definitions/run-test.d.ts.map +1 -0
- package/dist/tools/definitions/run-test.js +28 -0
- package/dist/tools/definitions/str_replace_editor.d.ts +3 -0
- package/dist/tools/definitions/str_replace_editor.d.ts.map +1 -0
- package/dist/tools/definitions/str_replace_editor.js +74 -0
- package/dist/tools/definitions/test-gen-browser.d.ts +26 -0
- package/dist/tools/definitions/test-gen-browser.d.ts.map +1 -0
- package/dist/tools/definitions/test-gen-browser.js +88 -0
- package/dist/{tool-call-service/utils.d.ts → tools/definitions/utils/queue.d.ts} +6 -4
- package/dist/tools/definitions/utils/queue.d.ts.map +1 -0
- package/dist/{tool-call-service/utils.js → tools/definitions/utils/queue.js} +20 -19
- package/dist/tools/diagnosis-fetcher.js +1 -1
- package/dist/{tool-call-service → tools/executor}/index.d.ts +2 -7
- package/dist/tools/executor/index.d.ts.map +1 -0
- package/dist/{tool-call-service → tools/executor}/index.js +15 -29
- package/dist/tools/executor/utils/checkpoint.d.ts.map +1 -0
- package/dist/tools/executor/utils/git.d.ts.map +1 -0
- package/dist/{utils → tools/executor/utils}/git.js +5 -5
- package/dist/tools/executor/utils/index.d.ts.map +1 -0
- package/dist/tools/list-environments.js +1 -1
- package/dist/tools/run-test.d.ts.map +1 -1
- package/dist/tools/run-test.js +2 -23
- package/dist/tools/str_replace_editor.d.ts.map +1 -1
- package/dist/tools/str_replace_editor.js +6 -58
- package/dist/tools/test-gen-browser.d.ts.map +1 -1
- package/dist/tools/test-gen-browser.js +2 -83
- package/dist/tools/test-run-fetcher/index.js +1 -1
- package/dist/tools/upgrade-packages/index.js +2 -2
- package/dist/tools/upgrade-packages/utils.js +1 -1
- package/dist/types/index.d.ts +0 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/SQSClient.d.ts +14 -0
- package/dist/utils/SQSClient.d.ts.map +1 -0
- package/dist/utils/SQSClient.js +116 -0
- package/dist/utils/repo-tree.d.ts +1 -1
- package/dist/utils/repo-tree.d.ts.map +1 -1
- package/dist/utils/repo-tree.js +7 -7
- package/package.json +16 -8
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/tool-call-service/index.d.ts.map +0 -1
- package/dist/tool-call-service/utils.d.ts.map +0 -1
- package/dist/tools/utils/index.d.ts.map +0 -1
- package/dist/utils/checkpoint.d.ts.map +0 -1
- package/dist/utils/file-tree.d.ts +0 -3
- package/dist/utils/file-tree.d.ts.map +0 -1
- package/dist/utils/git.d.ts.map +0 -1
- /package/dist/{utils → tools/executor/utils}/checkpoint.d.ts +0 -0
- /package/dist/{utils → tools/executor/utils}/checkpoint.js +0 -0
- /package/dist/{utils → tools/executor/utils}/git.d.ts +0 -0
- /package/dist/tools/{utils → executor/utils}/index.d.ts +0 -0
- /package/dist/tools/{utils → executor/utils}/index.js +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runTestTool = exports.RunTestSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.RunTestSchema = zod_1.z.object({
|
|
6
|
+
testName: zod_1.z.string().describe("The name of the test to run"),
|
|
7
|
+
suites: zod_1.z
|
|
8
|
+
.array(zod_1.z.string())
|
|
9
|
+
.describe("The suites (describe blocks) where the test is located."),
|
|
10
|
+
filePath: zod_1.z
|
|
11
|
+
.string()
|
|
12
|
+
.describe("Path of the file where the test is located. Path must be relative to the root of the repository. File name must end with .spec.ts. For example: tests/lesson.spec.ts"),
|
|
13
|
+
project: zod_1.z.string().describe("The project to run the test on"),
|
|
14
|
+
buildUrl: zod_1.z
|
|
15
|
+
.string()
|
|
16
|
+
.optional()
|
|
17
|
+
.describe(`The URL of the build to run the test on.
|
|
18
|
+
This is ONLY useful for preview deployments that are dynamically created on every pull request, like Vercel preview deployments.
|
|
19
|
+
For all other cases, the build url does not need to be provided, since it is already hard coded in the test repo.`),
|
|
20
|
+
});
|
|
21
|
+
exports.runTestTool = {
|
|
22
|
+
schema: {
|
|
23
|
+
name: "runTest",
|
|
24
|
+
description: "Run a test",
|
|
25
|
+
parameters: exports.RunTestSchema,
|
|
26
|
+
},
|
|
27
|
+
needsBrowser: true,
|
|
28
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"str_replace_editor.d.ts","sourceRoot":"","sources":["../../../src/tools/definitions/str_replace_editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AA0E5D,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAK1D,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.textEditorTools = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const fileViewTool = {
|
|
6
|
+
schema: {
|
|
7
|
+
name: "fileViewTool",
|
|
8
|
+
description: `A tool to view the content of a file or directory. If the path points
|
|
9
|
+
to a directory, the tool will return a list of files in the directory, separated by line breaks.
|
|
10
|
+
If the path points to a file, the tool will return the content of the file.
|
|
11
|
+
|
|
12
|
+
File contents are returned with line numbers, starting from 1.
|
|
13
|
+
|
|
14
|
+
1: line 1
|
|
15
|
+
2: line 2
|
|
16
|
+
...`,
|
|
17
|
+
parameters: zod_1.z.object({
|
|
18
|
+
// Does not support view_range for now
|
|
19
|
+
path: zod_1.z.string().describe("The path to the file or directory to view."),
|
|
20
|
+
}),
|
|
21
|
+
},
|
|
22
|
+
needsBrowser: false,
|
|
23
|
+
};
|
|
24
|
+
const fileCreateTool = {
|
|
25
|
+
schema: {
|
|
26
|
+
name: "fileCreateTool",
|
|
27
|
+
description: `A tool to create a new file with given contents.
|
|
28
|
+
This tool will also create parent directories that do not exist.
|
|
29
|
+
For example, for path "tests/example/foo.spec.ts", the tool will create
|
|
30
|
+
directories "tests", "tests/example", and "tests/example/foo.spec.ts".`,
|
|
31
|
+
parameters: zod_1.z.object({
|
|
32
|
+
path: zod_1.z.string().describe("The path to the new file."),
|
|
33
|
+
file_text: zod_1.z.string().describe("The contents of the new file."),
|
|
34
|
+
}),
|
|
35
|
+
},
|
|
36
|
+
needsBrowser: false,
|
|
37
|
+
};
|
|
38
|
+
const stringReplaceTool = {
|
|
39
|
+
schema: {
|
|
40
|
+
name: "stringReplaceTool",
|
|
41
|
+
description: `A tool to replace a string in a file. This tool requires old_str to be unique
|
|
42
|
+
in the file. If old_str is not unique, the tool will return an error.`,
|
|
43
|
+
parameters: zod_1.z.object({
|
|
44
|
+
path: zod_1.z.string().describe("The path to the file."),
|
|
45
|
+
old_str: zod_1.z.string().describe("The string to be replaced."),
|
|
46
|
+
new_str: zod_1.z.string().describe("The string to replace old_str with."),
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
needsBrowser: false,
|
|
50
|
+
};
|
|
51
|
+
const stringInsertTool = {
|
|
52
|
+
schema: {
|
|
53
|
+
name: "stringInsertTool",
|
|
54
|
+
description: "A tool to insert a string at a specific line in a file. Line numbers are 1-indexed, just like the file view tool.",
|
|
55
|
+
parameters: zod_1.z.object({
|
|
56
|
+
path: zod_1.z.string().describe("The path to the file."),
|
|
57
|
+
insert_line: zod_1.z
|
|
58
|
+
.number()
|
|
59
|
+
.int()
|
|
60
|
+
.min(1)
|
|
61
|
+
.describe(`The line number on which to insert the text (1 for beginning of file).
|
|
62
|
+
To insert a string at the beginning of the file, you should use insert_line = 1.
|
|
63
|
+
To insert a string at the end of the file, you should use insert_line = (total lines + 1).`),
|
|
64
|
+
new_str: zod_1.z.string().describe("The string to insert."),
|
|
65
|
+
}),
|
|
66
|
+
},
|
|
67
|
+
needsBrowser: false,
|
|
68
|
+
};
|
|
69
|
+
exports.textEditorTools = {
|
|
70
|
+
fileViewTool: fileViewTool,
|
|
71
|
+
fileCreateTool: fileCreateTool,
|
|
72
|
+
stringReplaceTool: stringReplaceTool,
|
|
73
|
+
stringInsertTool: stringInsertTool,
|
|
74
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ToolDefinition } from "@empiricalrun/shared-types";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const BrowserAgentSchema: z.ZodObject<{
|
|
4
|
+
testName: z.ZodString;
|
|
5
|
+
testSuites: z.ZodArray<z.ZodString, "many">;
|
|
6
|
+
filePath: z.ZodString;
|
|
7
|
+
project: z.ZodString;
|
|
8
|
+
buildUrl: z.ZodOptional<z.ZodString>;
|
|
9
|
+
changeToMake: z.ZodString;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
testName: string;
|
|
12
|
+
testSuites: string[];
|
|
13
|
+
filePath: string;
|
|
14
|
+
project: string;
|
|
15
|
+
changeToMake: string;
|
|
16
|
+
buildUrl?: string | undefined;
|
|
17
|
+
}, {
|
|
18
|
+
testName: string;
|
|
19
|
+
testSuites: string[];
|
|
20
|
+
filePath: string;
|
|
21
|
+
project: string;
|
|
22
|
+
changeToMake: string;
|
|
23
|
+
buildUrl?: string | undefined;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const generateTestWithBrowserAgent: ToolDefinition;
|
|
26
|
+
//# sourceMappingURL=test-gen-browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-gen-browser.d.ts","sourceRoot":"","sources":["../../../src/tools/definitions/test-gen-browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;EAwB7B,CAAC;AA4DH,eAAO,MAAM,4BAA4B,EAAE,cAO1C,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateTestWithBrowserAgent = exports.BrowserAgentSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.BrowserAgentSchema = zod_1.z.object({
|
|
6
|
+
testName: zod_1.z.string().describe("The name of the test to create or modify"),
|
|
7
|
+
testSuites: zod_1.z
|
|
8
|
+
.array(zod_1.z.string())
|
|
9
|
+
.describe("The suites (describe blocks) where the test is located"),
|
|
10
|
+
filePath: zod_1.z
|
|
11
|
+
.string()
|
|
12
|
+
.describe("Path of the file where the test is located. Path must be relative to the root of the repository. File name must end with .spec.ts. For example: tests/lesson.spec.ts"),
|
|
13
|
+
project: zod_1.z
|
|
14
|
+
.string()
|
|
15
|
+
.describe("The Playwright project to run tests against (e.g. 'chromium' or 'firefox')"),
|
|
16
|
+
buildUrl: zod_1.z
|
|
17
|
+
.string()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe(`The URL of the build to run the test on.
|
|
20
|
+
This is ONLY useful for preview deployments that are dynamically created on every pull request, like Vercel preview deployments.
|
|
21
|
+
For all other cases, the build url does not need to be provided, since it is already hard coded in the test repo.`),
|
|
22
|
+
changeToMake: zod_1.z.string().describe("The change to make to the test"),
|
|
23
|
+
});
|
|
24
|
+
const BROWSER_AGENT_DESCRIPTION = `
|
|
25
|
+
Create or modify a test case with browser agent. The browser agent can take user interactions in a web browser
|
|
26
|
+
and generate Playwright code for that actions. This is a useful tool when the modifications require knowing the
|
|
27
|
+
locator/selector for an element on the page.
|
|
28
|
+
|
|
29
|
+
IMPORTANT: Before you invoke this tool, you need to ensure that the test code is correctly prepared for this
|
|
30
|
+
agent. Preparation involves adding a TODO comment that describes the change that needs to be made, and the page
|
|
31
|
+
variable name where the actions must be performed. The content of the TODO comment calls out the element and browser
|
|
32
|
+
interactions it must take. The TODO comment also has (agent on pageName) next to it, to clearly label that the change
|
|
33
|
+
is for the agent to make on the given page (pageName in this case).
|
|
34
|
+
|
|
35
|
+
To choose the page variable name, go through the test code and find available page variables. If you are replacing some
|
|
36
|
+
existing test code, use the same page variable name as in the existing test code. If you are adding steps to the test,
|
|
37
|
+
use the page variable name that is appropriate for the new steps. The page variable represents the browser page (or tab) that
|
|
38
|
+
the agent is supposed to interact with.
|
|
39
|
+
|
|
40
|
+
For example, this is a good TODO comment:
|
|
41
|
+
|
|
42
|
+
\`\`\`
|
|
43
|
+
test("Example test code", async ({ page }) => {
|
|
44
|
+
await page.goto("https://example.com");
|
|
45
|
+
// TODO(agent on page): Click on the login button
|
|
46
|
+
});
|
|
47
|
+
\`\`\`
|
|
48
|
+
|
|
49
|
+
For the above file, the browser environment will execute the steps before the TODO comment and hand-over the control
|
|
50
|
+
to the browser agent. The agent will do the actions described in the TODO comment and then resume control back to the
|
|
51
|
+
test code.
|
|
52
|
+
|
|
53
|
+
Note that you CANNOT add TODO comments in the middle of a multi-line statement. This will break the tool.
|
|
54
|
+
|
|
55
|
+
For example, this is invalid:
|
|
56
|
+
|
|
57
|
+
\`\`\`
|
|
58
|
+
await extPage
|
|
59
|
+
.getByTestId("virtuoso-item-list")
|
|
60
|
+
// TODO(agent on extPage): Click on the STARS button
|
|
61
|
+
.getByText("STARS", { exact: true })
|
|
62
|
+
.click();
|
|
63
|
+
// This is invalid, because the TODO is in the middle of a multi-line statement
|
|
64
|
+
// Instead, add the TODO before or after the multi-line statement
|
|
65
|
+
\`\`\`
|
|
66
|
+
|
|
67
|
+
The TODO comment must be inside a test block, not outside of it. For example, this is invalid:
|
|
68
|
+
|
|
69
|
+
\`\`\`
|
|
70
|
+
// --- BEGIN INVALID EXAMPLE ---
|
|
71
|
+
test("Example test code", async ({ page }) => {
|
|
72
|
+
await page.goto("https://example.com");
|
|
73
|
+
});
|
|
74
|
+
// TODO(agent on page): Click on the login button
|
|
75
|
+
// --- END INVALID EXAMPLE ---
|
|
76
|
+
\`\`\`
|
|
77
|
+
|
|
78
|
+
After execution, the browser agent will return a summary of actions that it took, and the generated Playwright code for them.
|
|
79
|
+
You can then use the text editor tool to replace the TODO comment with the generated Playwright code.
|
|
80
|
+
`;
|
|
81
|
+
exports.generateTestWithBrowserAgent = {
|
|
82
|
+
schema: {
|
|
83
|
+
name: "generateTestWithBrowserAgent",
|
|
84
|
+
description: BROWSER_AGENT_DESCRIPTION,
|
|
85
|
+
parameters: exports.BrowserAgentSchema,
|
|
86
|
+
},
|
|
87
|
+
needsBrowser: true,
|
|
88
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { PendingToolCall, ServicePayload,
|
|
1
|
+
import { PendingToolCall, ServicePayload, ToolDefinition } from "@empiricalrun/shared-types";
|
|
2
2
|
export declare function appendBranchNameToQueueUrl(queueUrl: string, branchName: string): string;
|
|
3
3
|
export declare function replaceRegionInUrl(url: string, newRegion: string): string;
|
|
4
|
-
export declare function getQueueUrl(toolCalls: PendingToolCall[], tools:
|
|
5
|
-
export declare function sendToolRequestToRemoteQueue(queueUrl: string, payload: ServicePayload
|
|
6
|
-
|
|
4
|
+
export declare function getQueueUrl(toolCalls: PendingToolCall[], tools: ToolDefinition[], workerEnv?: Record<string, string>): string;
|
|
5
|
+
export declare function sendToolRequestToRemoteQueue(queueUrl: string, payload: ServicePayload & {
|
|
6
|
+
workerEnv?: Record<string, string>;
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../../src/tools/definitions/utils/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,cAAc,EACd,cAAc,EACf,MAAM,4BAA4B,CAAC;AAIpC,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,MAAM,CAOR;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAOzE;AAgBD,wBAAgB,WAAW,CACzB,SAAS,EAAE,eAAe,EAAE,EAC5B,KAAK,EAAE,cAAc,EAAE,EACvB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACjC,MAAM,CAyBR;AAED,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,cAAc,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,iBAiBjE"}
|
|
@@ -4,7 +4,7 @@ exports.appendBranchNameToQueueUrl = appendBranchNameToQueueUrl;
|
|
|
4
4
|
exports.replaceRegionInUrl = replaceRegionInUrl;
|
|
5
5
|
exports.getQueueUrl = getQueueUrl;
|
|
6
6
|
exports.sendToolRequestToRemoteQueue = sendToolRequestToRemoteQueue;
|
|
7
|
-
const
|
|
7
|
+
const SQSClient_1 = require("../../../utils/SQSClient");
|
|
8
8
|
function appendBranchNameToQueueUrl(queueUrl, branchName) {
|
|
9
9
|
const cleanBranchName = branchName.replace(/[/.]/g, "-");
|
|
10
10
|
const suffix = cleanBranchName.slice(0, 50);
|
|
@@ -28,12 +28,17 @@ function buildQueueUrlsForPreview(baseQueueUrl) {
|
|
|
28
28
|
console.log("queueUrl for preview", queueUrl);
|
|
29
29
|
return queueUrl;
|
|
30
30
|
}
|
|
31
|
-
function getQueueUrl(toolCalls, tools) {
|
|
31
|
+
function getQueueUrl(toolCalls, tools, workerEnv) {
|
|
32
32
|
const needsBrowser = toolCalls.some((toolCall) => tools.find((t) => t.schema.name === toolCall.name)?.needsBrowser);
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
const browserSwsQueueUrl = workerEnv?.TOOL_EXECUTION_SQS_URL_BROWSER ||
|
|
34
|
+
process.env.TOOL_EXECUTION_SQS_URL_BROWSER;
|
|
35
|
+
const baseSqsQueueUrl = workerEnv?.TOOL_EXECUTION_SQS_URL || process.env.TOOL_EXECUTION_SQS_URL;
|
|
36
|
+
const baseQueueUrl = needsBrowser ? browserSwsQueueUrl : baseSqsQueueUrl;
|
|
37
|
+
if (!baseQueueUrl) {
|
|
38
|
+
throw new Error("No queue URL found");
|
|
39
|
+
}
|
|
40
|
+
const vercelEnv = workerEnv?.VERCEL_ENV || process.env.VERCEL_ENV || "";
|
|
41
|
+
if (vercelEnv !== "preview") {
|
|
37
42
|
return baseQueueUrl;
|
|
38
43
|
}
|
|
39
44
|
else {
|
|
@@ -41,17 +46,13 @@ function getQueueUrl(toolCalls, tools) {
|
|
|
41
46
|
}
|
|
42
47
|
}
|
|
43
48
|
async function sendToolRequestToRemoteQueue(queueUrl, payload) {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
MessageGroupId: payload.requestId,
|
|
54
|
-
MessageDeduplicationId: payload.requestId,
|
|
55
|
-
MessageBody: JSON.stringify(payload),
|
|
56
|
-
}));
|
|
49
|
+
const { workerEnv } = payload;
|
|
50
|
+
const region = workerEnv?.AWS_REGION || process.env.AWS_REGION;
|
|
51
|
+
const accessKeyId = workerEnv?.AWS_ACCESS_KEY_ID || process.env.AWS_ACCESS_KEY_ID;
|
|
52
|
+
const secretAccessKey = workerEnv?.AWS_SECRET_ACCESS_KEY || process.env.AWS_SECRET_ACCESS_KEY;
|
|
53
|
+
if (!region || !accessKeyId || !secretAccessKey) {
|
|
54
|
+
throw new Error("AWS_REGION, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY must be set");
|
|
55
|
+
}
|
|
56
|
+
const sqs = new SQSClient_1.SQSClient(region, accessKeyId, secretAccessKey);
|
|
57
|
+
await sqs.sendMessage(queueUrl, payload);
|
|
57
58
|
}
|
|
@@ -7,7 +7,7 @@ exports.fetchDiagnosisReportTool = void 0;
|
|
|
7
7
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const zod_1 = require("zod");
|
|
10
|
-
const utils_1 = require("./utils");
|
|
10
|
+
const utils_1 = require("./executor/utils");
|
|
11
11
|
const DiagnosisSchema = zod_1.z.object({
|
|
12
12
|
diagnosisUrl: zod_1.z
|
|
13
13
|
.string()
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { TraceClient } from "@empiricalrun/llm";
|
|
2
2
|
import { PendingToolCall, ToolResult } from "@empiricalrun/llm/chat";
|
|
3
3
|
import { SupportedChatModels, Tool, ToolExecute } from "@empiricalrun/shared-types";
|
|
4
|
-
|
|
5
|
-
[key: string]: ToolExecute;
|
|
6
|
-
};
|
|
7
|
-
export declare class ToolCallService {
|
|
4
|
+
export declare class ToolExecutor {
|
|
8
5
|
tools: Tool[];
|
|
9
|
-
toolExecutors:
|
|
6
|
+
toolExecutors: Record<string, ToolExecute>;
|
|
10
7
|
chatSessionId: number | null;
|
|
11
8
|
selectedModel: SupportedChatModels;
|
|
12
9
|
branchName: string;
|
|
@@ -25,8 +22,6 @@ export declare class ToolCallService {
|
|
|
25
22
|
featureFlags: string[];
|
|
26
23
|
environmentOverrides?: Record<string, string>;
|
|
27
24
|
});
|
|
28
|
-
sendToQueue(requestId: string, toolCalls: PendingToolCall[]): Promise<void>;
|
|
29
25
|
execute(toolCalls: PendingToolCall[]): Promise<ToolResult[]>;
|
|
30
26
|
}
|
|
31
|
-
export {};
|
|
32
27
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/executor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAEL,eAAe,EACf,UAAU,EACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,mBAAmB,EACnB,IAAI,EACJ,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAkBpC,qBAAa,YAAY;IACvB,KAAK,EAAE,IAAI,EAAE,CAAM;IACnB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAM;IAChD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,mBAAmB,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAEjC,EACV,aAAa,EACb,aAAa,EACb,UAAU,EACV,QAAQ,EACR,MAAM,EACN,KAAK,EACL,YAAY,EACZ,oBAAyB,GAC1B,EAAE;QACD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;QAC7B,aAAa,EAAE,mBAAmB,CAAC;QACnC,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,KAAK,CAAC,EAAE,WAAW,CAAC;QACpB,YAAY,EAAE,MAAM,EAAE,CAAC;QACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC/C;IAoCK,OAAO,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAyEnE"}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ToolExecutor = void 0;
|
|
4
4
|
const chat_1 = require("@empiricalrun/llm/chat");
|
|
5
|
-
const artifacts_1 = require("
|
|
6
|
-
const commit_and_create_pr_1 = require("../
|
|
7
|
-
const diagnosis_fetcher_1 = require("../
|
|
8
|
-
const download_build_1 = require("../
|
|
9
|
-
const grep_1 = require("../
|
|
10
|
-
const list_environments_1 = require("../
|
|
11
|
-
const run_test_1 = require("../
|
|
12
|
-
const str_replace_editor_1 = require("../
|
|
13
|
-
const test_gen_browser_1 = require("../
|
|
14
|
-
const test_run_fetcher_1 = require("../
|
|
15
|
-
const upgrade_packages_1 = require("../
|
|
16
|
-
const checkpoint_1 = require("
|
|
17
|
-
|
|
18
|
-
class ToolCallService {
|
|
5
|
+
const artifacts_1 = require("../../artifacts");
|
|
6
|
+
const commit_and_create_pr_1 = require("../commit-and-create-pr");
|
|
7
|
+
const diagnosis_fetcher_1 = require("../diagnosis-fetcher");
|
|
8
|
+
const download_build_1 = require("../download-build");
|
|
9
|
+
const grep_1 = require("../grep");
|
|
10
|
+
const list_environments_1 = require("../list-environments");
|
|
11
|
+
const run_test_1 = require("../run-test");
|
|
12
|
+
const str_replace_editor_1 = require("../str_replace_editor");
|
|
13
|
+
const test_gen_browser_1 = require("../test-gen-browser");
|
|
14
|
+
const test_run_fetcher_1 = require("../test-run-fetcher");
|
|
15
|
+
const upgrade_packages_1 = require("../upgrade-packages");
|
|
16
|
+
const checkpoint_1 = require("./utils/checkpoint");
|
|
17
|
+
class ToolExecutor {
|
|
19
18
|
tools = [];
|
|
20
19
|
toolExecutors = {};
|
|
21
20
|
chatSessionId;
|
|
@@ -61,19 +60,6 @@ class ToolCallService {
|
|
|
61
60
|
};
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
|
-
async sendToQueue(requestId, toolCalls) {
|
|
65
|
-
const queueUrl = (0, utils_1.getQueueUrl)(toolCalls, this.tools);
|
|
66
|
-
if (!queueUrl) {
|
|
67
|
-
throw new Error(`queueUrl is required for remote execution.`);
|
|
68
|
-
}
|
|
69
|
-
await (0, utils_1.sendToolRequestToRemoteQueue)(queueUrl, {
|
|
70
|
-
toolCalls,
|
|
71
|
-
requestId,
|
|
72
|
-
chatSessionId: this.chatSessionId,
|
|
73
|
-
selectedModel: this.selectedModel,
|
|
74
|
-
branchName: this.branchName,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
63
|
async execute(toolCalls) {
|
|
78
64
|
const executeSpan = this.trace?.span({
|
|
79
65
|
name: "execute_tools",
|
|
@@ -140,4 +126,4 @@ class ToolCallService {
|
|
|
140
126
|
return toolResults;
|
|
141
127
|
}
|
|
142
128
|
}
|
|
143
|
-
exports.
|
|
129
|
+
exports.ToolExecutor = ToolExecutor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpoint.d.ts","sourceRoot":"","sources":["../../../../src/tools/executor/utils/checkpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAIzD,wBAAsB,gBAAgB,CAAC,EACrC,SAAS,EACT,UAAU,EACV,QAAQ,GACT,EAAE;IACD,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,iBAyBA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../../../src/tools/executor/utils/git.ts"],"names":[],"mappings":"AAOA,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAMhE;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAe1E;AAED,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,iBAQnE;AAED,wBAAsB,eAAe,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,oBAcvE;AAED,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,mBAO1D;AAED,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,iBAE/D;AAED,wBAAsB,wBAAwB,CAAC,EAC7C,aAAa,EACb,UAAU,EACV,KAAK,EACL,QAAQ,GACT,EAAE;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,iBAIA;AAED,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,qBAUhD;AAED,wBAAsB,gBAAgB,CAAC,EACrC,QAAQ,EACR,QAAQ,EACR,MAAM,GACP,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,oBA+BA;AAED,wBAAsB,YAAY,CAAC,EACjC,QAAQ,EACR,UAAU,EACV,MAAM,GACP,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,iBAoBA"}
|
|
@@ -11,7 +11,7 @@ exports.getFilesChanged = getFilesChanged;
|
|
|
11
11
|
exports.mergePullRequest = mergePullRequest;
|
|
12
12
|
exports.deleteBranch = deleteBranch;
|
|
13
13
|
const child_process_1 = require("child_process");
|
|
14
|
-
const
|
|
14
|
+
const index_1 = require("./index");
|
|
15
15
|
const GIT_USER_NAME = "empiricalrun[bot]";
|
|
16
16
|
const GIT_USER_EMAIL = "180257021+empiricalrun[bot]@users.noreply.github.com";
|
|
17
17
|
function getGitDiff(filepath, cwd) {
|
|
@@ -88,12 +88,12 @@ async function getFilesChanged(cwd) {
|
|
|
88
88
|
return filesChanged;
|
|
89
89
|
}
|
|
90
90
|
async function mergePullRequest({ repoName, prNumber, apiKey, }) {
|
|
91
|
-
const url = `${
|
|
91
|
+
const url = `${index_1.GITHUB_API_BASE}/${repoName}/pulls/${prNumber}/merge`;
|
|
92
92
|
const mergeBody = {
|
|
93
93
|
merge_method: "squash",
|
|
94
94
|
};
|
|
95
95
|
try {
|
|
96
|
-
const response = await (0,
|
|
96
|
+
const response = await (0, index_1.callGitHubProxy)({
|
|
97
97
|
method: "PUT",
|
|
98
98
|
url: url,
|
|
99
99
|
body: mergeBody,
|
|
@@ -112,9 +112,9 @@ async function mergePullRequest({ repoName, prNumber, apiKey, }) {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
async function deleteBranch({ repoName, branchName, apiKey, }) {
|
|
115
|
-
const url = `${
|
|
115
|
+
const url = `${index_1.GITHUB_API_BASE}/${repoName}/git/refs/heads/${branchName}`;
|
|
116
116
|
try {
|
|
117
|
-
await (0,
|
|
117
|
+
await (0, index_1.callGitHubProxy)({
|
|
118
118
|
method: "DELETE",
|
|
119
119
|
url: url,
|
|
120
120
|
apiKey,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tools/executor/utils/index.ts"],"names":[],"mappings":"AAAA,wBAAsB,oBAAoB,CAAC,CAAC,EAAE,EAC5C,IAAI,EACJ,MAAc,EACd,IAAI,EACJ,MAAM,GACP,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,CAAC,CAAC,CAmBb;AAED,wBAAsB,eAAe,CAAC,CAAC,EAAE,EACvC,MAAM,EACN,GAAG,EACH,IAAI,EACJ,MAAM,GACP,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,CAAC,CAAC,CAYb;AAGD,eAAO,MAAM,eAAe,+CAA+C,CAAC;AAG5E,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAiB1D;AAGD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CACvB;AAED,wBAAsB,cAAc,CAAC,EACnC,KAAK,EACL,IAAI,EACJ,UAAU,EACV,MAAM,GACP,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAYlC;AAED,wBAAsB,iBAAiB,CAAC,EACtC,KAAK,EACL,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,IAAa,EACb,IAAI,EACJ,MAAM,EACN,MAAM,GACP,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,eAAe,CAAC,CAqB3B;AAED,wBAAsB,iBAAiB,CAAC,EACtC,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,MAAM,GACP,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,eAAe,CAAC,CAU3B;AAED,wBAAsB,uBAAuB,CAAC,EAC5C,KAAK,EACL,IAAI,EACJ,UAAU,EACV,KAAK,EACL,IAAI,EACJ,MAAM,EACN,MAAM,GACP,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CAyBnD"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.listEnvironmentsTool = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const utils_1 = require("./utils");
|
|
5
|
+
const utils_1 = require("./executor/utils");
|
|
6
6
|
exports.listEnvironmentsTool = {
|
|
7
7
|
schema: {
|
|
8
8
|
name: "listEnvironments",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-test.d.ts","sourceRoot":"","sources":["../../src/tools/run-test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"run-test.d.ts","sourceRoot":"","sources":["../../src/tools/run-test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,4BAA4B,CAAC;AA0CnE,eAAO,MAAM,WAAW,EAAE,IAgFzB,CAAC"}
|
package/dist/tools/run-test.js
CHANGED
|
@@ -7,26 +7,10 @@ exports.runTestTool = void 0;
|
|
|
7
7
|
const test_run_1 = require("@empiricalrun/test-run");
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const zod_1 = require("zod");
|
|
11
10
|
const artifacts_1 = require("../artifacts");
|
|
12
11
|
const utils_1 = require("../artifacts/utils");
|
|
13
12
|
const utils_2 = require("../utils");
|
|
14
|
-
const
|
|
15
|
-
testName: zod_1.z.string().describe("The name of the test to run"),
|
|
16
|
-
suites: zod_1.z
|
|
17
|
-
.array(zod_1.z.string())
|
|
18
|
-
.describe("The suites (describe blocks) where the test is located."),
|
|
19
|
-
filePath: zod_1.z
|
|
20
|
-
.string()
|
|
21
|
-
.describe("Path of the file where the test is located. Path must be relative to the root of the repository. File name must end with .spec.ts. For example: tests/lesson.spec.ts"),
|
|
22
|
-
project: zod_1.z.string().describe("The project to run the test on"),
|
|
23
|
-
buildUrl: zod_1.z
|
|
24
|
-
.string()
|
|
25
|
-
.optional()
|
|
26
|
-
.describe(`The URL of the build to run the test on.
|
|
27
|
-
This is ONLY useful for preview deployments that are dynamically created on every pull request, like Vercel preview deployments.
|
|
28
|
-
For all other cases, the build url does not need to be provided, since it is already hard coded in the test repo.`),
|
|
29
|
-
});
|
|
13
|
+
const run_test_1 = require("./definitions/run-test");
|
|
30
14
|
function buildReportUrl(projectName, testRunId) {
|
|
31
15
|
return `https://reports.empirical.run/${projectName}/${testRunId}/index.html`;
|
|
32
16
|
}
|
|
@@ -44,12 +28,7 @@ ${JSON.stringify(truncatedSummaryJson)}
|
|
|
44
28
|
`;
|
|
45
29
|
}
|
|
46
30
|
exports.runTestTool = {
|
|
47
|
-
|
|
48
|
-
name: "runTest",
|
|
49
|
-
description: "Run a test",
|
|
50
|
-
parameters: RunTestSchema,
|
|
51
|
-
},
|
|
52
|
-
needsBrowser: true,
|
|
31
|
+
...run_test_1.runTestTool,
|
|
53
32
|
execute: async ({ input, repoPath, collectArtifacts, environmentOverrides = {}, }) => {
|
|
54
33
|
let reportUrl = undefined;
|
|
55
34
|
let envOverrides = { ...environmentOverrides };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"str_replace_editor.d.ts","sourceRoot":"","sources":["../../src/tools/str_replace_editor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EAChB,IAAI,EAEJ,UAAU,EACX,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"str_replace_editor.d.ts","sourceRoot":"","sources":["../../src/tools/str_replace_editor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EAChB,IAAI,EAEJ,UAAU,EACX,MAAM,4BAA4B,CAAC;AAuCpC,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;AAiWD;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,EAC7C,KAAK,EACL,QAAQ,EACR,gBAAgB,GACjB,EAAE;IACD,KAAK,EAAE,eAAe,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC,GAAG,OAAO,CAAC,UAAU,CAAC,CA8CtB;AA8ED,eAAO,MAAM,eAAe,EAAE,IAAI,EAKjC,CAAC"}
|
|
@@ -7,9 +7,9 @@ exports.textEditorTools = void 0;
|
|
|
7
7
|
exports.strReplaceEditorExecutor = strReplaceEditorExecutor;
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const zod_1 = require("zod");
|
|
11
10
|
const web_1 = require("../bin/utils/platform/web");
|
|
12
|
-
const
|
|
11
|
+
const str_replace_editor_1 = require("./definitions/str_replace_editor");
|
|
12
|
+
const git_1 = require("./executor/utils/git");
|
|
13
13
|
/**
|
|
14
14
|
* Helper function to collect git patch artifacts for file modifications
|
|
15
15
|
*/
|
|
@@ -358,23 +358,7 @@ async function strReplaceEditorExecutor({ input, repoPath, collectArtifacts, })
|
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
const fileViewTool = {
|
|
361
|
-
|
|
362
|
-
name: "fileViewTool",
|
|
363
|
-
description: `A tool to view the content of a file or directory. If the path points
|
|
364
|
-
to a directory, the tool will return a list of files in the directory, separated by line breaks.
|
|
365
|
-
If the path points to a file, the tool will return the content of the file.
|
|
366
|
-
|
|
367
|
-
File contents are returned with line numbers, starting from 1.
|
|
368
|
-
|
|
369
|
-
1: line 1
|
|
370
|
-
2: line 2
|
|
371
|
-
...`,
|
|
372
|
-
parameters: zod_1.z.object({
|
|
373
|
-
// Does not support view_range for now
|
|
374
|
-
path: zod_1.z.string().describe("The path to the file or directory to view."),
|
|
375
|
-
}),
|
|
376
|
-
},
|
|
377
|
-
needsBrowser: false,
|
|
361
|
+
...str_replace_editor_1.textEditorTools["fileViewTool"],
|
|
378
362
|
execute: async (params) => {
|
|
379
363
|
const { input } = params;
|
|
380
364
|
const { repoPath } = params;
|
|
@@ -388,18 +372,7 @@ File contents are returned with line numbers, starting from 1.
|
|
|
388
372
|
},
|
|
389
373
|
};
|
|
390
374
|
const fileCreateTool = {
|
|
391
|
-
|
|
392
|
-
name: "fileCreateTool",
|
|
393
|
-
description: `A tool to create a new file with given contents.
|
|
394
|
-
This tool will also create parent directories that do not exist.
|
|
395
|
-
For example, for path "tests/example/foo.spec.ts", the tool will create
|
|
396
|
-
directories "tests", "tests/example", and "tests/example/foo.spec.ts".`,
|
|
397
|
-
parameters: zod_1.z.object({
|
|
398
|
-
path: zod_1.z.string().describe("The path to the new file."),
|
|
399
|
-
file_text: zod_1.z.string().describe("The contents of the new file."),
|
|
400
|
-
}),
|
|
401
|
-
},
|
|
402
|
-
needsBrowser: false,
|
|
375
|
+
...str_replace_editor_1.textEditorTools["fileCreateTool"],
|
|
403
376
|
execute: async (params) => {
|
|
404
377
|
const { input } = params;
|
|
405
378
|
const { repoPath, collectArtifacts } = params;
|
|
@@ -415,17 +388,7 @@ directories "tests", "tests/example", and "tests/example/foo.spec.ts".`,
|
|
|
415
388
|
},
|
|
416
389
|
};
|
|
417
390
|
const stringReplaceTool = {
|
|
418
|
-
|
|
419
|
-
name: "stringReplaceTool",
|
|
420
|
-
description: `A tool to replace a string in a file. This tool requires old_str to be unique
|
|
421
|
-
in the file. If old_str is not unique, the tool will return an error.`,
|
|
422
|
-
parameters: zod_1.z.object({
|
|
423
|
-
path: zod_1.z.string().describe("The path to the file."),
|
|
424
|
-
old_str: zod_1.z.string().describe("The string to be replaced."),
|
|
425
|
-
new_str: zod_1.z.string().describe("The string to replace old_str with."),
|
|
426
|
-
}),
|
|
427
|
-
},
|
|
428
|
-
needsBrowser: false,
|
|
391
|
+
...str_replace_editor_1.textEditorTools["stringReplaceTool"],
|
|
429
392
|
execute: async (params) => {
|
|
430
393
|
const { input } = params;
|
|
431
394
|
const { repoPath, collectArtifacts } = params;
|
|
@@ -442,22 +405,7 @@ in the file. If old_str is not unique, the tool will return an error.`,
|
|
|
442
405
|
},
|
|
443
406
|
};
|
|
444
407
|
const stringInsertTool = {
|
|
445
|
-
|
|
446
|
-
name: "stringInsertTool",
|
|
447
|
-
description: "A tool to insert a string at a specific line in a file. Line numbers are 1-indexed, just like the file view tool.",
|
|
448
|
-
parameters: zod_1.z.object({
|
|
449
|
-
path: zod_1.z.string().describe("The path to the file."),
|
|
450
|
-
insert_line: zod_1.z
|
|
451
|
-
.number()
|
|
452
|
-
.int()
|
|
453
|
-
.min(1)
|
|
454
|
-
.describe(`The line number on which to insert the text (1 for beginning of file).
|
|
455
|
-
To insert a string at the beginning of the file, you should use insert_line = 1.
|
|
456
|
-
To insert a string at the end of the file, you should use insert_line = (total lines + 1).`),
|
|
457
|
-
new_str: zod_1.z.string().describe("The string to insert."),
|
|
458
|
-
}),
|
|
459
|
-
},
|
|
460
|
-
needsBrowser: false,
|
|
408
|
+
...str_replace_editor_1.textEditorTools["stringInsertTool"],
|
|
461
409
|
execute: async (params) => {
|
|
462
410
|
const { input } = params;
|
|
463
411
|
const { repoPath, collectArtifacts } = params;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-gen-browser.d.ts","sourceRoot":"","sources":["../../src/tools/test-gen-browser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,IAAI,EAGL,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"test-gen-browser.d.ts","sourceRoot":"","sources":["../../src/tools/test-gen-browser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,IAAI,EAGL,MAAM,4BAA4B,CAAC;AAoBpC,eAAO,MAAM,4BAA4B,EAAE,IA0L1C,CAAC"}
|