import { useCallback } from "react";
/**
 * Handles the `agent:suggestion` websocket message. Mirrors useAgentInfoSocketHandler: it owns the
 * message type and does its own agentId check, so it must be invoked BEFORE the router's generic
 * agentId filter (which would otherwise drop a payload whose agentId doesn't strictly match).
 */
export function useAgentSuggestionSocketHandler(input) {
    const { agent, onSuggestion } = input;
    return useCallback((messageType, payload) => {
        if (messageType !== "agent:suggestion") {
            return false;
        }
        // We own this message type; consume it regardless of whether it targets the active agent.
        if (agent) {
            const suggestionAgentId = payload?.agentId;
            const kind = payload?.kind;
            if (suggestionAgentId &&
                suggestionAgentId === agent.id &&
                (kind === "fresh-chat" || kind === "switch-profile")) {
                onSuggestion({
                    agentId: suggestionAgentId,
                    kind,
                    reason: typeof payload?.reason === "string" ? payload.reason : "",
                    targetProfileId: payload?.targetProfileId ?? null,
                    targetProfileName: payload?.targetProfileName ?? null,
                    initialPrompt: typeof payload?.initialPrompt === "string"
                        ? payload.initialPrompt
                        : null,
                });
            }
        }
        return true;
    }, [agent, onSuggestion]);
}
//# sourceMappingURL=useAgentSuggestionSocketHandler.js.map