UNPKG

prompt-format-mcp

Version:

Simple prompt optimization MCP server with SiliconFlow API integration

30 lines 939 B
export const Logger = { log: (...args) => console.log('[INFO]', ...args), error: (...args) => console.error('[ERROR]', ...args), warn: (...args) => console.warn('[WARN]', ...args), debug: (...args) => { if (process.env.NODE_ENV === 'development') { console.log('[DEBUG]', ...args); } } }; export function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } export async function retry(fn, maxAttempts = 3, delayMs = 1000) { let lastError; for (let attempt = 1; attempt <= maxAttempts; attempt++) { try { return await fn(); } catch (error) { lastError = error; Logger.warn(`尝试 ${attempt}/${maxAttempts} 失败:`, error); if (attempt < maxAttempts) { await delay(delayMs * attempt); } } } throw lastError; } //# sourceMappingURL=helpers.js.map