import { type ResultValue } from "../runtime/result.js"; import { type LocalReply, type LocalRequestOptions } from "./localRequest.js"; import type { HostNetwork } from "../host/host.js"; /** The TypeScript half of `std::vision`: one HTTP call behind three thin * exports. The Agency side has already raised `std::vision` for the * image's real path; this side re-validates that spelling, checks the * model is a vision model, reads the image, and posts its bytes to the * server `agency local serve` runs. The server never opens a path a * request names. */ /** The largest image sent. `MAX_IMAGE_BYTES` in * lib/cli/localServerCommon.py is the same, and a test compares them. */ export declare const MAX_IMAGE_BYTES = 50000000; /** The largest request body the vision server takes: the base64 of the * largest image, four characters for every three bytes, and room for the * settings. `MAX_BODY_BYTES` in lib/cli/visionRules.py is computed the * same way, and a test compares them. The serve front door holds vision * requests to it. This module cannot import `base64Length` from * localImageInputs.ts, which imports `MAX_IMAGE_BYTES` from here. */ export declare function visionBodyBytes(): number; /** What the client knows about one vision task. * * route where the server answers it, under `/v1` * replyField the field of the reply that holds the answer * numbered true: each item of the answer gets an `id`, its index, so * a caller can name crops after it * logNoun what the serve log counts the answer in, such as "tag" * logBody false: the serve log shows the reply's size alone and never * reads it, because the reply is too long to print or to * capture whole */ export type VisionTaskRow = { route: string; replyField: string; numbered: boolean; logNoun: string; logBody: boolean; }; /** One row per task the vision server answers. `ROUTE_TABLE` in * lib/cli/visionRules.py is the server's side, and a test compares the * routes. */ export declare const VISION_TASKS: { detections: { route: string; replyField: string; numbered: true; logNoun: string; logBody: true; }; tags: { route: string; replyField: string; numbered: false; logNoun: string; logBody: true; }; captions: { route: string; replyField: string; numbered: false; logNoun: string; logBody: true; }; embeddings: { route: string; replyField: string; numbered: false; logNoun: string; logBody: false; }; regions: { route: string; replyField: string; numbered: true; logNoun: string; logBody: true; }; }; export type VisionTask = keyof typeof VISION_TASKS; /** The model to send: the served name, or the reason it cannot be sent. */ export declare function checkVisionModel(model: string): { servedName: string; } | { error: string; }; /** Posts one request for an image already read, and returns the reply's * JSON or a failure worded for the caller to prefix. `model` is the name * the caller gave, for the message that says how to start a server, and * `servedName` the one `checkVisionModel` returned for it. */ export declare function postVisionRequest(network: HostNetwork, task: VisionTask, model: string, servedName: string, imageBase64: string, fields: Record, options?: LocalRequestOptions): Promise; /** The answer in a reply: its `replyField`, with each item given its * index as `id` when the task's row says so. */ export declare function visionAnswer(task: VisionTask, reply: Record): unknown; /** The file a vision function reads: its real spelling, and the folder and * name the std::vision interrupt shows. */ export type VisionFile = { image: string; dir: string; filename: string; }; /** Resolves the image a vision function was given. Throws for a path that * cannot be resolved, so the function fails before it asks anything. */ export declare function _visionFile(spelling: string): Promise; /** Backs `std::vision.detectObjects`. A null threshold is sent as JSON * null, which the server reads as the model's own default. */ export declare function _detectObjects(spelling: string, labels: string[], model: string, threshold: number | null): Promise; /** Backs `std::vision.tagImage`. */ export declare function _tagImage(spelling: string, model: string, threshold: number, limit: number): Promise; /** Backs `std::vision.captionImage`. */ export declare function _captionImage(spelling: string, model: string, detail: string): Promise; /** Backs `std::vision.embedImage`. Null boxes are sent as JSON null, which * the server reads as the whole image; an empty list embeds nothing. */ export declare function _embedImage(spelling: string, model: string, boxes: unknown[] | null): Promise; /** Backs `std::vision.findRegions`. A null threshold is sent as JSON null, * which the server reads as its default. */ export declare function _findRegions(spelling: string, model: string, limit: number, threshold: number | null): Promise;