import { useEffect } from "react";
import { AGENT_HISTORY_LIMIT } from "../agentMessageHelpers";
import { loadAgentSessionOperationHistory } from "./useAgentSessionSync";
export function useAgentOperationHistoryLoader(input) {
    const { agent, actions } = input;
    useEffect(() => {
        const fetchOperations = async () => {
            if (!agent?.id) {
                actions.replaceOperationHistory([]);
                return;
            }
            actions.replaceOperationHistory([]);
            try {
                const result = await loadAgentSessionOperationHistory(agent.id, AGENT_HISTORY_LIMIT);
                if (result.type === "success") {
                    actions.replaceOperationHistory(result.data ?? []);
                }
            }
            catch (error) {
                console.error("Failed to fetch agent operations:", error);
            }
        };
        void fetchOperations();
    }, [actions, agent?.id]);
}
//# sourceMappingURL=useAgentOperationHistoryLoader.js.map