import { type AddressInfo, type Socket } from "node:net"; import type { FetchLike } from "../handlers/HandlerRegistration.js"; export declare const TCP_CLIENT_LIMITS: { readonly spareLegs: 2; readonly maxLegs: 8; readonly controlTimeoutMs: 10000; readonly connectTimeoutMs: 10000; readonly responseTimeoutMs: 35000; readonly attachTimeoutMs: 3600000; readonly idleTimeoutMs: 300000; readonly sessionTimeoutMs: 3600000; readonly maxBytes: number; readonly reconnectMinMs: 1000; readonly reconnectMaxMs: 30000; }; export type TcpRole = "connector" | "client"; export interface TcpTarget { readonly host: string; readonly port: number; readonly resource: string; } export interface TcpClientConfig { /** Fixed local configuration, never supplied by a broker or a ticket. */ readonly controlApi: string; readonly gatewayUrl: string; readonly routeId: string; readonly target: string; /** Read a role-specific credential file again for each ticket; never a workspace key. */ readonly credential: () => string; } export interface TcpClientEvent { readonly event: string; readonly route_id: string; readonly code?: string; } export interface TcpClientDependencies { readonly fetch?: FetchLike; readonly report?: (event: TcpClientEvent) => void; /** CLI test seam; production reads a bounded, owner-only regular file from one descriptor. */ readonly readCredential?: (path: string) => string; /** Tests may supply a verified local TLS peer. Production always uses verifiedTls. */ readonly dialGateway?: (hostname: string, signal: AbortSignal) => Promise; readonly dialTarget?: (target: TcpTarget, signal: AbortSignal) => Promise; readonly clock?: () => number; readonly reconnectMinMs?: number; readonly reconnectMaxMs?: number; } export declare function parseTcpTarget(value: string): TcpTarget; /** Always verify the tenant hostname against public roots; no insecure client option. */ export declare function verifiedTls(hostname: string, signal: AbortSignal, transport?: { readonly address?: string; readonly port?: number; readonly ca?: string; }): Promise; declare class RouteClient { readonly config: TcpClientConfig; protected readonly dependencies: TcpClientDependencies; readonly target: TcpTarget; readonly gateway: URL; private readonly control; private readonly resourceHash; constructor(config: TcpClientConfig, dependencies: TcpClientDependencies); protected report(event: string, code?: string): void; protected leg(role: TcpRole, signal: AbortSignal, track: (socket: Socket) => void): Promise<{ socket: Socket; tail: Buffer; }>; private ticket; } /** Backpressure, buffered framing tails, half-close, and hard session/byte ceilings. */ export declare function spliceTcp(left: Socket, right: Socket, leftTail: Buffer, rightTail: Buffer, signal: AbortSignal): Promise; /** Two waiting outbound legs, at most eight total legs, and one bounded retry timer. */ export declare class TcpConnector extends RouteClient { private readonly legs; private retry; private stopped; private started; private failures; constructor(config: TcpClientConfig, dependencies?: TcpClientDependencies); start(): void; snapshot(): { readonly waiting: number; readonly active: number; }; close(): Promise; private fill; private schedule; private run; } /** One loopback listener; never accepts a bind address or a destination from its clients. */ export declare class TcpTunnel extends RouteClient { private readonly server; private readonly legs; private stopped; private listening; constructor(config: TcpClientConfig, dependencies?: TcpClientDependencies); listen(port: number): Promise; close(): Promise; private accept; private run; } export {}; //# sourceMappingURL=TcpClient.d.ts.map