"""
generate_demand_agent 工厂 — 组装需求生成 Agent。
"""
from __future__ import annotations

from pathlib import Path

from supply_agent import Agent
from supply_agent.config import Settings
from agents.generate_demand_agent.tools import register_all_tools

_PROMPT_PATH = Path(__file__).parent / "prompt" / "system_prompt.md"
GENERATE_DEMAND_AGENT_SYSTEM_PROMPT = _PROMPT_PATH.read_text(encoding="utf-8")


def create_generate_demand_agent(
    settings: Settings | None = None,
    *,
    model: str | None = None,
) -> Agent:
    """创建 generate_demand_agent 实例，注册专属工具。"""
    agent = Agent(
        settings=settings,
        name="generate_demand_agent",
        model=model,
        system_prompt=GENERATE_DEMAND_AGENT_SYSTEM_PROMPT,
        max_iterations=30,
    )
    register_all_tools(agent.tools)
    return agent
