mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 08:12:00 +02:00
🗂️ feat: Add File Search Toggle Permission for Chat Area Badge (#8605)
This commit is contained in:
parent
5178507b1c
commit
e5d08ccdf1
11 changed files with 184 additions and 19 deletions
|
@ -50,6 +50,7 @@ async function loadDefaultInterface(config, configDefaults, roleName = SystemRol
|
||||||
temporaryChat: interfaceConfig?.temporaryChat ?? defaults.temporaryChat,
|
temporaryChat: interfaceConfig?.temporaryChat ?? defaults.temporaryChat,
|
||||||
runCode: interfaceConfig?.runCode ?? defaults.runCode,
|
runCode: interfaceConfig?.runCode ?? defaults.runCode,
|
||||||
webSearch: interfaceConfig?.webSearch ?? defaults.webSearch,
|
webSearch: interfaceConfig?.webSearch ?? defaults.webSearch,
|
||||||
|
fileSearch: interfaceConfig?.fileSearch ?? defaults.fileSearch,
|
||||||
customWelcome: interfaceConfig?.customWelcome ?? defaults.customWelcome,
|
customWelcome: interfaceConfig?.customWelcome ?? defaults.customWelcome,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -65,6 +66,7 @@ async function loadDefaultInterface(config, configDefaults, roleName = SystemRol
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: loadedInterface.temporaryChat },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: loadedInterface.temporaryChat },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: loadedInterface.runCode },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: loadedInterface.runCode },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: loadedInterface.webSearch },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: loadedInterface.webSearch },
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: loadedInterface.fileSearch },
|
||||||
});
|
});
|
||||||
await updateAccessPermissions(SystemRoles.ADMIN, {
|
await updateAccessPermissions(SystemRoles.ADMIN, {
|
||||||
[PermissionTypes.PROMPTS]: { [Permissions.USE]: loadedInterface.prompts },
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: loadedInterface.prompts },
|
||||||
|
@ -78,6 +80,7 @@ async function loadDefaultInterface(config, configDefaults, roleName = SystemRol
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: loadedInterface.temporaryChat },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: loadedInterface.temporaryChat },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: loadedInterface.runCode },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: loadedInterface.runCode },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: loadedInterface.webSearch },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: loadedInterface.webSearch },
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: loadedInterface.fileSearch },
|
||||||
});
|
});
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
|
@ -18,6 +18,7 @@ describe('loadDefaultInterface', () => {
|
||||||
temporaryChat: true,
|
temporaryChat: true,
|
||||||
runCode: true,
|
runCode: true,
|
||||||
webSearch: true,
|
webSearch: true,
|
||||||
|
fileSearch: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const configDefaults = { interface: {} };
|
const configDefaults = { interface: {} };
|
||||||
|
@ -27,12 +28,13 @@ describe('loadDefaultInterface', () => {
|
||||||
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
||||||
[PermissionTypes.PROMPTS]: { [Permissions.USE]: true },
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: true },
|
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.MEMORIES]: { [Permissions.USE]: true },
|
[PermissionTypes.MEMORIES]: { [Permissions.USE]: true, [Permissions.OPT_OUT]: undefined },
|
||||||
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: true },
|
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.AGENTS]: { [Permissions.USE]: true },
|
[PermissionTypes.AGENTS]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: true },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: true },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: true },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: true },
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: true },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -47,6 +49,7 @@ describe('loadDefaultInterface', () => {
|
||||||
temporaryChat: false,
|
temporaryChat: false,
|
||||||
runCode: false,
|
runCode: false,
|
||||||
webSearch: false,
|
webSearch: false,
|
||||||
|
fileSearch: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const configDefaults = { interface: {} };
|
const configDefaults = { interface: {} };
|
||||||
|
@ -56,12 +59,13 @@ describe('loadDefaultInterface', () => {
|
||||||
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
||||||
[PermissionTypes.PROMPTS]: { [Permissions.USE]: false },
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: false },
|
||||||
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: false },
|
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: false },
|
||||||
[PermissionTypes.MEMORIES]: { [Permissions.USE]: false },
|
[PermissionTypes.MEMORIES]: { [Permissions.USE]: false, [Permissions.OPT_OUT]: undefined },
|
||||||
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: false },
|
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: false },
|
||||||
[PermissionTypes.AGENTS]: { [Permissions.USE]: false },
|
[PermissionTypes.AGENTS]: { [Permissions.USE]: false },
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: false },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: false },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: false },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: false },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: false },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: false },
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: false },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -74,12 +78,16 @@ describe('loadDefaultInterface', () => {
|
||||||
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
||||||
[PermissionTypes.PROMPTS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.MEMORIES]: { [Permissions.USE]: undefined },
|
[PermissionTypes.MEMORIES]: {
|
||||||
|
[Permissions.USE]: undefined,
|
||||||
|
[Permissions.OPT_OUT]: undefined,
|
||||||
|
},
|
||||||
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: undefined },
|
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.AGENTS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.AGENTS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -94,6 +102,7 @@ describe('loadDefaultInterface', () => {
|
||||||
temporaryChat: undefined,
|
temporaryChat: undefined,
|
||||||
runCode: undefined,
|
runCode: undefined,
|
||||||
webSearch: undefined,
|
webSearch: undefined,
|
||||||
|
fileSearch: undefined,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const configDefaults = { interface: {} };
|
const configDefaults = { interface: {} };
|
||||||
|
@ -103,12 +112,16 @@ describe('loadDefaultInterface', () => {
|
||||||
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
||||||
[PermissionTypes.PROMPTS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.MEMORIES]: { [Permissions.USE]: undefined },
|
[PermissionTypes.MEMORIES]: {
|
||||||
|
[Permissions.USE]: undefined,
|
||||||
|
[Permissions.OPT_OUT]: undefined,
|
||||||
|
},
|
||||||
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: undefined },
|
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.AGENTS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.AGENTS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -123,6 +136,7 @@ describe('loadDefaultInterface', () => {
|
||||||
temporaryChat: undefined,
|
temporaryChat: undefined,
|
||||||
runCode: false,
|
runCode: false,
|
||||||
webSearch: true,
|
webSearch: true,
|
||||||
|
fileSearch: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const configDefaults = { interface: {} };
|
const configDefaults = { interface: {} };
|
||||||
|
@ -132,12 +146,13 @@ describe('loadDefaultInterface', () => {
|
||||||
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
||||||
[PermissionTypes.PROMPTS]: { [Permissions.USE]: true },
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: false },
|
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: false },
|
||||||
[PermissionTypes.MEMORIES]: { [Permissions.USE]: true },
|
[PermissionTypes.MEMORIES]: { [Permissions.USE]: true, [Permissions.OPT_OUT]: undefined },
|
||||||
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: undefined },
|
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.AGENTS]: { [Permissions.USE]: true },
|
[PermissionTypes.AGENTS]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: false },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: false },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: true },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: true },
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: false },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -153,6 +168,7 @@ describe('loadDefaultInterface', () => {
|
||||||
temporaryChat: true,
|
temporaryChat: true,
|
||||||
runCode: true,
|
runCode: true,
|
||||||
webSearch: true,
|
webSearch: true,
|
||||||
|
fileSearch: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -161,12 +177,13 @@ describe('loadDefaultInterface', () => {
|
||||||
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
||||||
[PermissionTypes.PROMPTS]: { [Permissions.USE]: true },
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: true },
|
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.MEMORIES]: { [Permissions.USE]: true },
|
[PermissionTypes.MEMORIES]: { [Permissions.USE]: true, [Permissions.OPT_OUT]: undefined },
|
||||||
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: true },
|
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.AGENTS]: { [Permissions.USE]: true },
|
[PermissionTypes.AGENTS]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: true },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: true },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: true },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: true },
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: true },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -179,12 +196,16 @@ describe('loadDefaultInterface', () => {
|
||||||
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
||||||
[PermissionTypes.PROMPTS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.MEMORIES]: { [Permissions.USE]: undefined },
|
[PermissionTypes.MEMORIES]: {
|
||||||
|
[Permissions.USE]: undefined,
|
||||||
|
[Permissions.OPT_OUT]: undefined,
|
||||||
|
},
|
||||||
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: true },
|
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.AGENTS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.AGENTS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -197,12 +218,16 @@ describe('loadDefaultInterface', () => {
|
||||||
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
||||||
[PermissionTypes.PROMPTS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.MEMORIES]: { [Permissions.USE]: undefined },
|
[PermissionTypes.MEMORIES]: {
|
||||||
|
[Permissions.USE]: undefined,
|
||||||
|
[Permissions.OPT_OUT]: undefined,
|
||||||
|
},
|
||||||
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: false },
|
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: false },
|
||||||
[PermissionTypes.AGENTS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.AGENTS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -215,12 +240,16 @@ describe('loadDefaultInterface', () => {
|
||||||
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
||||||
[PermissionTypes.PROMPTS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.MEMORIES]: { [Permissions.USE]: undefined },
|
[PermissionTypes.MEMORIES]: {
|
||||||
|
[Permissions.USE]: undefined,
|
||||||
|
[Permissions.OPT_OUT]: undefined,
|
||||||
|
},
|
||||||
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: undefined },
|
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.AGENTS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.AGENTS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -234,6 +263,7 @@ describe('loadDefaultInterface', () => {
|
||||||
agents: false,
|
agents: false,
|
||||||
temporaryChat: true,
|
temporaryChat: true,
|
||||||
runCode: false,
|
runCode: false,
|
||||||
|
fileSearch: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const configDefaults = { interface: {} };
|
const configDefaults = { interface: {} };
|
||||||
|
@ -243,12 +273,13 @@ describe('loadDefaultInterface', () => {
|
||||||
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
||||||
[PermissionTypes.PROMPTS]: { [Permissions.USE]: true },
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: false },
|
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: false },
|
||||||
[PermissionTypes.MEMORIES]: { [Permissions.USE]: true },
|
[PermissionTypes.MEMORIES]: { [Permissions.USE]: true, [Permissions.OPT_OUT]: undefined },
|
||||||
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: true },
|
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.AGENTS]: { [Permissions.USE]: false },
|
[PermissionTypes.AGENTS]: { [Permissions.USE]: false },
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: true },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: false },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: false },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: true },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -264,6 +295,7 @@ describe('loadDefaultInterface', () => {
|
||||||
temporaryChat: undefined,
|
temporaryChat: undefined,
|
||||||
runCode: undefined,
|
runCode: undefined,
|
||||||
webSearch: undefined,
|
webSearch: undefined,
|
||||||
|
fileSearch: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -272,12 +304,13 @@ describe('loadDefaultInterface', () => {
|
||||||
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
||||||
[PermissionTypes.PROMPTS]: { [Permissions.USE]: true },
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: true },
|
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.MEMORIES]: { [Permissions.USE]: false },
|
[PermissionTypes.MEMORIES]: { [Permissions.USE]: false, [Permissions.OPT_OUT]: undefined },
|
||||||
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: false },
|
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: false },
|
||||||
[PermissionTypes.AGENTS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.AGENTS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: true },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -300,12 +333,90 @@ describe('loadDefaultInterface', () => {
|
||||||
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
||||||
[PermissionTypes.PROMPTS]: { [Permissions.USE]: true },
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: false },
|
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: false },
|
||||||
[PermissionTypes.MEMORIES]: { [Permissions.USE]: true },
|
[PermissionTypes.MEMORIES]: { [Permissions.USE]: true, [Permissions.OPT_OUT]: undefined },
|
||||||
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: true },
|
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.AGENTS]: { [Permissions.USE]: false },
|
[PermissionTypes.AGENTS]: { [Permissions.USE]: false },
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: true },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: false },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: false },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call updateAccessPermissions with the correct parameters when FILE_SEARCH is true', async () => {
|
||||||
|
const config = {
|
||||||
|
interface: {
|
||||||
|
fileSearch: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const configDefaults = { interface: {} };
|
||||||
|
|
||||||
|
await loadDefaultInterface(config, configDefaults);
|
||||||
|
|
||||||
|
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
||||||
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.MEMORIES]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.AGENTS]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: true },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call updateAccessPermissions with false when FILE_SEARCH is false', async () => {
|
||||||
|
const config = {
|
||||||
|
interface: {
|
||||||
|
fileSearch: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const configDefaults = { interface: {} };
|
||||||
|
|
||||||
|
await loadDefaultInterface(config, configDefaults);
|
||||||
|
|
||||||
|
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
||||||
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.MEMORIES]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.AGENTS]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: false },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call updateAccessPermissions with all interface options including fileSearch', async () => {
|
||||||
|
const config = {
|
||||||
|
interface: {
|
||||||
|
prompts: true,
|
||||||
|
bookmarks: false,
|
||||||
|
memories: true,
|
||||||
|
multiConvo: true,
|
||||||
|
agents: false,
|
||||||
|
temporaryChat: true,
|
||||||
|
runCode: false,
|
||||||
|
webSearch: true,
|
||||||
|
fileSearch: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const configDefaults = { interface: {} };
|
||||||
|
|
||||||
|
await loadDefaultInterface(config, configDefaults);
|
||||||
|
|
||||||
|
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
||||||
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: true },
|
||||||
|
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: false },
|
||||||
|
[PermissionTypes.MEMORIES]: { [Permissions.USE]: true, [Permissions.OPT_OUT]: undefined },
|
||||||
|
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: true },
|
||||||
|
[PermissionTypes.AGENTS]: { [Permissions.USE]: false },
|
||||||
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: true },
|
||||||
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: false },
|
||||||
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: true },
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: true },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,14 +1,24 @@
|
||||||
import React, { memo } from 'react';
|
import React, { memo } from 'react';
|
||||||
|
import { PermissionTypes, Permissions } from 'librechat-data-provider';
|
||||||
import CheckboxButton from '~/components/ui/CheckboxButton';
|
import CheckboxButton from '~/components/ui/CheckboxButton';
|
||||||
|
import { useLocalize, useHasAccess } from '~/hooks';
|
||||||
import { useBadgeRowContext } from '~/Providers';
|
import { useBadgeRowContext } from '~/Providers';
|
||||||
import { VectorIcon } from '~/components/svg';
|
import { VectorIcon } from '~/components/svg';
|
||||||
import { useLocalize } from '~/hooks';
|
|
||||||
|
|
||||||
function FileSearch() {
|
function FileSearch() {
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
const { fileSearch } = useBadgeRowContext();
|
const { fileSearch } = useBadgeRowContext();
|
||||||
const { toggleState: fileSearchEnabled, debouncedChange, isPinned } = fileSearch;
|
const { toggleState: fileSearchEnabled, debouncedChange, isPinned } = fileSearch;
|
||||||
|
|
||||||
|
const canUseFileSearch = useHasAccess({
|
||||||
|
permissionType: PermissionTypes.FILE_SEARCH,
|
||||||
|
permission: Permissions.USE,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!canUseFileSearch) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{(fileSearchEnabled || isPinned) && (
|
{(fileSearchEnabled || isPinned) && (
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
|
import { ImageUpIcon, FileSearch, TerminalSquareIcon, FileType2Icon } from 'lucide-react';
|
||||||
import { EToolResources, defaultAgentCapabilities } from 'librechat-data-provider';
|
import { EToolResources, defaultAgentCapabilities } from 'librechat-data-provider';
|
||||||
import { FileSearch, ImageUpIcon, FileType2Icon, TerminalSquareIcon } from 'lucide-react';
|
|
||||||
import { useLocalize, useGetAgentsConfig, useAgentCapabilities } from '~/hooks';
|
import { useLocalize, useGetAgentsConfig, useAgentCapabilities } from '~/hooks';
|
||||||
import { OGDialog, OGDialogTemplate } from '~/components/ui';
|
import { OGDialog, OGDialogTemplate } from '~/components/ui';
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,11 @@ const ToolsDropdown = ({ disabled }: ToolsDropdownProps) => {
|
||||||
permission: Permissions.USE,
|
permission: Permissions.USE,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const canUseFileSearch = useHasAccess({
|
||||||
|
permissionType: PermissionTypes.FILE_SEARCH,
|
||||||
|
permission: Permissions.USE,
|
||||||
|
});
|
||||||
|
|
||||||
const showWebSearchSettings = useMemo(() => {
|
const showWebSearchSettings = useMemo(() => {
|
||||||
const authTypes = webSearchAuthData?.authTypes ?? [];
|
const authTypes = webSearchAuthData?.authTypes ?? [];
|
||||||
if (authTypes.length === 0) return true;
|
if (authTypes.length === 0) return true;
|
||||||
|
@ -140,7 +145,7 @@ const ToolsDropdown = ({ disabled }: ToolsDropdownProps) => {
|
||||||
|
|
||||||
const dropdownItems: MenuItemProps[] = [];
|
const dropdownItems: MenuItemProps[] = [];
|
||||||
|
|
||||||
if (fileSearchEnabled) {
|
if (fileSearchEnabled && canUseFileSearch) {
|
||||||
dropdownItems.push({
|
dropdownItems.push({
|
||||||
onClick: handleFileSearchToggle,
|
onClick: handleFileSearchToggle,
|
||||||
hideOnClick: false,
|
hideOnClick: false,
|
||||||
|
|
|
@ -2,14 +2,20 @@ import React, { useState, useMemo, useCallback } from 'react';
|
||||||
import { EModelEndpoint } from 'librechat-data-provider';
|
import { EModelEndpoint } from 'librechat-data-provider';
|
||||||
import { Controller, useWatch, useFormContext } from 'react-hook-form';
|
import { Controller, useWatch, useFormContext } from 'react-hook-form';
|
||||||
import type { AgentForm, AgentPanelProps, IconComponentTypes } from '~/common';
|
import type { AgentForm, AgentPanelProps, IconComponentTypes } from '~/common';
|
||||||
import { cn, defaultTextProps, removeFocusOutlines, getEndpointField, getIconKey } from '~/utils';
|
import {
|
||||||
|
removeFocusOutlines,
|
||||||
|
processAgentOption,
|
||||||
|
getEndpointField,
|
||||||
|
defaultTextProps,
|
||||||
|
getIconKey,
|
||||||
|
cn,
|
||||||
|
} from '~/utils';
|
||||||
import { useToastContext, useFileMapContext, useAgentPanelContext } from '~/Providers';
|
import { useToastContext, useFileMapContext, useAgentPanelContext } from '~/Providers';
|
||||||
import useAgentCapabilities from '~/hooks/Agents/useAgentCapabilities';
|
import useAgentCapabilities from '~/hooks/Agents/useAgentCapabilities';
|
||||||
import Action from '~/components/SidePanel/Builder/Action';
|
import Action from '~/components/SidePanel/Builder/Action';
|
||||||
import { ToolSelectDialog } from '~/components/Tools';
|
import { ToolSelectDialog } from '~/components/Tools';
|
||||||
import { useGetAgentFiles } from '~/data-provider';
|
import { useGetAgentFiles } from '~/data-provider';
|
||||||
import { icons } from '~/hooks/Endpoint/Icons';
|
import { icons } from '~/hooks/Endpoint/Icons';
|
||||||
import { processAgentOption } from '~/utils';
|
|
||||||
import Instructions from './Instructions';
|
import Instructions from './Instructions';
|
||||||
import AgentAvatar from './AgentAvatar';
|
import AgentAvatar from './AgentAvatar';
|
||||||
import FileContext from './FileContext';
|
import FileContext from './FileContext';
|
||||||
|
|
|
@ -16,6 +16,10 @@ interface:
|
||||||
# MCP Servers UI configuration
|
# MCP Servers UI configuration
|
||||||
mcpServers:
|
mcpServers:
|
||||||
placeholder: 'MCP Servers'
|
placeholder: 'MCP Servers'
|
||||||
|
# Enable/disable file search as a chatarea selection (default: true)
|
||||||
|
# Note: This setting does not disable the Agents File Search Capability.
|
||||||
|
# To disable the Agents Capability, see the Agents Endpoint configuration instead.
|
||||||
|
fileSearch: true
|
||||||
# Privacy policy settings
|
# Privacy policy settings
|
||||||
privacyPolicy:
|
privacyPolicy:
|
||||||
externalUrl: 'https://librechat.ai/privacy-policy'
|
externalUrl: 'https://librechat.ai/privacy-policy'
|
||||||
|
|
|
@ -517,6 +517,7 @@ export const intefaceSchema = z
|
||||||
temporaryChatRetention: z.number().min(1).max(8760).optional(),
|
temporaryChatRetention: z.number().min(1).max(8760).optional(),
|
||||||
runCode: z.boolean().optional(),
|
runCode: z.boolean().optional(),
|
||||||
webSearch: z.boolean().optional(),
|
webSearch: z.boolean().optional(),
|
||||||
|
fileSearch: z.boolean().optional(),
|
||||||
})
|
})
|
||||||
.default({
|
.default({
|
||||||
endpointsMenu: true,
|
endpointsMenu: true,
|
||||||
|
@ -532,6 +533,7 @@ export const intefaceSchema = z
|
||||||
temporaryChat: true,
|
temporaryChat: true,
|
||||||
runCode: true,
|
runCode: true,
|
||||||
webSearch: true,
|
webSearch: true,
|
||||||
|
fileSearch: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TInterfaceConfig = z.infer<typeof intefaceSchema>;
|
export type TInterfaceConfig = z.infer<typeof intefaceSchema>;
|
||||||
|
|
|
@ -36,6 +36,10 @@ export enum PermissionTypes {
|
||||||
* Type for using the "Web Search" feature
|
* Type for using the "Web Search" feature
|
||||||
*/
|
*/
|
||||||
WEB_SEARCH = 'WEB_SEARCH',
|
WEB_SEARCH = 'WEB_SEARCH',
|
||||||
|
/**
|
||||||
|
* Type for using the "File Search" feature
|
||||||
|
*/
|
||||||
|
FILE_SEARCH = 'FILE_SEARCH',
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,6 +107,11 @@ export const webSearchPermissionsSchema = z.object({
|
||||||
});
|
});
|
||||||
export type TWebSearchPermissions = z.infer<typeof webSearchPermissionsSchema>;
|
export type TWebSearchPermissions = z.infer<typeof webSearchPermissionsSchema>;
|
||||||
|
|
||||||
|
export const fileSearchPermissionsSchema = z.object({
|
||||||
|
[Permissions.USE]: z.boolean().default(true),
|
||||||
|
});
|
||||||
|
export type TFileSearchPermissions = z.infer<typeof fileSearchPermissionsSchema>;
|
||||||
|
|
||||||
// Define a single permissions schema that holds all permission types.
|
// Define a single permissions schema that holds all permission types.
|
||||||
export const permissionsSchema = z.object({
|
export const permissionsSchema = z.object({
|
||||||
[PermissionTypes.PROMPTS]: promptPermissionsSchema,
|
[PermissionTypes.PROMPTS]: promptPermissionsSchema,
|
||||||
|
@ -113,4 +122,5 @@ export const permissionsSchema = z.object({
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: temporaryChatPermissionsSchema,
|
[PermissionTypes.TEMPORARY_CHAT]: temporaryChatPermissionsSchema,
|
||||||
[PermissionTypes.RUN_CODE]: runCodePermissionsSchema,
|
[PermissionTypes.RUN_CODE]: runCodePermissionsSchema,
|
||||||
[PermissionTypes.WEB_SEARCH]: webSearchPermissionsSchema,
|
[PermissionTypes.WEB_SEARCH]: webSearchPermissionsSchema,
|
||||||
|
[PermissionTypes.FILE_SEARCH]: fileSearchPermissionsSchema,
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,8 +7,9 @@ import {
|
||||||
promptPermissionsSchema,
|
promptPermissionsSchema,
|
||||||
memoryPermissionsSchema,
|
memoryPermissionsSchema,
|
||||||
runCodePermissionsSchema,
|
runCodePermissionsSchema,
|
||||||
webSearchPermissionsSchema,
|
|
||||||
bookmarkPermissionsSchema,
|
bookmarkPermissionsSchema,
|
||||||
|
webSearchPermissionsSchema,
|
||||||
|
fileSearchPermissionsSchema,
|
||||||
multiConvoPermissionsSchema,
|
multiConvoPermissionsSchema,
|
||||||
temporaryChatPermissionsSchema,
|
temporaryChatPermissionsSchema,
|
||||||
} from './permissions';
|
} from './permissions';
|
||||||
|
@ -74,6 +75,9 @@ const defaultRolesSchema = z.object({
|
||||||
[PermissionTypes.WEB_SEARCH]: webSearchPermissionsSchema.extend({
|
[PermissionTypes.WEB_SEARCH]: webSearchPermissionsSchema.extend({
|
||||||
[Permissions.USE]: z.boolean().default(true),
|
[Permissions.USE]: z.boolean().default(true),
|
||||||
}),
|
}),
|
||||||
|
[PermissionTypes.FILE_SEARCH]: fileSearchPermissionsSchema.extend({
|
||||||
|
[Permissions.USE]: z.boolean().default(true),
|
||||||
|
}),
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
[SystemRoles.USER]: roleSchema.extend({
|
[SystemRoles.USER]: roleSchema.extend({
|
||||||
|
@ -118,6 +122,9 @@ export const roleDefaults = defaultRolesSchema.parse({
|
||||||
[PermissionTypes.WEB_SEARCH]: {
|
[PermissionTypes.WEB_SEARCH]: {
|
||||||
[Permissions.USE]: true,
|
[Permissions.USE]: true,
|
||||||
},
|
},
|
||||||
|
[PermissionTypes.FILE_SEARCH]: {
|
||||||
|
[Permissions.USE]: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[SystemRoles.USER]: {
|
[SystemRoles.USER]: {
|
||||||
|
@ -131,6 +138,7 @@ export const roleDefaults = defaultRolesSchema.parse({
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: {},
|
[PermissionTypes.TEMPORARY_CHAT]: {},
|
||||||
[PermissionTypes.RUN_CODE]: {},
|
[PermissionTypes.RUN_CODE]: {},
|
||||||
[PermissionTypes.WEB_SEARCH]: {},
|
[PermissionTypes.WEB_SEARCH]: {},
|
||||||
|
[PermissionTypes.FILE_SEARCH]: {},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,9 @@ import { Schema } from 'mongoose';
|
||||||
import { PermissionTypes, Permissions } from 'librechat-data-provider';
|
import { PermissionTypes, Permissions } from 'librechat-data-provider';
|
||||||
import type { IRole } from '~/types';
|
import type { IRole } from '~/types';
|
||||||
|
|
||||||
// Create a sub-schema for permissions. Notice we disable _id for this subdocument.
|
/**
|
||||||
|
* Uses a sub-schema for permissions. Notice we disable `_id` for this subdocument.
|
||||||
|
*/
|
||||||
const rolePermissionsSchema = new Schema(
|
const rolePermissionsSchema = new Schema(
|
||||||
{
|
{
|
||||||
[PermissionTypes.BOOKMARKS]: {
|
[PermissionTypes.BOOKMARKS]: {
|
||||||
|
@ -37,6 +39,9 @@ const rolePermissionsSchema = new Schema(
|
||||||
[PermissionTypes.WEB_SEARCH]: {
|
[PermissionTypes.WEB_SEARCH]: {
|
||||||
[Permissions.USE]: { type: Boolean, default: true },
|
[Permissions.USE]: { type: Boolean, default: true },
|
||||||
},
|
},
|
||||||
|
[PermissionTypes.FILE_SEARCH]: {
|
||||||
|
[Permissions.USE]: { type: Boolean, default: true },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ _id: false },
|
{ _id: false },
|
||||||
);
|
);
|
||||||
|
@ -67,6 +72,7 @@ const roleSchema: Schema<IRole> = new Schema({
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: true },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: true },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: true },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: true },
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: true },
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue