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

async function main() {
  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,
    },
  });

  const agent = framework.createAgent({
    name: 'FolikoAgent',
    systemPrompt: '你是一个有帮助的助手。',
  });

  console.log(
    '_mainAgent provider:',
    framework._mainAgent ? framework._mainAgent.provider : 'none'
  );
  console.log(
    '_mainAgent has apiKey:',
    framework._mainAgent && framework._mainAgent.apiKey ? 'yes' : 'no'
  );

  const tools = framework.getTools();
  const thinkTool = tools.find((t) => t.name === 'think_now');

  if (thinkTool) {
    const result = await thinkTool.execute({ mode: 'reflect', topic: '测试' });
    console.log('think_now success:', result.success);
    if (result.success === false) console.log('Error:', result.error);
  }

  await framework.destroy();
}

main().catch(console.error);
