librechat-data-provider 0.7.4 → 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 (49) 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/dist/react-query/package.json +1 -1
  9. package/package.json +6 -6
  10. package/react-query/package.json +1 -1
  11. package/server-rollup.config.js +3 -3
  12. package/specs/actions.spec.ts +700 -36
  13. package/specs/azure.spec.ts +8 -5
  14. package/specs/filetypes.spec.ts +1 -7
  15. package/specs/mcp.spec.ts +52 -0
  16. package/specs/openapiSpecs.ts +127 -0
  17. package/specs/utils.spec.ts +129 -0
  18. package/src/actions.ts +311 -101
  19. package/src/api-endpoints.ts +70 -13
  20. package/src/artifacts.ts +3104 -0
  21. package/src/azure.ts +40 -33
  22. package/src/bedrock.ts +227 -0
  23. package/src/config.ts +344 -78
  24. package/src/createPayload.ts +3 -1
  25. package/src/data-service.ts +353 -90
  26. package/src/file-config.ts +13 -2
  27. package/src/generate.ts +31 -2
  28. package/src/index.ts +12 -4
  29. package/src/keys.ts +17 -0
  30. package/src/mcp.ts +87 -0
  31. package/src/models.ts +1 -1
  32. package/src/parsers.ts +118 -60
  33. package/src/react-query/react-query-service.ts +54 -115
  34. package/src/request.ts +31 -7
  35. package/src/roles.ts +91 -2
  36. package/src/schemas.ts +513 -340
  37. package/src/types/agents.ts +276 -0
  38. package/src/types/assistants.ts +181 -27
  39. package/src/types/files.ts +6 -0
  40. package/src/types/mutations.ts +170 -7
  41. package/src/types/queries.ts +43 -21
  42. package/src/types/runs.ts +23 -0
  43. package/src/types.ts +132 -67
  44. package/src/utils.ts +44 -0
  45. package/src/zod.spec.ts +526 -0
  46. package/src/zod.ts +86 -0
  47. package/tsconfig.json +1 -2
  48. package/specs/parsers.spec.ts +0 -48
  49. package/src/sse.js +0 -242
@@ -1,48 +0,0 @@
1
- import { extractEnvVariable } from '../src/parsers';
2
-
3
- describe('extractEnvVariable', () => {
4
- const originalEnv = process.env;
5
-
6
- beforeEach(() => {
7
- jest.resetModules();
8
- process.env = { ...originalEnv };
9
- });
10
-
11
- afterAll(() => {
12
- process.env = originalEnv;
13
- });
14
-
15
- test('should return the value of the environment variable', () => {
16
- process.env.TEST_VAR = 'test_value';
17
- expect(extractEnvVariable('${TEST_VAR}')).toBe('test_value');
18
- });
19
-
20
- test('should return the original string if the envrionment variable is not defined correctly', () => {
21
- process.env.TEST_VAR = 'test_value';
22
- expect(extractEnvVariable('${ TEST_VAR }')).toBe('${ TEST_VAR }');
23
- });
24
-
25
- test('should return the original string if environment variable is not set', () => {
26
- expect(extractEnvVariable('${NON_EXISTENT_VAR}')).toBe('${NON_EXISTENT_VAR}');
27
- });
28
-
29
- test('should return the original string if it does not contain an environment variable', () => {
30
- expect(extractEnvVariable('some_string')).toBe('some_string');
31
- });
32
-
33
- test('should handle empty strings', () => {
34
- expect(extractEnvVariable('')).toBe('');
35
- });
36
-
37
- test('should handle strings without variable format', () => {
38
- expect(extractEnvVariable('no_var_here')).toBe('no_var_here');
39
- });
40
-
41
- test('should not process multiple variable formats', () => {
42
- process.env.FIRST_VAR = 'first';
43
- process.env.SECOND_VAR = 'second';
44
- expect(extractEnvVariable('${FIRST_VAR} and ${SECOND_VAR}')).toBe(
45
- '${FIRST_VAR} and ${SECOND_VAR}',
46
- );
47
- });
48
- });
package/src/sse.js DELETED
@@ -1,242 +0,0 @@
1
- /* eslint-disable */
2
- /**
3
- * Copyright (C) 2016 Maxime Petazzoni <maxime.petazzoni@bulix.org>.
4
- * All rights reserved.
5
- */
6
-
7
- import request from './request';
8
- import { setTokenHeader } from './headers-helpers';
9
-
10
- var SSE = function (url, options) {
11
- if (!(this instanceof SSE)) {
12
- return new SSE(url, options);
13
- }
14
-
15
- this.INITIALIZING = -1;
16
- this.CONNECTING = 0;
17
- this.OPEN = 1;
18
- this.CLOSED = 2;
19
-
20
- this.url = url;
21
-
22
- options = options || {};
23
- this.headers = options.headers || {};
24
- this.payload = options.payload !== undefined ? options.payload : '';
25
- this.method = options.method || (this.payload && 'POST') || 'GET';
26
- this.withCredentials = !!options.withCredentials;
27
-
28
- this.FIELD_SEPARATOR = ':';
29
- this.listeners = {};
30
-
31
- this.xhr = null;
32
- this.readyState = this.INITIALIZING;
33
- this.progress = 0;
34
- this.chunk = '';
35
-
36
- this.addEventListener = function (type, listener) {
37
- if (this.listeners[type] === undefined) {
38
- this.listeners[type] = [];
39
- }
40
-
41
- if (this.listeners[type].indexOf(listener) === -1) {
42
- this.listeners[type].push(listener);
43
- }
44
- };
45
-
46
- this.removeEventListener = function (type, listener) {
47
- if (this.listeners[type] === undefined) {
48
- return;
49
- }
50
-
51
- var filtered = [];
52
- this.listeners[type].forEach(function (element) {
53
- if (element !== listener) {
54
- filtered.push(element);
55
- }
56
- });
57
- if (filtered.length === 0) {
58
- delete this.listeners[type];
59
- } else {
60
- this.listeners[type] = filtered;
61
- }
62
- };
63
-
64
- this.dispatchEvent = function (e) {
65
- if (!e) {
66
- return true;
67
- }
68
-
69
- e.source = this;
70
-
71
- var onHandler = 'on' + e.type;
72
- if (this.hasOwnProperty(onHandler)) {
73
- this[onHandler].call(this, e);
74
- if (e.defaultPrevented) {
75
- return false;
76
- }
77
- }
78
-
79
- if (this.listeners[e.type]) {
80
- return this.listeners[e.type].every(function (callback) {
81
- callback(e);
82
- return !e.defaultPrevented;
83
- });
84
- }
85
-
86
- return true;
87
- };
88
-
89
- this._setReadyState = function (state) {
90
- var event = new CustomEvent('readystatechange');
91
- event.readyState = state;
92
- this.readyState = state;
93
- this.dispatchEvent(event);
94
- };
95
-
96
- this._onStreamFailure = function (e) {
97
- var event = new CustomEvent('error');
98
- event.data = e.currentTarget.response;
99
- this.dispatchEvent(event);
100
- this.close();
101
- };
102
-
103
- this._onStreamAbort = function (e) {
104
- this.dispatchEvent(new CustomEvent('abort'));
105
- this.close();
106
- };
107
-
108
- this._onStreamProgress = async function (e) {
109
- if (!this.xhr) {
110
- return;
111
- }
112
-
113
- if (this.xhr.status === 401 && !this._retry) {
114
- this._retry = true;
115
- try {
116
- const refreshResponse = await request.refreshToken();
117
- this.headers = {
118
- 'Content-Type': 'application/json',
119
- Authorization: `Bearer ${refreshResponse.token}`,
120
- };
121
- setTokenHeader(refreshResponse.token);
122
- window.dispatchEvent(new CustomEvent('tokenUpdated', { detail: refreshResponse.token }));
123
- this.stream();
124
- } catch (err) {
125
- this._onStreamFailure(e);
126
- return;
127
- }
128
- } else if (this.xhr.status !== 200) {
129
- this._onStreamFailure(e);
130
- return;
131
- }
132
-
133
- if (this.readyState == this.CONNECTING) {
134
- this.dispatchEvent(new CustomEvent('open'));
135
- this._setReadyState(this.OPEN);
136
- }
137
-
138
- var data = this.xhr.responseText.substring(this.progress);
139
- this.progress += data.length;
140
- data.split(/(\r\n|\r|\n){2}/g).forEach(
141
- function (part) {
142
- if (part.trim().length === 0) {
143
- this.dispatchEvent(this._parseEventChunk(this.chunk.trim()));
144
- this.chunk = '';
145
- } else {
146
- this.chunk += part;
147
- }
148
- }.bind(this),
149
- );
150
- };
151
-
152
- this._onStreamLoaded = function (e) {
153
- this._onStreamProgress(e);
154
-
155
- // Parse the last chunk.
156
- this.dispatchEvent(this._parseEventChunk(this.chunk));
157
- this.chunk = '';
158
- };
159
-
160
- /**
161
- * Parse a received SSE event chunk into a constructed event object.
162
- */
163
- this._parseEventChunk = function (chunk) {
164
- if (!chunk || chunk.length === 0) {
165
- return null;
166
- }
167
-
168
- var e = { id: null, retry: null, data: '', event: 'message' };
169
- chunk.split(/\n|\r\n|\r/).forEach(
170
- function (line) {
171
- line = line.trimRight();
172
- var index = line.indexOf(this.FIELD_SEPARATOR);
173
- if (index <= 0) {
174
- // Line was either empty, or started with a separator and is a comment.
175
- // Either way, ignore.
176
- return;
177
- }
178
-
179
- var field = line.substring(0, index);
180
- if (!(field in e)) {
181
- return;
182
- }
183
-
184
- var value = line.substring(index + 1).trimLeft();
185
- if (field === 'data') {
186
- e[field] += value;
187
- } else {
188
- e[field] = value;
189
- }
190
- }.bind(this),
191
- );
192
-
193
- var event = new CustomEvent(e.event);
194
- event.data = e.data;
195
- event.id = e.id;
196
- return event;
197
- };
198
-
199
- this._checkStreamClosed = function () {
200
- if (!this.xhr) {
201
- return;
202
- }
203
-
204
- if (this.xhr.readyState === XMLHttpRequest.DONE) {
205
- this._setReadyState(this.CLOSED);
206
- }
207
- };
208
-
209
- this.stream = function () {
210
- this._setReadyState(this.CONNECTING);
211
-
212
- this.xhr = new XMLHttpRequest();
213
- this.xhr.addEventListener('progress', this._onStreamProgress.bind(this));
214
- this.xhr.addEventListener('load', this._onStreamLoaded.bind(this));
215
- this.xhr.addEventListener('readystatechange', this._checkStreamClosed.bind(this));
216
- this.xhr.addEventListener('error', this._onStreamFailure.bind(this));
217
- this.xhr.addEventListener('abort', this._onStreamAbort.bind(this));
218
- this.xhr.open(this.method, this.url);
219
- for (var header in this.headers) {
220
- this.xhr.setRequestHeader(header, this.headers[header]);
221
- }
222
- this.xhr.withCredentials = this.withCredentials;
223
- this.xhr.send(this.payload);
224
- };
225
-
226
- this.close = function () {
227
- if (this.readyState === this.CLOSED) {
228
- return;
229
- }
230
-
231
- this.xhr.abort();
232
- this.xhr = null;
233
- this._setReadyState(this.CLOSED);
234
- };
235
- };
236
-
237
- export { SSE };
238
- // Export our SSE module for npm.js
239
- // if (typeof exports !== 'undefined') {
240
- // // exports.SSE = SSE;
241
- // module.exports = { SSE };
242
- // }