(tomlText: string, filePath = 'config.toml')
| 263 | } |
| 264 | |
| 265 | export function parseConfigString(tomlText: string, filePath = 'config.toml'): KimiConfig { |
| 266 | if (tomlText.trim().length === 0) { |
| 267 | return getDefaultConfig(); |
| 268 | } |
| 269 | |
| 270 | let data: Record<string, unknown>; |
| 271 | try { |
| 272 | data = parseToml(tomlText) as Record<string, unknown>; |
| 273 | } catch (error) { |
| 274 | throw new KimiError(ErrorCodes.CONFIG_INVALID, `Invalid TOML in ${filePath}: ${error instanceof Error ? error.message : String(error)}`, { |
| 275 | cause: error, |
| 276 | }); |
| 277 | } |
| 278 | |
| 279 | return parseConfigData(data, filePath); |
| 280 | } |
| 281 | |
| 282 | function parseConfigData(data: Record<string, unknown>, filePath: string): KimiConfig { |
| 283 | const raw = cloneRecord(data); |
no test coverage detected