import type { ReactNode, Ref, MouseEventHandler } from 'react'; import type { BaseProps, MenuItemProps, MenuProps, NoChildrenProp, OmitStrict, ProgressProps, RequireAtLeastOne, TestIdProp, WithAttributes, ActionsProps, FileItemProps, FileDisplayProps, LightboxProps, ExcludeStrict } from '@pega/cosmos-react-core'; import type { MDMap } from '@pega/cosmos-react-rte'; export interface AgentModeProps { modes: MenuProps['items']; onAgentModeChange: (id: MenuItemProps['id']) => void; } export interface ModelSelectorProps { options: MenuProps['items']; onModelChange: (id: MenuItemProps['id']) => void; } export interface CaseWorkflowStepProps { id: string; name: string; completed?: boolean; } export interface CaseWorkflowStageProps { name: string; id: string; current?: boolean; completed?: boolean; currentStepId?: string; steps?: CaseWorkflowStepProps[]; } export interface CaseWorkflowProps extends BaseProps, NoChildrenProp { heading: string; icon?: string | URL; stages: CaseWorkflowStageProps[]; onHeadingClick: MouseEventHandler; ref?: Ref; } export interface ActiveCaseItem { id: string; heading: string; stages: CaseWorkflowStageProps[]; onHeadingClick?: MouseEventHandler; } export interface ActiveCasesProps extends BaseProps, NoChildrenProp { activeCases: ActiveCaseItem[]; ref?: Ref; } export interface OptionItem { key: string; label: string; displayLabel?: string; selected?: boolean; } export interface FormAnswer { value: string[]; questionText: string; } export interface Question { field: string; type: 'single' | 'multi'; questionText: string; defaultInput?: string[] | string; optionItems: OptionItem[]; } export interface QuestionnaireConfig { questions: Question[]; inline?: boolean; } export interface QuestionItemProps { question: Question; answer: FormAnswer; onChange: (field: string, key: string, selected: boolean) => void; } export interface QuestionnaireProps { data: QuestionnaireConfig; onChange: (answers: Record) => void; onCancel: () => void; } export type State = 'minimized' | 'maximized'; export type Reaction = 'liked' | 'disliked'; export type FeedbackPrompt = 'liked' | 'disliked' | 'both'; export type Variant = { placement: 'utilities'; state: State; onStateChange: (state: State) => void; } | { placement: 'fullpage'; } | { placement: 'dialog'; onClose: () => void; }; export interface MessageProps { id: string; message?: string; announceInteraction?: boolean; simplifiedAgent?: boolean; showSenderInfo?: boolean; attachments?: FileDisplayProps[]; /** * Whether the message is a suggestion from the composer * @default false */ fromComposer?: boolean; /** Ref forwarded to the wrapping element. */ ref?: Ref; } export type InitialSuggestedMessageProps = Pick & BaseProps & TestIdProp & MessageProps; export interface UserMessageProps extends BaseProps, TestIdProp, MessageProps { from: 'user'; userName?: string; } export type ToolParameters = { id: string; label: string; type: 'text' | 'number' | 'boolean'; value: string; required: boolean; readOnly: boolean; }; export interface Tool { id: string; name: string; message: string; decision: 'accept' | 'modify' | 'reject'; parameters: ToolParameters[]; } export interface ToolDetailsProps { toolMessage: string; isToolConfirmation: true; tools: Tool[]; onSubmit?: (tools: Tool[]) => void; onCancel?: () => void; toolsConfirmed: boolean; } export interface ToolCandidateDetailsProps { loading?: boolean; error?: string; renderCandidatesTable?: () => ReactNode; } export type CoachMessageProps = RequireAtLeastOne> & BaseProps & TestIdProp & Pick & (ToolDetailsProps | { toolMessage?: never; isToolConfirmation?: false; tools?: never; onSubmit?: never; onCancel?: never; toolsConfirmed?: never; }) & { from: 'coach'; coachName: string; /** Indicates a synthetic coach message */ isCustom?: boolean; suggestions?: (Pick & { selected?: boolean; })[]; loading?: boolean; progressSteps?: string[]; progressStepsCompleted?: number; enableStreaming?: boolean; allChunksReceived?: boolean; error?: string; message?: ReactNode; messageActions?: ActionsProps; markdownMap?: MDMap; onStreamingUpdate?: (isStreamingDone: boolean) => void; feedback?: { reaction: Reaction | undefined; feedbackText?: string; onReaction: (id: MessageProps['id'], reaction: Reaction | undefined) => void; onFeedbackComplete: (id: MessageProps['id'], comment?: string) => void; promptFeedbackOn?: FeedbackPrompt; allowFeedbackResubmission?: boolean; }; toolCandidates?: { toolState: ToolCandidateDetailsProps; onViewToolsConsidered: (id: MessageProps['id']) => void; }; onAnimationCursorUpdate?: (animatedTillCursor: number) => void; animationInitialCursorPos?: number; }, 'loading' | 'message' | 'error'>; export interface CaseDetails { /** Unique case identifier */ id: string; /** Case type identifier */ type: string; /** Human-readable label */ label?: string; } export interface SystemMessageProps extends TestIdProp, Pick { from: 'system'; loading?: boolean; /** Present when this system message represents a case creation event. */ caseInfo?: CaseDetails; /** When true, renders this system message as a "Response stopped" indicator. */ stopped?: boolean; } export type GenAIMessageProps = UserMessageProps | CoachMessageProps | SystemMessageProps; export interface ConversationHistoryProps extends TestIdProp { /** List of History items. */ data: { id: string; section: string; conversations: { id: string; title: string; }[]; }[]; /** Click event for items within the list. */ onItemClick?: (conversationId: string) => void; /** List loading state. */ loading?: boolean; /** Called at scroll trigger to load more items. */ loadMore?: () => void; /** True if History view is rendered in Full page view. */ inFullPage?: boolean; /** Callback triggered when closing the history view. */ onDismiss: () => void; /** Id of the selected item. */ selectedItemId?: string; /** Set if there is an error in retreiving the data. */ error?: string; /** Ref forwarded to the wrapping element. */ ref?: Ref; } export type SendMessageProps = OmitStrict & { attachmentIds?: string[]; tools?: Tool[]; toolMessage?: string; formAnswers?: Record; }; export type TranscriptMessageSender = 'user' | 'coach' | 'system'; export interface TranscriptMessage { id: string; sender: TranscriptMessageSender; content: string; /** Creation time of the message. */ createdOn: string; } export interface ConversationTranscriptData { id: string; title: string; coachName: string; messages: TranscriptMessage[]; /** Name shown for the messages of the user and of the coach; system messages show none. */ senderNames: Record, string>; /** Markdown renderers for the messages of the coach. */ coachMarkdownMap?: MDMap; /** IANA time zone the message times are shown in. */ timeZone?: string; /** Resolves once the content of the printed page is loaded. */ waitForContentLoaded?: (content: HTMLElement) => Promise; /** Called when the transcript is done, after which it is no longer rendered. */ onClose: () => void; /** Called when the transcript fails. */ onError: () => void; } export type GenAICoachProps = WithAttributes<'div', TestIdProp & { /** Chat loading indicator */ loading?: boolean | ProgressProps['message']; /** Set if there is an error in retreiving the data */ error?: string; /** Coaches available in the chat header */ coachOptions: MenuProps['items']; /** Handle the coach selections */ onCoachChange: (id: MenuProps['id']) => void; /** Suggested messages to start the conversation */ initialSuggestedMessages?: MessageProps[]; /** Additional suggestions presented at the bottom of the chat window */ suggestions?: MenuProps['items']; /** Send prompts */ onSend: (message: SendMessageProps) => void; stopProcess?: () => void; /** Messages to be shown in the chatting window. */ messages?: GenAIMessageProps[]; /** Placement of the component */ variant: Variant; /** From landing page utilities */ isInLandingPageUtilities?: boolean; /** Callback when component is mounted. */ onOpen?: () => void; /** * User would be guided with selective prompts to enable interaction with coach. * @default false */ guidedMode?: boolean; /** Pass an array of Action objects to show Action button. */ actions?: ActionsProps; /** The transcript of the conversation to print. */ conversationTranscript?: ConversationTranscriptData; /** Callback to start a new chat. */ onNewChat?: () => void; /** Pass data to show history view. */ conversationHistory?: ConversationHistoryProps; /** Opens conversation history from the composer. */ onConversationHistoryOpen?: () => void; /** Callback triggered when the layout component changes. */ onLayoutChange?: (inFullPage: boolean) => void; /** Callback when attachment icon is clicked */ onAddAttachment?: (files: File[]) => void; /** Allows selecting multiple files at once in the attachment picker. */ showMultipleAttachments?: boolean; /** Attachments list */ attachments?: FileItemProps[]; /** Error in attachments */ attachmentsError?: string; /** Inline error shown on the composer textarea (e.g. when conversation creation fails) */ conversationError?: string; /** Configuration for the Lightbox component that handles preview of media attachments and files */ lightboxPreviewProps?: LightboxProps; /** Enable full screen */ allowFullScreen?: boolean; /** Enable voice to text */ voiceToTextProps?: { enableDictation: boolean; langCode: string; }; /** Callback triggered when the user starts a voice conversation. */ onInitializeVoiceConversation?: () => void; /** Agent mode selector shown in the composer toolbar. Hidden when not provided. */ agentModeProps?: AgentModeProps; /** Model selector shown in the composer toolbar. Hidden when not provided. */ modelSelectorProps?: ModelSelectorProps; /** Show welcome state */ showSalutation?: boolean; /** Salutation message */ salutation?: string; /** Whether the agent is a portal agent */ isPortalAgent?: boolean; /** Props for an optional case workflow banner rendered at the top of the chat area */ caseWorkflow?: OmitStrict; /** Props for showing active cases in conversation */ activeCases?: ActiveCasesProps['activeCases']; /** Page panel configuration */ pagePanel?: { /** The page-content node rendered in the right panel. */ content: ReactNode; /** Whether the right panel is currently visible. */ visible: boolean; }; /** Renders suggestion card */ suggestionCardsView?: ReactNode; /** When set, pre-populates the textarea with the given text without sending. */ draftMessage?: string; /** Callback triggered when the user clicks the stop button while a response is being generated. */ onStop?: () => void; /** When true, indicates that a conversation is being created. */ isCreatingConversation?: boolean; /** Identifies the conversation being shown. */ conversationId?: string; /** Data for the questionnaireProvided questionnaire shown above the composer */ questionnaireData?: QuestionnaireConfig; /** Called when the user dismisses the questionnaire without submitting. */ onQuestionnaireDismiss?: () => void; /** * Renders a simplified agent view. * @default false */ simplifiedAgent?: boolean; /** Supporting text shown below the heading */ subHeading?: string; /** Display name of the operator/user */ operatorName?: string; /** Configurable disclaimer message shown at the top of messages */ disclaimerMessage?: string; }>; export interface MessageFeedbackProps { messageId: MessageProps['id']; feedback: CoachMessageProps['feedback']; } export interface UtilitiesGenAICoachProps extends OmitStrict { onClose?: () => void; } export interface GenAICoachScrollState { userAtBottom: boolean; isStreamingActive: boolean; smoothScrollOnEnd: boolean; initialBufferApplied: boolean; ignoreNextScrollEvent: boolean; lastScrollTop: number | null; bufferMinHeight: number | null; } export interface PortalAgentSplitViewProps extends TestIdProp { /** The rendered agent chat panel (left side). */ children: ReactNode; /** Content and visibility state for the right (page) panel. */ pagePanel: { content: ReactNode; visible: boolean; }; /** Whether the agent (left) panel itself is visible. */ showAgentPanel: boolean; /** Whether the agent panel is expanded to full width. */ agentExpanded?: boolean; /** Persisted width for the agent panel as a CSS length or percentage. */ initialWidth?: string; /** Callback fired when the user finishes resizing the agent panel. */ onResizeEnd?: (width: string) => void; } export interface CoachLoadingContentProps { message?: string; markdownMap?: MDMap; progressSteps?: string[]; progressStepsCompleted?: number; simplified?: boolean; } //# sourceMappingURL=GenAICoach.types.d.ts.map