@mastra/core
Version:
30 lines • 1.59 kB
TypeScript
import { MastraError } from '../../../error/index.js';
import type { AIV5Type } from '../types.js';
export declare const downloadFromUrl: ({ url, downloadRetries }: {
url: URL;
downloadRetries: number;
}) => Promise<{
data: Uint8Array<ArrayBuffer>;
mediaType: string | undefined;
}>;
/** The key a part's download result is stored under, or `undefined` when the part is not a URL. */
export declare function getAssetUrl(part: AIV5Type.ImagePart | AIV5Type.FilePart): string | undefined;
/**
* Successful downloads keyed by URL, shared across the prompt builds of one run so
* each attachment is downloaded at most once per run. Failures are not kept, so a
* retry requested by an error processor fetches again.
*/
export type AssetDownloadCache = Map<string, ReturnType<typeof downloadFromUrl>>;
export declare function isDownloadAssetsError(error: unknown): error is MastraError;
export declare function downloadAssetsFromMessages({ messages, downloadConcurrency, downloadRetries, supportedUrls, cache, isUnavailable, onUnavailable, }: {
messages: AIV5Type.ModelMessage[];
downloadConcurrency?: number;
downloadRetries?: number;
supportedUrls?: Record<string, RegExp[]>;
cache?: AssetDownloadCache;
/** Returns true for URLs already known to be unavailable. They are not fetched. */
isUnavailable?: (url: string) => boolean;
/** When set, a failed download is reported here instead of failing the whole prompt. */
onUnavailable?: (url: string, error: MastraError) => void;
}): Promise<any>;
//# sourceMappingURL=download-assets.d.ts.map