@ensembleapp/client-sdk 0.0.25 → 0.0.26
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 +37 -31
- package/dist/index.js +224 -93
- package/dist/index.js.map +1 -1
- package/dist/widget/widget.global.js +41 -41
- package/dist/widget/widget.global.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -62,33 +62,6 @@ type UIWidget = {
|
|
|
62
62
|
enriched?: Record<string, EnrichmentResult>;
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
type DeprecatedChatConfig = {
|
|
66
|
-
/** @deprecated use agentId instead */
|
|
67
|
-
agentExecutionId?: string;
|
|
68
|
-
};
|
|
69
|
-
interface ApiConfig {
|
|
70
|
-
/** The base URL where /chat and /chat/messages are hosted */
|
|
71
|
-
baseUrl: string;
|
|
72
|
-
/** JWT token generated from Secret */
|
|
73
|
-
token: string;
|
|
74
|
-
headers?: Record<string, string>;
|
|
75
|
-
}
|
|
76
|
-
type UseChatConfig = DeprecatedChatConfig & {
|
|
77
|
-
/** The server API configuration */
|
|
78
|
-
api: ApiConfig;
|
|
79
|
-
/** Thread ID for keeping conversation history */
|
|
80
|
-
threadId: string;
|
|
81
|
-
/** Ensemble agent ID to connect to */
|
|
82
|
-
agentId?: string;
|
|
83
|
-
/** additional context (anything) that needs to be passed to the LLM */
|
|
84
|
-
dataContext?: unknown;
|
|
85
|
-
onError?: (error: Error) => void;
|
|
86
|
-
/** Called when API returns 401/unauthorized (e.g., token expiry). Return a new token to retry the request. */
|
|
87
|
-
onAuthError?: () => Promise<string | null>;
|
|
88
|
-
onFinish?: (message: any) => void;
|
|
89
|
-
onData?: (data: any) => void;
|
|
90
|
-
onMessage?: (message: UIMessage) => void;
|
|
91
|
-
};
|
|
92
65
|
interface ToolCallContent {
|
|
93
66
|
type: 'tool-call';
|
|
94
67
|
toolName: string;
|
|
@@ -120,7 +93,38 @@ interface ChatMessage {
|
|
|
120
93
|
thoughts?: (string | UIWidget)[];
|
|
121
94
|
createdAt?: Date;
|
|
122
95
|
}
|
|
123
|
-
|
|
96
|
+
type DisplayMode = 'full' | 'brief';
|
|
97
|
+
|
|
98
|
+
type DeprecatedChatConfig = {
|
|
99
|
+
/** @deprecated use agentId instead */
|
|
100
|
+
agentExecutionId?: string;
|
|
101
|
+
};
|
|
102
|
+
interface ApiConfig {
|
|
103
|
+
/** The base URL where /chat and /chat/messages are hosted */
|
|
104
|
+
baseUrl: string;
|
|
105
|
+
/** JWT token generated from Secret */
|
|
106
|
+
token: string;
|
|
107
|
+
headers?: Record<string, string>;
|
|
108
|
+
}
|
|
109
|
+
type UseChatConfig = DeprecatedChatConfig & {
|
|
110
|
+
/** The server API configuration */
|
|
111
|
+
api: ApiConfig;
|
|
112
|
+
/** Thread ID for keeping conversation history */
|
|
113
|
+
threadId: string;
|
|
114
|
+
/** Ensemble agent ID to connect to */
|
|
115
|
+
agentId?: string;
|
|
116
|
+
/** additional context (anything) that needs to be passed to the LLM */
|
|
117
|
+
dataContext?: unknown;
|
|
118
|
+
/** Display mode: 'brief' (default) shows only last block per step, 'full' shows everything */
|
|
119
|
+
displayMode?: DisplayMode;
|
|
120
|
+
onError?: (error: Error) => void;
|
|
121
|
+
/** Called when API returns 401/unauthorized (e.g., token expiry). Return a new token to retry the request. */
|
|
122
|
+
onAuthError?: () => Promise<string | null>;
|
|
123
|
+
onFinish?: (message: any) => void;
|
|
124
|
+
onData?: (data: any) => void;
|
|
125
|
+
onMessage?: (message: UIMessage) => void;
|
|
126
|
+
};
|
|
127
|
+
declare function useChat({ api, threadId, agentId, agentExecutionId, dataContext, displayMode, onError, onAuthError, onFinish, onData, onMessage, }: UseChatConfig): {
|
|
124
128
|
messages: ChatMessage[];
|
|
125
129
|
status: ai.ChatStatus;
|
|
126
130
|
isLoadingInitial: boolean;
|
|
@@ -242,9 +246,11 @@ interface ChatWidgetFeedbackOptions {
|
|
|
242
246
|
/** Require comment when giving negative feedback. Default: false */
|
|
243
247
|
requireCommentForNegative?: boolean;
|
|
244
248
|
}
|
|
245
|
-
interface ChatWidgetConfig extends UseChatConfig {
|
|
249
|
+
interface ChatWidgetConfig extends Omit<UseChatConfig, 'displayMode'> {
|
|
246
250
|
/** Title for the Chat window */
|
|
247
251
|
title?: string;
|
|
252
|
+
/** Display mode: 'brief' (default) shows only last block per step, 'full' shows everything */
|
|
253
|
+
displayMode?: DisplayMode;
|
|
248
254
|
/** Initial assistant message displayed at the start of the chat (if history is empty).
|
|
249
255
|
* Skipped if initialUserMessage is provided. */
|
|
250
256
|
initialAssistantMessage?: string;
|
|
@@ -261,7 +267,7 @@ interface ChatWidgetConfig extends UseChatConfig {
|
|
|
261
267
|
/** Feedback options for assistant messages. Enabled by default. */
|
|
262
268
|
feedback?: ChatWidgetFeedbackOptions;
|
|
263
269
|
}
|
|
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;
|
|
270
|
+
declare function ChatWidget({ api, threadId, agentId, agentExecutionId, dataContext, displayMode, onError, onAuthError, onFinish, onMessage, title, initialAssistantMessage, initialUserMessage, inputPlaceholder, className, styles: styleProps, voice, speechToText, widgets, feedback, }: ChatWidgetConfig): react_jsx_runtime.JSX.Element;
|
|
265
271
|
|
|
266
272
|
interface PopupAnchorConfig {
|
|
267
273
|
enabled?: boolean;
|
|
@@ -351,4 +357,4 @@ declare const getVendorCardsWidget: (isProd?: boolean) => UIWidgetDefinition[];
|
|
|
351
357
|
|
|
352
358
|
declare function cn(...inputs: ClassValue[]): string;
|
|
353
359
|
|
|
354
|
-
export { type ApiConfig, type ChatContentItem, type ChatMessage, ChatWidget, type ChatWidgetFeedbackOptions, 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, createWidget, defaultChatWidgets, getVendorCardsWidget, registerChatWidgets, useChat, useFeedback };
|
|
360
|
+
export { type ApiConfig, type ChatContentItem, type ChatMessage, ChatWidget, type ChatWidgetFeedbackOptions, type ChatWidgetConfig as ChatWidgetProps, type ChatWidgetSpeechToTextOptions, type ChatWidgetStyles, type ChatWidgetVoiceOptions, type DisplayMode, 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, createWidget, defaultChatWidgets, getVendorCardsWidget, registerChatWidgets, useChat, useFeedback };
|
package/dist/index.js
CHANGED
|
@@ -18628,6 +18628,185 @@ var DefaultChatTransport = class extends HttpChatTransport {
|
|
|
18628
18628
|
|
|
18629
18629
|
// lib/hooks/useChat.ts
|
|
18630
18630
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
18631
|
+
|
|
18632
|
+
// lib/hooks/display-modes/full.ts
|
|
18633
|
+
var FullDisplayMode = class {
|
|
18634
|
+
transform(msg, context) {
|
|
18635
|
+
const sections = [];
|
|
18636
|
+
const thoughts = [];
|
|
18637
|
+
const tagStack = [];
|
|
18638
|
+
const addContent = (item) => {
|
|
18639
|
+
const currentTagGroup = tagStack[tagStack.length - 1];
|
|
18640
|
+
if (currentTagGroup) {
|
|
18641
|
+
currentTagGroup.content.push(item);
|
|
18642
|
+
} else {
|
|
18643
|
+
sections.push({ type: "content", item });
|
|
18644
|
+
}
|
|
18645
|
+
};
|
|
18646
|
+
msg.parts.forEach((part) => {
|
|
18647
|
+
if (part.type === "data-tag-start") {
|
|
18648
|
+
const data = part.data;
|
|
18649
|
+
if (data && typeof data === "object" && "tagId" in data) {
|
|
18650
|
+
tagStack.push({ tagId: data.tagId, content: [] });
|
|
18651
|
+
}
|
|
18652
|
+
} else if (part.type === "data-tag-end") {
|
|
18653
|
+
const group = tagStack.pop();
|
|
18654
|
+
if (group) {
|
|
18655
|
+
sections.push({ type: "tag-group", group });
|
|
18656
|
+
}
|
|
18657
|
+
} else if (part.type === "text") {
|
|
18658
|
+
const trimmedText = part.text?.trim();
|
|
18659
|
+
if (trimmedText) {
|
|
18660
|
+
addContent(trimmedText);
|
|
18661
|
+
}
|
|
18662
|
+
} else if (part.type === "data-ui") {
|
|
18663
|
+
part.data.forEach((widget) => addContent(widget));
|
|
18664
|
+
} else if (part.type === "data-thoughts") {
|
|
18665
|
+
const thoughtOutputs = part.data.map((t) => t.output).filter((output) => output != null);
|
|
18666
|
+
thoughts.push(...thoughtOutputs);
|
|
18667
|
+
} else if (part.type === "data-transfer") {
|
|
18668
|
+
} else if (part.type === "step-start") {
|
|
18669
|
+
const currentTagGroup = tagStack[tagStack.length - 1];
|
|
18670
|
+
if (currentTagGroup) {
|
|
18671
|
+
currentTagGroup.lastStepStartIndex = currentTagGroup.content.length;
|
|
18672
|
+
}
|
|
18673
|
+
} else if (part.type.startsWith("tool-")) {
|
|
18674
|
+
const toolName = part.toolName || part.type.replace("tool-", "");
|
|
18675
|
+
addContent({
|
|
18676
|
+
type: "tool-call",
|
|
18677
|
+
toolName,
|
|
18678
|
+
input: part.input,
|
|
18679
|
+
state: part.state === "output-available" ? "output-available" : part.state === "input-error" || part.state === "output-error" ? "error" : "pending",
|
|
18680
|
+
output: part.output
|
|
18681
|
+
});
|
|
18682
|
+
}
|
|
18683
|
+
});
|
|
18684
|
+
while (tagStack.length > 0) {
|
|
18685
|
+
const unfinishedGroup = tagStack.pop();
|
|
18686
|
+
if (unfinishedGroup) {
|
|
18687
|
+
sections.push({ type: "tag-group", group: unfinishedGroup });
|
|
18688
|
+
}
|
|
18689
|
+
}
|
|
18690
|
+
if (msg.role === "assistant" && (!context.isLastMessage || !context.isStreaming)) {
|
|
18691
|
+
const lastPart = msg.parts.at(-1);
|
|
18692
|
+
if (lastPart && lastPart.type === "data-thoughts") {
|
|
18693
|
+
const thoughtOutputs = lastPart.data.map((t) => t.output).filter((output) => output != null);
|
|
18694
|
+
thoughtOutputs.forEach((t) => sections.push({ type: "content", item: t }));
|
|
18695
|
+
}
|
|
18696
|
+
}
|
|
18697
|
+
return {
|
|
18698
|
+
id: msg.id,
|
|
18699
|
+
role: msg.role,
|
|
18700
|
+
sections,
|
|
18701
|
+
thoughts
|
|
18702
|
+
};
|
|
18703
|
+
}
|
|
18704
|
+
};
|
|
18705
|
+
var fullDisplayMode = new FullDisplayMode();
|
|
18706
|
+
|
|
18707
|
+
// lib/hooks/display-modes/brief.ts
|
|
18708
|
+
var BriefDisplayMode = class {
|
|
18709
|
+
transform(msg, _context) {
|
|
18710
|
+
const sections = [];
|
|
18711
|
+
const tagStack = [];
|
|
18712
|
+
let currentStepContent = [];
|
|
18713
|
+
let hasSeenStepStart = false;
|
|
18714
|
+
const addContent = (item) => {
|
|
18715
|
+
const currentTagGroup = tagStack[tagStack.length - 1];
|
|
18716
|
+
if (currentTagGroup) {
|
|
18717
|
+
currentTagGroup.content.push(item);
|
|
18718
|
+
} else {
|
|
18719
|
+
currentStepContent.push(item);
|
|
18720
|
+
}
|
|
18721
|
+
};
|
|
18722
|
+
const finalizeRootStep = () => {
|
|
18723
|
+
if (currentStepContent.length > 0) {
|
|
18724
|
+
currentStepContent.forEach((item) => {
|
|
18725
|
+
sections.push({ type: "content", item });
|
|
18726
|
+
});
|
|
18727
|
+
}
|
|
18728
|
+
};
|
|
18729
|
+
const processBriefTagGroup = (group) => {
|
|
18730
|
+
const lastStepIndex = group.lastStepStartIndex ?? 0;
|
|
18731
|
+
const briefContent = group.content.slice(lastStepIndex);
|
|
18732
|
+
return {
|
|
18733
|
+
...group,
|
|
18734
|
+
content: briefContent,
|
|
18735
|
+
lastStepStartIndex: 0
|
|
18736
|
+
};
|
|
18737
|
+
};
|
|
18738
|
+
msg.parts.forEach((part) => {
|
|
18739
|
+
if (part.type === "data-tag-start") {
|
|
18740
|
+
const data = part.data;
|
|
18741
|
+
if (data && typeof data === "object" && "tagId" in data) {
|
|
18742
|
+
tagStack.push({ tagId: data.tagId, content: [], lastStepStartIndex: 0 });
|
|
18743
|
+
}
|
|
18744
|
+
} else if (part.type === "data-tag-end") {
|
|
18745
|
+
const group = tagStack.pop();
|
|
18746
|
+
if (group) {
|
|
18747
|
+
const briefGroup = processBriefTagGroup(group);
|
|
18748
|
+
sections.push({ type: "tag-group", group: briefGroup });
|
|
18749
|
+
}
|
|
18750
|
+
} else if (part.type === "step-start") {
|
|
18751
|
+
const currentTagGroup = tagStack[tagStack.length - 1];
|
|
18752
|
+
if (currentTagGroup) {
|
|
18753
|
+
currentTagGroup.lastStepStartIndex = currentTagGroup.content.length;
|
|
18754
|
+
} else {
|
|
18755
|
+
hasSeenStepStart = true;
|
|
18756
|
+
currentStepContent = [];
|
|
18757
|
+
}
|
|
18758
|
+
} else if (part.type === "text") {
|
|
18759
|
+
const trimmedText = part.text?.trim();
|
|
18760
|
+
if (trimmedText) {
|
|
18761
|
+
addContent(trimmedText);
|
|
18762
|
+
}
|
|
18763
|
+
} else if (part.type === "data-ui") {
|
|
18764
|
+
part.data.forEach((widget) => addContent(widget));
|
|
18765
|
+
} else if (part.type === "data-thoughts") {
|
|
18766
|
+
} else if (part.type === "data-transfer") {
|
|
18767
|
+
} else if (part.type.startsWith("tool-")) {
|
|
18768
|
+
const toolName = part.toolName || part.type.replace("tool-", "");
|
|
18769
|
+
addContent({
|
|
18770
|
+
type: "tool-call",
|
|
18771
|
+
toolName,
|
|
18772
|
+
input: part.input,
|
|
18773
|
+
state: part.state === "output-available" ? "output-available" : part.state === "input-error" || part.state === "output-error" ? "error" : "pending",
|
|
18774
|
+
output: part.output
|
|
18775
|
+
});
|
|
18776
|
+
}
|
|
18777
|
+
});
|
|
18778
|
+
while (tagStack.length > 0) {
|
|
18779
|
+
const unfinishedGroup = tagStack.pop();
|
|
18780
|
+
if (unfinishedGroup) {
|
|
18781
|
+
const briefGroup = processBriefTagGroup(unfinishedGroup);
|
|
18782
|
+
sections.push({ type: "tag-group", group: briefGroup });
|
|
18783
|
+
}
|
|
18784
|
+
}
|
|
18785
|
+
if (!hasSeenStepStart || currentStepContent.length > 0) {
|
|
18786
|
+
currentStepContent.forEach((item) => {
|
|
18787
|
+
sections.push({ type: "content", item });
|
|
18788
|
+
});
|
|
18789
|
+
}
|
|
18790
|
+
return {
|
|
18791
|
+
id: msg.id,
|
|
18792
|
+
role: msg.role,
|
|
18793
|
+
sections
|
|
18794
|
+
// thoughts is empty in brief mode since data-thoughts is deprecated
|
|
18795
|
+
};
|
|
18796
|
+
}
|
|
18797
|
+
};
|
|
18798
|
+
var briefDisplayMode = new BriefDisplayMode();
|
|
18799
|
+
|
|
18800
|
+
// lib/hooks/display-modes/index.ts
|
|
18801
|
+
var displayModes = {
|
|
18802
|
+
full: fullDisplayMode,
|
|
18803
|
+
brief: briefDisplayMode
|
|
18804
|
+
};
|
|
18805
|
+
function getDisplayMode(mode = "brief") {
|
|
18806
|
+
return displayModes[mode] ?? fullDisplayMode;
|
|
18807
|
+
}
|
|
18808
|
+
|
|
18809
|
+
// lib/hooks/useChat.ts
|
|
18631
18810
|
function createAuthAwareFetch(tokenRef, onAuthError) {
|
|
18632
18811
|
return async (input, init) => {
|
|
18633
18812
|
const doFetch = (token) => fetch(input, {
|
|
@@ -18654,6 +18833,7 @@ function useChat({
|
|
|
18654
18833
|
agentId,
|
|
18655
18834
|
agentExecutionId,
|
|
18656
18835
|
dataContext,
|
|
18836
|
+
displayMode = "brief",
|
|
18657
18837
|
onError,
|
|
18658
18838
|
onAuthError,
|
|
18659
18839
|
onFinish,
|
|
@@ -18746,78 +18926,17 @@ function useChat({
|
|
|
18746
18926
|
onMessage(lastMessage);
|
|
18747
18927
|
}
|
|
18748
18928
|
}, [messages, onMessage]);
|
|
18749
|
-
const
|
|
18750
|
-
|
|
18751
|
-
|
|
18752
|
-
|
|
18753
|
-
|
|
18754
|
-
|
|
18755
|
-
|
|
18756
|
-
|
|
18757
|
-
|
|
18758
|
-
sections.push({ type: "content", item });
|
|
18759
|
-
}
|
|
18760
|
-
};
|
|
18761
|
-
msg.parts.forEach((part) => {
|
|
18762
|
-
if (part.type === "data-tag-start") {
|
|
18763
|
-
const data = part.data;
|
|
18764
|
-
if (data && typeof data === "object" && "tagId" in data) {
|
|
18765
|
-
tagStack.push({ tagId: data.tagId, content: [] });
|
|
18766
|
-
}
|
|
18767
|
-
} else if (part.type === "data-tag-end") {
|
|
18768
|
-
const group = tagStack.pop();
|
|
18769
|
-
if (group) {
|
|
18770
|
-
sections.push({ type: "tag-group", group });
|
|
18771
|
-
}
|
|
18772
|
-
} else if (part.type === "text") {
|
|
18773
|
-
const trimmedText = part.text.trim();
|
|
18774
|
-
if (trimmedText) {
|
|
18775
|
-
addContent(trimmedText);
|
|
18776
|
-
}
|
|
18777
|
-
} else if (part.type === "data-ui") {
|
|
18778
|
-
part.data.forEach((widget) => addContent(widget));
|
|
18779
|
-
} else if (part.type === "data-thoughts") {
|
|
18780
|
-
const thoughtOutputs = part.data.map((t) => t.output).filter((output) => output != null);
|
|
18781
|
-
thoughts.push(...thoughtOutputs);
|
|
18782
|
-
} else if (part.type === "data-transfer") {
|
|
18783
|
-
} else if (part.type === "step-start") {
|
|
18784
|
-
const currentTagGroup = tagStack[tagStack.length - 1];
|
|
18785
|
-
if (currentTagGroup) {
|
|
18786
|
-
currentTagGroup.lastStepStartIndex = currentTagGroup.content.length;
|
|
18787
|
-
}
|
|
18788
|
-
} else if (part.type.startsWith("tool-")) {
|
|
18789
|
-
const toolPart = part;
|
|
18790
|
-
const toolName = toolPart.toolName || toolPart.type.replace("tool-", "");
|
|
18791
|
-
addContent({
|
|
18792
|
-
type: "tool-call",
|
|
18793
|
-
toolName,
|
|
18794
|
-
input: toolPart.input,
|
|
18795
|
-
state: toolPart.state === "output-available" ? "output-available" : toolPart.state === "input-error" || toolPart.state === "output-error" ? "error" : "pending",
|
|
18796
|
-
output: toolPart.output
|
|
18797
|
-
});
|
|
18798
|
-
}
|
|
18929
|
+
const displayModeStrategy = useMemo(() => getDisplayMode(displayMode), [displayMode]);
|
|
18930
|
+
const rtnMessages = useMemo(() => {
|
|
18931
|
+
return messages.map((msg, index, array3) => {
|
|
18932
|
+
const isLastMessage = index === array3.length - 1;
|
|
18933
|
+
const isStreaming = status === "streaming";
|
|
18934
|
+
return displayModeStrategy.transform(
|
|
18935
|
+
msg,
|
|
18936
|
+
{ isLastMessage, isStreaming }
|
|
18937
|
+
);
|
|
18799
18938
|
});
|
|
18800
|
-
|
|
18801
|
-
const unfinishedGroup = tagStack.pop();
|
|
18802
|
-
if (unfinishedGroup) {
|
|
18803
|
-
sections.push({ type: "tag-group", group: unfinishedGroup });
|
|
18804
|
-
}
|
|
18805
|
-
}
|
|
18806
|
-
const isLastMessage = index === array3.length - 1;
|
|
18807
|
-
if (msg.role === "assistant" && (!isLastMessage || status !== "streaming")) {
|
|
18808
|
-
const lastPart = msg.parts.at(-1);
|
|
18809
|
-
if (lastPart && lastPart.type === "data-thoughts") {
|
|
18810
|
-
const thoughtOutputs = lastPart.data.map((t) => t.output);
|
|
18811
|
-
thoughtOutputs.forEach((t) => sections.push({ type: "content", item: t }));
|
|
18812
|
-
}
|
|
18813
|
-
}
|
|
18814
|
-
return {
|
|
18815
|
-
id: msg.id,
|
|
18816
|
-
role: msg.role,
|
|
18817
|
-
sections,
|
|
18818
|
-
thoughts
|
|
18819
|
-
};
|
|
18820
|
-
});
|
|
18939
|
+
}, [messages, status, displayModeStrategy]);
|
|
18821
18940
|
return {
|
|
18822
18941
|
messages: rtnMessages,
|
|
18823
18942
|
status,
|
|
@@ -24448,6 +24567,7 @@ function ChatWidget({
|
|
|
24448
24567
|
agentId,
|
|
24449
24568
|
agentExecutionId,
|
|
24450
24569
|
dataContext,
|
|
24570
|
+
displayMode,
|
|
24451
24571
|
onError,
|
|
24452
24572
|
onAuthError,
|
|
24453
24573
|
onFinish,
|
|
@@ -24508,6 +24628,7 @@ function ChatWidget({
|
|
|
24508
24628
|
agentId: agentId ?? void 0,
|
|
24509
24629
|
agentExecutionId: agentExecutionId ?? void 0,
|
|
24510
24630
|
dataContext,
|
|
24631
|
+
displayMode,
|
|
24511
24632
|
onError,
|
|
24512
24633
|
onAuthError,
|
|
24513
24634
|
onFinish,
|
|
@@ -24880,7 +25001,7 @@ var createWidget = ({
|
|
|
24880
25001
|
});
|
|
24881
25002
|
|
|
24882
25003
|
// lib/widgets/VendorCards.tsx
|
|
24883
|
-
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
25004
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
24884
25005
|
var vendorCardsSchema = zod_default.object({
|
|
24885
25006
|
fromLocation: zod_default.string().describe("The location the user is searching for"),
|
|
24886
25007
|
fromCoordinates: zod_default.object({
|
|
@@ -24918,6 +25039,11 @@ function VendorCards({ payload, enriched, onAddToList }) {
|
|
|
24918
25039
|
const reviewCount = data?.review_count;
|
|
24919
25040
|
const booleans = data?.booleans;
|
|
24920
25041
|
const verification = data?.verification;
|
|
25042
|
+
const cnScore = data?.quality_scores?.completeness_score;
|
|
25043
|
+
const subtypes = data?.subtype ?? [];
|
|
25044
|
+
const careLocationType = subtypes.includes("In-Home") ? "In-Home" : subtypes.includes("In-Center") ? "In-Center" : null;
|
|
25045
|
+
const backgroundCheckStatus = data?.references_and_background_check?.background_check_status?.toLowerCase();
|
|
25046
|
+
const hasBackgroundCheck = backgroundCheckStatus === "clear" || backgroundCheckStatus === "completed";
|
|
24921
25047
|
return /* @__PURE__ */ jsxs7(
|
|
24922
25048
|
"div",
|
|
24923
25049
|
{
|
|
@@ -24965,15 +25091,23 @@ function VendorCards({ payload, enriched, onAddToList }) {
|
|
|
24965
25091
|
}
|
|
24966
25092
|
)
|
|
24967
25093
|
] }),
|
|
24968
|
-
/* @__PURE__ */ jsxs7("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem", color: "#6b7280" }, children: [
|
|
24969
|
-
/* @__PURE__ */
|
|
24970
|
-
|
|
24971
|
-
|
|
24972
|
-
|
|
24973
|
-
|
|
24974
|
-
|
|
24975
|
-
|
|
25094
|
+
(reviewCount || cnScore) && /* @__PURE__ */ jsxs7("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem", color: "#6b7280" }, children: [
|
|
25095
|
+
avgRating && /* @__PURE__ */ jsxs7(Fragment, { children: [
|
|
25096
|
+
/* @__PURE__ */ jsx7("span", { style: { color: "#facc15" }, children: "\u2605" }),
|
|
25097
|
+
/* @__PURE__ */ jsx7("span", { children: avgRating.toFixed(1) }),
|
|
25098
|
+
reviewCount && /* @__PURE__ */ jsxs7("span", { style: { color: "#9ca3af" }, children: [
|
|
25099
|
+
"(",
|
|
25100
|
+
reviewCount,
|
|
25101
|
+
" reviews)"
|
|
25102
|
+
] })
|
|
25103
|
+
] }),
|
|
25104
|
+
avgRating && cnScore ? /* @__PURE__ */ jsx7("span", { style: { color: "#9ca3af" }, children: "\u2022" }) : null,
|
|
25105
|
+
cnScore ? /* @__PURE__ */ jsxs7("span", { children: [
|
|
25106
|
+
"CN Score: ",
|
|
25107
|
+
cnScore
|
|
25108
|
+
] }) : null
|
|
24976
25109
|
] }),
|
|
25110
|
+
careLocationType && /* @__PURE__ */ jsx7("div", { style: { color: "#6b7280" }, children: careLocationType }),
|
|
24977
25111
|
address && /* @__PURE__ */ jsx7("div", { style: { color: "#6b7280" }, children: address }),
|
|
24978
25112
|
distance && /* @__PURE__ */ jsxs7("div", { style: { display: "flex", alignItems: "center", gap: "0.25rem", color: "#6b7280" }, children: [
|
|
24979
25113
|
/* @__PURE__ */ jsx7("span", { children: "\u{1F4CD}" }),
|
|
@@ -25006,19 +25140,11 @@ function VendorCards({ payload, enriched, onAddToList }) {
|
|
|
25006
25140
|
}, children: [
|
|
25007
25141
|
verification?.verified && /* @__PURE__ */ jsxs7("span", { style: { display: "flex", alignItems: "center", gap: "0.25rem", color: "#22c55e", fontSize: "0.75rem" }, children: [
|
|
25008
25142
|
/* @__PURE__ */ jsx7("span", { style: { fontSize: "0.875rem" }, children: "\u2713" }),
|
|
25009
|
-
" Verified"
|
|
25143
|
+
" Wellthy Verified"
|
|
25010
25144
|
] }),
|
|
25011
|
-
|
|
25145
|
+
hasBackgroundCheck && /* @__PURE__ */ jsxs7("span", { style: { display: "flex", alignItems: "center", gap: "0.25rem", color: "#22c55e", fontSize: "0.75rem" }, children: [
|
|
25012
25146
|
/* @__PURE__ */ jsx7("span", { style: { fontSize: "0.875rem" }, children: "\u2713" }),
|
|
25013
|
-
"
|
|
25014
|
-
] }),
|
|
25015
|
-
booleans?.free_in_home_evaluation && /* @__PURE__ */ jsxs7("span", { style: { display: "flex", alignItems: "center", gap: "0.25rem", color: "#3b82f6", fontSize: "0.75rem" }, children: [
|
|
25016
|
-
/* @__PURE__ */ jsx7("span", { style: { fontSize: "0.875rem" }, children: "\u{1F3E0}" }),
|
|
25017
|
-
" Free In-Home Evaluation"
|
|
25018
|
-
] }),
|
|
25019
|
-
booleans?.can_request_same_caregiver && /* @__PURE__ */ jsxs7("span", { style: { display: "flex", alignItems: "center", gap: "0.25rem", color: "#6b7280", fontSize: "0.75rem" }, children: [
|
|
25020
|
-
/* @__PURE__ */ jsx7("span", { style: { fontSize: "0.875rem" }, children: "\u{1F464}" }),
|
|
25021
|
-
" Same Caregiver Available"
|
|
25147
|
+
" Background check"
|
|
25022
25148
|
] })
|
|
25023
25149
|
] })
|
|
25024
25150
|
]
|
|
@@ -25123,7 +25249,7 @@ var defaultChatWidgets = [
|
|
|
25123
25249
|
];
|
|
25124
25250
|
var getVendorCardsWidget = (isProd) => {
|
|
25125
25251
|
const vendorDetailsToolId = isProd ? "86dc78e28f933225750d9bcff7c94b18-CPgsswom7FkUYvplmy6H" : "CPgsswom7FkUYvplmy6H";
|
|
25126
|
-
const distanceMatrixToolId = isProd ? "
|
|
25252
|
+
const distanceMatrixToolId = isProd ? "82a0f402ed32bf51cfcb2c3baeb67d57-DwsbeKAxOctXSGgghvW8" : "DwsbeKAxOctXSGgghvW8";
|
|
25127
25253
|
return [
|
|
25128
25254
|
createWidget({
|
|
25129
25255
|
widgetType: "vendor-cards",
|
|
@@ -25149,7 +25275,12 @@ var getVendorCardsWidget = (isProd) => {
|
|
|
25149
25275
|
VendorCards,
|
|
25150
25276
|
{
|
|
25151
25277
|
payload,
|
|
25152
|
-
enriched
|
|
25278
|
+
enriched,
|
|
25279
|
+
onAddToList: (vendorId) => {
|
|
25280
|
+
window.dispatchEvent(new CustomEvent("vendor-selected", {
|
|
25281
|
+
detail: { vendorId }
|
|
25282
|
+
}));
|
|
25283
|
+
}
|
|
25153
25284
|
}
|
|
25154
25285
|
)
|
|
25155
25286
|
})
|