librechat-data-provider 0.7.76 → 0.7.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react-query/index.es.js +1 -1
- package/dist/react-query/index.es.js.map +1 -1
- package/package.json +1 -1
- package/src/config.ts +4 -0
- package/src/mcp.ts +13 -1
- package/src/parsers.ts +14 -0
- package/src/types/files.ts +1 -0
package/package.json
CHANGED
package/src/config.ts
CHANGED
package/src/mcp.ts
CHANGED
|
@@ -65,6 +65,7 @@ export const WebSocketOptionsSchema = BaseOptionsSchema.extend({
|
|
|
65
65
|
|
|
66
66
|
export const SSEOptionsSchema = BaseOptionsSchema.extend({
|
|
67
67
|
type: z.literal('sse').optional(),
|
|
68
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
68
69
|
url: z
|
|
69
70
|
.string()
|
|
70
71
|
.url()
|
|
@@ -92,9 +93,10 @@ export type MCPOptions = z.infer<typeof MCPOptionsSchema>;
|
|
|
92
93
|
/**
|
|
93
94
|
* Recursively processes an object to replace environment variables in string values
|
|
94
95
|
* @param {MCPOptions} obj - The object to process
|
|
96
|
+
* @param {string} [userId] - The user ID
|
|
95
97
|
* @returns {MCPOptions} - The processed object with environment variables replaced
|
|
96
98
|
*/
|
|
97
|
-
export function processMCPEnv(obj: MCPOptions): MCPOptions {
|
|
99
|
+
export function processMCPEnv(obj: MCPOptions, userId?: string): MCPOptions {
|
|
98
100
|
if (obj === null || obj === undefined) {
|
|
99
101
|
return obj;
|
|
100
102
|
}
|
|
@@ -105,6 +107,16 @@ export function processMCPEnv(obj: MCPOptions): MCPOptions {
|
|
|
105
107
|
processedEnv[key] = extractEnvVariable(value);
|
|
106
108
|
}
|
|
107
109
|
obj.env = processedEnv;
|
|
110
|
+
} else if ('headers' in obj && obj.headers) {
|
|
111
|
+
const processedHeaders: Record<string, string> = {};
|
|
112
|
+
for (const [key, value] of Object.entries(obj.headers)) {
|
|
113
|
+
if (value === '{{LIBRECHAT_USER_ID}}' && userId != null && userId) {
|
|
114
|
+
processedHeaders[key] = userId;
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
processedHeaders[key] = extractEnvVariable(value);
|
|
118
|
+
}
|
|
119
|
+
obj.headers = processedHeaders;
|
|
108
120
|
}
|
|
109
121
|
|
|
110
122
|
return obj;
|
package/src/parsers.ts
CHANGED
|
@@ -375,9 +375,23 @@ export function parseTextParts(contentParts: a.TMessageContentParts[]): string {
|
|
|
375
375
|
let result = '';
|
|
376
376
|
|
|
377
377
|
for (const part of contentParts) {
|
|
378
|
+
if (!part.type) {
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
378
381
|
if (part.type === ContentTypes.TEXT) {
|
|
379
382
|
const textValue = typeof part.text === 'string' ? part.text : part.text.value;
|
|
380
383
|
|
|
384
|
+
if (
|
|
385
|
+
result.length > 0 &&
|
|
386
|
+
textValue.length > 0 &&
|
|
387
|
+
result[result.length - 1] !== ' ' &&
|
|
388
|
+
textValue[0] !== ' '
|
|
389
|
+
) {
|
|
390
|
+
result += ' ';
|
|
391
|
+
}
|
|
392
|
+
result += textValue;
|
|
393
|
+
} else if (part.type === ContentTypes.THINK) {
|
|
394
|
+
const textValue = typeof part.think === 'string' ? part.think : '';
|
|
381
395
|
if (
|
|
382
396
|
result.length > 0 &&
|
|
383
397
|
textValue.length > 0 &&
|