test-wuying-agentbay-sdk 0.15.0-beta.20260113141358 → 0.15.0-beta.20260114142100

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
@@ -9702,6 +9702,15 @@ var _BaseTaskAgent = class _BaseTaskAgent {
9702
9702
  }
9703
9703
  return baseName;
9704
9704
  }
9705
+ getServerName() {
9706
+ if (this.toolPrefix === "flux") {
9707
+ return "flux";
9708
+ }
9709
+ if (this.toolPrefix === "browser_use") {
9710
+ return "wuying_browseruse";
9711
+ }
9712
+ return "wuying_mobile_agent";
9713
+ }
9705
9714
  /**
9706
9715
  * Execute a specific task described in human language.
9707
9716
  */
@@ -9710,7 +9719,9 @@ var _BaseTaskAgent = class _BaseTaskAgent {
9710
9719
  const args = { task };
9711
9720
  const result = await this.session.callMcpTool(
9712
9721
  this.getToolName("execute"),
9713
- args
9722
+ args,
9723
+ false,
9724
+ this.getServerName()
9714
9725
  );
9715
9726
  if (!result.success) {
9716
9727
  return {
@@ -9880,7 +9891,9 @@ var _BaseTaskAgent = class _BaseTaskAgent {
9880
9891
  const args = { task_id: taskId };
9881
9892
  const result = await this.session.callMcpTool(
9882
9893
  this.getToolName("get_status"),
9883
- args
9894
+ args,
9895
+ false,
9896
+ this.getServerName()
9884
9897
  );
9885
9898
  if (!result.success) {
9886
9899
  return {
@@ -9937,7 +9950,9 @@ var _BaseTaskAgent = class _BaseTaskAgent {
9937
9950
  const args = { task_id: taskId };
9938
9951
  const result = await this.session.callMcpTool(
9939
9952
  this.getToolName("terminate"),
9940
- args
9953
+ args,
9954
+ false,
9955
+ this.getServerName()
9941
9956
  );
9942
9957
  let content;
9943
9958
  try {
@@ -11080,7 +11095,7 @@ var _BrowserAgent = class _BrowserAgent {
11080
11095
  return [null, 0];
11081
11096
  }
11082
11097
  async _callMcpTool(toolName, args) {
11083
- return this.session.callMcpTool(toolName, args);
11098
+ return this.session.callMcpTool(toolName, args, false, "pageuse-mcp-server");
11084
11099
  }
11085
11100
  _delay(ms) {
11086
11101
  return new Promise((res) => setTimeout(res, ms));
@@ -12425,7 +12440,12 @@ var _Code = class _Code {
12425
12440
  language: canonicalLanguage,
12426
12441
  timeout_s: timeoutS
12427
12442
  };
12428
- const response = await this.session.callMcpTool("run_code", args);
12443
+ const response = await this.session.callMcpTool(
12444
+ "run_code",
12445
+ args,
12446
+ false,
12447
+ "wuying_codespace"
12448
+ );
12429
12449
  let codeResult;
12430
12450
  if (response.success) {
12431
12451
  codeResult = this.parseBackendResponse(response.data);
@@ -12589,7 +12609,12 @@ var _Command = class _Command {
12589
12609
  if (envs !== void 0) {
12590
12610
  args.envs = envs;
12591
12611
  }
12592
- const result = await this.session.callMcpTool("shell", args);
12612
+ const result = await this.session.callMcpTool(
12613
+ "shell",
12614
+ args,
12615
+ false,
12616
+ "wuying_shell"
12617
+ );
12593
12618
  if (result.success) {
12594
12619
  try {
12595
12620
  let dataJson;
@@ -12780,6 +12805,87 @@ var _Computer = class _Computer {
12780
12805
  constructor(session) {
12781
12806
  this.session = session;
12782
12807
  }
12808
+ static normalizeImageFormat(format, defaultValue) {
12809
+ const f = String(format || "").trim().toLowerCase();
12810
+ if (!f) {
12811
+ return defaultValue;
12812
+ }
12813
+ if (f === "jpg") {
12814
+ return "jpeg";
12815
+ }
12816
+ return f;
12817
+ }
12818
+ static validateBase64String(base64String) {
12819
+ const s = String(base64String || "");
12820
+ if (!s) {
12821
+ throw new Error("Empty base64 string");
12822
+ }
12823
+ if (s.length % 4 !== 0) {
12824
+ throw new Error("Invalid base64 string length");
12825
+ }
12826
+ const base64WithoutPadding = s.replace(/=+$/, "");
12827
+ if (!/^[A-Za-z0-9+/]+$/.test(base64WithoutPadding)) {
12828
+ throw new Error("Invalid base64 string format");
12829
+ }
12830
+ const paddingMatch = s.match(/=+$/);
12831
+ if (paddingMatch && paddingMatch[0].length > 2) {
12832
+ throw new Error("Invalid base64 padding format");
12833
+ }
12834
+ }
12835
+ static decodeScreenshotJsonToBytesStrict(jsonText, expectedFormat) {
12836
+ const s = String(jsonText || "").trim();
12837
+ if (!s) {
12838
+ throw new Error("Empty image data");
12839
+ }
12840
+ if (!s.startsWith("{")) {
12841
+ throw new Error("Screenshot tool returned non-JSON data");
12842
+ }
12843
+ let obj;
12844
+ try {
12845
+ obj = JSON.parse(s);
12846
+ } catch (e) {
12847
+ throw new Error(`Invalid screenshot JSON: ${e instanceof Error ? e.message : String(e)}`);
12848
+ }
12849
+ if (!obj || typeof obj !== "object" || Array.isArray(obj)) {
12850
+ throw new Error("Invalid screenshot JSON: expected object");
12851
+ }
12852
+ const b64 = obj.data;
12853
+ if (typeof b64 !== "string" || !b64.trim()) {
12854
+ throw new Error("Screenshot JSON missing base64 field");
12855
+ }
12856
+ _Computer.validateBase64String(b64);
12857
+ let bytes;
12858
+ if (typeof Buffer !== "undefined") {
12859
+ bytes = new Uint8Array(Buffer.from(b64, "base64"));
12860
+ } else {
12861
+ const binary = atob(b64);
12862
+ const out = new Uint8Array(binary.length);
12863
+ for (let i = 0; i < binary.length; i++) {
12864
+ out[i] = binary.charCodeAt(i);
12865
+ }
12866
+ bytes = out;
12867
+ }
12868
+ const fmt = _Computer.normalizeImageFormat(expectedFormat, "png");
12869
+ if (fmt === "png") {
12870
+ const pngMagic = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]);
12871
+ for (let i = 0; i < pngMagic.length; i++) {
12872
+ if (bytes[i] !== pngMagic[i]) {
12873
+ throw new Error("Screenshot data does not match expected format 'png'");
12874
+ }
12875
+ }
12876
+ return bytes;
12877
+ }
12878
+ if (fmt === "jpeg") {
12879
+ const jpgMagic = new Uint8Array([255, 216, 255]);
12880
+ for (let i = 0; i < jpgMagic.length; i++) {
12881
+ if (bytes[i] !== jpgMagic[i]) {
12882
+ throw new Error("Screenshot data does not match expected format 'jpeg'");
12883
+ }
12884
+ }
12885
+ return bytes;
12886
+ }
12887
+ throw new Error(`Unsupported format: ${JSON.stringify(expectedFormat)}`);
12888
+ }
12783
12889
  /**
12784
12890
  * Click mouse at specified coordinates.
12785
12891
  *
@@ -12807,7 +12913,7 @@ var _Computer = class _Computer {
12807
12913
  }
12808
12914
  const args = { x, y, button: buttonStr };
12809
12915
  try {
12810
- const result = await this.session.callMcpTool("click_mouse", args);
12916
+ const result = await this.session.callMcpTool("click_mouse", args, false, "wuying_ui");
12811
12917
  return {
12812
12918
  success: result.success || false,
12813
12919
  requestId: result.requestId || "",
@@ -12845,7 +12951,7 @@ var _Computer = class _Computer {
12845
12951
  async moveMouse(x, y) {
12846
12952
  const args = { x, y };
12847
12953
  try {
12848
- const result = await this.session.callMcpTool("move_mouse", args);
12954
+ const result = await this.session.callMcpTool("move_mouse", args, false, "wuying_ui");
12849
12955
  return {
12850
12956
  success: result.success || false,
12851
12957
  requestId: result.requestId || "",
@@ -12890,7 +12996,7 @@ var _Computer = class _Computer {
12890
12996
  }
12891
12997
  const args = { from_x: fromX, from_y: fromY, to_x: toX, to_y: toY, button: buttonStr };
12892
12998
  try {
12893
- const result = await this.session.callMcpTool("drag_mouse", args);
12999
+ const result = await this.session.callMcpTool("drag_mouse", args, false, "wuying_ui");
12894
13000
  return {
12895
13001
  success: result.success || false,
12896
13002
  requestId: result.requestId || "",
@@ -12933,7 +13039,7 @@ var _Computer = class _Computer {
12933
13039
  }
12934
13040
  const args = { x, y, direction: directionStr, amount };
12935
13041
  try {
12936
- const result = await this.session.callMcpTool("scroll", args);
13042
+ const result = await this.session.callMcpTool("scroll", args, false, "wuying_ui");
12937
13043
  return {
12938
13044
  success: result.success || false,
12939
13045
  requestId: result.requestId || "",
@@ -12968,7 +13074,7 @@ var _Computer = class _Computer {
12968
13074
  async inputText(text) {
12969
13075
  const args = { text };
12970
13076
  try {
12971
- const result = await this.session.callMcpTool("input_text", args);
13077
+ const result = await this.session.callMcpTool("input_text", args, false, "wuying_ui");
12972
13078
  return {
12973
13079
  success: result.success || false,
12974
13080
  requestId: result.requestId || "",
@@ -13005,7 +13111,7 @@ var _Computer = class _Computer {
13005
13111
  async pressKeys(keys, hold = false) {
13006
13112
  const args = { keys, hold };
13007
13113
  try {
13008
- const result = await this.session.callMcpTool("press_keys", args);
13114
+ const result = await this.session.callMcpTool("press_keys", args, false, "wuying_ui");
13009
13115
  return {
13010
13116
  success: result.success || false,
13011
13117
  requestId: result.requestId || "",
@@ -13041,7 +13147,7 @@ var _Computer = class _Computer {
13041
13147
  async releaseKeys(keys) {
13042
13148
  const args = { keys };
13043
13149
  try {
13044
- const result = await this.session.callMcpTool("release_keys", args);
13150
+ const result = await this.session.callMcpTool("release_keys", args, false, "wuying_ui");
13045
13151
  return {
13046
13152
  success: result.success || false,
13047
13153
  requestId: result.requestId || "",
@@ -13075,7 +13181,7 @@ var _Computer = class _Computer {
13075
13181
  */
13076
13182
  async getCursorPosition() {
13077
13183
  try {
13078
- const result = await this.session.callMcpTool("get_cursor_position", {});
13184
+ const result = await this.session.callMcpTool("get_cursor_position", {}, false, "wuying_ui");
13079
13185
  if (!result.success) {
13080
13186
  return {
13081
13187
  success: false,
@@ -13141,7 +13247,7 @@ var _Computer = class _Computer {
13141
13247
  */
13142
13248
  async getScreenSize() {
13143
13249
  try {
13144
- const result = await this.session.callMcpTool("get_screen_size", {});
13250
+ const result = await this.session.callMcpTool("get_screen_size", {}, false, "wuying_ui");
13145
13251
  if (!result.success) {
13146
13252
  return {
13147
13253
  success: false,
@@ -13212,7 +13318,7 @@ var _Computer = class _Computer {
13212
13318
  */
13213
13319
  async screenshot() {
13214
13320
  try {
13215
- const result = await this.session.callMcpTool("system_screenshot", {});
13321
+ const result = await this.session.callMcpTool("system_screenshot", {}, false, "mcp-server");
13216
13322
  if (!result.success) {
13217
13323
  return {
13218
13324
  success: false,
@@ -13245,6 +13351,55 @@ var _Computer = class _Computer {
13245
13351
  };
13246
13352
  }
13247
13353
  }
13354
+ /**
13355
+ * Capture the current screen and return raw image bytes (beta).
13356
+ *
13357
+ * This API uses the MCP tool `screenshot` (wuying_capture) and expects the backend to return
13358
+ * a JSON string with top-level field `data` containing base64.
13359
+ *
13360
+ * @param format - Output image format ("png", "jpeg", or "jpg"). Default is "png"
13361
+ */
13362
+ async betaTakeScreenshot(format = "png") {
13363
+ const fmt = _Computer.normalizeImageFormat(format, "png");
13364
+ if (fmt !== "png" && fmt !== "jpeg") {
13365
+ return {
13366
+ success: false,
13367
+ requestId: "",
13368
+ errorMessage: `Unsupported format: ${JSON.stringify(format)}. Supported values: "png", "jpeg".`,
13369
+ data: new Uint8Array(),
13370
+ format: fmt
13371
+ };
13372
+ }
13373
+ try {
13374
+ const result = await this.session.callMcpTool("screenshot", { format: fmt }, false, "wuying_capture");
13375
+ const requestId = result.requestId || "";
13376
+ if (!result.success) {
13377
+ return {
13378
+ success: false,
13379
+ requestId,
13380
+ errorMessage: result.errorMessage || "Failed to take screenshot",
13381
+ data: new Uint8Array(),
13382
+ format: fmt
13383
+ };
13384
+ }
13385
+ const bytes = _Computer.decodeScreenshotJsonToBytesStrict(String(result.data || ""), fmt);
13386
+ return {
13387
+ success: true,
13388
+ requestId,
13389
+ errorMessage: "",
13390
+ data: bytes,
13391
+ format: fmt
13392
+ };
13393
+ } catch (error) {
13394
+ return {
13395
+ success: false,
13396
+ requestId: "",
13397
+ errorMessage: `Failed to take screenshot: ${error instanceof Error ? error.message : String(error)}`,
13398
+ data: new Uint8Array(),
13399
+ format: fmt
13400
+ };
13401
+ }
13402
+ }
13248
13403
  /**
13249
13404
  * Lists all root windows.
13250
13405
  *
@@ -13265,7 +13420,7 @@ var _Computer = class _Computer {
13265
13420
  async listRootWindows(timeoutMs = 3e3) {
13266
13421
  try {
13267
13422
  const args = { timeout_ms: timeoutMs };
13268
- const response = await this.session.callMcpTool("list_root_windows", args);
13423
+ const response = await this.session.callMcpTool("list_root_windows", args, false, "wuying_ui");
13269
13424
  if (!response.success) {
13270
13425
  return {
13271
13426
  requestId: response.requestId,
@@ -13310,7 +13465,7 @@ var _Computer = class _Computer {
13310
13465
  async getActiveWindow() {
13311
13466
  try {
13312
13467
  const args = {};
13313
- const response = await this.session.callMcpTool("get_active_window", args);
13468
+ const response = await this.session.callMcpTool("get_active_window", args, false, "wuying_ui");
13314
13469
  if (!response.success) {
13315
13470
  return {
13316
13471
  requestId: response.requestId,
@@ -13355,7 +13510,7 @@ var _Computer = class _Computer {
13355
13510
  async activateWindow(windowId) {
13356
13511
  try {
13357
13512
  const args = { window_id: windowId };
13358
- const response = await this.session.callMcpTool("activate_window", args);
13513
+ const response = await this.session.callMcpTool("activate_window", args, false, "wuying_ui");
13359
13514
  return {
13360
13515
  requestId: response.requestId,
13361
13516
  success: response.success,
@@ -13390,7 +13545,7 @@ var _Computer = class _Computer {
13390
13545
  async closeWindow(windowId) {
13391
13546
  try {
13392
13547
  const args = { window_id: windowId };
13393
- const response = await this.session.callMcpTool("close_window", args);
13548
+ const response = await this.session.callMcpTool("close_window", args, false, "wuying_ui");
13394
13549
  return {
13395
13550
  requestId: response.requestId,
13396
13551
  success: response.success,
@@ -13425,7 +13580,7 @@ var _Computer = class _Computer {
13425
13580
  async maximizeWindow(windowId) {
13426
13581
  try {
13427
13582
  const args = { window_id: windowId };
13428
- const response = await this.session.callMcpTool("maximize_window", args);
13583
+ const response = await this.session.callMcpTool("maximize_window", args, false, "wuying_ui");
13429
13584
  return {
13430
13585
  requestId: response.requestId,
13431
13586
  success: response.success,
@@ -13460,7 +13615,7 @@ var _Computer = class _Computer {
13460
13615
  async minimizeWindow(windowId) {
13461
13616
  try {
13462
13617
  const args = { window_id: windowId };
13463
- const response = await this.session.callMcpTool("minimize_window", args);
13618
+ const response = await this.session.callMcpTool("minimize_window", args, false, "wuying_ui");
13464
13619
  return {
13465
13620
  requestId: response.requestId,
13466
13621
  success: response.success,
@@ -13496,7 +13651,7 @@ var _Computer = class _Computer {
13496
13651
  async restoreWindow(windowId) {
13497
13652
  try {
13498
13653
  const args = { window_id: windowId };
13499
- const response = await this.session.callMcpTool("restore_window", args);
13654
+ const response = await this.session.callMcpTool("restore_window", args, false, "wuying_ui");
13500
13655
  return {
13501
13656
  requestId: response.requestId,
13502
13657
  success: response.success,
@@ -13533,7 +13688,7 @@ var _Computer = class _Computer {
13533
13688
  async resizeWindow(windowId, width, height) {
13534
13689
  try {
13535
13690
  const args = { window_id: windowId, width, height };
13536
- const response = await this.session.callMcpTool("resize_window", args);
13691
+ const response = await this.session.callMcpTool("resize_window", args, false, "wuying_ui");
13537
13692
  return {
13538
13693
  requestId: response.requestId,
13539
13694
  success: response.success,
@@ -13568,7 +13723,7 @@ var _Computer = class _Computer {
13568
13723
  async fullscreenWindow(windowId) {
13569
13724
  try {
13570
13725
  const args = { window_id: windowId };
13571
- const response = await this.session.callMcpTool("fullscreen_window", args);
13726
+ const response = await this.session.callMcpTool("fullscreen_window", args, false, "wuying_ui");
13572
13727
  return {
13573
13728
  requestId: response.requestId,
13574
13729
  success: response.success,
@@ -13602,7 +13757,7 @@ var _Computer = class _Computer {
13602
13757
  async focusMode(on) {
13603
13758
  try {
13604
13759
  const args = { on };
13605
- const response = await this.session.callMcpTool("focus_mode", args);
13760
+ const response = await this.session.callMcpTool("focus_mode", args, false, "wuying_ui");
13606
13761
  return {
13607
13762
  requestId: response.requestId,
13608
13763
  success: response.success,
@@ -13643,7 +13798,7 @@ var _Computer = class _Computer {
13643
13798
  desktop,
13644
13799
  ignore_system_apps: ignoreSystemApps
13645
13800
  };
13646
- const response = await this.session.callMcpTool("get_installed_apps", args);
13801
+ const response = await this.session.callMcpTool("get_installed_apps", args, false, "wuying_app");
13647
13802
  if (!response.success) {
13648
13803
  return {
13649
13804
  requestId: response.requestId,
@@ -13692,7 +13847,7 @@ var _Computer = class _Computer {
13692
13847
  const args = { start_cmd: startCmd };
13693
13848
  if (workDirectory) args.work_directory = workDirectory;
13694
13849
  if (activity) args.activity = activity;
13695
- const response = await this.session.callMcpTool("start_app", args);
13850
+ const response = await this.session.callMcpTool("start_app", args, false, "wuying_app");
13696
13851
  if (!response.success) {
13697
13852
  return {
13698
13853
  requestId: response.requestId,
@@ -13737,7 +13892,7 @@ var _Computer = class _Computer {
13737
13892
  async stopAppByPName(pname) {
13738
13893
  try {
13739
13894
  const args = { pname };
13740
- const response = await this.session.callMcpTool("stop_app_by_pname", args);
13895
+ const response = await this.session.callMcpTool("stop_app_by_pname", args, false, "wuying_app");
13741
13896
  return {
13742
13897
  requestId: response.requestId,
13743
13898
  success: response.success,
@@ -13772,7 +13927,7 @@ var _Computer = class _Computer {
13772
13927
  async stopAppByPID(pid) {
13773
13928
  try {
13774
13929
  const args = { pid };
13775
- const response = await this.session.callMcpTool("stop_app_by_pid", args);
13930
+ const response = await this.session.callMcpTool("stop_app_by_pid", args, false, "wuying_app");
13776
13931
  return {
13777
13932
  requestId: response.requestId,
13778
13933
  success: response.success,
@@ -13806,7 +13961,7 @@ var _Computer = class _Computer {
13806
13961
  async stopAppByCmd(cmd) {
13807
13962
  try {
13808
13963
  const args = { stop_cmd: cmd };
13809
- const response = await this.session.callMcpTool("stop_app_by_cmd", args);
13964
+ const response = await this.session.callMcpTool("stop_app_by_cmd", args, false, "wuying_app");
13810
13965
  return {
13811
13966
  requestId: response.requestId,
13812
13967
  success: response.success,
@@ -13838,7 +13993,7 @@ var _Computer = class _Computer {
13838
13993
  */
13839
13994
  async listVisibleApps() {
13840
13995
  try {
13841
- const response = await this.session.callMcpTool("list_visible_apps", {});
13996
+ const response = await this.session.callMcpTool("list_visible_apps", {}, false, "wuying_app");
13842
13997
  if (!response.success) {
13843
13998
  return {
13844
13999
  requestId: response.requestId,
@@ -14910,7 +15065,9 @@ var _FileSystem = class _FileSystem {
14910
15065
  };
14911
15066
  const result = await this.session.callMcpTool(
14912
15067
  "create_directory",
14913
- args
15068
+ args,
15069
+ false,
15070
+ "wuying_filesystem"
14914
15071
  );
14915
15072
  if (!result.success) {
14916
15073
  return {
@@ -14955,7 +15112,12 @@ var _FileSystem = class _FileSystem {
14955
15112
  async deleteFile(path6) {
14956
15113
  try {
14957
15114
  const args = { path: path6 };
14958
- const result = await this.session.callMcpTool("delete_file", args);
15115
+ const result = await this.session.callMcpTool(
15116
+ "delete_file",
15117
+ args,
15118
+ false,
15119
+ "wuying_filesystem"
15120
+ );
14959
15121
  if (!result.success) {
14960
15122
  return {
14961
15123
  requestId: result.requestId,
@@ -15049,7 +15211,9 @@ var _FileSystem = class _FileSystem {
15049
15211
  };
15050
15212
  const result = await this.session.callMcpTool(
15051
15213
  "edit_file",
15052
- args
15214
+ args,
15215
+ false,
15216
+ "wuying_filesystem"
15053
15217
  );
15054
15218
  if (!result.success) {
15055
15219
  return {
@@ -15097,7 +15261,9 @@ var _FileSystem = class _FileSystem {
15097
15261
  };
15098
15262
  const result = await this.session.callMcpTool(
15099
15263
  "get_file_info",
15100
- args
15264
+ args,
15265
+ false,
15266
+ "wuying_filesystem"
15101
15267
  );
15102
15268
  if (!result.success) {
15103
15269
  return {
@@ -15175,7 +15341,9 @@ var _FileSystem = class _FileSystem {
15175
15341
  };
15176
15342
  const result = await this.session.callMcpTool(
15177
15343
  "list_directory",
15178
- args
15344
+ args,
15345
+ false,
15346
+ "wuying_filesystem"
15179
15347
  );
15180
15348
  if (!result.success) {
15181
15349
  return {
@@ -15228,7 +15396,9 @@ var _FileSystem = class _FileSystem {
15228
15396
  };
15229
15397
  const result = await this.session.callMcpTool(
15230
15398
  "move_file",
15231
- args
15399
+ args,
15400
+ false,
15401
+ "wuying_filesystem"
15232
15402
  );
15233
15403
  if (!result.success) {
15234
15404
  return {
@@ -15275,7 +15445,9 @@ var _FileSystem = class _FileSystem {
15275
15445
  }
15276
15446
  const result = await this.session.callMcpTool(
15277
15447
  "read_file",
15278
- args
15448
+ args,
15449
+ false,
15450
+ "wuying_filesystem"
15279
15451
  );
15280
15452
  if (!result.success) {
15281
15453
  if (formatType === "binary") {
@@ -15386,7 +15558,9 @@ var _FileSystem = class _FileSystem {
15386
15558
  };
15387
15559
  const result = await this.session.callMcpTool(
15388
15560
  "read_multiple_files",
15389
- args
15561
+ args,
15562
+ false,
15563
+ "wuying_filesystem"
15390
15564
  );
15391
15565
  if (!result.success) {
15392
15566
  return {
@@ -15477,7 +15651,9 @@ var _FileSystem = class _FileSystem {
15477
15651
  }
15478
15652
  const result = await this.session.callMcpTool(
15479
15653
  "search_files",
15480
- args
15654
+ args,
15655
+ false,
15656
+ "wuying_filesystem"
15481
15657
  );
15482
15658
  if (!result.success) {
15483
15659
  return {
@@ -15532,7 +15708,9 @@ var _FileSystem = class _FileSystem {
15532
15708
  };
15533
15709
  const result = await this.session.callMcpTool(
15534
15710
  "write_file",
15535
- args
15711
+ args,
15712
+ false,
15713
+ "wuying_filesystem"
15536
15714
  );
15537
15715
  if (!result.success) {
15538
15716
  return {
@@ -15848,7 +16026,12 @@ var _FileSystem = class _FileSystem {
15848
16026
  async getFileChange(path6) {
15849
16027
  try {
15850
16028
  const args = { path: path6 };
15851
- const result = await this.session.callMcpTool("get_file_change", args);
16029
+ const result = await this.session.callMcpTool(
16030
+ "get_file_change",
16031
+ args,
16032
+ false,
16033
+ "wuying_filesystem"
16034
+ );
15852
16035
  if (!result.success) {
15853
16036
  return {
15854
16037
  requestId: result.requestId,
@@ -16111,41 +16294,27 @@ function normalizeImageFormat(format, defaultValue) {
16111
16294
  return f;
16112
16295
  }
16113
16296
  _chunkJB6CNGN4cjs.__name.call(void 0, normalizeImageFormat, "normalizeImageFormat");
16114
- function stripDataUrlPrefix(b64) {
16115
- const s = String(b64 || "").trim();
16116
- const idx = s.indexOf("base64,");
16117
- if (idx >= 0) {
16118
- return s.slice(idx + "base64,".length).trim();
16297
+ function validateBase64String(base64String) {
16298
+ const s = String(base64String || "");
16299
+ if (!s) {
16300
+ throw new Error("Empty base64 string");
16119
16301
  }
16120
- return s;
16121
- }
16122
- _chunkJB6CNGN4cjs.__name.call(void 0, stripDataUrlPrefix, "stripDataUrlPrefix");
16123
- function indexOfSubarray(haystack, needle, maxSearch) {
16124
- if (needle.length === 0 || haystack.length < needle.length) {
16125
- return -1;
16126
- }
16127
- const limit = Math.min(haystack.length, Math.max(0, maxSearch));
16128
- for (let i = 0; i + needle.length <= limit; i++) {
16129
- let ok = true;
16130
- for (let j = 0; j < needle.length; j++) {
16131
- if (haystack[i + j] !== needle[j]) {
16132
- ok = false;
16133
- break;
16134
- }
16135
- }
16136
- if (ok) {
16137
- return i;
16138
- }
16302
+ const base64WithoutPadding = s.replace(/=+$/, "");
16303
+ if (!/^[A-Za-z0-9+/]+$/.test(base64WithoutPadding)) {
16304
+ throw new Error("Invalid base64 string format");
16139
16305
  }
16140
- return -1;
16141
- }
16142
- _chunkJB6CNGN4cjs.__name.call(void 0, indexOfSubarray, "indexOfSubarray");
16143
- function base64ToUint8Array(input) {
16144
- let s = stripDataUrlPrefix(input).replace(/[\r\n\t ]+/g, "").replace(/-/g, "+").replace(/_/g, "/");
16145
- const mod = s.length % 4;
16146
- if (mod !== 0) {
16147
- s += "=".repeat(4 - mod);
16306
+ if (s.length % 4 !== 0) {
16307
+ throw new Error("Invalid base64 string length");
16308
+ }
16309
+ const paddingMatch = s.match(/=+$/);
16310
+ if (paddingMatch && paddingMatch[0].length > 2) {
16311
+ throw new Error("Invalid base64 padding format");
16148
16312
  }
16313
+ }
16314
+ _chunkJB6CNGN4cjs.__name.call(void 0, validateBase64String, "validateBase64String");
16315
+ function base64ToUint8ArrayStrict(input) {
16316
+ const s = String(input || "").trim();
16317
+ validateBase64String(s);
16149
16318
  if (typeof Buffer !== "undefined") {
16150
16319
  return new Uint8Array(Buffer.from(s, "base64"));
16151
16320
  }
@@ -16156,82 +16325,55 @@ function base64ToUint8Array(input) {
16156
16325
  }
16157
16326
  return out;
16158
16327
  }
16159
- _chunkJB6CNGN4cjs.__name.call(void 0, base64ToUint8Array, "base64ToUint8Array");
16160
- function decodeBase64Image(input, expectedFormat) {
16161
- const b64 = extractBase64FromMcpPayload(input);
16162
- const raw = base64ToUint8Array(b64);
16163
- let b = raw;
16164
- const pngIdx = indexOfSubarray(b, PNG_MAGIC, 128);
16165
- if (pngIdx > 0) {
16166
- b = b.slice(pngIdx);
16167
- }
16168
- const jpgIdx = indexOfSubarray(b, JPEG_MAGIC, 128);
16169
- if (jpgIdx > 0) {
16170
- b = b.slice(jpgIdx);
16171
- }
16172
- const fmt = indexOfSubarray(b, PNG_MAGIC, PNG_MAGIC.length) === 0 ? "png" : indexOfSubarray(b, JPEG_MAGIC, JPEG_MAGIC.length) === 0 ? "jpeg" : expectedFormat;
16173
- return { bytes: b, format: fmt };
16328
+ _chunkJB6CNGN4cjs.__name.call(void 0, base64ToUint8ArrayStrict, "base64ToUint8ArrayStrict");
16329
+ function startsWithMagic(bytes, magic) {
16330
+ if (bytes.length < magic.length) {
16331
+ return false;
16332
+ }
16333
+ for (let i = 0; i < magic.length; i++) {
16334
+ if (bytes[i] !== magic[i]) {
16335
+ return false;
16336
+ }
16337
+ }
16338
+ return true;
16174
16339
  }
16175
- _chunkJB6CNGN4cjs.__name.call(void 0, decodeBase64Image, "decodeBase64Image");
16176
- function extractBase64FromMcpPayload(input) {
16177
- const s = String(input || "").trim();
16178
- if (!(s.startsWith("{") || s.startsWith("["))) {
16179
- return s;
16340
+ _chunkJB6CNGN4cjs.__name.call(void 0, startsWithMagic, "startsWithMagic");
16341
+ function detectImageFormat(bytes) {
16342
+ if (startsWithMagic(bytes, PNG_MAGIC)) {
16343
+ return "png";
16180
16344
  }
16181
- try {
16182
- const obj = JSON.parse(s);
16183
- const b64 = extractBase64FromAny(obj);
16184
- return b64 || s;
16185
- } catch (e12) {
16186
- return s;
16345
+ if (startsWithMagic(bytes, JPEG_MAGIC)) {
16346
+ return "jpeg";
16187
16347
  }
16348
+ return "";
16188
16349
  }
16189
- _chunkJB6CNGN4cjs.__name.call(void 0, extractBase64FromMcpPayload, "extractBase64FromMcpPayload");
16190
- function extractBase64FromAny(v) {
16191
- if (!v) {
16192
- return "";
16350
+ _chunkJB6CNGN4cjs.__name.call(void 0, detectImageFormat, "detectImageFormat");
16351
+ function decodeBase64Image(input, expectedFormat) {
16352
+ const s = String(input || "").trim();
16353
+ if (!s) {
16354
+ throw new Error("Empty image data");
16193
16355
  }
16194
- if (typeof v === "string") {
16195
- return v;
16356
+ if (!s.startsWith("{")) {
16357
+ throw new Error("Screenshot tool returned non-JSON data");
16196
16358
  }
16197
- if (Array.isArray(v)) {
16198
- return v.length > 0 ? extractBase64FromAny(v[0]) : "";
16359
+ let obj;
16360
+ try {
16361
+ obj = JSON.parse(s);
16362
+ } catch (e) {
16363
+ throw new Error(`Invalid screenshot JSON: ${e instanceof Error ? e.message : String(e)}`);
16199
16364
  }
16200
- if (typeof v === "object") {
16201
- if (typeof v.data === "string" && v.data) {
16202
- return v.data;
16203
- }
16204
- const content = v.content;
16205
- if (Array.isArray(content) && content.length > 0 && typeof content[0] === "object" && content[0]) {
16206
- const c0 = content[0];
16207
- if (typeof c0.blob === "string" && c0.blob) {
16208
- return c0.blob;
16209
- }
16210
- if (typeof c0.data === "string" && c0.data) {
16211
- return c0.data;
16212
- }
16213
- if (typeof c0.text === "string" && c0.text) {
16214
- return c0.text;
16215
- }
16216
- if (c0.blob && typeof c0.blob === "object") {
16217
- if (typeof c0.blob.data === "string" && c0.blob.data) {
16218
- return c0.blob.data;
16219
- }
16220
- }
16221
- if (c0.image && typeof c0.image === "object" && typeof c0.image.data === "string" && c0.image.data) {
16222
- return c0.image.data;
16223
- }
16224
- if (c0.source && typeof c0.source === "object" && typeof c0.source.data === "string" && c0.source.data) {
16225
- return c0.source.data;
16226
- }
16227
- }
16228
- if (v.result) {
16229
- return extractBase64FromAny(v.result);
16230
- }
16365
+ if (!obj || typeof obj !== "object" || Array.isArray(obj)) {
16366
+ throw new Error("Invalid screenshot JSON: expected object");
16231
16367
  }
16232
- return "";
16368
+ const b64 = obj.data;
16369
+ if (typeof b64 !== "string" || !b64.trim()) {
16370
+ throw new Error("Screenshot JSON missing base64 field");
16371
+ }
16372
+ const bytes = base64ToUint8ArrayStrict(b64);
16373
+ const detected = detectImageFormat(bytes);
16374
+ return { bytes, format: detected || expectedFormat };
16233
16375
  }
16234
- _chunkJB6CNGN4cjs.__name.call(void 0, extractBase64FromAny, "extractBase64FromAny");
16376
+ _chunkJB6CNGN4cjs.__name.call(void 0, decodeBase64Image, "decodeBase64Image");
16235
16377
  var _Mobile = class _Mobile {
16236
16378
  constructor(session) {
16237
16379
  this.session = session;
@@ -16257,7 +16399,7 @@ var _Mobile = class _Mobile {
16257
16399
  async tap(x, y) {
16258
16400
  const args = { x, y };
16259
16401
  try {
16260
- const result = await this.session.callMcpTool("tap", args);
16402
+ const result = await this.session.callMcpTool("tap", args, false, "wuying_ui");
16261
16403
  return {
16262
16404
  success: result.success || false,
16263
16405
  requestId: result.requestId || "",
@@ -16297,7 +16439,7 @@ var _Mobile = class _Mobile {
16297
16439
  async swipe(startX, startY, endX, endY, durationMs = 300) {
16298
16440
  const args = { start_x: startX, start_y: startY, end_x: endX, end_y: endY, duration_ms: durationMs };
16299
16441
  try {
16300
- const result = await this.session.callMcpTool("swipe", args);
16442
+ const result = await this.session.callMcpTool("swipe", args, false, "wuying_ui");
16301
16443
  return {
16302
16444
  success: result.success || false,
16303
16445
  requestId: result.requestId || "",
@@ -16333,7 +16475,7 @@ var _Mobile = class _Mobile {
16333
16475
  async inputText(text) {
16334
16476
  const args = { text };
16335
16477
  try {
16336
- const result = await this.session.callMcpTool("input_text", args);
16478
+ const result = await this.session.callMcpTool("input_text", args, false, "wuying_ui");
16337
16479
  return {
16338
16480
  success: result.success || false,
16339
16481
  requestId: result.requestId || "",
@@ -16369,7 +16511,7 @@ var _Mobile = class _Mobile {
16369
16511
  async sendKey(key) {
16370
16512
  const args = { key };
16371
16513
  try {
16372
- const result = await this.session.callMcpTool("send_key", args);
16514
+ const result = await this.session.callMcpTool("send_key", args, false, "wuying_ui");
16373
16515
  return {
16374
16516
  success: result.success || false,
16375
16517
  requestId: result.requestId || "",
@@ -16391,7 +16533,7 @@ var _Mobile = class _Mobile {
16391
16533
  async getClickableUIElements(timeoutMs = 5e3) {
16392
16534
  const args = { timeout_ms: timeoutMs };
16393
16535
  try {
16394
- const result = await this.session.callMcpTool("get_clickable_ui_elements", args);
16536
+ const result = await this.session.callMcpTool("get_clickable_ui_elements", args, false, "wuying_ui");
16395
16537
  if (!result.success) {
16396
16538
  return {
16397
16539
  success: false,
@@ -16451,7 +16593,7 @@ var _Mobile = class _Mobile {
16451
16593
  const formatNorm = (format || "json").trim().toLowerCase() || "json";
16452
16594
  const args = { timeout_ms: timeoutMs, format: formatNorm };
16453
16595
  try {
16454
- const result = await this.session.callMcpTool("get_all_ui_elements", args);
16596
+ const result = await this.session.callMcpTool("get_all_ui_elements", args, false, "wuying_ui");
16455
16597
  if (!result.success) {
16456
16598
  return {
16457
16599
  success: false,
@@ -16530,7 +16672,7 @@ var _Mobile = class _Mobile {
16530
16672
  async getInstalledApps(startMenu = false, desktop = true, ignoreSystemApps = true) {
16531
16673
  const args = { start_menu: startMenu, desktop, ignore_system_apps: ignoreSystemApps };
16532
16674
  try {
16533
- const result = await this.session.callMcpTool("get_installed_apps", args);
16675
+ const result = await this.session.callMcpTool("get_installed_apps", args, false, "wuying_app");
16534
16676
  if (!result.success) {
16535
16677
  return {
16536
16678
  success: false,
@@ -16594,7 +16736,7 @@ var _Mobile = class _Mobile {
16594
16736
  async startApp(startCmd, workDirectory = "", activity = "") {
16595
16737
  const args = { start_cmd: startCmd, work_directory: workDirectory, activity };
16596
16738
  try {
16597
- const result = await this.session.callMcpTool("start_app", args);
16739
+ const result = await this.session.callMcpTool("start_app", args, false, "wuying_app");
16598
16740
  if (!result.success) {
16599
16741
  return {
16600
16742
  success: false,
@@ -16657,7 +16799,7 @@ var _Mobile = class _Mobile {
16657
16799
  async stopAppByCmd(stopCmd) {
16658
16800
  const args = { stop_cmd: stopCmd };
16659
16801
  try {
16660
- const result = await this.session.callMcpTool("stop_app_by_cmd", args);
16802
+ const result = await this.session.callMcpTool("stop_app_by_cmd", args, false, "wuying_app");
16661
16803
  return {
16662
16804
  success: result.success || false,
16663
16805
  requestId: result.requestId || "",
@@ -16691,7 +16833,7 @@ var _Mobile = class _Mobile {
16691
16833
  */
16692
16834
  async screenshot() {
16693
16835
  try {
16694
- const result = await this.session.callMcpTool("system_screenshot", {});
16836
+ const result = await this.session.callMcpTool("system_screenshot", {}, false, "mcp-server");
16695
16837
  if (!result.success) {
16696
16838
  return {
16697
16839
  success: false,
@@ -16722,7 +16864,7 @@ var _Mobile = class _Mobile {
16722
16864
  */
16723
16865
  async betaTakeScreenshot() {
16724
16866
  try {
16725
- const result = await this.session.callMcpTool("screenshot", { format: "png" });
16867
+ const result = await this.session.callMcpTool("screenshot", { format: "png" }, false, "wuying_capture");
16726
16868
  const requestId = result.requestId || "";
16727
16869
  if (!result.success) {
16728
16870
  return {
@@ -16797,7 +16939,7 @@ var _Mobile = class _Mobile {
16797
16939
  if (quality !== void 0) {
16798
16940
  args.quality = quality;
16799
16941
  }
16800
- const result = await this.session.callMcpTool("long_screenshot", args);
16942
+ const result = await this.session.callMcpTool("long_screenshot", args, false, "wuying_capture");
16801
16943
  const requestId = result.requestId || "";
16802
16944
  if (!result.success) {
16803
16945
  return {
@@ -17211,7 +17353,12 @@ var _Oss = class _Oss {
17211
17353
  endpoint: endpoint || "",
17212
17354
  region: region || ""
17213
17355
  };
17214
- const result = await this.session.callMcpTool("oss_env_init", args);
17356
+ const result = await this.session.callMcpTool(
17357
+ "oss_env_init",
17358
+ args,
17359
+ false,
17360
+ "wuying_oss"
17361
+ );
17215
17362
  if (result.success) {
17216
17363
  if (result.data) {
17217
17364
  const clientConfigRaw = result.data;
@@ -17283,7 +17430,12 @@ var _Oss = class _Oss {
17283
17430
  object,
17284
17431
  path: path6
17285
17432
  };
17286
- const result = await this.session.callMcpTool("oss_upload", args);
17433
+ const result = await this.session.callMcpTool(
17434
+ "oss_upload",
17435
+ args,
17436
+ false,
17437
+ "wuying_oss"
17438
+ );
17287
17439
  return {
17288
17440
  requestId: result.requestId,
17289
17441
  success: result.success,
@@ -17325,7 +17477,12 @@ var _Oss = class _Oss {
17325
17477
  url,
17326
17478
  path: path6
17327
17479
  };
17328
- const result = await this.session.callMcpTool("oss_upload_annon", args);
17480
+ const result = await this.session.callMcpTool(
17481
+ "oss_upload_annon",
17482
+ args,
17483
+ false,
17484
+ "wuying_oss"
17485
+ );
17329
17486
  return {
17330
17487
  requestId: result.requestId,
17331
17488
  success: result.success,
@@ -17370,7 +17527,12 @@ var _Oss = class _Oss {
17370
17527
  object,
17371
17528
  path: path6
17372
17529
  };
17373
- const result = await this.session.callMcpTool("oss_download", args);
17530
+ const result = await this.session.callMcpTool(
17531
+ "oss_download",
17532
+ args,
17533
+ false,
17534
+ "wuying_oss"
17535
+ );
17374
17536
  return {
17375
17537
  requestId: result.requestId,
17376
17538
  success: result.success,
@@ -17412,7 +17574,12 @@ var _Oss = class _Oss {
17412
17574
  url,
17413
17575
  path: path6
17414
17576
  };
17415
- const result = await this.session.callMcpTool("oss_download_annon", args);
17577
+ const result = await this.session.callMcpTool(
17578
+ "oss_download_annon",
17579
+ args,
17580
+ false,
17581
+ "wuying_oss"
17582
+ );
17416
17583
  return {
17417
17584
  requestId: result.requestId,
17418
17585
  success: result.success,
@@ -17448,6 +17615,7 @@ var _SessionInfoClass = class _SessionInfoClass {
17448
17615
  _chunkJB6CNGN4cjs.__name.call(void 0, _SessionInfoClass, "SessionInfoClass");
17449
17616
  var SessionInfoClass = _SessionInfoClass;
17450
17617
  var _Session = class _Session {
17618
+ // MCP tools list is intentionally not stored in Session.
17451
17619
  /**
17452
17620
  * Initialize a Session object.
17453
17621
  *
@@ -17470,8 +17638,6 @@ var _Session = class _Session {
17470
17638
  this.resourceUrl = "";
17471
17639
  // Recording functionality
17472
17640
  this.enableBrowserReplay = false;
17473
- // MCP tools available for this session
17474
- this.mcpTools = [];
17475
17641
  this.agentBay = agentBay;
17476
17642
  this.sessionId = sessionId;
17477
17643
  this.fileSystem = new FileSystem(this);
@@ -17654,21 +17820,6 @@ var _Session = class _Session {
17654
17820
  getLinkUrl() {
17655
17821
  return this.linkUrl;
17656
17822
  }
17657
- /**
17658
- * Find the server that provides the given tool.
17659
- *
17660
- * @param toolName - Name of the tool to find
17661
- * @returns The server name that provides the tool, or empty string if not found
17662
- * @internal
17663
- */
17664
- findServerForTool(toolName) {
17665
- for (const tool of this.mcpTools) {
17666
- if (tool.name === toolName) {
17667
- return tool.server;
17668
- }
17669
- }
17670
- return "";
17671
- }
17672
17823
  /**
17673
17824
  * Delete this session.
17674
17825
  *
@@ -18347,7 +18498,6 @@ var _Session = class _Session {
18347
18498
  logError(`Error unmarshaling tools data: ${error}`);
18348
18499
  }
18349
18500
  }
18350
- this.mcpTools = tools;
18351
18501
  const keyFields = {
18352
18502
  image_id: imageId,
18353
18503
  tool_count: tools.length
@@ -18389,7 +18539,7 @@ var _Session = class _Session {
18389
18539
  * For press_keys tool, key names are automatically normalized to correct case format.
18390
18540
  * This improves case compatibility (e.g., "CTRL" -> "Ctrl", "tab" -> "Tab").
18391
18541
  */
18392
- async callMcpTool(toolName, args, autoGenSession = false) {
18542
+ async callMcpTool(toolName, args, autoGenSession = false, serverName) {
18393
18543
  try {
18394
18544
  if (toolName === "press_keys" && args && Array.isArray(args.keys)) {
18395
18545
  const { normalizeKeys } = await Promise.resolve().then(() => _interopRequireWildcard(require("./key-normalizer-GGJR2Y35.cjs")));
@@ -18399,10 +18549,10 @@ var _Session = class _Session {
18399
18549
  }
18400
18550
  const argsJSON = JSON.stringify(args);
18401
18551
  if (this.getLinkUrl() && this.getToken()) {
18402
- return await this.callMcpToolLinkUrl(toolName, args);
18552
+ return await this.callMcpToolLinkUrl(toolName, args, serverName);
18403
18553
  }
18404
18554
  if (this.isVpcEnabled()) {
18405
- const server = this.findServerForTool(toolName);
18555
+ const server = serverName || "";
18406
18556
  if (!server) {
18407
18557
  return {
18408
18558
  success: false,
@@ -18427,6 +18577,7 @@ var _Session = class _Session {
18427
18577
  url.searchParams.append("token", this.getToken());
18428
18578
  const requestId = `vpc-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
18429
18579
  url.searchParams.append("requestId", requestId);
18580
+ setRequestId(requestId);
18430
18581
  const response = await fetch(url.toString(), {
18431
18582
  method: "GET",
18432
18583
  headers: {
@@ -18438,7 +18589,7 @@ var _Session = class _Session {
18438
18589
  success: false,
18439
18590
  data: "",
18440
18591
  errorMessage: `VPC request failed: ${response.statusText}`,
18441
- requestId: ""
18592
+ requestId
18442
18593
  };
18443
18594
  }
18444
18595
  const responseData = await response.json();
@@ -18474,14 +18625,14 @@ var _Session = class _Session {
18474
18625
  success: true,
18475
18626
  data: dataStr,
18476
18627
  errorMessage: "",
18477
- requestId: ""
18628
+ requestId
18478
18629
  };
18479
18630
  }
18480
18631
  return {
18481
18632
  success: true,
18482
18633
  data: textContent || JSON.stringify(actualResult),
18483
18634
  errorMessage: "",
18484
- requestId: ""
18635
+ requestId
18485
18636
  };
18486
18637
  } else {
18487
18638
  const callToolRequest = new (0, _chunkQGXJA3GTcjs.CallMcpToolRequest)({
@@ -18511,6 +18662,9 @@ var _Session = class _Session {
18511
18662
  }
18512
18663
  const data = response.body.data;
18513
18664
  const reqId = extractRequestId(response) || "";
18665
+ if (reqId) {
18666
+ setRequestId(reqId);
18667
+ }
18514
18668
  if (toolName === "run_code") {
18515
18669
  let dataStr = "";
18516
18670
  if (data && Array.isArray(data.content) && data.content.length > 0 && data.content[0].text) {
@@ -18565,8 +18719,8 @@ var _Session = class _Session {
18565
18719
  };
18566
18720
  }
18567
18721
  }
18568
- async callMcpToolLinkUrl(toolName, args) {
18569
- const server = this.findServerForTool(toolName);
18722
+ async callMcpToolLinkUrl(toolName, args, serverName) {
18723
+ const server = serverName || "";
18570
18724
  if (!server) {
18571
18725
  return {
18572
18726
  success: false,
@@ -18713,7 +18867,7 @@ var _Session = class _Session {
18713
18867
  * ```
18714
18868
  */
18715
18869
  async getMetrics() {
18716
- const toolResult = await this.callMcpTool("get_metrics", {});
18870
+ const toolResult = await this.callMcpTool("get_metrics", {}, false, "wuying_system");
18717
18871
  const requestId = toolResult.requestId || "";
18718
18872
  if (!toolResult.success) {
18719
18873
  return {
@@ -19596,38 +19750,6 @@ var _AgentBay = class _AgentBay {
19596
19750
  logError(`Warning: Failed to apply mobile configuration: ${error}`);
19597
19751
  }
19598
19752
  }
19599
- const toolListStr = data.toolList;
19600
- if (toolListStr) {
19601
- try {
19602
- const toolsData = JSON.parse(toolListStr);
19603
- const tools = [];
19604
- if (Array.isArray(toolsData)) {
19605
- for (const toolData of toolsData) {
19606
- tools.push({
19607
- name: toolData["name"] || "",
19608
- description: toolData["description"] || "",
19609
- inputSchema: toolData["inputSchema"] || {},
19610
- server: toolData["server"] || "",
19611
- tool: toolData["tool"] || ""
19612
- });
19613
- }
19614
- }
19615
- session.mcpTools = tools;
19616
- } catch (error) {
19617
- logError(`Warning: Failed to parse toolList from CreateMcpSession: ${error}`);
19618
- }
19619
- }
19620
- if (paramsCopy.isVpc && session.mcpTools.length === 0) {
19621
- logDebug("VPC session detected, automatically fetching MCP tools...");
19622
- try {
19623
- const toolsResult = await session.listMcpTools();
19624
- logDebug(
19625
- `Successfully fetched ${toolsResult.tools.length} MCP tools for VPC session (RequestID: ${toolsResult.requestId})`
19626
- );
19627
- } catch (error) {
19628
- logError(`Warning: Failed to fetch MCP tools for VPC session: ${error}`);
19629
- }
19630
- }
19631
19753
  if (needsContextSync) {
19632
19754
  logDebug("Waiting for context synchronization to complete...");
19633
19755
  const maxRetries = 150;
@@ -21806,7 +21928,7 @@ var _LocalSession = class _LocalSession extends Session {
21806
21928
  /**
21807
21929
  * Call MCP tool asynchronously
21808
21930
  */
21809
- async callMcpTool(toolName, args, autoGenSession = false) {
21931
+ async callMcpTool(toolName, args, autoGenSession = false, serverName) {
21810
21932
  const localAgent = this.browser.agent;
21811
21933
  const result = await localAgent._callMcpToolAsync(toolName, args);
21812
21934
  return {