import { type ProviderDefinition, type ProviderMethodSpec } from './index'; /** * Machine translation, as a service with providers behind it. * * ForgeZero does not translate anything at runtime — its own catalogues are * filled in out of band, before a build. This exists because a TENANT may want * it, and the alternative is every tenant writing the same retry, pacing and * quota handling against whichever vendor they already pay for. * * Nothing here is specific to Google beyond the one adapter at the bottom. The * service contract is "given source text and a target language, return the * translated strings in order", and a tenant that prefers a different vendor * writes forty lines rather than adopting ours. * * ## Why order matters in the contract * * Returning a map keyed by source string looks friendlier and loses duplicates: * two identical English strings in different contexts are two entries in a * catalogue and must stay two. Positional results keep them distinct. */ export interface TranslateRequest { /** Source strings, in catalogue order. Duplicates are meaningful. */ texts: readonly string[]; /** BCP-47 code the texts are written in. */ from: string; /** BCP-47 code to translate into. */ to: string; /** * What the strings are for, passed to the model as context. * * "Sign in" is a button in one product and an instruction in another, and a * translator with no context picks wrong in exactly the places a user * notices. */ context?: string; } export interface TranslateResult { /** One entry per input, in the same order. */ texts: string[]; /** What actually served the request, for a log somebody has to read later. */ model?: string; } /** Anything that can translate. A tenant may supply their own. */ export type TranslationProvider = ProviderDefinition<{ translate: ProviderMethodSpec; }>; /** * Google AI Studio, on the free tier. * * Chosen as the first adapter because the free tier is generous enough for a * catalogue and needs no billing account — a tenant can try the feature without * a procurement conversation. * * Structured output is requested explicitly. Asking a model for "JSON" in prose * and parsing whatever comes back is how translation pipelines start returning * markdown fences on a Tuesday; a schema makes the shape the model's problem. */ export declare const googleAiStudio: ProviderDefinition>>; export declare class TranslationError extends Error { readonly code: 'NO_CREDENTIAL' | 'RATE_LIMITED' | 'REQUEST_FAILED' | 'EMPTY_RESPONSE' | 'LENGTH_MISMATCH'; readonly status?: number | undefined; constructor(code: 'NO_CREDENTIAL' | 'RATE_LIMITED' | 'REQUEST_FAILED' | 'EMPTY_RESPONSE' | 'LENGTH_MISMATCH', message: string, status?: number | undefined); } /** * Read an array of strings out of a model response. * * Fences are stripped defensively: models that honour `responseSchema` never * emit them, and models that ignore it wrap the same JSON in ```json. Handling * both costs three lines and removes a class of "worked until we changed model". */ export declare function parseStrings(raw: string): string[]; export declare const translationProviders: readonly [ProviderDefinition>>];