@empiricalrun/test-gen 0.76.0 → 0.78.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 +47 -0
- package/dist/agent/base/index.d.ts +25 -21
- package/dist/agent/base/index.d.ts.map +1 -1
- package/dist/agent/base/index.js +50 -37
- 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 +5 -5
- package/dist/agent/chat/agent-loop.d.ts.map +1 -1
- package/dist/agent/chat/agent-loop.js +3 -8
- package/dist/agent/chat/exports.d.ts +6 -5
- package/dist/agent/chat/exports.d.ts.map +1 -1
- package/dist/agent/chat/exports.js +4 -9
- package/dist/agent/chat/index.d.ts +2 -2
- package/dist/agent/chat/index.d.ts.map +1 -1
- package/dist/agent/chat/index.js +23 -35
- 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 -14
- package/dist/agent/chat/state.d.ts.map +1 -1
- package/dist/agent/chat/state.js +15 -60
- package/dist/agent/chat/utils.d.ts +2 -2
- package/dist/agent/chat/utils.d.ts.map +1 -1
- package/dist/agent/chat/utils.js +14 -7
- package/dist/agent/cli.d.ts.map +1 -1
- package/dist/agent/cli.js +49 -58
- 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 +8 -3
- package/dist/agent/code-review/index.d.ts.map +1 -1
- package/dist/agent/code-review/index.js +118 -21
- 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/triage/index.d.ts +3 -3
- package/dist/agent/triage/index.d.ts.map +1 -1
- package/dist/agent/triage/index.js +16 -20
- 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 +2 -2
- package/dist/agent/video-analysis/index.d.ts.map +1 -1
- package/dist/agent/video-analysis/index.js +38 -13
- 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 +11 -21
- 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/reader.d.ts +1 -1
- package/dist/file-info/adapters/github/reader.d.ts.map +1 -1
- package/dist/file-info/adapters/github/reader.js +8 -5
- 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 +56 -0
- package/dist/tools/create-pull-request/index.js +4 -6
- package/dist/tools/create-pull-request/utils.d.ts +1 -1
- 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 +131 -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 +7 -100
- 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 +5 -3
- package/dist/tools/executor/utils/index.d.ts.map +1 -1
- package/dist/tools/executor/utils/index.js +23 -2
- package/dist/tools/fetch-session-diff/index.js +2 -2
- 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 +21 -25
- package/dist/tools/file-operations/shared/helpers.d.ts +3 -5
- package/dist/tools/file-operations/shared/helpers.d.ts.map +1 -1
- package/dist/tools/file-operations/shared/helpers.js +1 -5
- package/dist/tools/grep/index.d.ts.map +1 -1
- package/dist/tools/grep/index.js +18 -11
- package/dist/tools/index.d.ts +5 -5
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +17 -16
- 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.map +1 -1
- package/dist/tools/review-pull-request/index.js +44 -65
- 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/upgrade-packages/index.d.ts.map +1 -1
- package/dist/tools/upgrade-packages/index.js +4 -0
- package/dist/tools/upgrade-packages/utils.d.ts +1 -0
- package/dist/tools/upgrade-packages/utils.d.ts.map +1 -1
- package/dist/tools/upgrade-packages/utils.js +1 -0
- package/dist/trace-utils/index.d.ts +1 -1
- package/dist/trace-utils/index.d.ts.map +1 -1
- package/dist/trace-utils/index.js +1 -1
- package/dist/utils/dedup/dedup-image.d.ts +22 -0
- package/dist/utils/dedup/dedup-image.d.ts.map +1 -0
- package/dist/utils/dedup/dedup-image.js +26 -0
- package/dist/utils/dedup/find-threshold.d.ts +2 -0
- package/dist/utils/dedup/find-threshold.d.ts.map +1 -0
- package/dist/utils/dedup/find-threshold.js +42 -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 +13 -0
- package/dist/video-core/agent-orchestrator.d.ts.map +1 -0
- package/dist/video-core/agent-orchestrator.js +59 -0
- package/dist/video-core/index.d.ts +39 -0
- package/dist/video-core/index.d.ts.map +1 -0
- package/dist/video-core/index.js +134 -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 +73 -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 +62 -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 +15 -0
- package/dist/video-core/utils.d.ts.map +1 -0
- package/dist/video-core/utils.js +194 -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 +6 -6
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/agent/chat/prompt/index.d.ts +0 -6
- package/dist/agent/chat/prompt/index.d.ts.map +0 -1
- package/dist/agent/chat/prompt/index.js +0 -200
- 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 -55
- 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/definitions/extract-frames-from-video.d.ts +0 -39
- package/dist/tools/definitions/extract-frames-from-video.d.ts.map +0 -1
- package/dist/tools/definitions/extract-frames-from-video.js +0 -60
- 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/extract-frames-from-video/index.d.ts +0 -7
- package/dist/tools/extract-frames-from-video/index.d.ts.map +0 -1
- package/dist/tools/extract-frames-from-video/index.js +0 -145
- 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 -149
- 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 -16
- package/dist/tools/fetch-video-analysis/utils.d.ts.map +0 -1
- package/dist/tools/fetch-video-analysis/utils.js +0 -121
- 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 -70
- 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/dist/utils/dedup-image-fs.d.ts +0 -27
- package/dist/utils/dedup-image-fs.d.ts.map +0 -1
- package/dist/utils/dedup-image-fs.js +0 -88
- package/dist/utils/dedup-image.d.ts +0 -25
- package/dist/utils/dedup-image.d.ts.map +0 -1
- package/dist/utils/dedup-image.js +0 -80
- package/dist/utils/local-ffmpeg-client.d.ts +0 -27
- package/dist/utils/local-ffmpeg-client.d.ts.map +0 -1
- package/dist/utils/local-ffmpeg-client.js +0 -299
- package/eslint.config.mjs +0 -43
package/dist/tools/grep/index.js
CHANGED
|
@@ -8,7 +8,7 @@ const child_process_1 = require("child_process");
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const util_1 = require("util");
|
|
10
10
|
const zod_1 = require("zod");
|
|
11
|
-
const
|
|
11
|
+
const constants_1 = require("../../constants");
|
|
12
12
|
const grep_1 = require("../definitions/grep");
|
|
13
13
|
const ripgrep_1 = require("./ripgrep");
|
|
14
14
|
const GrepInputSchema = zod_1.z.object({
|
|
@@ -24,18 +24,18 @@ const GrepInputSchema = zod_1.z.object({
|
|
|
24
24
|
.optional()
|
|
25
25
|
.describe("File pattern to search in (e.g., '*.ts' for TypeScript files)"),
|
|
26
26
|
});
|
|
27
|
-
async function usingSystemGrep(input, repoPath) {
|
|
27
|
+
async function usingSystemGrep(input, repoPath, logger) {
|
|
28
28
|
try {
|
|
29
29
|
const dir = path_1.default.join(repoPath, input.directory || "");
|
|
30
30
|
// Create exclude pattern for grep
|
|
31
|
-
const excludePatterns =
|
|
31
|
+
const excludePatterns = constants_1.DEFAULT_EXCLUDE.map((pattern) => typeof pattern === "string" ? pattern : pattern.source)
|
|
32
32
|
.map((pattern) => `--exclude-dir="${pattern}"`)
|
|
33
33
|
.join(" ");
|
|
34
34
|
// Using -n to show line numbers in output
|
|
35
35
|
let cmd = `grep -rin ${excludePatterns} "${input.pattern}" ${dir}`;
|
|
36
36
|
if (input.filePattern) {
|
|
37
37
|
// For file pattern searches, we'll use find with exclusions
|
|
38
|
-
const excludeFind =
|
|
38
|
+
const excludeFind = constants_1.DEFAULT_EXCLUDE.map((pattern) => typeof pattern === "string" ? pattern : pattern.source)
|
|
39
39
|
.map((pattern) => `-not -path "*/${pattern}/*"`)
|
|
40
40
|
.join(" ");
|
|
41
41
|
// Modified command to ensure filepath is included in the output
|
|
@@ -65,14 +65,15 @@ async function usingSystemGrep(input, repoPath) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
catch (error) {
|
|
68
|
-
|
|
68
|
+
logger?.error("Error executing grep", error) ||
|
|
69
|
+
console.error("Error executing grep", error);
|
|
69
70
|
return {
|
|
70
71
|
isError: true,
|
|
71
72
|
result: error instanceof Error ? error.message : String(error),
|
|
72
73
|
};
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
async function usingRipgrep(input, repoPath) {
|
|
76
|
+
async function usingRipgrep(input, repoPath, logger) {
|
|
76
77
|
try {
|
|
77
78
|
const dir = path_1.default.join(repoPath, input.directory || "");
|
|
78
79
|
const escapedPattern = input.pattern
|
|
@@ -109,7 +110,8 @@ All paths are relative to the current working directory.`;
|
|
|
109
110
|
};
|
|
110
111
|
}
|
|
111
112
|
catch (error) {
|
|
112
|
-
|
|
113
|
+
logger?.error("Error executing ripgrep", error) ||
|
|
114
|
+
console.error("Error executing ripgrep", error);
|
|
113
115
|
return {
|
|
114
116
|
isError: true,
|
|
115
117
|
result: error instanceof ripgrep_1.RipGrepError ? error.message : String(error),
|
|
@@ -118,13 +120,18 @@ All paths are relative to the current working directory.`;
|
|
|
118
120
|
}
|
|
119
121
|
exports.grepTool = {
|
|
120
122
|
...grep_1.grepTool,
|
|
121
|
-
execute: async ({ input, repoPath }) => {
|
|
123
|
+
execute: async ({ input, repoPath, logger }) => {
|
|
122
124
|
if ((0, ripgrep_1.isRgAvailable)()) {
|
|
123
|
-
return usingRipgrep(input, repoPath);
|
|
125
|
+
return usingRipgrep(input, repoPath, logger);
|
|
124
126
|
}
|
|
125
127
|
else {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
+
if (logger) {
|
|
129
|
+
logger.warn("ripgrep is not available, falling back to system grep.");
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
console.warn("ripgrep is not available, falling back to system grep.");
|
|
133
|
+
}
|
|
134
|
+
return usingSystemGrep(input, repoPath, logger);
|
|
128
135
|
}
|
|
129
136
|
},
|
|
130
137
|
};
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { PendingToolCall, ServicePayload, SupportedChatModels, Tool, ToolDefinition } from "@empiricalrun/shared-types";
|
|
2
2
|
import { createPullRequestTool } from "./create-pull-request";
|
|
3
|
+
import { analyseVideo } from "./definitions/analyse-video";
|
|
3
4
|
import { deleteFileTool } from "./definitions/delete-file";
|
|
4
5
|
import { downloadBuildTool } from "./definitions/download-build";
|
|
5
|
-
import { extractFramesFromVideo } from "./definitions/extract-frames-from-video";
|
|
6
|
-
import { fetchVideoAnalysis } from "./definitions/fetch-video-analysis";
|
|
7
6
|
import { grepTool } from "./definitions/grep";
|
|
8
|
-
import { listProjectsTool, listTestsForProjectTool } from "./definitions/list-tests-and-projects";
|
|
9
7
|
import { mergeConflictsTool } from "./definitions/merge-conflicts";
|
|
10
8
|
import { renameFileTool } from "./definitions/rename-file";
|
|
9
|
+
import { reviewPullRequestTool } from "./definitions/review-pull-request";
|
|
11
10
|
import { runTestTool } from "./definitions/run-test";
|
|
12
11
|
import { generateTestWithBrowserAgent } from "./definitions/test-gen-browser";
|
|
13
12
|
import { upgradePackagesTool } from "./definitions/upgrade-packages";
|
|
@@ -17,7 +16,6 @@ import { fetchLastSuccessfulTestRunTool } from "./fetch-last-successful-test-run
|
|
|
17
16
|
import { fetchSessionDiffTool } from "./fetch-session-diff";
|
|
18
17
|
import { createIssueTool, listIssuesTool, updateIssueTool } from "./issues";
|
|
19
18
|
import { listEnvironmentsTool } from "./list-environments";
|
|
20
|
-
import { reviewPullRequestTool } from "./review-pull-request";
|
|
21
19
|
import { fetchTestRunReportTool } from "./test-run-fetcher";
|
|
22
20
|
import { traceDotZipTool } from "./trace-dot-zip";
|
|
23
21
|
import { sendTriageSummaryTool } from "./triage-summary";
|
|
@@ -26,9 +24,11 @@ type ToolOrToolDefinition = Tool | ToolDefinition;
|
|
|
26
24
|
export declare const commonTools: ToolOrToolDefinition[];
|
|
27
25
|
export declare const testGenerationTools: ToolOrToolDefinition[];
|
|
28
26
|
export declare const triageOnlyTools: ToolOrToolDefinition[];
|
|
29
|
-
export { createIssueTool, createPullRequestTool, deleteFileTool, downloadBuildTool,
|
|
27
|
+
export { createIssueTool, createPullRequestTool, deleteFileTool, downloadBuildTool, fetchDiagnosisReportTool, fetchFileTool, fetchLastSuccessfulTestRunTool, fetchSessionDiffTool, fetchTestRunReportTool, analyseVideo, generateTestWithBrowserAgent, grepTool, listEnvironmentsTool, listIssuesTool, mergeConflictsTool, renameFileTool, reviewPullRequestTool, runTestTool, sendTriageSummaryTool, traceDotZipTool, updateIssueTool, upgradePackagesTool, viewFailedTestRunReportTool, };
|
|
30
28
|
export declare const allToolsDefinitions: ToolOrToolDefinition[];
|
|
29
|
+
export declare function hasBuiltInTextEditor(model: SupportedChatModels): boolean;
|
|
31
30
|
export declare function textEditorToolsForModel(model: SupportedChatModels): ToolOrToolDefinition[];
|
|
31
|
+
export declare function textViewToolsForModel(model: SupportedChatModels): ToolOrToolDefinition[];
|
|
32
32
|
export declare function toolsNeedBrowser(toolCalls: PendingToolCall[]): boolean;
|
|
33
33
|
export declare function nameForTelemetry(toolCall: PendingToolCall): string;
|
|
34
34
|
export declare function sendToolRequestToRemoteQueue(payload: ServicePayload): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,IAAI,EACJ,cAAc,EACf,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAK9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAKrD,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE5E,KAAK,oBAAoB,GAAG,IAAI,GAAG,cAAc,CAAC;AAIlD,eAAO,MAAM,WAAW,EAAE,oBAAoB,EAU7C,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,oBAAoB,EAQrD,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,oBAAoB,EASjD,CAAC;AAGF,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EAEjB,wBAAwB,EACxB,aAAa,EACb,8BAA8B,EAE9B,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,EAEZ,4BAA4B,EAC5B,QAAQ,EACR,oBAAoB,EAEpB,cAAc,EAEd,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EAErB,WAAW,EACX,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,2BAA2B,GAC5B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,oBAAoB,EAQrD,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,WAE9D;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,mBAAmB,GACzB,oBAAoB,EAAE,CAExB;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,mBAAmB,GACzB,oBAAoB,EAAE,CAExB;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,eAAe,EAAE,WAM5D;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,CAQlE;AAED,wBAAsB,4BAA4B,CAAC,OAAO,EAAE,cAAc,iBAoBzE"}
|
package/dist/tools/index.js
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.allToolsDefinitions = exports.viewFailedTestRunReportTool = exports.upgradePackagesTool = exports.updateIssueTool = exports.traceDotZipTool = exports.sendTriageSummaryTool = exports.runTestTool = exports.reviewPullRequestTool = exports.renameFileTool = exports.mergeConflictsTool = exports.
|
|
3
|
+
exports.allToolsDefinitions = exports.viewFailedTestRunReportTool = exports.upgradePackagesTool = exports.updateIssueTool = exports.traceDotZipTool = exports.sendTriageSummaryTool = exports.runTestTool = exports.reviewPullRequestTool = exports.renameFileTool = exports.mergeConflictsTool = exports.listIssuesTool = exports.listEnvironmentsTool = exports.grepTool = exports.generateTestWithBrowserAgent = exports.analyseVideo = exports.fetchTestRunReportTool = exports.fetchSessionDiffTool = exports.fetchLastSuccessfulTestRunTool = exports.fetchFileTool = exports.fetchDiagnosisReportTool = exports.downloadBuildTool = exports.deleteFileTool = exports.createPullRequestTool = exports.createIssueTool = exports.triageOnlyTools = exports.testGenerationTools = exports.commonTools = void 0;
|
|
4
|
+
exports.hasBuiltInTextEditor = hasBuiltInTextEditor;
|
|
4
5
|
exports.textEditorToolsForModel = textEditorToolsForModel;
|
|
6
|
+
exports.textViewToolsForModel = textViewToolsForModel;
|
|
5
7
|
exports.toolsNeedBrowser = toolsNeedBrowser;
|
|
6
8
|
exports.nameForTelemetry = nameForTelemetry;
|
|
7
9
|
exports.sendToolRequestToRemoteQueue = sendToolRequestToRemoteQueue;
|
|
8
|
-
const chat_1 = require("@empiricalrun/llm/chat");
|
|
9
10
|
const SQSClient_1 = require("../utils/SQSClient");
|
|
10
11
|
const create_pull_request_1 = require("./create-pull-request");
|
|
11
12
|
Object.defineProperty(exports, "createPullRequestTool", { enumerable: true, get: function () { return create_pull_request_1.createPullRequestTool; } });
|
|
13
|
+
const analyse_video_1 = require("./definitions/analyse-video");
|
|
14
|
+
Object.defineProperty(exports, "analyseVideo", { enumerable: true, get: function () { return analyse_video_1.analyseVideo; } });
|
|
12
15
|
const delete_file_1 = require("./definitions/delete-file");
|
|
13
16
|
Object.defineProperty(exports, "deleteFileTool", { enumerable: true, get: function () { return delete_file_1.deleteFileTool; } });
|
|
14
17
|
const download_build_1 = require("./definitions/download-build");
|
|
15
18
|
Object.defineProperty(exports, "downloadBuildTool", { enumerable: true, get: function () { return download_build_1.downloadBuildTool; } });
|
|
16
|
-
const extract_frames_from_video_1 = require("./definitions/extract-frames-from-video");
|
|
17
|
-
Object.defineProperty(exports, "extractFramesFromVideo", { enumerable: true, get: function () { return extract_frames_from_video_1.extractFramesFromVideo; } });
|
|
18
|
-
const fetch_video_analysis_1 = require("./definitions/fetch-video-analysis");
|
|
19
|
-
Object.defineProperty(exports, "fetchVideoAnalysis", { enumerable: true, get: function () { return fetch_video_analysis_1.fetchVideoAnalysis; } });
|
|
20
19
|
const grep_1 = require("./definitions/grep");
|
|
21
20
|
Object.defineProperty(exports, "grepTool", { enumerable: true, get: function () { return grep_1.grepTool; } });
|
|
22
21
|
const list_tests_and_projects_1 = require("./definitions/list-tests-and-projects");
|
|
23
|
-
Object.defineProperty(exports, "listProjectsTool", { enumerable: true, get: function () { return list_tests_and_projects_1.listProjectsTool; } });
|
|
24
|
-
Object.defineProperty(exports, "listTestsForProjectTool", { enumerable: true, get: function () { return list_tests_and_projects_1.listTestsForProjectTool; } });
|
|
25
22
|
const merge_conflicts_1 = require("./definitions/merge-conflicts");
|
|
26
23
|
Object.defineProperty(exports, "mergeConflictsTool", { enumerable: true, get: function () { return merge_conflicts_1.mergeConflictsTool; } });
|
|
27
24
|
const rename_file_1 = require("./definitions/rename-file");
|
|
28
25
|
Object.defineProperty(exports, "renameFileTool", { enumerable: true, get: function () { return rename_file_1.renameFileTool; } });
|
|
26
|
+
const review_pull_request_1 = require("./definitions/review-pull-request");
|
|
27
|
+
Object.defineProperty(exports, "reviewPullRequestTool", { enumerable: true, get: function () { return review_pull_request_1.reviewPullRequestTool; } });
|
|
29
28
|
const run_test_1 = require("./definitions/run-test");
|
|
30
29
|
Object.defineProperty(exports, "runTestTool", { enumerable: true, get: function () { return run_test_1.runTestTool; } });
|
|
31
30
|
const str_replace_editor_1 = require("./definitions/str_replace_editor");
|
|
@@ -47,8 +46,6 @@ Object.defineProperty(exports, "listIssuesTool", { enumerable: true, get: functi
|
|
|
47
46
|
Object.defineProperty(exports, "updateIssueTool", { enumerable: true, get: function () { return issues_1.updateIssueTool; } });
|
|
48
47
|
const list_environments_1 = require("./list-environments");
|
|
49
48
|
Object.defineProperty(exports, "listEnvironmentsTool", { enumerable: true, get: function () { return list_environments_1.listEnvironmentsTool; } });
|
|
50
|
-
const review_pull_request_1 = require("./review-pull-request");
|
|
51
|
-
Object.defineProperty(exports, "reviewPullRequestTool", { enumerable: true, get: function () { return review_pull_request_1.reviewPullRequestTool; } });
|
|
52
49
|
const test_run_fetcher_1 = require("./test-run-fetcher");
|
|
53
50
|
Object.defineProperty(exports, "fetchTestRunReportTool", { enumerable: true, get: function () { return test_run_fetcher_1.fetchTestRunReportTool; } });
|
|
54
51
|
const trace_dot_zip_1 = require("./trace-dot-zip");
|
|
@@ -68,6 +65,8 @@ exports.commonTools = [
|
|
|
68
65
|
download_build_1.downloadBuildTool,
|
|
69
66
|
fetch_file_1.fetchFileTool,
|
|
70
67
|
trace_dot_zip_1.traceDotZipTool,
|
|
68
|
+
list_tests_and_projects_1.listProjectsTool,
|
|
69
|
+
list_tests_and_projects_1.listTestsForProjectTool,
|
|
71
70
|
];
|
|
72
71
|
exports.testGenerationTools = [
|
|
73
72
|
test_gen_browser_1.generateTestWithBrowserAgent,
|
|
@@ -83,7 +82,7 @@ exports.triageOnlyTools = [
|
|
|
83
82
|
issues_1.createIssueTool,
|
|
84
83
|
issues_1.updateIssueTool,
|
|
85
84
|
view_failed_test_run_report_1.viewFailedTestRunReportTool,
|
|
86
|
-
|
|
85
|
+
analyse_video_1.analyseVideo,
|
|
87
86
|
fetch_last_successful_test_run_1.fetchLastSuccessfulTestRunTool,
|
|
88
87
|
triage_summary_1.sendTriageSummaryTool,
|
|
89
88
|
review_pull_request_1.reviewPullRequestTool,
|
|
@@ -93,16 +92,18 @@ exports.allToolsDefinitions = [
|
|
|
93
92
|
...exports.testGenerationTools,
|
|
94
93
|
...exports.triageOnlyTools,
|
|
95
94
|
// Individual tools that were in removed arrays
|
|
96
|
-
extract_frames_from_video_1.extractFramesFromVideo,
|
|
97
95
|
fetch_session_diff_1.fetchSessionDiffTool,
|
|
98
96
|
list_tests_and_projects_1.listProjectsTool,
|
|
99
97
|
list_tests_and_projects_1.listTestsForProjectTool,
|
|
100
98
|
];
|
|
99
|
+
function hasBuiltInTextEditor(model) {
|
|
100
|
+
return model.includes("claude") && !model.includes("haiku");
|
|
101
|
+
}
|
|
101
102
|
function textEditorToolsForModel(model) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return [];
|
|
103
|
+
return !hasBuiltInTextEditor(model) ? Object.values(str_replace_editor_1.textEditorTools) : [];
|
|
104
|
+
}
|
|
105
|
+
function textViewToolsForModel(model) {
|
|
106
|
+
return !hasBuiltInTextEditor(model) ? Object.values(str_replace_editor_1.textViewTools) : [];
|
|
106
107
|
}
|
|
107
108
|
function toolsNeedBrowser(toolCalls) {
|
|
108
109
|
return toolCalls.some((toolCall) => exports.allToolsDefinitions.find((t) => t.schema.name === toolCall.name)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/merge-conflicts/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/merge-conflicts/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AA8CvD,eAAO,MAAM,kBAAkB,EAAE,IAiDhC,CAAC"}
|
|
@@ -11,7 +11,7 @@ const merge_conflicts_1 = require("../definitions/merge-conflicts");
|
|
|
11
11
|
const git_1 = require("../executor/utils/git");
|
|
12
12
|
function runMergeMain(repoPath) {
|
|
13
13
|
try {
|
|
14
|
-
(0, child_process_1.execSync)("git merge --no-ff origin/main", { stdio: "pipe", cwd: repoPath });
|
|
14
|
+
(0, child_process_1.execSync)("git merge --no-ff origin/main -m 'Merge remote-tracking branch origin/main [skip ci]'", { stdio: "pipe", cwd: repoPath });
|
|
15
15
|
return "CLEAN";
|
|
16
16
|
}
|
|
17
17
|
catch (error) {
|
|
@@ -69,7 +69,7 @@ exports.renameFileTool = {
|
|
|
69
69
|
if (!tscResult.success) {
|
|
70
70
|
return {
|
|
71
71
|
result: `File renamed from '${input.oldPath}' to '${input.newPath}'. However, type checks are failing with errors:\n\n${tscResult.errors.join("\n")}`,
|
|
72
|
-
isError:
|
|
72
|
+
isError: false,
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/review-pull-request/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/review-pull-request/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,MAAM,4BAA4B,CAAC;AAS9D,eAAO,MAAM,qBAAqB,EAAE,IA2FnC,CAAC"}
|
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.reviewPullRequestTool = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const exports_1 = require("../../agent/chat/exports");
|
|
6
|
-
const state_1 = require("../../agent/chat/state");
|
|
7
4
|
const code_review_1 = require("../../agent/code-review");
|
|
8
|
-
const
|
|
5
|
+
const executor_1 = require("../../agent/code-review/executor");
|
|
6
|
+
const review_pull_request_1 = require("../definitions/review-pull-request");
|
|
9
7
|
const CODE_REVIEW_MODEL = "claude-sonnet-4-20250514";
|
|
10
|
-
const ReviewPullRequestInputSchema = zod_1.z.object({
|
|
11
|
-
sessionUrl: zod_1.z.string().describe("The URL of the chat session to review"),
|
|
12
|
-
});
|
|
13
8
|
exports.reviewPullRequestTool = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
description: `Reviews a pull request by using CodeReviewAgent to fetch session diff and analyze it. Returns a boolean result with an explanation.`,
|
|
17
|
-
parameters: ReviewPullRequestInputSchema,
|
|
18
|
-
},
|
|
19
|
-
needsBrowser: false,
|
|
20
|
-
isInlineTool: true,
|
|
21
|
-
execute: async ({ input, apiClient }) => {
|
|
9
|
+
...review_pull_request_1.reviewPullRequestTool,
|
|
10
|
+
execute: async ({ input, apiClient, chatSession, environmentOverrides, trace, featureFlags, repoPath, }) => {
|
|
22
11
|
try {
|
|
23
12
|
const { sessionUrl } = input;
|
|
24
13
|
if (!sessionUrl) {
|
|
@@ -27,61 +16,51 @@ exports.reviewPullRequestTool = {
|
|
|
27
16
|
result: "No chat session URL provided",
|
|
28
17
|
};
|
|
29
18
|
}
|
|
30
|
-
|
|
19
|
+
if (!apiClient)
|
|
20
|
+
return {
|
|
21
|
+
isError: true,
|
|
22
|
+
result: "API Client not available",
|
|
23
|
+
};
|
|
24
|
+
const span = trace?.span({
|
|
25
|
+
name: "code-review-agent",
|
|
26
|
+
input: {
|
|
27
|
+
sessionUrl,
|
|
28
|
+
model: CODE_REVIEW_MODEL,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
const codeReviewToolExecutor = new executor_1.CodeReviewToolExecutor({
|
|
32
|
+
chatSession: chatSession || null,
|
|
33
|
+
repoPath,
|
|
34
|
+
apiClient,
|
|
35
|
+
trace: span,
|
|
36
|
+
featureFlags,
|
|
37
|
+
environmentOverrides: environmentOverrides || {},
|
|
38
|
+
});
|
|
39
|
+
const agentParams = {
|
|
31
40
|
featureFlags: [],
|
|
32
41
|
selectedModel: CODE_REVIEW_MODEL,
|
|
33
|
-
|
|
42
|
+
chatState: undefined,
|
|
43
|
+
toolExecutor: codeReviewToolExecutor,
|
|
44
|
+
trace: span,
|
|
45
|
+
};
|
|
46
|
+
const agent = new code_review_1.CodeReviewAgent({ ...agentParams });
|
|
47
|
+
// Push the review prompt to the agent
|
|
34
48
|
const userPrompt = `Review this session: ${sessionUrl}`;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
attachments: [],
|
|
38
|
-
existingState: undefined,
|
|
39
|
-
selectedModel: CODE_REVIEW_MODEL,
|
|
40
|
-
error: null,
|
|
41
|
-
});
|
|
42
|
-
agent.initializeWithState(chatState);
|
|
43
|
-
let chatModel = (0, exports_1.createChatModel)(chatState.messages, CODE_REVIEW_MODEL);
|
|
44
|
-
while (!chatModel.askUserForInput) {
|
|
49
|
+
agent.pushUserMessage([{ text: userPrompt }]);
|
|
50
|
+
while (!agent.askUserForInput) {
|
|
45
51
|
await agent.runLoop({
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
console.log("Review progress:", data);
|
|
49
|
-
},
|
|
50
|
-
onPendingToolCall: async (toolCalls) => {
|
|
51
|
-
const [toolCall] = toolCalls;
|
|
52
|
-
// TODO: This will only work for 1 tool - will break if
|
|
53
|
-
// code review agent has more tools: need first class primitive
|
|
54
|
-
// for inline tool execution
|
|
55
|
-
if (toolCall?.name === "fetchSessionDiff") {
|
|
56
|
-
const tool = fetch_session_diff_1.fetchSessionDiffTool;
|
|
57
|
-
const result = await tool.execute({
|
|
58
|
-
input: toolCall.input,
|
|
59
|
-
apiClient,
|
|
60
|
-
repoPath: ``,
|
|
61
|
-
featureFlags: [],
|
|
62
|
-
});
|
|
63
|
-
chatModel.pushToolResultsMessage([toolCall], [result]);
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
onLLMResponse: async (response, model) => {
|
|
67
|
-
console.log(`Agent responded using ${model}:`, response);
|
|
68
|
-
},
|
|
52
|
+
reporter: async () => { },
|
|
53
|
+
trace: span,
|
|
69
54
|
});
|
|
70
|
-
// Update the chatModel with the agent's final state for next iteration
|
|
71
|
-
if (agent.messages) {
|
|
72
|
-
chatModel = (0, exports_1.createChatModel)(agent.messages, CODE_REVIEW_MODEL);
|
|
73
|
-
}
|
|
74
55
|
}
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
: undefined;
|
|
84
|
-
if (!lastMessageTextPart) {
|
|
56
|
+
const agentResult = agent.getResult();
|
|
57
|
+
span?.end({
|
|
58
|
+
output: {
|
|
59
|
+
result: agentResult,
|
|
60
|
+
success: !!agentResult,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
if (!agentResult) {
|
|
85
64
|
return {
|
|
86
65
|
isError: true,
|
|
87
66
|
result: "Could not extract text response from agent",
|
|
@@ -89,7 +68,7 @@ exports.reviewPullRequestTool = {
|
|
|
89
68
|
}
|
|
90
69
|
return {
|
|
91
70
|
isError: false,
|
|
92
|
-
result:
|
|
71
|
+
result: JSON.stringify(agentResult),
|
|
93
72
|
};
|
|
94
73
|
}
|
|
95
74
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-test.d.ts","sourceRoot":"","sources":["../../src/tools/run-test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"run-test.d.ts","sourceRoot":"","sources":["../../src/tools/run-test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,IAAI,EAAc,MAAM,4BAA4B,CAAC;AA0C3E,eAAO,MAAM,WAAW,EAAE,IA4GzB,CAAC"}
|
package/dist/tools/run-test.js
CHANGED
|
@@ -29,7 +29,7 @@ ${JSON.stringify(truncatedSummaryJson)}
|
|
|
29
29
|
}
|
|
30
30
|
exports.runTestTool = {
|
|
31
31
|
...run_test_1.runTestTool,
|
|
32
|
-
execute: async ({ input, repoPath, collectArtifacts, environmentOverrides = {}, }) => {
|
|
32
|
+
execute: async ({ input, repoPath, collectArtifacts, environmentOverrides = {}, logger, }) => {
|
|
33
33
|
let reportUrl = undefined;
|
|
34
34
|
let envOverrides = { ...environmentOverrides };
|
|
35
35
|
if ((0, artifacts_1.isArtifactCollectionEnabled)()) {
|
|
@@ -43,14 +43,18 @@ exports.runTestTool = {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
|
-
|
|
46
|
+
const warnMsg = "R2 credentials not found: report artifacts will not be uploaded";
|
|
47
|
+
logger?.warn(warnMsg) || console.warn(warnMsg);
|
|
47
48
|
}
|
|
48
49
|
const { filePath } = input;
|
|
49
50
|
const absoluteFilePath = path_1.default.join(repoPath, filePath);
|
|
50
51
|
if (!fs_1.default.existsSync(absoluteFilePath)) {
|
|
52
|
+
const errorMsg = `File ${filePath} does not exist.`;
|
|
53
|
+
logger?.error("Test file not found", { filePath, absoluteFilePath }) ||
|
|
54
|
+
console.error("Test file not found:", filePath);
|
|
51
55
|
return {
|
|
52
56
|
isError: true,
|
|
53
|
-
result:
|
|
57
|
+
result: errorMsg,
|
|
54
58
|
};
|
|
55
59
|
}
|
|
56
60
|
if (input.buildUrl) {
|
|
@@ -60,6 +64,12 @@ exports.runTestTool = {
|
|
|
60
64
|
};
|
|
61
65
|
}
|
|
62
66
|
try {
|
|
67
|
+
logger?.info("Starting test execution", {
|
|
68
|
+
testName: input.testName,
|
|
69
|
+
filePath,
|
|
70
|
+
project: input.project,
|
|
71
|
+
suites: input.suites,
|
|
72
|
+
}) || console.log("Starting test execution:", input.testName);
|
|
63
73
|
const result = await (0, test_run_1.runSingleTest)({
|
|
64
74
|
testName: input.testName,
|
|
65
75
|
suites: input.suites,
|
|
@@ -67,7 +77,14 @@ exports.runTestTool = {
|
|
|
67
77
|
repoDir: repoPath,
|
|
68
78
|
projects: [input.project],
|
|
69
79
|
envOverrides,
|
|
80
|
+
stdout: logger?.createPrefixedStream?.("stdout"),
|
|
81
|
+
stderr: logger?.createPrefixedStream?.("stderr"),
|
|
70
82
|
});
|
|
83
|
+
logger?.info("Test execution completed", {
|
|
84
|
+
passed: result.hasTestPassed,
|
|
85
|
+
testCount: result.summaryJson?.suites?.length || 0,
|
|
86
|
+
}) ||
|
|
87
|
+
console.log("Test execution completed. Passed:", result.hasTestPassed);
|
|
71
88
|
const artifacts = (0, utils_1.extractAttachmentsFromPlaywrightJSONReport)(result.summaryJson);
|
|
72
89
|
void collectArtifacts?.(artifacts);
|
|
73
90
|
return {
|
|
@@ -82,6 +99,11 @@ exports.runTestTool = {
|
|
|
82
99
|
catch (error) {
|
|
83
100
|
// Ensure we capture the full error message regardless of error type
|
|
84
101
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
102
|
+
logger?.error("Test execution failed", {
|
|
103
|
+
error: errorMessage,
|
|
104
|
+
testName: input.testName,
|
|
105
|
+
filePath,
|
|
106
|
+
}) || console.error("Test execution failed:", errorMessage);
|
|
85
107
|
return {
|
|
86
108
|
artifacts: null,
|
|
87
109
|
result: JSON.stringify({ error: errorMessage }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-gen-browser.d.ts","sourceRoot":"","sources":["../../src/tools/test-gen-browser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"test-gen-browser.d.ts","sourceRoot":"","sources":["../../src/tools/test-gen-browser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiB,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAqBtE,eAAO,MAAM,4BAA4B,EAAE,IA+L1C,CAAC"}
|
|
@@ -10,6 +10,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
10
10
|
const run_1 = require("../agent/browsing/run");
|
|
11
11
|
const utils_1 = require("../agent/browsing/utils");
|
|
12
12
|
const pw_pause_1 = require("../agent/cua/pw-codegen/pw-pause");
|
|
13
|
+
const utils_2 = require("../artifacts/utils");
|
|
13
14
|
const web_1 = require("../bin/utils/platform/web");
|
|
14
15
|
const scenarios_1 = require("../bin/utils/scenarios");
|
|
15
16
|
const test_gen_browser_1 = require("./definitions/test-gen-browser");
|
|
@@ -53,8 +54,9 @@ exports.generateTestWithBrowserAgent = {
|
|
|
53
54
|
}
|
|
54
55
|
// Prepare the file for the browser agent
|
|
55
56
|
const fileBackup = fs_1.default.readFileSync(absoluteFilePath, "utf-8");
|
|
57
|
+
let todoContent;
|
|
56
58
|
try {
|
|
57
|
-
|
|
59
|
+
todoContent = (0, utils_1.replaceTodoWithCreateTest)(filePath, repoPath);
|
|
58
60
|
}
|
|
59
61
|
catch (error) {
|
|
60
62
|
// Undo the TODO -> createTest and test.only changes
|
|
@@ -83,7 +85,7 @@ exports.generateTestWithBrowserAgent = {
|
|
|
83
85
|
BUILD_URL: input.buildUrl,
|
|
84
86
|
};
|
|
85
87
|
}
|
|
86
|
-
const testGenToken = (0, scenarios_1.buildTokenFromOptions)({ name: testName, file: filePath
|
|
88
|
+
const testGenToken = (0, scenarios_1.buildTokenFromOptions)({ name: testName, file: filePath }, { useComputerUseAgent: true });
|
|
87
89
|
console.log("[generateTestWithBrowserAgent] Validations passed, starting agent");
|
|
88
90
|
const agentResult = await (0, run_1.runBrowsingAgent)({
|
|
89
91
|
testCaseName: testName,
|
|
@@ -100,10 +102,7 @@ exports.generateTestWithBrowserAgent = {
|
|
|
100
102
|
// Cleanup: Undo the TODO -> createTest changes
|
|
101
103
|
await (0, pw_pause_1.revertToOriginalPwCode)(repoPath);
|
|
102
104
|
fs_1.default.writeFileSync(absoluteFilePath, fileBackup, "utf-8");
|
|
103
|
-
const { isError, error, result: toolResult,
|
|
104
|
-
if (artifacts) {
|
|
105
|
-
void collectArtifacts?.(artifacts);
|
|
106
|
-
}
|
|
105
|
+
const { isError, error, result: toolResult, usage } = agentResult;
|
|
107
106
|
if (isError || !toolResult) {
|
|
108
107
|
return {
|
|
109
108
|
isError,
|
|
@@ -112,53 +111,58 @@ ${error}
|
|
|
112
111
|
`,
|
|
113
112
|
};
|
|
114
113
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
const screenshotArtifacts = toolResult
|
|
115
|
+
.filter((item) => item.type === "screenshot")
|
|
116
|
+
.map((item) => item.screenshot)
|
|
117
|
+
.map((artifact) => ({
|
|
118
|
+
...artifact,
|
|
119
|
+
data: Buffer.isBuffer(artifact.data)
|
|
120
|
+
? artifact.data
|
|
121
|
+
: Buffer.from(artifact.data),
|
|
122
|
+
}));
|
|
123
|
+
const artifactsInput = [
|
|
124
|
+
...((0, utils_2.findPlaywrightArtifacts)(repoPath) || []),
|
|
125
|
+
...screenshotArtifacts,
|
|
126
|
+
];
|
|
127
|
+
const summaryResult = `Browser agent has finished running.
|
|
128
|
+
TODO comment which it worked on: ${todoContent}
|
|
129
|
+
Summary of actions it took, and the generated Playwright code:`;
|
|
130
|
+
if (!collectArtifacts || artifactsInput.length === 0) {
|
|
131
|
+
const result = [
|
|
132
|
+
{ type: "text", text: summaryResult },
|
|
133
|
+
...toolResult.map((item) => ({
|
|
134
|
+
type: "text",
|
|
135
|
+
text: item.type === "text" ? item.text : "[Screenshot]",
|
|
136
|
+
})),
|
|
137
|
+
];
|
|
138
|
+
return { isError, result, usage };
|
|
139
|
+
}
|
|
140
|
+
const uploadedArtifacts = await collectArtifacts(artifactsInput);
|
|
141
|
+
const artifactUrlMap = new Map(uploadedArtifacts.map((a) => [a.name, a.url]));
|
|
142
|
+
let screenshotIndex = 0;
|
|
143
|
+
const result = [
|
|
144
|
+
{ type: "text", text: summaryResult },
|
|
120
145
|
...toolResult.map((item) => {
|
|
121
146
|
if (item.type === "text") {
|
|
122
|
-
return {
|
|
123
|
-
type: "text",
|
|
124
|
-
text: item.text,
|
|
125
|
-
};
|
|
147
|
+
return { type: "text", text: item.text };
|
|
126
148
|
}
|
|
127
149
|
else if (item.type === "screenshot") {
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
else {
|
|
137
|
-
return {
|
|
138
|
-
type: "text",
|
|
139
|
-
text: `Unknown item type: ${item}`,
|
|
140
|
-
};
|
|
150
|
+
const screenshotName = screenshotArtifacts[screenshotIndex]?.name;
|
|
151
|
+
const url = screenshotName
|
|
152
|
+
? artifactUrlMap.get(screenshotName)
|
|
153
|
+
: undefined;
|
|
154
|
+
screenshotIndex++;
|
|
155
|
+
return url
|
|
156
|
+
? { type: "image/png", url }
|
|
157
|
+
: { type: "text", text: "[Screenshot upload failed]" };
|
|
141
158
|
}
|
|
159
|
+
return { type: "text", text: "Unknown item type" };
|
|
142
160
|
}),
|
|
143
161
|
];
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
usage,
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
const textOnlyResult = result
|
|
154
|
-
.filter((item) => item.type === "text")
|
|
155
|
-
.map((item) => item.text)
|
|
156
|
-
.join("\n");
|
|
157
|
-
return {
|
|
158
|
-
isError,
|
|
159
|
-
result: textOnlyResult,
|
|
160
|
-
usage,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
162
|
+
return {
|
|
163
|
+
isError,
|
|
164
|
+
result,
|
|
165
|
+
usage,
|
|
166
|
+
};
|
|
163
167
|
},
|
|
164
168
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/upgrade-packages/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAoBvD,eAAO,MAAM,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/upgrade-packages/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAoBvD,eAAO,MAAM,mBAAmB,EAAE,IA8HjC,CAAC"}
|
|
@@ -62,6 +62,9 @@ exports.upgradePackagesTool = {
|
|
|
62
62
|
let shouldMerge = false;
|
|
63
63
|
let prNumber = null;
|
|
64
64
|
let merged = false;
|
|
65
|
+
if (!chatSession) {
|
|
66
|
+
throw new Error("Chat session is not available.");
|
|
67
|
+
}
|
|
65
68
|
if (!apiClient) {
|
|
66
69
|
throw new Error("Dashboard API client is not available.");
|
|
67
70
|
}
|
|
@@ -71,6 +74,7 @@ exports.upgradePackagesTool = {
|
|
|
71
74
|
repo: repoName,
|
|
72
75
|
apiClient,
|
|
73
76
|
branchName,
|
|
77
|
+
base: chatSession?.baseBranchName,
|
|
74
78
|
title: prTitle,
|
|
75
79
|
body: (0, pr_description_1.addMetadataToPRDescription)(prBody, chatSession),
|
|
76
80
|
labels: ["automated"],
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IDashboardAPIClient } from "@empiricalrun/shared-types";
|
|
2
|
+
export declare function isPatchUpdate(currentVersion: string | undefined, newVersion: string | undefined): boolean;
|
|
2
3
|
export declare function getLatestVersion(packageName: string): Promise<any>;
|
|
3
4
|
export declare function parsePackageJsonDiff({ diff, }: {
|
|
4
5
|
diff: string;
|