mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-17 13:33:45 +00:00
* feat(insights): add agent-scoped access * fix(insights): exclude unattributed assistant messages * fix(sharing): key role insight toggles by principal * fix(sharing): preserve insight grant snapshot * fix(permissions): preserve insight bits atomically * fix(permissions): guard insight audit rollback * fix(insights): keep admin grant controls accessible * fix(permissions): reconcile duplicate principal updates * fix(insights): show automatic admin access * fix(permissions): harden insights access updates * fix(insights): simplify authorization and preserve client state
27 lines
903 B
JavaScript
27 lines
903 B
JavaScript
const express = require('express');
|
|
const {
|
|
createInsightsAccessHandler,
|
|
createInsightsAgentAccessResolver,
|
|
createInsightsHandler,
|
|
isEnabled,
|
|
} = require('@librechat/api');
|
|
const { requireJwtAuth } = require('~/server/middleware');
|
|
const db = require('~/models');
|
|
|
|
const router = express.Router();
|
|
const isInsightsEnabled = () => isEnabled(process.env.ENABLE_INSIGHTS);
|
|
const getAccessibleAgents = createInsightsAgentAccessResolver({
|
|
getAgents: db.getAgents,
|
|
getUserPrincipals: db.getUserPrincipals,
|
|
hasCapabilityForPrincipals: db.hasCapabilityForPrincipals,
|
|
findAccessibleResources: db.findAccessibleResources,
|
|
});
|
|
|
|
router.use(requireJwtAuth);
|
|
router.get('/access', createInsightsAccessHandler({ isInsightsEnabled, getAccessibleAgents }));
|
|
router.get(
|
|
'/',
|
|
createInsightsHandler({ isInsightsEnabled, getAccessibleAgents, getInsights: db.getInsights }),
|
|
);
|
|
|
|
module.exports = router;
|