@usecrow/ui 0.1.23 → 0.1.25

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.cts CHANGED
@@ -185,6 +185,8 @@ interface WidgetConfigResponse {
185
185
  persistAnonymousConversations?: boolean;
186
186
  /** Custom welcome message shown when chat opens. Null uses SDK default. */
187
187
  welcomeMessage?: string | null;
188
+ /** AI model to use for this product */
189
+ model?: string;
188
190
  }
189
191
 
190
192
  /** Identity data passed to the identify function */
@@ -433,6 +435,11 @@ declare function injectStyles(target?: Document | ShadowRoot): void;
433
435
  /**
434
436
  * Shared TypeScript interfaces for the widget and copilot
435
437
  */
438
+ interface ToolResultLink {
439
+ url: string;
440
+ label: string;
441
+ type?: "primary" | "secondary";
442
+ }
436
443
  interface Message {
437
444
  id: string;
438
445
  content: string;
@@ -441,6 +448,7 @@ interface Message {
441
448
  citations?: Citation[];
442
449
  thinking?: string;
443
450
  thinkingComplete?: boolean;
451
+ links?: ToolResultLink[];
444
452
  }
445
453
  interface Citation {
446
454
  document_id: string;
@@ -541,13 +549,15 @@ interface UseChatOptions {
541
549
  persistAnonymousConversations?: boolean;
542
550
  /** Custom welcome message (uses SDK default if not provided) */
543
551
  welcomeMessage?: string;
552
+ /** AI model to use for this chat (defaults to DEFAULT_MODEL) */
553
+ selectedModel?: string;
544
554
  onVerificationStatus?: (isVerified: boolean) => void;
545
555
  onConversationId?: (id: string) => void;
546
556
  onWorkflowEvent?: (event: WorkflowEvent) => void;
547
557
  onToolCall?: (toolCall: ToolCallEvent) => void;
548
558
  onRestoredConversation?: (conversationId: string) => void;
549
559
  }
550
- declare function useChat({ productId, apiUrl, persistAnonymousConversations, welcomeMessage, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onRestoredConversation, }: UseChatOptions): {
560
+ declare function useChat({ productId, apiUrl, persistAnonymousConversations, welcomeMessage, selectedModel: initialSelectedModel, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onRestoredConversation, }: UseChatOptions): {
551
561
  messages: Message[];
552
562
  isLoading: boolean;
553
563
  activeToolCalls: ToolCall[];
@@ -653,6 +663,8 @@ interface UseWidgetStylesResult {
653
663
  persistAnonymousConversations: boolean | undefined;
654
664
  /** Custom welcome message (undefined uses SDK default) */
655
665
  welcomeMessage: string | undefined;
666
+ /** AI model configured for this product */
667
+ selectedModel: string | undefined;
656
668
  /** Refetch styles from API */
657
669
  refetch: () => Promise<void>;
658
670
  }
package/dist/index.d.ts CHANGED
@@ -185,6 +185,8 @@ interface WidgetConfigResponse {
185
185
  persistAnonymousConversations?: boolean;
186
186
  /** Custom welcome message shown when chat opens. Null uses SDK default. */
187
187
  welcomeMessage?: string | null;
188
+ /** AI model to use for this product */
189
+ model?: string;
188
190
  }
189
191
 
190
192
  /** Identity data passed to the identify function */
@@ -433,6 +435,11 @@ declare function injectStyles(target?: Document | ShadowRoot): void;
433
435
  /**
434
436
  * Shared TypeScript interfaces for the widget and copilot
435
437
  */
438
+ interface ToolResultLink {
439
+ url: string;
440
+ label: string;
441
+ type?: "primary" | "secondary";
442
+ }
436
443
  interface Message {
437
444
  id: string;
438
445
  content: string;
@@ -441,6 +448,7 @@ interface Message {
441
448
  citations?: Citation[];
442
449
  thinking?: string;
443
450
  thinkingComplete?: boolean;
451
+ links?: ToolResultLink[];
444
452
  }
445
453
  interface Citation {
446
454
  document_id: string;
@@ -541,13 +549,15 @@ interface UseChatOptions {
541
549
  persistAnonymousConversations?: boolean;
542
550
  /** Custom welcome message (uses SDK default if not provided) */
543
551
  welcomeMessage?: string;
552
+ /** AI model to use for this chat (defaults to DEFAULT_MODEL) */
553
+ selectedModel?: string;
544
554
  onVerificationStatus?: (isVerified: boolean) => void;
545
555
  onConversationId?: (id: string) => void;
546
556
  onWorkflowEvent?: (event: WorkflowEvent) => void;
547
557
  onToolCall?: (toolCall: ToolCallEvent) => void;
548
558
  onRestoredConversation?: (conversationId: string) => void;
549
559
  }
550
- declare function useChat({ productId, apiUrl, persistAnonymousConversations, welcomeMessage, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onRestoredConversation, }: UseChatOptions): {
560
+ declare function useChat({ productId, apiUrl, persistAnonymousConversations, welcomeMessage, selectedModel: initialSelectedModel, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onRestoredConversation, }: UseChatOptions): {
551
561
  messages: Message[];
552
562
  isLoading: boolean;
553
563
  activeToolCalls: ToolCall[];
@@ -653,6 +663,8 @@ interface UseWidgetStylesResult {
653
663
  persistAnonymousConversations: boolean | undefined;
654
664
  /** Custom welcome message (undefined uses SDK default) */
655
665
  welcomeMessage: string | undefined;
666
+ /** AI model configured for this product */
667
+ selectedModel: string | undefined;
656
668
  /** Refetch styles from API */
657
669
  refetch: () => Promise<void>;
658
670
  }
package/dist/index.js CHANGED
@@ -47,6 +47,7 @@ function useChat({
47
47
  apiUrl = "",
48
48
  persistAnonymousConversations,
49
49
  welcomeMessage,
50
+ selectedModel: initialSelectedModel,
50
51
  onVerificationStatus,
51
52
  onConversationId,
52
53
  onWorkflowEvent,
@@ -65,9 +66,14 @@ function useChat({
65
66
  const [isLoading, setIsLoading] = useState(false);
66
67
  const [activeToolCalls, setActiveToolCalls] = useState([]);
67
68
  const [conversationId, setConversationId] = useState(null);
68
- const [selectedModel, setSelectedModel] = useState(DEFAULT_MODEL);
69
+ const [selectedModel, setSelectedModel] = useState(initialSelectedModel || DEFAULT_MODEL);
69
70
  const abortControllerRef = useRef(null);
70
71
  const hasCheckedPersistRef = useRef(false);
72
+ useEffect(() => {
73
+ if (initialSelectedModel) {
74
+ setSelectedModel((prev) => prev !== initialSelectedModel ? initialSelectedModel : prev);
75
+ }
76
+ }, [initialSelectedModel]);
71
77
  useEffect(() => {
72
78
  if (messages.length === 1 && messages[0].id === "welcome" && !conversationId) {
73
79
  setMessages([
@@ -249,6 +255,15 @@ function useChat({
249
255
  )
250
256
  );
251
257
  break;
258
+ case "tool_result_links":
259
+ if (parsed.links && Array.isArray(parsed.links)) {
260
+ setMessages(
261
+ (prev) => prev.map(
262
+ (msg) => msg.id === botMsgId ? { ...msg, links: [...msg.links || [], ...parsed.links] } : msg
263
+ )
264
+ );
265
+ }
266
+ break;
252
267
  case "client_tool_call":
253
268
  pendingClientTools.push({
254
269
  toolName: parsed.tool_name,
@@ -1093,6 +1108,9 @@ function useWidgetStyles({
1093
1108
  const [welcomeMessage, setWelcomeMessage] = useState(
1094
1109
  styleCache.get(key)?.welcomeMessage ?? void 0
1095
1110
  );
1111
+ const [selectedModel, setSelectedModel] = useState(
1112
+ styleCache.get(key)?.model ?? void 0
1113
+ );
1096
1114
  const hasFetchedRef = useRef(false);
1097
1115
  const fetchStyles = async () => {
1098
1116
  if (skip) return;
@@ -1107,6 +1125,7 @@ function useWidgetStyles({
1107
1125
  setShowThinking(config.showThinking ?? true);
1108
1126
  setPersistAnonymousConversations(config.persistAnonymousConversations ?? true);
1109
1127
  setWelcomeMessage(config.welcomeMessage ?? void 0);
1128
+ setSelectedModel(config.model ?? void 0);
1110
1129
  } catch (err) {
1111
1130
  console.error("[CrowWidget] Failed to fetch styles:", err);
1112
1131
  setError(err instanceof Error ? err : new Error(String(err)));
@@ -1124,6 +1143,7 @@ function useWidgetStyles({
1124
1143
  setShowThinking(cached.showThinking ?? true);
1125
1144
  setPersistAnonymousConversations(cached.persistAnonymousConversations ?? true);
1126
1145
  setWelcomeMessage(cached.welcomeMessage ?? void 0);
1146
+ setSelectedModel(cached.model ?? void 0);
1127
1147
  setIsLoading(false);
1128
1148
  return;
1129
1149
  }
@@ -1140,6 +1160,7 @@ function useWidgetStyles({
1140
1160
  showThinking,
1141
1161
  persistAnonymousConversations,
1142
1162
  welcomeMessage,
1163
+ selectedModel,
1143
1164
  refetch: fetchStyles
1144
1165
  };
1145
1166
  }
@@ -2735,7 +2756,8 @@ function CrowWidget({
2735
2756
  browserUseEnabled,
2736
2757
  showThinking: showThinkingFromAPI,
2737
2758
  persistAnonymousConversations,
2738
- welcomeMessage: welcomeMessageFromAPI
2759
+ welcomeMessage: welcomeMessageFromAPI,
2760
+ selectedModel: selectedModelFromAPI
2739
2761
  } = useWidgetStyles({
2740
2762
  productId,
2741
2763
  apiUrl,
@@ -2744,6 +2766,7 @@ function CrowWidget({
2744
2766
  });
2745
2767
  const agentName = agentNameProp ?? agentNameFromAPI;
2746
2768
  const welcomeMessage = welcomeMessageProp ?? welcomeMessageFromAPI;
2769
+ const selectedModel = selectedModelFromAPI ?? DEFAULT_MODEL;
2747
2770
  const showThinking = showThinkingProp ?? showThinkingFromAPI;
2748
2771
  const [autoTools, setAutoTools] = useState({});
2749
2772
  const cssVars = stylesToCssVars(styles);
@@ -2766,7 +2789,7 @@ function CrowWidget({
2766
2789
  productId,
2767
2790
  apiUrl,
2768
2791
  conversationId: null,
2769
- selectedModel: DEFAULT_MODEL
2792
+ selectedModel
2770
2793
  });
2771
2794
  const conversations = useConversations({ productId, apiUrl });
2772
2795
  const [shouldRestoreHistory, setShouldRestoreHistory] = useState(false);
@@ -2776,6 +2799,7 @@ function CrowWidget({
2776
2799
  apiUrl,
2777
2800
  persistAnonymousConversations,
2778
2801
  welcomeMessage,
2802
+ selectedModel,
2779
2803
  onVerificationStatus: (isVerified) => {
2780
2804
  setIsVerifiedUser(isVerified);
2781
2805
  },