import { JSONValue } from '../../global/dist/index.js';
import { MessageContentDetail, MessageContent, ChatMessage, ToolMetadata } from '../../llms/dist/index.js';
import { QueryType } from '../../query-engine/dist/index.js';
import { ImageType } from '../../schema/dist/index.js';

/**
 * Extracts just the text whether from
 *  a multi-modal message
 *  a single text message
 *  or a query
 *
 * @param message The message to extract text from.
 * @returns The extracted text
 */
declare function extractText(message: MessageContent | QueryType): string;
/**
 * Extracts a single text from a multi-modal message content
 *
 * @param message The message to extract images from.
 * @returns The extracted images
 */
declare function extractSingleText(message: MessageContentDetail): string | null;
/**
 * Extracts an image from a multi-modal message content
 *
 * @param message The message to extract images from.
 * @returns The extracted images
 */
declare function extractImage(message: MessageContentDetail): ImageType | null;
declare const extractDataUrlComponents: (dataUrl: string) => {
    mimeType: string;
    base64: string;
};
declare function messagesToHistory(messages: ChatMessage[]): string;
declare function toToolDescriptions(tools: ToolMetadata[]): string;
declare function imageToDataUrl(input: ImageType | Uint8Array): Promise<string>;

/**
 * Converts a base64 string (without data: prefix) to a Uint8Array
 * @param base64 - The base64 string without data: prefix
 * @returns The Uint8Array
 */
declare function base64ToUint8Array(base64: string): Uint8Array;
/**
 * Converts a Uint8Array to a base64 string.
 * @param uint8Array The Uint8Array to convert.
 * @returns The base64-encoded string.
 */
declare function uint8ArrayToBase64(uint8Array: Uint8Array): string;
/**
 * Extracts the MIME type from a data URL.
 * @param dataUrl The data URL string.
 * @returns The MIME type from the data URL.
 * @throws An error if the data URL is malformed.
 */
declare function getMimeTypeFromDataUrl(dataUrl: string): string;
/**
 * Convert base64 data to Blob
 * @param base64 - The base64 string
 * @param mimeType - The MIME type of the file
 * @returns The Blob
 */
declare function base64ToBlob(base64: string, mimeType?: string): Blob;
declare function blobToDataUrl(input: Blob): Promise<string>;

type ObjectEntries<T extends Record<string, any>> = {
    [K in keyof T]: [K, T[K]];
}[keyof T][];
/**
 * Type safe version of `Object.entries`
 */
declare function objectEntries<T extends Record<string, any>>(obj: T): ObjectEntries<{
    [K in keyof T]-?: NonNullable<T[K]>;
}>;

declare function streamConverter<S, D>(stream: AsyncIterable<S>, converter: (s: S) => D | null): AsyncIterable<D>;

declare const isPromise: <T>(obj: unknown) => obj is Promise<T>;
declare const isAsyncIterable: (obj: unknown) => obj is AsyncIterable<unknown>;
declare const isIterable: (obj: unknown) => obj is Iterable<unknown>;
declare function streamCallbacks<S>(stream: AsyncIterable<S>, callbacks: {
    finished?: (value?: S) => void;
}): AsyncIterable<S>;
declare function streamReducer<S, D>(params: {
    stream: AsyncIterable<S>;
    reducer: (previousValue: D, currentValue: S) => D;
    initialValue: D;
    finished?: (value: D) => void;
}): AsyncIterable<S>;
/**
 * Prettify an error for AI to read
 */
declare function prettifyError(error: unknown): string;
/**
 * Returns a stringfied JSON with double quotes removed.
 *
 * @param value - The JSON value to stringify
 * @returns The stringified JSON with no double quotes
 */
declare function stringifyJSONToMessageContent(value: JSONValue): string;
declare function assertIsJSONValue(value: unknown): asserts value is JSONValue;

export { assertIsJSONValue, base64ToBlob, base64ToUint8Array, blobToDataUrl, extractDataUrlComponents, extractImage, extractSingleText, extractText, getMimeTypeFromDataUrl, imageToDataUrl, isAsyncIterable, isIterable, isPromise, messagesToHistory, objectEntries, prettifyError, streamCallbacks, streamConverter, streamReducer, stringifyJSONToMessageContent, toToolDescriptions, uint8ArrayToBase64 };
