@paymanai/payman-ask-sdk 1.2.20 → 1.2.22

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
@@ -138,6 +138,12 @@ type ChatConfig = {
138
138
  voiceContinuous?: boolean;
139
139
  /** Show a "New Session" reset button inside the input bar (default: false) */
140
140
  showResetSession?: boolean;
141
+ /**
142
+ * Sentry DSN for error monitoring.
143
+ * The library will initialise Sentry with this DSN if Sentry has not already
144
+ * been initialised by the host application.
145
+ */
146
+ sentryDsn?: string;
141
147
  };
142
148
  type ChatCallbacks = {
143
149
  /** Called when a message is sent (before API call) */
@@ -240,6 +246,8 @@ type ChatInputProps = {
240
246
  showResetSession?: boolean;
241
247
  /** Handler called when the reset session button is clicked */
242
248
  onResetSession?: () => void;
249
+ /** React Native: called when the text input is focused (e.g. to scroll messages above the keyboard). */
250
+ onInputFocus?: () => void;
243
251
  };
244
252
  type MessageListProps = {
245
253
  /** Messages to display */
@@ -292,6 +300,15 @@ type MessageListProps = {
292
300
  isLoadingMoreMessages?: boolean;
293
301
  /** Whether there are more messages to load */
294
302
  hasMoreMessages?: boolean;
303
+ /**
304
+ * React Native: while true, keep scrolling to the end as layout updates (waiting for assistant reply).
305
+ */
306
+ isWaitingForResponse?: boolean;
307
+ /**
308
+ * React Native: ref to register a no-arg function that scrolls the message list to the end.
309
+ * Used so the parent can scroll when the input is focused and the keyboard opens.
310
+ */
311
+ scrollToEndHandleRef?: React__default.MutableRefObject<(() => void) | null>;
295
312
  };
296
313
  type MessageRowProps = {
297
314
  /** Message to display */
package/dist/index.d.ts CHANGED
@@ -138,6 +138,12 @@ type ChatConfig = {
138
138
  voiceContinuous?: boolean;
139
139
  /** Show a "New Session" reset button inside the input bar (default: false) */
140
140
  showResetSession?: boolean;
141
+ /**
142
+ * Sentry DSN for error monitoring.
143
+ * The library will initialise Sentry with this DSN if Sentry has not already
144
+ * been initialised by the host application.
145
+ */
146
+ sentryDsn?: string;
141
147
  };
142
148
  type ChatCallbacks = {
143
149
  /** Called when a message is sent (before API call) */
@@ -240,6 +246,8 @@ type ChatInputProps = {
240
246
  showResetSession?: boolean;
241
247
  /** Handler called when the reset session button is clicked */
242
248
  onResetSession?: () => void;
249
+ /** React Native: called when the text input is focused (e.g. to scroll messages above the keyboard). */
250
+ onInputFocus?: () => void;
243
251
  };
244
252
  type MessageListProps = {
245
253
  /** Messages to display */
@@ -292,6 +300,15 @@ type MessageListProps = {
292
300
  isLoadingMoreMessages?: boolean;
293
301
  /** Whether there are more messages to load */
294
302
  hasMoreMessages?: boolean;
303
+ /**
304
+ * React Native: while true, keep scrolling to the end as layout updates (waiting for assistant reply).
305
+ */
306
+ isWaitingForResponse?: boolean;
307
+ /**
308
+ * React Native: ref to register a no-arg function that scrolls the message list to the end.
309
+ * Used so the parent can scroll when the input is focused and the keyboard opens.
310
+ */
311
+ scrollToEndHandleRef?: React__default.MutableRefObject<(() => void) | null>;
295
312
  };
296
313
  type MessageRowProps = {
297
314
  /** Message to display */
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ var framerMotion = require('framer-motion');
5
5
  var react = require('react');
6
6
  var clsx = require('clsx');
7
7
  var tailwindMerge = require('tailwind-merge');
8
+ var Sentry = require('@sentry/react');
8
9
  var lucideReact = require('lucide-react');
9
10
  var jsxRuntime = require('react/jsx-runtime');
10
11
  var ReactMarkdown = require('react-markdown');
@@ -13,6 +14,25 @@ var reactDom = require('react-dom');
13
14
 
14
15
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
16
 
17
+ function _interopNamespace(e) {
18
+ if (e && e.__esModule) return e;
19
+ var n = Object.create(null);
20
+ if (e) {
21
+ Object.keys(e).forEach(function (k) {
22
+ if (k !== 'default') {
23
+ var d = Object.getOwnPropertyDescriptor(e, k);
24
+ Object.defineProperty(n, k, d.get ? d : {
25
+ enumerable: true,
26
+ get: function () { return e[k]; }
27
+ });
28
+ }
29
+ });
30
+ }
31
+ n.default = e;
32
+ return Object.freeze(n);
33
+ }
34
+
35
+ var Sentry__namespace = /*#__PURE__*/_interopNamespace(Sentry);
16
36
  var ReactMarkdown__default = /*#__PURE__*/_interopDefault(ReactMarkdown);
17
37
  var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
18
38
 
@@ -59,6 +79,17 @@ function formatElapsedTime(ms) {
59
79
  if (ms < 1e3) return `${ms}ms`;
60
80
  return `${(ms / 1e3).toFixed(1)}s`;
61
81
  }
82
+ function initSentryIfNeeded(dsn) {
83
+ if (!dsn) return;
84
+ if (Sentry__namespace.getClient()) return;
85
+ Sentry__namespace.init({
86
+ dsn,
87
+ sendDefaultPii: true,
88
+ initialScope: {
89
+ tags: { source: "payman-ask-sdk" }
90
+ }
91
+ });
92
+ }
62
93
  var AI_DISCLAIMER_TEXT = "AI can make mistakes. Please double-check responses.";
63
94
  function ChatInput({
64
95
  value,
@@ -2001,6 +2032,11 @@ var PaymanChat = react.forwardRef(function PaymanChat2({
2001
2032
  const [inputValue, setInputValue] = react.useState("");
2002
2033
  const prevInputValueRef = react.useRef(inputValue);
2003
2034
  const [hasEverSentMessage, setHasEverSentMessage] = react.useState(false);
2035
+ react.useEffect(() => {
2036
+ if (config.sentryDsn) {
2037
+ initSentryIfNeeded(config.sentryDsn);
2038
+ }
2039
+ }, [config.sentryDsn]);
2004
2040
  const chat = paymanTypescriptAskSdk.useChat(config, callbacks);
2005
2041
  const {
2006
2042
  messages,