@empiricalrun/test-gen 0.76.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 +33 -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 +48 -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 +5 -4
- package/dist/agent/chat/exports.d.ts.map +1 -1
- package/dist/agent/chat/exports.js +4 -7
- 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 +7 -6
- package/dist/agent/chat/state.d.ts.map +1 -1
- package/dist/agent/chat/state.js +15 -45
- 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 +62 -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 +115 -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 +2 -2
- package/dist/agent/triage/index.d.ts.map +1 -1
- package/dist/agent/triage/index.js +8 -7
- 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 +66 -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 +50 -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} +13 -8
- 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 +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.map +1 -1
- package/dist/tools/executor/utils/index.js +1 -1
- 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 +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 +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 +45 -59
- 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/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/utils/{local-ffmpeg-client.d.ts → ffmpeg/index.d.ts} +6 -7
- package/dist/utils/ffmpeg/index.d.ts.map +1 -0
- package/dist/utils/{local-ffmpeg-client.js → ffmpeg/index.js} +169 -53
- 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 -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/local-ffmpeg-client.d.ts.map +0 -1
- package/eslint.config.mjs +0 -43
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.analyseVideo = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
const hash_1 = require("../../utils/hash");
|
|
6
|
+
const video_core_1 = require("../../video-core");
|
|
7
|
+
const utils_1 = require("../../video-core/utils");
|
|
8
|
+
const analyse_video_1 = require("../definitions/analyse-video");
|
|
9
|
+
function getVideoAnalysisParams(params) {
|
|
10
|
+
return {
|
|
11
|
+
model: params?.model || constants_1.VIDEO_ANALYSIS.DEFAULT_MODEL,
|
|
12
|
+
fps: params?.fps ?? constants_1.VIDEO_ANALYSIS.DEFAULT_FPS,
|
|
13
|
+
threshold: params?.threshold ?? constants_1.VIDEO_ANALYSIS.DEFAULT_THRESHOLD,
|
|
14
|
+
startTime: params?.startTime,
|
|
15
|
+
duration: params?.duration,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.analyseVideo = {
|
|
19
|
+
...analyse_video_1.analyseVideo,
|
|
20
|
+
execute: async ({ input, featureFlags, repoPath }) => {
|
|
21
|
+
const { videoUrl } = input;
|
|
22
|
+
const params = getVideoAnalysisParams(input.params);
|
|
23
|
+
const videoUrlHash = (0, hash_1.createHashBasedOnParams)(videoUrl, params);
|
|
24
|
+
const validationResult = await (0, utils_1.validateVideoAccess)(videoUrl);
|
|
25
|
+
if (!validationResult.isValid) {
|
|
26
|
+
return {
|
|
27
|
+
result: validationResult.error,
|
|
28
|
+
isError: true,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const { result, isError, interleaved_tool_result } = await (0, video_core_1.runVideoAnalysis)({
|
|
32
|
+
videoUrl,
|
|
33
|
+
videoUrlHash,
|
|
34
|
+
params,
|
|
35
|
+
featureFlags,
|
|
36
|
+
workingDirectory: repoPath,
|
|
37
|
+
});
|
|
38
|
+
const finalResult = [
|
|
39
|
+
{
|
|
40
|
+
type: "text",
|
|
41
|
+
text: JSON.stringify(result),
|
|
42
|
+
},
|
|
43
|
+
...interleaved_tool_result,
|
|
44
|
+
];
|
|
45
|
+
return {
|
|
46
|
+
isError: isError,
|
|
47
|
+
result: finalResult,
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
};
|
|
@@ -43,12 +43,10 @@ Don't ask the user for this information, just come up with it yourself.
|
|
|
43
43
|
branchName,
|
|
44
44
|
apiClient: apiClient,
|
|
45
45
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return await (0, utils_2.handleNewPullRequest)(owner, repo, pullRequestTitle, branchName, chatSession, pullRequestDescription, apiClient);
|
|
51
|
-
}
|
|
46
|
+
const toolResponse = existingPR
|
|
47
|
+
? await (0, utils_2.handleExistingPullRequest)(existingPR, owner, repo, pullRequestDescription, chatSession, apiClient)
|
|
48
|
+
: await (0, utils_2.handleNewPullRequest)(owner, repo, pullRequestTitle, branchName, chatSession, pullRequestDescription, apiClient);
|
|
49
|
+
return toolResponse;
|
|
52
50
|
}
|
|
53
51
|
catch (error) {
|
|
54
52
|
return {
|
|
@@ -7,7 +7,7 @@ export interface ValidatedInputs {
|
|
|
7
7
|
export declare function validateInputs({ input, apiClient, chatSession, }: any): Promise<ValidatedInputs>;
|
|
8
8
|
export declare function getRepoName(chatSession: ChatSessionInfo | null | undefined, apiClient: IDashboardAPIClient): Promise<string>;
|
|
9
9
|
export declare function getMergeableStateInfo(owner: string, repo: string, pullRequest: any, apiClient: any): Promise<{
|
|
10
|
-
mergeableState: "unknown" | "
|
|
10
|
+
mergeableState: "unknown" | "dirty" | "clean" | "unstable";
|
|
11
11
|
stateDescription: string;
|
|
12
12
|
}>;
|
|
13
13
|
export declare function handleExistingPullRequest(pullRequest: any, owner: string, repo: string, pullRequestDescription: string, chatSession: any, apiClient: any): Promise<{
|
|
@@ -1,39 +1,44 @@
|
|
|
1
1
|
import { ToolDefinition } from "@empiricalrun/shared-types";
|
|
2
2
|
import z from "zod";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const analyseVideoSchema: z.ZodObject<{
|
|
4
4
|
videoUrl: z.ZodString;
|
|
5
5
|
params: z.ZodOptional<z.ZodObject<{
|
|
6
6
|
fps: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
7
7
|
threshold: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
8
|
+
startTime: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
duration: z.ZodOptional<z.ZodNumber>;
|
|
8
10
|
model: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
9
|
-
featureFlag: z.ZodOptional<z.ZodDefault<z.ZodEnum<["none", "send-all-frames", "separate-threshold", "ai-based-frames"]>>>;
|
|
10
11
|
}, "strip", z.ZodTypeAny, {
|
|
11
12
|
model?: string | undefined;
|
|
13
|
+
startTime?: number | undefined;
|
|
12
14
|
threshold?: number | undefined;
|
|
13
15
|
fps?: number | undefined;
|
|
14
|
-
|
|
16
|
+
duration?: number | undefined;
|
|
15
17
|
}, {
|
|
16
18
|
model?: string | undefined;
|
|
19
|
+
startTime?: number | undefined;
|
|
17
20
|
threshold?: number | undefined;
|
|
18
21
|
fps?: number | undefined;
|
|
19
|
-
|
|
22
|
+
duration?: number | undefined;
|
|
20
23
|
}>>;
|
|
21
24
|
}, "strip", z.ZodTypeAny, {
|
|
22
25
|
videoUrl: string;
|
|
23
26
|
params?: {
|
|
24
27
|
model?: string | undefined;
|
|
28
|
+
startTime?: number | undefined;
|
|
25
29
|
threshold?: number | undefined;
|
|
26
30
|
fps?: number | undefined;
|
|
27
|
-
|
|
31
|
+
duration?: number | undefined;
|
|
28
32
|
} | undefined;
|
|
29
33
|
}, {
|
|
30
34
|
videoUrl: string;
|
|
31
35
|
params?: {
|
|
32
36
|
model?: string | undefined;
|
|
37
|
+
startTime?: number | undefined;
|
|
33
38
|
threshold?: number | undefined;
|
|
34
39
|
fps?: number | undefined;
|
|
35
|
-
|
|
40
|
+
duration?: number | undefined;
|
|
36
41
|
} | undefined;
|
|
37
42
|
}>;
|
|
38
|
-
export declare const
|
|
39
|
-
//# sourceMappingURL=
|
|
43
|
+
export declare const analyseVideo: ToolDefinition<z.infer<typeof analyseVideoSchema>>;
|
|
44
|
+
//# sourceMappingURL=analyse-video.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyse-video.d.ts","sourceRoot":"","sources":["../../../src/tools/definitions/analyse-video.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,CAAC,MAAM,KAAK,CAAC;AAGpB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2C7B,CAAC;AAEH,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAczE,CAAC"}
|
|
@@ -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"}
|