import type { BaseStream } from "@langchain/langgraph-sdk/react"; import { createContext, useContext } from "react"; import type { AgentThreadState } from "@/core/threads"; export interface ThreadContextType { thread: BaseStream; isMock?: boolean; /** * When set, the conversation is rendered from a public read-only share. * Artifact/image URLs then resolve to the unauthenticated * `/api/public/shares/{code}/files/...` endpoint instead of the * auth-gated thread artifact route. */ publicShareCode?: string; } 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; }