@empiricalrun/playwright-utils 0.48.6 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # @empiricalrun/playwright-utils
2
2
 
3
+ ## 0.50.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 76d0872: chore: remove older LLM clients
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [76d0872]
12
+ - @empiricalrun/llm@0.27.0
13
+ - @empiricalrun/cua@0.4.1
14
+ - @empiricalrun/dashboard-client@0.3.0
15
+ - @empiricalrun/reporter@0.29.0
16
+
17
+ ## 0.49.0
18
+
19
+ ### Minor Changes
20
+
21
+ - 6fb8170: feat: playwright utils upgraded to use new core
22
+ - aa78c40: fix: narrower request payloads to avoid body attachments hogging request size
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies [6fb8170]
27
+ - @empiricalrun/cua@0.4.0
28
+ - @empiricalrun/reporter@0.29.0
29
+ - @empiricalrun/dashboard-client@0.3.0
30
+ - @empiricalrun/llm@0.26.0
31
+
3
32
  ## 0.48.6
4
33
 
5
34
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"empirical-reporter.d.ts","sourceRoot":"","sources":["../../src/reporter/empirical-reporter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACX,MAAM,2BAA2B,CAAC;AAuBnC,cAAM,iBAAkB,YAAW,QAAQ;IACzC,OAAO,CAAC,kBAAkB,CAAyB;IACnD,OAAO,CAAC,oBAAoB,CAG1B;IACF,OAAO,CAAC,sBAAsB,CAAuB;IACrD,OAAO,CAAC,YAAY,CAAgD;IACpE,OAAO,CAAC,iBAAiB,CAAyC;IAClE,OAAO,CAAC,gBAAgB,CAAkC;IAC1D,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,kBAAkB,CAA2B;;IAMrD,OAAO,CAAC,6BAA6B,CAqCnC;IAEF,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU;IAwGtC,KAAK,CAAC,MAAM,EAAE,UAAU;IAmG9B,OAAO,CAAC,qBAAqB;YAkBf,gBAAgB;YAOhB,iBAAiB;CAmChC;AAED,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"empirical-reporter.d.ts","sourceRoot":"","sources":["../../src/reporter/empirical-reporter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACX,MAAM,2BAA2B,CAAC;AAuBnC,cAAM,iBAAkB,YAAW,QAAQ;IACzC,OAAO,CAAC,kBAAkB,CAAyB;IACnD,OAAO,CAAC,oBAAoB,CAG1B;IACF,OAAO,CAAC,sBAAsB,CAAuB;IACrD,OAAO,CAAC,YAAY,CAAgD;IACpE,OAAO,CAAC,iBAAiB,CAAyC;IAClE,OAAO,CAAC,gBAAgB,CAAkC;IAC1D,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,kBAAkB,CAA2B;;IAMrD,OAAO,CAAC,6BAA6B,CAqCnC;IAEF,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU;IA+HtC,KAAK,CAAC,MAAM,EAAE,UAAU;IAmG9B,OAAO,CAAC,qBAAqB;YAkBf,gBAAgB;YAOhB,iBAAiB;CAmChC;AAED,eAAe,iBAAiB,CAAC"}
@@ -109,9 +109,32 @@ class EmpiricalReporter {
109
109
  ? parseInt(process.env.SHARD_INDEX, 10)
110
110
  : undefined;
111
111
  const params = {
112
- test,
112
+ test: {
113
+ id: test.id,
114
+ title: test.title,
115
+ location: test.location,
116
+ expectedStatus: test.expectedStatus,
117
+ retries: test.retries,
118
+ },
113
119
  suites,
114
- result,
120
+ result: {
121
+ retry: result.retry,
122
+ status: result.status,
123
+ duration: result.duration,
124
+ startTime: result.startTime,
125
+ error: result.error
126
+ ? {
127
+ message: result.error.message,
128
+ stack: result.error.stack,
129
+ location: result.error.location,
130
+ }
131
+ : undefined,
132
+ errors: result.errors?.map((e) => ({
133
+ message: e.message,
134
+ stack: e.stack,
135
+ location: e.location,
136
+ })),
137
+ },
115
138
  projectName,
116
139
  attachments: successfulAttachments,
117
140
  runId: process.env.TEST_RUN_GITHUB_ACTION_ID,
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/reporter/util.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAMhE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,EACL,UAAU,IAAI,oBAAoB,EAElC,QAAQ,EACT,MAAM,2BAA2B,CAAC;AAmBnC,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAmB7D;AAED,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAAG,SAAS,UAMhC;AAED,wBAAsB,0BAA0B,CAC9C,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5E,OAAO,CAAC;IACT,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CAyCD;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,QAAQ;;;EAwBrD;AAED,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,qBAAqB,GAC5B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C,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5E,OAAO,CAAC;IACT,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CAyCD;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,QAAQ;;;EAwBrD;AAED,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAiDf;AAED,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,GAAG,EACR,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,GACnC,GAAG,CAIL;AAED,wBAAsB,gCAAgC,CACpD,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,iBAuGjB;AAED;;;;;;;;;;GAUG;AACH;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC/C,mBAAmB,EAAE,MAAM,EAC3B,QAAQ,EAAE,MAAM,EAChB,cAAc,GAAE,OAAe,GAC9B,iBAAiB,CAcnB;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO7E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,6CA+BlB"}
@@ -16,11 +16,25 @@ exports.updateSummaryJsonAttachmentPaths = updateSummaryJsonAttachmentPaths;
16
16
  const zip_1 = require("@empiricalrun/r2-uploader/zip");
17
17
  const reporter_1 = require("@empiricalrun/reporter");
18
18
  const async_retry_1 = __importDefault(require("async-retry"));
19
+ const crypto_1 = __importDefault(require("crypto"));
19
20
  const fs_1 = __importDefault(require("fs"));
21
+ const mime_1 = __importDefault(require("mime"));
20
22
  const path_1 = __importDefault(require("path"));
21
- const utils_1 = require("playwright-core/lib/utils");
22
- const utilsBundle_1 = require("playwright-core/lib/utilsBundle");
23
23
  const logger_1 = require("../logger");
24
+ // Mirrors https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/tools/cli-client/program.ts#L440
25
+ function calculateSha1(buffer) {
26
+ const hash = crypto_1.default.createHash("sha1");
27
+ hash.update(buffer);
28
+ return hash.digest("hex");
29
+ }
30
+ // Mirrors https://github.com/microsoft/playwright/blob/main/packages/isomorphic/stringUtils.ts#L37
31
+ function isString(obj) {
32
+ return typeof obj === "string" || obj instanceof String;
33
+ }
34
+ // Mirrors https://github.com/microsoft/playwright/blob/main/packages/utils/fileUtils.ts#L77
35
+ function sanitizeForFilePath(s) {
36
+ return s.replace(/[\x00-\x2C\x2E-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, "-");
37
+ }
24
38
  const folderToPackageJsonPath = new Map();
25
39
  function getPackageJsonPath(folderPath) {
26
40
  const cached = folderToPackageJsonPath.get(folderPath);
@@ -55,15 +69,15 @@ async function normalizeAndSaveAttachment(outputPath, name, options = {}) {
55
69
  1)
56
70
  throw new Error(`Exactly one of "path" and "body" must be specified`);
57
71
  if (options.path !== undefined) {
58
- const hash = (0, utils_1.calculateSha1)(options.path);
59
- if (!(0, utils_1.isString)(name))
72
+ const hash = calculateSha1(options.path);
73
+ if (!isString(name))
60
74
  throw new Error('"name" should be string.');
61
- const sanitizedNamePrefix = (0, utils_1.sanitizeForFilePath)(name) + "-";
75
+ const sanitizedNamePrefix = sanitizeForFilePath(name) + "-";
62
76
  const dest = path_1.default.join(outputPath, "attachments", sanitizedNamePrefix + hash + path_1.default.extname(options.path));
63
77
  await fs_1.default.promises.mkdir(path_1.default.dirname(dest), { recursive: true });
64
78
  await fs_1.default.promises.copyFile(options.path, dest);
65
79
  const contentType = options.contentType ??
66
- (utilsBundle_1.mime.getType(path_1.default.basename(options.path)) || "application/octet-stream");
80
+ (mime_1.default.getType(path_1.default.basename(options.path)) || "application/octet-stream");
67
81
  return { name, contentType, path: dest };
68
82
  }
69
83
  else {
@@ -108,16 +122,10 @@ function suitesAndProjectForTest(test) {
108
122
  async function sendTestCaseUpdateToDashboard(params) {
109
123
  const DOMAIN = process.env.DASHBOARD_DOMAIN || "https://dash.empirical.run";
110
124
  try {
111
- const keyFilter = (key) => key === "parent";
112
- const payload = {
113
- ...params,
114
- test: safelySerialiseJSON(params.test, keyFilter),
115
- result: safelySerialiseJSON(params.result, keyFilter),
116
- };
117
125
  const requestBody = {
118
126
  name: "test_case_run_end",
119
127
  data: {
120
- ...payload,
128
+ ...params,
121
129
  },
122
130
  };
123
131
  if (!DOMAIN) {
@@ -7,11 +7,6 @@ interface TrackReportUploadParams {
7
7
  sizeBytes: number;
8
8
  }
9
9
  export declare function trackReportUpload(params: TrackReportUploadParams): Promise<void>;
10
- export declare function trackLLMResponseGenerated(opts: {
11
- modelName: string;
12
- tokensInput: number;
13
- tokensOutput: number;
14
- }): Promise<void>;
15
10
  export declare function trackOverlayDismissed(opts: {
16
11
  original: string | undefined;
17
12
  description: string;
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAKtE,wBAAsB,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBrE;AAED,UAAU,uBAAuB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,IAAI,CAAC,CAcf;AAED,wBAAsB,yBAA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M,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBhB"}
package/dist/telemetry.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.trackEvent = trackEvent;
4
4
  exports.trackReportUpload = trackReportUpload;
5
- exports.trackLLMResponseGenerated = trackLLMResponseGenerated;
6
5
  exports.trackOverlayDismissed = trackOverlayDismissed;
7
6
  const TELEMETRY_WORKER_URL = "https://telemetry-worker.empirical-run.workers.dev";
8
7
  async function trackEvent(event) {
@@ -42,26 +41,6 @@ async function trackReportUpload(params) {
42
41
  },
43
42
  });
44
43
  }
45
- async function trackLLMResponseGenerated(opts) {
46
- const environment = process.env.TEST_RUN_ENVIRONMENT || "unknown";
47
- await trackEvent({
48
- name: "llm_response_generated",
49
- properties: {
50
- environment,
51
- model_name: opts.modelName,
52
- chat_session_id: undefined,
53
- chat_session_source: "to_look_right",
54
- tokens_input: opts.tokensInput,
55
- tokens_output: opts.tokensOutput,
56
- cost_input: 0,
57
- cost_output: 0,
58
- tokens_cache_read: 0,
59
- tokens_cache_creation: 0,
60
- project_repo_name: process.env.GIT_REPO_NAME ?? "unknown",
61
- repo_name: process.env.GIT_REPO_NAME ?? "unknown",
62
- },
63
- });
64
- }
65
44
  async function trackOverlayDismissed(opts) {
66
45
  const environment = process.env.TEST_RUN_ENVIRONMENT || "unknown";
67
46
  await trackEvent({
@@ -1 +1 @@
1
- {"version":3,"file":"visual.d.ts","sourceRoot":"","sources":["../../../src/test/expect/visual.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAY,MAAM,kBAAkB,CAAC;AAUhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAsE7C,wBAAsB,WAAW,CAC/B,MAAM,EAAE,IAAI,GAAG,OAAO,EACtB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,aAAa,CAAC,CA2FxB"}
1
+ {"version":3,"file":"visual.d.ts","sourceRoot":"","sources":["../../../src/test/expect/visual.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAY,MAAM,kBAAkB,CAAC;AAShE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAsE7C,wBAAsB,WAAW,CAC/B,MAAM,EAAE,IAAI,GAAG,OAAO,EACtB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,aAAa,CAAC,CAyFxB"}
@@ -7,9 +7,9 @@ exports.toLookRight = toLookRight;
7
7
  const llm_1 = require("@empiricalrun/llm");
8
8
  const vision_1 = require("@empiricalrun/llm/vision");
9
9
  const fs_1 = __importDefault(require("fs"));
10
+ const openai_1 = __importDefault(require("openai"));
10
11
  const os_1 = __importDefault(require("os"));
11
12
  const path_1 = __importDefault(require("path"));
12
- const telemetry_1 = require("../../telemetry");
13
13
  const mouse_pointer_1 = require("../scripts/mouse-pointer");
14
14
  function getCallerLine() {
15
15
  const stack = new Error().stack;
@@ -83,11 +83,9 @@ async function toLookRight(target, pageDescription) {
83
83
  const base64Image = screenshot.toString("base64");
84
84
  await (0, mouse_pointer_1.addHighlighterScriptsToPage)(page);
85
85
  const model = "gpt-4o";
86
- const llm = new llm_1.LLM({
87
- provider: "openai",
88
- defaultModel: model,
89
- });
90
- const response = await llm.createChatCompletion({
86
+ const openai = new openai_1.default({ maxRetries: 5 });
87
+ const completion = await openai.chat.completions.create({
88
+ model,
91
89
  messages: [
92
90
  {
93
91
  role: "system",
@@ -109,12 +107,10 @@ async function toLookRight(target, pageDescription) {
109
107
  ],
110
108
  },
111
109
  ],
112
- modelParameters: {
113
- temperature: 0.1,
114
- tool_choice: {
115
- type: "function",
116
- function: { name: "send_response" },
117
- },
110
+ temperature: 0.1,
111
+ tool_choice: {
112
+ type: "function",
113
+ function: { name: "send_response" },
118
114
  },
119
115
  tools: [
120
116
  {
@@ -143,10 +139,12 @@ go through the reasons and pick the one that made you choose Fail`,
143
139
  },
144
140
  ],
145
141
  });
146
- (0, telemetry_1.trackLLMResponseGenerated)({
142
+ const response = completion.choices[0]?.message;
143
+ (0, llm_1.trackLLMResponseGenerated)({
147
144
  modelName: model,
148
- tokensInput: llm.promptTokens,
149
- tokensOutput: llm.completionTokens,
145
+ tokensInput: completion.usage?.prompt_tokens ?? 0,
146
+ tokensOutput: completion.usage?.completion_tokens ?? 0,
147
+ chatSessionSource: "to_look_right",
150
148
  });
151
149
  const rawResponse = response.tool_calls[0];
152
150
  if (!("function" in rawResponse)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/playwright-utils",
3
- "version": "0.48.6",
3
+ "version": "0.50.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -22,32 +22,35 @@
22
22
  },
23
23
  "author": "Empirical Team <hey@empirical.run>",
24
24
  "devDependencies": {
25
- "@playwright/test": "1.58.2",
25
+ "@playwright/test": "1.60.0",
26
26
  "@types/async-retry": "^1.4.8",
27
27
  "@types/authenticator": "^1.1.4",
28
28
  "@types/babel__code-frame": "^7.0.6",
29
29
  "@types/console-log-level": "^1.4.5",
30
+ "@types/mime": "3.0.0",
30
31
  "@types/node": "^20.14.9",
31
- "@types/serve-handler": "^6.1.4",
32
32
  "@types/pg": "^8.11.6",
33
- "playwright-core": "1.58.2",
33
+ "@types/serve-handler": "^6.1.4",
34
+ "playwright-core": "1.60.0",
34
35
  "serve-handler": "^6.1.6",
35
- "@empiricalrun/shared-types": "0.12.1"
36
+ "@empiricalrun/shared-types": "0.14.0"
36
37
  },
37
38
  "dependencies": {
38
39
  "@babel/code-frame": "^7.24.7",
39
- "pg": "^8.13.1",
40
40
  "async-retry": "^1.3.3",
41
41
  "authenticator": "^1.1.5",
42
42
  "console-log-level": "^1.4.1",
43
+ "mime": "3.0.0",
44
+ "openai": "^6.27.0",
45
+ "pg": "^8.13.1",
43
46
  "puppeteer-extra-plugin-recaptcha": "^3.6.8",
44
47
  "rimraf": "^6.0.1",
45
48
  "ts-morph": "^23.0.0",
46
- "@empiricalrun/cua": "^0.3.0",
49
+ "@empiricalrun/cua": "^0.4.1",
47
50
  "@empiricalrun/dashboard-client": "^0.3.0",
48
- "@empiricalrun/llm": "^0.26.0",
51
+ "@empiricalrun/llm": "^0.27.0",
49
52
  "@empiricalrun/r2-uploader": "^0.9.1",
50
- "@empiricalrun/reporter": "^0.28.1"
53
+ "@empiricalrun/reporter": "^0.29.0"
51
54
  },
52
55
  "scripts": {
53
56
  "dev": "tsc --build --watch",