mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-27 05:38:51 +01:00
* 💻 feat: deeper MCP UI integration in the chat UI using plugins --------- Co-authored-by: Samuel Path <samuel.path@shopify.com> Co-authored-by: Pierre-Luc Godin <pierreluc.godin@shopify.com> * 💻 refactor: Migrate MCP UI resources from index-based to ID-based referencing - Replace index-based resource markers with stable resource IDs - Update plugin to parse \ui{resourceId} format instead of \ui0 - Refactor components to use useMessagesOperations instead of useSubmitMessage - Add ShareMessagesProvider for UI resources in share view - Add useConversationUIResources hook for cross-turn resource lookups - Update parsers to generate resource IDs from content hashes - Update all tests to use resource IDs instead of indices - Add sandbox permissions for iframe popups - Remove deprecated MCP tool context instructions --------- Co-authored-by: Pierre-Luc Godin <pierreluc.godin@shopify.com>
28 lines
991 B
TypeScript
28 lines
991 B
TypeScript
import {
|
|
hasPermissions,
|
|
useGetEffectivePermissionsQuery,
|
|
} from 'librechat-data-provider/react-query';
|
|
import type { ResourceType } from 'librechat-data-provider';
|
|
|
|
/**
|
|
* fetches resource permissions once and returns a function to check any permission
|
|
* More efficient when checking multiple permissions for the same resource
|
|
* @param resourceType - Type of resource (e.g., ResourceType.AGENT)
|
|
* @param resourceId - ID of the resource
|
|
* @returns Object with hasPermission function and loading state
|
|
*/
|
|
export const useResourcePermissions = (resourceType: ResourceType, resourceId: string) => {
|
|
const { data, isLoading } = useGetEffectivePermissionsQuery(resourceType, resourceId);
|
|
|
|
const hasPermission = (requiredPermission: number): boolean => {
|
|
return data ? hasPermissions(data.permissionBits, requiredPermission) : false;
|
|
};
|
|
|
|
return {
|
|
hasPermission,
|
|
isLoading,
|
|
permissionBits: data?.permissionBits || 0,
|
|
};
|
|
};
|
|
|
|
export default useResourcePermissions;
|