@ensembleapp/client-sdk 0.0.18 → 0.0.20
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 +16 -20
- package/dist/index.js +16 -8
- package/dist/index.js.map +1 -1
- package/dist/widget/widget.global.js +39 -39
- package/dist/widget/widget.global.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -41,15 +41,17 @@ type ToolCallConfig = {
|
|
|
41
41
|
* ```
|
|
42
42
|
*/
|
|
43
43
|
type WidgetEnrichConfig = Record<string, ToolCallConfig>;
|
|
44
|
-
/**
|
|
45
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Enrichment result containing the full tool response.
|
|
46
|
+
* This should mirror ToolResult on server-side without debug/metadata info.
|
|
47
|
+
*/
|
|
48
|
+
type EnrichmentResult<TData = unknown> = {
|
|
46
49
|
success: boolean;
|
|
47
50
|
error?: {
|
|
48
|
-
message
|
|
51
|
+
message?: string;
|
|
49
52
|
code?: string;
|
|
50
53
|
};
|
|
51
|
-
data?:
|
|
52
|
-
metadata?: Record<string, unknown>;
|
|
54
|
+
data?: TData;
|
|
53
55
|
};
|
|
54
56
|
/** Widget output shape sent to the client */
|
|
55
57
|
type UIWidget = {
|
|
@@ -57,7 +59,7 @@ type UIWidget = {
|
|
|
57
59
|
/** LLM-generated data based on the widget schema specified by the client */
|
|
58
60
|
payload: unknown;
|
|
59
61
|
/** Server-injected enrichment results from tool calls, keyed by enrichment name */
|
|
60
|
-
enriched?: Record<string, EnrichmentResult
|
|
62
|
+
enriched?: Record<string, EnrichmentResult>;
|
|
61
63
|
};
|
|
62
64
|
|
|
63
65
|
type DeprecatedChatConfig = {
|
|
@@ -176,16 +178,6 @@ declare function useFeedback({ api, threadId, agentId, agentExecutionId, }: UseF
|
|
|
176
178
|
error: Error | null;
|
|
177
179
|
};
|
|
178
180
|
|
|
179
|
-
/** Enrichment result containing the full tool response - this should mirror ToolResult */
|
|
180
|
-
interface EnrichmentResult<TData = unknown> {
|
|
181
|
-
success: boolean;
|
|
182
|
-
error?: {
|
|
183
|
-
message: string;
|
|
184
|
-
code?: string;
|
|
185
|
-
};
|
|
186
|
-
data?: TData;
|
|
187
|
-
metadata?: Record<string, unknown>;
|
|
188
|
-
}
|
|
189
181
|
/** Enriched results keyed by enrichment name */
|
|
190
182
|
type EnrichedResults<T = unknown> = Record<string, EnrichmentResult<T>>;
|
|
191
183
|
interface UIWidgetDefinition<TSchema extends AnyZodObject = AnyZodObject, TEnriched extends EnrichedResults = EnrichedResults> {
|
|
@@ -253,8 +245,12 @@ interface ChatWidgetFeedbackOptions {
|
|
|
253
245
|
interface ChatWidgetConfig extends UseChatConfig {
|
|
254
246
|
/** Title for the Chat window */
|
|
255
247
|
title?: string;
|
|
256
|
-
/**
|
|
257
|
-
|
|
248
|
+
/** Initial assistant message displayed at the start of the chat (if history is empty).
|
|
249
|
+
* Skipped if initialUserMessage is provided. */
|
|
250
|
+
initialAssistantMessage?: string;
|
|
251
|
+
/** Initial user message to send automatically when the chat loads (if history is empty).
|
|
252
|
+
* Use this to kick-start the conversation without requiring user input. */
|
|
253
|
+
initialUserMessage?: string;
|
|
258
254
|
/** Placeholder text for the input box */
|
|
259
255
|
inputPlaceholder?: string;
|
|
260
256
|
className?: string;
|
|
@@ -265,7 +261,7 @@ interface ChatWidgetConfig extends UseChatConfig {
|
|
|
265
261
|
/** Feedback options for assistant messages. Enabled by default. */
|
|
266
262
|
feedback?: ChatWidgetFeedbackOptions;
|
|
267
263
|
}
|
|
268
|
-
declare function ChatWidget({ api, threadId, agentId, agentExecutionId, dataContext, onError, onAuthError, onFinish, onMessage, title,
|
|
264
|
+
declare function ChatWidget({ api, threadId, agentId, agentExecutionId, dataContext, onError, onAuthError, onFinish, onMessage, title, initialAssistantMessage, initialUserMessage, inputPlaceholder, className, styles: styleProps, voice, speechToText, widgets, feedback, }: ChatWidgetConfig): react_jsx_runtime.JSX.Element;
|
|
269
265
|
|
|
270
266
|
interface PopupAnchorConfig {
|
|
271
267
|
enabled?: boolean;
|
|
@@ -358,4 +354,4 @@ declare const defaultChatWidgets: UIWidgetDefinition[];
|
|
|
358
354
|
|
|
359
355
|
declare function cn(...inputs: ClassValue[]): string;
|
|
360
356
|
|
|
361
|
-
export { type ApiConfig, type ChatContentItem, type ChatMessage, ChatWidget, type ChatWidgetFeedbackOptions, type ChatWidgetInstance, type ChatWidgetConfig as ChatWidgetProps, type ChatWidgetSpeechToTextOptions, type ChatWidgetStyles, type ChatWidgetVoiceOptions, type EmbeddableChatWidgetConfig, type EnrichedResults, type
|
|
357
|
+
export { type ApiConfig, type ChatContentItem, type ChatMessage, ChatWidget, type ChatWidgetFeedbackOptions, type ChatWidgetInstance, type ChatWidgetConfig as ChatWidgetProps, type ChatWidgetSpeechToTextOptions, type ChatWidgetStyles, type ChatWidgetVoiceOptions, type EmbeddableChatWidgetConfig, type EnrichedResults, type FeedbackRating, type FeedbackState, type MessageFeedback, type MessageSection, type PopupAnchorConfig, PopupChatWidget, type PopupChatWidgetProps, type SubmitFeedbackParams, type TagGroup, TagGroupDisplay, type TagGroupDisplayProps, type ToolCallContent, ToolCallDisplay, type ToolCallDisplayProps, type UIWidgetDefinition, type UseChatConfig, type UseFeedbackConfig, type WidgetEnrichConfig, cn, createChatWidget, createWidget, defaultChatWidgets, registerChatWidgets, useChat, useFeedback };
|
package/dist/index.js
CHANGED
|
@@ -24422,7 +24422,8 @@ function ChatWidget({
|
|
|
24422
24422
|
onFinish,
|
|
24423
24423
|
onMessage,
|
|
24424
24424
|
title,
|
|
24425
|
-
|
|
24425
|
+
initialAssistantMessage,
|
|
24426
|
+
initialUserMessage,
|
|
24426
24427
|
inputPlaceholder,
|
|
24427
24428
|
className,
|
|
24428
24429
|
styles: styleProps,
|
|
@@ -24532,14 +24533,21 @@ function ChatWidget({
|
|
|
24532
24533
|
};
|
|
24533
24534
|
}, [voice]);
|
|
24534
24535
|
useEffect4(() => {
|
|
24535
|
-
if (
|
|
24536
|
+
if (initialAssistantMessage && !initialUserMessage && messages.length === 0) {
|
|
24536
24537
|
setMessages([{
|
|
24537
24538
|
id: "welcome-message",
|
|
24538
24539
|
role: "assistant",
|
|
24539
|
-
parts: [{ type: "text", text:
|
|
24540
|
+
parts: [{ type: "text", text: initialAssistantMessage }]
|
|
24540
24541
|
}]);
|
|
24541
24542
|
}
|
|
24542
|
-
}, [
|
|
24543
|
+
}, [initialAssistantMessage, initialUserMessage, messages.length, setMessages]);
|
|
24544
|
+
const initialMessageSentRef = useRef3(false);
|
|
24545
|
+
useEffect4(() => {
|
|
24546
|
+
if (initialUserMessage && !initialMessageSentRef.current && status === "ready" && messages.length === 0) {
|
|
24547
|
+
initialMessageSentRef.current = true;
|
|
24548
|
+
sendMessage({ text: initialUserMessage });
|
|
24549
|
+
}
|
|
24550
|
+
}, [initialUserMessage, status, messages.length, sendMessage]);
|
|
24543
24551
|
const handleScroll = useCallback4(() => {
|
|
24544
24552
|
if (!scrollContainerRef.current) return;
|
|
24545
24553
|
const { scrollTop, scrollHeight, clientHeight } = scrollContainerRef.current;
|
|
@@ -24908,7 +24916,7 @@ function VendorCards({ payload, enriched }) {
|
|
|
24908
24916
|
};
|
|
24909
24917
|
return /* @__PURE__ */ jsx8("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: payload.vendors.map((v, index) => {
|
|
24910
24918
|
const data = vendorData[v.vendor_id];
|
|
24911
|
-
const name17 = data?.names?.
|
|
24919
|
+
const name17 = data?.names?.[0]?.value ?? "Unknown";
|
|
24912
24920
|
const address = data?.location?.address;
|
|
24913
24921
|
const distanceEntry = distances.find((d) => d.destinationIndex === index);
|
|
24914
24922
|
const distance = distanceEntry && distanceEntry.distanceMeters ? formatDistance(distanceEntry.distanceMeters) : void 0;
|
|
@@ -25017,7 +25025,7 @@ var defaultChatWidgets = [
|
|
|
25017
25025
|
widgetType: "person-card",
|
|
25018
25026
|
schema: zod_default.object({
|
|
25019
25027
|
name: zod_default.string(),
|
|
25020
|
-
|
|
25028
|
+
photoUri: zod_default.string().optional().describe("URL to a photo of the person"),
|
|
25021
25029
|
details: zod_default.record(zod_default.any()).optional()
|
|
25022
25030
|
}).describe("showing a person card with name, photo and additional details"),
|
|
25023
25031
|
render: (payload) => /* @__PURE__ */ jsx9(
|
|
@@ -25034,10 +25042,10 @@ var defaultChatWidgets = [
|
|
|
25034
25042
|
boxShadow: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)"
|
|
25035
25043
|
},
|
|
25036
25044
|
children: /* @__PURE__ */ jsxs8("div", { style: { display: "flex", alignItems: "flex-start", gap: "0.75rem" }, children: [
|
|
25037
|
-
payload.
|
|
25045
|
+
payload.photoUri && /* @__PURE__ */ jsx9(
|
|
25038
25046
|
"img",
|
|
25039
25047
|
{
|
|
25040
|
-
src: payload.
|
|
25048
|
+
src: payload.photoUri,
|
|
25041
25049
|
alt: payload.name,
|
|
25042
25050
|
style: {
|
|
25043
25051
|
width: "3rem",
|