@empiricalrun/test-gen 0.64.0 → 0.64.2

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.
Files changed (58) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/agent/browsing/run.d.ts +2 -1
  3. package/dist/agent/browsing/run.d.ts.map +1 -1
  4. package/dist/agent/browsing/run.js +15 -7
  5. package/dist/agent/chat/index.d.ts.map +1 -1
  6. package/dist/agent/chat/index.js +3 -0
  7. package/dist/agent/chat/models.js +1 -1
  8. package/dist/agent/cua/computer.d.ts.map +1 -1
  9. package/dist/agent/cua/computer.js +5 -1
  10. package/dist/agent/cua/pw-codegen/element-from-point.d.ts.map +1 -1
  11. package/dist/agent/cua/pw-codegen/element-from-point.js +58 -46
  12. package/dist/artifacts/utils.d.ts +21 -0
  13. package/dist/artifacts/utils.d.ts.map +1 -0
  14. package/dist/artifacts/utils.js +102 -0
  15. package/dist/bin/index.js +2 -1
  16. package/dist/bin/utils/platform/web/index.d.ts.map +1 -1
  17. package/dist/bin/utils/platform/web/index.js +2 -0
  18. package/dist/test-build/index.js +1 -1
  19. package/dist/tool-call-service/index.d.ts +7 -2
  20. package/dist/tool-call-service/index.d.ts.map +1 -1
  21. package/dist/tool-call-service/index.js +11 -2
  22. package/dist/tool-call-service/utils.d.ts +2 -1
  23. package/dist/tool-call-service/utils.d.ts.map +1 -1
  24. package/dist/tool-call-service/utils.js +9 -5
  25. package/dist/tools/commit-and-create-pr.d.ts +1 -1
  26. package/dist/tools/commit-and-create-pr.d.ts.map +1 -1
  27. package/dist/tools/diagnosis-fetcher.d.ts +1 -1
  28. package/dist/tools/diagnosis-fetcher.d.ts.map +1 -1
  29. package/dist/tools/diagnosis-fetcher.js +3 -1
  30. package/dist/tools/download-build.d.ts +1 -1
  31. package/dist/tools/download-build.d.ts.map +1 -1
  32. package/dist/tools/download-build.js +3 -1
  33. package/dist/tools/environment-crud.d.ts +1 -1
  34. package/dist/tools/environment-crud.d.ts.map +1 -1
  35. package/dist/tools/grep/index.d.ts +1 -1
  36. package/dist/tools/grep/index.d.ts.map +1 -1
  37. package/dist/tools/grep/index.js +3 -2
  38. package/dist/tools/str_replace_editor.d.ts +1 -6
  39. package/dist/tools/str_replace_editor.d.ts.map +1 -1
  40. package/dist/tools/str_replace_editor.js +237 -229
  41. package/dist/tools/test-gen-browser.d.ts +1 -1
  42. package/dist/tools/test-gen-browser.d.ts.map +1 -1
  43. package/dist/tools/test-gen-browser.js +35 -21
  44. package/dist/tools/test-run-fetcher/index.d.ts +1 -1
  45. package/dist/tools/test-run-fetcher/index.d.ts.map +1 -1
  46. package/dist/tools/test-run.d.ts +1 -1
  47. package/dist/tools/test-run.d.ts.map +1 -1
  48. package/dist/tools/test-run.js +36 -12
  49. package/dist/tools/utils/index.d.ts +0 -13
  50. package/dist/tools/utils/index.d.ts.map +1 -1
  51. package/dist/tools/utils/index.js +0 -47
  52. package/dist/utils/exec.d.ts +4 -4
  53. package/dist/utils/exec.d.ts.map +1 -1
  54. package/dist/utils/exec.js +2 -4
  55. package/dist/utils/file-tree.d.ts.map +1 -1
  56. package/dist/utils/file-tree.js +2 -0
  57. package/package.json +4 -4
  58. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.64.2
4
+
5
+ ### Patch Changes
6
+
7
+ - f05aac2: feat: add environment overrides for projects in tool calls
8
+ - Updated dependencies [f05aac2]
9
+ - @empiricalrun/test-run@0.10.1
10
+ - @empiricalrun/llm@0.17.3
11
+
12
+ ## 0.64.1
13
+
14
+ ### Patch Changes
15
+
16
+ - 387f475: chore: move more types to shared-types package
17
+ - 39f1aa8: fix: add exception handling to codegen
18
+ - 09a1126: [WIP] refactor: process manager to have strict options to avoid failure due…
19
+ - 1f74b60: fix: clarify how file create tool can create directories
20
+ - e5f8110: fix: ripgrep should work with ampersand in query
21
+ - b39d75c: feat: add build url to some tools, to run tests on preview urls
22
+ - 99d8490: fix: override page screenshot to fix cua on mobile emulation
23
+ - 226c361: fix: validate file existence in text edit tools, browser agent and run test tool and update fileName to filePath
24
+ - 41fc766: feat: collect artifacts after process end, add fallback for actionSummary
25
+ - d00c867: fix: add test for artifact extraction function and fix the bug
26
+ - d018e6b: chore: change default model to claude sonnet 4
27
+ - b908890: feat: added useToolExecutionOnEcs feature flag to use ecs for tool execution
28
+ - Updated dependencies [387f475]
29
+ - Updated dependencies [587532f]
30
+ - Updated dependencies [226c361]
31
+ - Updated dependencies [0ef2e11]
32
+ - Updated dependencies [8c7e9c6]
33
+ - @empiricalrun/llm@0.17.3
34
+ - @empiricalrun/test-run@0.10.0
35
+
3
36
  ## 0.64.0
4
37
 
5
38
  ### 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;AAe3D,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,MAAM,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AM,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 utils_1 = require("./utils");
16
+ const utils_2 = require("./utils");
16
17
  async function convertProjectsFilterToProject({ pwProjectsFilter, repoDir, testFilePath, }) {
17
- const playwrightConfig = await (0, utils_1.readPlaywrightConfig)(repoDir);
18
- const project = await (0, utils_1.detectProjectName)(testFilePath, playwrightConfig, pwProjectsFilter);
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
- env: {
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
- artifacts: fileServer.getArtifactInputsFromServer(),
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,iBAsHA;AAuBD,wBAAsB,wBAAwB,CAAC,EAC7C,aAAa,EACb,aAAa,GACd,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB,iBA4DA"}
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,iBAwHA;AAuBD,wBAAsB,wBAAwB,CAAC,EAC7C,aAAa,EACb,aAAa,GACd,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB,iBA6DA"}
@@ -110,6 +110,8 @@ async function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialP
110
110
  repoPath: process.cwd(),
111
111
  apiKey: process.env.EMPIRICALRUN_API_KEY,
112
112
  trace,
113
+ featureFlags: [],
114
+ environmentOverrides: {},
113
115
  });
114
116
  const fileInfo = await (0, file_tree_1.getFileInfoFromFS)(process.cwd());
115
117
  await (0, agent_loop_1.chatAgentLoop)({
@@ -172,6 +174,7 @@ async function runChatAgentForDashboard({ chatSessionId, selectedModel, }) {
172
174
  repoPath: process.cwd(),
173
175
  apiKey: process.env.EMPIRICALRUN_API_KEY,
174
176
  trace,
177
+ featureFlags: [],
175
178
  });
176
179
  await (0, git_1.checkoutBranch)(branchName, process.cwd());
177
180
  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 = "gemini-2.5-pro-preview-03-25";
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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AAE,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
- const screenshotBytes = await page.screenshot();
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;AA4DxD,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;IA4D3C,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;CAG9C"}
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
- const locator = await page.evaluate(([x, y]) => {
7
- const element = document.elementFromPoint(x, y);
8
- const bbox = element?.getBoundingClientRect();
9
- return {
10
- locator: window.playwright.generateLocator(element),
11
- isIframe: element?.tagName === "IFRAME",
12
- x0: bbox?.x,
13
- y0: bbox?.y,
14
- src: element?.getAttribute("src"),
15
- id: element?.getAttribute("id"),
16
- };
17
- }, [x, y]);
18
- if (!locator.isIframe) {
19
- return locator.locator;
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
- const element = document.elementFromPoint(xPos, yPos);
41
- return window.playwright.generateLocator(element);
42
- }, [relativeX, relativeY]);
43
- return `${frameLocator}.contentFrame().${elementLocatorInsideFrame}`;
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
- const locator = await page.evaluate(() => {
47
- const element = document.activeElement;
48
- return window.playwright.generateLocator(element);
49
- });
50
- return locator;
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
- this.codeForLastAction = `await page.${locator}.click();\n`;
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
- this.codeForLastAction = `await page.${locator}.fill("${action.text}");\n`;
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.on(event, cleanup));
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,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG;IACF,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,QAAQ,EAAE,IAAI,GAAG,SAAS,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB,CA2CA;AAED,wBAAgB,YAAY,CAAC,EAC3B,QAA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AE,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({
@@ -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
- env: { ...Object(process.env), EMPIRICALRUN_API_KEY: apiKey },
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, Tool, ToolExecute, ToolResult } from "@empiricalrun/llm/chat";
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,17 @@ export declare class ToolCallService {
13
14
  repoPath: string;
14
15
  apiKey: string | undefined;
15
16
  trace?: TraceClient;
16
- constructor({ chatSessionId, selectedModel, branchName, repoPath, apiKey, trace, }: {
17
+ featureFlags: string[];
18
+ environmentOverrides: Record<string, string>;
19
+ constructor({ chatSessionId, selectedModel, branchName, repoPath, apiKey, trace, featureFlags, environmentOverrides, }: {
17
20
  chatSessionId: number | null;
18
21
  selectedModel: SupportedChatModels;
19
22
  branchName: string;
20
23
  repoPath: string;
21
24
  apiKey: string | undefined;
22
25
  trace?: TraceClient;
26
+ featureFlags: string[];
27
+ environmentOverrides?: Record<string, string>;
23
28
  });
24
29
  sendToQueue(toolCalls: PendingToolCall[]): Promise<void>;
25
30
  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,EACJ,WAAW,EACX,UAAU,EACX,MAAM,wBAAwB,CAAC;AAkBhC,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;gBACR,EACV,aAAa,EACb,aAAa,EACb,UAAU,EACV,QAAQ,EACR,MAAM,EACN,KAAK,GACN,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;KACrB;IAiCK,WAAW,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,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C;QACpB,YAAY,EAAE,MAAM,EAAE,CAAC;QACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC/C;IAmCK,WAAW,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBxD,OAAO,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAuEnE"}
@@ -23,13 +23,17 @@ class ToolCallService {
23
23
  repoPath;
24
24
  apiKey;
25
25
  trace;
26
- constructor({ chatSessionId, selectedModel, branchName, repoPath, apiKey, trace, }) {
26
+ featureFlags;
27
+ environmentOverrides;
28
+ constructor({ chatSessionId, selectedModel, branchName, repoPath, apiKey, trace, featureFlags, environmentOverrides = {}, }) {
27
29
  this.chatSessionId = chatSessionId;
28
30
  this.selectedModel = selectedModel;
29
31
  this.branchName = branchName;
30
32
  this.trace = trace;
31
33
  this.repoPath = repoPath;
32
34
  this.apiKey = apiKey;
35
+ this.featureFlags = featureFlags;
36
+ this.environmentOverrides = environmentOverrides;
33
37
  this.tools = [
34
38
  grep_1.grepTool,
35
39
  test_run_1.runTestTool,
@@ -60,7 +64,11 @@ class ToolCallService {
60
64
  if (!requestId) {
61
65
  throw new Error("Could not find an id for the tool call.");
62
66
  }
63
- await (0, utils_1.sendToolRequestToRemoteQueue)({
67
+ const queueUrl = (0, utils_1.getQueueUrl)(this.featureFlags);
68
+ if (!queueUrl) {
69
+ throw new Error(`queueUrl is required for remote execution.`);
70
+ }
71
+ await (0, utils_1.sendToolRequestToRemoteQueue)(queueUrl, {
64
72
  toolCalls,
65
73
  requestId,
66
74
  chatSessionId: this.chatSessionId,
@@ -107,6 +115,7 @@ class ToolCallService {
107
115
  apiKey: this.apiKey,
108
116
  trace: this.trace,
109
117
  collectArtifacts: collectArtifactsFn,
118
+ environmentOverrides: this.environmentOverrides,
110
119
  });
111
120
  const artifacts = await uploadArtifactsQueue.waitForCompletion();
112
121
  toolResults.push({ ...result, artifacts });
@@ -1,6 +1,7 @@
1
1
  import { SupportedChatModels } from "@empiricalrun/llm/chat";
2
2
  import { PendingToolCall } from "@empiricalrun/shared-types";
3
- export declare function sendToolRequestToRemoteQueue(payload: {
3
+ export declare function getQueueUrl(featureFlags: string[]): string | undefined;
4
+ export declare function sendToolRequestToRemoteQueue(queueUrl: string, payload: {
4
5
  toolCalls: PendingToolCall[];
5
6
  requestId: string;
6
7
  chatSessionId: number;
@@ -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;CACpB,iBAoBA"}
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,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,sBAMjD;AAED,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;IACP,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;CACpB,iBAiBF"}
@@ -1,8 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getQueueUrl = getQueueUrl;
3
4
  exports.sendToolRequestToRemoteQueue = sendToolRequestToRemoteQueue;
4
5
  const client_sqs_1 = require("@aws-sdk/client-sqs");
5
- async function sendToolRequestToRemoteQueue(payload) {
6
+ function getQueueUrl(featureFlags) {
7
+ const useToolExecutionOnEcs = featureFlags.includes("useToolExecutionOnEcs");
8
+ if (useToolExecutionOnEcs) {
9
+ return process.env.TOOL_EXECUTION_SQS_URL_ECS;
10
+ }
11
+ return process.env.TOOL_EXECUTION_SQS_URL;
12
+ }
13
+ async function sendToolRequestToRemoteQueue(queueUrl, payload) {
6
14
  const sqs = new client_sqs_1.SQSClient({
7
15
  region: process.env.AWS_REGION,
8
16
  credentials: {
@@ -10,10 +18,6 @@ async function sendToolRequestToRemoteQueue(payload) {
10
18
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
11
19
  },
12
20
  });
13
- const queueUrl = process.env.TOOL_EXECUTION_SQS_URL;
14
- if (!queueUrl) {
15
- throw new Error("TOOL_EXECUTION_SQS_URL is required for remote execution.");
16
- }
17
21
  await sqs.send(new client_sqs_1.SendMessageCommand({
18
22
  QueueUrl: queueUrl,
19
23
  MessageBody: JSON.stringify(payload),
@@ -1,4 +1,4 @@
1
- import type { Tool } from "@empiricalrun/llm/chat";
1
+ import type { Tool } from "@empiricalrun/shared-types";
2
2
  interface GitHubRepoInfo {
3
3
  owner: string;
4
4
  repo: string;
@@ -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,wBAAwB,CAAC;AAOnD,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
+ {"version":3,"file":"commit-and-create-pr.d.ts","sourceRoot":"","sources":["../../src/tools/commit-and-create-pr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,IAAI,EAEL,MAAM,4BAA4B,CAAC;AAOpC,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,IA6FnC,CAAC"}