/** * @fileoverview Index export. * @license * SPDX-License-Identifier: Apache-2.0 */ import { type StreamItems, type ReadableStream, type WritableStream } from "./stream/interfaces"; /** google.protobuf.Any proto mapping. */ export declare interface Any { readonly '@type': string; readonly [key: string]: undefined | null | string | number | boolean | object; } /** Metadata for a chunk. */ export declare interface ChunkMetadata { readonly mimetype?: Mimetype; readonly role?: string; readonly captureTime?: Date; readonly experimental?: Any[]; } /** Structured mimetype */ export interface Mimetype { readonly type?: string; readonly subtype?: string; readonly prefix?: string; readonly suffix?: string; readonly parameters?: Record; } /** Chunk with metadata. */ export interface MetadataChunk { readonly metadata?: ChunkMetadata; } /** Chunk with bytes. */ export interface DataChunk extends MetadataChunk { readonly data: Uint8Array; readonly ref?: undefined; } /** Chunk with a reference to content elsewhere. */ export interface RefChunk extends MetadataChunk { readonly data?: undefined; readonly ref: string; } /** Smallest unit of streamable information. */ export type Chunk = DataChunk | RefChunk; export type Content = StreamItems; export type Input = ReadableStream; export type Output = WritableStream; export interface Pipe extends Input, Output { } export type Dict = Readonly>; type StreamTypeOfDict> = T extends Dict ? U extends WritableStream ? V : never : never; export declare abstract class Action = Dict, U extends Dict = Dict> { abstract run(session: Session, inputs: T, outputs: U): Promise; } export type ActionInputs = T extends Action ? U : never; export type ActionOutputs = T extends Action ? Dict>, keyof V & string> : never; export type ActionConstraints = keyof ActionOutputs & string; /** Simplified transform of a unified Chunk stream. */ export type Processor = (stream: AsyncIterable<[I, T]>) => AsyncGenerator<[O, U]>; /** Processor Chunks. */ export type ProcessorChunks = AsyncIterable<[T, U]>; /** Input dict to a processor. */ export type ProcessorInputs = T extends Processor ? Record> : never; /** Output dict to a processor. */ export type ProcessorOutputs = T extends Processor ? Record> : never; export type ProcessorConstraints = keyof ProcessorOutputs & string; export interface Session { createPipe(content?: Content): Pipe; run = ActionConstraints>(action: T, inputs: ActionInputs, outputs: U[]): Pick, U>; run, U extends ProcessorConstraints = ProcessorConstraints>(processor: T, inputs: ProcessorInputs, outputs: U[]): Pick, U>; close(): Promise; } export interface SessionWriteOptions { seq?: number; continued?: boolean; } export interface SessionContext { read(id: string): AsyncIterable; write(id: string, chunk: Chunk, options?: SessionWriteOptions): Promise; error(id: string, reason?: string): void; close(): Promise; } export type SessionContextMiddleware = (context: SessionContext) => SessionContext; export type SessionProvider = (...middleware: SessionContextMiddleware[]) => Session; export {};