@ensembleapp/client-sdk 0.0.46 → 0.0.48

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
@@ -178,6 +178,7 @@ interface ApiConfig {
178
178
  }
179
179
  /** Agent version selector: 'latest' (default), 'published', or a specific version number */
180
180
  type AgentVersion = 'latest' | 'published' | number;
181
+ type StructuredMessagePayload = Record<string, unknown>;
181
182
  type UseChatConfig = DeprecatedChatConfig & {
182
183
  /** The server API configuration */
183
184
  api: ApiConfig;
@@ -200,6 +201,7 @@ declare function useChat({ api, threadId, agentId, agentVersion, agentExecutionI
200
201
  messages: ChatMessage[];
201
202
  status: ai.ChatStatus;
202
203
  isLoadingInitial: boolean;
204
+ canSendMessage: boolean;
203
205
  sendMessage: (message?: (Omit<UIMessage<unknown, ai.UIDataTypes, ai.UITools>, "id" | "role"> & {
204
206
  id?: string | undefined;
205
207
  role?: "user" | "assistant" | "system" | undefined;
@@ -219,6 +221,7 @@ declare function useChat({ api, threadId, agentId, agentVersion, agentExecutionI
219
221
  parts?: never;
220
222
  messageId?: string;
221
223
  } | undefined, options?: ai.ChatRequestOptions) => Promise<void>;
224
+ sendStructuredMessage: (text: string, payload: StructuredMessagePayload) => Promise<void>;
222
225
  stop: () => Promise<void>;
223
226
  setMessages: (messages: UIMessage<unknown, ai.UIDataTypes, ai.UITools>[] | ((messages: UIMessage<unknown, ai.UIDataTypes, ai.UITools>[]) => UIMessage<unknown, ai.UIDataTypes, ai.UITools>[])) => void;
224
227
  addToolOutput: <TOOL extends string>({ state, tool, toolCallId, output, errorText, }: {
@@ -310,6 +313,12 @@ interface WidgetRenderOptions {
310
313
  messageContext?: MessageContext;
311
314
  /** Function to invoke tools from within widgets (client-side enrichment) */
312
315
  invokeTool?: InvokeTool;
316
+ /** Whether the chat is ready for widget-triggered messages */
317
+ canSendMessage?: boolean;
318
+ /** Send a visible text message from within widgets */
319
+ sendMessage?: (text: string) => void | Promise<void>;
320
+ /** Send visible text plus structured JSON data from within widgets */
321
+ sendStructuredMessage?: (text: string, payload: Record<string, unknown>) => void | Promise<void>;
313
322
  }
314
323
 
315
324
  /** Enriched results keyed by enrichment name */
@@ -501,6 +510,8 @@ interface ChatWidgetFeedbackOptions {
501
510
  interface ChatWidgetHandle {
502
511
  /** Send a message programmatically */
503
512
  sendMessage: (message: string) => void;
513
+ /** Send visible text plus structured JSON data for the agent */
514
+ sendStructuredMessage: (message: string, payload: Record<string, unknown>) => void;
504
515
  }
505
516
  interface ChatWidgetConfig extends UseChatConfig {
506
517
  /** Title for the Chat window */
@@ -658,6 +669,12 @@ interface MessageRendererProps {
658
669
  feedback?: FeedbackConfig;
659
670
  /** Function to invoke tools from widgets (client-side enrichment) */
660
671
  invokeTool?: InvokeTool;
672
+ /** Whether the chat is ready for widget-triggered messages */
673
+ canSendMessage?: boolean;
674
+ /** Function to send a visible text message from widgets */
675
+ sendMessage?: (text: string) => void | Promise<void>;
676
+ /** Function to send visible text plus structured JSON data from widgets */
677
+ sendStructuredMessage?: (text: string, payload: Record<string, unknown>) => void | Promise<void>;
661
678
  }
662
679
  /**
663
680
  * MessageRenderer - renders message content with optional feedback UI.
@@ -665,7 +682,7 @@ interface MessageRendererProps {
665
682
  * Renders the content of a ChatMessage (text, tools, widgets, groups) and optionally
666
683
  * displays feedback buttons for assistant messages.
667
684
  */
668
- declare function MessageRenderer({ message, widgets, readonly, displayMode, tagExpansion, className, feedback, invokeTool, }: MessageRendererProps): react_jsx_runtime.JSX.Element;
685
+ declare function MessageRenderer({ message, widgets, readonly, displayMode, tagExpansion, className, feedback, invokeTool, canSendMessage, sendMessage, sendStructuredMessage, }: MessageRendererProps): react_jsx_runtime.JSX.Element;
669
686
 
670
687
  interface DisplayModeProps {
671
688
  /** Message sections to render */
@@ -739,4 +756,4 @@ declare const getVendorCardsWidget: (isProd?: boolean) => SDKUIWidgetDefinition[
739
756
 
740
757
  declare function cn(...inputs: ClassValue[]): string;
741
758
 
742
- export { type AgentVersion, type AnyUIWidgetDefinition, type ApiConfig, type ApprovalUIConfig, 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 FeedbackConfig, type FeedbackHandlers, type FeedbackNote, type FeedbackRating, type FetchApprovalConfigOptions, FullDisplayMode, FullDisplayMode as FullRenderer, type InvokeTool, type MessageContext, type MessageFeedback, MessageRenderer, type MessageRendererProps, type PendingToolApproval, type PendingToolOutput, type PopupAnchorConfig, PopupChatWidget, type PopupChatWidgetProps, type DisplayModeProps as RendererProps, type SDKUIWidgetDefinition, SDK_WIDGET_MARKER, type SubmitFeedbackParams, TagGroupDisplay, type TagGroupDisplayProps, ToolCallDisplay, type ToolCallDisplayProps, type ToolInvokeRequest, type ToolInvokeResult, type ToolPart, type UIMessagePart, type UIWidgetDefinition, type UseChatConfig, type UseFeedbackConfig, type WidgetEnrichConfig, type WidgetRenderOptions, cn, createSDKWidget, createWidget, defaultChatWidgets, fetchApprovalConfig, getVendorCardsWidget, isSDKWidget, registerChatWidgets, transformMessage, useChat, useFeedback };
759
+ export { type AgentVersion, type AnyUIWidgetDefinition, type ApiConfig, type ApprovalUIConfig, 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 FeedbackConfig, type FeedbackHandlers, type FeedbackNote, type FeedbackRating, type FetchApprovalConfigOptions, FullDisplayMode, FullDisplayMode as FullRenderer, type InvokeTool, type MessageContext, type MessageFeedback, MessageRenderer, type MessageRendererProps, type PendingToolApproval, type PendingToolOutput, type PopupAnchorConfig, PopupChatWidget, type PopupChatWidgetProps, type DisplayModeProps as RendererProps, type SDKUIWidgetDefinition, SDK_WIDGET_MARKER, type StructuredMessagePayload, type SubmitFeedbackParams, TagGroupDisplay, type TagGroupDisplayProps, ToolCallDisplay, type ToolCallDisplayProps, type ToolInvokeRequest, type ToolInvokeResult, type ToolPart, type UIMessagePart, type UIWidgetDefinition, type UseChatConfig, type UseFeedbackConfig, type WidgetEnrichConfig, type WidgetRenderOptions, cn, createSDKWidget, createWidget, defaultChatWidgets, fetchApprovalConfig, getVendorCardsWidget, isSDKWidget, registerChatWidgets, transformMessage, useChat, useFeedback };