@paymanai/payman-ask-sdk 1.2.8 → 1.2.9
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 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -1
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +16 -3
- package/dist/index.native.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -31,6 +31,7 @@ type MessageDisplay = {
|
|
|
31
31
|
content: string;
|
|
32
32
|
timestamp: string;
|
|
33
33
|
isError?: boolean;
|
|
34
|
+
/** When set to "WORKFLOW_FAILED" or "STREAM_NOT_STARTED", the UI shows the friendly "Oops, something went wrong" message. Other errors (e.g. subintent failures) do not show it. */
|
|
34
35
|
errorDetails?: string;
|
|
35
36
|
chunks?: ChunkDisplay[];
|
|
36
37
|
tracingData?: unknown;
|
|
@@ -338,7 +339,7 @@ type StreamingMessageProps = {
|
|
|
338
339
|
currentMessage?: string;
|
|
339
340
|
/** Stream progress */
|
|
340
341
|
streamProgress: StreamProgress;
|
|
341
|
-
/**
|
|
342
|
+
/** When set to "WORKFLOW_FAILED" or "STREAM_NOT_STARTED", the UI shows the friendly error message. Other errors do not. */
|
|
342
343
|
error?: string;
|
|
343
344
|
/** Streaming steps */
|
|
344
345
|
steps?: StreamingStep[];
|
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ type MessageDisplay = {
|
|
|
31
31
|
content: string;
|
|
32
32
|
timestamp: string;
|
|
33
33
|
isError?: boolean;
|
|
34
|
+
/** When set to "WORKFLOW_FAILED" or "STREAM_NOT_STARTED", the UI shows the friendly "Oops, something went wrong" message. Other errors (e.g. subintent failures) do not show it. */
|
|
34
35
|
errorDetails?: string;
|
|
35
36
|
chunks?: ChunkDisplay[];
|
|
36
37
|
tracingData?: unknown;
|
|
@@ -338,7 +339,7 @@ type StreamingMessageProps = {
|
|
|
338
339
|
currentMessage?: string;
|
|
339
340
|
/** Stream progress */
|
|
340
341
|
streamProgress: StreamProgress;
|
|
341
|
-
/**
|
|
342
|
+
/** When set to "WORKFLOW_FAILED" or "STREAM_NOT_STARTED", the UI shows the friendly error message. Other errors do not. */
|
|
342
343
|
error?: string;
|
|
343
344
|
/** Streaming steps */
|
|
344
345
|
steps?: StreamingStep[];
|
package/dist/index.js
CHANGED
|
@@ -255,6 +255,16 @@ function ThinkingBlock({ text }) {
|
|
|
255
255
|
] });
|
|
256
256
|
}
|
|
257
257
|
var FRIENDLY_ERROR_MESSAGE = "Oops, something went wrong. Please try again.";
|
|
258
|
+
var WORKFLOW_FAILED = "WORKFLOW_FAILED";
|
|
259
|
+
var STREAM_NOT_STARTED = "STREAM_NOT_STARTED";
|
|
260
|
+
function isFriendlyError(errorDetails) {
|
|
261
|
+
if (!errorDetails) return false;
|
|
262
|
+
return errorDetails === WORKFLOW_FAILED || errorDetails === STREAM_NOT_STARTED || errorDetails.includes(WORKFLOW_FAILED);
|
|
263
|
+
}
|
|
264
|
+
function looksLikeRawError(text) {
|
|
265
|
+
if (!text || text.length < 10) return false;
|
|
266
|
+
return text.includes("errorType=") || /failed:\s*\{/.test(text);
|
|
267
|
+
}
|
|
258
268
|
function AgentMessage({
|
|
259
269
|
message,
|
|
260
270
|
animated = false,
|
|
@@ -271,7 +281,6 @@ function AgentMessage({
|
|
|
271
281
|
const isStreaming = message.isStreaming ?? false;
|
|
272
282
|
const hasSteps = message.steps && message.steps.length > 0;
|
|
273
283
|
const hasTraceData = !!(message.tracingData || message.executionId) && !isStreaming;
|
|
274
|
-
const isError = message.isError ?? (message.streamProgress === "error" || !!message.errorDetails);
|
|
275
284
|
const isCancelled = message.isCancelled ?? false;
|
|
276
285
|
const currentExecutingStepId = message.currentExecutingStepId;
|
|
277
286
|
const [isStepsExpanded, setIsStepsExpanded] = react.useState(false);
|
|
@@ -289,6 +298,9 @@ function AgentMessage({
|
|
|
289
298
|
const currentMessage = message.currentMessage;
|
|
290
299
|
const rawContent = message.streamingContent || message.content || "";
|
|
291
300
|
const content = rawContent.replace(/\\n/g, "\n");
|
|
301
|
+
const hasMeaningfulContent = content.length > 0 && !looksLikeRawError(content);
|
|
302
|
+
const completedWithNoContent = !isStreaming && !isCancelled && content.length === 0 && (message.streamProgress === "completed" || message.streamProgress === "error");
|
|
303
|
+
const isError = (isFriendlyError(message.errorDetails) || looksLikeRawError(content)) && !hasMeaningfulContent || completedWithNoContent;
|
|
292
304
|
const activeThinkingText = message.activeThinkingText;
|
|
293
305
|
const allThinkingText = message.allThinkingText;
|
|
294
306
|
const currentStep = react.useMemo(
|