@empiricalrun/test-gen 0.62.0 → 0.64.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/agent/browsing/run.d.ts.map +1 -1
  3. package/dist/agent/browsing/run.js +10 -5
  4. package/dist/agent/browsing/utils.d.ts +1 -1
  5. package/dist/agent/browsing/utils.d.ts.map +1 -1
  6. package/dist/agent/browsing/utils.js +5 -4
  7. package/dist/agent/chat/index.d.ts.map +1 -1
  8. package/dist/agent/chat/index.js +8 -2
  9. package/dist/agent/cua/computer.d.ts.map +1 -1
  10. package/dist/agent/cua/computer.js +40 -23
  11. package/dist/agent/cua/pw-codegen/element-from-point.d.ts +3 -1
  12. package/dist/agent/cua/pw-codegen/element-from-point.d.ts.map +1 -1
  13. package/dist/agent/cua/pw-codegen/element-from-point.js +19 -14
  14. package/dist/agent/cua/pw-codegen/types.d.ts +2 -1
  15. package/dist/agent/cua/pw-codegen/types.d.ts.map +1 -1
  16. package/dist/artifacts/index.d.ts +9 -0
  17. package/dist/artifacts/index.d.ts.map +1 -1
  18. package/dist/artifacts/index.js +28 -0
  19. package/dist/file/server.js +1 -1
  20. package/dist/tool-call-service/index.d.ts.map +1 -1
  21. package/dist/tool-call-service/index.js +24 -3
  22. package/dist/tools/commit-and-create-pr.d.ts.map +1 -1
  23. package/dist/tools/commit-and-create-pr.js +11 -4
  24. package/dist/tools/diagnosis-fetcher.d.ts.map +1 -1
  25. package/dist/tools/diagnosis-fetcher.js +4 -3
  26. package/dist/tools/download-build.d.ts.map +1 -1
  27. package/dist/tools/download-build.js +1 -1
  28. package/dist/tools/environment-crud.d.ts.map +1 -1
  29. package/dist/tools/environment-crud.js +6 -4
  30. package/dist/tools/grep/index.d.ts.map +1 -1
  31. package/dist/tools/grep/index.js +9 -9
  32. package/dist/tools/str_replace_editor.d.ts +4 -1
  33. package/dist/tools/str_replace_editor.d.ts.map +1 -1
  34. package/dist/tools/str_replace_editor.js +50 -35
  35. package/dist/tools/test-gen-browser.d.ts.map +1 -1
  36. package/dist/tools/test-gen-browser.js +20 -12
  37. package/dist/tools/test-run-fetcher/index.d.ts.map +1 -1
  38. package/dist/tools/test-run-fetcher/index.js +2 -1
  39. package/dist/tools/test-run.d.ts.map +1 -1
  40. package/dist/tools/test-run.js +3 -4
  41. package/dist/tools/utils/index.d.ts +4 -2
  42. package/dist/tools/utils/index.d.ts.map +1 -1
  43. package/dist/tools/utils/index.js +4 -7
  44. package/dist/utils/checkpoint.d.ts +5 -1
  45. package/dist/utils/checkpoint.d.ts.map +1 -1
  46. package/dist/utils/checkpoint.js +8 -3
  47. package/dist/utils/git.d.ts +12 -7
  48. package/dist/utils/git.d.ts.map +1 -1
  49. package/dist/utils/git.js +27 -17
  50. package/package.json +4 -4
  51. package/tsconfig.tsbuildinfo +1 -1
  52. package/dist/tools/codegen-agent.d.ts +0 -3
  53. package/dist/tools/codegen-agent.d.ts.map +0 -1
  54. package/dist/tools/codegen-agent.js +0 -40
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.64.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 1a5ec8d: feat: stateless tool execution and named args for tool execute fn
8
+
9
+ ### Patch Changes
10
+
11
+ - e5b9f7e: feat: consume repoPath in browser agent
12
+ - 43dc453: fix: record locators before execution for more reliable codegen
13
+ - 24d9415: fix: error message in browser agent tool call + removed unused code
14
+ - Updated dependencies [1a5ec8d]
15
+ - @empiricalrun/llm@0.17.2
16
+
17
+ ## 0.63.0
18
+
19
+ ### Minor Changes
20
+
21
+ - f926e40: feat: consume repoPath in test run tool
22
+ - 55c7913: feat: artifact collection is fire-and-forget at tool level
23
+ - 2f1ee31: chore: consume repoPath and apikey in tools requiring Dashboard api call
24
+
25
+ ### Patch Changes
26
+
27
+ - c491cdd: fix: insert_line description in text editor tools
28
+ - 0fea8f1: test: add a multiline old_str replacement test
29
+ - 115a023: chore: allow grep tool to consume repoPath for the scope of search
30
+ - 6c7740b: feat: consume repoPath for all file edit tools
31
+ - Updated dependencies [f926e40]
32
+ - Updated dependencies [2f1ee31]
33
+ - @empiricalrun/test-run@0.9.4
34
+ - @empiricalrun/llm@0.17.1
35
+
3
36
  ## 0.62.0
4
37
 
5
38
  ### Minor Changes
@@ -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;AAc3D,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;CACpC,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,GAC1B,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,CAmFD"}
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,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;CACpC,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,GAC1B,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,CA2FD"}
@@ -8,6 +8,7 @@ exports.generateTestsUsingMasterAgent = generateTestsUsingMasterAgent;
8
8
  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
+ const path_1 = __importDefault(require("path"));
11
12
  const web_1 = require("../../bin/utils/platform/web");
12
13
  const server_1 = require("../../file/server");
13
14
  const exec_1 = require("../../utils/exec");
@@ -18,8 +19,10 @@ async function convertProjectsFilterToProject({ pwProjectsFilter, repoDir, testF
18
19
  return project;
19
20
  }
20
21
  async function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, testFilePath, filePathToUpdate, projectName, testGenToken, repoDir, traceId, editFileWithGeneratedCode, }) {
21
- if (!fs_1.default.existsSync(testFilePath)) {
22
- throw new Error(`File for master agent to run not found: ${testFilePath}`);
22
+ const absTestFilePath = path_1.default.join(repoDir, testFilePath);
23
+ if (!fs_1.default.existsSync(absTestFilePath)) {
24
+ const errorMsg = `File for master agent to run not found: ${testFilePath}`;
25
+ throw new Error(errorMsg);
23
26
  }
24
27
  const pm = new exec_1.ProcessManager();
25
28
  const availablePort = await (0, detect_port_1.default)(3030);
@@ -32,7 +35,8 @@ async function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, tes
32
35
  });
33
36
  await fileServer.startFileService();
34
37
  fileServer.setFilePath(filePathToUpdate);
35
- const pageVar = await (0, web_1.getPageVariableNameFromCreateTest)(filePathToUpdate);
38
+ const absFilePathToUpdate = path_1.default.join(repoDir, filePathToUpdate);
39
+ const pageVar = await (0, web_1.getPageVariableNameFromCreateTest)(absFilePathToUpdate);
36
40
  const testsDir = "tests";
37
41
  const cmd = await (0, test_run_1.runSpecificTestsCmd)({
38
42
  tests: [
@@ -66,11 +70,12 @@ async function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, tes
66
70
  // Enable this for the page.pause approach in codegen
67
71
  PW_CODEGEN_NO_INSPECTOR: "1",
68
72
  },
73
+ cwd: repoDir,
69
74
  });
70
75
  }
71
76
  catch (e) {
72
77
  error = `Failed to generate test using master agent ${e}`;
73
- console.error(error);
78
+ console.error(`[generateTestsUsingMasterAgent] ${error}`);
74
79
  }
75
80
  if (error) {
76
81
  // Clean up the file if there is any error
@@ -81,7 +86,7 @@ async function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, tes
81
86
  await (0, web_1.lintErrors)(filePathToUpdate);
82
87
  }
83
88
  catch (e) {
84
- console.error("Failed to remove extra scripts from files post test gen error", e);
89
+ console.error(`[generateTestsUsingMasterAgent] Failed to remove extra scripts from files post test gen error:`, e);
85
90
  }
86
91
  }
87
92
  await fileServer.stop();
@@ -4,7 +4,7 @@ import { Page } from "playwright";
4
4
  import { PlaywrightTestConfig } from "playwright/test";
5
5
  export declare function isRegExp(obj: any): obj is RegExp;
6
6
  export declare function prepareBrowsingAgentTask(steps: string[]): string;
7
- export declare function replaceTodoWithCreateTest(testFilePath: string): Promise<void>;
7
+ export declare function replaceTodoWithCreateTest(testFilePath: string, repoDir: string): Promise<void>;
8
8
  export declare function markTestAsOnly({ testCaseName, testCaseSuites, specPath, }: {
9
9
  testCaseName: string;
10
10
  testCaseSuites: string[];
@@ -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;AAI3D,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAsBvD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAIvD;AAiFD,wBAAsB,yBAAyB,CAAC,YAAY,EAAE,MAAM,iBAsBnE;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,iBA8HxD;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC,CA2B/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"}
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;AAI3D,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAsBvD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAIvD;AAiFD,wBAAsB,yBAAyB,CAC7C,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,iBAwBhB;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,iBA8HxD;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC,CA2B/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"}
@@ -93,10 +93,11 @@ async function prepareFileForUpdateScenario({ testCase, specPath, trace, }) {
93
93
  });
94
94
  return createTestFilePath;
95
95
  }
96
- async function replaceTodoWithCreateTest(testFilePath) {
96
+ async function replaceTodoWithCreateTest(testFilePath, repoDir) {
97
97
  // This method is an alternative to prepareFileForUpdateScenario
98
98
  // TODO: Does not support scoped variables and updates in POM files
99
- const fileContent = fs_1.default.readFileSync(testFilePath, "utf-8");
99
+ const absoluteTestFilePath = path_1.default.join(repoDir, testFilePath);
100
+ const fileContent = fs_1.default.readFileSync(absoluteTestFilePath, "utf-8");
100
101
  const todoRegex = /\/\/ TODO\(agent(?:\s+on\s+(\w+))?\):\s*(.*)/;
101
102
  const todoMatch = fileContent.match(todoRegex);
102
103
  if (!todoMatch) {
@@ -104,8 +105,8 @@ async function replaceTodoWithCreateTest(testFilePath) {
104
105
  }
105
106
  const [, pageVarName] = todoMatch;
106
107
  const pageVariable = pageVarName || "page"; // Default to "page" if not specified
107
- fs_1.default.writeFileSync(testFilePath, fileContent.replace(todoRegex, (_, __, todoText) => `await createTest("${todoText.replace(/"/g, '\\"')}", ${pageVariable});`));
108
- await addImportForCreateTest(testFilePath);
108
+ fs_1.default.writeFileSync(absoluteTestFilePath, fileContent.replace(todoRegex, (_, __, todoText) => `await createTest("${todoText.replace(/"/g, '\\"')}", ${pageVariable});`));
109
+ await addImportForCreateTest(absoluteTestFilePath);
109
110
  }
110
111
  async function markTestAsOnly({ testCaseName, testCaseSuites, specPath, }) {
111
112
  const testFileContent = fs_1.default.readFileSync(specPath, "utf-8");
@@ -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,iBAmHA;AAuBD,wBAAsB,wBAAwB,CAAC,EAC7C,aAAa,EACb,aAAa,GACd,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB,iBAyDA"}
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"}
@@ -29,7 +29,7 @@ async function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialP
29
29
  // TODO: Store branch name in chat state so that we don't recreate it every time
30
30
  const randomId = crypto.randomUUID().substring(0, 8);
31
31
  const branchName = `branch-${randomId}`;
32
- await (0, git_1.checkoutBranch)(branchName);
32
+ await (0, git_1.checkoutBranch)(branchName, process.cwd());
33
33
  let messagesLoadedFromDisk = chatState?.messages || [];
34
34
  let chatModel = (0, chat_1.createChatModel)(messagesLoadedFromDisk, selectedModel);
35
35
  if (initialPromptContent && chatModel.messages.length === 0) {
@@ -100,6 +100,9 @@ async function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialP
100
100
  }
101
101
  else {
102
102
  // TODO: Should we pass a loader function? That would allow us to show a spinner
103
+ if (!process.env.EMPIRICALRUN_API_KEY) {
104
+ throw new Error("EMPIRICALRUN_API_KEY is not set");
105
+ }
103
106
  const toolCallService = new tool_call_service_1.ToolCallService({
104
107
  chatSessionId: null,
105
108
  selectedModel,
@@ -159,6 +162,9 @@ async function runChatAgentForDashboard({ chatSessionId, selectedModel, }) {
159
162
  chatSessionId,
160
163
  },
161
164
  });
165
+ if (!process.env.EMPIRICALRUN_API_KEY) {
166
+ throw new Error("EMPIRICALRUN_API_KEY is not set");
167
+ }
162
168
  const toolCallService = new tool_call_service_1.ToolCallService({
163
169
  chatSessionId,
164
170
  selectedModel,
@@ -167,7 +173,7 @@ async function runChatAgentForDashboard({ chatSessionId, selectedModel, }) {
167
173
  apiKey: process.env.EMPIRICALRUN_API_KEY,
168
174
  trace,
169
175
  });
170
- await (0, git_1.checkoutBranch)(branchName);
176
+ await (0, git_1.checkoutBranch)(branchName, process.cwd());
171
177
  let chatModel = (0, chat_1.createChatModel)(chatState.messages, selectedModel);
172
178
  let reporterFunc = async (chatState, latest) => {
173
179
  const response = await fetch(`${DASHBOARD_DOMAIN}/api/chat-sessions/${chatSessionId}`, {
@@ -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,mBAG7C;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,CAkJD"}
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,mBAG7C;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,CAmKD"}
@@ -40,14 +40,21 @@ async function executeModelAction(page, action, codegen) {
40
40
  let actionCode = "";
41
41
  let actionSummary = "";
42
42
  try {
43
+ // For every action, this method:
44
+ // 1. Record the action in codegen
45
+ // -> This allows codegen to find locators for the element
46
+ // before the action is executed - execution can be a destructive
47
+ // operation that modifies the DOM
48
+ // 2. Execute the action
49
+ // 3. Add to action summary
50
+ // 4. Add to action code
43
51
  switch (actionType) {
44
- // For every action, this method 1. executes the action,
45
- // 2. adds to action summary, and 3. adds to action code
46
52
  case "goto": {
47
53
  const { url } = action;
54
+ await codegen.recordAction({ type: "goto", url });
48
55
  await page.goto(url);
49
56
  actionSummary = `Navigated page to ${url}`;
50
- actionCode = await codegen.codeForAction({ type: "goto", url });
57
+ actionCode = await codegen.getCodeForLastAction();
51
58
  break;
52
59
  }
53
60
  case "click": {
@@ -61,20 +68,23 @@ async function executeModelAction(page, action, codegen) {
61
68
  pwButton = "middle";
62
69
  }
63
70
  if (pwButton) {
71
+ await codegen.recordAction({ type: "click", x, y });
64
72
  await page.mouse.click(x, y, { button: pwButton });
65
- actionCode = await codegen.codeForAction({ type: "click", x, y });
66
73
  actionSummary = `Click at (${x}, ${y}) with button '${button}'`;
74
+ actionCode = await codegen.getCodeForLastAction();
67
75
  }
68
76
  if (button === "back" || button === "forward") {
69
77
  if (button === "back") {
78
+ await codegen.recordAction({ type: "back" });
70
79
  await page.goBack();
71
- actionCode = await codegen.codeForAction({ type: "back" });
72
80
  actionSummary = `Navigated page back`;
81
+ actionCode = await codegen.getCodeForLastAction();
73
82
  }
74
83
  else if (button === "forward") {
84
+ await codegen.recordAction({ type: "forward" });
75
85
  await page.goForward();
76
- actionCode = await codegen.codeForAction({ type: "forward" });
77
86
  actionSummary = `Navigated page forward`;
87
+ actionCode = await codegen.getCodeForLastAction();
78
88
  }
79
89
  }
80
90
  break;
@@ -82,17 +92,28 @@ async function executeModelAction(page, action, codegen) {
82
92
  case "double_click": {
83
93
  const { x, y } = action;
84
94
  console.log(`Action: doubleclick at (${x}, ${y})`);
95
+ await codegen.recordAction({ type: "doubleclick", x, y });
85
96
  await page.mouse.dblclick(x, y, { button: "left" });
86
97
  actionSummary = `Double click at (${x}, ${y})`;
87
- actionCode = await codegen.codeForAction({ type: "doubleclick", x, y });
98
+ actionCode = await codegen.getCodeForLastAction();
99
+ break;
100
+ }
101
+ case "type": {
102
+ const { text } = action;
103
+ console.log(`Action: type text '${text}'`);
104
+ await codegen.recordAction({ type: "type", text });
105
+ await page.keyboard.type(text);
106
+ actionSummary = `Type text '${text}'`;
107
+ actionCode = await codegen.getCodeForLastAction();
88
108
  break;
89
109
  }
90
110
  case "move": {
91
111
  const { x, y } = action;
92
112
  console.log(`Action: mouse move to (${x}, ${y})`);
113
+ await codegen.recordAction({ type: "move", x, y });
93
114
  await page.mouse.move(x, y);
94
115
  actionSummary = `Mouse move to (${x}, ${y})`;
95
- actionCode = await codegen.codeForAction({ type: "move", x, y });
116
+ actionCode = await codegen.getCodeForLastAction();
96
117
  break;
97
118
  }
98
119
  case "drag": {
@@ -102,32 +123,35 @@ async function executeModelAction(page, action, codegen) {
102
123
  if (!path || path.length === 0) {
103
124
  break;
104
125
  }
126
+ await codegen.recordAction({ type: "drag", path });
105
127
  await page.mouse.move(path[0].x, path[0].y);
106
128
  await page.mouse.down();
107
129
  for (let i = 1; i < path.length; i++) {
108
130
  await page.mouse.move(path[i].x, path[i].y);
109
131
  }
110
132
  await page.mouse.up();
111
- actionCode = await codegen.codeForAction({ type: "drag", path });
133
+ actionCode = await codegen.getCodeForLastAction();
112
134
  break;
113
135
  }
114
136
  case "scroll": {
115
137
  const { x, y, scroll_x, scroll_y } = action;
116
138
  console.log(`Action: scroll at (${x}, ${y}) with offsets (scroll_x=${scroll_x}, scroll_y=${scroll_y})`);
117
- await page.mouse.move(x, y);
118
- await page.evaluate(`window.scrollBy(${scroll_x}, ${scroll_y})`);
119
- actionSummary = `Scroll at (${x}, ${y}) with offsets (scroll_x=${scroll_x}, scroll_y=${scroll_y})`;
120
- actionCode = await codegen.codeForAction({
139
+ await codegen.recordAction({
121
140
  type: "scroll",
122
141
  x,
123
142
  y,
124
143
  scroll_x,
125
144
  scroll_y,
126
145
  });
146
+ await page.mouse.move(x, y);
147
+ await page.evaluate(`window.scrollBy(${scroll_x}, ${scroll_y})`);
148
+ actionSummary = `Scroll at (${x}, ${y}) with offsets (scroll_x=${scroll_x}, scroll_y=${scroll_y})`;
149
+ actionCode = await codegen.getCodeForLastAction();
127
150
  break;
128
151
  }
129
152
  case "keypress": {
130
153
  const { keys } = action;
154
+ await codegen.recordAction({ type: "keypress", keys });
131
155
  const mappedKeys = keys.map((k) => {
132
156
  return CUA_KEY_TO_PLAYWRIGHT_KEY[k.toLowerCase()] || k;
133
157
  });
@@ -135,22 +159,15 @@ async function executeModelAction(page, action, codegen) {
135
159
  console.log(`Action: keypress for keys ${keys} -> '${mappedKey}'`);
136
160
  await page.keyboard.press(mappedKey);
137
161
  actionSummary = `Keypress for keys ${keys} (mapped to '${mappedKey}' for Playwright)`;
138
- actionCode = await codegen.codeForAction({ type: "keypress", keys });
139
- break;
140
- }
141
- case "type": {
142
- const { text } = action;
143
- console.log(`Action: type text '${text}'`);
144
- await page.keyboard.type(text);
145
- actionSummary = `Type text '${text}'`;
146
- actionCode = await codegen.codeForAction({ type: "type", text });
162
+ actionCode = await codegen.getCodeForLastAction();
147
163
  break;
148
164
  }
149
165
  case "wait": {
150
166
  console.log(`Action: wait`);
167
+ await codegen.recordAction({ type: "wait" });
151
168
  await page.waitForTimeout(2000);
152
169
  actionSummary = `Wait for 2 seconds`;
153
- actionCode = await codegen.codeForAction({ type: "wait" });
170
+ actionCode = await codegen.getCodeForLastAction();
154
171
  break;
155
172
  }
156
173
  case "screenshot": {
@@ -2,7 +2,9 @@ import type { Page } from "playwright";
2
2
  import { Action, BasePlaywrightCodegen } from "./types";
3
3
  export declare class ElementFromPointCodegen implements BasePlaywrightCodegen {
4
4
  private page;
5
+ private codeForLastAction;
5
6
  initialize(page: Page): Promise<void>;
6
- codeForAction(action: Action): Promise<string>;
7
+ recordAction(action: Action): Promise<void>;
8
+ getCodeForLastAction(): Promise<string>;
7
9
  }
8
10
  //# sourceMappingURL=element-from-point.d.ts.map
@@ -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;IACzB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CA0DrD"}
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"}
@@ -51,35 +51,38 @@ async function getLocatorForFill(page) {
51
51
  }
52
52
  class ElementFromPointCodegen {
53
53
  page;
54
+ codeForLastAction;
54
55
  async initialize(page) {
55
56
  this.page = page;
56
57
  await (0, utils_1.injectPwLocatorGenerator)(page);
57
58
  }
58
- async codeForAction(action) {
59
+ async recordAction(action) {
59
60
  try {
60
61
  if (action.type === "goto") {
61
- return `await page.goto("${action.url}");\n`;
62
+ this.codeForLastAction = `await page.goto("${action.url}");\n`;
62
63
  }
63
64
  if (action.type === "click") {
64
65
  const { x, y } = action;
65
66
  if (!this.page) {
66
67
  throw new Error("Page is not initialized");
67
68
  }
69
+ // TODO: Need execption handling
68
70
  const locator = await getLocatorForClick(this.page, { x, y });
69
- return `await page.${locator}.click();\n`;
71
+ this.codeForLastAction = `await page.${locator}.click();\n`;
70
72
  }
71
73
  if (action.type === "type") {
72
74
  if (!this.page) {
73
75
  throw new Error("Page is not initialized");
74
76
  }
77
+ // TODO: Need execption handling
75
78
  const locator = await getLocatorForFill(this.page);
76
- return `await page.${locator}.fill("${action.text}");\n`;
79
+ this.codeForLastAction = `await page.${locator}.fill("${action.text}");\n`;
77
80
  }
78
81
  if (action.type === "back") {
79
- return `await page.goBack();\n`;
82
+ this.codeForLastAction = `await page.goBack();\n`;
80
83
  }
81
84
  if (action.type === "forward") {
82
- return `await page.goForward();\n`;
85
+ this.codeForLastAction = `await page.goForward();\n`;
83
86
  }
84
87
  if (action.type === "doubleclick") {
85
88
  const { x, y } = action;
@@ -87,32 +90,34 @@ class ElementFromPointCodegen {
87
90
  throw new Error("Page is not initialized");
88
91
  }
89
92
  const locator = await getLocatorForClick(this.page, { x, y });
90
- return `await page.${locator}.dblclick();\n`;
93
+ this.codeForLastAction = `await page.${locator}.dblclick();\n`;
91
94
  }
92
95
  if (action.type === "move") {
93
96
  const { x, y } = action;
94
- return `await page.mouse.move(${x}, ${y});\n`;
97
+ this.codeForLastAction = `await page.mouse.move(${x}, ${y});\n`;
95
98
  }
96
99
  if (action.type === "drag") {
97
100
  // const { path } = action;
98
101
  // TODO: This needs to be fixed
99
- return `No code generated: drag action not supported by code generation`;
102
+ this.codeForLastAction = `No code generated: drag action not supported by code generation`;
100
103
  }
101
104
  if (action.type === "scroll") {
102
- return `No code to generate: will rely on Playwright's ability to auto-wait`;
105
+ this.codeForLastAction = `No code to generate: will rely on Playwright's ability to auto-wait`;
103
106
  }
104
107
  if (action.type === "keypress") {
105
108
  const { keys } = action;
106
- return `await page.keyboard.press("${keys.join("+")}");\n`;
109
+ this.codeForLastAction = `await page.keyboard.press("${keys.join("+")}");\n`;
107
110
  }
108
111
  if (action.type === "wait") {
109
- return `No code to generate: will rely on Playwright's ability to auto-wait`;
112
+ this.codeForLastAction = `No code to generate: will rely on Playwright's ability to auto-wait`;
110
113
  }
111
- throw new Error(`Unsupported action: ${JSON.stringify(action)}`);
112
114
  }
113
115
  catch (e) {
114
- return `Error generating code for action: ${e.message || e.toString()}`;
116
+ this.codeForLastAction = `Error generating code for action: ${e.message || e.toString()}`;
115
117
  }
116
118
  }
119
+ async getCodeForLastAction() {
120
+ return this.codeForLastAction || "No code generated for the last action";
121
+ }
117
122
  }
118
123
  exports.ElementFromPointCodegen = ElementFromPointCodegen;
@@ -41,6 +41,7 @@ export type Action = {
41
41
  };
42
42
  export interface BasePlaywrightCodegen {
43
43
  initialize(page: Page): Promise<void>;
44
- codeForAction(action: Action): Promise<string>;
44
+ recordAction(action: Action): Promise<void>;
45
+ getCodeForLastAction(): Promise<string>;
45
46
  }
46
47
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/agent/cua/pw-codegen/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,MAAM,MAAM,GACd;IACE,IAAI,EAAE,OAAO,CAAC;IACd,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,GACD;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,GACD;IACE,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,SAAS,CAAC;CACjB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAClC,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb,GACD;IACE,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEN,MAAM,WAAW,qBAAqB;IACpC,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAChD"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/agent/cua/pw-codegen/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,MAAM,MAAM,GACd;IAEE,IAAI,EAAE,OAAO,CAAC;IACd,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,GACD;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,GACD;IACE,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,SAAS,CAAC;CACjB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAClC,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb,GACD;IACE,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEN,MAAM,WAAW,qBAAqB;IACpC,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACzC"}
@@ -40,4 +40,13 @@ export declare function isArtifactCollectionEnabled(): string | undefined;
40
40
  * // Throws: "Invalid path: relative/path/test.png..."
41
41
  */
42
42
  export declare function collectArtifacts(inputs: ArtifactInput[], repoDir: string, toolCallId: string): Promise<Artifact[]>;
43
+ export declare class UploadArtifactsQueue {
44
+ private toolCallId;
45
+ private baseRepoPath;
46
+ private artifactResults;
47
+ private uploadPromise;
48
+ constructor(baseRepoPath: string, toolCallId: string);
49
+ addTask(artifacts: ArtifactInput[]): Promise<void>;
50
+ waitForCompletion(): Promise<Artifact[]>;
51
+ }
43
52
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/artifacts/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,QAAQ,EACR,aAAa,EAGd,MAAM,4BAA4B,CAAC;AAkBpC,wBAAgB,2BAA2B,uBAM1C;AA6HD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,aAAa,EAAE,EACvB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,QAAQ,EAAE,CAAC,CA6DrB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/artifacts/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,QAAQ,EACR,aAAa,EAGd,MAAM,4BAA4B,CAAC;AAkBpC,wBAAgB,2BAA2B,uBAM1C;AA6HD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,aAAa,EAAE,EACvB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,QAAQ,EAAE,CAAC,CA6DrB;AAED,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,aAAa,CAA8B;gBAEvC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAKvC,OAAO,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAelD,iBAAiB,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;CAMtD"}
@@ -3,6 +3,7 @@ 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.UploadArtifactsQueue = void 0;
6
7
  exports.isArtifactCollectionEnabled = isArtifactCollectionEnabled;
7
8
  exports.collectArtifacts = collectArtifacts;
8
9
  const r2_uploader_1 = require("@empiricalrun/r2-uploader");
@@ -207,3 +208,30 @@ async function collectArtifacts(inputs, repoDir, toolCallId) {
207
208
  return [];
208
209
  }
209
210
  }
211
+ class UploadArtifactsQueue {
212
+ toolCallId;
213
+ baseRepoPath;
214
+ artifactResults = [];
215
+ uploadPromise = null;
216
+ constructor(baseRepoPath, toolCallId) {
217
+ this.baseRepoPath = baseRepoPath;
218
+ this.toolCallId = toolCallId;
219
+ }
220
+ async addTask(artifacts) {
221
+ this.uploadPromise = collectArtifacts(artifacts, this.baseRepoPath, this.toolCallId)
222
+ .then((results) => {
223
+ this.artifactResults.push(...results);
224
+ })
225
+ .catch((error) => {
226
+ console.error("Error processing artifact upload task:", error);
227
+ throw error;
228
+ });
229
+ }
230
+ async waitForCompletion() {
231
+ if (this.uploadPromise) {
232
+ await this.uploadPromise;
233
+ }
234
+ return this.artifactResults;
235
+ }
236
+ }
237
+ exports.UploadArtifactsQueue = UploadArtifactsQueue;
@@ -31,7 +31,7 @@ class FileServiceServer {
31
31
  return this.artifactsInputs;
32
32
  }
33
33
  setFilePath(filePath) {
34
- this.filePath = filePath;
34
+ this.filePath = path_1.default.resolve(this.repoDir, filePath);
35
35
  }
36
36
  async startFileService() {
37
37
  const app = (0, express_1.default)();
@@ -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;AAiBhC,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,OAAO,CAAC,IAAI,CAAC;IAcxD,OAAO,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAmDnE"}
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,OAAO,CAAC,IAAI,CAAC;IAcxD,OAAO,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAsEnE"}
@@ -79,6 +79,13 @@ class ToolCallService {
79
79
  name: `tool: ${toolCall.name}`,
80
80
  input: toolCall.input,
81
81
  });
82
+ const uploadArtifactsQueue = new artifacts_1.UploadArtifactsQueue(this.repoPath, toolCall.id);
83
+ const collectArtifactsFn = (artifactsInput) => {
84
+ uploadArtifactsQueue.addTask(artifactsInput).catch((error) => {
85
+ console.error("Error collecting artifacts:", error);
86
+ });
87
+ return;
88
+ };
82
89
  const toolExecutor = this.toolExecutors[toolCall.name];
83
90
  if (!toolExecutor) {
84
91
  const errorResult = {
@@ -90,9 +97,19 @@ class ToolCallService {
90
97
  span?.end({ output: errorResult });
91
98
  continue;
92
99
  }
100
+ if (!this.apiKey) {
101
+ throw new Error("API key is required for tool execution");
102
+ }
93
103
  try {
94
- const result = await toolExecutor(toolCall.input, this.repoPath, this.apiKey, this.trace, artifacts_1.collectArtifacts);
95
- toolResults.push(result);
104
+ const result = await toolExecutor({
105
+ input: toolCall.input,
106
+ repoPath: this.repoPath,
107
+ apiKey: this.apiKey,
108
+ trace: this.trace,
109
+ collectArtifacts: collectArtifactsFn,
110
+ });
111
+ const artifacts = await uploadArtifactsQueue.waitForCompletion();
112
+ toolResults.push({ ...result, artifacts });
96
113
  span?.end({ output: result });
97
114
  }
98
115
  catch (error) {
@@ -105,7 +122,11 @@ class ToolCallService {
105
122
  span?.end({ output: errorResult });
106
123
  }
107
124
  }
108
- await (0, checkpoint_1.createCheckpoint)(toolCalls, this.branchName);
125
+ await (0, checkpoint_1.createCheckpoint)({
126
+ toolCalls,
127
+ branchName: this.branchName,
128
+ repoPath: this.repoPath,
129
+ });
109
130
  executeSpan?.end({ output: { toolResults } });
110
131
  return toolResults;
111
132
  }
@@ -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,IA2EnC,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,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"}