/** * ChannelConnector - in-memory bidirectional connection * * This connector creates an in-memory channel for testing or for * embedded components that run in the same process. */ import type { ComponentConnection, ComponentConnector } from "../types.js"; /** * A pair of connected channel endpoints. * * Messages sent on one end are received on the other. */ export interface ChannelPair { /** The "left" side of the channel */ left: ComponentConnection; /** The "right" side of the channel */ right: ComponentConnection; } /** * Create a connected pair of channel endpoints. * * This is useful for testing or for connecting in-process components. */ export declare function createChannelPair(): ChannelPair; /** * Connector for in-memory channel connections. * * Each call to connect() returns a new channel pair. The "other" end * must be retrieved via getOtherEnd() after calling connect(). */ export declare class ChannelConnector implements ComponentConnector { private pendingOtherEnd; connect(): Promise; /** * Get the other end of the most recently created channel. * * This must be called after connect() to get the paired endpoint. */ getOtherEnd(): ComponentConnection | null; } /** * Handler function for an in-memory component */ export type ComponentHandler = (connection: ComponentConnection) => Promise; /** * Create a connector that runs a handler function in-process. * * This is useful for testing or for embedding simple components. * * @param handler - Function that handles the component side of the connection * @returns A connector that runs the handler when connect() is called */ export declare function inProcess(handler: ComponentHandler): ComponentConnector; /** * Create a simple echo component for testing. * * This component echoes back any request with the same params as the result. */ export declare function echoComponent(): ComponentConnector; //# sourceMappingURL=channel.d.ts.map