Documentation / @agentick/client-multiplexer / SharedTransportConfig
Interface: SharedTransportConfig ​
Defined in: client-multiplexer/src/shared-transport.ts:33
@agentick/client-multiplexer
Multi-tab connection multiplexer for Agentick client.
Reduces server connections by electing a leader tab that maintains the SSE connection while other tabs communicate via BroadcastChannel.
Features:
- Leader election using Web Locks API (instant, reliable)
- BroadcastChannel fallback for older browsers
- Automatic failover when leader tab closes
- Per-tab subscription filtering (each tab only receives its events)
- Subscription aggregation (leader subscribes to union of all tabs' sessions)
Example ​
import { createClient } from '@agentick/client';
import { createSharedTransport } from '@agentick/client-multiplexer';
// Create client with shared transport
const client = createClient({
baseUrl: '/api',
transport: createSharedTransport({ baseUrl: '/api', token: 'your-token' }),
});
// Use exactly like a regular client
const session = client.session('main');
session.subscribe(); // Subscribe to events
session.onEvent((event) => console.log(event));
// Send a message
const handle = session.send('Hello!');
await handle.result;
// Check leadership status (optional, for debugging/UI)
const transport = client.getTransport() as SharedTransport | undefined;
console.log('Is leader:', transport?.isLeader);Extends ​
Properties ​
baseUrl ​
baseUrl:
string
Defined in: shared/src/transport.ts:110
Base URL for the server
Inherited from ​
clientId? ​
optionalclientId:string
Defined in: client-multiplexer/src/shared-transport.ts:47
Client ID for WebSocket connections
headers? ​
optionalheaders:Record<string,string>
Defined in: shared/src/transport.ts:116
Custom headers
Inherited from ​
paths? ​
optionalpaths:object
Defined in: client-multiplexer/src/shared-transport.ts:44
Override default endpoint paths (SSE transport only)
abort? ​
optionalabort:string
channel? ​
optionalchannel:string
close? ​
optionalclose:string
events? ​
optionalevents:string
send? ​
optionalsend:string
subscribe? ​
optionalsubscribe:string
toolResponse? ​
optionaltoolResponse:string
reconnect? ​
optionalreconnect:object
Defined in: client-multiplexer/src/shared-transport.ts:53
Reconnection settings (WebSocket only)
delay? ​
optionaldelay:number
Delay between attempts in ms (default: 1000)
enabled? ​
optionalenabled:boolean
Enable auto-reconnection (default: true)
maxAttempts? ​
optionalmaxAttempts:number
Max reconnection attempts (default: 5)
timeout? ​
optionaltimeout:number
Defined in: shared/src/transport.ts:119
Request timeout in ms
Inherited from ​
token? ​
optionaltoken:string
Defined in: shared/src/transport.ts:113
Authentication token
Inherited from ​
transport? ​
optionaltransport:"websocket"|"sse"|"auto"
Defined in: client-multiplexer/src/shared-transport.ts:41
Transport type to use.
- "sse": HTTP/SSE transport (default for http:// URLs)
- "websocket": WebSocket transport (default for ws:// URLs)
- "auto": Auto-detect based on URL scheme (default)
Default ​
"auto"WebSocket()? ​
optionalWebSocket: (url,protocols?) =>WebSocket
Defined in: client-multiplexer/src/shared-transport.ts:50
WebSocket implementation (for Node.js compatibility)
Parameters ​
url ​
string | URL
protocols? ​
string | string[] | WebSocketInit
Returns ​
WebSocket
withCredentials? ​
optionalwithCredentials:boolean
Defined in: shared/src/transport.ts:122
Send credentials with requests