@paymanai/payman-ask-sdk 1.2.13 → 1.2.15
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 +16 -5
- package/dist/index.d.ts +16 -5
- package/dist/index.js +30 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -22
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +1 -12
- package/dist/index.native.js.map +1 -1
- package/dist/styles.css +6 -0
- package/dist/styles.css.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { UserActionResult, UserActionRequest } from '@paymanai/payman-typescript-ask-sdk';
|
|
3
|
-
export { StreamEvent, StreamOptions, UseVoiceReturn, UserActionRequest, UserActionResult, UserActionState, VoiceCallbacks, VoiceConfig, VoicePermissions, VoiceState, cancelUserAction, generateId, resendUserAction, streamWorkflowEvents, submitUserAction, useChat, useVoice } from '@paymanai/payman-typescript-ask-sdk';
|
|
4
1
|
import * as React from 'react';
|
|
5
2
|
import React__default from 'react';
|
|
3
|
+
import { UserActionResult, UserActionRequest } from '@paymanai/payman-typescript-ask-sdk';
|
|
4
|
+
export { StreamEvent, StreamOptions, UseVoiceReturn, UserActionRequest, UserActionResult, UserActionState, VoiceCallbacks, VoiceConfig, VoicePermissions, VoiceState, cancelUserAction, generateId, resendUserAction, streamWorkflowEvents, submitUserAction, useChat, useVoice } from '@paymanai/payman-typescript-ask-sdk';
|
|
6
5
|
import { ClassValue } from 'clsx';
|
|
7
6
|
|
|
8
7
|
type MessageRole = "user" | "assistant" | "system";
|
|
@@ -154,6 +153,18 @@ type ChatCallbacks = {
|
|
|
154
153
|
/** Called on user action events (SUCCESS, INVALID, EXPIRED, REJECTED, RESENT, FAILED) */
|
|
155
154
|
onUserActionEvent?: (eventType: string, message: string) => void;
|
|
156
155
|
};
|
|
156
|
+
type PaymanChatRef = {
|
|
157
|
+
/** Clear all messages and reset the session (clears both stores + generates new session ID) */
|
|
158
|
+
resetSession: () => void;
|
|
159
|
+
/** Clear all messages without resetting session ID */
|
|
160
|
+
clearMessages: () => void;
|
|
161
|
+
/** Cancel the current streaming operation */
|
|
162
|
+
cancelStream: () => void;
|
|
163
|
+
/** Get the current session ID */
|
|
164
|
+
getSessionId: () => string | undefined;
|
|
165
|
+
/** Get all messages */
|
|
166
|
+
getMessages: () => MessageDisplay[];
|
|
167
|
+
};
|
|
157
168
|
type PaymanChatProps = {
|
|
158
169
|
/** Chat configuration - includes API config */
|
|
159
170
|
config: ChatConfig;
|
|
@@ -409,7 +420,7 @@ type UserActionModalProps = {
|
|
|
409
420
|
clearOtpTrigger: number;
|
|
410
421
|
};
|
|
411
422
|
|
|
412
|
-
declare
|
|
423
|
+
declare const PaymanChat: React.ForwardRefExoticComponent<PaymanChatProps & React.RefAttributes<PaymanChatRef>>;
|
|
413
424
|
|
|
414
425
|
interface PaymanChatContextValue {
|
|
415
426
|
/**
|
|
@@ -471,4 +482,4 @@ declare function cn(...inputs: ClassValue[]): string;
|
|
|
471
482
|
*/
|
|
472
483
|
declare function formatDate(timestamp: string | Date): string;
|
|
473
484
|
|
|
474
|
-
export { type APIConfig, type AgentMessageProps, type ChatCallbacks, type ChatConfig, type ChatHeaderProps, type ChatInputProps, type ChunkDisplay, type MessageDisplay, type MessageListProps, type MessageRole, type MessageRowProps, type OtpInputProps, PaymanChat, PaymanChatContext, type PaymanChatContextValue, type PaymanChatProps, type SessionParams, type StreamProgress, type StreamingMessageProps, type StreamingStep, type UserActionModalProps, type UserMessageProps, type WorkflowStage, cn, formatDate, usePaymanChat };
|
|
485
|
+
export { type APIConfig, type AgentMessageProps, type ChatCallbacks, type ChatConfig, type ChatHeaderProps, type ChatInputProps, type ChunkDisplay, type MessageDisplay, type MessageListProps, type MessageRole, type MessageRowProps, type OtpInputProps, PaymanChat, PaymanChatContext, type PaymanChatContextValue, type PaymanChatProps, type PaymanChatRef, type SessionParams, type StreamProgress, type StreamingMessageProps, type StreamingStep, type UserActionModalProps, type UserMessageProps, type WorkflowStage, cn, formatDate, usePaymanChat };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { UserActionResult, UserActionRequest } from '@paymanai/payman-typescript-ask-sdk';
|
|
3
|
-
export { StreamEvent, StreamOptions, UseVoiceReturn, UserActionRequest, UserActionResult, UserActionState, VoiceCallbacks, VoiceConfig, VoicePermissions, VoiceState, cancelUserAction, generateId, resendUserAction, streamWorkflowEvents, submitUserAction, useChat, useVoice } from '@paymanai/payman-typescript-ask-sdk';
|
|
4
1
|
import * as React from 'react';
|
|
5
2
|
import React__default from 'react';
|
|
3
|
+
import { UserActionResult, UserActionRequest } from '@paymanai/payman-typescript-ask-sdk';
|
|
4
|
+
export { StreamEvent, StreamOptions, UseVoiceReturn, UserActionRequest, UserActionResult, UserActionState, VoiceCallbacks, VoiceConfig, VoicePermissions, VoiceState, cancelUserAction, generateId, resendUserAction, streamWorkflowEvents, submitUserAction, useChat, useVoice } from '@paymanai/payman-typescript-ask-sdk';
|
|
6
5
|
import { ClassValue } from 'clsx';
|
|
7
6
|
|
|
8
7
|
type MessageRole = "user" | "assistant" | "system";
|
|
@@ -154,6 +153,18 @@ type ChatCallbacks = {
|
|
|
154
153
|
/** Called on user action events (SUCCESS, INVALID, EXPIRED, REJECTED, RESENT, FAILED) */
|
|
155
154
|
onUserActionEvent?: (eventType: string, message: string) => void;
|
|
156
155
|
};
|
|
156
|
+
type PaymanChatRef = {
|
|
157
|
+
/** Clear all messages and reset the session (clears both stores + generates new session ID) */
|
|
158
|
+
resetSession: () => void;
|
|
159
|
+
/** Clear all messages without resetting session ID */
|
|
160
|
+
clearMessages: () => void;
|
|
161
|
+
/** Cancel the current streaming operation */
|
|
162
|
+
cancelStream: () => void;
|
|
163
|
+
/** Get the current session ID */
|
|
164
|
+
getSessionId: () => string | undefined;
|
|
165
|
+
/** Get all messages */
|
|
166
|
+
getMessages: () => MessageDisplay[];
|
|
167
|
+
};
|
|
157
168
|
type PaymanChatProps = {
|
|
158
169
|
/** Chat configuration - includes API config */
|
|
159
170
|
config: ChatConfig;
|
|
@@ -409,7 +420,7 @@ type UserActionModalProps = {
|
|
|
409
420
|
clearOtpTrigger: number;
|
|
410
421
|
};
|
|
411
422
|
|
|
412
|
-
declare
|
|
423
|
+
declare const PaymanChat: React.ForwardRefExoticComponent<PaymanChatProps & React.RefAttributes<PaymanChatRef>>;
|
|
413
424
|
|
|
414
425
|
interface PaymanChatContextValue {
|
|
415
426
|
/**
|
|
@@ -471,4 +482,4 @@ declare function cn(...inputs: ClassValue[]): string;
|
|
|
471
482
|
*/
|
|
472
483
|
declare function formatDate(timestamp: string | Date): string;
|
|
473
484
|
|
|
474
|
-
export { type APIConfig, type AgentMessageProps, type ChatCallbacks, type ChatConfig, type ChatHeaderProps, type ChatInputProps, type ChunkDisplay, type MessageDisplay, type MessageListProps, type MessageRole, type MessageRowProps, type OtpInputProps, PaymanChat, PaymanChatContext, type PaymanChatContextValue, type PaymanChatProps, type SessionParams, type StreamProgress, type StreamingMessageProps, type StreamingStep, type UserActionModalProps, type UserMessageProps, type WorkflowStage, cn, formatDate, usePaymanChat };
|
|
485
|
+
export { type APIConfig, type AgentMessageProps, type ChatCallbacks, type ChatConfig, type ChatHeaderProps, type ChatInputProps, type ChunkDisplay, type MessageDisplay, type MessageListProps, type MessageRole, type MessageRowProps, type OtpInputProps, PaymanChat, PaymanChatContext, type PaymanChatContextValue, type PaymanChatProps, type PaymanChatRef, type SessionParams, type StreamProgress, type StreamingMessageProps, type StreamingStep, type UserActionModalProps, type UserMessageProps, type WorkflowStage, cn, formatDate, usePaymanChat };
|
package/dist/index.js
CHANGED
|
@@ -76,6 +76,8 @@ function ChatInput({
|
|
|
76
76
|
isRecording = false
|
|
77
77
|
}) {
|
|
78
78
|
const textareaRef = react.useRef(null);
|
|
79
|
+
const containerRef = react.useRef(null);
|
|
80
|
+
const prevWaitingRef = react.useRef(isWaitingForResponse);
|
|
79
81
|
react.useEffect(() => {
|
|
80
82
|
if (textareaRef.current) {
|
|
81
83
|
textareaRef.current.style.height = "auto";
|
|
@@ -87,6 +89,21 @@ function ChatInput({
|
|
|
87
89
|
)}px`;
|
|
88
90
|
}
|
|
89
91
|
}, [value]);
|
|
92
|
+
react.useEffect(() => {
|
|
93
|
+
requestAnimationFrame(() => {
|
|
94
|
+
textareaRef.current?.focus();
|
|
95
|
+
});
|
|
96
|
+
}, []);
|
|
97
|
+
react.useEffect(() => {
|
|
98
|
+
const wasWaiting = prevWaitingRef.current;
|
|
99
|
+
prevWaitingRef.current = isWaitingForResponse;
|
|
100
|
+
if (wasWaiting && !isWaitingForResponse) {
|
|
101
|
+
requestAnimationFrame(() => {
|
|
102
|
+
textareaRef.current?.focus();
|
|
103
|
+
containerRef.current?.scrollIntoView({ block: "end", behavior: "smooth" });
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}, [isWaitingForResponse]);
|
|
90
107
|
const handleKeyDown = (e) => {
|
|
91
108
|
if (e.key === "Enter" && !e.shiftKey) {
|
|
92
109
|
e.preventDefault();
|
|
@@ -94,7 +111,6 @@ function ChatInput({
|
|
|
94
111
|
}
|
|
95
112
|
};
|
|
96
113
|
const isInputDisabled = disabled || isWaitingForResponse;
|
|
97
|
-
const showPauseButton = isWaitingForResponse && onPause;
|
|
98
114
|
const showVoiceButton = enableVoice && onVoicePress != null;
|
|
99
115
|
const isVoiceButtonDisabled = isWaitingForResponse || !voiceAvailable || !isSessionParamsConfigured;
|
|
100
116
|
const canSend = !isInputDisabled && !!value.trim();
|
|
@@ -106,6 +122,7 @@ function ChatInput({
|
|
|
106
122
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
107
123
|
"div",
|
|
108
124
|
{
|
|
125
|
+
ref: containerRef,
|
|
109
126
|
className: cn("flex-shrink-0 w-full", className),
|
|
110
127
|
style: { flexShrink: 0 },
|
|
111
128
|
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 pb-3 pt-1.5 w-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative w-full max-w-2xl mx-auto", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -175,22 +192,7 @@ function ChatInput({
|
|
|
175
192
|
]
|
|
176
193
|
}
|
|
177
194
|
),
|
|
178
|
-
|
|
179
|
-
"button",
|
|
180
|
-
{
|
|
181
|
-
type: "button",
|
|
182
|
-
onClick: onPause,
|
|
183
|
-
className: cn(
|
|
184
|
-
"flex items-center justify-center",
|
|
185
|
-
"w-8 h-8 rounded-full",
|
|
186
|
-
"payman-chat-input-btn-pause",
|
|
187
|
-
"hover:opacity-90 active:scale-95",
|
|
188
|
-
"transition-all duration-150"
|
|
189
|
-
),
|
|
190
|
-
"aria-label": "Stop response",
|
|
191
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Square, { className: "w-3.5 h-3.5", fill: "currentColor" })
|
|
192
|
-
}
|
|
193
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
195
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
194
196
|
"button",
|
|
195
197
|
{
|
|
196
198
|
type: "button",
|
|
@@ -617,7 +619,7 @@ function markdownComponents(_isError) {
|
|
|
617
619
|
tbody: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "[&_tr:last-child]:border-0", children }),
|
|
618
620
|
tr: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "border-b transition-colors payman-agent-tr", children }),
|
|
619
621
|
th: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("th", { className: "h-10 px-3 text-left align-middle font-medium whitespace-nowrap text-xs", children }),
|
|
620
|
-
td: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("td", { className: "p-3 align-middle text-sm", children })
|
|
622
|
+
td: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("td", { className: "p-3 align-middle text-sm whitespace-nowrap", children })
|
|
621
623
|
};
|
|
622
624
|
}
|
|
623
625
|
function UserMessage({
|
|
@@ -1449,7 +1451,7 @@ var DEFAULT_USER_ACTION_STATE = {
|
|
|
1449
1451
|
};
|
|
1450
1452
|
var NOOP_ASYNC = async () => {
|
|
1451
1453
|
};
|
|
1452
|
-
|
|
1454
|
+
var PaymanChat = react.forwardRef(function PaymanChat2({
|
|
1453
1455
|
config,
|
|
1454
1456
|
callbacks = {},
|
|
1455
1457
|
className,
|
|
@@ -1458,7 +1460,7 @@ function PaymanChat({
|
|
|
1458
1460
|
onLoadMoreMessages,
|
|
1459
1461
|
isLoadingMoreMessages = false,
|
|
1460
1462
|
hasMoreMessages = false
|
|
1461
|
-
}) {
|
|
1463
|
+
}, ref) {
|
|
1462
1464
|
const [inputValue, setInputValue] = react.useState("");
|
|
1463
1465
|
const prevInputValueRef = react.useRef(inputValue);
|
|
1464
1466
|
const chat = paymanTypescriptAskSdk.useChat(config, callbacks);
|
|
@@ -1521,6 +1523,13 @@ function PaymanChat({
|
|
|
1521
1523
|
isWaitingForResponse
|
|
1522
1524
|
]
|
|
1523
1525
|
);
|
|
1526
|
+
react.useImperativeHandle(ref, () => ({
|
|
1527
|
+
resetSession,
|
|
1528
|
+
clearMessages,
|
|
1529
|
+
cancelStream,
|
|
1530
|
+
getSessionId,
|
|
1531
|
+
getMessages
|
|
1532
|
+
}), [resetSession, clearMessages, cancelStream, getSessionId, getMessages]);
|
|
1524
1533
|
const { onExecutionTraceClick } = callbacks;
|
|
1525
1534
|
const {
|
|
1526
1535
|
placeholder = "Type your message...",
|
|
@@ -1672,7 +1681,7 @@ function PaymanChat({
|
|
|
1672
1681
|
]
|
|
1673
1682
|
}
|
|
1674
1683
|
) });
|
|
1675
|
-
}
|
|
1684
|
+
});
|
|
1676
1685
|
|
|
1677
1686
|
Object.defineProperty(exports, "cancelUserAction", {
|
|
1678
1687
|
enumerable: true,
|