/** The images a `generateImageLocal` request can carry, one row per request * field. `INPUT_IMAGES` in lib/cli/diffusersImageRules.py is the same * table for the image server, and a test compares the two. * * mode which kind of request the field makes: a ControlNet request, * an edit from reference pictures, a redraw of a start image, or * a redraw of the part of a start image a mask marks * maxCount how many images the field takes. One is sent as a base64 * string, more as a list of them * maxBytes the largest file each image may be * parameter the `generateImageLocal` parameter the paths come in * question what the std::readImage interrupt asks before the file is read * readEachStep true: the model reads each image at every step, as much * work as one more megapixel of output, and the provider's * timeout budgets for it * goesWith optional: the field this one comes only with. A mask goes * with a start image */ export type LocalImageField = { mode: "control" | "reference" | "img2img" | "inpaint"; maxCount: number; maxBytes: number; parameter: string; question: string; readEachStep: boolean; goesWith?: string; }; /** A control image is read up to the size every local server takes. */ export declare const MAX_CONTROL_IMAGE_BYTES = 50000000; /** A reference image or a start image. The model shrinks a reference to * about one megapixel, and a start image is scaled to the output size, * so a larger file buys nothing. */ export declare const MAX_INPUT_IMAGE_BYTES = 20000000; export declare const MAX_REFERENCE_IMAGES = 4; /** Room in a request body for everything but its images: the prompt and * the settings. */ export declare const REQUEST_SETTINGS_BYTES: number; export declare const LOCAL_IMAGE_FIELDS: Record; /** The image fields a request in `mode` carries, the one that sets the size * first. A field that goes with another brings it along, so inpaint is * start_image and mask_image. `image_fields_of` in diffusersImageRules.py * is the same. */ export declare function imageFieldsOf(mode: LocalImageField["mode"]): string[]; /** How many characters base64 turns `bytes` bytes into. */ export declare function base64Length(bytes: number): number; /** The largest request body the image server takes: the settings, plus the * base64 of the most image bytes one mode's fields may carry. * `MAX_BODY_BYTES` in diffusersImageRules.py is computed the same way. */ export declare function localBodyBytes(): number; /** The image types a local input may be, by extension. */ export declare const IMAGE_MIME_TYPES: Record; export declare function isRemoteSource(source: string): boolean; /** The real spelling of a local image file, once it is checked by name and * stat: an image extension, a regular file, at most `maxBytes`. No byte is * read, so a bad path fails here, before any approval is asked for. * `caller` names the stdlib function in a refusal. */ export declare function checkedImageFile(spelling: string, maxBytes: number, caller: string): string; /** One file a `generateImageLocal` call reads, after the std::readImage * interrupt that shows its folder and name asks `question`. `path` is its * real spelling, the one the interrupt shows, and `field` is the request * field it goes in. */ export type LocalImageFile = { field: string; path: string; dir: string; filename: string; question: string; }; /** The input images of one `generateImageLocal` call, none for a call * with none. `settings` holds the other request fields of the call's * mode, such as `controlnet` and `control_scale`. */ export type LocalImageInputs = { files: LocalImageFile[]; settings: Record; }; /** How many images of `inputs` the model reads at every step, which the * provider's timeout budgets for. 0 for a call with none. */ export declare function referenceCount(inputs: LocalImageInputs): number; /** How many images a call gave for each request field, by field name: * `{ control_image: 0, images: 2, start_image: 0, mask_image: 0 }`. */ export type ImageCounts = Record; /** The settings of a call that belong to one mode or another. */ export type ModeControls = { controlnet: string; controlScale: number | null; invertControlImage: boolean; strength: number | null; }; /** Which kind of request a call makes, decided from how many images it * gave and no file. * * fields the request fields in play, the one that sets the size * first. Empty for a call with no input image * settings the other request fields of the mode, such as `controlnet` * references how many images the model reads at every step, for the * timeout */ export type LocalImageMode = { fields: string[]; settings: Record; references: number; }; /** The checks on a call's input images that need no file: whether the * inputs go together, whether the strength is in range, that the call is * in one mode, and that no field has too many images. Throws with the * message to fail with, which starts with `caller`. The messages match * the image server's, with the parameters' names for the request * fields'. */ export declare function localImageMode(counts: ImageCounts, controls: ModeControls, caller: string): LocalImageMode; /** Backs the checks `generateImageLocal` makes before it asks anything: * which input images the call has, whether they go together, whether * there are too many, and whether each path is a local image file under * its field's size cap. Returns the files to raise std::readImage for. * Throws with the message to fail with. */ export declare function _localImageInputs(controlnet: string, controlImage: string, controlScale: number | null, invertControlImage: boolean, images: string[], startImage: string, strength: number | null, mask: string): LocalImageInputs; /** The value a request field carries for its images, each already * base64: one string when the field takes one image, a list otherwise. */ export declare function fieldValue(field: string, encoded: string[]): string | string[]; /** One input image as base64, from a path or from the image's bytes, at * most `maxBytes` either way. For the functions `agency-lang/local` * exports, which take both and raise no interrupt. * * A path goes through the same checks a stdlib input does: a file on * this machine, an image extension, a regular file, no symlink, and a * read through the contained-files module. Throws with the reason. */ export declare function encodedImageInput(input: string | Uint8Array, maxBytes: number, caller: string): Promise;