mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
* refactor: access control logic to TypeScript * chore: Change EndpointURLs to a constant object for improved type safety * 🐛 fix: Enhance agent access control by adding skipAgentCheck functionality * 🐛 fix: Add endpointFileConfig prop to AttachFileMenu and update file handling logic * 🐛 fix: Update tool handling logic to support optional groupedTools and improve null checks, add dedicated tool dialog for Assistants * chore: Export Accordion component from UI index for improved modularity * feat: Add ActivePanelContext for managing active panel state across components * chore: Replace string IDs with EModelEndpoint constants for assistants and agents in useSideNavLinks * fix: Integrate access checks for agent creation and deletion routes in actions.js
56 lines
1.7 KiB
JavaScript
56 lines
1.7 KiB
JavaScript
const express = require('express');
|
|
const { generateCheckAccess, skipAgentCheck } = require('@librechat/api');
|
|
const { PermissionTypes, Permissions } = require('librechat-data-provider');
|
|
const {
|
|
setHeaders,
|
|
moderateText,
|
|
// validateModel,
|
|
validateConvoAccess,
|
|
buildEndpointOption,
|
|
} = require('~/server/middleware');
|
|
const { initializeClient } = require('~/server/services/Endpoints/agents');
|
|
const AgentController = require('~/server/controllers/agents/request');
|
|
const addTitle = require('~/server/services/Endpoints/agents/title');
|
|
const { getRoleByName } = require('~/models/Role');
|
|
|
|
const router = express.Router();
|
|
|
|
router.use(moderateText);
|
|
|
|
const checkAgentAccess = generateCheckAccess({
|
|
permissionType: PermissionTypes.AGENTS,
|
|
permissions: [Permissions.USE],
|
|
skipCheck: skipAgentCheck,
|
|
getRoleByName,
|
|
});
|
|
|
|
router.use(checkAgentAccess);
|
|
router.use(validateConvoAccess);
|
|
router.use(buildEndpointOption);
|
|
router.use(setHeaders);
|
|
|
|
const controller = async (req, res, next) => {
|
|
await AgentController(req, res, next, initializeClient, addTitle);
|
|
};
|
|
|
|
/**
|
|
* @route POST / (regular endpoint)
|
|
* @desc Chat with an assistant
|
|
* @access Public
|
|
* @param {express.Request} req - The request object, containing the request data.
|
|
* @param {express.Response} res - The response object, used to send back a response.
|
|
* @returns {void}
|
|
*/
|
|
router.post('/', controller);
|
|
|
|
/**
|
|
* @route POST /:endpoint (ephemeral agents)
|
|
* @desc Chat with an assistant
|
|
* @access Public
|
|
* @param {express.Request} req - The request object, containing the request data.
|
|
* @param {express.Response} res - The response object, used to send back a response.
|
|
* @returns {void}
|
|
*/
|
|
router.post('/:endpoint', controller);
|
|
|
|
module.exports = router;
|