rawi
Version:
Rawi (راوي) is the developer-friendly AI CLI that brings the power of 12 major AI providers directly to your terminal. With seamless shell integration, persistent conversations, and 200+ specialized prompt templates, Rawi transforms your command line into
1 lines • 5.48 kB
Source Map (JSON)
{"version":3,"sources":["/home/mkabumattar/withrawi/rawi/dist/chunk-5SUCR572.cjs","../src/core/configs/managers/display.manager.ts"],"names":["ConfigDisplayManager","credentials","masked","maskApiKey","providerConfig","getProvider","chalk"],"mappings":"AAAA;AACA,wDAAwC,wDAAyC,4ECD/D,IAKLA,CAAAA,CAAN,KAA4D,CACjE,kBAAA,CAAmBC,CAAAA,CAAoC,CACrD,IAAMC,CAAAA,CAAS,CAAC,GAAGD,CAAW,CAAA,CAE1BC,CAAAA,CAAO,MAAA,EAAA,CACTA,CAAAA,CAAO,MAAA,CAASC,iCAAAA,CAAWD,CAAO,MAAM,CAAA,CAAA,CAG1C,IAAME,CAAAA,CAAiBC,iCAAAA,CAAYH,CAAO,QAAQ,CAAA,CAClD,EAAA,CAAI,CAACE,CAAAA,CAAgB,CACnB,OAAA,CAAQ,GAAA,CAAIE,eAAAA,CAAM,GAAA,CAAI,CAAA,kBAAA,EAAqBJ,CAAAA,CAAO,QAAQ,CAAA,CAAA;ADboM","file":"/home/mkabumattar/withrawi/rawi/dist/chunk-5SUCR572.cjs","sourcesContent":[null,"import chalk from 'chalk';\nimport {getProvider} from '../../providers/index.js';\nimport {maskApiKey, type RawiCredentials} from '../../shared/index.js';\nimport type {IConfigDisplayManager} from '../interfaces/config-manager.interface.js';\n\nexport class ConfigDisplayManager implements IConfigDisplayManager {\n displayCredentials(credentials: RawiCredentials): void {\n const masked = {...credentials};\n\n if (masked.apiKey) {\n masked.apiKey = maskApiKey(masked.apiKey);\n }\n\n const providerConfig = getProvider(masked.provider);\n if (!providerConfig) {\n console.log(chalk.red(`Unknown provider: ${masked.provider}`));\n return;\n }\n\n const providerDisplayName = providerConfig.displayName;\n const modelInfo = providerConfig.models.find(\n (m) => m.name === masked.model,\n );\n const modelDisplayName = modelInfo?.displayName || masked.model;\n\n console.log(\n chalk.blue(' Provider:') +\n chalk.white(` ${providerDisplayName} (${masked.provider})`),\n );\n console.log(chalk.blue(' Model:') + chalk.white(` ${modelDisplayName}`));\n\n // Get API key from provider settings if not in top-level\n let displayApiKey = masked.apiKey;\n if (\n !displayApiKey &&\n masked.providerSettings &&\n 'apiKey' in masked.providerSettings\n ) {\n displayApiKey = maskApiKey(masked.providerSettings.apiKey as string);\n }\n\n if (\n displayApiKey ||\n (masked.providerSettings &&\n Object.keys(masked.providerSettings).length > 0)\n ) {\n console.log(chalk.blue(' Configuration:'));\n\n if (displayApiKey) {\n console.log(chalk.gray(` API Key: ${displayApiKey}`));\n }\n\n if (masked.providerSettings) {\n this.displayProviderSettings(masked.providerSettings);\n }\n }\n\n if (masked.temperature !== undefined) {\n console.log(\n chalk.blue(' Temperature:') + chalk.white(` ${masked.temperature}`),\n );\n }\n\n if (masked.maxTokens !== undefined) {\n console.log(\n chalk.blue(' Max Tokens:') + chalk.white(` ${masked.maxTokens}`),\n );\n }\n\n if (masked.language) {\n console.log(\n chalk.blue(' Language:') + chalk.white(` ${masked.language}`),\n );\n }\n }\n\n displayConfigurationSummary(credentials: RawiCredentials): void {\n console.log(chalk.green('\\\\n✅ Configuration Summary:'));\n this.displayCredentials(credentials);\n }\n\n displayProfiles(profiles: string[]): void {\n if (profiles.length === 0) {\n console.log(chalk.yellow('No profiles found.'));\n return;\n }\n\n console.log(chalk.blue('\\\\nAvailable Profiles:'));\n for (const profile of profiles) {\n console.log(chalk.white(` • ${profile}`));\n }\n }\n\n private displayProviderSettings(settings: Record<string, any>): void {\n for (const [key, value] of Object.entries(settings)) {\n if (value !== undefined && value !== null) {\n // Skip API key from provider settings as it's already shown above\n if (key === 'apiKey') {\n continue;\n }\n const displayKey = this.formatSettingKey(key);\n const displayValue = this.formatSettingValue(key, value);\n console.log(chalk.gray(` ${displayKey}: ${displayValue}`));\n }\n }\n }\n\n private formatSettingKey(key: string): string {\n return key\n .replace(/([A-Z])/g, ' $1')\n .replace(/^./, (str) => str.toUpperCase());\n }\n\n private formatSettingValue(key: string, value: any): string {\n const sensitiveKeys = [\n 'apiKey',\n 'accessKey',\n 'secretKey',\n 'token',\n 'password',\n ];\n const lowerKey = key.toLowerCase();\n\n if (sensitiveKeys.some((sk) => lowerKey.includes(sk))) {\n return typeof value === 'string' ? maskApiKey(value) : '[MASKED]';\n }\n\n return String(value);\n }\n\n displayError(message: string, details?: string): void {\n console.error(chalk.red(`❌ ${message}`));\n if (details) {\n console.error(chalk.gray(` ${details}`));\n }\n }\n\n displayWarning(message: string, details?: string): void {\n console.warn(chalk.yellow(`⚠️ ${message}`));\n if (details) {\n console.warn(chalk.gray(` ${details}`));\n }\n }\n\n displaySuccess(message: string, details?: string): void {\n console.log(chalk.green(`✅ ${message}`));\n if (details) {\n console.log(chalk.gray(` ${details}`));\n }\n }\n\n displayInfo(message: string, details?: string): void {\n console.log(chalk.blue(`ℹ️ ${message}`));\n if (details) {\n console.log(chalk.gray(` ${details}`));\n }\n }\n}\n"]}