@axiom-lattice/client-sdk 2.1.50 → 2.1.52

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.
@@ -35,27 +35,22 @@ export class AbstractClient {
35
35
  * @returns A promise that resolves to the chat response
36
36
  */
37
37
  send: async (options) => {
38
- try {
39
- // Extract the message from the messages array (assuming the last message is the one to send)
40
- const message = options.messages[options.messages.length - 1];
41
- const { command, threadId, files, assistantId, mode, ...rest } = options;
42
- // Use the run method to send the message
43
- const result = await this.run({
44
- threadId: threadId,
45
- message: typeof message.content === "string"
46
- ? message.content
47
- : JSON.stringify(message.content),
48
- streaming: false,
49
- command: command,
50
- files: files,
51
- mode,
52
- ...rest,
53
- });
54
- return result;
55
- }
56
- catch (error) {
57
- throw error;
58
- }
38
+ // Extract the message from the messages array (assuming the last message is the one to send)
39
+ const message = options.messages[options.messages.length - 1];
40
+ const { command, threadId, files, assistantId, mode, ...rest } = options;
41
+ // Use the run method to send the message
42
+ const result = await this.run({
43
+ threadId: threadId,
44
+ message: typeof message.content === "string"
45
+ ? message.content
46
+ : JSON.stringify(message.content),
47
+ streaming: false,
48
+ command: command,
49
+ files: files,
50
+ mode,
51
+ ...rest,
52
+ });
53
+ return result;
59
54
  },
60
55
  /**
61
56
  * Sends a message to a thread and streams the response
@@ -91,15 +86,10 @@ export class AbstractClient {
91
86
  * @returns Promise with success status
92
87
  */
93
88
  removePendingMessage: async (options) => {
94
- try {
95
- const { assistantId, threadId, messageId } = options;
96
- return await this.makeRequest(`/api/assistants/${assistantId}/threads/${threadId}/pending-messages/${messageId}`, {
97
- method: "DELETE",
98
- });
99
- }
100
- catch (error) {
101
- throw error;
102
- }
89
+ const { assistantId, threadId, messageId } = options;
90
+ return await this.makeRequest(`/api/assistants/${assistantId}/threads/${threadId}/pending-messages/${messageId}`, {
91
+ method: "DELETE",
92
+ });
103
93
  },
104
94
  /**
105
95
  * Abort agent execution for a thread
@@ -107,14 +97,9 @@ export class AbstractClient {
107
97
  * @returns Promise with success status
108
98
  */
109
99
  abort: async (params) => {
110
- try {
111
- return await this.makeRequest(`/api/assistants/${params.assistantId}/threads/${params.threadId}/abort`, {
112
- method: "POST",
113
- });
114
- }
115
- catch (error) {
116
- throw error;
117
- }
100
+ return await this.makeRequest(`/api/assistants/${params.assistantId}/threads/${params.threadId}/abort`, {
101
+ method: "POST",
102
+ });
118
103
  },
119
104
  };
120
105
  /**
@@ -149,13 +134,8 @@ export class AbstractClient {
149
134
  * @returns A promise that resolves to the list of assistants
150
135
  */
151
136
  list: async () => {
152
- try {
153
- const response = await this.makeRequest("/api/assistants");
154
- return response.data.records;
155
- }
156
- catch (error) {
157
- throw error;
158
- }
137
+ const response = await this.makeRequest("/api/assistants");
138
+ return response.data.records;
159
139
  },
160
140
  /**
161
141
  * Retrieves a single assistant by ID
@@ -164,16 +144,11 @@ export class AbstractClient {
164
144
  * @returns A promise that resolves to the assistant information
165
145
  */
166
146
  get: async (id) => {
167
- try {
168
- const response = await this.makeRequest(`/api/assistants/${id}`);
169
- if (!response.data) {
170
- throw new ApiError("Assistant not found", 404);
171
- }
172
- return response.data;
173
- }
174
- catch (error) {
175
- throw error;
147
+ const response = await this.makeRequest(`/api/assistants/${id}`);
148
+ if (!response.data) {
149
+ throw new ApiError("Assistant not found", 404);
176
150
  }
151
+ return response.data;
177
152
  },
178
153
  /**
179
154
  * Creates a new assistant
@@ -182,19 +157,14 @@ export class AbstractClient {
182
157
  * @returns A promise that resolves to the created assistant
183
158
  */
184
159
  create: async (options) => {
185
- try {
186
- const response = await this.makeRequest("/api/assistants", {
187
- method: "POST",
188
- body: options,
189
- });
190
- if (!response.data) {
191
- throw new ApiError("Failed to create assistant", 500);
192
- }
193
- return response.data;
194
- }
195
- catch (error) {
196
- throw error;
160
+ const response = await this.makeRequest("/api/assistants", {
161
+ method: "POST",
162
+ body: options,
163
+ });
164
+ if (!response.data) {
165
+ throw new ApiError("Failed to create assistant", 500);
197
166
  }
167
+ return response.data;
198
168
  },
199
169
  /**
200
170
  * Updates an existing assistant by ID
@@ -204,19 +174,14 @@ export class AbstractClient {
204
174
  * @returns A promise that resolves to the updated assistant
205
175
  */
206
176
  update: async (id, options) => {
207
- try {
208
- const response = await this.makeRequest(`/api/assistants/${id}`, {
209
- method: "PUT",
210
- body: options,
211
- });
212
- if (!response.data) {
213
- throw new ApiError("Failed to update assistant", 500);
214
- }
215
- return response.data;
216
- }
217
- catch (error) {
218
- throw error;
177
+ const response = await this.makeRequest(`/api/assistants/${id}`, {
178
+ method: "PUT",
179
+ body: options,
180
+ });
181
+ if (!response.data) {
182
+ throw new ApiError("Failed to update assistant", 500);
219
183
  }
184
+ return response.data;
220
185
  },
221
186
  /**
222
187
  * Deletes an assistant by ID
@@ -225,14 +190,9 @@ export class AbstractClient {
225
190
  * @returns A promise that resolves when the assistant is deleted
226
191
  */
227
192
  delete: async (id) => {
228
- try {
229
- await this.makeRequest(`/api/assistants/${id}`, {
230
- method: "DELETE",
231
- });
232
- }
233
- catch (error) {
234
- throw error;
235
- }
193
+ await this.makeRequest(`/api/assistants/${id}`, {
194
+ method: "DELETE",
195
+ });
236
196
  },
237
197
  };
238
198
  /**
@@ -244,13 +204,8 @@ export class AbstractClient {
244
204
  * @returns A promise that resolves to the list of skills
245
205
  */
246
206
  list: async () => {
247
- try {
248
- const response = await this.makeRequest("/api/skills");
249
- return response.data.records;
250
- }
251
- catch (error) {
252
- throw error;
253
- }
207
+ const response = await this.makeRequest("/api/skills");
208
+ return response.data.records;
254
209
  },
255
210
  /**
256
211
  * Retrieves a single skill by ID
@@ -258,16 +213,11 @@ export class AbstractClient {
258
213
  * @returns A promise that resolves to the skill information
259
214
  */
260
215
  get: async (id) => {
261
- try {
262
- const response = await this.makeRequest(`/api/skills/${id}`);
263
- if (!response.data) {
264
- throw new ApiError("Skill not found", 404);
265
- }
266
- return response.data;
267
- }
268
- catch (error) {
269
- throw error;
216
+ const response = await this.makeRequest(`/api/skills/${id}`);
217
+ if (!response.data) {
218
+ throw new ApiError("Skill not found", 404);
270
219
  }
220
+ return response.data;
271
221
  },
272
222
  /**
273
223
  * Creates a new skill
@@ -275,19 +225,14 @@ export class AbstractClient {
275
225
  * @returns A promise that resolves to the created skill
276
226
  */
277
227
  create: async (options) => {
278
- try {
279
- const response = await this.makeRequest("/api/skills", {
280
- method: "POST",
281
- body: options,
282
- });
283
- if (!response.data) {
284
- throw new ApiError("Failed to create skill", 500);
285
- }
286
- return response.data;
287
- }
288
- catch (error) {
289
- throw error;
228
+ const response = await this.makeRequest("/api/skills", {
229
+ method: "POST",
230
+ body: options,
231
+ });
232
+ if (!response.data) {
233
+ throw new ApiError("Failed to create skill", 500);
290
234
  }
235
+ return response.data;
291
236
  },
292
237
  /**
293
238
  * Updates an existing skill by ID
@@ -296,19 +241,14 @@ export class AbstractClient {
296
241
  * @returns A promise that resolves to the updated skill
297
242
  */
298
243
  update: async (id, options) => {
299
- try {
300
- const response = await this.makeRequest(`/api/skills/${id}`, {
301
- method: "PUT",
302
- body: options,
303
- });
304
- if (!response.data) {
305
- throw new ApiError("Failed to update skill", 500);
306
- }
307
- return response.data;
308
- }
309
- catch (error) {
310
- throw error;
244
+ const response = await this.makeRequest(`/api/skills/${id}`, {
245
+ method: "PUT",
246
+ body: options,
247
+ });
248
+ if (!response.data) {
249
+ throw new ApiError("Failed to update skill", 500);
311
250
  }
251
+ return response.data;
312
252
  },
313
253
  /**
314
254
  * Deletes a skill by ID
@@ -316,14 +256,9 @@ export class AbstractClient {
316
256
  * @returns A promise that resolves when the skill is deleted
317
257
  */
318
258
  delete: async (id) => {
319
- try {
320
- await this.makeRequest(`/api/skills/${id}`, {
321
- method: "DELETE",
322
- });
323
- }
324
- catch (error) {
325
- throw error;
326
- }
259
+ await this.makeRequest(`/api/skills/${id}`, {
260
+ method: "DELETE",
261
+ });
327
262
  },
328
263
  };
329
264
  /**
@@ -335,13 +270,8 @@ export class AbstractClient {
335
270
  * @returns A promise that resolves to the list of threads
336
271
  */
337
272
  list: async () => {
338
- try {
339
- const response = await this.makeRequest(`/api/assistants/${this.assistantId}/threads`);
340
- return response.data.records;
341
- }
342
- catch (error) {
343
- throw error;
344
- }
273
+ const response = await this.makeRequest(`/api/assistants/${this.assistantId}/threads`);
274
+ return response.data.records;
345
275
  },
346
276
  /**
347
277
  * Retrieves a single thread by ID for the current assistant
@@ -349,16 +279,11 @@ export class AbstractClient {
349
279
  * @returns A promise that resolves to the thread information
350
280
  */
351
281
  get: async (threadId) => {
352
- try {
353
- const response = await this.makeRequest(`/api/assistants/${this.assistantId}/threads/${threadId}`);
354
- if (!response.data) {
355
- throw new ApiError("Thread not found", 404);
356
- }
357
- return response.data;
358
- }
359
- catch (error) {
360
- throw error;
282
+ const response = await this.makeRequest(`/api/assistants/${this.assistantId}/threads/${threadId}`);
283
+ if (!response.data) {
284
+ throw new ApiError("Thread not found", 404);
361
285
  }
286
+ return response.data;
362
287
  },
363
288
  /**
364
289
  * Creates a new thread for the current assistant
@@ -366,19 +291,14 @@ export class AbstractClient {
366
291
  * @returns A promise that resolves to the created thread
367
292
  */
368
293
  create: async (options) => {
369
- try {
370
- const response = await this.makeRequest(`/api/assistants/${this.assistantId}/threads`, {
371
- method: "POST",
372
- body: options,
373
- });
374
- if (!response.data) {
375
- throw new ApiError("Failed to create thread", 500);
376
- }
377
- return response.data;
378
- }
379
- catch (error) {
380
- throw error;
294
+ const response = await this.makeRequest(`/api/assistants/${this.assistantId}/threads`, {
295
+ method: "POST",
296
+ body: options,
297
+ });
298
+ if (!response.data) {
299
+ throw new ApiError("Failed to create thread", 500);
381
300
  }
301
+ return response.data;
382
302
  },
383
303
  /**
384
304
  * Updates an existing thread by ID for the current assistant
@@ -387,19 +307,14 @@ export class AbstractClient {
387
307
  * @returns A promise that resolves to the updated thread
388
308
  */
389
309
  update: async (threadId, options) => {
390
- try {
391
- const response = await this.makeRequest(`/api/assistants/${this.assistantId}/threads/${threadId}`, {
392
- method: "PUT",
393
- body: options,
394
- });
395
- if (!response.data) {
396
- throw new ApiError("Failed to update thread", 500);
397
- }
398
- return response.data;
399
- }
400
- catch (error) {
401
- throw error;
310
+ const response = await this.makeRequest(`/api/assistants/${this.assistantId}/threads/${threadId}`, {
311
+ method: "PUT",
312
+ body: options,
313
+ });
314
+ if (!response.data) {
315
+ throw new ApiError("Failed to update thread", 500);
402
316
  }
317
+ return response.data;
403
318
  },
404
319
  /**
405
320
  * Deletes a thread by ID for the current assistant
@@ -407,14 +322,9 @@ export class AbstractClient {
407
322
  * @returns A promise that resolves when the thread is deleted
408
323
  */
409
324
  delete: async (threadId) => {
410
- try {
411
- await this.makeRequest(`/api/assistants/${this.assistantId}/threads/${threadId}`, {
412
- method: "DELETE",
413
- });
414
- }
415
- catch (error) {
416
- throw error;
417
- }
325
+ await this.makeRequest(`/api/assistants/${this.assistantId}/threads/${threadId}`, {
326
+ method: "DELETE",
327
+ });
418
328
  },
419
329
  };
420
330
  /**
@@ -427,28 +337,23 @@ export class AbstractClient {
427
337
  * @returns A promise that resolves to the list of scheduled tasks
428
338
  */
429
339
  getByThread: async (options) => {
430
- try {
431
- let url = `/api/assistants/${this.assistantId}/threads/${options.threadId}/schedules`;
432
- const params = new URLSearchParams();
433
- if (options.status) {
434
- params.append("status", options.status);
435
- }
436
- if (options.limit !== undefined) {
437
- params.append("limit", options.limit.toString());
438
- }
439
- if (options.offset !== undefined) {
440
- params.append("offset", options.offset.toString());
441
- }
442
- const queryString = params.toString();
443
- if (queryString) {
444
- url += `?${queryString}`;
445
- }
446
- const response = await this.makeRequest(url);
447
- return response.data.records;
340
+ let url = `/api/assistants/${this.assistantId}/threads/${options.threadId}/schedules`;
341
+ const params = new URLSearchParams();
342
+ if (options.status) {
343
+ params.append("status", options.status);
344
+ }
345
+ if (options.limit !== undefined) {
346
+ params.append("limit", options.limit.toString());
347
+ }
348
+ if (options.offset !== undefined) {
349
+ params.append("offset", options.offset.toString());
448
350
  }
449
- catch (error) {
450
- throw error;
351
+ const queryString = params.toString();
352
+ if (queryString) {
353
+ url += `?${queryString}`;
451
354
  }
355
+ const response = await this.makeRequest(url);
356
+ return response.data.records;
452
357
  },
453
358
  /**
454
359
  * Gets a single scheduled task by ID
@@ -456,13 +361,8 @@ export class AbstractClient {
456
361
  * @returns A promise that resolves to the scheduled task or null
457
362
  */
458
363
  get: async (taskId) => {
459
- try {
460
- const response = await this.makeRequest(`/api/schedules/${taskId}`);
461
- return response.data;
462
- }
463
- catch (error) {
464
- throw error;
465
- }
364
+ const response = await this.makeRequest(`/api/schedules/${taskId}`);
365
+ return response.data;
466
366
  },
467
367
  /**
468
368
  * Cancels a scheduled task
@@ -470,15 +370,10 @@ export class AbstractClient {
470
370
  * @returns A promise that resolves when the task is cancelled
471
371
  */
472
372
  cancel: async (taskId) => {
473
- try {
474
- const response = await this.makeRequest(`/api/schedules/${taskId}/cancel`, {
475
- method: "POST",
476
- });
477
- return response.success;
478
- }
479
- catch (error) {
480
- throw error;
481
- }
373
+ const response = await this.makeRequest(`/api/schedules/${taskId}/cancel`, {
374
+ method: "POST",
375
+ });
376
+ return response.success;
482
377
  },
483
378
  /**
484
379
  * Pauses a scheduled cron task
@@ -486,15 +381,10 @@ export class AbstractClient {
486
381
  * @returns A promise that resolves when the task is paused
487
382
  */
488
383
  pause: async (taskId) => {
489
- try {
490
- const response = await this.makeRequest(`/api/schedules/${taskId}/pause`, {
491
- method: "POST",
492
- });
493
- return response.success;
494
- }
495
- catch (error) {
496
- throw error;
497
- }
384
+ const response = await this.makeRequest(`/api/schedules/${taskId}/pause`, {
385
+ method: "POST",
386
+ });
387
+ return response.success;
498
388
  },
499
389
  /**
500
390
  * Resumes a paused cron task
@@ -502,15 +392,10 @@ export class AbstractClient {
502
392
  * @returns A promise that resolves when the task is resumed
503
393
  */
504
394
  resume: async (taskId) => {
505
- try {
506
- const response = await this.makeRequest(`/api/schedules/${taskId}/resume`, {
507
- method: "POST",
508
- });
509
- return response.success;
510
- }
511
- catch (error) {
512
- throw error;
513
- }
395
+ const response = await this.makeRequest(`/api/schedules/${taskId}/resume`, {
396
+ method: "POST",
397
+ });
398
+ return response.success;
514
399
  },
515
400
  };
516
401
  this.config = {
@@ -639,6 +524,68 @@ export class AbstractClient {
639
524
  return await this.makeRequest(`/api/mcp-servers/${id}/test`, { method: "POST" });
640
525
  },
641
526
  };
527
+ this.tasks = {
528
+ list: async (params) => {
529
+ const qs = params ? `?${new URLSearchParams(params).toString()}` : '';
530
+ const response = await this.makeRequest(`/api/tasks${qs}`);
531
+ return response.data || [];
532
+ },
533
+ get: async (id) => {
534
+ const response = await this.makeRequest(`/api/tasks/${id}`);
535
+ if (!response.data)
536
+ throw new ApiError("Task not found", 404);
537
+ return response.data;
538
+ },
539
+ create: async (data) => {
540
+ const response = await this.makeRequest("/api/tasks", { method: "POST", body: data });
541
+ if (!response.data)
542
+ throw new ApiError("Failed to create task", 500);
543
+ return response.data;
544
+ },
545
+ update: async (id, data) => {
546
+ const response = await this.makeRequest(`/api/tasks/${id}`, { method: "PUT", body: data });
547
+ if (!response.data)
548
+ throw new ApiError("Failed to update task", 500);
549
+ return response.data;
550
+ },
551
+ delete: async (id) => {
552
+ await this.makeRequest(`/api/tasks/${id}`, { method: "DELETE" });
553
+ },
554
+ complete: async (id) => {
555
+ const response = await this.makeRequest(`/api/tasks/${id}/complete`, { method: "PATCH" });
556
+ if (!response.data)
557
+ throw new ApiError("Failed to complete task", 500);
558
+ return response.data;
559
+ },
560
+ };
561
+ this.menu = {
562
+ list: async (menuTarget) => {
563
+ const qs = menuTarget ? `?menuTarget=${menuTarget}` : '';
564
+ const response = await this.makeRequest(`/api/menu-items${qs}`);
565
+ return response.data?.records || [];
566
+ },
567
+ get: async (id) => {
568
+ const response = await this.makeRequest(`/api/menu-items/${id}`);
569
+ if (!response.data)
570
+ throw new Error("Menu item not found");
571
+ return response.data;
572
+ },
573
+ create: async (data) => {
574
+ const response = await this.makeRequest("/api/menu-items", { method: "POST", body: data });
575
+ if (!response.data)
576
+ throw new Error("Failed to create menu item");
577
+ return response.data;
578
+ },
579
+ update: async (id, data) => {
580
+ const response = await this.makeRequest(`/api/menu-items/${id}`, { method: "PUT", body: data });
581
+ if (!response.data)
582
+ throw new Error("Failed to update menu item");
583
+ return response.data;
584
+ },
585
+ delete: async (id) => {
586
+ await this.makeRequest(`/api/menu-items/${id}`, { method: "DELETE" });
587
+ },
588
+ };
642
589
  }
643
590
  /**
644
591
  * Make a generic API request
@@ -716,19 +663,14 @@ export class AbstractClient {
716
663
  * @returns A promise that resolves to the thread ID
717
664
  */
718
665
  async createThread(options) {
719
- try {
720
- const response = await this.makeRequest(`/api/assistants/${this.assistantId}/threads`, {
721
- method: "POST",
722
- body: options,
723
- });
724
- if (!response.data) {
725
- throw new ApiError("Failed to create thread", 500);
726
- }
727
- return response.data.id;
728
- }
729
- catch (error) {
730
- throw error;
666
+ const response = await this.makeRequest(`/api/assistants/${this.assistantId}/threads`, {
667
+ method: "POST",
668
+ body: options,
669
+ });
670
+ if (!response.data) {
671
+ throw new ApiError("Failed to create thread", 500);
731
672
  }
673
+ return response.data.id;
732
674
  }
733
675
  /**
734
676
  * Retrieves thread information
@@ -737,16 +679,11 @@ export class AbstractClient {
737
679
  * @returns A promise that resolves to the thread information
738
680
  */
739
681
  async getThread(threadId) {
740
- try {
741
- const response = await this.makeRequest(`/api/assistants/${this.assistantId}/threads/${threadId}`);
742
- if (!response.data) {
743
- throw new ApiError("Thread not found", 404);
744
- }
745
- return response.data;
746
- }
747
- catch (error) {
748
- throw error;
682
+ const response = await this.makeRequest(`/api/assistants/${this.assistantId}/threads/${threadId}`);
683
+ if (!response.data) {
684
+ throw new ApiError("Thread not found", 404);
749
685
  }
686
+ return response.data;
750
687
  }
751
688
  /**
752
689
  * Lists all threads
@@ -755,13 +692,8 @@ export class AbstractClient {
755
692
  * @returns A promise that resolves to an array of threads
756
693
  */
757
694
  async listThreads(options) {
758
- try {
759
- const response = await this.makeRequest(`/api/assistants/${this.assistantId}/threads`);
760
- return response.data.records;
761
- }
762
- catch (error) {
763
- throw error;
764
- }
695
+ const response = await this.makeRequest(`/api/assistants/${this.assistantId}/threads`);
696
+ return response.data.records;
765
697
  }
766
698
  /**
767
699
  * Deletes a thread
@@ -770,12 +702,7 @@ export class AbstractClient {
770
702
  * @returns A promise that resolves when the thread is deleted
771
703
  */
772
704
  async deleteThread(threadId) {
773
- try {
774
- await this.makeRequest(`/api/assistants/${this.assistantId}/threads/${threadId}`, { method: "DELETE" });
775
- }
776
- catch (error) {
777
- throw error;
778
- }
705
+ await this.makeRequest(`/api/assistants/${this.assistantId}/threads/${threadId}`, { method: "DELETE" });
779
706
  }
780
707
  /**
781
708
  * Retrieves messages from a thread
@@ -783,29 +710,24 @@ export class AbstractClient {
783
710
  * @returns A promise that resolves to an array of messages
784
711
  */
785
712
  async getMessages(options) {
786
- try {
787
- let url = `/api/assistants/${this.assistantId}/${options.threadId}/memory`;
788
- if (options.limit) {
789
- url += `?limit=${options.limit}`;
790
- }
791
- if (options.after) {
792
- url += url.includes("?")
793
- ? `&after=${options.after}`
794
- : `?after=${options.after}`;
795
- }
796
- if (options.reverse !== undefined) {
797
- url += url.includes("?")
798
- ? `&reverse=${options.reverse}`
799
- : `?reverse=${options.reverse}`;
800
- }
713
+ let url = `/api/assistants/${this.assistantId}/${options.threadId}/memory`;
714
+ if (options.limit) {
715
+ url += `?limit=${options.limit}`;
716
+ }
717
+ if (options.after) {
801
718
  url += url.includes("?")
802
- ? `&assistantId=${this.assistantId}`
803
- : `?assistantId=${this.assistantId}`;
804
- return await this.makeRequest(url);
719
+ ? `&after=${options.after}`
720
+ : `?after=${options.after}`;
805
721
  }
806
- catch (error) {
807
- throw error;
722
+ if (options.reverse !== undefined) {
723
+ url += url.includes("?")
724
+ ? `&reverse=${options.reverse}`
725
+ : `?reverse=${options.reverse}`;
808
726
  }
727
+ url += url.includes("?")
728
+ ? `&assistantId=${this.assistantId}`
729
+ : `?assistantId=${this.assistantId}`;
730
+ return await this.makeRequest(url);
809
731
  }
810
732
  /**
811
733
  * Retrieves agent state
@@ -813,25 +735,15 @@ export class AbstractClient {
813
735
  * @returns A promise that resolves to the agent state
814
736
  */
815
737
  async getAgentState(threadId) {
816
- try {
817
- return await this.makeRequest(`/api/assistants/${this.assistantId}/${threadId}/state`);
818
- }
819
- catch (error) {
820
- throw error;
821
- }
738
+ return await this.makeRequest(`/api/assistants/${this.assistantId}/${threadId}/state`);
822
739
  }
823
740
  /**
824
741
  * Gets agent graph visualization
825
742
  * @returns A promise that resolves to the graph visualization data
826
743
  */
827
744
  async getAgentGraph() {
828
- try {
829
- const data = await this.makeRequest(`/api/assistants/${this.assistantId}/graph`);
830
- return data.image;
831
- }
832
- catch (error) {
833
- throw error;
834
- }
745
+ const data = await this.makeRequest(`/api/assistants/${this.assistantId}/graph`);
746
+ return data.image;
835
747
  }
836
748
  /**
837
749
  * Run agent with options
@@ -839,30 +751,25 @@ export class AbstractClient {
839
751
  * @returns A promise that resolves to the run result
840
752
  */
841
753
  async run(options) {
842
- try {
843
- const { command, threadId, assistantId, message, files, background, custom_run_config, ...rest } = options;
844
- if (options.streaming) {
845
- throw new Error("Streaming without callbacks is not supported. Use chat.stream with callbacks instead.");
846
- }
847
- else {
848
- return await this.makeRequest("/api/runs", {
849
- method: "POST",
850
- body: {
851
- assistant_id: assistantId || this.assistantId,
852
- thread_id: threadId,
853
- message: message,
854
- files: files,
855
- command: command,
856
- streaming: false,
857
- background: background || false,
858
- custom_run_config,
859
- ...rest,
860
- },
861
- });
862
- }
754
+ const { command, threadId, assistantId, message, files, background, custom_run_config, ...rest } = options;
755
+ if (options.streaming) {
756
+ throw new Error("Streaming without callbacks is not supported. Use chat.stream with callbacks instead.");
863
757
  }
864
- catch (error) {
865
- throw error;
758
+ else {
759
+ return await this.makeRequest("/api/runs", {
760
+ method: "POST",
761
+ body: {
762
+ assistant_id: assistantId || this.assistantId,
763
+ thread_id: threadId,
764
+ message: message,
765
+ files: files,
766
+ command: command,
767
+ streaming: false,
768
+ background: background || false,
769
+ custom_run_config,
770
+ ...rest,
771
+ },
772
+ });
866
773
  }
867
774
  }
868
775
  }