"use client"; import { type ReactNode, createContext, useContext } from "react"; type ChatToolContextValue = { /** `approvalId` is the SDK's `approval.id`, NOT `toolCallId`. */ confirmTool: (approvalId: string) => void; cancelTool: (approvalId: string, reason?: string) => void; }; const ChatToolContext = createContext(null); export function ChatToolProvider({ value, children, }: { value: ChatToolContextValue; children: ReactNode; }) { return ( {children} ); } export type { ChatToolContextValue }; export function useChatTool(): ChatToolContextValue { const ctx = useContext(ChatToolContext); if (!ctx) { throw new Error("useChatTool must be used within "); } return ctx; }