@promptbook/node
Version:
Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action
54 lines (53 loc) • 1.62 kB
TypeScript
/**
* Represents a quick message button parsed from chat markdown.
*
* @private internal helper type of `MessageButton`
*/
export type MessageQuickButton = {
type: 'message';
text: string;
message: string;
};
/**
* Represents a quick draft-message button parsed from chat markdown.
*
* Unlike `MessageQuickButton`, clicking this button prefills the composer with an
* editable draft instead of sending the message immediately.
*
* @private internal helper type of `MessageButton`
*/
export type MessageDraftQuickButton = {
type: 'messageDraft';
text: string;
messageDraft: string;
};
/**
* Represents a quick action button parsed from chat markdown.
*
* @private internal helper type of `MessageButton`
*/
export type ActionQuickButton = {
type: 'action';
text: string;
code: string;
};
/**
* Represents one parsed quick button from chat markdown.
*
* @public exported from `@promptbook/components`
*/
export type MessageButton = MessageQuickButton | MessageDraftQuickButton | ActionQuickButton;
/**
* Parses markdown quick buttons in the format `[Button Text](?message=...)`, `[Button Text](?messageDraft=...)`
* or `[Button Text](?action=...)`.
* Returns both the content without supported quick buttons and the extracted button definitions.
*
* @param content The markdown content that may contain buttons
* @returns Object with contentWithoutButtons and buttons array
*
* @public exported from `@promptbook/components`
*/
export declare function parseMessageButtons(content: string): {
contentWithoutButtons: string;
buttons: MessageButton[];
};