@empiricalrun/playwright-utils 0.49.0 → 0.50.1

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,27 @@
1
1
  # @empiricalrun/playwright-utils
2
2
 
3
+ ## 0.50.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 8b1be9e: fix: html report attachment urls for pw 1.60.0
8
+ - Updated dependencies [8b1be9e]
9
+ - @empiricalrun/reporter@0.29.1
10
+
11
+ ## 0.50.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 76d0872: chore: remove older LLM clients
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [76d0872]
20
+ - @empiricalrun/llm@0.27.0
21
+ - @empiricalrun/cua@0.4.1
22
+ - @empiricalrun/dashboard-client@0.3.0
23
+ - @empiricalrun/reporter@0.29.0
24
+
3
25
  ## 0.49.0
4
26
 
5
27
  ### Minor Changes
@@ -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;AA0BnC,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;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AO,CAAC,CAO7E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,6CA+BlB"}
@@ -173,12 +173,10 @@ async function updateHtmlZipFileAttachmentPaths(jsonFilePath, htmlFilePath, repo
173
173
  console.error(`❌ Failed to read HTML file at ${htmlFilePath}:`, err);
174
174
  return;
175
175
  }
176
- // Support both old format (1.53.x) and new format (1.57.0+)
176
+ // Support the global assignment, script tag, and Playwright 1.60 template tag.
177
177
  // Old: window.playwrightReportBase64 = "data:application/zip;base64,..."
178
- // New: <script id="playwrightReportBase64" type="application/zip">data:application/zip;base64,...</script>
179
- const oldFormatMatch = htmlFile.match(/window\.playwrightReportBase64\s*=\s*"(?:data:application\/zip;base64,)?([^"]+)"/);
180
- const newFormatMatch = htmlFile.match(/<script\s+id="playwrightReportBase64"[^>]*>(?:data:application\/zip;base64,)?([^<]+)<\/script>/);
181
- const base64 = oldFormatMatch?.[1] || newFormatMatch?.[1];
178
+ // Newer: <script|template id="playwrightReportBase64">data:application/zip;base64,...</script|template>
179
+ const base64 = (0, reporter_1.findPlaywrightReportBase64)(htmlFile);
182
180
  if (!base64) {
183
181
  console.error("❌ Base64 zip data not found in HTML.");
184
182
  return;
@@ -214,15 +212,7 @@ async function updateHtmlZipFileAttachmentPaths(jsonFilePath, htmlFilePath, repo
214
212
  }
215
213
  const newBuffer = await (0, zip_1.createZipFromDirectory)(tempDir);
216
214
  const newBase64 = newBuffer.toString("base64");
217
- let updatedHtml;
218
- if (oldFormatMatch) {
219
- // Old format (1.53.x): window.playwrightReportBase64 = "..."
220
- updatedHtml = htmlFile.replace(/(window\.playwrightReportBase64\s*=\s*")(?:data:application\/zip;base64,)?[^"]*(")/, `$1data:application/zip;base64,${newBase64}$2`);
221
- }
222
- else {
223
- // New format (1.57.0+): <script id="playwrightReportBase64" ...>...</script>
224
- updatedHtml = htmlFile.replace(/(<script\s+id="playwrightReportBase64"[^>]*>)(?:data:application\/zip;base64,)?[^<]*(<\/script>)/, `$1data:application/zip;base64,${newBase64}$2`);
225
- }
215
+ const updatedHtml = (0, reporter_1.replacePlaywrightReportBase64)(htmlFile, newBase64);
226
216
  await fs_1.default.promises.writeFile(htmlFilePath, updatedHtml, "utf8");
227
217
  logger_1.logger.debug("✅ HTML file updated with new base64 zip attachment.");
228
218
  }
@@ -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,yBAAyB,CAAC,IAAI,EAAE;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBhB;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC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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.49.0",
3
+ "version": "0.50.1",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -27,29 +27,30 @@
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
- "@types/mime": "3.0.0",
33
+ "@types/serve-handler": "^6.1.4",
34
34
  "playwright-core": "1.60.0",
35
35
  "serve-handler": "^6.1.6",
36
- "@empiricalrun/shared-types": "0.13.0"
36
+ "@empiricalrun/shared-types": "0.14.0"
37
37
  },
38
38
  "dependencies": {
39
39
  "@babel/code-frame": "^7.24.7",
40
- "pg": "^8.13.1",
41
40
  "async-retry": "^1.3.3",
42
41
  "authenticator": "^1.1.5",
43
42
  "console-log-level": "^1.4.1",
43
+ "mime": "3.0.0",
44
+ "openai": "^6.27.0",
45
+ "pg": "^8.13.1",
44
46
  "puppeteer-extra-plugin-recaptcha": "^3.6.8",
45
47
  "rimraf": "^6.0.1",
46
48
  "ts-morph": "^23.0.0",
47
- "mime": "3.0.0",
48
- "@empiricalrun/cua": "^0.4.0",
49
+ "@empiricalrun/cua": "^0.4.1",
49
50
  "@empiricalrun/dashboard-client": "^0.3.0",
50
- "@empiricalrun/llm": "^0.26.0",
51
+ "@empiricalrun/llm": "^0.27.0",
51
52
  "@empiricalrun/r2-uploader": "^0.9.1",
52
- "@empiricalrun/reporter": "^0.29.0"
53
+ "@empiricalrun/reporter": "^0.29.1"
53
54
  },
54
55
  "scripts": {
55
56
  "dev": "tsc --build --watch",