import { useCallback } from "react";
function isNotFoundLoadError(error) {
    return (error?.message?.includes("404") || error?.message?.includes("not found"));
}
export function useAgentLoadErrorHandler(input) {
    const { messagesRef, actions, setAgent, setError } = input;
    return useCallback((error) => {
        if (isNotFoundLoadError(error)) {
            const hasExistingMessages = messagesRef.current.length > 0;
            setAgent(undefined);
            if (!hasExistingMessages) {
                messagesRef.current = [];
                actions.replaceTranscript([]);
            }
            setError(null);
            actions.finishReady();
            return;
        }
        console.error("[AgentTerminal] Load error:", error?.message);
        setError("Failed to load agent data");
        actions.applyError("Failed to load agent data");
    }, [actions, messagesRef, setAgent, setError]);
}
//# sourceMappingURL=useAgentLoadErrorHandler.js.map