import type { UseStream } from "@langchain/langgraph-sdk/react"; import { createContext, useContext } from "react"; import type { AgentThreadState } from "@/core/threads"; export interface ThreadContextType { threadId: string; thread: UseStream; } export const ThreadContext = createContext( undefined, ); export function useThread() { const context = useContext(ThreadContext); if (context === undefined) { throw new Error("useThread must be used within a ThreadContext"); } return context; }