require('dotenv').config();
const { Framework } = require('../src');

async function main() {
  console.log('Starting test...\n');

  const framework = new Framework({ debug: false });

  await framework.bootstrap({
    agentDir: process.cwd() + '/.agent',
    aiConfig: {
      provider: process.env.FOLIKO_PROVIDER || 'minimax',
      model: process.env.FOLIKO_MODEL || 'MiniMax-M2.7',
      baseURL: process.env.FOLIKO_BASE_URL || 'https://api.minimaxi.com/v1',
      apiKey: process.env.MINIMAX_API_KEY || process.env.DEEPSEEK_API_KEY,
    },
  });

  // 检查主 Agent
  const mainAgent = framework._mainAgent;
  console.log('Main Agent:', mainAgent ? mainAgent.name : 'NOT FOUND');
  console.log('Agent apiKey:', mainAgent?.apiKey ? 'set' : 'NOT SET');
  console.log('Agent _chatHandler:', mainAgent?._chatHandler ? 'exists' : 'NOT EXISTS');
  console.log(
    'Agent _chatHandler._aiClient:',
    mainAgent?._chatHandler?._aiClient ? 'exists' : 'NOT EXISTS'
  );

  // 检查 Telegram 插件
  const tgPlugin = framework.pluginManager.get('telegram');
  console.log('\nTelegram Plugin:', tgPlugin ? 'loaded' : 'NOT LOADED');

  if (tgPlugin) {
    console.log('Telegram _bot:', tgPlugin._bot ? 'exists' : 'NOT EXISTS');
  }

  console.log('\n========================================');
  console.log('Bot is running. Send a message to test!');
  console.log('========================================\n');

  // 保持运行
  await new Promise(() => {});
}

main().catch(console.error);
