@usecrow/ui 0.1.25 → 0.1.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.cjs +13 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -230,8 +230,10 @@ interface CrowWidgetProps {
|
|
|
230
230
|
onIdentify?: (identify: IdentifyFunction) => void;
|
|
231
231
|
/** Client-side tools the agent can call */
|
|
232
232
|
tools?: ToolsMap;
|
|
233
|
+
/** Callback fired when a server-side tool completes, with the tool name and full result data */
|
|
234
|
+
onToolResult?: (toolName: string, result: Record<string, unknown>) => void;
|
|
233
235
|
}
|
|
234
|
-
declare function CrowWidget({ productId, apiUrl, variant, styles: propStyles, previewMode, showThinking: showThinkingProp, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, onReady, onIdentify, tools, }: CrowWidgetProps): react_jsx_runtime.JSX.Element;
|
|
236
|
+
declare function CrowWidget({ productId, apiUrl, variant, styles: propStyles, previewMode, showThinking: showThinkingProp, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, onReady, onIdentify, tools, onToolResult, }: CrowWidgetProps): react_jsx_runtime.JSX.Element;
|
|
235
237
|
|
|
236
238
|
interface CrowCopilotProps {
|
|
237
239
|
/** Product ID for this copilot */
|
|
@@ -264,8 +266,10 @@ interface CrowCopilotProps {
|
|
|
264
266
|
className?: string;
|
|
265
267
|
/** Callback when copilot is ready */
|
|
266
268
|
onReady?: () => void;
|
|
269
|
+
/** Callback fired when a server-side tool completes, with the tool name and full result data */
|
|
270
|
+
onToolResult?: (toolName: string, result: Record<string, unknown>) => void;
|
|
267
271
|
}
|
|
268
|
-
declare function CrowCopilot({ productId, apiUrl, variant, title, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, position, width, defaultOpen, showClose, onClose, styles: propStyles, previewMode, className, onReady, }: CrowCopilotProps): react_jsx_runtime.JSX.Element;
|
|
272
|
+
declare function CrowCopilot({ productId, apiUrl, variant, title, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, position, width, defaultOpen, showClose, onClose, styles: propStyles, previewMode, className, onReady, onToolResult, }: CrowCopilotProps): react_jsx_runtime.JSX.Element;
|
|
269
273
|
|
|
270
274
|
interface CrowProviderProps extends CrowClientConfig {
|
|
271
275
|
children: React.ReactNode;
|
|
@@ -555,9 +559,10 @@ interface UseChatOptions {
|
|
|
555
559
|
onConversationId?: (id: string) => void;
|
|
556
560
|
onWorkflowEvent?: (event: WorkflowEvent) => void;
|
|
557
561
|
onToolCall?: (toolCall: ToolCallEvent) => void;
|
|
562
|
+
onToolResult?: (toolName: string, result: Record<string, unknown>) => void;
|
|
558
563
|
onRestoredConversation?: (conversationId: string) => void;
|
|
559
564
|
}
|
|
560
|
-
declare function useChat({ productId, apiUrl, persistAnonymousConversations, welcomeMessage, selectedModel: initialSelectedModel, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onRestoredConversation, }: UseChatOptions): {
|
|
565
|
+
declare function useChat({ productId, apiUrl, persistAnonymousConversations, welcomeMessage, selectedModel: initialSelectedModel, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onToolResult, onRestoredConversation, }: UseChatOptions): {
|
|
561
566
|
messages: Message[];
|
|
562
567
|
isLoading: boolean;
|
|
563
568
|
activeToolCalls: ToolCall[];
|
package/dist/index.d.ts
CHANGED
|
@@ -230,8 +230,10 @@ interface CrowWidgetProps {
|
|
|
230
230
|
onIdentify?: (identify: IdentifyFunction) => void;
|
|
231
231
|
/** Client-side tools the agent can call */
|
|
232
232
|
tools?: ToolsMap;
|
|
233
|
+
/** Callback fired when a server-side tool completes, with the tool name and full result data */
|
|
234
|
+
onToolResult?: (toolName: string, result: Record<string, unknown>) => void;
|
|
233
235
|
}
|
|
234
|
-
declare function CrowWidget({ productId, apiUrl, variant, styles: propStyles, previewMode, showThinking: showThinkingProp, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, onReady, onIdentify, tools, }: CrowWidgetProps): react_jsx_runtime.JSX.Element;
|
|
236
|
+
declare function CrowWidget({ productId, apiUrl, variant, styles: propStyles, previewMode, showThinking: showThinkingProp, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, onReady, onIdentify, tools, onToolResult, }: CrowWidgetProps): react_jsx_runtime.JSX.Element;
|
|
235
237
|
|
|
236
238
|
interface CrowCopilotProps {
|
|
237
239
|
/** Product ID for this copilot */
|
|
@@ -264,8 +266,10 @@ interface CrowCopilotProps {
|
|
|
264
266
|
className?: string;
|
|
265
267
|
/** Callback when copilot is ready */
|
|
266
268
|
onReady?: () => void;
|
|
269
|
+
/** Callback fired when a server-side tool completes, with the tool name and full result data */
|
|
270
|
+
onToolResult?: (toolName: string, result: Record<string, unknown>) => void;
|
|
267
271
|
}
|
|
268
|
-
declare function CrowCopilot({ productId, apiUrl, variant, title, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, position, width, defaultOpen, showClose, onClose, styles: propStyles, previewMode, className, onReady, }: CrowCopilotProps): react_jsx_runtime.JSX.Element;
|
|
272
|
+
declare function CrowCopilot({ productId, apiUrl, variant, title, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, position, width, defaultOpen, showClose, onClose, styles: propStyles, previewMode, className, onReady, onToolResult, }: CrowCopilotProps): react_jsx_runtime.JSX.Element;
|
|
269
273
|
|
|
270
274
|
interface CrowProviderProps extends CrowClientConfig {
|
|
271
275
|
children: React.ReactNode;
|
|
@@ -555,9 +559,10 @@ interface UseChatOptions {
|
|
|
555
559
|
onConversationId?: (id: string) => void;
|
|
556
560
|
onWorkflowEvent?: (event: WorkflowEvent) => void;
|
|
557
561
|
onToolCall?: (toolCall: ToolCallEvent) => void;
|
|
562
|
+
onToolResult?: (toolName: string, result: Record<string, unknown>) => void;
|
|
558
563
|
onRestoredConversation?: (conversationId: string) => void;
|
|
559
564
|
}
|
|
560
|
-
declare function useChat({ productId, apiUrl, persistAnonymousConversations, welcomeMessage, selectedModel: initialSelectedModel, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onRestoredConversation, }: UseChatOptions): {
|
|
565
|
+
declare function useChat({ productId, apiUrl, persistAnonymousConversations, welcomeMessage, selectedModel: initialSelectedModel, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onToolResult, onRestoredConversation, }: UseChatOptions): {
|
|
561
566
|
messages: Message[];
|
|
562
567
|
isLoading: boolean;
|
|
563
568
|
activeToolCalls: ToolCall[];
|
package/dist/index.js
CHANGED
|
@@ -52,6 +52,7 @@ function useChat({
|
|
|
52
52
|
onConversationId,
|
|
53
53
|
onWorkflowEvent,
|
|
54
54
|
onToolCall,
|
|
55
|
+
onToolResult,
|
|
55
56
|
onRestoredConversation
|
|
56
57
|
}) {
|
|
57
58
|
const effectiveWelcomeMessage = welcomeMessage || DEFAULT_WELCOME_MESSAGE;
|
|
@@ -264,6 +265,11 @@ function useChat({
|
|
|
264
265
|
);
|
|
265
266
|
}
|
|
266
267
|
break;
|
|
268
|
+
case "tool_result":
|
|
269
|
+
if (parsed.tool_name && parsed.result) {
|
|
270
|
+
onToolResult?.(parsed.tool_name, parsed.result);
|
|
271
|
+
}
|
|
272
|
+
break;
|
|
267
273
|
case "client_tool_call":
|
|
268
274
|
pendingClientTools.push({
|
|
269
275
|
toolName: parsed.tool_name,
|
|
@@ -323,7 +329,7 @@ function useChat({
|
|
|
323
329
|
abortControllerRef.current = null;
|
|
324
330
|
}
|
|
325
331
|
},
|
|
326
|
-
[apiUrl, productId, conversationId, selectedModel, persistAnonymousConversations, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall]
|
|
332
|
+
[apiUrl, productId, conversationId, selectedModel, persistAnonymousConversations, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onToolResult]
|
|
327
333
|
);
|
|
328
334
|
const sendMessage = useCallback(
|
|
329
335
|
(content) => {
|
|
@@ -2747,7 +2753,8 @@ function CrowWidget({
|
|
|
2747
2753
|
welcomeMessage: welcomeMessageProp,
|
|
2748
2754
|
onReady,
|
|
2749
2755
|
onIdentify,
|
|
2750
|
-
tools
|
|
2756
|
+
tools,
|
|
2757
|
+
onToolResult
|
|
2751
2758
|
}) {
|
|
2752
2759
|
const {
|
|
2753
2760
|
styles,
|
|
@@ -2825,6 +2832,7 @@ function CrowWidget({
|
|
|
2825
2832
|
break;
|
|
2826
2833
|
}
|
|
2827
2834
|
},
|
|
2835
|
+
onToolResult,
|
|
2828
2836
|
onToolCall: async (event) => {
|
|
2829
2837
|
if (event.type === "client_call" && event.toolName && event.toolCallId) {
|
|
2830
2838
|
try {
|
|
@@ -3264,7 +3272,8 @@ function CrowCopilot({
|
|
|
3264
3272
|
styles: propStyles,
|
|
3265
3273
|
previewMode = false,
|
|
3266
3274
|
className,
|
|
3267
|
-
onReady
|
|
3275
|
+
onReady,
|
|
3276
|
+
onToolResult
|
|
3268
3277
|
}) {
|
|
3269
3278
|
const {
|
|
3270
3279
|
styles,
|
|
@@ -3305,6 +3314,7 @@ function CrowCopilot({
|
|
|
3305
3314
|
},
|
|
3306
3315
|
onConversationId: () => {
|
|
3307
3316
|
},
|
|
3317
|
+
onToolResult,
|
|
3308
3318
|
onToolCall: (event) => {
|
|
3309
3319
|
if (event.type === "client_call" && event.toolName) {
|
|
3310
3320
|
console.log(
|