import { useAgentInfoSocketHandler } from "./useAgentInfoSocketHandler";
import { useAgentSuggestionSocketHandler, } from "./useAgentSuggestionSocketHandler";
import { useAgentOperationSocketHandler } from "./useAgentOperationSocketHandler";
import { useAgentPromptQueueSocketHandler } from "./useAgentPromptQueueSocketHandler";
import { useAgentRunCompletionSocketHandler } from "./useAgentRunCompletionSocketHandler";
import { useAgentRunDeltaRouter } from "./useAgentRunDeltaRouter";
import { useAgentRunDeltaSocketHandler } from "./useAgentRunDeltaSocketHandler";
import { useAgentRunResyncSocketHandler } from "./useAgentRunResyncSocketHandler";
import { useAgentRunStartSocketHandler } from "./useAgentRunStartSocketHandler";
import { useAgentRunStatusSocketHandler } from "./useAgentRunStatusSocketHandler";
import { useAgentSocketMessageRouter } from "./useAgentSocketMessageRouter";
import { useAgentStreamSubscription } from "./useAgentStreamSubscription";
import { useAgentUserMessageSocketHandler } from "./useAgentUserMessageSocketHandler";
export function useAgentStreamPipeline(input) {
    const { agent, agentStubId, profiles, setAgent, setAgentMetadata, setActiveProfile, onAgentUpdate, onSuggestion, sessionActions, messagesRef, seenMessageIdsRef, shouldSuppressQueuedPrompt, clearHeartbeatMessages, handleContentChunk, handleToolCall, handleToolResult, handleHeartbeatMessage, handleContextUpdate, appendToolUiEvent, isStoppingRef, currentRunIdRef, lastSettledRunIdRef, lastSeqRef, lastResyncedMessageIdsRef, lastNonHeartbeatUpdateAtRef, normalizeRunId, noteMissingRunId, acceptRunSequenceFrame, isWaitingRef, shouldCreateNewMessageRef, reconcileServerStateRef, clearStopGuard, schedulePendingDialogReplay, settleCompletedRun, setError, setLastRunStatusReason, setIsConnecting, setIsWaitingForResponse, setIsAgentThinking, effectiveIsVisible, editContext, subscribedAgentIdRef, createNewStreamMessage, } = input;
    const handleAgentInfoSocketMessage = useAgentInfoSocketHandler({
        agent,
        profiles,
        setAgent,
        setActiveProfile,
        onAgentUpdate,
    });
    const handleAgentSuggestionSocketMessage = useAgentSuggestionSocketHandler({
        agent,
        onSuggestion,
    });
    const handleAgentOperationSocketMessage = useAgentOperationSocketHandler({
        agent,
        actions: sessionActions,
    });
    const handleAgentUserSocketMessage = useAgentUserMessageSocketHandler({
        agent,
        messagesRef,
        seenMessageIdsRef,
        actions: sessionActions,
    });
    const handleAgentPromptQueueSocketMessage = useAgentPromptQueueSocketHandler({
        actions: sessionActions,
        shouldSuppressQueuedPrompt,
    });
    const routeAgentRunDelta = useAgentRunDeltaRouter({
        agent,
        messagesRef,
        clearHeartbeatMessages,
        handleContentChunk,
        handleToolCall,
        handleToolResult,
        handleHeartbeatMessage,
        handleContextUpdate,
        appendToolUiEvent,
    });
    const handleAgentRunDeltaSocketMessage = useAgentRunDeltaSocketHandler({
        agent,
        isStoppingRef,
        currentRunIdRef,
        lastResyncedMessageIdsRef,
        messagesRef,
        lastNonHeartbeatUpdateAtRef,
        normalizeRunId,
        noteMissingRunId,
        appendToolUiEvent,
        acceptRunSequenceFrame,
        routeRunDelta: routeAgentRunDelta,
    });
    const handleAgentRunStatusSocketMessage = useAgentRunStatusSocketHandler({
        agent,
        agentStubId,
        actions: sessionActions,
        currentRunIdRef,
        isStoppingRef,
        isWaitingRef,
        messagesRef,
        shouldCreateNewMessageRef,
        lastNonHeartbeatUpdateAtRef,
        reconcileServerStateRef,
        normalizeRunId,
        noteMissingRunId,
        appendToolUiEvent,
        acceptRunSequenceFrame,
        clearStopGuard,
        clearHeartbeatMessages,
        schedulePendingDialogReplay,
        settleCompletedRun,
        setAgent,
        setAgentMetadata,
        setError,
        setLastRunStatusReason,
        setIsConnecting,
        setIsWaitingForResponse,
        setIsAgentThinking,
    });
    const handleAgentRunCompletionSocketMessage = useAgentRunCompletionSocketHandler({
        actions: sessionActions,
        currentRunIdRef,
        lastSettledRunIdRef,
        lastNonHeartbeatUpdateAtRef,
        isWaitingRef,
        normalizeRunId,
        noteMissingRunId,
        settleCompletedRun,
        clearHeartbeatMessages,
        setError,
        setAgent,
        setLastRunStatusReason,
        setIsWaitingForResponse,
        setIsConnecting,
        setIsAgentThinking,
    });
    const handleAgentRunResyncSocketMessage = useAgentRunResyncSocketHandler({
        agent,
        actions: sessionActions,
        messagesRef,
        currentRunIdRef,
        lastSeqRef,
        lastResyncedMessageIdsRef,
        normalizeRunId,
        noteMissingRunId,
        appendToolUiEvent,
        createNewStreamMessage,
    });
    const handleAgentRunStartSocketMessage = useAgentRunStartSocketHandler({
        agent,
        isStoppingRef,
        currentRunIdRef,
        lastSettledRunIdRef,
        lastSeqRef,
        seenMessageIdsRef,
        lastResyncedMessageIdsRef,
        messagesRef,
        shouldCreateNewMessageRef,
        isWaitingRef,
        actions: sessionActions,
        normalizeRunId,
        noteMissingRunId,
        setAgent,
        setLastRunStatusReason,
        setIsConnecting,
        setIsWaitingForResponse,
        setIsAgentThinking,
    });
    const handleAgentWebSocketMessage = useAgentSocketMessageRouter({
        agent,
        handleAgentInfoSocketMessage,
        handleSuggestionSocketMessage: handleAgentSuggestionSocketMessage,
        handleOperationSocketMessage: handleAgentOperationSocketMessage,
        handleRunStartSocketMessage: handleAgentRunStartSocketMessage,
        handleUserMessageSocketMessage: handleAgentUserSocketMessage,
        handlePromptQueueSocketMessage: handleAgentPromptQueueSocketMessage,
        handleRunDeltaSocketMessage: handleAgentRunDeltaSocketMessage,
        handleRunStatusSocketMessage: handleAgentRunStatusSocketMessage,
        handleRunResyncSocketMessage: handleAgentRunResyncSocketMessage,
        handleRunCompletionSocketMessage: handleAgentRunCompletionSocketMessage,
    });
    useAgentStreamSubscription({
        effectiveIsVisible,
        editContext,
        agentStubId,
        agent,
        onMessage: handleAgentWebSocketMessage,
        subscribedAgentIdRef,
        seenMessageIdsRef,
        lastSeqRef,
        setIsWaitingForResponse,
        isWaitingRef,
        shouldCreateNewMessage: shouldCreateNewMessageRef,
        setIsAgentThinking,
    });
}
//# sourceMappingURL=useAgentStreamPipeline.js.map