namespace Health.Infrastructure.AI.AgentHandlers;

/// <summary>
/// AI 问诊 Agent 工具处理器——转医生
/// </summary>
public static class ConsultationAgentHandler
{
    public static readonly ToolDefinition RequestDoctorTool = new()
    {
        Function = new()
        {
            Name = "request_doctor", Description = "请求转接真人医生",
            Parameters = new { type = "object", properties = new { reason = new { type = "string" }, urgency_level = new { type = "string" } } }
        }
    };

    public static List<ToolDefinition> Tools => [CommonAgentHandler.QueryHealthRecordsTool, CommonAgentHandler.CheckArchiveTool, RequestDoctorTool];

    public static Task<object> Execute(string toolName, JsonElement args, AppDbContext db, Guid userId)
    {
        return toolName switch
        {
            "query_health_records" or "check_archive" => CommonAgentHandler.Execute(toolName, args, db, userId),
            _ => Task.FromResult<object>(new { success = false, message = $"未知工具: {toolName}" })
        };
    }
}
