"""测试 Router Agent 基本功能"""

import asyncio
import logging
import sys

# 修复 Windows 控制台编码问题
if sys.platform == 'win32':
    import io
    sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
    sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8')

from tool_agent.router.agent import Router
from tool_agent.router.router_agent import RouterAgent

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s [%(name)s] %(levelname)s: %(message)s"
)

async def test_router_agent():
    """测试 Router Agent 的基本功能"""
    print("=" * 60)
    print("Testing Router Agent")
    print("=" * 60)

    # 初始化 Router
    router = Router()
    router_agent = RouterAgent(router)

    # 测试 1: 搜索工具
    print("\n[Test 1] Searching for tools...")
    response = await router_agent.chat("列出所有可用的工具")
    print(f"Response: {response}")

    # 测试 2: 创建工具请求
    print("\n[Test 2] Requesting tool creation...")
    response = await router_agent.chat("我需要一个图片压缩工具")
    print(f"Response: {response}")

    print("\n" + "=" * 60)
    print("Tests completed")
    print("=" * 60)

if __name__ == "__main__":
    asyncio.run(test_router_agent())
