@orkestrel/browser 0.0.17 → 0.0.19
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/README.md +47 -28
- package/dist/bin/main.js +35 -0
- package/dist/bin/main.js.map +1 -0
- package/dist/src/browser/index.d.ts +841 -0
- package/dist/src/browser/index.js +1640 -0
- package/dist/src/browser/index.js.map +1 -0
- package/dist/src/core/index.cjs +8372 -2494
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +4410 -2110
- package/dist/src/core/index.d.ts +4410 -2110
- package/dist/src/core/index.js +8256 -2473
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +1013 -92
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +288 -39
- package/dist/src/server/index.d.ts +288 -39
- package/dist/src/server/index.js +975 -69
- package/dist/src/server/index.js.map +1 -1
- package/package.json +42 -19
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import type { BrowserContextInterface } from '@orkestrel/browser';
|
|
2
2
|
import type { BrowserContextOptions } from '@orkestrel/browser';
|
|
3
3
|
import { BrowserError } from '@orkestrel/browser';
|
|
4
|
+
import type { BrowserJourney } from '@orkestrel/browser';
|
|
5
|
+
import type { BrowserJourneyRevision } from '@orkestrel/browser';
|
|
6
|
+
import type { BrowserJourneyStoreInterface } from '@orkestrel/browser';
|
|
4
7
|
import type { BrowserPageInterface } from '@orkestrel/browser';
|
|
5
8
|
import type { BrowserPageOptions } from '@orkestrel/browser';
|
|
9
|
+
import type { BrowserRun } from '@orkestrel/browser';
|
|
10
|
+
import type { BrowserRunSlot } from '@orkestrel/browser';
|
|
11
|
+
import type { BrowserRunStoreInterface } from '@orkestrel/browser';
|
|
12
|
+
import type { BrowserStoreOptions } from '@orkestrel/browser';
|
|
13
|
+
import type { BrowserStorePage } from '@orkestrel/browser';
|
|
6
14
|
import type { BrowserViewport } from '@orkestrel/browser';
|
|
7
15
|
import type { BrowserWriterInterface } from '@orkestrel/browser';
|
|
8
16
|
import type { CDPTarget } from '@orkestrel/browser';
|
|
@@ -12,7 +20,9 @@ import type { ChildProcess } from 'node:child_process';
|
|
|
12
20
|
import type { EmitterErrorHandler } from '@orkestrel/emitter';
|
|
13
21
|
import type { EmitterHooks } from '@orkestrel/emitter';
|
|
14
22
|
import type { EmitterInterface } from '@orkestrel/emitter';
|
|
23
|
+
import type { Readable } from 'node:stream';
|
|
15
24
|
import type { Result } from '@orkestrel/contract';
|
|
25
|
+
import type { StdioServerOptions } from '@orkestrel/mcp/server';
|
|
16
26
|
|
|
17
27
|
/**
|
|
18
28
|
* Discovers, launches, connects to, and owns Chromium-family browser sessions.
|
|
@@ -74,6 +84,27 @@ export declare const BROWSER_DEFAULT_CDP_PORT = 9222;
|
|
|
74
84
|
*/
|
|
75
85
|
export declare const BROWSER_DEFAULT_HOST = "127.0.0.1";
|
|
76
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Matches the stderr line Chromium prints when its CDP endpoint accepts connections, and
|
|
89
|
+
* captures the `ws://` endpoint the line names.
|
|
90
|
+
*
|
|
91
|
+
* @remarks
|
|
92
|
+
* Chromium prints the line only when launched with `--remote-debugging-port`, which is why an
|
|
93
|
+
* owned launch always passes that flag.
|
|
94
|
+
*/
|
|
95
|
+
export declare const BROWSER_DEVTOOLS_PATTERN: RegExp;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Sets the interval in milliseconds between liveness probes of a terminated browser process
|
|
99
|
+
* group.
|
|
100
|
+
*
|
|
101
|
+
* @remarks
|
|
102
|
+
* Node raises an exit event for the direct child only. Neither the rest of a POSIX process
|
|
103
|
+
* group nor a process a launcher handed the endpoint to raises one, so the bounded drain in
|
|
104
|
+
* `Browser` probes on this interval until the group is gone or the grace period ends.
|
|
105
|
+
*/
|
|
106
|
+
export declare const BROWSER_DRAIN_INTERVAL_MS = 100;
|
|
107
|
+
|
|
77
108
|
/**
|
|
78
109
|
* Lists the case-insensitive substrings identifying an executable path/name's browser
|
|
79
110
|
* engine, checked by `parseBrowserEngine` in the order `edge` → `chromium` → `chrome`.
|
|
@@ -96,11 +127,26 @@ export declare const BROWSER_EXECUTABLE_NAMES: readonly string[];
|
|
|
96
127
|
*/
|
|
97
128
|
export declare const BROWSER_EXECUTABLE_PATHS: Readonly<Record<string, readonly string[]>>;
|
|
98
129
|
|
|
130
|
+
/** Bounds a file-store listing page by default. */
|
|
131
|
+
export declare const BROWSER_FILE_STORE_LIMIT = 100;
|
|
132
|
+
|
|
99
133
|
/**
|
|
100
134
|
* Names the flag that enables headless mode on a launched browser process, `'--headless=new'`.
|
|
101
135
|
*/
|
|
102
136
|
export declare const BROWSER_HEADLESS_ARG = "--headless=new";
|
|
103
137
|
|
|
138
|
+
/** Bounds attempts to acquire a journey lock after concurrent recovery. */
|
|
139
|
+
export declare const BROWSER_JOURNEY_LOCK_ATTEMPTS = 8;
|
|
140
|
+
|
|
141
|
+
/** Names the exclusive journey write lock directory. */
|
|
142
|
+
export declare const BROWSER_JOURNEY_LOCK_DIRECTORY = "journey.lock";
|
|
143
|
+
|
|
144
|
+
/** Names the retained journey revision counter. */
|
|
145
|
+
export declare const BROWSER_JOURNEY_REVISION_FILE = "revision";
|
|
146
|
+
|
|
147
|
+
/** Names the persisted journey snapshot. */
|
|
148
|
+
export declare const BROWSER_JOURNEY_SNAPSHOT_FILE = "journey.json";
|
|
149
|
+
|
|
104
150
|
/**
|
|
105
151
|
* Bounds each launched-process exit window during TERM-to-KILL teardown at `3_000`
|
|
106
152
|
* milliseconds.
|
|
@@ -129,6 +175,12 @@ export declare const BROWSER_PROCESS_EXIT_CAUSE = "process-exit";
|
|
|
129
175
|
*/
|
|
130
176
|
export declare const BROWSER_PROFILE_PREFIX = "orkestrel-browser-";
|
|
131
177
|
|
|
178
|
+
/** Names the journey directory holding its runs. */
|
|
179
|
+
export declare const BROWSER_RUN_DIRECTORY = "runs";
|
|
180
|
+
|
|
181
|
+
/** Names the persisted run snapshot. */
|
|
182
|
+
export declare const BROWSER_RUN_FILE = "run.json";
|
|
183
|
+
|
|
132
184
|
/** Names the per-OS default Playwright browser cache directory, relative to the home directory (win32 uses `LOCALAPPDATA` directly). */
|
|
133
185
|
export declare const BROWSER_STORE_CACHE_DIRS: Readonly<Record<string, string>>;
|
|
134
186
|
|
|
@@ -161,8 +213,8 @@ export declare const BROWSER_TRANSPORT_LOSS_CAUSE = "transport-loss";
|
|
|
161
213
|
|
|
162
214
|
/**
|
|
163
215
|
* Defers once for `50` milliseconds when a transport loss is observed on an owned process,
|
|
164
|
-
*
|
|
165
|
-
* socket close,
|
|
216
|
+
* so a near-simultaneous process-exit event, which libuv might reap slightly later than the
|
|
217
|
+
* socket close, decides the diagnosis first.
|
|
166
218
|
*/
|
|
167
219
|
export declare const BROWSER_TRANSPORT_LOSS_DEFER_MS = 50;
|
|
168
220
|
|
|
@@ -200,14 +252,6 @@ export declare interface BrowserCDPOptions {
|
|
|
200
252
|
/** Names how the browser connection was established. */
|
|
201
253
|
export declare type BrowserConnection = 'cdp' | 'launch' | 'persistent';
|
|
202
254
|
|
|
203
|
-
/**
|
|
204
|
-
* Reports that a CDP connection, discovery, or launch attempt failed, under the code
|
|
205
|
-
* `BROWSER_CONNECTION_ERROR`.
|
|
206
|
-
*/
|
|
207
|
-
export declare class BrowserConnectionError extends BrowserError {
|
|
208
|
-
constructor(message: string, context?: Readonly<Record<string, unknown>>);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
255
|
/**
|
|
212
256
|
* Reports that an operation was attempted after the browser wrapper was destroyed, under the
|
|
213
257
|
* code `BROWSER_DESTROYED_ERROR`.
|
|
@@ -350,11 +394,11 @@ export declare interface BrowserInterface {
|
|
|
350
394
|
/** Assumes responsibility for terminating the connected browser. */
|
|
351
395
|
adopt(): void;
|
|
352
396
|
/**
|
|
353
|
-
* Detaches the client-side transport while the remote browser keeps running.
|
|
354
|
-
*
|
|
355
|
-
* launched or explicitly adopted session retains ownership
|
|
356
|
-
* instance can reconnect and stays responsible for eventual
|
|
357
|
-
* while an owned browser remains alive is resumable the same way.
|
|
397
|
+
* Detaches the client-side transport while the remote browser keeps running. An attached CDP
|
|
398
|
+
* session that this instance neither launched nor adopted forgets the endpoint and its
|
|
399
|
+
* ownership becomes `undefined`. A launched or explicitly adopted session retains ownership
|
|
400
|
+
* and its endpoint, so the same instance can reconnect and stays responsible for eventual
|
|
401
|
+
* termination. Transport loss while an owned browser remains alive is resumable the same way.
|
|
358
402
|
*/
|
|
359
403
|
disconnect(): Promise<void>;
|
|
360
404
|
/** Returns one context by index, or the first. */
|
|
@@ -374,8 +418,9 @@ export declare interface BrowserInterface {
|
|
|
374
418
|
* process group and awaits its drain, and on Windows it terminates one process by
|
|
375
419
|
* identifier, the spawned process or the one a launcher handed the endpoint to — which
|
|
376
420
|
* leaves the profile unlocked before cleanup. An adopted attachment is sent CDP
|
|
377
|
-
* `Browser.close`.
|
|
378
|
-
* other clients
|
|
421
|
+
* `Browser.close`. An attached browser that this instance neither launched nor adopted is
|
|
422
|
+
* detached locally and nothing more, because other clients might share its targets.
|
|
423
|
+
* Idempotent.
|
|
379
424
|
*/
|
|
380
425
|
destroy(): Promise<void>;
|
|
381
426
|
/**
|
|
@@ -389,6 +434,104 @@ export declare interface BrowserInterface {
|
|
|
389
434
|
close(): Promise<void>;
|
|
390
435
|
}
|
|
391
436
|
|
|
437
|
+
/**
|
|
438
|
+
* Creates the browser a browse server connects on its first tool call.
|
|
439
|
+
*
|
|
440
|
+
* @param options - The launch the server composes: `headless`, `executable`, the profile it
|
|
441
|
+
* owns, `cdp.discover` set to `false`, and the signal its `destroy()` aborts
|
|
442
|
+
* @returns A browser whose `connect()` launches it
|
|
443
|
+
*/
|
|
444
|
+
export declare type BrowserLaunchFunction = (options: BrowserOptions) => BrowserInterface;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Implements `BrowserMCPServerInterface`: serves the browser vocabulary and the journey tools over
|
|
448
|
+
* the Model Context Protocol on stdio, and launches Chromium on the first tool call.
|
|
449
|
+
*
|
|
450
|
+
* @remarks
|
|
451
|
+
* The server's own manager holds one dispatcher per name of the vocabulary — `look`, `read`,
|
|
452
|
+
* `click`, `type`, `press`, `navigate`, `wait`, `dialog`, `tabs`, `switch`, `record`, `save`,
|
|
453
|
+
* `journeys`, `edit`, and `replay` — each carrying the description, parameters, and annotations
|
|
454
|
+
* `BROWSER_TOOL_COPY` gives, so `tools/list` answers before Chromium starts and with Chromium
|
|
455
|
+
* absent. After the launch, a tool the toolset's manager adds under another name, such as a page
|
|
456
|
+
* tool it adopts, is mirrored as a dispatcher with that tool's definition, and the mirror is
|
|
457
|
+
* removed when the toolset withdraws the tool, so the server's tool list changes and a subscribed
|
|
458
|
+
* client is notified. The first call of any dispatcher launches Chromium one time: concurrent callers await
|
|
459
|
+
* the same launch, a failed launch rejects every one of them, and the next call launches again.
|
|
460
|
+
* A launch creates `ROOT/.profiles/ID/` exclusively, connects a browser that never attaches to an
|
|
461
|
+
* existing endpoint, opens one page in an isolated context, and constructs the page toolset with
|
|
462
|
+
* that context and the file journey and run stores under the root, on a manager the toolset owns.
|
|
463
|
+
* A dispatcher forwards its arguments and the call's context, signal included, to the toolset's
|
|
464
|
+
* manager and returns that manager's value, or rejects with its failure message; a text value
|
|
465
|
+
* reaches the client as one text block rather than as its JSON text.
|
|
466
|
+
*
|
|
467
|
+
* `start()` serves stdio and destroys the server at the end of its input, on `SIGINT`, and on
|
|
468
|
+
* `SIGTERM`. `destroy()` stops reading requests and removes every dispatcher, then destroys the
|
|
469
|
+
* toolset, which aborts the active replay, then the browser it launched, then removes the profile.
|
|
470
|
+
*
|
|
471
|
+
* Chromium on Linux refuses to start as the root user unless its sandbox is disabled, so a server
|
|
472
|
+
* running as root on Linux launches Chromium with `--no-sandbox`; a launch that could run
|
|
473
|
+
* sandboxed is never changed.
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```ts
|
|
477
|
+
* import { BrowserMCPServer } from '@orkestrel/browser/server'
|
|
478
|
+
*
|
|
479
|
+
* const server = new BrowserMCPServer({ root: 'tmp/browsers', readonly: true })
|
|
480
|
+
* await server.start()
|
|
481
|
+
* await server.destroy()
|
|
482
|
+
* ```
|
|
483
|
+
*/
|
|
484
|
+
export declare class BrowserMCPServer implements BrowserMCPServerInterface {
|
|
485
|
+
#private;
|
|
486
|
+
/**
|
|
487
|
+
* Registers the dispatchers and binds the protocol to the stdio streams without reading them.
|
|
488
|
+
*
|
|
489
|
+
* @param options - The root, the launch, the journeys' read-only switch, and the streams
|
|
490
|
+
*/
|
|
491
|
+
constructor(options?: BrowserMCPServerOptions);
|
|
492
|
+
start(): Promise<void>;
|
|
493
|
+
destroy(): Promise<void>;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/** Serves the browser vocabulary and the journey tools over MCP on stdio. */
|
|
497
|
+
export declare interface BrowserMCPServerInterface {
|
|
498
|
+
/**
|
|
499
|
+
* Serves the tool list over stdio before Chromium starts; the first tool call launches Chromium
|
|
500
|
+
* with a profile the server owns.
|
|
501
|
+
*/
|
|
502
|
+
start(): Promise<void>;
|
|
503
|
+
/**
|
|
504
|
+
* Stops admission, aborts the active replay, destroys the toolset and the browser it launched,
|
|
505
|
+
* and removes its profile.
|
|
506
|
+
*/
|
|
507
|
+
destroy(): Promise<void>;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Configures the browse server.
|
|
512
|
+
*
|
|
513
|
+
* @remarks
|
|
514
|
+
* - `root` — the directory the journeys, the runs, and the browser profiles live under, resolved
|
|
515
|
+
* against the working directory at construction. Default: `tmp/browsers`
|
|
516
|
+
* - `headless` — if `true`, launches Chromium without a window; if `false`, with one. Default:
|
|
517
|
+
* `true`
|
|
518
|
+
* - `executable` — the path of the Chromium executable the server launches. Default: the browser
|
|
519
|
+
* `findSystemBrowser` finds
|
|
520
|
+
* - `readonly` — if `true`, refuses `record`, `save`, and `edit`, and `replay` still writes runs;
|
|
521
|
+
* if `false` or omitted, every tool runs
|
|
522
|
+
* - `launch` — creates the browser the first tool call connects. Default: `createBrowser`
|
|
523
|
+
* - `stdio` — the streams the server reads requests from and writes answers to; the end of
|
|
524
|
+
* `input` destroys the server. Default: `process.stdin` and `process.stdout`
|
|
525
|
+
*/
|
|
526
|
+
export declare interface BrowserMCPServerOptions {
|
|
527
|
+
readonly root?: string;
|
|
528
|
+
readonly headless?: boolean;
|
|
529
|
+
readonly executable?: string;
|
|
530
|
+
readonly readonly?: boolean;
|
|
531
|
+
readonly launch?: BrowserLaunchFunction;
|
|
532
|
+
readonly stdio?: StdioServerOptions;
|
|
533
|
+
}
|
|
534
|
+
|
|
392
535
|
/**
|
|
393
536
|
* Reports that an operation requiring an active connection was attempted while disconnected,
|
|
394
537
|
* under the code `BROWSER_NOT_CONNECTED_ERROR`.
|
|
@@ -476,13 +619,31 @@ export declare function buildWindowsRoots(env: Readonly<Record<string, string |
|
|
|
476
619
|
* const browser = createBrowser({ headless: true })
|
|
477
620
|
* await browser.connect() // CDP endpoint discovery → connect, else launch
|
|
478
621
|
* const page = await browser.create({ url: 'https://example.com' })
|
|
479
|
-
* await page.
|
|
622
|
+
* await (await page.elements.find({ css: '#accept' }))[0]?.click()
|
|
480
623
|
* const shot = await page.screenshot({ path: './out.png' })
|
|
481
624
|
* await browser.destroy()
|
|
482
625
|
* ```
|
|
483
626
|
*/
|
|
484
627
|
export declare function createBrowser(options?: BrowserOptions): BrowserInterface;
|
|
485
628
|
|
|
629
|
+
/**
|
|
630
|
+
* Creates the browse server, which serves the browser vocabulary and the journey tools over the
|
|
631
|
+
* Model Context Protocol on stdio and launches Chromium on the first tool call.
|
|
632
|
+
*
|
|
633
|
+
* @param options - The root, the launch, the journeys' read-only switch, and the streams
|
|
634
|
+
* @returns A {@link BrowserMCPServerInterface} that reads nothing until `start()`
|
|
635
|
+
*
|
|
636
|
+
* @example
|
|
637
|
+
* ```ts
|
|
638
|
+
* import { createBrowserMCPServer } from '@orkestrel/browser/server'
|
|
639
|
+
*
|
|
640
|
+
* const server = createBrowserMCPServer({ root: 'tmp/browsers', headless: true })
|
|
641
|
+
* await server.start() // answers tools/list before Chromium starts
|
|
642
|
+
* await server.destroy()
|
|
643
|
+
* ```
|
|
644
|
+
*/
|
|
645
|
+
export declare function createBrowserMCPServer(options?: BrowserMCPServerOptions): BrowserMCPServerInterface;
|
|
646
|
+
|
|
486
647
|
/**
|
|
487
648
|
* Resolves a persistent caller profile or creates an isolated temporary one.
|
|
488
649
|
*
|
|
@@ -507,6 +668,24 @@ export declare function createBrowserWriter(): BrowserWriterInterface;
|
|
|
507
668
|
*/
|
|
508
669
|
export declare function createCDPTransport(options: WebSocketCDPTransportOptions): CDPTransportInterface;
|
|
509
670
|
|
|
671
|
+
/**
|
|
672
|
+
* Creates a journey store over an existing filesystem root.
|
|
673
|
+
* @param options - Root and listing cap
|
|
674
|
+
* @returns A durable journey store
|
|
675
|
+
* @example
|
|
676
|
+
* const store = createFileBrowserJourneyStore({ root: directory })
|
|
677
|
+
*/
|
|
678
|
+
export declare function createFileBrowserJourneyStore(options: FileBrowserStoreOptions): BrowserJourneyStoreInterface;
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Creates a run store over an existing filesystem root.
|
|
682
|
+
* @param options - Root and listing cap
|
|
683
|
+
* @returns A durable run and capture store
|
|
684
|
+
* @example
|
|
685
|
+
* const store = createFileBrowserRunStore({ root: directory })
|
|
686
|
+
*/
|
|
687
|
+
export declare function createFileBrowserRunStore(options: FileBrowserStoreOptions): BrowserRunStoreInterface;
|
|
688
|
+
|
|
510
689
|
/**
|
|
511
690
|
* Fetches the current CDP target list from a browser's `/json/list` endpoint, as a `Result`
|
|
512
691
|
* carrying either the targets or a coded `BrowserConnectionError`.
|
|
@@ -533,6 +712,60 @@ export declare function createCDPTransport(options: WebSocketCDPTransportOptions
|
|
|
533
712
|
*/
|
|
534
713
|
export declare function fetchCDPTargets(port: number, timeout: number, host?: string): Promise<Result<readonly CDPTarget[], BrowserError>>;
|
|
535
714
|
|
|
715
|
+
/**
|
|
716
|
+
* Persists journeys with exclusive writes and revision counters retained across deletion.
|
|
717
|
+
* @remarks Requires an existing root. A live holder refuses immediately; dead or empty locks are reclaimed within a bounded attempt count.
|
|
718
|
+
* @example
|
|
719
|
+
* const store = new FileBrowserJourneyStore({ root: directory })
|
|
720
|
+
* await store.set(journey)
|
|
721
|
+
*/
|
|
722
|
+
export declare class FileBrowserJourneyStore implements BrowserJourneyStoreInterface {
|
|
723
|
+
#private;
|
|
724
|
+
constructor(options: FileBrowserStoreOptions);
|
|
725
|
+
get(name: string, options?: BrowserStoreOptions): Promise<BrowserJourneyRevision | undefined>;
|
|
726
|
+
set(journey: BrowserJourney, expected?: number, options?: BrowserStoreOptions): Promise<BrowserJourneyRevision>;
|
|
727
|
+
delete(name: string, options?: BrowserStoreOptions): Promise<void>;
|
|
728
|
+
list(options?: BrowserStoreOptions & {
|
|
729
|
+
readonly offset?: number;
|
|
730
|
+
readonly limit?: number;
|
|
731
|
+
}): Promise<BrowserStorePage<BrowserJourneyRevision>>;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Persists runs and captures only in directories allocated by this instance.
|
|
736
|
+
* @remarks Requires an existing root. Reopened stores can read and delete saved runs.
|
|
737
|
+
* @example
|
|
738
|
+
* const store = new FileBrowserRunStore({ root: directory })
|
|
739
|
+
* const slot = await store.open('check-ready')
|
|
740
|
+
*/
|
|
741
|
+
export declare class FileBrowserRunStore implements BrowserRunStoreInterface {
|
|
742
|
+
#private;
|
|
743
|
+
constructor(options: FileBrowserStoreOptions);
|
|
744
|
+
open(name: string, options?: BrowserStoreOptions): Promise<BrowserRunSlot>;
|
|
745
|
+
get(name: string, id: string, options?: BrowserStoreOptions): Promise<BrowserRun | undefined>;
|
|
746
|
+
set(run: BrowserRun, options?: BrowserStoreOptions): Promise<void>;
|
|
747
|
+
capture(slot: BrowserRunSlot, name: string, bytes: Uint8Array, options?: BrowserStoreOptions): Promise<string>;
|
|
748
|
+
delete(name: string, id: string, options?: BrowserStoreOptions): Promise<void>;
|
|
749
|
+
clear(name: string, options?: BrowserStoreOptions): Promise<number>;
|
|
750
|
+
list(name: string, options?: BrowserStoreOptions & {
|
|
751
|
+
readonly offset?: number;
|
|
752
|
+
readonly limit?: number;
|
|
753
|
+
}): Promise<BrowserStorePage<BrowserRun>>;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* Configures a file store: its root under the checkout and the listing cap.
|
|
758
|
+
*
|
|
759
|
+
* @remarks
|
|
760
|
+
* - `root` — the directory the store keeps its entries under, such as `tmp/browsers`, resolved
|
|
761
|
+
* through `realpath` one time; every path the store reads or writes lies inside it
|
|
762
|
+
* - `limit` — the most entries one `list` page holds
|
|
763
|
+
*/
|
|
764
|
+
export declare interface FileBrowserStoreOptions {
|
|
765
|
+
readonly root: string;
|
|
766
|
+
readonly limit?: number;
|
|
767
|
+
}
|
|
768
|
+
|
|
536
769
|
/**
|
|
537
770
|
* Persists captured browser bytes to the filesystem through `node:fs/promises`.
|
|
538
771
|
*
|
|
@@ -602,12 +835,14 @@ export declare function findSystemBrowser(options?: SystemBrowserOptions): Syste
|
|
|
602
835
|
export declare function findSystemBrowsers(options?: SystemBrowserOptions): readonly SystemBrowser[];
|
|
603
836
|
|
|
604
837
|
/**
|
|
605
|
-
*
|
|
606
|
-
*
|
|
607
|
-
* @param
|
|
608
|
-
* @returns
|
|
838
|
+
* Formats a process identifier and UUID token as a lock entry name.
|
|
839
|
+
* @param pid - Positive safe integer identifying the holder process
|
|
840
|
+
* @param token - Lowercase UUID token identifying this acquisition
|
|
841
|
+
* @returns The entry name
|
|
842
|
+
* @example
|
|
843
|
+
* formatBrowserLockEntry(123, '11111111-1111-4111-8111-111111111111')
|
|
609
844
|
*/
|
|
610
|
-
export declare function
|
|
845
|
+
export declare function formatBrowserLockEntry(pid: number, token: string): string;
|
|
611
846
|
|
|
612
847
|
/**
|
|
613
848
|
* Narrows an unknown value to a `BrowserDestroyedError`.
|
|
@@ -638,13 +873,13 @@ export declare function isBrowserNotConnectedError(value: unknown): value is Bro
|
|
|
638
873
|
* subprocesses with it, so that single signal drains the tree.
|
|
639
874
|
*
|
|
640
875
|
* @param executable - Absolute path to the browser executable
|
|
641
|
-
* @param port - Port the browser exposes its CDP endpoint on
|
|
876
|
+
* @param port - Port the browser exposes its CDP endpoint on, or undefined for a port the operating system picks
|
|
642
877
|
* @param headless - Whether to launch in headless mode
|
|
643
878
|
* @param profile - Optional user-data-dir for a persistent profile
|
|
644
879
|
* @param extra - Additional command-line flags
|
|
645
|
-
* @returns The spawned ChildProcess
|
|
880
|
+
* @returns The spawned ChildProcess, whose standard error carries the endpoint line `readBrowserEndpoint` reads
|
|
646
881
|
*/
|
|
647
|
-
export declare function launchBrowserProcess(executable: string, port: number, headless: boolean, profile?: string, extra?: readonly string[]): ChildProcess;
|
|
882
|
+
export declare function launchBrowserProcess(executable: string, port: number | undefined, headless: boolean, profile?: string, extra?: readonly string[]): ChildProcess;
|
|
648
883
|
|
|
649
884
|
/** Normalizes an executable path for cross-source deduplication (case-insensitive on Windows). */
|
|
650
885
|
export declare function normalizeExecutablePath(path: string, platform: string): string;
|
|
@@ -658,9 +893,36 @@ export declare function normalizeExecutablePath(path: string, platform: string):
|
|
|
658
893
|
*/
|
|
659
894
|
export declare function parseBrowserEngine(executable: string): BrowserEngine | undefined;
|
|
660
895
|
|
|
896
|
+
/**
|
|
897
|
+
* Parses the holder process identifier from a lock entry name.
|
|
898
|
+
* @remarks Requires a positive safe integer followed by a lowercase UUID token.
|
|
899
|
+
* @param name - Directory entry name
|
|
900
|
+
* @returns The process identifier, or undefined when the entry is malformed
|
|
901
|
+
* @example
|
|
902
|
+
* parseBrowserLockEntry('123-11111111-1111-4111-8111-111111111111') // 123
|
|
903
|
+
*/
|
|
904
|
+
export declare function parseBrowserLockEntry(name: string): number | undefined;
|
|
905
|
+
|
|
661
906
|
/** Probes PATH (`which`/`where`) for every resolvable command name, in the given order. */
|
|
662
907
|
export declare function probePathNames(names: readonly string[], platform: string): readonly string[];
|
|
663
908
|
|
|
909
|
+
/**
|
|
910
|
+
* Reads the CDP endpoint a launched browser announces on its standard error.
|
|
911
|
+
*
|
|
912
|
+
* @remarks
|
|
913
|
+
* Chromium prints `DevTools listening on ws://HOST:PORT/devtools/browser/ID` after it binds the
|
|
914
|
+
* debugging port. The read splits arriving text on line breaks across chunks, so a line split
|
|
915
|
+
* between two chunks and a line ending `\r\n` both resolve. After resolving, the stream keeps
|
|
916
|
+
* draining until it closes so the browser's logging never fills the pipe.
|
|
917
|
+
*
|
|
918
|
+
* @param stream - The browser's standard error
|
|
919
|
+
* @param signal - Abort that rejects the read with its reason
|
|
920
|
+
* @returns The `ws://` endpoint the browser announced
|
|
921
|
+
*
|
|
922
|
+
* @throws When the stream closes without the line, or the signal aborts first
|
|
923
|
+
*/
|
|
924
|
+
export declare function readBrowserEndpoint(stream: Readable, signal: AbortSignal): Promise<string>;
|
|
925
|
+
|
|
664
926
|
/**
|
|
665
927
|
* Returns the first non-empty line of a command's output, without its
|
|
666
928
|
* surrounding whitespace.
|
|
@@ -733,19 +995,6 @@ export declare interface SystemBrowserOptions {
|
|
|
733
995
|
readonly engine?: BrowserEngine;
|
|
734
996
|
}
|
|
735
997
|
|
|
736
|
-
/**
|
|
737
|
-
* Polls a browser's CDP version endpoint until it responds or the timeout elapses.
|
|
738
|
-
*
|
|
739
|
-
* @param port - Port the browser exposes its CDP endpoint on
|
|
740
|
-
* @param timeout - Maximum time to wait in milliseconds
|
|
741
|
-
* @param host - Host the browser exposes its CDP endpoint on (default `127.0.0.1`)
|
|
742
|
-
* @param signal - Optional external abort; an abort while waiting rethrows rather than resolving
|
|
743
|
-
* @returns The browser's WebSocket debugger URL
|
|
744
|
-
*
|
|
745
|
-
* @throws When the endpoint does not become ready before the timeout
|
|
746
|
-
*/
|
|
747
|
-
export declare function waitForCDPReady(port: number, timeout: number, host?: string, signal?: AbortSignal): Promise<string>;
|
|
748
|
-
|
|
749
998
|
/**
|
|
750
999
|
* Provides a raw CDP text transport backed by `@orkestrel/websocket`.
|
|
751
1000
|
*
|