diff --git a/packages/chatkit/types/index.d.ts b/packages/chatkit/types/index.d.ts index 75451ea..556a18e 100644 --- a/packages/chatkit/types/index.d.ts +++ b/packages/chatkit/types/index.d.ts @@ -109,6 +109,13 @@ export type ChatKitOptions = { */ entities?: EntitiesOption; + /** + * Configuration for the composer command menu. + * + * @see {@link CommandsOption} + */ + commands?: CommandsOption; + /** * Configuration for widgets. * @@ -233,6 +240,22 @@ export type EntitiesOption = { ) => Promise<{ preview: Widgets.BasicRoot | null }>; }; +export type CommandsOption = { + /** + * Enables the "/" command menu, including applicable built-in composer actions. + */ + enabled: boolean; + + /** Returns integration-defined commands matching the input query. */ + onSearch?: (query: string) => Promise; + + /** + * Runs a command. Return an entity to insert it, another menu to continue + * command selection, or nothing when the command only performs an effect. + */ + onSelect?: (command: Command) => Promise; +}; + export type DisclaimerOption = { /** Markdown text displayed below the composer. */ text: string; @@ -597,6 +620,25 @@ export type Entity = { // Later: optional entity-specific tag display options (e.g. tag prefix) }; +/** + * An action that can be found from the composer's command menu. + */ +export type Command = { + id: string; + label: string; + description?: string; + icon?: ChatKitIcon; + group?: string; +}; + +/** + * Determines what ChatKit inserts or displays after a command is selected. + * Returning no selection lets the integration perform an effect outside ChatKit. + */ +export type CommandSelection = + | { type: 'entity'; entity: Entity } + | { type: 'menu'; commands: Command[] }; + /** * Identifies the tool that should run for a single message submission. * Mirrors the `ToolChoice` shape exposed by the chatkit-python SDK.