@orkestrel/browser 0.0.24 → 0.0.26

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.
@@ -160,7 +160,15 @@ export declare const BROWSER_JOURNEY_SNAPSHOT_FILE = "journey.json";
160
160
  */
161
161
  export declare const BROWSER_KILL_GRACE_MS = 3000;
162
162
 
163
- /** Lists the flags always passed to a launched browser process, alongside the caller's own. */
163
+ /**
164
+ * Lists the flags always passed to a launched browser process, alongside the caller's own.
165
+ *
166
+ * @remarks
167
+ * Disables account sync so extension installs cannot reset URL loader factories during page imports.
168
+ * Disables Edge's implicit sign-in so fresh automation profiles carry no Microsoft account.
169
+ * Chromium ignores the unknown Edge feature name on Chrome and Chromium.
170
+ * The launcher merges disabled features with the caller's into one switch.
171
+ */
164
172
  export declare const BROWSER_LAUNCH_ARGS: readonly string[];
165
173
 
166
174
  /**
@@ -191,6 +199,12 @@ export declare const BROWSER_RUN_FILE = "run.json";
191
199
  /** Names the refusal when every browser is admitted to a holder. */
192
200
  export declare const BROWSER_SERVER_BUSY = "BROWSER_SERVER_BUSY";
193
201
 
202
+ /** Sets the default context capacity per browser, including the shared holder. */
203
+ export declare const BROWSER_SERVER_CONTEXTS = 2;
204
+
205
+ /** Limits context capacity to the largest measured per-browser count. */
206
+ export declare const BROWSER_SERVER_CONTEXTS_LIMIT = 4;
207
+
194
208
  /** Defines the holder tools independently of the shared browser's vocabulary. */
195
209
  export declare const BROWSER_SERVER_COPY: Readonly<Record<BrowserServerToolName, ToolDefinition>>;
196
210
 
@@ -512,17 +526,18 @@ export declare type BrowserLaunchFunction = (options: BrowserOptions) => Browser
512
526
  * tool it adopts, is mirrored as a dispatcher with that tool's definition, and the mirror is
513
527
  * removed when the toolset withdraws the tool, so the server's tool list changes and a subscribed
514
528
  * client is notified. The server also advertises `acquire`, `execute`, `tools`, and `destroy` with
515
- * `BROWSER_SERVER_COPY`. Startup warms the pool and leases the shared browser. The legacy
529
+ * `BROWSER_SERVER_COPY`. Startup warms the pool and assigns a prepared context to the shared holder. The legacy
516
530
  * handshake and browser calls await that setup. Named holders each own a lease, a pending grant,
517
531
  * and loss notices; concurrent calls on a holder share its replacement grant. Ending a holder
518
- * destroys its token, and admission counts that holder until disposal settles.
532
+ * closes its context and releases its lease, and admission counts that holder until disposal settles.
519
533
  * A launch creates `ROOT/.profiles/PID-UUID/` exclusively, connects a browser that never attaches to an
520
534
  * existing endpoint, opens one page in an isolated context, and constructs the page toolset with
521
535
  * that context and the file journey and run stores under the root, on a manager the toolset owns.
522
536
  * A dispatcher forwards its arguments and the call's context, signal included, to the toolset's
523
537
  * manager and returns that manager's value, or rejects with its failure message; a text value
524
538
  * reaches the client as one text block rather than as its JSON text.
525
- * A disconnect or current-page crash retires its slot. A failed call receives a liveness ping;
539
+ * A disconnect retires its browser and every hosted generation. A current-page crash retires only
540
+ * that holder's context. A failed call receives a liveness ping;
526
541
  * loss makes its outcome unresolved, while a known success remains successful. Pending losses
527
542
  * prefix the next outcome on a successor, or a refusal, and calls are never repeated.
528
543
  * Concurrent checks share one ping per slot. Cancelling a call ends only its wait; the ping keeps
@@ -530,7 +545,8 @@ export declare type BrowserLaunchFunction = (options: BrowserOptions) => Browser
530
545
  *
531
546
  * `start()` serves stdio and destroys the server at the end of its input, on `SIGINT`, and on
532
547
  * `SIGTERM`. `destroy()` stops reading requests and removes every dispatcher, then destroys every
533
- * slot through the pool — its toolset, which aborts the active replay, then its browser, then its
548
+ * slot through the pool — each toolset, which aborts its active replay, then its context and downloads,
549
+ * then its browser and its
534
550
  * profile — and rechecks the profile folders this server made or kept.
535
551
  *
536
552
  * Chromium on Linux refuses to start as the root user unless its sandbox is disabled, so a server
@@ -562,7 +578,7 @@ export declare class BrowserMCPServer implements BrowserMCPServerInterface {
562
578
  export declare interface BrowserMCPServerInterface {
563
579
  /**
564
580
  * Serves stdio, sweeps the profiles ended servers left, warms the pool, and resolves after the
565
- * shared holder leases a warm browser; the legacy handshake and every tool call await the same setup.
581
+ * shared holder consumes a prepared context on a warm browser; the legacy handshake and every tool call await the same setup.
566
582
  * Rejects with `BROWSER_SERVER_UNAVAILABLE` when no browser can serve and with
567
583
  * `BROWSER_TOOLSET_ENDED` after `destroy()`, and resolves when `destroy()` interrupts setup.
568
584
  */
@@ -592,8 +608,10 @@ export declare interface BrowserMCPServerInterface {
592
608
  * `input` destroys the server. Default: `process.stdin` and `process.stdout`
593
609
  * - `pool.size` — the integer number of browsers kept warm, from 1 through
594
610
  * `BROWSER_SERVER_POOL_LIMIT`. Default: `BROWSER_SERVER_POOL_SIZE`.
611
+ * - `pool.contexts` — the integer context capacity per browser, shared holder included, from 1
612
+ * through `BROWSER_SERVER_CONTEXTS_LIMIT`. Default: `BROWSER_SERVER_CONTEXTS`.
595
613
  * - `log` — receives diagnostic lines. Default: `process.stderr`
596
- * @throws Thrown when `pool.size` is outside that range or is not an integer, with `BROWSER_SERVER_OPTIONS`
614
+ * @throws Thrown when `pool.size` or `pool.contexts` is outside its range or is not an integer, with `BROWSER_SERVER_OPTIONS`
597
615
  */
598
616
  export declare interface BrowserMCPServerOptions {
599
617
  readonly root?: string;
@@ -605,6 +623,7 @@ export declare interface BrowserMCPServerOptions {
605
623
  readonly stdio?: StdioServerOptions;
606
624
  readonly pool?: {
607
625
  readonly size?: number;
626
+ readonly contexts?: number;
608
627
  };
609
628
  readonly log?: NodeJS.WritableStream;
610
629
  }
@@ -679,6 +698,13 @@ export declare interface BrowserServerCatalog {
679
698
  readonly tools: readonly ToolDefinition[];
680
699
  }
681
700
 
701
+ /** Holds one prepared or assigned context generation and its downloads directory. */
702
+ export declare interface BrowserServerContext {
703
+ readonly context: BrowserContextInterface;
704
+ readonly toolset: BrowserToolsetInterface;
705
+ readonly directory: string;
706
+ }
707
+
682
708
  /** Identifies one admitted browser lifetime independently of its current pool token. */
683
709
  export declare interface BrowserServerHolder {
684
710
  readonly id: string;
@@ -686,9 +712,21 @@ export declare interface BrowserServerHolder {
686
712
  readonly abort: AbortController;
687
713
  }
688
714
 
689
- /** Binds shared catalog subscriptions to the exact token that published them. */
690
- export declare interface BrowserServerMirror {
715
+ /** Binds a holder generation to the exact browser lease reserved for its lifetime. */
716
+ export declare interface BrowserServerLease {
691
717
  readonly token: PoolToken<BrowserSlot>;
718
+ readonly generation: BrowserServerContext;
719
+ }
720
+
721
+ /** Records a lost generation's cause and its own last URL. */
722
+ export declare interface BrowserServerLoss {
723
+ readonly cause: unknown;
724
+ readonly url: string;
725
+ }
726
+
727
+ /** Binds shared catalog subscriptions to the exact generation that published them. */
728
+ export declare interface BrowserServerMirror {
729
+ readonly lease: BrowserServerLease;
692
730
  readonly added: (tool: ToolInterface) => void;
693
731
  readonly removed: (tool: ToolInterface) => void;
694
732
  readonly cleared: (tools: readonly ToolInterface[]) => void;
@@ -697,20 +735,22 @@ export declare interface BrowserServerMirror {
697
735
  /** Names the server tools that manage independent browser holders. */
698
736
  export declare type BrowserServerToolName = 'acquire' | 'execute' | 'tools' | 'destroy';
699
737
 
700
- /** Holds one warm browser a browse server owns: the browser, its profile, its isolated context, and its started toolset. */
738
+ /** Holds page subscriptions for one prepared or assigned context generation. */
739
+ export declare interface BrowserServerWatch {
740
+ readonly page: (page: BrowserPageInterface) => void;
741
+ readonly crashes: ReadonlyMap<BrowserPageInterface, () => void>;
742
+ }
743
+
744
+ /** Holds one pooled browser and its exclusively owned profile. */
701
745
  export declare interface BrowserSlot {
702
746
  readonly browser: BrowserInterface;
703
747
  readonly profile: string;
704
- readonly context: BrowserContextInterface;
705
- readonly toolset: BrowserToolsetInterface;
706
748
  }
707
749
 
708
750
  /** Holds the listeners and resolver of one browser slot's loss watch. */
709
751
  export declare interface BrowserSlotWatch {
710
752
  readonly resolve: (cause: unknown) => void;
711
753
  readonly disconnect: () => void;
712
- readonly page: (page: BrowserPageInterface) => void;
713
- readonly crashes: ReadonlyMap<BrowserPageInterface, () => void>;
714
754
  readonly subscription: Disposable;
715
755
  }
716
756
 
@@ -869,6 +909,8 @@ export declare class FileBrowserJourneyStore implements BrowserJourneyStoreInter
869
909
  /**
870
910
  * Persists runs and captures only in directories allocated by this instance.
871
911
  * @remarks Requires an existing root. Reopened stores can read and delete saved runs.
912
+ * Allocations of one journey share a process-local queue across instances; the filesystem lock
913
+ * still refuses conflicting mutations and allocations from another process.
872
914
  * @example
873
915
  * const store = new FileBrowserRunStore({ root: directory })
874
916
  * const slot = await store.open('check-ready')
@@ -1000,6 +1042,10 @@ export declare function isBrowserNotConnectedError(value: unknown): value is Bro
1000
1042
  * Launches a browser process with raw-CDP debugging flags.
1001
1043
  *
1002
1044
  * @remarks
1045
+ * Merges every caller and library `--disable-features` value into one switch because Chromium
1046
+ * reads only the last occurrence. Keeps `msImplicitSignin` disabled alongside caller features;
1047
+ * Chrome and Chromium ignore this Edge feature name. Preserves the caller's other arguments.
1048
+ *
1003
1049
  * POSIX launches own an isolated process group so lifecycle teardown can
1004
1050
  * signal and await every Chromium subprocess without affecting the caller.
1005
1051
  * Windows launches are not detached and own no group, so teardown there
@@ -160,7 +160,15 @@ export declare const BROWSER_JOURNEY_SNAPSHOT_FILE = "journey.json";
160
160
  */
161
161
  export declare const BROWSER_KILL_GRACE_MS = 3000;
162
162
 
163
- /** Lists the flags always passed to a launched browser process, alongside the caller's own. */
163
+ /**
164
+ * Lists the flags always passed to a launched browser process, alongside the caller's own.
165
+ *
166
+ * @remarks
167
+ * Disables account sync so extension installs cannot reset URL loader factories during page imports.
168
+ * Disables Edge's implicit sign-in so fresh automation profiles carry no Microsoft account.
169
+ * Chromium ignores the unknown Edge feature name on Chrome and Chromium.
170
+ * The launcher merges disabled features with the caller's into one switch.
171
+ */
164
172
  export declare const BROWSER_LAUNCH_ARGS: readonly string[];
165
173
 
166
174
  /**
@@ -191,6 +199,12 @@ export declare const BROWSER_RUN_FILE = "run.json";
191
199
  /** Names the refusal when every browser is admitted to a holder. */
192
200
  export declare const BROWSER_SERVER_BUSY = "BROWSER_SERVER_BUSY";
193
201
 
202
+ /** Sets the default context capacity per browser, including the shared holder. */
203
+ export declare const BROWSER_SERVER_CONTEXTS = 2;
204
+
205
+ /** Limits context capacity to the largest measured per-browser count. */
206
+ export declare const BROWSER_SERVER_CONTEXTS_LIMIT = 4;
207
+
194
208
  /** Defines the holder tools independently of the shared browser's vocabulary. */
195
209
  export declare const BROWSER_SERVER_COPY: Readonly<Record<BrowserServerToolName, ToolDefinition>>;
196
210
 
@@ -512,17 +526,18 @@ export declare type BrowserLaunchFunction = (options: BrowserOptions) => Browser
512
526
  * tool it adopts, is mirrored as a dispatcher with that tool's definition, and the mirror is
513
527
  * removed when the toolset withdraws the tool, so the server's tool list changes and a subscribed
514
528
  * client is notified. The server also advertises `acquire`, `execute`, `tools`, and `destroy` with
515
- * `BROWSER_SERVER_COPY`. Startup warms the pool and leases the shared browser. The legacy
529
+ * `BROWSER_SERVER_COPY`. Startup warms the pool and assigns a prepared context to the shared holder. The legacy
516
530
  * handshake and browser calls await that setup. Named holders each own a lease, a pending grant,
517
531
  * and loss notices; concurrent calls on a holder share its replacement grant. Ending a holder
518
- * destroys its token, and admission counts that holder until disposal settles.
532
+ * closes its context and releases its lease, and admission counts that holder until disposal settles.
519
533
  * A launch creates `ROOT/.profiles/PID-UUID/` exclusively, connects a browser that never attaches to an
520
534
  * existing endpoint, opens one page in an isolated context, and constructs the page toolset with
521
535
  * that context and the file journey and run stores under the root, on a manager the toolset owns.
522
536
  * A dispatcher forwards its arguments and the call's context, signal included, to the toolset's
523
537
  * manager and returns that manager's value, or rejects with its failure message; a text value
524
538
  * reaches the client as one text block rather than as its JSON text.
525
- * A disconnect or current-page crash retires its slot. A failed call receives a liveness ping;
539
+ * A disconnect retires its browser and every hosted generation. A current-page crash retires only
540
+ * that holder's context. A failed call receives a liveness ping;
526
541
  * loss makes its outcome unresolved, while a known success remains successful. Pending losses
527
542
  * prefix the next outcome on a successor, or a refusal, and calls are never repeated.
528
543
  * Concurrent checks share one ping per slot. Cancelling a call ends only its wait; the ping keeps
@@ -530,7 +545,8 @@ export declare type BrowserLaunchFunction = (options: BrowserOptions) => Browser
530
545
  *
531
546
  * `start()` serves stdio and destroys the server at the end of its input, on `SIGINT`, and on
532
547
  * `SIGTERM`. `destroy()` stops reading requests and removes every dispatcher, then destroys every
533
- * slot through the pool — its toolset, which aborts the active replay, then its browser, then its
548
+ * slot through the pool — each toolset, which aborts its active replay, then its context and downloads,
549
+ * then its browser and its
534
550
  * profile — and rechecks the profile folders this server made or kept.
535
551
  *
536
552
  * Chromium on Linux refuses to start as the root user unless its sandbox is disabled, so a server
@@ -562,7 +578,7 @@ export declare class BrowserMCPServer implements BrowserMCPServerInterface {
562
578
  export declare interface BrowserMCPServerInterface {
563
579
  /**
564
580
  * Serves stdio, sweeps the profiles ended servers left, warms the pool, and resolves after the
565
- * shared holder leases a warm browser; the legacy handshake and every tool call await the same setup.
581
+ * shared holder consumes a prepared context on a warm browser; the legacy handshake and every tool call await the same setup.
566
582
  * Rejects with `BROWSER_SERVER_UNAVAILABLE` when no browser can serve and with
567
583
  * `BROWSER_TOOLSET_ENDED` after `destroy()`, and resolves when `destroy()` interrupts setup.
568
584
  */
@@ -592,8 +608,10 @@ export declare interface BrowserMCPServerInterface {
592
608
  * `input` destroys the server. Default: `process.stdin` and `process.stdout`
593
609
  * - `pool.size` — the integer number of browsers kept warm, from 1 through
594
610
  * `BROWSER_SERVER_POOL_LIMIT`. Default: `BROWSER_SERVER_POOL_SIZE`.
611
+ * - `pool.contexts` — the integer context capacity per browser, shared holder included, from 1
612
+ * through `BROWSER_SERVER_CONTEXTS_LIMIT`. Default: `BROWSER_SERVER_CONTEXTS`.
595
613
  * - `log` — receives diagnostic lines. Default: `process.stderr`
596
- * @throws Thrown when `pool.size` is outside that range or is not an integer, with `BROWSER_SERVER_OPTIONS`
614
+ * @throws Thrown when `pool.size` or `pool.contexts` is outside its range or is not an integer, with `BROWSER_SERVER_OPTIONS`
597
615
  */
598
616
  export declare interface BrowserMCPServerOptions {
599
617
  readonly root?: string;
@@ -605,6 +623,7 @@ export declare interface BrowserMCPServerOptions {
605
623
  readonly stdio?: StdioServerOptions;
606
624
  readonly pool?: {
607
625
  readonly size?: number;
626
+ readonly contexts?: number;
608
627
  };
609
628
  readonly log?: NodeJS.WritableStream;
610
629
  }
@@ -679,6 +698,13 @@ export declare interface BrowserServerCatalog {
679
698
  readonly tools: readonly ToolDefinition[];
680
699
  }
681
700
 
701
+ /** Holds one prepared or assigned context generation and its downloads directory. */
702
+ export declare interface BrowserServerContext {
703
+ readonly context: BrowserContextInterface;
704
+ readonly toolset: BrowserToolsetInterface;
705
+ readonly directory: string;
706
+ }
707
+
682
708
  /** Identifies one admitted browser lifetime independently of its current pool token. */
683
709
  export declare interface BrowserServerHolder {
684
710
  readonly id: string;
@@ -686,9 +712,21 @@ export declare interface BrowserServerHolder {
686
712
  readonly abort: AbortController;
687
713
  }
688
714
 
689
- /** Binds shared catalog subscriptions to the exact token that published them. */
690
- export declare interface BrowserServerMirror {
715
+ /** Binds a holder generation to the exact browser lease reserved for its lifetime. */
716
+ export declare interface BrowserServerLease {
691
717
  readonly token: PoolToken<BrowserSlot>;
718
+ readonly generation: BrowserServerContext;
719
+ }
720
+
721
+ /** Records a lost generation's cause and its own last URL. */
722
+ export declare interface BrowserServerLoss {
723
+ readonly cause: unknown;
724
+ readonly url: string;
725
+ }
726
+
727
+ /** Binds shared catalog subscriptions to the exact generation that published them. */
728
+ export declare interface BrowserServerMirror {
729
+ readonly lease: BrowserServerLease;
692
730
  readonly added: (tool: ToolInterface) => void;
693
731
  readonly removed: (tool: ToolInterface) => void;
694
732
  readonly cleared: (tools: readonly ToolInterface[]) => void;
@@ -697,20 +735,22 @@ export declare interface BrowserServerMirror {
697
735
  /** Names the server tools that manage independent browser holders. */
698
736
  export declare type BrowserServerToolName = 'acquire' | 'execute' | 'tools' | 'destroy';
699
737
 
700
- /** Holds one warm browser a browse server owns: the browser, its profile, its isolated context, and its started toolset. */
738
+ /** Holds page subscriptions for one prepared or assigned context generation. */
739
+ export declare interface BrowserServerWatch {
740
+ readonly page: (page: BrowserPageInterface) => void;
741
+ readonly crashes: ReadonlyMap<BrowserPageInterface, () => void>;
742
+ }
743
+
744
+ /** Holds one pooled browser and its exclusively owned profile. */
701
745
  export declare interface BrowserSlot {
702
746
  readonly browser: BrowserInterface;
703
747
  readonly profile: string;
704
- readonly context: BrowserContextInterface;
705
- readonly toolset: BrowserToolsetInterface;
706
748
  }
707
749
 
708
750
  /** Holds the listeners and resolver of one browser slot's loss watch. */
709
751
  export declare interface BrowserSlotWatch {
710
752
  readonly resolve: (cause: unknown) => void;
711
753
  readonly disconnect: () => void;
712
- readonly page: (page: BrowserPageInterface) => void;
713
- readonly crashes: ReadonlyMap<BrowserPageInterface, () => void>;
714
754
  readonly subscription: Disposable;
715
755
  }
716
756
 
@@ -869,6 +909,8 @@ export declare class FileBrowserJourneyStore implements BrowserJourneyStoreInter
869
909
  /**
870
910
  * Persists runs and captures only in directories allocated by this instance.
871
911
  * @remarks Requires an existing root. Reopened stores can read and delete saved runs.
912
+ * Allocations of one journey share a process-local queue across instances; the filesystem lock
913
+ * still refuses conflicting mutations and allocations from another process.
872
914
  * @example
873
915
  * const store = new FileBrowserRunStore({ root: directory })
874
916
  * const slot = await store.open('check-ready')
@@ -1000,6 +1042,10 @@ export declare function isBrowserNotConnectedError(value: unknown): value is Bro
1000
1042
  * Launches a browser process with raw-CDP debugging flags.
1001
1043
  *
1002
1044
  * @remarks
1045
+ * Merges every caller and library `--disable-features` value into one switch because Chromium
1046
+ * reads only the last occurrence. Keeps `msImplicitSignin` disabled alongside caller features;
1047
+ * Chrome and Chromium ignore this Edge feature name. Preserves the caller's other arguments.
1048
+ *
1003
1049
  * POSIX launches own an isolated process group so lifecycle teardown can
1004
1050
  * signal and await every Chromium subprocess without affecting the caller.
1005
1051
  * Windows launches are not detached and own no group, so teardown there