@iblai/web-utils 1.1.8 → 1.1.10

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.
@@ -433,3 +433,147 @@ export interface TranscriptsConversationHeadlineResponse {
433
433
  value: number;
434
434
  }>;
435
435
  }
436
+ export interface ContentAnalyticsArgs {
437
+ metric: string;
438
+ date_filter?: string;
439
+ start_date?: string;
440
+ end_date?: string;
441
+ include_overtime?: boolean;
442
+ limit?: number;
443
+ page?: number;
444
+ platform_key?: string;
445
+ mentor_unique_id?: string;
446
+ }
447
+ export interface ContentAnalyticsTotals {
448
+ total_learners: number;
449
+ total_enrollments: number;
450
+ total_time_spent: number;
451
+ courses: number;
452
+ active_courses: number;
453
+ platform_courses: number;
454
+ external_courses: number;
455
+ programs: number;
456
+ active_programs: number;
457
+ platform_programs: number;
458
+ external_programs: number;
459
+ pathways: number;
460
+ active_pathways: number;
461
+ platform_pathways: number;
462
+ external_pathways: number;
463
+ skills: number;
464
+ active_skills: number;
465
+ platform_skills: number;
466
+ external_skills: number;
467
+ associated_courses: number;
468
+ learners_with_skills: number;
469
+ }
470
+ export interface ContentAnalyticsAverages {
471
+ completion_rate: number;
472
+ average_rating: number;
473
+ enrollments_per_course: number;
474
+ enrollments_per_program: number;
475
+ enrollments_per_pathway: number;
476
+ courses_per_skill: number;
477
+ time_per_learner: number;
478
+ }
479
+ export interface ContentAnalyticsSummary {
480
+ totals: ContentAnalyticsTotals;
481
+ averages: ContentAnalyticsAverages;
482
+ overtime: Array<{
483
+ date: string;
484
+ value: number;
485
+ }>;
486
+ }
487
+ export interface ContentAnalyticsPagination {
488
+ count: number;
489
+ next: string | null;
490
+ previous: string | null;
491
+ current_page: number;
492
+ total_pages: number;
493
+ }
494
+ export interface ContentAnalyticsItem {
495
+ id: string;
496
+ name: string;
497
+ slug: string;
498
+ platform: string;
499
+ external: boolean;
500
+ analytics: {
501
+ enrollments: number;
502
+ active_enrollments: number;
503
+ completion_rate: number;
504
+ avg_rating: number;
505
+ rating_count: number;
506
+ associated_courses: number;
507
+ learners_count: number;
508
+ total_time_spent: number;
509
+ avg_time_per_learner: number;
510
+ };
511
+ instructor: string;
512
+ category: string;
513
+ duration: string;
514
+ enabled: boolean;
515
+ created: string;
516
+ updated: string;
517
+ metadata: string;
518
+ }
519
+ export interface ContentAnalyticsResponse {
520
+ metric: string;
521
+ summary: ContentAnalyticsSummary;
522
+ pagination: ContentAnalyticsPagination;
523
+ results: ContentAnalyticsItem[];
524
+ }
525
+ export interface ContentAnalyticsDetailsArgs {
526
+ content_id: string;
527
+ metric: string;
528
+ date_filter?: string;
529
+ start_date?: string;
530
+ end_date?: string;
531
+ include_overtime?: boolean;
532
+ limit?: number;
533
+ page?: number;
534
+ platform_key?: string;
535
+ mentor_unique_id?: string;
536
+ search?: string;
537
+ time_metric?: string;
538
+ }
539
+ export interface ContentAnalyticsContentInfo {
540
+ id: string;
541
+ name: string;
542
+ type: string;
543
+ slug: string;
544
+ platform: string;
545
+ external: boolean;
546
+ metadata: Record<string, string>;
547
+ }
548
+ export interface ContentAnalyticsDetailsSummary {
549
+ totals: Record<string, number>;
550
+ averages: Record<string, number>;
551
+ time_series: {
552
+ metric: string;
553
+ interval: string;
554
+ data: Array<{
555
+ period: string;
556
+ value: number;
557
+ average: number;
558
+ }>;
559
+ };
560
+ }
561
+ export interface ContentAnalyticsLearner {
562
+ user_id: number;
563
+ username: string;
564
+ email: string;
565
+ name: string;
566
+ enrollment_date: string;
567
+ completion_status: string;
568
+ completion_percentage: number;
569
+ last_activity: string;
570
+ rating: number;
571
+ review: string;
572
+ details: Record<string, string>;
573
+ }
574
+ export interface ContentAnalyticsDetailsResponse {
575
+ content_info: ContentAnalyticsContentInfo;
576
+ summary: ContentAnalyticsDetailsSummary;
577
+ pagination: ContentAnalyticsPagination;
578
+ learners: ContentAnalyticsLearner[];
579
+ }
@@ -30,6 +30,7 @@ export * from './features/sessions/api-slice';
30
30
  export * from './features/datasets/api-slice';
31
31
  export * from './features/tools/api-slice';
32
32
  export * from './features/analytics/api-slice';
33
+ export * from './features/analytics/custom-api-slice';
33
34
  export * from './features/analytics/types';
34
35
  export * from './features/reports/api-slice';
35
36
  export * from './features/catalog/api-slice';
@@ -79,6 +80,9 @@ export * from './features/disclaimers/types';
79
80
  export * from './features/search/ai-search-api-slice';
80
81
  export * from './features/search/types';
81
82
  export * from './features/search/constants';
83
+ export * from './features/projects/api-slice';
84
+ export * from './features/projects/constants';
85
+ export type { Project, ProjectsFetchResponse, GetProjectsParams, GetProjectsArgs, GetProjectDetailsArgs, CreateProjectData, CreateProjectArgs, UpdateProjectData, UpdateProjectArgs, DeleteProjectArgs, } from './features/projects/types';
82
86
  export * from './reducers';
83
87
  export * from './utils';
84
88
  export type { LLMResponse, MentorSettings } from '@iblai/iblai-api';
package/dist/index.d.ts CHANGED
@@ -811,7 +811,7 @@ declare const isWeb: () => boolean;
811
811
  declare const isNode: () => any;
812
812
  declare const isExpo: () => any;
813
813
  declare const isTauri: () => boolean;
814
- declare const getPlatform: () => "react-native" | "web" | "node" | "unknown";
814
+ declare const getPlatform: () => "web" | "react-native" | "node" | "unknown";
815
815
  declare const safeRequire: (moduleName: string) => any;
816
816
  declare const getNextNavigation: () => any;
817
817
 
@@ -1199,8 +1199,9 @@ type Props$5 = {
1199
1199
  onOAuthResolved?: (data: OAuthResolvedData) => void;
1200
1200
  isOffline?: boolean;
1201
1201
  onOfflineWithoutLocalLLM?: () => void;
1202
+ isPublicRoute?: boolean;
1202
1203
  };
1203
- declare function useAdvancedChat({ tenantKey, mentorId, username, token, wsUrl, stopGenerationWsUrl, redirectToAuthSpa, errorHandler, sendMessageToParentWebsite, isPreviewMode, mentorShareableToken, on402Error, cachedSessionId, onStartNewChat, onOAuthRequired, onOAuthResolved, isOffline, onOfflineWithoutLocalLLM, }: Props$5): {
1204
+ declare function useAdvancedChat({ tenantKey, mentorId, username, token, wsUrl, stopGenerationWsUrl, redirectToAuthSpa, errorHandler, sendMessageToParentWebsite, isPreviewMode, mentorShareableToken, on402Error, cachedSessionId, onStartNewChat, onOAuthRequired, onOAuthResolved, isOffline, onOfflineWithoutLocalLLM, isPublicRoute, }: Props$5): {
1204
1205
  messages: Message[];
1205
1206
  isStreaming: boolean;
1206
1207
  status: ChatStatus;
@@ -1235,8 +1236,9 @@ type Props$4 = {
1235
1236
  mentorId: string;
1236
1237
  username: string;
1237
1238
  errorHandler?: (message: string, error?: any) => void;
1239
+ isPublicRoute?: boolean;
1238
1240
  };
1239
- declare function useMentorTools({ tenantKey, mentorId, username, errorHandler, }: Props$4): {
1241
+ declare function useMentorTools({ tenantKey, mentorId, username, errorHandler, isPublicRoute, }: Props$4): {
1240
1242
  tools: any;
1241
1243
  activeTools: string[];
1242
1244
  updateSessionTools: (tool: string) => Promise<void>;
@@ -1410,6 +1412,7 @@ type Props$3 = {
1410
1412
  mentorId: string;
1411
1413
  tenantKey: string;
1412
1414
  username: string;
1415
+ isPublicRoute?: boolean;
1413
1416
  };
1414
1417
  type MentorSettingsData = {
1415
1418
  profileImage?: string | null;
@@ -1429,7 +1432,7 @@ type MentorSettingsData = {
1429
1432
  type UseMentorSettingsReturn = {
1430
1433
  data: MentorSettingsData;
1431
1434
  };
1432
- declare function useMentorSettings({ mentorId, tenantKey, username, }: Props$3): UseMentorSettingsReturn;
1435
+ declare function useMentorSettings({ mentorId, tenantKey, username, isPublicRoute, }: Props$3): UseMentorSettingsReturn;
1433
1436
 
1434
1437
  /**
1435
1438
  * Sync authentication state to cookies (web only)
package/dist/index.esm.js CHANGED
@@ -1,4 +1,3 @@
1
- 'use client';
2
1
  import * as React from 'react';
3
2
  import React__default, { useState, useRef, useEffect, createContext, useContext, useCallback, useDebugValue, useMemo, useLayoutEffect } from 'react';
4
3
  import { useRenewSubscriptionMutation, useLazyGetUserAppsQuery, useCreateStripeCustomerPortalMutation, useLazyGetFreeUsageCountQuery, useGetTenantMetadataQuery, useLazyGetStripeContextQuery, useUpdateUserTrialStatusMutation, useLazyGetAccountBillingInfoQuery, useLazyRefreshJwtTokenQuery, useLazyGetUserTenantsQuery, useJoinTenantMutation, useLazyGetTenantMetadataQuery, useGetAppTokensMutation, useGetCustomDomainsQuery, useGetRbacPermissionsMutation, useLazyGetMentorsQuery, useLazySeedMentorsQuery, useLazyGetMentorPublicSettingsQuery, useLazyGetRecentlyAccessedMentorsQuery, useCreateSessionIdMutation, useLazyGetSessionIdQuery, useLazyGetSharedSessionIdQuery, useEditSessionMutation, useGetToolsQuery, useGetPromptsSearchQuery, useUpdateUserAccountMutation, useGetUserMetadataQuery, useUploadProfileImageMutation, useRemoveProfileImageMutation } from '@iblai/data-layer';
@@ -1200,10 +1199,13 @@ const getPlatform = () => {
1200
1199
  }
1201
1200
  return "unknown";
1202
1201
  };
1202
+ // Safe access to platform-specific APIs
1203
1203
  const safeRequire = (moduleName) => {
1204
1204
  try {
1205
- if (typeof __non_webpack_require__ !== "undefined") {
1206
- return __non_webpack_require__(moduleName);
1205
+ // eslint-disable-next-line no-undef, @typescript-eslint/no-require-imports
1206
+ if (typeof require !== "undefined") {
1207
+ // eslint-disable-next-line no-undef, @typescript-eslint/no-require-imports
1208
+ return require(moduleName);
1207
1209
  }
1208
1210
  }
1209
1211
  catch (error) {
@@ -3417,6 +3419,13 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
3417
3419
  // user is not authenticated so we don't need to do anything that concerns an authenticated user
3418
3420
  return;
3419
3421
  }
3422
+ // Logged-in user on a public route (e.g. shareable link) visiting another tenant
3423
+ // — treat as visitor, skip tenant join/token/RBAC calls that will 403
3424
+ if (userIsAccessingPublicRoute) {
3425
+ saveVisitingTenant === null || saveVisitingTenant === void 0 ? void 0 : saveVisitingTenant(newCurrentTenant);
3426
+ setIsLoading(false);
3427
+ return;
3428
+ }
3420
3429
  const { data: tenants } = await fetchUserTenants();
3421
3430
  const enhancedTenants = await enhanceTenants(tenants, data);
3422
3431
  saveUserTenants(enhancedTenants);
@@ -3434,10 +3443,10 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
3434
3443
  }
3435
3444
  if (currentTenant && currentTenant !== tenantKey) {
3436
3445
  setTenantKey(data.platform_key);
3437
- const rbacPermissions = await loadPlatformPermissions(data.platform_key);
3438
- onLoadPlatformPermissions === null || onLoadPlatformPermissions === void 0 ? void 0 : onLoadPlatformPermissions(rbacPermissions);
3439
3446
  const userAlreadyInTenant = enhancedTenants === null || enhancedTenants === void 0 ? void 0 : enhancedTenants.find((t) => t.key === tenantKey);
3440
3447
  if (userAlreadyInTenant) {
3448
+ const rbacPermissions = await loadPlatformPermissions(data.platform_key);
3449
+ onLoadPlatformPermissions === null || onLoadPlatformPermissions === void 0 ? void 0 : onLoadPlatformPermissions(rbacPermissions);
3441
3450
  const formData = new FormData();
3442
3451
  formData.append("platform_key", tenantKey);
3443
3452
  const { data: tokenResponse } = await getAppToken(formData).unwrap();
@@ -3468,6 +3477,8 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
3468
3477
  else {
3469
3478
  // TODO: What happense when if for any reason we fetch tenants and it's an empty list
3470
3479
  }
3480
+ const rbacPermissions = await loadPlatformPermissions(data.platform_key);
3481
+ onLoadPlatformPermissions === null || onLoadPlatformPermissions === void 0 ? void 0 : onLoadPlatformPermissions(rbacPermissions);
3471
3482
  onAutoJoinUserToTenant === null || onAutoJoinUserToTenant === void 0 ? void 0 : onAutoJoinUserToTenant((_c = data.platform_name) !== null && _c !== void 0 ? _c : data === null || data === void 0 ? void 0 : data.platform_key.toUpperCase());
3472
3483
  saveTenant === null || saveTenant === void 0 ? void 0 : saveTenant(tenantKey);
3473
3484
  setUserIsAccessingPublicRoute(false);
@@ -3939,7 +3950,7 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
3939
3950
  mentorDbId = await getMentorDbId(mentor);
3940
3951
  }
3941
3952
  // Load permissions if we have a mentor DB ID and user is logged in
3942
- if (mentorDbId && isLoggedIn) {
3953
+ if (mentorDbId && isLoggedIn && !userIsAccessingPublicRoute) {
3943
3954
  const rbacPermissions = await loadMentorsPermissions(mentorDbId);
3944
3955
  onLoadMentorsPermissions === null || onLoadMentorsPermissions === void 0 ? void 0 : onLoadMentorsPermissions(rbacPermissions);
3945
3956
  }
@@ -3986,7 +3997,9 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
3986
3997
  }
3987
3998
  else {
3988
3999
  console.log("requested mentor exists in tenant, proceeding", requestedMentorId);
3989
- if (requestedMentorDbId && isLoggedIn) {
4000
+ if (requestedMentorDbId &&
4001
+ isLoggedIn &&
4002
+ !userIsAccessingPublicRoute) {
3990
4003
  const rbacPermissions = await loadMentorsPermissions(requestedMentorDbId);
3991
4004
  onLoadMentorsPermissions === null || onLoadMentorsPermissions === void 0 ? void 0 : onLoadMentorsPermissions(rbacPermissions);
3992
4005
  }
@@ -15217,6 +15230,14 @@ const NON_AI_ANALYTICS_ENDPOINTS = {
15217
15230
  service: SERVICES.DM,
15218
15231
  path: (args) => `/api/analytics/conversations?platform_key=${args.platform_key}${args.mentor_unique_id ? `&mentor_unique_id=${args.mentor_unique_id}` : ''}&metric=${args.metric}${args.date_filter ? `&date_filter=${args.date_filter}` : ''}${args.start_date ? `&start_date=${args.start_date}` : ''}${args.end_date ? `&end_date=${args.end_date}` : ''}`,
15219
15232
  },
15233
+ GET_CONTENT_ANALYTICS: {
15234
+ service: SERVICES.DM,
15235
+ path: () => `/api/analytics/content/`,
15236
+ },
15237
+ GET_CONTENT_ANALYTICS_DETAILS: {
15238
+ service: SERVICES.DM,
15239
+ path: (content_id) => `/api/analytics/content/details/${content_id}/`,
15240
+ },
15220
15241
  };
15221
15242
  const ANALYTICS_REDUCER_PATH = 'analyticsApiSlice';
15222
15243
 
@@ -15501,6 +15522,38 @@ createApi({
15501
15522
  service: NON_AI_ANALYTICS_ENDPOINTS.GET_TRANSCRIPTS_CONVERSATION_HEADLINE.service,
15502
15523
  }),
15503
15524
  }),
15525
+ getContentAnalytics: builder.query({
15526
+ query: (args) => ({
15527
+ url: NON_AI_ANALYTICS_ENDPOINTS.GET_CONTENT_ANALYTICS.path(),
15528
+ service: NON_AI_ANALYTICS_ENDPOINTS.GET_CONTENT_ANALYTICS.service,
15529
+ params: args,
15530
+ }),
15531
+ }),
15532
+ getContentAnalyticsDetails: builder.query({
15533
+ query: (args) => ({
15534
+ url: NON_AI_ANALYTICS_ENDPOINTS.GET_CONTENT_ANALYTICS_DETAILS.path(args.content_id),
15535
+ service: NON_AI_ANALYTICS_ENDPOINTS.GET_CONTENT_ANALYTICS_DETAILS.service,
15536
+ params: args,
15537
+ }),
15538
+ }),
15539
+ }),
15540
+ });
15541
+
15542
+ createApi({
15543
+ reducerPath: 'analyticsCustomApiSlice',
15544
+ baseQuery: iblFetchBaseQuery,
15545
+ tagTypes: ['Analytics'],
15546
+ endpoints: (builder) => ({
15547
+ getDownloadReportFromURL: builder.query({
15548
+ query: ({ url }) => ({
15549
+ url: url,
15550
+ service: SERVICES.DM,
15551
+ method: 'GET',
15552
+ responseHandler: (response) => response.blob(),
15553
+ }),
15554
+ // Blobs are non-serializable; disable caching to prevent Redux serialization warnings
15555
+ keepUnusedDataFor: 0,
15556
+ }),
15504
15557
  }),
15505
15558
  });
15506
15559
 
@@ -17294,8 +17347,8 @@ createApi({
17294
17347
  }),
17295
17348
  });
17296
17349
 
17297
- function useMentorSettings({ mentorId, tenantKey, username, }) {
17298
- var _a, _b, _c, _d;
17350
+ function useMentorSettings({ mentorId, tenantKey, username, isPublicRoute, }) {
17351
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
17299
17352
  const isLoggedIn = username !== ANONYMOUS_USERNAME;
17300
17353
  const { data: mentorSettings } = useGetMentorSettingsQuery({
17301
17354
  mentor: mentorId,
@@ -17303,7 +17356,7 @@ function useMentorSettings({ mentorId, tenantKey, username, }) {
17303
17356
  // @ts-expect-error - userId is passed but not in generated API types
17304
17357
  userId: username !== null && username !== void 0 ? username : "",
17305
17358
  }, {
17306
- skip: !username || !isLoggedIn,
17359
+ skip: !username || !isLoggedIn || !!isPublicRoute,
17307
17360
  });
17308
17361
  const { data: mentorPublicSettings } = useGetMentorPublicSettingsQuery({
17309
17362
  mentor: mentorId,
@@ -17315,44 +17368,26 @@ function useMentorSettings({ mentorId, tenantKey, username, }) {
17315
17368
  });
17316
17369
  return {
17317
17370
  data: {
17318
- profileImage: isLoggedIn
17319
- ? mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.profile_image
17320
- : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.profile_image,
17321
- greetingMethod: isLoggedIn
17322
- ? mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.greeting_method
17323
- : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.greeting_method,
17324
- proactiveResponse: isLoggedIn
17325
- ? mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.proactive_response
17326
- : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.proactive_response,
17327
- llmProvider: isLoggedIn ? mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.llm_provider : "",
17328
- llmName: isLoggedIn
17329
- ? mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.llm_name
17330
- : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.llm_name,
17331
- mentorUniqueId: isLoggedIn
17332
- ? mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.mentor_unique_id
17333
- : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.mentor_unique_id,
17334
- mentorVisibility: isLoggedIn
17335
- ? mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.mentor_visibility
17336
- : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.mentor_visibility,
17337
- mentorName: (_a = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.mentor) !== null && _a !== void 0 ? _a : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.mentor,
17338
- enableGuidedPrompts: isLoggedIn
17339
- ? mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.enable_guided_prompts
17340
- : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.enable_guided_prompts,
17341
- mentorSlug: isLoggedIn
17342
- ? mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.mentor_slug
17343
- : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.mentor_slug,
17344
- safetyDisclaimer: isLoggedIn
17345
- ? (_b = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.metadata) === null || _b === void 0 ? void 0 : _b.safety_disclaimer
17346
- : (_c = mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.metadata) === null || _c === void 0 ? void 0 : _c.safety_disclaimer,
17347
- mentorTools: isLoggedIn
17348
- ? mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.mentor_tools
17349
- : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.mentor_tools,
17350
- allowAnonymous: (_d = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.allow_anonymous) !== null && _d !== void 0 ? _d : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.allow_anonymous,
17371
+ profileImage: (_a = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.profile_image) !== null && _a !== void 0 ? _a : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.profile_image,
17372
+ greetingMethod: (_b = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.greeting_method) !== null && _b !== void 0 ? _b : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.greeting_method,
17373
+ proactiveResponse: (_c = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.proactive_response) !== null && _c !== void 0 ? _c : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.proactive_response,
17374
+ llmProvider: (mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.llm_provider) ||
17375
+ (mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.llm_provider) ||
17376
+ "",
17377
+ llmName: (_d = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.llm_name) !== null && _d !== void 0 ? _d : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.llm_name,
17378
+ mentorUniqueId: (_e = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.mentor_unique_id) !== null && _e !== void 0 ? _e : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.mentor_unique_id,
17379
+ mentorVisibility: (_f = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.mentor_visibility) !== null && _f !== void 0 ? _f : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.mentor_visibility,
17380
+ mentorName: (_g = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.mentor) !== null && _g !== void 0 ? _g : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.mentor,
17381
+ enableGuidedPrompts: (_h = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.enable_guided_prompts) !== null && _h !== void 0 ? _h : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.enable_guided_prompts,
17382
+ mentorSlug: (_j = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.mentor_slug) !== null && _j !== void 0 ? _j : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.mentor_slug,
17383
+ safetyDisclaimer: (_l = (_k = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.metadata) === null || _k === void 0 ? void 0 : _k.safety_disclaimer) !== null && _l !== void 0 ? _l : (_m = mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.metadata) === null || _m === void 0 ? void 0 : _m.safety_disclaimer,
17384
+ mentorTools: (_o = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.mentor_tools) !== null && _o !== void 0 ? _o : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.mentor_tools,
17385
+ allowAnonymous: (_p = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.allow_anonymous) !== null && _p !== void 0 ? _p : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.allow_anonymous,
17351
17386
  },
17352
17387
  };
17353
17388
  }
17354
17389
 
17355
- function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, token, wsUrl, stopGenerationWsUrl, redirectToAuthSpa, errorHandler, sendMessageToParentWebsite, isPreviewMode, mentorShareableToken, on402Error, cachedSessionId, onStartNewChat, onOAuthRequired, onOAuthResolved, isOffline = false, onOfflineWithoutLocalLLM, }) {
17390
+ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, token, wsUrl, stopGenerationWsUrl, redirectToAuthSpa, errorHandler, sendMessageToParentWebsite, isPreviewMode, mentorShareableToken, on402Error, cachedSessionId, onStartNewChat, onOAuthRequired, onOAuthResolved, isOffline = false, onOfflineWithoutLocalLLM, isPublicRoute, }) {
17356
17391
  var _a, _b, _c, _d;
17357
17392
  const dispatch = useDispatch();
17358
17393
  const [createSessionId, { isLoading: isLoadingSessionIds }] = useCreateSessionIdMutation();
@@ -17372,6 +17407,7 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
17372
17407
  mentorId,
17373
17408
  tenantKey,
17374
17409
  username,
17410
+ isPublicRoute,
17375
17411
  });
17376
17412
  const onStreamingChange = (streamingState) => {
17377
17413
  dispatch(chatActions.setStreaming(streamingState));
@@ -17684,26 +17720,30 @@ function hasTool(tools, mentorSettings, toolSlug) {
17684
17720
  // Check if the specific tool exists in both available tools and enabled tools
17685
17721
  return tools.some((tool) => tool.slug === toolSlug && enabledToolSlugs.has(tool.slug));
17686
17722
  }
17687
- function useMentorTools({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, errorHandler, }) {
17723
+ function useMentorTools({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, errorHandler, isPublicRoute, }) {
17688
17724
  var _a;
17689
17725
  const dispatch = useDispatch();
17690
17726
  const activeTools = useSelector(selectTools);
17691
17727
  const artifactsEnabled = useSelector(selectArtifactsEnabled);
17692
17728
  const sessionId = useSelector(selectSessionId);
17693
17729
  const [editSession] = useEditSessionMutation();
17694
- const { data: tools } = useGetToolsQuery({
17730
+ const { data: apiTools } = useGetToolsQuery({
17695
17731
  mentor: mentorId,
17696
17732
  org: tenantKey,
17697
17733
  // @ts-expect-error - userId is passed but not in generated API types
17698
17734
  userId: username !== null && username !== void 0 ? username : "",
17699
17735
  }, {
17700
- skip: !username || username === ANONYMOUS_USERNAME,
17736
+ skip: !username || username === ANONYMOUS_USERNAME || !!isPublicRoute,
17701
17737
  });
17702
17738
  const { data: mentorSettings } = useMentorSettings({
17703
17739
  mentorId,
17704
17740
  tenantKey,
17705
17741
  username,
17742
+ isPublicRoute,
17706
17743
  });
17744
+ // Fall back to mentor_tools from public settings when available-tools endpoint
17745
+ // is blocked by RBAC (403). This ensures shareable link users see tool buttons.
17746
+ const tools = apiTools !== null && apiTools !== void 0 ? apiTools : mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.mentorTools;
17707
17747
  const { data: prompts } = useGetPromptsSearchQuery({
17708
17748
  org: tenantKey,
17709
17749
  username: username !== null && username !== void 0 ? username : "",
@@ -17713,7 +17753,7 @@ function useMentorTools({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, er
17713
17753
  mentor: mentorId,
17714
17754
  orderDirection: "asc",
17715
17755
  }, {
17716
- skip: !tenantKey || !username || !mentorId,
17756
+ skip: !tenantKey || !username || !mentorId || !!isPublicRoute,
17717
17757
  });
17718
17758
  const updateSessionTools = async (tool) => {
17719
17759
  let toolsToAdd = activeTools;