@mastra/core
Version:
47 lines • 2.37 kB
TypeScript
/**
* Shared provider registry generation logic
* Used by both the CLI generation script and runtime refresh
*/
import type { AttachmentCapabilities, MastraModelGatewayInterface, ProviderConfig, TemperatureCapabilities } from './gateways/base.js';
/**
* Write a file atomically using the write-to-temp-then-rename pattern.
* This prevents file corruption when multiple processes write to the same file concurrently.
*
* The rename operation is atomic on POSIX systems when source and destination
* are on the same filesystem.
*
* @param filePath - The target file path
* @param content - The content to write
* @param encoding - The encoding to use (default: 'utf-8')
*/
export declare function atomicWriteFile(filePath: string, content: string, encoding?: BufferEncoding): Promise<void>;
/**
* Fetch providers from all enabled gateways with silent retry logic.
* Retries up to 3 times per gateway with exponential backoff. If all
* retries are exhausted the gateway is silently skipped (no error logging)
* since the bundled registry already contains all model data.
* @param gateways - Array of gateway instances to fetch from
* @returns Object containing providers and models records
*/
export declare function fetchProvidersFromGateways(gateways: MastraModelGatewayInterface[]): Promise<{
providers: Record<string, ProviderConfig>;
models: Record<string, string[]>;
attachmentCapabilities: AttachmentCapabilities;
temperatureCapabilities: TemperatureCapabilities;
failedGateways: string[];
}>;
/**
* Generate TypeScript type definitions content
* @param models - Record of provider IDs to model arrays
* @returns Generated TypeScript type definitions as a string
*/
export declare function generateTypesContent(models: Record<string, string[]>): string;
/**
* Write registry files to disk (JSON and .d.ts)
* @param jsonPath - Path to write the JSON file
* @param typesPath - Path to write the .d.ts file
* @param providers - Provider configurations
* @param models - Model lists by provider
*/
export declare function writeRegistryFiles(jsonPath: string, typesPath: string, providers: Record<string, ProviderConfig>, models: Record<string, string[]>, attachmentCapabilities?: AttachmentCapabilities, temperatureCapabilities?: TemperatureCapabilities): Promise<void>;
//# sourceMappingURL=registry-generator.d.ts.map