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