mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-21 15:33:45 +00:00
* feat: expose skill discovery and authoring through management API * fix: declare public skill management schema and handler types * fix: preserve skill permissions and shared management error semantics * fix: validate skill file paths before writing storage * test: isolate execution limiter routes from skills management * fix: align skills discovery access and file upload protections * fix: authorize skills operations before sync and upload admission * perf: overlap independent skills authorization reads * style: sort skills management imports
47 lines
2 KiB
JavaScript
47 lines
2 KiB
JavaScript
const { createSkillsHandlers } = require('@librechat/api');
|
|
const { isValidObjectIdString } = require('@librechat/data-schemas');
|
|
const { PermissionBits } = require('librechat-data-provider');
|
|
const { createSkill, updateSkill, deleteSkill, deleteSkillFile } = require('~/models');
|
|
const {
|
|
findAccessibleResources,
|
|
findPubliclyAccessibleResources,
|
|
hasPublicPermission,
|
|
grantPermission,
|
|
} = require('~/server/services/PermissionService');
|
|
const {
|
|
getSkillDbMethods,
|
|
withDeploymentSkillIds,
|
|
getSkillStrategyFunctions,
|
|
} = require('~/server/services/Endpoints/agents/skillDeps');
|
|
|
|
function getSkillsHandlers() {
|
|
const skillDbMethods = getSkillDbMethods();
|
|
return createSkillsHandlers({
|
|
createSkill,
|
|
getSkillById: skillDbMethods.getSkillById,
|
|
listSkillsByAccess: skillDbMethods.listSkillsByAccess,
|
|
updateSkill,
|
|
deleteSkill,
|
|
listSkillFiles: skillDbMethods.listSkillFiles,
|
|
deleteSkillFile,
|
|
getSkillFileByPath: skillDbMethods.getSkillFileByPath,
|
|
updateSkillFileContent: skillDbMethods.updateSkillFileContent,
|
|
getStrategyFunctions: getSkillStrategyFunctions,
|
|
findAccessibleResources: async (params) =>
|
|
params.resourceType === 'skill' && params.requiredPermissions === PermissionBits.VIEW
|
|
? withDeploymentSkillIds(await findAccessibleResources(params))
|
|
: findAccessibleResources(params),
|
|
findPubliclyAccessibleResources: async (params) =>
|
|
params.resourceType === 'skill' && params.requiredPermissions === PermissionBits.VIEW
|
|
? withDeploymentSkillIds(await findPubliclyAccessibleResources(params))
|
|
: findPubliclyAccessibleResources(params),
|
|
hasPublicPermission: async (params) =>
|
|
params.resourceType === 'skill' && params.requiredPermissions === PermissionBits.VIEW
|
|
? withDeploymentSkillIds([]).some((id) => id.toString() === params.resourceId.toString()) ||
|
|
hasPublicPermission(params)
|
|
: hasPublicPermission(params),
|
|
grantPermission,
|
|
isValidObjectIdString,
|
|
});
|
|
}
|
|
module.exports = { getSkillsHandlers };
|