Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions packages/chatkit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ export type ChatKitOptions = {
*/
entities?: EntitiesOption;

/**
* Configuration for the composer command menu.
*
* @see {@link CommandsOption}
*/
commands?: CommandsOption;

/**
* Configuration for widgets.
*
Expand Down Expand Up @@ -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<Command[]>;

/**
* 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<void | CommandSelection>;
};

export type DisclaimerOption = {
/** Markdown text displayed below the composer. */
text: string;
Expand Down Expand Up @@ -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.
Expand Down
Loading