@realtimex/sdk 1.6.0 → 1.7.4

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.
@@ -0,0 +1,445 @@
1
+ /**
2
+ * DeveloperApiClient - HTTP client for the RealtimeX v1 Developer API.
3
+ *
4
+ * Supports two authentication modes:
5
+ * - API Key: Authorization: Bearer <apiKey>
6
+ * - App ID: x-app-id header (for LocalApp / SDK agent authentication)
7
+ *
8
+ * When both are provided, x-app-id takes priority on the server side.
9
+ */
10
+ declare class DeveloperApiClient {
11
+ private readonly baseUrl;
12
+ private readonly apiKey;
13
+ private readonly appId?;
14
+ constructor(baseUrl: string, apiKey: string, appId?: string);
15
+ private getHeaders;
16
+ private handleResponse;
17
+ /**
18
+ * Make a JSON request to the v1 API.
19
+ */
20
+ request<T = unknown>(method: string, path: string, body?: unknown): Promise<T>;
21
+ /**
22
+ * Make a multipart/form-data request (e.g. file uploads).
23
+ * Do NOT set Content-Type — browser/fetch will set it with the boundary.
24
+ */
25
+ requestMultipart<T = unknown>(method: string, path: string, form: FormData): Promise<T>;
26
+ /**
27
+ * Make a raw request and return the Response object directly.
28
+ * Used for streaming (SSE) endpoints.
29
+ */
30
+ requestRaw(method: string, path: string, body?: unknown): Promise<Response>;
31
+ }
32
+
33
+ declare class V1AuthModule {
34
+ private readonly client;
35
+ constructor(client: DeveloperApiClient);
36
+ /**
37
+ * Verify the attached Authentication header contains a valid API token.
38
+ * @see GET /v1/auth
39
+ */
40
+ getAuth(): Promise<unknown>;
41
+ }
42
+
43
+ declare class V1AdminModule {
44
+ private readonly client;
45
+ constructor(client: DeveloperApiClient);
46
+ /**
47
+ * Check to see if the instance is in multi-user-mode first. Methods are disabled until multi user mode is enabled via the UI.
48
+ * @see GET /v1/admin/is-multi-user-mode
49
+ */
50
+ getIsMultiUserMode(): Promise<unknown>;
51
+ /**
52
+ * Check to see if the instance is in multi-user-mode first. Methods are disabled until multi user mode is enabled via the UI.
53
+ * @see GET /v1/admin/users
54
+ */
55
+ listUsers(): Promise<unknown>;
56
+ /**
57
+ * Create a new user with username and password. Methods are disabled until multi user mode is enabled via the UI.
58
+ * @see POST /v1/admin/users/new
59
+ */
60
+ createUser(body?: Record<string, unknown>): Promise<unknown>;
61
+ /**
62
+ * Update existing user settings. Methods are disabled until multi user mode is enabled via the UI.
63
+ * @see POST /v1/admin/users/{id}
64
+ */
65
+ updateUser(id: string, body?: Record<string, unknown>): Promise<unknown>;
66
+ /**
67
+ * Delete existing user by id. Methods are disabled until multi user mode is enabled via the UI.
68
+ * @see DELETE /v1/admin/users/{id}
69
+ */
70
+ deleteUser(id: string): Promise<unknown>;
71
+ /**
72
+ * List all existing invitations to instance regardless of status. Methods are disabled until multi user mode is enabled via the UI.
73
+ * @see GET /v1/admin/invites
74
+ */
75
+ listInvites(): Promise<unknown>;
76
+ /**
77
+ * Create a new invite code for someone to use to register with instance. Methods are disabled until multi user mode is enabled via the UI.
78
+ * @see POST /v1/admin/invite/new
79
+ */
80
+ createInvite(body?: Record<string, unknown>): Promise<unknown>;
81
+ /**
82
+ * Deactivates (soft-delete) invite by id. Methods are disabled until multi user mode is enabled via the UI.
83
+ * @see DELETE /v1/admin/invite/{id}
84
+ */
85
+ deleteInvite(id: string): Promise<unknown>;
86
+ /**
87
+ * Retrieve a list of users with permissions to access the specified workspace.
88
+ * @see GET /v1/admin/workspaces/{workspaceId}/users
89
+ */
90
+ listWorkspaceUsers(workspaceId: string): Promise<unknown>;
91
+ /**
92
+ * Overwrite workspace permissions to only be accessible by the given user ids and admins. Methods are disabled until multi user mode is enabled via the UI.
93
+ * @see POST /v1/admin/workspaces/{workspaceId}/update-users
94
+ */
95
+ updateUsers(workspaceId: string, body?: Record<string, unknown>): Promise<unknown>;
96
+ /**
97
+ * Set workspace permissions to be accessible by the given user ids and admins. Methods are disabled until multi user mode is enabled via the UI.
98
+ * @see POST /v1/admin/workspaces/{workspaceSlug}/manage-users
99
+ */
100
+ workspacesManageUsers(workspaceSlug: string, body?: Record<string, unknown>): Promise<unknown>;
101
+ /**
102
+ * All chats in the system ordered by most recent. Methods are disabled until multi user mode is enabled via the UI.
103
+ * @see POST /v1/admin/workspace-chats
104
+ */
105
+ workspaceChats(body?: Record<string, unknown>): Promise<unknown>;
106
+ /**
107
+ * Update multi-user preferences for instance. Methods are disabled until multi user mode is enabled via the UI.
108
+ * @see POST /v1/admin/preferences
109
+ */
110
+ createPreference(body?: Record<string, unknown>): Promise<unknown>;
111
+ }
112
+
113
+ declare class V1DocumentModule {
114
+ private readonly client;
115
+ constructor(client: DeveloperApiClient);
116
+ /**
117
+ * Upload a new file to RealTimeX to be parsed and prepared for embedding.
118
+ * @see POST /v1/document/upload
119
+ */
120
+ upload(form: FormData): Promise<unknown>;
121
+ /**
122
+ * Upload a new file to a specific folder in RealTimeX to be parsed and prepared for embedding. If the folder does not exist, it will be created.
123
+ * @see POST /v1/document/upload/{folderName}
124
+ */
125
+ uploadFolder(folderName: string, form: FormData): Promise<unknown>;
126
+ /**
127
+ * Upload a valid URL for RealTimeX to scrape and prepare for embedding. Optionally, specify a comma-separated list of workspace slugs to embed the document into post-upload.
128
+ * @see POST /v1/document/upload-link
129
+ */
130
+ uploadLink(body?: Record<string, unknown>): Promise<unknown>;
131
+ /**
132
+ * Upload a file by specifying its raw text content and metadata values without having to upload a file.
133
+ * @see POST /v1/document/raw-text
134
+ */
135
+ rawText(body?: Record<string, unknown>): Promise<unknown>;
136
+ /**
137
+ * List of all locally-stored documents in instance
138
+ * @see GET /v1/documents
139
+ */
140
+ listDocuments(): Promise<unknown>;
141
+ /**
142
+ * Get all documents stored in a specific folder.
143
+ * @see GET /v1/documents/folder/{folderName}
144
+ */
145
+ getFolder(folderName: string): Promise<unknown>;
146
+ /**
147
+ * Check available filetypes and MIMEs that can be uploaded.
148
+ * @see GET /v1/document/accepted-file-types
149
+ */
150
+ listAcceptedFileTypes(): Promise<unknown>;
151
+ /**
152
+ * Get the known available metadata schema for when doing a raw-text upload and the acceptable type of value for each key.
153
+ * @see GET /v1/document/metadata-schema
154
+ */
155
+ getMetadataSchema(): Promise<unknown>;
156
+ /**
157
+ * Get a single document by its unique RealTimeX document name
158
+ * @see GET /v1/document/{docName}
159
+ */
160
+ getDocument(docName: string): Promise<unknown>;
161
+ /**
162
+ * Create a new folder inside the documents storage directory.
163
+ * @see POST /v1/document/create-folder
164
+ */
165
+ createFolder(body?: Record<string, unknown>): Promise<unknown>;
166
+ /**
167
+ * Remove a folder and all its contents from the documents storage directory.
168
+ * @see DELETE /v1/document/remove-folder
169
+ */
170
+ deleteRemoveFolder(): Promise<unknown>;
171
+ /**
172
+ * Move files within the documents storage directory.
173
+ * @see POST /v1/document/move-files
174
+ */
175
+ moveFiles(body?: Record<string, unknown>): Promise<unknown>;
176
+ }
177
+
178
+ declare class V1WorkspaceModule {
179
+ private readonly client;
180
+ constructor(client: DeveloperApiClient);
181
+ /**
182
+ * Create a new workspace
183
+ * @see POST /v1/workspace/new
184
+ */
185
+ createWorkspace(body?: Record<string, unknown>): Promise<unknown>;
186
+ /**
187
+ * List all current workspaces
188
+ * @see GET /v1/workspaces
189
+ */
190
+ listWorkspaces(): Promise<unknown>;
191
+ /**
192
+ * Get a workspace by its unique slug.
193
+ * @see GET /v1/workspace/{slug}
194
+ */
195
+ getWorkspace(slug: string): Promise<unknown>;
196
+ /**
197
+ * Deletes a workspace by its slug.
198
+ * @see DELETE /v1/workspace/{slug}
199
+ */
200
+ deleteWorkspace(slug: string): Promise<unknown>;
201
+ /**
202
+ * Update workspace settings by its unique slug.
203
+ * @see POST /v1/workspace/{slug}/update
204
+ */
205
+ updateWorkspace(slug: string, body?: Record<string, unknown>): Promise<unknown>;
206
+ /**
207
+ * Get a workspaces chats regardless of user by its unique slug.
208
+ * @see GET /v1/workspace/{slug}/chats
209
+ */
210
+ listChats(slug: string): Promise<unknown>;
211
+ /**
212
+ * Add or remove documents from a workspace by its unique slug.
213
+ * @see POST /v1/workspace/{slug}/update-embeddings
214
+ */
215
+ updateEmbeddings(slug: string, body?: Record<string, unknown>): Promise<unknown>;
216
+ /**
217
+ * Add or remove pin from a document in a workspace by its unique slug.
218
+ * @see POST /v1/workspace/{slug}/update-pin
219
+ */
220
+ updatePin(slug: string, body?: Record<string, unknown>): Promise<unknown>;
221
+ /**
222
+ * Execute a chat with a workspace
223
+ * @see POST /v1/workspace/{slug}/chat
224
+ */
225
+ chat(slug: string, body?: Record<string, unknown>): Promise<unknown>;
226
+ /**
227
+ * Execute a streamable chat with a workspace
228
+ * @see POST /v1/workspace/{slug}/stream-chat
229
+ */
230
+ streamChat(slug: string, body?: Record<string, unknown>): Promise<Response>;
231
+ /**
232
+ * Perform a vector similarity search in a workspace
233
+ * @see POST /v1/workspace/{slug}/vector-search
234
+ */
235
+ vectorSearch(slug: string, body?: Record<string, unknown>): Promise<unknown>;
236
+ }
237
+
238
+ declare class V1SystemModule {
239
+ private readonly client;
240
+ constructor(client: DeveloperApiClient);
241
+ /**
242
+ * Dump all settings to file storage
243
+ * @see GET /v1/system/env-dump
244
+ */
245
+ getEnvDump(): Promise<unknown>;
246
+ /**
247
+ * Get all current system settings that are defined.
248
+ * @see GET /v1/system
249
+ */
250
+ getSystem(): Promise<unknown>;
251
+ /**
252
+ * Number of all vectors in connected vector database
253
+ * @see GET /v1/system/vector-count
254
+ */
255
+ getVectorCount(): Promise<unknown>;
256
+ /**
257
+ * Update a system setting or preference.
258
+ * @see POST /v1/system/update-env
259
+ */
260
+ updateEnv(body?: Record<string, unknown>): Promise<unknown>;
261
+ /**
262
+ * Export all of the chats from the system in a known format. Output depends on the type sent. Will be send with the correct header for the output.
263
+ * @see GET /v1/system/export-chats
264
+ */
265
+ listExportChats(): Promise<unknown>;
266
+ /**
267
+ * Permanently remove documents from the system.
268
+ * @see DELETE /v1/system/remove-documents
269
+ */
270
+ deleteRemoveDocument(): Promise<unknown>;
271
+ /**
272
+ * Returns a health check object with server uptime and version.
273
+ * @see GET /v1/system/health
274
+ */
275
+ getHealth(): Promise<unknown>;
276
+ /**
277
+ * Returns a health check object with server uptime and version.
278
+ * @see GET /v1/system/health-version-2
279
+ */
280
+ getHealthVersion2(): Promise<unknown>;
281
+ /**
282
+ * Returns a health check object with server uptime and version.
283
+ * @see GET /v1/system/health-version-3
284
+ */
285
+ getHealthVersion3(): Promise<unknown>;
286
+ }
287
+
288
+ declare class V1ThreadModule {
289
+ private readonly client;
290
+ constructor(client: DeveloperApiClient);
291
+ /**
292
+ * Create a new workspace thread
293
+ * @see POST /v1/workspace/{slug}/thread/new
294
+ */
295
+ createThread(slug: string, body?: Record<string, unknown>): Promise<unknown>;
296
+ /**
297
+ * Update thread settings by its unique slug.
298
+ * @see POST /v1/workspace/{slug}/thread/{threadSlug}/update
299
+ */
300
+ updateThread(slug: string, threadSlug: string, body?: Record<string, unknown>): Promise<unknown>;
301
+ /**
302
+ * Delete a workspace thread
303
+ * @see DELETE /v1/workspace/{slug}/thread/{threadSlug}
304
+ */
305
+ deleteThread(slug: string, threadSlug: string): Promise<unknown>;
306
+ /**
307
+ * Get chats for a workspace thread
308
+ * @see GET /v1/workspace/{slug}/thread/{threadSlug}/chats
309
+ */
310
+ listChats(slug: string, threadSlug: string): Promise<unknown>;
311
+ /**
312
+ * Chat with a workspace thread
313
+ * @see POST /v1/workspace/{slug}/thread/{threadSlug}/chat
314
+ */
315
+ chat(slug: string, threadSlug: string, body?: Record<string, unknown>): Promise<unknown>;
316
+ /**
317
+ * Stream chat with a workspace thread
318
+ * @see POST /v1/workspace/{slug}/thread/{threadSlug}/stream-chat
319
+ */
320
+ streamChat(slug: string, threadSlug: string, body?: Record<string, unknown>): Promise<Response>;
321
+ }
322
+
323
+ declare class V1UsersModule {
324
+ private readonly client;
325
+ constructor(client: DeveloperApiClient);
326
+ /**
327
+ * List all users
328
+ * @see GET /v1/users
329
+ */
330
+ listUsers(): Promise<unknown>;
331
+ /**
332
+ * Issue a temporary auth token for a user
333
+ * @see GET /v1/users/{id}/issue-auth-token
334
+ */
335
+ getIssueAuthToken(id: string): Promise<unknown>;
336
+ }
337
+
338
+ declare class V1OpenAIModule {
339
+ private readonly client;
340
+ constructor(client: DeveloperApiClient);
341
+ /**
342
+ * Get all available "models" which are workspaces you can use for chatting.
343
+ * @see GET /v1/openai/models
344
+ */
345
+ listModels(): Promise<unknown>;
346
+ /**
347
+ * Execute a chat with a workspace with OpenAI compatibility. Supports streaming as well. Model must be a workspace slug from /models.
348
+ * @see POST /v1/openai/chat/completions
349
+ */
350
+ chatCompletions(body?: Record<string, unknown>): Promise<unknown>;
351
+ /**
352
+ * Get the embeddings of any arbitrary text string. This will use the embedder provider set in the system. Please ensure the token length of each string fits within the context of your embedder model.
353
+ * @see POST /v1/openai/embeddings
354
+ */
355
+ createEmbedding(body?: Record<string, unknown>): Promise<unknown>;
356
+ /**
357
+ * List all the vector database collections connected to RealTimeX. These are essentially workspaces but return their unique vector db identifier - this is the same as the workspace slug.
358
+ * @see GET /v1/openai/vector_stores
359
+ */
360
+ listVectorStores(): Promise<unknown>;
361
+ }
362
+
363
+ declare class V1EmbedModule {
364
+ private readonly client;
365
+ constructor(client: DeveloperApiClient);
366
+ /**
367
+ * List all active embeds
368
+ * @see GET /v1/embed
369
+ */
370
+ getEmbed(): Promise<unknown>;
371
+ /**
372
+ * Get all chats for a specific embed
373
+ * @see GET /v1/embed/{embedUuid}/chats
374
+ */
375
+ listChats(embedUuid: string): Promise<unknown>;
376
+ /**
377
+ * Get chats for a specific embed and session
378
+ * @see GET /v1/embed/{embedUuid}/chats/{sessionUuid}
379
+ */
380
+ getChat(embedUuid: string, sessionUuid: string): Promise<unknown>;
381
+ /**
382
+ * Create a new embed configuration
383
+ * @see POST /v1/embed/new
384
+ */
385
+ createEmbed(body?: Record<string, unknown>): Promise<unknown>;
386
+ /**
387
+ * Update an existing embed configuration
388
+ * @see POST /v1/embed/{embedUuid}
389
+ */
390
+ updateEmbed(embedUuid: string, body?: Record<string, unknown>): Promise<unknown>;
391
+ /**
392
+ * Delete an existing embed configuration
393
+ * @see DELETE /v1/embed/{embedUuid}
394
+ */
395
+ deleteEmbed(embedUuid: string): Promise<unknown>;
396
+ }
397
+
398
+ /**
399
+ * V1ApiNamespace - Container for all RealtimeX Developer API (v1) modules.
400
+ *
401
+ * Usage:
402
+ * const sdk = new RealtimeXSDK({ realtimex: { apiKey: 'sk-...' } });
403
+ * await sdk.v1?.workspace.listWorkspaces();
404
+ * await sdk.v1?.admin.listUsers();
405
+ *
406
+ * Regenerate modules: node scripts/generate-v1-sdk.mjs --force
407
+ */
408
+
409
+ declare class V1ApiNamespace {
410
+ /** @internal Shared HTTP client used by all v1 modules */
411
+ readonly _client: DeveloperApiClient;
412
+ auth: V1AuthModule;
413
+ admin: V1AdminModule;
414
+ document: V1DocumentModule;
415
+ workspace: V1WorkspaceModule;
416
+ system: V1SystemModule;
417
+ thread: V1ThreadModule;
418
+ users: V1UsersModule;
419
+ openai: V1OpenAIModule;
420
+ embed: V1EmbedModule;
421
+ constructor(baseUrl: string, apiKey: string, appId?: string);
422
+ }
423
+
424
+ /**
425
+ * RealtimeX SDK - Developer API (v1) Error Classes
426
+ */
427
+ declare class DeveloperApiError extends Error {
428
+ readonly status: number;
429
+ readonly code: string;
430
+ constructor(status: number, code: string, message: string);
431
+ }
432
+ declare class AuthenticationError extends DeveloperApiError {
433
+ constructor(message?: string);
434
+ }
435
+ declare class NotFoundError extends DeveloperApiError {
436
+ constructor(message?: string);
437
+ }
438
+ declare class ValidationError extends DeveloperApiError {
439
+ constructor(message: string);
440
+ }
441
+ declare class ServerError extends DeveloperApiError {
442
+ constructor(message?: string);
443
+ }
444
+
445
+ export { AuthenticationError as A, DeveloperApiClient as D, NotFoundError as N, ServerError as S, V1ApiNamespace as V, DeveloperApiError as a, ValidationError as b, V1AuthModule as c, V1AdminModule as d, V1DocumentModule as e, V1WorkspaceModule as f, V1SystemModule as g, V1ThreadModule as h, V1UsersModule as i, V1OpenAIModule as j, V1EmbedModule as k };