@empiricalrun/test-gen 0.65.0 → 0.66.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 (50) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/agent/browsing/run.d.ts.map +1 -1
  3. package/dist/agent/browsing/run.js +1 -0
  4. package/dist/agent/chat/index.d.ts +1 -2
  5. package/dist/agent/chat/index.d.ts.map +1 -1
  6. package/dist/agent/chat/index.js +7 -4
  7. package/dist/agent/cua/computer.js +1 -1
  8. package/dist/agent/cua/index.d.ts.map +1 -1
  9. package/dist/agent/cua/index.js +10 -5
  10. package/dist/agent/cua/pw-codegen/pw-pause/index.d.ts +7 -5
  11. package/dist/agent/cua/pw-codegen/pw-pause/index.d.ts.map +1 -1
  12. package/dist/agent/cua/pw-codegen/pw-pause/index.js +57 -29
  13. package/dist/agent/cua/pw-codegen/pw-pause/ipc.d.ts +3 -0
  14. package/dist/agent/cua/pw-codegen/pw-pause/ipc.d.ts.map +1 -0
  15. package/dist/agent/cua/pw-codegen/pw-pause/ipc.js +13 -0
  16. package/dist/agent/cua/pw-codegen/pw-pause/{utils.d.ts → patch.d.ts} +4 -11
  17. package/dist/agent/cua/pw-codegen/pw-pause/patch.d.ts.map +1 -0
  18. package/dist/agent/cua/pw-codegen/pw-pause/{utils.js → patch.js} +49 -3
  19. package/dist/bin/index.js +1 -3
  20. package/dist/bin/utils/index.d.ts +0 -1
  21. package/dist/bin/utils/index.d.ts.map +1 -1
  22. package/dist/bin/utils/index.js +2 -0
  23. package/dist/tool-call-service/index.d.ts.map +1 -1
  24. package/dist/tool-call-service/index.js +2 -0
  25. package/dist/tool-call-service/utils.d.ts +1 -0
  26. package/dist/tool-call-service/utils.d.ts.map +1 -1
  27. package/dist/tool-call-service/utils.js +18 -11
  28. package/dist/tools/commit-and-create-pr.d.ts +0 -6
  29. package/dist/tools/commit-and-create-pr.d.ts.map +1 -1
  30. package/dist/tools/commit-and-create-pr.js +20 -40
  31. package/dist/tools/str_replace_editor.d.ts +3 -2
  32. package/dist/tools/str_replace_editor.d.ts.map +1 -1
  33. package/dist/tools/str_replace_editor.js +44 -7
  34. package/dist/tools/test-gen-browser.d.ts.map +1 -1
  35. package/dist/tools/test-gen-browser.js +8 -0
  36. package/dist/tools/upgrade-packages/index.d.ts +3 -0
  37. package/dist/tools/upgrade-packages/index.d.ts.map +1 -0
  38. package/dist/tools/upgrade-packages/index.js +124 -0
  39. package/dist/tools/upgrade-packages/utils.d.ts +13 -0
  40. package/dist/tools/upgrade-packages/utils.d.ts.map +1 -0
  41. package/dist/tools/upgrade-packages/utils.js +106 -0
  42. package/dist/tools/utils/index.d.ts +50 -2
  43. package/dist/tools/utils/index.d.ts.map +1 -1
  44. package/dist/tools/utils/index.js +87 -0
  45. package/dist/utils/git.d.ts +12 -1
  46. package/dist/utils/git.d.ts.map +1 -1
  47. package/dist/utils/git.js +66 -1
  48. package/package.json +4 -4
  49. package/tsconfig.tsbuildinfo +1 -1
  50. package/dist/agent/cua/pw-codegen/pw-pause/utils.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.66.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 576870a: feat: allow specifying package version in upgradePackages tool
8
+ - e94a2da: feat: update upgradePackages tool to include input schema for package selection
9
+ - dfb2007: feat: add upgradePackages tool
10
+
11
+ ### Patch Changes
12
+
13
+ - 33abadf: fix: text appendBranchNameToQueueUrl output is under 80 characters fixed
14
+ - 1300a80: fix: branch name with dot should deploy tool execute service
15
+ - 985d721: fix: git patch for new files
16
+ - 6a19421: feat: collect git patch artifacts from text editor tools
17
+ - 1a46013: feat: page.pause codegen works when tool execution is headed
18
+ - 805f35f: fix: handle error when fetching environment variables in chat agent
19
+ - 0a9ec78: feat: add o3 with reduced costs
20
+ - c430cc0: fix: use mouse wheel to execute scroll in cua
21
+ - Updated dependencies [9b873e3]
22
+ - Updated dependencies [41c266d]
23
+ - Updated dependencies [0a9ec78]
24
+ - Updated dependencies [8a83b29]
25
+ - @empiricalrun/test-run@0.10.2
26
+ - @empiricalrun/llm@0.18.1
27
+
3
28
  ## 0.65.0
4
29
 
5
30
  ### 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,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAclE,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAG5C,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,gBAAgB,CAAC,EACrC,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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,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,SAAS,EAAE,aAAa,EAAE,CAAC;CAC5B,CAAC,CAmGD"}
@@ -51,6 +51,7 @@ async function runBrowsingAgent({ testCaseName, testCaseSuites, testFilePath, fi
51
51
  projects: [projectName],
52
52
  passthroughArgs: "--retries 0 --timeout 0",
53
53
  repoDir,
54
+ envOverrides: envOverrides,
54
55
  // @ts-ignore
55
56
  platform: "web",
56
57
  });
@@ -1,9 +1,8 @@
1
1
  import { SupportedChatModels } from "@empiricalrun/shared-types";
2
- export declare function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialPromptContent, withRetry, }: {
2
+ export declare function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialPromptContent, }: {
3
3
  selectedModel: SupportedChatModels;
4
4
  useDiskForChatState: boolean;
5
5
  initialPromptContent: string | undefined;
6
- withRetry?: boolean;
7
6
  }): Promise<void>;
8
7
  export declare function runChatAgentForDashboard({ chatSessionId, selectedModel, }: {
9
8
  selectedModel: SupportedChatModels;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AA8DpC,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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AAkEpC,wBAAsB,kBAAkB,CAAC,EACvC,mBAAmB,EACnB,aAAa,EACb,oBAAoB,GACrB,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C,iBA4HA;AAuBD,wBAAsB,wBAAwB,CAAC,EAC7C,aAAa,EACb,aAAa,GACd,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB,iBA6DA"}
@@ -30,13 +30,17 @@ async function fetchEnvironmentVariables() {
30
30
  },
31
31
  });
32
32
  const data = await response.json();
33
+ if (!data.data) {
34
+ console.error("Failed to fetch environment variables:", data);
35
+ throw new Error("Failed to fetch environment variables");
36
+ }
33
37
  const envVars = data.data.environment_variables.reduce((acc, envVar) => {
34
38
  acc[envVar.name] = envVar.value;
35
39
  return acc;
36
40
  }, {});
37
41
  return envVars;
38
42
  }
39
- async function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialPromptContent, withRetry, }) {
43
+ async function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialPromptContent, }) {
40
44
  let chatState;
41
45
  if (useDiskForChatState) {
42
46
  chatState = (0, state_1.loadChatState)();
@@ -61,8 +65,8 @@ async function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialP
61
65
  console.log(`${(0, picocolors_1.blue)(latest.role)}: ${latest.textMessage}`);
62
66
  }
63
67
  }
64
- // if withRetry set the chatState error null
65
- if (withRetry && chatState) {
68
+ if (chatState && chatState.error) {
69
+ // Reset error state as we are attempting a retry
66
70
  chatState.error = null;
67
71
  }
68
72
  const handleSigInt = () => {
@@ -114,7 +118,6 @@ async function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialP
114
118
  }
115
119
  }
116
120
  else {
117
- // TODO: Should we pass a loader function? That would allow us to show a spinner
118
121
  if (!process.env.EMPIRICALRUN_API_KEY) {
119
122
  throw new Error("EMPIRICALRUN_API_KEY is not set");
120
123
  }
@@ -148,7 +148,7 @@ async function executeModelAction(page, action, codegen) {
148
148
  scroll_y,
149
149
  });
150
150
  await page.mouse.move(x, y);
151
- await page.evaluate(`window.scrollBy(${scroll_x}, ${scroll_y})`);
151
+ await page.mouse.wheel(scroll_x, scroll_y);
152
152
  actionSummary = `Scroll at (${x}, ${y}) with offsets (scroll_x=${scroll_x}, scroll_y=${scroll_y})`;
153
153
  actionCode = await codegen.getCodeForLastAction();
154
154
  break;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/cua/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAStE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAwBlC,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAClC;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,UAAU,EAAE,iBAAiB,CAAC;CAC/B,CACJ,CAAC;AAEF,wBAAsB,+BAA+B,CAAC,EACpD,IAAI,EACJ,IAAI,EACJ,KAAK,GACN,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,KAAK,EAAE,KAAK,CAAC;CACd,CAAC,CAuND"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/cua/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAStE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAgClC,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAClC;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,UAAU,EAAE,iBAAiB,CAAC;CAC/B,CACJ,CAAC;AAEF,wBAAsB,+BAA+B,CAAC,EACpD,IAAI,EACJ,IAAI,EACJ,KAAK,GACN,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,KAAK,EAAE,KAAK,CAAC;CACd,CAAC,CAuND"}
@@ -9,12 +9,17 @@ const openai_1 = __importDefault(require("openai"));
9
9
  const computer_1 = require("./computer");
10
10
  const model_1 = require("./model");
11
11
  const element_from_point_1 = require("./pw-codegen/element-from-point");
12
+ const pw_pause_1 = require("./pw-codegen/pw-pause");
12
13
  const MAX_ITERATIONS = 15;
13
- function getCodegen() {
14
+ async function getCodegenInstance() {
15
+ const repoDir = process.cwd();
16
+ const canUsePwPause = await (0, pw_pause_1.canUsePauseCodegen)(repoDir);
17
+ if (canUsePwPause) {
18
+ console.log("[getCodegen] using PlaywrightPauseCodegen");
19
+ return new pw_pause_1.PlaywrightPauseCodegen();
20
+ }
21
+ console.log("[getCodegen] using ElementFromPointCodegen");
14
22
  return new element_from_point_1.ElementFromPointCodegen();
15
- // TODO: Add support for page.pause approach
16
- // We can use PlaywrightPauseCodegen if playwright patch was successful,
17
- // IPC port is available and PW_CODEGEN_NO_INSPECTOR env var is set
18
23
  }
19
24
  function artifact(screenshot, name) {
20
25
  return {
@@ -24,7 +29,7 @@ function artifact(screenshot, name) {
24
29
  };
25
30
  }
26
31
  async function createTestUsingComputerUseAgent({ page, task, trace, }) {
27
- const codegen = getCodegen();
32
+ const codegen = await getCodegenInstance();
28
33
  await codegen.initialize(page);
29
34
  const screenshot = await (0, computer_1.getScreenshot)(page);
30
35
  const initialArtifact = artifact(screenshot, "Initial screen");
@@ -1,15 +1,17 @@
1
1
  import type { Page } from "playwright";
2
- export { revertToOriginalPwCode } from "./utils";
3
- export declare const PW_PAUSE_IPC_PORT = 3039;
4
- export declare function preparePlaywrightForCodegen(repoDir: string): Promise<void>;
5
- export declare class PlaywrightPauseCodegen {
2
+ import { BasePlaywrightCodegen } from "../types";
3
+ export { preparePlaywrightForCodegen, revertToOriginalPwCode } from "./patch";
4
+ export declare function canUsePauseCodegen(repoDir: string): Promise<boolean>;
5
+ export declare class PlaywrightPauseCodegen implements BasePlaywrightCodegen {
6
6
  private port;
7
7
  private page;
8
8
  private server;
9
+ private codeForLastAction;
9
10
  constructor();
11
+ private saveCode;
10
12
  initialize(page: Page): Promise<void>;
11
13
  startPlaywrightCodegen(page: Page): Promise<void>;
12
14
  recordAction(): Promise<void>;
13
- getCodegenResult(): Promise<string>;
15
+ getCodeForLastAction(): Promise<string>;
14
16
  }
15
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/agent/cua/pw-codegen/pw-pause/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AASvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD,eAAO,MAAM,iBAAiB,OAAO,CAAC;AAEtC,wBAAsB,2BAA2B,CAAC,OAAO,EAAE,MAAM,iBAoBhE;AAGD,qBAAa,sBAAsB;IACjC,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,IAAI,CAAmB;IAC/B,OAAO,CAAC,MAAM,CAA4C;;IAMpD,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBrC,sBAAsB,CAAC,IAAI,EAAE,IAAI;IAsBjC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;CAI1C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/agent/cua/pw-codegen/pw-pause/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAIjD,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAE9E,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,oBAqCvD;AAiBD,qBAAa,sBAAuB,YAAW,qBAAqB;IAClE,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,IAAI,CAAmB;IAC/B,OAAO,CAAC,MAAM,CAA4C;IAC1D,OAAO,CAAC,iBAAiB,CAAqB;;YAMhC,QAAQ;IAOhB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBrC,sBAAsB,CAAC,IAAI,EAAE,IAAI;IAsBjC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;CAU9C"}
@@ -3,45 +3,67 @@ 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.PlaywrightPauseCodegen = exports.PW_PAUSE_IPC_PORT = exports.revertToOriginalPwCode = void 0;
7
- exports.preparePlaywrightForCodegen = preparePlaywrightForCodegen;
6
+ exports.PlaywrightPauseCodegen = exports.revertToOriginalPwCode = exports.preparePlaywrightForCodegen = void 0;
7
+ exports.canUsePauseCodegen = canUsePauseCodegen;
8
8
  const express_1 = __importDefault(require("express"));
9
- const fs_1 = __importDefault(require("fs"));
10
- const path_1 = __importDefault(require("path"));
11
- const utils_1 = require("./utils");
12
- var utils_2 = require("./utils");
13
- Object.defineProperty(exports, "revertToOriginalPwCode", { enumerable: true, get: function () { return utils_2.revertToOriginalPwCode; } });
14
- exports.PW_PAUSE_IPC_PORT = 3039;
15
- async function preparePlaywrightForCodegen(repoDir) {
16
- const npmListOutput = await (0, utils_1.runNpmList)(repoDir);
17
- if (!npmListOutput) {
18
- return;
9
+ const ipc_1 = require("./ipc");
10
+ const patch_1 = require("./patch");
11
+ var patch_2 = require("./patch");
12
+ Object.defineProperty(exports, "preparePlaywrightForCodegen", { enumerable: true, get: function () { return patch_2.preparePlaywrightForCodegen; } });
13
+ Object.defineProperty(exports, "revertToOriginalPwCode", { enumerable: true, get: function () { return patch_2.revertToOriginalPwCode; } });
14
+ async function canUsePauseCodegen(repoDir) {
15
+ const hasPatchedPwCode = await (0, patch_1.hasPatchedRecorderApp)(repoDir);
16
+ if (!hasPatchedPwCode) {
17
+ // This codegen approach requires patching the playwright code to setup an
18
+ // IPC server <> client that passes generated code from Playwright to @empiricalrun/test-gen
19
+ console.log("Cannot use pause codegen because recorder app is not patched");
20
+ return false;
19
21
  }
20
- const playwrightCorePath = (0, utils_1.getPlaywrightCoreFromNpmList)(npmListOutput);
21
- const pathToRecorderApp = path_1.default.join(playwrightCorePath, "lib", "server", "recorder", "recorderApp.js");
22
- if (!fs_1.default.existsSync(pathToRecorderApp)) {
23
- const errMsg = `Cannot patch Playwright: ${pathToRecorderApp} does not exist`;
24
- throw new Error(errMsg);
22
+ if (!(await (0, ipc_1.isIPCPortAvailable)())) {
23
+ // The IPC port is hardcoded, and it should be available for IPC to work
24
+ console.log("Cannot use pause codegen because IPC port is not available");
25
+ return false;
25
26
  }
26
- await (0, utils_1.createFileBackup)(pathToRecorderApp);
27
- const port = exports.PW_PAUSE_IPC_PORT;
28
- await (0, utils_1.patchPwCode)(pathToRecorderApp, port);
27
+ const isRunningHeaded = process.env.RUN_PLAYWRIGHT_HEADED &&
28
+ process.env.RUN_PLAYWRIGHT_HEADED === "true";
29
+ if (!isRunningHeaded) {
30
+ // This codegen approach requires running Playwright in headed mode because
31
+ // it depends on the page.pause() API, which is no-op in headless mode
32
+ console.log("Cannot use pause codegen because RUN_PLAYWRIGHT_HEADED is not true");
33
+ return false;
34
+ }
35
+ // eslint-disable-next-line turbo/no-undeclared-env-vars
36
+ if (!process.env.PW_CODEGEN_NO_INSPECTOR) {
37
+ // PW_CODEGEN_NO_INSPECTOR should be set to true, so that Playwright runs the
38
+ // EmptyRecorderApp() -- which is the entrypoint to our patched code
39
+ // Ref: https://github.com/microsoft/playwright/blob/c96558d0691c0377dbc0c772a1bd8120d546e6d7/packages/playwright-core/src/server/recorder/recorderApp.ts#L98
40
+ console.log("Cannot use pause codegen because PW_CODEGEN_NO_INSPECTOR is not set");
41
+ return false;
42
+ }
43
+ // Need all conditions to be met to use pause codegen
44
+ return true;
29
45
  }
30
- // TODO: Fix this to implement BasePlaywrightCodegen
31
46
  class PlaywrightPauseCodegen {
32
47
  port = 0;
33
48
  page;
34
49
  server;
50
+ codeForLastAction;
35
51
  constructor() {
36
- this.port = exports.PW_PAUSE_IPC_PORT;
52
+ this.port = ipc_1.PW_PAUSE_IPC_PORT;
53
+ }
54
+ async saveCode(code) {
55
+ const generatedCode = code.map((c) => c.actions.join("\n")).join("\n");
56
+ if (generatedCode) {
57
+ this.codeForLastAction = generatedCode;
58
+ }
37
59
  }
38
60
  async initialize(page) {
39
61
  // Start server to receive generated code from patch
40
62
  const app = (0, express_1.default)();
41
63
  app.use(express_1.default.json());
42
- app.post("/test", async (req, res) => {
43
- console.log("--- Received request in PlaywrightPatchCodegen ---");
44
- console.log(req.body);
64
+ app.post("/sources", async (req, res) => {
65
+ const { payload } = req.body;
66
+ await this.saveCode(JSON.parse(payload));
45
67
  return res.send({ success: true });
46
68
  });
47
69
  await new Promise((resolve) => {
@@ -74,11 +96,17 @@ class PlaywrightPauseCodegen {
74
96
  await page.pause();
75
97
  }
76
98
  async recordAction() {
77
- console.log("Record action is no-op");
99
+ // Record action is no-op
78
100
  }
79
- async getCodegenResult() {
80
- console.log("Get codegen result is no-op");
81
- return "";
101
+ async getCodeForLastAction() {
102
+ // Wait for the server to send the code
103
+ await new Promise((resolve) => setTimeout(resolve, 1000));
104
+ let codeToReturn = this.codeForLastAction;
105
+ this.codeForLastAction = undefined;
106
+ if (!codeToReturn) {
107
+ throw new Error("No code for last action");
108
+ }
109
+ return codeToReturn;
82
110
  }
83
111
  }
84
112
  exports.PlaywrightPauseCodegen = PlaywrightPauseCodegen;
@@ -0,0 +1,3 @@
1
+ export declare const PW_PAUSE_IPC_PORT = 3039;
2
+ export declare function isIPCPortAvailable(): Promise<boolean>;
3
+ //# sourceMappingURL=ipc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ipc.d.ts","sourceRoot":"","sources":["../../../../../src/agent/cua/pw-codegen/pw-pause/ipc.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,OAAO,CAAC;AAEtC,wBAAsB,kBAAkB,qBAGvC"}
@@ -0,0 +1,13 @@
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.PW_PAUSE_IPC_PORT = void 0;
7
+ exports.isIPCPortAvailable = isIPCPortAvailable;
8
+ const detect_port_1 = __importDefault(require("detect-port"));
9
+ exports.PW_PAUSE_IPC_PORT = 3039;
10
+ async function isIPCPortAvailable() {
11
+ const portAvailable = await (0, detect_port_1.default)(exports.PW_PAUSE_IPC_PORT);
12
+ return portAvailable === exports.PW_PAUSE_IPC_PORT;
13
+ }
@@ -1,16 +1,9 @@
1
- /**
2
- * Helpful commands for debugging:
3
- *
4
- * 1. Find playwright-core path
5
- * cd `npm ls playwright-core --json --long | jq -r '.dependencies["@playwright/test"].dependencies.playwright.dependencies["playwright-core"].path'`
6
- *
7
- * 2. Find the path to the recorder app
8
- * cat lib/server/recorder/recorderApp.js
9
- *
10
- */
1
+ export declare function preparePlaywrightForCodegen(repoDir: string): Promise<void>;
2
+ export declare function getPathToRecorderApp(repoDir: string): Promise<string | undefined>;
11
3
  export declare function runNpmList(repoDir: string): Promise<string | undefined>;
12
4
  export declare function getPlaywrightCoreFromNpmList(output: string): any;
5
+ export declare function hasPatchedRecorderApp(repoDir: string): Promise<boolean>;
13
6
  export declare function revertToOriginalPwCode(repoDir: string): Promise<void>;
14
7
  export declare function createFileBackup(pathToFile: string): Promise<void>;
15
8
  export declare function patchPwCode(pathToRecorderApp: string, port: number): Promise<void>;
16
- //# sourceMappingURL=utils.d.ts.map
9
+ //# sourceMappingURL=patch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../../../../src/agent/cua/pw-codegen/pw-pause/patch.ts"],"names":[],"mappings":"AAmBA,wBAAsB,2BAA2B,CAAC,OAAO,EAAE,MAAM,iBAgBhE;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,MAAM,+BAczD;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,+BAiB/C;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,OAuB1D;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,MAAM,oBAY1D;AAED,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,MAAM,iBAoB3D;AAED,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,MAAM,iBAGxD;AAED,wBAAsB,WAAW,CAAC,iBAAiB,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAkBxE"}
@@ -3,14 +3,18 @@ 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.preparePlaywrightForCodegen = preparePlaywrightForCodegen;
7
+ exports.getPathToRecorderApp = getPathToRecorderApp;
6
8
  exports.runNpmList = runNpmList;
7
9
  exports.getPlaywrightCoreFromNpmList = getPlaywrightCoreFromNpmList;
10
+ exports.hasPatchedRecorderApp = hasPatchedRecorderApp;
8
11
  exports.revertToOriginalPwCode = revertToOriginalPwCode;
9
12
  exports.createFileBackup = createFileBackup;
10
13
  exports.patchPwCode = patchPwCode;
11
14
  const child_process_1 = require("child_process");
12
15
  const fs_1 = __importDefault(require("fs"));
13
16
  const path_1 = __importDefault(require("path"));
17
+ const ipc_1 = require("./ipc");
14
18
  /**
15
19
  * Helpful commands for debugging:
16
20
  *
@@ -21,6 +25,34 @@ const path_1 = __importDefault(require("path"));
21
25
  * cat lib/server/recorder/recorderApp.js
22
26
  *
23
27
  */
28
+ const CUSTOM_PATCH_COMMENT = `// Custom patch code set by @empiricalrun/test-gen`;
29
+ async function preparePlaywrightForCodegen(repoDir) {
30
+ try {
31
+ const pathToRecorderApp = await getPathToRecorderApp(repoDir);
32
+ if (!pathToRecorderApp) {
33
+ throw new Error("Cannot find path to recorder app");
34
+ }
35
+ if (!fs_1.default.existsSync(pathToRecorderApp)) {
36
+ const errMsg = `Cannot patch Playwright: ${pathToRecorderApp} does not exist`;
37
+ throw new Error(errMsg);
38
+ }
39
+ await createFileBackup(pathToRecorderApp);
40
+ await patchPwCode(pathToRecorderApp, ipc_1.PW_PAUSE_IPC_PORT);
41
+ }
42
+ catch (error) {
43
+ console.error("Error patching Playwright", error);
44
+ throw error;
45
+ }
46
+ }
47
+ async function getPathToRecorderApp(repoDir) {
48
+ const npmListOutput = await runNpmList(repoDir);
49
+ if (!npmListOutput) {
50
+ return;
51
+ }
52
+ const playwrightCorePath = getPlaywrightCoreFromNpmList(npmListOutput);
53
+ const pathToRecorderApp = path_1.default.join(playwrightCorePath, "lib", "server", "recorder", "recorderApp.js");
54
+ return pathToRecorderApp;
55
+ }
24
56
  async function runNpmList(repoDir) {
25
57
  try {
26
58
  const output = (0, child_process_1.execSync)("npm ls playwright-core --json --long --production=false", {
@@ -57,6 +89,20 @@ function getPlaywrightCoreFromNpmList(output) {
57
89
  }
58
90
  return playwrightCoreDep.path;
59
91
  }
92
+ async function hasPatchedRecorderApp(repoDir) {
93
+ try {
94
+ const pathToRecorderApp = await getPathToRecorderApp(repoDir);
95
+ if (!pathToRecorderApp) {
96
+ return false;
97
+ }
98
+ const recorderAppContents = fs_1.default.readFileSync(pathToRecorderApp, "utf-8");
99
+ return recorderAppContents.includes(CUSTOM_PATCH_COMMENT);
100
+ }
101
+ catch (error) {
102
+ console.error("Error checking if recorder app is patched", error);
103
+ return false;
104
+ }
105
+ }
60
106
  async function revertToOriginalPwCode(repoDir) {
61
107
  try {
62
108
  const npmListOutput = await runNpmList(repoDir);
@@ -80,11 +126,11 @@ async function createFileBackup(pathToFile) {
80
126
  async function patchPwCode(pathToRecorderApp, port) {
81
127
  const currentFileContents = fs_1.default.readFileSync(pathToRecorderApp, "utf-8");
82
128
  const original = `async setSources(sources) {}`;
83
- // TODO: Can we have a request payload and parse it in our code
84
129
  const replacement = `async setSources(sources) {
85
- const payload = JSON.stringify(sources.filter(source => source.isRecorded).filter(source => source.id === "javascript").map(source => source.actions));
130
+ ${CUSTOM_PATCH_COMMENT}
131
+ const payload = JSON.stringify(sources.filter(source => source.isRecorded).filter(source => source.id === "javascript"));
86
132
  const body = JSON.stringify({ payload });
87
- await fetch("http://localhost:${port}/test", {
133
+ await fetch("http://localhost:${port}/sources", {
88
134
  method: "POST",
89
135
  headers: {
90
136
  "Content-Type": "application/json",
package/dist/bin/index.js CHANGED
@@ -35,7 +35,7 @@ function setupProcessListeners(cleanup) {
35
35
  events.forEach((event) => process.removeListener(event, cleanup));
36
36
  };
37
37
  }
38
- async function runChatAgent({ modelInput, chatSessionId, useDiskForChatState, initialPromptPath, withRetry, }) {
38
+ async function runChatAgent({ modelInput, chatSessionId, useDiskForChatState, initialPromptPath, }) {
39
39
  if (modelInput && !utils_2.ARGS_TO_MODEL_MAP[modelInput]) {
40
40
  throw new Error(`Invalid chat model: ${modelInput}`);
41
41
  }
@@ -63,7 +63,6 @@ async function runChatAgent({ modelInput, chatSessionId, useDiskForChatState, in
63
63
  selectedModel: specifiedModel || defaultModel,
64
64
  useDiskForChatState: useDiskForChatState || false,
65
65
  initialPromptContent,
66
- withRetry,
67
66
  });
68
67
  }
69
68
  async function runAgentsWorkflow(testGenConfig, testGenToken) {
@@ -249,7 +248,6 @@ async function main() {
249
248
  modelInput: completedOptions.chatModel,
250
249
  useDiskForChatState: completedOptions.useDiskForChatState,
251
250
  initialPromptPath: completedOptions.initialPrompt,
252
- withRetry: completedOptions.withRetry,
253
251
  });
254
252
  return;
255
253
  }
@@ -11,7 +11,6 @@ export interface CLIOptions {
11
11
  initialPrompt?: string;
12
12
  chatSessionId?: string;
13
13
  chatModel?: (typeof ARGS_TO_MODEL_MAP)[keyof typeof ARGS_TO_MODEL_MAP];
14
- withRetry?: boolean;
15
14
  }
16
15
  export declare function validateAndCompleteCliOptions(options: CLIOptions): Promise<CLIOptions>;
17
16
  export declare function printBanner(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjE,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAajE,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,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_TO_MODEL_MAP = {
16
16
  "gemini-2.5": "gemini-2.5-pro-preview-06-05",
17
17
  "gemini-2.5-pro": "gemini-2.5-pro-preview-06-05",
18
18
  "gemini-2.5-pro-preview-03-25": "gemini-2.5-pro-preview-06-05",
19
+ o3: "o3-2025-04-16",
20
+ "o3-2025-04-16": "o3-2025-04-16",
19
21
  "o4-mini": "o4-mini-2025-04-16",
20
22
  "o4-mini-2025-04-16": "o4-mini-2025-04-16",
21
23
  };
@@ -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,UAAU,EACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,mBAAmB,EACnB,IAAI,EACJ,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAkBpC,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;IACvB,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAEjC,EACV,aAAa,EACb,aAAa,EACb,UAAU,EACV,QAAQ,EACR,MAAM,EACN,KAAK,EACL,YAAY,EACZ,oBAAyB,GAC1B,EAAE;QACD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;QAC7B,aAAa,EAAE,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AQ,EACR,MAAM,EACN,KAAK,EACL,YAAY,EACZ,oBAAyB,GAC1B,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;QACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC/C;IAoCK,WAAW,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBxD,OAAO,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAwEnE"}
@@ -12,6 +12,7 @@ const str_replace_editor_1 = require("../tools/str_replace_editor");
12
12
  const test_gen_browser_1 = require("../tools/test-gen-browser");
13
13
  const test_run_1 = require("../tools/test-run");
14
14
  const test_run_fetcher_1 = require("../tools/test-run-fetcher");
15
+ const upgrade_packages_1 = require("../tools/upgrade-packages");
15
16
  const checkpoint_1 = require("../utils/checkpoint");
16
17
  const utils_1 = require("./utils");
17
18
  class ToolCallService {
@@ -43,6 +44,7 @@ class ToolCallService {
43
44
  commit_and_create_pr_1.createPullRequestTool,
44
45
  list_environments_1.listEnvironmentsTool,
45
46
  download_build_1.downloadBuildTool,
47
+ upgrade_packages_1.upgradePackagesTool,
46
48
  ];
47
49
  if ((0, chat_1.getProviderForModel)(this.selectedModel) !== "claude") {
48
50
  this.tools.push(...str_replace_editor_1.textEditorTools);
@@ -1,4 +1,5 @@
1
1
  import { PendingToolCall, ServicePayload, Tool } from "@empiricalrun/shared-types";
2
+ export declare function appendBranchNameToQueueUrl(queueUrl: string, branchName: string): string;
2
3
  export declare function getQueueUrl(toolCalls: PendingToolCall[], tools: Tool[]): string;
3
4
  export declare function sendToolRequestToRemoteQueue(queueUrl: string, payload: ServicePayload): Promise<void>;
4
5
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/tool-call-service/utils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,cAAc,EACd,IAAI,EACL,MAAM,4BAA4B,CAAC;AAUpC,wBAAgB,WAAW,CACzB,SAAS,EAAE,eAAe,EAAE,EAC5B,KAAK,EAAE,IAAI,EAAE,GACZ,MAAM,CAwBR;AAED,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,cAAc,iBAiBxB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/tool-call-service/utils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,cAAc,EACd,IAAI,EACL,MAAM,4BAA4B,CAAC;AAEpC,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,MAAM,CAOR;AAYD,wBAAgB,WAAW,CACzB,SAAS,EAAE,eAAe,EAAE,EAC5B,KAAK,EAAE,IAAI,EAAE,GACZ,MAAM,CAeR;AAED,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,cAAc,iBAiBxB"}
@@ -1,14 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.appendBranchNameToQueueUrl = appendBranchNameToQueueUrl;
3
4
  exports.getQueueUrl = getQueueUrl;
4
5
  exports.sendToolRequestToRemoteQueue = sendToolRequestToRemoteQueue;
5
6
  const client_sqs_1 = require("@aws-sdk/client-sqs");
6
- function appendPrefixToQueueUrl(queueUrl, prefix) {
7
- if (!queueUrl || !prefix) {
8
- throw new Error("queueUrl and prefix must be set");
9
- }
7
+ function appendBranchNameToQueueUrl(queueUrl, branchName) {
8
+ const cleanBranchName = branchName.replace(/[/.]/g, "-");
9
+ const suffix = cleanBranchName.slice(0, 50);
10
10
  const parts = queueUrl.split("/");
11
- return `${parts.slice(0, -1).join("/")}/${prefix}-${parts.pop()}`;
11
+ const queueName = parts.pop();
12
+ const queueNameWithoutFifo = queueName?.replace(/\.fifo$/, "");
13
+ return `${parts.join("/")}/${queueNameWithoutFifo}-${suffix}.fifo`;
14
+ }
15
+ function buildQueueUrlsForPreview(baseQueueUrl) {
16
+ const branch = process.env.VERCEL_GIT_COMMIT_REF;
17
+ if (!branch) {
18
+ throw new Error("VERCEL_GIT_COMMIT_REF is not set");
19
+ }
20
+ const queueUrl = appendBranchNameToQueueUrl(baseQueueUrl, branch);
21
+ console.log("queueUrl for preview", queueUrl);
22
+ return queueUrl;
12
23
  }
13
24
  function getQueueUrl(toolCalls, tools) {
14
25
  const needsBrowser = toolCalls.some((toolCall) => tools.find((t) => t.schema.name === toolCall.name)?.needsBrowser);
@@ -18,13 +29,9 @@ function getQueueUrl(toolCalls, tools) {
18
29
  if (process.env.VERCEL_ENV !== "preview") {
19
30
  return baseQueueUrl;
20
31
  }
21
- const branch = process.env.VERCEL_GIT_COMMIT_REF;
22
- if (!branch) {
23
- throw new Error("VERCEL_GIT_COMMIT_REF is not set");
32
+ else {
33
+ return buildQueueUrlsForPreview(baseQueueUrl);
24
34
  }
25
- const queueUrl = appendPrefixToQueueUrl(baseQueueUrl, `gh-branch-${branch.replace(/\//g, "-")}`);
26
- console.log("queueUrl", queueUrl);
27
- return queueUrl;
28
35
  }
29
36
  async function sendToolRequestToRemoteQueue(queueUrl, payload) {
30
37
  const sqs = new client_sqs_1.SQSClient({
@@ -1,9 +1,3 @@
1
1
  import type { Tool } from "@empiricalrun/shared-types";
2
- interface GitHubRepoInfo {
3
- owner: string;
4
- repo: string;
5
- }
6
- export declare function parseGitHubUrl(url: string): GitHubRepoInfo;
7
2
  export declare const createPullRequestTool: Tool;
8
- export {};
9
3
  //# sourceMappingURL=commit-and-create-pr.d.ts.map
@@ -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,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;AAiCD,eAAO,MAAM,qBAAqB,EAAE,IAmFnC,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;AAoCpC,eAAO,MAAM,qBAAqB,EAAE,IAkFnC,CAAC"}