import { a as ChatEvent } from '../types-ajANVzf7.js';
export { B as BackendAdapterOptions, I as IChatBackend, d as IResumableBackend, i as isResumableBackend } from '../types-ajANVzf7.js';
export { B as BaseBackendAdapter, C as ClaudeChatAdapter, a as ClaudeChatAdapterOptions, b as CopilotChatAdapter, c as CopilotChatAdapterOptions, I as InProcessChatTransport, V as VercelAIChatAdapter, d as VercelAIChatAdapterOptions, W as WS_READY_STATE, e as WebSocketLike, f as WsChatTransport, g as WsTransportOptions } from '../in-process-transport-C1JnJGVR.js';
import { I as IChatTransport } from '../transport-Ciap4PWK.js';
export { C as CloseDetectable, S as SSEChatTransport, a as SSETransportOptions, W as WritableResponse, s as streamToTransport } from '../transport-Ciap4PWK.js';
import '../agent-CW9XbmG_.js';
import 'zod';
import '../errors-C-so0M4t.js';
import '../types-BxggH0Yh.js';
import '../errors-CmVvczxZ.js';
import '../backends-BSrsBYFn.js';

/**
 * @witqq/agent-sdk - Transport Interceptors
 *
 * Composable hooks that wrap any IChatTransport to intercept events
 * at the transport boundary. Use for logging, metrics, rate limiting,
 * or event transformation without modifying the transport itself.
 *
 * ```typescript
 * import { withInterceptors } from "@witqq/agent-sdk/chat/backends";
 *
 * const transport = withInterceptors(sseTransport, [
 *   loggingInterceptor(),
 *   metricsInterceptor(),
 * ]);
 * ```
 */

/** Context passed to interceptor hooks */
interface InterceptorContext {
    /** The event being intercepted (mutable for beforeSend) */
    event: ChatEvent;
    /** The underlying transport being wrapped */
    transport: IChatTransport;
}
/**
 * Transport interceptor with lifecycle hooks.
 * All hooks are optional — implement only what you need.
 */
interface TransportInterceptor {
    /** Optional name for debugging */
    name?: string;
    /**
     * Called before each event is sent to the transport.
     * Return the event to send, a modified event, or null to suppress.
     */
    beforeSend?(event: ChatEvent, transport: IChatTransport): ChatEvent | null;
    /** Called after each event is sent to the transport */
    afterSend?(event: ChatEvent, transport: IChatTransport): void;
    /** Called before the transport is closed */
    beforeClose?(transport: IChatTransport): void;
    /** Called when an error is signaled on the transport */
    onError?(error: Error, transport: IChatTransport): void;
}
/**
 * Wrap a transport with one or more interceptors.
 * Interceptors are applied in order: first interceptor's beforeSend runs first.
 *
 * @param transport - Base transport to wrap
 * @param interceptors - Array of interceptors to apply
 * @returns Wrapped transport with interceptor hooks
 */
declare function withInterceptors(transport: IChatTransport, interceptors: TransportInterceptor[]): IChatTransport;

export { IChatTransport, type InterceptorContext, type TransportInterceptor, withInterceptors };
