/** * MiniMax Provider Media Module (DESIGN.md §9 — P3-02). * * Owns MiniMax-local image media facts: accepted extensions, size limit, * existence check, and absolute-path resolution. Commands pass raw * path-or-URL strings; this module is the single owner of every * Provider-specific media decision for MiniMax images. * * Boundary rules (ARCHITECTURE.md §2): * - May import normalized errors from `lib/errors.ts` and the shared * `ProviderQuotaFetch` port from `providers/types.ts` (HTTP-source * image fetch only). * - Content reads happen here, in the Adapter-local media Module, * since the SDK no longer performs data-URI conversion. The Module * owns every MiniMax image fact: accepted extensions, size limit, * existence check, absolute-path resolution, MIME detection, and * base64 conversion. * * Media rules (DESIGN.md §9 MiniMax Transitional SDK): * - Local image: JPG, JPEG, PNG, WebP (case-insensitive), at most 50 MiB. * - HTTP(S) source is accepted. * - Local source becomes an absolute path after validation. * - `convertToDataUri` performs data-URI conversion for HTTP sources * (fetched bytes) and local paths (read bytes); `data:` URIs pass * through unchanged. * - No MiniMax video media module exists in this scope. * - Missing local file rejects with `FILE_ERROR`. * - Non-HTTP URL-like strings and unsupported extensions reject with * `VALIDATION_ERROR` and Provider-specific supported-format help. */ import type { ProviderImageFetch } from "../types.js"; /** * HTTP image-fetch timeout in milliseconds (DESIGN.md §9, critique G2). * Matches the SDK's effective default (`config.timeout * 1000`, * `config.timeout = 300` → 30 s). Local files are NOT bound by this * timeout — already validated synchronously by `resolveImageSource` * via `fs.statSync`, so a slow disk read is not a real risk here. */ export declare const MINIMAX_IMAGE_FETCH_TIMEOUT_MS = 30000; /** * Local-file extension → MIME mapping for `convertToDataUri` (critique * G1). Mirrors the SDK's `IMAGE_MIME_TYPES` table at * `mmx-cli/dist/sdk.mjs:1581-1586` exactly. The extension has already * been validated against `MINIMAX_IMAGE_EXTENSIONS` by * `resolveImageSource`, so a missing entry is not expected at this * layer (we still fall back to `image/jpeg` defensively, matching SDK). */ export declare const MINIMAX_IMAGE_MIME_BY_EXTENSION: Readonly>; /** * Resolve a MiniMax image source into the value the MiniMax SDK consumes. * For a local file, validates existence, size (≤ 50 MiB), and extension * (JPG/JPEG/PNG/WebP) and returns the absolute path (the SDK performs * data-URI conversion from this path). For an HTTP(S) URL, returns the URL * unchanged without touching the local filesystem. */ export declare function resolveImageSource(source: string): string; /** * Injectable dependencies for `convertToDataUri`. Fetch and timer * injection mirror the `MiniMaxQuotaClientDeps` pattern in * `quota-client.ts` so a unit test can drive the HTTP branch * deterministically without real network I/O. */ export interface ConvertToDataUriDeps { readonly fetch?: ProviderImageFetch; readonly setTimeout?: typeof setTimeout; readonly clearTimeout?: typeof clearTimeout; } /** * Convert a MiniMax image source into the `data:;base64,...` form * the MiniMax VLM endpoint consumes. Three branches: * * 1. `data:` prefix → returned unchanged. * 2. `http(s)://` → bytes fetched via injected `fetch` with an * `AbortController` timed out by `MINIMAX_IMAGE_FETCH_TIMEOUT_MS`, * MIME detected via `detectMimeFromContentType`, base64-encoded. * The 50 MiB cap (`MINIMAX_MAX_IMAGE_BYTES`) is enforced on the * fetched byte length. * 3. Local path → bytes read via `node:fs/promises`, MIME from * `MINIMAX_IMAGE_MIME_BY_EXTENSION`. The path has already been * validated (existence, size, extension) by `resolveImageSource`, * so this branch trusts the prior validation. * * The HTTP branch mirrors the abort/timeout + injected-fetch + * injected-setTimeout pattern from `quota-client.ts` so the same test * fixtures drive both transports. */ export declare function convertToDataUri(source: string, deps?: ConvertToDataUriDeps): Promise; //# sourceMappingURL=media.d.ts.map