@empiricalrun/test-gen 0.47.2 → 0.47.4

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 (78) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/actions/index.d.ts +1 -1
  3. package/dist/actions/index.js +1 -1
  4. package/dist/agent/browsing/index.d.ts.map +1 -1
  5. package/dist/agent/browsing/index.js +2 -3
  6. package/dist/agent/browsing/run.d.ts +4 -1
  7. package/dist/agent/browsing/run.d.ts.map +1 -1
  8. package/dist/agent/browsing/run.js +8 -3
  9. package/dist/agent/browsing/utils.d.ts +6 -13
  10. package/dist/agent/browsing/utils.d.ts.map +1 -1
  11. package/dist/agent/browsing/utils.js +9 -38
  12. package/dist/agent/chat.d.ts +7 -0
  13. package/dist/agent/chat.d.ts.map +1 -0
  14. package/dist/agent/chat.js +89 -0
  15. package/dist/agent/codegen/create-test-block.d.ts +2 -3
  16. package/dist/agent/codegen/create-test-block.d.ts.map +1 -1
  17. package/dist/agent/codegen/create-test-block.js +4 -9
  18. package/dist/agent/codegen/fix-ts-errors.d.ts +2 -3
  19. package/dist/agent/codegen/fix-ts-errors.d.ts.map +1 -1
  20. package/dist/agent/codegen/fix-ts-errors.js +4 -5
  21. package/dist/agent/codegen/generate-code-apply-changes.d.ts.map +1 -1
  22. package/dist/agent/codegen/generate-code-apply-changes.js +5 -6
  23. package/dist/agent/codegen/run.d.ts +6 -4
  24. package/dist/agent/codegen/run.d.ts.map +1 -1
  25. package/dist/agent/codegen/run.js +8 -6
  26. package/dist/agent/codegen/update-flow.d.ts +7 -5
  27. package/dist/agent/codegen/update-flow.d.ts.map +1 -1
  28. package/dist/agent/codegen/update-flow.js +9 -49
  29. package/dist/agent/codegen/utils.d.ts +2 -16
  30. package/dist/agent/codegen/utils.d.ts.map +1 -1
  31. package/dist/agent/codegen/utils.js +3 -41
  32. package/dist/agent/diagnosis-agent/index.d.ts +2 -9
  33. package/dist/agent/diagnosis-agent/index.d.ts.map +1 -1
  34. package/dist/agent/diagnosis-agent/index.js +1 -8
  35. package/dist/agent/enrich-prompt/index.d.ts.map +1 -1
  36. package/dist/agent/enrich-prompt/index.js +0 -1
  37. package/dist/agent/infer-agent/index.d.ts.map +1 -1
  38. package/dist/agent/infer-agent/index.js +0 -9
  39. package/dist/agent/master/browser-tests/index.spec.js +15 -1
  40. package/dist/agent/master/element-annotation.d.ts.map +1 -1
  41. package/dist/agent/master/element-annotation.js +1 -2
  42. package/dist/agent/master/execute-browser-action.d.ts.map +1 -1
  43. package/dist/agent/master/execute-browser-action.js +1 -2
  44. package/dist/agent/master/execute-skill-action.d.ts.map +1 -1
  45. package/dist/agent/master/execute-skill-action.js +1 -2
  46. package/dist/agent/master/next-action.d.ts.map +1 -1
  47. package/dist/agent/master/next-action.js +2 -3
  48. package/dist/agent/master/planner.d.ts.map +1 -1
  49. package/dist/agent/master/planner.js +1 -2
  50. package/dist/agent/master/run.d.ts.map +1 -1
  51. package/dist/agent/master/run.js +1 -2
  52. package/dist/agent/master/scroller.d.ts.map +1 -1
  53. package/dist/agent/master/scroller.js +2 -3
  54. package/dist/agent/planner/run-time-planner.d.ts.map +1 -1
  55. package/dist/agent/planner/run-time-planner.js +1 -2
  56. package/dist/bin/index.js +49 -34
  57. package/dist/bin/utils/index.d.ts +1 -0
  58. package/dist/bin/utils/index.d.ts.map +1 -1
  59. package/dist/bin/utils/index.js +9 -3
  60. package/dist/file/server.d.ts +2 -0
  61. package/dist/file/server.d.ts.map +1 -1
  62. package/dist/file/server.js +18 -1
  63. package/dist/tools/browser-agent.d.ts +16 -0
  64. package/dist/tools/browser-agent.d.ts.map +1 -0
  65. package/dist/tools/browser-agent.js +76 -0
  66. package/dist/tools/codegen-agent.d.ts +9 -0
  67. package/dist/tools/codegen-agent.d.ts.map +1 -0
  68. package/dist/tools/codegen-agent.js +44 -0
  69. package/dist/tools/test-run.d.ts +10 -0
  70. package/dist/tools/test-run.d.ts.map +1 -0
  71. package/dist/tools/test-run.js +35 -0
  72. package/dist/utils/git.d.ts +2 -0
  73. package/dist/utils/git.d.ts.map +1 -0
  74. package/dist/utils/git.js +11 -0
  75. package/package.json +3 -2
  76. package/dist/agent/utils.d.ts +0 -2
  77. package/dist/agent/utils.d.ts.map +0 -1
  78. package/dist/agent/utils.js +0 -12
@@ -15,19 +15,21 @@ export declare function getUpdateTestCodeCompletion({ testCase, testFileContent,
15
15
  agentResponse: string;
16
16
  fileChanges: CodeUpdate[];
17
17
  }>;
18
- export declare function updateTest(testCase: TestCase, file: string, options: TestGenConfigOptions | undefined, logging?: boolean, validate?: boolean, trace?: TraceClient): Promise<UpdatedTestCase[]>;
19
- export declare function getAppendCreateTestBlockCompletion({ testFiles, pageFiles, testCase, testFilePath, options, trace, }: {
18
+ export declare function updateTest({ testCase, file, trace, }: {
19
+ testCase: TestCase;
20
+ file: string;
21
+ trace?: TraceClient;
22
+ }): Promise<UpdatedTestCase[]>;
23
+ export declare function getAppendCreateTestBlockCompletion({ testFiles, pageFiles, testCase, testFilePath, trace, }: {
20
24
  trace?: TraceClient;
21
25
  pageFiles?: string;
22
26
  testFiles: string;
23
27
  testCase: TestCase;
24
- options?: TestGenConfigOptions;
25
28
  testFilePath: string;
26
29
  }): Promise<string>;
27
- export declare function appendCreateTestBlock({ testCase, file, options, trace, validateTypes, }: {
30
+ export declare function appendCreateTestBlock({ testCase, file, trace, validateTypes, }: {
28
31
  testCase: TestCase;
29
32
  file: string;
30
- options?: TestGenConfigOptions;
31
33
  trace?: TraceClient;
32
34
  validateTypes?: boolean;
33
35
  }): Promise<UpdatedTestCase[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"update-flow.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/update-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE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GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CA8E7B;AAED,wBAAsB,kCAAkC,CAAC,EACvD,SAAS,EACT,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,KAAK,GACN,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,QAAQ,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB,mBAkFA;AAED,wBAAsB,qBAAqB,CAAC,EAC1C,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,aAAoB,GACrB,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CA8C7B"}
@@ -5,16 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.appendCreateTestBlock = exports.getAppendCreateTestBlockCompletion = exports.updateTest = exports.getUpdateTestCodeCompletion = void 0;
7
7
  const llm_1 = require("@empiricalrun/llm");
8
- const crypto_1 = __importDefault(require("crypto"));
9
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
10
9
  const logger_1 = require("../../bin/logger");
11
10
  const context_1 = require("../../bin/utils/context");
12
11
  const fs_1 = require("../../bin/utils/fs");
13
12
  const web_1 = require("../../bin/utils/platform/web");
14
13
  const constants_1 = require("../../constants");
15
- const promptTemplate_0 = "{{#section \"system\"}}\n\nYou are a software test engineer who is given a task to update a test case. You will be provided with steps of a test\ncase scenario and you are given a snippet with interface await createTest(task, playwright_page_instance).\n\nYou need to analyze the request and place createTest snippet at the correct position and pass on the steps to this\n`createTest` method with the correct page instance.\n\nYou will be provided with current tests, fixtures and page object models for you to use and update code as per the\ntask provided to you.\nYou need to respond with file path and updated code block inside the file.\n\nHere is the list of current tests and fixtures:\n\n{{testFiles}}\n\n\nHere is the list of current page object models:\n\n{{pageFiles}}\n{{/section}}\n\n\n{{#section \"user\"}}\nFollowing is the test scenario for which you need to update the test:\ntest name:\n{{scenarioName}}\n\n\nTask:\n{{scenarioSteps}}\n\n\nFollow these steps to complete the task:\n\n1. Determine the task's intent:\n- The default intent is **\"add steps\"**.\n- If the task explicitly mentions (using words like \"replace\", \"remove\", \"delete\") that existing test steps should\nbe replaced or deleted, the intent is **\"update steps\"**. Identify the specific steps to be replaced or removed.\n- Note:\n- Do not assume that providing new or different steps implies an intent to update or replace existing steps. Unless\nthe task explicitly instructs to replace or remove existing code, interpret the intent as adding new steps to the\nexisting test.\n\n2. Identify the test block that requires updating.\n\n3. Place the `createTest` snippet:\n- Insert the `createTest` snippet at the location determined by the task, and pass the Playwright page instance.\n- If the intent is \"add\", do not alter the existing test code; simply append the `createTest` snippet based on any\nprovided location hints.\n- If the task includes location hints that don't match steps within the test, check dependent methods called from\nthe test for the update.\n- If no location hint is provided, place the `createTest` snippet at the end of the test block.\n- Even if the task includes steps that overlap with or are similar to existing steps, do not modify the existing\ncode. Unless the task explicitly instructs to replace or remove existing code, interpret the intent as adding new\nsteps to the existing test.\n\n4. Strip location hints from the task:\n- Remove any location hints (e.g., \"replace the current assertion and\") before passing the task to the `createTest`\nmethod.\n\nSubmission Guidelines:\n\n- Focus only on the provided test case and any related page object model methods used in the test.\n- Do not modify or add code within the `createTest` snippet.\n- Do not update or modify any other code apart from adding `createTest` code snippet.\n- Since the response will be used for search-and-replace operations, always provide the immediate parent AST node\nfor any code updates.\n- Include the full test block if any part of it is updated, preserving all unchanged code.\n- Do not use markdown syntax or backticks.\n- Respond using the following XML format:\n<reason_for_intent></reason_for_intent>\n<intent></intent>\n<location_of_update></location_of_update>\n<file_path></file_path>\n<old_code_block></old_code_block>\n<new_code_block></new_code_block>\n<change></change>\n\n- Each `<old_code_block>` and `<new_code_block>` should contain only one test block or page object model method\n definition. Provide separate blocks for multiple updates.\n - The `<change></change>` tag should also mention the file path being updated.\n - There should be only one `createTest` block in the `new_code_block`. The `createTest` method should be passed\n with entire task. Do not split the task while forwarding it to `createTest`.\n - `<new_code_block>` code snippet should be syntactically correct.\n - The code_block should not contain any import statements.\n {{/section}}";
14
+ const promptTemplate_0 = "{{#section \"system\"}}\n\nYou are a software test engineer who is given a task to update a test case. You will be provided with steps of a test\ncase scenario and you are given a snippet with interface await createTest(task, playwright_page_instance).\n\nYou need to analyze the request and place createTest snippet at the correct position and pass on the steps to this\n`createTest` method with the correct page instance.\n\nYou will be provided with current tests, fixtures and page object models for you to use and update code as per the\ntask provided to you.\nYou need to respond with file path and updated code block inside the file.\n\nHere is the list of current tests and fixtures:\n\n{{testFiles}}\n\n\nHere is the list of current page object models:\n\n{{pageFiles}}\n{{/section}}\n\n\n{{#section \"user\"}}\nFollowing is the test scenario for which you need to update the test:\n\ntest name:\n{{scenarioName}}\n\nTask:\n{{scenarioSteps}}\n\nFollow these steps to complete the task:\n\n1. Determine the task's intent:\n- The default intent is **\"add steps\"**.\n- If the task explicitly mentions (using words like \"replace\", \"remove\", \"delete\") that existing test steps should\nbe replaced or deleted, the intent is **\"update steps\"**. Identify the specific steps to be replaced or removed.\n- Do not assume that providing new or different steps implies an intent to update or replace existing steps. Unless\nthe task explicitly instructs to replace or remove existing code, interpret the intent as adding new steps to the\nexisting test.\n\n2. Identify the test block that requires updating.\n\n3. Place the `createTest` snippet:\n- Insert the `createTest` snippet at the location determined by the task, and pass the Playwright page instance.\n- If the intent is \"add\", do not alter the existing test code; simply append the `createTest` snippet based on any\nprovided location hints.\n- If the task includes location hints that don't match steps within the test, check dependent methods called from\nthe test for the update.\n- If no location hint is provided, place the `createTest` snippet at the end of the test block.\n- Even if the task includes steps that overlap with or are similar to existing steps, do not modify the existing\ncode. Unless the task explicitly instructs to replace or remove existing code, interpret the intent as adding new\nsteps to the existing test.\n\n4. Strip location hints from the task:\n- Remove any location hints (e.g., \"replace the current assertion and\") before passing the task to the `createTest`\nmethod.\n- The task passed into `createTest` should not contain any location hints. It should only contain actions that\nare required to be performed.\n- For example, if the original task: \"replace the current assertion and add a new assertion\" should be transformed to\n\"add a new assertion\" before passing it to the `createTest` method. This is the \"task_without_location_hints\"\n\nSubmission Guidelines:\n\n- Focus only on the provided test case and any related page object model methods used in the test.\n- Do not modify or add code within the `createTest` snippet.\n- Do not update or modify any other code apart from adding `createTest` code snippet.\n- Since the response will be used for search-and-replace operations, always provide the immediate parent AST node\nfor any code updates.\n- Include the full test block if any part of it is updated, preserving all unchanged code.\n- Do not use markdown syntax or backticks.\n- Respond using the following XML format:\n<reason_for_intent></reason_for_intent>\n<intent></intent>\n<location_of_update></location_of_update>\n<task_without_location_hints></task_without_location_hints>\n<file_path></file_path>\n<old_code_block></old_code_block>\n<new_code_block></new_code_block>\n<change></change>\n\n- Each `<old_code_block>` and `<new_code_block>` should contain only one test block or page object model method\n definition. Provide separate blocks for multiple updates.\n- The `<change></change>` tag should also mention the file path being updated.\n- There should be only one `createTest` block in the `new_code_block`. The `createTest` method should be passed\nwith entire task. Do not split the task while forwarding it to `createTest`.\n- `<new_code_block>` code snippet should be syntactically correct.\n - The code_block should not contain any import statements.\n{{/section}}";
16
15
  const promptTemplate_1 = "{{#section \"system\"}}\nYou are a software test engineer who is given an objective to update test basis the task provided.\nYou will be provided with a test name, test and test file path.\n\nYou will be provided with current tests, fixtures and page object models for you to use and update code as per the task\nprovided to you. You need to respond with file path and updated code block inside the file.\n\nBefore responding you need to ensure that the code change is minimal and the change is reusable across tests. You need\nto ensure the code follows DRY principle.\n\nHere is the list of current tests and fixtures:\n\n{{testFiles}}\n\n\nHere is the list of current page object models:\n\n{{pageFiles}}\n\n{{/section}}\n\n{{#section \"user\"}}\nFollowing are the test details and the task to complete your objective:\nTest name:\n{{scenarioName}}\n\nTest case:\n{{currentScenarioCodeBlock}}\n\nTask:\n{{scenarioSteps}}\n\nIn order to execute the task:\n- Think step by step and first identify current test block which needs update and the methods which the current test\nblock depend on.\n- The task will demand changes in the current test case or the methods it depend on. Based on the task, identify list of\nfile paths which need change, the reason for change and the code change they need.\n- Next make changes to code blocks in each file paths.\n\n------\n\nFollow these instructions before responding with output:\n- Read the code line by line and ensure that achieve the task provided to you\n- Read the dependencies of the code block by scanning through file paths and file provided to you. refer the same file\npath while responding with output.\n- Focus only on the test case provided and associated JS methods called from the test case.\n- Since the response will be used to search and replace blocks, always respond with output which includes the full\nlexical scope surrounding the modified code.\n- If there are any updates inside test code block, ensure responding with full test block with unchanged code as well\n- Each code block should contain edits to only one code block in file path\n- DO NOT respond with any backticks or markdown syntax\n- Respond only with file path where the code block to be updated is present, old code block, new code block and a one\nliner reason for the change\n- Respond with <file_path></file_path>, <old_code_block></old_code_block>, <new_code_block></new_code_block> and\n<change></change> as xml tags\n- The reason for change should adhere to coding principles provided and review if the updated code is present in the\nfile path mentioned\n- The code change should belong to the right file path\n- The response must start with <file_path>\n {{/section}}";
17
- const session_1 = require("../../session");
18
16
  const test_update_feedback_1 = require("./test-update-feedback");
19
17
  const utils_1 = require("./utils");
20
18
  async function getUpdateTestCodeCompletion({ testCase, testFileContent, testFiles, pageFiles, testFilePath, options, trace, }) {
@@ -65,31 +63,18 @@ async function getUpdateTestCodeCompletion({ testCase, testFileContent, testFile
65
63
  };
66
64
  }
67
65
  exports.getUpdateTestCodeCompletion = getUpdateTestCodeCompletion;
68
- async function updateTest(testCase, file, options, logging = true, validate = true, trace) {
69
- const logger = new logger_1.CustomLogger({ useReporter: logging });
66
+ async function updateTest({ testCase, file, trace, }) {
67
+ const logger = new logger_1.CustomLogger({ useReporter: true });
70
68
  const context = await (0, context_1.contextForGeneration)(file);
71
69
  const { codePrompt, pomPrompt, nonSpecFilePrompt, testFileContent } = context;
72
70
  const generatedTestCases = [];
73
71
  logger.logEmptyLine();
74
- const session = (0, session_1.getSessionDetails)();
75
- trace =
76
- trace ||
77
- llm_1.langfuseInstance?.trace({
78
- name: "update-test",
79
- id: crypto_1.default.randomUUID(),
80
- release: session.version,
81
- tags: [
82
- options?.metadata.projectName || "",
83
- options?.metadata.environment || "",
84
- ].filter((s) => !!s),
85
- });
86
72
  const request = {
87
73
  testCase,
88
74
  testFileContent,
89
75
  testFiles: codePrompt,
90
76
  pageFiles: pomPrompt,
91
77
  testFilePath: file,
92
- options,
93
78
  };
94
79
  const updateTestSpan = trace?.span({
95
80
  name: "update-test",
@@ -105,7 +90,6 @@ async function updateTest(testCase, file, options, logging = true, validate = tr
105
90
  testCase,
106
91
  fileChanges,
107
92
  logger,
108
- testGenOptions: options,
109
93
  pomPrompt: pomPrompt,
110
94
  nonSpecFilePrompt: nonSpecFilePrompt,
111
95
  });
@@ -125,18 +109,16 @@ async function updateTest(testCase, file, options, logging = true, validate = tr
125
109
  testCase,
126
110
  fileChanges: filteredFileChanges,
127
111
  logger,
128
- testGenOptions: options,
129
112
  pomPrompt: pomPrompt,
130
113
  nonSpecFilePrompt: nonSpecFilePrompt,
131
114
  });
132
115
  }
133
116
  await (0, utils_1.validateTypesAndFormatCode)({
134
- validateTypes: validate,
117
+ validateTypes: true,
135
118
  trace: updateTestSpan,
136
119
  testCase,
137
120
  filePaths: fileChanges.map((f) => f.filePath),
138
121
  logger,
139
- testGenOptions: options,
140
122
  pomPrompt: pomPrompt,
141
123
  nonSpecFilePrompt: nonSpecFilePrompt,
142
124
  });
@@ -153,19 +135,7 @@ async function updateTest(testCase, file, options, logging = true, validate = tr
153
135
  return generatedTestCases;
154
136
  }
155
137
  exports.updateTest = updateTest;
156
- async function getAppendCreateTestBlockCompletion({ testFiles, pageFiles, testCase, testFilePath, options, trace, }) {
157
- const session = (0, session_1.getSessionDetails)();
158
- trace =
159
- trace ||
160
- llm_1.langfuseInstance?.trace({
161
- name: "append-create-test-block",
162
- id: crypto_1.default.randomUUID(),
163
- release: session.version,
164
- tags: [
165
- options?.metadata.projectName || "",
166
- options?.metadata.environment || "",
167
- ].filter((s) => !!s),
168
- });
138
+ async function getAppendCreateTestBlockCompletion({ testFiles, pageFiles, testCase, testFilePath, trace, }) {
169
139
  const appendCreateTestSpan = trace?.span({
170
140
  name: "append-create-test-block",
171
141
  input: {
@@ -175,9 +145,6 @@ async function getAppendCreateTestBlockCompletion({ testFiles, pageFiles, testCa
175
145
  testFilePath,
176
146
  },
177
147
  });
178
- const promptSpan = trace?.span({
179
- name: "append-create-test-block-prompt",
180
- });
181
148
  const instruction = (0, llm_1.compilePrompt)(promptTemplate_0, {
182
149
  testFiles: testFiles,
183
150
  pageFiles: pageFiles,
@@ -185,7 +152,6 @@ async function getAppendCreateTestBlockCompletion({ testFiles, pageFiles, testCa
185
152
  scenarioSteps: testCase.steps.join("\n"),
186
153
  scenarioFile: testFilePath,
187
154
  });
188
- promptSpan?.end({ output: { instruction } });
189
155
  const [userInstruction] = instruction.filter((s) => s.role === "user");
190
156
  const [systemInstruction] = instruction.filter((s) => s.role === "system");
191
157
  userInstruction.content = `${systemInstruction?.content}
@@ -193,7 +159,7 @@ async function getAppendCreateTestBlockCompletion({ testFiles, pageFiles, testCa
193
159
  ${userInstruction?.content}
194
160
  `;
195
161
  const llm = new llm_1.LLM({
196
- trace,
162
+ trace: appendCreateTestSpan,
197
163
  provider: "anthropic",
198
164
  defaultModel: "claude-3-5-sonnet-latest",
199
165
  providerApiKey: constants_1.MODEL_API_KEYS["anthropic"],
@@ -201,7 +167,6 @@ async function getAppendCreateTestBlockCompletion({ testFiles, pageFiles, testCa
201
167
  const chatCompletionParams = {
202
168
  messages: [userInstruction],
203
169
  modelParameters: {
204
- ...options?.modelParameters,
205
170
  ...constants_1.DEFAULT_MODEL_PARAMETERS,
206
171
  },
207
172
  };
@@ -245,7 +210,7 @@ Respond with the same xml format which was originally expected.
245
210
  return response;
246
211
  }
247
212
  exports.getAppendCreateTestBlockCompletion = getAppendCreateTestBlockCompletion;
248
- async function appendCreateTestBlock({ testCase, file, options, trace, validateTypes = true, }) {
213
+ async function appendCreateTestBlock({ testCase, file, trace, validateTypes = true, }) {
249
214
  const logger = new logger_1.CustomLogger({ useReporter: false });
250
215
  logger.log("Appending create test block");
251
216
  const context = await (0, context_1.contextForGeneration)(file);
@@ -258,22 +223,19 @@ async function appendCreateTestBlock({ testCase, file, options, trace, validateT
258
223
  ]);
259
224
  const { pomPrompt, nonSpecFilePrompt } = context;
260
225
  const generatedTestCases = [];
261
- const appendCreateTestParams = {
226
+ const appendCreateTestResp = await getAppendCreateTestBlockCompletion({
262
227
  testCase,
263
228
  testFilePath: file,
264
- options,
265
229
  trace,
266
230
  pageFiles: pomPrompt,
267
231
  testFiles: testCodePrompt,
268
- };
269
- const appendCreateTestResp = await getAppendCreateTestBlockCompletion(appendCreateTestParams);
232
+ });
270
233
  const fileChanges = (0, utils_1.extractAppendTestUpdates)(appendCreateTestResp);
271
234
  await (0, utils_1.applyFileChanges)({
272
235
  trace,
273
236
  testCase,
274
237
  fileChanges,
275
238
  logger,
276
- testGenOptions: options,
277
239
  pomPrompt: pomPrompt,
278
240
  nonSpecFilePrompt: nonSpecFilePrompt,
279
241
  });
@@ -282,7 +244,6 @@ async function appendCreateTestBlock({ testCase, file, options, trace, validateT
282
244
  testCase,
283
245
  filePaths: fileChanges.map((f) => f.filePath),
284
246
  logger,
285
- testGenOptions: options,
286
247
  pomPrompt: pomPrompt,
287
248
  nonSpecFilePrompt: nonSpecFilePrompt,
288
249
  validateTypes,
@@ -294,7 +255,6 @@ async function appendCreateTestBlock({ testCase, file, options, trace, validateT
294
255
  ...testCase,
295
256
  updatedFiles: fileChanges.map((f) => f.filePath),
296
257
  });
297
- await (0, llm_1.flushAllTraces)();
298
258
  return generatedTestCases;
299
259
  }
300
260
  exports.appendCreateTestBlock = appendCreateTestBlock;
@@ -1,5 +1,5 @@
1
1
  import { TraceClient } from "@empiricalrun/llm";
2
- import type { TestCase, TestGenConfigOptions } from "@empiricalrun/shared-types";
2
+ import type { TestCase } from "@empiricalrun/shared-types";
3
3
  import { CustomLogger } from "../../bin/logger";
4
4
  import { TestGenUpdatesReporter } from "../../reporter";
5
5
  import { CodeUpdate, CreateTestCodeUpdate, FileUpdateResponse } from "./types";
@@ -57,13 +57,12 @@ export declare function extractTestStepsSuggestions(input: string): {
57
57
  reason: string;
58
58
  methodName: string;
59
59
  }[];
60
- export declare function validateTypesAndFormatCode({ validateTypes, trace, testCase, filePaths, logger, testGenOptions, pomPrompt, nonSpecFilePrompt, }: {
60
+ export declare function validateTypesAndFormatCode({ validateTypes, trace, testCase, filePaths, logger, pomPrompt, nonSpecFilePrompt, }: {
61
61
  validateTypes?: boolean;
62
62
  trace?: TraceClient;
63
63
  testCase: TestCase;
64
64
  filePaths: (string | undefined)[];
65
65
  logger?: CustomLogger;
66
- testGenOptions?: TestGenConfigOptions;
67
66
  pomPrompt?: string;
68
67
  nonSpecFilePrompt?: string;
69
68
  }): Promise<void>;
@@ -72,18 +71,6 @@ export declare function applyFileChangesUsingStrReplace({ trace, fileChanges, lo
72
71
  fileChanges: CodeUpdate[];
73
72
  logger?: CustomLogger;
74
73
  }): Promise<FileUpdateResponse[]>;
75
- export declare function searchAndReplaceCodeUsingStrReplace({ logger, fileChange, }: {
76
- fileChange: {
77
- filePath: string | undefined;
78
- oldCode: string | undefined;
79
- newCode: string | undefined;
80
- reason: string | undefined;
81
- };
82
- logger?: CustomLogger;
83
- }): Promise<{
84
- result: FileUpdateResponse;
85
- updatedContent: string;
86
- }>;
87
74
  export declare function applyFileChangesForCreateTest({ trace, fileChanges, testgenUpdatesReporter, }: {
88
75
  trace?: TraceClient;
89
76
  fileChanges: CreateTestCodeUpdate[];
@@ -115,7 +102,6 @@ export declare function applyFileChanges({ trace, testCase, fileChanges, logger,
115
102
  reason: string | undefined;
116
103
  }[];
117
104
  logger?: CustomLogger;
118
- testGenOptions?: TestGenConfigOptions;
119
105
  pomPrompt?: string;
120
106
  nonSpecFilePrompt?: string;
121
107
  }): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../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AAW,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE;QACX,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;KAC5B,EAAE,CAAC;IACJ,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CAkIxE"}
@@ -3,7 +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.applyFileChanges = exports.searchAndReplaceCode = exports.applyFileChangesForCreateTest = exports.searchAndReplaceCodeUsingStrReplace = exports.applyFileChangesUsingStrReplace = exports.validateTypesAndFormatCode = exports.extractTestStepsSuggestions = exports.extractAppendTestUpdates = exports.extractCreateTestUpdates = exports.extractTestUpdates = void 0;
6
+ exports.applyFileChanges = exports.searchAndReplaceCode = exports.applyFileChangesForCreateTest = exports.applyFileChangesUsingStrReplace = exports.validateTypesAndFormatCode = exports.extractTestStepsSuggestions = exports.extractAppendTestUpdates = exports.extractCreateTestUpdates = exports.extractTestUpdates = void 0;
7
7
  const llm_1 = require("@empiricalrun/llm");
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const ts_morph_1 = require("ts-morph");
@@ -127,7 +127,7 @@ function extractTestStepsSuggestions(input) {
127
127
  return result.filter((r) => !!r.filePath && !!r.usageExample);
128
128
  }
129
129
  exports.extractTestStepsSuggestions = extractTestStepsSuggestions;
130
- async function validateTypesAndFormatCode({ validateTypes = true, trace, testCase, filePaths, logger, testGenOptions, pomPrompt, nonSpecFilePrompt, }) {
130
+ async function validateTypesAndFormatCode({ validateTypes = true, trace, testCase, filePaths, logger, pomPrompt, nonSpecFilePrompt, }) {
131
131
  for (let filePath of filePaths) {
132
132
  if (!filePath) {
133
133
  continue;
@@ -141,7 +141,6 @@ async function validateTypesAndFormatCode({ validateTypes = true, trace, testCas
141
141
  pomCode: pomPrompt ?? "",
142
142
  nonSpecFileCode: nonSpecFilePrompt ?? "",
143
143
  testCase: testCase,
144
- options: testGenOptions,
145
144
  });
146
145
  }
147
146
  trace?.event({ name: "format-file" });
@@ -198,44 +197,6 @@ async function applyFileChangesUsingStrReplace({ trace, fileChanges, logger, })
198
197
  return results;
199
198
  }
200
199
  exports.applyFileChangesUsingStrReplace = applyFileChangesUsingStrReplace;
201
- async function searchAndReplaceCodeUsingStrReplace({ logger, fileChange, }) {
202
- let contents = await fs_extra_1.default.readFile(fileChange.filePath, "utf-8");
203
- if (contents.includes(fileChange.oldCode)) {
204
- // Check for multiple instances of old code block
205
- // If there are multiple instances, then we cannot safely determine which instance to replace
206
- const firstIndex = contents.indexOf(fileChange.oldCode);
207
- const lastIndex = contents.lastIndexOf(fileChange.oldCode);
208
- if (firstIndex !== lastIndex) {
209
- return {
210
- result: {
211
- error: true,
212
- errorMessage: `Multiple instances of the code block found in file "${fileChange.filePath}". Cannot safely determine which instance to replace.`,
213
- filePath: fileChange.filePath,
214
- },
215
- updatedContent: contents,
216
- };
217
- }
218
- const updatedContent = contents.replace(fileChange.oldCode, `\n\n${fileChange.newCode}`);
219
- return {
220
- result: {
221
- error: false,
222
- errorMessage: "",
223
- filePath: fileChange.filePath,
224
- },
225
- updatedContent,
226
- };
227
- }
228
- logger?.error(`Unable to find the code to update in ${fileChange.filePath}`);
229
- return {
230
- result: {
231
- error: true,
232
- errorMessage: `The content of "old_code_block" corresponding to file path "${fileChange.filePath}" did not match the current content of the file "${fileChange.filePath}"`,
233
- filePath: fileChange.filePath,
234
- },
235
- updatedContent: contents,
236
- };
237
- }
238
- exports.searchAndReplaceCodeUsingStrReplace = searchAndReplaceCodeUsingStrReplace;
239
200
  async function applyFileChangesForCreateTest({ trace, fileChanges, testgenUpdatesReporter, }) {
240
201
  const repoEditFileChangesSpan = trace?.span({
241
202
  name: "create-test-file-changes",
@@ -298,6 +259,7 @@ async function searchAndReplaceCode({ logger, fileChange, }) {
298
259
  return {
299
260
  result: {
300
261
  error: true,
262
+ // TODO: old_code_block should be replaced with oldCode
301
263
  errorMessage: `The content of "old_code_block" corresponding to file path "${fileChange.filePath}" did not match the current content of the file "${fileChange.filePath}"`,
302
264
  filePath: fileChange.filePath,
303
265
  },
@@ -1,14 +1,7 @@
1
1
  import { TraceClient } from "@empiricalrun/llm";
2
- import { TestErrorDiagnosisDetails, TestGenConfigOptions } from "@empiricalrun/shared-types";
2
+ import { TestErrorDiagnosisDetails } from "@empiricalrun/shared-types";
3
3
  import { CustomLogger } from "../../bin/logger";
4
- /**
5
- *
6
- * inputs
7
- * - task
8
- * - diagnosis
9
- */
10
- export declare function createTaskUsingFailureDiagnosis({ options, trace, diagnosis, logger, }: {
11
- options?: TestGenConfigOptions;
4
+ export declare function createTaskUsingFailureDiagnosis({ trace, diagnosis, logger, }: {
12
5
  trace?: TraceClient;
13
6
  diagnosis: TestErrorDiagnosisDetails;
14
7
  logger?: CustomLogger;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/diagnosis-agent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAuChD;;;;;GAKG;AACH,wBAAsB,+BAA+B,CAAC,EACpD,OAAO,EACP,KAAK,EACL,SAAS,EACT,MAAM,GACP,EAAE;IACD,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,yBAAyB,CAAC;IACrC,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CA8E5B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/diagnosis-agent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAuChD,wBAAsB,+BAA+B,CAAC,EACpD,KAAK,EACL,SAAS,EACT,MAAM,GACP,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,yBAAyB,CAAC;IACrC,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CA6E5B"}
@@ -30,13 +30,7 @@ const responseFormat = {
30
30
  },
31
31
  },
32
32
  };
33
- /**
34
- *
35
- * inputs
36
- * - task
37
- * - diagnosis
38
- */
39
- async function createTaskUsingFailureDiagnosis({ options, trace, diagnosis, logger, }) {
33
+ async function createTaskUsingFailureDiagnosis({ trace, diagnosis, logger, }) {
40
34
  trace =
41
35
  trace ||
42
36
  llm_1.langfuseInstance?.trace({
@@ -48,7 +42,6 @@ async function createTaskUsingFailureDiagnosis({ options, trace, diagnosis, logg
48
42
  name: "auto-fix",
49
43
  input: {
50
44
  diagnosisId: diagnosis.diagnosisId,
51
- prjRepoName: options?.metadata.projectRepoName,
52
45
  },
53
46
  });
54
47
  logger?.log("Trying to fix the test using failure diagnosis. Fetching key moments of the diagnosis");
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/enrich-prompt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAmCpE,eAAO,MAAM,2BAA2B;eAM3B,MAAM;kBACH,MAAM;sBACF,MAAM;;;YAGhB,MAAM;8BACY,OAAO;uBACd,MAAM;EA0D1B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/enrich-prompt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAmCpE,eAAO,MAAM,2BAA2B;eAM3B,MAAM;kBACH,MAAM;sBACF,MAAM;;;YAGhB,MAAM;8BACY,OAAO;uBACd,MAAM;EAyD1B,CAAC"}
@@ -59,7 +59,6 @@ const enrichPromptWithFailingLine = async ({ trace, testBlock, testFilePath, sug
59
59
  });
60
60
  const llmResponse = await llm.createChatCompletion({
61
61
  messages: instructions,
62
- trace,
63
62
  modelParameters: {
64
63
  temperature: 0.5,
65
64
  },
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/infer-agent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAYzE,wBAAsB,mBAAmB,CAAC,EACxC,IAAI,EACJ,OAAO,EACP,KAAK,GACN,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAA;CAAE,CAAC,CAmE/B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/infer-agent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAUzE,wBAAsB,mBAAmB,CAAC,EACxC,IAAI,EACJ,OAAO,EACP,KAAK,GACN,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAA;CAAE,CAAC,CA4D/B"}
@@ -4,16 +4,7 @@ exports.inferAgentBasedTask = void 0;
4
4
  const llm_1 = require("@empiricalrun/llm");
5
5
  const constants_1 = require("../../constants");
6
6
  const promptTemplate_0 = "{{#section \"system\"}}\nYou are a software test engineer specializing in Playwright end-to-end tests. You are given a task which is a part of an\nend-to-end test scenario. The task may involve updating an existing end-to-end test case or writing a new test case from\nscratch. Tests involve user interactions (e.g. click on element) or other actions supported by Playwright (e.g.\nintercept network requests)\n\nYour objective is to identify whether the task requires accessing a web browser or not.\n\nTo fulfill your objective, answer the following questions:\n\n1. Does it require you to interact with a UI element in the browser? Examples of interactions are click, fill, type, key\npress, assert visibility of the element. Actions that interact with network requests are not UI element interactions.\n\n2. Is the locator of this UI element given to you in the task? Locators look like `getByText(...)`, `getByTestId(...)`\nand other locator methods in Playwright\n\n3. Decide if you need a browser: if you need to interact with a UI element AND you are NOT given the locator for that\nelement, you WILL NEED a browser.\n\n4. If you NEED a browser, then respond with answer as \"master\", otherwise respond with \"code\"\n\n\n# Example 1\n## Input\nTask:\nin this test don't delete the agent and remove steps after that\n\n## Output\n- ui_interaction_to_be_performed: There is no interaction here\n- ui_element_to_interact_with: No element specified\n- has_locator_for_that_element: No element specified\n- reasoning_for_browser_required: No interaction hence browser is not required\n- answer: code\n\n# Example 2\n## Input\nTask:\nin the swapfast test, replace the selectTokenForSwap method. Instead we will do this\\nclick on token button - this will\nshow a drawer\\nEnter usd in the search field that shows up in the drawer\\nSelect USDC.axl for Cosmos Hub - very\nimportant to choose this instead of USDC.axl on Osmosis\n\n## Output\n- ui_interaction_to_be_performed: Click on token button\n- ui_element_to_interact_with: Token button\n- has_locator_for_that_element: false\n- reasoning_for_browser_required: Task requires interacting with a UI element and identifying its locator which needs a\nbrowser\n- answer: master\n{{/section}}\n\n{{#section \"user\"}}\nTask:\n{{task}}\n{{/section}}";
7
- const session_1 = require("../../session");
8
- const session = (0, session_1.getSessionDetails)();
9
7
  async function inferAgentBasedTask({ task, options, trace, }) {
10
- trace =
11
- trace ||
12
- llm_1.langfuseInstance?.trace({
13
- name: "infer-agent-task",
14
- id: crypto.randomUUID(),
15
- release: session.version,
16
- });
17
8
  const inferAgentSpan = trace?.span({
18
9
  name: "infer-agent",
19
10
  input: {
@@ -49,7 +49,7 @@ click on maverick inside ford dropdown`,
49
49
  (0, fixtures_1.expect)(lines.find((l) => l.match(/^await page.+Ford.+.click/))).toBeTruthy();
50
50
  (0, fixtures_1.expect)(lines.find((l) => l.match(/^await page.+Maverick.+.click/))).toBeTruthy();
51
51
  });
52
- (0, fixtures_1.test)("agent can click icons accurately", async ({ page, server }) => {
52
+ (0, fixtures_1.test)("master agent can click icons accurately", async ({ page, server }) => {
53
53
  await page.goto(`${server.baseURL}/icons-navbar.html`);
54
54
  await (0, fixtures_1.expect)(page.getByText("select an icon")).toBeVisible();
55
55
  const response = await (0, run_1.createTestUsingMasterAgent)({
@@ -72,6 +72,20 @@ click on maverick inside ford dropdown`,
72
72
  // expect(icons.length).toBe(4); // 1 for each unique icon
73
73
  fs_1.default.unlinkSync(iconsRegistryFile);
74
74
  });
75
+ (0, fixtures_1.test)("cua agent can click icons accurately", async ({ page, server }) => {
76
+ await page.goto(`${server.baseURL}/icons-navbar.html`);
77
+ await (0, fixtures_1.expect)(page.getByText("select an icon")).toBeVisible();
78
+ const response = await (0, run_1.executeUsingComputerUseAgent)({
79
+ task: `click on the gear icon`,
80
+ page,
81
+ });
82
+ // Validate code generated and action performed
83
+ await (0, fixtures_1.expect)(page.getByText("you clicked Gear")).toBeVisible();
84
+ console.log(response);
85
+ (0, fixtures_1.expect)(response.importPaths.length).toBe(0);
86
+ (0, fixtures_1.expect)(response.code).toContain("page.locator");
87
+ (0, fixtures_1.expect)(response.code).toContain("click()");
88
+ });
75
89
  (0, fixtures_1.test)("annotate and enrich annotations correctly", async ({ page, server }) => {
76
90
  await (0, utils_1.injectPwLocatorGenerator)(page);
77
91
  await page.goto(`${server.baseURL}/iframe-elements.html`);
@@ -1 +1 @@
1
- {"version":3,"file":"element-annotation.d.ts","sourceRoot":"","sources":["../../../src/agent/master/element-annotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AASlC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AA2DjD,wBAAsB,oBAAoB,CAAC,EACzC,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,KAAK,EACL,GAAG,EACH,OAAO,EACP,UAAU,GACX,EAAE;IACD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,UAAU,EAAE,oBAAoB,CAAC;CAClC,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA8C9B;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EACN,KAAK,GACL,UAAU,CAAC,IAAI,GACf,UAAU,CAAC,WAAW,GACtB,UAAU,CAAC,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,CAAC;AAgBF,wBAAsB,iBAAiB,CAAC,EACtC,IAAI,EACJ,UAAU,EACV,KAAK,GACN,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE,oBAAoB,CAAC;IACjC,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC;IACV,cAAc,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACtD,gBAAgB,EAAE,MAAM,CAAC;IACzB,uBAAuB,EAAE,MAAM,CAAC;CACjC,CAAC,CAoFD"}
1
+ {"version":3,"file":"element-annotation.d.ts","sourceRoot":"","sources":["../../../src/agent/master/element-annotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAQlC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AA2DjD,wBAAsB,oBAAoB,CAAC,EACzC,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,KAAK,EACL,GAAG,EACH,OAAO,EACP,UAAU,GACX,EAAE;IACD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,UAAU,EAAE,oBAAoB,CAAC;CAClC,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA8C9B;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EACN,KAAK,GACL,UAAU,CAAC,IAAI,GACf,UAAU,CAAC,WAAW,GACtB,UAAU,CAAC,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,CAAC;AAgBF,wBAAsB,iBAAiB,CAAC,EACtC,IAAI,EACJ,UAAU,EACV,KAAK,GACN,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE,oBAAoB,CAAC;IACjC,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC;IACV,cAAc,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACtD,gBAAgB,EAAE,MAAM,CAAC;IACzB,uBAAuB,EAAE,MAAM,CAAC;CACjC,CAAC,CAoFD"}
@@ -4,7 +4,6 @@ exports.getAnnotationKeys = exports.getElementAnnotation = void 0;
4
4
  const llm_1 = require("@empiricalrun/llm");
5
5
  const constants_1 = require("../../constants");
6
6
  const promptTemplate_0 = "{{#section \"system\"}}\nYou are an expert in describing the images and it's content. You need to provide the descriptions of annotated elements\npresent in the image.\n\nYou will be provided with an annotated screenshot where interact-able / clickable elements are annotated. The annotation\nis done by drawing a red box around the element and a small yellow box on it which contains unique element id.\n\nYou are given a Annotations which contains list of unique element id and description of the element separated by \":\".\n\nYou are also given the description of the element on which the action needs to be taken. The description includes\ninformation about how the element looks, it's position etc.\n\nYour task is to provide the annotation of the element on which the action needs to be performed based on the element\ndescription.\n\nFollow steps to fulfil your task:\n- Using the list of all element Ids provided to you, map all the element Ids on the annotated screen and describe each\nelement.\n- For describing each element Id\n-- iterate over each element Id in annotation list\n-- check if the description is already present for the element Id in the Annotation provided to you. If present skip\ndescribing it and use it as is.\n-- if the description is NA, then identify the element in the annotated screenshot and describe it using the image or\nicon enclosed in the element.\n- Respond with the mapped element Ids as \"enriched_annotations\"\n- Based on the description provided to you and the enriched annotations, first identify the element Id whose description\nmatches the task provided\n\nNote:\n- Ensure providing the description of all the elements in the list.\n- Don't update the description if its already present in the given annotations\n- Replace all the \"NA\" with description of the element. Its position, how does it look like etc.\n- There should be no \"NA\" present in any of the element description\n{{/section}}\n\n{{#section \"user\"}}\nElement description:\n{{elementDescription}}\n\nAnnotations:\n{{annotations}}\n\n{{image annotatedScreenshot}}\n{{/section}}";
7
- const utils_1 = require("../utils");
8
7
  const icon_descriptor_1 = require("./icon-descriptor");
9
8
  const annotationToolAction = {
10
9
  name: "element_annotation",
@@ -94,7 +93,7 @@ async function getElementAnnotation({ elementDescription, annotations, annotated
94
93
  const toolCall = completion?.tool_calls?.[0];
95
94
  annotationsSpan?.end({ output: toolCall });
96
95
  if (toolCall) {
97
- const args = (0, utils_1.parseJson)(toolCall.function.arguments);
96
+ const args = JSON.parse(toolCall.function.arguments);
98
97
  return args.element_annotation;
99
98
  }
100
99
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"execute-browser-action.d.ts","sourceRoot":"","sources":["../../../src/agent/master/execute-browser-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAYlD,wBAAsB,oBAAoB,CAAC,EACzC,IAAI,EACJ,UAAU,EACV,KAAK,EACL,OAAO,EACP,GAAG,EACH,KAAK,GACN,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE;QACV,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,KAAK,EAAE;QACL,4BAA4B,EAAE,OAAO,CAAC;KACvC,CAAC;IACF,OAAO,EAAE,iBAAiB,CAAC;IAC3B,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,GAAG,EAAE,GAAG,CAAC;CACV;;;gBAIW,MAAM;gBACN,MAAM;;;GAkIjB"}
1
+ {"version":3,"file":"execute-browser-action.d.ts","sourceRoot":"","sources":["../../../src/agent/master/execute-browser-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAWlD,wBAAsB,oBAAoB,CAAC,EACzC,IAAI,EACJ,UAAU,EACV,KAAK,EACL,OAAO,EACP,GAAG,EACH,KAAK,GACN,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE;QACV,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,KAAK,EAAE;QACL,4BAA4B,EAAE,OAAO,CAAC;KACvC,CAAC;IACF,OAAO,EAAE,iBAAiB,CAAC;IAC3B,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,GAAG,EAAE,GAAG,CAAC;CACV;;;gBAIW,MAAM;gBACN,MAAM;;;GAkIjB"}
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeBrowserAction = void 0;
4
4
  const reporter_1 = require("../../reporter");
5
5
  const browsing_1 = require("../browsing");
6
- const utils_1 = require("../utils");
7
6
  const action_tool_calls_1 = require("./action-tool-calls");
8
7
  const element_annotation_1 = require("./element-annotation");
9
8
  const with_hints_1 = require("./with-hints");
10
9
  async function executeBrowserAction({ page, nextAction, flags, actions, llm, trace, }) {
11
- const args = (0, utils_1.parseJson)(nextAction.toolCallArgs);
10
+ const args = JSON.parse(nextAction.toolCallArgs);
12
11
  let generatedCodeSteps = [];
13
12
  let output = {
14
13
  action: args.action,
@@ -1 +1 @@
1
- {"version":3,"file":"execute-skill-action.d.ts","sourceRoot":"","sources":["../../../src/agent/master/execute-skill-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAOlD,wBAAsB,kBAAkB,CAAC,EACvC,OAAO,EACP,UAAU,EACV,KAAK,GACN,EAAE;IACD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,UAAU,EAAE;QACV,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;CAChC,+BAeA"}
1
+ {"version":3,"file":"execute-skill-action.d.ts","sourceRoot":"","sources":["../../../src/agent/master/execute-skill-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAMlD,wBAAsB,kBAAkB,CAAC,EACvC,OAAO,EACP,UAAU,EACV,KAAK,GACN,EAAE;IACD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,UAAU,EAAE;QACV,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;CAChC,+BAeA"}
@@ -5,9 +5,8 @@ const skill_1 = require("../../actions/skill");
5
5
  const errors_1 = require("../../errors");
6
6
  const human_in_the_loop_1 = require("../../human-in-the-loop");
7
7
  const env_1 = require("../../utils/env");
8
- const utils_1 = require("../utils");
9
8
  async function executeSkillAction({ actions, nextAction, trace, }) {
10
- const args = (0, utils_1.parseJson)(nextAction.toolCallArgs);
9
+ const args = JSON.parse(nextAction.toolCallArgs);
11
10
  if (!(0, env_1.isRunningOnCloud)()) {
12
11
  const { skillDetails } = (0, skill_1.extractSkillFromArgs)(args);
13
12
  const feedback = await human_in_the_loop_1.humanLoop.getFeedback({
@@ -1 +1 @@
1
- {"version":3,"file":"next-action.d.ts","sourceRoot":"","sources":["../../../src/agent/master/next-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAWhD,wBAAsB,aAAa,CAAC,EAClC,IAAI,EACJ,cAAc,EACd,IAAI,EACJ,eAAe,EACf,aAAa,EACb,KAAK,EACL,GAAG,EACH,OAAO,EACP,OAAO,EACP,aAAa,EACb,MAAM,GACP,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,aAAa,EAAE,GAAG,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACxC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,GAAG,OAAO,CACP;IACE,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB,GACD,SAAS,CACZ,CA8FA"}
1
+ {"version":3,"file":"next-action.d.ts","sourceRoot":"","sources":["../../../src/agent/master/next-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUhD,wBAAsB,aAAa,CAAC,EAClC,IAAI,EACJ,cAAc,EACd,IAAI,EACJ,eAAe,EACf,aAAa,EACb,KAAK,EACL,GAAG,EACH,OAAO,EACP,OAAO,EACP,aAAa,EACb,MAAM,GACP,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,aAAa,EAAE,GAAG,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACxC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,GAAG,OAAO,CACP;IACE,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB,GACD,SAAS,CACZ,CA8FA"}
@@ -5,7 +5,6 @@ const llm_1 = require("@empiricalrun/llm");
5
5
  const skill_1 = require("../../actions/skill");
6
6
  const constants_1 = require("../../constants");
7
7
  const promptTemplate_0 = "{{#section \"system\"}}\nYou are a web automation tool which is given a task to complete. You need to execute the\ntask provided to you with the help of web page screenshot, a browser automation tool or skills\nwhich are learnt while writing previous tests. \n \nBrowser automation tool is a tool which uses Playwright and browser to execute action using\nnext_action tool call.\nSkill usage is a tool which helps to execute previously known pieces of code to achieve a task.\n\nYou will be provided with a screenshot of the webpage which you will use to extract the action\nthat needs to be taken.\n\nYou will be provided with previously executed actions by the browser automation tool and based\non the current screenshot and previously executed actions, you need to predict the next action\nto be taken.\n\nYou will also be provided with failed next action predicted by you, so that you can avoid\nsuggesting the same action again - which failed.\n\nThe next action should be as atomic as possible. e.g: scroll, click on an element, fill an input\nelement, assert, extract text from an element are valid next action as they are atomic in nature.\n\nYou also need to provide the action type using the list below, action type which is not present in\nthe list is invalid: {{validActionTypes}}\n\nYou will also be provided with skill usage tool which you can use to execute action. These skills\nare compound functions which helps you to complete your action.\n\nYou need to respond with either:\n- Next action to be taken by a browser automation tool \n- Use previously learnt skills in the form of tool call.\n \nYou need to make a decision whether the given skill can be reused if \"YES\" respond with the\nskill else respond with the next action.\n{{/section}}\n\n{{#section \"user\"}}\nTask:\n{{task}}\n\n-----\n\nPrevious executed actions:\n{{executedActions}}\n\n-----\n\nPrevious failed actions:\n{{failedActions}}\n\n-----\n\nYou are also provided with a page screenshot for you to decide the next action.\n\nCurrent page URL: {{pageUrl}}\n\nFollow the instructions before responding:\n- Divide the task into sub tasks\n- Using previously executed actions, identify tasks are complete and which tasks needs to be executed next.\n- You will be provided a skill usage action, if the testStep matches the next action then respond with the skill usage.\n- If responding with next action, ensure next action to be detailed and explicit about what action needs to be done. Provide all the information which can be extracted from the screenshot as a part of next action.\n- Mark task as complete only when executed actions provided to you indicates that the task is done.\n- Refer to the text and references available in the screenshot to create the next action.\n- Do not take any extra actions which are not required for the execution of the task\n- If there are no further actions required based on the task, then respond with task as done.\n- Do not recommend actions which are not available in the screenshot\n\nScreenshots:\n{{images pageScreenshots}}\n\n{{/section}}\n";
8
- const utils_1 = require("../utils");
9
8
  const action_tool_calls_1 = require("./action-tool-calls");
10
9
  const scroller_1 = require("./scroller");
11
10
  async function getNextAction({ page, pageScreenshot, task, executedActions, failedActions, trace, llm, options, actions, disableSkills, logger, }) {
@@ -33,7 +32,7 @@ async function getNextAction({ page, pageScreenshot, task, executedActions, fail
33
32
  });
34
33
  const actionSchemas = disableSkills || skill_1.testCaseSkills.getAvailableSkills().length === 0
35
34
  ? []
36
- : actions.getMasterActionSchemas();
35
+ : actions.getSkillsActionSchemas();
37
36
  const tools = [...(0, action_tool_calls_1.getActionToolCalls)(), ...actionSchemas];
38
37
  llm =
39
38
  llm ||
@@ -57,7 +56,7 @@ async function getNextAction({ page, pageScreenshot, task, executedActions, fail
57
56
  const toolCall = completion?.tool_calls?.[0];
58
57
  nextActionSpan?.end({ output: toolCall });
59
58
  if (toolCall) {
60
- const toolCallArgs = (0, utils_1.parseJson)(toolCall.function.arguments);
59
+ const toolCallArgs = JSON.parse(toolCall.function.arguments);
61
60
  const actionType = toolCall.function.name;
62
61
  // If the action type is scroll, we need to scroll the page and get the reference to the frame in which the element is visible
63
62
  // else we return the next action
@@ -1 +1 @@
1
- {"version":3,"file":"planner.d.ts","sourceRoot":"","sources":["../../../src/agent/master/planner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAKvC,wBAAsB,4BAA4B,CAAC,EACjD,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,IAAI,EACJ,WAAW,GACZ,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;;;;GAwIA"}
1
+ {"version":3,"file":"planner.d.ts","sourceRoot":"","sources":["../../../src/agent/master/planner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAIvC,wBAAsB,4BAA4B,CAAC,EACjD,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,IAAI,EACJ,WAAW,GACZ,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;;;;GAwIA"}