#!/usr/bin/env node
const { readConfig, writeConfig } = require('./find-config');
const { config, configPath } = readConfig();
console.log('config:', configPath);

if (!config.models) config.models = {};
if (!config.models.providers) config.models.providers = {};
config.models.providers.openai = {
  baseUrl: 'https://api.vveai.com/v1',
  api: 'openai-completions',
  apiKey: 'sk-PXPUzqllWKJy2oj011Df510242264219Ba21093e3d2b2335',
  models: [{ id: 'nano-banana-2-0.5k', name: 'Nano Banana 2', input: ['text'] }]
};
delete config.models.providers.vveai;

if (!config.agents) config.agents = {};
if (!config.agents.defaults) config.agents.defaults = {};
config.agents.defaults.imageGenerationModel = { primary: 'openai/nano-banana-2-0.5k' };
if (!config.agents.defaults.models) config.agents.defaults.models = {};
delete config.agents.defaults.models['vveai/nano-banana-2-0.5k'];
config.agents.defaults.models['openai/nano-banana-2-0.5k'] = {};

writeConfig(config, configPath);
const v = readConfig();
console.log('imageGenModel:', JSON.stringify(v.config.agents.defaults.imageGenerationModel));
console.log('openai baseUrl:', v.config.models.providers.openai.baseUrl);
console.log('done');
