@paymanai/payman-ask-sdk 1.2.10 → 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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +45 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -8
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +47 -10
- package/dist/index.native.js.map +1 -1
- package/package.json +1 -1
package/dist/index.native.js
CHANGED
|
@@ -504,6 +504,48 @@ var s = reactNative.StyleSheet.create({
|
|
|
504
504
|
justifyContent: "center"
|
|
505
505
|
}
|
|
506
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
|
+
}
|
|
507
549
|
function AnimatedLoader({
|
|
508
550
|
size = 14,
|
|
509
551
|
color = "#00858d"
|
|
@@ -576,12 +618,6 @@ function ThinkingBlock({ text }) {
|
|
|
576
618
|
isOpen && /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: ts.thinkingContent, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: ts.thinkingContentText, children: text }) })
|
|
577
619
|
] });
|
|
578
620
|
}
|
|
579
|
-
var WORKFLOW_FAILED = "WORKFLOW_FAILED";
|
|
580
|
-
var STREAM_NOT_STARTED = "STREAM_NOT_STARTED";
|
|
581
|
-
function isFriendlyError(errorDetails) {
|
|
582
|
-
if (!errorDetails) return false;
|
|
583
|
-
return errorDetails === WORKFLOW_FAILED || errorDetails === STREAM_NOT_STARTED || errorDetails.includes(WORKFLOW_FAILED);
|
|
584
|
-
}
|
|
585
621
|
function looksLikeRawError(text) {
|
|
586
622
|
if (!text || text.length < 10) return false;
|
|
587
623
|
return text.includes("errorType=") || /failed:\s*\{/.test(text);
|
|
@@ -620,7 +656,8 @@ function AgentMessage({
|
|
|
620
656
|
const content = rawContent.replace(/\\n/g, "\n");
|
|
621
657
|
const hasMeaningfulContent = content.length > 0 && !looksLikeRawError(content);
|
|
622
658
|
const completedWithNoContent = !isStreaming && !isCancelled && content.length === 0 && (message.streamProgress === "completed" || message.streamProgress === "error");
|
|
623
|
-
const
|
|
659
|
+
const conflictErrorMessage = getConflictErrorMessage(message.errorDetails);
|
|
660
|
+
const isError = !!conflictErrorMessage || (isFriendlyWorkflowError(message.errorDetails) || looksLikeRawError(content)) && !hasMeaningfulContent || completedWithNoContent;
|
|
624
661
|
const activeThinkingText = message.activeThinkingText;
|
|
625
662
|
const allThinkingText = message.allThinkingText;
|
|
626
663
|
const currentStep = React.useMemo(
|
|
@@ -715,7 +752,7 @@ function AgentMessage({
|
|
|
715
752
|
Markdown__default.default,
|
|
716
753
|
{
|
|
717
754
|
style: isError ? markdownErrorStyles : markdownStyles,
|
|
718
|
-
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." : "")
|
|
719
756
|
}
|
|
720
757
|
) })
|
|
721
758
|
]
|
|
@@ -1899,7 +1936,7 @@ function PaymanChat({
|
|
|
1899
1936
|
const approveUserAction = chat.approveUserAction ?? NOOP_ASYNC;
|
|
1900
1937
|
const rejectUserAction = chat.rejectUserAction ?? NOOP_ASYNC;
|
|
1901
1938
|
const resendOtp = chat.resendOtp ?? NOOP_ASYNC;
|
|
1902
|
-
typeof chat.approveUserAction === "function" && typeof chat.rejectUserAction === "function" && typeof chat.resendOtp === "function";
|
|
1939
|
+
const isUserActionSupported = typeof chat.approveUserAction === "function" && typeof chat.rejectUserAction === "function" && typeof chat.resendOtp === "function";
|
|
1903
1940
|
const {
|
|
1904
1941
|
voiceState,
|
|
1905
1942
|
transcribedText,
|
|
@@ -2098,7 +2135,7 @@ function PaymanChat({
|
|
|
2098
2135
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2099
2136
|
UserActionModal,
|
|
2100
2137
|
{
|
|
2101
|
-
isOpen:
|
|
2138
|
+
isOpen: isUserActionSupported && userActionState.request !== null,
|
|
2102
2139
|
userActionRequest: userActionState.request,
|
|
2103
2140
|
onApprove: approveUserAction,
|
|
2104
2141
|
onReject: rejectUserAction,
|