import { useCallback, useEffect, useRef } from "react";
export function useAgentRunRefs(input) {
    const { isWaitingForResponse } = input;
    const isWaitingRef = useRef(false);
    const seenMessageIdsRef = useRef(new Set());
    const lastSeqRef = useRef(0);
    const shouldCreateNewMessageRef = useRef(false);
    const currentRunIdRef = useRef(null);
    const lastSettledRunIdRef = useRef(null);
    const warnedMissingRunIdRef = useRef(false);
    const lastResyncedMessageIdsRef = useRef(new Set());
    const subscribedAgentIdRef = useRef(null);
    const lastNonHeartbeatUpdateAtRef = useRef(0);
    const lastStallReloadAtRef = useRef(0);
    const toolCallFirstSeenAtRef = useRef({});
    const pendingToolCompletionTimersRef = useRef({});
    const noteMissingRunId = useCallback((source) => {
        if (warnedMissingRunIdRef.current)
            return;
        warnedMissingRunIdRef.current = true;
        console.warn("[AgentTerminal] received lifecycle/delta payload without runId; " +
            "falling back to legacy run scoping. Server may need upgrade. source=" +
            source);
    }, []);
    useEffect(() => {
        isWaitingRef.current = isWaitingForResponse;
    }, [isWaitingForResponse]);
    return {
        isWaitingRef,
        seenMessageIdsRef,
        lastSeqRef,
        shouldCreateNewMessageRef,
        currentRunIdRef,
        lastSettledRunIdRef,
        lastResyncedMessageIdsRef,
        subscribedAgentIdRef,
        lastNonHeartbeatUpdateAtRef,
        lastStallReloadAtRef,
        toolCallFirstSeenAtRef,
        pendingToolCompletionTimersRef,
        noteMissingRunId,
    };
}
//# sourceMappingURL=useAgentRunRefs.js.map