@agentrun/sdk 0.0.2-test.21112547326 → 0.0.2-test.21113892804

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
@@ -250,6 +250,80 @@ var init_exception = __esm({
250
250
  }
251
251
  });
252
252
 
253
+ // src/utils/model.ts
254
+ function isFinalStatus(status) {
255
+ return [
256
+ void 0,
257
+ null,
258
+ "",
259
+ ...[
260
+ "READY",
261
+ "CREATE_FAILED",
262
+ "UPDATE_FAILED",
263
+ "DELETE_FAILED"
264
+ ]
265
+ ].includes(status);
266
+ }
267
+ var Status, NetworkMode;
268
+ var init_model = __esm({
269
+ "src/utils/model.ts"() {
270
+ Status = {
271
+ CREATING: "CREATING",
272
+ CREATE_FAILED: "CREATE_FAILED",
273
+ READY: "READY",
274
+ UPDATING: "UPDATING",
275
+ UPDATE_FAILED: "UPDATE_FAILED",
276
+ DELETING: "DELETING",
277
+ DELETE_FAILED: "DELETE_FAILED"
278
+ };
279
+ NetworkMode = {
280
+ PUBLIC: "PUBLIC",
281
+ PRIVATE: "PRIVATE",
282
+ PUBLIC_AND_PRIVATE: "PUBLIC_AND_PRIVATE"
283
+ };
284
+ }
285
+ });
286
+
287
+ // src/utils/control-api.ts
288
+ var control_api_exports = {};
289
+ __export(control_api_exports, {
290
+ $AgentRun: () => $AgentRun3,
291
+ ControlAPI: () => ControlAPI
292
+ });
293
+ var $AgentRunClient, ControlAPI;
294
+ var init_control_api = __esm({
295
+ "src/utils/control-api.ts"() {
296
+ init_config();
297
+ $AgentRunClient = // @ts-expect-error - ESM interop: default.default exists when imported as ESM namespace
298
+ $AgentRun3.default?.default ?? $AgentRun3.default ?? $AgentRun3;
299
+ ControlAPI = class {
300
+ config;
301
+ constructor(config2) {
302
+ this.config = config2;
303
+ }
304
+ /**
305
+ * Get the underlying AgentRun client instance
306
+ */
307
+ getClient(config2) {
308
+ const cfg = Config.withConfigs(this.config, config2);
309
+ let endpoint = cfg.controlEndpoint;
310
+ if (endpoint.startsWith("http://") || endpoint.startsWith("https://")) {
311
+ endpoint = endpoint.split("://")[1];
312
+ }
313
+ const openApiConfig = new $OpenApi.Config({
314
+ accessKeyId: cfg.accessKeyId,
315
+ accessKeySecret: cfg.accessKeySecret,
316
+ securityToken: cfg.securityToken || void 0,
317
+ regionId: cfg.regionId,
318
+ endpoint,
319
+ connectTimeout: cfg.timeout
320
+ });
321
+ return new $AgentRunClient(openApiConfig);
322
+ }
323
+ };
324
+ }
325
+ });
326
+
253
327
  // src/utils/log.ts
254
328
  var LOG_LEVELS, COLORS, Logger, logger;
255
329
  var init_log = __esm({
@@ -448,89 +522,6 @@ ${msg}
448
522
  }
449
523
  }
450
524
  });
451
-
452
- // src/utils/model.ts
453
- function isFinalStatus(status) {
454
- return [
455
- void 0,
456
- null,
457
- "",
458
- ...[
459
- "READY",
460
- "CREATE_FAILED",
461
- "UPDATE_FAILED",
462
- "DELETE_FAILED"
463
- ]
464
- ].includes(status);
465
- }
466
- function fromInnerObject(obj, extra) {
467
- logger.debug(
468
- "before parse object obj=%s, extra=%s",
469
- JSON.stringify(obj),
470
- "null"
471
- );
472
- return obj;
473
- }
474
- var Status, NetworkMode;
475
- var init_model = __esm({
476
- "src/utils/model.ts"() {
477
- init_log();
478
- Status = {
479
- CREATING: "CREATING",
480
- CREATE_FAILED: "CREATE_FAILED",
481
- READY: "READY",
482
- UPDATING: "UPDATING",
483
- UPDATE_FAILED: "UPDATE_FAILED",
484
- DELETING: "DELETING",
485
- DELETE_FAILED: "DELETE_FAILED"
486
- };
487
- NetworkMode = {
488
- PUBLIC: "PUBLIC",
489
- PRIVATE: "PRIVATE",
490
- PUBLIC_AND_PRIVATE: "PUBLIC_AND_PRIVATE"
491
- };
492
- }
493
- });
494
-
495
- // src/utils/control-api.ts
496
- var control_api_exports = {};
497
- __export(control_api_exports, {
498
- $AgentRun: () => $AgentRun3,
499
- ControlAPI: () => ControlAPI
500
- });
501
- var $AgentRunClient, ControlAPI;
502
- var init_control_api = __esm({
503
- "src/utils/control-api.ts"() {
504
- init_config();
505
- $AgentRunClient = // @ts-expect-error - ESM interop: default.default exists when imported as ESM namespace
506
- $AgentRun3.default?.default ?? $AgentRun3.default ?? $AgentRun3;
507
- ControlAPI = class {
508
- config;
509
- constructor(config2) {
510
- this.config = config2;
511
- }
512
- /**
513
- * Get the underlying AgentRun client instance
514
- */
515
- getClient(config2) {
516
- const cfg = Config.withConfigs(this.config, config2);
517
- let endpoint = cfg.controlEndpoint;
518
- if (endpoint.startsWith("http://") || endpoint.startsWith("https://")) {
519
- endpoint = endpoint.split("://")[1];
520
- }
521
- const openApiConfig = new $OpenApi.Config({
522
- accessKeyId: cfg.accessKeyId,
523
- accessKeySecret: cfg.accessKeySecret,
524
- securityToken: cfg.securityToken || void 0,
525
- regionId: cfg.regionId,
526
- endpoint,
527
- connectTimeout: cfg.timeout
528
- });
529
- return new $AgentRunClient(openApiConfig);
530
- }
531
- };
532
- }
533
- });
534
525
  var AgentRuntimeControlAPI;
535
526
  var init_control = __esm({
536
527
  "src/agent-runtime/api/control.ts"() {
@@ -1657,7 +1648,6 @@ var AgentRuntimeEndpoint;
1657
1648
  var init_endpoint = __esm({
1658
1649
  "src/agent-runtime/endpoint.ts"() {
1659
1650
  init_config();
1660
- init_exception();
1661
1651
  init_resource();
1662
1652
  init_data();
1663
1653
  AgentRuntimeEndpoint = class _AgentRuntimeEndpoint extends ResourceBase {
@@ -1693,100 +1683,56 @@ var init_endpoint = __esm({
1693
1683
  */
1694
1684
  static async create(params) {
1695
1685
  const { agentRuntimeId, input, config: config2 } = params;
1696
- try {
1697
- const client = _AgentRuntimeEndpoint.getClient();
1698
- return await client.createEndpoint({ agentRuntimeId, input, config: config2 });
1699
- } catch (error) {
1700
- if (error instanceof HTTPError) {
1701
- throw error.toResourceError(
1702
- "AgentRuntimeEndpoint",
1703
- `${agentRuntimeId}/${input.agentRuntimeEndpointName}`
1704
- );
1705
- }
1706
- throw error;
1707
- }
1686
+ return await _AgentRuntimeEndpoint.getClient().createEndpoint({
1687
+ agentRuntimeId,
1688
+ input,
1689
+ config: config2
1690
+ });
1708
1691
  }
1709
1692
  /**
1710
1693
  * Delete an endpoint by ID
1711
1694
  */
1712
1695
  static async delete(params) {
1713
1696
  const { agentRuntimeId, endpointId, config: config2 } = params;
1714
- try {
1715
- const client = _AgentRuntimeEndpoint.getClient();
1716
- return await client.deleteEndpoint({
1717
- agentRuntimeId,
1718
- endpointId,
1719
- config: config2
1720
- });
1721
- } catch (error) {
1722
- if (error instanceof HTTPError) {
1723
- throw error.toResourceError(
1724
- "AgentRuntimeEndpoint",
1725
- `${agentRuntimeId}/${endpointId}`
1726
- );
1727
- }
1728
- throw error;
1729
- }
1697
+ return await _AgentRuntimeEndpoint.getClient().deleteEndpoint({
1698
+ agentRuntimeId,
1699
+ endpointId,
1700
+ config: config2
1701
+ });
1730
1702
  }
1731
1703
  /**
1732
1704
  * Update an endpoint by ID
1733
1705
  */
1734
1706
  static async update(params) {
1735
1707
  const { agentRuntimeId, endpointId, input, config: config2 } = params;
1736
- try {
1737
- const client = _AgentRuntimeEndpoint.getClient();
1738
- return await client.updateEndpoint({
1739
- agentRuntimeId,
1740
- endpointId,
1741
- input,
1742
- config: config2
1743
- });
1744
- } catch (error) {
1745
- if (error instanceof HTTPError) {
1746
- throw error.toResourceError(
1747
- "AgentRuntimeEndpoint",
1748
- `${agentRuntimeId}/${endpointId}`
1749
- );
1750
- }
1751
- throw error;
1752
- }
1708
+ return await _AgentRuntimeEndpoint.getClient().updateEndpoint({
1709
+ agentRuntimeId,
1710
+ endpointId,
1711
+ input,
1712
+ config: config2
1713
+ });
1753
1714
  }
1754
1715
  /**
1755
1716
  * Get an endpoint by ID
1756
1717
  */
1757
1718
  static async get(params) {
1758
1719
  const { agentRuntimeId, endpointId, config: config2 } = params;
1759
- try {
1760
- const client = _AgentRuntimeEndpoint.getClient();
1761
- return await client.getEndpoint({
1762
- agentRuntimeId,
1763
- endpointId,
1764
- config: config2
1765
- });
1766
- } catch (error) {
1767
- if (error instanceof HTTPError) {
1768
- throw error.toResourceError(
1769
- "AgentRuntimeEndpoint",
1770
- `${agentRuntimeId}/${endpointId}`
1771
- );
1772
- }
1773
- throw error;
1774
- }
1720
+ return await _AgentRuntimeEndpoint.getClient().getEndpoint({
1721
+ agentRuntimeId,
1722
+ endpointId,
1723
+ config: config2
1724
+ });
1775
1725
  }
1776
1726
  /**
1777
1727
  * List endpoints by Agent Runtime ID
1778
1728
  */
1779
1729
  static async list(params) {
1780
1730
  const { agentRuntimeId, input, config: config2 } = params;
1781
- try {
1782
- const client = _AgentRuntimeEndpoint.getClient();
1783
- return await client.listEndpoints({ agentRuntimeId, input, config: config2 });
1784
- } catch (error) {
1785
- if (error instanceof HTTPError) {
1786
- throw error.toResourceError("AgentRuntime", agentRuntimeId);
1787
- }
1788
- throw error;
1789
- }
1731
+ return await _AgentRuntimeEndpoint.getClient().listEndpoints({
1732
+ agentRuntimeId,
1733
+ input,
1734
+ config: config2
1735
+ });
1790
1736
  }
1791
1737
  static listAll = async (params) => {
1792
1738
  const { agentRuntimeId, ...restParams } = params;
@@ -1937,7 +1883,6 @@ var AgentRuntime;
1937
1883
  var init_runtime = __esm({
1938
1884
  "src/agent-runtime/runtime.ts"() {
1939
1885
  init_config();
1940
- init_exception();
1941
1886
  init_resource();
1942
1887
  init_data();
1943
1888
  init_endpoint();
@@ -1987,68 +1932,35 @@ var init_runtime = __esm({
1987
1932
  */
1988
1933
  static async create(params) {
1989
1934
  const { input, config: config2 } = params;
1990
- try {
1991
- const client = _AgentRuntime.getClient();
1992
- return await client.create({ input, config: config2 });
1993
- } catch (error) {
1994
- if (error instanceof HTTPError) {
1995
- throw error.toResourceError("AgentRuntime", input.agentRuntimeName);
1996
- }
1997
- throw error;
1998
- }
1935
+ return await _AgentRuntime.getClient().create({ input, config: config2 });
1999
1936
  }
2000
1937
  /**
2001
1938
  * Delete an Agent Runtime by ID
2002
1939
  */
2003
1940
  static async delete(params) {
2004
1941
  const { id, config: config2 } = params;
2005
- try {
2006
- const client = _AgentRuntime.getClient();
2007
- return await client.delete({ id, config: config2 });
2008
- } catch (error) {
2009
- if (error instanceof HTTPError) {
2010
- throw error.toResourceError("AgentRuntime", id);
2011
- }
2012
- throw error;
2013
- }
1942
+ return await _AgentRuntime.getClient().delete({ id, config: config2 });
2014
1943
  }
2015
1944
  /**
2016
1945
  * Update an Agent Runtime by ID
2017
1946
  */
2018
1947
  static async update(params) {
2019
1948
  const { id, input, config: config2 } = params;
2020
- try {
2021
- const client = _AgentRuntime.getClient();
2022
- return await client.update({ id, input, config: config2 });
2023
- } catch (error) {
2024
- if (error instanceof HTTPError) {
2025
- throw error.toResourceError("AgentRuntime", id);
2026
- }
2027
- throw error;
2028
- }
1949
+ return await _AgentRuntime.getClient().update({ id, input, config: config2 });
2029
1950
  }
2030
1951
  /**
2031
1952
  * Get an Agent Runtime by ID
2032
1953
  */
2033
1954
  static async get(params) {
2034
1955
  const { id, config: config2 } = params;
2035
- try {
2036
- const client = _AgentRuntime.getClient();
2037
- return await client.get({ id, config: config2 });
2038
- } catch (error) {
2039
- if (error instanceof HTTPError) {
2040
- throw error.toResourceError("AgentRuntime", id);
2041
- }
2042
- throw error;
2043
- }
1956
+ return await _AgentRuntime.getClient().get({ id, config: config2 });
2044
1957
  }
2045
1958
  /**
2046
1959
  * List Agent Runtimes
2047
1960
  */
2048
1961
  static async list(params) {
2049
1962
  const { input, config: config2 } = params ?? {};
2050
- const client = _AgentRuntime.getClient();
2051
- return await client.list({ input, config: config2 });
1963
+ return await _AgentRuntime.getClient().list({ input, config: config2 });
2052
1964
  }
2053
1965
  static listAll = listAllResourcesFunction(this.list);
2054
1966
  /**
@@ -2244,6 +2156,7 @@ var AgentRuntimeClient;
2244
2156
  var init_client = __esm({
2245
2157
  "src/agent-runtime/client.ts"() {
2246
2158
  init_config();
2159
+ init_exception();
2247
2160
  init_model();
2248
2161
  init_control();
2249
2162
  init_data();
@@ -2263,39 +2176,46 @@ var init_client = __esm({
2263
2176
  create = async (params) => {
2264
2177
  const { input, config: config2 } = params;
2265
2178
  const cfg = Config.withConfigs(this.config, config2);
2266
- if (!input.networkConfiguration) {
2267
- input.networkConfiguration = {};
2268
- }
2269
- if (!input.artifactType) {
2270
- if (input.codeConfiguration) {
2271
- input.artifactType = AgentRuntimeArtifact.CODE;
2272
- } else if (input.containerConfiguration) {
2273
- input.artifactType = AgentRuntimeArtifact.CONTAINER;
2274
- } else {
2275
- throw new Error(
2276
- "Either codeConfiguration or containerConfiguration must be provided"
2277
- );
2179
+ try {
2180
+ if (!input.networkConfiguration) {
2181
+ input.networkConfiguration = {};
2182
+ }
2183
+ if (!input.artifactType) {
2184
+ if (input.codeConfiguration) {
2185
+ input.artifactType = AgentRuntimeArtifact.CODE;
2186
+ } else if (input.containerConfiguration) {
2187
+ input.artifactType = AgentRuntimeArtifact.CONTAINER;
2188
+ } else {
2189
+ throw new Error(
2190
+ "Either codeConfiguration or containerConfiguration must be provided"
2191
+ );
2192
+ }
2278
2193
  }
2194
+ const result = await this.controlApi.createAgentRuntime({
2195
+ input: new $AgentRun3.CreateAgentRuntimeInput({
2196
+ ...input,
2197
+ codeConfiguration: input.codeConfiguration ? new $AgentRun3.CodeConfiguration({
2198
+ ...input.codeConfiguration
2199
+ }) : void 0,
2200
+ containerConfiguration: input.containerConfiguration ? new $AgentRun3.ContainerConfiguration({
2201
+ ...input.containerConfiguration
2202
+ }) : void 0,
2203
+ networkConfiguration: input.networkConfiguration ? new $AgentRun3.NetworkConfiguration({
2204
+ networkMode: input.networkConfiguration.networkMode || NetworkMode.PUBLIC,
2205
+ securityGroupId: input.networkConfiguration.securityGroupId,
2206
+ vpcId: input.networkConfiguration.vpcId,
2207
+ vswitchIds: input.networkConfiguration.vSwitchIds
2208
+ }) : void 0
2209
+ }),
2210
+ config: cfg
2211
+ });
2212
+ return new AgentRuntime(result, cfg);
2213
+ } catch (error) {
2214
+ if (error instanceof HTTPError) {
2215
+ throw error.toResourceError("AgentRuntime", input.agentRuntimeName);
2216
+ }
2217
+ throw error;
2279
2218
  }
2280
- const result = await this.controlApi.createAgentRuntime({
2281
- input: new $AgentRun3.CreateAgentRuntimeInput({
2282
- ...input,
2283
- codeConfiguration: input.codeConfiguration ? new $AgentRun3.CodeConfiguration({
2284
- ...input.codeConfiguration
2285
- }) : void 0,
2286
- containerConfiguration: input.containerConfiguration ? new $AgentRun3.ContainerConfiguration({
2287
- ...input.containerConfiguration
2288
- }) : void 0,
2289
- networkConfiguration: input.networkConfiguration ? new $AgentRun3.NetworkConfiguration({
2290
- networkMode: input.networkConfiguration.networkMode || NetworkMode.PUBLIC,
2291
- securityGroupId: input.networkConfiguration.securityGroupId,
2292
- vpcId: input.networkConfiguration.vpcId,
2293
- vswitchIds: input.networkConfiguration.vSwitchIds
2294
- }) : void 0
2295
- }),
2296
- config: cfg
2297
- });
2298
- return new AgentRuntime(result, cfg);
2299
2219
  };
2300
2220
  /**
2301
2221
  * Delete an Agent Runtime
@@ -2303,29 +2223,36 @@ var init_client = __esm({
2303
2223
  delete = async (params) => {
2304
2224
  const { id, config: config2 } = params;
2305
2225
  const cfg = Config.withConfigs(this.config, config2);
2306
- const endpoints = await this.listEndpoints({
2307
- agentRuntimeId: id,
2308
- config: cfg
2309
- });
2310
- for (const endpoint of endpoints) {
2311
- await endpoint.delete({ config: cfg });
2312
- }
2313
- let remaining = await this.listEndpoints({
2314
- agentRuntimeId: id,
2315
- config: cfg
2316
- });
2317
- while (remaining.length > 0) {
2318
- await new Promise((resolve) => setTimeout(resolve, 1e3));
2319
- remaining = await this.listEndpoints({
2226
+ try {
2227
+ const endpoints = await this.listEndpoints({
2228
+ agentRuntimeId: id,
2229
+ config: cfg
2230
+ });
2231
+ for (const endpoint of endpoints) {
2232
+ await endpoint.delete({ config: cfg });
2233
+ }
2234
+ let remaining = await this.listEndpoints({
2320
2235
  agentRuntimeId: id,
2321
2236
  config: cfg
2322
2237
  });
2238
+ while (remaining.length > 0) {
2239
+ await new Promise((resolve) => setTimeout(resolve, 1e3));
2240
+ remaining = await this.listEndpoints({
2241
+ agentRuntimeId: id,
2242
+ config: cfg
2243
+ });
2244
+ }
2245
+ const result = await this.controlApi.deleteAgentRuntime({
2246
+ agentId: id,
2247
+ config: cfg
2248
+ });
2249
+ return new AgentRuntime(result, cfg);
2250
+ } catch (error) {
2251
+ if (error instanceof HTTPError) {
2252
+ throw error.toResourceError("AgentRuntime", id);
2253
+ }
2254
+ throw error;
2323
2255
  }
2324
- const result = await this.controlApi.deleteAgentRuntime({
2325
- agentId: id,
2326
- config: cfg
2327
- });
2328
- return new AgentRuntime(result, cfg);
2329
2256
  };
2330
2257
  /**
2331
2258
  * Update an Agent Runtime
@@ -2333,20 +2260,27 @@ var init_client = __esm({
2333
2260
  update = async (params) => {
2334
2261
  const { id, input, config: config2 } = params;
2335
2262
  const cfg = Config.withConfigs(this.config, config2);
2336
- const result = await this.controlApi.updateAgentRuntime({
2337
- agentId: id,
2338
- input: new $AgentRun3.UpdateAgentRuntimeInput({
2339
- ...input,
2340
- codeConfiguration: input.codeConfiguration ? new $AgentRun3.CodeConfiguration({
2341
- ...input.codeConfiguration
2342
- }) : void 0,
2343
- containerConfiguration: input.containerConfiguration ? new $AgentRun3.ContainerConfiguration({
2344
- ...input.containerConfiguration
2345
- }) : void 0
2346
- }),
2347
- config: cfg
2348
- });
2349
- return new AgentRuntime(result, cfg);
2263
+ try {
2264
+ const result = await this.controlApi.updateAgentRuntime({
2265
+ agentId: id,
2266
+ input: new $AgentRun3.UpdateAgentRuntimeInput({
2267
+ ...input,
2268
+ codeConfiguration: input.codeConfiguration ? new $AgentRun3.CodeConfiguration({
2269
+ ...input.codeConfiguration
2270
+ }) : void 0,
2271
+ containerConfiguration: input.containerConfiguration ? new $AgentRun3.ContainerConfiguration({
2272
+ ...input.containerConfiguration
2273
+ }) : void 0
2274
+ }),
2275
+ config: cfg
2276
+ });
2277
+ return new AgentRuntime(result, cfg);
2278
+ } catch (error) {
2279
+ if (error instanceof HTTPError) {
2280
+ throw error.toResourceError("AgentRuntime", id);
2281
+ }
2282
+ throw error;
2283
+ }
2350
2284
  };
2351
2285
  /**
2352
2286
  * Get an Agent Runtime
@@ -2354,11 +2288,18 @@ var init_client = __esm({
2354
2288
  get = async (params) => {
2355
2289
  const { id, config: config2 } = params;
2356
2290
  const cfg = Config.withConfigs(this.config, config2);
2357
- const result = await this.controlApi.getAgentRuntime({
2358
- agentId: id,
2359
- config: cfg
2360
- });
2361
- return new AgentRuntime(result, cfg);
2291
+ try {
2292
+ const result = await this.controlApi.getAgentRuntime({
2293
+ agentId: id,
2294
+ config: cfg
2295
+ });
2296
+ return new AgentRuntime(result, cfg);
2297
+ } catch (error) {
2298
+ if (error instanceof HTTPError) {
2299
+ throw error.toResourceError("AgentRuntime", id);
2300
+ }
2301
+ throw error;
2302
+ }
2362
2303
  };
2363
2304
  /**
2364
2305
  * List Agent Runtimes
@@ -2395,16 +2336,26 @@ var init_client = __esm({
2395
2336
  createEndpoint = async (params) => {
2396
2337
  const { agentRuntimeId, input, config: config2 } = params;
2397
2338
  const cfg = Config.withConfigs(this.config, config2);
2398
- const targetVersion = input.targetVersion || "LATEST";
2399
- const result = await this.controlApi.createAgentRuntimeEndpoint({
2400
- agentId: agentRuntimeId,
2401
- input: new $AgentRun3.CreateAgentRuntimeEndpointInput({
2402
- ...input,
2403
- targetVersion
2404
- }),
2405
- config: cfg
2406
- });
2407
- return new AgentRuntimeEndpoint(result, cfg);
2339
+ try {
2340
+ const targetVersion = input.targetVersion || "LATEST";
2341
+ const result = await this.controlApi.createAgentRuntimeEndpoint({
2342
+ agentId: agentRuntimeId,
2343
+ input: new $AgentRun3.CreateAgentRuntimeEndpointInput({
2344
+ ...input,
2345
+ targetVersion
2346
+ }),
2347
+ config: cfg
2348
+ });
2349
+ return new AgentRuntimeEndpoint(result, cfg);
2350
+ } catch (error) {
2351
+ if (error instanceof HTTPError) {
2352
+ throw error.toResourceError(
2353
+ "AgentRuntimeEndpoint",
2354
+ `${agentRuntimeId}/${input.agentRuntimeEndpointName}`
2355
+ );
2356
+ }
2357
+ throw error;
2358
+ }
2408
2359
  };
2409
2360
  /**
2410
2361
  * Delete an endpoint
@@ -2412,12 +2363,22 @@ var init_client = __esm({
2412
2363
  deleteEndpoint = async (params) => {
2413
2364
  const { agentRuntimeId, endpointId, config: config2 } = params;
2414
2365
  const cfg = Config.withConfigs(this.config, config2);
2415
- const result = await this.controlApi.deleteAgentRuntimeEndpoint({
2416
- agentId: agentRuntimeId,
2417
- endpointId,
2418
- config: cfg
2419
- });
2420
- return new AgentRuntimeEndpoint(result, cfg);
2366
+ try {
2367
+ const result = await this.controlApi.deleteAgentRuntimeEndpoint({
2368
+ agentId: agentRuntimeId,
2369
+ endpointId,
2370
+ config: cfg
2371
+ });
2372
+ return new AgentRuntimeEndpoint(result, cfg);
2373
+ } catch (error) {
2374
+ if (error instanceof HTTPError) {
2375
+ throw error.toResourceError(
2376
+ "AgentRuntimeEndpoint",
2377
+ `${agentRuntimeId}/${endpointId}`
2378
+ );
2379
+ }
2380
+ throw error;
2381
+ }
2421
2382
  };
2422
2383
  /**
2423
2384
  * Update an endpoint
@@ -2425,15 +2386,25 @@ var init_client = __esm({
2425
2386
  updateEndpoint = async (params) => {
2426
2387
  const { agentRuntimeId, endpointId, input, config: config2 } = params;
2427
2388
  const cfg = Config.withConfigs(this.config, config2);
2428
- const result = await this.controlApi.updateAgentRuntimeEndpoint({
2429
- agentId: agentRuntimeId,
2430
- endpointId,
2431
- input: new $AgentRun3.UpdateAgentRuntimeEndpointInput({
2432
- ...input
2433
- }),
2434
- config: cfg
2435
- });
2436
- return new AgentRuntimeEndpoint(result, cfg);
2389
+ try {
2390
+ const result = await this.controlApi.updateAgentRuntimeEndpoint({
2391
+ agentId: agentRuntimeId,
2392
+ endpointId,
2393
+ input: new $AgentRun3.UpdateAgentRuntimeEndpointInput({
2394
+ ...input
2395
+ }),
2396
+ config: cfg
2397
+ });
2398
+ return new AgentRuntimeEndpoint(result, cfg);
2399
+ } catch (error) {
2400
+ if (error instanceof HTTPError) {
2401
+ throw error.toResourceError(
2402
+ "AgentRuntimeEndpoint",
2403
+ `${agentRuntimeId}/${endpointId}`
2404
+ );
2405
+ }
2406
+ throw error;
2407
+ }
2437
2408
  };
2438
2409
  /**
2439
2410
  * Get an endpoint
@@ -2441,12 +2412,22 @@ var init_client = __esm({
2441
2412
  getEndpoint = async (params) => {
2442
2413
  const { agentRuntimeId, endpointId, config: config2 } = params;
2443
2414
  const cfg = Config.withConfigs(this.config, config2);
2444
- const result = await this.controlApi.getAgentRuntimeEndpoint({
2445
- agentId: agentRuntimeId,
2446
- endpointId,
2447
- config: cfg
2448
- });
2449
- return new AgentRuntimeEndpoint(result, cfg);
2415
+ try {
2416
+ const result = await this.controlApi.getAgentRuntimeEndpoint({
2417
+ agentId: agentRuntimeId,
2418
+ endpointId,
2419
+ config: cfg
2420
+ });
2421
+ return new AgentRuntimeEndpoint(result, cfg);
2422
+ } catch (error) {
2423
+ if (error instanceof HTTPError) {
2424
+ throw error.toResourceError(
2425
+ "AgentRuntimeEndpoint",
2426
+ `${agentRuntimeId}/${endpointId}`
2427
+ );
2428
+ }
2429
+ throw error;
2430
+ }
2450
2431
  };
2451
2432
  /**
2452
2433
  * List endpoints for an Agent Runtime
@@ -2454,17 +2435,24 @@ var init_client = __esm({
2454
2435
  listEndpoints = async (params) => {
2455
2436
  const { agentRuntimeId, input, config: config2 } = params;
2456
2437
  const cfg = Config.withConfigs(this.config, config2);
2457
- const request = new $AgentRun3.ListAgentRuntimeEndpointsRequest({
2458
- ...input
2459
- });
2460
- const result = await this.controlApi.listAgentRuntimeEndpoints({
2461
- agentId: agentRuntimeId,
2462
- input: request,
2463
- config: cfg
2464
- });
2465
- return (result.items || []).map(
2466
- (item) => new AgentRuntimeEndpoint(item, cfg)
2467
- );
2438
+ try {
2439
+ const request = new $AgentRun3.ListAgentRuntimeEndpointsRequest({
2440
+ ...input
2441
+ });
2442
+ const result = await this.controlApi.listAgentRuntimeEndpoints({
2443
+ agentId: agentRuntimeId,
2444
+ input: request,
2445
+ config: cfg
2446
+ });
2447
+ return (result.items || []).map(
2448
+ (item) => new AgentRuntimeEndpoint(item, cfg)
2449
+ );
2450
+ } catch (error) {
2451
+ if (error instanceof HTTPError) {
2452
+ throw error.toResourceError("AgentRuntime", agentRuntimeId);
2453
+ }
2454
+ throw error;
2455
+ }
2468
2456
  };
2469
2457
  /**
2470
2458
  * List versions for an Agent Runtime
@@ -2796,7 +2784,6 @@ __export(credential_exports, {
2796
2784
  var Credential;
2797
2785
  var init_credential = __esm({
2798
2786
  "src/credential/credential.ts"() {
2799
- init_exception();
2800
2787
  init_resource();
2801
2788
  init_resource();
2802
2789
  init_client2();
@@ -2834,15 +2821,7 @@ var init_credential = __esm({
2834
2821
  const hasInputProp = paramsOrInput && paramsOrInput.input !== void 0;
2835
2822
  const input = hasInputProp ? paramsOrInput.input : paramsOrInput;
2836
2823
  const config2 = hasInputProp ? paramsOrInput.config : void 0;
2837
- const client = _Credential.getClient();
2838
- try {
2839
- return await client.create({ input, config: config2 });
2840
- } catch (error) {
2841
- if (error instanceof HTTPError) {
2842
- throw error.toResourceError("Credential", input.credentialName || "");
2843
- }
2844
- throw error;
2845
- }
2824
+ return await _Credential.getClient().create({ input, config: config2 });
2846
2825
  };
2847
2826
  /**
2848
2827
  * Delete a Credential by name
@@ -2851,15 +2830,7 @@ var init_credential = __esm({
2851
2830
  const isString = typeof paramsOrName === "string";
2852
2831
  const name = isString ? paramsOrName : paramsOrName.name;
2853
2832
  const config2 = isString ? void 0 : paramsOrName.config;
2854
- const client = _Credential.getClient();
2855
- try {
2856
- return await client.delete({ name, config: config2 });
2857
- } catch (error) {
2858
- if (error instanceof HTTPError) {
2859
- throw error.toResourceError("Credential", name);
2860
- }
2861
- throw error;
2862
- }
2833
+ return await _Credential.getClient().delete({ name, config: config2 });
2863
2834
  };
2864
2835
  /**
2865
2836
  * Update a Credential by name
@@ -2868,15 +2839,7 @@ var init_credential = __esm({
2868
2839
  const name = paramsOrName.name;
2869
2840
  const input = paramsOrName.input;
2870
2841
  const config2 = paramsOrName.config;
2871
- const client = _Credential.getClient();
2872
- try {
2873
- return await client.update({ name, input, config: config2 });
2874
- } catch (error) {
2875
- if (error instanceof HTTPError) {
2876
- throw error.toResourceError("Credential", name);
2877
- }
2878
- throw error;
2879
- }
2842
+ return await _Credential.getClient().update({ name, input, config: config2 });
2880
2843
  };
2881
2844
  /**
2882
2845
  * Get a Credential by name
@@ -2885,15 +2848,7 @@ var init_credential = __esm({
2885
2848
  const isString = typeof paramsOrName === "string";
2886
2849
  const name = isString ? paramsOrName : paramsOrName.name;
2887
2850
  const config2 = isString ? void 0 : paramsOrName.config;
2888
- const client = _Credential.getClient();
2889
- try {
2890
- return await client.get({ name, config: config2 });
2891
- } catch (error) {
2892
- if (error instanceof HTTPError) {
2893
- throw error.toResourceError("Credential", name);
2894
- }
2895
- throw error;
2896
- }
2851
+ return await _Credential.getClient().get({ name, config: config2 });
2897
2852
  };
2898
2853
  /**
2899
2854
  * List all Credentials (with pagination)
@@ -2901,15 +2856,7 @@ var init_credential = __esm({
2901
2856
  static list = async (paramsOrUndefined) => {
2902
2857
  const input = paramsOrUndefined?.input ?? paramsOrUndefined;
2903
2858
  const config2 = paramsOrUndefined?.config;
2904
- const client = _Credential.getClient();
2905
- try {
2906
- return await client.list({ input, config: config2 });
2907
- } catch (error) {
2908
- if (error instanceof HTTPError) {
2909
- throw error.toResourceError("Credential", "list");
2910
- }
2911
- throw error;
2912
- }
2859
+ return await _Credential.getClient().list({ input, config: config2 });
2913
2860
  };
2914
2861
  static listAll = listAllResourcesFunction(this.list);
2915
2862
  /**
@@ -3089,7 +3036,6 @@ var init_client2 = __esm({
3089
3036
  "src/credential/client.ts"() {
3090
3037
  init_utils();
3091
3038
  init_config();
3092
- init_model();
3093
3039
  init_control2();
3094
3040
  init_credential();
3095
3041
  init_model3();
@@ -3139,8 +3085,7 @@ var init_client2 = __esm({
3139
3085
  input: new $AgentRun3.CreateCredentialInput(normalized),
3140
3086
  config: cfg
3141
3087
  });
3142
- const credential = fromInnerObject(result);
3143
- return new Credential(credential);
3088
+ return new Credential(result);
3144
3089
  } catch (error) {
3145
3090
  if (error instanceof HTTPError) {
3146
3091
  throw error.toResourceError(
@@ -3162,8 +3107,7 @@ var init_client2 = __esm({
3162
3107
  credentialName: name,
3163
3108
  config: cfg
3164
3109
  });
3165
- const credential = fromInnerObject(result);
3166
- return new Credential(credential);
3110
+ return new Credential(result);
3167
3111
  } catch (error) {
3168
3112
  if (error instanceof HTTPError) {
3169
3113
  throw error.toResourceError("Credential", params?.name);
@@ -4139,7 +4083,6 @@ var Sandbox;
4139
4083
  var init_sandbox = __esm({
4140
4084
  "src/sandbox/sandbox.ts"() {
4141
4085
  init_config();
4142
- init_exception();
4143
4086
  init_resource();
4144
4087
  init_model4();
4145
4088
  Sandbox = class _Sandbox extends ResourceBase {
@@ -4239,88 +4182,34 @@ var init_sandbox = __esm({
4239
4182
  * 创建新沙箱 / Create a New Sandbox
4240
4183
  */
4241
4184
  static async create(input, config2) {
4242
- try {
4243
- const client = _Sandbox.getClient();
4244
- return await client.createSandbox({ input, config: config2 });
4245
- } catch (error) {
4246
- if (error instanceof HTTPError) {
4247
- throw error.toResourceError("Sandbox", input.templateName);
4248
- }
4249
- _Sandbox.handleError(error);
4250
- }
4185
+ return await _Sandbox.getClient().createSandbox({ input, config: config2 });
4251
4186
  }
4252
4187
  /**
4253
4188
  * Delete a Sandbox by ID
4254
4189
  */
4255
4190
  static async delete(params) {
4256
4191
  const { id, config: config2 } = params;
4257
- try {
4258
- const client = _Sandbox.getClient();
4259
- return await client.deleteSandbox({ id, config: config2 });
4260
- } catch (error) {
4261
- if (error instanceof HTTPError) {
4262
- throw error.toResourceError("Sandbox", id);
4263
- }
4264
- _Sandbox.handleError(error);
4265
- }
4192
+ return await _Sandbox.getClient().deleteSandbox({ id, config: config2 });
4266
4193
  }
4267
4194
  /**
4268
4195
  * Stop a Sandbox by ID
4269
4196
  */
4270
4197
  static async stop(params) {
4271
4198
  const { id, config: config2 } = params;
4272
- try {
4273
- const client = _Sandbox.getClient();
4274
- return await client.stopSandbox({ id, config: config2 });
4275
- } catch (error) {
4276
- if (error instanceof HTTPError) {
4277
- throw error.toResourceError("Sandbox", id);
4278
- }
4279
- _Sandbox.handleError(error);
4280
- }
4199
+ return await _Sandbox.getClient().stopSandbox({ id, config: config2 });
4281
4200
  }
4282
4201
  /**
4283
4202
  * Get a Sandbox by ID
4284
4203
  */
4285
4204
  static async get(params) {
4286
4205
  const { id, templateType, config: config2 } = params;
4287
- try {
4288
- const client = _Sandbox.getClient();
4289
- return await client.getSandbox({ id, templateType, config: config2 });
4290
- } catch (error) {
4291
- if (error instanceof HTTPError) {
4292
- throw error.toResourceError("Sandbox", id);
4293
- }
4294
- _Sandbox.handleError(error);
4295
- }
4206
+ return await _Sandbox.getClient().getSandbox({ id, templateType, config: config2 });
4296
4207
  }
4297
4208
  /**
4298
4209
  * List Sandboxes
4299
- */
4300
- static async list(input, config2) {
4301
- try {
4302
- const client = _Sandbox.getClient();
4303
- return await client.listSandboxes({ input, config: config2 });
4304
- } catch (error) {
4305
- _Sandbox.handleError(error);
4306
- }
4307
- }
4308
- /**
4309
- * Handle API errors
4310
- */
4311
- static handleError(error) {
4312
- if (error && typeof error === "object" && "statusCode" in error) {
4313
- const e = error;
4314
- const statusCode = e.statusCode;
4315
- const message = e.message || "Unknown error";
4316
- const requestId = e.data?.requestId;
4317
- if (statusCode >= 400 && statusCode < 500) {
4318
- throw new ClientError(statusCode, message, { requestId });
4319
- } else if (statusCode >= 500) {
4320
- throw new ServerError(statusCode, message, { requestId });
4321
- }
4322
- }
4323
- throw error;
4210
+ */
4211
+ static async list(input, config2) {
4212
+ return await _Sandbox.getClient().listSandboxes({ input, config: config2 });
4324
4213
  }
4325
4214
  get = async (params) => {
4326
4215
  const { config: config2 } = params ?? {};
@@ -5067,7 +4956,6 @@ var init_code_interpreter_sandbox = __esm({
5067
4956
  var Template;
5068
4957
  var init_template = __esm({
5069
4958
  "src/sandbox/template.ts"() {
5070
- init_exception();
5071
4959
  init_resource();
5072
4960
  Template = class _Template extends ResourceBase {
5073
4961
  /**
@@ -5156,94 +5044,40 @@ var init_template = __esm({
5156
5044
  */
5157
5045
  static async create(params) {
5158
5046
  const { input, config: config2 } = params;
5159
- try {
5160
- const client = _Template.getClient();
5161
- return await client.createTemplate({ input, config: config2 });
5162
- } catch (error) {
5163
- if (error instanceof HTTPError) {
5164
- throw error.toResourceError("Template", input.templateName);
5165
- }
5166
- _Template.handleError(error);
5167
- }
5047
+ return await _Template.getClient().createTemplate({ input, config: config2 });
5168
5048
  }
5169
5049
  /**
5170
5050
  * Delete a Template by name
5171
5051
  */
5172
5052
  static async delete(params) {
5173
5053
  const { name, config: config2 } = params;
5174
- try {
5175
- const client = _Template.getClient();
5176
- return await client.deleteTemplate({ name, config: config2 });
5177
- } catch (error) {
5178
- if (error instanceof HTTPError) {
5179
- throw error.toResourceError("Template", name);
5180
- }
5181
- _Template.handleError(error);
5182
- }
5054
+ return await _Template.getClient().deleteTemplate({ name, config: config2 });
5183
5055
  }
5184
5056
  /**
5185
5057
  * Update a Template by name
5186
5058
  */
5187
5059
  static async update(params) {
5188
5060
  const { name, input, config: config2 } = params;
5189
- try {
5190
- const client = _Template.getClient();
5191
- return await client.updateTemplate({ name, input, config: config2 });
5192
- } catch (error) {
5193
- if (error instanceof HTTPError) {
5194
- throw error.toResourceError("Template", name);
5195
- }
5196
- _Template.handleError(error);
5197
- }
5061
+ return await _Template.getClient().updateTemplate({ name, input, config: config2 });
5198
5062
  }
5199
5063
  /**
5200
5064
  * Get a Template by name
5201
5065
  */
5202
5066
  static async get(params) {
5203
5067
  const { name, config: config2 } = params;
5204
- try {
5205
- const client = _Template.getClient();
5206
- return await client.getTemplate({ name, config: config2 });
5207
- } catch (error) {
5208
- if (error instanceof HTTPError) {
5209
- throw error.toResourceError("Template", name);
5210
- }
5211
- _Template.handleError(error);
5212
- }
5068
+ return await _Template.getClient().getTemplate({ name, config: config2 });
5213
5069
  }
5214
5070
  /**
5215
5071
  * List Templates
5216
5072
  */
5217
5073
  static async list(params) {
5218
5074
  const { input, config: config2 } = params ?? {};
5219
- try {
5220
- const client = _Template.getClient();
5221
- return await client.listTemplates({ input, config: config2 });
5222
- } catch (error) {
5223
- _Template.handleError(error);
5224
- }
5075
+ return await _Template.getClient().listTemplates({ input, config: config2 });
5225
5076
  }
5226
5077
  /**
5227
5078
  * List all Templates (with pagination)
5228
5079
  */
5229
5080
  static listAll = listAllResourcesFunction(this.list);
5230
- /**
5231
- * Handle API errors
5232
- */
5233
- static handleError(error) {
5234
- if (error && typeof error === "object" && "statusCode" in error) {
5235
- const e = error;
5236
- const statusCode = e.statusCode;
5237
- const message = e.message || "Unknown error";
5238
- const requestId = e.data?.requestId;
5239
- if (statusCode >= 400 && statusCode < 500) {
5240
- throw new ClientError(statusCode, message, { requestId });
5241
- } else if (statusCode >= 500) {
5242
- throw new ServerError(statusCode, message, { requestId });
5243
- }
5244
- }
5245
- throw error;
5246
- }
5247
5081
  get = async (params = {}) => {
5248
5082
  return await _Template.get({
5249
5083
  name: this.templateName,
@@ -5697,6 +5531,7 @@ var SandboxClient;
5697
5531
  var init_client3 = __esm({
5698
5532
  "src/sandbox/client.ts"() {
5699
5533
  init_config();
5534
+ init_exception();
5700
5535
  init_control3();
5701
5536
  init_browser_sandbox();
5702
5537
  init_code_interpreter_sandbox();
@@ -5717,17 +5552,24 @@ var init_client3 = __esm({
5717
5552
  createTemplate = async (params) => {
5718
5553
  const { input, config: config2 } = params;
5719
5554
  const cfg = Config.withConfigs(this.config, config2);
5720
- const finalInput = this.prepareTemplateCreateInput(input);
5721
- const result = await this.controlApi.createTemplate({
5722
- input: new $AgentRun3.CreateTemplateInput({
5723
- ...finalInput,
5724
- networkConfiguration: finalInput.networkConfiguration ? new $AgentRun3.NetworkConfiguration({
5725
- ...finalInput.networkConfiguration
5726
- }) : void 0
5727
- }),
5728
- config: cfg
5729
- });
5730
- return new Template(result, cfg);
5555
+ try {
5556
+ const finalInput = this.prepareTemplateCreateInput(input);
5557
+ const result = await this.controlApi.createTemplate({
5558
+ input: new $AgentRun3.CreateTemplateInput({
5559
+ ...finalInput,
5560
+ networkConfiguration: finalInput.networkConfiguration ? new $AgentRun3.NetworkConfiguration({
5561
+ ...finalInput.networkConfiguration
5562
+ }) : void 0
5563
+ }),
5564
+ config: cfg
5565
+ });
5566
+ return new Template(result, cfg);
5567
+ } catch (error) {
5568
+ if (error instanceof HTTPError) {
5569
+ throw error.toResourceError("Template", input.templateName);
5570
+ }
5571
+ throw error;
5572
+ }
5731
5573
  };
5732
5574
  /**
5733
5575
  * Delete a Template
@@ -5735,11 +5577,18 @@ var init_client3 = __esm({
5735
5577
  deleteTemplate = async (params) => {
5736
5578
  const { name, config: config2 } = params;
5737
5579
  const cfg = Config.withConfigs(this.config, config2);
5738
- const result = await this.controlApi.deleteTemplate({
5739
- templateName: name,
5740
- config: cfg
5741
- });
5742
- return new Template(result, cfg);
5580
+ try {
5581
+ const result = await this.controlApi.deleteTemplate({
5582
+ templateName: name,
5583
+ config: cfg
5584
+ });
5585
+ return new Template(result, cfg);
5586
+ } catch (error) {
5587
+ if (error instanceof HTTPError) {
5588
+ throw error.toResourceError("Template", name);
5589
+ }
5590
+ throw error;
5591
+ }
5743
5592
  };
5744
5593
  /**
5745
5594
  * Update a Template
@@ -5747,17 +5596,24 @@ var init_client3 = __esm({
5747
5596
  updateTemplate = async (params) => {
5748
5597
  const { name, input, config: config2 } = params;
5749
5598
  const cfg = Config.withConfigs(this.config, config2);
5750
- const result = await this.controlApi.updateTemplate({
5751
- templateName: name,
5752
- input: new $AgentRun3.UpdateTemplateInput({
5753
- ...input,
5754
- networkConfiguration: input.networkConfiguration ? new $AgentRun3.NetworkConfiguration({
5755
- ...input.networkConfiguration
5756
- }) : void 0
5757
- }),
5758
- config: cfg
5759
- });
5760
- return new Template(result, cfg);
5599
+ try {
5600
+ const result = await this.controlApi.updateTemplate({
5601
+ templateName: name,
5602
+ input: new $AgentRun3.UpdateTemplateInput({
5603
+ ...input,
5604
+ networkConfiguration: input.networkConfiguration ? new $AgentRun3.NetworkConfiguration({
5605
+ ...input.networkConfiguration
5606
+ }) : void 0
5607
+ }),
5608
+ config: cfg
5609
+ });
5610
+ return new Template(result, cfg);
5611
+ } catch (error) {
5612
+ if (error instanceof HTTPError) {
5613
+ throw error.toResourceError("Template", name);
5614
+ }
5615
+ throw error;
5616
+ }
5761
5617
  };
5762
5618
  /**
5763
5619
  * Get a Template
@@ -5765,11 +5621,18 @@ var init_client3 = __esm({
5765
5621
  getTemplate = async (params) => {
5766
5622
  const { name, config: config2 } = params;
5767
5623
  const cfg = Config.withConfigs(this.config, config2);
5768
- const result = await this.controlApi.getTemplate({
5769
- templateName: name,
5770
- config: cfg
5771
- });
5772
- return new Template(result, cfg);
5624
+ try {
5625
+ const result = await this.controlApi.getTemplate({
5626
+ templateName: name,
5627
+ config: cfg
5628
+ });
5629
+ return new Template(result, cfg);
5630
+ } catch (error) {
5631
+ if (error instanceof HTTPError) {
5632
+ throw error.toResourceError("Template", name);
5633
+ }
5634
+ throw error;
5635
+ }
5773
5636
  };
5774
5637
  /**
5775
5638
  * List Templates
@@ -5793,13 +5656,20 @@ var init_client3 = __esm({
5793
5656
  createSandbox = async (params) => {
5794
5657
  const { input, config: config2 } = params;
5795
5658
  const cfg = Config.withConfigs(this.config, config2);
5796
- const result = await this.controlApi.createSandbox({
5797
- input: new $AgentRun3.CreateSandboxInput({
5798
- ...input
5799
- }),
5800
- config: cfg
5801
- });
5802
- return Sandbox.fromInnerObject(result, cfg);
5659
+ try {
5660
+ const result = await this.controlApi.createSandbox({
5661
+ input: new $AgentRun3.CreateSandboxInput({
5662
+ ...input
5663
+ }),
5664
+ config: cfg
5665
+ });
5666
+ return Sandbox.fromInnerObject(result, cfg);
5667
+ } catch (error) {
5668
+ if (error instanceof HTTPError) {
5669
+ throw error.toResourceError("Sandbox", input.templateName);
5670
+ }
5671
+ throw error;
5672
+ }
5803
5673
  };
5804
5674
  /**
5805
5675
  * Create a Code Interpreter Sandbox
@@ -5831,11 +5701,18 @@ var init_client3 = __esm({
5831
5701
  deleteSandbox = async (params) => {
5832
5702
  const { id, config: config2 } = params;
5833
5703
  const cfg = Config.withConfigs(this.config, config2);
5834
- const result = await this.controlApi.deleteSandbox({
5835
- sandboxId: id,
5836
- config: cfg
5837
- });
5838
- return Sandbox.fromInnerObject(result, cfg);
5704
+ try {
5705
+ const result = await this.controlApi.deleteSandbox({
5706
+ sandboxId: id,
5707
+ config: cfg
5708
+ });
5709
+ return Sandbox.fromInnerObject(result, cfg);
5710
+ } catch (error) {
5711
+ if (error instanceof HTTPError) {
5712
+ throw error.toResourceError("Sandbox", id);
5713
+ }
5714
+ throw error;
5715
+ }
5839
5716
  };
5840
5717
  /**
5841
5718
  * Stop a Sandbox
@@ -5843,11 +5720,18 @@ var init_client3 = __esm({
5843
5720
  stopSandbox = async (params) => {
5844
5721
  const { id, config: config2 } = params;
5845
5722
  const cfg = Config.withConfigs(this.config, config2);
5846
- const result = await this.controlApi.stopSandbox({
5847
- sandboxId: id,
5848
- config: cfg
5849
- });
5850
- return Sandbox.fromInnerObject(result, cfg);
5723
+ try {
5724
+ const result = await this.controlApi.stopSandbox({
5725
+ sandboxId: id,
5726
+ config: cfg
5727
+ });
5728
+ return Sandbox.fromInnerObject(result, cfg);
5729
+ } catch (error) {
5730
+ if (error instanceof HTTPError) {
5731
+ throw error.toResourceError("Sandbox", id);
5732
+ }
5733
+ throw error;
5734
+ }
5851
5735
  };
5852
5736
  /**
5853
5737
  * Get a Sandbox
@@ -5859,26 +5743,33 @@ var init_client3 = __esm({
5859
5743
  getSandbox = async (params) => {
5860
5744
  const { id, templateType, config: config2 } = params;
5861
5745
  const cfg = Config.withConfigs(this.config, config2);
5862
- const result = await this.controlApi.getSandbox({
5863
- sandboxId: id,
5864
- config: cfg
5865
- });
5866
- const baseSandbox = Sandbox.fromInnerObject(result, cfg);
5867
- if (templateType) {
5868
- switch (templateType) {
5869
- case "CodeInterpreter" /* CODE_INTERPRETER */: {
5870
- return new CodeInterpreterSandbox(baseSandbox, cfg);
5871
- }
5872
- case "Browser" /* BROWSER */: {
5873
- return new BrowserSandbox(baseSandbox, cfg);
5874
- }
5875
- case "AllInOne" /* AIO */: {
5876
- const { AioSandbox: AioSandbox2 } = await Promise.resolve().then(() => (init_aio_sandbox(), aio_sandbox_exports));
5877
- return new AioSandbox2(baseSandbox, cfg);
5746
+ try {
5747
+ const result = await this.controlApi.getSandbox({
5748
+ sandboxId: id,
5749
+ config: cfg
5750
+ });
5751
+ const baseSandbox = Sandbox.fromInnerObject(result, cfg);
5752
+ if (templateType) {
5753
+ switch (templateType) {
5754
+ case "CodeInterpreter" /* CODE_INTERPRETER */: {
5755
+ return new CodeInterpreterSandbox(baseSandbox, cfg);
5756
+ }
5757
+ case "Browser" /* BROWSER */: {
5758
+ return new BrowserSandbox(baseSandbox, cfg);
5759
+ }
5760
+ case "AllInOne" /* AIO */: {
5761
+ const { AioSandbox: AioSandbox2 } = await Promise.resolve().then(() => (init_aio_sandbox(), aio_sandbox_exports));
5762
+ return new AioSandbox2(baseSandbox, cfg);
5763
+ }
5878
5764
  }
5879
5765
  }
5766
+ return baseSandbox;
5767
+ } catch (error) {
5768
+ if (error instanceof HTTPError) {
5769
+ throw error.toResourceError("Sandbox", id);
5770
+ }
5771
+ throw error;
5880
5772
  }
5881
- return baseSandbox;
5882
5773
  };
5883
5774
  /**
5884
5775
  * List Sandboxes
@@ -8143,7 +8034,6 @@ var ToolSet;
8143
8034
  var init_toolset = __esm({
8144
8035
  "src/toolset/toolset.ts"() {
8145
8036
  init_config();
8146
- init_exception();
8147
8037
  init_log();
8148
8038
  init_resource();
8149
8039
  ToolSet = class _ToolSet {
@@ -8175,56 +8065,27 @@ var init_toolset = __esm({
8175
8065
  */
8176
8066
  static async create(params) {
8177
8067
  const { input, config: config2 } = params;
8178
- try {
8179
- const client = _ToolSet.getClient();
8180
- return await client.create({ input, config: config2 });
8181
- } catch (error) {
8182
- if (error instanceof HTTPError) {
8183
- throw error.toResourceError("ToolSet", input.name);
8184
- }
8185
- _ToolSet.handleError(error);
8186
- }
8068
+ return await _ToolSet.getClient().create({ input, config: config2 });
8187
8069
  }
8188
8070
  /**
8189
8071
  * Delete a ToolSet by Name
8190
8072
  */
8191
8073
  static async delete(params) {
8192
8074
  const { name, config: config2 } = params;
8193
- try {
8194
- const client = _ToolSet.getClient();
8195
- return await client.delete({ name, config: config2 });
8196
- } catch (error) {
8197
- if (error instanceof HTTPError) {
8198
- throw error.toResourceError("ToolSet", name);
8199
- }
8200
- _ToolSet.handleError(error);
8201
- }
8075
+ return await _ToolSet.getClient().delete({ name, config: config2 });
8202
8076
  }
8203
8077
  /**
8204
8078
  * Get a ToolSet by Name
8205
8079
  */
8206
8080
  static async get(params) {
8207
8081
  const { name, config: config2 } = params;
8208
- try {
8209
- const client = _ToolSet.getClient();
8210
- return await client.get({ name, config: config2 });
8211
- } catch (error) {
8212
- if (error instanceof HTTPError) {
8213
- throw error.toResourceError("ToolSet", name);
8214
- }
8215
- _ToolSet.handleError(error);
8216
- }
8082
+ return await _ToolSet.getClient().get({ name, config: config2 });
8217
8083
  }
8218
8084
  /**
8219
8085
  * List ToolSets
8220
8086
  */
8221
8087
  static async list(input, config2) {
8222
- try {
8223
- const client = _ToolSet.getClient();
8224
- return await client.list({ input, config: config2 });
8225
- } catch (error) {
8226
- _ToolSet.handleError(error);
8227
- }
8088
+ return await _ToolSet.getClient().list({ input, config: config2 });
8228
8089
  }
8229
8090
  /**
8230
8091
  * List all ToolSets with pagination
@@ -8260,32 +8121,7 @@ var init_toolset = __esm({
8260
8121
  */
8261
8122
  static async update(params) {
8262
8123
  const { name, input, config: config2 } = params;
8263
- try {
8264
- const client = _ToolSet.getClient();
8265
- return await client.update({ name, input, config: config2 });
8266
- } catch (error) {
8267
- if (error instanceof HTTPError) {
8268
- throw error.toResourceError("ToolSet", name);
8269
- }
8270
- _ToolSet.handleError(error);
8271
- }
8272
- }
8273
- /**
8274
- * Handle API errors
8275
- */
8276
- static handleError(error) {
8277
- if (error && typeof error === "object" && "statusCode" in error) {
8278
- const e = error;
8279
- const statusCode = e.statusCode;
8280
- const message = e.message || "Unknown error";
8281
- const requestId = e.data?.requestId;
8282
- if (statusCode >= 400 && statusCode < 500) {
8283
- throw new ClientError(statusCode, message, { requestId });
8284
- } else if (statusCode >= 500) {
8285
- throw new ServerError(statusCode, message, { requestId });
8286
- }
8287
- }
8288
- throw error;
8124
+ return await _ToolSet.getClient().update({ name, input, config: config2 });
8289
8125
  }
8290
8126
  /**
8291
8127
  * Delete this toolset
@@ -8490,6 +8326,7 @@ var ToolSetClient;
8490
8326
  var init_client5 = __esm({
8491
8327
  "src/toolset/client.ts"() {
8492
8328
  init_config();
8329
+ init_exception();
8493
8330
  init_api();
8494
8331
  init_toolset();
8495
8332
  ToolSetClient = class {
@@ -8505,31 +8342,38 @@ var init_client5 = __esm({
8505
8342
  create = async (params) => {
8506
8343
  const { input, config: config2 } = params;
8507
8344
  const cfg = Config.withConfigs(this.config, config2);
8508
- const authConfig = input.spec?.authConfig ? new Authorization({
8509
- type: input.spec.authConfig.type,
8510
- parameters: new AuthorizationParameters({
8511
- apiKeyParameter: new APIKeyAuthParameter({
8512
- key: input.spec.authConfig.apiKeyHeaderName,
8513
- value: input.spec.authConfig.apiKeyValue,
8514
- in: "header"
8345
+ try {
8346
+ const authConfig = input.spec?.authConfig ? new Authorization({
8347
+ type: input.spec.authConfig.type,
8348
+ parameters: new AuthorizationParameters({
8349
+ apiKeyParameter: new APIKeyAuthParameter({
8350
+ key: input.spec.authConfig.apiKeyHeaderName,
8351
+ value: input.spec.authConfig.apiKeyValue,
8352
+ in: "header"
8353
+ })
8515
8354
  })
8516
- })
8517
- }) : void 0;
8518
- const request = new Toolset({
8519
- ...input,
8520
- spec: input.spec ? new ToolsetSpec({
8521
- ...input.spec,
8522
- schema: input.spec.schema ? new ToolsetSchema({
8523
- ...input.spec.schema
8524
- }) : void 0,
8525
- authConfig
8526
- }) : void 0
8527
- });
8528
- const result = await this.controlApi.createToolset({
8529
- input: request,
8530
- config: cfg
8531
- });
8532
- return new ToolSet(result, cfg);
8355
+ }) : void 0;
8356
+ const request = new Toolset({
8357
+ ...input,
8358
+ spec: input.spec ? new ToolsetSpec({
8359
+ ...input.spec,
8360
+ schema: input.spec.schema ? new ToolsetSchema({
8361
+ ...input.spec.schema
8362
+ }) : void 0,
8363
+ authConfig
8364
+ }) : void 0
8365
+ });
8366
+ const result = await this.controlApi.createToolset({
8367
+ input: request,
8368
+ config: cfg
8369
+ });
8370
+ return new ToolSet(result, cfg);
8371
+ } catch (error) {
8372
+ if (error instanceof HTTPError) {
8373
+ throw error.toResourceError("ToolSet", input.name);
8374
+ }
8375
+ throw error;
8376
+ }
8533
8377
  };
8534
8378
  /**
8535
8379
  * Delete a ToolSet by name
@@ -8537,11 +8381,18 @@ var init_client5 = __esm({
8537
8381
  delete = async (params) => {
8538
8382
  const { name, config: config2 } = params;
8539
8383
  const cfg = Config.withConfigs(this.config, config2);
8540
- const result = await this.controlApi.deleteToolset({
8541
- name,
8542
- config: cfg
8543
- });
8544
- return new ToolSet(result, cfg);
8384
+ try {
8385
+ const result = await this.controlApi.deleteToolset({
8386
+ name,
8387
+ config: cfg
8388
+ });
8389
+ return new ToolSet(result, cfg);
8390
+ } catch (error) {
8391
+ if (error instanceof HTTPError) {
8392
+ throw error.toResourceError("ToolSet", name);
8393
+ }
8394
+ throw error;
8395
+ }
8545
8396
  };
8546
8397
  /**
8547
8398
  * Update a ToolSet by name
@@ -8549,55 +8400,59 @@ var init_client5 = __esm({
8549
8400
  update = async (params) => {
8550
8401
  const { name, input, config: config2 } = params;
8551
8402
  const cfg = Config.withConfigs(this.config, config2);
8552
- const authConfig = input.spec?.authConfig ? new Authorization({
8553
- type: input.spec.authConfig.type,
8554
- parameters: new AuthorizationParameters({
8555
- apiKeyParameter: new APIKeyAuthParameter({
8556
- key: input.spec.authConfig.apiKeyHeaderName,
8557
- value: input.spec.authConfig.apiKeyValue,
8558
- in: "header"
8403
+ try {
8404
+ const authConfig = input.spec?.authConfig ? new Authorization({
8405
+ type: input.spec.authConfig.type,
8406
+ parameters: new AuthorizationParameters({
8407
+ apiKeyParameter: new APIKeyAuthParameter({
8408
+ key: input.spec.authConfig.apiKeyHeaderName,
8409
+ value: input.spec.authConfig.apiKeyValue,
8410
+ in: "header"
8411
+ })
8559
8412
  })
8560
- })
8561
- }) : void 0;
8562
- const request = new Toolset({
8563
- name,
8564
- ...input,
8565
- spec: input.spec ? new ToolsetSpec({
8566
- ...input.spec,
8567
- schema: input.spec.schema ? new ToolsetSchema({
8568
- ...input.spec.schema
8569
- }) : void 0,
8570
- authConfig
8571
- }) : void 0
8572
- });
8573
- const result = await this.controlApi.updateToolset({
8574
- name,
8575
- input: request,
8576
- config: cfg
8577
- });
8578
- return new ToolSet(result, cfg);
8413
+ }) : void 0;
8414
+ const request = new Toolset({
8415
+ name,
8416
+ ...input,
8417
+ spec: input.spec ? new ToolsetSpec({
8418
+ ...input.spec,
8419
+ schema: input.spec.schema ? new ToolsetSchema({
8420
+ ...input.spec.schema
8421
+ }) : void 0,
8422
+ authConfig
8423
+ }) : void 0
8424
+ });
8425
+ const result = await this.controlApi.updateToolset({
8426
+ name,
8427
+ input: request,
8428
+ config: cfg
8429
+ });
8430
+ return new ToolSet(result, cfg);
8431
+ } catch (error) {
8432
+ if (error instanceof HTTPError) {
8433
+ throw error.toResourceError("ToolSet", name);
8434
+ }
8435
+ throw error;
8436
+ }
8579
8437
  };
8580
- // /**
8581
- // * Delete a ToolSet by name
8582
- // */
8583
- // deleteToolSet = async (params: {
8584
- // name: string;
8585
- // config?: Config;
8586
- // }): Promise<ToolSet> => {
8587
- // const { name, config } = params;
8588
- // return ToolSet.delete({ name, config: config ?? this.config });
8589
- // };
8590
8438
  /**
8591
8439
  * Get a ToolSet by name
8592
8440
  */
8593
8441
  get = async (params) => {
8594
8442
  const { name, config: config2 } = params;
8595
8443
  const cfg = Config.withConfigs(this.config, config2);
8596
- const result = await this.controlApi.getToolset({
8597
- name,
8598
- config: cfg
8599
- });
8600
- return new ToolSet(result, cfg);
8444
+ try {
8445
+ const result = await this.controlApi.getToolset({
8446
+ name,
8447
+ config: cfg
8448
+ });
8449
+ return new ToolSet(result, cfg);
8450
+ } catch (error) {
8451
+ if (error instanceof HTTPError) {
8452
+ throw error.toResourceError("ToolSet", name);
8453
+ }
8454
+ throw error;
8455
+ }
8601
8456
  };
8602
8457
  /**
8603
8458
  * List ToolSets