mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-18 14:08:21 +00:00
PromptService gains importSourceGroup, which finds or creates a source pointer group, grants the PUBLIC viewer role and rolls the group back if the grant fails. The Langfuse catalog sync calls it instead of four storage callbacks and two Mongo error predicates, and the prompt service is composed once in api/server/services/Prompts.js and passed to the prompt routes, linked instructions, instructions prompt access and the Langfuse sync runner. Co-authored-by: Rebase Probe <probe@example.com>
37 lines
1.5 KiB
JavaScript
37 lines
1.5 KiB
JavaScript
const { logger, SystemCapabilities } = require('@librechat/data-schemas');
|
|
const {
|
|
checkAccess,
|
|
assertModelBoundContent,
|
|
createInstructionsPromptAccess,
|
|
} = require('@librechat/api');
|
|
const { Permissions, PermissionTypes } = require('librechat-data-provider');
|
|
const { getResourcePermissionsMap } = require('~/server/services/PermissionService');
|
|
const { hasCapability } = require('~/server/middleware/roles/capabilities');
|
|
const { promptService } = require('~/server/services/Prompts');
|
|
const db = require('~/models');
|
|
|
|
/**
|
|
* Wiring only: the write/present decision logic lives in `@librechat/api`
|
|
* (`createInstructionsPromptAccess`, `checkInstructionsPromptWrite`).
|
|
*/
|
|
const instructionsPromptAccess = createInstructionsPromptAccess({
|
|
getResourcePermissionsMap,
|
|
canManagePrompts: (user) => hasCapability(user, SystemCapabilities.MANAGE_PROMPTS),
|
|
promptService,
|
|
assertAgentInstructionsContent: ({ instructions, filters }) =>
|
|
assertModelBoundContent({ filters, agents: [{ instructions }] }),
|
|
/** The same role-level gate `checkPromptAccess` applies to every `/prompts` route
|
|
* (`PermissionTypes.PROMPTS`, `Permissions.USE`). Only `.role` is read, so the
|
|
* `{ id, role }` identity `validateLinkWrite` carries is enough. */
|
|
canUsePrompts: (user, req) =>
|
|
checkAccess({
|
|
req,
|
|
user,
|
|
permissionType: PermissionTypes.PROMPTS,
|
|
permissions: [Permissions.USE],
|
|
getRoleByName: db.getRoleByName,
|
|
}),
|
|
logger,
|
|
});
|
|
|
|
module.exports = { instructionsPromptAccess };
|