@paymanai/payman-ask-sdk 1.2.11 → 1.2.12
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 +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +64 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -9
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +59 -9
- package/dist/index.native.js.map +1 -1
- package/package.json +1 -1
package/dist/index.native.js
CHANGED
|
@@ -99,6 +99,7 @@ function ChatInput({
|
|
|
99
99
|
value,
|
|
100
100
|
onChange,
|
|
101
101
|
onSend,
|
|
102
|
+
onPause,
|
|
102
103
|
disabled = false,
|
|
103
104
|
placeholder = "Chat with Claude",
|
|
104
105
|
isWaitingForResponse = false,
|
|
@@ -117,6 +118,7 @@ function ChatInput({
|
|
|
117
118
|
transcribedText
|
|
118
119
|
}) {
|
|
119
120
|
const isInputDisabled = disabled || isWaitingForResponse;
|
|
121
|
+
const showPauseButton = isWaitingForResponse && onPause;
|
|
120
122
|
const showVoiceButton = enableVoice && onVoicePress != null;
|
|
121
123
|
const isVoiceButtonDisabled = isWaitingForResponse || !voiceAvailable || !isSessionParamsConfigured;
|
|
122
124
|
const canSend = !isInputDisabled && value.trim().length > 0;
|
|
@@ -302,7 +304,17 @@ function ChatInput({
|
|
|
302
304
|
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: s.iconBtnInner, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReactNative.Mic, { size: 22, color: "#6B7280", strokeWidth: 2 }) })
|
|
303
305
|
}
|
|
304
306
|
),
|
|
305
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
307
|
+
showPauseButton ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
308
|
+
reactNative.Pressable,
|
|
309
|
+
{
|
|
310
|
+
onPress: onPause,
|
|
311
|
+
style: ({ pressed }) => [
|
|
312
|
+
s.sendBtn,
|
|
313
|
+
pressed && s.btnPressed
|
|
314
|
+
],
|
|
315
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: s.sendBtnInner, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReactNative.Pause, { size: 18, color: "#FFFFFF" }) })
|
|
316
|
+
}
|
|
317
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
306
318
|
reactNative.Pressable,
|
|
307
319
|
{
|
|
308
320
|
onPress: onSend,
|
|
@@ -492,6 +504,48 @@ var s = reactNative.StyleSheet.create({
|
|
|
492
504
|
justifyContent: "center"
|
|
493
505
|
}
|
|
494
506
|
});
|
|
507
|
+
|
|
508
|
+
// src/utils/errorMessages.ts
|
|
509
|
+
var WORKFLOW_FAILED = "WORKFLOW_FAILED";
|
|
510
|
+
var STREAM_NOT_STARTED = "STREAM_NOT_STARTED";
|
|
511
|
+
var HTTP_ERROR_PREFIX = /^HTTP\s+(\d+)\s*:\s*([\s\S]+)$/;
|
|
512
|
+
function isFriendlyWorkflowError(errorDetails) {
|
|
513
|
+
if (!errorDetails) return false;
|
|
514
|
+
return errorDetails === WORKFLOW_FAILED || errorDetails === STREAM_NOT_STARTED || errorDetails.includes(WORKFLOW_FAILED);
|
|
515
|
+
}
|
|
516
|
+
function parseErrorPayload(payload) {
|
|
517
|
+
try {
|
|
518
|
+
const parsed = JSON.parse(payload);
|
|
519
|
+
if (typeof parsed === "string") {
|
|
520
|
+
return { message: parsed.trim() || void 0 };
|
|
521
|
+
}
|
|
522
|
+
if (typeof parsed === "object" && parsed !== null) {
|
|
523
|
+
const record = parsed;
|
|
524
|
+
return {
|
|
525
|
+
status: typeof record.status === "number" ? record.status : void 0,
|
|
526
|
+
message: typeof record.message === "string" && record.message.trim() ? record.message.trim() : void 0
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
} catch {
|
|
530
|
+
}
|
|
531
|
+
return {};
|
|
532
|
+
}
|
|
533
|
+
function getConflictErrorMessage(errorDetails) {
|
|
534
|
+
if (!errorDetails) return void 0;
|
|
535
|
+
const trimmedError = errorDetails.trim();
|
|
536
|
+
const httpMatch = trimmedError.match(HTTP_ERROR_PREFIX);
|
|
537
|
+
const httpStatus = httpMatch ? Number(httpMatch[1]) : void 0;
|
|
538
|
+
const rawPayload = (httpMatch ? httpMatch[2] : trimmedError).trim();
|
|
539
|
+
const payload = parseErrorPayload(rawPayload);
|
|
540
|
+
const status = payload.status ?? httpStatus;
|
|
541
|
+
if (status !== 409) {
|
|
542
|
+
return void 0;
|
|
543
|
+
}
|
|
544
|
+
if (payload.message) {
|
|
545
|
+
return payload.message;
|
|
546
|
+
}
|
|
547
|
+
return rawPayload || void 0;
|
|
548
|
+
}
|
|
495
549
|
function AnimatedLoader({
|
|
496
550
|
size = 14,
|
|
497
551
|
color = "#00858d"
|
|
@@ -564,12 +618,6 @@ function ThinkingBlock({ text }) {
|
|
|
564
618
|
isOpen && /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: ts.thinkingContent, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: ts.thinkingContentText, children: text }) })
|
|
565
619
|
] });
|
|
566
620
|
}
|
|
567
|
-
var WORKFLOW_FAILED = "WORKFLOW_FAILED";
|
|
568
|
-
var STREAM_NOT_STARTED = "STREAM_NOT_STARTED";
|
|
569
|
-
function isFriendlyError(errorDetails) {
|
|
570
|
-
if (!errorDetails) return false;
|
|
571
|
-
return errorDetails === WORKFLOW_FAILED || errorDetails === STREAM_NOT_STARTED || errorDetails.includes(WORKFLOW_FAILED);
|
|
572
|
-
}
|
|
573
621
|
function looksLikeRawError(text) {
|
|
574
622
|
if (!text || text.length < 10) return false;
|
|
575
623
|
return text.includes("errorType=") || /failed:\s*\{/.test(text);
|
|
@@ -608,7 +656,8 @@ function AgentMessage({
|
|
|
608
656
|
const content = rawContent.replace(/\\n/g, "\n");
|
|
609
657
|
const hasMeaningfulContent = content.length > 0 && !looksLikeRawError(content);
|
|
610
658
|
const completedWithNoContent = !isStreaming && !isCancelled && content.length === 0 && (message.streamProgress === "completed" || message.streamProgress === "error");
|
|
611
|
-
const
|
|
659
|
+
const conflictErrorMessage = getConflictErrorMessage(message.errorDetails);
|
|
660
|
+
const isError = !!conflictErrorMessage || (isFriendlyWorkflowError(message.errorDetails) || looksLikeRawError(content)) && !hasMeaningfulContent || completedWithNoContent;
|
|
612
661
|
const activeThinkingText = message.activeThinkingText;
|
|
613
662
|
const allThinkingText = message.allThinkingText;
|
|
614
663
|
const currentStep = React.useMemo(
|
|
@@ -703,7 +752,7 @@ function AgentMessage({
|
|
|
703
752
|
Markdown__default.default,
|
|
704
753
|
{
|
|
705
754
|
style: isError ? markdownErrorStyles : markdownStyles,
|
|
706
|
-
children: content || (isStreaming ? "Thinking..." : isCancelled ? "Request was stopped." :
|
|
755
|
+
children: isError ? conflictErrorMessage ?? "Something went wrong. Please try again." : content || (isStreaming ? "Thinking..." : isCancelled ? "Request was stopped." : "")
|
|
707
756
|
}
|
|
708
757
|
) })
|
|
709
758
|
]
|
|
@@ -2065,6 +2114,7 @@ function PaymanChat({
|
|
|
2065
2114
|
value: inputValue,
|
|
2066
2115
|
onChange: setInputValue,
|
|
2067
2116
|
onSend: handleSend,
|
|
2117
|
+
onPause: cancelStream,
|
|
2068
2118
|
disabled: isInputDisabled,
|
|
2069
2119
|
placeholder,
|
|
2070
2120
|
isWaitingForResponse,
|