import type { Context } from "@earendil-works/chord"; import type { ConversationId, Extension, ToolExecutionApi, ToolExecutionResult } from "@earendil-works/pi-durable"; import type { VisionEnv } from "./core/env.js"; import type { CallContext, ReadArgs, ToolResult, VisionOptions } from "./core/host.js"; import { type JudgeGlobal } from "./core/judge.js"; import { type TranscribeGlobal } from "./core/transcribe.js"; import { type SeeGlobal } from "./core/see.js"; import { type ChildEnv } from "./node.js"; export { modelsEyes, modelsOf, type ModelsDoor, type ModelsEyesOptions } from "./eyes/models.js"; export { packageProviders } from "./providers/defaults.js"; /** What `createVisionExtension` gives: the extension to install, and the same reading and fitting as functions for a host that * shapes results itself, with the code-mode globals. */ export type VisionHandle = { /** Install once per Harness; select per conversation. */ readonly extension: Extension; /** The media half of `read`, for a host whose `read` is its own. Null when the path reads as plain text. */ read(env: VisionEnv, args: ReadArgs, call: CallContext): Promise; /** One tool result's image blocks fitted to the call's route, for a host that shapes results itself. */ fit(result: ToolResult, call: CallContext): Promise; /** The text of a PDF held in memory; null when it has none. */ pdfText(bytes: Uint8Array, signal?: AbortSignal): Promise; /** `vision.see` for a host's code-mode sandbox, built per call so it has the call's memos and environment: pass it in * pi-codemode's `globals`, as in `globals: [vision.see(api.env, await callContext(api, context))]`. It reads paths * through `env`; with none, it sees image blocks only. */ see(env: VisionEnv | undefined, call: CallContext): SeeGlobal; /** `vision.judge`, Jev's typed answers about images (`VisionOptions.jev`), for the same sandbox, built the same way. */ judge(env: VisionEnv | undefined, call: CallContext): JudgeGlobal; /** `vision.transcribe`, what is said in a recording (`VisionOptions.transcriber`), for the same sandbox, built the same way. */ transcribe(env: VisionEnv | undefined, call: CallContext): TranscribeGlobal; }; /** pi's tool result for the core's: the blocks, the error flag, the details and the usage pi folds into the * conversation's spend under the tool's name. */ export declare function piResult(result: ToolResult): ToolExecutionResult; /** The call context of one pi tool call, for a pi-durable host whose `read` is its own: pass it as it is to * `handle.read` and `handle.fit`, which then look through the call's `api.models` too. `tool` names the tool whose * result `fit` guards, for its rows; pi's tool API does not say it. */ export declare function callContext(api: ToolExecutionApi, context: Context, tool?: string): Promise; /** The host contract, and one thing only an adapter that starts programs needs: `env`, the whole environment of every * program a read starts (a PDF reader, ffmpeg, LibreOffice), in whichever environment the call runs and whatever * that environment would give a program itself. Without it a program gets `inheritedEnv()` of `./node`: where * programs are found, home, temp, locale and time zone, and never the rest of this process's environment. A host * whose calls run on another machine names that machine's. `scope` is also given pi's own conversation id, which * pi's documents and `harness.snapshot` take; it is undefined only for a call context the host built itself rather * than through `callContext`. */ export type VisionAdapterOptions = Omit & { readonly scope: (conversationId: string, id: ConversationId | undefined) => ReturnType; readonly env?: ChildEnv; }; /** The pi-durable adapter. The extension it makes wraps `read` with the media half and guards the image blocks of every tool's * result (`options.install` turns either off); the handle gives the same as functions and builds `vision.see`, `vision.judge` * and `vision.transcribe` for a call. Nothing here loads a dependency until a call needs it. */ export declare function createVisionExtension(options: VisionAdapterOptions): VisionHandle;