@ensembleapp/client-sdk 0.0.35 → 0.0.36

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.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React$1, { ReactElement } from 'react';
1
+ import React, { ReactElement, ReactNode } from 'react';
2
2
  import * as ai from 'ai';
3
3
  import { UIMessage } from 'ai';
4
4
  import { FlexibleSchema, InferSchema } from '@ai-sdk/provider-utils';
@@ -39,7 +39,7 @@ type DeprecatedChatConfig = {
39
39
  agentExecutionId?: string;
40
40
  };
41
41
  interface ApiConfig {
42
- /** The base URL where /chat and /chat/messages are hosted */
42
+ /** The base URL where /api/chat and /api/chat/messages are hosted */
43
43
  baseUrl: string;
44
44
  /** JWT token generated from Secret */
45
45
  token: string;
@@ -327,7 +327,7 @@ interface ChatWidgetConfig extends UseChatConfig {
327
327
  /** Feedback options for assistant messages. Enabled by default. */
328
328
  feedback?: ChatWidgetFeedbackOptions;
329
329
  }
330
- declare const ChatWidget: React$1.ForwardRefExoticComponent<ChatWidgetConfig & React$1.RefAttributes<ChatWidgetHandle>>;
330
+ declare const ChatWidget: React.ForwardRefExoticComponent<ChatWidgetConfig & React.RefAttributes<ChatWidgetHandle>>;
331
331
 
332
332
  interface PopupAnchorConfig {
333
333
  enabled?: boolean;
@@ -337,13 +337,13 @@ interface PopupAnchorConfig {
337
337
  render?: (options: {
338
338
  isOpen: boolean;
339
339
  toggle: () => void;
340
- }) => React$1.ReactNode;
340
+ }) => React.ReactNode;
341
341
  closeButton?: PopupCloseConfig;
342
342
  }
343
343
  interface PopupCloseConfig {
344
344
  render?: (options: {
345
345
  toggle: () => void;
346
- }) => React$1.ReactNode;
346
+ }) => React.ReactNode;
347
347
  position?: 'top-end' | 'top-start';
348
348
  show?: boolean;
349
349
  }
@@ -395,6 +395,22 @@ declare function useFeedback({ api, threadId, agentId, agentVersion, agentExecut
395
395
  error: Error | null;
396
396
  };
397
397
 
398
+ /**
399
+ * Transforms a UIMessage into a ChatMessage with sections.
400
+ *
401
+ * Groups UIMessage.parts into step and group sections:
402
+ * - step: content between step-start markers (one LLM turn)
403
+ * - group: content within data-tag-start/end markers (sub-agent output)
404
+ *
405
+ * Parts pass through as-is - no content transformation.
406
+ * Structural markers (step-start, data-tag-*, data-transfer, data-thoughts)
407
+ * are consumed during grouping and not included in output.
408
+ *
409
+ * @param msg - The UIMessage from AI SDK
410
+ * @returns ChatMessage with sections
411
+ */
412
+ declare function transformMessage(msg: UIMessage): ChatMessage;
413
+
398
414
  /** Tool part from UIMessage - either typed tool-* or dynamic-tool */
399
415
  type ToolPart = Extract<UIMessagePart, {
400
416
  type: `tool-${string}`;
@@ -411,34 +427,84 @@ interface TagGroupDisplayProps {
411
427
  tagId: string;
412
428
  isExpanded: boolean;
413
429
  onToggle: () => void;
414
- children: React.ReactNode;
430
+ children: ReactNode;
415
431
  }
416
432
  declare function TagGroupDisplay({ tagId, isExpanded, onToggle, children, }: TagGroupDisplayProps): react_jsx_runtime.JSX.Element;
417
433
 
418
- interface RendererProps {
434
+ interface MessageRendererProps {
435
+ /** The message to render */
436
+ message: ChatMessage;
437
+ /** Widget definitions for rendering data-ui parts */
438
+ widgets?: AnyUIWidgetDefinition[];
439
+ /** Readonly mode - disables all widget interactions */
440
+ readonly?: boolean;
441
+ /** Display mode: 'brief' collapses previous steps, 'full' shows everything */
442
+ displayMode?: 'brief' | 'full';
443
+ /** Tag expansion state and handler */
444
+ tagExpansion?: {
445
+ state: Map<string, boolean>;
446
+ onToggle: (tagId: string) => void;
447
+ };
448
+ /** Optional className for the container */
449
+ className?: string;
450
+ }
451
+ /**
452
+ * MessageRenderer - content-only message renderer.
453
+ *
454
+ * Renders the content of a ChatMessage (text, tools, widgets, groups) without
455
+ * any bubble layout. Use this when you want to provide your own bubble/container styling.
456
+ *
457
+ * For a complete solution with bubble layout included, use MessageBubbleRenderer.
458
+ */
459
+ declare function MessageRenderer({ message, widgets, readonly, displayMode, tagExpansion, className, }: MessageRendererProps): react_jsx_runtime.JSX.Element;
460
+
461
+ interface MessageWithFeedbackRendererProps extends MessageRendererProps {
462
+ /** Feedback configuration (ignored if readonly=true) */
463
+ feedback?: {
464
+ enabled: boolean;
465
+ showButtons?: boolean;
466
+ existingRating?: FeedbackRating;
467
+ existingComment?: string;
468
+ submitting?: boolean;
469
+ requireCommentForNegative?: boolean;
470
+ onSubmit?: (rating: FeedbackRating, comment?: string) => void;
471
+ };
472
+ }
473
+ /**
474
+ * MessageWithFeedbackRenderer - message renderer with optional feedback UI.
475
+ *
476
+ * Wraps MessageRenderer and adds feedback buttons for assistant messages.
477
+ * Use this when you want content rendering + feedback without bubble styling.
478
+ *
479
+ * For a complete solution with ChatWidget bubble layout, use ChatWidget directly.
480
+ * For content-only rendering, use MessageRenderer.
481
+ */
482
+ declare function MessageWithFeedbackRenderer({ message, widgets, readonly, displayMode, tagExpansion, className, feedback, }: MessageWithFeedbackRendererProps): react_jsx_runtime.JSX.Element;
483
+
484
+ interface DisplayModeProps {
419
485
  /** Message sections to render */
420
486
  sections: ChatMessageSection[];
421
487
  /** Unique message ID for keying */
422
488
  messageId: string;
423
489
  /** Render function for individual parts (text, widgets, tool calls) */
424
- renderPart: (part: UIMessagePart, key: string) => React$1.ReactNode;
490
+ renderPart: (part: UIMessagePart, key: string) => ReactNode;
425
491
  /** Render function for group sections */
426
- renderGroup: (groupName: string, key: string, children: React$1.ReactNode) => React$1.ReactNode;
492
+ renderGroup: (groupName: string, key: string, children: ReactNode) => ReactNode;
427
493
  }
428
494
 
429
495
  /**
430
- * Full display mode renderer - shows all content without collapsing.
431
- * Each section is rendered as-is in chronological order.
432
- */
433
- declare function FullRenderer({ sections, messageId, renderPart, renderGroup, }: RendererProps): react_jsx_runtime.JSX.Element;
434
-
435
- /**
436
- * Brief display mode renderer - collapses previous steps.
496
+ * Brief display mode - collapses previous steps.
437
497
  *
438
498
  * All steps before the last one are collapsed into a single "Show more" section.
439
499
  * Groups collapse their internal content similarly.
440
500
  */
441
- declare function BriefRenderer({ sections, messageId, renderPart, renderGroup, }: RendererProps): react_jsx_runtime.JSX.Element;
501
+ declare function BriefDisplayMode({ sections, messageId, renderPart, renderGroup, }: DisplayModeProps): react_jsx_runtime.JSX.Element;
502
+
503
+ /**
504
+ * Full display mode - shows all content without collapsing.
505
+ * Each section is rendered as-is in chronological order.
506
+ */
507
+ declare function FullDisplayMode({ sections, messageId, renderPart, renderGroup, }: DisplayModeProps): react_jsx_runtime.JSX.Element;
442
508
 
443
509
  type RegisterChatWidgetsParams = {
444
510
  api: ApiConfig;
@@ -482,4 +548,4 @@ declare const getVendorCardsWidget: (isProd?: boolean) => SDKUIWidgetDefinition[
482
548
 
483
549
  declare function cn(...inputs: ClassValue[]): string;
484
550
 
485
- export { type AgentVersion, type AnyUIWidgetDefinition, type ApiConfig, BriefRenderer, type ChatMessage, type ChatMessageSection, ChatWidget, type ChatWidgetFeedbackOptions, type ChatWidgetHandle, type ChatWidgetConfig as ChatWidgetProps, type ChatWidgetSpeechToTextOptions, type ChatWidgetStyles, type ChatWidgetVoiceOptions, type CustomerReactDOM, type DisplayMode, type EmbeddableChatWidgetConfig, type EnrichedResults, type FeedbackRating, type FeedbackState, FullRenderer, type MessageFeedback, type PopupAnchorConfig, PopupChatWidget, type PopupChatWidgetProps, type RendererProps, type SDKUIWidgetDefinition, SDK_WIDGET_MARKER, type SubmitFeedbackParams, TagGroupDisplay, type TagGroupDisplayProps, ToolCallDisplay, type ToolCallDisplayProps, type ToolPart, type UIMessagePart, type UIWidgetDefinition, type UseChatConfig, type UseFeedbackConfig, type WidgetEnrichConfig, cn, createSDKWidget, createWidget, defaultChatWidgets, getVendorCardsWidget, isSDKWidget, registerChatWidgets, useChat, useFeedback };
551
+ export { type AgentVersion, type AnyUIWidgetDefinition, type ApiConfig, BriefDisplayMode, BriefDisplayMode as BriefRenderer, type ChatMessage, type ChatMessageSection, ChatWidget, type ChatWidgetFeedbackOptions, type ChatWidgetHandle, type ChatWidgetConfig as ChatWidgetProps, type ChatWidgetSpeechToTextOptions, type ChatWidgetStyles, type ChatWidgetVoiceOptions, type CustomerReactDOM, type DisplayMode, type DisplayModeProps, type EmbeddableChatWidgetConfig, type EnrichedResults, type FeedbackRating, type FeedbackState, FullDisplayMode, FullDisplayMode as FullRenderer, MessageWithFeedbackRenderer as MessageBubbleRenderer, type MessageWithFeedbackRendererProps as MessageBubbleRendererProps, type MessageFeedback, MessageRenderer, type MessageRendererProps, MessageWithFeedbackRenderer, type MessageWithFeedbackRendererProps, type PopupAnchorConfig, PopupChatWidget, type PopupChatWidgetProps, type DisplayModeProps as RendererProps, type SDKUIWidgetDefinition, SDK_WIDGET_MARKER, type SubmitFeedbackParams, TagGroupDisplay, type TagGroupDisplayProps, ToolCallDisplay, type ToolCallDisplayProps, type ToolPart, type UIMessagePart, type UIWidgetDefinition, type UseChatConfig, type UseFeedbackConfig, type WidgetEnrichConfig, cn, createSDKWidget, createWidget, defaultChatWidgets, getVendorCardsWidget, isSDKWidget, registerChatWidgets, transformMessage, useChat, useFeedback };