mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-16 13:00:55 +00:00
* 🫰 feat: Configure Tool Approval Modes Per Agent
* fix: Fence Remembered Tool Approval Authority
* fix: Unify Tool Approval Execution Invariants
* fix: Revalidate Learned Approval at MCP Invocation
* fix: Preserve One-Time MCP Review at Invocation
* fix: Execute Reviewed Calls on Templated MCP Connections
* fix: Scope Approval Witnesses to Executing Agents
* fix: Retain Approval Bindings for Hook-Rewritten Inputs
* fix: Pin Review Authority and Retire Settled Tool Calls
* fix: Fingerprint Effective MCP Request Headers
* fix: Preserve Routing Around Renewable MCP Token Fragments
* fix: Bind Tool Consent to OAuth Credential Generations
* test: Keep Mobile Approval Save Outside Drawer Escape Race
* fix: Fence OAuth Consent at MCP Transport Retries
* fix: Let Shared Agent Viewers Reset Personal Consent
* fix: Preserve Renewed Consent Across Reset Races
* fix: Resolve Verified Aliases for Personal Tool Reset
* fix: Fence Renewed OAuth Consent and Credential Review
* fix: Require Foreground Execution for Review-Only MCP Calls
* fix: Pin Invocation Ownership and Stable MCP Consent
* fix: Fence Superseded Tool Consent Completion Writes
* fix: Scope Consent Epochs to Effective MCP Authentication
* fix: Scope Approval Admission to Reachable Agent Tools
* fix: Preserve Approval Epochs for Runtime-Detected OAuth
* fix: Address Tool Approval Review Findings
* fix: Preserve Captured Consent When Tool Approval Is Inherited
* fix: Preserve Approval Admission Through Lazy Metadata
* fix: Fence Programmatic Reviews and Unresolved Lazy Approval Keys
* fix: Account for Normalized and Skill-Contributed Lazy Tools
* fix: Scope Lazy Approval to Selected Tool Spellings and Servers
* fix: Honor Disabled MCP Capability During Lazy Approval Admission
* test: Preserve Approval Merge Regressions After Rebase
* fix: Preserve One-Time Review During Non-OAuth Grant Outages
* fix: Retain One-Time Consent Across Resume Recovery
* fix: Preserve Reviewed Consent Through Transport Outages
* fix: Preserve Case-Variant Lazy Approval Hook Admission
---------
Co-authored-by: Lia <lia@librechat.ai>
84 lines
2.7 KiB
JavaScript
84 lines
2.7 KiB
JavaScript
const express = require('express');
|
|
const {
|
|
reportLocatorTraversalFailure,
|
|
createResetToolApprovalController,
|
|
createContentFilter,
|
|
extractToolArgumentContent,
|
|
} = require('@librechat/api');
|
|
const { callTool, verifyToolAuth, getToolCalls } = require('~/server/controllers/tools');
|
|
const { ResourceType, PermissionBits } = require('librechat-data-provider');
|
|
const { checkPermission } = require('~/server/services/PermissionService');
|
|
const { hasCapability } = require('~/server/middleware/roles/capabilities');
|
|
const { resolveAllMcpConfigs } = require('~/server/services/MCP');
|
|
const { getMCPServerTools } = require('~/server/services/Config');
|
|
const { getAvailableTools } = require('~/server/controllers/PluginController');
|
|
const { toolCallLimiter } = require('~/server/middleware');
|
|
|
|
const approvalStorage = require('~/models');
|
|
const router = express.Router();
|
|
router.post(
|
|
'/approvals/reset',
|
|
toolCallLimiter,
|
|
createResetToolApprovalController({
|
|
storage: approvalStorage,
|
|
hasCapability,
|
|
getMCPServerConfigs: resolveAllMcpConfigs,
|
|
getMCPServerTools,
|
|
getAgent: approvalStorage.getAgent,
|
|
canAccessAgent: (agent, user) =>
|
|
checkPermission({
|
|
userId: user.id,
|
|
role: user.role,
|
|
resourceType: ResourceType.AGENT,
|
|
resourceId: agent._id,
|
|
requiredPermission: PermissionBits.VIEW,
|
|
}),
|
|
}),
|
|
);
|
|
const filterToolArguments = createContentFilter({
|
|
onTraversalFailure: reportLocatorTraversalFailure,
|
|
getFilters: (req) => req.config?.filters,
|
|
extract: (req) => {
|
|
const {
|
|
partIndex: _partIndex,
|
|
blockIndex: _blockIndex,
|
|
messageId: _messageId,
|
|
conversationId: _conversationId,
|
|
...args
|
|
} = req.body ?? {};
|
|
return extractToolArgumentContent({ name: req.params.toolId, arguments: args });
|
|
},
|
|
});
|
|
|
|
/**
|
|
* Get a list of available tools for agents.
|
|
* @route GET /agents/tools
|
|
* @returns {TPlugin[]} 200 - application/json
|
|
*/
|
|
router.get('/', getAvailableTools);
|
|
|
|
/**
|
|
* Get a list of tool calls.
|
|
* @route GET /agents/tools/calls
|
|
* @returns {ToolCallData[]} 200 - application/json
|
|
*/
|
|
router.get('/calls', getToolCalls);
|
|
|
|
/**
|
|
* Verify authentication for a specific tool
|
|
* @route GET /agents/tools/:toolId/auth
|
|
* @param {string} toolId - The ID of the tool to verify
|
|
* @returns {{ authenticated?: boolean; message?: string }}
|
|
*/
|
|
router.get('/:toolId/auth', verifyToolAuth);
|
|
|
|
/**
|
|
* Execute code for a specific tool
|
|
* @route POST /agents/tools/:toolId/call
|
|
* @param {string} toolId - The ID of the tool to execute
|
|
* @param {object} req.body - Request body
|
|
* @returns {object} Result of code execution
|
|
*/
|
|
router.post('/:toolId/call', toolCallLimiter, filterToolArguments, callTool);
|
|
|
|
module.exports = router;
|