/** * Redis Transport Bus — Distributed Session Location Registry * * Maps sessions to the pods that own them using Redis Hash keys. * Used by TransportService in distributed mode to discover which * pod owns a given session and (optionally) relay operations to it. */ import type { RemoteLocation, TransportBus, TransportKey } from '../transport.types'; /** * Minimal Redis client interface for the transport bus. * Subset of ioredis — allows plugging any compatible client. */ export interface BusRedisClient { hset(key: string, field: string, value: string): Promise; hdel(key: string, ...fields: string[]): Promise; hget(key: string, field: string): Promise; expire(key: string, seconds: number): Promise; del(key: string): Promise; publish(channel: string, message: string): Promise; eval(script: string, numkeys: number, ...args: (string | number)[]): Promise; } /** * Configuration options for RedisTransportBus. */ export interface RedisTransportBusOptions { /** Redis key prefix. @default 'mcp:bus:' */ keyPrefix?: string; /** TTL for bus entries in seconds. @default 3600 */ ttlSeconds?: number; /** HA relay key prefix for destroy commands. @default 'mcp:ha:' */ haKeyPrefix?: string; /** Logger (optional) */ logger?: { info: (msg: string, meta?: Record) => void; warn: (msg: string, meta?: Record) => void; debug: (msg: string, meta?: Record) => void; }; } /** * Redis-backed TransportBus implementation. * * For each session, stores a Hash with nodeId and channel fields. * The bus provides session-to-node mapping for distributed lookups * and destroy-remote via pub/sub relay. * * Note: `proxyRequest()` is deferred — session recreation via * TransportService.recreateTransporter() handles cross-pod requests. */ export declare class RedisTransportBus implements TransportBus { private readonly redis; private readonly machineId; private readonly keyPrefix; private readonly ttlSeconds; private readonly haKeyPrefix; private readonly logger?; constructor(redis: BusRedisClient, machineId: string, options?: RedisTransportBusOptions); nodeId(): string; /** * Advertise that this node owns a session. * Stores the nodeId and relay channel in a Redis Hash. */ advertise(key: TransportKey): Promise; /** * Revoke ownership of a session (e.g., on transport dispose). * Uses atomic compare-and-delete to avoid removing a newer owner's registration. */ revoke(key: TransportKey): Promise; /** * Look up which node owns a session. * Returns null if the session is not registered in the bus. */ lookup(key: TransportKey): Promise; /** * Proxy a request to the owning node. * * Phase 1: Not implemented — TransportService.recreateTransporter() * handles cross-pod session access via Redis session store. */ proxyRequest(): Promise; /** * Destroy a session on a remote node via pub/sub relay. */ destroyRemote(key: TransportKey, reason?: string): Promise; /** * Build the Redis key for a session in the bus. * Format: {prefix}{type}:{tokenHash}:{sessionId} */ private busKey; } //# sourceMappingURL=redis-transport-bus.d.ts.map