@usecrow/ui 0.1.54 → 0.1.56
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.cjs +40 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -6
- package/dist/index.d.ts +28 -6
- package/dist/index.js +40 -18
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -341,6 +341,8 @@ interface CrowWidgetProps {
|
|
|
341
341
|
productId: string;
|
|
342
342
|
/** API URL (defaults to relative path) */
|
|
343
343
|
apiUrl?: string;
|
|
344
|
+
/** Subdomain for multi-endpoint routing */
|
|
345
|
+
subdomain?: string;
|
|
344
346
|
/** Widget variant: floating (with bubble) or embedded (for preview) */
|
|
345
347
|
variant?: "floating" | "embedded";
|
|
346
348
|
/** Custom styles to override DB and default styles */
|
|
@@ -382,14 +384,21 @@ interface CrowWidgetProps {
|
|
|
382
384
|
* exists for its name, that component is rendered inline in the chat.
|
|
383
385
|
*/
|
|
384
386
|
toolRenderers?: ToolRenderers;
|
|
387
|
+
/**
|
|
388
|
+
* ISO 639-1 language code (e.g., "es", "fr", "ja"). When set, the AI
|
|
389
|
+
* responds in that language and the welcome message is translated.
|
|
390
|
+
*/
|
|
391
|
+
language?: string;
|
|
385
392
|
}
|
|
386
|
-
declare function CrowWidget({ productId, apiUrl, variant, styles: propStyles, previewMode, showThinking: showThinkingProp, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, onReady, onIdentify, tools, navigate, onToolResult, getIdentityToken, context, toolRenderers, }: CrowWidgetProps): react_jsx_runtime.JSX.Element;
|
|
393
|
+
declare function CrowWidget({ productId, apiUrl, subdomain, variant, styles: propStyles, previewMode, showThinking: showThinkingProp, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, onReady, onIdentify, tools, navigate, onToolResult, getIdentityToken, context, toolRenderers, language, }: CrowWidgetProps): react_jsx_runtime.JSX.Element;
|
|
387
394
|
|
|
388
395
|
interface CrowCopilotProps {
|
|
389
396
|
/** Product ID for this copilot */
|
|
390
397
|
productId: string;
|
|
391
398
|
/** API URL (defaults to relative path) */
|
|
392
399
|
apiUrl?: string;
|
|
400
|
+
/** Subdomain for multi-endpoint routing */
|
|
401
|
+
subdomain?: string;
|
|
393
402
|
/** Copilot variant: embedded (in-app) or floating (with toggle button) */
|
|
394
403
|
variant?: "embedded" | "floating";
|
|
395
404
|
/** Title shown in header (fallback if agentName not provided) */
|
|
@@ -458,8 +467,13 @@ interface CrowCopilotProps {
|
|
|
458
467
|
* ```
|
|
459
468
|
*/
|
|
460
469
|
context?: Record<string, unknown>;
|
|
470
|
+
/**
|
|
471
|
+
* ISO 639-1 language code (e.g., "es", "fr", "ja"). When set, the AI
|
|
472
|
+
* responds in that language and the welcome message is translated.
|
|
473
|
+
*/
|
|
474
|
+
language?: string;
|
|
461
475
|
}
|
|
462
|
-
declare function CrowCopilot({ productId, apiUrl, variant, title, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, position, width, defaultOpen, showClose, onClose, styles: propStyles, previewMode, className, onReady, navigate, onToolResult, toolRenderers, getIdentityToken, context, }: CrowCopilotProps): react_jsx_runtime.JSX.Element;
|
|
476
|
+
declare function CrowCopilot({ productId, apiUrl, subdomain, variant, title, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, position, width, defaultOpen, showClose, onClose, styles: propStyles, previewMode, className, onReady, navigate, onToolResult, toolRenderers, getIdentityToken, context, language, }: CrowCopilotProps): react_jsx_runtime.JSX.Element;
|
|
463
477
|
|
|
464
478
|
interface CrowProviderProps extends CrowClientConfig {
|
|
465
479
|
children: React.ReactNode;
|
|
@@ -467,7 +481,7 @@ interface CrowProviderProps extends CrowClientConfig {
|
|
|
467
481
|
/**
|
|
468
482
|
* Provider component that creates and shares a CrowClient instance
|
|
469
483
|
*/
|
|
470
|
-
declare function CrowProvider({ children, productId, apiUrl, model, }: CrowProviderProps): react_jsx_runtime.JSX.Element;
|
|
484
|
+
declare function CrowProvider({ children, productId, apiUrl, model, subdomain, }: CrowProviderProps): react_jsx_runtime.JSX.Element;
|
|
471
485
|
|
|
472
486
|
/**
|
|
473
487
|
* Default Widget and Copilot Styles
|
|
@@ -653,10 +667,14 @@ interface UseChatOptions {
|
|
|
653
667
|
welcomeMessage?: string;
|
|
654
668
|
/** AI model to use for this chat (defaults to DEFAULT_MODEL) */
|
|
655
669
|
selectedModel?: string;
|
|
670
|
+
/** Subdomain for multi-endpoint products (routes to specific backend config) */
|
|
671
|
+
subdomain?: string;
|
|
656
672
|
/** Per-tool consent settings — when a tool has requires_consent, show Allow/Deny before executing */
|
|
657
673
|
toolConsentSettings?: Record<string, {
|
|
658
674
|
requires_consent: boolean;
|
|
659
675
|
}>;
|
|
676
|
+
/** ISO 639-1 language code (e.g., "es", "fr") — AI will respond in this language */
|
|
677
|
+
language?: string;
|
|
660
678
|
onVerificationStatus?: (isVerified: boolean) => void;
|
|
661
679
|
onConversationId?: (id: string) => void;
|
|
662
680
|
onWorkflowEvent?: (event: WorkflowEvent) => void;
|
|
@@ -664,7 +682,7 @@ interface UseChatOptions {
|
|
|
664
682
|
onToolResult?: (toolName: string, result: Record<string, unknown>) => void;
|
|
665
683
|
onRestoredConversation?: (conversationId: string) => void;
|
|
666
684
|
}
|
|
667
|
-
declare function useChat({ productId, apiUrl, persistAnonymousConversations, welcomeMessage, selectedModel: initialSelectedModel, toolConsentSettings, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onToolResult, onRestoredConversation, }: UseChatOptions): {
|
|
685
|
+
declare function useChat({ productId, apiUrl, persistAnonymousConversations, welcomeMessage, selectedModel: initialSelectedModel, subdomain, toolConsentSettings, language, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onToolResult, onRestoredConversation, }: UseChatOptions): {
|
|
668
686
|
messages: Message[];
|
|
669
687
|
isLoading: boolean;
|
|
670
688
|
activeToolCalls: ToolCall[];
|
|
@@ -811,6 +829,8 @@ interface UseWidgetStylesOptions {
|
|
|
811
829
|
skip?: boolean;
|
|
812
830
|
/** Cache key override (defaults to productId) */
|
|
813
831
|
cacheKey?: string;
|
|
832
|
+
/** ISO 639-1 language code for welcome message translation */
|
|
833
|
+
language?: string;
|
|
814
834
|
}
|
|
815
835
|
interface UseWidgetStylesResult {
|
|
816
836
|
/** Fully resolved styles ready for use */
|
|
@@ -863,6 +883,8 @@ interface UseCopilotStylesOptions {
|
|
|
863
883
|
skip?: boolean;
|
|
864
884
|
/** Cache key override (defaults to productId) */
|
|
865
885
|
cacheKey?: string;
|
|
886
|
+
/** ISO 639-1 language code for welcome message translation */
|
|
887
|
+
language?: string;
|
|
866
888
|
}
|
|
867
889
|
interface UseCopilotStylesResult {
|
|
868
890
|
/** Fully resolved styles ready for use */
|
|
@@ -908,7 +930,7 @@ interface UseCopilotStylesResult {
|
|
|
908
930
|
* });
|
|
909
931
|
* ```
|
|
910
932
|
*/
|
|
911
|
-
declare function useWidgetStyles$1({ productId, apiUrl, propStyles, skip, cacheKey, }: UseWidgetStylesOptions): UseWidgetStylesResult;
|
|
933
|
+
declare function useWidgetStyles$1({ productId, apiUrl, propStyles, skip, cacheKey, language, }: UseWidgetStylesOptions): UseWidgetStylesResult;
|
|
912
934
|
/**
|
|
913
935
|
* Hook to fetch and merge copilot styles
|
|
914
936
|
*
|
|
@@ -920,7 +942,7 @@ declare function useWidgetStyles$1({ productId, apiUrl, propStyles, skip, cacheK
|
|
|
920
942
|
* });
|
|
921
943
|
* ```
|
|
922
944
|
*/
|
|
923
|
-
declare function useCopilotStyles$1({ productId, apiUrl, propStyles, skip, cacheKey, }: UseCopilotStylesOptions): UseCopilotStylesResult;
|
|
945
|
+
declare function useCopilotStyles$1({ productId, apiUrl, propStyles, skip, cacheKey, language, }: UseCopilotStylesOptions): UseCopilotStylesResult;
|
|
924
946
|
/**
|
|
925
947
|
* Clear the style cache (useful for testing or forcing refetch)
|
|
926
948
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -341,6 +341,8 @@ interface CrowWidgetProps {
|
|
|
341
341
|
productId: string;
|
|
342
342
|
/** API URL (defaults to relative path) */
|
|
343
343
|
apiUrl?: string;
|
|
344
|
+
/** Subdomain for multi-endpoint routing */
|
|
345
|
+
subdomain?: string;
|
|
344
346
|
/** Widget variant: floating (with bubble) or embedded (for preview) */
|
|
345
347
|
variant?: "floating" | "embedded";
|
|
346
348
|
/** Custom styles to override DB and default styles */
|
|
@@ -382,14 +384,21 @@ interface CrowWidgetProps {
|
|
|
382
384
|
* exists for its name, that component is rendered inline in the chat.
|
|
383
385
|
*/
|
|
384
386
|
toolRenderers?: ToolRenderers;
|
|
387
|
+
/**
|
|
388
|
+
* ISO 639-1 language code (e.g., "es", "fr", "ja"). When set, the AI
|
|
389
|
+
* responds in that language and the welcome message is translated.
|
|
390
|
+
*/
|
|
391
|
+
language?: string;
|
|
385
392
|
}
|
|
386
|
-
declare function CrowWidget({ productId, apiUrl, variant, styles: propStyles, previewMode, showThinking: showThinkingProp, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, onReady, onIdentify, tools, navigate, onToolResult, getIdentityToken, context, toolRenderers, }: CrowWidgetProps): react_jsx_runtime.JSX.Element;
|
|
393
|
+
declare function CrowWidget({ productId, apiUrl, subdomain, variant, styles: propStyles, previewMode, showThinking: showThinkingProp, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, onReady, onIdentify, tools, navigate, onToolResult, getIdentityToken, context, toolRenderers, language, }: CrowWidgetProps): react_jsx_runtime.JSX.Element;
|
|
387
394
|
|
|
388
395
|
interface CrowCopilotProps {
|
|
389
396
|
/** Product ID for this copilot */
|
|
390
397
|
productId: string;
|
|
391
398
|
/** API URL (defaults to relative path) */
|
|
392
399
|
apiUrl?: string;
|
|
400
|
+
/** Subdomain for multi-endpoint routing */
|
|
401
|
+
subdomain?: string;
|
|
393
402
|
/** Copilot variant: embedded (in-app) or floating (with toggle button) */
|
|
394
403
|
variant?: "embedded" | "floating";
|
|
395
404
|
/** Title shown in header (fallback if agentName not provided) */
|
|
@@ -458,8 +467,13 @@ interface CrowCopilotProps {
|
|
|
458
467
|
* ```
|
|
459
468
|
*/
|
|
460
469
|
context?: Record<string, unknown>;
|
|
470
|
+
/**
|
|
471
|
+
* ISO 639-1 language code (e.g., "es", "fr", "ja"). When set, the AI
|
|
472
|
+
* responds in that language and the welcome message is translated.
|
|
473
|
+
*/
|
|
474
|
+
language?: string;
|
|
461
475
|
}
|
|
462
|
-
declare function CrowCopilot({ productId, apiUrl, variant, title, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, position, width, defaultOpen, showClose, onClose, styles: propStyles, previewMode, className, onReady, navigate, onToolResult, toolRenderers, getIdentityToken, context, }: CrowCopilotProps): react_jsx_runtime.JSX.Element;
|
|
476
|
+
declare function CrowCopilot({ productId, apiUrl, subdomain, variant, title, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, position, width, defaultOpen, showClose, onClose, styles: propStyles, previewMode, className, onReady, navigate, onToolResult, toolRenderers, getIdentityToken, context, language, }: CrowCopilotProps): react_jsx_runtime.JSX.Element;
|
|
463
477
|
|
|
464
478
|
interface CrowProviderProps extends CrowClientConfig {
|
|
465
479
|
children: React.ReactNode;
|
|
@@ -467,7 +481,7 @@ interface CrowProviderProps extends CrowClientConfig {
|
|
|
467
481
|
/**
|
|
468
482
|
* Provider component that creates and shares a CrowClient instance
|
|
469
483
|
*/
|
|
470
|
-
declare function CrowProvider({ children, productId, apiUrl, model, }: CrowProviderProps): react_jsx_runtime.JSX.Element;
|
|
484
|
+
declare function CrowProvider({ children, productId, apiUrl, model, subdomain, }: CrowProviderProps): react_jsx_runtime.JSX.Element;
|
|
471
485
|
|
|
472
486
|
/**
|
|
473
487
|
* Default Widget and Copilot Styles
|
|
@@ -653,10 +667,14 @@ interface UseChatOptions {
|
|
|
653
667
|
welcomeMessage?: string;
|
|
654
668
|
/** AI model to use for this chat (defaults to DEFAULT_MODEL) */
|
|
655
669
|
selectedModel?: string;
|
|
670
|
+
/** Subdomain for multi-endpoint products (routes to specific backend config) */
|
|
671
|
+
subdomain?: string;
|
|
656
672
|
/** Per-tool consent settings — when a tool has requires_consent, show Allow/Deny before executing */
|
|
657
673
|
toolConsentSettings?: Record<string, {
|
|
658
674
|
requires_consent: boolean;
|
|
659
675
|
}>;
|
|
676
|
+
/** ISO 639-1 language code (e.g., "es", "fr") — AI will respond in this language */
|
|
677
|
+
language?: string;
|
|
660
678
|
onVerificationStatus?: (isVerified: boolean) => void;
|
|
661
679
|
onConversationId?: (id: string) => void;
|
|
662
680
|
onWorkflowEvent?: (event: WorkflowEvent) => void;
|
|
@@ -664,7 +682,7 @@ interface UseChatOptions {
|
|
|
664
682
|
onToolResult?: (toolName: string, result: Record<string, unknown>) => void;
|
|
665
683
|
onRestoredConversation?: (conversationId: string) => void;
|
|
666
684
|
}
|
|
667
|
-
declare function useChat({ productId, apiUrl, persistAnonymousConversations, welcomeMessage, selectedModel: initialSelectedModel, toolConsentSettings, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onToolResult, onRestoredConversation, }: UseChatOptions): {
|
|
685
|
+
declare function useChat({ productId, apiUrl, persistAnonymousConversations, welcomeMessage, selectedModel: initialSelectedModel, subdomain, toolConsentSettings, language, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onToolResult, onRestoredConversation, }: UseChatOptions): {
|
|
668
686
|
messages: Message[];
|
|
669
687
|
isLoading: boolean;
|
|
670
688
|
activeToolCalls: ToolCall[];
|
|
@@ -811,6 +829,8 @@ interface UseWidgetStylesOptions {
|
|
|
811
829
|
skip?: boolean;
|
|
812
830
|
/** Cache key override (defaults to productId) */
|
|
813
831
|
cacheKey?: string;
|
|
832
|
+
/** ISO 639-1 language code for welcome message translation */
|
|
833
|
+
language?: string;
|
|
814
834
|
}
|
|
815
835
|
interface UseWidgetStylesResult {
|
|
816
836
|
/** Fully resolved styles ready for use */
|
|
@@ -863,6 +883,8 @@ interface UseCopilotStylesOptions {
|
|
|
863
883
|
skip?: boolean;
|
|
864
884
|
/** Cache key override (defaults to productId) */
|
|
865
885
|
cacheKey?: string;
|
|
886
|
+
/** ISO 639-1 language code for welcome message translation */
|
|
887
|
+
language?: string;
|
|
866
888
|
}
|
|
867
889
|
interface UseCopilotStylesResult {
|
|
868
890
|
/** Fully resolved styles ready for use */
|
|
@@ -908,7 +930,7 @@ interface UseCopilotStylesResult {
|
|
|
908
930
|
* });
|
|
909
931
|
* ```
|
|
910
932
|
*/
|
|
911
|
-
declare function useWidgetStyles$1({ productId, apiUrl, propStyles, skip, cacheKey, }: UseWidgetStylesOptions): UseWidgetStylesResult;
|
|
933
|
+
declare function useWidgetStyles$1({ productId, apiUrl, propStyles, skip, cacheKey, language, }: UseWidgetStylesOptions): UseWidgetStylesResult;
|
|
912
934
|
/**
|
|
913
935
|
* Hook to fetch and merge copilot styles
|
|
914
936
|
*
|
|
@@ -920,7 +942,7 @@ declare function useWidgetStyles$1({ productId, apiUrl, propStyles, skip, cacheK
|
|
|
920
942
|
* });
|
|
921
943
|
* ```
|
|
922
944
|
*/
|
|
923
|
-
declare function useCopilotStyles$1({ productId, apiUrl, propStyles, skip, cacheKey, }: UseCopilotStylesOptions): UseCopilotStylesResult;
|
|
945
|
+
declare function useCopilotStyles$1({ productId, apiUrl, propStyles, skip, cacheKey, language, }: UseCopilotStylesOptions): UseCopilotStylesResult;
|
|
924
946
|
/**
|
|
925
947
|
* Clear the style cache (useful for testing or forcing refetch)
|
|
926
948
|
*/
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,9 @@ function useChat({
|
|
|
44
44
|
persistAnonymousConversations,
|
|
45
45
|
welcomeMessage,
|
|
46
46
|
selectedModel: initialSelectedModel,
|
|
47
|
+
subdomain,
|
|
47
48
|
toolConsentSettings,
|
|
49
|
+
language,
|
|
48
50
|
onVerificationStatus,
|
|
49
51
|
onConversationId,
|
|
50
52
|
onWorkflowEvent,
|
|
@@ -126,10 +128,12 @@ function useChat({
|
|
|
126
128
|
conversation_id: conversationId,
|
|
127
129
|
identity_token: identityToken,
|
|
128
130
|
model: selectedModel,
|
|
131
|
+
subdomain,
|
|
129
132
|
user_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
130
133
|
user_local_time: (/* @__PURE__ */ new Date()).toLocaleString("en-US", { year: "numeric", month: "long", day: "numeric", hour: "numeric", minute: "numeric", hour12: true }),
|
|
131
134
|
page_path: typeof window !== "undefined" ? window.location.pathname : void 0,
|
|
132
|
-
context: typeof window !== "undefined" ? window.__crow_page_context : void 0
|
|
135
|
+
context: typeof window !== "undefined" ? window.__crow_page_context : void 0,
|
|
136
|
+
...language && language !== "en" ? { language } : {}
|
|
133
137
|
}),
|
|
134
138
|
signal: abortControllerRef.current.signal
|
|
135
139
|
});
|
|
@@ -458,7 +462,7 @@ function useChat({
|
|
|
458
462
|
abortControllerRef.current = null;
|
|
459
463
|
}
|
|
460
464
|
},
|
|
461
|
-
[apiUrl, productId, conversationId, selectedModel, persistAnonymousConversations, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onToolResult]
|
|
465
|
+
[apiUrl, productId, conversationId, selectedModel, subdomain, persistAnonymousConversations, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onToolResult]
|
|
462
466
|
);
|
|
463
467
|
const sendMessage = useCallback(
|
|
464
468
|
(content) => {
|
|
@@ -549,8 +553,10 @@ function useChat({
|
|
|
549
553
|
result,
|
|
550
554
|
identity_token: identityToken,
|
|
551
555
|
model: selectedModel,
|
|
556
|
+
subdomain,
|
|
552
557
|
user_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
553
|
-
user_local_time: (/* @__PURE__ */ new Date()).toLocaleString("en-US", { year: "numeric", month: "long", day: "numeric", hour: "numeric", minute: "numeric", hour12: true })
|
|
558
|
+
user_local_time: (/* @__PURE__ */ new Date()).toLocaleString("en-US", { year: "numeric", month: "long", day: "numeric", hour: "numeric", minute: "numeric", hour12: true }),
|
|
559
|
+
...language && language !== "en" ? { language } : {}
|
|
554
560
|
})
|
|
555
561
|
});
|
|
556
562
|
if (!response.ok) {
|
|
@@ -827,7 +833,7 @@ function useChat({
|
|
|
827
833
|
setIsLoading(false);
|
|
828
834
|
}
|
|
829
835
|
},
|
|
830
|
-
[apiUrl, productId, conversationId, selectedModel]
|
|
836
|
+
[apiUrl, productId, conversationId, selectedModel, subdomain]
|
|
831
837
|
);
|
|
832
838
|
const addMessage = useCallback(
|
|
833
839
|
async (role, content) => {
|
|
@@ -1511,9 +1517,12 @@ function stylesToCSSVariables(styles) {
|
|
|
1511
1517
|
|
|
1512
1518
|
// src/hooks/useWidgetStyles.ts
|
|
1513
1519
|
var styleCache = /* @__PURE__ */ new Map();
|
|
1514
|
-
async function fetchWidgetConfig(productId, apiUrl) {
|
|
1520
|
+
async function fetchWidgetConfig(productId, apiUrl, language) {
|
|
1515
1521
|
const baseUrl = apiUrl || "";
|
|
1516
|
-
|
|
1522
|
+
let url = `${baseUrl}/api/products/${productId}/widget-config`;
|
|
1523
|
+
if (language && language !== "en") {
|
|
1524
|
+
url += `?language=${encodeURIComponent(language)}`;
|
|
1525
|
+
}
|
|
1517
1526
|
const response = await fetch(url);
|
|
1518
1527
|
if (!response.ok) {
|
|
1519
1528
|
throw new Error(`Failed to fetch widget config: ${response.status} ${response.statusText}`);
|
|
@@ -1525,9 +1534,10 @@ function useWidgetStyles({
|
|
|
1525
1534
|
apiUrl,
|
|
1526
1535
|
propStyles,
|
|
1527
1536
|
skip = false,
|
|
1528
|
-
cacheKey
|
|
1537
|
+
cacheKey,
|
|
1538
|
+
language
|
|
1529
1539
|
}) {
|
|
1530
|
-
const key = cacheKey || productId;
|
|
1540
|
+
const key = cacheKey || (language && language !== "en" ? `${productId}:${language}` : productId);
|
|
1531
1541
|
const [isLoading, setIsLoading] = useState(!skip && !styleCache.has(key));
|
|
1532
1542
|
const [error, setError] = useState(null);
|
|
1533
1543
|
const [dbStyles, setDbStyles] = useState(
|
|
@@ -1567,7 +1577,7 @@ function useWidgetStyles({
|
|
|
1567
1577
|
setIsLoading(true);
|
|
1568
1578
|
setError(null);
|
|
1569
1579
|
try {
|
|
1570
|
-
const config = await fetchWidgetConfig(productId, apiUrl);
|
|
1580
|
+
const config = await fetchWidgetConfig(productId, apiUrl, language);
|
|
1571
1581
|
styleCache.set(key, config);
|
|
1572
1582
|
setDbStyles(config.widgetStyles);
|
|
1573
1583
|
setAgentName(config.agentName || "Assistant");
|
|
@@ -1627,9 +1637,10 @@ function useCopilotStyles({
|
|
|
1627
1637
|
apiUrl,
|
|
1628
1638
|
propStyles,
|
|
1629
1639
|
skip = false,
|
|
1630
|
-
cacheKey
|
|
1640
|
+
cacheKey,
|
|
1641
|
+
language
|
|
1631
1642
|
}) {
|
|
1632
|
-
const key = cacheKey || productId;
|
|
1643
|
+
const key = cacheKey || (language && language !== "en" ? `${productId}:${language}` : productId);
|
|
1633
1644
|
const [isLoading, setIsLoading] = useState(!skip && !styleCache.has(key));
|
|
1634
1645
|
const [error, setError] = useState(null);
|
|
1635
1646
|
const [dbStyles, setDbStyles] = useState(
|
|
@@ -1663,7 +1674,7 @@ function useCopilotStyles({
|
|
|
1663
1674
|
setIsLoading(true);
|
|
1664
1675
|
setError(null);
|
|
1665
1676
|
try {
|
|
1666
|
-
const config = await fetchWidgetConfig(productId, apiUrl);
|
|
1677
|
+
const config = await fetchWidgetConfig(productId, apiUrl, language);
|
|
1667
1678
|
styleCache.set(key, config);
|
|
1668
1679
|
setDbStyles(config.copilotStyles);
|
|
1669
1680
|
setAgentName(config.agentName || "Assistant");
|
|
@@ -3487,6 +3498,7 @@ function injectStyles(target = document) {
|
|
|
3487
3498
|
function CrowWidget({
|
|
3488
3499
|
productId,
|
|
3489
3500
|
apiUrl = "",
|
|
3501
|
+
subdomain,
|
|
3490
3502
|
variant = "floating",
|
|
3491
3503
|
styles: propStyles,
|
|
3492
3504
|
previewMode = false,
|
|
@@ -3500,7 +3512,8 @@ function CrowWidget({
|
|
|
3500
3512
|
onToolResult,
|
|
3501
3513
|
getIdentityToken,
|
|
3502
3514
|
context,
|
|
3503
|
-
toolRenderers
|
|
3515
|
+
toolRenderers,
|
|
3516
|
+
language
|
|
3504
3517
|
}) {
|
|
3505
3518
|
const effectiveGetIdentityToken = getIdentityToken || window.__crow_identity_token_fetcher;
|
|
3506
3519
|
const effectiveOnToolResult = onToolResult || window.__crow_on_tool_result;
|
|
@@ -3522,7 +3535,8 @@ function CrowWidget({
|
|
|
3522
3535
|
productId,
|
|
3523
3536
|
apiUrl,
|
|
3524
3537
|
propStyles,
|
|
3525
|
-
skip: previewMode
|
|
3538
|
+
skip: previewMode,
|
|
3539
|
+
language
|
|
3526
3540
|
});
|
|
3527
3541
|
const agentName = agentNameProp ?? agentNameFromAPI;
|
|
3528
3542
|
const welcomeMessage = welcomeMessageProp ?? welcomeMessageFromAPI;
|
|
@@ -3560,7 +3574,9 @@ function CrowWidget({
|
|
|
3560
3574
|
persistAnonymousConversations,
|
|
3561
3575
|
welcomeMessage,
|
|
3562
3576
|
selectedModel,
|
|
3577
|
+
subdomain,
|
|
3563
3578
|
toolConsentSettings,
|
|
3579
|
+
language,
|
|
3564
3580
|
onVerificationStatus: (isVerified) => {
|
|
3565
3581
|
setIsVerifiedUser(isVerified);
|
|
3566
3582
|
},
|
|
@@ -4303,6 +4319,7 @@ function CopilotContainer({
|
|
|
4303
4319
|
function CrowCopilot({
|
|
4304
4320
|
productId,
|
|
4305
4321
|
apiUrl = "",
|
|
4322
|
+
subdomain,
|
|
4306
4323
|
variant = "embedded",
|
|
4307
4324
|
title = "Copilot",
|
|
4308
4325
|
agentName: agentNameProp,
|
|
@@ -4320,7 +4337,8 @@ function CrowCopilot({
|
|
|
4320
4337
|
onToolResult,
|
|
4321
4338
|
toolRenderers,
|
|
4322
4339
|
getIdentityToken,
|
|
4323
|
-
context
|
|
4340
|
+
context,
|
|
4341
|
+
language
|
|
4324
4342
|
}) {
|
|
4325
4343
|
const effectiveGetIdentityToken = getIdentityToken || window.__crow_identity_token_fetcher;
|
|
4326
4344
|
const effectiveOnToolResult = onToolResult || window.__crow_on_tool_result;
|
|
@@ -4340,7 +4358,8 @@ function CrowCopilot({
|
|
|
4340
4358
|
productId,
|
|
4341
4359
|
apiUrl,
|
|
4342
4360
|
propStyles,
|
|
4343
|
-
skip: previewMode
|
|
4361
|
+
skip: previewMode,
|
|
4362
|
+
language
|
|
4344
4363
|
});
|
|
4345
4364
|
const agentName = agentNameProp ?? agentNameFromAPI ?? title;
|
|
4346
4365
|
const welcomeMessage = welcomeMessageProp ?? welcomeMessageFromAPI;
|
|
@@ -4526,7 +4545,9 @@ function CrowCopilot({
|
|
|
4526
4545
|
persistAnonymousConversations,
|
|
4527
4546
|
welcomeMessage,
|
|
4528
4547
|
selectedModel,
|
|
4548
|
+
subdomain,
|
|
4529
4549
|
toolConsentSettings,
|
|
4550
|
+
language,
|
|
4530
4551
|
onVerificationStatus: (isVerified) => {
|
|
4531
4552
|
setIsVerifiedUser(isVerified);
|
|
4532
4553
|
},
|
|
@@ -5413,11 +5434,12 @@ function CrowProvider({
|
|
|
5413
5434
|
children,
|
|
5414
5435
|
productId,
|
|
5415
5436
|
apiUrl,
|
|
5416
|
-
model
|
|
5437
|
+
model,
|
|
5438
|
+
subdomain
|
|
5417
5439
|
}) {
|
|
5418
5440
|
const clientRef = useRef(null);
|
|
5419
5441
|
if (!clientRef.current) {
|
|
5420
|
-
clientRef.current = new CrowClient({ productId, apiUrl, model });
|
|
5442
|
+
clientRef.current = new CrowClient({ productId, apiUrl, model, subdomain });
|
|
5421
5443
|
}
|
|
5422
5444
|
const client = clientRef.current;
|
|
5423
5445
|
useEffect(() => {
|