interface ToolbarPluginCommand { name: string; description: string; icon: string; } interface CommentAuthor { id: string; username: string; displayName: string; } interface ThreadCommentData { id: string; text: string; userId: string; author?: CommentAuthor; assistedMetadata?: { commandName: string; icon: string; meta?: Record; }; } interface ThreadData { id: string; nodeId: string; page?: string; pageTitle?: string; selectionRange?: { text?: string; }; frameworkContext?: string; screenWidth?: number; screenHeight?: number; comments: ThreadCommentData[]; [key: string]: unknown; } interface CommandInvocation { commandName: string; commentId: string; replyCommentId: string; thread: ThreadData; context: string; } interface CommandReplyPayload { body: string; assistedMetadata: { commandName: string; icon: string; meta?: Record; }; } /** * Reply interface for plugin commands. * * For simple (non-streaming) plugins: * await reply.finalize(payload); * * For streaming plugins: * await reply.update(payload); // Send intermediate updates * await reply.update(payload); // ...as many times as needed * await reply.finalize(payload); // Send final reply * * To handle cancellation: * if (reply.signal.aborted) return; */ interface CommandReply { /** Send an intermediate update (for streaming responses) */ update: (payload: CommandReplyPayload) => Promise; /** Send the final reply and clean up */ finalize: (payload: CommandReplyPayload) => Promise; /** Abort signal - check this to know if the command was cancelled */ signal: AbortSignal; } /** * Options passed to plugin onInit. */ interface PluginInitOptions { /** Debug logger - only logs when NEXT_PUBLIC_VERCEL_TOOLBAR_DEBUG is set */ debugLog: (...args: unknown[]) => void; } interface ToolbarPlugin { name: string; onInit?: (options: PluginInitOptions) => Promise | void; getCommands: () => Promise | ToolbarPluginCommand[]; onCommand: (invocation: CommandInvocation, reply: CommandReply) => Promise; } export { CommandInvocation, CommandReply, CommandReplyPayload, CommentAuthor, PluginInitOptions, ThreadCommentData, ThreadData, ToolbarPlugin, ToolbarPluginCommand };