librechat-data-provider 0.8.400 → 0.8.401

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "librechat-data-provider",
3
- "version": "0.8.400",
3
+ "version": "0.8.401",
4
4
  "description": "data services for librechat apps",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
package/src/config.ts CHANGED
@@ -1616,6 +1616,10 @@ export enum ErrorTypes {
1616
1616
  * Model refused to respond (content policy violation)
1617
1617
  */
1618
1618
  REFUSAL = 'refusal',
1619
+ /**
1620
+ * SSE stream 404 — job completed, expired, or was deleted before the subscriber connected
1621
+ */
1622
+ STREAM_EXPIRED = 'stream_expired',
1619
1623
  }
1620
1624
 
1621
1625
  /**
@@ -1740,7 +1744,7 @@ export enum TTSProviders {
1740
1744
  /** Enum for app-wide constants */
1741
1745
  export enum Constants {
1742
1746
  /** Key for the app's version. */
1743
- VERSION = 'v0.8.4-rc1',
1747
+ VERSION = 'v0.8.4',
1744
1748
  /** Key for the Custom Config's version (librechat.yaml). */
1745
1749
  CONFIG_VERSION = '1.3.6',
1746
1750
  /** Standard value for the first message's `parentMessageId` value, to indicate no parent exists. */
@@ -31,6 +31,7 @@ describe('inferMimeType', () => {
31
31
  expect(inferMimeType('test.py', '')).toBe('text/x-python');
32
32
  expect(inferMimeType('code.js', '')).toBe('text/javascript');
33
33
  expect(inferMimeType('photo.heic', '')).toBe('image/heic');
34
+ expect(inferMimeType('Main.java', '')).toBe('text/x-java');
34
35
  });
35
36
 
36
37
  it('should return empty string for unknown extension with no browser type', () => {
@@ -141,12 +142,12 @@ describe('documentParserMimeTypes', () => {
141
142
  'application/x-msexcel',
142
143
  'application/x-ms-excel',
143
144
  'application/vnd.oasis.opendocument.spreadsheet',
145
+ 'application/vnd.oasis.opendocument.text',
144
146
  ])('matches natively parseable type: %s', (mimeType) => {
145
147
  expect(check(mimeType)).toBe(true);
146
148
  });
147
149
 
148
150
  it.each([
149
- 'application/vnd.oasis.opendocument.text',
150
151
  'application/vnd.oasis.opendocument.presentation',
151
152
  'application/vnd.oasis.opendocument.graphics',
152
153
  'text/plain',
@@ -202,12 +202,13 @@ export const defaultOCRMimeTypes = [
202
202
  /^application\/vnd\.oasis\.opendocument\.(text|spreadsheet|presentation|graphics)$/,
203
203
  ];
204
204
 
205
- /** MIME types handled by the built-in document parser (pdf, docx, excel variants, ods) */
205
+ /** MIME types handled by the built-in document parser (pdf, docx, excel variants, ods/odt) */
206
206
  export const documentParserMimeTypes = [
207
207
  excelMimeTypes,
208
208
  /^application\/pdf$/,
209
209
  /^application\/vnd\.openxmlformats-officedocument\.wordprocessingml\.document$/,
210
210
  /^application\/vnd\.oasis\.opendocument\.spreadsheet$/,
211
+ /^application\/vnd\.oasis\.opendocument\.text$/,
211
212
  ];
212
213
 
213
214
  export const defaultTextMimeTypes = [/^[\w.-]+\/[\w.-]+$/];
@@ -242,6 +243,7 @@ export const codeTypeMapping: { [key: string]: string } = {
242
243
  py: 'text/x-python', // .py - Python source
243
244
  rb: 'text/x-ruby', // .rb - Ruby source
244
245
  tex: 'text/x-tex', // .tex - LaTeX source
246
+ java: 'text/x-java', // .java - Java source
245
247
  js: 'text/javascript', // .js - JavaScript source
246
248
  sh: 'application/x-sh', // .sh - Shell script
247
249
  ts: 'application/typescript', // .ts - TypeScript source
@@ -0,0 +1,132 @@
1
+ import { Permissions, PermissionTypes, permissionsSchema } from './permissions';
2
+ import { SystemRoles, roleDefaults } from './roles';
3
+
4
+ const RESOURCE_MANAGEMENT_FIELDS: Permissions[] = [
5
+ Permissions.CREATE,
6
+ Permissions.SHARE,
7
+ Permissions.SHARE_PUBLIC,
8
+ ];
9
+
10
+ /**
11
+ * Permission types where CREATE/SHARE/SHARE_PUBLIC must default to false for USER.
12
+ * MEMORIES is excluded: its CREATE/READ/UPDATE apply to the user's own private data.
13
+ * AGENTS/PROMPTS are excluded: CREATE=true is intentional (users own their agents/prompts).
14
+ * Add new types here if they gate shared/multi-user resources.
15
+ */
16
+ const RESOURCE_PERMISSION_TYPES: PermissionTypes[] = [
17
+ PermissionTypes.MCP_SERVERS,
18
+ PermissionTypes.REMOTE_AGENTS,
19
+ ];
20
+
21
+ describe('roleDefaults', () => {
22
+ describe('USER role', () => {
23
+ const userPerms = roleDefaults[SystemRoles.USER].permissions;
24
+
25
+ it('should have explicit values for every field in every multi-field permission type', () => {
26
+ const schemaShape = permissionsSchema.shape;
27
+
28
+ for (const [permType, subSchema] of Object.entries(schemaShape)) {
29
+ const fieldNames = Object.keys(subSchema.shape);
30
+ if (fieldNames.length <= 1) {
31
+ continue;
32
+ }
33
+
34
+ const userValues =
35
+ userPerms[permType as PermissionTypes] as Record<string, boolean>;
36
+
37
+ for (const field of fieldNames) {
38
+ expect({
39
+ permType,
40
+ field,
41
+ value: userValues[field],
42
+ }).toEqual(
43
+ expect.objectContaining({
44
+ permType,
45
+ field,
46
+ value: expect.any(Boolean),
47
+ }),
48
+ );
49
+ }
50
+ }
51
+ });
52
+
53
+ it('should never grant CREATE, SHARE, or SHARE_PUBLIC by default for resource-management types', () => {
54
+ for (const permType of RESOURCE_PERMISSION_TYPES) {
55
+ const permissions = userPerms[permType] as Record<string, boolean>;
56
+ for (const field of RESOURCE_MANAGEMENT_FIELDS) {
57
+ if (permissions[field] === undefined) {
58
+ continue;
59
+ }
60
+ expect({
61
+ permType,
62
+ field,
63
+ value: permissions[field],
64
+ }).toEqual(
65
+ expect.objectContaining({
66
+ permType,
67
+ field,
68
+ value: false,
69
+ }),
70
+ );
71
+ }
72
+ }
73
+ });
74
+
75
+ it('should cover every permission type that has CREATE, SHARE, or SHARE_PUBLIC fields', () => {
76
+ const schemaShape = permissionsSchema.shape;
77
+ const restrictedSet = new Set<string>(RESOURCE_PERMISSION_TYPES);
78
+
79
+ for (const [permType, subSchema] of Object.entries(schemaShape)) {
80
+ const fieldNames = Object.keys(subSchema.shape);
81
+ const hasResourceFields = fieldNames.some((f) => RESOURCE_MANAGEMENT_FIELDS.includes(f as Permissions));
82
+ if (!hasResourceFields) {
83
+ continue;
84
+ }
85
+
86
+ const isTracked =
87
+ restrictedSet.has(permType) ||
88
+ permType === PermissionTypes.MEMORIES ||
89
+ permType === PermissionTypes.PROMPTS ||
90
+ permType === PermissionTypes.AGENTS;
91
+
92
+ expect({
93
+ permType,
94
+ tracked: isTracked,
95
+ }).toEqual(
96
+ expect.objectContaining({
97
+ permType,
98
+ tracked: true,
99
+ }),
100
+ );
101
+ }
102
+ });
103
+ });
104
+
105
+ describe('ADMIN role', () => {
106
+ const adminPerms = roleDefaults[SystemRoles.ADMIN].permissions;
107
+
108
+ it('should have explicit values for every field in every permission type', () => {
109
+ const schemaShape = permissionsSchema.shape;
110
+
111
+ for (const [permType, subSchema] of Object.entries(schemaShape)) {
112
+ const fieldNames = Object.keys(subSchema.shape);
113
+ const adminValues =
114
+ adminPerms[permType as PermissionTypes] as Record<string, boolean>;
115
+
116
+ for (const field of fieldNames) {
117
+ expect({
118
+ permType,
119
+ field,
120
+ value: adminValues[field],
121
+ }).toEqual(
122
+ expect.objectContaining({
123
+ permType,
124
+ field,
125
+ value: expect.any(Boolean),
126
+ }),
127
+ );
128
+ }
129
+ }
130
+ });
131
+ });
132
+ });
package/src/roles.ts CHANGED
@@ -180,10 +180,20 @@ export const roleDefaults = defaultRolesSchema.parse({
180
180
  [SystemRoles.USER]: {
181
181
  name: SystemRoles.USER,
182
182
  permissions: {
183
- [PermissionTypes.PROMPTS]: {},
183
+ [PermissionTypes.PROMPTS]: {
184
+ [Permissions.USE]: true,
185
+ [Permissions.CREATE]: true,
186
+ [Permissions.SHARE]: false,
187
+ [Permissions.SHARE_PUBLIC]: false,
188
+ },
184
189
  [PermissionTypes.BOOKMARKS]: {},
185
190
  [PermissionTypes.MEMORIES]: {},
186
- [PermissionTypes.AGENTS]: {},
191
+ [PermissionTypes.AGENTS]: {
192
+ [Permissions.USE]: true,
193
+ [Permissions.CREATE]: true,
194
+ [Permissions.SHARE]: false,
195
+ [Permissions.SHARE_PUBLIC]: false,
196
+ },
187
197
  [PermissionTypes.MULTI_CONVO]: {},
188
198
  [PermissionTypes.TEMPORARY_CHAT]: {},
189
199
  [PermissionTypes.RUN_CODE]: {},
@@ -198,8 +208,18 @@ export const roleDefaults = defaultRolesSchema.parse({
198
208
  },
199
209
  [PermissionTypes.FILE_SEARCH]: {},
200
210
  [PermissionTypes.FILE_CITATIONS]: {},
201
- [PermissionTypes.MCP_SERVERS]: {},
202
- [PermissionTypes.REMOTE_AGENTS]: {},
211
+ [PermissionTypes.MCP_SERVERS]: {
212
+ [Permissions.USE]: true,
213
+ [Permissions.CREATE]: false,
214
+ [Permissions.SHARE]: false,
215
+ [Permissions.SHARE_PUBLIC]: false,
216
+ },
217
+ [PermissionTypes.REMOTE_AGENTS]: {
218
+ [Permissions.USE]: false,
219
+ [Permissions.CREATE]: false,
220
+ [Permissions.SHARE]: false,
221
+ [Permissions.SHARE_PUBLIC]: false,
222
+ },
203
223
  },
204
224
  },
205
225
  });