@agentrun/sdk 0.0.3 → 0.0.4

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.
Files changed (130) hide show
  1. package/README.md +20 -15
  2. package/dist/agent-runtime/api/index.cjs +907 -0
  3. package/dist/agent-runtime/api/index.cjs.map +1 -0
  4. package/dist/agent-runtime/api/index.d.cts +193 -0
  5. package/dist/agent-runtime/api/index.d.ts +193 -0
  6. package/dist/agent-runtime/api/index.js +882 -0
  7. package/dist/agent-runtime/api/index.js.map +1 -0
  8. package/dist/agent-runtime/index.cjs +2528 -0
  9. package/dist/agent-runtime/index.cjs.map +1 -0
  10. package/dist/agent-runtime/index.d.cts +778 -0
  11. package/dist/agent-runtime/index.d.ts +778 -0
  12. package/dist/agent-runtime/index.js +2496 -0
  13. package/dist/agent-runtime/index.js.map +1 -0
  14. package/dist/base-K1GMfJbH.d.ts +59 -0
  15. package/dist/base-xcWt5bua.d.cts +59 -0
  16. package/dist/client-DHXxjuo3.d.ts +58 -0
  17. package/dist/client-DPUTs69s.d.cts +58 -0
  18. package/dist/config-07gMelJP.d.cts +125 -0
  19. package/dist/config-07gMelJP.d.ts +125 -0
  20. package/dist/control-api-BWD4eua5.d.cts +27 -0
  21. package/dist/control-api-d-82Sgpr.d.ts +27 -0
  22. package/dist/credential/api/index.cjs +655 -0
  23. package/dist/credential/api/index.cjs.map +1 -0
  24. package/dist/credential/api/index.d.cts +93 -0
  25. package/dist/credential/api/index.d.ts +93 -0
  26. package/dist/credential/api/index.js +630 -0
  27. package/dist/credential/api/index.js.map +1 -0
  28. package/dist/credential/index.cjs +1286 -0
  29. package/dist/credential/index.cjs.map +1 -0
  30. package/dist/credential/index.d.cts +246 -0
  31. package/dist/credential/index.d.ts +246 -0
  32. package/dist/credential/index.js +1263 -0
  33. package/dist/credential/index.js.map +1 -0
  34. package/dist/data-api-B-4h9_Vf.d.ts +166 -0
  35. package/dist/data-api-DsG-8JRQ.d.cts +166 -0
  36. package/dist/exception-DM9H2Rpo.d.cts +68 -0
  37. package/dist/exception-DM9H2Rpo.d.ts +68 -0
  38. package/dist/index.cjs +29281 -1427
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.d.cts +38 -4485
  41. package/dist/index.d.ts +38 -4485
  42. package/dist/index.js +29259 -1426
  43. package/dist/index.js.map +1 -1
  44. package/dist/integration/builtin/index.cjs +9399 -0
  45. package/dist/integration/builtin/index.cjs.map +1 -0
  46. package/dist/integration/builtin/index.d.cts +692 -0
  47. package/dist/integration/builtin/index.d.ts +692 -0
  48. package/dist/integration/builtin/index.js +9363 -0
  49. package/dist/integration/builtin/index.js.map +1 -0
  50. package/dist/integration/index.cjs +9524 -0
  51. package/dist/integration/index.cjs.map +1 -0
  52. package/dist/integration/index.d.cts +98 -0
  53. package/dist/integration/index.d.ts +98 -0
  54. package/dist/integration/index.js +9481 -0
  55. package/dist/integration/index.js.map +1 -0
  56. package/dist/integration/mastra/index.cjs +9383 -0
  57. package/dist/integration/mastra/index.cjs.map +1 -0
  58. package/dist/integration/mastra/index.d.cts +186 -0
  59. package/dist/integration/mastra/index.d.ts +186 -0
  60. package/dist/integration/mastra/index.js +9348 -0
  61. package/dist/integration/mastra/index.js.map +1 -0
  62. package/dist/model/index.cjs +2392 -0
  63. package/dist/model/index.cjs.map +1 -0
  64. package/dist/model/index.d.cts +97 -0
  65. package/dist/model/index.d.ts +97 -0
  66. package/dist/model/index.js +2368 -0
  67. package/dist/model/index.js.map +1 -0
  68. package/dist/model--I90nCqy.d.cts +66 -0
  69. package/dist/model--I90nCqy.d.ts +66 -0
  70. package/dist/model-BV7A6Trb.d.cts +512 -0
  71. package/dist/model-DGBy-o_L.d.cts +176 -0
  72. package/dist/model-DGBy-o_L.d.ts +176 -0
  73. package/dist/model-RiiiZnou.d.ts +512 -0
  74. package/dist/model-service-D-P2FZNi.d.ts +540 -0
  75. package/dist/model-service-VpzBb7rV.d.cts +540 -0
  76. package/dist/resource-CQovFUeh.d.cts +44 -0
  77. package/dist/resource-DnE_DEka.d.ts +44 -0
  78. package/dist/sandbox/index.cjs +3557 -0
  79. package/dist/sandbox/index.cjs.map +1 -0
  80. package/dist/sandbox/index.d.cts +1598 -0
  81. package/dist/sandbox/index.d.ts +1598 -0
  82. package/dist/sandbox/index.js +3532 -0
  83. package/dist/sandbox/index.js.map +1 -0
  84. package/dist/server/adapter/index.cjs +24886 -0
  85. package/dist/server/adapter/index.cjs.map +1 -0
  86. package/dist/server/adapter/index.d.cts +68 -0
  87. package/dist/server/adapter/index.d.ts +68 -0
  88. package/dist/server/adapter/index.js +24883 -0
  89. package/dist/server/adapter/index.js.map +1 -0
  90. package/dist/server/core/index.cjs +313 -0
  91. package/dist/server/core/index.cjs.map +1 -0
  92. package/dist/server/core/index.d.cts +58 -0
  93. package/dist/server/core/index.d.ts +58 -0
  94. package/dist/server/core/index.js +309 -0
  95. package/dist/server/core/index.js.map +1 -0
  96. package/dist/server/index.cjs +25098 -0
  97. package/dist/server/index.cjs.map +1 -0
  98. package/dist/server/index.d.cts +73 -0
  99. package/dist/server/index.d.ts +73 -0
  100. package/dist/server/index.js +25067 -0
  101. package/dist/server/index.js.map +1 -0
  102. package/dist/server/protocol/index.cjs +1057 -0
  103. package/dist/server/protocol/index.cjs.map +1 -0
  104. package/dist/server/protocol/index.d.cts +135 -0
  105. package/dist/server/protocol/index.d.ts +135 -0
  106. package/dist/server/protocol/index.js +1053 -0
  107. package/dist/server/protocol/index.js.map +1 -0
  108. package/dist/tool-CG0LY-ov.d.cts +155 -0
  109. package/dist/tool-JJHam0ms.d.ts +155 -0
  110. package/dist/toolset/api/index.cjs +754 -0
  111. package/dist/toolset/api/index.cjs.map +1 -0
  112. package/dist/toolset/api/index.d.cts +207 -0
  113. package/dist/toolset/api/index.d.ts +207 -0
  114. package/dist/toolset/api/index.js +727 -0
  115. package/dist/toolset/api/index.js.map +1 -0
  116. package/dist/toolset/index.cjs +1945 -0
  117. package/dist/toolset/index.cjs.map +1 -0
  118. package/dist/toolset/index.d.cts +182 -0
  119. package/dist/toolset/index.d.ts +182 -0
  120. package/dist/toolset/index.js +1920 -0
  121. package/dist/toolset/index.js.map +1 -0
  122. package/dist/toolset-BYDvhwRp.d.cts +394 -0
  123. package/dist/toolset-CSRsJxCb.d.ts +394 -0
  124. package/dist/utils/index.cjs +994 -0
  125. package/dist/utils/index.cjs.map +1 -0
  126. package/dist/utils/index.d.cts +30 -0
  127. package/dist/utils/index.d.ts +30 -0
  128. package/dist/utils/index.js +951 -0
  129. package/dist/utils/index.js.map +1 -0
  130. package/package.json +65 -13
@@ -0,0 +1,994 @@
1
+ 'use strict';
2
+
3
+ var dotenv = require('dotenv');
4
+ var $AgentRun = require('@alicloud/agentrun20250910');
5
+ var $OpenApi = require('@alicloud/openapi-client');
6
+ var http = require('http');
7
+ var https = require('https');
8
+ var fs = require('fs');
9
+ var nodePath = require('path');
10
+ var url = require('url');
11
+
12
+ function _interopNamespace(e) {
13
+ if (e && e.__esModule) return e;
14
+ var n = Object.create(null);
15
+ if (e) {
16
+ Object.keys(e).forEach(function (k) {
17
+ if (k !== 'default') {
18
+ var d = Object.getOwnPropertyDescriptor(e, k);
19
+ Object.defineProperty(n, k, d.get ? d : {
20
+ enumerable: true,
21
+ get: function () { return e[k]; }
22
+ });
23
+ }
24
+ });
25
+ }
26
+ n.default = e;
27
+ return Object.freeze(n);
28
+ }
29
+
30
+ var dotenv__namespace = /*#__PURE__*/_interopNamespace(dotenv);
31
+ var $AgentRun__namespace = /*#__PURE__*/_interopNamespace($AgentRun);
32
+ var $OpenApi__namespace = /*#__PURE__*/_interopNamespace($OpenApi);
33
+ var http__namespace = /*#__PURE__*/_interopNamespace(http);
34
+ var https__namespace = /*#__PURE__*/_interopNamespace(https);
35
+ var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
36
+ var nodePath__namespace = /*#__PURE__*/_interopNamespace(nodePath);
37
+
38
+ var __defProp = Object.defineProperty;
39
+ var __getOwnPropNames = Object.getOwnPropertyNames;
40
+ var __esm = (fn, res) => function __init() {
41
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
42
+ };
43
+ var __export = (target, all) => {
44
+ for (var name in all)
45
+ __defProp(target, name, { get: all[name], enumerable: true });
46
+ };
47
+ function getEnvWithDefault(defaultValue, ...keys) {
48
+ for (const key of keys) {
49
+ const value = process.env[key];
50
+ if (value !== void 0 && value !== "") {
51
+ return value;
52
+ }
53
+ }
54
+ return defaultValue;
55
+ }
56
+ exports.Config = void 0;
57
+ var init_config = __esm({
58
+ "src/utils/config.ts"() {
59
+ dotenv__namespace.config();
60
+ exports.Config = class _Config {
61
+ _accessKeyId;
62
+ _accessKeySecret;
63
+ _securityToken;
64
+ _accountId;
65
+ _token;
66
+ _regionId;
67
+ _timeout;
68
+ _readTimeout;
69
+ _controlEndpoint;
70
+ _dataEndpoint;
71
+ _devsEndpoint;
72
+ _headers;
73
+ constructor(options = {}) {
74
+ this._accessKeyId = options.accessKeyId ?? getEnvWithDefault("", "AGENTRUN_ACCESS_KEY_ID", "ALIBABA_CLOUD_ACCESS_KEY_ID");
75
+ this._accessKeySecret = options.accessKeySecret ?? getEnvWithDefault("", "AGENTRUN_ACCESS_KEY_SECRET", "ALIBABA_CLOUD_ACCESS_KEY_SECRET");
76
+ this._securityToken = options.securityToken ?? getEnvWithDefault("", "AGENTRUN_SECURITY_TOKEN", "ALIBABA_CLOUD_SECURITY_TOKEN");
77
+ this._accountId = options.accountId ?? getEnvWithDefault("", "AGENTRUN_ACCOUNT_ID", "FC_ACCOUNT_ID");
78
+ this._token = options.token;
79
+ this._regionId = options.regionId ?? getEnvWithDefault("cn-hangzhou", "AGENTRUN_REGION", "FC_REGION");
80
+ this._timeout = options.timeout ?? 6e5;
81
+ this._readTimeout = options.readTimeout ?? 1e8;
82
+ this._controlEndpoint = options.controlEndpoint ?? getEnvWithDefault("", "AGENTRUN_CONTROL_ENDPOINT");
83
+ this._dataEndpoint = options.dataEndpoint ?? getEnvWithDefault("", "AGENTRUN_DATA_ENDPOINT");
84
+ this._devsEndpoint = options.devsEndpoint ?? getEnvWithDefault("", "DEVS_ENDPOINT");
85
+ this._headers = options.headers ?? {};
86
+ }
87
+ /**
88
+ * Create a new Config by merging multiple configs.
89
+ * Later configs take precedence.
90
+ */
91
+ static withConfigs(...configs) {
92
+ return new _Config().update(...configs);
93
+ }
94
+ /**
95
+ * Update this config with values from other configs.
96
+ * Non-undefined values from later configs take precedence.
97
+ */
98
+ update(...configs) {
99
+ for (const config2 of configs) {
100
+ if (!config2) continue;
101
+ if (config2._accessKeyId) this._accessKeyId = config2._accessKeyId;
102
+ if (config2._accessKeySecret) this._accessKeySecret = config2._accessKeySecret;
103
+ if (config2._securityToken) this._securityToken = config2._securityToken;
104
+ if (config2._accountId) this._accountId = config2._accountId;
105
+ if (config2._token) this._token = config2._token;
106
+ if (config2._regionId) this._regionId = config2._regionId;
107
+ if (config2._timeout) this._timeout = config2._timeout;
108
+ if (config2._readTimeout) this._readTimeout = config2._readTimeout;
109
+ if (config2._controlEndpoint) this._controlEndpoint = config2._controlEndpoint;
110
+ if (config2._dataEndpoint) this._dataEndpoint = config2._dataEndpoint;
111
+ if (config2._devsEndpoint) this._devsEndpoint = config2._devsEndpoint;
112
+ if (config2._headers && Object.keys(config2._headers).length > 0) {
113
+ this._headers = { ...this._headers, ...config2._headers };
114
+ }
115
+ }
116
+ return this;
117
+ }
118
+ get accessKeyId() {
119
+ return this._accessKeyId;
120
+ }
121
+ get accessKeySecret() {
122
+ return this._accessKeySecret;
123
+ }
124
+ get securityToken() {
125
+ return this._securityToken;
126
+ }
127
+ get accountId() {
128
+ if (!this._accountId) {
129
+ throw new Error(
130
+ "Account ID is not set. Please add AGENTRUN_ACCOUNT_ID environment variable or set it in code."
131
+ );
132
+ }
133
+ return this._accountId;
134
+ }
135
+ get token() {
136
+ return this._token;
137
+ }
138
+ get regionId() {
139
+ return this._regionId || "cn-hangzhou";
140
+ }
141
+ get timeout() {
142
+ return this._timeout || 6e5;
143
+ }
144
+ get readTimeout() {
145
+ return this._readTimeout || 1e8;
146
+ }
147
+ get controlEndpoint() {
148
+ if (this._controlEndpoint) {
149
+ return this._controlEndpoint;
150
+ }
151
+ return `https://agentrun.${this.regionId}.aliyuncs.com`;
152
+ }
153
+ get dataEndpoint() {
154
+ if (this._dataEndpoint) {
155
+ return this._dataEndpoint;
156
+ }
157
+ return `https://${this.accountId}.agentrun-data.${this.regionId}.aliyuncs.com`;
158
+ }
159
+ get devsEndpoint() {
160
+ if (this._devsEndpoint) {
161
+ return this._devsEndpoint;
162
+ }
163
+ return `https://devs.${this.regionId}.aliyuncs.com`;
164
+ }
165
+ get headers() {
166
+ return this._headers;
167
+ }
168
+ };
169
+ }
170
+ });
171
+
172
+ // src/utils/control-api.ts
173
+ var control_api_exports = {};
174
+ __export(control_api_exports, {
175
+ $AgentRun: () => $AgentRun__namespace,
176
+ ControlAPI: () => ControlAPI
177
+ });
178
+ var $AgentRunClient, ControlAPI;
179
+ var init_control_api = __esm({
180
+ "src/utils/control-api.ts"() {
181
+ init_config();
182
+ $AgentRunClient = // @ts-expect-error - ESM interop: default.default exists when imported as ESM namespace
183
+ $AgentRun__namespace.default?.default ?? $AgentRun__namespace.default ?? $AgentRun__namespace;
184
+ ControlAPI = class {
185
+ config;
186
+ constructor(config2) {
187
+ this.config = config2;
188
+ }
189
+ /**
190
+ * Get the underlying AgentRun client instance
191
+ */
192
+ getClient(config2) {
193
+ const cfg = exports.Config.withConfigs(this.config, config2);
194
+ let endpoint = cfg.controlEndpoint;
195
+ if (endpoint.startsWith("http://") || endpoint.startsWith("https://")) {
196
+ endpoint = endpoint.split("://")[1];
197
+ }
198
+ const openApiConfig = new $OpenApi__namespace.Config({
199
+ accessKeyId: cfg.accessKeyId,
200
+ accessKeySecret: cfg.accessKeySecret,
201
+ securityToken: cfg.securityToken || void 0,
202
+ regionId: cfg.regionId,
203
+ endpoint,
204
+ connectTimeout: cfg.timeout,
205
+ readTimeout: cfg.readTimeout
206
+ });
207
+ return new $AgentRunClient(openApiConfig);
208
+ }
209
+ };
210
+ }
211
+ });
212
+
213
+ // src/utils/log.ts
214
+ var LOG_LEVELS = {
215
+ debug: 0,
216
+ info: 1,
217
+ warn: 2,
218
+ error: 3
219
+ };
220
+ var COLORS = {
221
+ reset: "\x1B[0m",
222
+ bright: "\x1B[1m",
223
+ dim: "\x1B[2m",
224
+ italic: "\x1B[3m",
225
+ blue: "\x1B[34m",
226
+ cyan: "\x1B[36m",
227
+ yellow: "\x1B[33m",
228
+ red: "\x1B[31m"
229
+ };
230
+ var Logger = class {
231
+ level = "info";
232
+ // match Python logger name
233
+ prefix = "agentrun-logger";
234
+ setLevel(level) {
235
+ this.level = level;
236
+ }
237
+ shouldLog(level) {
238
+ return LOG_LEVELS[level] >= LOG_LEVELS[this.level];
239
+ }
240
+ getColor(level) {
241
+ switch (level) {
242
+ case "debug":
243
+ return COLORS.cyan;
244
+ case "info":
245
+ return COLORS.blue;
246
+ case "warn":
247
+ return COLORS.yellow;
248
+ case "error":
249
+ return COLORS.red;
250
+ default:
251
+ return COLORS.reset;
252
+ }
253
+ }
254
+ // format timestamp like Python: YYYY-MM-DD HH:mm:ss,SSS
255
+ formatTimestamp(d = /* @__PURE__ */ new Date()) {
256
+ const pad = (n, sz = 2) => n.toString().padStart(sz, "0");
257
+ const year = d.getFullYear();
258
+ const month = pad(d.getMonth() + 1);
259
+ const day = pad(d.getDate());
260
+ const hour = pad(d.getHours());
261
+ const minute = pad(d.getMinutes());
262
+ const second = pad(d.getSeconds());
263
+ const ms = pad(d.getMilliseconds(), 3);
264
+ return `${year}-${month}-${day} ${hour}:${minute}:${second},${ms}`;
265
+ }
266
+ // attempt to infer caller file and line by parsing Error.stack
267
+ // helper: parse a single stack frame into {filepath, line, functionName}
268
+ parseFrame(frame) {
269
+ const m = frame.match(/^(?:at\s+)?(?:(.+?)\s+\()?(.*?):(\d+):(\d+)\)?$/);
270
+ if (!m) return null;
271
+ return {
272
+ functionName: m[1] ? m[1].trim() : void 0,
273
+ filepath: m[2],
274
+ line: parseInt(m[3], 10)
275
+ };
276
+ }
277
+ // get caller by fixed stack offset (used in public log methods)
278
+ getCallerByOffset() {
279
+ const err = new Error();
280
+ const stack = err.stack;
281
+ if (!stack) return {};
282
+ const lines = stack.split("\n").map((l) => l.trim());
283
+ for (let i = 3; i < lines.length; i++) {
284
+ let parsed = this.parseFrame(lines[i]);
285
+ if (!parsed) {
286
+ const m = lines[i].match(/(\/[^:\s]+:\d+:\d+)/);
287
+ if (m) {
288
+ const parts = m[1].split(":");
289
+ parts.pop();
290
+ const ln = Number(parts.pop());
291
+ const fp2 = parts.join(":");
292
+ parsed = { filepath: fp2, line: ln, functionName: void 0 };
293
+ }
294
+ }
295
+ if (!parsed) continue;
296
+ const fp = parsed.filepath;
297
+ if (fp.includes("node_modules") || fp.includes("internal") || fp.includes("<anonymous>") || fp.includes("native"))
298
+ continue;
299
+ return { filepath: parsed.filepath, line: parsed.line };
300
+ }
301
+ const cwd = process.cwd();
302
+ for (let i = 0; i < lines.length; i++) {
303
+ let parsed = this.parseFrame(lines[i]);
304
+ if (!parsed) {
305
+ const m = lines[i].match(/(\/[^:\s]+:\d+:\d+)/);
306
+ if (m) {
307
+ const parts = m[1].split(":");
308
+ parts.pop();
309
+ const ln = Number(parts.pop());
310
+ const fp2 = parts.join(":");
311
+ parsed = { filepath: fp2, line: ln, functionName: void 0 };
312
+ }
313
+ }
314
+ if (!parsed) continue;
315
+ const fp = parsed.filepath;
316
+ if (fp.includes("node_modules") || fp.includes("internal") || fp.includes("<anonymous>") || fp.includes("native"))
317
+ continue;
318
+ if (fp.includes("/src/utils/log.ts")) continue;
319
+ if (fp.startsWith(cwd)) return { filepath: parsed.filepath, line: parsed.line };
320
+ }
321
+ for (let i = 0; i < lines.length; i++) {
322
+ let parsed = this.parseFrame(lines[i]);
323
+ if (!parsed) {
324
+ const m = lines[i].match(/(\/[^:\s]+:\d+:\d+)/);
325
+ if (m) {
326
+ const parts = m[1].split(":");
327
+ parts.pop();
328
+ const ln = Number(parts.pop());
329
+ const fp2 = parts.join(":");
330
+ parsed = { filepath: fp2, line: ln, functionName: void 0 };
331
+ }
332
+ }
333
+ if (!parsed) continue;
334
+ const fp = parsed.filepath;
335
+ if (fp.includes("node_modules") || fp.includes("internal") || fp.includes("<anonymous>") || fp.includes("native"))
336
+ continue;
337
+ if (fp.includes("/src/utils/log.ts")) continue;
338
+ return { filepath: parsed.filepath, line: parsed.line };
339
+ }
340
+ return {};
341
+ }
342
+ formatMessage(level, message, filepath, line) {
343
+ const timestamp = this.formatTimestamp();
344
+ const color = this.getColor(level);
345
+ const reset = COLORS.reset;
346
+ const levelName = level === "warn" ? "WARNING" : level.toUpperCase();
347
+ const levelStr = `${COLORS.bright}${color}${levelName}${reset}`;
348
+ const nameStr = `${color}[${this.prefix}]${reset}`;
349
+ const tsStr = `${color} ${timestamp}${reset}`;
350
+ const pathInfo = filepath && line !== void 0 ? ` ${COLORS.dim}${COLORS.italic}${filepath}:${line}${reset}` : "";
351
+ const msg = level === "debug" ? `${COLORS.dim}${message}${reset}` : message;
352
+ return `
353
+ ${levelStr} ${nameStr}${tsStr}${pathInfo}
354
+ ${msg}
355
+ `;
356
+ }
357
+ debug(message, ...args) {
358
+ if (this.shouldLog("debug")) {
359
+ const caller = this.getCallerByOffset();
360
+ console.debug(this.formatMessage("debug", message, caller.filepath, caller.line), ...args);
361
+ }
362
+ }
363
+ info(message, ...args) {
364
+ if (this.shouldLog("info")) {
365
+ const caller = this.getCallerByOffset();
366
+ console.info(this.formatMessage("info", message, caller.filepath, caller.line), ...args);
367
+ }
368
+ }
369
+ warn(message, ...args) {
370
+ if (this.shouldLog("warn")) {
371
+ const caller = this.getCallerByOffset();
372
+ console.warn(this.formatMessage("warn", message, caller.filepath, caller.line), ...args);
373
+ }
374
+ }
375
+ error(message, ...args) {
376
+ if (this.shouldLog("error")) {
377
+ const caller = this.getCallerByOffset();
378
+ console.error(this.formatMessage("error", message, caller.filepath, caller.line), ...args);
379
+ }
380
+ }
381
+ };
382
+ var logger = new Logger();
383
+ if (![void 0, null, "", "False", "FALSE", "false", "0"].includes(process.env["AGENTRUN_SDK_DEBUG"])) {
384
+ logger.setLevel("debug");
385
+ if (!globalThis._AGENTRUN_DEBUG_LOGGED) {
386
+ logger.warn("\u542F\u7528 AgentRun SDK \u8C03\u8BD5\u65E5\u5FD7\uFF0C \u79FB\u9664 AGENTRUN_SDK_DEBUG \u73AF\u5883\u53D8\u91CF\u4EE5\u5173\u95ED");
387
+ globalThis._AGENTRUN_DEBUG_LOGGED = true;
388
+ }
389
+ } else {
390
+ logger.setLevel("info");
391
+ }
392
+
393
+ // src/utils/version-check.ts
394
+ var VERSION = "0.0.4" ;
395
+ if (!process.env.DISABLE_BREAKING_CHANGES_WARNING && !globalThis._AGENTRUN_VERSION_WARNING_SHOWN) {
396
+ globalThis._AGENTRUN_VERSION_WARNING_SHOWN = true;
397
+ logger.warn(
398
+ `\u5F53\u524D\u60A8\u6B63\u5728\u4F7F\u7528 AgentRun Python SDK \u7248\u672C ${VERSION}\u3002\u65E9\u671F\u7248\u672C\u901A\u5E38\u5305\u542B\u8BB8\u591A\u65B0\u529F\u80FD\uFF0C\u8FD9\u4E9B\u529F\u80FD\x1B[1;33m \u53EF\u80FD\u5F15\u5165\u4E0D\u517C\u5BB9\u7684\u53D8\u66F4 \x1B[0m\u3002\u4E3A\u907F\u514D\u6F5C\u5728\u95EE\u9898\uFF0C\u6211\u4EEC\u5F3A\u70C8\u5EFA\u8BAE\x1B[1;32m \u5C06\u4F9D\u8D56\u9501\u5B9A\u4E3A\u6B64\u7248\u672C \x1B[0m\u3002
399
+ You are currently using AgentRun Python SDK version ${VERSION}. Early versions often include many new features, which\x1B[1;33m may introduce breaking changes\x1B[0m. To avoid potential issues, we strongly recommend \x1B[1;32mpinning the dependency to this version\x1B[0m.
400
+ \x1B[2;3m pip install 'agentrun-sdk==${VERSION}' \x1B[0m
401
+
402
+ \u589E\u52A0\x1B[2;3m DISABLE_BREAKING_CHANGES_WARNING=1 \x1B[0m\u5230\u60A8\u7684\u73AF\u5883\u53D8\u91CF\u4EE5\u5173\u95ED\u6B64\u8B66\u544A\u3002
403
+ Add\x1B[2;3m DISABLE_BREAKING_CHANGES_WARNING=1 \x1B[0mto your environment variables to disable this warning.
404
+
405
+ Releases:\x1B[2;3m https://github.com/Serverless-Devs/agentrun-sdk-python/releases\x1B[0m`
406
+ );
407
+ }
408
+
409
+ // src/utils/index.ts
410
+ init_config();
411
+
412
+ // src/utils/data-api.ts
413
+ init_config();
414
+
415
+ // src/utils/exception.ts
416
+ var AgentRunError = class _AgentRunError extends Error {
417
+ constructor(message) {
418
+ super(message);
419
+ this.name = "AgentRunError";
420
+ Object.setPrototypeOf(this, _AgentRunError.prototype);
421
+ }
422
+ };
423
+ var HTTPError = class _HTTPError extends AgentRunError {
424
+ statusCode;
425
+ requestId;
426
+ errorCode;
427
+ constructor(statusCode, message, options) {
428
+ super(message);
429
+ this.name = "HTTPError";
430
+ this.statusCode = statusCode;
431
+ this.requestId = options?.requestId;
432
+ this.errorCode = options?.errorCode;
433
+ Object.setPrototypeOf(this, _HTTPError.prototype);
434
+ }
435
+ /**
436
+ * Convert HTTP error to resource-specific error based on status code
437
+ */
438
+ toResourceError(resourceType, resourceId) {
439
+ if (this.statusCode == 404) return new ResourceNotExistError(resourceType, resourceId);
440
+ else if (this.statusCode == 409) return new ResourceAlreadyExistError(resourceType, resourceId);
441
+ else if ((this.statusCode == 400 || this.statusCode == 500) && this.message.includes("already exists"))
442
+ return new ResourceAlreadyExistError(resourceType, resourceId);
443
+ else return this;
444
+ }
445
+ };
446
+ var ClientError = class _ClientError extends HTTPError {
447
+ constructor(statusCode, message, options) {
448
+ super(statusCode, message, options);
449
+ this.name = "ClientError";
450
+ Object.setPrototypeOf(this, _ClientError.prototype);
451
+ }
452
+ };
453
+ var ServerError = class _ServerError extends HTTPError {
454
+ constructor(statusCode, message, options) {
455
+ super(statusCode, message, options);
456
+ this.name = "ServerError";
457
+ Object.setPrototypeOf(this, _ServerError.prototype);
458
+ }
459
+ };
460
+ var ResourceNotExistError = class _ResourceNotExistError extends ClientError {
461
+ resourceType;
462
+ resourceId;
463
+ constructor(resourceType, resourceId, options) {
464
+ const message = resourceId ? `${resourceType} '${resourceId}' does not exist` : `${resourceType} does not exist`;
465
+ super(404, message, options);
466
+ this.name = "ResourceNotExistError";
467
+ this.resourceType = resourceType;
468
+ this.resourceId = resourceId;
469
+ Object.setPrototypeOf(this, _ResourceNotExistError.prototype);
470
+ }
471
+ };
472
+ var ResourceAlreadyExistError = class _ResourceAlreadyExistError extends ClientError {
473
+ resourceType;
474
+ resourceId;
475
+ constructor(resourceType, resourceId, options) {
476
+ const message = resourceId ? `${resourceType} '${resourceId}' already exists` : `${resourceType} already exists`;
477
+ super(409, message, options);
478
+ this.name = "ResourceAlreadyExistError";
479
+ this.resourceType = resourceType;
480
+ this.resourceId = resourceId;
481
+ Object.setPrototypeOf(this, _ResourceAlreadyExistError.prototype);
482
+ }
483
+ };
484
+
485
+ // src/utils/data-api.ts
486
+ var ResourceType = /* @__PURE__ */ ((ResourceType2) => {
487
+ ResourceType2["Runtime"] = "runtime";
488
+ ResourceType2["LiteLLM"] = "litellm";
489
+ ResourceType2["Tool"] = "tool";
490
+ ResourceType2["Template"] = "template";
491
+ ResourceType2["Sandbox"] = "sandbox";
492
+ return ResourceType2;
493
+ })(ResourceType || {});
494
+ var DataAPI = class {
495
+ resourceName;
496
+ resourceType;
497
+ accessToken = null;
498
+ config;
499
+ namespace;
500
+ /**
501
+ * Initialize the Data API Client.
502
+ *
503
+ * @param resourceName - Resource name for access token
504
+ * @param resourceType - Resource type for access token
505
+ * @param config - Configuration options
506
+ * @param namespace - API namespace (default: "agents")
507
+ */
508
+ constructor(resourceName, resourceType, config2, namespace = "agents") {
509
+ this.resourceName = resourceName;
510
+ this.resourceType = resourceType;
511
+ this.config = exports.Config.withConfigs(config2);
512
+ this.namespace = namespace;
513
+ const token = this.config.token;
514
+ if (token) {
515
+ logger.debug(`Using provided access token from config`);
516
+ this.accessToken = token;
517
+ }
518
+ }
519
+ /**
520
+ * Get the base URL for API requests.
521
+ */
522
+ getBaseUrl() {
523
+ return this.config.dataEndpoint;
524
+ }
525
+ /**
526
+ * Construct full URL with the given path and query parameters.
527
+ *
528
+ * @param path - API path (may include query string)
529
+ * @param query - Query parameters to add/merge
530
+ * @returns Complete URL string with query parameters
531
+ */
532
+ withPath(path, query) {
533
+ path = path.replace(/^\//, "");
534
+ const parts = [this.getBaseUrl(), this.namespace, path].filter(Boolean).map((part) => part.replace(/^\/|\/$/g, ""));
535
+ const baseUrl = parts.join("/");
536
+ if (!query || Object.keys(query).length === 0) {
537
+ return baseUrl;
538
+ }
539
+ const urlObj = new url.URL(baseUrl);
540
+ const existingParams = urlObj.searchParams;
541
+ for (const key in query) {
542
+ if (Object.prototype.hasOwnProperty.call(query, key)) {
543
+ const value = query[key];
544
+ if (Array.isArray(value)) {
545
+ value.forEach((v) => existingParams.append(key, String(v)));
546
+ } else if (value !== void 0 && value !== null) {
547
+ existingParams.set(key, String(value));
548
+ }
549
+ }
550
+ }
551
+ urlObj.search = existingParams.toString();
552
+ return urlObj.toString();
553
+ }
554
+ /**
555
+ * Authenticate and prepare headers for the request.
556
+ *
557
+ * @param url - Request URL
558
+ * @param headers - Request headers
559
+ * @param query - Query parameters
560
+ * @param config - Optional config override
561
+ * @returns Tuple of [url, headers, query]
562
+ */
563
+ async auth(url, headers, query, config2) {
564
+ const cfg = exports.Config.withConfigs(this.config, config2);
565
+ if (this.accessToken === null && this.resourceName && this.resourceType && !cfg.token) {
566
+ try {
567
+ const { ControlAPI: ControlAPI2 } = await Promise.resolve().then(() => (init_control_api(), control_api_exports));
568
+ const $AgentRun2 = await import('@alicloud/agentrun20250910');
569
+ const cli = new ControlAPI2(this.config).getClient();
570
+ const input = this.resourceType === "sandbox" /* Sandbox */ ? new $AgentRun2.GetAccessTokenRequest({
571
+ resourceId: this.resourceName,
572
+ resourceType: this.resourceType
573
+ }) : new $AgentRun2.GetAccessTokenRequest({
574
+ resourceName: this.resourceName,
575
+ resourceType: this.resourceType
576
+ });
577
+ const resp = await cli.getAccessToken(input);
578
+ this.accessToken = resp.body?.data?.accessToken || null;
579
+ logger.debug(
580
+ `Fetched access token for resource ${this.resourceName} of type ${this.resourceType}`
581
+ );
582
+ } catch (e) {
583
+ logger.warn(
584
+ `Failed to get access token for ${this.resourceType}(${this.resourceName}): ${e}`
585
+ );
586
+ }
587
+ }
588
+ const authHeaders = {
589
+ "Agentrun-Access-Token": cfg.token || this.accessToken || "",
590
+ ...cfg.headers,
591
+ ...headers
592
+ };
593
+ return [url, authHeaders, query];
594
+ }
595
+ /**
596
+ * Prepare the HTTP request.
597
+ */
598
+ async prepareRequest(method, url$1, data, headers, query, config2) {
599
+ const reqHeaders = {
600
+ "Content-Type": "application/json",
601
+ "User-Agent": "AgentRunDataClient/1.0"
602
+ };
603
+ const cfg = exports.Config.withConfigs(this.config, config2);
604
+ Object.assign(reqHeaders, cfg.headers);
605
+ if (headers) {
606
+ Object.assign(reqHeaders, headers);
607
+ }
608
+ const [authUrl, authHeaders, authQuery] = await this.auth(url$1, reqHeaders, query, cfg);
609
+ let finalUrl = authUrl;
610
+ if (authQuery && Object.keys(authQuery).length > 0) {
611
+ const urlObj = new url.URL(authUrl);
612
+ for (const key in authQuery) {
613
+ if (Object.prototype.hasOwnProperty.call(authQuery, key)) {
614
+ const value = authQuery[key];
615
+ if (value !== void 0 && value !== null) {
616
+ urlObj.searchParams.set(key, String(value));
617
+ }
618
+ }
619
+ }
620
+ finalUrl = urlObj.toString();
621
+ }
622
+ let body;
623
+ if (data !== void 0) {
624
+ if (Buffer.isBuffer(data)) {
625
+ body = data;
626
+ } else if (typeof data === "object") {
627
+ body = JSON.stringify(data);
628
+ } else {
629
+ body = data;
630
+ }
631
+ }
632
+ logger.debug(`${method} ${finalUrl} headers=${JSON.stringify(authHeaders)}`);
633
+ return { method, url: finalUrl, headers: authHeaders, body };
634
+ }
635
+ /**
636
+ * Make an HTTP request.
637
+ */
638
+ async makeRequest(method, path, data, query, headers, config2) {
639
+ const fullUrl = this.withPath(path, query);
640
+ const {
641
+ method: reqMethod,
642
+ url: reqUrl,
643
+ headers: reqHeaders,
644
+ body: reqBody
645
+ } = await this.prepareRequest(method, fullUrl, data, headers, void 0, config2);
646
+ const client = reqUrl.startsWith("https") ? https__namespace : http__namespace;
647
+ const urlObj = new url.URL(reqUrl);
648
+ const options = {
649
+ hostname: urlObj.hostname,
650
+ port: urlObj.port || (reqUrl.startsWith("https") ? 443 : 80),
651
+ path: urlObj.pathname + urlObj.search,
652
+ method: reqMethod,
653
+ headers: reqHeaders,
654
+ timeout: this.config.timeout
655
+ };
656
+ return new Promise((resolve, reject) => {
657
+ const req = client.request(options, (res) => {
658
+ let responseData = "";
659
+ res.on("data", (chunk) => responseData += chunk);
660
+ res.on("end", () => {
661
+ logger.debug(`Response: ${responseData}`);
662
+ if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
663
+ try {
664
+ resolve(responseData ? JSON.parse(responseData) : {});
665
+ } catch (e) {
666
+ const errorMsg = `Failed to parse JSON response: ${e}`;
667
+ logger.error(errorMsg);
668
+ reject(new ClientError(res.statusCode || 0, errorMsg));
669
+ }
670
+ } else {
671
+ const errorMsg = responseData || res.statusMessage || "Unknown error";
672
+ reject(new ClientError(res.statusCode || 0, errorMsg));
673
+ }
674
+ });
675
+ });
676
+ req.on("error", (e) => {
677
+ reject(new ClientError(0, `Request error: ${e.message}`));
678
+ });
679
+ req.on("timeout", () => {
680
+ req.destroy();
681
+ reject(new ClientError(0, "Request timeout"));
682
+ });
683
+ if (reqBody) {
684
+ req.write(reqBody);
685
+ }
686
+ req.end();
687
+ });
688
+ }
689
+ /**
690
+ * Make a GET request.
691
+ *
692
+ * @param path - API path
693
+ * @param query - Query parameters
694
+ * @param headers - Additional headers
695
+ * @param config - Optional config override
696
+ */
697
+ async get(path, query, headers, config2) {
698
+ return this.makeRequest("GET", path, void 0, query, headers, config2);
699
+ }
700
+ /**
701
+ * Make a POST request.
702
+ *
703
+ * @param path - API path
704
+ * @param data - Request body
705
+ * @param query - Query parameters
706
+ * @param headers - Additional headers
707
+ * @param config - Optional config override
708
+ */
709
+ async post(path, data, query, headers, config2) {
710
+ return this.makeRequest("POST", path, data, query, headers, config2);
711
+ }
712
+ /**
713
+ * Make a PUT request.
714
+ *
715
+ * @param path - API path
716
+ * @param data - Request body
717
+ * @param query - Query parameters
718
+ * @param headers - Additional headers
719
+ * @param config - Optional config override
720
+ */
721
+ async put(path, data, query, headers, config2) {
722
+ return this.makeRequest("PUT", path, data, query, headers, config2);
723
+ }
724
+ /**
725
+ * Make a PATCH request.
726
+ *
727
+ * @param path - API path
728
+ * @param data - Request body
729
+ * @param query - Query parameters
730
+ * @param headers - Additional headers
731
+ * @param config - Optional config override
732
+ */
733
+ async patch(path, data, query, headers, config2) {
734
+ return this.makeRequest("PATCH", path, data, query, headers, config2);
735
+ }
736
+ /**
737
+ * Make a DELETE request.
738
+ *
739
+ * @param path - API path
740
+ * @param query - Query parameters
741
+ * @param headers - Additional headers
742
+ * @param config - Optional config override
743
+ */
744
+ async delete(path, query, headers, config2) {
745
+ return this.makeRequest("DELETE", path, void 0, query, headers, config2);
746
+ }
747
+ /**
748
+ * Upload a file using multipart/form-data.
749
+ *
750
+ * @param path - API path
751
+ * @param localFilePath - Local file path to upload
752
+ * @param targetFilePath - Target file path on the server
753
+ * @param formData - Additional form data fields
754
+ * @param query - Query parameters
755
+ * @param headers - Additional headers
756
+ * @param config - Optional config override
757
+ */
758
+ async postFile(path, localFilePath, targetFilePath, formData, query, headers, config2) {
759
+ const fullUrl = this.withPath(path, query);
760
+ const { url: reqUrl, headers: reqHeaders } = await this.prepareRequest(
761
+ "POST",
762
+ fullUrl,
763
+ void 0,
764
+ headers,
765
+ void 0,
766
+ config2
767
+ );
768
+ const client = reqUrl.startsWith("https") ? https__namespace : http__namespace;
769
+ const urlObj = new url.URL(reqUrl);
770
+ return new Promise((resolve, reject) => {
771
+ const boundary = `----WebKitFormBoundary${Math.random().toString(36).substring(2)}`;
772
+ const contentHeaders = {
773
+ ...reqHeaders,
774
+ "Content-Type": `multipart/form-data; boundary=${boundary}`
775
+ };
776
+ const options = {
777
+ hostname: urlObj.hostname,
778
+ port: urlObj.port || (reqUrl.startsWith("https") ? 443 : 80),
779
+ path: urlObj.pathname + urlObj.search,
780
+ method: "POST",
781
+ headers: contentHeaders,
782
+ timeout: this.config.timeout
783
+ };
784
+ const req = client.request(options, (res) => {
785
+ let responseData = "";
786
+ res.on("data", (chunk) => responseData += chunk);
787
+ res.on("end", () => {
788
+ if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
789
+ try {
790
+ resolve(responseData ? JSON.parse(responseData) : {});
791
+ } catch (e) {
792
+ logger.error(`Failed to parse JSON response: ${e}`);
793
+ reject(new ClientError(res.statusCode || 0, `Failed to parse JSON: ${e}`));
794
+ }
795
+ } else {
796
+ reject(new ClientError(res.statusCode || 0, responseData || "Unknown error"));
797
+ }
798
+ });
799
+ });
800
+ req.on("error", (e) => {
801
+ reject(new ClientError(0, `Request error: ${e.message}`));
802
+ });
803
+ const appendField = (name, value) => {
804
+ req.write(`--${boundary}\r
805
+ `);
806
+ req.write(`Content-Disposition: form-data; name="${name}"\r
807
+ `);
808
+ req.write("\r\n");
809
+ req.write(`${value}\r
810
+ `);
811
+ };
812
+ if (formData) {
813
+ for (const key in formData) {
814
+ if (Object.prototype.hasOwnProperty.call(formData, key)) {
815
+ appendField(key, formData[key]);
816
+ }
817
+ }
818
+ }
819
+ appendField("path", targetFilePath);
820
+ const filename = nodePath__namespace.basename(localFilePath);
821
+ req.write(`--${boundary}\r
822
+ `);
823
+ req.write(`Content-Disposition: form-data; name="file"; filename="${filename}"\r
824
+ `);
825
+ req.write("Content-Type: application/octet-stream\r\n");
826
+ req.write("\r\n");
827
+ const fileStream = fs__namespace.createReadStream(localFilePath);
828
+ fileStream.pipe(req, { end: false });
829
+ fileStream.on("end", () => {
830
+ req.write(`\r
831
+ --${boundary}--\r
832
+ `);
833
+ req.end();
834
+ });
835
+ fileStream.on("error", (e) => {
836
+ reject(new ClientError(0, `File stream error: ${e.message}`));
837
+ });
838
+ });
839
+ }
840
+ /**
841
+ * Download a file and save it to local path.
842
+ *
843
+ * @param path - API path
844
+ * @param savePath - Local file path to save the downloaded file
845
+ * @param query - Query parameters
846
+ * @param headers - Additional headers
847
+ * @param config - Optional config override
848
+ */
849
+ async getFile(path, savePath, query, headers, config2) {
850
+ const fullUrl = this.withPath(path, query);
851
+ const { url: reqUrl, headers: reqHeaders } = await this.prepareRequest(
852
+ "GET",
853
+ fullUrl,
854
+ void 0,
855
+ headers,
856
+ void 0,
857
+ config2
858
+ );
859
+ const client = reqUrl.startsWith("https") ? https__namespace : http__namespace;
860
+ const urlObj = new url.URL(reqUrl);
861
+ return new Promise((resolve, reject) => {
862
+ const options = {
863
+ hostname: urlObj.hostname,
864
+ port: urlObj.port || (reqUrl.startsWith("https") ? 443 : 80),
865
+ path: urlObj.pathname + urlObj.search,
866
+ method: "GET",
867
+ headers: reqHeaders,
868
+ timeout: this.config.timeout
869
+ };
870
+ const req = client.request(options, (res) => {
871
+ if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
872
+ const fileStream = fs__namespace.createWriteStream(savePath);
873
+ let downloadedSize = 0;
874
+ res.on("data", (chunk) => {
875
+ fileStream.write(chunk);
876
+ downloadedSize += chunk.length;
877
+ });
878
+ res.on("end", () => {
879
+ fileStream.end();
880
+ resolve({ savedPath: savePath, size: downloadedSize });
881
+ });
882
+ res.on("error", (e) => {
883
+ fileStream.end();
884
+ reject(new ClientError(0, `Response error: ${e.message}`));
885
+ });
886
+ } else {
887
+ let errorData = "";
888
+ res.on("data", (chunk) => errorData += chunk);
889
+ res.on("end", () => {
890
+ reject(new ClientError(res.statusCode || 0, errorData || "Download failed"));
891
+ });
892
+ }
893
+ });
894
+ req.on("error", (e) => {
895
+ reject(new ClientError(0, `Request error: ${e.message}`));
896
+ });
897
+ req.end();
898
+ });
899
+ }
900
+ /**
901
+ * Download a video file and save it to local path.
902
+ *
903
+ * @param path - API path
904
+ * @param savePath - Local file path to save the downloaded video
905
+ * @param query - Query parameters
906
+ * @param headers - Additional headers
907
+ * @param config - Optional config override
908
+ */
909
+ async getVideo(path, savePath, query, headers, config2) {
910
+ return this.getFile(path, savePath, query, headers, config2);
911
+ }
912
+ };
913
+
914
+ // src/utils/model.ts
915
+ var Status = {
916
+ CREATING: "CREATING",
917
+ CREATE_FAILED: "CREATE_FAILED",
918
+ READY: "READY",
919
+ UPDATING: "UPDATING",
920
+ UPDATE_FAILED: "UPDATE_FAILED",
921
+ DELETING: "DELETING",
922
+ DELETE_FAILED: "DELETE_FAILED"
923
+ };
924
+ var NetworkMode = {
925
+ PUBLIC: "PUBLIC",
926
+ PRIVATE: "PRIVATE",
927
+ PUBLIC_AND_PRIVATE: "PUBLIC_AND_PRIVATE"
928
+ };
929
+ function toSnakeCase(str) {
930
+ return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
931
+ }
932
+ function toCamelCase(str) {
933
+ return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
934
+ }
935
+ function toSnakeCaseKeys(obj) {
936
+ const result = {};
937
+ for (const [key, value] of Object.entries(obj)) {
938
+ const snakeKey = toSnakeCase(key);
939
+ if (value !== null && typeof value === "object" && !Array.isArray(value)) {
940
+ result[snakeKey] = toSnakeCaseKeys(value);
941
+ } else if (Array.isArray(value)) {
942
+ result[snakeKey] = value.map(
943
+ (item) => typeof item === "object" && item !== null ? toSnakeCaseKeys(item) : item
944
+ );
945
+ } else {
946
+ result[snakeKey] = value;
947
+ }
948
+ }
949
+ return result;
950
+ }
951
+ function toCamelCaseKeys(obj) {
952
+ const result = {};
953
+ for (const [key, value] of Object.entries(obj)) {
954
+ const camelKey = toCamelCase(key);
955
+ if (value !== null && typeof value === "object" && !Array.isArray(value)) {
956
+ result[camelKey] = toCamelCaseKeys(value);
957
+ } else if (Array.isArray(value)) {
958
+ result[camelKey] = value.map(
959
+ (item) => typeof item === "object" && item !== null ? toCamelCaseKeys(item) : item
960
+ );
961
+ } else {
962
+ result[camelKey] = value;
963
+ }
964
+ }
965
+ return result;
966
+ }
967
+ function removeUndefined(obj) {
968
+ const result = {};
969
+ for (const [key, value] of Object.entries(obj)) {
970
+ if (value !== void 0) {
971
+ result[key] = value;
972
+ }
973
+ }
974
+ return result;
975
+ }
976
+
977
+ exports.AgentRunError = AgentRunError;
978
+ exports.ClientError = ClientError;
979
+ exports.DataAPI = DataAPI;
980
+ exports.HTTPError = HTTPError;
981
+ exports.NetworkMode = NetworkMode;
982
+ exports.ResourceAlreadyExistError = ResourceAlreadyExistError;
983
+ exports.ResourceNotExistError = ResourceNotExistError;
984
+ exports.ResourceType = ResourceType;
985
+ exports.ServerError = ServerError;
986
+ exports.Status = Status;
987
+ exports.logger = logger;
988
+ exports.removeUndefined = removeUndefined;
989
+ exports.toCamelCase = toCamelCase;
990
+ exports.toCamelCaseKeys = toCamelCaseKeys;
991
+ exports.toSnakeCase = toSnakeCase;
992
+ exports.toSnakeCaseKeys = toSnakeCaseKeys;
993
+ //# sourceMappingURL=index.cjs.map
994
+ //# sourceMappingURL=index.cjs.map