@usecrow/ui 0.1.33 → 0.1.34

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
@@ -187,6 +187,15 @@ interface WidgetConfigResponse {
187
187
  welcomeMessage?: string | null;
188
188
  /** AI model to use for this product */
189
189
  model?: string;
190
+ /** Whether page navigation is enabled for this product */
191
+ pageNavigationEnabled?: boolean;
192
+ /** Route definitions for page navigation */
193
+ pageNavigationRoutes?: Array<{
194
+ name: string;
195
+ path: string;
196
+ description?: string;
197
+ params?: Record<string, string>;
198
+ }>;
190
199
  }
191
200
 
192
201
  /** Identity data passed to the identify function */
@@ -230,10 +239,12 @@ interface CrowWidgetProps {
230
239
  onIdentify?: (identify: IdentifyFunction) => void;
231
240
  /** Client-side tools the agent can call */
232
241
  tools?: ToolsMap;
242
+ /** Custom navigation function for SPA-safe page navigation (e.g. router.push from Next.js or React Router) */
243
+ navigate?: (path: string) => void;
233
244
  /** Callback fired when a server-side tool completes, with the tool name and full result data */
234
245
  onToolResult?: (toolName: string, result: Record<string, unknown>) => void;
235
246
  }
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;
247
+ declare function CrowWidget({ productId, apiUrl, variant, styles: propStyles, previewMode, showThinking: showThinkingProp, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, onReady, onIdentify, tools, navigate, onToolResult, }: CrowWidgetProps): react_jsx_runtime.JSX.Element;
237
248
 
238
249
  interface CrowCopilotProps {
239
250
  /** Product ID for this copilot */
@@ -266,10 +277,12 @@ interface CrowCopilotProps {
266
277
  className?: string;
267
278
  /** Callback when copilot is ready */
268
279
  onReady?: () => void;
280
+ /** Custom navigation function for SPA-safe page navigation (e.g. router.push from Next.js or React Router) */
281
+ navigate?: (path: string) => void;
269
282
  /** Callback fired when a server-side tool completes, with the tool name and full result data */
270
283
  onToolResult?: (toolName: string, result: Record<string, unknown>) => void;
271
284
  }
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;
285
+ declare function CrowCopilot({ productId, apiUrl, variant, title, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, position, width, defaultOpen, showClose, onClose, styles: propStyles, previewMode, className, onReady, navigate, onToolResult, }: CrowCopilotProps): react_jsx_runtime.JSX.Element;
273
286
 
274
287
  interface CrowProviderProps extends CrowClientConfig {
275
288
  children: React.ReactNode;
@@ -663,6 +676,15 @@ interface UseWidgetStylesResult {
663
676
  agentName: string;
664
677
  /** Whether browser_use is enabled for this product */
665
678
  browserUseEnabled: boolean;
679
+ /** Whether page navigation is enabled for this product */
680
+ pageNavigationEnabled: boolean;
681
+ /** Route definitions for page navigation */
682
+ pageNavigationRoutes: Array<{
683
+ name: string;
684
+ path: string;
685
+ description?: string;
686
+ params?: Record<string, string>;
687
+ }>;
666
688
  /** Whether to show thinking/reasoning to users */
667
689
  showThinking: boolean;
668
690
  /** Whether to persist anonymous conversations across page refreshes (undefined while loading) */
@@ -695,6 +717,15 @@ interface UseCopilotStylesResult {
695
717
  error: Error | null;
696
718
  /** Agent name from product config */
697
719
  agentName: string;
720
+ /** Whether page navigation is enabled for this product */
721
+ pageNavigationEnabled: boolean;
722
+ /** Route definitions for page navigation */
723
+ pageNavigationRoutes: Array<{
724
+ name: string;
725
+ path: string;
726
+ description?: string;
727
+ params?: Record<string, string>;
728
+ }>;
698
729
  /** Whether to persist anonymous conversations across page refreshes (undefined while loading) */
699
730
  persistAnonymousConversations: boolean | undefined;
700
731
  /** Custom welcome message (undefined uses SDK default) */
package/dist/index.d.ts CHANGED
@@ -187,6 +187,15 @@ interface WidgetConfigResponse {
187
187
  welcomeMessage?: string | null;
188
188
  /** AI model to use for this product */
189
189
  model?: string;
190
+ /** Whether page navigation is enabled for this product */
191
+ pageNavigationEnabled?: boolean;
192
+ /** Route definitions for page navigation */
193
+ pageNavigationRoutes?: Array<{
194
+ name: string;
195
+ path: string;
196
+ description?: string;
197
+ params?: Record<string, string>;
198
+ }>;
190
199
  }
191
200
 
192
201
  /** Identity data passed to the identify function */
@@ -230,10 +239,12 @@ interface CrowWidgetProps {
230
239
  onIdentify?: (identify: IdentifyFunction) => void;
231
240
  /** Client-side tools the agent can call */
232
241
  tools?: ToolsMap;
242
+ /** Custom navigation function for SPA-safe page navigation (e.g. router.push from Next.js or React Router) */
243
+ navigate?: (path: string) => void;
233
244
  /** Callback fired when a server-side tool completes, with the tool name and full result data */
234
245
  onToolResult?: (toolName: string, result: Record<string, unknown>) => void;
235
246
  }
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;
247
+ declare function CrowWidget({ productId, apiUrl, variant, styles: propStyles, previewMode, showThinking: showThinkingProp, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, onReady, onIdentify, tools, navigate, onToolResult, }: CrowWidgetProps): react_jsx_runtime.JSX.Element;
237
248
 
238
249
  interface CrowCopilotProps {
239
250
  /** Product ID for this copilot */
@@ -266,10 +277,12 @@ interface CrowCopilotProps {
266
277
  className?: string;
267
278
  /** Callback when copilot is ready */
268
279
  onReady?: () => void;
280
+ /** Custom navigation function for SPA-safe page navigation (e.g. router.push from Next.js or React Router) */
281
+ navigate?: (path: string) => void;
269
282
  /** Callback fired when a server-side tool completes, with the tool name and full result data */
270
283
  onToolResult?: (toolName: string, result: Record<string, unknown>) => void;
271
284
  }
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;
285
+ declare function CrowCopilot({ productId, apiUrl, variant, title, agentName: agentNameProp, welcomeMessage: welcomeMessageProp, position, width, defaultOpen, showClose, onClose, styles: propStyles, previewMode, className, onReady, navigate, onToolResult, }: CrowCopilotProps): react_jsx_runtime.JSX.Element;
273
286
 
274
287
  interface CrowProviderProps extends CrowClientConfig {
275
288
  children: React.ReactNode;
@@ -663,6 +676,15 @@ interface UseWidgetStylesResult {
663
676
  agentName: string;
664
677
  /** Whether browser_use is enabled for this product */
665
678
  browserUseEnabled: boolean;
679
+ /** Whether page navigation is enabled for this product */
680
+ pageNavigationEnabled: boolean;
681
+ /** Route definitions for page navigation */
682
+ pageNavigationRoutes: Array<{
683
+ name: string;
684
+ path: string;
685
+ description?: string;
686
+ params?: Record<string, string>;
687
+ }>;
666
688
  /** Whether to show thinking/reasoning to users */
667
689
  showThinking: boolean;
668
690
  /** Whether to persist anonymous conversations across page refreshes (undefined while loading) */
@@ -695,6 +717,15 @@ interface UseCopilotStylesResult {
695
717
  error: Error | null;
696
718
  /** Agent name from product config */
697
719
  agentName: string;
720
+ /** Whether page navigation is enabled for this product */
721
+ pageNavigationEnabled: boolean;
722
+ /** Route definitions for page navigation */
723
+ pageNavigationRoutes: Array<{
724
+ name: string;
725
+ path: string;
726
+ description?: string;
727
+ params?: Record<string, string>;
728
+ }>;
698
729
  /** Whether to persist anonymous conversations across page refreshes (undefined while loading) */
699
730
  persistAnonymousConversations: boolean | undefined;
700
731
  /** Custom welcome message (undefined uses SDK default) */
package/dist/index.js CHANGED
@@ -1164,6 +1164,10 @@ function useWidgetStyles({
1164
1164
  const [browserUseEnabled, setBrowserUseEnabled] = useState(
1165
1165
  styleCache.get(key)?.browserUseEnabled || false
1166
1166
  );
1167
+ const [pageNavigationEnabled, setPageNavigationEnabled] = useState(
1168
+ styleCache.get(key)?.pageNavigationEnabled || false
1169
+ );
1170
+ const [pageNavigationRoutes, setPageNavigationRoutes] = useState(styleCache.get(key)?.pageNavigationRoutes || []);
1167
1171
  const [showThinking, setShowThinking] = useState(
1168
1172
  styleCache.get(key)?.showThinking ?? true
1169
1173
  );
@@ -1187,6 +1191,8 @@ function useWidgetStyles({
1187
1191
  setDbStyles(config.widgetStyles);
1188
1192
  setAgentName(config.agentName || "Assistant");
1189
1193
  setBrowserUseEnabled(config.browserUseEnabled || false);
1194
+ setPageNavigationEnabled(config.pageNavigationEnabled || false);
1195
+ setPageNavigationRoutes(config.pageNavigationRoutes || []);
1190
1196
  setShowThinking(config.showThinking ?? true);
1191
1197
  setPersistAnonymousConversations(config.persistAnonymousConversations ?? true);
1192
1198
  setWelcomeMessage(config.welcomeMessage ?? void 0);
@@ -1222,6 +1228,8 @@ function useWidgetStyles({
1222
1228
  error,
1223
1229
  agentName,
1224
1230
  browserUseEnabled,
1231
+ pageNavigationEnabled,
1232
+ pageNavigationRoutes,
1225
1233
  showThinking,
1226
1234
  persistAnonymousConversations,
1227
1235
  welcomeMessage,
@@ -1245,6 +1253,10 @@ function useCopilotStyles({
1245
1253
  const [agentName, setAgentName] = useState(
1246
1254
  styleCache.get(key)?.agentName || "Assistant"
1247
1255
  );
1256
+ const [pageNavigationEnabled, setPageNavigationEnabled] = useState(
1257
+ styleCache.get(key)?.pageNavigationEnabled || false
1258
+ );
1259
+ const [pageNavigationRoutes, setPageNavigationRoutes] = useState(styleCache.get(key)?.pageNavigationRoutes || []);
1248
1260
  const [persistAnonymousConversations, setPersistAnonymousConversations] = useState(
1249
1261
  styleCache.has(key) ? styleCache.get(key)?.persistAnonymousConversations ?? true : void 0
1250
1262
  );
@@ -1264,6 +1276,8 @@ function useCopilotStyles({
1264
1276
  styleCache.set(key, config);
1265
1277
  setDbStyles(config.copilotStyles);
1266
1278
  setAgentName(config.agentName || "Assistant");
1279
+ setPageNavigationEnabled(config.pageNavigationEnabled || false);
1280
+ setPageNavigationRoutes(config.pageNavigationRoutes || []);
1267
1281
  setPersistAnonymousConversations(config.persistAnonymousConversations ?? true);
1268
1282
  setWelcomeMessage(config.welcomeMessage ?? void 0);
1269
1283
  setSelectedModel(config.model ?? void 0);
@@ -1280,6 +1294,8 @@ function useCopilotStyles({
1280
1294
  if (cached) {
1281
1295
  setDbStyles(cached.copilotStyles);
1282
1296
  setAgentName(cached.agentName || "Assistant");
1297
+ setPageNavigationEnabled(cached.pageNavigationEnabled || false);
1298
+ setPageNavigationRoutes(cached.pageNavigationRoutes || []);
1283
1299
  setPersistAnonymousConversations(cached.persistAnonymousConversations ?? true);
1284
1300
  setWelcomeMessage(cached.welcomeMessage ?? void 0);
1285
1301
  setSelectedModel(cached.model ?? void 0);
@@ -1295,6 +1311,8 @@ function useCopilotStyles({
1295
1311
  isLoading,
1296
1312
  error,
1297
1313
  agentName,
1314
+ pageNavigationEnabled,
1315
+ pageNavigationRoutes,
1298
1316
  persistAnonymousConversations,
1299
1317
  welcomeMessage,
1300
1318
  selectedModel,
@@ -2842,6 +2860,7 @@ function CrowWidget({
2842
2860
  onReady,
2843
2861
  onIdentify,
2844
2862
  tools,
2863
+ navigate,
2845
2864
  onToolResult
2846
2865
  }) {
2847
2866
  const {
@@ -2849,6 +2868,8 @@ function CrowWidget({
2849
2868
  isLoading: isLoadingStyles,
2850
2869
  agentName: agentNameFromAPI,
2851
2870
  browserUseEnabled,
2871
+ pageNavigationEnabled,
2872
+ pageNavigationRoutes,
2852
2873
  showThinking: showThinkingFromAPI,
2853
2874
  persistAnonymousConversations,
2854
2875
  welcomeMessage: welcomeMessageFromAPI,
@@ -3054,17 +3075,33 @@ function CrowWidget({
3054
3075
  };
3055
3076
  }, [handleBrowserConfirmation, handleBrowserQuestion, handleBrowserProgress]);
3056
3077
  useEffect(() => {
3057
- if (browserUseEnabled && !isLoadingStyles && Object.keys(autoTools).length === 0) {
3078
+ if (browserUseEnabled && !isLoadingStyles && !autoTools.browser_use) {
3058
3079
  import('@usecrow/client/browser').then(({ createBrowserUseTool }) => {
3059
- setAutoTools({
3080
+ setAutoTools((prev) => ({
3081
+ ...prev,
3060
3082
  browser_use: createBrowserUseTool({ productId, apiUrl })
3061
- });
3083
+ }));
3062
3084
  console.log("[Crow] browser_use tool auto-loaded");
3063
3085
  }).catch((err) => {
3064
3086
  console.warn("[Crow] Failed to load browser_use:", err);
3065
3087
  });
3066
3088
  }
3067
3089
  }, [browserUseEnabled, isLoadingStyles, productId, apiUrl, autoTools]);
3090
+ useEffect(() => {
3091
+ if (pageNavigationEnabled && pageNavigationRoutes.length > 0 && !isLoadingStyles) {
3092
+ import('@usecrow/client').then(({ createNavigateToPageTool }) => {
3093
+ setAutoTools((prev) => ({
3094
+ ...prev,
3095
+ navigateToPage: createNavigateToPageTool(pageNavigationRoutes, navigate)
3096
+ }));
3097
+ console.log(
3098
+ `[Crow] navigateToPage tool auto-loaded with ${pageNavigationRoutes.length} routes`
3099
+ );
3100
+ }).catch((err) => {
3101
+ console.warn("[Crow] Failed to load navigateToPage:", err);
3102
+ });
3103
+ }
3104
+ }, [pageNavigationEnabled, pageNavigationRoutes, isLoadingStyles, navigate]);
3068
3105
  const mergedTools = useMemo(() => ({ ...autoTools, ...tools }), [autoTools, tools]);
3069
3106
  useEffect(() => {
3070
3107
  if (Object.keys(mergedTools).length > 0) {
@@ -3361,12 +3398,15 @@ function CrowCopilot({
3361
3398
  previewMode = false,
3362
3399
  className,
3363
3400
  onReady,
3401
+ navigate,
3364
3402
  onToolResult
3365
3403
  }) {
3366
3404
  const {
3367
3405
  styles,
3368
3406
  isLoading: isLoadingStyles,
3369
3407
  agentName: agentNameFromAPI,
3408
+ pageNavigationEnabled,
3409
+ pageNavigationRoutes,
3370
3410
  persistAnonymousConversations,
3371
3411
  welcomeMessage: welcomeMessageFromAPI,
3372
3412
  selectedModel
@@ -3378,6 +3418,27 @@ function CrowCopilot({
3378
3418
  });
3379
3419
  const agentName = agentNameProp ?? agentNameFromAPI ?? title;
3380
3420
  const welcomeMessage = welcomeMessageProp ?? welcomeMessageFromAPI;
3421
+ const [autoTools, setAutoTools] = useState({});
3422
+ useEffect(() => {
3423
+ if (pageNavigationEnabled && pageNavigationRoutes.length > 0 && !isLoadingStyles) {
3424
+ import('@usecrow/client').then(({ createNavigateToPageTool }) => {
3425
+ setAutoTools((prev) => ({
3426
+ ...prev,
3427
+ navigateToPage: createNavigateToPageTool(pageNavigationRoutes, navigate)
3428
+ }));
3429
+ console.log(
3430
+ `[Crow] navigateToPage tool auto-loaded with ${pageNavigationRoutes.length} routes`
3431
+ );
3432
+ }).catch((err) => {
3433
+ console.warn("[Crow] Failed to load navigateToPage:", err);
3434
+ });
3435
+ }
3436
+ }, [pageNavigationEnabled, pageNavigationRoutes, isLoadingStyles, navigate]);
3437
+ useEffect(() => {
3438
+ if (Object.keys(autoTools).length > 0) {
3439
+ window.crow?.("registerTools", autoTools);
3440
+ }
3441
+ }, [autoTools]);
3381
3442
  const messagesContainerRef = useRef(null);
3382
3443
  const tabsScrollRef = useRef(null);
3383
3444
  const executeClientToolRef = useRef(null);