librechat-data-provider 0.7.5 → 0.7.7

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.
Files changed (45) hide show
  1. package/check_updates.sh +1 -0
  2. package/dist/index.es.js +1 -1
  3. package/dist/index.es.js.map +1 -1
  4. package/dist/index.js +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/react-query/index.es.js +1 -1
  7. package/dist/react-query/index.es.js.map +1 -1
  8. package/package.json +4 -4
  9. package/server-rollup.config.js +3 -3
  10. package/specs/actions.spec.ts +424 -35
  11. package/specs/azure.spec.ts +8 -5
  12. package/specs/filetypes.spec.ts +1 -7
  13. package/specs/mcp.spec.ts +52 -0
  14. package/specs/utils.spec.ts +129 -0
  15. package/src/actions.ts +209 -82
  16. package/src/api-endpoints.ts +39 -16
  17. package/src/azure.ts +40 -33
  18. package/src/bedrock.ts +84 -4
  19. package/src/config.ts +199 -95
  20. package/src/createPayload.ts +3 -1
  21. package/src/data-service.ts +114 -20
  22. package/src/file-config.ts +10 -2
  23. package/src/generate.ts +1 -1
  24. package/src/index.ts +7 -4
  25. package/src/keys.ts +6 -0
  26. package/src/mcp.ts +87 -0
  27. package/src/models.ts +1 -1
  28. package/src/parsers.ts +43 -43
  29. package/src/react-query/react-query-service.ts +40 -126
  30. package/src/request.ts +28 -7
  31. package/src/roles.ts +33 -1
  32. package/src/schemas.ts +250 -198
  33. package/src/types/agents.ts +57 -1
  34. package/src/types/assistants.ts +33 -2
  35. package/src/types/files.ts +1 -0
  36. package/src/types/mutations.ts +96 -8
  37. package/src/types/queries.ts +39 -21
  38. package/src/types/runs.ts +1 -0
  39. package/src/types.ts +90 -81
  40. package/src/utils.ts +44 -0
  41. package/src/zod.spec.ts +526 -0
  42. package/src/zod.ts +86 -0
  43. package/tsconfig.json +1 -2
  44. package/specs/parsers.spec.ts +0 -48
  45. package/src/sse.js +0 -242
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import OpenAI from 'openai';
1
+ import type OpenAI from 'openai';
2
2
  import type { InfiniteData } from '@tanstack/react-query';
3
3
  import type {
4
4
  TMessage,
@@ -10,17 +10,12 @@ import type {
10
10
  TConversationTag,
11
11
  TBanner,
12
12
  } from './schemas';
13
- import type { TSpecsConfig } from './models';
14
13
  export type TOpenAIMessage = OpenAI.Chat.ChatCompletionMessageParam;
15
- export type TOpenAIFunction = OpenAI.Chat.ChatCompletionCreateParams.Function;
16
- export type TOpenAIFunctionCall = OpenAI.Chat.ChatCompletionCreateParams.FunctionCallOption;
17
14
 
18
15
  export * from './schemas';
19
16
 
20
17
  export type TMessages = TMessage[];
21
18
 
22
- export type TMessagesAtom = TMessages | null;
23
-
24
19
  /* TODO: Cleanup EndpointOption types */
25
20
  export type TEndpointOption = {
26
21
  endpoint: EModelEndpoint;
@@ -49,6 +44,7 @@ export type TPayload = Partial<TMessage> &
49
44
  isContinued: boolean;
50
45
  conversationId: string | null;
51
46
  messages?: TMessages;
47
+ isTemporary: boolean;
52
48
  };
53
49
 
54
50
  export type TSubmission = {
@@ -58,12 +54,14 @@ export type TSubmission = {
58
54
  userMessage: TMessage;
59
55
  isEdited?: boolean;
60
56
  isContinued?: boolean;
57
+ isTemporary: boolean;
61
58
  messages: TMessage[];
62
59
  isRegenerate?: boolean;
63
60
  conversationId?: string;
64
61
  initialResponse?: TMessage;
65
62
  conversation: Partial<TConversation>;
66
63
  endpointOption: TEndpointOption;
64
+ clientTimestamp?: string;
67
65
  };
68
66
 
69
67
  export type EventSubmission = Omit<TSubmission, 'initialResponse'> & { initialResponse: TMessage };
@@ -72,19 +70,19 @@ export type TPluginAction = {
72
70
  pluginKey: string;
73
71
  action: 'install' | 'uninstall';
74
72
  auth?: unknown;
75
- isAssistantTool?: boolean;
73
+ isEntityTool?: boolean;
76
74
  };
77
75
 
78
76
  export type GroupedConversations = [key: string, TConversation[]][];
79
77
 
80
78
  export type TUpdateUserPlugins = {
81
- isAssistantTool?: boolean;
82
- isAgentTool?: boolean;
79
+ isEntityTool?: boolean;
83
80
  pluginKey: string;
84
81
  action: string;
85
82
  auth?: unknown;
86
83
  };
87
84
 
85
+ // TODO `label` needs to be changed to the proper `TranslationKeys`
88
86
  export type TCategory = {
89
87
  id?: string;
90
88
  value: string;
@@ -102,6 +100,12 @@ export type TError = {
102
100
  };
103
101
  };
104
102
 
103
+ export type TBackupCode = {
104
+ codeHash: string;
105
+ used: boolean;
106
+ usedAt: Date | null;
107
+ };
108
+
105
109
  export type TUser = {
106
110
  id: string;
107
111
  username: string;
@@ -110,7 +114,8 @@ export type TUser = {
110
114
  avatar: string;
111
115
  role: string;
112
116
  provider: string;
113
- plugins: string[];
117
+ plugins?: string[];
118
+ backupCodes?: TBackupCode[];
114
119
  createdAt: string;
115
120
  updatedAt: string;
116
121
  };
@@ -152,6 +157,7 @@ export type TUpdateConversationResponse = TConversation;
152
157
  export type TDeleteConversationRequest = {
153
158
  conversationId?: string;
154
159
  thread_id?: string;
160
+ endpoint?: string;
155
161
  source?: string;
156
162
  };
157
163
 
@@ -174,15 +180,17 @@ export type TArchiveConversationResponse = TConversation;
174
180
  export type TSharedMessagesResponse = Omit<TSharedLink, 'messages'> & {
175
181
  messages: TMessage[];
176
182
  };
177
- export type TSharedLinkRequest = Partial<
178
- Omit<TSharedLink, 'messages' | 'createdAt' | 'updatedAt'>
179
- > & {
180
- conversationId: string;
181
- };
182
183
 
183
- export type TSharedLinkResponse = TSharedLink;
184
- export type TSharedLinksResponse = TSharedLink[];
185
- export type TDeleteSharedLinkResponse = TSharedLink;
184
+ export type TCreateShareLinkRequest = Pick<TConversation, 'conversationId'>;
185
+
186
+ export type TUpdateShareLinkRequest = Pick<TSharedLink, 'shareId'>;
187
+
188
+ export type TSharedLinkResponse = Pick<TSharedLink, 'shareId'> &
189
+ Pick<TConversation, 'conversationId'>;
190
+
191
+ export type TSharedLinkGetResponse = TSharedLinkResponse & {
192
+ success: boolean;
193
+ };
186
194
 
187
195
  // type for getting conversation tags
188
196
  export type TConversationTagsResponse = TConversationTag[];
@@ -196,12 +204,22 @@ export type TConversationTagRequest = Partial<
196
204
 
197
205
  export type TConversationTagResponse = TConversationTag;
198
206
 
199
- // type for tagging conversation
200
207
  export type TTagConversationRequest = {
201
208
  tags: string[];
209
+ tag: string;
202
210
  };
211
+
203
212
  export type TTagConversationResponse = string[];
204
213
 
214
+ export type TDuplicateConvoRequest = {
215
+ conversationId?: string;
216
+ };
217
+
218
+ export type TDuplicateConvoResponse = {
219
+ conversation: TConversation;
220
+ messages: TMessage[];
221
+ };
222
+
205
223
  export type TForkConvoRequest = {
206
224
  messageId: string;
207
225
  conversationId: string;
@@ -274,11 +292,61 @@ export type TRegisterUser = {
274
292
  export type TLoginUser = {
275
293
  email: string;
276
294
  password: string;
295
+ token?: string;
296
+ backupCode?: string;
277
297
  };
278
298
 
279
299
  export type TLoginResponse = {
280
- token: string;
281
- user: TUser;
300
+ token?: string;
301
+ user?: TUser;
302
+ twoFAPending?: boolean;
303
+ tempToken?: string;
304
+ };
305
+
306
+ export type TEnable2FAResponse = {
307
+ otpauthUrl: string;
308
+ backupCodes: string[];
309
+ message?: string;
310
+ };
311
+
312
+ export type TVerify2FARequest = {
313
+ token?: string;
314
+ backupCode?: string;
315
+ };
316
+
317
+ export type TVerify2FAResponse = {
318
+ message: string;
319
+ };
320
+
321
+ /**
322
+ * For verifying 2FA during login with a temporary token.
323
+ */
324
+ export type TVerify2FATempRequest = {
325
+ tempToken: string;
326
+ token?: string;
327
+ backupCode?: string;
328
+ };
329
+
330
+ export type TVerify2FATempResponse = {
331
+ token?: string;
332
+ user?: TUser;
333
+ message?: string;
334
+ };
335
+
336
+ /**
337
+ * Response from disabling 2FA.
338
+ */
339
+ export type TDisable2FAResponse = {
340
+ message: string;
341
+ };
342
+
343
+ /**
344
+ * Response from regenerating backup codes.
345
+ */
346
+ export type TRegenerateBackupCodesResponse = {
347
+ message: string;
348
+ backupCodes: string[];
349
+ backupCodesHash: string[];
282
350
  };
283
351
 
284
352
  export type TRequestPasswordReset = {
@@ -301,63 +369,6 @@ export type TVerifyEmail = {
301
369
 
302
370
  export type TResendVerificationEmail = Omit<TVerifyEmail, 'token'>;
303
371
 
304
- export type TInterfaceConfig = {
305
- privacyPolicy?: {
306
- externalUrl?: string;
307
- openNewTab?: boolean;
308
- };
309
- termsOfService?: {
310
- externalUrl?: string;
311
- openNewTab?: boolean;
312
- modalAcceptance?: boolean;
313
- modalTitle?: string;
314
- modalContent?: string;
315
- };
316
- endpointsMenu: boolean;
317
- modelSelect: boolean;
318
- parameters: boolean;
319
- sidePanel: boolean;
320
- presets: boolean;
321
- multiConvo: boolean;
322
- bookmarks: boolean;
323
- prompts: boolean;
324
- };
325
-
326
- export type TStartupConfig = {
327
- appTitle: string;
328
- socialLogins?: string[];
329
- interface?: TInterfaceConfig;
330
- discordLoginEnabled: boolean;
331
- facebookLoginEnabled: boolean;
332
- githubLoginEnabled: boolean;
333
- googleLoginEnabled: boolean;
334
- openidLoginEnabled: boolean;
335
- openidLabel: string;
336
- openidImageUrl: string;
337
- /** LDAP Auth Configuration */
338
- ldap?: {
339
- /** LDAP enabled */
340
- enabled: boolean;
341
- /** Whether LDAP uses username vs. email */
342
- username?: boolean;
343
- };
344
- serverDomain: string;
345
- emailLoginEnabled: boolean;
346
- registrationEnabled: boolean;
347
- socialLoginEnabled: boolean;
348
- passwordResetEnabled: boolean;
349
- emailEnabled: boolean;
350
- checkBalance: boolean;
351
- showBirthdayIcon: boolean;
352
- helpAndFaqURL: string;
353
- customFooter?: string;
354
- modelSpecs?: TSpecsConfig;
355
- sharedLinksEnabled: boolean;
356
- publicSharedLinksEnabled: boolean;
357
- analyticsGtmId?: string;
358
- instanceProjectId: string;
359
- };
360
-
361
372
  export type TRefreshTokenResponse = {
362
373
  token: string;
363
374
  user: TUser;
@@ -491,9 +502,7 @@ export type TUpdatePromptLabelsResponse = {
491
502
  message: string;
492
503
  };
493
504
 
494
- export type TDeletePromptGroupResponse = {
495
- promptGroup: string;
496
- };
505
+ export type TDeletePromptGroupResponse = TUpdatePromptLabelsResponse;
497
506
 
498
507
  export type TDeletePromptGroupRequest = {
499
508
  id: string;
package/src/utils.ts ADDED
@@ -0,0 +1,44 @@
1
+ export const envVarRegex = /^\${(.+)}$/;
2
+
3
+ /** Extracts the value of an environment variable from a string. */
4
+ export function extractEnvVariable(value: string) {
5
+ if (!value) {
6
+ return value;
7
+ }
8
+
9
+ // Trim the input
10
+ const trimmed = value.trim();
11
+
12
+ // Special case: if it's just a single environment variable
13
+ const singleMatch = trimmed.match(envVarRegex);
14
+ if (singleMatch) {
15
+ const varName = singleMatch[1];
16
+ return process.env[varName] || trimmed;
17
+ }
18
+
19
+ // For multiple variables, process them using a regex loop
20
+ const regex = /\${([^}]+)}/g;
21
+ let result = trimmed;
22
+
23
+ // First collect all matches and their positions
24
+ const matches = [];
25
+ let match;
26
+ while ((match = regex.exec(trimmed)) !== null) {
27
+ matches.push({
28
+ fullMatch: match[0],
29
+ varName: match[1],
30
+ index: match.index,
31
+ });
32
+ }
33
+
34
+ // Process matches in reverse order to avoid position shifts
35
+ for (let i = matches.length - 1; i >= 0; i--) {
36
+ const { fullMatch, varName, index } = matches[i];
37
+ const envValue = process.env[varName] || fullMatch;
38
+
39
+ // Replace at exact position
40
+ result = result.substring(0, index) + envValue + result.substring(index + fullMatch.length);
41
+ }
42
+
43
+ return result;
44
+ }