Skip to content

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 ​

typescript
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 ​

TransportConfig.baseUrl


clientId? ​

optional clientId: string

Defined in: client-multiplexer/src/shared-transport.ts:47

Client ID for WebSocket connections


headers? ​

optional headers: Record<string, string>

Defined in: shared/src/transport.ts:116

Custom headers

Inherited from ​

TransportConfig.headers


paths? ​

optional paths: object

Defined in: client-multiplexer/src/shared-transport.ts:44

Override default endpoint paths (SSE transport only)

abort? ​

optional abort: string

channel? ​

optional channel: string

close? ​

optional close: string

events? ​

optional events: string

send? ​

optional send: string

subscribe? ​

optional subscribe: string

toolResponse? ​

optional toolResponse: string


reconnect? ​

optional reconnect: object

Defined in: client-multiplexer/src/shared-transport.ts:53

Reconnection settings (WebSocket only)

delay? ​

optional delay: number

Delay between attempts in ms (default: 1000)

enabled? ​

optional enabled: boolean

Enable auto-reconnection (default: true)

maxAttempts? ​

optional maxAttempts: number

Max reconnection attempts (default: 5)


timeout? ​

optional timeout: number

Defined in: shared/src/transport.ts:119

Request timeout in ms

Inherited from ​

TransportConfig.timeout


token? ​

optional token: string

Defined in: shared/src/transport.ts:113

Authentication token

Inherited from ​

TransportConfig.token


transport? ​

optional transport: "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 ​

ts
"auto"

WebSocket()? ​

optional WebSocket: (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? ​

optional withCredentials: boolean

Defined in: shared/src/transport.ts:122

Send credentials with requests

Inherited from ​

TransportConfig.withCredentials

Released under the ISC License.