import { useCallback } from "react";
import { updateAgentSessionCostLimit } from "./useAgentSessionSync";
export function useAgentCostLimitActions(input) {
    const { agentId, actions, isWaitingRef, setAgent, setError, setIsAgentThinking, setIsWaitingForResponse, setShouldAutoScroll, } = input;
    const handleExtendCostLimit = useCallback(async () => {
        if (!agentId)
            return;
        try {
            const result = await updateAgentSessionCostLimit(agentId, "extend");
            if (result.success && result.costLimit !== undefined) {
                setAgent((prev) => prev
                    ? {
                        ...prev,
                        costLimit: result.costLimit,
                        status: prev.status === "costLimitReached" ? "running" : prev.status,
                    }
                    : prev);
            }
            actions.replaceCostLimitExceeded(null);
            setIsWaitingForResponse(true);
            isWaitingRef.current = true;
            setIsAgentThinking(true);
            setShouldAutoScroll(true);
        }
        catch (error) {
            console.error("Failed to extend cost limit:", error);
            setError(error instanceof Error ? error.message : "Failed to extend cost limit");
        }
    }, [
        actions,
        agentId,
        isWaitingRef,
        setAgent,
        setError,
        setIsAgentThinking,
        setIsWaitingForResponse,
        setShouldAutoScroll,
    ]);
    return { handleExtendCostLimit };
}
//# sourceMappingURL=useAgentCostLimitActions.js.map