mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
🔒 feat: View/Delete Shared Agent Files (#8419)
* 🔧 fix: Add localized message for delete operation not allowed
* refactor: improve file deletion operations ux
* feat: agent-based file access control and enhance file retrieval logic
* feat: implement agent-specific file retrieval
* feat: enhance agent file retrieval logic for authors and shared access
* ci: include userId and agentId in mockGetFiles call for OCR file retrieval
This commit is contained in:
parent
6aa4bb5a4a
commit
f1b29ffb45
22 changed files with 1216 additions and 35 deletions
|
|
@ -71,7 +71,12 @@ describe('primeResources', () => {
|
|||
tool_resources,
|
||||
});
|
||||
|
||||
expect(mockGetFiles).toHaveBeenCalledWith({ file_id: { $in: ['ocr-file-1'] } }, {}, {});
|
||||
expect(mockGetFiles).toHaveBeenCalledWith(
|
||||
{ file_id: { $in: ['ocr-file-1'] } },
|
||||
{},
|
||||
{},
|
||||
{ userId: undefined, agentId: undefined },
|
||||
);
|
||||
expect(result.attachments).toEqual(mockOcrFiles);
|
||||
expect(result.tool_resources).toEqual(tool_resources);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,12 +10,14 @@ import type { Request as ServerRequest } from 'express';
|
|||
* @param filter - MongoDB filter query for files
|
||||
* @param _sortOptions - Sorting options (currently unused)
|
||||
* @param selectFields - Field selection options
|
||||
* @param options - Additional options including userId and agentId for access control
|
||||
* @returns Promise resolving to array of files
|
||||
*/
|
||||
export type TGetFiles = (
|
||||
filter: FilterQuery<IMongoFile>,
|
||||
_sortOptions: ProjectionType<IMongoFile> | null | undefined,
|
||||
selectFields: QueryOptions<IMongoFile> | null | undefined,
|
||||
options?: { userId?: string; agentId?: string },
|
||||
) => Promise<Array<TFile>>;
|
||||
|
||||
/**
|
||||
|
|
@ -145,12 +147,14 @@ export const primeResources = async ({
|
|||
requestFileSet,
|
||||
attachments: _attachments,
|
||||
tool_resources: _tool_resources,
|
||||
agentId,
|
||||
}: {
|
||||
req: ServerRequest;
|
||||
requestFileSet: Set<string>;
|
||||
attachments: Promise<Array<TFile | null>> | undefined;
|
||||
tool_resources: AgentToolResources | undefined;
|
||||
getFiles: TGetFiles;
|
||||
agentId?: string;
|
||||
}): Promise<{
|
||||
attachments: Array<TFile | undefined> | undefined;
|
||||
tool_resources: AgentToolResources | undefined;
|
||||
|
|
@ -205,6 +209,7 @@ export const primeResources = async ({
|
|||
},
|
||||
{},
|
||||
{},
|
||||
{ userId: req.user?.id, agentId },
|
||||
);
|
||||
|
||||
for (const file of context) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue