@paymanai/payman-ask-sdk 2.0.5 → 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/README.md +51 -0
- package/dist/index.d.mts +372 -219
- package/dist/index.d.ts +372 -219
- package/dist/index.js +3188 -4588
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3191 -4574
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +1800 -3953
- package/dist/index.native.js.map +1 -1
- package/dist/styles.css +132 -602
- package/dist/styles.css.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
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,166 +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 ChatUIConfig = {
|
|
59
|
-
layout?: "centered" | "full-width";
|
|
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;
|
|
60
52
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
53
|
+
* UI version to render.
|
|
54
|
+
* 1 = original component set
|
|
55
|
+
* 2 = redesigned chat UI (ChatGPT-style with thinking blocks, inline verification, etc.) — default
|
|
63
56
|
*/
|
|
64
|
-
|
|
57
|
+
uiVersion?: 1 | 2;
|
|
65
58
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
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.
|
|
68
68
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
content?: React__default.ReactNode;
|
|
88
|
-
/** Custom logo element rendered in the empty state (native only). Replaces the default HeroMark. */
|
|
89
|
-
logo?: React__default.ReactNode;
|
|
90
|
-
};
|
|
91
|
-
input?: {
|
|
92
|
-
/** Default: "Type your message..." */
|
|
93
|
-
placeholder?: string;
|
|
94
|
-
/** Default: false */
|
|
95
|
-
showResetButton?: boolean;
|
|
96
|
-
/**
|
|
97
|
-
* `true` (default) shows all attachment options, `false` hides the menu entirely.
|
|
98
|
-
* Pass an object to toggle individual options.
|
|
99
|
-
*/
|
|
100
|
-
attachments?: boolean | {
|
|
101
|
-
uploadImage?: boolean;
|
|
102
|
-
attachFile?: boolean;
|
|
103
|
-
};
|
|
104
|
-
/** `true` enables voice with defaults. Pass an object to customize lang/interim/continuous. */
|
|
105
|
-
voice?: boolean | VoiceOptions;
|
|
106
|
-
};
|
|
107
|
-
messages?: {
|
|
108
|
-
/** `true` shows both sides; `false` hides both; pass object for per-role control. */
|
|
109
|
-
avatars?: boolean | {
|
|
110
|
-
user?: boolean;
|
|
111
|
-
assistant?: boolean;
|
|
112
|
-
};
|
|
113
|
-
/** Default: false */
|
|
114
|
-
timestamps?: boolean;
|
|
115
|
-
/** Default: true */
|
|
116
|
-
streamingDot?: boolean;
|
|
117
|
-
actions?: MessageActionsConfig;
|
|
118
|
-
};
|
|
119
|
-
execution?: {
|
|
120
|
-
/** Default: true */
|
|
121
|
-
showSteps?: boolean;
|
|
122
|
-
/** Default: "Completed in {time}s ({count} steps)" */
|
|
123
|
-
completedLabel?: string;
|
|
124
|
-
/** Default: "View progress ({count} steps)" */
|
|
125
|
-
streamingLabel?: string;
|
|
126
|
-
};
|
|
127
|
-
/** `true` enables the session-history sidebar with defaults; pass an object to customize. */
|
|
128
|
-
sessionHistory?: boolean | SessionHistoryOptions;
|
|
129
|
-
};
|
|
130
|
-
type ChatConfig = BaseChatConfig & {
|
|
131
|
-
availability?: ChatAvailability;
|
|
132
|
-
ui?: ChatUIConfig;
|
|
133
|
-
observability?: {
|
|
134
|
-
sentryDsn?: string;
|
|
69
|
+
typingSpeed?: number;
|
|
70
|
+
/**
|
|
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.
|
|
81
|
+
*/
|
|
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;
|
|
135
87
|
};
|
|
136
88
|
};
|
|
137
89
|
type ChatCallbacks = ChatCallbacks$1 & {
|
|
90
|
+
/** Called when the session is reset (via SDK reset button or ref.resetSession()) */
|
|
138
91
|
onResetSession?: () => void;
|
|
92
|
+
/** Called when the v2 "Upload image" attachment option is clicked */
|
|
139
93
|
onUploadImageClick?: () => void;
|
|
94
|
+
/** Called when the v2 "Attach file" attachment option is clicked */
|
|
140
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;
|
|
141
101
|
};
|
|
142
102
|
type PaymanChatRef = {
|
|
103
|
+
/** Clear all messages and reset the session (clears both stores + generates new session ID) */
|
|
143
104
|
resetSession: () => void;
|
|
105
|
+
/** Clear all messages without resetting session ID */
|
|
144
106
|
clearMessages: () => void;
|
|
107
|
+
/** Cancel the current streaming operation */
|
|
145
108
|
cancelStream: () => void;
|
|
109
|
+
/** Get the current session ID */
|
|
146
110
|
getSessionId: () => string | undefined;
|
|
111
|
+
/** Get all messages */
|
|
147
112
|
getMessages: () => MessageDisplay[];
|
|
148
|
-
/** Replace the active chat with a prior session's history. */
|
|
149
|
-
loadSession: (sessionId: string) => Promise<void>;
|
|
150
113
|
};
|
|
151
114
|
type PaymanChatProps = {
|
|
115
|
+
/** Chat configuration - includes API config */
|
|
152
116
|
config: ChatConfig;
|
|
117
|
+
/** Callbacks for events */
|
|
153
118
|
callbacks?: ChatCallbacks;
|
|
119
|
+
/** Custom class name */
|
|
154
120
|
className?: string;
|
|
121
|
+
/** Custom style */
|
|
155
122
|
style?: React__default.CSSProperties;
|
|
123
|
+
/** Custom children to render (e.g., header) */
|
|
156
124
|
children?: React__default.ReactNode;
|
|
157
125
|
/** Called when the user scrolls to the top — use to load older messages */
|
|
158
126
|
onLoadMoreMessages?: () => void;
|
|
127
|
+
/** Show a loading spinner at the top of the list while fetching older messages */
|
|
159
128
|
isLoadingMoreMessages?: boolean;
|
|
129
|
+
/** Whether there are more messages to load (hides the spinner/trigger when false) */
|
|
160
130
|
hasMoreMessages?: boolean;
|
|
161
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
|
+
};
|
|
162
248
|
type MessageListV2Props = {
|
|
249
|
+
/** Messages to display */
|
|
163
250
|
messages: MessageDisplay[];
|
|
251
|
+
/** Whether an assistant response is currently streaming */
|
|
164
252
|
isStreaming?: boolean;
|
|
165
|
-
/**
|
|
166
|
-
* When true, the messages area shows a centered activity indicator
|
|
167
|
-
* instead of the (empty) message list. Used while the conversation
|
|
168
|
-
* history for a session is being fetched.
|
|
169
|
-
*/
|
|
170
|
-
isLoadingSession?: boolean;
|
|
253
|
+
/** Edit a user message */
|
|
171
254
|
onEditUserMessage?: (messageId: string) => void;
|
|
255
|
+
/** Retry a user message */
|
|
172
256
|
onRetryUserMessage?: (messageId: string) => void;
|
|
257
|
+
/** Open a markdown image */
|
|
173
258
|
onImageClick?: (src: string, alt: string) => void;
|
|
259
|
+
/** Execution trace click handler */
|
|
174
260
|
onExecutionTraceClick?: (data: {
|
|
175
261
|
message: MessageDisplay;
|
|
176
262
|
tracingData?: unknown;
|
|
177
263
|
executionId?: string;
|
|
178
264
|
}) => void;
|
|
265
|
+
/** Which message actions are visible */
|
|
179
266
|
messageActions?: MessageActionsConfig;
|
|
267
|
+
/** Disable retry/resend actions while the chat is busy */
|
|
180
268
|
retryDisabled?: boolean;
|
|
269
|
+
/** Current user action card */
|
|
181
270
|
userAction?: {
|
|
182
271
|
messageId: string;
|
|
183
272
|
action: {
|
|
@@ -187,157 +276,229 @@ type MessageListV2Props = {
|
|
|
187
276
|
payeeName?: string;
|
|
188
277
|
};
|
|
189
278
|
status: "pending" | "verifying" | "approved" | "rejected" | "error";
|
|
190
|
-
clearOtpTrigger?: number;
|
|
191
279
|
} | null;
|
|
280
|
+
/** Approve a user action */
|
|
192
281
|
onApproveAction?: (messageId: string, otp: string) => Promise<void>;
|
|
282
|
+
/** Reject a user action */
|
|
193
283
|
onRejectAction?: (messageId: string) => Promise<void>;
|
|
284
|
+
/** Resend a user action */
|
|
194
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;
|
|
195
372
|
};
|
|
196
373
|
type StreamingMessageProps = {
|
|
374
|
+
/** Streaming content */
|
|
197
375
|
content: string;
|
|
376
|
+
/** Is currently streaming */
|
|
198
377
|
isStreaming: boolean;
|
|
378
|
+
/** Current worker */
|
|
199
379
|
currentWorker?: string;
|
|
380
|
+
/** Current message */
|
|
200
381
|
currentMessage?: string;
|
|
382
|
+
/** Stream progress */
|
|
201
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. */
|
|
202
385
|
error?: string;
|
|
386
|
+
/** Streaming steps */
|
|
203
387
|
steps?: StreamingStep[];
|
|
204
388
|
};
|
|
205
389
|
type ChatHeaderProps = {
|
|
390
|
+
/** Session ID */
|
|
206
391
|
sessionId?: string;
|
|
392
|
+
/** On copy session ID */
|
|
207
393
|
onCopySessionId?: (sessionId: string) => void;
|
|
394
|
+
/** On load session click */
|
|
395
|
+
onLoadSession?: () => void;
|
|
396
|
+
/** On new session click */
|
|
208
397
|
onNewSession?: () => void;
|
|
398
|
+
/** On session params click */
|
|
399
|
+
onSessionParamsClick?: () => void;
|
|
400
|
+
/** Show load session button */
|
|
401
|
+
showLoadSession?: boolean;
|
|
402
|
+
/** Show reset session button */
|
|
209
403
|
showResetSession?: boolean;
|
|
210
|
-
/**
|
|
211
|
-
|
|
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 */
|
|
212
411
|
children?: React__default.ReactNode;
|
|
412
|
+
/** Custom class name */
|
|
213
413
|
className?: string;
|
|
214
414
|
};
|
|
215
415
|
type OtpInputProps = {
|
|
416
|
+
/** Current OTP value */
|
|
216
417
|
value: string;
|
|
418
|
+
/** Called with new OTP value */
|
|
217
419
|
onChange: (value: string) => void;
|
|
420
|
+
/** Number of digit boxes */
|
|
218
421
|
maxLength: number;
|
|
422
|
+
/** Disabled state */
|
|
219
423
|
disabled?: boolean;
|
|
424
|
+
/** Transient error state — triggers red borders + shake */
|
|
220
425
|
error?: boolean;
|
|
221
426
|
};
|
|
222
427
|
type UserActionModalProps = {
|
|
428
|
+
/** Whether the modal is open */
|
|
223
429
|
isOpen: boolean;
|
|
430
|
+
/** User action request data from the stream */
|
|
224
431
|
userActionRequest: UserActionRequest | null;
|
|
432
|
+
/** Submit OTP */
|
|
225
433
|
onApprove: (otp: string) => Promise<void>;
|
|
434
|
+
/** Reject / cancel */
|
|
226
435
|
onReject: () => Promise<void>;
|
|
436
|
+
/** Resend OTP */
|
|
227
437
|
onResend: () => Promise<void>;
|
|
438
|
+
/** Increment to externally clear OTP field */
|
|
228
439
|
clearOtpTrigger: number;
|
|
229
440
|
};
|
|
230
|
-
type Stage = WorkflowStage;
|
|
231
441
|
|
|
232
|
-
|
|
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>>;
|
|
233
451
|
|
|
234
|
-
|
|
235
|
-
key: string;
|
|
236
|
-
sessionId: string;
|
|
237
|
-
previousSessionId?: string;
|
|
238
|
-
lastMessageAt: string;
|
|
239
|
-
sessionTitle?: string;
|
|
240
|
-
};
|
|
241
|
-
type SessionHistorySidebarProps = {
|
|
242
|
-
config: BaseChatConfig;
|
|
243
|
-
options: SessionHistoryOptions;
|
|
244
|
-
activeSessionId?: string;
|
|
245
|
-
/** Session id whose conversation history is currently being fetched.
|
|
246
|
-
* The matching row renders a small inline spinner next to its title. */
|
|
247
|
-
loadingSessionId?: string;
|
|
452
|
+
interface PaymanChatContextValue {
|
|
248
453
|
/**
|
|
249
|
-
*
|
|
250
|
-
* renders a check mark on the right of its title — the parent is
|
|
251
|
-
* expected to drop the id from the set after a few seconds so the mark
|
|
252
|
-
* goes away on its own.
|
|
454
|
+
* Clear all messages and reset the chat
|
|
253
455
|
*/
|
|
254
|
-
recentlyCompletedSessionIds?: ReadonlySet<string>;
|
|
255
|
-
optimisticActivity?: OptimisticSessionActivity | null;
|
|
256
|
-
/** Called when the user clicks a row. */
|
|
257
|
-
onSelectSession: (session: SessionSummary) => void;
|
|
258
|
-
/** Called by the optional sidebar "New Session" button. */
|
|
259
|
-
onNewSession?: () => void;
|
|
260
|
-
/** Disabled state for the optional sidebar "New Session" button. */
|
|
261
|
-
newSessionDisabled?: boolean;
|
|
262
|
-
/** Controlled mobile drawer open state. */
|
|
263
|
-
mobileOpen: boolean;
|
|
264
|
-
onMobileOpenChange: (open: boolean) => void;
|
|
265
|
-
};
|
|
266
|
-
declare function SessionHistorySidebar({ config, options, activeSessionId, loadingSessionId, recentlyCompletedSessionIds, optimisticActivity, onSelectSession, onNewSession, newSessionDisabled, mobileOpen, onMobileOpenChange, }: SessionHistorySidebarProps): react_jsx_runtime.JSX.Element;
|
|
267
|
-
|
|
268
|
-
declare function ChatHeader({ sessionId, onCopySessionId, onNewSession, showResetSession, onToggleSidebar, children, className, }: ChatHeaderProps): react_jsx_runtime.JSX.Element;
|
|
269
|
-
|
|
270
|
-
declare function UserActionModal({ isOpen, userActionRequest, onApprove, onReject, onResend, clearOtpTrigger, }: UserActionModalProps): react_jsx_runtime.JSX.Element | null;
|
|
271
|
-
|
|
272
|
-
interface FloatingChatProps {
|
|
273
|
-
config: ChatConfig;
|
|
274
|
-
callbacks?: ChatCallbacks;
|
|
275
|
-
buttonPosition?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
276
|
-
buttonSize?: "sm" | "md" | "lg";
|
|
277
|
-
buttonColor?: string;
|
|
278
|
-
buttonIcon?: React.ReactNode;
|
|
279
|
-
buttonIconUrl?: string;
|
|
280
|
-
windowWidth?: string | number;
|
|
281
|
-
windowHeight?: string | number;
|
|
282
|
-
headerTitle?: string;
|
|
283
|
-
headerSubtitle?: string;
|
|
284
|
-
headerAvatar?: string;
|
|
285
|
-
headerColor?: string;
|
|
286
|
-
defaultOpen?: boolean;
|
|
287
|
-
showNotificationBadge?: boolean;
|
|
288
|
-
}
|
|
289
|
-
declare function FloatingChat({ config, callbacks, buttonPosition, buttonSize, buttonColor, buttonIcon, buttonIconUrl, windowWidth, windowHeight, headerTitle, headerSubtitle, headerAvatar, headerColor, defaultOpen, showNotificationBadge, }: FloatingChatProps): react_jsx_runtime.JSX.Element;
|
|
290
|
-
|
|
291
|
-
interface PaymanChatContextValue {
|
|
292
|
-
/** Clear all messages and reset the chat. */
|
|
293
456
|
resetSession: () => void;
|
|
294
|
-
/**
|
|
457
|
+
/**
|
|
458
|
+
* Clear all messages without resetting session ID
|
|
459
|
+
*/
|
|
295
460
|
clearMessages: () => void;
|
|
296
|
-
/**
|
|
461
|
+
/**
|
|
462
|
+
* Prepend older messages to the top of the list (e.g. from history pagination)
|
|
463
|
+
*/
|
|
297
464
|
prependMessages: (messages: MessageDisplay[]) => void;
|
|
298
|
-
/**
|
|
465
|
+
/**
|
|
466
|
+
* Cancel current streaming operation
|
|
467
|
+
*/
|
|
299
468
|
cancelStream: () => void;
|
|
300
|
-
/**
|
|
469
|
+
/**
|
|
470
|
+
* Get current session ID
|
|
471
|
+
*/
|
|
301
472
|
getSessionId: () => string | undefined;
|
|
302
|
-
/**
|
|
473
|
+
/**
|
|
474
|
+
* Get all messages
|
|
475
|
+
*/
|
|
303
476
|
getMessages: () => MessageDisplay[];
|
|
304
477
|
/**
|
|
305
|
-
*
|
|
306
|
-
* Same call the built-in sidebar uses; exposed for advanced consumers.
|
|
478
|
+
* Check if currently waiting for response
|
|
307
479
|
*/
|
|
308
|
-
loadSession: (sessionId: string) => Promise<void>;
|
|
309
|
-
/** Whether a stream is currently in flight. */
|
|
310
480
|
isWaitingForResponse: boolean;
|
|
311
481
|
}
|
|
312
|
-
declare const PaymanChatContext: React
|
|
482
|
+
declare const PaymanChatContext: React.Context<PaymanChatContextValue | undefined>;
|
|
313
483
|
/**
|
|
314
|
-
*
|
|
484
|
+
* Hook to access PaymanChat controls from parent components
|
|
315
485
|
*
|
|
316
486
|
* @example
|
|
317
487
|
* ```tsx
|
|
318
|
-
*
|
|
319
|
-
* 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
|
+
* }
|
|
320
498
|
* ```
|
|
321
499
|
*/
|
|
322
500
|
declare function usePaymanChat(): PaymanChatContextValue;
|
|
323
501
|
|
|
324
|
-
type UseSessionHistoryReturn = {
|
|
325
|
-
sessions: SessionSummary[];
|
|
326
|
-
isLoading: boolean;
|
|
327
|
-
error: Error | null;
|
|
328
|
-
hasNext: boolean;
|
|
329
|
-
loadMore: () => Promise<void>;
|
|
330
|
-
refresh: () => Promise<void>;
|
|
331
|
-
width: number;
|
|
332
|
-
setWidth: (px: number) => void;
|
|
333
|
-
collapsed: boolean;
|
|
334
|
-
setCollapsed: (value: boolean | ((prev: boolean) => boolean)) => void;
|
|
335
|
-
minWidth: number;
|
|
336
|
-
maxWidth: number;
|
|
337
|
-
isReady: boolean;
|
|
338
|
-
};
|
|
339
|
-
declare function useSessionHistory(config: BaseChatConfig, options?: SessionHistoryOptions, optimisticActivity?: OptimisticSessionActivity | null): UseSessionHistoryReturn;
|
|
340
|
-
|
|
341
502
|
/**
|
|
342
503
|
* Utility function to merge Tailwind CSS classes
|
|
343
504
|
*/
|
|
@@ -351,7 +512,7 @@ declare function formatDate(timestamp: string | Date): string;
|
|
|
351
512
|
interface ChatSessionContext {
|
|
352
513
|
sessionId?: string;
|
|
353
514
|
sessionOwnerId?: string;
|
|
354
|
-
|
|
515
|
+
agentId?: string;
|
|
355
516
|
executionId?: string;
|
|
356
517
|
cfRay?: string;
|
|
357
518
|
route?: string;
|
|
@@ -367,12 +528,4 @@ interface ChatSessionContext {
|
|
|
367
528
|
*/
|
|
368
529
|
declare function captureSentryError(error: Error | string, context: ChatSessionContext): void;
|
|
369
530
|
|
|
370
|
-
|
|
371
|
-
* Format an ISO timestamp as a human-friendly relative label:
|
|
372
|
-
* "just now" / "Nm ago" / "Nh ago" / "Yesterday" / "<day>" (this week) / "Mon D" / "Mon D, YYYY"
|
|
373
|
-
*
|
|
374
|
-
* No dayjs / date-fns — deliberately ~0 bytes extra.
|
|
375
|
-
*/
|
|
376
|
-
declare function formatRelativeTime(iso: string, now?: Date): string;
|
|
377
|
-
|
|
378
|
-
export { type AssistantMessageActionsConfig, type ChatAvailability, type ChatCallbacks, type ChatConfig, ChatHeader, type ChatHeaderProps, type ChatSessionContext, type ChatUIConfig, 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 };
|