@radheim/plugin-browser 0.0.0-stage → 2.4.3

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.
@@ -0,0 +1,72 @@
1
+ export * as StreamMux from "./stream-mux.js";
2
+ import type { Socket } from "node:net";
3
+ import { Duplex } from "node:stream";
4
+ import { EgressPolicy } from "./egress-policy.js";
5
+ import type { Browser } from "./rpc.js";
6
+ import { BrowserTunnelHost } from "./tunnel-host.js";
7
+ export interface MuxOptions {
8
+ /** Per-stream receive window advertised to peer. Default 1.5 MiB. */
9
+ readonly streamWindowBytes?: number;
10
+ /** Batch threshold for sending WINDOW_UPDATE credits. Default min(256 KiB, window / 4). */
11
+ readonly creditBatchBytes?: number;
12
+ /** Maximum DATA payload bytes per frame. Default 16 KiB. */
13
+ readonly frameChunkBytes?: number;
14
+ /** Maximum bytes allowed in WebSocket library bufferedAmount for DATA frames. Default 256 KiB. */
15
+ readonly maxWsBufferedBytes?: number;
16
+ /** Maximum concurrent streams for this attachment. Default 128. */
17
+ readonly maxStreams?: number;
18
+ /** Maximum concurrent in-flight TCP connects for this attachment. Default 32. */
19
+ readonly maxPendingConnects?: number;
20
+ /** Maximum total buffered bytes across all streams of this attachment. Default 8 MiB. */
21
+ readonly maxAttachmentBufferedBytes?: number;
22
+ /** Per-stream outbound pause high-water mark. Default 256 KiB. */
23
+ readonly streamOutboundHighWaterBytes?: number;
24
+ /** Heartbeat interval in milliseconds (0 disables heartbeat timer). Default 25000. */
25
+ readonly heartbeatIntervalMs?: number;
26
+ /** Disconnect if peer is silent for longer than this (ms). Default 60000. */
27
+ readonly heartbeatTimeoutMs?: number;
28
+ /** Cross-attachment global resource limits. */
29
+ readonly globalLimits?: BrowserTunnelHost.GlobalLimits;
30
+ }
31
+ export interface ServerMuxOptions extends MuxOptions {
32
+ readonly policy: EgressPolicy.AttachmentPolicy;
33
+ /** TCP connect timeout per stream in milliseconds. Default 10000. */
34
+ readonly connectTimeoutMs?: number;
35
+ /** Optional custom connector (for deterministic tests). */
36
+ readonly connect?: (target: Browser.TunnelTarget, policy: EgressPolicy.AttachmentPolicy, options: {
37
+ readonly signal?: AbortSignal;
38
+ readonly timeoutMs?: number;
39
+ }) => Promise<Socket>;
40
+ }
41
+ export interface MuxCloseInfo {
42
+ readonly code: number;
43
+ readonly reason: string;
44
+ readonly replaced: boolean;
45
+ }
46
+ export interface ServerMux {
47
+ readonly closed: Promise<MuxCloseInfo>;
48
+ readonly activeStreams: () => number;
49
+ readonly bufferedBytes: () => number;
50
+ close(code?: number, reason?: string): void;
51
+ }
52
+ export interface ClientMux {
53
+ readonly closed: Promise<MuxCloseInfo>;
54
+ readonly activeStreams: () => number;
55
+ readonly bufferedBytes: () => number;
56
+ readonly isClosed: () => boolean;
57
+ openStream(target: Browser.TunnelTarget, signal?: AbortSignal): Promise<Duplex>;
58
+ ping(): void;
59
+ close(code?: number, reason?: string): void;
60
+ }
61
+ /**
62
+ * Server-side multiplexed stream owner bound to one live desktop browser attachment.
63
+ * Enforces egress policy, per-attachment and cross-attachment caps, credit-based flow control,
64
+ * half-close, RESET cancellation, and clean teardown of every owned target TCP socket on close.
65
+ */
66
+ export declare function createServerMux(socket: BrowserTunnelHost.BinarySocket, options: ServerMuxOptions): ServerMux;
67
+ /**
68
+ * Desktop-side multiplexed stream client bound to one prewarmed binary WebSocket.
69
+ * Returns standard Node `Duplex` sockets per target TCP connection with end-to-end
70
+ * credit backpressure, half-close, RESET cancellation, and zero automatic replay of writes.
71
+ */
72
+ export declare function createClientMux(socket: BrowserTunnelHost.BinarySocket, options?: MuxOptions): ClientMux;