@orkestrel/browser 0.0.14 → 0.0.15

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.
@@ -4,6 +4,8 @@ import { BrowserError } from '@orkestrel/browser';
4
4
  import { BrowserPageInterface } from '@orkestrel/browser';
5
5
  import { BrowserPageOptions } from '@orkestrel/browser';
6
6
  import { BrowserViewport } from '@orkestrel/browser';
7
+ import { BrowserWriterInterface } from '@orkestrel/browser';
8
+ import { BrowserWriterInterface as BrowserWriterInterface_2 } from '@orkestrel/browser';
7
9
  import { CDPTarget } from '@orkestrel/browser';
8
10
  import { CDPTransportEventMap } from '@orkestrel/browser';
9
11
  import { CDPTransportEventMap as CDPTransportEventMap_2 } from '@orkestrel/browser';
@@ -13,10 +15,20 @@ import { ChildProcess } from 'node:child_process';
13
15
  import { EmitterErrorHandler } from '@orkestrel/emitter';
14
16
  import { EmitterHooks } from '@orkestrel/emitter';
15
17
  import { EmitterInterface } from '@orkestrel/emitter';
16
- import { ScreenshotWriterInterface } from '@orkestrel/browser';
18
+ import { Result } from '@orkestrel/contract';
17
19
 
18
20
  /**
19
21
  * Discovers, launches, connects to, and owns Chromium-family browser sessions.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import { Browser } from '@orkestrel/browser/server'
26
+ *
27
+ * const browser = new Browser({ headless: true })
28
+ * await browser.connect()
29
+ * const page = await browser.create({ url: 'https://example.com' })
30
+ * await browser.destroy()
31
+ * ```
20
32
  */
21
33
  export declare class Browser implements BrowserInterface {
22
34
  #private;
@@ -26,7 +38,6 @@ export declare class Browser implements BrowserInterface {
26
38
  get status(): BrowserStatus;
27
39
  get connection(): BrowserConnection | undefined;
28
40
  get owned(): boolean | undefined;
29
- get connected(): boolean;
30
41
  get pid(): number | undefined;
31
42
  discover(): Promise<BrowserDiscoveryResult>;
32
43
  connect(): Promise<void>;
@@ -40,83 +51,83 @@ export declare class Browser implements BrowserInterface {
40
51
  close(): Promise<void>;
41
52
  }
42
53
 
43
- /** Path appended to the CDP host to list open targets (pages, workers, etc). */
54
+ /** Names the path appended to the CDP host to list open targets (pages, workers, etc). */
44
55
  export declare const BROWSER_CDP_LIST_PATH = "/json/list";
45
56
 
46
- /** Protocol prefix for CDP discovery requests. */
57
+ /** Names the protocol prefix for CDP discovery requests. */
47
58
  export declare const BROWSER_CDP_PROTOCOL = "http";
48
59
 
49
- /** Path appended to the CDP host to fetch version metadata (endpoint discovery). */
60
+ /** Names the path appended to the CDP host to fetch version metadata (endpoint discovery). */
50
61
  export declare const BROWSER_CDP_VERSION_PATH = "/json/version";
51
62
 
52
- /** Default CDP port probed for an existing browser and used for launches. */
63
+ /** Sets the default CDP port probed for an existing browser and used for launches. */
53
64
  export declare const BROWSER_DEFAULT_CDP_PORT = 9222;
54
65
 
55
- /** Default host probed for an existing browser and used for launches (avoids `localhost` resolving to `::1` when Chromium binds `127.0.0.1`). */
66
+ /** Sets the default host probed for an existing browser and used for launches (avoids `localhost` resolving to `::1` when Chromium binds `127.0.0.1`). */
56
67
  export declare const BROWSER_DEFAULT_HOST = "127.0.0.1";
57
68
 
58
69
  /**
59
- * Case-insensitive substrings identifying an executable path/name's browser
70
+ * Lists the case-insensitive substrings identifying an executable path/name's browser
60
71
  * engine, checked by `parseBrowserEngine` in the order `edge` → `chromium` → `chrome`.
61
72
  */
62
73
  export declare const BROWSER_ENGINE_HINTS: Readonly<Record<BrowserEngine, readonly string[]>>;
63
74
 
64
- /** Environment variables checked (in order) for an explicit browser executable path override. */
75
+ /** Lists the environment variables checked (in order) for an explicit browser executable path override. */
65
76
  export declare const BROWSER_ENV_PATH_KEYS: readonly string[];
66
77
 
67
- /** Command names probed on PATH when no well-known executable path exists. */
78
+ /** Lists the command names probed on PATH when no well-known executable path exists. */
68
79
  export declare const BROWSER_EXECUTABLE_NAMES: readonly string[];
69
80
 
70
- /** Well-known Chrome/Chromium/Edge executable paths with no platform-specific root, keyed by `process.platform`. */
81
+ /** Lists the well-known Chrome/Chromium/Edge executable paths with no platform-specific root, keyed by `process.platform`. */
71
82
  export declare const BROWSER_EXECUTABLE_PATHS: Readonly<Record<string, readonly string[]>>;
72
83
 
73
- /** Flag enabling headless mode on a launched browser process. */
84
+ /** Names the flag that enables headless mode on a launched browser process. */
74
85
  export declare const BROWSER_HEADLESS_ARG = "--headless=new";
75
86
 
76
- /** Bound for each launched-process exit window during TERM-to-KILL teardown. */
87
+ /** Bounds each launched-process exit window during TERM-to-KILL teardown. */
77
88
  export declare const BROWSER_KILL_GRACE_MS = 3000;
78
89
 
79
- /** Flags always passed to a launched browser process, alongside the caller's own. */
90
+ /** Lists the flags always passed to a launched browser process, alongside the caller's own. */
80
91
  export declare const BROWSER_LAUNCH_ARGS: readonly string[];
81
92
 
82
- /** Bound for the `discover: false` port-occupancy probe before launching — short, since it only needs to detect an already-listening CDP endpoint, not perform full discovery. */
93
+ /** Bounds the `discover: false` port-occupancy probe before launching — short, because it only needs to detect an already-listening CDP endpoint, not perform full discovery. */
83
94
  export declare const BROWSER_PORT_PROBE_TIMEOUT_MS = 200;
84
95
 
85
- /** Machine-readable error-context cause for an owned browser process exiting. */
96
+ /** Names the machine-readable error-context cause for an owned browser process exiting. */
86
97
  export declare const BROWSER_PROCESS_EXIT_CAUSE = "process-exit";
87
98
 
88
- /** Prefix for isolated browser profiles created beneath the operating-system temp directory. */
99
+ /** Names the prefix for isolated browser profiles created beneath the operating-system temp directory. */
89
100
  export declare const BROWSER_PROFILE_PREFIX = "orkestrel-browser-";
90
101
 
91
- /** Per-OS default Playwright browser cache directory, relative to the home directory (win32 uses `LOCALAPPDATA` directly). */
102
+ /** Names the per-OS default Playwright browser cache directory, relative to the home directory (win32 uses `LOCALAPPDATA` directly). */
92
103
  export declare const BROWSER_STORE_CACHE_DIRS: Readonly<Record<string, string>>;
93
104
 
94
- /** Well-known Playwright browser store base directories checked in addition to `PLAYWRIGHT_BROWSERS_PATH`. */
105
+ /** Lists the well-known Playwright browser store base directories checked in addition to `PLAYWRIGHT_BROWSERS_PATH`. */
95
106
  export declare const BROWSER_STORE_DEFAULT_DIRS: readonly string[];
96
107
 
97
- /** Environment variable naming an additional Playwright browser store base directory. */
108
+ /** Names the environment variable that carries an additional Playwright browser store base directory. */
98
109
  export declare const BROWSER_STORE_ENV_KEY = "PLAYWRIGHT_BROWSERS_PATH";
99
110
 
100
- /** Glob pattern (relative to a store base) matching a versioned Chromium binary, keyed by `process.platform`. */
111
+ /** Names the glob pattern (relative to a store base) matching a versioned Chromium binary, keyed by `process.platform`. */
101
112
  export declare const BROWSER_STORE_GLOBS: Readonly<Record<string, string>>;
102
113
 
103
- /** Name of the top-level Chromium symlink/binary Playwright maintains inside a browser store base. */
114
+ /** Names the top-level Chromium symlink/binary Playwright maintains inside a browser store base. */
104
115
  export declare const BROWSER_STORE_LINK_NAME = "chromium";
105
116
 
106
- /** Machine-readable error-context cause for a CDP transport disconnecting while its browser remains alive. */
117
+ /** Names the machine-readable error-context cause for a CDP transport disconnecting while its browser remains alive. */
107
118
  export declare const BROWSER_TRANSPORT_LOSS_CAUSE = "transport-loss";
108
119
 
109
- /** Brief defer applied once when a transport loss is observed on an owned process, giving a near-simultaneous process-exit event (which libuv may reap slightly later than the socket close) first say over the diagnosis. */
120
+ /** Defers once, briefly, when a transport loss is observed on an owned process, giving a near-simultaneous process-exit event (which libuv may reap slightly later than the socket close) first say over the diagnosis. */
110
121
  export declare const BROWSER_TRANSPORT_LOSS_DEFER_MS = 50;
111
122
 
112
- /** Fallback Windows install roots used when the corresponding environment variable is absent. */
123
+ /** Lists the fallback Windows install roots used when the corresponding environment variable is absent. */
113
124
  export declare const BROWSER_WINDOWS_ROOT_FALLBACKS: Readonly<Record<string, string>>;
114
125
 
115
- /** Windows install-root-relative suffixes for Chrome/Edge/Chromium, joined against each candidate root (`PROGRAMFILES`, `PROGRAMFILES(X86)`, `LOCALAPPDATA`). */
126
+ /** Lists the Windows install-root-relative suffixes for Chrome/Edge/Chromium, joined against each candidate root (`PROGRAMFILES`, `PROGRAMFILES(X86)`, `LOCALAPPDATA`). */
116
127
  export declare const BROWSER_WINDOWS_SUFFIXES: readonly string[];
117
128
 
118
129
  /**
119
- * CDP (Chrome DevTools Protocol) connection configuration.
130
+ * Configures the CDP (Chrome DevTools Protocol) connection.
120
131
  *
121
132
  * @remarks
122
133
  * - `port` — port number to probe for an existing CDP endpoint (default `9222`)
@@ -137,47 +148,44 @@ export declare interface BrowserCDPOptions {
137
148
  readonly discover?: boolean;
138
149
  }
139
150
 
140
- /** How the browser connection was established. */
151
+ /** Names how the browser connection was established. */
141
152
  export declare type BrowserConnection = 'cdp' | 'launch' | 'persistent';
142
153
 
143
154
  /**
144
- * A CDP connection, discovery, or launch attempt failed.
155
+ * Reports that a CDP connection, discovery, or launch attempt failed.
145
156
  */
146
157
  export declare class BrowserConnectionError extends BrowserError {
147
158
  constructor(message: string, context?: Readonly<Record<string, unknown>>);
148
159
  }
149
160
 
150
161
  /**
151
- * An operation was attempted after the Browser was destroyed.
162
+ * Reports that an operation was attempted after the Browser was destroyed.
152
163
  */
153
164
  export declare class BrowserDestroyedError extends BrowserError {
154
165
  constructor(context?: Readonly<Record<string, unknown>>);
155
166
  }
156
167
 
157
168
  /**
158
- * Result of passive browser discovery.
169
+ * Describes the result of passive browser discovery.
159
170
  *
160
171
  * @remarks
161
172
  * Returned by `discover()` to report whether an existing browser is
162
- * reachable via CDP without actually connecting to it.
173
+ * reachable through CDP without actually connecting to it. A defined
174
+ * `endpoint` is the whole answer — no separate flag repeats it.
163
175
  *
164
- * - `found` — true when a browser responded on the CDP endpoint
165
- * - `endpoint` — the CDP WebSocket URL when found
176
+ * - `endpoint` — the CDP WebSocket URL, or undefined when nothing answered
166
177
  * - `browser` — browser product name reported by the endpoint
167
- * - `connection` — the connection mode that would be used
168
178
  */
169
179
  export declare interface BrowserDiscoveryResult {
170
- readonly found: boolean;
171
180
  readonly endpoint: string | undefined;
172
181
  readonly browser: string | undefined;
173
- readonly connection: BrowserConnection | undefined;
174
182
  }
175
183
 
176
- /** Supported browser engine (raw CDP targets Chromium-family browsers only). */
184
+ /** Names a supported browser engine (raw CDP targets Chromium-family browsers only). */
177
185
  export declare type BrowserEngine = 'chromium' | 'chrome' | 'edge';
178
186
 
179
187
  /**
180
- * Event map for a {@link BrowserInterface}.
188
+ * Maps the events a {@link BrowserInterface} emits.
181
189
  *
182
190
  * @remarks
183
191
  * - `idle` — no active connection (initial state, or after disconnect)
@@ -187,7 +195,8 @@ export declare type BrowserEngine = 'chromium' | 'chrome' | 'edge';
187
195
  * an external disconnect (process exit or transport loss); always preceded
188
196
  * by a coded `error` describing the cause
189
197
  * - `launch` — a new browser process was launched, carrying the engine
190
- * - `page` — a new page was created via the `create()` shortcut
198
+ * - `page` — a new page was created through the `create()` shortcut
199
+ * - `context` — an isolated browser context was created, carrying the context
191
200
  * - `error` — a connection or launch fault
192
201
  * - `destroy` — the browser and all resources were torn down
193
202
  */
@@ -204,13 +213,13 @@ export declare type BrowserEventMap = {
204
213
  };
205
214
 
206
215
  /**
207
- * Browser wrapper with discovery, connection management, and lifecycle control.
216
+ * Wraps a browser with discovery, connection management, and lifecycle control.
208
217
  *
209
218
  * @remarks
210
219
  * Encapsulates the full raw-CDP browser lifecycle behind a clean interface:
211
220
  *
212
221
  * **Connection strategy** (executed by `connect()`):
213
- * 1. If `cdp.endpoint` is set, connect directly via CDP
222
+ * 1. If `cdp.endpoint` is set, connect directly through CDP
214
223
  * 2. Probe `localhost:{cdp.port}` for an existing browser (passive discovery)
215
224
  * 3. If found, connect over CDP (preserves the existing browser session)
216
225
  * 4. Otherwise, launch a new browser process with raw-CDP flags
@@ -246,6 +255,8 @@ export declare type BrowserEventMap = {
246
255
  * **Page management:**
247
256
  * - `context(index?)` → one context or first
248
257
  * - `contexts()` → all contexts
258
+ * - `isolate` — create and register an isolated CDP context with validated
259
+ * proxy, download, origin, and emulation options
249
260
  * - `create(options?)` → shortcut to open a page in the default context
250
261
  */
251
262
  export declare interface BrowserInterface {
@@ -254,16 +265,15 @@ export declare interface BrowserInterface {
254
265
  readonly status: BrowserStatus;
255
266
  readonly connection: BrowserConnection | undefined;
256
267
  /**
257
- * Whether this instance is responsible for terminating the represented browser.
268
+ * Reports whether this instance is responsible for terminating the represented browser.
258
269
  *
259
270
  * @remarks
260
271
  * `true` for launched and explicitly adopted sessions, `false` for an
261
272
  * active attachment, and `undefined` when no session is represented.
262
273
  */
263
274
  readonly owned: boolean | undefined;
264
- readonly connected: boolean;
265
275
  /**
266
- * The process serving this session's CDP endpoint, if any, while it is
276
+ * Reports the process serving this session's CDP endpoint, if any, while it is
267
277
  * believed alive.
268
278
  *
269
279
  * @remarks
@@ -278,7 +288,7 @@ export declare interface BrowserInterface {
278
288
  readonly pid: number | undefined;
279
289
  discover(): Promise<BrowserDiscoveryResult>;
280
290
  connect(): Promise<void>;
281
- /** Assume responsibility for terminating the currently connected browser. */
291
+ /** Assumes responsibility for terminating the currently connected browser. */
282
292
  adopt(): void;
283
293
  disconnect(): Promise<void>;
284
294
  context(index?: number): BrowserContextInterface | undefined;
@@ -290,14 +300,14 @@ export declare interface BrowserInterface {
290
300
  }
291
301
 
292
302
  /**
293
- * An operation requiring an active connection was attempted while disconnected.
303
+ * Reports that an operation requiring an active connection was attempted while disconnected.
294
304
  */
295
305
  export declare class BrowserNotConnectedError extends BrowserError {
296
306
  constructor(context?: Readonly<Record<string, unknown>>);
297
307
  }
298
308
 
299
309
  /**
300
- * Options for creating a Browser.
310
+ * Describes the options for creating a Browser.
301
311
  *
302
312
  * @remarks
303
313
  * - `on` — initial event listeners wired at construction
@@ -334,7 +344,7 @@ export declare interface BrowserOptions {
334
344
  }
335
345
 
336
346
  /**
337
- * Resolved browser profile directory used for a Chromium-family launch.
347
+ * Describes the resolved browser profile directory used for a Chromium-family launch.
338
348
  *
339
349
  * @remarks
340
350
  * `temporary` is true only for an isolated profile created by
@@ -346,21 +356,30 @@ export declare interface BrowserProfileResult {
346
356
  readonly temporary: boolean;
347
357
  }
348
358
 
349
- /** Lifecycle status of a browser wrapper. */
359
+ /** Names the lifecycle status of a browser wrapper. */
350
360
  export declare type BrowserStatus = 'idle' | 'connecting' | 'connected' | 'disconnected' | 'error';
351
361
 
352
- /** Classify a `/json/version` `Browser` string into a {@link BrowserEngine} (`Edg/` → edge, `Chrome/` → chrome, else chromium). */
362
+ /** Classifies a `/json/version` `Browser` string into a {@link BrowserEngine} (`Edg/` → edge, `Chrome/` → chrome, else chromium). */
353
363
  export declare function browserToEngine(browser?: string): BrowserEngine;
354
364
 
365
+ /** Builds the default well-known install-path candidates for a platform, deriving Windows roots from env vars. */
366
+ export declare function buildInstallPaths(platform: string, env: Readonly<Record<string, string | undefined>>): readonly string[];
367
+
368
+ /** Builds the default Playwright browser store base directories to search for a managed Chromium. */
369
+ export declare function buildStoreBases(env: Readonly<Record<string, string | undefined>>, platform: string): readonly string[];
370
+
371
+ /** Derives Windows install roots from env vars, falling back to well-known literals when absent. */
372
+ export declare function buildWindowsRoots(env: Readonly<Record<string, string | undefined>>): readonly string[];
373
+
355
374
  /**
356
- * Create a raw-CDP Browser façade.
375
+ * Creates a raw-CDP Browser façade.
357
376
  *
358
377
  * @param options - Connection, launch, and viewport configuration
359
378
  * @returns A {@link BrowserInterface}
360
379
  *
361
380
  * @example
362
381
  * ```ts
363
- * import { createBrowser } from '@src/server'
382
+ * import { createBrowser } from '@orkestrel/browser/server'
364
383
  *
365
384
  * const browser = createBrowser()
366
385
  * await browser.connect()
@@ -369,7 +388,7 @@ export declare function browserToEngine(browser?: string): BrowserEngine;
369
388
  export declare function createBrowser(options?: BrowserOptions): BrowserInterface;
370
389
 
371
390
  /**
372
- * Resolve a persistent caller profile or create an isolated temporary one.
391
+ * Resolves a persistent caller profile or creates an isolated temporary one.
373
392
  *
374
393
  * @param path - Optional caller-owned persistent user-data directory
375
394
  * @returns The resolved profile and whether the library owns its lifecycle
@@ -377,56 +396,82 @@ export declare function createBrowser(options?: BrowserOptions): BrowserInterfac
377
396
  export declare function createBrowserProfile(path?: string): Promise<BrowserProfileResult>;
378
397
 
379
398
  /**
380
- * Create a Node `WebSocket`-backed CDP transport.
399
+ * Creates a filesystem-backed browser writer.
381
400
  *
382
- * @param options - The CDP WebSocket debugger URL (and optional timeout)
383
- * @returns A {@link CDPTransportInterface}
401
+ * @returns A {@link BrowserWriterInterface} that persists bytes through `node:fs/promises`
384
402
  */
385
- export declare function createCDPTransport(options: WebSocketCDPTransportOptions): CDPTransportInterface_2;
403
+ export declare function createBrowserWriter(): BrowserWriterInterface_2;
386
404
 
387
405
  /**
388
- * Create a filesystem-backed screenshot writer.
406
+ * Creates a Node `WebSocket`-backed CDP transport.
389
407
  *
390
- * @returns A {@link ScreenshotWriterInterface} that persists bytes via `node:fs/promises`
408
+ * @param options - The CDP WebSocket debugger URL (and optional timeout)
409
+ * @returns A {@link CDPTransportInterface}
391
410
  */
392
- export declare function createScreenshotWriter(): ScreenshotWriterInterface;
393
-
394
- /** Build the default well-known install-path candidates for a platform, deriving Windows roots from env vars. */
395
- export declare function defaultInstallPaths(platform: string, env: Readonly<Record<string, string | undefined>>): readonly string[];
396
-
397
- /** Build the default Playwright browser store base directories to search for a managed Chromium. */
398
- export declare function defaultStoreBases(env: Readonly<Record<string, string | undefined>>, platform: string): readonly string[];
411
+ export declare function createCDPTransport(options: WebSocketCDPTransportOptions): CDPTransportInterface_2;
399
412
 
400
413
  /**
401
- * Fetch the current CDP target list from a browser's `/json/list` endpoint.
414
+ * Fetches the current CDP target list from a browser's `/json/list` endpoint.
415
+ *
416
+ * @remarks
417
+ * The endpoint is a network boundary, so an unreachable host, a non-2xx
418
+ * response, and a body that is not a JSON array each come back as a failed
419
+ * `Result` carrying a coded `BrowserConnectionError`. An entry missing a
420
+ * required string field is skipped rather than failing the whole list.
402
421
  *
403
422
  * @param port - Port the browser exposes its CDP endpoint on
404
423
  * @param timeout - Request timeout in milliseconds
405
424
  * @param host - Host the browser exposes its CDP endpoint on (default `127.0.0.1`)
406
- * @returns Normalized CDP targets
425
+ * @returns The normalized CDP targets, or the fault that stopped the request
426
+ *
427
+ * @example
428
+ * ```ts
429
+ * import { fetchCDPTargets } from '@orkestrel/browser/server'
430
+ *
431
+ * const result = await fetchCDPTargets(9222, 2000)
432
+ * if (result.success) log(result.value.length)
433
+ * else log(result.error.code)
434
+ * ```
407
435
  */
408
- export declare function fetchCDPTargets(port: number, timeout: number, host?: string): Promise<readonly CDPTarget[]>;
409
-
410
- /** Check the env-override keys (`PLAYWRIGHT_EXECUTABLE_PATH`, `CHROME_PATH`) in order, returning every one that exists. */
411
- export declare function findAllEnvOverrides(env: Readonly<Record<string, string | undefined>>): readonly string[];
412
-
413
- /** Return every candidate path that exists on disk, in the given order. */
414
- export declare function findAllInstallPaths(paths: readonly string[]): readonly string[];
436
+ export declare function fetchCDPTargets(port: number, timeout: number, host?: string): Promise<Result<readonly CDPTarget[], BrowserError>>;
415
437
 
416
- /** Search one store base for the top-level `chromium` link and every `chromium-*` install, highest revision first. */
417
- export declare function findAllInStore(base: string, platform: string): readonly string[];
438
+ /**
439
+ * Persists captured browser bytes to the filesystem through `node:fs/promises`.
440
+ *
441
+ * @remarks
442
+ * Creates every missing parent directory of the target path before writing, so
443
+ * a caller may name a nested destination that does not exist yet.
444
+ *
445
+ * @example
446
+ * ```ts
447
+ * import { FileBrowserWriter } from '@orkestrel/browser/server'
448
+ *
449
+ * const writer = new FileBrowserWriter()
450
+ * await writer.write('shots/hero.png', new Uint8Array([137, 80, 78, 71]))
451
+ * ```
452
+ */
453
+ export declare class FileBrowserWriter implements BrowserWriterInterface {
454
+ /**
455
+ * Writes the captured bytes to a path, creating its parent directories.
456
+ *
457
+ * @param path - Destination file path
458
+ * @param data - Captured bytes to persist
459
+ * @returns A promise resolving once the bytes are on disk
460
+ */
461
+ write(path: string, data: Uint8Array): Promise<void>;
462
+ }
418
463
 
419
- /** Check the env-override keys (`PLAYWRIGHT_EXECUTABLE_PATH`, `CHROME_PATH`) in order for an existing file. */
420
- export declare function findEnvOverride(env: Readonly<Record<string, string | undefined>>): string | undefined;
464
+ /** Checks the env-override keys (`PLAYWRIGHT_EXECUTABLE_PATH`, `CHROME_PATH`) in order and returns every one that exists. */
465
+ export declare function findEnvOverrides(env: Readonly<Record<string, string | undefined>>): readonly string[];
421
466
 
422
- /** Return the first candidate path that exists on disk. */
423
- export declare function findInstallPath(paths: readonly string[]): string | undefined;
467
+ /** Returns every candidate path that exists on disk, in the given order. */
468
+ export declare function findInstallPaths(paths: readonly string[]): readonly string[];
424
469
 
425
- /** Search one store base for the top-level `chromium` link, else the highest-revision `chromium-*` install. */
426
- export declare function findInStore(base: string, platform: string): string | undefined;
470
+ /** Searches one store base for the top-level `chromium` link and every `chromium-*` install, highest revision first. */
471
+ export declare function findStorePaths(base: string, platform: string): readonly string[];
427
472
 
428
473
  /**
429
- * Locate a Chrome/Chromium/Edge executable on this machine — the first entry
474
+ * Locates a Chrome/Chromium/Edge executable on this machine — the first entry
430
475
  * of {@link findSystemBrowsers}.
431
476
  *
432
477
  * @param options - Overrides for the candidate sources; see {@link SystemBrowserOptions}
@@ -435,7 +480,7 @@ export declare function findInStore(base: string, platform: string): string | un
435
480
  export declare function findSystemBrowser(options?: SystemBrowserOptions): SystemBrowser | undefined;
436
481
 
437
482
  /**
438
- * Enumerate every Chrome/Chromium/Edge executable discoverable on this
483
+ * Enumerates every Chrome/Chromium/Edge executable discoverable on this
439
484
  * machine, deduplicated by normalized absolute path.
440
485
  *
441
486
  * @remarks
@@ -449,7 +494,7 @@ export declare function findSystemBrowser(options?: SystemBrowserOptions): Syste
449
494
  * and the per-OS Playwright cache directory) — the top-level `chromium`
450
495
  * link/binary, then the highest-revision `chromium-*` install found
451
496
  *
452
- * Each candidate is classified into a {@link BrowserEngine} via
497
+ * Each candidate is classified into a {@link BrowserEngine} through
453
498
  * `parseBrowserEngine` (unclassifiable candidates default to `'chromium'`),
454
499
  * and `options.engine` (when given) narrows the result to that engine.
455
500
  *
@@ -459,31 +504,31 @@ export declare function findSystemBrowser(options?: SystemBrowserOptions): Syste
459
504
  export declare function findSystemBrowsers(options?: SystemBrowserOptions): readonly SystemBrowser[];
460
505
 
461
506
  /**
462
- * Narrow an unknown value to BrowserConnectionError.
507
+ * Narrows an unknown value to BrowserConnectionError.
463
508
  *
464
509
  * @param value - Value to check
465
- * @returns True when value is a BrowserConnectionError instance
510
+ * @returns True if value is a BrowserConnectionError instance; false otherwise
466
511
  */
467
512
  export declare function isBrowserConnectionError(value: unknown): value is BrowserConnectionError;
468
513
 
469
514
  /**
470
- * Narrow an unknown value to BrowserDestroyedError.
515
+ * Narrows an unknown value to BrowserDestroyedError.
471
516
  *
472
517
  * @param value - Value to check
473
- * @returns True when value is a BrowserDestroyedError instance
518
+ * @returns True if value is a BrowserDestroyedError instance; false otherwise
474
519
  */
475
520
  export declare function isBrowserDestroyedError(value: unknown): value is BrowserDestroyedError;
476
521
 
477
522
  /**
478
- * Narrow an unknown value to BrowserNotConnectedError.
523
+ * Narrows an unknown value to BrowserNotConnectedError.
479
524
  *
480
525
  * @param value - Value to check
481
- * @returns True when value is a BrowserNotConnectedError instance
526
+ * @returns True if value is a BrowserNotConnectedError instance; false otherwise
482
527
  */
483
528
  export declare function isBrowserNotConnectedError(value: unknown): value is BrowserNotConnectedError;
484
529
 
485
530
  /**
486
- * Launch a browser process with raw-CDP debugging flags.
531
+ * Launches a browser process with raw-CDP debugging flags.
487
532
  *
488
533
  * @remarks
489
534
  * POSIX launches own an isolated process group so lifecycle teardown can
@@ -503,11 +548,11 @@ export declare function isBrowserNotConnectedError(value: unknown): value is Bro
503
548
  */
504
549
  export declare function launchBrowserProcess(executable: string, port: number, headless: boolean, profile?: string, extra?: readonly string[]): ChildProcess;
505
550
 
506
- /** Normalize an executable path for cross-source deduplication (case-insensitive on Windows). */
551
+ /** Normalizes an executable path for cross-source deduplication (case-insensitive on Windows). */
507
552
  export declare function normalizeExecutablePath(path: string, platform: string): string;
508
553
 
509
554
  /**
510
- * Classify an executable path/name into a {@link BrowserEngine} by
555
+ * Classifies an executable path/name into a {@link BrowserEngine} by
511
556
  * case-insensitive hint, checked in the order edge → chromium → chrome.
512
557
  *
513
558
  * @param executable - Executable path or command name to classify
@@ -515,11 +560,8 @@ export declare function normalizeExecutablePath(path: string, platform: string):
515
560
  */
516
561
  export declare function parseBrowserEngine(executable: string): BrowserEngine | undefined;
517
562
 
518
- /** Probe PATH (`which`/`where`) for every resolvable command name, in the given order. */
519
- export declare function probeAllPathNames(names: readonly string[], platform: string): readonly string[];
520
-
521
- /** Probe PATH (`which`/`where`) for the first resolvable command name. */
522
- export declare function probePathNames(names: readonly string[], platform: string): string | undefined;
563
+ /** Probes PATH (`which`/`where`) for every resolvable command name, in the given order. */
564
+ export declare function probePathNames(names: readonly string[], platform: string): readonly string[];
523
565
 
524
566
  /**
525
567
  * Returns the first non-empty line of a command's output, without its
@@ -541,7 +583,7 @@ export declare function probePathNames(names: readonly string[], platform: strin
541
583
  export declare function readFirstLine(output: string): string | undefined;
542
584
 
543
585
  /**
544
- * Remove a library-owned isolated browser profile.
586
+ * Removes a library-owned isolated browser profile.
545
587
  *
546
588
  * @remarks
547
589
  * The path must remain a direct child of the operating-system temp directory
@@ -553,7 +595,7 @@ export declare function readFirstLine(output: string): string | undefined;
553
595
  export declare function removeBrowserProfile(profile: BrowserProfileResult): Promise<void>;
554
596
 
555
597
  /**
556
- * One discovered browser executable on this machine.
598
+ * Represents one discovered browser executable on this machine.
557
599
  *
558
600
  * @remarks
559
601
  * Returned by `findSystemBrowsers`/`findSystemBrowser` — pairs the resolved
@@ -565,7 +607,7 @@ export declare type SystemBrowser = {
565
607
  };
566
608
 
567
609
  /**
568
- * Options overriding `findSystemBrowsers`'/`findSystemBrowser`'s candidate sources.
610
+ * Describes the options overriding `findSystemBrowsers`'/`findSystemBrowser`'s candidate sources.
569
611
  *
570
612
  * @remarks
571
613
  * Each field replaces the default candidate list for its category — a field
@@ -594,11 +636,12 @@ export declare interface SystemBrowserOptions {
594
636
  }
595
637
 
596
638
  /**
597
- * Poll a browser's CDP version endpoint until it responds or the timeout elapses.
639
+ * Polls a browser's CDP version endpoint until it responds or the timeout elapses.
598
640
  *
599
641
  * @param port - Port the browser exposes its CDP endpoint on
600
642
  * @param timeout - Maximum time to wait in milliseconds
601
643
  * @param host - Host the browser exposes its CDP endpoint on (default `127.0.0.1`)
644
+ * @param signal - Optional external abort; an abort while waiting rethrows rather than resolving
602
645
  * @returns The browser's WebSocket debugger URL
603
646
  *
604
647
  * @throws When the endpoint does not become ready before the timeout
@@ -606,13 +649,22 @@ export declare interface SystemBrowserOptions {
606
649
  export declare function waitForCDPReady(port: number, timeout: number, host?: string, signal?: AbortSignal): Promise<string>;
607
650
 
608
651
  /**
609
- * `@orkestrel/websocket`-backed raw CDP text transport.
652
+ * Provides a raw CDP text transport backed by `@orkestrel/websocket`.
610
653
  *
611
654
  * @remarks
612
655
  * Performs and validates the RFC 6455 HTTP upgrade, then delegates frame
613
656
  * handling to `@orkestrel/websocket`. Concurrent and repeated `start()` /
614
657
  * `close()` calls share their active transition, and a later `start()` opens a
615
658
  * fresh socket after the prior one closes.
659
+ *
660
+ * @example
661
+ * ```ts
662
+ * import { WebSocketCDPTransport } from '@orkestrel/browser/server'
663
+ *
664
+ * const transport = new WebSocketCDPTransport({ url: 'ws://127.0.0.1:9222/devtools/browser/abc' })
665
+ * await transport.start()
666
+ * await transport.close()
667
+ * ```
616
668
  */
617
669
  export declare class WebSocketCDPTransport implements CDPTransportInterface {
618
670
  #private;
@@ -624,7 +676,7 @@ export declare class WebSocketCDPTransport implements CDPTransportInterface {
624
676
  }
625
677
 
626
678
  /**
627
- * Options for creating a WebSocketCDPTransport.
679
+ * Describes the options for creating a WebSocketCDPTransport.
628
680
  *
629
681
  * @remarks
630
682
  * - `on` — initial event listeners wired at construction
@@ -639,7 +691,4 @@ export declare interface WebSocketCDPTransportOptions {
639
691
  readonly timeout?: number;
640
692
  }
641
693
 
642
- /** Derive Windows install roots from env vars, falling back to well-known literals when absent. */
643
- export declare function windowsRoots(env: Readonly<Record<string, string | undefined>>): readonly string[];
644
-
645
694
  export { }