@empiricalrun/test-gen 0.64.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 +24 -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 +15 -7
- 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 +5 -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 +58 -46
- 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/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 +4 -1
- 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/diagnosis-fetcher.d.ts +1 -1
- package/dist/tools/diagnosis-fetcher.d.ts.map +1 -1
- package/dist/tools/download-build.d.ts +1 -1
- package/dist/tools/download-build.d.ts.map +1 -1
- package/dist/tools/environment-crud.d.ts +1 -1
- package/dist/tools/environment-crud.d.ts.map +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 +3 -2
- package/dist/tools/str_replace_editor.d.ts +1 -6
- package/dist/tools/str_replace_editor.d.ts.map +1 -1
- package/dist/tools/str_replace_editor.js +225 -225
- 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 +34 -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.d.ts +1 -1
- package/dist/tools/test-run.d.ts.map +1 -1
- package/dist/tools/test-run.js +34 -11
- 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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.64.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 387f475: chore: move more types to shared-types package
|
|
8
|
+
- 39f1aa8: fix: add exception handling to codegen
|
|
9
|
+
- 09a1126: [WIP] refactor: process manager to have strict options to avoid failure due…
|
|
10
|
+
- 1f74b60: fix: clarify how file create tool can create directories
|
|
11
|
+
- e5f8110: fix: ripgrep should work with ampersand in query
|
|
12
|
+
- b39d75c: feat: add build url to some tools, to run tests on preview urls
|
|
13
|
+
- 99d8490: fix: override page screenshot to fix cua on mobile emulation
|
|
14
|
+
- 226c361: fix: validate file existence in text edit tools, browser agent and run test tool and update fileName to filePath
|
|
15
|
+
- 41fc766: feat: collect artifacts after process end, add fallback for actionSummary
|
|
16
|
+
- d00c867: fix: add test for artifact extraction function and fix the bug
|
|
17
|
+
- d018e6b: chore: change default model to claude sonnet 4
|
|
18
|
+
- b908890: feat: added useToolExecutionOnEcs feature flag to use ecs for tool execution
|
|
19
|
+
- Updated dependencies [387f475]
|
|
20
|
+
- Updated dependencies [587532f]
|
|
21
|
+
- Updated dependencies [226c361]
|
|
22
|
+
- Updated dependencies [0ef2e11]
|
|
23
|
+
- Updated dependencies [8c7e9c6]
|
|
24
|
+
- @empiricalrun/llm@0.17.3
|
|
25
|
+
- @empiricalrun/test-run@0.10.0
|
|
26
|
+
|
|
3
27
|
## 0.64.0
|
|
4
28
|
|
|
5
29
|
### Minor Changes
|
|
@@ -9,13 +9,14 @@ type GenerateTestsType = {
|
|
|
9
9
|
repoDir: string;
|
|
10
10
|
traceId?: string;
|
|
11
11
|
editFileWithGeneratedCode: boolean;
|
|
12
|
+
envOverrides: Record<string, string>;
|
|
12
13
|
};
|
|
13
14
|
export declare function convertProjectsFilterToProject({ pwProjectsFilter, repoDir, testFilePath, }: {
|
|
14
15
|
pwProjectsFilter: string[];
|
|
15
16
|
repoDir: string;
|
|
16
17
|
testFilePath: string;
|
|
17
18
|
}): Promise<string>;
|
|
18
|
-
export declare function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, testFilePath, filePathToUpdate, projectName, testGenToken, repoDir, traceId, editFileWithGeneratedCode, }: GenerateTestsType): Promise<{
|
|
19
|
+
export declare function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, testFilePath, filePathToUpdate, projectName, testGenToken, repoDir, traceId, editFileWithGeneratedCode, envOverrides, }: GenerateTestsType): Promise<{
|
|
19
20
|
isError: boolean;
|
|
20
21
|
error: string;
|
|
21
22
|
actionsSummary?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAgB3D,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yBAAyB,EAAE,OAAO,CAAC;IACnC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,CAAC;AAEF,wBAAsB,8BAA8B,CAAC,EACnD,gBAAgB,EAChB,OAAO,EACP,YAAY,GACb,EAAE;IACD,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,MAAM,CAAC,CAQlB;AAED,wBAAsB,6BAA6B,CAAC,EAClD,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,OAAO,EACP,OAAO,EACP,yBAAyB,EACzB,YAAY,GACb,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;CAC7B,CAAC,CAqGD"}
|
|
@@ -9,16 +9,17 @@ const test_run_1 = require("@empiricalrun/test-run");
|
|
|
9
9
|
const detect_port_1 = __importDefault(require("detect-port"));
|
|
10
10
|
const fs_1 = __importDefault(require("fs"));
|
|
11
11
|
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const utils_1 = require("../../artifacts/utils");
|
|
12
13
|
const web_1 = require("../../bin/utils/platform/web");
|
|
13
14
|
const server_1 = require("../../file/server");
|
|
14
15
|
const exec_1 = require("../../utils/exec");
|
|
15
|
-
const
|
|
16
|
+
const utils_2 = require("./utils");
|
|
16
17
|
async function convertProjectsFilterToProject({ pwProjectsFilter, repoDir, testFilePath, }) {
|
|
17
|
-
const playwrightConfig = await (0,
|
|
18
|
-
const project = await (0,
|
|
18
|
+
const playwrightConfig = await (0, utils_2.readPlaywrightConfig)(repoDir);
|
|
19
|
+
const project = await (0, utils_2.detectProjectName)(testFilePath, playwrightConfig, pwProjectsFilter);
|
|
19
20
|
return project;
|
|
20
21
|
}
|
|
21
|
-
async function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, testFilePath, filePathToUpdate, projectName, testGenToken, repoDir, traceId, editFileWithGeneratedCode, }) {
|
|
22
|
+
async function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, testFilePath, filePathToUpdate, projectName, testGenToken, repoDir, traceId, editFileWithGeneratedCode, envOverrides, }) {
|
|
22
23
|
const absTestFilePath = path_1.default.join(repoDir, testFilePath);
|
|
23
24
|
if (!fs_1.default.existsSync(absTestFilePath)) {
|
|
24
25
|
const errorMsg = `File for master agent to run not found: ${testFilePath}`;
|
|
@@ -58,7 +59,8 @@ async function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, tes
|
|
|
58
59
|
const cmdLog = `${cmd.command} ${cmd.args.join(" ")}`;
|
|
59
60
|
console.log(`[generateTestsUsingMasterAgent] Running command: ${cmdLog}`);
|
|
60
61
|
await pm.execute(cmd.command, cmd.args, {
|
|
61
|
-
|
|
62
|
+
envOverrides: {
|
|
63
|
+
...envOverrides,
|
|
62
64
|
IPC_FILE_SERVICE_PORT: availablePort.toString(),
|
|
63
65
|
PW_TEST_HTML_REPORT_OPEN: "never",
|
|
64
66
|
TEST_GEN_TOKEN: testGenToken,
|
|
@@ -77,6 +79,7 @@ async function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, tes
|
|
|
77
79
|
error = `Failed to generate test using master agent ${e}`;
|
|
78
80
|
console.error(`[generateTestsUsingMasterAgent] ${error}`);
|
|
79
81
|
}
|
|
82
|
+
let artifacts = [];
|
|
80
83
|
if (error) {
|
|
81
84
|
// Clean up the file if there is any error
|
|
82
85
|
try {
|
|
@@ -89,11 +92,16 @@ async function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, tes
|
|
|
89
92
|
console.error(`[generateTestsUsingMasterAgent] Failed to remove extra scripts from files post test gen error:`, e);
|
|
90
93
|
}
|
|
91
94
|
}
|
|
95
|
+
artifacts = [...artifacts, ...(0, utils_1.findPlaywrightArtifacts)(repoDir)];
|
|
96
|
+
const serverArtifacts = fileServer.getArtifactInputsFromServer() || [];
|
|
97
|
+
artifacts = [...serverArtifacts, ...artifacts];
|
|
92
98
|
await fileServer.stop();
|
|
93
99
|
return {
|
|
94
100
|
isError: !!error,
|
|
95
101
|
error: error || "",
|
|
96
|
-
actionsSummary: fileServer.getActionsSummary()
|
|
97
|
-
|
|
102
|
+
actionsSummary: fileServer.getActionsSummary() ||
|
|
103
|
+
error ||
|
|
104
|
+
"Unknown error, there was no summary or error reported",
|
|
105
|
+
artifacts,
|
|
98
106
|
};
|
|
99
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/index.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAyChC,wBAAsB,kBAAkB,CAAC,EACvC,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,SAAS,GACV,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/index.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAyChC,wBAAsB,kBAAkB,CAAC,EACvC,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,SAAS,GACV,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,iBAuHA;AAuBD,wBAAsB,wBAAwB,CAAC,EAC7C,aAAa,EACb,aAAa,GACd,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB,iBA6DA"}
|
package/dist/agent/chat/index.js
CHANGED
|
@@ -110,6 +110,7 @@ async function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialP
|
|
|
110
110
|
repoPath: process.cwd(),
|
|
111
111
|
apiKey: process.env.EMPIRICALRUN_API_KEY,
|
|
112
112
|
trace,
|
|
113
|
+
featureFlags: [],
|
|
113
114
|
});
|
|
114
115
|
const fileInfo = await (0, file_tree_1.getFileInfoFromFS)(process.cwd());
|
|
115
116
|
await (0, agent_loop_1.chatAgentLoop)({
|
|
@@ -172,6 +173,7 @@ async function runChatAgentForDashboard({ chatSessionId, selectedModel, }) {
|
|
|
172
173
|
repoPath: process.cwd(),
|
|
173
174
|
apiKey: process.env.EMPIRICALRUN_API_KEY,
|
|
174
175
|
trace,
|
|
176
|
+
featureFlags: [],
|
|
175
177
|
});
|
|
176
178
|
await (0, git_1.checkoutBranch)(branchName, process.cwd());
|
|
177
179
|
let chatModel = (0, chat_1.createChatModel)(chatState.messages, selectedModel);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.modelLabels = exports.defaultModel = void 0;
|
|
4
4
|
const chat_1 = require("@empiricalrun/llm/chat");
|
|
5
|
-
const DEFAULT_CHAT_MODEL_ID = "
|
|
5
|
+
const DEFAULT_CHAT_MODEL_ID = "claude-sonnet-4-20250514";
|
|
6
6
|
function getDefaultChatModelId() {
|
|
7
7
|
if (!chat_1.SUPPORTED_CHAT_MODELS.some((m) => m.id === DEFAULT_CHAT_MODEL_ID)) {
|
|
8
8
|
throw new Error("Default chat model is not in SUPPORTED_CHAT_MODELS");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computer.d.ts","sourceRoot":"","sources":["../../../src/agent/cua/computer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACpF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,KAAK,oBAAoB,GACrB,wBAAwB,CAAC,KAAK,GAC9B,wBAAwB,CAAC,WAAW,GACpC,wBAAwB,CAAC,IAAI,GAC7B,wBAAwB,CAAC,QAAQ,GACjC,wBAAwB,CAAC,IAAI,GAC7B,wBAAwB,CAAC,UAAU,GACnC,wBAAwB,CAAC,MAAM,GAC/B,wBAAwB,CAAC,IAAI,GAC7B,wBAAwB,CAAC,IAAI,CAAC;AAElC,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"computer.d.ts","sourceRoot":"","sources":["../../../src/agent/cua/computer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACpF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,KAAK,oBAAoB,GACrB,wBAAwB,CAAC,KAAK,GAC9B,wBAAwB,CAAC,WAAW,GACpC,wBAAwB,CAAC,IAAI,GAC7B,wBAAwB,CAAC,QAAQ,GACjC,wBAAwB,CAAC,IAAI,GAC7B,wBAAwB,CAAC,UAAU,GACnC,wBAAwB,CAAC,MAAM,GAC/B,wBAAwB,CAAC,IAAI,GAC7B,wBAAwB,CAAC,IAAI,CAAC;AAElC,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,mBAO7C;AAgCD,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,oBAAoB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAC5D,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC;IACT,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC,CAoKD"}
|
|
@@ -3,7 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getScreenshot = getScreenshot;
|
|
4
4
|
exports.executeModelAction = executeModelAction;
|
|
5
5
|
async function getScreenshot(page) {
|
|
6
|
-
|
|
6
|
+
// We override the `scale` option to "css" to ensure the screenshot is
|
|
7
|
+
// consistent with the viewport size. Without this, the screenshot dimensions
|
|
8
|
+
// are viewport size * device pixel ratio (= 3 on iPhone device emulation).
|
|
9
|
+
// Docs: https://playwright.dev/docs/api/class-page#page-screenshot-option-scale
|
|
10
|
+
const screenshotBytes = await page.screenshot({ scale: "css" });
|
|
7
11
|
return Buffer.from(screenshotBytes).toString("base64");
|
|
8
12
|
}
|
|
9
13
|
const CUA_KEY_TO_PLAYWRIGHT_KEY = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element-from-point.d.ts","sourceRoot":"","sources":["../../../../src/agent/cua/pw-codegen/element-from-point.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"element-from-point.d.ts","sourceRoot":"","sources":["../../../../src/agent/cua/pw-codegen/element-from-point.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAwExD,qBAAa,uBAAwB,YAAW,qBAAqB;IACnE,OAAO,CAAC,IAAI,CAAmB;IAC/B,OAAO,CAAC,iBAAiB,CAAqB;IAExC,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA8D3C,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;CAG9C"}
|
|
@@ -3,51 +3,61 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ElementFromPointCodegen = void 0;
|
|
4
4
|
const utils_1 = require("../../browsing/utils");
|
|
5
5
|
async function getLocatorForClick(page, { x, y }) {
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
await (0, utils_1.injectPwLocatorGenerator)(page);
|
|
22
|
-
const relativeX = x - locator.x0;
|
|
23
|
-
const relativeY = y - locator.y0;
|
|
24
|
-
// TODO: Reuse locator.locator for the frameLocator.
|
|
25
|
-
let frameEl = locator.src
|
|
26
|
-
? page.locator(`[src="${locator.src}"]`)
|
|
27
|
-
: page.locator(`#${locator.id}`);
|
|
28
|
-
const frameLocator = locator.src
|
|
29
|
-
? `locator('[src="${locator.src}"]')`
|
|
30
|
-
: `locator('#${locator.id}')`;
|
|
31
|
-
const elementLocatorInsideFrame = await frameEl
|
|
32
|
-
.contentFrame()
|
|
33
|
-
.locator(":root")
|
|
34
|
-
.evaluate((rootElement, coords) => {
|
|
35
|
-
const xPos = coords[0];
|
|
36
|
-
const yPos = coords[1];
|
|
37
|
-
if (xPos === undefined || yPos === undefined) {
|
|
38
|
-
throw new Error("Coordinates are undefined in evaluate call");
|
|
6
|
+
try {
|
|
7
|
+
const locator = await page.evaluate(([x, y]) => {
|
|
8
|
+
const element = document.elementFromPoint(x, y);
|
|
9
|
+
const bbox = element?.getBoundingClientRect();
|
|
10
|
+
return {
|
|
11
|
+
locator: window.playwright.generateLocator(element),
|
|
12
|
+
isIframe: element?.tagName === "IFRAME",
|
|
13
|
+
x0: bbox?.x,
|
|
14
|
+
y0: bbox?.y,
|
|
15
|
+
src: element?.getAttribute("src"),
|
|
16
|
+
id: element?.getAttribute("id"),
|
|
17
|
+
};
|
|
18
|
+
}, [x, y]);
|
|
19
|
+
if (!locator.isIframe) {
|
|
20
|
+
return locator.locator;
|
|
39
21
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
22
|
+
await (0, utils_1.injectPwLocatorGenerator)(page);
|
|
23
|
+
const relativeX = x - locator.x0;
|
|
24
|
+
const relativeY = y - locator.y0;
|
|
25
|
+
// TODO: Reuse locator.locator for the frameLocator.
|
|
26
|
+
let frameEl = locator.src
|
|
27
|
+
? page.locator(`[src="${locator.src}"]`)
|
|
28
|
+
: page.locator(`#${locator.id}`);
|
|
29
|
+
const frameLocator = locator.src
|
|
30
|
+
? `locator('[src="${locator.src}"]')`
|
|
31
|
+
: `locator('#${locator.id}')`;
|
|
32
|
+
const elementLocatorInsideFrame = await frameEl
|
|
33
|
+
.contentFrame()
|
|
34
|
+
.locator(":root")
|
|
35
|
+
.evaluate((rootElement, coords) => {
|
|
36
|
+
const xPos = coords[0];
|
|
37
|
+
const yPos = coords[1];
|
|
38
|
+
if (xPos === undefined || yPos === undefined) {
|
|
39
|
+
throw new Error("Coordinates are undefined in evaluate call");
|
|
40
|
+
}
|
|
41
|
+
const element = document.elementFromPoint(xPos, yPos);
|
|
42
|
+
return window.playwright.generateLocator(element);
|
|
43
|
+
}, [relativeX, relativeY]);
|
|
44
|
+
return `${frameLocator}.contentFrame().${elementLocatorInsideFrame}`;
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
console.error(`Error generating locator for click: ${e.message || e.toString()}`);
|
|
48
|
+
}
|
|
44
49
|
}
|
|
45
50
|
async function getLocatorForFill(page) {
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
try {
|
|
52
|
+
const locator = await page.evaluate(() => {
|
|
53
|
+
const element = document.activeElement;
|
|
54
|
+
return window.playwright.generateLocator(element);
|
|
55
|
+
});
|
|
56
|
+
return locator;
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
console.error(`Error generating locator for fill: ${e.message || e.toString()}`);
|
|
60
|
+
}
|
|
51
61
|
}
|
|
52
62
|
class ElementFromPointCodegen {
|
|
53
63
|
page;
|
|
@@ -66,17 +76,19 @@ class ElementFromPointCodegen {
|
|
|
66
76
|
if (!this.page) {
|
|
67
77
|
throw new Error("Page is not initialized");
|
|
68
78
|
}
|
|
69
|
-
// TODO: Need execption handling
|
|
70
79
|
const locator = await getLocatorForClick(this.page, { x, y });
|
|
71
|
-
|
|
80
|
+
if (locator) {
|
|
81
|
+
this.codeForLastAction = `await page.${locator}.click();\n`;
|
|
82
|
+
}
|
|
72
83
|
}
|
|
73
84
|
if (action.type === "type") {
|
|
74
85
|
if (!this.page) {
|
|
75
86
|
throw new Error("Page is not initialized");
|
|
76
87
|
}
|
|
77
|
-
// TODO: Need execption handling
|
|
78
88
|
const locator = await getLocatorForFill(this.page);
|
|
79
|
-
|
|
89
|
+
if (locator) {
|
|
90
|
+
this.codeForLastAction = `await page.${locator}.fill("${action.text}");\n`;
|
|
91
|
+
}
|
|
80
92
|
}
|
|
81
93
|
if (action.type === "back") {
|
|
82
94
|
this.codeForLastAction = `await page.goBack();\n`;
|
|
@@ -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,CA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,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;CACpB,WAYA;AAED,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,MAAM,GACP,EAAE;IACD,QAAQ,EAAE,MAAM,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/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) {
|
|
@@ -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"}
|
|
@@ -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"}
|
|
@@ -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"}
|
|
@@ -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"}
|