@onkernel/sdk 0.119.0 → 0.121.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.
Files changed (123) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/client.d.mts +2 -2
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +2 -2
  5. package/client.d.ts.map +1 -1
  6. package/client.js.map +1 -1
  7. package/client.mjs.map +1 -1
  8. package/package.json +1 -1
  9. package/resources/auth/connections.d.mts +1 -1
  10. package/resources/auth/connections.d.mts.map +1 -1
  11. package/resources/auth/connections.d.ts +1 -1
  12. package/resources/auth/connections.d.ts.map +1 -1
  13. package/resources/browser-pools.d.mts +4 -4
  14. package/resources/browser-pools.d.mts.map +1 -1
  15. package/resources/browser-pools.d.ts +4 -4
  16. package/resources/browser-pools.d.ts.map +1 -1
  17. package/resources/browsers/browsers.d.mts +59 -11
  18. package/resources/browsers/browsers.d.mts.map +1 -1
  19. package/resources/browsers/browsers.d.ts +59 -11
  20. package/resources/browsers/browsers.d.ts.map +1 -1
  21. package/resources/browsers/browsers.js +2 -2
  22. package/resources/browsers/browsers.js.map +1 -1
  23. package/resources/browsers/browsers.mjs +2 -2
  24. package/resources/browsers/browsers.mjs.map +1 -1
  25. package/resources/browsers/index.d.mts +2 -2
  26. package/resources/browsers/index.d.mts.map +1 -1
  27. package/resources/browsers/index.d.ts +2 -2
  28. package/resources/browsers/index.d.ts.map +1 -1
  29. package/resources/browsers/index.js +4 -4
  30. package/resources/browsers/index.js.map +1 -1
  31. package/resources/browsers/index.mjs +1 -1
  32. package/resources/browsers/index.mjs.map +1 -1
  33. package/resources/browsers/playwright/executors.d.mts +95 -0
  34. package/resources/browsers/playwright/executors.d.mts.map +1 -0
  35. package/resources/browsers/playwright/executors.d.ts +95 -0
  36. package/resources/browsers/playwright/executors.d.ts.map +1 -0
  37. package/resources/browsers/playwright/executors.js +57 -0
  38. package/resources/browsers/playwright/executors.js.map +1 -0
  39. package/resources/browsers/playwright/executors.mjs +53 -0
  40. package/resources/browsers/playwright/executors.mjs.map +1 -0
  41. package/resources/browsers/playwright/index.d.mts +3 -0
  42. package/resources/browsers/playwright/index.d.mts.map +1 -0
  43. package/resources/browsers/playwright/index.d.ts +3 -0
  44. package/resources/browsers/playwright/index.d.ts.map +1 -0
  45. package/resources/browsers/playwright/index.js +9 -0
  46. package/resources/browsers/playwright/index.js.map +1 -0
  47. package/resources/browsers/playwright/index.mjs +4 -0
  48. package/resources/browsers/playwright/index.mjs.map +1 -0
  49. package/resources/browsers/playwright/playwright.d.mts +149 -0
  50. package/resources/browsers/playwright/playwright.d.mts.map +1 -0
  51. package/resources/browsers/playwright/playwright.d.ts +149 -0
  52. package/resources/browsers/playwright/playwright.d.ts.map +1 -0
  53. package/resources/browsers/playwright/playwright.js +76 -0
  54. package/resources/browsers/playwright/playwright.js.map +1 -0
  55. package/resources/browsers/playwright/playwright.mjs +71 -0
  56. package/resources/browsers/playwright/playwright.mjs.map +1 -0
  57. package/resources/browsers/playwright.d.mts +1 -68
  58. package/resources/browsers/playwright.d.mts.map +1 -1
  59. package/resources/browsers/playwright.d.ts +1 -68
  60. package/resources/browsers/playwright.d.ts.map +1 -1
  61. package/resources/browsers/playwright.js +2 -29
  62. package/resources/browsers/playwright.js.map +1 -1
  63. package/resources/browsers/playwright.mjs +1 -27
  64. package/resources/browsers/playwright.mjs.map +1 -1
  65. package/resources/browsers/telemetry.d.mts +17 -15
  66. package/resources/browsers/telemetry.d.mts.map +1 -1
  67. package/resources/browsers/telemetry.d.ts +17 -15
  68. package/resources/browsers/telemetry.d.ts.map +1 -1
  69. package/resources/config-registry/config-registry.d.mts +3 -16
  70. package/resources/config-registry/config-registry.d.mts.map +1 -1
  71. package/resources/config-registry/config-registry.d.ts +3 -16
  72. package/resources/config-registry/config-registry.d.ts.map +1 -1
  73. package/resources/config-registry/config-registry.js.map +1 -1
  74. package/resources/config-registry/config-registry.mjs.map +1 -1
  75. package/resources/index.d.mts +1 -1
  76. package/resources/index.d.mts.map +1 -1
  77. package/resources/index.d.ts +1 -1
  78. package/resources/index.d.ts.map +1 -1
  79. package/resources/index.js.map +1 -1
  80. package/resources/index.mjs.map +1 -1
  81. package/resources/invocations.d.mts +1 -1
  82. package/resources/invocations.d.mts.map +1 -1
  83. package/resources/invocations.d.ts +1 -1
  84. package/resources/invocations.d.ts.map +1 -1
  85. package/resources/proxies.d.mts +33 -113
  86. package/resources/proxies.d.mts.map +1 -1
  87. package/resources/proxies.d.ts +33 -113
  88. package/resources/proxies.d.ts.map +1 -1
  89. package/resources/proxies.js +6 -8
  90. package/resources/proxies.js.map +1 -1
  91. package/resources/proxies.mjs +6 -8
  92. package/resources/proxies.mjs.map +1 -1
  93. package/resources/search/search.d.mts +4 -2
  94. package/resources/search/search.d.mts.map +1 -1
  95. package/resources/search/search.d.ts +4 -2
  96. package/resources/search/search.d.ts.map +1 -1
  97. package/resources/search/search.js.map +1 -1
  98. package/resources/search/search.mjs.map +1 -1
  99. package/resources/vaults/items.d.mts +42 -42
  100. package/resources/vaults/items.d.mts.map +1 -1
  101. package/resources/vaults/items.d.ts +42 -42
  102. package/resources/vaults/items.d.ts.map +1 -1
  103. package/src/client.ts +2 -0
  104. package/src/resources/auth/connections.ts +1 -1
  105. package/src/resources/browser-pools.ts +4 -4
  106. package/src/resources/browsers/browsers.ts +69 -9
  107. package/src/resources/browsers/index.ts +8 -1
  108. package/src/resources/browsers/playwright/executors.ts +123 -0
  109. package/src/resources/browsers/playwright/index.ts +10 -0
  110. package/src/resources/browsers/playwright/playwright.ts +186 -0
  111. package/src/resources/browsers/playwright.ts +1 -87
  112. package/src/resources/browsers/telemetry.ts +17 -14
  113. package/src/resources/config-registry/config-registry.ts +2 -17
  114. package/src/resources/index.ts +1 -0
  115. package/src/resources/invocations.ts +1 -1
  116. package/src/resources/proxies.ts +27 -119
  117. package/src/resources/search/search.ts +4 -2
  118. package/src/resources/vaults/items.ts +43 -45
  119. package/src/version.ts +1 -1
  120. package/version.d.mts +1 -1
  121. package/version.d.ts +1 -1
  122. package/version.js +1 -1
  123. package/version.mjs +1 -1
@@ -22,8 +22,6 @@ import {
22
22
  } from './computer';
23
23
  import * as LogsAPI from './logs';
24
24
  import { LogStreamParams, Logs } from './logs';
25
- import * as PlaywrightAPI from './playwright';
26
- import { Playwright, PlaywrightExecuteParams, PlaywrightExecuteResponse } from './playwright';
27
25
  import * as ProcessAPI from './process';
28
26
  import {
29
27
  Process,
@@ -128,6 +126,14 @@ import {
128
126
  FWriteFileParams,
129
127
  Fs,
130
128
  } from './fs/fs';
129
+ import * as PlaywrightAPI from './playwright/playwright';
130
+ import {
131
+ ExecutorLimitError,
132
+ Playwright,
133
+ PlaywrightExecuteParams,
134
+ PlaywrightExecuteResponse,
135
+ Tab,
136
+ } from './playwright/playwright';
131
137
  import * as WebmcpAPI from './webmcp/webmcp';
132
138
  import {
133
139
  CustomToolSource,
@@ -354,6 +360,30 @@ export type BrowserMemoryRequest = '8GiB' | '16GiB';
354
360
  * Network configuration for a browser session or browser pool.
355
361
  */
356
362
  export interface BrowserNetworkConfig {
363
+ /**
364
+ * Egress allowlist for a browser session: the only destinations the browser may
365
+ * reach through Kernel-managed egress. Any other destination is refused with a 403
366
+ * whose X-Kernel-Proxy-Error header is network_policy_denied, so pages cannot load
367
+ * or send data to unlisted hosts, including with fetch() and WebSockets. Omit the
368
+ * field for unfiltered egress; an empty list is invalid. The allowlist applies
369
+ * from the browser's first request, and start_url must be allowed by it. Entries
370
+ * are exact hostnames ("example.com"), one leading "_." wildcard that matches
371
+ * subdomains at any depth but not the domain itself ("_.example.com" matches
372
+ * api.example.com, not example.com), public IPv4 addresses ("8.8.8.8"), bracketed
373
+ * public IPv6 addresses ("[2001:4860:4860::8888]"), or public CIDR ranges in
374
+ * canonical form ("8.8.4.0/24", "2001:4860::/32"). IP and CIDR entries only match
375
+ * destinations written as an IP address, never hostnames that resolve into the
376
+ * range. Entries cannot include ports, paths, or schemes, and match every port on
377
+ * their host. Wildcards over a public suffix ("_.com", "_.github.io") and private
378
+ * or reserved IP ranges are rejected, as are entries that overlap private_hosts.
379
+ * Enforced at Kernel's egress proxy only: destinations in private_hosts, and
380
+ * processes in the browser VM that do not use the browser's proxy, are not
381
+ * filtered, and Kernel's own control traffic is always allowed. Can be replaced or
382
+ * removed while the session runs with PATCH /browsers/{id_or_name}. Requires proxy
383
+ * v3. Not supported on browser pools.
384
+ */
385
+ allowed_hosts?: Array<string>;
386
+
357
387
  /**
358
388
  * Destinations the browser reaches directly through the session's own network
359
389
  * instead of through Kernel-managed egress — for private hosts reachable over a
@@ -427,6 +457,27 @@ export namespace BrowserNetworkConfig {
427
457
  }
428
458
  }
429
459
 
460
+ /**
461
+ * Network configuration changes for a running browser session. Other network
462
+ * settings can only be set at creation.
463
+ */
464
+ export interface BrowserNetworkUpdate {
465
+ /**
466
+ * Replaces the session's egress allowlist, using the same entry rules as
467
+ * network.allowed_hosts on create. Omit to leave the allowlist unchanged, or set
468
+ * to null to remove it and return to unfiltered egress; an empty list is invalid.
469
+ * The new list applies without restarting the browser: new requests to
470
+ * destinations it no longer allows are refused within a few seconds, and open
471
+ * connections to them are closed within about 30 seconds, or up to 10 minutes
472
+ * during a Kernel deploy. Connections to destinations it still allows, such as
473
+ * WebSockets, stay open. A start_url in the same request must be allowed by the
474
+ * updated list, and is loaded only after the list takes effect. Requires a browser
475
+ * created with proxy v3, and not supported on pooled browsers. If the request
476
+ * fails, retry it: the new list may already apply to some requests.
477
+ */
478
+ allowed_hosts?: Array<string> | null;
479
+ }
480
+
430
481
  /**
431
482
  * Browser pool this session was acquired from, if any.
432
483
  */
@@ -684,7 +735,7 @@ export interface BrowserCreateResponse {
684
735
  /**
685
736
  * Geographic region of the browser session. Fixed once the session is created.
686
737
  */
687
- region: 'us-east' | 'eu-west' | 'ap-southeast';
738
+ region: 'us-east' | 'us-west' | 'eu-west' | 'ap-southeast';
688
739
 
689
740
  /**
690
741
  * Unique identifier for the browser session
@@ -855,7 +906,7 @@ export interface BrowserRetrieveResponse {
855
906
  /**
856
907
  * Geographic region of the browser session. Fixed once the session is created.
857
908
  */
858
- region: 'us-east' | 'eu-west' | 'ap-southeast';
909
+ region: 'us-east' | 'us-west' | 'eu-west' | 'ap-southeast';
859
910
 
860
911
  /**
861
912
  * Unique identifier for the browser session
@@ -1026,7 +1077,7 @@ export interface BrowserUpdateResponse {
1026
1077
  /**
1027
1078
  * Geographic region of the browser session. Fixed once the session is created.
1028
1079
  */
1029
- region: 'us-east' | 'eu-west' | 'ap-southeast';
1080
+ region: 'us-east' | 'us-west' | 'eu-west' | 'ap-southeast';
1030
1081
 
1031
1082
  /**
1032
1083
  * Unique identifier for the browser session
@@ -1197,7 +1248,7 @@ export interface BrowserListResponse {
1197
1248
  /**
1198
1249
  * Geographic region of the browser session. Fixed once the session is created.
1199
1250
  */
1200
- region: 'us-east' | 'eu-west' | 'ap-southeast';
1251
+ region: 'us-east' | 'us-west' | 'eu-west' | 'ap-southeast';
1201
1252
 
1202
1253
  /**
1203
1254
  * Unique identifier for the browser session
@@ -1419,7 +1470,8 @@ export interface BrowserCreateParams {
1419
1470
  name?: string;
1420
1471
 
1421
1472
  /**
1422
- * Network configuration for the browser session. Cannot be changed after creation.
1473
+ * Network configuration for the browser session. Only allowed_hosts can be changed
1474
+ * after creation, with PATCH /browsers/{id_or_name}.
1423
1475
  */
1424
1476
  network?: BrowserNetworkConfig;
1425
1477
 
@@ -1452,7 +1504,7 @@ export interface BrowserCreateParams {
1452
1504
  * created. Region selection requires a Start-Up or Enterprise plan, defaults to
1453
1505
  * us-east when omitted on create.
1454
1506
  */
1455
- region?: 'us-east' | 'eu-west' | 'ap-southeast';
1507
+ region?: 'us-east' | 'us-west' | 'eu-west' | 'ap-southeast';
1456
1508
 
1457
1509
  /**
1458
1510
  * Optional URL to open when the browser session is created. Navigation is
@@ -1649,6 +1701,11 @@ export interface BrowserUpdateParams {
1649
1701
  */
1650
1702
  name?: string | null;
1651
1703
 
1704
+ /**
1705
+ * Network configuration changes to apply to the running browser session.
1706
+ */
1707
+ network?: BrowserNetworkUpdate;
1708
+
1652
1709
  /**
1653
1710
  * Profile to load into the browser session. Only allowed if the session does not
1654
1711
  * already have a profile loaded.
@@ -1839,7 +1896,7 @@ export interface BrowserListParams extends OffsetPaginationParams {
1839
1896
  /**
1840
1897
  * Filter sessions by geographic region. Omit to list sessions in all regions.
1841
1898
  */
1842
- region?: 'us-east' | 'eu-west' | 'ap-southeast';
1899
+ region?: 'us-east' | 'us-west' | 'eu-west' | 'ap-southeast';
1843
1900
 
1844
1901
  /**
1845
1902
  * Filter sessions by status. "active" returns only active sessions (default),
@@ -1945,6 +2002,7 @@ export declare namespace Browsers {
1945
2002
  type BrowserMemory as BrowserMemory,
1946
2003
  type BrowserMemoryRequest as BrowserMemoryRequest,
1947
2004
  type BrowserNetworkConfig as BrowserNetworkConfig,
2005
+ type BrowserNetworkUpdate as BrowserNetworkUpdate,
1948
2006
  type BrowserPoolRef as BrowserPoolRef,
1949
2007
  type BrowserProxy as BrowserProxy,
1950
2008
  type BrowserProxyConfig as BrowserProxyConfig,
@@ -2098,6 +2156,8 @@ export declare namespace Browsers {
2098
2156
 
2099
2157
  export {
2100
2158
  Playwright as Playwright,
2159
+ type ExecutorLimitError as ExecutorLimitError,
2160
+ type Tab as Tab,
2101
2161
  type PlaywrightExecuteResponse as PlaywrightExecuteResponse,
2102
2162
  type PlaywrightExecuteParams as PlaywrightExecuteParams,
2103
2163
  };
@@ -5,6 +5,7 @@ export {
5
5
  type BrowserMemory,
6
6
  type BrowserMemoryRequest,
7
7
  type BrowserNetworkConfig,
8
+ type BrowserNetworkUpdate,
8
9
  type BrowserPoolRef,
9
10
  type BrowserProxy,
10
11
  type BrowserProxyConfig,
@@ -67,7 +68,13 @@ export {
67
68
  type FWriteFileParams,
68
69
  } from './fs/index';
69
70
  export { Logs, type LogStreamParams } from './logs';
70
- export { Playwright, type PlaywrightExecuteResponse, type PlaywrightExecuteParams } from './playwright';
71
+ export {
72
+ Playwright,
73
+ type ExecutorLimitError,
74
+ type Tab,
75
+ type PlaywrightExecuteResponse,
76
+ type PlaywrightExecuteParams,
77
+ } from './playwright/index';
71
78
  export {
72
79
  Process,
73
80
  type ProcessExecResponse,
@@ -0,0 +1,123 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../../core/resource';
4
+ import { APIPromise } from '../../../core/api-promise';
5
+ import { buildHeaders } from '../../../internal/headers';
6
+ import { RequestOptions } from '../../../internal/request-options';
7
+ import { path } from '../../../internal/utils/path';
8
+
9
+ /**
10
+ * Execute Playwright code against the browser instance and manage the executors it runs in.
11
+ */
12
+ export class Executors extends APIResource {
13
+ /**
14
+ * Lists the default executor first, then the named executors created by POST
15
+ * /browsers/{id_or_name}/playwright/execute. Each entry reports whether a call is
16
+ * running on it and, for named executors, the target ID and URL of the tab it
17
+ * owns. Returns 404 for a browser whose image predates executors.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const executorList =
22
+ * await client.browsers.playwright.executors.list(
23
+ * 'htzv5orfit78e1m2biiifpbv',
24
+ * );
25
+ * ```
26
+ */
27
+ list(idOrName: string, options?: RequestOptions): APIPromise<ExecutorList> {
28
+ return this._client.get(path`/browsers/${idOrName}/playwright/executors`, options);
29
+ }
30
+
31
+ /**
32
+ * Stops the executor's process. A call running on it fails with an error saying
33
+ * the executor was deleted. By default the executor's tab is closed too. The name
34
+ * can be reused; the next call with it creates a new executor and tab.
35
+ *
36
+ * The default executor is restarted instead of removed: its process is stopped, a
37
+ * call running on it fails with an error saying the executor was restarted, and
38
+ * queued and later calls run on a new process. It owns no tab, so 'close_tab' has
39
+ * no effect on it.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * await client.browsers.playwright.executors.delete(
44
+ * 'checkout',
45
+ * { id_or_name: 'htzv5orfit78e1m2biiifpbv' },
46
+ * );
47
+ * ```
48
+ */
49
+ delete(name: string, params: ExecutorDeleteParams, options?: RequestOptions): APIPromise<void> {
50
+ const { id_or_name, close_tab } = params;
51
+ return this._client.delete(path`/browsers/${id_or_name}/playwright/executors/${name}`, {
52
+ query: { close_tab },
53
+ ...options,
54
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
55
+ });
56
+ }
57
+ }
58
+
59
+ /**
60
+ * A Playwright executor on the browser
61
+ */
62
+ export interface Executor {
63
+ /**
64
+ * Whether a call is running on the executor
65
+ */
66
+ busy: boolean;
67
+
68
+ /**
69
+ * When the executor was created
70
+ */
71
+ created_at: string;
72
+
73
+ /**
74
+ * When the most recent call on the executor started
75
+ */
76
+ last_used_at: string;
77
+
78
+ /**
79
+ * Name of a Playwright executor. Calls with the same name run in the same
80
+ * executor, one at a time; the first call with a new name creates it. Calls on
81
+ * different executors run concurrently. 'default' names the executor that runs
82
+ * calls without a name.
83
+ */
84
+ name: string;
85
+
86
+ /**
87
+ * CDP page target ID of the executor's tab, once it has one. The default executor
88
+ * owns no tab.
89
+ */
90
+ target_id?: string;
91
+
92
+ /**
93
+ * Current URL of the executor's tab, when it is open
94
+ */
95
+ url?: string;
96
+ }
97
+
98
+ /**
99
+ * The default executor followed by the named executors
100
+ */
101
+ export interface ExecutorList {
102
+ executors: Array<Executor>;
103
+ }
104
+
105
+ export interface ExecutorDeleteParams {
106
+ /**
107
+ * Path param: Browser session ID or name
108
+ */
109
+ id_or_name: string;
110
+
111
+ /**
112
+ * Query param: Close the executor's tab. Defaults to true.
113
+ */
114
+ close_tab?: boolean;
115
+ }
116
+
117
+ export declare namespace Executors {
118
+ export {
119
+ type Executor as Executor,
120
+ type ExecutorList as ExecutorList,
121
+ type ExecutorDeleteParams as ExecutorDeleteParams,
122
+ };
123
+ }
@@ -0,0 +1,10 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export { Executors, type Executor, type ExecutorList, type ExecutorDeleteParams } from './executors';
4
+ export {
5
+ Playwright,
6
+ type ExecutorLimitError,
7
+ type Tab,
8
+ type PlaywrightExecuteResponse,
9
+ type PlaywrightExecuteParams,
10
+ } from './playwright';
@@ -0,0 +1,186 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../../core/resource';
4
+ import * as ExecutorsAPI from './executors';
5
+ import { Executor, ExecutorDeleteParams, ExecutorList, Executors } from './executors';
6
+ import { APIPromise } from '../../../core/api-promise';
7
+ import { RequestOptions } from '../../../internal/request-options';
8
+ import { path } from '../../../internal/utils/path';
9
+
10
+ /**
11
+ * Execute Playwright code against the browser instance and manage the executors it runs in.
12
+ */
13
+ export class Playwright extends APIResource {
14
+ executors: ExecutorsAPI.Executors = new ExecutorsAPI.Executors(this._client);
15
+
16
+ /**
17
+ * Execute arbitrary Playwright code in a fresh execution context against the
18
+ * browser. The code runs in the same VM as the browser, minimizing latency and
19
+ * maximizing throughput. It has access to 'page', 'context', 'browser', and
20
+ * 'webmcp' variables. Use 'webmcp.listTools()' to discover browser-wide WebMCP
21
+ * tools and 'webmcp.invokeTool(toolRef, input?, { timeoutSec? })' to invoke an
22
+ * exact registration. It can `return` a value, and this value is returned in the
23
+ * response.
24
+ *
25
+ * Every call runs in an executor: a dedicated Node.js process with its own browser
26
+ * connection. Calls on different executors run concurrently; calls on the same
27
+ * executor run one at a time. A timeout, crash, or blocked event loop in one
28
+ * executor does not affect other executors. After a timeout the executor keeps its
29
+ * process and drops its browser connection, so code abandoned by the timeout
30
+ * cannot keep driving the browser. After a crash or a blocked event loop, the next
31
+ * call on that executor starts a fresh process.
32
+ *
33
+ * Calls without 'executor' run in the executor named 'default', which always
34
+ * exists and is the same as passing 'executor: "default"'. In the default
35
+ * executor, 'page' is bound to an active tab reported by Chrome. In single-window
36
+ * sessions, this is the foreground tab. When multiple browser windows are open,
37
+ * Chrome reports one active tab per window and the selected window is unspecified.
38
+ * 'context' is the BrowserContext that owns the selected page. Use
39
+ * 'browser.contexts()' to select a context or page explicitly.
40
+ *
41
+ * Pass any other name to run the call in a named executor. The first call with a
42
+ * new name creates it. Each named executor owns a tab: its first call opens a new
43
+ * background tab in the default browser context, and 'page' is bound to that tab
44
+ * on every later call while it stays open. Opening it does not change the active
45
+ * tab of an existing window. If the tab is closed, the next call opens a new one
46
+ * and reports 'tab.created: true'. Executor code can still reach other tabs
47
+ * through 'context' and 'browser'; ownership only decides what 'page' is bound to.
48
+ * Use named executors to drive several tabs of one browser in parallel.
49
+ *
50
+ * A browser can have at most 8 named executors; the default executor does not
51
+ * count. A call that would create another returns 409 with the current executors;
52
+ * delete one with DELETE /browsers/{id_or_name}/playwright/executors/{name}. Named
53
+ * executors are not removed automatically while the browser runs; when it shuts
54
+ * down, they are removed and their tabs closed.
55
+ *
56
+ * A named call to a browser whose image predates executors fails with 400 instead
57
+ * of running on the active tab; calls without 'executor' keep working on every
58
+ * image.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * const response = await client.browsers.playwright.execute(
63
+ * 'htzv5orfit78e1m2biiifpbv',
64
+ * { code: 'code' },
65
+ * );
66
+ * ```
67
+ */
68
+ execute(
69
+ idOrName: string,
70
+ body: PlaywrightExecuteParams,
71
+ options?: RequestOptions,
72
+ ): APIPromise<PlaywrightExecuteResponse> {
73
+ return this._client.post(path`/browsers/${idOrName}/playwright/execute`, { body, ...options });
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Returned when a call would create a named executor beyond the per-browser limit
79
+ */
80
+ export interface ExecutorLimitError {
81
+ /**
82
+ * The default executor and the named executors that already exist
83
+ */
84
+ executors: Array<ExecutorsAPI.Executor>;
85
+
86
+ /**
87
+ * Human-readable error description
88
+ */
89
+ message: string;
90
+ }
91
+
92
+ /**
93
+ * The tab 'page' was bound to for this call. Absent if the call failed before
94
+ * binding a tab.
95
+ */
96
+ export interface Tab {
97
+ /**
98
+ * Whether this call opened the tab. For a named executor this happens on its first
99
+ * call and after its previous tab was closed. For the default executor it happens
100
+ * only when the browser had no open page.
101
+ */
102
+ created: boolean;
103
+
104
+ /**
105
+ * CDP page target ID of the tab
106
+ */
107
+ target_id: string;
108
+ }
109
+
110
+ /**
111
+ * Result of Playwright code execution
112
+ */
113
+ export interface PlaywrightExecuteResponse {
114
+ /**
115
+ * Whether the code executed successfully
116
+ */
117
+ success: boolean;
118
+
119
+ /**
120
+ * Error message if execution failed
121
+ */
122
+ error?: string;
123
+
124
+ /**
125
+ * The value returned by the code (if any)
126
+ */
127
+ result?: unknown;
128
+
129
+ /**
130
+ * Standard error from the execution
131
+ */
132
+ stderr?: string;
133
+
134
+ /**
135
+ * Standard output from the execution
136
+ */
137
+ stdout?: string;
138
+
139
+ /**
140
+ * The tab 'page' was bound to for this call. Absent if the call failed before
141
+ * binding a tab.
142
+ */
143
+ tab?: Tab;
144
+ }
145
+
146
+ export interface PlaywrightExecuteParams {
147
+ /**
148
+ * TypeScript/JavaScript code to execute. The code has access to 'page', 'context',
149
+ * and 'browser' variables. It runs within a function, so you can use a return
150
+ * statement at the end to return a value. This value is returned as the `result`
151
+ * property in the response. Example: "await page.goto('https://example.com');
152
+ * return await page.title();"
153
+ */
154
+ code: string;
155
+
156
+ /**
157
+ * Name of a Playwright executor. Calls with the same name run in the same
158
+ * executor, one at a time; the first call with a new name creates it. Calls on
159
+ * different executors run concurrently. 'default' names the executor that runs
160
+ * calls without a name.
161
+ */
162
+ executor?: string;
163
+
164
+ /**
165
+ * Maximum execution time in seconds. Default is 60.
166
+ */
167
+ timeout_sec?: number;
168
+ }
169
+
170
+ Playwright.Executors = Executors;
171
+
172
+ export declare namespace Playwright {
173
+ export {
174
+ type ExecutorLimitError as ExecutorLimitError,
175
+ type Tab as Tab,
176
+ type PlaywrightExecuteResponse as PlaywrightExecuteResponse,
177
+ type PlaywrightExecuteParams as PlaywrightExecuteParams,
178
+ };
179
+
180
+ export {
181
+ Executors as Executors,
182
+ type Executor as Executor,
183
+ type ExecutorList as ExecutorList,
184
+ type ExecutorDeleteParams as ExecutorDeleteParams,
185
+ };
186
+ }
@@ -1,89 +1,3 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { APIResource } from '../../core/resource';
4
- import { APIPromise } from '../../core/api-promise';
5
- import { RequestOptions } from '../../internal/request-options';
6
- import { path } from '../../internal/utils/path';
7
-
8
- /**
9
- * Execute Playwright code against the browser instance.
10
- */
11
- export class Playwright extends APIResource {
12
- /**
13
- * Execute arbitrary Playwright code in a fresh execution context against the
14
- * browser. The code runs in the same VM as the browser, minimizing latency and
15
- * maximizing throughput. It has access to 'page', 'context', 'browser', and
16
- * 'webmcp' variables. Use 'webmcp.listTools()' to discover browser-wide WebMCP
17
- * tools and 'webmcp.invokeTool(toolRef, input?, { timeoutSec? })' to invoke an
18
- * exact registration. It can `return` a value, and this value is returned in the
19
- * response.
20
- *
21
- * @example
22
- * ```ts
23
- * const response = await client.browsers.playwright.execute(
24
- * 'htzv5orfit78e1m2biiifpbv',
25
- * { code: 'code' },
26
- * );
27
- * ```
28
- */
29
- execute(
30
- idOrName: string,
31
- body: PlaywrightExecuteParams,
32
- options?: RequestOptions,
33
- ): APIPromise<PlaywrightExecuteResponse> {
34
- return this._client.post(path`/browsers/${idOrName}/playwright/execute`, { body, ...options });
35
- }
36
- }
37
-
38
- /**
39
- * Result of Playwright code execution
40
- */
41
- export interface PlaywrightExecuteResponse {
42
- /**
43
- * Whether the code executed successfully
44
- */
45
- success: boolean;
46
-
47
- /**
48
- * Error message if execution failed
49
- */
50
- error?: string;
51
-
52
- /**
53
- * The value returned by the code (if any)
54
- */
55
- result?: unknown;
56
-
57
- /**
58
- * Standard error from the execution
59
- */
60
- stderr?: string;
61
-
62
- /**
63
- * Standard output from the execution
64
- */
65
- stdout?: string;
66
- }
67
-
68
- export interface PlaywrightExecuteParams {
69
- /**
70
- * TypeScript/JavaScript code to execute. The code has access to 'page', 'context',
71
- * and 'browser' variables. It runs within a function, so you can use a return
72
- * statement at the end to return a value. This value is returned as the `result`
73
- * property in the response. Example: "await page.goto('https://example.com');
74
- * return await page.title();"
75
- */
76
- code: string;
77
-
78
- /**
79
- * Maximum execution time in seconds. Default is 60.
80
- */
81
- timeout_sec?: number;
82
- }
83
-
84
- export declare namespace Playwright {
85
- export {
86
- type PlaywrightExecuteResponse as PlaywrightExecuteResponse,
87
- type PlaywrightExecuteParams as PlaywrightExecuteParams,
88
- };
89
- }
3
+ export * from './playwright/index';
@@ -4325,12 +4325,13 @@ export namespace BrowserPlatformAPICallEvent {
4325
4325
 
4326
4326
  /**
4327
4327
  * A branded proxy-layer failure observed by the browser. Emitted when the metro
4328
- * egress host-proxy serves a branded 5xx error page whose response carries the
4329
- * X-Kernel-Proxy-Error header. Low-volume and carries a typed code. Its value is
4330
- * per-session and per-URL attribution for sessions that already capture the
4331
- * network stream: proxy failures are only observable while the CDP network
4332
- * collector is running, so this is an opt-in refinement of the raw network events
4333
- * rather than a default-on alerting signal.
4328
+ * egress host-proxy serves a branded error page whose response carries the
4329
+ * X-Kernel-Proxy-Error header: a 502 for proxy-layer failures, or a 403 when the
4330
+ * session's network policy blocks the destination. Low-volume and carries a typed
4331
+ * code. Its value is per-session and per-URL attribution for sessions that already
4332
+ * capture the network stream: proxy failures are only observable while the CDP
4333
+ * network collector is running, so this is an opt-in refinement of the raw network
4334
+ * events rather than a default-on alerting signal.
4334
4335
  */
4335
4336
  export interface BrowserProxyErrorEvent {
4336
4337
  category: 'network';
@@ -4369,17 +4370,18 @@ export namespace BrowserProxyErrorEvent {
4369
4370
  export interface Data extends TelemetryAPI.BrowserEventContext {
4370
4371
  /**
4371
4372
  * Proxy-layer error code: the X-Kernel-Proxy-Error response header value from a
4372
- * branded 5xx error page served by the metro egress host-proxy. Values mirror what
4373
- * the proxy emits: destination_blocked, destination_route_unavailable,
4374
- * provider_blacklisted, provider_unreachable, provider_rejected,
4375
- * origin_tls_timeout, origin_response_incomplete, proxy_unavailable,
4376
- * restricted_route_unavailable, upstream_timeout, upstream_dns_failure,
4377
- * upstream_connect_failed. A header value the browser image does not recognize is
4378
- * reported as unknown, with the header value in raw_code.
4373
+ * branded error page served by the metro egress host-proxy. Values mirror what the
4374
+ * proxy emits: destination_blocked, destination_route_unavailable,
4375
+ * network_policy_denied, provider_blacklisted, provider_unreachable,
4376
+ * provider_rejected, origin_tls_timeout, origin_response_incomplete,
4377
+ * proxy_unavailable, restricted_route_unavailable, upstream_timeout,
4378
+ * upstream_dns_failure, upstream_connect_failed. A header value the browser image
4379
+ * does not recognize is reported as unknown, with the header value in raw_code.
4379
4380
  */
4380
4381
  code:
4381
4382
  | 'destination_blocked'
4382
4383
  | 'destination_route_unavailable'
4384
+ | 'network_policy_denied'
4383
4385
  | 'provider_blacklisted'
4384
4386
  | 'provider_unreachable'
4385
4387
  | 'provider_rejected'
@@ -4398,7 +4400,8 @@ export namespace BrowserProxyErrorEvent {
4398
4400
  request_id: string;
4399
4401
 
4400
4402
  /**
4401
- * HTTP response status of the branded error page (502).
4403
+ * HTTP response status of the branded error page (502, or 403 for
4404
+ * network_policy_denied).
4402
4405
  */
4403
4406
  status: number;
4404
4407