/** * Media and document content types for multimodal AI interactions. * * This module provides types for handling images, videos, and documents * with support for multiple sources (bytes, S3, URLs, files). */ import type { Serialized, MaybeSerializedInput, JSONSerializable } from './json.js'; import { TextBlock, type TextBlockData } from './messages.js'; export type { ImageFormat, VideoFormat, DocumentFormat, MediaFormat } from '../mime.js'; import type { ImageFormat, VideoFormat, DocumentFormat } from '../mime.js'; /** * Cross-platform base64 encoding function that works in both browser and Node.js environments. */ export declare function encodeBase64(input: string | Uint8Array): string; /** * Cross-platform base64 decoding function that works in both browser and Node.js environments. * * @param input - Base64 encoded string to decode * @returns Decoded bytes as Uint8Array */ export declare function decodeBase64(input: string): Uint8Array; /** * Base interface for a document/media source location. */ export interface LocationData { /** * Location type discriminator. */ type: string; } /** * Data for an S3 location. */ export interface S3LocationData extends LocationData { /** * Location type — always "s3". */ type: 's3'; /** * S3 URI in format: s3://bucket-name/key-name */ uri: string; /** * AWS account ID of the S3 bucket owner (12-digit). * Required if the bucket belongs to another AWS account. */ bucketOwner?: string; } /** * S3 location for media and document sources. */ export declare class S3Location implements S3LocationData, JSONSerializable { readonly type: "s3"; readonly uri: string; readonly bucketOwner?: string; constructor(data: Omit & { type?: 's3'; }); /** * Serializes the S3Location to a JSON-compatible S3LocationData object. * Called automatically by JSON.stringify(). */ toJSON(): S3LocationData; /** * Creates an S3Location instance from S3LocationData. * * @param data - S3LocationData to deserialize * @returns S3Location instance */ static fromJSON(data: S3LocationData): S3Location; } /** * Source for an image (Data version). * Supports multiple formats for different providers. */ export type ImageSourceData = { bytes: Uint8Array; } | { location: S3LocationData; } | { url: string; }; /** * Source for an image (Class version). */ export type ImageSource = { type: 'imageSourceBytes'; bytes: Uint8Array; } | { type: 'imageSourceS3Location'; location: S3Location; } | { type: 'imageSourceUrl'; url: string; }; /** * Data for an image block. */ export interface ImageBlockData { /** * Image format. */ format: ImageFormat; /** * Image source. */ source: ImageSourceData; } /** * Image content block. */ export declare class ImageBlock implements ImageBlockData, JSONSerializable<{ image: Serialized; }> { /** * Discriminator for image content. */ readonly type: "imageBlock"; /** * Image format. */ readonly format: ImageFormat; /** * Image source. */ readonly source: ImageSource; constructor(data: ImageBlockData); private _convertSource; /** * Serializes the ImageBlock to a JSON-compatible ContentBlockData object. * Called automatically by JSON.stringify(). * Uint8Array bytes are encoded as base64 string. */ toJSON(): { image: Serialized; }; /** * Creates an ImageBlock instance from its wrapped data format. * Base64-encoded bytes are decoded back to Uint8Array. * * @param data - Wrapped ImageBlockData to deserialize (accepts both string and Uint8Array for bytes) * @returns ImageBlock instance */ static fromJSON(data: { image: MaybeSerializedInput; }): ImageBlock; } /** * Source for a video (Data version). */ export type VideoSourceData = { bytes: Uint8Array; } | { location: S3LocationData; }; /** * Source for a video (Class version). */ export type VideoSource = { type: 'videoSourceBytes'; bytes: Uint8Array; } | { type: 'videoSourceS3Location'; location: S3Location; }; /** * Data for a video block. */ export interface VideoBlockData { /** * Video format. */ format: VideoFormat; /** * Video source. */ source: VideoSourceData; } /** * Video content block. */ export declare class VideoBlock implements VideoBlockData, JSONSerializable<{ video: Serialized; }> { /** * Discriminator for video content. */ readonly type: "videoBlock"; /** * Video format. */ readonly format: VideoFormat; /** * Video source. */ readonly source: VideoSource; constructor(data: VideoBlockData); private _convertSource; /** * Serializes the VideoBlock to a JSON-compatible ContentBlockData object. * Called automatically by JSON.stringify(). * Uint8Array bytes are encoded as base64 string. */ toJSON(): { video: Serialized; }; /** * Creates a VideoBlock instance from its wrapped data format. * Base64-encoded bytes are decoded back to Uint8Array. * * @param data - Wrapped VideoBlockData to deserialize (accepts both string and Uint8Array for bytes) * @returns VideoBlock instance */ static fromJSON(data: { video: MaybeSerializedInput; }): VideoBlock; } /** * Content blocks that can be nested inside a document. * Documents can contain text blocks for structured content. */ export type DocumentContentBlockData = TextBlockData; export type DocumentContentBlock = TextBlock; /** * Source for a document (Data version). * Supports multiple formats including structured content. */ export type DocumentSourceData = { bytes: Uint8Array; } | { text: string; } | { content: DocumentContentBlockData[]; } | { location: S3LocationData; }; /** * Source for a document (Class version). */ export type DocumentSource = { type: 'documentSourceBytes'; bytes: Uint8Array; } | { type: 'documentSourceText'; text: string; } | { type: 'documentSourceContentBlock'; content: DocumentContentBlock[]; } | { type: 'documentSourceS3Location'; location: S3Location; }; /** * Data for a document block. */ export interface DocumentBlockData { /** * Document name. */ name: string; /** * Document format. */ format: DocumentFormat; /** * Document source. */ source: DocumentSourceData; /** * Citation configuration. */ citations?: { enabled: boolean; }; /** * Context information for the document. */ context?: string; } /** * Document content block. */ export declare class DocumentBlock implements DocumentBlockData, JSONSerializable<{ document: Serialized; }> { /** * Discriminator for document content. */ readonly type: "documentBlock"; /** * Document name. */ readonly name: string; /** * Document format. */ readonly format: DocumentFormat; /** * Document source. */ readonly source: DocumentSource; /** * Citation configuration. */ readonly citations?: { enabled: boolean; }; /** * Context information for the document. */ readonly context?: string; constructor(data: DocumentBlockData); private _convertSource; /** * Serializes the DocumentBlock to a JSON-compatible ContentBlockData object. * Called automatically by JSON.stringify(). * Uint8Array bytes are encoded as base64 string. */ toJSON(): { document: Serialized; }; /** * Creates a DocumentBlock instance from its wrapped data format. * Base64-encoded bytes are decoded back to Uint8Array. * * @param data - Wrapped DocumentBlockData to deserialize (accepts both string and Uint8Array for bytes) * @returns DocumentBlock instance */ static fromJSON(data: { document: MaybeSerializedInput; }): DocumentBlock; } //# sourceMappingURL=media.d.ts.map