import { useAgentCostLimitWatcher } from "./useAgentCostLimitWatcher";
import { useAgentDraftInitializer } from "./useAgentDraftInitializer";
import { useAgentLoadedRunStateSync } from "./useAgentLoadedRunStateSync";
import { useAgentLoader } from "./useAgentLoader";
import { useAgentLoadErrorHandler } from "./useAgentLoadErrorHandler";
import { useAgentLoadLifecycle } from "./useAgentLoadLifecycle";
import { useAgentOperationHistoryLoader } from "./useAgentOperationHistoryLoader";
import { useAgentServerReconciler } from "./useAgentServerReconciler";
export function useAgentLoadPipeline(input) {
    const { agent, agentStub, initialMetadata, profiles, currentItemDescriptor, buildEditorContextPayload, messagesRef, sessionActions, setAgent, setAgentMetadata, setError, setPrompt, onAgentNotFound, isStoppingRef, isWaitingRef, setIsWaitingForResponse, setIsConnecting, setIsAgentThinking, seenMessageIdsRef, sanitizeAgentMetadata, effectiveIsVisible, sessionCostLimitExceeded, sessionLiveTotalCost, } = input;
    const initializeDraftAgent = useAgentDraftInitializer({
        agentStub,
        initialMetadata,
        profiles,
        currentItemDescriptor,
        buildEditorContextPayload,
        messagesRef,
        actions: sessionActions,
        setAgent,
        setAgentMetadata,
        setError,
        setPrompt,
    });
    const syncLoadedRunState = useAgentLoadedRunStateSync({
        isStoppingRef,
        isWaitingRef,
        setIsWaitingForResponse,
        setIsConnecting,
        setIsAgentThinking,
    });
    const handleLoadError = useAgentLoadErrorHandler({
        agentId: agentStub.id,
        messagesRef,
        actions: sessionActions,
        setAgent,
        setError,
        onAgentNotFound,
    });
    const loadAgent = useAgentLoader({
        agentStub,
        initialMetadata,
        actions: sessionActions,
        messagesRef,
        seenMessageIdsRef,
        isStoppingRef,
        initializeDraftAgent,
        syncLoadedRunState,
        sanitizeAgentMetadata,
        handleLoadError,
        setAgent,
        setAgentMetadata,
        setError,
    });
    const reconcileServerStateRef = useAgentServerReconciler({ loadAgent });
    useAgentLoadLifecycle({
        agent,
        agentId: agentStub.id,
        effectiveIsVisible,
        loadAgent,
    });
    useAgentOperationHistoryLoader({
        agent,
        actions: sessionActions,
    });
    useAgentCostLimitWatcher({
        agent,
        sessionCostLimitExceeded,
        sessionLiveTotalCost,
        actions: sessionActions,
    });
    return {
        loadAgent,
        reconcileServerStateRef,
    };
}
//# sourceMappingURL=useAgentLoadPipeline.js.map