/**
 * HTTP/WebSocket Client Library
 *
 * Core client for accessing the NeuroLink API with built-in authentication,
 * retry logic, and middleware support. Supports both browser and Node.js environments.
 *
 * @module @neurolink/client
 */
import type { ClientConfig, RequestOptions, ClientApiResponse, ApiError, ClientRetryConfig, Middleware, MiddlewareRequest, MiddlewareResponse, ClientMiddlewareContext, StreamCallbacks, ClientStreamEvent, ClientStreamResult, GenerateRequestOptions, GenerateResponse, StreamRequestOptions, AgentExecuteOptions, AgentExecuteResult, AgentInfo, WorkflowExecuteOptions, WorkflowExecuteResult, WorkflowInfo, ToolInfo, ClientProviderStatus, WebSocketOptions, WebSocketState, WebSocketMessageHandler } from "../types/clientTypes.js";
import type { UnknownRecord } from "../types/common.js";
import { HttpError, ClientNetworkError, ClientTimeoutError } from "./errors.js";
/**
 * Combine multiple AbortSignals into a single signal.
 * Aborts as soon as any input signal is aborted.
 */
export declare function combineSignals(...signals: AbortSignal[]): AbortSignal;
/**
 * Promise-based delay utility.
 */
export declare function sleep(ms: number): Promise<void>;
export { HttpError as NeuroLinkApiError, ClientNetworkError, ClientTimeoutError, };
/**
 * HTTP Client for NeuroLink API
 *
 * Provides type-safe access to all NeuroLink API endpoints with
 * built-in authentication, retry logic, and middleware support.
 *
 * @example Basic usage
 * ```typescript
 * import { createClient } from '@neurolink/client';
 *
 * const client = createClient({
 *   baseUrl: 'https://api.neurolink.example.com',
 *   apiKey: 'your-api-key',
 * });
 *
 * const result = await client.generate({
 *   input: { text: 'Hello, world!' },
 *   provider: 'openai',
 * });
 * ```
 *
 * @example With middleware
 * ```typescript
 * const client = createClient({ baseUrl: 'https://api.example.com' });
 *
 * client.use(async (request, next) => {
 *   console.log('Request:', request.url);
 *   const response = await next();
 *   console.log('Response:', response.status);
 *   return response;
 * });
 * ```
 */
export declare class NeuroLinkClient {
    private config;
    private middlewares;
    private wsConnection;
    private wsState;
    private wsMessageHandlers;
    constructor(config: ClientConfig);
    /**
     * Get default fetch implementation
     */
    private getDefaultFetch;
    /**
     * Add middleware to the client
     *
     * @param middleware - Middleware function
     * @returns Client instance for chaining
     */
    use(middleware: Middleware): this;
    /**
     * Clear all middleware
     */
    clearMiddleware(): this;
    /**
     * Generate unique request ID
     */
    private generateRequestId;
    /**
     * Calculate delay for exponential backoff
     */
    private calculateDelay;
    /**
     * Delay utility — delegates to shared sleep()
     */
    private delay;
    /**
     * Combine multiple abort signals — delegates to shared combineSignals()
     */
    private combineSignals;
    /**
     * Debug logging via the unified NeuroLink logger.
     * Guarded by `logger.shouldLog("debug")` so expensive serialization is
     * skipped when debug output is disabled.
     */
    private log;
    /**
     * Execute HTTP request with middleware and retry logic
     */
    private request;
    /**
     * Generate text using AI models
     *
     * @example
     * ```typescript
     * const response = await client.generate({
     *   input: { text: 'Write a poem about coding' },
     *   provider: 'openai',
     *   model: 'gpt-4o',
     *   temperature: 0.7,
     * });
     * console.log(response.data.content);
     * ```
     */
    generate(options: GenerateRequestOptions, requestOptions?: RequestOptions): Promise<ClientApiResponse<GenerateResponse>>;
    /**
     * Stream text generation
     *
     * @example
     * ```typescript
     * await client.stream(
     *   { input: { text: 'Tell me a story' }, provider: 'openai' },
     *   {
     *     onText: (text) => process.stdout.write(text),
     *     onDone: (result) => console.log('\nDone!', result.usage),
     *   }
     * );
     * ```
     */
    stream(options: StreamRequestOptions | GenerateRequestOptions, callbacks?: StreamCallbacks, requestOptions?: RequestOptions): Promise<ClientStreamResult>;
    /**
     * Handle individual stream events
     */
    private handleStreamEvent;
    /**
     * Execute an agent
     *
     * @example
     * ```typescript
     * const result = await client.executeAgent({
     *   agentId: 'customer-support',
     *   input: 'I need help with my order',
     *   sessionId: 'user-123',
     * });
     * console.log(result.data.content);
     * ```
     */
    executeAgent(options: AgentExecuteOptions, requestOptions?: RequestOptions): Promise<ClientApiResponse<AgentExecuteResult>>;
    /**
     * Stream agent execution
     */
    streamAgent(options: AgentExecuteOptions, callbacks?: StreamCallbacks, requestOptions?: RequestOptions): Promise<ClientStreamResult>;
    /**
     * List available agents
     */
    listAgents(requestOptions?: RequestOptions): Promise<ClientApiResponse<AgentInfo[]>>;
    /**
     * Get agent details
     */
    getAgent(agentId: string, requestOptions?: RequestOptions): Promise<ClientApiResponse<AgentInfo>>;
    /**
     * Execute a workflow
     *
     * @example
     * ```typescript
     * const result = await client.executeWorkflow({
     *   workflowId: 'data-pipeline',
     *   input: { data: [...] },
     * });
     *
     * if (result.data.status === 'running') {
     *   // Poll for completion
     *   const status = await client.getWorkflowStatus(
     *     'data-pipeline',
     *     result.data.runId
     *   );
     * }
     * ```
     */
    executeWorkflow(options: WorkflowExecuteOptions, requestOptions?: RequestOptions): Promise<ClientApiResponse<WorkflowExecuteResult>>;
    /**
     * Resume a suspended workflow
     */
    resumeWorkflow(workflowId: string, resumeToken: string, resumeData?: UnknownRecord, requestOptions?: RequestOptions): Promise<ClientApiResponse<WorkflowExecuteResult>>;
    /**
     * Get workflow execution status
     */
    getWorkflowStatus(workflowId: string, runId: string, requestOptions?: RequestOptions): Promise<ClientApiResponse<WorkflowExecuteResult>>;
    /**
     * Cancel workflow execution
     */
    cancelWorkflow(workflowId: string, runId: string, requestOptions?: RequestOptions): Promise<ClientApiResponse<{
        success: boolean;
    }>>;
    /**
     * List available workflows
     */
    listWorkflows(requestOptions?: RequestOptions): Promise<ClientApiResponse<WorkflowInfo[]>>;
    /**
     * Get workflow details
     */
    getWorkflow(workflowId: string, requestOptions?: RequestOptions): Promise<ClientApiResponse<WorkflowInfo>>;
    /**
     * List available tools
     *
     * @example
     * ```typescript
     * const tools = await client.listTools({ category: 'data' });
     * console.log(tools.data);
     * ```
     */
    listTools(options?: {
        category?: string;
        serverId?: string;
    }, requestOptions?: RequestOptions): Promise<ClientApiResponse<ToolInfo[]>>;
    /**
     * Execute a tool
     */
    executeTool(toolName: string, params: UnknownRecord, requestOptions?: RequestOptions): Promise<ClientApiResponse<unknown>>;
    /**
     * Get tool details
     */
    getTool(toolName: string, requestOptions?: RequestOptions): Promise<ClientApiResponse<ToolInfo>>;
    /**
     * List available providers
     */
    listProviders(requestOptions?: RequestOptions): Promise<ClientApiResponse<ClientProviderStatus[]>>;
    /**
     * Get provider status
     */
    getProviderStatus(providerName: string, requestOptions?: RequestOptions): Promise<ClientApiResponse<ClientProviderStatus>>;
    /**
     * Health check
     */
    health(requestOptions?: RequestOptions): Promise<ClientApiResponse<{
        status: string;
        version: string;
    }>>;
    /**
     * Connect to WebSocket for real-time communication
     *
     * @example
     * ```typescript
     * client.connectWebSocket({
     *   url: 'wss://api.example.com/ws',
     *   autoReconnect: true,
     * });
     *
     * client.onWebSocketMessage('chat', (data) => {
     *   console.log('Chat message:', data);
     * });
     * ```
     */
    connectWebSocket(options?: Partial<WebSocketOptions>): void;
    /**
     * Disconnect WebSocket
     */
    disconnectWebSocket(): void;
    /**
     * Send message over WebSocket
     */
    sendWebSocketMessage(data: unknown): void;
    /**
     * Register WebSocket message handler
     */
    onWebSocketMessage(messageType: string, handler: WebSocketMessageHandler): () => void;
    /**
     * Get WebSocket connection state
     */
    getWebSocketState(): WebSocketState;
    /**
     * Update client configuration
     */
    updateConfig(config: Partial<ClientConfig>): void;
    /**
     * Get current configuration (readonly)
     */
    getConfig(): Readonly<ClientConfig>;
}
/**
 * Create a new NeuroLink client instance
 *
 * @example
 * ```typescript
 * import { createClient } from '@neurolink/client';
 *
 * const client = createClient({
 *   baseUrl: 'https://api.neurolink.example.com',
 *   apiKey: process.env.NEUROLINK_API_KEY,
 *   debug: true,
 * });
 * ```
 */
export declare function createClient(config: ClientConfig): NeuroLinkClient;
export type { ClientConfig, RequestOptions, ClientApiResponse, ApiError, ClientRetryConfig, Middleware, MiddlewareRequest, MiddlewareResponse, ClientMiddlewareContext, StreamCallbacks, ClientStreamEvent, ClientStreamResult, GenerateRequestOptions, GenerateResponse, StreamRequestOptions, AgentExecuteOptions, AgentExecuteResult, AgentInfo, WorkflowExecuteOptions, WorkflowExecuteResult, WorkflowInfo, ToolInfo, ClientProviderStatus, WebSocketOptions, WebSocketState, WebSocketMessageHandler, };
