/** * Midstream-aware federation transport loader (ADR-120, Step 2). * * Extends the agentic-flow `loadQuicTransport` loader pattern with a * preferred branch that probes `midstreamer` first. When `midstreamer` * ships real QUIC (currently the WASM build is a counter-tracking * stub per ADR-119), this loader picks it up automatically without * any change to consumer plugins. * * Resolution order: * * 1. If `MIDSTREAMER_QUIC_NATIVE=1` AND the `midstreamer` module * exposes a real `QuicMultistream`-derived `AgentTransport`, * use it. (Today: probes fail closed and we fall through.) * * 2. Otherwise: defer to agentic-flow's existing loader, which * itself respects `AGENTIC_FLOW_QUIC_NATIVE=1` (ADR-108) and * falls back to WebSocket (ADR-104) otherwise. * * The loader is opt-in: callers must explicitly invoke * `loadFederationTransport()` instead of `loadQuicTransport()`. * Behavior is identical to `loadQuicTransport()` until upstream * `midstreamer` ships its real QUIC build AND the operator sets the * env flag — so this change is safe to land before any of that * happens. * * Re-exports the `AgentTransport` / `AgentMessage` / `QuicTransportConfig` * surface from agentic-flow so consumers only import from one place. */ export interface AgentMessage { id: string; type: 'task' | 'result' | 'status' | 'coordination' | 'heartbeat' | string; payload: unknown; metadata?: Record; [key: string]: unknown; } export interface AgentTransport { send: (address: string, message: AgentMessage) => Promise; onMessage: (handler: (address: string, message: AgentMessage) => void) => void; listen?: (port: number, host?: string) => Promise; close?: () => Promise | void; [key: string]: unknown; } export interface QuicTransportConfig { port?: number; host?: string; serverName?: string; [key: string]: unknown; } /** Result envelope describing which backend the loader picked. */ export interface LoadedFederationTransport { /** The live transport. Send/receive against this. */ transport: AgentTransport; /** Which loader branch resolved. Useful for logs/metrics. */ source: 'midstreamer-native' | 'agentic-flow-loader' | 'websocket-fallback'; /** Free-form note when a probe failed (helps explain a fallback). */ fallbackReason?: string; } /** * Top-level loader for federation transport. Identical signature to * agentic-flow's `loadQuicTransport`, but with the midstreamer-first * preference. Use this from `plugins/ruflo-federation` in place of * the bare `loadQuicTransport`. * * Failure mode: if midstreamer is requested but rejects (stub, init * error, missing package), this function falls through to the * agentic-flow loader. If current agentic-flow does not export its * historical loader subpath, the plugin-owned WebSocket fallback is * used directly (ADR-104, #2618). */ export declare function loadFederationTransport(config?: QuicTransportConfig): Promise; //# sourceMappingURL=midstream-aware-loader.d.ts.map