@empiricalrun/test-gen 0.42.27 → 0.42.29

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.42.29
4
+
5
+ ### Patch Changes
6
+
7
+ - f39500b: fix: removed explicit delays from master agent
8
+
9
+ ## 0.42.28
10
+
11
+ ### Patch Changes
12
+
13
+ - df9f428: feat: add distributed tracing for ci-service, ci-worker, test-gen and test-run
14
+
3
15
  ## 0.42.27
4
16
 
5
17
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../src/actions/click.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrD,eAAO,MAAM,4BAA4B,kBAAkB,CAAC;AAE5D,eAAO,MAAM,oBAAoB,EAAE,yBAuDlC,CAAC"}
1
+ {"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../src/actions/click.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrD,eAAO,MAAM,4BAA4B,kBAAkB,CAAC;AAE5D,eAAO,MAAM,oBAAoB,EAAE,yBAsDlC,CAAC"}
@@ -11,7 +11,6 @@ const clickActionGenerator = (page) => {
11
11
  const locator = await (0, utils_1.getPlaywrightLocatorUsingCssSelector)(selector, args.xpath, page.pwPageInstance, args?.elementAnnotation);
12
12
  const exec = new Function("page", `return page.${locator}.click({ timeout: 3000 })`);
13
13
  await exec(page.pwPageInstance);
14
- await page.pwPageInstance.waitForTimeout(3000);
15
14
  return {
16
15
  locator,
17
16
  };
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"AAmBA,KAAK,iBAAiB,GAAG;IACvB;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAsB,6BAA6B,CAAC,EAClD,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,GACjB,EAAE,iBAAiB,iBA6EnB"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"AAoBA,KAAK,iBAAiB,GAAG;IACvB;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAsB,6BAA6B,CAAC,EAClD,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,GACjB,EAAE,iBAAiB,iBA8EnB"}
@@ -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.generateTestsUsingMasterAgent = void 0;
30
+ const Sentry = __importStar(require("@sentry/node"));
7
31
  const detect_port_1 = __importDefault(require("detect-port"));
8
32
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
33
  const utils_1 = require("../../bin/utils");
@@ -57,6 +81,7 @@ async function generateTestsUsingMasterAgent({ testFilePath, filePathToUpdate, p
57
81
  PAGE_VAR_NAME: pageVar || "page",
58
82
  DISPLAY: ":99",
59
83
  },
84
+ span: Sentry.getActiveSpan(),
60
85
  });
61
86
  }
62
87
  catch (e) {
@@ -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,IAAI,EAAE,MAAM,YAAY,CAAC;AAQlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AA0DjD,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;AAEF,wBAAsB,iBAAiB,CAAC,EACtC,IAAI,EACJ,UAAU,EACV,OAAO,GACR,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE,oBAAoB,CAAC;IACjC,OAAO,EAAE,oBAAoB,CAAC;CAC/B,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,CAqDD"}
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,IAAI,EAAE,MAAM,YAAY,CAAC;AAQlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AA0DjD,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;AAEF,wBAAsB,iBAAiB,CAAC,EACtC,IAAI,EACJ,UAAU,EACV,OAAO,GACR,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE,oBAAoB,CAAC;IACjC,OAAO,EAAE,oBAAoB,CAAC;CAC/B,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,CAoDD"}
@@ -120,7 +120,6 @@ async function getAnnotationKeys({ page, preference, options, }) {
120
120
  }));
121
121
  return annotations;
122
122
  }, { preference, options });
123
- await page.waitForTimeout(2000);
124
123
  const annotationBuffer = await page.screenshot({
125
124
  // path: `screenshots/screenshot-${screenshotIndex++}.png`,
126
125
  });
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/master/run.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAclC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,oBAAoB,EAErB,MAAM,aAAa,CAAC;AA6BrB,wBAAsB,0BAA0B,CAAC,EAC/C,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;;;GA0WA"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/master/run.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAclC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,oBAAoB,EAErB,MAAM,aAAa,CAAC;AA6BrB,wBAAsB,0BAA0B,CAAC,EAC/C,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;;;GAsWA"}
@@ -37,8 +37,6 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
37
37
  const testgenUpdatesReporter = new reporter_1.TestGenUpdatesReporter();
38
38
  const session = (0, session_1.getSessionDetails)();
39
39
  const testGenPage = new page_1.TestGenPage(page, (0, utils_1.getPageVarName)());
40
- // add timeout for the page to settle in
41
- await page.waitForTimeout(3000);
42
40
  const trace = llm_1.langfuseInstance?.trace({
43
41
  name: "test-generator",
44
42
  id: crypto.randomUUID(),
@@ -182,7 +180,6 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
182
180
  let shouldTriggerHintsFlow;
183
181
  let hintsExecutionCompletion;
184
182
  let elementAnnotation;
185
- await page.waitForTimeout(2000);
186
183
  const actionType = toolCall.actionType;
187
184
  let preference = {
188
185
  actionType: "all",
@@ -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
  }
@@ -127,50 +157,57 @@ async function runAgent(testGenConfig) {
127
157
  }
128
158
  }
129
159
  (async function main() {
130
- // this is where test gen starts executing on giving the command from ci
131
- const logger = new logger_1.CustomLogger({ useReporter: false });
132
- if (process.argv.length < 3) {
133
- logger.error("Please provide path to scenarios using command:", "npx @empiricalrun/test-gen <TEST_GEN_TOKEN>");
134
- process.exit(1);
135
- }
136
- const { testGenConfig } = await (0, utils_2.parseCliArgs)();
137
- (0, reporter_1.setReporterConfig)({
138
- projectRepoName: testGenConfig.options?.metadata.projectRepoName,
139
- testSessionId: testGenConfig.options?.metadata.testSessionId,
140
- generationId: testGenConfig.options?.metadata.generationId,
141
- });
142
- (0, session_1.setSessionDetails)({
143
- sessionId: testGenConfig.options?.metadata.testSessionId,
144
- generationId: testGenConfig.options?.metadata.generationId,
145
- testCaseId: testGenConfig.testCase.id,
146
- projectRepoName: testGenConfig.options?.metadata.projectRepoName,
147
- });
148
- let testGenFailed = false;
149
- try {
150
- // download the build if it exists
151
- await (0, test_build_1.downloadBuild)(testGenConfig.build || {});
152
- await runAgent(testGenConfig);
153
- }
154
- catch (e) {
155
- testGenFailed = true;
156
- 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);
157
- }
158
- if (testGenConfig.options?.agent !== "code" &&
159
- testGenConfig.options?.agent !== "plan" &&
160
- testGenConfig.testCase.name) {
161
- await new reporter_1.TestGenUpdatesReporter().reportGenAssets({
162
- projectRepoName: testGenConfig.options.metadata.projectRepoName,
163
- 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
+ }
164
211
  });
165
- }
166
- // TODO: move these reporters to a better lifecycle
167
- await (0, llm_1.flushAllTraces)();
168
- await (0, logger_1.waitForLogsToFlush)();
169
- await (0, session_1.endSession)();
170
- if (testGenFailed) {
171
- process.exit(1);
172
- }
173
- else {
174
- process.exit(0);
175
- }
212
+ });
176
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;
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"}
@@ -1,37 +1,77 @@
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.cmd = void 0;
30
+ const Sentry = __importStar(require("@sentry/node"));
7
31
  const child_process_1 = require("child_process");
8
32
  const process_1 = __importDefault(require("process"));
9
- function cmd(command, options) {
10
- let errorLogs = [];
11
- return new Promise((resolveFunc, rejectFunc) => {
12
- let p = (0, child_process_1.spawn)(command[0], command.slice(1), {
13
- env: { ...process_1.default.env, ...options.env },
14
- });
15
- p.stdout.on("data", (x) => {
16
- const log = x.toString();
17
- if (log.includes("Error")) {
18
- errorLogs.push(log);
19
- }
20
- process_1.default.stdout.write(log);
21
- });
22
- p.stderr.on("data", (x) => {
23
- const log = x.toString();
24
- process_1.default.stderr.write(x.toString());
25
- errorLogs.push(log);
26
- });
27
- p.on("exit", (code) => {
28
- if (code != 0) {
29
- // assuming last log is the error message before exiting
30
- rejectFunc(errorLogs.slice(-3).join("\n"));
31
- }
32
- else {
33
- resolveFunc(code);
34
- }
33
+ const utils_1 = require("../bin/utils");
34
+ async function cmd(command, options) {
35
+ return Sentry.continueTrace({ sentryTrace: utils_1.sentryTrace, baggage: utils_1.baggage }, async () => {
36
+ return Sentry.startSpan({ name: "test-gen" }, async (span) => {
37
+ let errorLogs = [];
38
+ return new Promise((resolveFunc, rejectFunc) => {
39
+ if (!command[0]) {
40
+ rejectFunc(new Error("Command cannot be empty"));
41
+ return;
42
+ }
43
+ let p = (0, child_process_1.spawn)(command[0], command.slice(1), {
44
+ env: { ...process_1.default.env, ...options.env },
45
+ });
46
+ p.stdout.on("data", (x) => {
47
+ const log = x.toString();
48
+ if (log.includes("Error")) {
49
+ errorLogs.push(log);
50
+ }
51
+ process_1.default.stdout.write(log);
52
+ });
53
+ p.stderr.on("data", (x) => {
54
+ const log = x.toString();
55
+ process_1.default.stderr.write(log);
56
+ errorLogs.push(log);
57
+ });
58
+ p.on("error", async (err) => {
59
+ span?.recordException(err);
60
+ Sentry.captureException(err);
61
+ rejectFunc(err);
62
+ });
63
+ p.on("exit", async (code) => {
64
+ if (code !== 0) {
65
+ const errorMessage = errorLogs.slice(-3).join("\n");
66
+ span?.recordException(errorMessage);
67
+ Sentry.captureException(new Error(errorMessage));
68
+ rejectFunc(new Error(errorMessage));
69
+ }
70
+ else {
71
+ resolveFunc(code ?? 1);
72
+ }
73
+ });
74
+ });
35
75
  });
36
76
  });
37
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-gen",
3
- "version": "0.42.27",
3
+ "version": "0.42.29",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -47,6 +47,7 @@
47
47
  "dependencies": {
48
48
  "@actions/core": "^1.10.1",
49
49
  "@babel/parser": "^7.26.3",
50
+ "@sentry/node": "^8.54.0",
50
51
  "@types/sanitize-html": "^2.11.0",
51
52
  "commander": "^12.1.0",
52
53
  "detect-port": "^1.6.1",
@@ -72,8 +73,8 @@
72
73
  "tsx": "^4.16.2",
73
74
  "typescript": "^5.3.3",
74
75
  "@empiricalrun/reporter": "^0.23.1",
75
- "@empiricalrun/llm": "^0.9.34",
76
- "@empiricalrun/r2-uploader": "^0.3.8"
76
+ "@empiricalrun/r2-uploader": "^0.3.8",
77
+ "@empiricalrun/llm": "^0.9.34"
77
78
  },
78
79
  "devDependencies": {
79
80
  "@playwright/test": "1.47.1",