@axiom-lattice/client-sdk 2.1.50 → 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.js CHANGED
@@ -1897,22 +1897,18 @@ var AbstractClient = class {
1897
1897
  * @returns A promise that resolves to the chat response
1898
1898
  */
1899
1899
  send: async (options) => {
1900
- try {
1901
- const message = options.messages[options.messages.length - 1];
1902
- const { command, threadId, files, assistantId, mode, ...rest } = options;
1903
- const result = await this.run({
1904
- threadId,
1905
- message: typeof message.content === "string" ? message.content : JSON.stringify(message.content),
1906
- streaming: false,
1907
- command,
1908
- files,
1909
- mode,
1910
- ...rest
1911
- });
1912
- return result;
1913
- } catch (error) {
1914
- throw error;
1915
- }
1900
+ const message = options.messages[options.messages.length - 1];
1901
+ const { command, threadId, files, assistantId, mode, ...rest } = options;
1902
+ const result = await this.run({
1903
+ threadId,
1904
+ message: typeof message.content === "string" ? message.content : JSON.stringify(message.content),
1905
+ streaming: false,
1906
+ command,
1907
+ files,
1908
+ mode,
1909
+ ...rest
1910
+ });
1911
+ return result;
1916
1912
  },
1917
1913
  /**
1918
1914
  * Sends a message to a thread and streams the response
@@ -1958,17 +1954,13 @@ var AbstractClient = class {
1958
1954
  * @returns Promise with success status
1959
1955
  */
1960
1956
  removePendingMessage: async (options) => {
1961
- try {
1962
- const { assistantId, threadId, messageId } = options;
1963
- return await this.makeRequest(
1964
- `/api/assistants/${assistantId}/threads/${threadId}/pending-messages/${messageId}`,
1965
- {
1966
- method: "DELETE"
1967
- }
1968
- );
1969
- } catch (error) {
1970
- throw error;
1971
- }
1957
+ const { assistantId, threadId, messageId } = options;
1958
+ return await this.makeRequest(
1959
+ `/api/assistants/${assistantId}/threads/${threadId}/pending-messages/${messageId}`,
1960
+ {
1961
+ method: "DELETE"
1962
+ }
1963
+ );
1972
1964
  },
1973
1965
  /**
1974
1966
  * Abort agent execution for a thread
@@ -1976,16 +1968,12 @@ var AbstractClient = class {
1976
1968
  * @returns Promise with success status
1977
1969
  */
1978
1970
  abort: async (params) => {
1979
- try {
1980
- return await this.makeRequest(
1981
- `/api/assistants/${params.assistantId}/threads/${params.threadId}/abort`,
1982
- {
1983
- method: "POST"
1984
- }
1985
- );
1986
- } catch (error) {
1987
- throw error;
1988
- }
1971
+ return await this.makeRequest(
1972
+ `/api/assistants/${params.assistantId}/threads/${params.threadId}/abort`,
1973
+ {
1974
+ method: "POST"
1975
+ }
1976
+ );
1989
1977
  }
1990
1978
  };
1991
1979
  /**
@@ -2022,14 +2010,10 @@ var AbstractClient = class {
2022
2010
  * @returns A promise that resolves to the list of assistants
2023
2011
  */
2024
2012
  list: async () => {
2025
- try {
2026
- const response = await this.makeRequest(
2027
- "/api/assistants"
2028
- );
2029
- return response.data.records;
2030
- } catch (error) {
2031
- throw error;
2032
- }
2013
+ const response = await this.makeRequest(
2014
+ "/api/assistants"
2015
+ );
2016
+ return response.data.records;
2033
2017
  },
2034
2018
  /**
2035
2019
  * Retrieves a single assistant by ID
@@ -2038,17 +2022,13 @@ var AbstractClient = class {
2038
2022
  * @returns A promise that resolves to the assistant information
2039
2023
  */
2040
2024
  get: async (id) => {
2041
- try {
2042
- const response = await this.makeRequest(
2043
- `/api/assistants/${id}`
2044
- );
2045
- if (!response.data) {
2046
- throw new ApiError("Assistant not found", 404);
2047
- }
2048
- return response.data;
2049
- } catch (error) {
2050
- throw error;
2025
+ const response = await this.makeRequest(
2026
+ `/api/assistants/${id}`
2027
+ );
2028
+ if (!response.data) {
2029
+ throw new ApiError("Assistant not found", 404);
2051
2030
  }
2031
+ return response.data;
2052
2032
  },
2053
2033
  /**
2054
2034
  * Creates a new assistant
@@ -2057,21 +2037,17 @@ var AbstractClient = class {
2057
2037
  * @returns A promise that resolves to the created assistant
2058
2038
  */
2059
2039
  create: async (options) => {
2060
- try {
2061
- const response = await this.makeRequest(
2062
- "/api/assistants",
2063
- {
2064
- method: "POST",
2065
- body: options
2066
- }
2067
- );
2068
- if (!response.data) {
2069
- throw new ApiError("Failed to create assistant", 500);
2040
+ const response = await this.makeRequest(
2041
+ "/api/assistants",
2042
+ {
2043
+ method: "POST",
2044
+ body: options
2070
2045
  }
2071
- return response.data;
2072
- } catch (error) {
2073
- throw error;
2046
+ );
2047
+ if (!response.data) {
2048
+ throw new ApiError("Failed to create assistant", 500);
2074
2049
  }
2050
+ return response.data;
2075
2051
  },
2076
2052
  /**
2077
2053
  * Updates an existing assistant by ID
@@ -2081,21 +2057,17 @@ var AbstractClient = class {
2081
2057
  * @returns A promise that resolves to the updated assistant
2082
2058
  */
2083
2059
  update: async (id, options) => {
2084
- try {
2085
- const response = await this.makeRequest(
2086
- `/api/assistants/${id}`,
2087
- {
2088
- method: "PUT",
2089
- body: options
2090
- }
2091
- );
2092
- if (!response.data) {
2093
- throw new ApiError("Failed to update assistant", 500);
2060
+ const response = await this.makeRequest(
2061
+ `/api/assistants/${id}`,
2062
+ {
2063
+ method: "PUT",
2064
+ body: options
2094
2065
  }
2095
- return response.data;
2096
- } catch (error) {
2097
- throw error;
2066
+ );
2067
+ if (!response.data) {
2068
+ throw new ApiError("Failed to update assistant", 500);
2098
2069
  }
2070
+ return response.data;
2099
2071
  },
2100
2072
  /**
2101
2073
  * Deletes an assistant by ID
@@ -2104,16 +2076,12 @@ var AbstractClient = class {
2104
2076
  * @returns A promise that resolves when the assistant is deleted
2105
2077
  */
2106
2078
  delete: async (id) => {
2107
- try {
2108
- await this.makeRequest(
2109
- `/api/assistants/${id}`,
2110
- {
2111
- method: "DELETE"
2112
- }
2113
- );
2114
- } catch (error) {
2115
- throw error;
2116
- }
2079
+ await this.makeRequest(
2080
+ `/api/assistants/${id}`,
2081
+ {
2082
+ method: "DELETE"
2083
+ }
2084
+ );
2117
2085
  }
2118
2086
  };
2119
2087
  /**
@@ -2125,12 +2093,8 @@ var AbstractClient = class {
2125
2093
  * @returns A promise that resolves to the list of skills
2126
2094
  */
2127
2095
  list: async () => {
2128
- try {
2129
- const response = await this.makeRequest("/api/skills");
2130
- return response.data.records;
2131
- } catch (error) {
2132
- throw error;
2133
- }
2096
+ const response = await this.makeRequest("/api/skills");
2097
+ return response.data.records;
2134
2098
  },
2135
2099
  /**
2136
2100
  * Retrieves a single skill by ID
@@ -2138,15 +2102,11 @@ var AbstractClient = class {
2138
2102
  * @returns A promise that resolves to the skill information
2139
2103
  */
2140
2104
  get: async (id) => {
2141
- try {
2142
- const response = await this.makeRequest(`/api/skills/${id}`);
2143
- if (!response.data) {
2144
- throw new ApiError("Skill not found", 404);
2145
- }
2146
- return response.data;
2147
- } catch (error) {
2148
- throw error;
2105
+ const response = await this.makeRequest(`/api/skills/${id}`);
2106
+ if (!response.data) {
2107
+ throw new ApiError("Skill not found", 404);
2149
2108
  }
2109
+ return response.data;
2150
2110
  },
2151
2111
  /**
2152
2112
  * Creates a new skill
@@ -2154,18 +2114,14 @@ var AbstractClient = class {
2154
2114
  * @returns A promise that resolves to the created skill
2155
2115
  */
2156
2116
  create: async (options) => {
2157
- try {
2158
- const response = await this.makeRequest("/api/skills", {
2159
- method: "POST",
2160
- body: options
2161
- });
2162
- if (!response.data) {
2163
- throw new ApiError("Failed to create skill", 500);
2164
- }
2165
- return response.data;
2166
- } catch (error) {
2167
- throw error;
2117
+ const response = await this.makeRequest("/api/skills", {
2118
+ method: "POST",
2119
+ body: options
2120
+ });
2121
+ if (!response.data) {
2122
+ throw new ApiError("Failed to create skill", 500);
2168
2123
  }
2124
+ return response.data;
2169
2125
  },
2170
2126
  /**
2171
2127
  * Updates an existing skill by ID
@@ -2174,18 +2130,14 @@ var AbstractClient = class {
2174
2130
  * @returns A promise that resolves to the updated skill
2175
2131
  */
2176
2132
  update: async (id, options) => {
2177
- try {
2178
- const response = await this.makeRequest(`/api/skills/${id}`, {
2179
- method: "PUT",
2180
- body: options
2181
- });
2182
- if (!response.data) {
2183
- throw new ApiError("Failed to update skill", 500);
2184
- }
2185
- return response.data;
2186
- } catch (error) {
2187
- throw error;
2133
+ const response = await this.makeRequest(`/api/skills/${id}`, {
2134
+ method: "PUT",
2135
+ body: options
2136
+ });
2137
+ if (!response.data) {
2138
+ throw new ApiError("Failed to update skill", 500);
2188
2139
  }
2140
+ return response.data;
2189
2141
  },
2190
2142
  /**
2191
2143
  * Deletes a skill by ID
@@ -2193,16 +2145,12 @@ var AbstractClient = class {
2193
2145
  * @returns A promise that resolves when the skill is deleted
2194
2146
  */
2195
2147
  delete: async (id) => {
2196
- try {
2197
- await this.makeRequest(
2198
- `/api/skills/${id}`,
2199
- {
2200
- method: "DELETE"
2201
- }
2202
- );
2203
- } catch (error) {
2204
- throw error;
2205
- }
2148
+ await this.makeRequest(
2149
+ `/api/skills/${id}`,
2150
+ {
2151
+ method: "DELETE"
2152
+ }
2153
+ );
2206
2154
  }
2207
2155
  };
2208
2156
  /**
@@ -2214,14 +2162,10 @@ var AbstractClient = class {
2214
2162
  * @returns A promise that resolves to the list of threads
2215
2163
  */
2216
2164
  list: async () => {
2217
- try {
2218
- const response = await this.makeRequest(
2219
- `/api/assistants/${this.assistantId}/threads`
2220
- );
2221
- return response.data.records;
2222
- } catch (error) {
2223
- throw error;
2224
- }
2165
+ const response = await this.makeRequest(
2166
+ `/api/assistants/${this.assistantId}/threads`
2167
+ );
2168
+ return response.data.records;
2225
2169
  },
2226
2170
  /**
2227
2171
  * Retrieves a single thread by ID for the current assistant
@@ -2229,17 +2173,13 @@ var AbstractClient = class {
2229
2173
  * @returns A promise that resolves to the thread information
2230
2174
  */
2231
2175
  get: async (threadId) => {
2232
- try {
2233
- const response = await this.makeRequest(
2234
- `/api/assistants/${this.assistantId}/threads/${threadId}`
2235
- );
2236
- if (!response.data) {
2237
- throw new ApiError("Thread not found", 404);
2238
- }
2239
- return response.data;
2240
- } catch (error) {
2241
- throw error;
2176
+ const response = await this.makeRequest(
2177
+ `/api/assistants/${this.assistantId}/threads/${threadId}`
2178
+ );
2179
+ if (!response.data) {
2180
+ throw new ApiError("Thread not found", 404);
2242
2181
  }
2182
+ return response.data;
2243
2183
  },
2244
2184
  /**
2245
2185
  * Creates a new thread for the current assistant
@@ -2247,21 +2187,17 @@ var AbstractClient = class {
2247
2187
  * @returns A promise that resolves to the created thread
2248
2188
  */
2249
2189
  create: async (options) => {
2250
- try {
2251
- const response = await this.makeRequest(
2252
- `/api/assistants/${this.assistantId}/threads`,
2253
- {
2254
- method: "POST",
2255
- body: options
2256
- }
2257
- );
2258
- if (!response.data) {
2259
- throw new ApiError("Failed to create thread", 500);
2190
+ const response = await this.makeRequest(
2191
+ `/api/assistants/${this.assistantId}/threads`,
2192
+ {
2193
+ method: "POST",
2194
+ body: options
2260
2195
  }
2261
- return response.data;
2262
- } catch (error) {
2263
- throw error;
2196
+ );
2197
+ if (!response.data) {
2198
+ throw new ApiError("Failed to create thread", 500);
2264
2199
  }
2200
+ return response.data;
2265
2201
  },
2266
2202
  /**
2267
2203
  * Updates an existing thread by ID for the current assistant
@@ -2270,21 +2206,17 @@ var AbstractClient = class {
2270
2206
  * @returns A promise that resolves to the updated thread
2271
2207
  */
2272
2208
  update: async (threadId, options) => {
2273
- try {
2274
- const response = await this.makeRequest(
2275
- `/api/assistants/${this.assistantId}/threads/${threadId}`,
2276
- {
2277
- method: "PUT",
2278
- body: options
2279
- }
2280
- );
2281
- if (!response.data) {
2282
- throw new ApiError("Failed to update thread", 500);
2209
+ const response = await this.makeRequest(
2210
+ `/api/assistants/${this.assistantId}/threads/${threadId}`,
2211
+ {
2212
+ method: "PUT",
2213
+ body: options
2283
2214
  }
2284
- return response.data;
2285
- } catch (error) {
2286
- throw error;
2215
+ );
2216
+ if (!response.data) {
2217
+ throw new ApiError("Failed to update thread", 500);
2287
2218
  }
2219
+ return response.data;
2288
2220
  },
2289
2221
  /**
2290
2222
  * Deletes a thread by ID for the current assistant
@@ -2292,16 +2224,12 @@ var AbstractClient = class {
2292
2224
  * @returns A promise that resolves when the thread is deleted
2293
2225
  */
2294
2226
  delete: async (threadId) => {
2295
- try {
2296
- await this.makeRequest(
2297
- `/api/assistants/${this.assistantId}/threads/${threadId}`,
2298
- {
2299
- method: "DELETE"
2300
- }
2301
- );
2302
- } catch (error) {
2303
- throw error;
2304
- }
2227
+ await this.makeRequest(
2228
+ `/api/assistants/${this.assistantId}/threads/${threadId}`,
2229
+ {
2230
+ method: "DELETE"
2231
+ }
2232
+ );
2305
2233
  }
2306
2234
  };
2307
2235
  /**
@@ -2314,29 +2242,25 @@ var AbstractClient = class {
2314
2242
  * @returns A promise that resolves to the list of scheduled tasks
2315
2243
  */
2316
2244
  getByThread: async (options) => {
2317
- try {
2318
- let url = `/api/assistants/${this.assistantId}/threads/${options.threadId}/schedules`;
2319
- const params = new URLSearchParams();
2320
- if (options.status) {
2321
- params.append("status", options.status);
2322
- }
2323
- if (options.limit !== void 0) {
2324
- params.append("limit", options.limit.toString());
2325
- }
2326
- if (options.offset !== void 0) {
2327
- params.append("offset", options.offset.toString());
2328
- }
2329
- const queryString = params.toString();
2330
- if (queryString) {
2331
- url += `?${queryString}`;
2332
- }
2333
- const response = await this.makeRequest(
2334
- url
2335
- );
2336
- return response.data.records;
2337
- } catch (error) {
2338
- throw error;
2245
+ let url = `/api/assistants/${this.assistantId}/threads/${options.threadId}/schedules`;
2246
+ const params = new URLSearchParams();
2247
+ if (options.status) {
2248
+ params.append("status", options.status);
2249
+ }
2250
+ if (options.limit !== void 0) {
2251
+ params.append("limit", options.limit.toString());
2252
+ }
2253
+ if (options.offset !== void 0) {
2254
+ params.append("offset", options.offset.toString());
2255
+ }
2256
+ const queryString = params.toString();
2257
+ if (queryString) {
2258
+ url += `?${queryString}`;
2339
2259
  }
2260
+ const response = await this.makeRequest(
2261
+ url
2262
+ );
2263
+ return response.data.records;
2340
2264
  },
2341
2265
  /**
2342
2266
  * Gets a single scheduled task by ID
@@ -2344,12 +2268,8 @@ var AbstractClient = class {
2344
2268
  * @returns A promise that resolves to the scheduled task or null
2345
2269
  */
2346
2270
  get: async (taskId) => {
2347
- try {
2348
- const response = await this.makeRequest(`/api/schedules/${taskId}`);
2349
- return response.data;
2350
- } catch (error) {
2351
- throw error;
2352
- }
2271
+ const response = await this.makeRequest(`/api/schedules/${taskId}`);
2272
+ return response.data;
2353
2273
  },
2354
2274
  /**
2355
2275
  * Cancels a scheduled task
@@ -2357,14 +2277,10 @@ var AbstractClient = class {
2357
2277
  * @returns A promise that resolves when the task is cancelled
2358
2278
  */
2359
2279
  cancel: async (taskId) => {
2360
- try {
2361
- const response = await this.makeRequest(`/api/schedules/${taskId}/cancel`, {
2362
- method: "POST"
2363
- });
2364
- return response.success;
2365
- } catch (error) {
2366
- throw error;
2367
- }
2280
+ const response = await this.makeRequest(`/api/schedules/${taskId}/cancel`, {
2281
+ method: "POST"
2282
+ });
2283
+ return response.success;
2368
2284
  },
2369
2285
  /**
2370
2286
  * Pauses a scheduled cron task
@@ -2372,14 +2288,10 @@ var AbstractClient = class {
2372
2288
  * @returns A promise that resolves when the task is paused
2373
2289
  */
2374
2290
  pause: async (taskId) => {
2375
- try {
2376
- const response = await this.makeRequest(`/api/schedules/${taskId}/pause`, {
2377
- method: "POST"
2378
- });
2379
- return response.success;
2380
- } catch (error) {
2381
- throw error;
2382
- }
2291
+ const response = await this.makeRequest(`/api/schedules/${taskId}/pause`, {
2292
+ method: "POST"
2293
+ });
2294
+ return response.success;
2383
2295
  },
2384
2296
  /**
2385
2297
  * Resumes a paused cron task
@@ -2387,14 +2299,10 @@ var AbstractClient = class {
2387
2299
  * @returns A promise that resolves when the task is resumed
2388
2300
  */
2389
2301
  resume: async (taskId) => {
2390
- try {
2391
- const response = await this.makeRequest(`/api/schedules/${taskId}/resume`, {
2392
- method: "POST"
2393
- });
2394
- return response.success;
2395
- } catch (error) {
2396
- throw error;
2397
- }
2302
+ const response = await this.makeRequest(`/api/schedules/${taskId}/resume`, {
2303
+ method: "POST"
2304
+ });
2305
+ return response.success;
2398
2306
  }
2399
2307
  };
2400
2308
  this.config = {
@@ -2524,6 +2432,68 @@ var AbstractClient = class {
2524
2432
  return await this.makeRequest(`/api/mcp-servers/${id}/test`, { method: "POST" });
2525
2433
  }
2526
2434
  };
2435
+ this.tasks = {
2436
+ list: async (params) => {
2437
+ const qs = params ? `?${new URLSearchParams(params).toString()}` : "";
2438
+ const response = await this.makeRequest(`/api/tasks${qs}`);
2439
+ return response.data || [];
2440
+ },
2441
+ get: async (id) => {
2442
+ const response = await this.makeRequest(`/api/tasks/${id}`);
2443
+ if (!response.data)
2444
+ throw new ApiError("Task not found", 404);
2445
+ return response.data;
2446
+ },
2447
+ create: async (data) => {
2448
+ const response = await this.makeRequest("/api/tasks", { method: "POST", body: data });
2449
+ if (!response.data)
2450
+ throw new ApiError("Failed to create task", 500);
2451
+ return response.data;
2452
+ },
2453
+ update: async (id, data) => {
2454
+ const response = await this.makeRequest(`/api/tasks/${id}`, { method: "PUT", body: data });
2455
+ if (!response.data)
2456
+ throw new ApiError("Failed to update task", 500);
2457
+ return response.data;
2458
+ },
2459
+ delete: async (id) => {
2460
+ await this.makeRequest(`/api/tasks/${id}`, { method: "DELETE" });
2461
+ },
2462
+ complete: async (id) => {
2463
+ const response = await this.makeRequest(`/api/tasks/${id}/complete`, { method: "PATCH" });
2464
+ if (!response.data)
2465
+ throw new ApiError("Failed to complete task", 500);
2466
+ return response.data;
2467
+ }
2468
+ };
2469
+ this.menu = {
2470
+ list: async (menuTarget) => {
2471
+ const qs = menuTarget ? `?menuTarget=${menuTarget}` : "";
2472
+ const response = await this.makeRequest(`/api/menu-items${qs}`);
2473
+ return response.data?.records || [];
2474
+ },
2475
+ get: async (id) => {
2476
+ const response = await this.makeRequest(`/api/menu-items/${id}`);
2477
+ if (!response.data)
2478
+ throw new Error("Menu item not found");
2479
+ return response.data;
2480
+ },
2481
+ create: async (data) => {
2482
+ const response = await this.makeRequest("/api/menu-items", { method: "POST", body: data });
2483
+ if (!response.data)
2484
+ throw new Error("Failed to create menu item");
2485
+ return response.data;
2486
+ },
2487
+ update: async (id, data) => {
2488
+ const response = await this.makeRequest(`/api/menu-items/${id}`, { method: "PUT", body: data });
2489
+ if (!response.data)
2490
+ throw new Error("Failed to update menu item");
2491
+ return response.data;
2492
+ },
2493
+ delete: async (id) => {
2494
+ await this.makeRequest(`/api/menu-items/${id}`, { method: "DELETE" });
2495
+ }
2496
+ };
2527
2497
  }
2528
2498
  /**
2529
2499
  * Set handler for 401 unauthorized errors
@@ -2611,21 +2581,17 @@ var AbstractClient = class {
2611
2581
  * @returns A promise that resolves to the thread ID
2612
2582
  */
2613
2583
  async createThread(options) {
2614
- try {
2615
- const response = await this.makeRequest(
2616
- `/api/assistants/${this.assistantId}/threads`,
2617
- {
2618
- method: "POST",
2619
- body: options
2620
- }
2621
- );
2622
- if (!response.data) {
2623
- throw new ApiError("Failed to create thread", 500);
2584
+ const response = await this.makeRequest(
2585
+ `/api/assistants/${this.assistantId}/threads`,
2586
+ {
2587
+ method: "POST",
2588
+ body: options
2624
2589
  }
2625
- return response.data.id;
2626
- } catch (error) {
2627
- throw error;
2590
+ );
2591
+ if (!response.data) {
2592
+ throw new ApiError("Failed to create thread", 500);
2628
2593
  }
2594
+ return response.data.id;
2629
2595
  }
2630
2596
  /**
2631
2597
  * Retrieves thread information
@@ -2634,17 +2600,13 @@ var AbstractClient = class {
2634
2600
  * @returns A promise that resolves to the thread information
2635
2601
  */
2636
2602
  async getThread(threadId) {
2637
- try {
2638
- const response = await this.makeRequest(
2639
- `/api/assistants/${this.assistantId}/threads/${threadId}`
2640
- );
2641
- if (!response.data) {
2642
- throw new ApiError("Thread not found", 404);
2643
- }
2644
- return response.data;
2645
- } catch (error) {
2646
- throw error;
2603
+ const response = await this.makeRequest(
2604
+ `/api/assistants/${this.assistantId}/threads/${threadId}`
2605
+ );
2606
+ if (!response.data) {
2607
+ throw new ApiError("Thread not found", 404);
2647
2608
  }
2609
+ return response.data;
2648
2610
  }
2649
2611
  /**
2650
2612
  * Lists all threads
@@ -2653,14 +2615,10 @@ var AbstractClient = class {
2653
2615
  * @returns A promise that resolves to an array of threads
2654
2616
  */
2655
2617
  async listThreads(options) {
2656
- try {
2657
- const response = await this.makeRequest(
2658
- `/api/assistants/${this.assistantId}/threads`
2659
- );
2660
- return response.data.records;
2661
- } catch (error) {
2662
- throw error;
2663
- }
2618
+ const response = await this.makeRequest(
2619
+ `/api/assistants/${this.assistantId}/threads`
2620
+ );
2621
+ return response.data.records;
2664
2622
  }
2665
2623
  /**
2666
2624
  * Deletes a thread
@@ -2669,14 +2627,10 @@ var AbstractClient = class {
2669
2627
  * @returns A promise that resolves when the thread is deleted
2670
2628
  */
2671
2629
  async deleteThread(threadId) {
2672
- try {
2673
- await this.makeRequest(
2674
- `/api/assistants/${this.assistantId}/threads/${threadId}`,
2675
- { method: "DELETE" }
2676
- );
2677
- } catch (error) {
2678
- throw error;
2679
- }
2630
+ await this.makeRequest(
2631
+ `/api/assistants/${this.assistantId}/threads/${threadId}`,
2632
+ { method: "DELETE" }
2633
+ );
2680
2634
  }
2681
2635
  /**
2682
2636
  * Retrieves messages from a thread
@@ -2684,22 +2638,18 @@ var AbstractClient = class {
2684
2638
  * @returns A promise that resolves to an array of messages
2685
2639
  */
2686
2640
  async getMessages(options) {
2687
- try {
2688
- let url = `/api/assistants/${this.assistantId}/${options.threadId}/memory`;
2689
- if (options.limit) {
2690
- url += `?limit=${options.limit}`;
2691
- }
2692
- if (options.after) {
2693
- url += url.includes("?") ? `&after=${options.after}` : `?after=${options.after}`;
2694
- }
2695
- if (options.reverse !== void 0) {
2696
- url += url.includes("?") ? `&reverse=${options.reverse}` : `?reverse=${options.reverse}`;
2697
- }
2698
- url += url.includes("?") ? `&assistantId=${this.assistantId}` : `?assistantId=${this.assistantId}`;
2699
- return await this.makeRequest(url);
2700
- } catch (error) {
2701
- throw error;
2641
+ let url = `/api/assistants/${this.assistantId}/${options.threadId}/memory`;
2642
+ if (options.limit) {
2643
+ url += `?limit=${options.limit}`;
2702
2644
  }
2645
+ if (options.after) {
2646
+ url += url.includes("?") ? `&after=${options.after}` : `?after=${options.after}`;
2647
+ }
2648
+ if (options.reverse !== void 0) {
2649
+ url += url.includes("?") ? `&reverse=${options.reverse}` : `?reverse=${options.reverse}`;
2650
+ }
2651
+ url += url.includes("?") ? `&assistantId=${this.assistantId}` : `?assistantId=${this.assistantId}`;
2652
+ return await this.makeRequest(url);
2703
2653
  }
2704
2654
  /**
2705
2655
  * Retrieves agent state
@@ -2707,27 +2657,19 @@ var AbstractClient = class {
2707
2657
  * @returns A promise that resolves to the agent state
2708
2658
  */
2709
2659
  async getAgentState(threadId) {
2710
- try {
2711
- return await this.makeRequest(
2712
- `/api/assistants/${this.assistantId}/${threadId}/state`
2713
- );
2714
- } catch (error) {
2715
- throw error;
2716
- }
2660
+ return await this.makeRequest(
2661
+ `/api/assistants/${this.assistantId}/${threadId}/state`
2662
+ );
2717
2663
  }
2718
2664
  /**
2719
2665
  * Gets agent graph visualization
2720
2666
  * @returns A promise that resolves to the graph visualization data
2721
2667
  */
2722
2668
  async getAgentGraph() {
2723
- try {
2724
- const data = await this.makeRequest(
2725
- `/api/assistants/${this.assistantId}/graph`
2726
- );
2727
- return data.image;
2728
- } catch (error) {
2729
- throw error;
2730
- }
2669
+ const data = await this.makeRequest(
2670
+ `/api/assistants/${this.assistantId}/graph`
2671
+ );
2672
+ return data.image;
2731
2673
  }
2732
2674
  /**
2733
2675
  * Run agent with options
@@ -2735,39 +2677,35 @@ var AbstractClient = class {
2735
2677
  * @returns A promise that resolves to the run result
2736
2678
  */
2737
2679
  async run(options) {
2738
- try {
2739
- const {
2740
- command,
2741
- threadId,
2742
- assistantId,
2743
- message,
2744
- files,
2745
- background,
2746
- custom_run_config,
2747
- ...rest
2748
- } = options;
2749
- if (options.streaming) {
2750
- throw new Error(
2751
- "Streaming without callbacks is not supported. Use chat.stream with callbacks instead."
2752
- );
2753
- } else {
2754
- return await this.makeRequest("/api/runs", {
2755
- method: "POST",
2756
- body: {
2757
- assistant_id: assistantId || this.assistantId,
2758
- thread_id: threadId,
2759
- message,
2760
- files,
2761
- command,
2762
- streaming: false,
2763
- background: background || false,
2764
- custom_run_config,
2765
- ...rest
2766
- }
2767
- });
2768
- }
2769
- } catch (error) {
2770
- throw error;
2680
+ const {
2681
+ command,
2682
+ threadId,
2683
+ assistantId,
2684
+ message,
2685
+ files,
2686
+ background,
2687
+ custom_run_config,
2688
+ ...rest
2689
+ } = options;
2690
+ if (options.streaming) {
2691
+ throw new Error(
2692
+ "Streaming without callbacks is not supported. Use chat.stream with callbacks instead."
2693
+ );
2694
+ } else {
2695
+ return await this.makeRequest("/api/runs", {
2696
+ method: "POST",
2697
+ body: {
2698
+ assistant_id: assistantId || this.assistantId,
2699
+ thread_id: threadId,
2700
+ message,
2701
+ files,
2702
+ command,
2703
+ streaming: false,
2704
+ background: background || false,
2705
+ custom_run_config,
2706
+ ...rest
2707
+ }
2708
+ });
2771
2709
  }
2772
2710
  }
2773
2711
  };
@@ -3264,7 +3202,7 @@ var WeChatClient = class extends AbstractClient {
3264
3202
  async makeRequest(url, options) {
3265
3203
  const methodStr = options?.method || "GET";
3266
3204
  const method = methodStr;
3267
- let fullUrl = `${this.config.baseURL}${url}`;
3205
+ const fullUrl = `${this.config.baseURL}${url}`;
3268
3206
  const headers = {
3269
3207
  "Content-Type": "application/json",
3270
3208
  Authorization: `Bearer ${this.config.apiKey}`,
@@ -3487,20 +3425,20 @@ var WeChatClient = class extends AbstractClient {
3487
3425
  * @return {String} Decoded string including Chinese characters
3488
3426
  */
3489
3427
  hexToStr(hex) {
3490
- let trimedStr = hex.trim();
3491
- let rawStr = trimedStr.substr(0, 2).toLowerCase() === "0x" ? trimedStr.substr(2) : trimedStr;
3492
- let len = rawStr.length;
3428
+ const trimedStr = hex.trim();
3429
+ const rawStr = trimedStr.substr(0, 2).toLowerCase() === "0x" ? trimedStr.substr(2) : trimedStr;
3430
+ const len = rawStr.length;
3493
3431
  if (len % 2 !== 0) {
3494
3432
  return "";
3495
3433
  }
3496
3434
  let curCharCode;
3497
- let resultStr = [];
3435
+ const resultStr = [];
3498
3436
  for (let i = 0; i < len; i = i + 2) {
3499
3437
  curCharCode = parseInt(rawStr.substr(i, 2), 16);
3500
3438
  resultStr.push(curCharCode);
3501
3439
  }
3502
- let bytesView = new Uint8Array(resultStr);
3503
- let str = new import_encoding.default.TextDecoder().decode(bytesView);
3440
+ const bytesView = new Uint8Array(resultStr);
3441
+ const str = new import_encoding.default.TextDecoder().decode(bytesView);
3504
3442
  return str;
3505
3443
  }
3506
3444
  };