export interface SlashCommand { /** One token, without the leading slash. */ name: string; description: string; /** Other executable names. Tags only help search. */ aliases: readonly string[]; tags: readonly string[]; takesArg?: boolean; } export interface ParsedCommand { name: string; /** Undefined before a space; empty after a space with no argument yet. */ arg?: string; } /** Multiline text and a slash inside a message are not commands. */ export declare function parseCommand(text: string): ParsedCommand | null; export type CommandResolution = { kind: "matched"; command: T; } | { kind: "unknown"; name: string; } | { kind: "ambiguous"; name: string; commands: readonly T[]; }; /** Exact names win over aliases. Search tags never execute an action. */ export declare function resolveCommand(commands: readonly T[], name: string): CommandResolution; /** One row per name, in registry order when two results have the same rank. */ export declare function matchCommands(commands: readonly T[], query: string): T[]; /** Replace only the name, keeping the argument already typed. */ export declare function completeCommand(command: SlashCommand, text: string): string; export type CommandProblem = Exclude, { kind: "matched"; }>; export interface CommandOptions { text: string; /** Supply only commands allowed here, with current translated descriptions and tags. */ commands: readonly T[]; onChange: (text: string) => void; /** The app owns authorization, errors, draft cleanup and attachments. */ onExecute: (command: T, arg: string | undefined, altKey: boolean) => void; /** Required: show a way back to the available commands, never send this text to the model. */ onError: (problem: CommandProblem) => void; } /** Structural so React events and small test events both fit. */ export interface CommandKeyEvent { key: string; shiftKey?: boolean; altKey?: boolean; ctrlKey?: boolean; metaKey?: boolean; isComposing?: boolean; keyCode?: number; nativeEvent?: { isComposing?: boolean; keyCode?: number; }; preventDefault: () => void; } export interface SlashCommandMenu { parsed: ParsedCommand | null; open: boolean; items: readonly T[]; index: number; active: T | undefined; listId: string; itemId: (command: T) => string; activeId: string | undefined; highlight: (index: number) => void; close: () => void; showAll: () => void; pick: (command: T, altKey?: boolean) => void; submit: (altKey?: boolean) => boolean; handleKeyDown: (event: CommandKeyEvent) => boolean; } /** A controlled textarea menu. No UI, browser globals, timers or attachment state. */ export declare function useSlashCommands({ text, commands, onChange, onExecute, onError, }: CommandOptions): SlashCommandMenu; //# sourceMappingURL=commands.d.ts.map