@ensembleapp/client-sdk 0.0.37 → 0.0.39
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 +49 -12
- package/dist/index.js +454 -359
- package/dist/index.js.map +1 -1
- package/dist/widget/widget.global.js +55 -55
- package/dist/widget/widget.global.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -158,6 +158,32 @@ type EnrichmentResult<TData = unknown> = {
|
|
|
158
158
|
data?: TData;
|
|
159
159
|
};
|
|
160
160
|
|
|
161
|
+
/** Matches POST /api/tools/:toolId/invoke request body */
|
|
162
|
+
interface ToolInvokeRequest {
|
|
163
|
+
/** Tool arguments (defaults to empty object) */
|
|
164
|
+
args?: Record<string, unknown>;
|
|
165
|
+
/** Key/value context data passed to the tool */
|
|
166
|
+
dataContext?: Record<string, unknown>;
|
|
167
|
+
/** Tool version: 'latest' (default), 'published', or specific version number */
|
|
168
|
+
version?: 'latest' | 'published' | number;
|
|
169
|
+
}
|
|
170
|
+
/** Matches POST /api/tools/:toolId/invoke response body */
|
|
171
|
+
interface ToolInvokeResult {
|
|
172
|
+
success: boolean;
|
|
173
|
+
/** Tool execution result (when success: true) */
|
|
174
|
+
data?: unknown;
|
|
175
|
+
/** Error details (when success: false) */
|
|
176
|
+
error?: {
|
|
177
|
+
message: string;
|
|
178
|
+
details?: string[];
|
|
179
|
+
code?: string;
|
|
180
|
+
};
|
|
181
|
+
debug?: {
|
|
182
|
+
executionTime: number;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
type InvokeTool = (toolId: string, request?: ToolInvokeRequest) => Promise<ToolInvokeResult>;
|
|
186
|
+
|
|
161
187
|
/**
|
|
162
188
|
* Client-specific types for the SDK.
|
|
163
189
|
* Core feedback types (FeedbackRating, FeedbackNote, MessageFeedback, CreateFeedbackRequest)
|
|
@@ -194,6 +220,16 @@ interface FeedbackConfig extends FeedbackHandlers {
|
|
|
194
220
|
interface MessageContext extends FeedbackHandlers {
|
|
195
221
|
messageId: string;
|
|
196
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Options passed to widget render functions.
|
|
225
|
+
* Provides utilities for message context and tool invocation.
|
|
226
|
+
*/
|
|
227
|
+
interface WidgetRenderOptions {
|
|
228
|
+
/** Message-level context with feedback handlers */
|
|
229
|
+
messageContext?: MessageContext;
|
|
230
|
+
/** Function to invoke tools from within widgets (client-side enrichment) */
|
|
231
|
+
invokeTool?: InvokeTool;
|
|
232
|
+
}
|
|
197
233
|
|
|
198
234
|
/** Enriched results keyed by enrichment name */
|
|
199
235
|
type EnrichedResults<T = unknown> = Record<string, EnrichmentResult<T>>;
|
|
@@ -210,9 +246,7 @@ interface SDKUIWidgetDefinition<TSchema extends FlexibleSchema = FlexibleSchema,
|
|
|
210
246
|
widgetType: string;
|
|
211
247
|
schema: TSchema;
|
|
212
248
|
enrich?: WidgetEnrichConfig;
|
|
213
|
-
render(payload: InferSchema<TSchema>, enriched: TEnriched, options:
|
|
214
|
-
messageContext?: MessageContext;
|
|
215
|
-
}): ReactElement;
|
|
249
|
+
render(payload: InferSchema<TSchema>, enriched: TEnriched, options: WidgetRenderOptions): ReactElement;
|
|
216
250
|
}
|
|
217
251
|
/** Type guard to check if a widget is an SDK-provided widget */
|
|
218
252
|
declare function isSDKWidget(widget: AnyUIWidgetDefinition): widget is SDKUIWidgetDefinition;
|
|
@@ -284,11 +318,9 @@ interface UIWidgetDefinition<TSchema extends FlexibleSchema = FlexibleSchema, TE
|
|
|
284
318
|
* Render function that receives the payload and enriched results.
|
|
285
319
|
* @param payload - The LLM-generated data matching the schema
|
|
286
320
|
* @param enriched - Enrichment results keyed by name (empty object if no enrich config)
|
|
287
|
-
* @param options - Render options (messageContext,
|
|
321
|
+
* @param options - Render options (messageContext, invokeTool)
|
|
288
322
|
*/
|
|
289
|
-
render(payload: InferSchema<TSchema>, enriched: TEnriched, options:
|
|
290
|
-
messageContext?: MessageContext;
|
|
291
|
-
}): unknown;
|
|
323
|
+
render(payload: InferSchema<TSchema>, enriched: TEnriched, options: WidgetRenderOptions): unknown;
|
|
292
324
|
}
|
|
293
325
|
/**
|
|
294
326
|
* Helper to create customer widgets.
|
|
@@ -318,9 +350,7 @@ declare const createWidget: <TEnriched extends EnrichedResults = EnrichedResults
|
|
|
318
350
|
schema: any;
|
|
319
351
|
enrich?: WidgetEnrichConfig;
|
|
320
352
|
reactDOM: CustomerReactDOM;
|
|
321
|
-
render(payload: any, enriched: TEnriched, options:
|
|
322
|
-
messageContext?: MessageContext;
|
|
323
|
-
}): unknown;
|
|
353
|
+
render(payload: any, enriched: TEnriched, options: WidgetRenderOptions): unknown;
|
|
324
354
|
}) => UIWidgetDefinition<FlexibleSchema, TEnriched>;
|
|
325
355
|
|
|
326
356
|
type DisplayMode = 'full' | 'brief';
|
|
@@ -492,6 +522,8 @@ interface MessageRendererProps {
|
|
|
492
522
|
className?: string;
|
|
493
523
|
/** Feedback config - if provided, feedback UI will be shown */
|
|
494
524
|
feedback?: FeedbackConfig;
|
|
525
|
+
/** Function to invoke tools from widgets (client-side enrichment) */
|
|
526
|
+
invokeTool?: InvokeTool;
|
|
495
527
|
}
|
|
496
528
|
/**
|
|
497
529
|
* MessageRenderer - renders message content with optional feedback UI.
|
|
@@ -499,7 +531,7 @@ interface MessageRendererProps {
|
|
|
499
531
|
* Renders the content of a ChatMessage (text, tools, widgets, groups) and optionally
|
|
500
532
|
* displays feedback buttons for assistant messages.
|
|
501
533
|
*/
|
|
502
|
-
declare function MessageRenderer({ message, widgets, readonly, displayMode, tagExpansion, className, feedback, }: MessageRendererProps): react_jsx_runtime.JSX.Element;
|
|
534
|
+
declare function MessageRenderer({ message, widgets, readonly, displayMode, tagExpansion, className, feedback, invokeTool, }: MessageRendererProps): react_jsx_runtime.JSX.Element;
|
|
503
535
|
|
|
504
536
|
interface DisplayModeProps {
|
|
505
537
|
/** Message sections to render */
|
|
@@ -564,8 +596,13 @@ declare global {
|
|
|
564
596
|
}
|
|
565
597
|
|
|
566
598
|
declare const defaultChatWidgets: SDKUIWidgetDefinition[];
|
|
599
|
+
/**
|
|
600
|
+
* Hybrid vendor cards widget:
|
|
601
|
+
* - Server enriches vendor details (parallel to LLM, immediate render)
|
|
602
|
+
* - Client fetches distance matrix (progressive, fills in after render)
|
|
603
|
+
*/
|
|
567
604
|
declare const getVendorCardsWidget: (isProd?: boolean) => SDKUIWidgetDefinition[];
|
|
568
605
|
|
|
569
606
|
declare function cn(...inputs: ClassValue[]): string;
|
|
570
607
|
|
|
571
|
-
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 FeedbackConfig, type FeedbackHandlers, type FeedbackNote, type FeedbackRating, FullDisplayMode, FullDisplayMode as FullRenderer, type MessageContext, type MessageFeedback, MessageRenderer, type MessageRendererProps, 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 };
|
|
608
|
+
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 FeedbackConfig, type FeedbackHandlers, type FeedbackNote, type FeedbackRating, FullDisplayMode, FullDisplayMode as FullRenderer, type InvokeTool, type MessageContext, type MessageFeedback, MessageRenderer, type MessageRendererProps, 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, getVendorCardsWidget, isSDKWidget, registerChatWidgets, transformMessage, useChat, useFeedback };
|