@paymanai/payman-ask-sdk 1.2.26 → 2.0.1
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 +216 -201
- package/dist/index.d.mts +204 -318
- package/dist/index.d.ts +204 -318
- package/dist/index.js +4539 -4618
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4517 -4610
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +1123 -1745
- package/dist/index.native.js.map +1 -1
- package/dist/styles.css +454 -11
- package/dist/styles.css.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export { APIConfig, ChunkDisplay, MessageDisplay, MessageRole,
|
|
3
|
+
import { ChatCallbacks as ChatCallbacks$1, BaseChatConfig, MessageDisplay, WorkflowStage, StreamProgress, StreamingStep, UserActionRequest, SessionSummary } from '@paymanai/payman-typescript-ask-sdk';
|
|
4
|
+
export { APIConfig, BaseChatConfig, ChunkDisplay, ConversationEntry, ConversationListResponse, MessageDisplay, MessageRole, PageInfo, SessionListResponse, SessionOwner, SessionSummary, StreamEvent, StreamOptions, StreamProgress, StreamingStep, UseChatV2Return, UseVoiceReturn, UserActionRequest, UserActionResult, UserActionState, UserActionType, V2EventProcessorState, VoiceCallbacks, VoiceConfig, VoicePermissions, VoiceResult, VoiceState, WorkflowStage, buildFormattedThinking, buildScopeKey, cancelUserAction, createInitialV2State, generateId, listConversations, listSessions, processStreamEventV2, resendUserAction, streamWorkflowEvents, submitUserAction, useChatV2, useVoice } from '@paymanai/payman-typescript-ask-sdk';
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
6
|
import { ClassValue } from 'clsx';
|
|
6
7
|
|
|
7
8
|
type UserMessageActionsConfig = {
|
|
@@ -22,212 +23,142 @@ type MessageActionsConfig = {
|
|
|
22
23
|
userMessageActions?: UserMessageActionsConfig;
|
|
23
24
|
assistantMessageActions?: AssistantMessageActionsConfig;
|
|
24
25
|
};
|
|
25
|
-
type
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
26
|
+
type ChatAvailability = {
|
|
27
|
+
state: "ready";
|
|
28
|
+
} | {
|
|
29
|
+
state: "readOnly";
|
|
30
|
+
} | {
|
|
31
|
+
state: "disabled";
|
|
32
|
+
reason?: React__default.ReactNode;
|
|
33
|
+
};
|
|
34
|
+
type VoiceOptions = {
|
|
35
|
+
/** Default: "en-US" */
|
|
36
|
+
lang?: string;
|
|
37
|
+
/** Default: true */
|
|
38
|
+
interimResults?: boolean;
|
|
39
|
+
/** Default: true */
|
|
40
|
+
continuous?: boolean;
|
|
41
|
+
};
|
|
42
|
+
type SessionHistoryOptions = {
|
|
43
|
+
/** Desktop sidebar default width in px. Default: 280 */
|
|
44
|
+
defaultWidth?: number;
|
|
45
|
+
/** Default: 240 */
|
|
46
|
+
minWidth?: number;
|
|
47
|
+
/** Default: 480 */
|
|
48
|
+
maxWidth?: number;
|
|
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
|
+
};
|
|
56
|
+
type ChatUIConfig = {
|
|
57
|
+
layout?: "centered" | "full-width";
|
|
58
|
+
agent?: {
|
|
59
|
+
/** Default: "Assistant" */
|
|
60
|
+
name?: string;
|
|
61
|
+
/** Default: true */
|
|
62
|
+
showName?: boolean;
|
|
63
|
+
};
|
|
64
|
+
emptyState?: {
|
|
65
|
+
/** Default: "What can I help with?" */
|
|
66
|
+
text?: string;
|
|
67
|
+
/** Default: true */
|
|
68
|
+
icon?: boolean;
|
|
69
|
+
/** Custom React node rendered above the empty-state text */
|
|
70
|
+
content?: React__default.ReactNode;
|
|
71
|
+
};
|
|
72
|
+
input?: {
|
|
73
|
+
/** Default: "Type your message..." */
|
|
74
|
+
placeholder?: string;
|
|
75
|
+
/** Default: false */
|
|
76
|
+
showResetButton?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* `true` (default) shows all attachment options, `false` hides the menu entirely.
|
|
79
|
+
* Pass an object to toggle individual options.
|
|
80
|
+
*/
|
|
81
|
+
attachments?: boolean | {
|
|
82
|
+
uploadImage?: boolean;
|
|
83
|
+
attachFile?: boolean;
|
|
84
|
+
};
|
|
85
|
+
/** `true` enables voice with defaults. Pass an object to customize lang/interim/continuous. */
|
|
86
|
+
voice?: boolean | VoiceOptions;
|
|
87
|
+
};
|
|
88
|
+
messages?: {
|
|
89
|
+
/** `true` shows both sides; `false` hides both; pass object for per-role control. */
|
|
90
|
+
avatars?: boolean | {
|
|
91
|
+
user?: boolean;
|
|
92
|
+
assistant?: boolean;
|
|
93
|
+
};
|
|
94
|
+
/** Default: false */
|
|
95
|
+
timestamps?: boolean;
|
|
96
|
+
/** Default: true */
|
|
97
|
+
streamingDot?: boolean;
|
|
98
|
+
actions?: MessageActionsConfig;
|
|
99
|
+
};
|
|
100
|
+
execution?: {
|
|
101
|
+
/** Default: true */
|
|
102
|
+
showSteps?: boolean;
|
|
103
|
+
/** Default: "Completed in {time}s ({count} steps)" */
|
|
104
|
+
completedLabel?: string;
|
|
105
|
+
/** Default: "View progress ({count} steps)" */
|
|
106
|
+
streamingLabel?: string;
|
|
107
|
+
};
|
|
108
|
+
/** `true` enables the session-history sidebar with defaults; pass an object to customize. */
|
|
109
|
+
sessionHistory?: boolean | SessionHistoryOptions;
|
|
110
|
+
};
|
|
111
|
+
type ChatConfig = BaseChatConfig & {
|
|
112
|
+
availability?: ChatAvailability;
|
|
113
|
+
ui?: ChatUIConfig;
|
|
114
|
+
observability?: {
|
|
115
|
+
sentryDsn?: string;
|
|
116
|
+
};
|
|
54
117
|
};
|
|
55
118
|
type ChatCallbacks = ChatCallbacks$1 & {
|
|
56
|
-
/** Called when the session is reset (via SDK reset button or ref.resetSession()) */
|
|
57
119
|
onResetSession?: () => void;
|
|
58
|
-
/** Called when the v2 "Upload image" attachment option is clicked */
|
|
59
120
|
onUploadImageClick?: () => void;
|
|
60
|
-
/** Called when the v2 "Attach file" attachment option is clicked */
|
|
61
121
|
onAttachFileClick?: () => void;
|
|
62
122
|
};
|
|
63
123
|
type PaymanChatRef = {
|
|
64
|
-
/** Clear all messages and reset the session (clears both stores + generates new session ID) */
|
|
65
124
|
resetSession: () => void;
|
|
66
|
-
/** Clear all messages without resetting session ID */
|
|
67
125
|
clearMessages: () => void;
|
|
68
|
-
/** Cancel the current streaming operation */
|
|
69
126
|
cancelStream: () => void;
|
|
70
|
-
/** Get the current session ID */
|
|
71
127
|
getSessionId: () => string | undefined;
|
|
72
|
-
/** Get all messages */
|
|
73
128
|
getMessages: () => MessageDisplay[];
|
|
129
|
+
/** Replace the active chat with a prior session's history. */
|
|
130
|
+
loadSession: (sessionId: string) => Promise<void>;
|
|
74
131
|
};
|
|
75
132
|
type PaymanChatProps = {
|
|
76
|
-
/** Chat configuration - includes API config */
|
|
77
133
|
config: ChatConfig;
|
|
78
|
-
/** Callbacks for events */
|
|
79
134
|
callbacks?: ChatCallbacks;
|
|
80
|
-
/** Custom class name */
|
|
81
135
|
className?: string;
|
|
82
|
-
/** Custom style */
|
|
83
136
|
style?: React__default.CSSProperties;
|
|
84
|
-
/** Custom children to render (e.g., header) */
|
|
85
137
|
children?: React__default.ReactNode;
|
|
86
138
|
/** Called when the user scrolls to the top — use to load older messages */
|
|
87
139
|
onLoadMoreMessages?: () => void;
|
|
88
|
-
/** Show a loading spinner at the top of the list while fetching older messages */
|
|
89
|
-
isLoadingMoreMessages?: boolean;
|
|
90
|
-
/** Whether there are more messages to load (hides the spinner/trigger when false) */
|
|
91
|
-
hasMoreMessages?: boolean;
|
|
92
|
-
};
|
|
93
|
-
type ChatInputProps = {
|
|
94
|
-
/** Input value */
|
|
95
|
-
value: string;
|
|
96
|
-
/** On change handler */
|
|
97
|
-
onChange: (value: string) => void;
|
|
98
|
-
/** On send handler */
|
|
99
|
-
onSend: () => void;
|
|
100
|
-
/** On pause/cancel handler */
|
|
101
|
-
onPause?: () => void;
|
|
102
|
-
/** Disabled state */
|
|
103
|
-
disabled?: boolean;
|
|
104
|
-
/** Placeholder text */
|
|
105
|
-
placeholder?: string;
|
|
106
|
-
/** Is waiting for response */
|
|
107
|
-
isWaitingForResponse?: boolean;
|
|
108
|
-
/** Has selected session */
|
|
109
|
-
hasSelectedSession?: boolean;
|
|
110
|
-
/** Is session params configured */
|
|
111
|
-
isSessionParamsConfigured?: boolean;
|
|
112
|
-
/** On input click handler */
|
|
113
|
-
onClick?: () => void;
|
|
114
|
-
/** Input style variant */
|
|
115
|
-
inputStyle?: "rounded" | "flat";
|
|
116
|
-
/** Layout style */
|
|
117
|
-
layout?: "centered" | "full-width";
|
|
118
|
-
/** Custom class name */
|
|
119
|
-
className?: string;
|
|
120
|
-
/** Enable voice input in the chat input. When false, voice button is hidden. */
|
|
121
|
-
enableVoice?: boolean;
|
|
122
|
-
/** Voice button handler */
|
|
123
|
-
onVoicePress?: () => void;
|
|
124
|
-
/** Is voice available (e.g. speech recognition ready) */
|
|
125
|
-
voiceAvailable?: boolean;
|
|
126
|
-
/** Is currently recording voice */
|
|
127
|
-
isRecording?: boolean;
|
|
128
|
-
/** Recording duration in seconds (for voice bar timer) */
|
|
129
|
-
recordingDurationSeconds?: number;
|
|
130
|
-
/** Confirm voice recording (stop and apply transcript to input) */
|
|
131
|
-
onConfirmRecording?: () => void;
|
|
132
|
-
/** Cancel voice recording (stop without applying transcript) */
|
|
133
|
-
onCancelRecording?: () => void;
|
|
134
|
-
/** Live transcript while recording (used to animate waveforms only when user is talking) */
|
|
135
|
-
transcribedText?: string;
|
|
136
|
-
/** Show a reset/new session button in the input bar */
|
|
137
|
-
showResetSession?: boolean;
|
|
138
|
-
/** Handler called when the reset session button is clicked */
|
|
139
|
-
onResetSession?: () => void;
|
|
140
|
-
/** Show the attachment (+) menu button */
|
|
141
|
-
showAttachmentButton?: boolean;
|
|
142
|
-
/** Show the "Upload image" attachment option */
|
|
143
|
-
showUploadImageButton?: boolean;
|
|
144
|
-
/** Show the "Attach file" attachment option */
|
|
145
|
-
showAttachFileButton?: boolean;
|
|
146
|
-
/** Handler called when the "Upload image" option is clicked */
|
|
147
|
-
onUploadImageClick?: () => void;
|
|
148
|
-
/** Handler called when the "Attach file" option is clicked */
|
|
149
|
-
onAttachFileClick?: () => void;
|
|
150
|
-
/** React Native: called when the text input is focused (e.g. to scroll messages above the keyboard). */
|
|
151
|
-
onInputFocus?: () => void;
|
|
152
|
-
};
|
|
153
|
-
type MessageListProps = {
|
|
154
|
-
/** Messages to display */
|
|
155
|
-
messages: MessageDisplay[];
|
|
156
|
-
/** Loading state */
|
|
157
|
-
isLoading?: boolean;
|
|
158
|
-
/** Empty state text */
|
|
159
|
-
emptyStateText?: string;
|
|
160
|
-
/** Show icon in empty state */
|
|
161
|
-
showEmptyStateIcon?: boolean;
|
|
162
|
-
/** Custom React component to render above the empty state text */
|
|
163
|
-
emptyStateComponent?: React__default.ReactNode;
|
|
164
|
-
/** Layout style */
|
|
165
|
-
layout?: "centered" | "full-width";
|
|
166
|
-
/** Show timestamps on messages */
|
|
167
|
-
showTimestamps?: boolean;
|
|
168
|
-
/** Stage */
|
|
169
|
-
stage?: WorkflowStage;
|
|
170
|
-
/** Animated */
|
|
171
|
-
animated?: boolean;
|
|
172
|
-
/** Show agent name */
|
|
173
|
-
showAgentName?: boolean;
|
|
174
|
-
/** Agent name */
|
|
175
|
-
agentName?: string;
|
|
176
|
-
/** Show avatars */
|
|
177
|
-
showAvatars?: boolean;
|
|
178
|
-
/** Show user avatar only (overrides showAvatars) */
|
|
179
|
-
showUserAvatar?: boolean;
|
|
180
|
-
/** Show assistant avatar only (overrides showAvatars) */
|
|
181
|
-
showAssistantAvatar?: boolean;
|
|
182
|
-
/** Show execution steps */
|
|
183
|
-
showExecutionSteps?: boolean;
|
|
184
|
-
/** Show streaming dot */
|
|
185
|
-
showStreamingDot?: boolean;
|
|
186
|
-
/** Custom streaming steps text */
|
|
187
|
-
streamingStepsText?: string;
|
|
188
|
-
/** Custom completed steps text */
|
|
189
|
-
completedStepsText?: string;
|
|
190
|
-
/** On execution trace click */
|
|
191
|
-
onExecutionTraceClick?: (data: {
|
|
192
|
-
message: MessageDisplay;
|
|
193
|
-
tracingData?: unknown;
|
|
194
|
-
executionId?: string;
|
|
195
|
-
}) => void;
|
|
196
|
-
/** Custom class name */
|
|
197
|
-
className?: string;
|
|
198
|
-
/** Called when the user scrolls to the top — use to load older messages */
|
|
199
|
-
onLoadMoreMessages?: () => void;
|
|
200
|
-
/** Show a loading spinner at the top while fetching older messages */
|
|
201
140
|
isLoadingMoreMessages?: boolean;
|
|
202
|
-
/** Whether there are more messages to load */
|
|
203
141
|
hasMoreMessages?: boolean;
|
|
204
|
-
/** React Native: while true, keep scrolling to the end as layout updates. */
|
|
205
|
-
isWaitingForResponse?: boolean;
|
|
206
|
-
/** React Native: ref to register a no-arg function that scrolls the message list to the end. */
|
|
207
|
-
scrollToEndHandleRef?: React__default.MutableRefObject<(() => void) | null>;
|
|
208
142
|
};
|
|
209
143
|
type MessageListV2Props = {
|
|
210
|
-
/** Messages to display */
|
|
211
144
|
messages: MessageDisplay[];
|
|
212
|
-
/** Whether an assistant response is currently streaming */
|
|
213
145
|
isStreaming?: boolean;
|
|
214
|
-
/**
|
|
146
|
+
/**
|
|
147
|
+
* When true, the messages area shows a centered activity indicator
|
|
148
|
+
* instead of the (empty) message list. Used while the conversation
|
|
149
|
+
* history for a session is being fetched.
|
|
150
|
+
*/
|
|
151
|
+
isLoadingSession?: boolean;
|
|
215
152
|
onEditUserMessage?: (messageId: string) => void;
|
|
216
|
-
/** Retry a user message */
|
|
217
153
|
onRetryUserMessage?: (messageId: string) => void;
|
|
218
|
-
/** Open a markdown image */
|
|
219
154
|
onImageClick?: (src: string, alt: string) => void;
|
|
220
|
-
/** Execution trace click handler */
|
|
221
155
|
onExecutionTraceClick?: (data: {
|
|
222
156
|
message: MessageDisplay;
|
|
223
157
|
tracingData?: unknown;
|
|
224
158
|
executionId?: string;
|
|
225
159
|
}) => void;
|
|
226
|
-
/** Which message actions are visible */
|
|
227
160
|
messageActions?: MessageActionsConfig;
|
|
228
|
-
/** Disable retry/resend actions while the chat is busy */
|
|
229
161
|
retryDisabled?: boolean;
|
|
230
|
-
/** Current user action card */
|
|
231
162
|
userAction?: {
|
|
232
163
|
messageId: string;
|
|
233
164
|
action: {
|
|
@@ -237,211 +168,158 @@ type MessageListV2Props = {
|
|
|
237
168
|
payeeName?: string;
|
|
238
169
|
};
|
|
239
170
|
status: "pending" | "verifying" | "approved" | "rejected" | "error";
|
|
171
|
+
clearOtpTrigger?: number;
|
|
240
172
|
} | null;
|
|
241
|
-
/** Approve a user action */
|
|
242
173
|
onApproveAction?: (messageId: string, otp: string) => Promise<void>;
|
|
243
|
-
/** Reject a user action */
|
|
244
174
|
onRejectAction?: (messageId: string) => Promise<void>;
|
|
245
|
-
/** Resend a user action */
|
|
246
175
|
onResendAction?: (messageId: string) => Promise<void>;
|
|
247
176
|
};
|
|
248
|
-
type MessageRowProps = {
|
|
249
|
-
/** Message to display */
|
|
250
|
-
message: MessageDisplay;
|
|
251
|
-
/** Stage */
|
|
252
|
-
stage?: WorkflowStage;
|
|
253
|
-
/** Animated */
|
|
254
|
-
animated?: boolean;
|
|
255
|
-
/** Show agent name */
|
|
256
|
-
showAgentName?: boolean;
|
|
257
|
-
/** Agent name */
|
|
258
|
-
agentName?: string;
|
|
259
|
-
/** Show avatars */
|
|
260
|
-
showAvatars?: boolean;
|
|
261
|
-
/** Show user avatar only (overrides showAvatars) */
|
|
262
|
-
showUserAvatar?: boolean;
|
|
263
|
-
/** Show assistant avatar only (overrides showAvatars) */
|
|
264
|
-
showAssistantAvatar?: boolean;
|
|
265
|
-
/** Layout style */
|
|
266
|
-
layout?: "centered" | "full-width";
|
|
267
|
-
/** Show timestamps on messages */
|
|
268
|
-
showTimestamps?: boolean;
|
|
269
|
-
/** Show execution steps */
|
|
270
|
-
showExecutionSteps?: boolean;
|
|
271
|
-
/** Show streaming dot */
|
|
272
|
-
showStreamingDot?: boolean;
|
|
273
|
-
/** Custom streaming steps text */
|
|
274
|
-
streamingStepsText?: string;
|
|
275
|
-
/** Custom completed steps text */
|
|
276
|
-
completedStepsText?: string;
|
|
277
|
-
/** On execution trace click */
|
|
278
|
-
onExecutionTraceClick?: (data: {
|
|
279
|
-
message: MessageDisplay;
|
|
280
|
-
tracingData?: unknown;
|
|
281
|
-
executionId?: string;
|
|
282
|
-
}) => void;
|
|
283
|
-
};
|
|
284
|
-
type UserMessageProps = {
|
|
285
|
-
/** Message to display */
|
|
286
|
-
message: MessageDisplay;
|
|
287
|
-
/** Animated */
|
|
288
|
-
animated?: boolean;
|
|
289
|
-
/** Show avatar */
|
|
290
|
-
showAvatar?: boolean;
|
|
291
|
-
};
|
|
292
|
-
type AgentMessageProps = {
|
|
293
|
-
/** Message to display */
|
|
294
|
-
message: MessageDisplay;
|
|
295
|
-
/** Stage */
|
|
296
|
-
stage?: WorkflowStage;
|
|
297
|
-
/** Animated */
|
|
298
|
-
animated?: boolean;
|
|
299
|
-
/** Show agent name */
|
|
300
|
-
showAgentName?: boolean;
|
|
301
|
-
/** Agent name */
|
|
302
|
-
agentName?: string;
|
|
303
|
-
/** Show avatar */
|
|
304
|
-
showAvatar?: boolean;
|
|
305
|
-
/** Layout style */
|
|
306
|
-
layout?: "centered" | "full-width";
|
|
307
|
-
/** Show timestamp */
|
|
308
|
-
showTimestamp?: boolean;
|
|
309
|
-
/** Show execution steps */
|
|
310
|
-
showExecutionSteps?: boolean;
|
|
311
|
-
/** Show streaming dot */
|
|
312
|
-
showStreamingDot?: boolean;
|
|
313
|
-
/** Custom streaming steps text */
|
|
314
|
-
streamingStepsText?: string;
|
|
315
|
-
/** Custom completed steps text */
|
|
316
|
-
completedStepsText?: string;
|
|
317
|
-
/** On execution trace click */
|
|
318
|
-
onExecutionTraceClick?: (data: {
|
|
319
|
-
message: MessageDisplay;
|
|
320
|
-
tracingData?: unknown;
|
|
321
|
-
executionId?: string;
|
|
322
|
-
}) => void;
|
|
323
|
-
};
|
|
324
177
|
type StreamingMessageProps = {
|
|
325
|
-
/** Streaming content */
|
|
326
178
|
content: string;
|
|
327
|
-
/** Is currently streaming */
|
|
328
179
|
isStreaming: boolean;
|
|
329
|
-
/** Current worker */
|
|
330
180
|
currentWorker?: string;
|
|
331
|
-
/** Current message */
|
|
332
181
|
currentMessage?: string;
|
|
333
|
-
/** Stream progress */
|
|
334
182
|
streamProgress: StreamProgress;
|
|
335
|
-
/** "WORKFLOW_FAILED" and "STREAM_NOT_STARTED" show the friendly fallback; HTTP 409 conflicts render the backend message from the error payload. */
|
|
336
183
|
error?: string;
|
|
337
|
-
/** Streaming steps */
|
|
338
184
|
steps?: StreamingStep[];
|
|
339
185
|
};
|
|
340
186
|
type ChatHeaderProps = {
|
|
341
|
-
/** Session ID */
|
|
342
187
|
sessionId?: string;
|
|
343
|
-
/** On copy session ID */
|
|
344
188
|
onCopySessionId?: (sessionId: string) => void;
|
|
345
|
-
/** On load session click */
|
|
346
|
-
onLoadSession?: () => void;
|
|
347
|
-
/** On new session click */
|
|
348
189
|
onNewSession?: () => void;
|
|
349
|
-
/** On session params click */
|
|
350
|
-
onSessionParamsClick?: () => void;
|
|
351
|
-
/** Show load session button */
|
|
352
|
-
showLoadSession?: boolean;
|
|
353
|
-
/** Show reset session button */
|
|
354
190
|
showResetSession?: boolean;
|
|
355
|
-
/**
|
|
356
|
-
|
|
357
|
-
/** Show session params tooltip */
|
|
358
|
-
showSessionParamsTooltip?: boolean;
|
|
359
|
-
/** Session params button ref */
|
|
360
|
-
sessionParamsButtonRef?: React__default.RefObject<HTMLButtonElement | null> | undefined;
|
|
361
|
-
/** Custom children */
|
|
191
|
+
/** Render a hamburger button on the left that toggles the session-history sidebar on mobile. */
|
|
192
|
+
onToggleSidebar?: () => void;
|
|
362
193
|
children?: React__default.ReactNode;
|
|
363
|
-
/** Custom class name */
|
|
364
194
|
className?: string;
|
|
365
195
|
};
|
|
366
196
|
type OtpInputProps = {
|
|
367
|
-
/** Current OTP value */
|
|
368
197
|
value: string;
|
|
369
|
-
/** Called with new OTP value */
|
|
370
198
|
onChange: (value: string) => void;
|
|
371
|
-
/** Number of digit boxes */
|
|
372
199
|
maxLength: number;
|
|
373
|
-
/** Disabled state */
|
|
374
200
|
disabled?: boolean;
|
|
375
|
-
/** Transient error state — triggers red borders + shake */
|
|
376
201
|
error?: boolean;
|
|
377
202
|
};
|
|
378
203
|
type UserActionModalProps = {
|
|
379
|
-
/** Whether the modal is open */
|
|
380
204
|
isOpen: boolean;
|
|
381
|
-
/** User action request data from the stream */
|
|
382
205
|
userActionRequest: UserActionRequest | null;
|
|
383
|
-
/** Submit OTP */
|
|
384
206
|
onApprove: (otp: string) => Promise<void>;
|
|
385
|
-
/** Reject / cancel */
|
|
386
207
|
onReject: () => Promise<void>;
|
|
387
|
-
/** Resend OTP */
|
|
388
208
|
onResend: () => Promise<void>;
|
|
389
|
-
/** Increment to externally clear OTP field */
|
|
390
209
|
clearOtpTrigger: number;
|
|
391
210
|
};
|
|
211
|
+
type Stage = WorkflowStage;
|
|
392
212
|
|
|
393
|
-
declare const PaymanChat: React.ForwardRefExoticComponent<PaymanChatProps & React.RefAttributes<PaymanChatRef>>;
|
|
213
|
+
declare const PaymanChat: React$1.ForwardRefExoticComponent<PaymanChatProps & React$1.RefAttributes<PaymanChatRef>>;
|
|
394
214
|
|
|
395
|
-
|
|
215
|
+
type OptimisticSessionActivity = {
|
|
216
|
+
key: string;
|
|
217
|
+
sessionId: string;
|
|
218
|
+
previousSessionId?: string;
|
|
219
|
+
lastMessageAt: string;
|
|
220
|
+
sessionTitle?: string;
|
|
221
|
+
};
|
|
222
|
+
type SessionHistorySidebarProps = {
|
|
223
|
+
config: BaseChatConfig;
|
|
224
|
+
options: SessionHistoryOptions;
|
|
225
|
+
activeSessionId?: string;
|
|
226
|
+
/** Session id whose conversation history is currently being fetched.
|
|
227
|
+
* The matching row renders a small inline spinner next to its title. */
|
|
228
|
+
loadingSessionId?: string;
|
|
396
229
|
/**
|
|
397
|
-
*
|
|
230
|
+
* Session ids that currently have an in-flight workflow stream. Each
|
|
231
|
+
* matching row renders a subtle running mark on the right of its title.
|
|
398
232
|
*/
|
|
399
|
-
|
|
233
|
+
streamingSessionIds?: ReadonlySet<string>;
|
|
400
234
|
/**
|
|
401
|
-
*
|
|
235
|
+
* Session ids whose stream completed recently. Each matching row briefly
|
|
236
|
+
* renders a check mark on the right of its title — the parent is
|
|
237
|
+
* expected to drop the id from the set after a few seconds so the mark
|
|
238
|
+
* goes away on its own.
|
|
402
239
|
*/
|
|
240
|
+
recentlyCompletedSessionIds?: ReadonlySet<string>;
|
|
241
|
+
optimisticActivity?: OptimisticSessionActivity | null;
|
|
242
|
+
/** Called when the user clicks a row. */
|
|
243
|
+
onSelectSession: (session: SessionSummary) => void;
|
|
244
|
+
/** Controlled mobile drawer open state. */
|
|
245
|
+
mobileOpen: boolean;
|
|
246
|
+
onMobileOpenChange: (open: boolean) => void;
|
|
247
|
+
};
|
|
248
|
+
declare function SessionHistorySidebar({ config, options, activeSessionId, loadingSessionId, streamingSessionIds, recentlyCompletedSessionIds, optimisticActivity, onSelectSession, mobileOpen, onMobileOpenChange, }: SessionHistorySidebarProps): react_jsx_runtime.JSX.Element;
|
|
249
|
+
|
|
250
|
+
declare function ChatHeader({ sessionId, onCopySessionId, onNewSession, showResetSession, onToggleSidebar, children, className, }: ChatHeaderProps): react_jsx_runtime.JSX.Element;
|
|
251
|
+
|
|
252
|
+
declare function UserActionModal({ isOpen, userActionRequest, onApprove, onReject, onResend, clearOtpTrigger, }: UserActionModalProps): react_jsx_runtime.JSX.Element | null;
|
|
253
|
+
|
|
254
|
+
interface FloatingChatProps {
|
|
255
|
+
config: ChatConfig;
|
|
256
|
+
callbacks?: ChatCallbacks;
|
|
257
|
+
buttonPosition?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
258
|
+
buttonSize?: "sm" | "md" | "lg";
|
|
259
|
+
buttonColor?: string;
|
|
260
|
+
buttonIcon?: React.ReactNode;
|
|
261
|
+
buttonIconUrl?: string;
|
|
262
|
+
windowWidth?: string | number;
|
|
263
|
+
windowHeight?: string | number;
|
|
264
|
+
headerTitle?: string;
|
|
265
|
+
headerSubtitle?: string;
|
|
266
|
+
headerAvatar?: string;
|
|
267
|
+
headerColor?: string;
|
|
268
|
+
defaultOpen?: boolean;
|
|
269
|
+
showNotificationBadge?: boolean;
|
|
270
|
+
}
|
|
271
|
+
declare function FloatingChat({ config, callbacks, buttonPosition, buttonSize, buttonColor, buttonIcon, buttonIconUrl, windowWidth, windowHeight, headerTitle, headerSubtitle, headerAvatar, headerColor, defaultOpen, showNotificationBadge, }: FloatingChatProps): react_jsx_runtime.JSX.Element;
|
|
272
|
+
|
|
273
|
+
interface PaymanChatContextValue {
|
|
274
|
+
/** Clear all messages and reset the chat. */
|
|
275
|
+
resetSession: () => void;
|
|
276
|
+
/** Clear all messages without resetting the session id. */
|
|
403
277
|
clearMessages: () => void;
|
|
404
|
-
/**
|
|
405
|
-
* Prepend older messages to the top of the list (e.g. from history pagination)
|
|
406
|
-
*/
|
|
278
|
+
/** Prepend older messages (history pagination). */
|
|
407
279
|
prependMessages: (messages: MessageDisplay[]) => void;
|
|
408
|
-
/**
|
|
409
|
-
* Cancel current streaming operation
|
|
410
|
-
*/
|
|
280
|
+
/** Cancel the active stream. */
|
|
411
281
|
cancelStream: () => void;
|
|
412
|
-
/**
|
|
413
|
-
* Get current session ID
|
|
414
|
-
*/
|
|
282
|
+
/** Current session id, if any. */
|
|
415
283
|
getSessionId: () => string | undefined;
|
|
416
|
-
/**
|
|
417
|
-
* Get all messages
|
|
418
|
-
*/
|
|
284
|
+
/** All current messages. */
|
|
419
285
|
getMessages: () => MessageDisplay[];
|
|
420
286
|
/**
|
|
421
|
-
*
|
|
287
|
+
* Replace the active chat with a prior session's conversation history.
|
|
288
|
+
* Same call the built-in sidebar uses; exposed for advanced consumers.
|
|
422
289
|
*/
|
|
290
|
+
loadSession: (sessionId: string) => Promise<void>;
|
|
291
|
+
/** Whether a stream is currently in flight. */
|
|
423
292
|
isWaitingForResponse: boolean;
|
|
424
293
|
}
|
|
425
|
-
declare const PaymanChatContext: React.Context<PaymanChatContextValue | undefined>;
|
|
294
|
+
declare const PaymanChatContext: React$1.Context<PaymanChatContextValue | undefined>;
|
|
426
295
|
/**
|
|
427
|
-
*
|
|
296
|
+
* Access PaymanChat controls from a child of `<PaymanChat>`.
|
|
428
297
|
*
|
|
429
298
|
* @example
|
|
430
299
|
* ```tsx
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
* return (
|
|
435
|
-
* <>
|
|
436
|
-
* <button onClick={chat.resetSession}>Reset</button>
|
|
437
|
-
* <button onClick={chat.clearMessages}>Clear</button>
|
|
438
|
-
* </>
|
|
439
|
-
* );
|
|
440
|
-
* }
|
|
300
|
+
* const chat = usePaymanChat();
|
|
301
|
+
* chat.loadSession(sessionId);
|
|
441
302
|
* ```
|
|
442
303
|
*/
|
|
443
304
|
declare function usePaymanChat(): PaymanChatContextValue;
|
|
444
305
|
|
|
306
|
+
type UseSessionHistoryReturn = {
|
|
307
|
+
sessions: SessionSummary[];
|
|
308
|
+
isLoading: boolean;
|
|
309
|
+
error: Error | null;
|
|
310
|
+
hasNext: boolean;
|
|
311
|
+
loadMore: () => Promise<void>;
|
|
312
|
+
refresh: () => Promise<void>;
|
|
313
|
+
width: number;
|
|
314
|
+
setWidth: (px: number) => void;
|
|
315
|
+
collapsed: boolean;
|
|
316
|
+
setCollapsed: (value: boolean | ((prev: boolean) => boolean)) => void;
|
|
317
|
+
minWidth: number;
|
|
318
|
+
maxWidth: number;
|
|
319
|
+
isReady: boolean;
|
|
320
|
+
};
|
|
321
|
+
declare function useSessionHistory(config: BaseChatConfig, options?: SessionHistoryOptions, optimisticActivity?: OptimisticSessionActivity | null): UseSessionHistoryReturn;
|
|
322
|
+
|
|
445
323
|
/**
|
|
446
324
|
* Utility function to merge Tailwind CSS classes
|
|
447
325
|
*/
|
|
@@ -471,4 +349,12 @@ interface ChatSessionContext {
|
|
|
471
349
|
*/
|
|
472
350
|
declare function captureSentryError(error: Error | string, context: ChatSessionContext): void;
|
|
473
351
|
|
|
474
|
-
|
|
352
|
+
/**
|
|
353
|
+
* Format an ISO timestamp as a human-friendly relative label:
|
|
354
|
+
* "just now" / "Nm ago" / "Nh ago" / "Yesterday" / "<day>" (this week) / "Mon D" / "Mon D, YYYY"
|
|
355
|
+
*
|
|
356
|
+
* No dayjs / date-fns — deliberately ~0 bytes extra.
|
|
357
|
+
*/
|
|
358
|
+
declare function formatRelativeTime(iso: string, now?: Date): string;
|
|
359
|
+
|
|
360
|
+
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 };
|