@empiricalrun/test-gen 0.75.0 → 0.77.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 +48 -0
- package/dist/agent/base/index.d.ts +32 -21
- package/dist/agent/base/index.d.ts.map +1 -1
- package/dist/agent/base/index.js +100 -57
- package/dist/agent/browsing/run.d.ts +1 -2
- package/dist/agent/browsing/run.d.ts.map +1 -1
- package/dist/agent/browsing/run.js +3 -9
- package/dist/agent/browsing/utils.d.ts +2 -9
- package/dist/agent/browsing/utils.d.ts.map +1 -1
- package/dist/agent/browsing/utils.js +5 -109
- package/dist/agent/chat/agent-loop.d.ts +8 -7
- package/dist/agent/chat/agent-loop.d.ts.map +1 -1
- package/dist/agent/chat/agent-loop.js +7 -18
- package/dist/agent/chat/exports.d.ts +9 -6
- package/dist/agent/chat/exports.d.ts.map +1 -1
- package/dist/agent/chat/exports.js +11 -13
- package/dist/agent/chat/index.d.ts +6 -10
- package/dist/agent/chat/index.d.ts.map +1 -1
- package/dist/agent/chat/index.js +117 -196
- package/dist/agent/chat/models.d.ts +0 -2
- package/dist/agent/chat/models.d.ts.map +1 -1
- package/dist/agent/chat/models.js +12 -26
- package/dist/agent/chat/prompt/pw-utils-docs.d.ts +1 -1
- package/dist/agent/chat/prompt/pw-utils-docs.d.ts.map +1 -1
- package/dist/agent/chat/prompt/pw-utils-docs.js +52 -0
- package/dist/agent/chat/prompt/repo.d.ts.map +1 -1
- package/dist/agent/chat/prompt/repo.js +11 -22
- package/dist/agent/chat/prompt/test-case-def.d.ts +2 -0
- package/dist/agent/chat/prompt/test-case-def.d.ts.map +1 -0
- package/dist/agent/chat/prompt/test-case-def.js +44 -0
- package/dist/agent/chat/state.d.ts +8 -8
- package/dist/agent/chat/state.d.ts.map +1 -1
- package/dist/agent/chat/state.js +17 -47
- package/dist/agent/chat/utils.d.ts +4 -5
- package/dist/agent/chat/utils.d.ts.map +1 -1
- package/dist/agent/chat/utils.js +15 -9
- package/dist/agent/cli.d.ts +11 -0
- package/dist/agent/cli.d.ts.map +1 -0
- package/dist/agent/cli.js +213 -0
- package/dist/agent/code-review/executor/index.d.ts +5 -0
- package/dist/agent/code-review/executor/index.d.ts.map +1 -0
- package/dist/agent/code-review/executor/index.js +13 -0
- package/dist/agent/code-review/index.d.ts +12 -0
- package/dist/agent/code-review/index.d.ts.map +1 -0
- package/dist/agent/code-review/index.js +159 -0
- package/dist/agent/code-review/parser.d.ts +5 -0
- package/dist/agent/code-review/parser.d.ts.map +1 -0
- package/dist/agent/code-review/parser.js +70 -0
- package/dist/agent/code-review/types.d.ts +36 -0
- package/dist/agent/code-review/types.d.ts.map +1 -0
- package/dist/agent/code-review/types.js +13 -0
- package/dist/agent/cua/index.d.ts.map +1 -1
- package/dist/agent/cua/index.js +18 -2
- package/dist/agent/cua/model.d.ts.map +1 -1
- package/dist/agent/cua/model.js +4 -1
- package/dist/agent/cua/pw-codegen/pw-pause/index.d.ts.map +1 -1
- package/dist/agent/index.d.ts +10 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +19 -0
- package/dist/agent/triage/index.d.ts +7 -0
- package/dist/agent/triage/index.d.ts.map +1 -0
- package/dist/agent/triage/index.js +103 -0
- package/dist/agent/video-analysis/executor/index.d.ts +5 -0
- package/dist/agent/video-analysis/executor/index.d.ts.map +1 -0
- package/dist/agent/video-analysis/executor/index.js +10 -0
- package/dist/agent/video-analysis/index.d.ts +7 -0
- package/dist/agent/video-analysis/index.d.ts.map +1 -0
- package/dist/agent/video-analysis/index.js +60 -0
- package/dist/artifacts/index.d.ts +1 -1
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +3 -1
- package/dist/artifacts/utils.d.ts.map +1 -1
- package/dist/bin/index.js +68 -23
- package/dist/constants/index.d.ts +14 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +33 -1
- package/dist/file/server.d.ts +1 -3
- package/dist/file/server.d.ts.map +1 -1
- package/dist/file/server.js +0 -13
- package/dist/file-info/adapters/file-system/index.d.ts.map +1 -1
- package/dist/file-info/adapters/file-system/reader.d.ts.map +1 -1
- package/dist/file-info/adapters/file-system/reader.js +8 -1
- package/dist/file-info/adapters/github/index.d.ts.map +1 -1
- package/dist/file-info/adapters/github/index.js +1 -2
- package/dist/file-info/adapters/github/reader.d.ts +4 -9
- package/dist/file-info/adapters/github/reader.d.ts.map +1 -1
- package/dist/file-info/adapters/github/reader.js +166 -134
- package/dist/index.d.ts.map +1 -1
- package/dist/tools/analyse-video/index.d.ts +5 -0
- package/dist/tools/analyse-video/index.d.ts.map +1 -0
- package/dist/tools/analyse-video/index.js +50 -0
- package/dist/tools/create-pull-request/index.d.ts.map +1 -0
- package/dist/tools/{definitions/commit-and-create-pr.js → create-pull-request/index.js} +28 -1
- package/dist/tools/create-pull-request/utils.d.ts +21 -0
- package/dist/tools/create-pull-request/utils.d.ts.map +1 -0
- package/dist/tools/create-pull-request/utils.js +83 -0
- package/dist/tools/definitions/{fetch-video-analysis.d.ts → analyse-video.d.ts} +17 -12
- package/dist/tools/definitions/analyse-video.d.ts.map +1 -0
- package/dist/tools/definitions/analyse-video.js +60 -0
- package/dist/tools/definitions/review-pull-request.d.ts +3 -0
- package/dist/tools/definitions/review-pull-request.d.ts.map +1 -0
- package/dist/tools/definitions/review-pull-request.js +16 -0
- package/dist/tools/definitions/str_replace_editor.d.ts +1 -0
- package/dist/tools/definitions/str_replace_editor.d.ts.map +1 -1
- package/dist/tools/definitions/str_replace_editor.js +4 -1
- package/dist/tools/definitions/test-gen-browser.d.ts +0 -3
- package/dist/tools/definitions/test-gen-browser.d.ts.map +1 -1
- package/dist/tools/definitions/test-gen-browser.js +33 -8
- package/dist/tools/delete-file/index.d.ts.map +1 -1
- package/dist/tools/delete-file/index.js +1 -19
- package/dist/tools/executor/base.d.ts +32 -0
- package/dist/tools/executor/base.d.ts.map +1 -0
- package/dist/tools/executor/base.js +114 -0
- package/dist/tools/executor/index.d.ts +3 -22
- package/dist/tools/executor/index.d.ts.map +1 -1
- package/dist/tools/executor/index.js +13 -92
- package/dist/tools/executor/utils/checkpoint.d.ts +1 -1
- package/dist/tools/executor/utils/checkpoint.d.ts.map +1 -1
- package/dist/tools/executor/utils/checkpoint.js +6 -2
- package/dist/tools/executor/utils/git.d.ts +2 -2
- package/dist/tools/executor/utils/git.d.ts.map +1 -1
- package/dist/tools/executor/utils/git.js +7 -3
- package/dist/tools/executor/utils/index.d.ts.map +1 -1
- package/dist/tools/executor/utils/index.js +1 -1
- package/dist/tools/fetch-session-diff/index.d.ts +3 -0
- package/dist/tools/fetch-session-diff/index.d.ts.map +1 -0
- package/dist/tools/fetch-session-diff/index.js +46 -0
- package/dist/tools/file-operations/create.d.ts.map +1 -1
- package/dist/tools/file-operations/create.js +1 -4
- package/dist/tools/file-operations/index.d.ts +2 -1
- package/dist/tools/file-operations/index.d.ts.map +1 -1
- package/dist/tools/file-operations/index.js +4 -1
- package/dist/tools/file-operations/insert.d.ts +1 -2
- package/dist/tools/file-operations/insert.d.ts.map +1 -1
- package/dist/tools/file-operations/insert.js +1 -4
- package/dist/tools/file-operations/replace.d.ts.map +1 -1
- package/dist/tools/file-operations/replace.js +1 -4
- package/dist/tools/grep/index.d.ts.map +1 -1
- package/dist/tools/grep/index.js +18 -11
- package/dist/tools/index.d.ts +28 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +52 -33
- package/dist/tools/merge-conflicts/index.d.ts.map +1 -1
- package/dist/tools/merge-conflicts/index.js +1 -1
- package/dist/tools/rename-file/index.js +1 -1
- package/dist/tools/review-pull-request/index.d.ts +3 -0
- package/dist/tools/review-pull-request/index.d.ts.map +1 -0
- package/dist/tools/review-pull-request/index.js +89 -0
- package/dist/tools/run-test.d.ts.map +1 -1
- package/dist/tools/run-test.js +25 -3
- package/dist/tools/test-gen-browser.d.ts.map +1 -1
- package/dist/tools/test-gen-browser.js +51 -47
- package/dist/tools/test-run-fetcher/index.d.ts.map +1 -1
- package/dist/tools/test-run-fetcher/index.js +4 -14
- package/dist/tools/utils/urls.d.ts +5 -0
- package/dist/tools/utils/urls.d.ts.map +1 -0
- package/dist/tools/utils/urls.js +19 -0
- package/dist/tools/view-failed-test-run-report/index.d.ts.map +1 -1
- package/dist/tools/view-failed-test-run-report/index.js +3 -15
- package/dist/utils/artifact-paths.d.ts +20 -0
- package/dist/utils/artifact-paths.d.ts.map +1 -0
- package/dist/utils/artifact-paths.js +16 -0
- package/dist/utils/dedup-image-fs.d.ts +2 -16
- package/dist/utils/dedup-image-fs.d.ts.map +1 -1
- package/dist/utils/dedup-image-fs.js +12 -16
- package/dist/utils/dedup-image.d.ts +1 -14
- package/dist/utils/dedup-image.d.ts.map +1 -1
- package/dist/utils/dedup-image.js +7 -62
- package/dist/{tools/fetch-video-analysis/local-ffmpeg-client.d.ts → utils/ffmpeg/index.d.ts} +9 -6
- package/dist/utils/ffmpeg/index.d.ts.map +1 -0
- package/dist/utils/ffmpeg/index.js +415 -0
- package/dist/utils/file.d.ts +1 -0
- package/dist/utils/file.d.ts.map +1 -1
- package/dist/utils/file.js +45 -1
- package/dist/utils/find-threshold.d.ts +8 -0
- package/dist/utils/find-threshold.d.ts.map +1 -0
- package/dist/utils/find-threshold.js +55 -0
- package/dist/utils/hash.d.ts +2 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/hash.js +24 -0
- package/dist/utils/model.d.ts +1 -1
- package/dist/utils/model.d.ts.map +1 -1
- package/dist/utils/model.js +7 -5
- package/dist/utils/repo-tree.d.ts +0 -1
- package/dist/utils/repo-tree.d.ts.map +1 -1
- package/dist/utils/repo-tree.js +2 -14
- package/dist/utils/slug.js +1 -1
- package/dist/video-core/agent-orchestrator.d.ts +14 -0
- package/dist/video-core/agent-orchestrator.d.ts.map +1 -0
- package/dist/video-core/agent-orchestrator.js +78 -0
- package/dist/video-core/analysis-server.d.ts +24 -0
- package/dist/video-core/analysis-server.d.ts.map +1 -0
- package/dist/video-core/analysis-server.js +398 -0
- package/dist/video-core/analysis-viewer.html +1374 -0
- package/dist/video-core/index.d.ts +44 -0
- package/dist/video-core/index.d.ts.map +1 -0
- package/dist/video-core/index.js +204 -0
- package/dist/video-core/model-limits.d.ts +4 -0
- package/dist/video-core/model-limits.d.ts.map +1 -0
- package/dist/video-core/model-limits.js +67 -0
- package/dist/video-core/storage-manager.d.ts +5 -0
- package/dist/video-core/storage-manager.d.ts.map +1 -0
- package/dist/video-core/storage-manager.js +55 -0
- package/dist/video-core/types.d.ts +13 -0
- package/dist/video-core/types.d.ts.map +1 -0
- package/dist/video-core/types.js +2 -0
- package/dist/video-core/utils.d.ts +25 -0
- package/dist/video-core/utils.d.ts.map +1 -0
- package/dist/video-core/utils.js +211 -0
- package/dist/video-core/xml-parser.d.ts +3 -0
- package/dist/video-core/xml-parser.d.ts.map +1 -0
- package/dist/video-core/xml-parser.js +27 -0
- package/package.json +5 -6
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/agent/chat/prompt/index.d.ts +0 -5
- package/dist/agent/chat/prompt/index.d.ts.map +0 -1
- package/dist/agent/chat/prompt/index.js +0 -189
- package/dist/agent/chat/utils/tool-calls.d.ts +0 -21
- package/dist/agent/chat/utils/tool-calls.d.ts.map +0 -1
- package/dist/agent/chat/utils/tool-calls.js +0 -64
- package/dist/agent/code-review/prompt.d.ts +0 -2
- package/dist/agent/code-review/prompt.d.ts.map +0 -1
- package/dist/agent/code-review/prompt.js +0 -19
- package/dist/agent/diagnosis-agent/index.d.ts +0 -11
- package/dist/agent/diagnosis-agent/index.d.ts.map +0 -1
- package/dist/agent/diagnosis-agent/index.js +0 -88
- package/dist/agent/diagnosis-agent/strict-mode-violation.d.ts +0 -10
- package/dist/agent/diagnosis-agent/strict-mode-violation.d.ts.map +0 -1
- package/dist/agent/diagnosis-agent/strict-mode-violation.js +0 -30
- package/dist/tools/commit-and-create-pr/index.d.ts.map +0 -1
- package/dist/tools/commit-and-create-pr/index.js +0 -83
- package/dist/tools/definitions/commit-and-create-pr.d.ts +0 -3
- package/dist/tools/definitions/commit-and-create-pr.d.ts.map +0 -1
- package/dist/tools/definitions/fetch-video-analysis.d.ts.map +0 -1
- package/dist/tools/definitions/fetch-video-analysis.js +0 -61
- package/dist/tools/fetch-video-analysis/index.d.ts +0 -5
- package/dist/tools/fetch-video-analysis/index.d.ts.map +0 -1
- package/dist/tools/fetch-video-analysis/index.js +0 -138
- package/dist/tools/fetch-video-analysis/local-ffmpeg-client.d.ts.map +0 -1
- package/dist/tools/fetch-video-analysis/local-ffmpeg-client.js +0 -247
- package/dist/tools/fetch-video-analysis/open-ai.d.ts +0 -6
- package/dist/tools/fetch-video-analysis/open-ai.d.ts.map +0 -1
- package/dist/tools/fetch-video-analysis/open-ai.js +0 -37
- package/dist/tools/fetch-video-analysis/utils.d.ts +0 -13
- package/dist/tools/fetch-video-analysis/utils.d.ts.map +0 -1
- package/dist/tools/fetch-video-analysis/utils.js +0 -98
- package/dist/tools/fetch-video-analysis/video-analysis.d.ts +0 -7
- package/dist/tools/fetch-video-analysis/video-analysis.d.ts.map +0 -1
- package/dist/tools/fetch-video-analysis/video-analysis.js +0 -54
- package/dist/tools/file-operations/shared/git-helper.d.ts +0 -4
- package/dist/tools/file-operations/shared/git-helper.d.ts.map +0 -1
- package/dist/tools/file-operations/shared/git-helper.js +0 -29
- package/eslint.config.mjs +0 -43
- /package/dist/tools/{commit-and-create-pr → create-pull-request}/index.d.ts +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.analyseVideo = exports.analyseVideoSchema = void 0;
|
|
7
|
+
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
const constants_1 = require("../../constants");
|
|
9
|
+
exports.analyseVideoSchema = zod_1.default.object({
|
|
10
|
+
videoUrl: zod_1.default
|
|
11
|
+
.string()
|
|
12
|
+
.url("Must be a valid URL")
|
|
13
|
+
.describe("The URL of the video to analyze."),
|
|
14
|
+
params: zod_1.default
|
|
15
|
+
.object({
|
|
16
|
+
fps: zod_1.default
|
|
17
|
+
.number()
|
|
18
|
+
.int()
|
|
19
|
+
.min(1)
|
|
20
|
+
.max(constants_1.VIDEO_ANALYSIS.DEFAULT_FPS)
|
|
21
|
+
.default(constants_1.VIDEO_ANALYSIS.DEFAULT_FPS)
|
|
22
|
+
.optional()
|
|
23
|
+
.describe(`Frames per second to extract from the video (default: ${constants_1.VIDEO_ANALYSIS.DEFAULT_FPS})`),
|
|
24
|
+
threshold: zod_1.default
|
|
25
|
+
.number()
|
|
26
|
+
.min(0)
|
|
27
|
+
.max(0.5)
|
|
28
|
+
.default(constants_1.VIDEO_ANALYSIS.DEFAULT_THRESHOLD)
|
|
29
|
+
.optional()
|
|
30
|
+
.describe(`Deduplication threshold (fraction of pixels that may differ to consider frames identical). Higher = stricter (Less Number of unique frames). Default: ${constants_1.VIDEO_ANALYSIS.DEFAULT_THRESHOLD}`),
|
|
31
|
+
startTime: zod_1.default
|
|
32
|
+
.number()
|
|
33
|
+
.optional()
|
|
34
|
+
.describe("Start time in seconds, example 1 min 32 sec -> 92"),
|
|
35
|
+
duration: zod_1.default
|
|
36
|
+
.number()
|
|
37
|
+
.optional()
|
|
38
|
+
.describe("Duration time in seconds, example 1 min 32 sec -> 92"),
|
|
39
|
+
model: zod_1.default
|
|
40
|
+
.string()
|
|
41
|
+
.default(constants_1.VIDEO_ANALYSIS.DEFAULT_MODEL)
|
|
42
|
+
.optional()
|
|
43
|
+
.describe(`LLM model identifier to use for analysis defaults to ${constants_1.VIDEO_ANALYSIS.DEFAULT_MODEL}`),
|
|
44
|
+
})
|
|
45
|
+
.optional(),
|
|
46
|
+
});
|
|
47
|
+
exports.analyseVideo = {
|
|
48
|
+
schema: {
|
|
49
|
+
name: "analyseVideo",
|
|
50
|
+
description: `
|
|
51
|
+
Analyzes videos to summarise.
|
|
52
|
+
|
|
53
|
+
**Input:** The video URL is mandatory (supports webm, mp4). DO NOT specify params UNLESS the user has explicitly asked for a specific param value to be tested.
|
|
54
|
+
**Output:** analysis summary of what happened during the test execution.
|
|
55
|
+
**Use when:** You have a failing test with a video recording and need to understand what went wrong`,
|
|
56
|
+
parameters: exports.analyseVideoSchema,
|
|
57
|
+
},
|
|
58
|
+
needsBrowser: false,
|
|
59
|
+
isInlineTool: false,
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review-pull-request.d.ts","sourceRoot":"","sources":["../../../src/tools/definitions/review-pull-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAOjE,eAAO,MAAM,qBAAqB,EAAE,cAQnC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reviewPullRequestTool = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const ReviewPullRequestInputSchema = zod_1.z.object({
|
|
6
|
+
sessionUrl: zod_1.z.string().describe("The URL of the chat session to review"),
|
|
7
|
+
});
|
|
8
|
+
exports.reviewPullRequestTool = {
|
|
9
|
+
schema: {
|
|
10
|
+
name: "reviewPullRequest",
|
|
11
|
+
description: `Reviews a pull request by using CodeReviewAgent to fetch session diff and analyze it. Returns a boolean result with an explanation.`,
|
|
12
|
+
parameters: ReviewPullRequestInputSchema,
|
|
13
|
+
},
|
|
14
|
+
needsBrowser: false,
|
|
15
|
+
isInlineTool: true,
|
|
16
|
+
};
|
|
@@ -1 +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;AA6E5D,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAK1D,CAAC"}
|
|
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;AA6E5D,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAK1D,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAExD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.textEditorTools = void 0;
|
|
3
|
+
exports.textViewTools = exports.textEditorTools = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const fileViewTool = {
|
|
6
6
|
schema: {
|
|
@@ -76,3 +76,6 @@ exports.textEditorTools = {
|
|
|
76
76
|
stringReplaceTool: stringReplaceTool,
|
|
77
77
|
stringInsertTool: stringInsertTool,
|
|
78
78
|
};
|
|
79
|
+
exports.textViewTools = {
|
|
80
|
+
fileViewTool: fileViewTool,
|
|
81
|
+
};
|
|
@@ -3,7 +3,6 @@ import { z } from "zod";
|
|
|
3
3
|
export declare const BrowserAgentSchema: z.ZodObject<{
|
|
4
4
|
project: z.ZodString;
|
|
5
5
|
buildUrl: z.ZodOptional<z.ZodString>;
|
|
6
|
-
changeToMake: z.ZodString;
|
|
7
6
|
testName: z.ZodString;
|
|
8
7
|
suites: z.ZodArray<z.ZodString, "many">;
|
|
9
8
|
filePath: z.ZodString;
|
|
@@ -12,14 +11,12 @@ export declare const BrowserAgentSchema: z.ZodObject<{
|
|
|
12
11
|
testName: string;
|
|
13
12
|
filePath: string;
|
|
14
13
|
project: string;
|
|
15
|
-
changeToMake: string;
|
|
16
14
|
buildUrl?: string | undefined;
|
|
17
15
|
}, {
|
|
18
16
|
suites: string[];
|
|
19
17
|
testName: string;
|
|
20
18
|
filePath: string;
|
|
21
19
|
project: string;
|
|
22
|
-
changeToMake: string;
|
|
23
20
|
buildUrl?: string | undefined;
|
|
24
21
|
}>;
|
|
25
22
|
export declare const generateTestWithBrowserAgent: ToolDefinition;
|
|
@@ -1 +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;AAQxB,eAAO,MAAM,kBAAkB
|
|
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;AAQxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;EAe7B,CAAC;AAsFH,eAAO,MAAM,4BAA4B,EAAE,cAQ1C,CAAC"}
|
|
@@ -15,7 +15,6 @@ exports.BrowserAgentSchema = zod_1.z.object({
|
|
|
15
15
|
.describe(`The URL of the build to run the test on.
|
|
16
16
|
This is ONLY useful for preview deployments that are dynamically created on every pull request, like Vercel preview deployments.
|
|
17
17
|
For all other cases, the build url does not need to be provided, since it is already hard coded in the test repo.`),
|
|
18
|
-
changeToMake: zod_1.z.string().describe("The change to make to the test"),
|
|
19
18
|
});
|
|
20
19
|
const BROWSER_AGENT_DESCRIPTION = `
|
|
21
20
|
Create or modify a test case with browser agent. The browser agent can take user interactions in a web browser
|
|
@@ -23,16 +22,34 @@ and generate Playwright code for that actions. This is a useful tool when the mo
|
|
|
23
22
|
locator/selector for an element on the page.
|
|
24
23
|
|
|
25
24
|
IMPORTANT: Before you invoke this tool, you need to ensure that the test code is correctly prepared for this
|
|
26
|
-
agent.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
agent.
|
|
26
|
+
|
|
27
|
+
## Preparation
|
|
28
|
+
|
|
29
|
+
You can do this by using one of the text editor tools to add a TODO comment to the test
|
|
30
|
+
code. This comment explains to the browser agent what it needs to do.
|
|
31
|
+
|
|
32
|
+
For example, if the expected modification is to click on a login button, you could add the following comment.
|
|
33
|
+
|
|
34
|
+
// TODO(agent): Click on the login button
|
|
35
|
+
|
|
36
|
+
The position of the comment is important: the test code before this line will be executed as any Playwright test,
|
|
37
|
+
and the browser agent will be invoked when the test encounters the TODO. The browser agent will respond with
|
|
38
|
+
Playwright code (with element selectors) for the action and YOU will be responsible to replace the TODO comment with
|
|
39
|
+
the actual code to click on the login button. If you are fixing a failing test, your comment should be
|
|
40
|
+
before the failing line of code, so that it can be replaced/modified.
|
|
41
|
+
|
|
42
|
+
You can optionally, add a page variable name where the actions must be performed. In this case, the TODO comment
|
|
43
|
+
will look like "// TODO(agent on pageName)" to indicate which page the action is to be performed on. The browser
|
|
44
|
+
agent cannot switch pages, so use multiple invocations if you need to perform actions on multiple pages.
|
|
30
45
|
|
|
31
46
|
To choose the page variable name, go through the test code and find available page variables. If you are replacing some
|
|
32
47
|
existing test code, use the same page variable name as in the existing test code. If you are adding steps to the test,
|
|
33
48
|
use the page variable name that is appropriate for the new steps. The page variable represents the browser page (or tab) that
|
|
34
49
|
the agent is supposed to interact with.
|
|
35
50
|
|
|
51
|
+
## Examples
|
|
52
|
+
|
|
36
53
|
For example, this is a good TODO comment:
|
|
37
54
|
|
|
38
55
|
\`\`\`
|
|
@@ -42,9 +59,11 @@ test("Example test code", async ({ page }) => {
|
|
|
42
59
|
});
|
|
43
60
|
\`\`\`
|
|
44
61
|
|
|
45
|
-
For the above file, the browser environment will execute the steps before the TODO comment and hand-over
|
|
46
|
-
to the browser agent. The agent will do the actions described in the TODO comment and then
|
|
47
|
-
test code.
|
|
62
|
+
For the above file, the browser environment will execute the steps before the TODO comment (page goto) and hand-over
|
|
63
|
+
the control to the browser agent. The agent will do the actions described in the TODO comment and then
|
|
64
|
+
resume control back to the test code.
|
|
65
|
+
|
|
66
|
+
## Caveat: Multi-line statements
|
|
48
67
|
|
|
49
68
|
Note that you CANNOT add TODO comments in the middle of a multi-line statement. This will break the tool.
|
|
50
69
|
|
|
@@ -73,6 +92,12 @@ test("Example test code", async ({ page }) => {
|
|
|
73
92
|
|
|
74
93
|
After execution, the browser agent will return a summary of actions that it took, and the generated Playwright code for them.
|
|
75
94
|
You can then use the text editor tool to replace the TODO comment with the generated Playwright code.
|
|
95
|
+
|
|
96
|
+
## Caveat: Multiple TODO comments
|
|
97
|
+
|
|
98
|
+
This tool only works on the first TODO comment in the file, and the tool response will confirm the TODO comment that
|
|
99
|
+
it worked on. If you have multiple TODO comments, you will need to run the tool multiple times. Remember to replace the
|
|
100
|
+
TODO comment with the generated Playwright code and run the tool again.
|
|
76
101
|
`;
|
|
77
102
|
exports.generateTestWithBrowserAgent = {
|
|
78
103
|
schema: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/delete-file/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/delete-file/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,4BAA4B,CAAC;AAQnE,eAAO,MAAM,cAAc,EAAE,IA2D5B,CAAC"}
|
|
@@ -9,7 +9,6 @@ const promises_1 = require("fs/promises");
|
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const web_1 = require("../../bin/utils/platform/web");
|
|
11
11
|
const delete_file_1 = require("../definitions/delete-file");
|
|
12
|
-
const git_1 = require("../executor/utils/git");
|
|
13
12
|
exports.deleteFileTool = {
|
|
14
13
|
...delete_file_1.deleteFileTool,
|
|
15
14
|
execute: async ({ input, repoPath, collectArtifacts, }) => {
|
|
@@ -42,29 +41,12 @@ exports.deleteFileTool = {
|
|
|
42
41
|
await (0, promises_1.unlink)(filePath);
|
|
43
42
|
// Stage the deletion
|
|
44
43
|
(0, child_process_1.execSync)(`git add "${input.path}"`, { cwd: repoPath });
|
|
45
|
-
// Collect git patch artifact after deletion
|
|
46
|
-
if (collectArtifacts) {
|
|
47
|
-
try {
|
|
48
|
-
const gitPatch = (0, git_1.getGitDiffStaged)(input.path, repoPath);
|
|
49
|
-
if (gitPatch.trim()) {
|
|
50
|
-
const patchArtifact = {
|
|
51
|
-
name: `${path_1.default.basename(input.path, path_1.default.extname(input.path))}_delete.patch`,
|
|
52
|
-
contentType: "text/plain",
|
|
53
|
-
data: Buffer.from(gitPatch, "utf-8"),
|
|
54
|
-
};
|
|
55
|
-
collectArtifacts([patchArtifact]);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
console.warn("Failed to create git patch artifact:", error);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
44
|
// Run TypeScript compilation check
|
|
63
45
|
const tscResult = await (0, web_1.runTypescriptCompiler)(repoPath);
|
|
64
46
|
if (!tscResult.success) {
|
|
65
47
|
return {
|
|
66
48
|
result: `File ${input.path} has been deleted. However, type checks are failing with errors:\n\n${tscResult.errors.join("\n")}`,
|
|
67
|
-
isError:
|
|
49
|
+
isError: false,
|
|
68
50
|
};
|
|
69
51
|
}
|
|
70
52
|
return {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TraceClient } from "@empiricalrun/llm";
|
|
2
|
+
import { PendingToolCall, ToolResult } from "@empiricalrun/llm/chat";
|
|
3
|
+
import type { ChatSessionInfo, IDashboardAPIClient, Logger, MessageCheckpoint, Tool, ToolExecute } from "@empiricalrun/shared-types";
|
|
4
|
+
export type BaseToolExecutorProps = {
|
|
5
|
+
tools: Array<Tool>;
|
|
6
|
+
chatSession: ChatSessionInfo | {
|
|
7
|
+
branchName: string;
|
|
8
|
+
} | null;
|
|
9
|
+
repoPath: string;
|
|
10
|
+
apiClient?: IDashboardAPIClient;
|
|
11
|
+
trace?: TraceClient;
|
|
12
|
+
featureFlags: string[];
|
|
13
|
+
environmentOverrides?: Record<string, string>;
|
|
14
|
+
logger?: Logger;
|
|
15
|
+
};
|
|
16
|
+
export declare class BaseToolExecutor {
|
|
17
|
+
toolExecutors: Record<string, ToolExecute>;
|
|
18
|
+
featureFlags: string[];
|
|
19
|
+
chatSession: ChatSessionInfo | null;
|
|
20
|
+
branchName: string | null;
|
|
21
|
+
repoPath: string;
|
|
22
|
+
apiClient: IDashboardAPIClient | undefined;
|
|
23
|
+
trace?: TraceClient;
|
|
24
|
+
environmentOverrides: Record<string, string>;
|
|
25
|
+
logger: Logger;
|
|
26
|
+
constructor({ tools, chatSession, repoPath, apiClient, trace, featureFlags, environmentOverrides, logger, }: BaseToolExecutorProps);
|
|
27
|
+
execute(toolCalls: PendingToolCall[]): Promise<{
|
|
28
|
+
toolResults: ToolResult[];
|
|
29
|
+
checkpoint: MessageCheckpoint | null;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/tools/executor/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,KAAK,EACV,eAAe,EAEf,mBAAmB,EACnB,MAAM,EACN,iBAAiB,EACjB,IAAI,EACJ,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAapC,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACnB,WAAW,EAAE,eAAe,GAAG;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC7D,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAChC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,qBAAa,gBAAgB;IAC3B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAM;IAChD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,eAAe,GAAG,IAAI,CAAC;IACpC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,mBAAmB,GAAG,SAAS,CAAC;IAC3C,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,MAAM,EAAE,MAAM,CAAC;gBAEH,EACV,KAAK,EACL,WAAW,EACX,QAAQ,EACR,SAAS,EACT,KAAK,EACL,YAAY,EACZ,oBAAoB,EACpB,MAAM,GACP,EAAE,qBAAqB;IAuBlB,OAAO,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;QACnD,WAAW,EAAE,UAAU,EAAE,CAAC;QAC1B,UAAU,EAAE,iBAAiB,GAAG,IAAI,CAAC;KACtC,CAAC;CAiFH"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseToolExecutor = void 0;
|
|
4
|
+
const artifacts_1 = require("../../artifacts");
|
|
5
|
+
const file_operations_1 = require("../file-operations");
|
|
6
|
+
const checkpoint_1 = require("./utils/checkpoint");
|
|
7
|
+
const LOGGER = {
|
|
8
|
+
info: (msg, meta) => console.log(`[info] ${msg}`, meta || ""),
|
|
9
|
+
error: (msg, meta) => console.error(`[error] ${msg}`, meta || ""),
|
|
10
|
+
warn: (msg, meta) => console.warn(`[warn] ${msg}`, meta || ""),
|
|
11
|
+
debug: (msg, meta) => console.debug(`[debug] ${msg}`, meta || ""),
|
|
12
|
+
};
|
|
13
|
+
class BaseToolExecutor {
|
|
14
|
+
toolExecutors = {};
|
|
15
|
+
featureFlags;
|
|
16
|
+
chatSession;
|
|
17
|
+
branchName;
|
|
18
|
+
repoPath;
|
|
19
|
+
apiClient;
|
|
20
|
+
trace;
|
|
21
|
+
environmentOverrides;
|
|
22
|
+
logger;
|
|
23
|
+
constructor({ tools, chatSession, repoPath, apiClient, trace, featureFlags, environmentOverrides, logger, }) {
|
|
24
|
+
this.chatSession = chatSession && "id" in chatSession ? chatSession : null;
|
|
25
|
+
this.branchName = chatSession?.branchName || null;
|
|
26
|
+
this.trace = trace;
|
|
27
|
+
this.repoPath = repoPath;
|
|
28
|
+
this.apiClient = apiClient;
|
|
29
|
+
this.featureFlags = featureFlags;
|
|
30
|
+
this.environmentOverrides = environmentOverrides || {};
|
|
31
|
+
// Build toolExecutors
|
|
32
|
+
let toolExecutors = {};
|
|
33
|
+
tools.forEach((tool) => {
|
|
34
|
+
toolExecutors[tool.schema.name] = tool.execute;
|
|
35
|
+
});
|
|
36
|
+
this.toolExecutors = {
|
|
37
|
+
...toolExecutors,
|
|
38
|
+
// Support for Claude 3x and 4: They use different tool names
|
|
39
|
+
str_replace_editor: file_operations_1.strReplaceEditorExecutor,
|
|
40
|
+
str_replace_based_edit_tool: file_operations_1.strReplaceEditorExecutor,
|
|
41
|
+
};
|
|
42
|
+
this.logger = logger || LOGGER;
|
|
43
|
+
}
|
|
44
|
+
async execute(toolCalls) {
|
|
45
|
+
const executeSpan = this.trace?.span({
|
|
46
|
+
name: "execute_tools",
|
|
47
|
+
input: { toolCalls: toolCalls.map((tc) => ({ name: tc.name })) },
|
|
48
|
+
});
|
|
49
|
+
const toolResults = [];
|
|
50
|
+
for (const toolCall of toolCalls) {
|
|
51
|
+
const span = executeSpan?.span({
|
|
52
|
+
name: `tool: ${toolCall.name}`,
|
|
53
|
+
input: toolCall.input,
|
|
54
|
+
});
|
|
55
|
+
const uploadArtifactsQueue = new artifacts_1.UploadArtifactsQueue(this.repoPath, toolCall.id);
|
|
56
|
+
const collectArtifactsFn = async (artifactsInput, callback) => {
|
|
57
|
+
const uploadedArtifacts = await uploadArtifactsQueue.addTask(artifactsInput);
|
|
58
|
+
if (callback) {
|
|
59
|
+
callback(uploadedArtifacts);
|
|
60
|
+
}
|
|
61
|
+
return uploadedArtifacts;
|
|
62
|
+
};
|
|
63
|
+
const toolExecutor = this.toolExecutors[toolCall.name];
|
|
64
|
+
if (!toolExecutor) {
|
|
65
|
+
const errorResult = {
|
|
66
|
+
isError: true,
|
|
67
|
+
result: `Invalid function/tool call: ${toolCall.name} not found`,
|
|
68
|
+
artifacts: null,
|
|
69
|
+
};
|
|
70
|
+
toolResults.push(errorResult);
|
|
71
|
+
span?.end({ output: errorResult });
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const result = await toolExecutor({
|
|
76
|
+
input: toolCall.input,
|
|
77
|
+
repoPath: this.repoPath,
|
|
78
|
+
apiClient: this.apiClient,
|
|
79
|
+
trace: this.trace,
|
|
80
|
+
chatSession: this.chatSession,
|
|
81
|
+
collectArtifacts: collectArtifactsFn,
|
|
82
|
+
environmentOverrides: this.environmentOverrides,
|
|
83
|
+
featureFlags: this.featureFlags,
|
|
84
|
+
logger: this.logger,
|
|
85
|
+
});
|
|
86
|
+
const artifacts = await uploadArtifactsQueue.waitForCompletion();
|
|
87
|
+
toolResults.push({ ...result, artifacts });
|
|
88
|
+
span?.end({ output: result });
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
const errorResult = {
|
|
92
|
+
isError: true,
|
|
93
|
+
result: error instanceof Error ? error.message : String(error),
|
|
94
|
+
artifacts: null,
|
|
95
|
+
};
|
|
96
|
+
toolResults.push(errorResult);
|
|
97
|
+
span?.end({ output: errorResult });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
let checkpoint = null;
|
|
101
|
+
if (this.branchName) {
|
|
102
|
+
const commit = (0, checkpoint_1.createCommitCheckpoint)({
|
|
103
|
+
branchName: this.branchName,
|
|
104
|
+
repoPath: this.repoPath,
|
|
105
|
+
});
|
|
106
|
+
if (commit) {
|
|
107
|
+
checkpoint = { commit };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
executeSpan?.end({ output: { toolResults, checkpoint } });
|
|
111
|
+
return { toolResults, checkpoint };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.BaseToolExecutor = BaseToolExecutor;
|
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export declare class ToolExecutor {
|
|
5
|
-
toolExecutors: Record<string, ToolExecute>;
|
|
6
|
-
chatSession: ChatSessionInfo | null;
|
|
7
|
-
branchName: string;
|
|
8
|
-
repoPath: string;
|
|
9
|
-
apiClient: IDashboardAPIClient;
|
|
10
|
-
trace?: TraceClient;
|
|
11
|
-
featureFlags: string[];
|
|
12
|
-
environmentOverrides: Record<string, string>;
|
|
13
|
-
constructor({ chatSession, branchName, repoPath, apiClient, trace, featureFlags, environmentOverrides, }: {
|
|
14
|
-
chatSession: ChatSessionInfo | null;
|
|
15
|
-
branchName: string;
|
|
16
|
-
repoPath: string;
|
|
17
|
-
apiClient: IDashboardAPIClient;
|
|
18
|
-
trace?: TraceClient;
|
|
19
|
-
featureFlags: string[];
|
|
20
|
-
environmentOverrides?: Record<string, string>;
|
|
21
|
-
});
|
|
22
|
-
execute(toolCalls: PendingToolCall[]): Promise<ToolResult[]>;
|
|
1
|
+
import { BaseToolExecutor, BaseToolExecutorProps } from "./base";
|
|
2
|
+
export declare class ToolExecutor extends BaseToolExecutor {
|
|
3
|
+
constructor(params: Omit<BaseToolExecutorProps, "tools">);
|
|
23
4
|
}
|
|
24
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/executor/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/executor/index.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAEjE,qBAAa,YAAa,SAAQ,gBAAgB;gBACpC,MAAM,EAAE,IAAI,CAAC,qBAAqB,EAAE,OAAO,CAAC;CAgCzD"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ToolExecutor = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const analyse_video_1 = require("../analyse-video");
|
|
5
|
+
const create_pull_request_1 = require("../create-pull-request");
|
|
6
6
|
const delete_file_1 = require("../delete-file");
|
|
7
7
|
const diagnosis_fetcher_1 = require("../diagnosis-fetcher");
|
|
8
8
|
const download_build_1 = require("../download-build");
|
|
9
9
|
const fetch_file_1 = require("../fetch-file");
|
|
10
10
|
const fetch_last_successful_test_run_1 = require("../fetch-last-successful-test-run");
|
|
11
|
-
const
|
|
11
|
+
const fetch_session_diff_1 = require("../fetch-session-diff");
|
|
12
12
|
const file_operations_1 = require("../file-operations");
|
|
13
13
|
const grep_1 = require("../grep");
|
|
14
14
|
const issues_1 = require("../issues");
|
|
@@ -16,6 +16,7 @@ const list_environments_1 = require("../list-environments");
|
|
|
16
16
|
const list_tests_and_projects_1 = require("../list-tests-and-projects");
|
|
17
17
|
const merge_conflicts_1 = require("../merge-conflicts");
|
|
18
18
|
const rename_file_1 = require("../rename-file");
|
|
19
|
+
const review_pull_request_1 = require("../review-pull-request");
|
|
19
20
|
const run_test_1 = require("../run-test");
|
|
20
21
|
const test_gen_browser_1 = require("../test-gen-browser");
|
|
21
22
|
const test_run_fetcher_1 = require("../test-run-fetcher");
|
|
@@ -23,24 +24,9 @@ const trace_dot_zip_1 = require("../trace-dot-zip");
|
|
|
23
24
|
const triage_summary_1 = require("../triage-summary");
|
|
24
25
|
const upgrade_packages_1 = require("../upgrade-packages");
|
|
25
26
|
const view_failed_test_run_report_1 = require("../view-failed-test-run-report");
|
|
26
|
-
const
|
|
27
|
-
class ToolExecutor {
|
|
28
|
-
|
|
29
|
-
chatSession;
|
|
30
|
-
branchName;
|
|
31
|
-
repoPath;
|
|
32
|
-
apiClient;
|
|
33
|
-
trace;
|
|
34
|
-
featureFlags;
|
|
35
|
-
environmentOverrides;
|
|
36
|
-
constructor({ chatSession, branchName, repoPath, apiClient, trace, featureFlags, environmentOverrides = {}, }) {
|
|
37
|
-
this.chatSession = chatSession;
|
|
38
|
-
this.branchName = branchName;
|
|
39
|
-
this.trace = trace;
|
|
40
|
-
this.repoPath = repoPath;
|
|
41
|
-
this.apiClient = apiClient;
|
|
42
|
-
this.featureFlags = featureFlags;
|
|
43
|
-
this.environmentOverrides = environmentOverrides;
|
|
27
|
+
const base_1 = require("./base");
|
|
28
|
+
class ToolExecutor extends base_1.BaseToolExecutor {
|
|
29
|
+
constructor(params) {
|
|
44
30
|
// Found for "Tool Executor Tools List" and add any new tools to the list
|
|
45
31
|
const tools = [
|
|
46
32
|
grep_1.grepTool,
|
|
@@ -48,7 +34,7 @@ class ToolExecutor {
|
|
|
48
34
|
test_run_fetcher_1.fetchTestRunReportTool,
|
|
49
35
|
diagnosis_fetcher_1.fetchDiagnosisReportTool,
|
|
50
36
|
test_gen_browser_1.generateTestWithBrowserAgent,
|
|
51
|
-
|
|
37
|
+
create_pull_request_1.createPullRequestTool,
|
|
52
38
|
merge_conflicts_1.mergeConflictsTool,
|
|
53
39
|
list_environments_1.listEnvironmentsTool,
|
|
54
40
|
issues_1.listIssuesTool,
|
|
@@ -56,7 +42,7 @@ class ToolExecutor {
|
|
|
56
42
|
download_build_1.downloadBuildTool,
|
|
57
43
|
upgrade_packages_1.upgradePackagesTool,
|
|
58
44
|
fetch_file_1.fetchFileTool,
|
|
59
|
-
|
|
45
|
+
analyse_video_1.analyseVideo,
|
|
60
46
|
delete_file_1.deleteFileTool,
|
|
61
47
|
rename_file_1.renameFileTool,
|
|
62
48
|
trace_dot_zip_1.traceDotZipTool,
|
|
@@ -65,77 +51,12 @@ class ToolExecutor {
|
|
|
65
51
|
fetch_last_successful_test_run_1.fetchLastSuccessfulTestRunTool,
|
|
66
52
|
triage_summary_1.sendTriageSummaryTool,
|
|
67
53
|
list_tests_and_projects_1.listProjectsTool,
|
|
54
|
+
fetch_session_diff_1.fetchSessionDiffTool,
|
|
55
|
+
review_pull_request_1.reviewPullRequestTool,
|
|
56
|
+
list_tests_and_projects_1.listTestsForProjectTool,
|
|
68
57
|
...file_operations_1.textEditorTools,
|
|
69
58
|
];
|
|
70
|
-
|
|
71
|
-
this.toolExecutors[tool.schema.name] = tool.execute;
|
|
72
|
-
});
|
|
73
|
-
this.toolExecutors = {
|
|
74
|
-
...this.toolExecutors,
|
|
75
|
-
// Support for Claude 3x and 4: They use different tool names
|
|
76
|
-
str_replace_editor: file_operations_1.strReplaceEditorExecutor,
|
|
77
|
-
str_replace_based_edit_tool: file_operations_1.strReplaceEditorExecutor,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
async execute(toolCalls) {
|
|
81
|
-
const executeSpan = this.trace?.span({
|
|
82
|
-
name: "execute_tools",
|
|
83
|
-
input: { toolCalls: toolCalls.map((tc) => ({ name: tc.name })) },
|
|
84
|
-
});
|
|
85
|
-
const toolResults = [];
|
|
86
|
-
for (const toolCall of toolCalls) {
|
|
87
|
-
const span = executeSpan?.span({
|
|
88
|
-
name: `tool: ${toolCall.name}`,
|
|
89
|
-
input: toolCall.input,
|
|
90
|
-
});
|
|
91
|
-
const uploadArtifactsQueue = new artifacts_1.UploadArtifactsQueue(this.repoPath, toolCall.id);
|
|
92
|
-
const collectArtifactsFn = (artifactsInput) => {
|
|
93
|
-
uploadArtifactsQueue.addTask(artifactsInput).catch((error) => {
|
|
94
|
-
console.error("Error collecting artifacts:", error);
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
const toolExecutor = this.toolExecutors[toolCall.name];
|
|
98
|
-
if (!toolExecutor) {
|
|
99
|
-
const errorResult = {
|
|
100
|
-
isError: true,
|
|
101
|
-
result: `Invalid function/tool call: ${toolCall.name} not found`,
|
|
102
|
-
artifacts: null,
|
|
103
|
-
};
|
|
104
|
-
toolResults.push(errorResult);
|
|
105
|
-
span?.end({ output: errorResult });
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
try {
|
|
109
|
-
const result = await toolExecutor({
|
|
110
|
-
input: toolCall.input,
|
|
111
|
-
repoPath: this.repoPath,
|
|
112
|
-
apiClient: this.apiClient,
|
|
113
|
-
trace: this.trace,
|
|
114
|
-
chatSession: this.chatSession,
|
|
115
|
-
collectArtifacts: collectArtifactsFn,
|
|
116
|
-
environmentOverrides: this.environmentOverrides,
|
|
117
|
-
featureFlags: this.featureFlags,
|
|
118
|
-
});
|
|
119
|
-
const artifacts = await uploadArtifactsQueue.waitForCompletion();
|
|
120
|
-
toolResults.push({ ...result, artifacts });
|
|
121
|
-
span?.end({ output: result });
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
const errorResult = {
|
|
125
|
-
isError: true,
|
|
126
|
-
result: error instanceof Error ? error.message : String(error),
|
|
127
|
-
artifacts: null,
|
|
128
|
-
};
|
|
129
|
-
toolResults.push(errorResult);
|
|
130
|
-
span?.end({ output: errorResult });
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
(0, checkpoint_1.createCommitCheckpoint)({
|
|
134
|
-
branchName: this.branchName,
|
|
135
|
-
repoPath: this.repoPath,
|
|
136
|
-
});
|
|
137
|
-
executeSpan?.end({ output: { toolResults } });
|
|
138
|
-
return toolResults;
|
|
59
|
+
super({ ...params, tools });
|
|
139
60
|
}
|
|
140
61
|
}
|
|
141
62
|
exports.ToolExecutor = ToolExecutor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkpoint.d.ts","sourceRoot":"","sources":["../../../../src/tools/executor/utils/checkpoint.ts"],"names":[],"mappings":"AAIA,wBAAgB,sBAAsB,CAAC,EACrC,UAAU,EACV,QAAQ,GACT,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,
|
|
1
|
+
{"version":3,"file":"checkpoint.d.ts","sourceRoot":"","sources":["../../../../src/tools/executor/utils/checkpoint.ts"],"names":[],"mappings":"AAIA,wBAAgB,sBAAsB,CAAC,EACrC,UAAU,EACV,QAAQ,GACT,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,GAAG,IAAI,CA2BhB"}
|
|
@@ -20,7 +20,11 @@ function createCommitCheckpoint({ branchName, repoPath, }) {
|
|
|
20
20
|
});
|
|
21
21
|
const commitMessage = commitMessages.join(", ");
|
|
22
22
|
// Files are already staged by individual tools, just commit
|
|
23
|
-
(0, git_1.commitAsBotUser)(commitMessage, repoPath);
|
|
24
|
-
(
|
|
23
|
+
const commitSha = (0, git_1.commitAsBotUser)(commitMessage, repoPath);
|
|
24
|
+
if (commitSha) {
|
|
25
|
+
(0, child_process_1.execSync)(`git push origin ${branchName}`, { cwd: repoPath });
|
|
26
|
+
}
|
|
27
|
+
return commitSha;
|
|
25
28
|
}
|
|
29
|
+
return null;
|
|
26
30
|
}
|
|
@@ -4,14 +4,14 @@ export declare function getGitDiffStaged(filepath: string, cwd: string): string;
|
|
|
4
4
|
export declare function getGitDiffForStagedOrUnstaged(filepath: string, cwd: string): string;
|
|
5
5
|
export declare function getGitDiffForNewFile(filepath: string, cwd: string): string;
|
|
6
6
|
export declare function checkoutBranch(branchName: string, cwd: string): Promise<void>;
|
|
7
|
-
export declare function commitAsBotUser(commitMessage: string, cwd: string):
|
|
7
|
+
export declare function commitAsBotUser(commitMessage: string, cwd: string): string | null;
|
|
8
8
|
export declare function getCurrentBranchName(repoPath: string): Promise<string>;
|
|
9
9
|
export declare function pullBranch(branchName: string, cwd: string): Promise<void>;
|
|
10
10
|
export declare function stageAndCommitFilesAsBotUser({ commitMessage, files, repoPath, }: {
|
|
11
11
|
commitMessage: string;
|
|
12
12
|
files: string[];
|
|
13
13
|
repoPath: string;
|
|
14
|
-
}):
|
|
14
|
+
}): string | null;
|
|
15
15
|
export type FileChange = {
|
|
16
16
|
type: "added" | "modified" | "removed" | "renamed";
|
|
17
17
|
path: string;
|