@paymanai/payman-ask-sdk 1.2.26 → 2.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 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 { MessageDisplay, WorkflowStage, ChatCallbacks as ChatCallbacks$1, ChatConfig as ChatConfig$1, StreamProgress, StreamingStep, UserActionRequest } from '@paymanai/payman-typescript-ask-sdk';
4
- export { APIConfig, ChunkDisplay, MessageDisplay, MessageRole, SessionParams, StreamEvent, StreamOptions, StreamProgress, StreamingStep, UseChatReturn, UseChatV2Return, UseVoiceReturn, UserActionRequest, UserActionResult, UserActionState, UserActionType, V2EventProcessorState, VoiceCallbacks, VoiceConfig, VoicePermissions, VoiceResult, VoiceState, WorkflowStage, buildFormattedThinking, cancelUserAction, createInitialV2State, generateId, processStreamEventV2, resendUserAction, streamWorkflowEvents, submitUserAction, useChat, useChatV2, useVoice } from '@paymanai/payman-typescript-ask-sdk';
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 ChatConfig = ChatConfig$1 & {
26
- /** Custom React component to render above the empty state text (e.g. logo, illustration). */
27
- emptyStateComponent?: React__default.ReactNode;
28
- /** Enable voice input (default: true) */
29
- enableVoice?: boolean;
30
- /** Voice language (default: "en-US") */
31
- voiceLang?: string;
32
- /** Voice interim results (default: true) */
33
- voiceInterimResults?: boolean;
34
- /** Voice continuous mode (default: true) */
35
- voiceContinuous?: boolean;
36
- /** Show a "New Session" reset button inside the input bar (default: false) */
37
- showResetSession?: boolean;
38
- /** Show the v2 attachment (+) menu button in the input bar (default: true) */
39
- showAttachmentButton?: boolean;
40
- /** Show the v2 "Upload image" attachment option (default: true) */
41
- showUploadImageButton?: boolean;
42
- /** Show the v2 "Attach file" attachment option (default: true) */
43
- showAttachFileButton?: boolean;
44
- /** Configure which per-message actions are visible in the v2 UI */
45
- messageActions?: MessageActionsConfig;
46
- /** Sentry DSN for error monitoring. */
47
- sentryDsn?: string;
48
- /**
49
- * UI version to render.
50
- * 1 = original component set
51
- * 2 = redesigned chat UI (ChatGPT-style with thinking blocks, inline verification, etc.) — default
52
- */
53
- uiVersion?: 1 | 2;
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
- /** Edit a user message */
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: {
@@ -238,210 +169,156 @@ type MessageListV2Props = {
238
169
  };
239
170
  status: "pending" | "verifying" | "approved" | "rejected" | "error";
240
171
  } | null;
241
- /** Approve a user action */
242
172
  onApproveAction?: (messageId: string, otp: string) => Promise<void>;
243
- /** Reject a user action */
244
173
  onRejectAction?: (messageId: string) => Promise<void>;
245
- /** Resend a user action */
246
174
  onResendAction?: (messageId: string) => Promise<void>;
247
175
  };
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
176
  type StreamingMessageProps = {
325
- /** Streaming content */
326
177
  content: string;
327
- /** Is currently streaming */
328
178
  isStreaming: boolean;
329
- /** Current worker */
330
179
  currentWorker?: string;
331
- /** Current message */
332
180
  currentMessage?: string;
333
- /** Stream progress */
334
181
  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
182
  error?: string;
337
- /** Streaming steps */
338
183
  steps?: StreamingStep[];
339
184
  };
340
185
  type ChatHeaderProps = {
341
- /** Session ID */
342
186
  sessionId?: string;
343
- /** On copy session ID */
344
187
  onCopySessionId?: (sessionId: string) => void;
345
- /** On load session click */
346
- onLoadSession?: () => void;
347
- /** On new session click */
348
188
  onNewSession?: () => void;
349
- /** On session params click */
350
- onSessionParamsClick?: () => void;
351
- /** Show load session button */
352
- showLoadSession?: boolean;
353
- /** Show reset session button */
354
189
  showResetSession?: boolean;
355
- /** Show session params button */
356
- showSessionParams?: boolean;
357
- /** Show session params tooltip */
358
- showSessionParamsTooltip?: boolean;
359
- /** Session params button ref */
360
- sessionParamsButtonRef?: React__default.RefObject<HTMLButtonElement | null> | undefined;
361
- /** Custom children */
190
+ /** Render a hamburger button on the left that toggles the session-history sidebar on mobile. */
191
+ onToggleSidebar?: () => void;
362
192
  children?: React__default.ReactNode;
363
- /** Custom class name */
364
193
  className?: string;
365
194
  };
366
195
  type OtpInputProps = {
367
- /** Current OTP value */
368
196
  value: string;
369
- /** Called with new OTP value */
370
197
  onChange: (value: string) => void;
371
- /** Number of digit boxes */
372
198
  maxLength: number;
373
- /** Disabled state */
374
199
  disabled?: boolean;
375
- /** Transient error state — triggers red borders + shake */
376
200
  error?: boolean;
377
201
  };
378
202
  type UserActionModalProps = {
379
- /** Whether the modal is open */
380
203
  isOpen: boolean;
381
- /** User action request data from the stream */
382
204
  userActionRequest: UserActionRequest | null;
383
- /** Submit OTP */
384
205
  onApprove: (otp: string) => Promise<void>;
385
- /** Reject / cancel */
386
206
  onReject: () => Promise<void>;
387
- /** Resend OTP */
388
207
  onResend: () => Promise<void>;
389
- /** Increment to externally clear OTP field */
390
208
  clearOtpTrigger: number;
391
209
  };
210
+ type Stage = WorkflowStage;
392
211
 
393
- declare const PaymanChat: React.ForwardRefExoticComponent<PaymanChatProps & React.RefAttributes<PaymanChatRef>>;
212
+ declare const PaymanChat: React$1.ForwardRefExoticComponent<PaymanChatProps & React$1.RefAttributes<PaymanChatRef>>;
394
213
 
395
- interface PaymanChatContextValue {
214
+ type OptimisticSessionActivity = {
215
+ key: string;
216
+ sessionId: string;
217
+ previousSessionId?: string;
218
+ lastMessageAt: string;
219
+ sessionTitle?: string;
220
+ };
221
+ type SessionHistorySidebarProps = {
222
+ config: BaseChatConfig;
223
+ options: SessionHistoryOptions;
224
+ activeSessionId?: string;
225
+ /** Session id whose conversation history is currently being fetched.
226
+ * The matching row renders a small inline spinner next to its title. */
227
+ loadingSessionId?: string;
396
228
  /**
397
- * Clear all messages and reset the chat
229
+ * Session ids that currently have an in-flight workflow stream. Each
230
+ * matching row renders a subtle running mark on the right of its title.
398
231
  */
399
- resetSession: () => void;
232
+ streamingSessionIds?: ReadonlySet<string>;
400
233
  /**
401
- * Clear all messages without resetting session ID
234
+ * Session ids whose stream completed recently. Each matching row briefly
235
+ * renders a check mark on the right of its title — the parent is
236
+ * expected to drop the id from the set after a few seconds so the mark
237
+ * goes away on its own.
402
238
  */
239
+ recentlyCompletedSessionIds?: ReadonlySet<string>;
240
+ optimisticActivity?: OptimisticSessionActivity | null;
241
+ /** Called when the user clicks a row. */
242
+ onSelectSession: (session: SessionSummary) => void;
243
+ /** Controlled mobile drawer open state. */
244
+ mobileOpen: boolean;
245
+ onMobileOpenChange: (open: boolean) => void;
246
+ };
247
+ declare function SessionHistorySidebar({ config, options, activeSessionId, loadingSessionId, streamingSessionIds, recentlyCompletedSessionIds, optimisticActivity, onSelectSession, mobileOpen, onMobileOpenChange, }: SessionHistorySidebarProps): react_jsx_runtime.JSX.Element;
248
+
249
+ declare function ChatHeader({ sessionId, onCopySessionId, onNewSession, showResetSession, onToggleSidebar, children, className, }: ChatHeaderProps): react_jsx_runtime.JSX.Element;
250
+
251
+ declare function UserActionModal({ isOpen, userActionRequest, onApprove, onReject, onResend, clearOtpTrigger, }: UserActionModalProps): react_jsx_runtime.JSX.Element | null;
252
+
253
+ interface FloatingChatProps {
254
+ config: ChatConfig;
255
+ callbacks?: ChatCallbacks;
256
+ buttonPosition?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
257
+ buttonSize?: "sm" | "md" | "lg";
258
+ buttonColor?: string;
259
+ buttonIcon?: React.ReactNode;
260
+ buttonIconUrl?: string;
261
+ windowWidth?: string | number;
262
+ windowHeight?: string | number;
263
+ headerTitle?: string;
264
+ headerSubtitle?: string;
265
+ headerAvatar?: string;
266
+ headerColor?: string;
267
+ defaultOpen?: boolean;
268
+ showNotificationBadge?: boolean;
269
+ }
270
+ declare function FloatingChat({ config, callbacks, buttonPosition, buttonSize, buttonColor, buttonIcon, buttonIconUrl, windowWidth, windowHeight, headerTitle, headerSubtitle, headerAvatar, headerColor, defaultOpen, showNotificationBadge, }: FloatingChatProps): react_jsx_runtime.JSX.Element;
271
+
272
+ interface PaymanChatContextValue {
273
+ /** Clear all messages and reset the chat. */
274
+ resetSession: () => void;
275
+ /** Clear all messages without resetting the session id. */
403
276
  clearMessages: () => void;
404
- /**
405
- * Prepend older messages to the top of the list (e.g. from history pagination)
406
- */
277
+ /** Prepend older messages (history pagination). */
407
278
  prependMessages: (messages: MessageDisplay[]) => void;
408
- /**
409
- * Cancel current streaming operation
410
- */
279
+ /** Cancel the active stream. */
411
280
  cancelStream: () => void;
412
- /**
413
- * Get current session ID
414
- */
281
+ /** Current session id, if any. */
415
282
  getSessionId: () => string | undefined;
416
- /**
417
- * Get all messages
418
- */
283
+ /** All current messages. */
419
284
  getMessages: () => MessageDisplay[];
420
285
  /**
421
- * Check if currently waiting for response
286
+ * Replace the active chat with a prior session's conversation history.
287
+ * Same call the built-in sidebar uses; exposed for advanced consumers.
422
288
  */
289
+ loadSession: (sessionId: string) => Promise<void>;
290
+ /** Whether a stream is currently in flight. */
423
291
  isWaitingForResponse: boolean;
424
292
  }
425
- declare const PaymanChatContext: React.Context<PaymanChatContextValue | undefined>;
293
+ declare const PaymanChatContext: React$1.Context<PaymanChatContextValue | undefined>;
426
294
  /**
427
- * Hook to access PaymanChat controls from parent components
295
+ * Access PaymanChat controls from a child of `<PaymanChat>`.
428
296
  *
429
297
  * @example
430
298
  * ```tsx
431
- * function MyComponent() {
432
- * const chat = usePaymanChat();
433
- *
434
- * return (
435
- * <>
436
- * <button onClick={chat.resetSession}>Reset</button>
437
- * <button onClick={chat.clearMessages}>Clear</button>
438
- * </>
439
- * );
440
- * }
299
+ * const chat = usePaymanChat();
300
+ * chat.loadSession(sessionId);
441
301
  * ```
442
302
  */
443
303
  declare function usePaymanChat(): PaymanChatContextValue;
444
304
 
305
+ type UseSessionHistoryReturn = {
306
+ sessions: SessionSummary[];
307
+ isLoading: boolean;
308
+ error: Error | null;
309
+ hasNext: boolean;
310
+ loadMore: () => Promise<void>;
311
+ refresh: () => Promise<void>;
312
+ width: number;
313
+ setWidth: (px: number) => void;
314
+ collapsed: boolean;
315
+ setCollapsed: (value: boolean | ((prev: boolean) => boolean)) => void;
316
+ minWidth: number;
317
+ maxWidth: number;
318
+ isReady: boolean;
319
+ };
320
+ declare function useSessionHistory(config: BaseChatConfig, options?: SessionHistoryOptions, optimisticActivity?: OptimisticSessionActivity | null): UseSessionHistoryReturn;
321
+
445
322
  /**
446
323
  * Utility function to merge Tailwind CSS classes
447
324
  */
@@ -471,4 +348,12 @@ interface ChatSessionContext {
471
348
  */
472
349
  declare function captureSentryError(error: Error | string, context: ChatSessionContext): void;
473
350
 
474
- 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 };
351
+ /**
352
+ * Format an ISO timestamp as a human-friendly relative label:
353
+ * "just now" / "Nm ago" / "Nh ago" / "Yesterday" / "<day>" (this week) / "Mon D" / "Mon D, YYYY"
354
+ *
355
+ * No dayjs / date-fns — deliberately ~0 bytes extra.
356
+ */
357
+ declare function formatRelativeTime(iso: string, now?: Date): string;
358
+
359
+ 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 };