@realtimex/sdk 2.0.17 → 2.0.18

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