@usecrow/ui 0.1.8 → 0.1.9
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 +20 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -2
- package/dist/index.d.ts +24 -2
- package/dist/index.js +20 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -182,6 +182,21 @@ interface WidgetConfigResponse {
|
|
|
182
182
|
copilotStyles: CopilotStyleConfig;
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
+
/** Identity data passed to the identify function */
|
|
186
|
+
interface IdentifyData {
|
|
187
|
+
/** JWT token from your backend */
|
|
188
|
+
token: string;
|
|
189
|
+
/** User's display name */
|
|
190
|
+
name?: string;
|
|
191
|
+
/** Additional metadata */
|
|
192
|
+
[key: string]: unknown;
|
|
193
|
+
}
|
|
194
|
+
/** Function to identify a user */
|
|
195
|
+
type IdentifyFunction = (data: IdentifyData) => void;
|
|
196
|
+
/** Client-side tool handler */
|
|
197
|
+
type ToolHandler = (args: Record<string, unknown>) => Promise<unknown> | unknown;
|
|
198
|
+
/** Map of tool names to handlers */
|
|
199
|
+
type ToolsMap = Record<string, ToolHandler>;
|
|
185
200
|
interface CrowWidgetProps {
|
|
186
201
|
/** Product ID for this widget */
|
|
187
202
|
productId: string;
|
|
@@ -195,8 +210,15 @@ interface CrowWidgetProps {
|
|
|
195
210
|
previewMode?: boolean;
|
|
196
211
|
/** Callback when widget is ready */
|
|
197
212
|
onReady?: () => void;
|
|
213
|
+
/**
|
|
214
|
+
* Callback to identify the user. Called with an identify function
|
|
215
|
+
* that you should call with the user's token when available.
|
|
216
|
+
*/
|
|
217
|
+
onIdentify?: (identify: IdentifyFunction) => void;
|
|
218
|
+
/** Client-side tools the agent can call */
|
|
219
|
+
tools?: ToolsMap;
|
|
198
220
|
}
|
|
199
|
-
declare function CrowWidget({ productId, apiUrl, variant, styles: propStyles, previewMode, onReady, }: CrowWidgetProps): react_jsx_runtime.JSX.Element;
|
|
221
|
+
declare function CrowWidget({ productId, apiUrl, variant, styles: propStyles, previewMode, onReady, onIdentify, tools, }: CrowWidgetProps): react_jsx_runtime.JSX.Element;
|
|
200
222
|
|
|
201
223
|
interface CrowCopilotProps {
|
|
202
224
|
/** Product ID for this copilot */
|
|
@@ -884,4 +906,4 @@ interface WidgetHeaderProps {
|
|
|
884
906
|
}
|
|
885
907
|
declare function WidgetHeader({ isVerifiedUser, showConversationList, onNewChat, onToggleHistory, showMinimize, isMinimized, onToggleMinimize, }: WidgetHeaderProps): react_jsx_runtime.JSX.Element;
|
|
886
908
|
|
|
887
|
-
export { AVAILABLE_MODELS, type ActiveWorkflow, type AnimationsConfig, CSS_VAR_NAMES, ChatBubble, type Citation, type ClientToolHandler, type ColorsConfig, type Conversation, ConversationList, type CopilotBrandingConfig, type CopilotDimensionsConfig, type CopilotPositionConfig, type CopilotStyleConfig, CopilotStyleProvider, CrowCopilot, type CrowCopilotProps, CrowProvider, CrowWidget, type CrowWidgetProps, DEFAULT_COPILOT_STYLES, DEFAULT_MODEL, DEFAULT_WELCOME_MESSAGE, DEFAULT_WIDGET_STYLES, type JourneyEvent, LoadingHistory, MESSAGES_CONTAINER_ID, type Message, MessageBubble, MessageList, MessagesContainer, type Model, ModelSelector, PoweredByBadge, PromptInputBox, ReasoningTrace, type ResolvedCopilotStyles, type ResolvedWidgetStyles, ShadowContainer, StreamingText, ThinkingIndicator, type ToolCall, type TypographyConfig, WIDGET_CSS, type WidgetBrandingConfig, type WidgetBubbleConfig, type WidgetConfigResponse, type WidgetDimensionsConfig, WidgetHeader, type WidgetPositionConfig, type WidgetProps, type WidgetShadowsConfig, WidgetShell, type WidgetStyleConfig, WidgetStyleProvider, WorkflowPanel, type WorkflowTodo, clearStyleCache, getCssVar, injectStyles, mergeCopilotStyles, mergeWidgetStyles, stylesToCSSVariables, stylesToCssVars, useChat, useConversations, useCopilotStyleContext, useCopilotStyles$1 as useCopilotStyles, useCopilotStyles as useCopilotStylesContext, useCrowAPI, usePreviewCopilotStyles, usePreviewWidgetStyles, useWidgetStyleContext, useWidgetStyles$1 as useWidgetStyles, useWidgetStyles as useWidgetStylesContext, useWorkflow };
|
|
909
|
+
export { AVAILABLE_MODELS, type ActiveWorkflow, type AnimationsConfig, CSS_VAR_NAMES, ChatBubble, type Citation, type ClientToolHandler, type ColorsConfig, type Conversation, ConversationList, type CopilotBrandingConfig, type CopilotDimensionsConfig, type CopilotPositionConfig, type CopilotStyleConfig, CopilotStyleProvider, CrowCopilot, type CrowCopilotProps, CrowProvider, CrowWidget, type CrowWidgetProps, DEFAULT_COPILOT_STYLES, DEFAULT_MODEL, DEFAULT_WELCOME_MESSAGE, DEFAULT_WIDGET_STYLES, type IdentifyData, type IdentifyFunction, type JourneyEvent, LoadingHistory, MESSAGES_CONTAINER_ID, type Message, MessageBubble, MessageList, MessagesContainer, type Model, ModelSelector, PoweredByBadge, PromptInputBox, ReasoningTrace, type ResolvedCopilotStyles, type ResolvedWidgetStyles, ShadowContainer, StreamingText, ThinkingIndicator, type ToolCall, type ToolHandler, type ToolsMap, type TypographyConfig, WIDGET_CSS, type WidgetBrandingConfig, type WidgetBubbleConfig, type WidgetConfigResponse, type WidgetDimensionsConfig, WidgetHeader, type WidgetPositionConfig, type WidgetProps, type WidgetShadowsConfig, WidgetShell, type WidgetStyleConfig, WidgetStyleProvider, WorkflowPanel, type WorkflowTodo, clearStyleCache, getCssVar, injectStyles, mergeCopilotStyles, mergeWidgetStyles, stylesToCSSVariables, stylesToCssVars, useChat, useConversations, useCopilotStyleContext, useCopilotStyles$1 as useCopilotStyles, useCopilotStyles as useCopilotStylesContext, useCrowAPI, usePreviewCopilotStyles, usePreviewWidgetStyles, useWidgetStyleContext, useWidgetStyles$1 as useWidgetStyles, useWidgetStyles as useWidgetStylesContext, useWorkflow };
|
package/dist/index.d.ts
CHANGED
|
@@ -182,6 +182,21 @@ interface WidgetConfigResponse {
|
|
|
182
182
|
copilotStyles: CopilotStyleConfig;
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
+
/** Identity data passed to the identify function */
|
|
186
|
+
interface IdentifyData {
|
|
187
|
+
/** JWT token from your backend */
|
|
188
|
+
token: string;
|
|
189
|
+
/** User's display name */
|
|
190
|
+
name?: string;
|
|
191
|
+
/** Additional metadata */
|
|
192
|
+
[key: string]: unknown;
|
|
193
|
+
}
|
|
194
|
+
/** Function to identify a user */
|
|
195
|
+
type IdentifyFunction = (data: IdentifyData) => void;
|
|
196
|
+
/** Client-side tool handler */
|
|
197
|
+
type ToolHandler = (args: Record<string, unknown>) => Promise<unknown> | unknown;
|
|
198
|
+
/** Map of tool names to handlers */
|
|
199
|
+
type ToolsMap = Record<string, ToolHandler>;
|
|
185
200
|
interface CrowWidgetProps {
|
|
186
201
|
/** Product ID for this widget */
|
|
187
202
|
productId: string;
|
|
@@ -195,8 +210,15 @@ interface CrowWidgetProps {
|
|
|
195
210
|
previewMode?: boolean;
|
|
196
211
|
/** Callback when widget is ready */
|
|
197
212
|
onReady?: () => void;
|
|
213
|
+
/**
|
|
214
|
+
* Callback to identify the user. Called with an identify function
|
|
215
|
+
* that you should call with the user's token when available.
|
|
216
|
+
*/
|
|
217
|
+
onIdentify?: (identify: IdentifyFunction) => void;
|
|
218
|
+
/** Client-side tools the agent can call */
|
|
219
|
+
tools?: ToolsMap;
|
|
198
220
|
}
|
|
199
|
-
declare function CrowWidget({ productId, apiUrl, variant, styles: propStyles, previewMode, onReady, }: CrowWidgetProps): react_jsx_runtime.JSX.Element;
|
|
221
|
+
declare function CrowWidget({ productId, apiUrl, variant, styles: propStyles, previewMode, onReady, onIdentify, tools, }: CrowWidgetProps): react_jsx_runtime.JSX.Element;
|
|
200
222
|
|
|
201
223
|
interface CrowCopilotProps {
|
|
202
224
|
/** Product ID for this copilot */
|
|
@@ -884,4 +906,4 @@ interface WidgetHeaderProps {
|
|
|
884
906
|
}
|
|
885
907
|
declare function WidgetHeader({ isVerifiedUser, showConversationList, onNewChat, onToggleHistory, showMinimize, isMinimized, onToggleMinimize, }: WidgetHeaderProps): react_jsx_runtime.JSX.Element;
|
|
886
908
|
|
|
887
|
-
export { AVAILABLE_MODELS, type ActiveWorkflow, type AnimationsConfig, CSS_VAR_NAMES, ChatBubble, type Citation, type ClientToolHandler, type ColorsConfig, type Conversation, ConversationList, type CopilotBrandingConfig, type CopilotDimensionsConfig, type CopilotPositionConfig, type CopilotStyleConfig, CopilotStyleProvider, CrowCopilot, type CrowCopilotProps, CrowProvider, CrowWidget, type CrowWidgetProps, DEFAULT_COPILOT_STYLES, DEFAULT_MODEL, DEFAULT_WELCOME_MESSAGE, DEFAULT_WIDGET_STYLES, type JourneyEvent, LoadingHistory, MESSAGES_CONTAINER_ID, type Message, MessageBubble, MessageList, MessagesContainer, type Model, ModelSelector, PoweredByBadge, PromptInputBox, ReasoningTrace, type ResolvedCopilotStyles, type ResolvedWidgetStyles, ShadowContainer, StreamingText, ThinkingIndicator, type ToolCall, type TypographyConfig, WIDGET_CSS, type WidgetBrandingConfig, type WidgetBubbleConfig, type WidgetConfigResponse, type WidgetDimensionsConfig, WidgetHeader, type WidgetPositionConfig, type WidgetProps, type WidgetShadowsConfig, WidgetShell, type WidgetStyleConfig, WidgetStyleProvider, WorkflowPanel, type WorkflowTodo, clearStyleCache, getCssVar, injectStyles, mergeCopilotStyles, mergeWidgetStyles, stylesToCSSVariables, stylesToCssVars, useChat, useConversations, useCopilotStyleContext, useCopilotStyles$1 as useCopilotStyles, useCopilotStyles as useCopilotStylesContext, useCrowAPI, usePreviewCopilotStyles, usePreviewWidgetStyles, useWidgetStyleContext, useWidgetStyles$1 as useWidgetStyles, useWidgetStyles as useWidgetStylesContext, useWorkflow };
|
|
909
|
+
export { AVAILABLE_MODELS, type ActiveWorkflow, type AnimationsConfig, CSS_VAR_NAMES, ChatBubble, type Citation, type ClientToolHandler, type ColorsConfig, type Conversation, ConversationList, type CopilotBrandingConfig, type CopilotDimensionsConfig, type CopilotPositionConfig, type CopilotStyleConfig, CopilotStyleProvider, CrowCopilot, type CrowCopilotProps, CrowProvider, CrowWidget, type CrowWidgetProps, DEFAULT_COPILOT_STYLES, DEFAULT_MODEL, DEFAULT_WELCOME_MESSAGE, DEFAULT_WIDGET_STYLES, type IdentifyData, type IdentifyFunction, type JourneyEvent, LoadingHistory, MESSAGES_CONTAINER_ID, type Message, MessageBubble, MessageList, MessagesContainer, type Model, ModelSelector, PoweredByBadge, PromptInputBox, ReasoningTrace, type ResolvedCopilotStyles, type ResolvedWidgetStyles, ShadowContainer, StreamingText, ThinkingIndicator, type ToolCall, type ToolHandler, type ToolsMap, type TypographyConfig, WIDGET_CSS, type WidgetBrandingConfig, type WidgetBubbleConfig, type WidgetConfigResponse, type WidgetDimensionsConfig, WidgetHeader, type WidgetPositionConfig, type WidgetProps, type WidgetShadowsConfig, WidgetShell, type WidgetStyleConfig, WidgetStyleProvider, WorkflowPanel, type WorkflowTodo, clearStyleCache, getCssVar, injectStyles, mergeCopilotStyles, mergeWidgetStyles, stylesToCSSVariables, stylesToCssVars, useChat, useConversations, useCopilotStyleContext, useCopilotStyles$1 as useCopilotStyles, useCopilotStyles as useCopilotStylesContext, useCrowAPI, usePreviewCopilotStyles, usePreviewWidgetStyles, useWidgetStyleContext, useWidgetStyles$1 as useWidgetStyles, useWidgetStyles as useWidgetStylesContext, useWorkflow };
|
package/dist/index.js
CHANGED
|
@@ -2266,7 +2266,9 @@ function CrowWidget({
|
|
|
2266
2266
|
variant = "floating",
|
|
2267
2267
|
styles: propStyles,
|
|
2268
2268
|
previewMode = false,
|
|
2269
|
-
onReady
|
|
2269
|
+
onReady,
|
|
2270
|
+
onIdentify,
|
|
2271
|
+
tools
|
|
2270
2272
|
}) {
|
|
2271
2273
|
const { styles, isLoading: isLoadingStyles, agentName } = useWidgetStyles({
|
|
2272
2274
|
productId,
|
|
@@ -2399,6 +2401,23 @@ function CrowWidget({
|
|
|
2399
2401
|
onReady?.();
|
|
2400
2402
|
}
|
|
2401
2403
|
}, [isLoadingStyles, onReady]);
|
|
2404
|
+
useEffect(() => {
|
|
2405
|
+
if (!isLoadingStyles && onIdentify) {
|
|
2406
|
+
const identify = (data) => {
|
|
2407
|
+
if (!data.token) {
|
|
2408
|
+
console.error("[Crow] identify() requires a token");
|
|
2409
|
+
return;
|
|
2410
|
+
}
|
|
2411
|
+
window.crow?.("identify", data);
|
|
2412
|
+
};
|
|
2413
|
+
onIdentify(identify);
|
|
2414
|
+
}
|
|
2415
|
+
}, [isLoadingStyles, onIdentify]);
|
|
2416
|
+
useEffect(() => {
|
|
2417
|
+
if (tools && Object.keys(tools).length > 0) {
|
|
2418
|
+
window.crow?.("registerTools", tools);
|
|
2419
|
+
}
|
|
2420
|
+
}, [tools]);
|
|
2402
2421
|
const handleSend = (message) => {
|
|
2403
2422
|
if (!message.trim()) return;
|
|
2404
2423
|
setIsCollapsed(false);
|