/**
 * Streaming context management for automatic streaming in useModel calls.
 *
 * Follows the OpenTelemetry ContextManager pattern:
 * - Interface for context management
 * - Platform-specific implementations (Node.js AsyncLocalStorage, Browser Stack)
 * - Auto-detected at runtime - no separate entry points needed
 *
 * @see https://opentelemetry.io/docs/languages/js/context/
 */
import type { StreamChunkCallback } from "./types/components";
/**
 * Streaming context containing callbacks for streaming lifecycle.
 */
export interface StreamingContext {
    /** Called for each chunk of streamed content */
    onStreamChunk: StreamChunkCallback;
    /** Called when a useModel streaming call completes (allows reset between calls) */
    onStreamEnd?: () => void;
    messageId?: string;
    /** Optional abort signal to cancel streaming */
    abortSignal?: AbortSignal;
}
/**
 * Interface for streaming context managers.
 * Different implementations exist for Node.js (AsyncLocalStorage) and Browser (Stack).
 */
export interface IStreamingContextManager {
    /**
     * Run a function with a streaming context.
     * The context will be available to all nested async calls via `active()`.
     */
    run<T>(context: StreamingContext | undefined, fn: () => T): T;
    /**
     * Get the currently active streaming context.
     * Returns undefined if no context is active.
     */
    active(): StreamingContext | undefined;
}
/**
 * Set the global streaming context manager.
 * Can be used to override the auto-detected manager.
 *
 * @param manager - The context manager to use globally
 */
export declare function setStreamingContextManager(manager: IStreamingContextManager): void;
/**
 * Get the global streaming context manager.
 * Auto-detects and creates the appropriate manager on first access.
 */
export declare function getStreamingContextManager(): IStreamingContextManager;
/**
 * Run a function with a streaming context.
 * All useModel calls within this function will automatically use streaming.
 *
 * @example
 * ```typescript
 * await runWithStreamingContext(
 *   { onStreamChunk: async (chunk) => sendSSE(chunk), messageId },
 *   async () => {
 *     // All useModel calls here will stream automatically
 *     await runtime.processMessage(message);
 *   }
 * );
 * ```
 *
 * @param context - The streaming context with onStreamChunk callback
 * @param fn - The function to run with streaming context
 * @returns The result of the function
 */
export declare function runWithStreamingContext<T>(context: StreamingContext | undefined, fn: () => T): T;
/**
 * Get the currently active streaming context.
 * Called by useModel to check if automatic streaming should be enabled.
 *
 * @returns The current streaming context or undefined
 */
export declare function getStreamingContext(): StreamingContext | undefined;
//# sourceMappingURL=streaming-context.d.ts.map