@empiricalrun/test-gen 0.42.26 → 0.42.28

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 (36) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/agent/browsing/run.d.ts.map +1 -1
  3. package/dist/agent/browsing/run.js +25 -0
  4. package/dist/agent/codegen/generate-code-apply-changes.js +1 -1
  5. package/dist/agent/codegen/repo-edit.d.ts +2 -4
  6. package/dist/agent/codegen/repo-edit.d.ts.map +1 -1
  7. package/dist/agent/codegen/repo-edit.js +18 -156
  8. package/dist/agent/codegen/run.d.ts +12 -0
  9. package/dist/agent/codegen/run.d.ts.map +1 -1
  10. package/dist/agent/codegen/run.js +82 -15
  11. package/dist/agent/codegen/types.d.ts +5 -0
  12. package/dist/agent/codegen/types.d.ts.map +1 -1
  13. package/dist/agent/codegen/update-flow.js +2 -2
  14. package/dist/agent/codegen/utils.d.ts +20 -20
  15. package/dist/agent/codegen/utils.d.ts.map +1 -1
  16. package/dist/agent/codegen/utils.js +51 -38
  17. package/dist/bin/index.d.ts +1 -1
  18. package/dist/bin/index.d.ts.map +1 -1
  19. package/dist/bin/index.js +87 -51
  20. package/dist/bin/utils/index.d.ts +2 -0
  21. package/dist/bin/utils/index.d.ts.map +1 -1
  22. package/dist/bin/utils/index.js +3 -1
  23. package/dist/evals/add-scenario-agent.evals.d.ts.map +1 -1
  24. package/dist/evals/add-scenario-agent.evals.js +4 -4
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +33 -4
  28. package/dist/initSentry.d.ts +2 -0
  29. package/dist/initSentry.d.ts.map +1 -0
  30. package/dist/initSentry.js +37 -0
  31. package/dist/test-build/index.d.ts.map +1 -1
  32. package/dist/test-build/index.js +25 -0
  33. package/dist/utils/exec.d.ts +2 -0
  34. package/dist/utils/exec.d.ts.map +1 -1
  35. package/dist/utils/exec.js +66 -26
  36. package/package.json +3 -2
@@ -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.applyFileChangesForRepoEdit = exports.searchAndReplaceCodeUsingStrReplace = exports.applyFileChangesUsingStrReplace = exports.getTaskForCreateTest = exports.validateTypesAndFormatCode = exports.extractTestStepsSuggestions = exports.extractAppendTestUpdates = exports.extractTestUpdates = void 0;
6
+ exports.applyFileChanges = exports.searchAndReplaceCode = exports.applyFileChangesForCreateTest = exports.searchAndReplaceCodeUsingStrReplace = 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");
@@ -38,6 +38,33 @@ function extractTestUpdates(input) {
38
38
  return result;
39
39
  }
40
40
  exports.extractTestUpdates = extractTestUpdates;
41
+ /**
42
+ *
43
+ * method to extract file path and code updates for the LLM response of create flow
44
+ * @export
45
+ * @param {string} input
46
+ * @return {*} {({
47
+ * filePath: string | undefined;
48
+ * code: string | undefined;
49
+ * reason: string | undefined;
50
+ * }[])}
51
+ */
52
+ function extractCreateTestUpdates(input) {
53
+ const result = [];
54
+ // TODO: use better structure for this. Do not kill me for this please.
55
+ const regex = /<file_path>(.*?)<\/file_path>[\s\S]*?<code_block>([\s\S]*?)<\/code_block>[\s\S]*?<change>([\s\S]*?)<\/change>/g;
56
+ let match;
57
+ while ((match = regex.exec(input)) !== null) {
58
+ const [, filePath, code, reason] = match;
59
+ result.push({
60
+ filePath: filePath?.trim(),
61
+ code: code?.trim(),
62
+ reason: reason?.trim(),
63
+ });
64
+ }
65
+ return result;
66
+ }
67
+ exports.extractCreateTestUpdates = extractCreateTestUpdates;
41
68
  /**
42
69
  *
43
70
  * method to extract append create test updates
@@ -89,9 +116,9 @@ function extractTestStepsSuggestions(input) {
89
116
  return result.filter((r) => !!r.filePath && !!r.usageExample);
90
117
  }
91
118
  exports.extractTestStepsSuggestions = extractTestStepsSuggestions;
92
- async function validateTypesAndFormatCode({ validateTypes = true, trace, testCase, fileChanges, logger, testGenOptions, pomPrompt, nonSpecFilePrompt, }) {
93
- for (let fileChange of fileChanges) {
94
- if (!fileChange.filePath) {
119
+ async function validateTypesAndFormatCode({ validateTypes = true, trace, testCase, filePaths, logger, testGenOptions, pomPrompt, nonSpecFilePrompt, }) {
120
+ for (let filePath of filePaths) {
121
+ if (!filePath) {
95
122
  continue;
96
123
  }
97
124
  try {
@@ -99,7 +126,7 @@ async function validateTypesAndFormatCode({ validateTypes = true, trace, testCas
99
126
  await (0, fix_ts_errors_1.validateAndFixTypescriptErrors)({
100
127
  trace,
101
128
  logger,
102
- file: fileChange.filePath,
129
+ file: filePath,
103
130
  pomCode: pomPrompt ?? "",
104
131
  nonSpecFileCode: nonSpecFilePrompt ?? "",
105
132
  testCase: testCase,
@@ -107,29 +134,16 @@ async function validateTypesAndFormatCode({ validateTypes = true, trace, testCas
107
134
  });
108
135
  }
109
136
  trace?.event({ name: "format-file" });
110
- await (0, web_1.formatCode)(fileChange.filePath, trace);
111
- logger?.success(`${fileChange.filePath} file formatted successfully!`);
137
+ await (0, web_1.formatCode)(filePath, trace);
138
+ logger?.success(`${filePath} file formatted successfully!`);
112
139
  }
113
140
  catch (e) {
114
- console.error(`Error while formatting the file ${fileChange.filePath}`, e);
141
+ console.error(`Error while formatting the file ${filePath}`, e);
115
142
  }
116
143
  }
117
144
  await (0, llm_1.flushAllTraces)();
118
145
  }
119
146
  exports.validateTypesAndFormatCode = validateTypesAndFormatCode;
120
- function getTaskForCreateTest({ testCase, file, }) {
121
- return `
122
- Create a new test case with name '${testCase.name}' at file path '${file}'
123
- ${testCase.suites.length
124
- ? `
125
- Put this test case inside describe blocks named: ${testCase.suites.join(" > ")}`
126
- : ""}
127
-
128
- In the above test, write code that performs these actions and ONLY these actions:
129
- ${testCase.steps.join("\n")}
130
- `;
131
- }
132
- exports.getTaskForCreateTest = getTaskForCreateTest;
133
147
  async function applyFileChangesUsingStrReplace({ trace, fileChanges, logger, }) {
134
148
  const repoEditFileChangesSpan = trace?.span({
135
149
  name: "repo-edit-file-changes",
@@ -211,11 +225,10 @@ async function searchAndReplaceCodeUsingStrReplace({ logger, fileChange, }) {
211
225
  };
212
226
  }
213
227
  exports.searchAndReplaceCodeUsingStrReplace = searchAndReplaceCodeUsingStrReplace;
214
- async function applyFileChangesForRepoEdit({ trace, fileChanges, logger, }) {
228
+ async function applyFileChangesForCreateTest({ trace, fileChanges, testgenUpdatesReporter, }) {
215
229
  const repoEditFileChangesSpan = trace?.span({
216
- name: "repo-edit-file-changes",
230
+ name: "create-test-file-changes",
217
231
  });
218
- const results = [];
219
232
  for (const fileChange of fileChanges) {
220
233
  if (!fileChange.filePath) {
221
234
  continue;
@@ -227,33 +240,33 @@ async function applyFileChangesForRepoEdit({ trace, fileChanges, logger, }) {
227
240
  fileChange,
228
241
  },
229
242
  });
230
- const { result, updatedContent } = await searchAndReplaceCode({
231
- logger,
232
- fileChange,
233
- });
234
- if (result.error) {
235
- logger?.error(`Unable to find the code to update in ${result.filePath}`);
236
- }
237
- else {
238
- await fs_extra_1.default.writeFile(fileChange.filePath, updatedContent, "utf-8");
239
- readWriteFileSpan?.end({ output: { updatedContent } });
243
+ if (fileChange.code) {
244
+ const currentContent = fs_extra_1.default.existsSync(fileChange.filePath)
245
+ ? await fs_extra_1.default.readFile(fileChange.filePath, "utf-8")
246
+ : "";
247
+ await fs_extra_1.default.writeFile(fileChange.filePath, currentContent
248
+ ? `${currentContent}\n\n${fileChange.code}`
249
+ : fileChange.code, "utf-8");
250
+ const updatedFileContent = await fs_extra_1.default.readFile(fileChange.filePath, "utf-8");
251
+ readWriteFileSpan?.end({
252
+ output: { fileChange, updatedFile: updatedFileContent },
253
+ });
240
254
  }
241
- results.push(result);
242
255
  }
243
256
  catch (e) {
244
257
  trace?.event({
245
- name: "repo-edit-file-changes-error",
258
+ name: "create-test-file-changes-error",
246
259
  output: {
247
260
  filePath: fileChange.filePath,
248
261
  error: e,
249
262
  },
250
263
  });
264
+ void testgenUpdatesReporter?.sendMessage(`Error while applying changes to file ${fileChange.filePath}, error: ${e}`);
251
265
  console.error(`Error while applying changes to file ${fileChange.filePath}`, e);
252
266
  }
253
267
  }
254
- return results;
255
268
  }
256
- exports.applyFileChangesForRepoEdit = applyFileChangesForRepoEdit;
269
+ exports.applyFileChangesForCreateTest = applyFileChangesForCreateTest;
257
270
  async function searchAndReplaceCode({ logger, fileChange, }) {
258
271
  let contents = await fs_extra_1.default.readFile(fileChange.filePath, "utf-8");
259
272
  // since we dont know what is getting updated,
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- export {};
2
+ import "../initSentry";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bin/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bin/index.ts"],"names":[],"mappings":";AAEA,OAAO,eAAe,CAAC"}
package/dist/bin/index.js CHANGED
@@ -1,10 +1,35 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
3
26
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
28
  };
6
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
+ require("../initSentry");
7
31
  const llm_1 = require("@empiricalrun/llm");
32
+ const Sentry = __importStar(require("@sentry/node"));
8
33
  const dotenv_1 = __importDefault(require("dotenv"));
9
34
  const run_1 = require("../agent/browsing/run");
10
35
  const utils_1 = require("../agent/browsing/utils");
@@ -21,10 +46,14 @@ const utils_2 = require("./utils");
21
46
  dotenv_1.default.config({
22
47
  path: [".env.local", ".env"],
23
48
  });
24
- process.on("beforeExit", async () => await (0, llm_1.flushAllTraces)());
25
- process.on("exit", async () => await (0, llm_1.flushAllTraces)());
26
- process.on("SIGINT", async () => await (0, llm_1.flushAllTraces)());
27
- process.on("SIGTERM", async () => await (0, llm_1.flushAllTraces)());
49
+ const flushEvents = async () => {
50
+ await (0, llm_1.flushAllTraces)();
51
+ await Sentry.flush();
52
+ };
53
+ process.on("beforeExit", async () => await flushEvents());
54
+ process.on("exit", async () => await flushEvents());
55
+ process.on("SIGINT", async () => await flushEvents());
56
+ process.on("SIGTERM", async () => await flushEvents());
28
57
  async function resolveAgentUsingTask({ testCase, trace, }) {
29
58
  const { response } = await (0, infer_agent_1.inferAgentBasedTask)({
30
59
  task: testCase.steps.join("\n"),
@@ -32,7 +61,7 @@ async function resolveAgentUsingTask({ testCase, trace, }) {
32
61
  });
33
62
  return response;
34
63
  }
35
- async function runAgent(testGenConfig) {
64
+ async function runAgent(testGenConfig, span) {
36
65
  const logger = new logger_1.CustomLogger();
37
66
  const { specPath, testCase } = testGenConfig;
38
67
  if (process.env.LOG_URL) {
@@ -40,6 +69,7 @@ async function runAgent(testGenConfig) {
40
69
  void new reporter_1.TestGenUpdatesReporter().sendLogUrl(process.env.LOG_URL);
41
70
  }
42
71
  catch (e) {
72
+ span?.recordException(e);
43
73
  console.warn("Failed to send log url to test gen update", e);
44
74
  }
45
75
  }
@@ -79,7 +109,6 @@ async function runAgent(testGenConfig) {
79
109
  trace,
80
110
  task: testGenConfig.testCase.steps.join("\n"),
81
111
  logger,
82
- useStrReplace: testGenConfig.options?.useStrReplace,
83
112
  });
84
113
  return;
85
114
  }
@@ -128,50 +157,57 @@ async function runAgent(testGenConfig) {
128
157
  }
129
158
  }
130
159
  (async function main() {
131
- // this is where test gen starts executing on giving the command from ci
132
- const logger = new logger_1.CustomLogger({ useReporter: false });
133
- if (process.argv.length < 3) {
134
- logger.error("Please provide path to scenarios using command:", "npx @empiricalrun/test-gen <TEST_GEN_TOKEN>");
135
- process.exit(1);
136
- }
137
- const { testGenConfig } = await (0, utils_2.parseCliArgs)();
138
- (0, reporter_1.setReporterConfig)({
139
- projectRepoName: testGenConfig.options?.metadata.projectRepoName,
140
- testSessionId: testGenConfig.options?.metadata.testSessionId,
141
- generationId: testGenConfig.options?.metadata.generationId,
142
- });
143
- (0, session_1.setSessionDetails)({
144
- sessionId: testGenConfig.options?.metadata.testSessionId,
145
- generationId: testGenConfig.options?.metadata.generationId,
146
- testCaseId: testGenConfig.testCase.id,
147
- projectRepoName: testGenConfig.options?.metadata.projectRepoName,
148
- });
149
- let testGenFailed = false;
150
- try {
151
- // download the build if it exists
152
- await (0, test_build_1.downloadBuild)(testGenConfig.build || {});
153
- await runAgent(testGenConfig);
154
- }
155
- catch (e) {
156
- testGenFailed = true;
157
- new logger_1.CustomLogger().error(`Failed to generate test for the scenario. ${process.env.LOG_URL ? `[view log](${process.env.LOG_URL})` : ""}`, e?.message, e?.stack);
158
- }
159
- if (testGenConfig.options?.agent !== "code" &&
160
- testGenConfig.options?.agent !== "plan" &&
161
- testGenConfig.testCase.name) {
162
- await new reporter_1.TestGenUpdatesReporter().reportGenAssets({
163
- projectRepoName: testGenConfig.options.metadata.projectRepoName,
164
- testName: testGenConfig.testCase.name,
160
+ await Sentry.continueTrace({ sentryTrace: utils_2.sentryTrace, baggage: utils_2.baggage }, async () => {
161
+ await Sentry.startSpan({ name: "test-gen" }, async (span) => {
162
+ // this is where test gen starts executing on giving the command from ci
163
+ const logger = new logger_1.CustomLogger({ useReporter: false });
164
+ if (process.argv.length < 3) {
165
+ logger.error("Please provide path to scenarios using command:", "npx @empiricalrun/test-gen <TEST_GEN_TOKEN>");
166
+ process.exit(1);
167
+ }
168
+ const { testGenConfig } = await (0, utils_2.parseCliArgs)();
169
+ (0, reporter_1.setReporterConfig)({
170
+ projectRepoName: testGenConfig.options?.metadata.projectRepoName,
171
+ testSessionId: testGenConfig.options?.metadata.testSessionId,
172
+ generationId: testGenConfig.options?.metadata.generationId,
173
+ });
174
+ (0, session_1.setSessionDetails)({
175
+ sessionId: testGenConfig.options?.metadata.testSessionId,
176
+ generationId: testGenConfig.options?.metadata.generationId,
177
+ testCaseId: testGenConfig.testCase.id,
178
+ projectRepoName: testGenConfig.options?.metadata.projectRepoName,
179
+ });
180
+ let testGenFailed = false;
181
+ try {
182
+ // download the build if it exists
183
+ await (0, test_build_1.downloadBuild)(testGenConfig.build || {});
184
+ await runAgent(testGenConfig);
185
+ }
186
+ catch (e) {
187
+ span.recordException(e);
188
+ Sentry.captureException(e);
189
+ testGenFailed = true;
190
+ new logger_1.CustomLogger().error(`Failed to generate test for the scenario. ${process.env.LOG_URL ? `[view log](${process.env.LOG_URL})` : ""}`, e?.message, e?.stack);
191
+ }
192
+ if (testGenConfig.options?.agent !== "code" &&
193
+ testGenConfig.options?.agent !== "plan" &&
194
+ testGenConfig.testCase.name) {
195
+ await new reporter_1.TestGenUpdatesReporter().reportGenAssets({
196
+ projectRepoName: testGenConfig.options.metadata.projectRepoName,
197
+ testName: testGenConfig.testCase.name,
198
+ });
199
+ }
200
+ // TODO: move these reporters to a better lifecycle
201
+ await (0, llm_1.flushAllTraces)();
202
+ await (0, logger_1.waitForLogsToFlush)();
203
+ await (0, session_1.endSession)();
204
+ span.end();
205
+ if (testGenFailed) {
206
+ process.exit(1);
207
+ }
208
+ else {
209
+ process.exit(0);
210
+ }
165
211
  });
166
- }
167
- // TODO: move these reporters to a better lifecycle
168
- await (0, llm_1.flushAllTraces)();
169
- await (0, logger_1.waitForLogsToFlush)();
170
- await (0, session_1.endSession)();
171
- if (testGenFailed) {
172
- process.exit(1);
173
- }
174
- else {
175
- process.exit(0);
176
- }
212
+ });
177
213
  })();
@@ -3,4 +3,6 @@ export declare function parseCliArgs(testGenToken?: string): Promise<{
3
3
  testGenConfig: TestGenConfig;
4
4
  }>;
5
5
  export declare function getTestConfigCliArg(): string;
6
+ export declare const sentryTrace: string | undefined;
7
+ export declare const baggage: string | undefined;
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAIhE,wBAAsB,YAAY,CAChC,YAAY,GAAE,MAA8B;;GAM7C;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAIhE,wBAAsB,YAAY,CAChC,YAAY,GAAE,MAA8B;;GAM7C;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED,eAAO,MAAM,WAAW,oBAA2B,CAAC;AACpD,eAAO,MAAM,OAAO,oBAA6B,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTestConfigCliArg = exports.parseCliArgs = void 0;
3
+ exports.baggage = exports.sentryTrace = exports.getTestConfigCliArg = exports.parseCliArgs = void 0;
4
4
  const scenarios_1 = require("./scenarios");
5
5
  async function parseCliArgs(testGenToken = getTestConfigCliArg()) {
6
6
  const testGenConfig = await (0, scenarios_1.loadTestConfigs)(testGenToken);
@@ -13,3 +13,5 @@ function getTestConfigCliArg() {
13
13
  return process.argv[2];
14
14
  }
15
15
  exports.getTestConfigCliArg = getTestConfigCliArg;
16
+ exports.sentryTrace = process.env.SENTRY_TRACE;
17
+ exports.baggage = process.env.SENTRY_BAGGAGE;
@@ -1 +1 @@
1
- {"version":3,"file":"add-scenario-agent.evals.d.ts","sourceRoot":"","sources":["../../src/evals/add-scenario-agent.evals.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAqCpC,QAAA,MAAM,4BAA4B,EAAE,UAqBnC,CAAC;AAEF,eAAe,4BAA4B,CAAC"}
1
+ {"version":3,"file":"add-scenario-agent.evals.d.ts","sourceRoot":"","sources":["../../src/evals/add-scenario-agent.evals.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AA2BpC,QAAA,MAAM,4BAA4B,EAAE,UAsBnC,CAAC;AAEF,eAAe,4BAA4B,CAAC"}
@@ -4,8 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const path_1 = __importDefault(require("path"));
7
- const repo_edit_1 = require("../agent/codegen/repo-edit");
8
- const utils_1 = require("../agent/codegen/utils");
7
+ const run_1 = require("../agent/codegen/run");
9
8
  function evaluateEqualityScore({ currentOutput, expectedOutput, }) {
10
9
  for (const expectedFile of expectedOutput) {
11
10
  if (!currentOutput.find((output) => {
@@ -23,8 +22,9 @@ function evaluateEqualityScore({ currentOutput, expectedOutput, }) {
23
22
  const addScenarioCodeAgentEvaluate = async ({ item, trace }) => {
24
23
  const { testCase, testFilePath, pageFiles, testFiles } = item.input;
25
24
  const repoFiles = pageFiles + testFiles;
26
- const repoAgentOutput = await (0, repo_edit_1.generateCodeUsingRepoAgent)({
27
- task: (0, utils_1.getTaskForCreateTest)({ testCase, file: testFilePath }),
25
+ const repoAgentOutput = await (0, run_1.createTestWithCodeAgent)({
26
+ testCase,
27
+ file: testFilePath,
28
28
  trace,
29
29
  repoFiles,
30
30
  });
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import "./initSentry";
1
2
  import { Page } from "playwright";
2
3
  import { ScopeVars } from "./types";
3
4
  export declare function createTest(task: string, page: Page, scope?: ScopeVars): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAOlC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAQpC,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,SAAS,iBAuC3E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAItB,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAOlC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAapC,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,SAAS,iBAuC3E"}
package/dist/index.js CHANGED
@@ -1,20 +1,49 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  exports.createTest = void 0;
30
+ require("./initSentry");
7
31
  const llm_1 = require("@empiricalrun/llm");
32
+ const Sentry = __importStar(require("@sentry/node"));
8
33
  const run_1 = require("./agent/master/run");
9
34
  const utils_1 = require("./bin/utils");
10
35
  const client_1 = __importDefault(require("./file/client"));
11
36
  const reporter_1 = require("./reporter");
12
37
  const session_1 = require("./session");
13
38
  const pw_test_1 = require("./utils/pw-test");
14
- process.on("beforeExit", async () => await (0, llm_1.flushAllTraces)());
15
- process.on("exit", async () => await (0, llm_1.flushAllTraces)());
16
- process.on("SIGINT", async () => await (0, llm_1.flushAllTraces)());
17
- process.on("SIGTERM", async () => await (0, llm_1.flushAllTraces)());
39
+ const flushEvents = async () => {
40
+ await (0, llm_1.flushAllTraces)();
41
+ await Sentry.flush();
42
+ };
43
+ process.on("beforeExit", async () => await flushEvents());
44
+ process.on("exit", async () => await flushEvents());
45
+ process.on("SIGINT", async () => await flushEvents());
46
+ process.on("SIGTERM", async () => await flushEvents());
18
47
  async function createTest(task, page, scope) {
19
48
  const port = process.env.APP_PORT || 3030;
20
49
  const testConfigArg = process.env.TEST_GEN_TOKEN;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=initSentry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initSentry.d.ts","sourceRoot":"","sources":["../src/initSentry.ts"],"names":[],"mappings":""}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const Sentry = __importStar(require("@sentry/node"));
27
+ Sentry.init({
28
+ enabled: process.env.NODE_ENV !== "development",
29
+ dsn: "https://87e61b11ede1431d7156bcd26da997cc@o4506822020235264.ingest.us.sentry.io/4508806031015936",
30
+ tracesSampleRate: 1.0,
31
+ serverName: "test-gen",
32
+ debug: process.env.NODE_ENV === "development",
33
+ integrations: [Sentry.consoleIntegration(), Sentry.httpIntegration()],
34
+ clientReportFlushInterval: 2000,
35
+ shutdownTimeout: 5000,
36
+ enableTracing: true,
37
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-build/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAUnD;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAY/D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-build/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAWnD;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAa/D"}
@@ -1,9 +1,33 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  exports.downloadBuild = void 0;
30
+ const Sentry = __importStar(require("@sentry/node"));
7
31
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
32
  const logger_1 = require("../bin/logger");
9
33
  const exec_1 = require("../utils/exec");
@@ -24,6 +48,7 @@ async function downloadBuild(build) {
24
48
  logger.log(`Downloading build from ${build.url}`);
25
49
  await (0, exec_1.cmd)(`npm run download ${build.url}`.split(" "), {
26
50
  env: { ...Object(process.env) },
51
+ span: Sentry.getActiveSpan(),
27
52
  });
28
53
  }
29
54
  }
@@ -1,4 +1,6 @@
1
+ import * as Sentry from "@sentry/node";
1
2
  export declare function cmd(command: string[], options: {
2
3
  env?: Record<string, string>;
4
+ span?: Sentry.Span;
3
5
  }): Promise<number>;
4
6
  //# sourceMappingURL=exec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/utils/exec.ts"],"names":[],"mappings":"AAGA,wBAAgB,GAAG,CACjB,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GACxC,OAAO,CAAC,MAAM,CAAC,CA2BjB"}
1
+ {"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/utils/exec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AAMvC,wBAAsB,GAAG,CACvB,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAA;CAAE,GAC5D,OAAO,CAAC,MAAM,CAAC,CA+CjB"}