@empiricalrun/playwright-utils 0.58.5 → 0.59.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,30 @@
1
1
  # @empiricalrun/playwright-utils
2
2
 
3
+ ## 0.59.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 17d8ac5: feat: report Playwright default-mode groups for scheduling
8
+
9
+ ### Patch Changes
10
+
11
+ - @empiricalrun/cua@0.4.2
12
+ - @empiricalrun/llm@0.27.1
13
+ - @empiricalrun/reporter@0.30.0
14
+
15
+ ## 0.58.6
16
+
17
+ ### Patch Changes
18
+
19
+ - bcf5ed7: chore: drop fallbacks for LLM proxy
20
+ - 68091d9: feat: route LLM calls via api-worker proxy for usage attribution
21
+ - Updated dependencies [bcf5ed7]
22
+ - Updated dependencies [68091d9]
23
+ - Updated dependencies [ed03fc8]
24
+ - @empiricalrun/llm@0.27.1
25
+ - @empiricalrun/cua@0.4.2
26
+ - @empiricalrun/reporter@0.30.0
27
+
3
28
  ## 0.58.5
4
29
 
5
30
  ### Patch Changes
@@ -9,6 +9,23 @@ export type TwoCaptchaProxyResponse = components["schemas"]["TwoCaptchaProxyResp
9
9
  export type ProjectKvGetResponse = components["schemas"]["ProjectKvGetResponse"];
10
10
  export type ProjectKvSetRequest = NonNullable<paths["/api/projects/kv"]["post"]["requestBody"]>["content"]["application/json"];
11
11
  export type ProjectKvSetResponse = components["schemas"]["ProjectKvSetResponse"];
12
+ /**
13
+ * OpenAI client config for the LLM calls playwright-utils makes from inside a
14
+ * test run — the overlay-dismissal browser agent and the toLookRight visual
15
+ * assertion. Both go through api-worker's proxy, which holds the provider key
16
+ * and forwards via the Cloudflare AI Gateway; the run worker puts
17
+ * EMPIRICALRUN_API_KEY and DASHBOARD_DOMAIN in the Playwright child process.
18
+ *
19
+ * There is deliberately no fallback to a direct OPENAI_API_KEY. A fallback
20
+ * makes the transport depend on ambient env, which hides a broken proxy behind
21
+ * a working direct call and lets a test that clears one credential still reach
22
+ * the model. Returns undefined only for a pi sandbox, whose OPENAI_BASE_URL
23
+ * already points at the sidecar's own keyless proxy route.
24
+ */
25
+ export declare function llmProxyOpenAIConfig(): {
26
+ baseURL: string;
27
+ apiKey: string;
28
+ } | undefined;
12
29
  export declare class HTTPError extends Error {
13
30
  status: number;
14
31
  constructor(message: string, status: number);
@@ -1 +1 @@
1
- {"version":3,"file":"api-worker-client.d.ts","sourceRoot":"","sources":["../src/api-worker-client.ts"],"names":[],"mappings":"AACA,OAAqB,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAExE,KAAK,mBAAmB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AAEzC,KAAK,iBAAiB,GAClB,kBAAkB,GAClB,sBAAsB,GACtB,yBAAyB,CAAC;AAE9B,MAAM,MAAM,oBAAoB,GAC9B,UAAU,CAAC,SAAS,CAAC,CAAC,6BAA6B,CAAC,CAAC;AACvD,MAAM,MAAM,qBAAqB,GAC/B,UAAU,CAAC,SAAS,CAAC,CAAC,8BAA8B,CAAC,CAAC;AACxD,MAAM,MAAM,sBAAsB,GAChC,UAAU,CAAC,SAAS,CAAC,CAAC,wBAAwB,CAAC,CAAC;AAClD,MAAM,MAAM,uBAAuB,GACjC,UAAU,CAAC,SAAS,CAAC,CAAC,yBAAyB,CAAC,CAAC;AACnD,MAAM,MAAM,oBAAoB,GAC9B,UAAU,CAAC,SAAS,CAAC,CAAC,sBAAsB,CAAC,CAAC;AAChD,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAC3C,KAAK,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CACjD,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC;AACjC,MAAM,MAAM,oBAAoB,GAC9B,UAAU,CAAC,SAAS,CAAC,CA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C;QACvB,OAAO,CAAC,EAAE,MAAM,CAAC;KACb,EAgBL;IAED,UAAU,IAAI,MAAM,CAEnB;IAEK,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAK7D;IAEK,YAAY,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAK3E;IAEK,iBAAiB,CACrB,IAAI,EAAE,iBAAiB,EACvB,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,qBAAqB,CAAC,CAKhC;IAED,MAAM,CAAC,CAAC,EACN,MAAM,EAAE;QACN,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,QAAQ,EAAE,QAAQ,CAAC;KACpB,EACD,KAAK,EAAE,MAAM,GACZ,CAAC,CAUH;CACF"}
@@ -4,8 +4,41 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ApiWorkerClient = exports.RetryableHTTPError = exports.NonRetryableHTTPError = exports.HTTPError = void 0;
7
+ exports.llmProxyOpenAIConfig = llmProxyOpenAIConfig;
7
8
  const async_retry_1 = __importDefault(require("async-retry"));
8
9
  const openapi_fetch_1 = __importDefault(require("openapi-fetch"));
10
+ const DEFAULT_API_WORKER_URL = "https://api.empirical.run";
11
+ function apiWorkerBaseUrl() {
12
+ return process.env.DASHBOARD_DOMAIN || DEFAULT_API_WORKER_URL;
13
+ }
14
+ /**
15
+ * OpenAI client config for the LLM calls playwright-utils makes from inside a
16
+ * test run — the overlay-dismissal browser agent and the toLookRight visual
17
+ * assertion. Both go through api-worker's proxy, which holds the provider key
18
+ * and forwards via the Cloudflare AI Gateway; the run worker puts
19
+ * EMPIRICALRUN_API_KEY and DASHBOARD_DOMAIN in the Playwright child process.
20
+ *
21
+ * There is deliberately no fallback to a direct OPENAI_API_KEY. A fallback
22
+ * makes the transport depend on ambient env, which hides a broken proxy behind
23
+ * a working direct call and lets a test that clears one credential still reach
24
+ * the model. Returns undefined only for a pi sandbox, whose OPENAI_BASE_URL
25
+ * already points at the sidecar's own keyless proxy route.
26
+ */
27
+ function llmProxyOpenAIConfig() {
28
+ if (process.env.OPENAI_BASE_URL) {
29
+ return undefined;
30
+ }
31
+ const apiKey = process.env.EMPIRICALRUN_API_KEY;
32
+ if (!apiKey) {
33
+ throw new Error("EMPIRICALRUN_API_KEY is required to reach Empirical's LLM proxy. Set it, " +
34
+ "or point OPENAI_BASE_URL at a proxy of your own — playwright-utils no " +
35
+ "longer calls OpenAI directly with OPENAI_API_KEY.");
36
+ }
37
+ return {
38
+ baseURL: `${apiWorkerBaseUrl()}/api/llm/openai/v1`,
39
+ apiKey,
40
+ };
41
+ }
9
42
  class HTTPError extends Error {
10
43
  status;
11
44
  constructor(message, status) {
@@ -63,8 +96,7 @@ class ApiWorkerClient {
63
96
  baseUrl;
64
97
  client;
65
98
  constructor({ projectApiKey, baseUrl, } = {}) {
66
- this.baseUrl =
67
- baseUrl || process.env.DASHBOARD_DOMAIN || "https://api.empirical.run";
99
+ this.baseUrl = baseUrl || apiWorkerBaseUrl();
68
100
  const apiKey = projectApiKey || process.env.EMPIRICALRUN_API_KEY;
69
101
  if (!apiKey) {
70
102
  throw new Error("EMPIRICALRUN_API_KEY environment variable is required");