librechat-data-provider 0.7.68 → 0.7.71

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.
@@ -8,6 +8,11 @@ export namespace Agents {
8
8
 
9
9
  export type ImageDetail = 'auto' | 'low' | 'high';
10
10
 
11
+ export type ReasoningContentText = {
12
+ type: ContentTypes.THINK;
13
+ think: string;
14
+ };
15
+
11
16
  export type MessageContentText = {
12
17
  type: ContentTypes.TEXT;
13
18
  text: string;
@@ -20,6 +25,7 @@ export namespace Agents {
20
25
  };
21
26
 
22
27
  export type MessageContentComplex =
28
+ | ReasoningContentText
23
29
  | MessageContentText
24
30
  | MessageContentImageUrl
25
31
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -46,6 +52,10 @@ export namespace Agents {
46
52
  id?: string;
47
53
  /** If provided, the output of the tool call */
48
54
  output?: string;
55
+ /** Auth URL */
56
+ auth?: string;
57
+ /** Expiration time */
58
+ expires_at?: number;
49
59
  };
50
60
 
51
61
  export type ToolEndEvent = {
@@ -184,6 +194,8 @@ export namespace Agents {
184
194
  export type ToolCallDelta = {
185
195
  type: StepTypes.TOOL_CALLS | string;
186
196
  tool_calls?: ToolCallChunk[];
197
+ auth?: string;
198
+ expires_at?: number;
187
199
  };
188
200
  export type AgentToolCall = FunctionToolCall | ToolCall;
189
201
  export interface ExtendedMessageContent {
@@ -212,12 +224,44 @@ export namespace Agents {
212
224
  * The delta containing the fields that have changed on the Message.
213
225
  */
214
226
  export interface MessageDelta {
227
+ /**
228
+ * The content of the message in array of text and/or images.
229
+ */
230
+ content?: Agents.MessageContentComplex[];
231
+ }
232
+
233
+ /**
234
+ * Represents a reasoning delta i.e. any changed fields on a message during
235
+ * streaming.
236
+ */
237
+ export interface ReasoningDeltaEvent {
238
+ /**
239
+ * The identifier of the message, which can be referenced in API endpoints.
240
+ */
241
+ id: string;
242
+
243
+ /**
244
+ * The delta containing the fields that have changed.
245
+ */
246
+ delta: ReasoningDelta;
247
+ }
248
+
249
+ /**
250
+ * The reasoning delta containing the fields that have changed on the Message.
251
+ */
252
+ export interface ReasoningDelta {
215
253
  /**
216
254
  * The content of the message in array of text and/or images.
217
255
  */
218
256
  content?: MessageContentComplex[];
219
257
  }
220
- export type ContentType = ContentTypes.TEXT | ContentTypes.IMAGE_URL | string;
258
+
259
+ export type ReasoningDeltaUpdate = { type: ContentTypes.THINK; think: string };
260
+ export type ContentType =
261
+ | ContentTypes.THINK
262
+ | ContentTypes.TEXT
263
+ | ContentTypes.IMAGE_URL
264
+ | string;
221
265
  }
222
266
 
223
267
  export type ToolCallResult = {
@@ -3,6 +3,7 @@ import type { AssistantsEndpoint, AgentProvider } from 'src/schemas';
3
3
  import type { ContentTypes } from './runs';
4
4
  import type { Agents } from './agents';
5
5
  import type { TFile } from './files';
6
+ import { ArtifactModes } from 'src/artifacts';
6
7
 
7
8
  export type Schema = OpenAPIV3.SchemaObject & { description?: string };
8
9
  export type Reference = OpenAPIV3.ReferenceObject & { description?: string };
@@ -26,6 +27,7 @@ export enum EToolResources {
26
27
  code_interpreter = 'code_interpreter',
27
28
  execute_code = 'execute_code',
28
29
  file_search = 'file_search',
30
+ ocr = 'ocr',
29
31
  }
30
32
 
31
33
  export type Tool = {
@@ -38,6 +40,8 @@ export type FunctionTool = {
38
40
  description: string;
39
41
  name: string;
40
42
  parameters: Record<string, unknown>;
43
+ strict?: boolean;
44
+ additionalProperties?: boolean; // must be false if strict is true https://platform.openai.com/docs/guides/structured-outputs/some-type-specific-keywords-are-not-yet-supported
41
45
  };
42
46
  };
43
47
 
@@ -160,7 +164,8 @@ export type AgentModelParameters = {
160
164
 
161
165
  export interface AgentToolResources {
162
166
  execute_code?: ExecuteCodeResource;
163
- file_search?: AgentFileSearchResource;
167
+ file_search?: AgentFileResource;
168
+ ocr?: Omit<AgentFileResource, 'vector_store_ids'>;
164
169
  }
165
170
  export interface ExecuteCodeResource {
166
171
  /**
@@ -174,7 +179,7 @@ export interface ExecuteCodeResource {
174
179
  files?: Array<TFile>;
175
180
  }
176
181
 
177
- export interface AgentFileSearchResource {
182
+ export interface AgentFileResource {
178
183
  /**
179
184
  * The ID of the vector store attached to this agent. There
180
185
  * can be a maximum of 1 vector store attached to the agent.
@@ -202,6 +207,7 @@ export type Agent = {
202
207
  created_at: number;
203
208
  avatar: AgentAvatar | null;
204
209
  instructions: string | null;
210
+ additional_instructions?: string | null;
205
211
  tools?: string[];
206
212
  projectIds?: string[];
207
213
  tool_kwargs?: Record<string, unknown>;
@@ -215,6 +221,7 @@ export type Agent = {
215
221
  agent_ids?: string[];
216
222
  end_after_tools?: boolean;
217
223
  hide_sequential_outputs?: boolean;
224
+ artifacts?: ArtifactModes;
218
225
  };
219
226
 
220
227
  export type TAgentsMap = Record<string, Agent | undefined>;
@@ -229,7 +236,7 @@ export type AgentCreateParams = {
229
236
  provider: AgentProvider;
230
237
  model: string | null;
231
238
  model_parameters: AgentModelParameters;
232
- } & Pick<Agent, 'agent_ids' | 'end_after_tools' | 'hide_sequential_outputs'>;
239
+ } & Pick<Agent, 'agent_ids' | 'end_after_tools' | 'hide_sequential_outputs' | 'artifacts'>;
233
240
 
234
241
  export type AgentUpdateParams = {
235
242
  name?: string | null;
@@ -245,7 +252,7 @@ export type AgentUpdateParams = {
245
252
  projectIds?: string[];
246
253
  removeProjectIds?: string[];
247
254
  isCollaborative?: boolean;
248
- } & Pick<Agent, 'agent_ids' | 'end_after_tools' | 'hide_sequential_outputs'>;
255
+ } & Pick<Agent, 'agent_ids' | 'end_after_tools' | 'hide_sequential_outputs' | 'artifacts'>;
249
256
 
250
257
  export type AgentListParams = {
251
258
  limit?: number;
@@ -417,6 +424,8 @@ export type PartMetadata = {
417
424
  asset_pointer?: string;
418
425
  status?: string;
419
426
  action?: boolean;
427
+ auth?: string;
428
+ expires_at?: number;
420
429
  };
421
430
 
422
431
  export type ContentPart = (
@@ -432,6 +441,7 @@ export type ContentPart = (
432
441
 
433
442
  export type TMessageContentParts =
434
443
  | { type: ContentTypes.ERROR; text: Text & PartMetadata }
444
+ | { type: ContentTypes.THINK; think: string | (Text & PartMetadata) }
435
445
  | { type: ContentTypes.TEXT; text: string | (Text & PartMetadata); tool_call_ids?: string[] }
436
446
  | {
437
447
  type: ContentTypes.TOOL_CALL;
@@ -505,6 +515,12 @@ export type ActionMetadata = {
505
515
  oauth_client_secret?: string;
506
516
  };
507
517
 
518
+ export type ActionMetadataRuntime = ActionMetadata & {
519
+ oauth_access_token?: string;
520
+ oauth_refresh_token?: string;
521
+ oauth_token_expires_at?: Date;
522
+ };
523
+
508
524
  /* Assistant types */
509
525
 
510
526
  export type Action = {
@@ -8,6 +8,8 @@ export enum FileSources {
8
8
  s3 = 's3',
9
9
  vectordb = 'vectordb',
10
10
  execute_code = 'execute_code',
11
+ mistral_ocr = 'mistral_ocr',
12
+ text = 'text',
11
13
  }
12
14
 
13
15
  export const checkOpenAIStorage = (source: string) =>
@@ -24,6 +24,12 @@ export type MutationOptions<
24
24
  onSuccess?: (data: Response, variables: Request, context?: Context) => void;
25
25
  onMutate?: (variables: Request) => Snapshot | Promise<Snapshot>;
26
26
  onError?: (error: Error, variables: Request, context?: Context, snapshot?: Snapshot) => void;
27
+ onSettled?: (
28
+ data: Response | undefined,
29
+ error: Error | null,
30
+ variables: Request,
31
+ context?: Context,
32
+ ) => void;
27
33
  };
28
34
 
29
35
  export type TGenTitleRequest = {
@@ -43,8 +49,6 @@ export type UpdatePresetOptions = MutationOptions<types.TPreset, types.TPreset>;
43
49
 
44
50
  export type DeletePresetOptions = MutationOptions<PresetDeleteResponse, types.TPreset | undefined>;
45
51
 
46
- export type LogoutOptions = MutationOptions<unknown, undefined>;
47
-
48
52
  /* Assistant mutations */
49
53
 
50
54
  export type AssistantAvatarVariables = {
@@ -186,7 +190,12 @@ export type ArchiveConvoOptions = MutationOptions<
186
190
  types.TArchiveConversationRequest
187
191
  >;
188
192
 
189
- export type DeleteSharedLinkOptions = MutationOptions<types.TSharedLink, { shareId: string }>;
193
+ export type DeleteSharedLinkContext = { previousQueries?: Map<string, TDeleteSharedLinkResponse> };
194
+ export type DeleteSharedLinkOptions = MutationOptions<
195
+ TDeleteSharedLinkResponse,
196
+ { shareId: string },
197
+ DeleteSharedLinkContext
198
+ >;
190
199
 
191
200
  export type TUpdatePromptContext =
192
201
  | {
@@ -298,3 +307,32 @@ export type ToolCallMutationOptions<T extends ToolId> = MutationOptions<
298
307
  ToolCallResponse,
299
308
  ToolParams<T>
300
309
  >;
310
+
311
+ export type TDeleteSharedLinkResponse = {
312
+ success: boolean;
313
+ shareId: string;
314
+ message: string;
315
+ };
316
+
317
+ export type TEditArtifactRequest = {
318
+ index: number;
319
+ messageId: string;
320
+ original: string;
321
+ updated: string;
322
+ };
323
+
324
+ export type TEditArtifactResponse = Pick<types.TMessage, 'content' | 'text' | 'conversationId'>;
325
+
326
+ export type EditArtifactOptions = MutationOptions<
327
+ TEditArtifactResponse,
328
+ TEditArtifactRequest,
329
+ unknown,
330
+ Error
331
+ >;
332
+
333
+ export type TLogoutResponse = {
334
+ message: string;
335
+ redirect?: string;
336
+ };
337
+
338
+ export type LogoutOptions = MutationOptions<TLogoutResponse, undefined>;
@@ -41,23 +41,34 @@ export type ConversationUpdater = (
41
41
  export type SharedMessagesResponse = Omit<s.TSharedLink, 'messages'> & {
42
42
  messages: s.TMessage[];
43
43
  };
44
- export type SharedLinkListParams = Omit<ConversationListParams, 'isArchived' | 'conversationId'> & {
45
- isPublic?: boolean;
46
- };
47
44
 
48
- export type SharedLinksResponse = Omit<ConversationListResponse, 'conversations' | 'messages'> & {
49
- sharedLinks: s.TSharedLink[];
50
- };
45
+ export interface SharedLinksListParams {
46
+ pageSize: number;
47
+ isPublic: boolean;
48
+ sortBy: 'title' | 'createdAt';
49
+ sortDirection: 'asc' | 'desc';
50
+ search?: string;
51
+ cursor?: string;
52
+ }
51
53
 
52
- // Type for the response from the conversation list API
53
- export type SharedLinkListResponse = {
54
- sharedLinks: s.TSharedLink[];
55
- pageNumber: string;
56
- pageSize: string | number;
57
- pages: string | number;
54
+ export type SharedLinkItem = {
55
+ shareId: string;
56
+ title: string;
57
+ isPublic: boolean;
58
+ createdAt: Date;
59
+ conversationId: string;
58
60
  };
59
61
 
60
- export type SharedLinkListData = InfiniteData<SharedLinkListResponse>;
62
+ export interface SharedLinksResponse {
63
+ links: SharedLinkItem[];
64
+ nextCursor: string | null;
65
+ hasNextPage: boolean;
66
+ }
67
+
68
+ export interface SharedLinkQueryData {
69
+ pages: SharedLinksResponse[];
70
+ pageParams: (string | null)[];
71
+ }
61
72
 
62
73
  export type AllPromptGroupsFilterRequest = {
63
74
  category: string;
package/src/types/runs.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export enum ContentTypes {
2
2
  TEXT = 'text',
3
+ THINK = 'think',
3
4
  TEXT_DELTA = 'text_delta',
4
5
  TOOL_CALL = 'tool_call',
5
6
  IMAGE_FILE = 'image_file',
package/src/types.ts CHANGED
@@ -10,15 +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
14
 
16
15
  export * from './schemas';
17
16
 
18
17
  export type TMessages = TMessage[];
19
18
 
20
- export type TMessagesAtom = TMessages | null;
21
-
22
19
  /* TODO: Cleanup EndpointOption types */
23
20
  export type TEndpointOption = {
24
21
  endpoint: EModelEndpoint;
@@ -47,6 +44,7 @@ export type TPayload = Partial<TMessage> &
47
44
  isContinued: boolean;
48
45
  conversationId: string | null;
49
46
  messages?: TMessages;
47
+ isTemporary: boolean;
50
48
  };
51
49
 
52
50
  export type TSubmission = {
@@ -56,6 +54,7 @@ export type TSubmission = {
56
54
  userMessage: TMessage;
57
55
  isEdited?: boolean;
58
56
  isContinued?: boolean;
57
+ isTemporary: boolean;
59
58
  messages: TMessage[];
60
59
  isRegenerate?: boolean;
61
60
  conversationId?: string;
@@ -83,6 +82,7 @@ export type TUpdateUserPlugins = {
83
82
  auth?: unknown;
84
83
  };
85
84
 
85
+ // TODO `label` needs to be changed to the proper `TranslationKeys`
86
86
  export type TCategory = {
87
87
  id?: string;
88
88
  value: string;
@@ -100,6 +100,12 @@ export type TError = {
100
100
  };
101
101
  };
102
102
 
103
+ export type TBackupCode = {
104
+ codeHash: string;
105
+ used: boolean;
106
+ usedAt: Date | null;
107
+ };
108
+
103
109
  export type TUser = {
104
110
  id: string;
105
111
  username: string;
@@ -108,7 +114,9 @@ export type TUser = {
108
114
  avatar: string;
109
115
  role: string;
110
116
  provider: string;
111
- plugins: string[];
117
+ plugins?: string[];
118
+ twoFactorEnabled?: boolean;
119
+ backupCodes?: TBackupCode[];
112
120
  createdAt: string;
113
121
  updatedAt: string;
114
122
  };
@@ -173,15 +181,17 @@ export type TArchiveConversationResponse = TConversation;
173
181
  export type TSharedMessagesResponse = Omit<TSharedLink, 'messages'> & {
174
182
  messages: TMessage[];
175
183
  };
176
- export type TSharedLinkRequest = Partial<
177
- Omit<TSharedLink, 'messages' | 'createdAt' | 'updatedAt'>
178
- > & {
179
- conversationId: string;
180
- };
181
184
 
182
- export type TSharedLinkResponse = TSharedLink;
183
- export type TSharedLinksResponse = TSharedLink[];
184
- export type TDeleteSharedLinkResponse = TSharedLink;
185
+ export type TCreateShareLinkRequest = Pick<TConversation, 'conversationId'>;
186
+
187
+ export type TUpdateShareLinkRequest = Pick<TSharedLink, 'shareId'>;
188
+
189
+ export type TSharedLinkResponse = Pick<TSharedLink, 'shareId'> &
190
+ Pick<TConversation, 'conversationId'>;
191
+
192
+ export type TSharedLinkGetResponse = TSharedLinkResponse & {
193
+ success: boolean;
194
+ };
185
195
 
186
196
  // type for getting conversation tags
187
197
  export type TConversationTagsResponse = TConversationTag[];
@@ -206,12 +216,10 @@ export type TDuplicateConvoRequest = {
206
216
  conversationId?: string;
207
217
  };
208
218
 
209
- export type TDuplicateConvoResponse =
210
- | {
211
- conversation: TConversation;
212
- messages: TMessage[];
213
- }
214
- | undefined;
219
+ export type TDuplicateConvoResponse = {
220
+ conversation: TConversation;
221
+ messages: TMessage[];
222
+ };
215
223
 
216
224
  export type TForkConvoRequest = {
217
225
  messageId: string;
@@ -285,11 +293,61 @@ export type TRegisterUser = {
285
293
  export type TLoginUser = {
286
294
  email: string;
287
295
  password: string;
296
+ token?: string;
297
+ backupCode?: string;
288
298
  };
289
299
 
290
300
  export type TLoginResponse = {
291
- token: string;
292
- user: TUser;
301
+ token?: string;
302
+ user?: TUser;
303
+ twoFAPending?: boolean;
304
+ tempToken?: string;
305
+ };
306
+
307
+ export type TEnable2FAResponse = {
308
+ otpauthUrl: string;
309
+ backupCodes: string[];
310
+ message?: string;
311
+ };
312
+
313
+ export type TVerify2FARequest = {
314
+ token?: string;
315
+ backupCode?: string;
316
+ };
317
+
318
+ export type TVerify2FAResponse = {
319
+ message: string;
320
+ };
321
+
322
+ /**
323
+ * For verifying 2FA during login with a temporary token.
324
+ */
325
+ export type TVerify2FATempRequest = {
326
+ tempToken: string;
327
+ token?: string;
328
+ backupCode?: string;
329
+ };
330
+
331
+ export type TVerify2FATempResponse = {
332
+ token?: string;
333
+ user?: TUser;
334
+ message?: string;
335
+ };
336
+
337
+ /**
338
+ * Response from disabling 2FA.
339
+ */
340
+ export type TDisable2FAResponse = {
341
+ message: string;
342
+ };
343
+
344
+ /**
345
+ * Response from regenerating backup codes.
346
+ */
347
+ export type TRegenerateBackupCodesResponse = {
348
+ message: string;
349
+ backupCodes: string[];
350
+ backupCodesHash: string[];
293
351
  };
294
352
 
295
353
  export type TRequestPasswordReset = {
@@ -312,63 +370,6 @@ export type TVerifyEmail = {
312
370
 
313
371
  export type TResendVerificationEmail = Omit<TVerifyEmail, 'token'>;
314
372
 
315
- export type TInterfaceConfig = {
316
- privacyPolicy?: {
317
- externalUrl?: string;
318
- openNewTab?: boolean;
319
- };
320
- termsOfService?: {
321
- externalUrl?: string;
322
- openNewTab?: boolean;
323
- modalAcceptance?: boolean;
324
- modalTitle?: string;
325
- modalContent?: string;
326
- };
327
- endpointsMenu: boolean;
328
- modelSelect: boolean;
329
- parameters: boolean;
330
- sidePanel: boolean;
331
- presets: boolean;
332
- multiConvo: boolean;
333
- bookmarks: boolean;
334
- prompts: boolean;
335
- };
336
-
337
- export type TStartupConfig = {
338
- appTitle: string;
339
- socialLogins?: string[];
340
- interface?: TInterfaceConfig;
341
- discordLoginEnabled: boolean;
342
- facebookLoginEnabled: boolean;
343
- githubLoginEnabled: boolean;
344
- googleLoginEnabled: boolean;
345
- openidLoginEnabled: boolean;
346
- openidLabel: string;
347
- openidImageUrl: string;
348
- /** LDAP Auth Configuration */
349
- ldap?: {
350
- /** LDAP enabled */
351
- enabled: boolean;
352
- /** Whether LDAP uses username vs. email */
353
- username?: boolean;
354
- };
355
- serverDomain: string;
356
- emailLoginEnabled: boolean;
357
- registrationEnabled: boolean;
358
- socialLoginEnabled: boolean;
359
- passwordResetEnabled: boolean;
360
- emailEnabled: boolean;
361
- checkBalance: boolean;
362
- showBirthdayIcon: boolean;
363
- helpAndFaqURL: string;
364
- customFooter?: string;
365
- modelSpecs?: TSpecsConfig;
366
- sharedLinksEnabled: boolean;
367
- publicSharedLinksEnabled: boolean;
368
- analyticsGtmId?: string;
369
- instanceProjectId: string;
370
- };
371
-
372
373
  export type TRefreshTokenResponse = {
373
374
  token: string;
374
375
  user: TUser;
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
+ }