@realtimex/sdk 2.0.17 → 2.0.19

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/dist/index.js DELETED
@@ -1,785 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- AuthenticationError: () => AuthenticationError,
24
- CliApiClient: () => CliApiClient,
25
- CliApiNamespace: () => CliApiNamespace,
26
- DeveloperApiClient: () => DeveloperApiClient,
27
- DeveloperApiError: () => DeveloperApiError,
28
- NotFoundError: () => NotFoundError,
29
- RealtimeXSDK: () => RealtimeXSDK,
30
- ServerError: () => ServerError,
31
- V1ApiNamespace: () => V1ApiNamespace,
32
- ValidationError: () => ValidationError
33
- });
34
- module.exports = __toCommonJS(index_exports);
35
-
36
- // src/v1/errors.ts
37
- var DeveloperApiError = class extends Error {
38
- constructor(status, code, message) {
39
- super(message);
40
- this.status = status;
41
- this.code = code;
42
- this.name = "DeveloperApiError";
43
- }
44
- };
45
- var AuthenticationError = class extends DeveloperApiError {
46
- constructor(message = "Invalid or missing API key") {
47
- super(403, "AUTHENTICATION_ERROR", message);
48
- this.name = "AuthenticationError";
49
- }
50
- };
51
- var NotFoundError = class extends DeveloperApiError {
52
- constructor(message = "Resource not found") {
53
- super(404, "NOT_FOUND", message);
54
- this.name = "NotFoundError";
55
- }
56
- };
57
- var ValidationError = class extends DeveloperApiError {
58
- constructor(message) {
59
- super(400, "VALIDATION_ERROR", message);
60
- this.name = "ValidationError";
61
- }
62
- };
63
- var ServerError = class extends DeveloperApiError {
64
- constructor(message = "Internal server error") {
65
- super(500, "SERVER_ERROR", message);
66
- this.name = "ServerError";
67
- }
68
- };
69
-
70
- // src/v1/client.ts
71
- var DeveloperApiClient = class {
72
- constructor(baseUrl, apiKey, appId) {
73
- this.baseUrl = baseUrl.replace(/\/$/, "");
74
- this.apiKey = apiKey;
75
- this.appId = appId;
76
- }
77
- getHeaders(extra) {
78
- const headers = {
79
- "Content-Type": "application/json",
80
- "Authorization": `Bearer ${this.apiKey}`
81
- };
82
- if (this.appId) headers["x-app-id"] = this.appId;
83
- return { ...headers, ...extra };
84
- }
85
- async handleResponse(response) {
86
- let data;
87
- try {
88
- data = await response.json();
89
- } catch {
90
- data = {};
91
- }
92
- if (response.ok) return data;
93
- const message = data?.message || data?.error || response.statusText || "Request failed";
94
- switch (response.status) {
95
- case 400:
96
- throw new ValidationError(message);
97
- case 401:
98
- case 403:
99
- throw new AuthenticationError(message);
100
- case 404:
101
- throw new NotFoundError(message);
102
- case 500:
103
- case 502:
104
- case 503:
105
- throw new ServerError(message);
106
- default:
107
- throw new DeveloperApiError(response.status, "API_ERROR", message);
108
- }
109
- }
110
- /**
111
- * Make a JSON request to the v1 API.
112
- */
113
- async request(method, path, body) {
114
- const url = `${this.baseUrl}/api${path}`;
115
- const response = await fetch(url, {
116
- method,
117
- headers: this.getHeaders(),
118
- body: body !== void 0 ? JSON.stringify(body) : void 0
119
- });
120
- return this.handleResponse(response);
121
- }
122
- /**
123
- * Make a multipart/form-data request (e.g. file uploads).
124
- * Do NOT set Content-Type — browser/fetch will set it with the boundary.
125
- */
126
- async requestMultipart(method, path, form) {
127
- const url = `${this.baseUrl}/api${path}`;
128
- const authHeaders = { "Authorization": `Bearer ${this.apiKey}` };
129
- if (this.appId) authHeaders["x-app-id"] = this.appId;
130
- const response = await fetch(url, {
131
- method,
132
- headers: authHeaders,
133
- body: form
134
- });
135
- return this.handleResponse(response);
136
- }
137
- /**
138
- * Make a raw request and return the Response object directly.
139
- * Used for streaming (SSE) endpoints.
140
- */
141
- async requestRaw(method, path, body) {
142
- const url = `${this.baseUrl}/api${path}`;
143
- return fetch(url, {
144
- method,
145
- headers: this.getHeaders(),
146
- body: body !== void 0 ? JSON.stringify(body) : void 0
147
- });
148
- }
149
- };
150
-
151
- // src/v1/modules/v1Chat.ts
152
- var V1ChatModule = class {
153
- constructor(client) {
154
- this.client = client;
155
- }
156
- /**
157
- * Stream a chat response for a workspace default thread.
158
- * @see POST /v1/workspace/{slug}/stream-chat
159
- */
160
- // @streaming-stub — implement SSE parsing in overrides/v1ChatStreaming.ts
161
- async streamWorkspaceChat(slug, body) {
162
- return this.client.requestRaw("POST", `/v1/workspace/${slug}/stream-chat`, body);
163
- }
164
- /**
165
- * Stream a chat response for a workspace thread.
166
- * @see POST /v1/workspace/{slug}/thread/{threadSlug}/stream-chat
167
- */
168
- // @streaming-stub — implement SSE parsing in overrides/v1ChatStreaming.ts
169
- async streamThreadChat(slug, threadSlug, body) {
170
- return this.client.requestRaw("POST", `/v1/workspace/${slug}/thread/${threadSlug}/stream-chat`, body);
171
- }
172
- };
173
-
174
- // src/v1/modules/v1Workspace.ts
175
- var V1WorkspaceModule = class {
176
- constructor(client) {
177
- this.client = client;
178
- }
179
- /**
180
- * List workspaces using the app workspace list behavior.
181
- * @see GET /v1/workspaces
182
- */
183
- async listWorkspaces() {
184
- return this.client.request("GET", `/v1/workspaces`);
185
- }
186
- /**
187
- * Create a workspace using the app workspace creation behavior.
188
- * @see POST /v1/workspace/new
189
- */
190
- async createWorkspace(body) {
191
- return this.client.request("POST", `/v1/workspace/new`, body);
192
- }
193
- /**
194
- * Search workspaces and threads.
195
- * @see POST /v1/workspace/search
196
- */
197
- async searchWorkspaces(body) {
198
- return this.client.request("POST", `/v1/workspace/search`, body);
199
- }
200
- /**
201
- * Get a workspace by slug.
202
- * @see GET /v1/workspace/{slug}
203
- */
204
- async getWorkspace(slug) {
205
- return this.client.request("GET", `/v1/workspace/${slug}`);
206
- }
207
- /**
208
- * Delete a workspace.
209
- * @see DELETE /v1/workspace/{slug}
210
- */
211
- async deleteWorkspace(slug) {
212
- return this.client.request("DELETE", `/v1/workspace/${slug}`);
213
- }
214
- /**
215
- * Get document content for a workspace document.
216
- * @see GET /v1/workspace/{slug}/document/{docPath}
217
- */
218
- async getWorkspaceDocument(slug, docPath) {
219
- return this.client.request("GET", `/v1/workspace/${slug}/document/${docPath}`);
220
- }
221
- /**
222
- * Get or create workspace config.
223
- * @see GET /v1/workspace/{slug}/config
224
- */
225
- async getWorkspaceConfig(slug) {
226
- return this.client.request("GET", `/v1/workspace/${slug}/config`);
227
- }
228
- /**
229
- * Update workspace config.
230
- * @see POST /v1/workspace/{slug}/config
231
- */
232
- async updateWorkspaceConfig(slug, body) {
233
- return this.client.request("POST", `/v1/workspace/${slug}/config`, body);
234
- }
235
- /**
236
- * Update workspace settings by slug.
237
- * @see POST /v1/workspace/{slug}/update
238
- */
239
- async updateWorkspace(slug, body) {
240
- return this.client.request("POST", `/v1/workspace/${slug}/update`, body);
241
- }
242
- /**
243
- * Generate a local LLM tuning suggestion.
244
- * @see POST /v1/workspace/{slug}/local-llm-tuning-suggestion
245
- */
246
- async suggestWorkspaceLocalLlmTuning(slug, body) {
247
- return this.client.request("POST", `/v1/workspace/${slug}/local-llm-tuning-suggestion`, body);
248
- }
249
- /**
250
- * Upload a document to workspace documents.
251
- * @see POST /v1/workspace/{slug}/upload
252
- */
253
- // @upload-stub — multipart upload; wire form manually or use helper
254
- async uploadWorkspaceDocument(slug, form) {
255
- return this.client.requestMultipart("POST", `/v1/workspace/${slug}/upload`, form);
256
- }
257
- /**
258
- * Upload a link to workspace documents.
259
- * @see POST /v1/workspace/{slug}/upload-link
260
- */
261
- async uploadWorkspaceLink(slug, body) {
262
- return this.client.request("POST", `/v1/workspace/${slug}/upload-link`, body);
263
- }
264
- /**
265
- * Update workspace document embeddings.
266
- * @see POST /v1/workspace/{slug}/update-embeddings
267
- */
268
- async updateWorkspaceEmbeddings(slug, body) {
269
- return this.client.request("POST", `/v1/workspace/${slug}/update-embeddings`, body);
270
- }
271
- /**
272
- * Reset workspace vector database records.
273
- * @see DELETE /v1/workspace/{slug}/reset-vector-db
274
- */
275
- async resetWorkspaceVectorDb(slug) {
276
- return this.client.request("DELETE", `/v1/workspace/${slug}/reset-vector-db`);
277
- }
278
- /**
279
- * Get workspace LLM provider metadata.
280
- * @see GET /v1/workspace/{slug}/llm-provider
281
- */
282
- async getWorkspaceLlmProvider(slug) {
283
- return this.client.request("GET", `/v1/workspace/${slug}/llm-provider`);
284
- }
285
- /**
286
- * Get workspace vision availability.
287
- * @see GET /v1/workspace/{slug}/vision-availability
288
- */
289
- async getWorkspaceVisionAvailability(slug) {
290
- return this.client.request("GET", `/v1/workspace/${slug}/vision-availability`);
291
- }
292
- /**
293
- * Get workspace chats.
294
- * @see GET /v1/workspace/{slug}/chats
295
- */
296
- async getWorkspaceChats(slug) {
297
- return this.client.request("GET", `/v1/workspace/${slug}/chats`);
298
- }
299
- /**
300
- * Get workspace terminal session details.
301
- * @see GET /v1/workspace/{slug}/terminal-session-details
302
- */
303
- async getWorkspaceTerminalSessionDetails(slug) {
304
- return this.client.request("GET", `/v1/workspace/${slug}/terminal-session-details`);
305
- }
306
- /**
307
- * Persist terminal UI events.
308
- * @see POST /v1/workspace/{slug}/terminal-ui-events
309
- */
310
- async persistWorkspaceTerminalUiEvents(slug, body) {
311
- return this.client.request("POST", `/v1/workspace/${slug}/terminal-ui-events`, body);
312
- }
313
- /**
314
- * Persist a linked terminal message.
315
- * @see POST /v1/workspace/{slug}/linked-terminal-message
316
- */
317
- async createWorkspaceLinkedTerminalMessage(slug, body) {
318
- return this.client.request("POST", `/v1/workspace/${slug}/linked-terminal-message`, body);
319
- }
320
- /**
321
- * Delete selected workspace chats.
322
- * @see DELETE /v1/workspace/{slug}/delete-chats
323
- */
324
- async deleteWorkspaceChats(slug, body) {
325
- return this.client.request("DELETE", `/v1/workspace/${slug}/delete-chats`, body);
326
- }
327
- /**
328
- * Delete edited workspace chats from a starting id.
329
- * @see DELETE /v1/workspace/{slug}/delete-edited-chats
330
- */
331
- async deleteEditedWorkspaceChats(slug, body) {
332
- return this.client.request("DELETE", `/v1/workspace/${slug}/delete-edited-chats`, body);
333
- }
334
- /**
335
- * Update a workspace chat response.
336
- * @see POST /v1/workspace/{slug}/update-chat
337
- */
338
- async updateWorkspaceChat(slug, body) {
339
- return this.client.request("POST", `/v1/workspace/${slug}/update-chat`, body);
340
- }
341
- /**
342
- * Update workspace chat feedback.
343
- * @see POST /v1/workspace/{slug}/chat-feedback/{chatId}
344
- */
345
- async updateWorkspaceChatFeedback(slug, chatId, body) {
346
- return this.client.request("POST", `/v1/workspace/${slug}/chat-feedback/${chatId}`, body);
347
- }
348
- /**
349
- * Get suggested messages for a workspace.
350
- * @see GET /v1/workspace/{slug}/suggested-messages
351
- */
352
- async getWorkspaceSuggestedMessages(slug) {
353
- return this.client.request("GET", `/v1/workspace/${slug}/suggested-messages`);
354
- }
355
- /**
356
- * Save suggested messages for a workspace.
357
- * @see POST /v1/workspace/{slug}/suggested-messages
358
- */
359
- async saveWorkspaceSuggestedMessages(slug, body) {
360
- return this.client.request("POST", `/v1/workspace/${slug}/suggested-messages`, body);
361
- }
362
- /**
363
- * Update workspace document pin status.
364
- * @see POST /v1/workspace/{slug}/update-pin
365
- */
366
- async updateWorkspaceDocumentPin(slug, body) {
367
- return this.client.request("POST", `/v1/workspace/${slug}/update-pin`, body);
368
- }
369
- /**
370
- * Generate text-to-speech audio for a workspace chat.
371
- * @see GET /v1/workspace/{slug}/tts/{chatId}
372
- */
373
- async getWorkspaceChatTts(slug, chatId) {
374
- return this.client.request("GET", `/v1/workspace/${slug}/tts/${chatId}`);
375
- }
376
- /**
377
- * Get a workspace profile picture.
378
- * @see GET /v1/workspace/{slug}/pfp
379
- */
380
- async getWorkspaceProfilePicture(slug) {
381
- return this.client.request("GET", `/v1/workspace/${slug}/pfp`);
382
- }
383
- /**
384
- * Upload a workspace profile picture.
385
- * @see POST /v1/workspace/{slug}/upload-pfp
386
- */
387
- // @upload-stub — multipart upload; wire form manually or use helper
388
- async uploadWorkspaceProfilePicture(slug, form) {
389
- return this.client.requestMultipart("POST", `/v1/workspace/${slug}/upload-pfp`, form);
390
- }
391
- /**
392
- * Remove a workspace profile picture.
393
- * @see DELETE /v1/workspace/{slug}/remove-pfp
394
- */
395
- async removeWorkspaceProfilePicture(slug) {
396
- return this.client.request("DELETE", `/v1/workspace/${slug}/remove-pfp`);
397
- }
398
- /**
399
- * Fork the workspace default thread.
400
- * @see POST /v1/workspace/{slug}/thread/fork
401
- */
402
- async forkThread(slug, body) {
403
- return this.client.request("POST", `/v1/workspace/${slug}/thread/fork`, body);
404
- }
405
- /**
406
- * Hide a workspace chat.
407
- * @see PUT /v1/workspace/workspace-chats/{id}
408
- */
409
- async hideWorkspaceChat(id) {
410
- return this.client.request("PUT", `/v1/workspace/workspace-chats/${id}`);
411
- }
412
- /**
413
- * Upload and embed a document.
414
- * @see POST /v1/workspace/{slug}/upload-and-embed
415
- */
416
- // @upload-stub — multipart upload; wire form manually or use helper
417
- async uploadAndEmbedWorkspaceDocument(slug, form) {
418
- return this.client.requestMultipart("POST", `/v1/workspace/${slug}/upload-and-embed`, form);
419
- }
420
- /**
421
- * Remove and unembed a document.
422
- * @see DELETE /v1/workspace/{slug}/remove-and-unembed
423
- */
424
- async removeAndUnembedWorkspaceDocument(slug, body) {
425
- return this.client.request("DELETE", `/v1/workspace/${slug}/remove-and-unembed`, body);
426
- }
427
- /**
428
- * Get workspace prompt history.
429
- * @see GET /v1/workspace/{slug}/prompt-history
430
- */
431
- async getWorkspacePromptHistory(slug) {
432
- return this.client.request("GET", `/v1/workspace/${slug}/prompt-history`);
433
- }
434
- /**
435
- * Clear workspace prompt history.
436
- * @see DELETE /v1/workspace/{slug}/prompt-history
437
- */
438
- async deleteWorkspacePromptHistory(slug) {
439
- return this.client.request("DELETE", `/v1/workspace/${slug}/prompt-history`);
440
- }
441
- /**
442
- * Delete a workspace prompt history entry.
443
- * @see DELETE /v1/workspace/{slug}/prompt-history/{id}
444
- */
445
- async deleteWorkspacePromptHistoryEntry(slug, id) {
446
- return this.client.request("DELETE", `/v1/workspace/${slug}/prompt-history/${id}`);
447
- }
448
- /**
449
- * Validate search provider configuration.
450
- * @see POST /v1/workspace/{slug}/search/validate
451
- */
452
- async validateWorkspaceSearchProvider(slug, body) {
453
- return this.client.request("POST", `/v1/workspace/${slug}/search/validate`, body);
454
- }
455
- };
456
-
457
- // src/v1/modules/v1Thread.ts
458
- var V1ThreadModule = class {
459
- constructor(client) {
460
- this.client = client;
461
- }
462
- /**
463
- * Create a workspace thread.
464
- * @see POST /v1/workspace/{slug}/thread/new
465
- */
466
- async createThread(slug) {
467
- return this.client.request("POST", `/v1/workspace/${slug}/thread/new`);
468
- }
469
- /**
470
- * List workspace threads.
471
- * @see GET /v1/workspace/{slug}/threads
472
- */
473
- async listThreads(slug) {
474
- return this.client.request("GET", `/v1/workspace/${slug}/threads`);
475
- }
476
- /**
477
- * Open an SSE stream for workspace thread events.
478
- * @see GET /v1/workspace/{slug}/thread-events
479
- */
480
- async openThreadEventsStream(slug) {
481
- return this.client.request("GET", `/v1/workspace/${slug}/thread-events`);
482
- }
483
- /**
484
- * Get a workspace thread.
485
- * @see GET /v1/workspace/{slug}/thread/{threadSlug}
486
- */
487
- async getThread(slug, threadSlug) {
488
- return this.client.request("GET", `/v1/workspace/${slug}/thread/${threadSlug}`);
489
- }
490
- /**
491
- * Delete a workspace thread.
492
- * @see DELETE /v1/workspace/{slug}/thread/{threadSlug}
493
- */
494
- async deleteThread(slug, threadSlug) {
495
- return this.client.request("DELETE", `/v1/workspace/${slug}/thread/${threadSlug}`);
496
- }
497
- /**
498
- * Get thread vision availability.
499
- * @see GET /v1/workspace/{slug}/thread/{threadSlug}/vision-availability
500
- */
501
- async getThreadVisionAvailability(slug, threadSlug) {
502
- return this.client.request("GET", `/v1/workspace/${slug}/thread/${threadSlug}/vision-availability`);
503
- }
504
- /**
505
- * Promote a thread into a tracked goal.
506
- * @see POST /v1/workspace/{slug}/thread/{threadSlug}/goal
507
- */
508
- async createThreadGoal(slug, threadSlug, body) {
509
- return this.client.request("POST", `/v1/workspace/${slug}/thread/${threadSlug}/goal`, body);
510
- }
511
- /**
512
- * Draft a terminal goal for a workspace.
513
- * @see POST /v1/workspace/{slug}/terminal-goal-draft
514
- */
515
- async draftWorkspaceTerminalGoal(slug, body) {
516
- return this.client.request("POST", `/v1/workspace/${slug}/terminal-goal-draft`, body);
517
- }
518
- /**
519
- * Create a terminal goal for a workspace.
520
- * @see POST /v1/workspace/{slug}/terminal-goal
521
- */
522
- async createWorkspaceTerminalGoal(slug, body) {
523
- return this.client.request("POST", `/v1/workspace/${slug}/terminal-goal`, body);
524
- }
525
- /**
526
- * Draft a terminal goal for a workspace thread.
527
- * @see POST /v1/workspace/{slug}/thread/{threadSlug}/terminal-goal-draft
528
- */
529
- async draftThreadTerminalGoal(slug, threadSlug, body) {
530
- return this.client.request("POST", `/v1/workspace/${slug}/thread/${threadSlug}/terminal-goal-draft`, body);
531
- }
532
- /**
533
- * Create a terminal goal for a workspace thread.
534
- * @see POST /v1/workspace/{slug}/thread/{threadSlug}/terminal-goal
535
- */
536
- async createThreadTerminalGoal(slug, threadSlug, body) {
537
- return this.client.request("POST", `/v1/workspace/${slug}/thread/${threadSlug}/terminal-goal`, body);
538
- }
539
- /**
540
- * Bulk delete workspace threads.
541
- * @see DELETE /v1/workspace/{slug}/thread-bulk-delete
542
- */
543
- async bulkDeleteThreads(slug, body) {
544
- return this.client.request("DELETE", `/v1/workspace/${slug}/thread-bulk-delete`, body);
545
- }
546
- /**
547
- * Get workspace thread chats.
548
- * @see GET /v1/workspace/{slug}/thread/{threadSlug}/chats
549
- */
550
- async getThreadChats(slug, threadSlug) {
551
- return this.client.request("GET", `/v1/workspace/${slug}/thread/${threadSlug}/chats`);
552
- }
553
- /**
554
- * Get thread terminal session details.
555
- * @see GET /v1/workspace/{slug}/thread/{threadSlug}/terminal-session-details
556
- */
557
- async getThreadTerminalSessionDetails(slug, threadSlug) {
558
- return this.client.request("GET", `/v1/workspace/${slug}/thread/${threadSlug}/terminal-session-details`);
559
- }
560
- /**
561
- * Update a workspace thread.
562
- * @see POST /v1/workspace/{slug}/thread/{threadSlug}/update
563
- */
564
- async updateThread(slug, threadSlug, body) {
565
- return this.client.request("POST", `/v1/workspace/${slug}/thread/${threadSlug}/update`, body);
566
- }
567
- /**
568
- * Delete edited chats from a thread.
569
- * @see DELETE /v1/workspace/{slug}/thread/{threadSlug}/delete-edited-chats
570
- */
571
- async deleteEditedThreadChats(slug, threadSlug, body) {
572
- return this.client.request("DELETE", `/v1/workspace/${slug}/thread/${threadSlug}/delete-edited-chats`, body);
573
- }
574
- /**
575
- * Update a thread chat response.
576
- * @see POST /v1/workspace/{slug}/thread/{threadSlug}/update-chat
577
- */
578
- async updateThreadChat(slug, threadSlug, body) {
579
- return this.client.request("POST", `/v1/workspace/${slug}/thread/${threadSlug}/update-chat`, body);
580
- }
581
- /**
582
- * Persist terminal UI events for a workspace thread.
583
- * @see POST /v1/workspace/{slug}/thread/{threadSlug}/terminal-ui-events
584
- */
585
- async persistThreadTerminalUiEvents(slug, threadSlug, body) {
586
- return this.client.request("POST", `/v1/workspace/${slug}/thread/${threadSlug}/terminal-ui-events`, body);
587
- }
588
- /**
589
- * Persist a linked terminal message for a workspace thread.
590
- * @see POST /v1/workspace/{slug}/thread/{threadSlug}/linked-terminal-message
591
- */
592
- async createThreadLinkedTerminalMessage(slug, threadSlug, body) {
593
- return this.client.request("POST", `/v1/workspace/${slug}/thread/${threadSlug}/linked-terminal-message`, body);
594
- }
595
- /**
596
- * Coordinate a task into a workspace thread.
597
- * @see POST /v1/workspace/{slug}/thread/coordinate-task
598
- */
599
- async coordinateThreadTask(slug, body) {
600
- return this.client.request("POST", `/v1/workspace/${slug}/thread/coordinate-task`, body);
601
- }
602
- /**
603
- * Open an SSE stream for external workspace thread chat events.
604
- * @see GET /v1/workspace/{slug}/thread/{threadSlug}/chat-stream
605
- */
606
- async openThreadChatStream(slug, threadSlug) {
607
- return this.client.request("GET", `/v1/workspace/${slug}/thread/${threadSlug}/chat-stream`);
608
- }
609
- };
610
-
611
- // src/v1/namespace.ts
612
- var V1ApiNamespace = class {
613
- // [GENERATED-PROPS-END]
614
- constructor(baseUrl, apiKey, appId) {
615
- this._client = new DeveloperApiClient(baseUrl, apiKey, appId);
616
- this.chat = new V1ChatModule(this._client);
617
- this.workspace = new V1WorkspaceModule(this._client);
618
- this.thread = new V1ThreadModule(this._client);
619
- }
620
- };
621
-
622
- // src/cli/client.ts
623
- var CliApiClient = class {
624
- constructor(baseUrl, apiKey, appId) {
625
- this.baseUrl = baseUrl.replace(/\/$/, "");
626
- this.apiKey = apiKey;
627
- this.appId = appId;
628
- }
629
- getHeaders(extra) {
630
- const headers = {
631
- "Content-Type": "application/json",
632
- "Authorization": `Bearer ${this.apiKey}`
633
- };
634
- if (this.appId) headers["x-app-id"] = this.appId;
635
- return { ...headers, ...extra };
636
- }
637
- async handleResponse(response) {
638
- let data;
639
- try {
640
- data = await response.json();
641
- } catch {
642
- data = {};
643
- }
644
- if (response.ok) return data;
645
- const message = data?.message || data?.error || response.statusText || "Request failed";
646
- switch (response.status) {
647
- case 400:
648
- throw new ValidationError(message);
649
- case 401:
650
- case 403:
651
- throw new AuthenticationError(message);
652
- case 404:
653
- throw new NotFoundError(message);
654
- case 500:
655
- case 502:
656
- case 503:
657
- throw new ServerError(message);
658
- default:
659
- throw new DeveloperApiError(response.status, "API_ERROR", message);
660
- }
661
- }
662
- async request(method, path, body) {
663
- const url = `${this.baseUrl}/cli${path}`;
664
- const response = await fetch(url, {
665
- method,
666
- headers: this.getHeaders(),
667
- body: body !== void 0 ? JSON.stringify(body) : void 0
668
- });
669
- return this.handleResponse(response);
670
- }
671
- };
672
-
673
- // src/cli/namespace.ts
674
- var CliApiNamespace = class {
675
- constructor(baseUrl, apiKey, appId) {
676
- this._client = new CliApiClient(baseUrl, apiKey, appId);
677
- }
678
- async prepare() {
679
- return this._client.request("GET", "/prepare");
680
- }
681
- async listWorkspaces() {
682
- return this._client.request("GET", "/list-workspaces");
683
- }
684
- async createWorkspace(body) {
685
- return this._client.request("POST", "/create-workspace", body);
686
- }
687
- async getWorkspace(workspaceSlug) {
688
- return this._client.request("GET", `/get-workspace/${encodeURIComponent(workspaceSlug)}`);
689
- }
690
- async renameWorkspace(workspaceSlug, body) {
691
- return this._client.request("POST", `/rename-workspace/${encodeURIComponent(workspaceSlug)}`, body);
692
- }
693
- async deleteWorkspace(workspaceSlug) {
694
- return this._client.request("DELETE", `/delete-workspace/${encodeURIComponent(workspaceSlug)}`);
695
- }
696
- async setWorkspaceDefaultAgent(workspaceSlug, body) {
697
- return this._client.request("POST", `/set-workspace-default-agent/${encodeURIComponent(workspaceSlug)}`, body);
698
- }
699
- async clearWorkspaceDefaultAgent(workspaceSlug) {
700
- return this._client.request("DELETE", `/clear-workspace-default-agent/${encodeURIComponent(workspaceSlug)}`);
701
- }
702
- async listThreads(workspaceSlug) {
703
- return this._client.request("GET", `/list-threads/${encodeURIComponent(workspaceSlug)}`);
704
- }
705
- async createThread(workspaceSlug, body) {
706
- return this._client.request("POST", `/create-thread/${encodeURIComponent(workspaceSlug)}`, body);
707
- }
708
- async getThread(workspaceSlug, threadSlug) {
709
- return this._client.request(
710
- "GET",
711
- `/get-thread/${encodeURIComponent(workspaceSlug)}/${encodeURIComponent(threadSlug)}`
712
- );
713
- }
714
- async renameThread(workspaceSlug, threadSlug, body) {
715
- return this._client.request(
716
- "POST",
717
- `/rename-thread/${encodeURIComponent(workspaceSlug)}/${encodeURIComponent(threadSlug)}`,
718
- body
719
- );
720
- }
721
- async deleteThread(workspaceSlug, threadSlug) {
722
- return this._client.request(
723
- "DELETE",
724
- `/delete-thread/${encodeURIComponent(workspaceSlug)}/${encodeURIComponent(threadSlug)}`
725
- );
726
- }
727
- async sendLlmMessage(workspaceSlug, threadSlug, body) {
728
- return this._client.request(
729
- "POST",
730
- `/send-llm-message/${encodeURIComponent(workspaceSlug)}/${encodeURIComponent(threadSlug)}`,
731
- body
732
- );
733
- }
734
- async listLlmProviders() {
735
- return this._client.request("GET", "/list-llm-providers");
736
- }
737
- async listLlmModels(provider) {
738
- return this._client.request("GET", `/list-llm-models/${encodeURIComponent(provider)}`);
739
- }
740
- };
741
-
742
- // src/index.ts
743
- var _RealtimeXSDK = class _RealtimeXSDK {
744
- constructor(config = {}) {
745
- const envAppId = this.getEnvVar("RTX_APP_ID");
746
- const envApiKey = this.getEnvVar("RTX_API_KEY");
747
- this.appId = config.realtimex?.appId || envAppId || "";
748
- this.apiKey = config.realtimex?.apiKey || envApiKey;
749
- this.realtimexUrl = config.realtimex?.url || _RealtimeXSDK.DEFAULT_REALTIMEX_URL;
750
- this.v1 = new V1ApiNamespace(
751
- this.realtimexUrl,
752
- this.apiKey ?? "",
753
- this.appId || void 0
754
- );
755
- this.cli = new CliApiNamespace(
756
- this.realtimexUrl,
757
- this.apiKey ?? "",
758
- this.appId || void 0
759
- );
760
- }
761
- getEnvVar(name) {
762
- if (typeof process !== "undefined" && process.env) {
763
- return process.env[name];
764
- }
765
- if (typeof window !== "undefined") {
766
- return window[name];
767
- }
768
- return void 0;
769
- }
770
- };
771
- _RealtimeXSDK.DEFAULT_REALTIMEX_URL = "http://localhost:3001";
772
- var RealtimeXSDK = _RealtimeXSDK;
773
- // Annotate the CommonJS export names for ESM import in node:
774
- 0 && (module.exports = {
775
- AuthenticationError,
776
- CliApiClient,
777
- CliApiNamespace,
778
- DeveloperApiClient,
779
- DeveloperApiError,
780
- NotFoundError,
781
- RealtimeXSDK,
782
- ServerError,
783
- V1ApiNamespace,
784
- ValidationError
785
- });