@usecrow/ui 0.1.55 → 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 +28 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -5
- package/dist/index.d.ts +21 -5
- package/dist/index.js +28 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -384,8 +384,13 @@ interface CrowWidgetProps {
|
|
|
384
384
|
* exists for its name, that component is rendered inline in the chat.
|
|
385
385
|
*/
|
|
386
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;
|
|
387
392
|
}
|
|
388
|
-
declare function CrowWidget({ productId, apiUrl, subdomain, 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;
|
|
389
394
|
|
|
390
395
|
interface CrowCopilotProps {
|
|
391
396
|
/** Product ID for this copilot */
|
|
@@ -462,8 +467,13 @@ interface CrowCopilotProps {
|
|
|
462
467
|
* ```
|
|
463
468
|
*/
|
|
464
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;
|
|
465
475
|
}
|
|
466
|
-
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, }: 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;
|
|
467
477
|
|
|
468
478
|
interface CrowProviderProps extends CrowClientConfig {
|
|
469
479
|
children: React.ReactNode;
|
|
@@ -663,6 +673,8 @@ interface UseChatOptions {
|
|
|
663
673
|
toolConsentSettings?: Record<string, {
|
|
664
674
|
requires_consent: boolean;
|
|
665
675
|
}>;
|
|
676
|
+
/** ISO 639-1 language code (e.g., "es", "fr") — AI will respond in this language */
|
|
677
|
+
language?: string;
|
|
666
678
|
onVerificationStatus?: (isVerified: boolean) => void;
|
|
667
679
|
onConversationId?: (id: string) => void;
|
|
668
680
|
onWorkflowEvent?: (event: WorkflowEvent) => void;
|
|
@@ -670,7 +682,7 @@ interface UseChatOptions {
|
|
|
670
682
|
onToolResult?: (toolName: string, result: Record<string, unknown>) => void;
|
|
671
683
|
onRestoredConversation?: (conversationId: string) => void;
|
|
672
684
|
}
|
|
673
|
-
declare function useChat({ productId, apiUrl, persistAnonymousConversations, welcomeMessage, selectedModel: initialSelectedModel, subdomain, 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): {
|
|
674
686
|
messages: Message[];
|
|
675
687
|
isLoading: boolean;
|
|
676
688
|
activeToolCalls: ToolCall[];
|
|
@@ -817,6 +829,8 @@ interface UseWidgetStylesOptions {
|
|
|
817
829
|
skip?: boolean;
|
|
818
830
|
/** Cache key override (defaults to productId) */
|
|
819
831
|
cacheKey?: string;
|
|
832
|
+
/** ISO 639-1 language code for welcome message translation */
|
|
833
|
+
language?: string;
|
|
820
834
|
}
|
|
821
835
|
interface UseWidgetStylesResult {
|
|
822
836
|
/** Fully resolved styles ready for use */
|
|
@@ -869,6 +883,8 @@ interface UseCopilotStylesOptions {
|
|
|
869
883
|
skip?: boolean;
|
|
870
884
|
/** Cache key override (defaults to productId) */
|
|
871
885
|
cacheKey?: string;
|
|
886
|
+
/** ISO 639-1 language code for welcome message translation */
|
|
887
|
+
language?: string;
|
|
872
888
|
}
|
|
873
889
|
interface UseCopilotStylesResult {
|
|
874
890
|
/** Fully resolved styles ready for use */
|
|
@@ -914,7 +930,7 @@ interface UseCopilotStylesResult {
|
|
|
914
930
|
* });
|
|
915
931
|
* ```
|
|
916
932
|
*/
|
|
917
|
-
declare function useWidgetStyles$1({ productId, apiUrl, propStyles, skip, cacheKey, }: UseWidgetStylesOptions): UseWidgetStylesResult;
|
|
933
|
+
declare function useWidgetStyles$1({ productId, apiUrl, propStyles, skip, cacheKey, language, }: UseWidgetStylesOptions): UseWidgetStylesResult;
|
|
918
934
|
/**
|
|
919
935
|
* Hook to fetch and merge copilot styles
|
|
920
936
|
*
|
|
@@ -926,7 +942,7 @@ declare function useWidgetStyles$1({ productId, apiUrl, propStyles, skip, cacheK
|
|
|
926
942
|
* });
|
|
927
943
|
* ```
|
|
928
944
|
*/
|
|
929
|
-
declare function useCopilotStyles$1({ productId, apiUrl, propStyles, skip, cacheKey, }: UseCopilotStylesOptions): UseCopilotStylesResult;
|
|
945
|
+
declare function useCopilotStyles$1({ productId, apiUrl, propStyles, skip, cacheKey, language, }: UseCopilotStylesOptions): UseCopilotStylesResult;
|
|
930
946
|
/**
|
|
931
947
|
* Clear the style cache (useful for testing or forcing refetch)
|
|
932
948
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -384,8 +384,13 @@ interface CrowWidgetProps {
|
|
|
384
384
|
* exists for its name, that component is rendered inline in the chat.
|
|
385
385
|
*/
|
|
386
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;
|
|
387
392
|
}
|
|
388
|
-
declare function CrowWidget({ productId, apiUrl, subdomain, 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;
|
|
389
394
|
|
|
390
395
|
interface CrowCopilotProps {
|
|
391
396
|
/** Product ID for this copilot */
|
|
@@ -462,8 +467,13 @@ interface CrowCopilotProps {
|
|
|
462
467
|
* ```
|
|
463
468
|
*/
|
|
464
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;
|
|
465
475
|
}
|
|
466
|
-
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, }: 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;
|
|
467
477
|
|
|
468
478
|
interface CrowProviderProps extends CrowClientConfig {
|
|
469
479
|
children: React.ReactNode;
|
|
@@ -663,6 +673,8 @@ interface UseChatOptions {
|
|
|
663
673
|
toolConsentSettings?: Record<string, {
|
|
664
674
|
requires_consent: boolean;
|
|
665
675
|
}>;
|
|
676
|
+
/** ISO 639-1 language code (e.g., "es", "fr") — AI will respond in this language */
|
|
677
|
+
language?: string;
|
|
666
678
|
onVerificationStatus?: (isVerified: boolean) => void;
|
|
667
679
|
onConversationId?: (id: string) => void;
|
|
668
680
|
onWorkflowEvent?: (event: WorkflowEvent) => void;
|
|
@@ -670,7 +682,7 @@ interface UseChatOptions {
|
|
|
670
682
|
onToolResult?: (toolName: string, result: Record<string, unknown>) => void;
|
|
671
683
|
onRestoredConversation?: (conversationId: string) => void;
|
|
672
684
|
}
|
|
673
|
-
declare function useChat({ productId, apiUrl, persistAnonymousConversations, welcomeMessage, selectedModel: initialSelectedModel, subdomain, 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): {
|
|
674
686
|
messages: Message[];
|
|
675
687
|
isLoading: boolean;
|
|
676
688
|
activeToolCalls: ToolCall[];
|
|
@@ -817,6 +829,8 @@ interface UseWidgetStylesOptions {
|
|
|
817
829
|
skip?: boolean;
|
|
818
830
|
/** Cache key override (defaults to productId) */
|
|
819
831
|
cacheKey?: string;
|
|
832
|
+
/** ISO 639-1 language code for welcome message translation */
|
|
833
|
+
language?: string;
|
|
820
834
|
}
|
|
821
835
|
interface UseWidgetStylesResult {
|
|
822
836
|
/** Fully resolved styles ready for use */
|
|
@@ -869,6 +883,8 @@ interface UseCopilotStylesOptions {
|
|
|
869
883
|
skip?: boolean;
|
|
870
884
|
/** Cache key override (defaults to productId) */
|
|
871
885
|
cacheKey?: string;
|
|
886
|
+
/** ISO 639-1 language code for welcome message translation */
|
|
887
|
+
language?: string;
|
|
872
888
|
}
|
|
873
889
|
interface UseCopilotStylesResult {
|
|
874
890
|
/** Fully resolved styles ready for use */
|
|
@@ -914,7 +930,7 @@ interface UseCopilotStylesResult {
|
|
|
914
930
|
* });
|
|
915
931
|
* ```
|
|
916
932
|
*/
|
|
917
|
-
declare function useWidgetStyles$1({ productId, apiUrl, propStyles, skip, cacheKey, }: UseWidgetStylesOptions): UseWidgetStylesResult;
|
|
933
|
+
declare function useWidgetStyles$1({ productId, apiUrl, propStyles, skip, cacheKey, language, }: UseWidgetStylesOptions): UseWidgetStylesResult;
|
|
918
934
|
/**
|
|
919
935
|
* Hook to fetch and merge copilot styles
|
|
920
936
|
*
|
|
@@ -926,7 +942,7 @@ declare function useWidgetStyles$1({ productId, apiUrl, propStyles, skip, cacheK
|
|
|
926
942
|
* });
|
|
927
943
|
* ```
|
|
928
944
|
*/
|
|
929
|
-
declare function useCopilotStyles$1({ productId, apiUrl, propStyles, skip, cacheKey, }: UseCopilotStylesOptions): UseCopilotStylesResult;
|
|
945
|
+
declare function useCopilotStyles$1({ productId, apiUrl, propStyles, skip, cacheKey, language, }: UseCopilotStylesOptions): UseCopilotStylesResult;
|
|
930
946
|
/**
|
|
931
947
|
* Clear the style cache (useful for testing or forcing refetch)
|
|
932
948
|
*/
|
package/dist/index.js
CHANGED
|
@@ -46,6 +46,7 @@ function useChat({
|
|
|
46
46
|
selectedModel: initialSelectedModel,
|
|
47
47
|
subdomain,
|
|
48
48
|
toolConsentSettings,
|
|
49
|
+
language,
|
|
49
50
|
onVerificationStatus,
|
|
50
51
|
onConversationId,
|
|
51
52
|
onWorkflowEvent,
|
|
@@ -131,7 +132,8 @@ function useChat({
|
|
|
131
132
|
user_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
132
133
|
user_local_time: (/* @__PURE__ */ new Date()).toLocaleString("en-US", { year: "numeric", month: "long", day: "numeric", hour: "numeric", minute: "numeric", hour12: true }),
|
|
133
134
|
page_path: typeof window !== "undefined" ? window.location.pathname : void 0,
|
|
134
|
-
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 } : {}
|
|
135
137
|
}),
|
|
136
138
|
signal: abortControllerRef.current.signal
|
|
137
139
|
});
|
|
@@ -553,7 +555,8 @@ function useChat({
|
|
|
553
555
|
model: selectedModel,
|
|
554
556
|
subdomain,
|
|
555
557
|
user_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
556
|
-
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 } : {}
|
|
557
560
|
})
|
|
558
561
|
});
|
|
559
562
|
if (!response.ok) {
|
|
@@ -1514,9 +1517,12 @@ function stylesToCSSVariables(styles) {
|
|
|
1514
1517
|
|
|
1515
1518
|
// src/hooks/useWidgetStyles.ts
|
|
1516
1519
|
var styleCache = /* @__PURE__ */ new Map();
|
|
1517
|
-
async function fetchWidgetConfig(productId, apiUrl) {
|
|
1520
|
+
async function fetchWidgetConfig(productId, apiUrl, language) {
|
|
1518
1521
|
const baseUrl = apiUrl || "";
|
|
1519
|
-
|
|
1522
|
+
let url = `${baseUrl}/api/products/${productId}/widget-config`;
|
|
1523
|
+
if (language && language !== "en") {
|
|
1524
|
+
url += `?language=${encodeURIComponent(language)}`;
|
|
1525
|
+
}
|
|
1520
1526
|
const response = await fetch(url);
|
|
1521
1527
|
if (!response.ok) {
|
|
1522
1528
|
throw new Error(`Failed to fetch widget config: ${response.status} ${response.statusText}`);
|
|
@@ -1528,9 +1534,10 @@ function useWidgetStyles({
|
|
|
1528
1534
|
apiUrl,
|
|
1529
1535
|
propStyles,
|
|
1530
1536
|
skip = false,
|
|
1531
|
-
cacheKey
|
|
1537
|
+
cacheKey,
|
|
1538
|
+
language
|
|
1532
1539
|
}) {
|
|
1533
|
-
const key = cacheKey || productId;
|
|
1540
|
+
const key = cacheKey || (language && language !== "en" ? `${productId}:${language}` : productId);
|
|
1534
1541
|
const [isLoading, setIsLoading] = useState(!skip && !styleCache.has(key));
|
|
1535
1542
|
const [error, setError] = useState(null);
|
|
1536
1543
|
const [dbStyles, setDbStyles] = useState(
|
|
@@ -1570,7 +1577,7 @@ function useWidgetStyles({
|
|
|
1570
1577
|
setIsLoading(true);
|
|
1571
1578
|
setError(null);
|
|
1572
1579
|
try {
|
|
1573
|
-
const config = await fetchWidgetConfig(productId, apiUrl);
|
|
1580
|
+
const config = await fetchWidgetConfig(productId, apiUrl, language);
|
|
1574
1581
|
styleCache.set(key, config);
|
|
1575
1582
|
setDbStyles(config.widgetStyles);
|
|
1576
1583
|
setAgentName(config.agentName || "Assistant");
|
|
@@ -1630,9 +1637,10 @@ function useCopilotStyles({
|
|
|
1630
1637
|
apiUrl,
|
|
1631
1638
|
propStyles,
|
|
1632
1639
|
skip = false,
|
|
1633
|
-
cacheKey
|
|
1640
|
+
cacheKey,
|
|
1641
|
+
language
|
|
1634
1642
|
}) {
|
|
1635
|
-
const key = cacheKey || productId;
|
|
1643
|
+
const key = cacheKey || (language && language !== "en" ? `${productId}:${language}` : productId);
|
|
1636
1644
|
const [isLoading, setIsLoading] = useState(!skip && !styleCache.has(key));
|
|
1637
1645
|
const [error, setError] = useState(null);
|
|
1638
1646
|
const [dbStyles, setDbStyles] = useState(
|
|
@@ -1666,7 +1674,7 @@ function useCopilotStyles({
|
|
|
1666
1674
|
setIsLoading(true);
|
|
1667
1675
|
setError(null);
|
|
1668
1676
|
try {
|
|
1669
|
-
const config = await fetchWidgetConfig(productId, apiUrl);
|
|
1677
|
+
const config = await fetchWidgetConfig(productId, apiUrl, language);
|
|
1670
1678
|
styleCache.set(key, config);
|
|
1671
1679
|
setDbStyles(config.copilotStyles);
|
|
1672
1680
|
setAgentName(config.agentName || "Assistant");
|
|
@@ -3504,7 +3512,8 @@ function CrowWidget({
|
|
|
3504
3512
|
onToolResult,
|
|
3505
3513
|
getIdentityToken,
|
|
3506
3514
|
context,
|
|
3507
|
-
toolRenderers
|
|
3515
|
+
toolRenderers,
|
|
3516
|
+
language
|
|
3508
3517
|
}) {
|
|
3509
3518
|
const effectiveGetIdentityToken = getIdentityToken || window.__crow_identity_token_fetcher;
|
|
3510
3519
|
const effectiveOnToolResult = onToolResult || window.__crow_on_tool_result;
|
|
@@ -3526,7 +3535,8 @@ function CrowWidget({
|
|
|
3526
3535
|
productId,
|
|
3527
3536
|
apiUrl,
|
|
3528
3537
|
propStyles,
|
|
3529
|
-
skip: previewMode
|
|
3538
|
+
skip: previewMode,
|
|
3539
|
+
language
|
|
3530
3540
|
});
|
|
3531
3541
|
const agentName = agentNameProp ?? agentNameFromAPI;
|
|
3532
3542
|
const welcomeMessage = welcomeMessageProp ?? welcomeMessageFromAPI;
|
|
@@ -3566,6 +3576,7 @@ function CrowWidget({
|
|
|
3566
3576
|
selectedModel,
|
|
3567
3577
|
subdomain,
|
|
3568
3578
|
toolConsentSettings,
|
|
3579
|
+
language,
|
|
3569
3580
|
onVerificationStatus: (isVerified) => {
|
|
3570
3581
|
setIsVerifiedUser(isVerified);
|
|
3571
3582
|
},
|
|
@@ -4326,7 +4337,8 @@ function CrowCopilot({
|
|
|
4326
4337
|
onToolResult,
|
|
4327
4338
|
toolRenderers,
|
|
4328
4339
|
getIdentityToken,
|
|
4329
|
-
context
|
|
4340
|
+
context,
|
|
4341
|
+
language
|
|
4330
4342
|
}) {
|
|
4331
4343
|
const effectiveGetIdentityToken = getIdentityToken || window.__crow_identity_token_fetcher;
|
|
4332
4344
|
const effectiveOnToolResult = onToolResult || window.__crow_on_tool_result;
|
|
@@ -4346,7 +4358,8 @@ function CrowCopilot({
|
|
|
4346
4358
|
productId,
|
|
4347
4359
|
apiUrl,
|
|
4348
4360
|
propStyles,
|
|
4349
|
-
skip: previewMode
|
|
4361
|
+
skip: previewMode,
|
|
4362
|
+
language
|
|
4350
4363
|
});
|
|
4351
4364
|
const agentName = agentNameProp ?? agentNameFromAPI ?? title;
|
|
4352
4365
|
const welcomeMessage = welcomeMessageProp ?? welcomeMessageFromAPI;
|
|
@@ -4534,6 +4547,7 @@ function CrowCopilot({
|
|
|
4534
4547
|
selectedModel,
|
|
4535
4548
|
subdomain,
|
|
4536
4549
|
toolConsentSettings,
|
|
4550
|
+
language,
|
|
4537
4551
|
onVerificationStatus: (isVerified) => {
|
|
4538
4552
|
setIsVerifiedUser(isVerified);
|
|
4539
4553
|
},
|