import { useEffect, useRef } from "react";
export function useAgentMessageCompletionNotifier(input) {
    const { agentId, messages, onMessage } = input;
    const observedMessageIdsRef = useRef(new Set());
    useEffect(() => {
        observedMessageIdsRef.current = new Set();
    }, [agentId]);
    useEffect(() => {
        if (!onMessage)
            return;
        for (const message of messages) {
            if (!message?.id)
                continue;
            if (!message.isCompleted)
                continue;
            if (observedMessageIdsRef.current.has(message.id))
                continue;
            observedMessageIdsRef.current.add(message.id);
            onMessage(message);
        }
    }, [messages, onMessage]);
}
//# sourceMappingURL=useAgentMessageCompletionNotifier.js.map