@paymanai/payman-ask-sdk 1.2.8 → 1.2.10

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.mjs CHANGED
@@ -249,6 +249,16 @@ function ThinkingBlock({ text }) {
249
249
  ] });
250
250
  }
251
251
  var FRIENDLY_ERROR_MESSAGE = "Oops, something went wrong. Please try again.";
252
+ var WORKFLOW_FAILED = "WORKFLOW_FAILED";
253
+ var STREAM_NOT_STARTED = "STREAM_NOT_STARTED";
254
+ function isFriendlyError(errorDetails) {
255
+ if (!errorDetails) return false;
256
+ return errorDetails === WORKFLOW_FAILED || errorDetails === STREAM_NOT_STARTED || errorDetails.includes(WORKFLOW_FAILED);
257
+ }
258
+ function looksLikeRawError(text) {
259
+ if (!text || text.length < 10) return false;
260
+ return text.includes("errorType=") || /failed:\s*\{/.test(text);
261
+ }
252
262
  function AgentMessage({
253
263
  message,
254
264
  animated = false,
@@ -265,7 +275,6 @@ function AgentMessage({
265
275
  const isStreaming = message.isStreaming ?? false;
266
276
  const hasSteps = message.steps && message.steps.length > 0;
267
277
  const hasTraceData = !!(message.tracingData || message.executionId) && !isStreaming;
268
- const isError = message.isError ?? (message.streamProgress === "error" || !!message.errorDetails);
269
278
  const isCancelled = message.isCancelled ?? false;
270
279
  const currentExecutingStepId = message.currentExecutingStepId;
271
280
  const [isStepsExpanded, setIsStepsExpanded] = useState(false);
@@ -283,6 +292,9 @@ function AgentMessage({
283
292
  const currentMessage = message.currentMessage;
284
293
  const rawContent = message.streamingContent || message.content || "";
285
294
  const content = rawContent.replace(/\\n/g, "\n");
295
+ const hasMeaningfulContent = content.length > 0 && !looksLikeRawError(content);
296
+ const completedWithNoContent = !isStreaming && !isCancelled && content.length === 0 && (message.streamProgress === "completed" || message.streamProgress === "error");
297
+ const isError = (isFriendlyError(message.errorDetails) || looksLikeRawError(content)) && !hasMeaningfulContent || completedWithNoContent;
286
298
  const activeThinkingText = message.activeThinkingText;
287
299
  const allThinkingText = message.allThinkingText;
288
300
  const currentStep = useMemo(