test-wuying-agentbay-sdk 0.13.1-beta.20251223155807 → 0.13.1-beta.20251223194518

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.cjs CHANGED
@@ -11216,7 +11216,8 @@ var _Code = class _Code {
11216
11216
  * Corresponds to Python's run_code() method
11217
11217
  *
11218
11218
  * @param code - The code to execute.
11219
- * @param language - The programming language of the code. Must be either 'python' or 'javascript'.
11219
+ * @param language - The programming language of the code. Case-insensitive.
11220
+ * Supported values: 'python', 'javascript', 'r', 'java'.
11220
11221
  * @param timeoutS - The timeout for the code execution in seconds. Default is 60s.
11221
11222
  * Note: Due to gateway limitations, each request cannot exceed 60 seconds.
11222
11223
  * @returns CodeExecutionResult with code execution output and requestId
@@ -11238,17 +11239,28 @@ var _Code = class _Code {
11238
11239
  */
11239
11240
  async runCode(code, language, timeoutS = 60) {
11240
11241
  try {
11241
- if (language !== "python" && language !== "javascript") {
11242
+ const rawLanguage = _nullishCoalesce(language, () => ( ""));
11243
+ const normalizedLanguage = String(rawLanguage).trim().toLowerCase();
11244
+ const aliases = {
11245
+ py: "python",
11246
+ python3: "python",
11247
+ js: "javascript",
11248
+ node: "javascript",
11249
+ nodejs: "javascript"
11250
+ };
11251
+ const canonicalLanguage = aliases[normalizedLanguage] || normalizedLanguage;
11252
+ const supported = /* @__PURE__ */ new Set(["python", "javascript", "r", "java"]);
11253
+ if (!supported.has(canonicalLanguage)) {
11242
11254
  return {
11243
11255
  requestId: "",
11244
11256
  success: false,
11245
11257
  result: "",
11246
- errorMessage: `Unsupported language: ${language}. Supported languages are 'python' and 'javascript'`
11258
+ errorMessage: `Unsupported language: ${rawLanguage}. Supported languages are 'python', 'javascript', 'r', and 'java'`
11247
11259
  };
11248
11260
  }
11249
11261
  const args = {
11250
11262
  code,
11251
- language,
11263
+ language: canonicalLanguage,
11252
11264
  timeout_s: timeoutS
11253
11265
  };
11254
11266
  const response = await this.session.callMcpTool("run_code", args);
@@ -11288,6 +11300,18 @@ var _Code = class _Code {
11288
11300
  };
11289
11301
  }
11290
11302
  }
11303
+ /**
11304
+ * Alias of runCode().
11305
+ */
11306
+ async run(code, language, timeoutS = 60) {
11307
+ return await this.runCode(code, language, timeoutS);
11308
+ }
11309
+ /**
11310
+ * Alias of runCode().
11311
+ */
11312
+ async execute(code, language, timeoutS = 60) {
11313
+ return await this.runCode(code, language, timeoutS);
11314
+ }
11291
11315
  };
11292
11316
  _chunk4IPTHWLMcjs.__name.call(void 0, _Code, "Code");
11293
11317
  var Code = _Code;
@@ -11474,6 +11498,18 @@ var _Command = class _Command {
11474
11498
  };
11475
11499
  }
11476
11500
  }
11501
+ /**
11502
+ * Alias of executeCommand().
11503
+ */
11504
+ async run(command, timeoutMs = 1e3, cwd, envs) {
11505
+ return await this.executeCommand(command, timeoutMs, cwd, envs);
11506
+ }
11507
+ /**
11508
+ * Alias of executeCommand().
11509
+ */
11510
+ async exec(command, timeoutMs = 1e3, cwd, envs) {
11511
+ return await this.executeCommand(command, timeoutMs, cwd, envs);
11512
+ }
11477
11513
  };
11478
11514
  _chunk4IPTHWLMcjs.__name.call(void 0, _Command, "Command");
11479
11515
  var Command = _Command;
@@ -13199,10 +13235,11 @@ var _FileTransfer = class _FileTransfer {
13199
13235
  error: `Upload exception: ${e.message || e}`
13200
13236
  };
13201
13237
  }
13238
+ const remoteDir = this.remoteDir(remotePath);
13202
13239
  let reqIdSync;
13203
13240
  try {
13204
13241
  logDebug("Triggering sync to cloud disk");
13205
- reqIdSync = await this.awaitSync("download", remotePath, this.contextId);
13242
+ reqIdSync = await this.awaitSync("download", remoteDir, this.contextId);
13206
13243
  } catch (e) {
13207
13244
  return {
13208
13245
  success: false,
@@ -13222,7 +13259,7 @@ var _FileTransfer = class _FileTransfer {
13222
13259
  if (wait) {
13223
13260
  const { success, error } = await this.waitForTask({
13224
13261
  contextId: this.contextId,
13225
- remotePath,
13262
+ remotePath: remoteDir,
13226
13263
  taskType: "download",
13227
13264
  timeout: waitTimeout,
13228
13265
  interval: pollInterval
@@ -13292,9 +13329,10 @@ var _FileTransfer = class _FileTransfer {
13292
13329
  };
13293
13330
  }
13294
13331
  }
13332
+ const remoteDir = this.remoteDir(remotePath);
13295
13333
  let reqIdSync;
13296
13334
  try {
13297
- reqIdSync = await this.awaitSync("upload", remotePath, this.contextId);
13335
+ reqIdSync = await this.awaitSync("upload", remoteDir, this.contextId);
13298
13336
  } catch (e) {
13299
13337
  return {
13300
13338
  success: false,
@@ -13308,7 +13346,7 @@ var _FileTransfer = class _FileTransfer {
13308
13346
  if (wait) {
13309
13347
  const { success, error } = await this.waitForTask({
13310
13348
  contextId: this.contextId,
13311
- remotePath,
13349
+ remotePath: remoteDir,
13312
13350
  taskType: "upload",
13313
13351
  timeout: waitTimeout,
13314
13352
  interval: pollInterval
@@ -13402,6 +13440,18 @@ var _FileTransfer = class _FileTransfer {
13402
13440
  }
13403
13441
  }
13404
13442
  // ========== Internal Utilities ==========
13443
+ /**
13444
+ * Ensure sync path is a directory: strip filename, keep directory inputs.
13445
+ */
13446
+ remoteDir(remotePath) {
13447
+ if (!remotePath) return "";
13448
+ if (remotePath.endsWith("/")) {
13449
+ const trimmed = remotePath.replace(/\/+$/, "");
13450
+ return trimmed || "/";
13451
+ }
13452
+ const dir = path4.posix.dirname(remotePath);
13453
+ return dir === "." ? "/" : dir;
13454
+ }
13405
13455
  /**
13406
13456
  * Compatibility wrapper for session.context.sync which may be sync or async:
13407
13457
  * - Try async call first
@@ -13777,6 +13827,48 @@ var _FileSystem = class _FileSystem {
13777
13827
  };
13778
13828
  }
13779
13829
  }
13830
+ /**
13831
+ * Alias of readFile().
13832
+ */
13833
+ async read(path6) {
13834
+ return await this.readFile(path6);
13835
+ }
13836
+ /**
13837
+ * Alias of writeFile().
13838
+ */
13839
+ async write(path6, content, mode = "overwrite") {
13840
+ return await this.writeFile(path6, content, mode);
13841
+ }
13842
+ /**
13843
+ * Alias of listDirectory().
13844
+ */
13845
+ async list(path6) {
13846
+ return await this.listDirectory(path6);
13847
+ }
13848
+ /**
13849
+ * Alias of listDirectory().
13850
+ */
13851
+ async ls(path6) {
13852
+ return await this.listDirectory(path6);
13853
+ }
13854
+ /**
13855
+ * Alias of deleteFile().
13856
+ */
13857
+ async delete(path6) {
13858
+ return await this.deleteFile(path6);
13859
+ }
13860
+ /**
13861
+ * Alias of deleteFile().
13862
+ */
13863
+ async remove(path6) {
13864
+ return await this.deleteFile(path6);
13865
+ }
13866
+ /**
13867
+ * Alias of deleteFile().
13868
+ */
13869
+ async rm(path6) {
13870
+ return await this.deleteFile(path6);
13871
+ }
13780
13872
  /**
13781
13873
  * Edits a file by replacing occurrences of oldText with newText.
13782
13874
  * Corresponds to Python's edit_file() method
@@ -15825,6 +15917,24 @@ var _Session = class _Session {
15825
15917
  this.browser = new Browser(this);
15826
15918
  this.context = newContextManager(this);
15827
15919
  }
15920
+ /**
15921
+ * Alias of fileSystem.
15922
+ */
15923
+ get fs() {
15924
+ return this.fileSystem;
15925
+ }
15926
+ /**
15927
+ * Alias of fileSystem.
15928
+ */
15929
+ get filesystem() {
15930
+ return this.fileSystem;
15931
+ }
15932
+ /**
15933
+ * Alias of fileSystem.
15934
+ */
15935
+ get files() {
15936
+ return this.fileSystem;
15937
+ }
15828
15938
  /**
15829
15939
  * Return the AgentBay instance that created this session.
15830
15940
  *