@entro314labs/ai-changelog-generator
Version:
AI-powered changelog generator with MCP server support - works with most providers, online and local models
154 lines (153 loc) • 5.7 kB
TypeScript
/**
* Common utility functions for AI providers
* Consolidates duplicate logic across all provider implementations
*/
export interface BedrockCredentialBundle {
accessKeyId: string;
secretAccessKey: string;
sessionToken?: string;
region?: string;
}
/**
* Serialize the complete AWS credential set as one secret value. Config and
* keychain backends encrypt/protect this whole value, avoiding secret material
* in metadata or VS Code settings.
*/
export declare function encodeBedrockCredential(bundle: BedrockCredentialBundle): string;
export declare function decodeBedrockCredential(value: unknown): BedrockCredentialBundle;
/**
* Standard model selection algorithm based on commit details
* @param {Object} commitDetails - Details about the commit (files, lines, breaking, complex)
* @param {Object} modelConfig - Provider-specific model configuration
* @returns {Object} Selected model and reason
*/
export declare function selectModelByComplexity(commitDetails: any, modelConfig: any): {
model: any;
reason: string;
};
/**
* Standard connection test implementation
* @param {Function} generateCompletion - Provider's generateCompletion method
* @param {string} defaultModel - Default model to use for testing
* @returns {Promise<Object>} Test result with success status
*/
export declare function standardConnectionTest(generateCompletion: any, defaultModel: any): Promise<{
success: boolean;
response: any;
model: any;
error?: undefined;
} | {
response?: undefined;
success: boolean;
error: any;
model?: undefined;
}>;
/**
* Generate standard error response for provider operations
* @param {string} providerName - Name of the provider
* @param {string} operation - Operation that failed
* @param {string} reason - Reason for failure
* @param {Array} alternatives - Alternative suggestions
* @returns {Object} Standardized error response
*/
export declare function createProviderErrorResponse(providerName: any, operation: any, reason: any, alternatives?: any[]): {
available: boolean;
provider: any;
operation: any;
error: any;
alternatives: any[];
timestamp: string;
};
/**
* Generate standard success response for provider operations
* @param {string} providerName - Name of the provider
* @param {Object} data - Success data
* @returns {Object} Standardized success response
*/
export declare function createProviderSuccessResponse(providerName: any, data?: Record<string, any>): {
available: boolean;
provider: any;
timestamp: string;
};
/**
* Build common model capabilities structure
* @param {Object} baseCapabilities - Base capabilities all models have
* @param {Object} modelSpecificCapabilities - Capabilities specific to the model
* @returns {Object} Complete capabilities object
*/
export declare function buildCapabilities(baseCapabilities?: Record<string, any>, modelSpecificCapabilities?: Record<string, any>): {
vision: boolean;
tool_use: boolean;
json_mode: boolean;
reasoning: boolean;
large_context: boolean;
streaming: boolean;
temperature_control: boolean;
max_tokens_control: boolean;
};
/**
* Extract provider configuration with defaults
* @param {Object} config - Full configuration object
* @param {string} providerPrefix - Provider prefix (e.g., 'OPENAI', 'ANTHROPIC')
* @param {Object} defaults - Default values for missing config
* @returns {Object} Provider-specific configuration
*/
export declare function extractProviderConfig(config: any, providerPrefix: any, defaults?: Record<string, any>): Record<string, any>;
/**
* Parse numeric configuration values with defaults
* @param {string|number} value - Value to parse
* @param {number} defaultValue - Default if parsing fails
* @returns {number} Parsed numeric value
*/
export declare function parseNumericConfig(value: any, defaultValue: any): any;
/**
* Standard model validation logic
* @param {Function} testModelFn - Function to test if model is available
* @param {string} modelName - Model name to validate
* @param {Array} fallbackModels - Fallback models to suggest
* @returns {Promise<Object>} Validation result
*/
export declare function validateModelWithFallbacks(testModelFn: any, modelName: any, fallbackModels?: any[]): Promise<{
available: boolean;
provider: any;
timestamp: string;
}>;
/**
* Common message formatting for different provider APIs
* @param {Array} messages - OpenAI-style messages
* @param {string} format - Target format ('openai', 'anthropic', 'google')
* @returns {Object} Formatted messages for the specific provider
*/
export declare function formatMessagesForProvider(messages: any, format: any): {
system: any;
messages: any;
systemInstruction?: undefined;
history?: undefined;
} | {
system?: undefined;
systemInstruction: any;
history: any;
messages?: undefined;
} | {
system?: undefined;
systemInstruction?: undefined;
history?: undefined;
messages: any;
};
/**
* Build standard client options for providers
* @param {Object} config - Provider configuration
* @param {Object} defaults - Default client options
* @returns {Object} Client initialization options
*/
export declare function buildClientOptions(config: any, defaults?: Record<string, any>): {
[x: string]: any;
};
/**
* Standard request parameters builder
* @param {Array} messages - Chat messages
* @param {Object} options - Request options
* @param {Object} defaults - Provider-specific defaults
* @returns {Object} Standard request parameters
*/
export declare function buildRequestParams(messages: any, options: any, defaults?: Record<string, any>): any;