// CangjieMagic Agent DSL — 路由分派 (主从协同)
// 来源: https://blog.csdn.net/gitblog_00020/article/details/150225071

@agent[model: "deepseek:deepseek-chat"]
class DispatchAgent {
    @prompt[pattern: APE](
        action: "分析用户任务的类型和复杂度",
        purpose: "将任务分派给最合适的子智能体",
        expectation: "返回任务分类标签"
    )
}

@agent[model: "ollama:llama3"]
class PrimaryAgent {
    @prompt[pattern: APE](
        action: "处理简单的日常任务",
        purpose: "快速响应用户需求",
        expectation: "在3步内给出回复"
    )

    @tool[description: "快速搜索"]
    func quickSearch(query: String): String { ... }
}

@agent[model: "deepseek:deepseek-chat"]
class SecondaryAgent {
    @prompt[pattern: APE](
        action: "处理复杂的分析任务",
        purpose: "提供深入的分析报告",
        expectation: "输出结构化的分析报告"
    )

    @tool[description: "深度分析"]
    func deepAnalyze(data: String): String { ... }

    @tool[description: "报告生成"]
    func generateReport(analysis: String): String { ... }
}

// 主从协同: DispatchAgent 分派任务给 Primary 或 Secondary
let routerAgent = DispatchAgent() <= [
    PrimaryAgent(),
    SecondaryAgent()
]

let result = routerAgent.chat("分析一下这份财务报表的异常项")
print(result)
