import type { MissCode } from "./contract.js"; import { type VisionEnv } from "./env.js"; import { type Filing, type LookRecord } from "./evidence.js"; import type { CallContext, CallSetup, ImageContent } from "./host.js"; import type { ImageProcessor } from "./image.js"; import { type Kind } from "./kinds.js"; import { type Miss } from "./misses.js"; /** A look `vision.see` or `vision.judge` could not make, thrown once it is filed and told; the message starts with the code. */ export declare class SeeMiss extends Error { readonly code: MissCode; constructor(code: MissCode, reason: string); } /** A processor that fits nothing: an image within the limits passes as it is, any other is refused. */ export declare const AS_IS: ImageProcessor; /** The media fields of a code-mode request: `fragments[i]` names medium `i`, the images first and then the paths. */ export type MediaRequest = { readonly images?: readonly ImageContent[]; readonly paths?: readonly string[]; readonly fragments?: readonly string[]; }; export type Medium = { readonly bytes: Uint8Array; readonly mimeType: string; readonly fragment: string; }; /** What a miss with no block in a request is about: the medium as the agent named it, the kind it reads as, the hash * of its bytes ("" when none were read), and the window or page its name cites; or the request's media before any is * read. */ export type About = { readonly path: string; readonly kind: Kind; readonly sha256: string; readonly fragment: string; }; /** A miss on its way to being filed, with the medium it is about when it is about one. */ export type MediaMiss = Miss & { readonly about?: About; }; export declare const aboutMedium: (label: string, kind: Kind, bytes?: Uint8Array) => About; /** Before any medium is read, a miss is about the request's media as named: their kind and bytes are known only when * every one is a block. */ export declare function requestedAbout(r: MediaRequest): About; /** Whether `r` names at least one image block or path, each well formed. */ export declare const namesMedia: (r: Record) => boolean; /** A miss filed as a failed look and told, then thrown. A stopped call files none: what failed was the stop (a * cancelled read, say), not the source or the model; it rejects with the stop's reason. */ export declare function throwMiss(filing: Filing, tool: string, call: CallContext, cause: Miss, record: LookRecord): Promise; /** The request's media: its image blocks, then its files read through `env`, each checked as an image or a video and * against the host's policy. `fail` files and throws the miss for a file that cannot be used. */ export declare function gatherMedia(request: MediaRequest, env: VisionEnv | undefined, call: CallContext, setup: CallSetup, tool: "vision.see" | "vision.judge", fail: (cause: MediaMiss) => Promise): Promise; /** `work` for `key`, once at a time per call: a second ask while the first runs waits for it, alone paying, filing and * telling, and is told it `shared`. */ export declare function singleFlight(call: CallContext, key: string, work: () => Promise): Promise<{ readonly value: T; readonly shared: boolean; }>;