@axiom-lattice/client-sdk 2.1.49 → 2.1.51

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.mjs CHANGED
@@ -1874,22 +1874,18 @@ var AbstractClient = class {
1874
1874
  * @returns A promise that resolves to the chat response
1875
1875
  */
1876
1876
  send: async (options) => {
1877
- try {
1878
- const message = options.messages[options.messages.length - 1];
1879
- const { command, threadId, files, assistantId, mode, ...rest } = options;
1880
- const result = await this.run({
1881
- threadId,
1882
- message: typeof message.content === "string" ? message.content : JSON.stringify(message.content),
1883
- streaming: false,
1884
- command,
1885
- files,
1886
- mode,
1887
- ...rest
1888
- });
1889
- return result;
1890
- } catch (error) {
1891
- throw error;
1892
- }
1877
+ const message = options.messages[options.messages.length - 1];
1878
+ const { command, threadId, files, assistantId, mode, ...rest } = options;
1879
+ const result = await this.run({
1880
+ threadId,
1881
+ message: typeof message.content === "string" ? message.content : JSON.stringify(message.content),
1882
+ streaming: false,
1883
+ command,
1884
+ files,
1885
+ mode,
1886
+ ...rest
1887
+ });
1888
+ return result;
1893
1889
  },
1894
1890
  /**
1895
1891
  * Sends a message to a thread and streams the response
@@ -1935,17 +1931,13 @@ var AbstractClient = class {
1935
1931
  * @returns Promise with success status
1936
1932
  */
1937
1933
  removePendingMessage: async (options) => {
1938
- try {
1939
- const { assistantId, threadId, messageId } = options;
1940
- return await this.makeRequest(
1941
- `/api/assistants/${assistantId}/threads/${threadId}/pending-messages/${messageId}`,
1942
- {
1943
- method: "DELETE"
1944
- }
1945
- );
1946
- } catch (error) {
1947
- throw error;
1948
- }
1934
+ const { assistantId, threadId, messageId } = options;
1935
+ return await this.makeRequest(
1936
+ `/api/assistants/${assistantId}/threads/${threadId}/pending-messages/${messageId}`,
1937
+ {
1938
+ method: "DELETE"
1939
+ }
1940
+ );
1949
1941
  },
1950
1942
  /**
1951
1943
  * Abort agent execution for a thread
@@ -1953,16 +1945,12 @@ var AbstractClient = class {
1953
1945
  * @returns Promise with success status
1954
1946
  */
1955
1947
  abort: async (params) => {
1956
- try {
1957
- return await this.makeRequest(
1958
- `/api/assistants/${params.assistantId}/threads/${params.threadId}/abort`,
1959
- {
1960
- method: "POST"
1961
- }
1962
- );
1963
- } catch (error) {
1964
- throw error;
1965
- }
1948
+ return await this.makeRequest(
1949
+ `/api/assistants/${params.assistantId}/threads/${params.threadId}/abort`,
1950
+ {
1951
+ method: "POST"
1952
+ }
1953
+ );
1966
1954
  }
1967
1955
  };
1968
1956
  /**
@@ -1999,14 +1987,10 @@ var AbstractClient = class {
1999
1987
  * @returns A promise that resolves to the list of assistants
2000
1988
  */
2001
1989
  list: async () => {
2002
- try {
2003
- const response = await this.makeRequest(
2004
- "/api/assistants"
2005
- );
2006
- return response.data.records;
2007
- } catch (error) {
2008
- throw error;
2009
- }
1990
+ const response = await this.makeRequest(
1991
+ "/api/assistants"
1992
+ );
1993
+ return response.data.records;
2010
1994
  },
2011
1995
  /**
2012
1996
  * Retrieves a single assistant by ID
@@ -2015,17 +1999,13 @@ var AbstractClient = class {
2015
1999
  * @returns A promise that resolves to the assistant information
2016
2000
  */
2017
2001
  get: async (id) => {
2018
- try {
2019
- const response = await this.makeRequest(
2020
- `/api/assistants/${id}`
2021
- );
2022
- if (!response.data) {
2023
- throw new ApiError("Assistant not found", 404);
2024
- }
2025
- return response.data;
2026
- } catch (error) {
2027
- throw error;
2002
+ const response = await this.makeRequest(
2003
+ `/api/assistants/${id}`
2004
+ );
2005
+ if (!response.data) {
2006
+ throw new ApiError("Assistant not found", 404);
2028
2007
  }
2008
+ return response.data;
2029
2009
  },
2030
2010
  /**
2031
2011
  * Creates a new assistant
@@ -2034,21 +2014,17 @@ var AbstractClient = class {
2034
2014
  * @returns A promise that resolves to the created assistant
2035
2015
  */
2036
2016
  create: async (options) => {
2037
- try {
2038
- const response = await this.makeRequest(
2039
- "/api/assistants",
2040
- {
2041
- method: "POST",
2042
- body: options
2043
- }
2044
- );
2045
- if (!response.data) {
2046
- throw new ApiError("Failed to create assistant", 500);
2017
+ const response = await this.makeRequest(
2018
+ "/api/assistants",
2019
+ {
2020
+ method: "POST",
2021
+ body: options
2047
2022
  }
2048
- return response.data;
2049
- } catch (error) {
2050
- throw error;
2023
+ );
2024
+ if (!response.data) {
2025
+ throw new ApiError("Failed to create assistant", 500);
2051
2026
  }
2027
+ return response.data;
2052
2028
  },
2053
2029
  /**
2054
2030
  * Updates an existing assistant by ID
@@ -2058,21 +2034,17 @@ var AbstractClient = class {
2058
2034
  * @returns A promise that resolves to the updated assistant
2059
2035
  */
2060
2036
  update: async (id, options) => {
2061
- try {
2062
- const response = await this.makeRequest(
2063
- `/api/assistants/${id}`,
2064
- {
2065
- method: "PUT",
2066
- body: options
2067
- }
2068
- );
2069
- if (!response.data) {
2070
- throw new ApiError("Failed to update assistant", 500);
2037
+ const response = await this.makeRequest(
2038
+ `/api/assistants/${id}`,
2039
+ {
2040
+ method: "PUT",
2041
+ body: options
2071
2042
  }
2072
- return response.data;
2073
- } catch (error) {
2074
- throw error;
2043
+ );
2044
+ if (!response.data) {
2045
+ throw new ApiError("Failed to update assistant", 500);
2075
2046
  }
2047
+ return response.data;
2076
2048
  },
2077
2049
  /**
2078
2050
  * Deletes an assistant by ID
@@ -2081,16 +2053,12 @@ var AbstractClient = class {
2081
2053
  * @returns A promise that resolves when the assistant is deleted
2082
2054
  */
2083
2055
  delete: async (id) => {
2084
- try {
2085
- await this.makeRequest(
2086
- `/api/assistants/${id}`,
2087
- {
2088
- method: "DELETE"
2089
- }
2090
- );
2091
- } catch (error) {
2092
- throw error;
2093
- }
2056
+ await this.makeRequest(
2057
+ `/api/assistants/${id}`,
2058
+ {
2059
+ method: "DELETE"
2060
+ }
2061
+ );
2094
2062
  }
2095
2063
  };
2096
2064
  /**
@@ -2102,12 +2070,8 @@ var AbstractClient = class {
2102
2070
  * @returns A promise that resolves to the list of skills
2103
2071
  */
2104
2072
  list: async () => {
2105
- try {
2106
- const response = await this.makeRequest("/api/skills");
2107
- return response.data.records;
2108
- } catch (error) {
2109
- throw error;
2110
- }
2073
+ const response = await this.makeRequest("/api/skills");
2074
+ return response.data.records;
2111
2075
  },
2112
2076
  /**
2113
2077
  * Retrieves a single skill by ID
@@ -2115,15 +2079,11 @@ var AbstractClient = class {
2115
2079
  * @returns A promise that resolves to the skill information
2116
2080
  */
2117
2081
  get: async (id) => {
2118
- try {
2119
- const response = await this.makeRequest(`/api/skills/${id}`);
2120
- if (!response.data) {
2121
- throw new ApiError("Skill not found", 404);
2122
- }
2123
- return response.data;
2124
- } catch (error) {
2125
- throw error;
2082
+ const response = await this.makeRequest(`/api/skills/${id}`);
2083
+ if (!response.data) {
2084
+ throw new ApiError("Skill not found", 404);
2126
2085
  }
2086
+ return response.data;
2127
2087
  },
2128
2088
  /**
2129
2089
  * Creates a new skill
@@ -2131,18 +2091,14 @@ var AbstractClient = class {
2131
2091
  * @returns A promise that resolves to the created skill
2132
2092
  */
2133
2093
  create: async (options) => {
2134
- try {
2135
- const response = await this.makeRequest("/api/skills", {
2136
- method: "POST",
2137
- body: options
2138
- });
2139
- if (!response.data) {
2140
- throw new ApiError("Failed to create skill", 500);
2141
- }
2142
- return response.data;
2143
- } catch (error) {
2144
- throw error;
2094
+ const response = await this.makeRequest("/api/skills", {
2095
+ method: "POST",
2096
+ body: options
2097
+ });
2098
+ if (!response.data) {
2099
+ throw new ApiError("Failed to create skill", 500);
2145
2100
  }
2101
+ return response.data;
2146
2102
  },
2147
2103
  /**
2148
2104
  * Updates an existing skill by ID
@@ -2151,18 +2107,14 @@ var AbstractClient = class {
2151
2107
  * @returns A promise that resolves to the updated skill
2152
2108
  */
2153
2109
  update: async (id, options) => {
2154
- try {
2155
- const response = await this.makeRequest(`/api/skills/${id}`, {
2156
- method: "PUT",
2157
- body: options
2158
- });
2159
- if (!response.data) {
2160
- throw new ApiError("Failed to update skill", 500);
2161
- }
2162
- return response.data;
2163
- } catch (error) {
2164
- throw error;
2110
+ const response = await this.makeRequest(`/api/skills/${id}`, {
2111
+ method: "PUT",
2112
+ body: options
2113
+ });
2114
+ if (!response.data) {
2115
+ throw new ApiError("Failed to update skill", 500);
2165
2116
  }
2117
+ return response.data;
2166
2118
  },
2167
2119
  /**
2168
2120
  * Deletes a skill by ID
@@ -2170,16 +2122,12 @@ var AbstractClient = class {
2170
2122
  * @returns A promise that resolves when the skill is deleted
2171
2123
  */
2172
2124
  delete: async (id) => {
2173
- try {
2174
- await this.makeRequest(
2175
- `/api/skills/${id}`,
2176
- {
2177
- method: "DELETE"
2178
- }
2179
- );
2180
- } catch (error) {
2181
- throw error;
2182
- }
2125
+ await this.makeRequest(
2126
+ `/api/skills/${id}`,
2127
+ {
2128
+ method: "DELETE"
2129
+ }
2130
+ );
2183
2131
  }
2184
2132
  };
2185
2133
  /**
@@ -2191,14 +2139,10 @@ var AbstractClient = class {
2191
2139
  * @returns A promise that resolves to the list of threads
2192
2140
  */
2193
2141
  list: async () => {
2194
- try {
2195
- const response = await this.makeRequest(
2196
- `/api/assistants/${this.assistantId}/threads`
2197
- );
2198
- return response.data.records;
2199
- } catch (error) {
2200
- throw error;
2201
- }
2142
+ const response = await this.makeRequest(
2143
+ `/api/assistants/${this.assistantId}/threads`
2144
+ );
2145
+ return response.data.records;
2202
2146
  },
2203
2147
  /**
2204
2148
  * Retrieves a single thread by ID for the current assistant
@@ -2206,17 +2150,13 @@ var AbstractClient = class {
2206
2150
  * @returns A promise that resolves to the thread information
2207
2151
  */
2208
2152
  get: async (threadId) => {
2209
- try {
2210
- const response = await this.makeRequest(
2211
- `/api/assistants/${this.assistantId}/threads/${threadId}`
2212
- );
2213
- if (!response.data) {
2214
- throw new ApiError("Thread not found", 404);
2215
- }
2216
- return response.data;
2217
- } catch (error) {
2218
- throw error;
2153
+ const response = await this.makeRequest(
2154
+ `/api/assistants/${this.assistantId}/threads/${threadId}`
2155
+ );
2156
+ if (!response.data) {
2157
+ throw new ApiError("Thread not found", 404);
2219
2158
  }
2159
+ return response.data;
2220
2160
  },
2221
2161
  /**
2222
2162
  * Creates a new thread for the current assistant
@@ -2224,21 +2164,17 @@ var AbstractClient = class {
2224
2164
  * @returns A promise that resolves to the created thread
2225
2165
  */
2226
2166
  create: async (options) => {
2227
- try {
2228
- const response = await this.makeRequest(
2229
- `/api/assistants/${this.assistantId}/threads`,
2230
- {
2231
- method: "POST",
2232
- body: options
2233
- }
2234
- );
2235
- if (!response.data) {
2236
- throw new ApiError("Failed to create thread", 500);
2167
+ const response = await this.makeRequest(
2168
+ `/api/assistants/${this.assistantId}/threads`,
2169
+ {
2170
+ method: "POST",
2171
+ body: options
2237
2172
  }
2238
- return response.data;
2239
- } catch (error) {
2240
- throw error;
2173
+ );
2174
+ if (!response.data) {
2175
+ throw new ApiError("Failed to create thread", 500);
2241
2176
  }
2177
+ return response.data;
2242
2178
  },
2243
2179
  /**
2244
2180
  * Updates an existing thread by ID for the current assistant
@@ -2247,21 +2183,17 @@ var AbstractClient = class {
2247
2183
  * @returns A promise that resolves to the updated thread
2248
2184
  */
2249
2185
  update: async (threadId, options) => {
2250
- try {
2251
- const response = await this.makeRequest(
2252
- `/api/assistants/${this.assistantId}/threads/${threadId}`,
2253
- {
2254
- method: "PUT",
2255
- body: options
2256
- }
2257
- );
2258
- if (!response.data) {
2259
- throw new ApiError("Failed to update thread", 500);
2186
+ const response = await this.makeRequest(
2187
+ `/api/assistants/${this.assistantId}/threads/${threadId}`,
2188
+ {
2189
+ method: "PUT",
2190
+ body: options
2260
2191
  }
2261
- return response.data;
2262
- } catch (error) {
2263
- throw error;
2192
+ );
2193
+ if (!response.data) {
2194
+ throw new ApiError("Failed to update thread", 500);
2264
2195
  }
2196
+ return response.data;
2265
2197
  },
2266
2198
  /**
2267
2199
  * Deletes a thread by ID for the current assistant
@@ -2269,16 +2201,12 @@ var AbstractClient = class {
2269
2201
  * @returns A promise that resolves when the thread is deleted
2270
2202
  */
2271
2203
  delete: async (threadId) => {
2272
- try {
2273
- await this.makeRequest(
2274
- `/api/assistants/${this.assistantId}/threads/${threadId}`,
2275
- {
2276
- method: "DELETE"
2277
- }
2278
- );
2279
- } catch (error) {
2280
- throw error;
2281
- }
2204
+ await this.makeRequest(
2205
+ `/api/assistants/${this.assistantId}/threads/${threadId}`,
2206
+ {
2207
+ method: "DELETE"
2208
+ }
2209
+ );
2282
2210
  }
2283
2211
  };
2284
2212
  /**
@@ -2291,29 +2219,25 @@ var AbstractClient = class {
2291
2219
  * @returns A promise that resolves to the list of scheduled tasks
2292
2220
  */
2293
2221
  getByThread: async (options) => {
2294
- try {
2295
- let url = `/api/assistants/${this.assistantId}/threads/${options.threadId}/schedules`;
2296
- const params = new URLSearchParams();
2297
- if (options.status) {
2298
- params.append("status", options.status);
2299
- }
2300
- if (options.limit !== void 0) {
2301
- params.append("limit", options.limit.toString());
2302
- }
2303
- if (options.offset !== void 0) {
2304
- params.append("offset", options.offset.toString());
2305
- }
2306
- const queryString = params.toString();
2307
- if (queryString) {
2308
- url += `?${queryString}`;
2309
- }
2310
- const response = await this.makeRequest(
2311
- url
2312
- );
2313
- return response.data.records;
2314
- } catch (error) {
2315
- throw error;
2222
+ let url = `/api/assistants/${this.assistantId}/threads/${options.threadId}/schedules`;
2223
+ const params = new URLSearchParams();
2224
+ if (options.status) {
2225
+ params.append("status", options.status);
2226
+ }
2227
+ if (options.limit !== void 0) {
2228
+ params.append("limit", options.limit.toString());
2229
+ }
2230
+ if (options.offset !== void 0) {
2231
+ params.append("offset", options.offset.toString());
2232
+ }
2233
+ const queryString = params.toString();
2234
+ if (queryString) {
2235
+ url += `?${queryString}`;
2316
2236
  }
2237
+ const response = await this.makeRequest(
2238
+ url
2239
+ );
2240
+ return response.data.records;
2317
2241
  },
2318
2242
  /**
2319
2243
  * Gets a single scheduled task by ID
@@ -2321,12 +2245,8 @@ var AbstractClient = class {
2321
2245
  * @returns A promise that resolves to the scheduled task or null
2322
2246
  */
2323
2247
  get: async (taskId) => {
2324
- try {
2325
- const response = await this.makeRequest(`/api/schedules/${taskId}`);
2326
- return response.data;
2327
- } catch (error) {
2328
- throw error;
2329
- }
2248
+ const response = await this.makeRequest(`/api/schedules/${taskId}`);
2249
+ return response.data;
2330
2250
  },
2331
2251
  /**
2332
2252
  * Cancels a scheduled task
@@ -2334,14 +2254,10 @@ var AbstractClient = class {
2334
2254
  * @returns A promise that resolves when the task is cancelled
2335
2255
  */
2336
2256
  cancel: async (taskId) => {
2337
- try {
2338
- const response = await this.makeRequest(`/api/schedules/${taskId}/cancel`, {
2339
- method: "POST"
2340
- });
2341
- return response.success;
2342
- } catch (error) {
2343
- throw error;
2344
- }
2257
+ const response = await this.makeRequest(`/api/schedules/${taskId}/cancel`, {
2258
+ method: "POST"
2259
+ });
2260
+ return response.success;
2345
2261
  },
2346
2262
  /**
2347
2263
  * Pauses a scheduled cron task
@@ -2349,14 +2265,10 @@ var AbstractClient = class {
2349
2265
  * @returns A promise that resolves when the task is paused
2350
2266
  */
2351
2267
  pause: async (taskId) => {
2352
- try {
2353
- const response = await this.makeRequest(`/api/schedules/${taskId}/pause`, {
2354
- method: "POST"
2355
- });
2356
- return response.success;
2357
- } catch (error) {
2358
- throw error;
2359
- }
2268
+ const response = await this.makeRequest(`/api/schedules/${taskId}/pause`, {
2269
+ method: "POST"
2270
+ });
2271
+ return response.success;
2360
2272
  },
2361
2273
  /**
2362
2274
  * Resumes a paused cron task
@@ -2364,14 +2276,10 @@ var AbstractClient = class {
2364
2276
  * @returns A promise that resolves when the task is resumed
2365
2277
  */
2366
2278
  resume: async (taskId) => {
2367
- try {
2368
- const response = await this.makeRequest(`/api/schedules/${taskId}/resume`, {
2369
- method: "POST"
2370
- });
2371
- return response.success;
2372
- } catch (error) {
2373
- throw error;
2374
- }
2279
+ const response = await this.makeRequest(`/api/schedules/${taskId}/resume`, {
2280
+ method: "POST"
2281
+ });
2282
+ return response.success;
2375
2283
  }
2376
2284
  };
2377
2285
  this.config = {
@@ -2501,6 +2409,68 @@ var AbstractClient = class {
2501
2409
  return await this.makeRequest(`/api/mcp-servers/${id}/test`, { method: "POST" });
2502
2410
  }
2503
2411
  };
2412
+ this.tasks = {
2413
+ list: async (params) => {
2414
+ const qs = params ? `?${new URLSearchParams(params).toString()}` : "";
2415
+ const response = await this.makeRequest(`/api/tasks${qs}`);
2416
+ return response.data || [];
2417
+ },
2418
+ get: async (id) => {
2419
+ const response = await this.makeRequest(`/api/tasks/${id}`);
2420
+ if (!response.data)
2421
+ throw new ApiError("Task not found", 404);
2422
+ return response.data;
2423
+ },
2424
+ create: async (data) => {
2425
+ const response = await this.makeRequest("/api/tasks", { method: "POST", body: data });
2426
+ if (!response.data)
2427
+ throw new ApiError("Failed to create task", 500);
2428
+ return response.data;
2429
+ },
2430
+ update: async (id, data) => {
2431
+ const response = await this.makeRequest(`/api/tasks/${id}`, { method: "PUT", body: data });
2432
+ if (!response.data)
2433
+ throw new ApiError("Failed to update task", 500);
2434
+ return response.data;
2435
+ },
2436
+ delete: async (id) => {
2437
+ await this.makeRequest(`/api/tasks/${id}`, { method: "DELETE" });
2438
+ },
2439
+ complete: async (id) => {
2440
+ const response = await this.makeRequest(`/api/tasks/${id}/complete`, { method: "PATCH" });
2441
+ if (!response.data)
2442
+ throw new ApiError("Failed to complete task", 500);
2443
+ return response.data;
2444
+ }
2445
+ };
2446
+ this.menu = {
2447
+ list: async (menuTarget) => {
2448
+ const qs = menuTarget ? `?menuTarget=${menuTarget}` : "";
2449
+ const response = await this.makeRequest(`/api/menu-items${qs}`);
2450
+ return response.data?.records || [];
2451
+ },
2452
+ get: async (id) => {
2453
+ const response = await this.makeRequest(`/api/menu-items/${id}`);
2454
+ if (!response.data)
2455
+ throw new Error("Menu item not found");
2456
+ return response.data;
2457
+ },
2458
+ create: async (data) => {
2459
+ const response = await this.makeRequest("/api/menu-items", { method: "POST", body: data });
2460
+ if (!response.data)
2461
+ throw new Error("Failed to create menu item");
2462
+ return response.data;
2463
+ },
2464
+ update: async (id, data) => {
2465
+ const response = await this.makeRequest(`/api/menu-items/${id}`, { method: "PUT", body: data });
2466
+ if (!response.data)
2467
+ throw new Error("Failed to update menu item");
2468
+ return response.data;
2469
+ },
2470
+ delete: async (id) => {
2471
+ await this.makeRequest(`/api/menu-items/${id}`, { method: "DELETE" });
2472
+ }
2473
+ };
2504
2474
  }
2505
2475
  /**
2506
2476
  * Set handler for 401 unauthorized errors
@@ -2588,21 +2558,17 @@ var AbstractClient = class {
2588
2558
  * @returns A promise that resolves to the thread ID
2589
2559
  */
2590
2560
  async createThread(options) {
2591
- try {
2592
- const response = await this.makeRequest(
2593
- `/api/assistants/${this.assistantId}/threads`,
2594
- {
2595
- method: "POST",
2596
- body: options
2597
- }
2598
- );
2599
- if (!response.data) {
2600
- throw new ApiError("Failed to create thread", 500);
2561
+ const response = await this.makeRequest(
2562
+ `/api/assistants/${this.assistantId}/threads`,
2563
+ {
2564
+ method: "POST",
2565
+ body: options
2601
2566
  }
2602
- return response.data.id;
2603
- } catch (error) {
2604
- throw error;
2567
+ );
2568
+ if (!response.data) {
2569
+ throw new ApiError("Failed to create thread", 500);
2605
2570
  }
2571
+ return response.data.id;
2606
2572
  }
2607
2573
  /**
2608
2574
  * Retrieves thread information
@@ -2611,17 +2577,13 @@ var AbstractClient = class {
2611
2577
  * @returns A promise that resolves to the thread information
2612
2578
  */
2613
2579
  async getThread(threadId) {
2614
- try {
2615
- const response = await this.makeRequest(
2616
- `/api/assistants/${this.assistantId}/threads/${threadId}`
2617
- );
2618
- if (!response.data) {
2619
- throw new ApiError("Thread not found", 404);
2620
- }
2621
- return response.data;
2622
- } catch (error) {
2623
- throw error;
2580
+ const response = await this.makeRequest(
2581
+ `/api/assistants/${this.assistantId}/threads/${threadId}`
2582
+ );
2583
+ if (!response.data) {
2584
+ throw new ApiError("Thread not found", 404);
2624
2585
  }
2586
+ return response.data;
2625
2587
  }
2626
2588
  /**
2627
2589
  * Lists all threads
@@ -2630,14 +2592,10 @@ var AbstractClient = class {
2630
2592
  * @returns A promise that resolves to an array of threads
2631
2593
  */
2632
2594
  async listThreads(options) {
2633
- try {
2634
- const response = await this.makeRequest(
2635
- `/api/assistants/${this.assistantId}/threads`
2636
- );
2637
- return response.data.records;
2638
- } catch (error) {
2639
- throw error;
2640
- }
2595
+ const response = await this.makeRequest(
2596
+ `/api/assistants/${this.assistantId}/threads`
2597
+ );
2598
+ return response.data.records;
2641
2599
  }
2642
2600
  /**
2643
2601
  * Deletes a thread
@@ -2646,14 +2604,10 @@ var AbstractClient = class {
2646
2604
  * @returns A promise that resolves when the thread is deleted
2647
2605
  */
2648
2606
  async deleteThread(threadId) {
2649
- try {
2650
- await this.makeRequest(
2651
- `/api/assistants/${this.assistantId}/threads/${threadId}`,
2652
- { method: "DELETE" }
2653
- );
2654
- } catch (error) {
2655
- throw error;
2656
- }
2607
+ await this.makeRequest(
2608
+ `/api/assistants/${this.assistantId}/threads/${threadId}`,
2609
+ { method: "DELETE" }
2610
+ );
2657
2611
  }
2658
2612
  /**
2659
2613
  * Retrieves messages from a thread
@@ -2661,22 +2615,18 @@ var AbstractClient = class {
2661
2615
  * @returns A promise that resolves to an array of messages
2662
2616
  */
2663
2617
  async getMessages(options) {
2664
- try {
2665
- let url = `/api/assistants/${this.assistantId}/${options.threadId}/memory`;
2666
- if (options.limit) {
2667
- url += `?limit=${options.limit}`;
2668
- }
2669
- if (options.after) {
2670
- url += url.includes("?") ? `&after=${options.after}` : `?after=${options.after}`;
2671
- }
2672
- if (options.reverse !== void 0) {
2673
- url += url.includes("?") ? `&reverse=${options.reverse}` : `?reverse=${options.reverse}`;
2674
- }
2675
- url += url.includes("?") ? `&assistantId=${this.assistantId}` : `?assistantId=${this.assistantId}`;
2676
- return await this.makeRequest(url);
2677
- } catch (error) {
2678
- throw error;
2618
+ let url = `/api/assistants/${this.assistantId}/${options.threadId}/memory`;
2619
+ if (options.limit) {
2620
+ url += `?limit=${options.limit}`;
2679
2621
  }
2622
+ if (options.after) {
2623
+ url += url.includes("?") ? `&after=${options.after}` : `?after=${options.after}`;
2624
+ }
2625
+ if (options.reverse !== void 0) {
2626
+ url += url.includes("?") ? `&reverse=${options.reverse}` : `?reverse=${options.reverse}`;
2627
+ }
2628
+ url += url.includes("?") ? `&assistantId=${this.assistantId}` : `?assistantId=${this.assistantId}`;
2629
+ return await this.makeRequest(url);
2680
2630
  }
2681
2631
  /**
2682
2632
  * Retrieves agent state
@@ -2684,27 +2634,19 @@ var AbstractClient = class {
2684
2634
  * @returns A promise that resolves to the agent state
2685
2635
  */
2686
2636
  async getAgentState(threadId) {
2687
- try {
2688
- return await this.makeRequest(
2689
- `/api/assistants/${this.assistantId}/${threadId}/state`
2690
- );
2691
- } catch (error) {
2692
- throw error;
2693
- }
2637
+ return await this.makeRequest(
2638
+ `/api/assistants/${this.assistantId}/${threadId}/state`
2639
+ );
2694
2640
  }
2695
2641
  /**
2696
2642
  * Gets agent graph visualization
2697
2643
  * @returns A promise that resolves to the graph visualization data
2698
2644
  */
2699
2645
  async getAgentGraph() {
2700
- try {
2701
- const data = await this.makeRequest(
2702
- `/api/assistants/${this.assistantId}/graph`
2703
- );
2704
- return data.image;
2705
- } catch (error) {
2706
- throw error;
2707
- }
2646
+ const data = await this.makeRequest(
2647
+ `/api/assistants/${this.assistantId}/graph`
2648
+ );
2649
+ return data.image;
2708
2650
  }
2709
2651
  /**
2710
2652
  * Run agent with options
@@ -2712,39 +2654,35 @@ var AbstractClient = class {
2712
2654
  * @returns A promise that resolves to the run result
2713
2655
  */
2714
2656
  async run(options) {
2715
- try {
2716
- const {
2717
- command,
2718
- threadId,
2719
- assistantId,
2720
- message,
2721
- files,
2722
- background,
2723
- custom_run_config,
2724
- ...rest
2725
- } = options;
2726
- if (options.streaming) {
2727
- throw new Error(
2728
- "Streaming without callbacks is not supported. Use chat.stream with callbacks instead."
2729
- );
2730
- } else {
2731
- return await this.makeRequest("/api/runs", {
2732
- method: "POST",
2733
- body: {
2734
- assistant_id: assistantId || this.assistantId,
2735
- thread_id: threadId,
2736
- message,
2737
- files,
2738
- command,
2739
- streaming: false,
2740
- background: background || false,
2741
- custom_run_config,
2742
- ...rest
2743
- }
2744
- });
2745
- }
2746
- } catch (error) {
2747
- throw error;
2657
+ const {
2658
+ command,
2659
+ threadId,
2660
+ assistantId,
2661
+ message,
2662
+ files,
2663
+ background,
2664
+ custom_run_config,
2665
+ ...rest
2666
+ } = options;
2667
+ if (options.streaming) {
2668
+ throw new Error(
2669
+ "Streaming without callbacks is not supported. Use chat.stream with callbacks instead."
2670
+ );
2671
+ } else {
2672
+ return await this.makeRequest("/api/runs", {
2673
+ method: "POST",
2674
+ body: {
2675
+ assistant_id: assistantId || this.assistantId,
2676
+ thread_id: threadId,
2677
+ message,
2678
+ files,
2679
+ command,
2680
+ streaming: false,
2681
+ background: background || false,
2682
+ custom_run_config,
2683
+ ...rest
2684
+ }
2685
+ });
2748
2686
  }
2749
2687
  }
2750
2688
  };
@@ -3241,7 +3179,7 @@ var WeChatClient = class extends AbstractClient {
3241
3179
  async makeRequest(url, options) {
3242
3180
  const methodStr = options?.method || "GET";
3243
3181
  const method = methodStr;
3244
- let fullUrl = `${this.config.baseURL}${url}`;
3182
+ const fullUrl = `${this.config.baseURL}${url}`;
3245
3183
  const headers = {
3246
3184
  "Content-Type": "application/json",
3247
3185
  Authorization: `Bearer ${this.config.apiKey}`,
@@ -3464,20 +3402,20 @@ var WeChatClient = class extends AbstractClient {
3464
3402
  * @return {String} Decoded string including Chinese characters
3465
3403
  */
3466
3404
  hexToStr(hex) {
3467
- let trimedStr = hex.trim();
3468
- let rawStr = trimedStr.substr(0, 2).toLowerCase() === "0x" ? trimedStr.substr(2) : trimedStr;
3469
- let len = rawStr.length;
3405
+ const trimedStr = hex.trim();
3406
+ const rawStr = trimedStr.substr(0, 2).toLowerCase() === "0x" ? trimedStr.substr(2) : trimedStr;
3407
+ const len = rawStr.length;
3470
3408
  if (len % 2 !== 0) {
3471
3409
  return "";
3472
3410
  }
3473
3411
  let curCharCode;
3474
- let resultStr = [];
3412
+ const resultStr = [];
3475
3413
  for (let i = 0; i < len; i = i + 2) {
3476
3414
  curCharCode = parseInt(rawStr.substr(i, 2), 16);
3477
3415
  resultStr.push(curCharCode);
3478
3416
  }
3479
- let bytesView = new Uint8Array(resultStr);
3480
- let str = new import_encoding.default.TextDecoder().decode(bytesView);
3417
+ const bytesView = new Uint8Array(resultStr);
3418
+ const str = new import_encoding.default.TextDecoder().decode(bytesView);
3481
3419
  return str;
3482
3420
  }
3483
3421
  };