@empiricalrun/test-gen 0.54.1 → 0.56.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 +31 -0
- package/dist/agent/browsing/utils.d.ts.map +1 -1
- package/dist/agent/browsing/utils.js +20 -2
- package/dist/agent/chat/agent-loop.d.ts +3 -1
- package/dist/agent/chat/agent-loop.d.ts.map +1 -1
- package/dist/agent/chat/agent-loop.js +10 -58
- package/dist/agent/chat/exports.d.ts +8 -0
- package/dist/agent/chat/exports.d.ts.map +1 -0
- package/dist/agent/chat/exports.js +7 -0
- package/dist/agent/chat/index.d.ts.map +1 -1
- package/dist/agent/chat/index.js +5 -0
- package/dist/agent/chat/model.d.ts.map +1 -1
- package/dist/agent/chat/model.js +3 -0
- package/dist/agent/chat/types.d.ts +1 -1
- package/dist/agent/chat/types.d.ts.map +1 -1
- package/dist/bin/index.js +7 -4
- package/dist/bin/utils/index.d.ts +1 -1
- package/dist/bin/utils/index.d.ts.map +1 -1
- package/dist/test-build/index.d.ts +2 -9
- package/dist/test-build/index.d.ts.map +1 -1
- package/dist/test-build/index.js +16 -15
- package/dist/tool-call-service/index.d.ts +18 -0
- package/dist/tool-call-service/index.d.ts.map +1 -0
- package/dist/tool-call-service/index.js +101 -0
- package/dist/tools/download-build.d.ts +3 -0
- package/dist/tools/download-build.d.ts.map +1 -0
- package/dist/tools/download-build.js +39 -0
- package/dist/tools/environment-crud.d.ts +4 -0
- package/dist/tools/environment-crud.d.ts.map +1 -0
- package/dist/tools/environment-crud.js +98 -0
- package/dist/tools/str_replace_editor.d.ts +1 -1
- package/dist/tools/str_replace_editor.d.ts.map +1 -1
- package/dist/tools/str_replace_editor.js +20 -25
- package/dist/tools/utils/index.d.ts.map +1 -1
- package/dist/tools/utils/index.js +6 -2
- package/package.json +12 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.56.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b073084: feat: new APIs and refactor to introduce tool execute service
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 93d7a0b: feat: add tool call for downloading builds
|
|
12
|
+
- a58ac3f: feat: add dashboard agent integration and optimize tsx handling
|
|
13
|
+
- Updated dependencies [87af227]
|
|
14
|
+
- Updated dependencies [3831109]
|
|
15
|
+
- Updated dependencies [a58ac3f]
|
|
16
|
+
- Updated dependencies [f77e33d]
|
|
17
|
+
- @empiricalrun/llm@0.15.1
|
|
18
|
+
- @empiricalrun/test-run@0.8.1
|
|
19
|
+
|
|
20
|
+
## 0.55.0
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- 508565d: feat: add support for openai chat model
|
|
25
|
+
- 8da022c: feat: add environment fetching tool
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- 99e4e6e: refactor: decoupled agentloop and toolcall
|
|
30
|
+
- Updated dependencies [cc4cb5e]
|
|
31
|
+
- Updated dependencies [508565d]
|
|
32
|
+
- @empiricalrun/llm@0.15.0
|
|
33
|
+
|
|
3
34
|
## 0.54.1
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAe,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAIxE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAe,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAIxE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAwBvD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAIvD;AAiFD,wBAAsB,yBAAyB,CAAC,EAC9C,YAAY,EACZ,YAAY,EACZ,cAAc,GACf,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,iBA2BA;AAED,wBAAsB,cAAc,CAAC,EACnC,YAAY,EACZ,cAAc,EACd,QAAQ,GACT,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;CAClB,iBAoBA;AAED,wBAAsB,yBAAyB,CAAC,EAC9C,QAAQ,EACR,QAAQ,EACR,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC,MAAM,CAAC,CAyDlB;AAyBD,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,IAAI,iBA2HxD;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC,CA0B/B;AAWD,wBAAsB,oBAAoB,CACxC,gBAAgB,EAAE,oBAAoB,GACrC,OAAO,CAAC,MAAM,EAAE,CAAC,CAQnB;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,oBAAoB,EACtC,gBAAgB,GAAE,MAAM,EAAU,GACjC,OAAO,CAAC,MAAM,CAAC,CA+CjB;AAED,qBAAa,eAAe;IACd,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,MAAM;IACrC,OAAO,CAAC,aAAa,CAAqB;YAE5B,mBAAmB;YAUnB,gBAAgB;IAsBjB,OAAO;IAoBb,SAAS;CAKjB"}
|
|
@@ -8,7 +8,8 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
8
8
|
const minimatch_1 = require("minimatch");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const ts_morph_1 = require("ts-morph");
|
|
11
|
-
|
|
11
|
+
// For TypeScript type safety
|
|
12
|
+
let tsxImport = null;
|
|
12
13
|
const logger_1 = require("../../bin/logger");
|
|
13
14
|
const context_1 = require("../../bin/utils/context");
|
|
14
15
|
const fs_1 = require("../../bin/utils/fs");
|
|
@@ -295,8 +296,25 @@ exports.injectPwLocatorGenerator = injectPwLocatorGenerator;
|
|
|
295
296
|
* @return {*} {Promise<PlaywrightTestConfig>}
|
|
296
297
|
*/
|
|
297
298
|
async function readPlaywrightConfig(repoDir) {
|
|
299
|
+
if (typeof window !== "undefined") {
|
|
300
|
+
throw new Error("readPlaywrightConfig cannot be used in browser environments");
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
// Only initialize on server side
|
|
304
|
+
// This will only execute on the server
|
|
305
|
+
await import("tsx/cjs/api")
|
|
306
|
+
.then((module) => {
|
|
307
|
+
tsxImport = module;
|
|
308
|
+
})
|
|
309
|
+
.catch((err) => {
|
|
310
|
+
console.error("Failed to import tsx:", err);
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
if (!tsxImport) {
|
|
314
|
+
throw new Error("tsx module not available");
|
|
315
|
+
}
|
|
298
316
|
const [lastDir] = repoDir.split("/").reverse();
|
|
299
|
-
const playwrightConfig = (await
|
|
317
|
+
const playwrightConfig = (await tsxImport.require("./playwright.config.ts", `${repoDir}/${lastDir}`)).default;
|
|
300
318
|
return playwrightConfig;
|
|
301
319
|
}
|
|
302
320
|
exports.readPlaywrightConfig = readPlaywrightConfig;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { TraceClient } from "@empiricalrun/llm";
|
|
2
2
|
import { IChatModel } from "@empiricalrun/llm/chat";
|
|
3
|
+
import { ToolCallService } from "../../tool-call-service";
|
|
3
4
|
import { ReporterFunction, SupportedChatModels } from "./types";
|
|
4
|
-
export declare function chatAgentLoop({ chatModel, selectedModel, reporter, trace, }: {
|
|
5
|
+
export declare function chatAgentLoop({ chatModel, selectedModel, reporter, trace, toolCallService, }: {
|
|
5
6
|
chatModel: IChatModel<any>;
|
|
6
7
|
selectedModel: SupportedChatModels;
|
|
8
|
+
toolCallService: ToolCallService;
|
|
7
9
|
reporter: ReporterFunction;
|
|
8
10
|
trace?: TraceClient;
|
|
9
11
|
}): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-loop.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/agent-loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,UAAU,EAIX,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-loop.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/agent-loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,UAAU,EAIX,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAgBhE,wBAAsB,aAAa,CAAC,EAClC,SAAS,EACT,aAAa,EACb,QAAQ,EACR,KAAK,EACL,eAAe,GAChB,EAAE;IACD,SAAS,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IAC3B,aAAa,EAAE,mBAAmB,CAAC;IACnC,eAAe,EAAE,eAAe,CAAC;IACjC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,iBAoCA"}
|
|
@@ -3,80 +3,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.chatAgentLoop = void 0;
|
|
4
4
|
const chat_1 = require("@empiricalrun/llm/chat");
|
|
5
5
|
const picocolors_1 = require("picocolors");
|
|
6
|
-
const web_1 = require("../../bin/utils/platform/web");
|
|
7
|
-
const commit_and_create_pr_1 = require("../../tools/commit-and-create-pr");
|
|
8
|
-
const diagnosis_fetcher_1 = require("../../tools/diagnosis-fetcher");
|
|
9
|
-
const grep_1 = require("../../tools/grep");
|
|
10
|
-
const str_replace_editor_1 = require("../../tools/str_replace_editor");
|
|
11
|
-
const test_gen_browser_1 = require("../../tools/test-gen-browser");
|
|
12
|
-
const test_run_1 = require("../../tools/test-run");
|
|
13
|
-
const test_run_fetcher_1 = require("../../tools/test-run-fetcher");
|
|
14
6
|
const prompt_1 = require("./prompt");
|
|
15
7
|
const state_1 = require("./state");
|
|
16
|
-
function getTools(selectedModel) {
|
|
17
|
-
let tools = [
|
|
18
|
-
grep_1.grepTool,
|
|
19
|
-
test_run_1.runTestTool,
|
|
20
|
-
test_run_fetcher_1.fetchTestRunReportTool,
|
|
21
|
-
diagnosis_fetcher_1.fetchDiagnosisReportTool,
|
|
22
|
-
test_gen_browser_1.generateTestWithBrowserAgent,
|
|
23
|
-
commit_and_create_pr_1.commitAndPushChangesTool,
|
|
24
|
-
];
|
|
25
|
-
if (selectedModel.startsWith("gemini")) {
|
|
26
|
-
// Claude will have its own built-in text editor tools
|
|
27
|
-
str_replace_editor_1.textEditorTools.forEach((tool) => {
|
|
28
|
-
const originalExecute = tool.execute;
|
|
29
|
-
tool.execute = (input) => originalExecute(input, web_1.validateTypescript);
|
|
30
|
-
});
|
|
31
|
-
tools.push(...str_replace_editor_1.textEditorTools);
|
|
32
|
-
}
|
|
33
|
-
const toolExecutors = {
|
|
34
|
-
...Object.fromEntries(tools.map((tool) => [tool.schema.name, tool.execute])),
|
|
35
|
-
};
|
|
36
|
-
if (selectedModel.startsWith("claude")) {
|
|
37
|
-
toolExecutors.str_replace_editor = (input) => (0, str_replace_editor_1.strReplaceEditorExecutor)(input, web_1.validateTypescript);
|
|
38
|
-
}
|
|
39
|
-
return { tools, toolExecutors };
|
|
40
|
-
}
|
|
41
8
|
function getModelName(model) {
|
|
42
9
|
if (model.startsWith("claude"))
|
|
43
10
|
return "Claude";
|
|
44
11
|
if (model.startsWith("gemini"))
|
|
45
12
|
return "Gemini";
|
|
13
|
+
if (model.startsWith("o4"))
|
|
14
|
+
return "o4";
|
|
46
15
|
return "AI";
|
|
47
16
|
}
|
|
48
17
|
const log = (...args) => {
|
|
49
18
|
console.log((0, picocolors_1.gray)(args.join(" ")));
|
|
50
19
|
};
|
|
51
|
-
|
|
20
|
+
const isRemote = process.env.TOOL_EXECUTION_IS_REMOTE === "true" || false;
|
|
21
|
+
async function chatAgentLoop({ chatModel, selectedModel, reporter, trace, toolCallService, }) {
|
|
52
22
|
const systemPrompt = await (0, prompt_1.buildSystemPrompt)();
|
|
53
23
|
trace?.update({ input: { systemPrompt } });
|
|
54
|
-
const { tools
|
|
24
|
+
const { tools } = await toolCallService.getTools();
|
|
55
25
|
while (!chatModel.askUserForInput) {
|
|
56
26
|
const toolCalls = chatModel.getPendingToolCalls();
|
|
27
|
+
console.log("toolCalls", toolCalls);
|
|
57
28
|
if (toolCalls.length) {
|
|
58
|
-
const toolResults =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const toolExecutor = toolExecutors[call.name];
|
|
63
|
-
let callResponse;
|
|
64
|
-
if (!toolExecutor) {
|
|
65
|
-
callResponse = {
|
|
66
|
-
isError: true,
|
|
67
|
-
result: `Invalid function/tool call: ${call.name} not found`,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
callResponse = await toolExecutor(call.input);
|
|
72
|
-
if (callResponse.isError) {
|
|
73
|
-
log(`Tool ${call.name} failed: ${callResponse.result}`);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
log(`Tool ${call.name} completed`);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
toolResults.push(callResponse);
|
|
29
|
+
const toolResults = await toolCallService.execute(toolCalls, isRemote);
|
|
30
|
+
if (isRemote) {
|
|
31
|
+
log(`Tool call remote execution in progress`);
|
|
32
|
+
break;
|
|
80
33
|
}
|
|
81
34
|
chatModel.pushToolResultsMessage(toolCalls, toolResults);
|
|
82
35
|
}
|
|
@@ -94,6 +47,5 @@ async function chatAgentLoop({ chatModel, selectedModel, reporter, trace, }) {
|
|
|
94
47
|
const latest = chatModel.getHumanReadableLatestMessage();
|
|
95
48
|
await reporter((0, state_1.chatStateFromModel)(chatModel, selectedModel), latest);
|
|
96
49
|
}
|
|
97
|
-
(0, str_replace_editor_1.cleanupBackupFiles)(process.cwd());
|
|
98
50
|
}
|
|
99
51
|
exports.chatAgentLoop = chatAgentLoop;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IChatModel } from "@empiricalrun/llm/chat";
|
|
2
|
+
import { chatAgentLoop } from "./agent-loop";
|
|
3
|
+
import { createChatModel } from "./model";
|
|
4
|
+
import { ChatStateOnDisk } from "./state";
|
|
5
|
+
import { ReporterFunction, SupportedChatModels } from "./types";
|
|
6
|
+
export { chatAgentLoop, createChatModel };
|
|
7
|
+
export type { ChatStateOnDisk, IChatModel, ReporterFunction, SupportedChatModels, };
|
|
8
|
+
//# sourceMappingURL=exports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC;AAE1C,YAAY,EACV,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,mBAAmB,GACpB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createChatModel = exports.chatAgentLoop = void 0;
|
|
4
|
+
const agent_loop_1 = require("./agent-loop");
|
|
5
|
+
Object.defineProperty(exports, "chatAgentLoop", { enumerable: true, get: function () { return agent_loop_1.chatAgentLoop; } });
|
|
6
|
+
const model_1 = require("./model");
|
|
7
|
+
Object.defineProperty(exports, "createChatModel", { enumerable: true, get: function () { return model_1.createChatModel; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAoB,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAiBhE,wBAAsB,kBAAkB,CAAC,EACvC,mBAAmB,EACnB,aAAa,EACb,oBAAoB,GACrB,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C,iBAsFA;AAuBD,wBAAsB,wBAAwB,CAAC,EAC7C,aAAa,EACb,aAAa,GACd,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB,iBA2CA"}
|
package/dist/agent/chat/index.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.runChatAgentForDashboard = exports.runChatAgentForCLI = void 0;
|
|
|
4
4
|
const llm_1 = require("@empiricalrun/llm");
|
|
5
5
|
const picocolors_1 = require("picocolors");
|
|
6
6
|
const human_in_the_loop_1 = require("../../human-in-the-loop");
|
|
7
|
+
const tool_call_service_1 = require("../../tool-call-service");
|
|
7
8
|
const git_1 = require("../../utils/git");
|
|
8
9
|
const agent_loop_1 = require("./agent-loop");
|
|
9
10
|
const model_1 = require("./model");
|
|
@@ -83,11 +84,13 @@ async function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialP
|
|
|
83
84
|
}
|
|
84
85
|
else {
|
|
85
86
|
// TODO: Should we pass a loader function? That would allow us to show a spinner
|
|
87
|
+
const toolCallService = new tool_call_service_1.ToolCallService(null, selectedModel);
|
|
86
88
|
await (0, agent_loop_1.chatAgentLoop)({
|
|
87
89
|
chatModel,
|
|
88
90
|
selectedModel,
|
|
89
91
|
reporter: reporterFunc,
|
|
90
92
|
trace,
|
|
93
|
+
toolCallService,
|
|
91
94
|
});
|
|
92
95
|
}
|
|
93
96
|
}
|
|
@@ -125,6 +128,7 @@ async function runChatAgentForDashboard({ chatSessionId, selectedModel, }) {
|
|
|
125
128
|
chatSessionId,
|
|
126
129
|
},
|
|
127
130
|
});
|
|
131
|
+
const toolCallService = new tool_call_service_1.ToolCallService(chatSessionId, selectedModel);
|
|
128
132
|
await (0, git_1.checkoutBranch)(branchName);
|
|
129
133
|
let chatModel = (0, model_1.createChatModel)(chatState.messages, selectedModel);
|
|
130
134
|
let reporterFunc = async (chatState, latest) => {
|
|
@@ -147,6 +151,7 @@ async function runChatAgentForDashboard({ chatSessionId, selectedModel, }) {
|
|
|
147
151
|
selectedModel,
|
|
148
152
|
reporter: reporterFunc,
|
|
149
153
|
trace,
|
|
154
|
+
toolCallService,
|
|
150
155
|
});
|
|
151
156
|
await (0, git_1.commitLocalAndPushBranchToRemote)(branchName);
|
|
152
157
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EAEX,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,GAAG,EAAE,EACf,aAAa,EAAE,mBAAmB,GACjC,UAAU,CAAC,GAAG,CAAC,CAWjB"}
|
package/dist/agent/chat/model.js
CHANGED
|
@@ -9,6 +9,9 @@ function createChatModel(messages, selectedModel) {
|
|
|
9
9
|
if (selectedModel.startsWith("gemini")) {
|
|
10
10
|
return new chat_1.GeminiChatModel(messages);
|
|
11
11
|
}
|
|
12
|
+
if (selectedModel.startsWith("o4")) {
|
|
13
|
+
return new chat_1.OpenAIChatModel(messages);
|
|
14
|
+
}
|
|
12
15
|
throw new Error(`Unsupported model: ${selectedModel}`);
|
|
13
16
|
}
|
|
14
17
|
exports.createChatModel = createChatModel;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChatStateOnDisk } from "./state";
|
|
2
|
-
export type SupportedChatModels = "claude-3-7-sonnet-20250219" | "claude-3-5-sonnet-20241022" | "gemini-2.5-pro-preview-03-25";
|
|
2
|
+
export type SupportedChatModels = "claude-3-7-sonnet-20250219" | "claude-3-5-sonnet-20241022" | "gemini-2.5-pro-preview-03-25" | "o4-mini-2025-04-16";
|
|
3
3
|
type LatestMessage = {
|
|
4
4
|
role: string;
|
|
5
5
|
textMessage: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,mBAAmB,GAC3B,4BAA4B,GAC5B,4BAA4B,GAC5B,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,mBAAmB,GAC3B,4BAA4B,GAC5B,4BAA4B,GAC5B,8BAA8B,GAC9B,oBAAoB,CAAC;AAEzB,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAC7B,KAAK,EAAE,eAAe,CAAC,GAAG,CAAC,EAC3B,0BAA0B,EAAE,aAAa,GAAG,SAAS,KAClD,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/dist/bin/index.js
CHANGED
|
@@ -38,10 +38,11 @@ function setupProcessListeners(cleanup) {
|
|
|
38
38
|
async function runChatAgent({ modelInput, chatSessionId, useDiskForChatState, initialPromptPath, }) {
|
|
39
39
|
const MODEL_MAPPING = {
|
|
40
40
|
"claude-3-7": "claude-3-7-sonnet-20250219",
|
|
41
|
-
"3-7": "claude-3-7-sonnet-20250219",
|
|
42
41
|
"claude-3-5": "claude-3-5-sonnet-20241022",
|
|
43
|
-
"3-5": "claude-3-5-sonnet-20241022",
|
|
44
42
|
"gemini-2.5-pro-preview-03-25": "gemini-2.5-pro-preview-03-25",
|
|
43
|
+
"gemini-2.5-pro": "gemini-2.5-pro-preview-03-25",
|
|
44
|
+
"o4-mini": "o4-mini-2025-04-16",
|
|
45
|
+
"o4-mini-2025-04-16": "o4-mini-2025-04-16",
|
|
45
46
|
};
|
|
46
47
|
if (modelInput && !MODEL_MAPPING[modelInput]) {
|
|
47
48
|
throw new Error(`Invalid chat model: ${modelInput}`);
|
|
@@ -232,8 +233,10 @@ async function main() {
|
|
|
232
233
|
generationId: testGenConfig.options?.metadata.generationId,
|
|
233
234
|
projectRepoName: testGenConfig.options?.metadata.projectRepoName,
|
|
234
235
|
});
|
|
235
|
-
|
|
236
|
-
|
|
236
|
+
if (testGenConfig.build?.url) {
|
|
237
|
+
// Download the build if repo has a download script
|
|
238
|
+
await (0, test_build_1.downloadBuild)(testGenConfig.build.url);
|
|
239
|
+
}
|
|
237
240
|
if (completedOptions.useChat) {
|
|
238
241
|
await runChatAgent({
|
|
239
242
|
chatSessionId: completedOptions.chatSessionId,
|
|
@@ -8,7 +8,7 @@ export interface CliOptions {
|
|
|
8
8
|
useDiskForChatState?: boolean;
|
|
9
9
|
initialPrompt?: string;
|
|
10
10
|
chatSessionId?: string;
|
|
11
|
-
chatModel?: "claude-3-7" | "
|
|
11
|
+
chatModel?: "claude-3-7" | "claude-3-5" | "claude-3-7-sonnet-20250219" | "claude-3-5-sonnet-20241022" | "gemini-2.5-pro" | "gemini-2.5-pro-preview-03-25" | "o4-mini" | "o4-mini-2025-04-16";
|
|
12
12
|
}
|
|
13
13
|
export declare function validateAndCompleteCliOptions(options: CliOptions): Promise<CliOptions>;
|
|
14
14
|
export declare function printBanner(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/utils/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EACN,YAAY,GACZ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/utils/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EACN,YAAY,GACZ,YAAY,GACZ,4BAA4B,GAC5B,4BAA4B,GAC5B,gBAAgB,GAChB,8BAA8B,GAC9B,SAAS,GACT,oBAAoB,CAAC;CAC1B;AAQD,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,UAAU,CAAC,CAyDrB;AAED,wBAAgB,WAAW,SAgC1B"}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* method to download the build from the URL provided in the build object
|
|
4
|
-
* this is only used in cases like chrome extension as of yet.
|
|
5
|
-
* @export
|
|
6
|
-
* @param {Build} build
|
|
7
|
-
* @return {*} {Promise<void>}
|
|
8
|
-
*/
|
|
9
|
-
export declare function downloadBuild(build: Build): Promise<void>;
|
|
1
|
+
export declare function hasDownloadScript(): Promise<boolean>;
|
|
2
|
+
export declare function downloadBuild(buildUrl: string): Promise<void>;
|
|
10
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-build/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-build/index.ts"],"names":[],"mappings":"AAeA,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAG1D;AAED,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUnE"}
|
package/dist/test-build/index.js
CHANGED
|
@@ -3,26 +3,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.downloadBuild = void 0;
|
|
6
|
+
exports.downloadBuild = exports.hasDownloadScript = void 0;
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
8
|
const logger_1 = require("../bin/logger");
|
|
9
9
|
const exec_1 = require("../utils/exec");
|
|
10
|
-
|
|
11
|
-
* method to download the build from the URL provided in the build object
|
|
12
|
-
* this is only used in cases like chrome extension as of yet.
|
|
13
|
-
* @export
|
|
14
|
-
* @param {Build} build
|
|
15
|
-
* @return {*} {Promise<void>}
|
|
16
|
-
*/
|
|
17
|
-
async function downloadBuild(build) {
|
|
18
|
-
const logger = new logger_1.CustomLogger({ useReporter: false });
|
|
10
|
+
async function getPackageJSON() {
|
|
19
11
|
const packageJSONPath = "package.json";
|
|
20
12
|
const packageJsonStr = await fs_extra_1.default.readFile(packageJSONPath, "utf-8");
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
return JSON.parse(packageJsonStr);
|
|
14
|
+
}
|
|
15
|
+
async function hasDownloadScript() {
|
|
16
|
+
const packageJSON = await getPackageJSON();
|
|
17
|
+
return !!packageJSON.scripts["download"];
|
|
18
|
+
}
|
|
19
|
+
exports.hasDownloadScript = hasDownloadScript;
|
|
20
|
+
async function downloadBuild(buildUrl) {
|
|
21
|
+
const logger = new logger_1.CustomLogger({ useReporter: false });
|
|
22
|
+
const packageJSON = await getPackageJSON();
|
|
23
|
+
const buildDownloadScript = packageJSON.scripts["download"];
|
|
24
|
+
if (buildDownloadScript && buildUrl) {
|
|
25
|
+
logger.log(`Downloading build from ${buildUrl}`);
|
|
26
|
+
await (0, exec_1.cmd)(`npm run download ${buildUrl}`.split(" "), {
|
|
26
27
|
env: { ...Object(process.env) },
|
|
27
28
|
});
|
|
28
29
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PendingToolCall, Tool, ToolResult } from "@empiricalrun/llm/chat";
|
|
2
|
+
import { SupportedChatModels } from "../agent/chat/types";
|
|
3
|
+
export type { SupportedChatModels };
|
|
4
|
+
type ToolExecutors = {
|
|
5
|
+
[key: string]: (input: any) => Promise<ToolResult>;
|
|
6
|
+
};
|
|
7
|
+
export declare class ToolCallService {
|
|
8
|
+
tools: Tool[];
|
|
9
|
+
toolExecutors: ToolExecutors;
|
|
10
|
+
chatSessionId: number | null;
|
|
11
|
+
selectedModel: SupportedChatModels;
|
|
12
|
+
constructor(chatSessionId: number | null, selectedModel: SupportedChatModels);
|
|
13
|
+
getTools(): Promise<{
|
|
14
|
+
tools: Tool[];
|
|
15
|
+
}>;
|
|
16
|
+
execute(toolCalls: PendingToolCall[], isRemote: boolean): Promise<ToolResult[]>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tool-call-service/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAE3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAa1D,YAAY,EAAE,mBAAmB,EAAE,CAAC;AAEpC,KAAK,aAAa,GAAG;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CACpD,CAAC;AAyBF,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;gBAGjC,aAAa,EAAE,MAAM,GAAG,IAAI,EAC5B,aAAa,EAAE,mBAAmB;IAgB9B,QAAQ;;;IAaR,OAAO,CACX,SAAS,EAAE,eAAe,EAAE,EAC5B,QAAQ,EAAE,OAAO,GAChB,OAAO,CAAC,UAAU,EAAE,CAAC;CAqCzB"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToolCallService = void 0;
|
|
4
|
+
const client_sqs_1 = require("@aws-sdk/client-sqs");
|
|
5
|
+
const commit_and_create_pr_1 = require("../tools/commit-and-create-pr");
|
|
6
|
+
const diagnosis_fetcher_1 = require("../tools/diagnosis-fetcher");
|
|
7
|
+
const download_build_1 = require("../tools/download-build");
|
|
8
|
+
const environment_crud_1 = require("../tools/environment-crud");
|
|
9
|
+
const grep_1 = require("../tools/grep");
|
|
10
|
+
const str_replace_editor_1 = require("../tools/str_replace_editor");
|
|
11
|
+
const test_gen_browser_1 = require("../tools/test-gen-browser");
|
|
12
|
+
const test_run_1 = require("../tools/test-run");
|
|
13
|
+
const test_run_fetcher_1 = require("../tools/test-run-fetcher");
|
|
14
|
+
async function sendToolRequestToRemoteQueue(payload) {
|
|
15
|
+
const sqs = new client_sqs_1.SQSClient({
|
|
16
|
+
region: process.env.AWS_REGION,
|
|
17
|
+
credentials: {
|
|
18
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
19
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
const queueUrl = process.env.TOOL_REQUEST_QUEUE_URL;
|
|
23
|
+
await sqs.send(new client_sqs_1.SendMessageCommand({
|
|
24
|
+
QueueUrl: queueUrl,
|
|
25
|
+
MessageBody: JSON.stringify(payload),
|
|
26
|
+
MessageGroupId: payload.requestId,
|
|
27
|
+
MessageDeduplicationId: payload.requestId, // unique id for the tool request
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
class ToolCallService {
|
|
31
|
+
tools = [];
|
|
32
|
+
toolExecutors = {};
|
|
33
|
+
chatSessionId;
|
|
34
|
+
selectedModel;
|
|
35
|
+
constructor(chatSessionId, selectedModel) {
|
|
36
|
+
this.chatSessionId = chatSessionId;
|
|
37
|
+
this.selectedModel = selectedModel;
|
|
38
|
+
this.tools = [
|
|
39
|
+
grep_1.grepTool,
|
|
40
|
+
test_run_1.runTestTool,
|
|
41
|
+
test_run_fetcher_1.fetchTestRunReportTool,
|
|
42
|
+
diagnosis_fetcher_1.fetchDiagnosisReportTool,
|
|
43
|
+
test_gen_browser_1.generateTestWithBrowserAgent,
|
|
44
|
+
commit_and_create_pr_1.commitAndPushChangesTool,
|
|
45
|
+
environment_crud_1.getEnvironmentTool,
|
|
46
|
+
download_build_1.downloadBuildTool,
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
async getTools() {
|
|
50
|
+
if (!this.selectedModel.startsWith("claude")) {
|
|
51
|
+
this.tools.push(...str_replace_editor_1.textEditorTools);
|
|
52
|
+
}
|
|
53
|
+
this.tools.forEach((tool) => {
|
|
54
|
+
this.toolExecutors[tool.schema.name] = tool.execute;
|
|
55
|
+
});
|
|
56
|
+
if (this.selectedModel.startsWith("claude")) {
|
|
57
|
+
this.toolExecutors["str_replace_editor"] = str_replace_editor_1.strReplaceEditorExecutor;
|
|
58
|
+
}
|
|
59
|
+
return { tools: this.tools };
|
|
60
|
+
}
|
|
61
|
+
async execute(toolCalls, isRemote) {
|
|
62
|
+
if (isRemote && this.chatSessionId) {
|
|
63
|
+
console.log("Executing tool remotely", toolCalls);
|
|
64
|
+
await sendToolRequestToRemoteQueue({
|
|
65
|
+
toolCalls,
|
|
66
|
+
requestId: crypto.randomUUID(),
|
|
67
|
+
chatSessionId: this.chatSessionId,
|
|
68
|
+
selectedModel: this.selectedModel,
|
|
69
|
+
});
|
|
70
|
+
return toolCalls.map(() => ({
|
|
71
|
+
isError: false,
|
|
72
|
+
result: `Tool request sent to remote queue to execute.`,
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
const toolResults = [];
|
|
77
|
+
for (const toolCall of toolCalls) {
|
|
78
|
+
const toolExecutor = this.toolExecutors[toolCall.name];
|
|
79
|
+
if (!toolExecutor) {
|
|
80
|
+
toolResults.push({
|
|
81
|
+
isError: true,
|
|
82
|
+
result: `Invalid function/tool call: invalid_tool_call not found`,
|
|
83
|
+
});
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const result = await toolExecutor(toolCall.input);
|
|
88
|
+
toolResults.push(result);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
toolResults.push({
|
|
92
|
+
isError: true,
|
|
93
|
+
result: error instanceof Error ? error.message : String(error),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return toolResults;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.ToolCallService = ToolCallService;
|
|
@@ -0,0 +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,wBAAwB,CAAC;AAKnD,eAAO,MAAM,iBAAiB,EAAE,IAkC/B,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.downloadBuildTool = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const test_build_1 = require("../test-build");
|
|
6
|
+
exports.downloadBuildTool = {
|
|
7
|
+
schema: {
|
|
8
|
+
name: "downloadBuild",
|
|
9
|
+
description: `Download a build from a build URL. If you do not have
|
|
10
|
+
have a build URL, you can try getting the environment details with the getEnvironment tool.
|
|
11
|
+
Environment details will include the build URL.`,
|
|
12
|
+
parameters: zod_1.z.object({
|
|
13
|
+
buildUrl: zod_1.z.string().describe("The URL of the build to download"),
|
|
14
|
+
}),
|
|
15
|
+
},
|
|
16
|
+
execute: async (input) => {
|
|
17
|
+
if (!(await (0, test_build_1.hasDownloadScript)())) {
|
|
18
|
+
return {
|
|
19
|
+
isError: true,
|
|
20
|
+
result: `This repo does not have a download script in package.json.
|
|
21
|
+
You probably don't need to worry about this, since it means this repo does not have a build to download.`,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const { buildUrl } = input;
|
|
25
|
+
try {
|
|
26
|
+
await (0, test_build_1.downloadBuild)(buildUrl);
|
|
27
|
+
return {
|
|
28
|
+
isError: false,
|
|
29
|
+
result: "Build downloaded successfully",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return {
|
|
34
|
+
isError: true,
|
|
35
|
+
result: `Failed to download build: ${error}`,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
};
|
|
@@ -0,0 +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,wBAAwB,CAAC;AAyDnD,eAAO,MAAM,kBAAkB,EAAE,IAwEhC,CAAC;AAGF,eAAO,MAAM,gBAAgB,EAAE,IAAI,EAAyB,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
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.environmentTools = exports.getEnvironmentTool = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
|
+
const getProjectRepoName = () => {
|
|
11
|
+
const packageJson = fs_1.default.readFileSync("package.json", "utf8");
|
|
12
|
+
if (!packageJson) {
|
|
13
|
+
throw new Error("Could not find or read package.json file");
|
|
14
|
+
}
|
|
15
|
+
const packageJsonData = JSON.parse(packageJson);
|
|
16
|
+
if (!packageJsonData.name) {
|
|
17
|
+
throw new Error("package.json does not contain a name field");
|
|
18
|
+
}
|
|
19
|
+
return packageJsonData.name;
|
|
20
|
+
};
|
|
21
|
+
const GetEnvironmentSchema = zod_1.z.object({
|
|
22
|
+
environment_slug: zod_1.z
|
|
23
|
+
.string()
|
|
24
|
+
.describe("The unique identifier (slug) for the environment you want to fetch details for. This is typically a URL-friendly version of the environment name."),
|
|
25
|
+
});
|
|
26
|
+
// Get Environment Tool
|
|
27
|
+
exports.getEnvironmentTool = {
|
|
28
|
+
schema: {
|
|
29
|
+
name: "getEnvironment",
|
|
30
|
+
description: "Fetch details of an existing environment",
|
|
31
|
+
parameters: GetEnvironmentSchema,
|
|
32
|
+
},
|
|
33
|
+
execute: async (input) => {
|
|
34
|
+
// Get project repo name
|
|
35
|
+
let projectRepoName;
|
|
36
|
+
try {
|
|
37
|
+
projectRepoName = getProjectRepoName();
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
return {
|
|
41
|
+
isError: true,
|
|
42
|
+
result: `Failed to get project repository name from package.json: ${error instanceof Error ? error.message : String(error)}`,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
// Make API request
|
|
46
|
+
let response;
|
|
47
|
+
try {
|
|
48
|
+
const queryParams = new URLSearchParams({
|
|
49
|
+
project_repo_name: projectRepoName,
|
|
50
|
+
environment_slug: input.environment_slug,
|
|
51
|
+
});
|
|
52
|
+
response = await (0, utils_1.makeDashboardRequest)({
|
|
53
|
+
path: `/api/environments?${queryParams.toString()}`,
|
|
54
|
+
method: "GET",
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
return {
|
|
59
|
+
isError: true,
|
|
60
|
+
result: `Failed to make API request to fetch environment: ${error instanceof Error ? error.message : String(error)}`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Parse and validate response
|
|
64
|
+
try {
|
|
65
|
+
const data = response;
|
|
66
|
+
if (data.error) {
|
|
67
|
+
return {
|
|
68
|
+
isError: true,
|
|
69
|
+
result: `API returned error while fetching environment: ${data.error.message}`,
|
|
70
|
+
data: data.error,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (!data.data?.environment) {
|
|
74
|
+
return {
|
|
75
|
+
isError: true,
|
|
76
|
+
result: `Environment "${input.environment_slug}" not found in project "${projectRepoName}"`,
|
|
77
|
+
data: data.data,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
result: JSON.stringify({
|
|
82
|
+
message: `Successfully fetched environment "${input.environment_slug}"`,
|
|
83
|
+
data: data.data,
|
|
84
|
+
}),
|
|
85
|
+
isError: false,
|
|
86
|
+
data: data.data,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
return {
|
|
91
|
+
isError: true,
|
|
92
|
+
result: `Failed to parse or validate environment response data: ${error instanceof Error ? error.message : String(error)}`,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
// Export all environment tools as a single array
|
|
98
|
+
exports.environmentTools = [exports.getEnvironmentTool];
|
|
@@ -17,7 +17,7 @@ export declare function cleanupBackupFiles(repoDir: string): number;
|
|
|
17
17
|
* Our implementation of Claude's built-in text editor tool
|
|
18
18
|
* https://docs.anthropic.com/en/docs/build-with-claude/tool-use/text-editor-tool
|
|
19
19
|
*/
|
|
20
|
-
export declare function strReplaceEditorExecutor(input: StrReplaceInput
|
|
20
|
+
export declare function strReplaceEditorExecutor(input: StrReplaceInput): Promise<ToolResult>;
|
|
21
21
|
export declare const textEditorTools: Tool[];
|
|
22
22
|
export {};
|
|
23
23
|
//# 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":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"str_replace_editor.d.ts","sourceRoot":"","sources":["../../src/tools/str_replace_editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AA2B1D,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;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAwC1D;AAMD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,UAAU,CAAC,CAwIrB;AA+FD,eAAO,MAAM,eAAe,EAAE,IAAI,EAKjC,CAAC"}
|
|
@@ -7,6 +7,7 @@ exports.textEditorTools = exports.strReplaceEditorExecutor = exports.cleanupBack
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const zod_1 = require("zod");
|
|
10
|
+
const web_1 = require("../bin/utils/platform/web");
|
|
10
11
|
function createBackup(filePath) {
|
|
11
12
|
const backupPath = `${filePath}.bak`;
|
|
12
13
|
if (fs_1.default.existsSync(filePath)) {
|
|
@@ -79,7 +80,7 @@ function escapeRegExp(text) {
|
|
|
79
80
|
* Our implementation of Claude's built-in text editor tool
|
|
80
81
|
* https://docs.anthropic.com/en/docs/build-with-claude/tool-use/text-editor-tool
|
|
81
82
|
*/
|
|
82
|
-
async function strReplaceEditorExecutor(input
|
|
83
|
+
async function strReplaceEditorExecutor(input) {
|
|
83
84
|
const { path: filePath } = input;
|
|
84
85
|
try {
|
|
85
86
|
let content;
|
|
@@ -156,25 +157,19 @@ async function strReplaceEditorExecutor(input, typeChecker) {
|
|
|
156
157
|
}
|
|
157
158
|
newContent = content.replace(input.old_str, input.new_str);
|
|
158
159
|
fs_1.default.writeFileSync(filePath, newContent);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
};
|
|
172
|
-
}
|
|
160
|
+
const errors = (0, web_1.validateTypescript)(filePath);
|
|
161
|
+
if (errors.length > 0) {
|
|
162
|
+
return {
|
|
163
|
+
result: `Edits to file ${filePath} have been applied. However, type checks are failing with errors:\n${errors.join("\n")}`,
|
|
164
|
+
isError: true,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
return {
|
|
169
|
+
result: `Edits to file ${filePath} have been applied. Type checks have also passed.`,
|
|
170
|
+
isError: false,
|
|
171
|
+
};
|
|
173
172
|
}
|
|
174
|
-
return {
|
|
175
|
-
result: `Edits to file ${filePath} have been applied.`,
|
|
176
|
-
isError: false,
|
|
177
|
-
};
|
|
178
173
|
}
|
|
179
174
|
case "insert":
|
|
180
175
|
if (input.insert_line === undefined || !input.new_str) {
|
|
@@ -245,12 +240,12 @@ const fileCreateTool = {
|
|
|
245
240
|
file_text: zod_1.z.string().describe("The contents of the new file."),
|
|
246
241
|
}),
|
|
247
242
|
},
|
|
248
|
-
execute: async (input
|
|
243
|
+
execute: async (input) => {
|
|
249
244
|
return strReplaceEditorExecutor({
|
|
250
245
|
command: "create",
|
|
251
246
|
path: input.path,
|
|
252
247
|
file_text: input.file_text,
|
|
253
|
-
}
|
|
248
|
+
});
|
|
254
249
|
},
|
|
255
250
|
};
|
|
256
251
|
const stringReplaceTool = {
|
|
@@ -264,13 +259,13 @@ in the file. If old_str is not unique, the tool will return an error.`,
|
|
|
264
259
|
new_str: zod_1.z.string().describe("The string to replace old_str with."),
|
|
265
260
|
}),
|
|
266
261
|
},
|
|
267
|
-
execute: async (input
|
|
262
|
+
execute: async (input) => {
|
|
268
263
|
return strReplaceEditorExecutor({
|
|
269
264
|
command: "str_replace",
|
|
270
265
|
path: input.path,
|
|
271
266
|
old_str: input.old_str,
|
|
272
267
|
new_str: input.new_str,
|
|
273
|
-
}
|
|
268
|
+
});
|
|
274
269
|
},
|
|
275
270
|
};
|
|
276
271
|
const stringInsertTool = {
|
|
@@ -287,13 +282,13 @@ const stringInsertTool = {
|
|
|
287
282
|
new_str: zod_1.z.string().describe("The string to insert."),
|
|
288
283
|
}),
|
|
289
284
|
},
|
|
290
|
-
execute: async (input
|
|
285
|
+
execute: async (input) => {
|
|
291
286
|
return strReplaceEditorExecutor({
|
|
292
287
|
command: "insert",
|
|
293
288
|
path: input.path,
|
|
294
289
|
insert_line: input.insert_line,
|
|
295
290
|
new_str: input.new_str,
|
|
296
|
-
}
|
|
291
|
+
});
|
|
297
292
|
},
|
|
298
293
|
};
|
|
299
294
|
exports.textEditorTools = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/utils/index.ts"],"names":[],"mappings":"AAAA,wBAAsB,oBAAoB,CAAC,CAAC,EAAE,EAC5C,IAAI,EACJ,MAAc,EACd,IAAI,GACL,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ,GAAG,OAAO,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/utils/index.ts"],"names":[],"mappings":"AAAA,wBAAsB,oBAAoB,CAAC,CAAC,EAAE,EAC5C,IAAI,EACJ,MAAc,EACd,IAAI,GACL,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ,GAAG,OAAO,CAAC,CAAC,CAAC,CAuBb;AAED,wBAAsB,eAAe,CAAC,EACpC,MAAM,EACN,GAAG,EACH,IAAI,GACL,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ,oBAWA"}
|
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.callGitHubProxy = exports.makeDashboardRequest = void 0;
|
|
4
4
|
async function makeDashboardRequest({ path, method = "GET", body, }) {
|
|
5
|
+
const API_KEY = process.env.EMPIRICALRUN_API_KEY;
|
|
6
|
+
if (!API_KEY) {
|
|
7
|
+
throw new Error("EMPIRICALRUN_API_KEY is not found");
|
|
8
|
+
}
|
|
5
9
|
const requestHeaders = {
|
|
6
10
|
"Content-Type": "application/json",
|
|
7
|
-
Authorization: `Bearer ${
|
|
11
|
+
Authorization: `Bearer ${API_KEY}`,
|
|
8
12
|
"User-Agent": "empiricalrun/test-gen",
|
|
9
13
|
};
|
|
10
|
-
const baseUrl = "https://dash.empirical.run";
|
|
14
|
+
const baseUrl = process.env.DASHBOARD_DOMAIN || "https://dash.empirical.run";
|
|
11
15
|
const response = await fetch(`${baseUrl}${path}`, {
|
|
12
16
|
method,
|
|
13
17
|
headers: requestHeaders,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
"types": "./dist/agent/chat/state.d.ts",
|
|
19
19
|
"default": "./dist/agent/chat/state.js"
|
|
20
20
|
},
|
|
21
|
+
"./chat": {
|
|
22
|
+
"types": "./dist/agent/chat/exports.d.ts",
|
|
23
|
+
"default": "./dist/agent/chat/exports.js"
|
|
24
|
+
},
|
|
21
25
|
"./utils": {
|
|
22
26
|
"types": "./dist/utils/index.d.ts",
|
|
23
27
|
"default": "./dist/utils/index.js"
|
|
@@ -25,6 +29,10 @@
|
|
|
25
29
|
".": {
|
|
26
30
|
"types": "./dist/index.d.ts",
|
|
27
31
|
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./tool-call-service": {
|
|
34
|
+
"types": "./dist/tool-call-service/index.d.ts",
|
|
35
|
+
"default": "./dist/tool-call-service/index.js"
|
|
28
36
|
}
|
|
29
37
|
},
|
|
30
38
|
"repository": {
|
|
@@ -33,6 +41,7 @@
|
|
|
33
41
|
},
|
|
34
42
|
"author": "Empirical Team <hey@empirical.run>",
|
|
35
43
|
"dependencies": {
|
|
44
|
+
"@aws-sdk/client-sqs": "^3.787.0",
|
|
36
45
|
"@babel/parser": "^7.26.3",
|
|
37
46
|
"@types/sanitize-html": "^2.11.0",
|
|
38
47
|
"async-retry": "^1.3.3",
|
|
@@ -56,9 +65,9 @@
|
|
|
56
65
|
"tsx": "^4.16.2",
|
|
57
66
|
"typescript": "^5.3.3",
|
|
58
67
|
"zod": "^3.23.8",
|
|
59
|
-
"@empiricalrun/llm": "^0.
|
|
68
|
+
"@empiricalrun/llm": "^0.15.1",
|
|
60
69
|
"@empiricalrun/r2-uploader": "^0.3.8",
|
|
61
|
-
"@empiricalrun/test-run": "^0.8.
|
|
70
|
+
"@empiricalrun/test-run": "^0.8.1"
|
|
62
71
|
},
|
|
63
72
|
"devDependencies": {
|
|
64
73
|
"@playwright/test": "1.47.1",
|