/** * `TransportPool` — Phase 1.d shared multi-robot transport pool. * * Lives in `@agenticros/core` so every adapter (Claude Code, Gemini, * future ones) can route per-robot transports through the same battle- * tested implementation. OpenClaw's plugin uses a thinner add-on * because its existing service has long-lived eager-connect / poll * semantics that don't compose cleanly with a generic pool. * * Semantics: * * - Pool key is `__global__` when the robot has no per-robot * `transport` override in config — every robot then shares one * connection (the legacy / single-transport behaviour). Opting * into `config.robots[]` is NOT a breaking change for that path. * * - Pool key is `robot.id` when the robot DOES declare an override. * A distinct transport is materialised on first use and cached * for subsequent tool calls. * * - Acquires are lazy — the constructor never opens a connection. * The first call to `acquire()` for a given key triggers the * create + connect dance, gated by `connectWithTimeout()`. * * - Concurrent first-acquires on the same key share one in-flight * connect promise — important when an MCP server gets two * near-simultaneous tool calls right after startup. * * - Cached entries that drop to a non-`connected` state are * rebuilt on the next acquire (self-heal — matches the pre-pool * `connect()` behaviour). * * - `disconnectAll()` drains every entry and is safe to call on * SIGINT/SIGTERM. Errors on individual disconnects are swallowed * so one misbehaving transport can't block the others from * cleaning up. * * The default factory is `createTransport` from `./transport/factory`. * Adapter shutdowns / tests can inject a fake factory by passing one * to the constructor — see packages/core/src/__tests__/transport-pool.test.ts * for the unit-test seam. */ import type { AgenticROSConfig, ResolvedRobot, RosTransport, TransportConfig } from "./index.js"; export declare const TRANSPORT_POOL_GLOBAL_KEY = "__global__"; export type TransportFactory = (cfg: TransportConfig) => Promise; export declare class TransportPool { private readonly factory; private readonly entries; /** Promises kept while a connection is in flight, so concurrent acquires share the same connect. */ private readonly inFlight; private readonly failSafeUnsub; /** Last config passed to acquire — used to resolve which robots share a transport on drain. */ private lastConfig; constructor(factory?: TransportFactory); /** * Acquire (lazy-connect on first call) the transport for this robot. * See the module docstring for the full key + caching contract. */ acquire(config: AgenticROSConfig, robot: ResolvedRobot): Promise; /** * Pre-warm the active robot's transport at server start — used by * adapters that want to pay the connect-latency tax upfront instead * of on the first tool call. */ connectActive(config: AgenticROSConfig): Promise; /** * Disconnect every transport in the pool. Safe to call multiple * times. Errors on individual disconnects are swallowed. */ disconnectAll(): Promise; private clearFailSafe; /** Visible for tests: how many distinct transports are alive right now. */ get size(): number; /** Visible for tests: list of pool keys currently cached. */ keys(): string[]; private acquireByKey; } //# sourceMappingURL=transport-pool.d.ts.map