@empiricalrun/test-gen 0.63.0 → 0.64.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/dist/agent/browsing/run.d.ts +2 -1
- package/dist/agent/browsing/run.d.ts.map +1 -1
- package/dist/agent/browsing/run.js +25 -12
- package/dist/agent/browsing/utils.d.ts +1 -1
- package/dist/agent/browsing/utils.d.ts.map +1 -1
- package/dist/agent/browsing/utils.js +5 -4
- package/dist/agent/chat/index.d.ts.map +1 -1
- package/dist/agent/chat/index.js +2 -0
- package/dist/agent/chat/models.js +1 -1
- package/dist/agent/cua/computer.d.ts.map +1 -1
- package/dist/agent/cua/computer.js +45 -24
- package/dist/agent/cua/pw-codegen/element-from-point.d.ts +3 -1
- package/dist/agent/cua/pw-codegen/element-from-point.d.ts.map +1 -1
- package/dist/agent/cua/pw-codegen/element-from-point.js +73 -56
- package/dist/agent/cua/pw-codegen/types.d.ts +2 -1
- package/dist/agent/cua/pw-codegen/types.d.ts.map +1 -1
- package/dist/artifacts/utils.d.ts +21 -0
- package/dist/artifacts/utils.d.ts.map +1 -0
- package/dist/artifacts/utils.js +102 -0
- package/dist/bin/index.js +2 -1
- package/dist/bin/utils/platform/web/index.d.ts.map +1 -1
- package/dist/bin/utils/platform/web/index.js +2 -0
- package/dist/file/server.js +1 -1
- package/dist/test-build/index.js +1 -1
- package/dist/tool-call-service/index.d.ts +5 -2
- package/dist/tool-call-service/index.d.ts.map +1 -1
- package/dist/tool-call-service/index.js +11 -2
- package/dist/tool-call-service/utils.d.ts +1 -0
- package/dist/tool-call-service/utils.d.ts.map +1 -1
- package/dist/tool-call-service/utils.js +6 -2
- package/dist/tools/commit-and-create-pr.d.ts +1 -1
- package/dist/tools/commit-and-create-pr.d.ts.map +1 -1
- package/dist/tools/commit-and-create-pr.js +1 -1
- package/dist/tools/diagnosis-fetcher.d.ts +1 -1
- package/dist/tools/diagnosis-fetcher.d.ts.map +1 -1
- package/dist/tools/diagnosis-fetcher.js +1 -1
- package/dist/tools/download-build.d.ts +1 -1
- package/dist/tools/download-build.d.ts.map +1 -1
- package/dist/tools/download-build.js +1 -1
- package/dist/tools/environment-crud.d.ts +1 -1
- package/dist/tools/environment-crud.d.ts.map +1 -1
- package/dist/tools/environment-crud.js +1 -1
- package/dist/tools/grep/index.d.ts +1 -1
- package/dist/tools/grep/index.d.ts.map +1 -1
- package/dist/tools/grep/index.js +4 -3
- package/dist/tools/str_replace_editor.d.ts +5 -7
- package/dist/tools/str_replace_editor.d.ts.map +1 -1
- package/dist/tools/str_replace_editor.js +259 -247
- package/dist/tools/test-gen-browser.d.ts +1 -1
- package/dist/tools/test-gen-browser.d.ts.map +1 -1
- package/dist/tools/test-gen-browser.js +45 -20
- package/dist/tools/test-run-fetcher/index.d.ts +1 -1
- package/dist/tools/test-run-fetcher/index.d.ts.map +1 -1
- package/dist/tools/test-run-fetcher/index.js +1 -1
- package/dist/tools/test-run.d.ts +1 -1
- package/dist/tools/test-run.d.ts.map +1 -1
- package/dist/tools/test-run.js +35 -12
- package/dist/tools/utils/index.d.ts +0 -13
- package/dist/tools/utils/index.d.ts.map +1 -1
- package/dist/tools/utils/index.js +0 -47
- package/dist/utils/exec.d.ts +4 -4
- package/dist/utils/exec.d.ts.map +1 -1
- package/dist/utils/exec.js +2 -4
- package/dist/utils/file-tree.d.ts.map +1 -1
- package/dist/utils/file-tree.js +2 -0
- package/package.json +4 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/tools/codegen-agent.d.ts +0 -3
- package/dist/tools/codegen-agent.d.ts.map +0 -1
- package/dist/tools/codegen-agent.js +0 -40
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ArtifactInput, ArtifactInputPath } from "@empiricalrun/shared-types";
|
|
2
|
+
import { JSONReport as PlaywrightJSONReport } from "@playwright/test/reporter";
|
|
3
|
+
/**
|
|
4
|
+
* Extracts attachment information from a Playwright JSON report.
|
|
5
|
+
* @param report The Playwright JSON report to extract attachments from
|
|
6
|
+
* @returns An array of objects containing path and contentType for each attachment
|
|
7
|
+
*/
|
|
8
|
+
export declare function extractAttachmentsFromPlaywrightJSONReport(report: PlaywrightJSONReport): ArtifactInputPath[];
|
|
9
|
+
/**
|
|
10
|
+
* Scans the given repository directory for Playwright artifacts (attachments) by:
|
|
11
|
+
* - Constructing the path to the Playwright report directory using the provided repoDir.
|
|
12
|
+
* - Building the absolute path to the summary.json file within the report directory.
|
|
13
|
+
* - Checking if summary.json exists, and if so, reading and parsing its contents.
|
|
14
|
+
* - Extracting attachment information (such as file paths and content types) from the parsed Playwright JSON report.
|
|
15
|
+
* - Returning an array of ArtifactInput objects, each containing details about a found attachment.
|
|
16
|
+
*
|
|
17
|
+
* @param repoDir Absolute path to the root of the repository. Used to construct paths to Playwright artifacts.
|
|
18
|
+
* @returns Array of ArtifactInput objects representing found Playwright attachments, including their resolved paths and content types.
|
|
19
|
+
*/
|
|
20
|
+
export declare function findPlaywrightArtifacts(repoDir: string): ArtifactInput[];
|
|
21
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/artifacts/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EACL,UAAU,IAAI,oBAAoB,EAGnC,MAAM,2BAA2B,CAAC;AAGnC;;;;GAIG;AACH,wBAAgB,0CAA0C,CACxD,MAAM,EAAE,oBAAoB,GAC3B,iBAAiB,EAAE,CAqErB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,EAAE,CAmBxE"}
|
|
@@ -0,0 +1,102 @@
|
|
|
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.extractAttachmentsFromPlaywrightJSONReport = extractAttachmentsFromPlaywrightJSONReport;
|
|
7
|
+
exports.findPlaywrightArtifacts = findPlaywrightArtifacts;
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
/**
|
|
10
|
+
* Extracts attachment information from a Playwright JSON report.
|
|
11
|
+
* @param report The Playwright JSON report to extract attachments from
|
|
12
|
+
* @returns An array of objects containing path and contentType for each attachment
|
|
13
|
+
*/
|
|
14
|
+
function extractAttachmentsFromPlaywrightJSONReport(report) {
|
|
15
|
+
const attachments = [];
|
|
16
|
+
if (!report || !report.suites || report.suites.length === 0) {
|
|
17
|
+
return attachments;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Helper function to process a single spec and extract its attachments.
|
|
21
|
+
* @param {JSONReportSpec} spec - The spec object to process.
|
|
22
|
+
*/
|
|
23
|
+
function processSpec(spec) {
|
|
24
|
+
const testTitle = spec.title;
|
|
25
|
+
if (!spec.tests) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
for (const test of spec.tests) {
|
|
29
|
+
if (!test.results) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
for (const result of test.results) {
|
|
33
|
+
if (!result.attachments) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
for (const attachment of result.attachments) {
|
|
37
|
+
// Only collect attachments that have a 'path' (i.e., not embedded content)
|
|
38
|
+
if (attachment.path && attachment.contentType) {
|
|
39
|
+
attachments.push({
|
|
40
|
+
name: `${testTitle} ${attachment.name}`,
|
|
41
|
+
path: attachment.path,
|
|
42
|
+
contentType: attachment.contentType,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Recursive helper function to traverse the suite structure.
|
|
51
|
+
* @param {JSONReportSuite[]} suites - An array of suites to process.
|
|
52
|
+
*/
|
|
53
|
+
function traverseSuites(suites) {
|
|
54
|
+
if (!suites) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
for (const suite of suites) {
|
|
58
|
+
// Process specs directly within the current suite
|
|
59
|
+
if (suite.specs) {
|
|
60
|
+
for (const spec of suite.specs) {
|
|
61
|
+
processSpec(spec);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Recursively call for any nested suites
|
|
65
|
+
if (suite.suites) {
|
|
66
|
+
traverseSuites(suite.suites);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Start the recursive traversal from the top-level suites
|
|
71
|
+
traverseSuites(report.suites);
|
|
72
|
+
return attachments;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Scans the given repository directory for Playwright artifacts (attachments) by:
|
|
76
|
+
* - Constructing the path to the Playwright report directory using the provided repoDir.
|
|
77
|
+
* - Building the absolute path to the summary.json file within the report directory.
|
|
78
|
+
* - Checking if summary.json exists, and if so, reading and parsing its contents.
|
|
79
|
+
* - Extracting attachment information (such as file paths and content types) from the parsed Playwright JSON report.
|
|
80
|
+
* - Returning an array of ArtifactInput objects, each containing details about a found attachment.
|
|
81
|
+
*
|
|
82
|
+
* @param repoDir Absolute path to the root of the repository. Used to construct paths to Playwright artifacts.
|
|
83
|
+
* @returns Array of ArtifactInput objects representing found Playwright attachments, including their resolved paths and content types.
|
|
84
|
+
*/
|
|
85
|
+
function findPlaywrightArtifacts(repoDir) {
|
|
86
|
+
const artifacts = [];
|
|
87
|
+
const reportPath = require("path").join(repoDir, "playwright-report");
|
|
88
|
+
const summaryJsonPath = require("path").join(reportPath, "summary.json");
|
|
89
|
+
if (fs_1.default.existsSync(summaryJsonPath)) {
|
|
90
|
+
try {
|
|
91
|
+
const summaryJson = JSON.parse(fs_1.default.readFileSync(summaryJsonPath, "utf-8"));
|
|
92
|
+
const found = extractAttachmentsFromPlaywrightJSONReport(summaryJson);
|
|
93
|
+
if (Array.isArray(found) && found.length > 0) {
|
|
94
|
+
artifacts.push(...found);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (e) {
|
|
98
|
+
console.error(`[findPlaywrightArtifacts] Error parsing summary.json: ${e}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return artifacts;
|
|
102
|
+
}
|
package/dist/bin/index.js
CHANGED
|
@@ -30,7 +30,7 @@ const flushEvents = async () => {
|
|
|
30
30
|
};
|
|
31
31
|
function setupProcessListeners(cleanup) {
|
|
32
32
|
const events = ["beforeExit", "exit", "SIGINT", "SIGTERM"];
|
|
33
|
-
events.forEach((event) => process.
|
|
33
|
+
events.forEach((event) => process.once(event, cleanup));
|
|
34
34
|
return () => {
|
|
35
35
|
events.forEach((event) => process.removeListener(event, cleanup));
|
|
36
36
|
};
|
|
@@ -191,6 +191,7 @@ async function runAgentsWorkflow(testGenConfig, testGenToken) {
|
|
|
191
191
|
testGenToken,
|
|
192
192
|
repoDir: process.cwd(),
|
|
193
193
|
editFileWithGeneratedCode: true,
|
|
194
|
+
envOverrides: {},
|
|
194
195
|
});
|
|
195
196
|
if (isError) {
|
|
196
197
|
throw new Error(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/bin/utils/platform/web/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAM3D,OAAO,EAGL,IAAI,EAEJ,UAAU,EAEX,MAAM,UAAU,CAAC;AAMlB,eAAO,MAAM,gCAAgC,GAC3C,YAAY,UAAU,KACrB,MAgBF,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,YAAY,EACZ,MAAM,EACN,OAAO,GACR,EA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CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,UAOA;AAED,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CA4B5E;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAQnD"}
|
|
@@ -275,6 +275,7 @@ async function stripAndPrependImports(content, testName) {
|
|
|
275
275
|
return [prependContent, strippedContent];
|
|
276
276
|
}
|
|
277
277
|
async function lintErrors(filePath) {
|
|
278
|
+
// TODO: use in new tools - return result/error?
|
|
278
279
|
const eslint = new eslint_1.ESLint({
|
|
279
280
|
fix: true,
|
|
280
281
|
useEslintrc: true,
|
|
@@ -285,6 +286,7 @@ async function lintErrors(filePath) {
|
|
|
285
286
|
}
|
|
286
287
|
}
|
|
287
288
|
async function formatCode(filePath, trace) {
|
|
289
|
+
// TODO: should we delete this?
|
|
288
290
|
const fileContent = fs_1.default.readFileSync(filePath, "utf8");
|
|
289
291
|
if (!fileContent) {
|
|
290
292
|
trace?.span({
|
package/dist/file/server.js
CHANGED
|
@@ -31,7 +31,7 @@ class FileServiceServer {
|
|
|
31
31
|
return this.artifactsInputs;
|
|
32
32
|
}
|
|
33
33
|
setFilePath(filePath) {
|
|
34
|
-
this.filePath = filePath;
|
|
34
|
+
this.filePath = path_1.default.resolve(this.repoDir, filePath);
|
|
35
35
|
}
|
|
36
36
|
async startFileService() {
|
|
37
37
|
const app = (0, express_1.default)();
|
package/dist/test-build/index.js
CHANGED
|
@@ -26,7 +26,7 @@ async function downloadBuild({ buildUrl, repoPath, apiKey, }) {
|
|
|
26
26
|
logger.log(`Downloading build from ${buildUrl}`);
|
|
27
27
|
await (0, exec_1.cmd)(`npm`, ["run", "download", buildUrl], {
|
|
28
28
|
cwd: repoPath,
|
|
29
|
-
|
|
29
|
+
envOverrides: { ...Object(process.env), EMPIRICALRUN_API_KEY: apiKey },
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TraceClient } from "@empiricalrun/llm";
|
|
2
|
-
import { PendingToolCall, SupportedChatModels,
|
|
2
|
+
import { PendingToolCall, SupportedChatModels, ToolResult } from "@empiricalrun/llm/chat";
|
|
3
|
+
import { Tool, ToolExecute } from "@empiricalrun/shared-types";
|
|
3
4
|
export type { SupportedChatModels };
|
|
4
5
|
type ToolExecutors = {
|
|
5
6
|
[key: string]: ToolExecute;
|
|
@@ -13,13 +14,15 @@ export declare class ToolCallService {
|
|
|
13
14
|
repoPath: string;
|
|
14
15
|
apiKey: string | undefined;
|
|
15
16
|
trace?: TraceClient;
|
|
16
|
-
|
|
17
|
+
featureFlags: string[];
|
|
18
|
+
constructor({ chatSessionId, selectedModel, branchName, repoPath, apiKey, trace, featureFlags, }: {
|
|
17
19
|
chatSessionId: number | null;
|
|
18
20
|
selectedModel: SupportedChatModels;
|
|
19
21
|
branchName: string;
|
|
20
22
|
repoPath: string;
|
|
21
23
|
apiKey: string | undefined;
|
|
22
24
|
trace?: TraceClient;
|
|
25
|
+
featureFlags: string[];
|
|
23
26
|
});
|
|
24
27
|
sendToQueue(toolCalls: PendingToolCall[]): Promise<void>;
|
|
25
28
|
execute(toolCalls: PendingToolCall[]): Promise<ToolResult[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tool-call-service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAEL,eAAe,EACf,mBAAmB,EACnB,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tool-call-service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAEL,eAAe,EACf,mBAAmB,EACnB,UAAU,EACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAiB,IAAI,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAiB9E,YAAY,EAAE,mBAAmB,EAAE,CAAC;AAEpC,KAAK,aAAa,GAAG;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC;CAC5B,CAAC;AAEF,qBAAa,eAAe;IAC1B,KAAK,EAAE,IAAI,EAAE,CAAM;IACnB,aAAa,EAAE,aAAa,CAAM;IAClC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,mBAAmB,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;gBACX,EACV,aAAa,EACb,aAAa,EACb,UAAU,EACV,QAAQ,EACR,MAAM,EACN,KAAK,EACL,YAAY,GACb,EAAE;QACD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;QAC7B,aAAa,EAAE,mBAAmB,CAAC;QACnC,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,KAAK,CAAC,EAAE,WAAW,CAAC;QACpB,YAAY,EAAE,MAAM,EAAE,CAAC;KACxB;IAkCK,WAAW,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAexD,OAAO,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAsEnE"}
|
|
@@ -23,13 +23,15 @@ class ToolCallService {
|
|
|
23
23
|
repoPath;
|
|
24
24
|
apiKey;
|
|
25
25
|
trace;
|
|
26
|
-
|
|
26
|
+
featureFlags;
|
|
27
|
+
constructor({ chatSessionId, selectedModel, branchName, repoPath, apiKey, trace, featureFlags, }) {
|
|
27
28
|
this.chatSessionId = chatSessionId;
|
|
28
29
|
this.selectedModel = selectedModel;
|
|
29
30
|
this.branchName = branchName;
|
|
30
31
|
this.trace = trace;
|
|
31
32
|
this.repoPath = repoPath;
|
|
32
33
|
this.apiKey = apiKey;
|
|
34
|
+
this.featureFlags = featureFlags;
|
|
33
35
|
this.tools = [
|
|
34
36
|
grep_1.grepTool,
|
|
35
37
|
test_run_1.runTestTool,
|
|
@@ -66,6 +68,7 @@ class ToolCallService {
|
|
|
66
68
|
chatSessionId: this.chatSessionId,
|
|
67
69
|
selectedModel: this.selectedModel,
|
|
68
70
|
branchName: this.branchName,
|
|
71
|
+
featureFlags: this.featureFlags || [],
|
|
69
72
|
});
|
|
70
73
|
}
|
|
71
74
|
async execute(toolCalls) {
|
|
@@ -101,7 +104,13 @@ class ToolCallService {
|
|
|
101
104
|
throw new Error("API key is required for tool execution");
|
|
102
105
|
}
|
|
103
106
|
try {
|
|
104
|
-
const result = await toolExecutor(
|
|
107
|
+
const result = await toolExecutor({
|
|
108
|
+
input: toolCall.input,
|
|
109
|
+
repoPath: this.repoPath,
|
|
110
|
+
apiKey: this.apiKey,
|
|
111
|
+
trace: this.trace,
|
|
112
|
+
collectArtifacts: collectArtifactsFn,
|
|
113
|
+
});
|
|
105
114
|
const artifacts = await uploadArtifactsQueue.waitForCompletion();
|
|
106
115
|
toolResults.push({ ...result, artifacts });
|
|
107
116
|
span?.end({ output: result });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/tool-call-service/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,wBAAsB,4BAA4B,CAAC,OAAO,EAAE;IAC1D,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,mBAAmB,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/tool-call-service/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,wBAAsB,4BAA4B,CAAC,OAAO,EAAE;IAC1D,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,mBAAmB,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,iBA4BA"}
|
|
@@ -10,9 +10,13 @@ async function sendToolRequestToRemoteQueue(payload) {
|
|
|
10
10
|
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
11
11
|
},
|
|
12
12
|
});
|
|
13
|
-
const
|
|
13
|
+
const useToolExecutionOnEcs = payload.featureFlags.includes("useToolExecutionOnEcs");
|
|
14
|
+
let queueUrl = process.env.TOOL_EXECUTION_SQS_URL;
|
|
15
|
+
if (useToolExecutionOnEcs) {
|
|
16
|
+
queueUrl = process.env.TOOL_EXECUTION_SQS_URL_ECS;
|
|
17
|
+
}
|
|
14
18
|
if (!queueUrl) {
|
|
15
|
-
throw new Error("TOOL_EXECUTION_SQS_URL is required for remote execution
|
|
19
|
+
throw new Error(`${useToolExecutionOnEcs ? "TOOL_EXECUTION_SQS_URL_ECS" : "TOOL_EXECUTION_SQS_URL"} is required for remote execution.`);
|
|
16
20
|
}
|
|
17
21
|
await sqs.send(new client_sqs_1.SendMessageCommand({
|
|
18
22
|
QueueUrl: queueUrl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commit-and-create-pr.d.ts","sourceRoot":"","sources":["../../src/tools/commit-and-create-pr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"commit-and-create-pr.d.ts","sourceRoot":"","sources":["../../src/tools/commit-and-create-pr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAOvD,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAiB1D;AA2CD,eAAO,MAAM,qBAAqB,EAAE,IA0FnC,CAAC"}
|
|
@@ -55,7 +55,7 @@ Don't ask the user for this information, just come up with it yourself.
|
|
|
55
55
|
`,
|
|
56
56
|
parameters: createPullRequestSchema,
|
|
57
57
|
},
|
|
58
|
-
execute: async (input, repoPath, apiKey) => {
|
|
58
|
+
execute: async ({ input, repoPath, apiKey, }) => {
|
|
59
59
|
try {
|
|
60
60
|
const { pullRequestTitle, pullRequestDescription } = input;
|
|
61
61
|
const branchName = await (0, git_1.getCurrentBranchName)(repoPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnosis-fetcher.d.ts","sourceRoot":"","sources":["../../src/tools/diagnosis-fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"diagnosis-fetcher.d.ts","sourceRoot":"","sources":["../../src/tools/diagnosis-fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAevD,eAAO,MAAM,wBAAwB,EAAE,IAyFtC,CAAC"}
|
|
@@ -19,7 +19,7 @@ exports.fetchDiagnosisReportTool = {
|
|
|
19
19
|
description: "Fetch details about a test case diagnosis using its URL or slug",
|
|
20
20
|
parameters: DiagnosisSchema,
|
|
21
21
|
},
|
|
22
|
-
execute: async (input, repoPath, apiKey) => {
|
|
22
|
+
execute: async ({ input, repoPath, apiKey, }) => {
|
|
23
23
|
const { diagnosisUrl } = input;
|
|
24
24
|
// Extract the slug from the URL - it's the part after the last '--'
|
|
25
25
|
const slug = diagnosisUrl.split("--").pop();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download-build.d.ts","sourceRoot":"","sources":["../../src/tools/download-build.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"download-build.d.ts","sourceRoot":"","sources":["../../src/tools/download-build.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,uBAAuB;;;;;;EAElC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE7E,eAAO,MAAM,iBAAiB,EAAE,IAsC/B,CAAC"}
|
|
@@ -14,7 +14,7 @@ have a build URL, you can try getting the environment details with the getEnviro
|
|
|
14
14
|
Environment details will include the build URL.`,
|
|
15
15
|
parameters: exports.downloadBuildToolSchema,
|
|
16
16
|
},
|
|
17
|
-
execute: async (input, repoPath, apiKey) => {
|
|
17
|
+
execute: async ({ input, repoPath, apiKey, }) => {
|
|
18
18
|
if (!(await (0, test_build_1.hasDownloadScript)(repoPath))) {
|
|
19
19
|
return {
|
|
20
20
|
isError: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment-crud.d.ts","sourceRoot":"","sources":["../../src/tools/environment-crud.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"environment-crud.d.ts","sourceRoot":"","sources":["../../src/tools/environment-crud.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AA6DvD,eAAO,MAAM,kBAAkB,EAAE,IAiFhC,CAAC;AAGF,eAAO,MAAM,gBAAgB,EAAE,IAAI,EAAyB,CAAC"}
|
|
@@ -31,7 +31,7 @@ exports.getEnvironmentTool = {
|
|
|
31
31
|
description: "Fetch details of an existing environment",
|
|
32
32
|
parameters: GetEnvironmentSchema,
|
|
33
33
|
},
|
|
34
|
-
execute: async (input, repoPath, apiKey) => {
|
|
34
|
+
execute: async ({ input, repoPath, apiKey, }) => {
|
|
35
35
|
// Get project repo name
|
|
36
36
|
let projectRepoName;
|
|
37
37
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/grep/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/grep/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,4BAA4B,CAAC;AA8HnE,eAAO,MAAM,QAAQ,EAAE,IAuBtB,CAAC"}
|
package/dist/tools/grep/index.js
CHANGED
|
@@ -75,8 +75,9 @@ async function usingRipgrep(input, repoPath) {
|
|
|
75
75
|
try {
|
|
76
76
|
const dir = path_1.default.join(repoPath, input.directory || "");
|
|
77
77
|
const escapedPattern = input.pattern
|
|
78
|
-
.replace(
|
|
79
|
-
.replace(/
|
|
78
|
+
.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") // Escape special characters that have meaning in regex/grep
|
|
79
|
+
.replace(/[&;|<>]/g, "\\$&") // Escape shell special characters
|
|
80
|
+
.replace(/\s+/g, "\\ "); // Handle spaces
|
|
80
81
|
const results = (0, ripgrep_1.ripgrep)(dir, {
|
|
81
82
|
string: escapedPattern,
|
|
82
83
|
globs: input.filePattern ? [input.filePattern] : undefined,
|
|
@@ -123,7 +124,7 @@ If ripgrep is not available, it will fall back to using system grep.
|
|
|
123
124
|
Search is case insensitive and regex patterns are not supported.`,
|
|
124
125
|
parameters: GrepInputSchema,
|
|
125
126
|
},
|
|
126
|
-
execute: async (input, repoPath) => {
|
|
127
|
+
execute: async ({ input, repoPath, }) => {
|
|
127
128
|
if ((0, ripgrep_1.isRgAvailable)()) {
|
|
128
129
|
return usingRipgrep(input, repoPath);
|
|
129
130
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Tool, ToolResult } from "@empiricalrun/
|
|
1
|
+
import type { Tool, ToolResult } from "@empiricalrun/shared-types";
|
|
2
2
|
interface StrReplaceInput {
|
|
3
3
|
command: string;
|
|
4
4
|
path: string;
|
|
@@ -8,16 +8,14 @@ interface StrReplaceInput {
|
|
|
8
8
|
file_text?: string;
|
|
9
9
|
insert_line?: number;
|
|
10
10
|
}
|
|
11
|
-
/**
|
|
12
|
-
* Cleans up any backup files that were created during the editing process
|
|
13
|
-
* @returns The number of backup files that were cleaned up
|
|
14
|
-
*/
|
|
15
|
-
export declare function cleanupBackupFiles(repoDir: string): number;
|
|
16
11
|
/**
|
|
17
12
|
* Our implementation of Claude's built-in text editor tool
|
|
18
13
|
* https://docs.anthropic.com/en/docs/build-with-claude/tool-use/text-editor-tool
|
|
19
14
|
*/
|
|
20
|
-
export declare function strReplaceEditorExecutor(input
|
|
15
|
+
export declare function strReplaceEditorExecutor({ input, repoPath, }: {
|
|
16
|
+
input: StrReplaceInput;
|
|
17
|
+
repoPath: string;
|
|
18
|
+
}): Promise<ToolResult>;
|
|
21
19
|
export declare const textEditorTools: Tool[];
|
|
22
20
|
export {};
|
|
23
21
|
//# sourceMappingURL=str_replace_editor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"str_replace_editor.d.ts","sourceRoot":"","sources":["../../src/tools/str_replace_editor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"str_replace_editor.d.ts","sourceRoot":"","sources":["../../src/tools/str_replace_editor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAOnE,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AA6UD;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,EAC7C,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,eAAe,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,UAAU,CAAC,CA2CtB;AAsID,eAAO,MAAM,eAAe,EAAE,IAAI,EAKjC,CAAC"}
|