(config: KimiConfig)
| 458 | } |
| 459 | |
| 460 | export function configToTomlData(config: KimiConfig): Record<string, unknown> { |
| 461 | const out = cloneRecord(config.raw); |
| 462 | |
| 463 | // Strip deprecated fields |
| 464 | delete out['default_yolo']; |
| 465 | delete out['defaultYolo']; |
| 466 | delete out['defaultPermissionMode']; |
| 467 | delete out['default_thinking']; |
| 468 | delete out['defaultThinking']; |
| 469 | |
| 470 | // Top-level scalar fields |
| 471 | const scalarFields: (keyof KimiConfig)[] = [ |
| 472 | 'defaultProvider', |
| 473 | 'defaultModel', |
| 474 | 'planMode', |
| 475 | 'yolo', |
| 476 | 'defaultPermissionMode', |
| 477 | 'defaultPlanMode', |
| 478 | 'mergeAllAvailableSkills', |
| 479 | 'extraSkillDirs', |
| 480 | 'telemetry', |
| 481 | ]; |
| 482 | for (const key of scalarFields) { |
| 483 | setDefined(out, camelToSnake(key), config[key]); |
| 484 | } |
| 485 | |
| 486 | setRecordSection(out, 'providers', config.providers, providerToToml); |
| 487 | setRecordSection(out, 'models', config.models, modelToToml); |
| 488 | setSection(out, 'thinking', config.thinking, thinkingToToml); |
| 489 | setSection(out, 'services', config.services, servicesToToml); |
| 490 | setSection(out, 'loop_control', config.loopControl, loopControlToToml); |
| 491 | setSection(out, 'background', config.background, backgroundToToml); |
| 492 | setSection(out, 'experimental', config.experimental, experimentalToToml); |
| 493 | setSection(out, 'permission', config.permission, permissionToToml); |
| 494 | setHooks(out, config.hooks); |
| 495 | |
| 496 | return out; |
| 497 | } |
| 498 | |
| 499 | function setRecordSection<T>( |
| 500 | out: Record<string, unknown>, |
no test coverage detected