style: minor styling cleanup

This commit is contained in:
Dustin Healy 2025-08-09 15:59:31 -07:00
parent d37db43e29
commit f4833b6b25
5 changed files with 18 additions and 14 deletions

View file

@ -428,7 +428,11 @@ describe('resolveHeaders', () => {
});
it('should process LIBRECHAT_BODY placeholders', () => {
const body = { conversationId: 'conv-123', parentMessageId: 'parent-456', messageId: 'msg-789' };
const body = {
conversationId: 'conv-123',
parentMessageId: 'parent-456',
messageId: 'msg-789',
};
const headers = { 'X-Conversation': '{{LIBRECHAT_BODY_CONVERSATIONID}}' };
const result = resolveHeaders({ headers, body });
expect(result['X-Conversation']).toBe('conv-123');

View file

@ -29,11 +29,7 @@ const ALLOWED_USER_FIELDS = [
* List of allowed request body fields that can be used in header placeholders.
* These are common fields from the request body that are safe to expose in headers.
*/
const ALLOWED_BODY_FIELDS = [
'conversationId',
'parentMessageId',
'messageId'
] as const;
const ALLOWED_BODY_FIELDS = ['conversationId', 'parentMessageId', 'messageId'] as const;
/**
* Processes a string value to replace user field placeholders
@ -81,7 +77,6 @@ function processUserPlaceholders(value: string, user?: TUser): string {
* @returns The processed string with placeholders replaced
*/
function processBodyPlaceholders(value: string, body: RequestBody): string {
for (const field of ALLOWED_BODY_FIELDS) {
const placeholder = `{{LIBRECHAT_BODY_${field.toUpperCase()}}}`;
if (!value.includes(placeholder)) {
@ -195,7 +190,7 @@ export function processMCPEnv(
/**
* Resolves header values by replacing user placeholders, body variables, custom variables, and environment variables.
*
*
* @param options - Optional configuration object.
* @param options.headers - The headers object to process.
* @param options.user - Optional user object for replacing user field placeholders (can be partial with just id).