@paymanai/payman-ask-sdk 2.0.6 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +370 -240
- package/dist/index.d.ts +370 -240
- package/dist/index.js +3171 -4717
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3176 -4705
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +1821 -4214
- package/dist/index.native.js.map +1 -1
- package/dist/styles.css +132 -814
- package/dist/styles.css.map +1 -1
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import * as React
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
-
import { ChatCallbacks as ChatCallbacks$1,
|
|
4
|
-
export { APIConfig,
|
|
5
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { MessageDisplay, AgentStage, ChatCallbacks as ChatCallbacks$1, ChatConfig as ChatConfig$1, StreamProgress, StreamingStep, UserActionRequest } from '@paymanai/payman-typescript-ask-sdk';
|
|
4
|
+
export { APIConfig, AgentStage, ChunkDisplay, MessageDisplay, MessageRole, SessionParams, StreamEvent, StreamOptions, StreamProgress, StreamingStep, UseChatV2Return, UseVoiceReturn, UserActionRequest, UserActionResult, UserActionState, UserActionType, V2EventProcessorState, VoiceCallbacks, VoiceConfig, VoicePermissions, VoiceResult, VoiceState, buildFormattedThinking, cancelUserAction, createInitialV2State, generateId, processStreamEventV2, resendUserAction, streamWorkflowEvents, submitUserAction, useChatV2, useVoice } from '@paymanai/payman-typescript-ask-sdk';
|
|
6
5
|
import { ClassValue } from 'clsx';
|
|
7
6
|
|
|
8
7
|
type UserMessageActionsConfig = {
|
|
@@ -18,189 +17,256 @@ type AssistantMessageActionsConfig = {
|
|
|
18
17
|
copy?: boolean;
|
|
19
18
|
/** Show trace action on assistant messages (default: true, still requires callback) */
|
|
20
19
|
trace?: boolean;
|
|
20
|
+
/** Show thumbs-up feedback button (default: true) */
|
|
21
|
+
thumbsUp?: boolean;
|
|
22
|
+
/** Show thumbs-down feedback button (default: true) */
|
|
23
|
+
thumbsDown?: boolean;
|
|
21
24
|
};
|
|
22
25
|
type MessageActionsConfig = {
|
|
23
26
|
userMessageActions?: UserMessageActionsConfig;
|
|
24
27
|
assistantMessageActions?: AssistantMessageActionsConfig;
|
|
25
28
|
};
|
|
26
|
-
type
|
|
27
|
-
state
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
/** Desktop only. Default: false */
|
|
50
|
-
defaultCollapsed?: boolean;
|
|
51
|
-
/** Page size for listSessions. Default: 20 */
|
|
52
|
-
pageSize?: number;
|
|
53
|
-
/** localStorage key for width + collapsed. Default: `payman-chat-sidebar:${workflow.id}` */
|
|
54
|
-
persistKey?: string;
|
|
55
|
-
/** Show a sidebar "New Session" button wired to the chat reset flow. Default: false */
|
|
56
|
-
showNewSessionButton?: boolean;
|
|
57
|
-
};
|
|
58
|
-
type EmptyStatePromptCategory = {
|
|
59
|
-
/** Label shown in the category bubble, e.g. "Account". Also used as the accessible name for the prompt group. */
|
|
60
|
-
label: string;
|
|
61
|
-
/** Optional icon rendered before the label in the category bubble. */
|
|
62
|
-
icon?: React__default.ReactNode;
|
|
63
|
-
/** Prompt strings; clicking sends the string verbatim. Array order is preserved as render order. */
|
|
64
|
-
prompts: string[];
|
|
65
|
-
};
|
|
66
|
-
type EmptyStateSuggestionsConfig = {
|
|
67
|
-
/** Default: true. Pass false to hide bubbles without removing data. */
|
|
68
|
-
enabled?: boolean;
|
|
69
|
-
/** Optional heading above categories. Falls back to ui.emptyState.text. */
|
|
70
|
-
title?: string;
|
|
29
|
+
type ChatConfig = ChatConfig$1 & {
|
|
30
|
+
/** Custom React component to render above the empty state text (e.g. logo, illustration). */
|
|
31
|
+
emptyStateComponent?: React__default.ReactNode;
|
|
32
|
+
/** Enable voice input (default: true) */
|
|
33
|
+
enableVoice?: boolean;
|
|
34
|
+
/** Voice language (default: "en-US") */
|
|
35
|
+
voiceLang?: string;
|
|
36
|
+
/** Voice interim results (default: true) */
|
|
37
|
+
voiceInterimResults?: boolean;
|
|
38
|
+
/** Voice continuous mode (default: true) */
|
|
39
|
+
voiceContinuous?: boolean;
|
|
40
|
+
/** Show a "New Session" reset button inside the input bar (default: false) */
|
|
41
|
+
showResetSession?: boolean;
|
|
42
|
+
/** Show the v2 attachment (+) menu button in the input bar (default: true) */
|
|
43
|
+
showAttachmentButton?: boolean;
|
|
44
|
+
/** Show the v2 "Upload image" attachment option (default: true) */
|
|
45
|
+
showUploadImageButton?: boolean;
|
|
46
|
+
/** Show the v2 "Attach file" attachment option (default: true) */
|
|
47
|
+
showAttachFileButton?: boolean;
|
|
48
|
+
/** Configure which per-message actions are visible in the v2 UI */
|
|
49
|
+
messageActions?: MessageActionsConfig;
|
|
50
|
+
/** Sentry DSN for error monitoring. */
|
|
51
|
+
sentryDsn?: string;
|
|
71
52
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* render exactly what is passed.
|
|
53
|
+
* UI version to render.
|
|
54
|
+
* 1 = original component set
|
|
55
|
+
* 2 = redesigned chat UI (ChatGPT-style with thinking blocks, inline verification, etc.) — default
|
|
76
56
|
*/
|
|
77
|
-
|
|
78
|
-
};
|
|
79
|
-
type ChatUIConfig = {
|
|
80
|
-
layout?: "centered" | "full-width";
|
|
57
|
+
uiVersion?: 1 | 2;
|
|
81
58
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
59
|
+
* Speed multiplier for the assistant typing-reveal animation in the v2 UI.
|
|
60
|
+
* 1 = leisurely "human reading" pace
|
|
61
|
+
* 2 = default (snappy but still animated)
|
|
62
|
+
* 4 = near-instant trickle
|
|
63
|
+
* 0.5 = half speed
|
|
64
|
+
* 0 = disable the animation entirely (reveal text instantly as it arrives)
|
|
65
|
+
*
|
|
66
|
+
* Clamped to a minimum of 0.1 when non-zero to avoid division blow-ups.
|
|
67
|
+
* Default: 2.
|
|
84
68
|
*/
|
|
85
|
-
|
|
69
|
+
typingSpeed?: number;
|
|
86
70
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
71
|
+
* Custom loading animation shown next to the streaming stage label.
|
|
72
|
+
* Accepts any URL that @lottiefiles/dotlottie-react can load — both
|
|
73
|
+
* `.lottie` and `.json` (Lottie format) work. Point this at a
|
|
74
|
+
* LottieFiles free animation, a self-hosted `.lottie` file, or any
|
|
75
|
+
* CDN-hosted URL.
|
|
76
|
+
*
|
|
77
|
+
* When unset the v2 UI falls back to a small 12-point SVG asterisk
|
|
78
|
+
* that spins and pulses — zero-dependency, always works, looks fine.
|
|
79
|
+
* Consumers who want a branded animation (e.g. the Payman logo
|
|
80
|
+
* pulse, a specific LottieFiles loader) set this.
|
|
89
81
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
showName?: boolean;
|
|
96
|
-
};
|
|
97
|
-
emptyState?: {
|
|
98
|
-
/** Default: "What can I help with?" */
|
|
99
|
-
text?: string;
|
|
100
|
-
/**
|
|
101
|
-
* Small line above the main empty-state text (e.g. "Hi, Mike").
|
|
102
|
-
* Native only — web ignores this for now.
|
|
103
|
-
*/
|
|
104
|
-
eyebrow?: string;
|
|
105
|
-
/** Default: true */
|
|
106
|
-
icon?: boolean;
|
|
107
|
-
/** Custom React node rendered above the empty-state text */
|
|
108
|
-
content?: React__default.ReactNode;
|
|
109
|
-
/** Custom logo element rendered in the empty state (native only). Replaces the default HeroMark. */
|
|
110
|
-
logo?: React__default.ReactNode;
|
|
111
|
-
/** Optional app-provided prompt bubbles rendered by the SDK. */
|
|
112
|
-
suggestions?: EmptyStateSuggestionsConfig;
|
|
113
|
-
};
|
|
114
|
-
input?: {
|
|
115
|
-
/** Default: "Type your message..." */
|
|
116
|
-
placeholder?: string;
|
|
117
|
-
/** Default: false */
|
|
118
|
-
showResetButton?: boolean;
|
|
119
|
-
/**
|
|
120
|
-
* `true` (default) shows all attachment options, `false` hides the menu entirely.
|
|
121
|
-
* Pass an object to toggle individual options.
|
|
122
|
-
*/
|
|
123
|
-
attachments?: boolean | {
|
|
124
|
-
uploadImage?: boolean;
|
|
125
|
-
attachFile?: boolean;
|
|
126
|
-
};
|
|
127
|
-
/** `true` enables voice with defaults. Pass an object to customize lang/interim/continuous. */
|
|
128
|
-
voice?: boolean | VoiceOptions;
|
|
129
|
-
};
|
|
130
|
-
messages?: {
|
|
131
|
-
/** `true` shows both sides; `false` hides both; pass object for per-role control. */
|
|
132
|
-
avatars?: boolean | {
|
|
133
|
-
user?: boolean;
|
|
134
|
-
assistant?: boolean;
|
|
135
|
-
};
|
|
136
|
-
/** Default: false */
|
|
137
|
-
timestamps?: boolean;
|
|
138
|
-
/** Default: true */
|
|
139
|
-
streamingDot?: boolean;
|
|
140
|
-
actions?: MessageActionsConfig;
|
|
141
|
-
};
|
|
142
|
-
execution?: {
|
|
143
|
-
/** Default: true */
|
|
144
|
-
showSteps?: boolean;
|
|
145
|
-
/** Default: "Completed in {time}s ({count} steps)" */
|
|
146
|
-
completedLabel?: string;
|
|
147
|
-
/** Default: "View progress ({count} steps)" */
|
|
148
|
-
streamingLabel?: string;
|
|
149
|
-
};
|
|
150
|
-
/** `true` enables the session-history sidebar with defaults; pass an object to customize. */
|
|
151
|
-
sessionHistory?: boolean | SessionHistoryOptions;
|
|
152
|
-
};
|
|
153
|
-
type ChatConfig = BaseChatConfig & {
|
|
154
|
-
availability?: ChatAvailability;
|
|
155
|
-
ui?: ChatUIConfig;
|
|
156
|
-
observability?: {
|
|
157
|
-
sentryDsn?: string;
|
|
82
|
+
loadingAnimation?: {
|
|
83
|
+
/** Fully-qualified URL to a `.lottie` or Lottie `.json` file. */
|
|
84
|
+
src: string;
|
|
85
|
+
/** Rendered size in pixels. Defaults to 18 to match the default SVG spinner. */
|
|
86
|
+
size?: number;
|
|
158
87
|
};
|
|
159
88
|
};
|
|
160
89
|
type ChatCallbacks = ChatCallbacks$1 & {
|
|
90
|
+
/** Called when the session is reset (via SDK reset button or ref.resetSession()) */
|
|
161
91
|
onResetSession?: () => void;
|
|
92
|
+
/** Called when the v2 "Upload image" attachment option is clicked */
|
|
162
93
|
onUploadImageClick?: () => void;
|
|
94
|
+
/** Called when the v2 "Attach file" attachment option is clicked */
|
|
163
95
|
onAttachFileClick?: () => void;
|
|
96
|
+
/** Called when the user gives thumbs-up/down feedback on a message */
|
|
97
|
+
onMessageFeedback?: (data: {
|
|
98
|
+
messageId: string;
|
|
99
|
+
feedback: "up" | "down";
|
|
100
|
+
}) => void;
|
|
164
101
|
};
|
|
165
102
|
type PaymanChatRef = {
|
|
103
|
+
/** Clear all messages and reset the session (clears both stores + generates new session ID) */
|
|
166
104
|
resetSession: () => void;
|
|
105
|
+
/** Clear all messages without resetting session ID */
|
|
167
106
|
clearMessages: () => void;
|
|
107
|
+
/** Cancel the current streaming operation */
|
|
168
108
|
cancelStream: () => void;
|
|
109
|
+
/** Get the current session ID */
|
|
169
110
|
getSessionId: () => string | undefined;
|
|
111
|
+
/** Get all messages */
|
|
170
112
|
getMessages: () => MessageDisplay[];
|
|
171
|
-
/** Replace the active chat with a prior session's history. */
|
|
172
|
-
loadSession: (sessionId: string) => Promise<void>;
|
|
173
113
|
};
|
|
174
114
|
type PaymanChatProps = {
|
|
115
|
+
/** Chat configuration - includes API config */
|
|
175
116
|
config: ChatConfig;
|
|
117
|
+
/** Callbacks for events */
|
|
176
118
|
callbacks?: ChatCallbacks;
|
|
119
|
+
/** Custom class name */
|
|
177
120
|
className?: string;
|
|
121
|
+
/** Custom style */
|
|
178
122
|
style?: React__default.CSSProperties;
|
|
123
|
+
/** Custom children to render (e.g., header) */
|
|
179
124
|
children?: React__default.ReactNode;
|
|
180
125
|
/** Called when the user scrolls to the top — use to load older messages */
|
|
181
126
|
onLoadMoreMessages?: () => void;
|
|
127
|
+
/** Show a loading spinner at the top of the list while fetching older messages */
|
|
182
128
|
isLoadingMoreMessages?: boolean;
|
|
129
|
+
/** Whether there are more messages to load (hides the spinner/trigger when false) */
|
|
183
130
|
hasMoreMessages?: boolean;
|
|
184
131
|
};
|
|
132
|
+
type ChatInputProps = {
|
|
133
|
+
/** Input value */
|
|
134
|
+
value: string;
|
|
135
|
+
/** On change handler */
|
|
136
|
+
onChange: (value: string) => void;
|
|
137
|
+
/** On send handler */
|
|
138
|
+
onSend: () => void;
|
|
139
|
+
/** On pause/cancel handler */
|
|
140
|
+
onPause?: () => void;
|
|
141
|
+
/** Disabled state */
|
|
142
|
+
disabled?: boolean;
|
|
143
|
+
/** Placeholder text */
|
|
144
|
+
placeholder?: string;
|
|
145
|
+
/** Is waiting for response */
|
|
146
|
+
isWaitingForResponse?: boolean;
|
|
147
|
+
/** Has selected session */
|
|
148
|
+
hasSelectedSession?: boolean;
|
|
149
|
+
/** Is session params configured */
|
|
150
|
+
isSessionParamsConfigured?: boolean;
|
|
151
|
+
/** On input click handler */
|
|
152
|
+
onClick?: () => void;
|
|
153
|
+
/** Input style variant */
|
|
154
|
+
inputStyle?: "rounded" | "flat";
|
|
155
|
+
/** Layout style */
|
|
156
|
+
layout?: "centered" | "full-width";
|
|
157
|
+
/** Custom class name */
|
|
158
|
+
className?: string;
|
|
159
|
+
/** Enable voice input in the chat input. When false, voice button is hidden. */
|
|
160
|
+
enableVoice?: boolean;
|
|
161
|
+
/** Voice button handler */
|
|
162
|
+
onVoicePress?: () => void;
|
|
163
|
+
/** Is voice available (e.g. speech recognition ready) */
|
|
164
|
+
voiceAvailable?: boolean;
|
|
165
|
+
/** Is currently recording voice */
|
|
166
|
+
isRecording?: boolean;
|
|
167
|
+
/** Recording duration in seconds (for voice bar timer) */
|
|
168
|
+
recordingDurationSeconds?: number;
|
|
169
|
+
/** Confirm voice recording (stop and apply transcript to input) */
|
|
170
|
+
onConfirmRecording?: () => void;
|
|
171
|
+
/** Cancel voice recording (stop without applying transcript) */
|
|
172
|
+
onCancelRecording?: () => void;
|
|
173
|
+
/** Live transcript while recording (used to animate waveforms only when user is talking) */
|
|
174
|
+
transcribedText?: string;
|
|
175
|
+
/** Show a reset/new session button in the input bar */
|
|
176
|
+
showResetSession?: boolean;
|
|
177
|
+
/** Handler called when the reset session button is clicked */
|
|
178
|
+
onResetSession?: () => void;
|
|
179
|
+
/** Show the attachment (+) menu button */
|
|
180
|
+
showAttachmentButton?: boolean;
|
|
181
|
+
/** Show the "Upload image" attachment option */
|
|
182
|
+
showUploadImageButton?: boolean;
|
|
183
|
+
/** Show the "Attach file" attachment option */
|
|
184
|
+
showAttachFileButton?: boolean;
|
|
185
|
+
/** Handler called when the "Upload image" option is clicked */
|
|
186
|
+
onUploadImageClick?: () => void;
|
|
187
|
+
/** Handler called when the "Attach file" option is clicked */
|
|
188
|
+
onAttachFileClick?: () => void;
|
|
189
|
+
/** React Native: called when the text input is focused (e.g. to scroll messages above the keyboard). */
|
|
190
|
+
onInputFocus?: () => void;
|
|
191
|
+
};
|
|
192
|
+
type MessageListProps = {
|
|
193
|
+
/** Messages to display */
|
|
194
|
+
messages: MessageDisplay[];
|
|
195
|
+
/** Loading state */
|
|
196
|
+
isLoading?: boolean;
|
|
197
|
+
/** Empty state text */
|
|
198
|
+
emptyStateText?: string;
|
|
199
|
+
/** Show icon in empty state */
|
|
200
|
+
showEmptyStateIcon?: boolean;
|
|
201
|
+
/** Custom React component to render above the empty state text */
|
|
202
|
+
emptyStateComponent?: React__default.ReactNode;
|
|
203
|
+
/** Layout style */
|
|
204
|
+
layout?: "centered" | "full-width";
|
|
205
|
+
/** Show timestamps on messages */
|
|
206
|
+
showTimestamps?: boolean;
|
|
207
|
+
/** Stage */
|
|
208
|
+
stage?: AgentStage;
|
|
209
|
+
/** Animated */
|
|
210
|
+
animated?: boolean;
|
|
211
|
+
/** Show agent name */
|
|
212
|
+
showAgentName?: boolean;
|
|
213
|
+
/** Agent name */
|
|
214
|
+
agentName?: string;
|
|
215
|
+
/** Show avatars */
|
|
216
|
+
showAvatars?: boolean;
|
|
217
|
+
/** Show user avatar only (overrides showAvatars) */
|
|
218
|
+
showUserAvatar?: boolean;
|
|
219
|
+
/** Show assistant avatar only (overrides showAvatars) */
|
|
220
|
+
showAssistantAvatar?: boolean;
|
|
221
|
+
/** Show execution steps */
|
|
222
|
+
showExecutionSteps?: boolean;
|
|
223
|
+
/** Show streaming dot */
|
|
224
|
+
showStreamingDot?: boolean;
|
|
225
|
+
/** Custom streaming steps text */
|
|
226
|
+
streamingStepsText?: string;
|
|
227
|
+
/** Custom completed steps text */
|
|
228
|
+
completedStepsText?: string;
|
|
229
|
+
/** On execution trace click */
|
|
230
|
+
onExecutionTraceClick?: (data: {
|
|
231
|
+
message: MessageDisplay;
|
|
232
|
+
tracingData?: unknown;
|
|
233
|
+
executionId?: string;
|
|
234
|
+
}) => void;
|
|
235
|
+
/** Custom class name */
|
|
236
|
+
className?: string;
|
|
237
|
+
/** Called when the user scrolls to the top — use to load older messages */
|
|
238
|
+
onLoadMoreMessages?: () => void;
|
|
239
|
+
/** Show a loading spinner at the top while fetching older messages */
|
|
240
|
+
isLoadingMoreMessages?: boolean;
|
|
241
|
+
/** Whether there are more messages to load */
|
|
242
|
+
hasMoreMessages?: boolean;
|
|
243
|
+
/** React Native: while true, keep scrolling to the end as layout updates. */
|
|
244
|
+
isWaitingForResponse?: boolean;
|
|
245
|
+
/** React Native: ref to register a no-arg function that scrolls the message list to the end. */
|
|
246
|
+
scrollToEndHandleRef?: React__default.MutableRefObject<(() => void) | null>;
|
|
247
|
+
};
|
|
185
248
|
type MessageListV2Props = {
|
|
249
|
+
/** Messages to display */
|
|
186
250
|
messages: MessageDisplay[];
|
|
251
|
+
/** Whether an assistant response is currently streaming */
|
|
187
252
|
isStreaming?: boolean;
|
|
188
|
-
/**
|
|
189
|
-
* When true, the messages area shows a centered activity indicator
|
|
190
|
-
* instead of the (empty) message list. Used while the conversation
|
|
191
|
-
* history for a session is being fetched.
|
|
192
|
-
*/
|
|
193
|
-
isLoadingSession?: boolean;
|
|
253
|
+
/** Edit a user message */
|
|
194
254
|
onEditUserMessage?: (messageId: string) => void;
|
|
255
|
+
/** Retry a user message */
|
|
195
256
|
onRetryUserMessage?: (messageId: string) => void;
|
|
257
|
+
/** Open a markdown image */
|
|
196
258
|
onImageClick?: (src: string, alt: string) => void;
|
|
259
|
+
/** Execution trace click handler */
|
|
197
260
|
onExecutionTraceClick?: (data: {
|
|
198
261
|
message: MessageDisplay;
|
|
199
262
|
tracingData?: unknown;
|
|
200
263
|
executionId?: string;
|
|
201
264
|
}) => void;
|
|
265
|
+
/** Which message actions are visible */
|
|
202
266
|
messageActions?: MessageActionsConfig;
|
|
267
|
+
/** Disable retry/resend actions while the chat is busy */
|
|
203
268
|
retryDisabled?: boolean;
|
|
269
|
+
/** Current user action card */
|
|
204
270
|
userAction?: {
|
|
205
271
|
messageId: string;
|
|
206
272
|
action: {
|
|
@@ -210,157 +276,229 @@ type MessageListV2Props = {
|
|
|
210
276
|
payeeName?: string;
|
|
211
277
|
};
|
|
212
278
|
status: "pending" | "verifying" | "approved" | "rejected" | "error";
|
|
213
|
-
clearOtpTrigger?: number;
|
|
214
279
|
} | null;
|
|
280
|
+
/** Approve a user action */
|
|
215
281
|
onApproveAction?: (messageId: string, otp: string) => Promise<void>;
|
|
282
|
+
/** Reject a user action */
|
|
216
283
|
onRejectAction?: (messageId: string) => Promise<void>;
|
|
284
|
+
/** Resend a user action */
|
|
217
285
|
onResendAction?: (messageId: string) => Promise<void>;
|
|
286
|
+
/** Called when the user gives thumbs-up/down feedback */
|
|
287
|
+
onMessageFeedback?: (data: {
|
|
288
|
+
messageId: string;
|
|
289
|
+
feedback: "up" | "down";
|
|
290
|
+
}) => void;
|
|
291
|
+
/**
|
|
292
|
+
* Speed multiplier for the typing-reveal animation.
|
|
293
|
+
* 1 = default, 2 = 2x faster, 0.5 = half speed, 0 = instant reveal.
|
|
294
|
+
*/
|
|
295
|
+
typingSpeed?: number;
|
|
296
|
+
};
|
|
297
|
+
type MessageRowProps = {
|
|
298
|
+
/** Message to display */
|
|
299
|
+
message: MessageDisplay;
|
|
300
|
+
/** Stage */
|
|
301
|
+
stage?: AgentStage;
|
|
302
|
+
/** Animated */
|
|
303
|
+
animated?: boolean;
|
|
304
|
+
/** Show agent name */
|
|
305
|
+
showAgentName?: boolean;
|
|
306
|
+
/** Agent name */
|
|
307
|
+
agentName?: string;
|
|
308
|
+
/** Show avatars */
|
|
309
|
+
showAvatars?: boolean;
|
|
310
|
+
/** Show user avatar only (overrides showAvatars) */
|
|
311
|
+
showUserAvatar?: boolean;
|
|
312
|
+
/** Show assistant avatar only (overrides showAvatars) */
|
|
313
|
+
showAssistantAvatar?: boolean;
|
|
314
|
+
/** Layout style */
|
|
315
|
+
layout?: "centered" | "full-width";
|
|
316
|
+
/** Show timestamps on messages */
|
|
317
|
+
showTimestamps?: boolean;
|
|
318
|
+
/** Show execution steps */
|
|
319
|
+
showExecutionSteps?: boolean;
|
|
320
|
+
/** Show streaming dot */
|
|
321
|
+
showStreamingDot?: boolean;
|
|
322
|
+
/** Custom streaming steps text */
|
|
323
|
+
streamingStepsText?: string;
|
|
324
|
+
/** Custom completed steps text */
|
|
325
|
+
completedStepsText?: string;
|
|
326
|
+
/** On execution trace click */
|
|
327
|
+
onExecutionTraceClick?: (data: {
|
|
328
|
+
message: MessageDisplay;
|
|
329
|
+
tracingData?: unknown;
|
|
330
|
+
executionId?: string;
|
|
331
|
+
}) => void;
|
|
332
|
+
};
|
|
333
|
+
type UserMessageProps = {
|
|
334
|
+
/** Message to display */
|
|
335
|
+
message: MessageDisplay;
|
|
336
|
+
/** Animated */
|
|
337
|
+
animated?: boolean;
|
|
338
|
+
/** Show avatar */
|
|
339
|
+
showAvatar?: boolean;
|
|
340
|
+
};
|
|
341
|
+
type AgentMessageProps = {
|
|
342
|
+
/** Message to display */
|
|
343
|
+
message: MessageDisplay;
|
|
344
|
+
/** Stage */
|
|
345
|
+
stage?: AgentStage;
|
|
346
|
+
/** Animated */
|
|
347
|
+
animated?: boolean;
|
|
348
|
+
/** Show agent name */
|
|
349
|
+
showAgentName?: boolean;
|
|
350
|
+
/** Agent name */
|
|
351
|
+
agentName?: string;
|
|
352
|
+
/** Show avatar */
|
|
353
|
+
showAvatar?: boolean;
|
|
354
|
+
/** Layout style */
|
|
355
|
+
layout?: "centered" | "full-width";
|
|
356
|
+
/** Show timestamp */
|
|
357
|
+
showTimestamp?: boolean;
|
|
358
|
+
/** Show execution steps */
|
|
359
|
+
showExecutionSteps?: boolean;
|
|
360
|
+
/** Show streaming dot */
|
|
361
|
+
showStreamingDot?: boolean;
|
|
362
|
+
/** Custom streaming steps text */
|
|
363
|
+
streamingStepsText?: string;
|
|
364
|
+
/** Custom completed steps text */
|
|
365
|
+
completedStepsText?: string;
|
|
366
|
+
/** On execution trace click */
|
|
367
|
+
onExecutionTraceClick?: (data: {
|
|
368
|
+
message: MessageDisplay;
|
|
369
|
+
tracingData?: unknown;
|
|
370
|
+
executionId?: string;
|
|
371
|
+
}) => void;
|
|
218
372
|
};
|
|
219
373
|
type StreamingMessageProps = {
|
|
374
|
+
/** Streaming content */
|
|
220
375
|
content: string;
|
|
376
|
+
/** Is currently streaming */
|
|
221
377
|
isStreaming: boolean;
|
|
378
|
+
/** Current worker */
|
|
222
379
|
currentWorker?: string;
|
|
380
|
+
/** Current message */
|
|
223
381
|
currentMessage?: string;
|
|
382
|
+
/** Stream progress */
|
|
224
383
|
streamProgress: StreamProgress;
|
|
384
|
+
/** "WORKFLOW_FAILED" and "STREAM_NOT_STARTED" show the friendly fallback; HTTP 409 conflicts render the backend message from the error payload. */
|
|
225
385
|
error?: string;
|
|
386
|
+
/** Streaming steps */
|
|
226
387
|
steps?: StreamingStep[];
|
|
227
388
|
};
|
|
228
389
|
type ChatHeaderProps = {
|
|
390
|
+
/** Session ID */
|
|
229
391
|
sessionId?: string;
|
|
392
|
+
/** On copy session ID */
|
|
230
393
|
onCopySessionId?: (sessionId: string) => void;
|
|
394
|
+
/** On load session click */
|
|
395
|
+
onLoadSession?: () => void;
|
|
396
|
+
/** On new session click */
|
|
231
397
|
onNewSession?: () => void;
|
|
398
|
+
/** On session params click */
|
|
399
|
+
onSessionParamsClick?: () => void;
|
|
400
|
+
/** Show load session button */
|
|
401
|
+
showLoadSession?: boolean;
|
|
402
|
+
/** Show reset session button */
|
|
232
403
|
showResetSession?: boolean;
|
|
233
|
-
/**
|
|
234
|
-
|
|
404
|
+
/** Show session params button */
|
|
405
|
+
showSessionParams?: boolean;
|
|
406
|
+
/** Show session params tooltip */
|
|
407
|
+
showSessionParamsTooltip?: boolean;
|
|
408
|
+
/** Session params button ref */
|
|
409
|
+
sessionParamsButtonRef?: React__default.RefObject<HTMLButtonElement | null> | undefined;
|
|
410
|
+
/** Custom children */
|
|
235
411
|
children?: React__default.ReactNode;
|
|
412
|
+
/** Custom class name */
|
|
236
413
|
className?: string;
|
|
237
414
|
};
|
|
238
415
|
type OtpInputProps = {
|
|
416
|
+
/** Current OTP value */
|
|
239
417
|
value: string;
|
|
418
|
+
/** Called with new OTP value */
|
|
240
419
|
onChange: (value: string) => void;
|
|
420
|
+
/** Number of digit boxes */
|
|
241
421
|
maxLength: number;
|
|
422
|
+
/** Disabled state */
|
|
242
423
|
disabled?: boolean;
|
|
424
|
+
/** Transient error state — triggers red borders + shake */
|
|
243
425
|
error?: boolean;
|
|
244
426
|
};
|
|
245
427
|
type UserActionModalProps = {
|
|
428
|
+
/** Whether the modal is open */
|
|
246
429
|
isOpen: boolean;
|
|
430
|
+
/** User action request data from the stream */
|
|
247
431
|
userActionRequest: UserActionRequest | null;
|
|
432
|
+
/** Submit OTP */
|
|
248
433
|
onApprove: (otp: string) => Promise<void>;
|
|
434
|
+
/** Reject / cancel */
|
|
249
435
|
onReject: () => Promise<void>;
|
|
436
|
+
/** Resend OTP */
|
|
250
437
|
onResend: () => Promise<void>;
|
|
438
|
+
/** Increment to externally clear OTP field */
|
|
251
439
|
clearOtpTrigger: number;
|
|
252
440
|
};
|
|
253
|
-
type Stage = WorkflowStage;
|
|
254
441
|
|
|
255
|
-
|
|
442
|
+
/**
|
|
443
|
+
* PaymanChat — the public component. Delegates to `PaymanChatInner`
|
|
444
|
+
* with a chat hook instance from `useChatV2`. The `config.uiVersion`
|
|
445
|
+
* prop used to gate an older V1 render path; the V1 code has been
|
|
446
|
+
* removed since nothing in the SDK's current consumers (paygent-studio
|
|
447
|
+
* etc.) opted into it. The `uiVersion` prop is still accepted on
|
|
448
|
+
* `ChatConfig` for type compatibility but is now ignored at runtime.
|
|
449
|
+
*/
|
|
450
|
+
declare const PaymanChat: React.ForwardRefExoticComponent<PaymanChatProps & React.RefAttributes<PaymanChatRef>>;
|
|
256
451
|
|
|
257
|
-
|
|
258
|
-
key: string;
|
|
259
|
-
sessionId: string;
|
|
260
|
-
previousSessionId?: string;
|
|
261
|
-
lastMessageAt: string;
|
|
262
|
-
sessionTitle?: string;
|
|
263
|
-
};
|
|
264
|
-
type SessionHistorySidebarProps = {
|
|
265
|
-
config: BaseChatConfig;
|
|
266
|
-
options: SessionHistoryOptions;
|
|
267
|
-
activeSessionId?: string;
|
|
268
|
-
/** Session id whose conversation history is currently being fetched.
|
|
269
|
-
* The matching row renders a small inline spinner next to its title. */
|
|
270
|
-
loadingSessionId?: string;
|
|
452
|
+
interface PaymanChatContextValue {
|
|
271
453
|
/**
|
|
272
|
-
*
|
|
273
|
-
* renders a check mark on the right of its title — the parent is
|
|
274
|
-
* expected to drop the id from the set after a few seconds so the mark
|
|
275
|
-
* goes away on its own.
|
|
454
|
+
* Clear all messages and reset the chat
|
|
276
455
|
*/
|
|
277
|
-
recentlyCompletedSessionIds?: ReadonlySet<string>;
|
|
278
|
-
optimisticActivity?: OptimisticSessionActivity | null;
|
|
279
|
-
/** Called when the user clicks a row. */
|
|
280
|
-
onSelectSession: (session: SessionSummary) => void;
|
|
281
|
-
/** Called by the optional sidebar "New Session" button. */
|
|
282
|
-
onNewSession?: () => void;
|
|
283
|
-
/** Disabled state for the optional sidebar "New Session" button. */
|
|
284
|
-
newSessionDisabled?: boolean;
|
|
285
|
-
/** Controlled mobile drawer open state. */
|
|
286
|
-
mobileOpen: boolean;
|
|
287
|
-
onMobileOpenChange: (open: boolean) => void;
|
|
288
|
-
};
|
|
289
|
-
declare function SessionHistorySidebar({ config, options, activeSessionId, loadingSessionId, recentlyCompletedSessionIds, optimisticActivity, onSelectSession, onNewSession, newSessionDisabled, mobileOpen, onMobileOpenChange, }: SessionHistorySidebarProps): react_jsx_runtime.JSX.Element;
|
|
290
|
-
|
|
291
|
-
declare function ChatHeader({ sessionId, onCopySessionId, onNewSession, showResetSession, onToggleSidebar, children, className, }: ChatHeaderProps): react_jsx_runtime.JSX.Element;
|
|
292
|
-
|
|
293
|
-
declare function UserActionModal({ isOpen, userActionRequest, onApprove, onReject, onResend, clearOtpTrigger, }: UserActionModalProps): react_jsx_runtime.JSX.Element | null;
|
|
294
|
-
|
|
295
|
-
interface FloatingChatProps {
|
|
296
|
-
config: ChatConfig;
|
|
297
|
-
callbacks?: ChatCallbacks;
|
|
298
|
-
buttonPosition?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
299
|
-
buttonSize?: "sm" | "md" | "lg";
|
|
300
|
-
buttonColor?: string;
|
|
301
|
-
buttonIcon?: React.ReactNode;
|
|
302
|
-
buttonIconUrl?: string;
|
|
303
|
-
windowWidth?: string | number;
|
|
304
|
-
windowHeight?: string | number;
|
|
305
|
-
headerTitle?: string;
|
|
306
|
-
headerSubtitle?: string;
|
|
307
|
-
headerAvatar?: string;
|
|
308
|
-
headerColor?: string;
|
|
309
|
-
defaultOpen?: boolean;
|
|
310
|
-
showNotificationBadge?: boolean;
|
|
311
|
-
}
|
|
312
|
-
declare function FloatingChat({ config, callbacks, buttonPosition, buttonSize, buttonColor, buttonIcon, buttonIconUrl, windowWidth, windowHeight, headerTitle, headerSubtitle, headerAvatar, headerColor, defaultOpen, showNotificationBadge, }: FloatingChatProps): react_jsx_runtime.JSX.Element;
|
|
313
|
-
|
|
314
|
-
interface PaymanChatContextValue {
|
|
315
|
-
/** Clear all messages and reset the chat. */
|
|
316
456
|
resetSession: () => void;
|
|
317
|
-
/**
|
|
457
|
+
/**
|
|
458
|
+
* Clear all messages without resetting session ID
|
|
459
|
+
*/
|
|
318
460
|
clearMessages: () => void;
|
|
319
|
-
/**
|
|
461
|
+
/**
|
|
462
|
+
* Prepend older messages to the top of the list (e.g. from history pagination)
|
|
463
|
+
*/
|
|
320
464
|
prependMessages: (messages: MessageDisplay[]) => void;
|
|
321
|
-
/**
|
|
465
|
+
/**
|
|
466
|
+
* Cancel current streaming operation
|
|
467
|
+
*/
|
|
322
468
|
cancelStream: () => void;
|
|
323
|
-
/**
|
|
469
|
+
/**
|
|
470
|
+
* Get current session ID
|
|
471
|
+
*/
|
|
324
472
|
getSessionId: () => string | undefined;
|
|
325
|
-
/**
|
|
473
|
+
/**
|
|
474
|
+
* Get all messages
|
|
475
|
+
*/
|
|
326
476
|
getMessages: () => MessageDisplay[];
|
|
327
477
|
/**
|
|
328
|
-
*
|
|
329
|
-
* Same call the built-in sidebar uses; exposed for advanced consumers.
|
|
478
|
+
* Check if currently waiting for response
|
|
330
479
|
*/
|
|
331
|
-
loadSession: (sessionId: string) => Promise<void>;
|
|
332
|
-
/** Whether a stream is currently in flight. */
|
|
333
480
|
isWaitingForResponse: boolean;
|
|
334
481
|
}
|
|
335
|
-
declare const PaymanChatContext: React
|
|
482
|
+
declare const PaymanChatContext: React.Context<PaymanChatContextValue | undefined>;
|
|
336
483
|
/**
|
|
337
|
-
*
|
|
484
|
+
* Hook to access PaymanChat controls from parent components
|
|
338
485
|
*
|
|
339
486
|
* @example
|
|
340
487
|
* ```tsx
|
|
341
|
-
*
|
|
342
|
-
* chat
|
|
488
|
+
* function MyComponent() {
|
|
489
|
+
* const chat = usePaymanChat();
|
|
490
|
+
*
|
|
491
|
+
* return (
|
|
492
|
+
* <>
|
|
493
|
+
* <button onClick={chat.resetSession}>Reset</button>
|
|
494
|
+
* <button onClick={chat.clearMessages}>Clear</button>
|
|
495
|
+
* </>
|
|
496
|
+
* );
|
|
497
|
+
* }
|
|
343
498
|
* ```
|
|
344
499
|
*/
|
|
345
500
|
declare function usePaymanChat(): PaymanChatContextValue;
|
|
346
501
|
|
|
347
|
-
type UseSessionHistoryReturn = {
|
|
348
|
-
sessions: SessionSummary[];
|
|
349
|
-
isLoading: boolean;
|
|
350
|
-
error: Error | null;
|
|
351
|
-
hasNext: boolean;
|
|
352
|
-
loadMore: () => Promise<void>;
|
|
353
|
-
refresh: () => Promise<void>;
|
|
354
|
-
width: number;
|
|
355
|
-
setWidth: (px: number) => void;
|
|
356
|
-
collapsed: boolean;
|
|
357
|
-
setCollapsed: (value: boolean | ((prev: boolean) => boolean)) => void;
|
|
358
|
-
minWidth: number;
|
|
359
|
-
maxWidth: number;
|
|
360
|
-
isReady: boolean;
|
|
361
|
-
};
|
|
362
|
-
declare function useSessionHistory(config: BaseChatConfig, options?: SessionHistoryOptions, optimisticActivity?: OptimisticSessionActivity | null): UseSessionHistoryReturn;
|
|
363
|
-
|
|
364
502
|
/**
|
|
365
503
|
* Utility function to merge Tailwind CSS classes
|
|
366
504
|
*/
|
|
@@ -374,7 +512,7 @@ declare function formatDate(timestamp: string | Date): string;
|
|
|
374
512
|
interface ChatSessionContext {
|
|
375
513
|
sessionId?: string;
|
|
376
514
|
sessionOwnerId?: string;
|
|
377
|
-
|
|
515
|
+
agentId?: string;
|
|
378
516
|
executionId?: string;
|
|
379
517
|
cfRay?: string;
|
|
380
518
|
route?: string;
|
|
@@ -390,12 +528,4 @@ interface ChatSessionContext {
|
|
|
390
528
|
*/
|
|
391
529
|
declare function captureSentryError(error: Error | string, context: ChatSessionContext): void;
|
|
392
530
|
|
|
393
|
-
|
|
394
|
-
* Format an ISO timestamp as a human-friendly relative label:
|
|
395
|
-
* "just now" / "Nm ago" / "Nh ago" / "Yesterday" / "<day>" (this week) / "Mon D" / "Mon D, YYYY"
|
|
396
|
-
*
|
|
397
|
-
* No dayjs / date-fns — deliberately ~0 bytes extra.
|
|
398
|
-
*/
|
|
399
|
-
declare function formatRelativeTime(iso: string, now?: Date): string;
|
|
400
|
-
|
|
401
|
-
export { type AssistantMessageActionsConfig, type ChatAvailability, type ChatCallbacks, type ChatConfig, ChatHeader, type ChatHeaderProps, type ChatSessionContext, type ChatUIConfig, type EmptyStatePromptCategory, type EmptyStateSuggestionsConfig, FloatingChat, type MessageActionsConfig, type MessageListV2Props, type OtpInputProps, PaymanChat, PaymanChatContext, type PaymanChatContextValue, type PaymanChatProps, type PaymanChatRef, type SessionHistoryOptions, SessionHistorySidebar, type Stage, type StreamingMessageProps, UserActionModal, type UserActionModalProps, type UserMessageActionsConfig, type VoiceOptions, captureSentryError, cn, formatDate, formatRelativeTime, usePaymanChat, useSessionHistory };
|
|
531
|
+
export { type AgentMessageProps, type AssistantMessageActionsConfig, type ChatCallbacks, type ChatConfig, type ChatHeaderProps, type ChatInputProps, type ChatSessionContext, type MessageActionsConfig, type MessageListProps, type MessageListV2Props, type MessageRowProps, type OtpInputProps, PaymanChat, PaymanChatContext, type PaymanChatContextValue, type PaymanChatProps, type PaymanChatRef, type StreamingMessageProps, type UserActionModalProps, type UserMessageActionsConfig, type UserMessageProps, captureSentryError, cn, formatDate, usePaymanChat };
|