package com.infoepoch.pms.agent.observability.ai;

import com.alibaba.cloud.ai.graph.agent.ReactAgent;
import com.infoepoch.pms.agent.observability.ai.hook.AiAgentLifecycleObservationHook;
import com.infoepoch.pms.agent.observability.ai.hook.AiModelMessageObservationHook;
import org.springframework.ai.chat.model.ChatModel;

/**
 * 带通用观测 hooks 的 ReactAgent 工厂。
 */
public class ObservedReactAgentFactory {

    private final AiAgentLifecycleObservationHook agentLifecycleObservationHook;
    private final AiModelMessageObservationHook modelMessageObservationHook;

    public ObservedReactAgentFactory(AiAgentLifecycleObservationHook agentLifecycleObservationHook,
                                     AiModelMessageObservationHook modelMessageObservationHook) {
        this.agentLifecycleObservationHook = agentLifecycleObservationHook;
        this.modelMessageObservationHook = modelMessageObservationHook;
    }

    public ReactAgent create(String agentName, ChatModel chatModel, String systemPrompt) {
        return ReactAgent.builder()
                .name(agentName)
                .model(chatModel)
                .hooks(agentLifecycleObservationHook, modelMessageObservationHook)
                .systemPrompt(systemPrompt)
                .build();
    }
}
