import { StoreApi } from 'zustand';
import { QueryClient } from '@tanstack/react-query';
import { Socket } from 'socket.io-client';
import { AgentFrontendConfig, AgentToolDefinition, ToolRendererComponent, ValidatedAgentFrontendConfig, AgentTransportConfig, PageContextInput } from '../config/types';
import { AgentStore } from '../state/useAgentStore';
import { AgentTransport } from './transports/AgentTransport';
import { AgentAttachment } from '@multiplayer-app/ai-agent-types';
import { ToolRegistry } from './ToolRegistry';
import { AgentToolCall } from './types';

export declare class AgentRuntime {
    private rawConfig;
    readonly config: ValidatedAgentFrontendConfig;
    transport: AgentTransport;
    readonly tools: ToolRegistry;
    readonly queryClient: QueryClient;
    /**
     * Per-runtime event bus for host integrations (e.g. form apply requests).
     * Host apps can subscribe via `runtime.events.addEventListener(...)`.
     */
    readonly events: EventTarget;
    private socketClient;
    private readonly toolRendererMap;
    private storeRef?;
    private readonly pageContextProviders;
    constructor(rawConfig: AgentFrontendConfig);
    private createTransport;
    private configureTransportAfterCreate;
    /**
     * Update transport configuration at runtime.
     *
     * This is intentionally explicit because transports cache config internally and the UI
     * needs a rerender/reconnect to pick up changes (e.g. Socket.IO auth headers).
     */
    updateTransportConfig(nextTransport: AgentTransportConfig): void;
    /**
     * Replace the full transport headers map (pass undefined to clear).
     */
    setTransportHeaders(headers?: Record<string, string>): void;
    /**
     * Merge headers into the current transport headers (overwrites existing keys).
     */
    mergeTransportHeaders(headers: Record<string, string>): void;
    /**
     * Remove specific header keys from the current transport headers.
     */
    removeTransportHeaders(keys: string[]): void;
    get defaultContextKey(): string;
    get store(): StoreApi<AgentStore>;
    attachStore(store: StoreApi<AgentStore>): void;
    /**
     * Live Socket.IO client when proxy transport is used and `SocketProvider` has created a client.
     * Host apps can attach listeners with `runtime.socket?.on(...)`.
     * Listen for `runtime:socket-changed` on `runtime.events` if you need to react when the instance is replaced.
     */
    get socket(): Socket | null;
    /**
     * @internal Used by `SocketProvider` to publish the active client (or clear it on teardown / non-proxy mode).
     */
    setSocketClient(next: Socket | null): void;
    registerTool(tool: AgentToolDefinition): void;
    registerToolRenderer(toolName: string, renderer: ToolRendererComponent): void;
    /**
     * Register a page-level provider for extra page context data.
     * Intended to be called by route/page components (via a hook).
     *
     * The returned cleanup function MUST be called (on unmount) to avoid leaks.
     */
    registerPageContextProvider(provider: (input: PageContextInput) => Record<string, unknown> | undefined): () => void;
    getPageContextInput(): PageContextInput;
    getPageContextData(input?: PageContextInput): Record<string, unknown> | undefined;
    buildPageContextAttachment(): AgentAttachment | undefined;
    getToolRenderer(call: AgentToolCall): ToolRendererComponent | undefined;
    private ensureStore;
    private resolveChatId;
    private buildToolContext;
    private writeToolCall;
    private invokeTool;
}
//# sourceMappingURL=AgentRuntime.d.ts.map