test-wuying-agentbay-sdk 0.15.0-beta.20260114170244 → 0.15.0-beta.20260114224118

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
@@ -2745,6 +2745,35 @@ function maskSensitiveData(data, fields) {
2745
2745
  return mask(data);
2746
2746
  }
2747
2747
  _chunkJB6CNGN4cjs.__name.call(void 0, maskSensitiveData, "maskSensitiveData");
2748
+ function truncateStringForLog(s, max) {
2749
+ if (!max || max <= 0 || s.length <= max) {
2750
+ return s;
2751
+ }
2752
+ return s.slice(0, max) + "...(truncated)";
2753
+ }
2754
+ _chunkJB6CNGN4cjs.__name.call(void 0, truncateStringForLog, "truncateStringForLog");
2755
+ function maskSensitiveDataString(input) {
2756
+ try {
2757
+ const parsed = JSON.parse(input);
2758
+ const masked = maskSensitiveData(parsed);
2759
+ return JSON.stringify(masked);
2760
+ } catch (e4) {
2761
+ const fields = SENSITIVE_FIELDS;
2762
+ let out = input;
2763
+ for (const field of fields) {
2764
+ const re = new RegExp(`("${field}"\\s*:\\s*")([^"]*)(")`, "gi");
2765
+ out = out.replace(re, (_m, p1, p2, p3) => {
2766
+ const v = String(p2 || "");
2767
+ if (v.length > 4) {
2768
+ return `${p1}${v.substring(0, 2)}****${v.substring(v.length - 2)}${p3}`;
2769
+ }
2770
+ return `${p1}****${p3}`;
2771
+ });
2772
+ }
2773
+ return out;
2774
+ }
2775
+ }
2776
+ _chunkJB6CNGN4cjs.__name.call(void 0, maskSensitiveDataString, "maskSensitiveDataString");
2748
2777
  function setLogLevel(level) {
2749
2778
  if (LOG_LEVEL_VALUES[level] !== void 0) {
2750
2779
  currentLogLevel = level;
@@ -3037,7 +3066,8 @@ function logAPIResponseWithDetails(apiName, requestId, success = true, keyFields
3037
3066
  }
3038
3067
  }
3039
3068
  if (fullResponse && shouldLog("DEBUG")) {
3040
- logDebug(`\u{1F4E5} Full Response: ${fullResponse}`);
3069
+ const masked = truncateStringForLog(maskSensitiveDataString(fullResponse), 2e3);
3070
+ logDebug(`\u{1F4E5} Full Response: ${masked}`);
3041
3071
  }
3042
3072
  } else {
3043
3073
  if (shouldLog("ERROR")) {
@@ -3051,12 +3081,25 @@ function logAPIResponseWithDetails(apiName, requestId, success = true, keyFields
3051
3081
  } else {
3052
3082
  logError(errorMessage);
3053
3083
  }
3084
+ if (keyFields) {
3085
+ for (const [key, value] of Object.entries(keyFields)) {
3086
+ const maskedValue = maskSensitiveData({ [key]: value });
3087
+ const keyMessage = ` \u2514\u2500 ${key}=${maskedValue[key]}`;
3088
+ if (useColors) {
3089
+ process.stderr.write(`${ANSI_RED}\u274C ERROR: ${keyMessage}${ANSI_RESET}
3090
+ `);
3091
+ } else {
3092
+ logError(keyMessage);
3093
+ }
3094
+ }
3095
+ }
3054
3096
  if (fullResponse) {
3097
+ const masked = truncateStringForLog(maskSensitiveDataString(fullResponse), 2e3);
3055
3098
  if (useColors) {
3056
- process.stderr.write(`${ANSI_RED}\u2139\uFE0F INFO: \u{1F4E5} Response: ${fullResponse}${ANSI_RESET}
3099
+ process.stderr.write(`${ANSI_RED}\u274C ERROR: \u{1F4E5} Response: ${masked}${ANSI_RESET}
3057
3100
  `);
3058
3101
  } else {
3059
- logError(`\u{1F4E5} Response: ${fullResponse}`);
3102
+ logError(`\u{1F4E5} Response: ${masked}`);
3060
3103
  }
3061
3104
  }
3062
3105
  }
@@ -5479,7 +5522,7 @@ function isValidJWT(jwt, alg) {
5479
5522
  if (alg && decoded.alg !== alg)
5480
5523
  return false;
5481
5524
  return true;
5482
- } catch (e4) {
5525
+ } catch (e5) {
5483
5526
  return false;
5484
5527
  }
5485
5528
  }
@@ -5640,7 +5683,7 @@ var _ZodString = class _ZodString extends ZodType {
5640
5683
  } else if (check.kind === "url") {
5641
5684
  try {
5642
5685
  new URL(input.data);
5643
- } catch (e5) {
5686
+ } catch (e6) {
5644
5687
  ctx = this._getOrReturnCtx(input, ctx);
5645
5688
  addIssueToContext(ctx, {
5646
5689
  validation: "url",
@@ -6295,7 +6338,7 @@ var _ZodBigInt = class _ZodBigInt extends ZodType {
6295
6338
  if (this._def.coerce) {
6296
6339
  try {
6297
6340
  input.data = BigInt(input.data);
6298
- } catch (e6) {
6341
+ } catch (e7) {
6299
6342
  return this._getInvalidInput(input);
6300
6343
  }
6301
6344
  }
@@ -10899,7 +10942,7 @@ var _BrowserAgent = class _BrowserAgent {
10899
10942
  let argsParsed;
10900
10943
  try {
10901
10944
  argsParsed = typeof item.arguments === "string" ? JSON.parse(item.arguments) : item.arguments;
10902
- } catch (e7) {
10945
+ } catch (e8) {
10903
10946
  logWarn(`Warning: Could not parse arguments JSON: ${item.arguments}`);
10904
10947
  argsParsed = item.arguments;
10905
10948
  }
@@ -10955,7 +10998,7 @@ var _BrowserAgent = class _BrowserAgent {
10955
10998
  let argsParsed;
10956
10999
  try {
10957
11000
  argsParsed = typeof item.arguments === "string" ? JSON.parse(item.arguments) : item.arguments;
10958
- } catch (e8) {
11001
+ } catch (e9) {
10959
11002
  logWarn(
10960
11003
  `Warning: Could not parse arguments JSON: ${item.arguments}`
10961
11004
  );
@@ -12103,7 +12146,7 @@ var _Browser = class _Browser {
12103
12146
  */
12104
12147
  async destroy() {
12105
12148
  if (this.isInitialized()) {
12106
- await this.session.callMcpTool("stopChrome", {});
12149
+ await this.session.callMcpTool("stopChrome", {}, false, "wuying_cdp_mcp_server");
12107
12150
  } else {
12108
12151
  throw new BrowserError("Browser is not initialized. Cannot destroy browser.");
12109
12152
  }
@@ -12133,22 +12176,17 @@ var _Browser = class _Browser {
12133
12176
  throw new BrowserError("Browser is not initialized. Cannot access endpoint URL.");
12134
12177
  }
12135
12178
  try {
12136
- if (this.session.isVpc) {
12137
- logDebug(`VPC mode, endpoint_router_port: ${this.session.httpPort}`);
12138
- this._endpointUrl = `ws://${this.session.networkInterfaceIp}:${this.session.httpPort}`;
12179
+ const { GetCdpLinkRequest: GetCdpLinkRequest2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./model-662HEOBJ.cjs")));
12180
+ const request = new GetCdpLinkRequest2({
12181
+ authorization: `Bearer ${this.session.getAPIKey()}`,
12182
+ sessionId: this.session.sessionId
12183
+ });
12184
+ const response = await this.session.getAgentBay().getClient().getCdpLink(request);
12185
+ if (response.body && response.body.success && response.body.data) {
12186
+ this._endpointUrl = response.body.data.url || null;
12139
12187
  } else {
12140
- const { GetCdpLinkRequest: GetCdpLinkRequest2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./model-662HEOBJ.cjs")));
12141
- const request = new GetCdpLinkRequest2({
12142
- authorization: `Bearer ${this.session.getAPIKey()}`,
12143
- sessionId: this.session.sessionId
12144
- });
12145
- const response = await this.session.getAgentBay().getClient().getCdpLink(request);
12146
- if (response.body && response.body.success && response.body.data) {
12147
- this._endpointUrl = response.body.data.url || null;
12148
- } else {
12149
- const errorMsg = _optionalChain([response, 'access', _149 => _149.body, 'optionalAccess', _150 => _150.message]) || "Unknown error";
12150
- throw new BrowserError(`Failed to get CDP link: ${errorMsg}`);
12151
- }
12188
+ const errorMsg = _optionalChain([response, 'access', _149 => _149.body, 'optionalAccess', _150 => _150.message]) || "Unknown error";
12189
+ throw new BrowserError(`Failed to get CDP link: ${errorMsg}`);
12152
12190
  }
12153
12191
  return this._endpointUrl;
12154
12192
  } catch (error) {
@@ -12172,7 +12210,7 @@ var _Browser = class _Browser {
12172
12210
  */
12173
12211
  _stopBrowser() {
12174
12212
  if (this.isInitialized()) {
12175
- this.session.callMcpTool("stopChrome", {});
12213
+ this.session.callMcpTool("stopChrome", {}, false, "wuying_cdp_mcp_server");
12176
12214
  } else {
12177
12215
  throw new BrowserError("Browser is not initialized. Cannot stop browser.");
12178
12216
  }
@@ -12262,7 +12300,7 @@ var _Browser = class _Browser {
12262
12300
  let errorStr;
12263
12301
  try {
12264
12302
  errorStr = String(error);
12265
- } catch (e9) {
12303
+ } catch (e10) {
12266
12304
  errorStr = "Unknown error occurred";
12267
12305
  }
12268
12306
  const errorMsg = `Failed to capture screenshot: ${errorStr}`;
@@ -12462,7 +12500,7 @@ var _Code = class _Code {
12462
12500
  errorMessage: response.errorMessage
12463
12501
  };
12464
12502
  }
12465
- } catch (e10) {
12503
+ } catch (e11) {
12466
12504
  return {
12467
12505
  requestId: response.requestId,
12468
12506
  success: false,
@@ -12667,7 +12705,7 @@ var _Command = class _Command {
12667
12705
  errorMessage: stderr || result.errorMessage
12668
12706
  };
12669
12707
  }
12670
- } catch (e11) {
12708
+ } catch (e12) {
12671
12709
  }
12672
12710
  return {
12673
12711
  requestId: result.requestId,
@@ -17600,6 +17638,16 @@ _chunkJB6CNGN4cjs.__name.call(void 0, _Oss, "Oss");
17600
17638
  var Oss = _Oss;
17601
17639
 
17602
17640
  // src/session.ts
17641
+ async function fetchCompat(input, init) {
17642
+ const f = globalThis.fetch;
17643
+ if (typeof f === "function") {
17644
+ return await f(input, init);
17645
+ }
17646
+ const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("node-fetch")));
17647
+ const nodeFetch = mod.default || mod;
17648
+ return await nodeFetch(input, init);
17649
+ }
17650
+ _chunkJB6CNGN4cjs.__name.call(void 0, fetchCompat, "fetchCompat");
17603
17651
  var _SessionInfoClass = class _SessionInfoClass {
17604
17652
  constructor(sessionId = "", resourceUrl = "", appId = "", authCode = "", connectionProperties = "", resourceId = "", resourceType = "", ticket = "") {
17605
17653
  this.sessionId = sessionId;
@@ -17623,19 +17671,11 @@ var _Session = class _Session {
17623
17671
  * @param sessionId - The ID of this session.
17624
17672
  */
17625
17673
  constructor(agentBay, sessionId) {
17626
- // VPC-related information
17627
- this.isVpc = false;
17628
- // Whether this session uses VPC resources
17629
- this.networkInterfaceIp = "";
17630
- // Network interface IP for VPC sessions
17631
- this.httpPort = "";
17632
- // HTTP port for VPC sessions
17633
- this.token = "";
17634
- // Token for VPC sessions
17635
- this.linkUrl = "";
17636
- // LinkUrl for LinkUrl-based VPC route
17637
17674
  // Resource URL for accessing the session
17638
17675
  this.resourceUrl = "";
17676
+ // LinkUrl-based direct tool call (non-VPC)
17677
+ this.token = "";
17678
+ this.linkUrl = "";
17639
17679
  // Recording functionality
17640
17680
  this.enableBrowserReplay = false;
17641
17681
  this.agentBay = agentBay;
@@ -17687,6 +17727,12 @@ var _Session = class _Session {
17687
17727
  getAPIKey() {
17688
17728
  return this.agentBay.getAPIKey();
17689
17729
  }
17730
+ getToken() {
17731
+ return this.token;
17732
+ }
17733
+ getLinkUrl() {
17734
+ return this.linkUrl;
17735
+ }
17690
17736
  /**
17691
17737
  * Return the HTTP client for this session.
17692
17738
  *
@@ -17781,45 +17827,6 @@ var _Session = class _Session {
17781
17827
  };
17782
17828
  }
17783
17829
  }
17784
- /**
17785
- * Return whether this session uses VPC resources.
17786
- *
17787
- * @returns boolean indicating if VPC is enabled for this session
17788
- * @internal
17789
- */
17790
- isVpcEnabled() {
17791
- return this.isVpc;
17792
- }
17793
- /**
17794
- * Return the network interface IP for VPC sessions.
17795
- *
17796
- * @returns The network interface IP string for VPC sessions
17797
- * @internal
17798
- */
17799
- getNetworkInterfaceIp() {
17800
- return this.networkInterfaceIp;
17801
- }
17802
- /**
17803
- * Return the HTTP port for VPC sessions.
17804
- *
17805
- * @returns The HTTP port string for VPC sessions
17806
- * @internal
17807
- */
17808
- getHttpPort() {
17809
- return this.httpPort;
17810
- }
17811
- /**
17812
- * Return the token for VPC sessions.
17813
- *
17814
- * @returns The token string for VPC sessions
17815
- * @internal
17816
- */
17817
- getToken() {
17818
- return this.token;
17819
- }
17820
- getLinkUrl() {
17821
- return this.linkUrl;
17822
- }
17823
17830
  /**
17824
17831
  * Delete this session.
17825
17832
  *
@@ -18551,165 +18558,80 @@ var _Session = class _Session {
18551
18558
  if (this.getLinkUrl() && this.getToken()) {
18552
18559
  return await this.callMcpToolLinkUrl(toolName, args, serverName);
18553
18560
  }
18554
- if (this.isVpcEnabled()) {
18555
- const server = serverName || "";
18556
- if (!server) {
18557
- return {
18558
- success: false,
18559
- data: "",
18560
- errorMessage: `Server not found for tool: ${toolName}`,
18561
- requestId: ""
18562
- };
18563
- }
18564
- if (!this.networkInterfaceIp || !this.httpPort) {
18565
- return {
18566
- success: false,
18567
- data: "",
18568
- errorMessage: `VPC network configuration incomplete: networkInterfaceIp=${this.networkInterfaceIp}, httpPort=${this.httpPort}. This may indicate the VPC session was not properly configured with network parameters.`,
18569
- requestId: ""
18570
- };
18571
- }
18572
- const baseURL = `http://${this.networkInterfaceIp}:${this.httpPort}/callTool`;
18573
- const url = new URL(baseURL);
18574
- url.searchParams.append("server", server);
18575
- url.searchParams.append("tool", toolName);
18576
- url.searchParams.append("args", argsJSON);
18577
- url.searchParams.append("token", this.getToken());
18578
- const requestId = `vpc-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
18579
- url.searchParams.append("requestId", requestId);
18580
- setRequestId(requestId);
18581
- const response = await fetch(url.toString(), {
18582
- method: "GET",
18583
- headers: {
18584
- "Content-Type": "application/x-www-form-urlencoded"
18585
- }
18586
- });
18587
- if (!response.ok) {
18588
- return {
18589
- success: false,
18590
- data: "",
18591
- errorMessage: `VPC request failed: ${response.statusText}`,
18592
- requestId
18593
- };
18594
- }
18595
- const responseData = await response.json();
18596
- let actualResult = responseData;
18597
- if (typeof responseData.data === "string") {
18598
- try {
18599
- const dataMap = JSON.parse(responseData.data);
18600
- if (dataMap.result) {
18601
- actualResult = dataMap.result;
18602
- }
18603
- } catch (err) {
18604
- }
18605
- } else if (responseData.data && responseData.data.result) {
18606
- actualResult = responseData.data.result;
18607
- }
18608
- let textContent = "";
18609
- if (actualResult.content && Array.isArray(actualResult.content) && actualResult.content.length > 0) {
18610
- const contentItem = actualResult.content[0];
18611
- if (contentItem) {
18612
- if (typeof contentItem.text === "string" && contentItem.text) {
18613
- textContent = contentItem.text;
18614
- } else if (typeof contentItem.blob === "string" && contentItem.blob) {
18615
- textContent = contentItem.blob;
18616
- } else if (typeof contentItem.data === "string" && contentItem.data) {
18617
- textContent = contentItem.data;
18618
- }
18619
- }
18620
- }
18621
- if (toolName === "run_code" && actualResult) {
18622
- const dataStr = typeof actualResult === "string" ? actualResult : JSON.stringify(actualResult);
18623
- logCodeExecutionOutput(requestId, dataStr);
18624
- return {
18625
- success: true,
18626
- data: dataStr,
18627
- errorMessage: "",
18628
- requestId
18629
- };
18630
- }
18561
+ const callToolRequest = new (0, _chunkQGXJA3GTcjs.CallMcpToolRequest)({
18562
+ authorization: `Bearer ${this.getAPIKey()}`,
18563
+ sessionId: this.getSessionId(),
18564
+ name: toolName,
18565
+ args: argsJSON,
18566
+ autoGenSession
18567
+ });
18568
+ const response = await this.getClient().callMcpTool(callToolRequest);
18569
+ if (!_optionalChain([response, 'access', _205 => _205.body, 'optionalAccess', _206 => _206.data])) {
18631
18570
  return {
18632
- success: true,
18633
- data: textContent || JSON.stringify(actualResult),
18634
- errorMessage: "",
18635
- requestId
18571
+ success: false,
18572
+ data: "",
18573
+ errorMessage: "Invalid response data format",
18574
+ requestId: extractRequestId(response) || ""
18636
18575
  };
18637
- } else {
18638
- const callToolRequest = new (0, _chunkQGXJA3GTcjs.CallMcpToolRequest)({
18639
- authorization: `Bearer ${this.getAPIKey()}`,
18640
- sessionId: this.getSessionId(),
18641
- name: toolName,
18642
- args: argsJSON,
18643
- autoGenSession
18644
- });
18645
- const response = await this.getClient().callMcpTool(callToolRequest);
18646
- if (!_optionalChain([response, 'access', _205 => _205.body, 'optionalAccess', _206 => _206.data])) {
18647
- return {
18648
- success: false,
18649
- data: "",
18650
- errorMessage: "Invalid response data format",
18651
- requestId: extractRequestId(response) || ""
18652
- };
18653
- }
18654
- if (response.body.success === false && response.body.code) {
18655
- const errorMessage = `[${response.body.code}] ${response.body.message || "Unknown error"}`;
18656
- return {
18657
- success: false,
18658
- data: "",
18659
- errorMessage,
18660
- requestId: extractRequestId(response) || ""
18661
- };
18662
- }
18663
- const data = response.body.data;
18664
- const reqId = extractRequestId(response) || "";
18665
- if (reqId) {
18666
- setRequestId(reqId);
18667
- }
18668
- if (toolName === "run_code") {
18669
- let dataStr = "";
18670
- if (data && Array.isArray(data.content) && data.content.length > 0 && data.content[0].text) {
18671
- dataStr = data.content[0].text;
18672
- } else {
18673
- dataStr = typeof response.body.data === "string" ? response.body.data : JSON.stringify(response.body.data);
18674
- }
18675
- logCodeExecutionOutput(reqId, dataStr);
18676
- const isError = data.isError === true;
18677
- return {
18678
- success: !isError,
18679
- data: dataStr,
18680
- errorMessage: isError ? dataStr : "",
18681
- requestId: reqId
18682
- };
18683
- }
18684
- if (data.isError) {
18685
- const errorContent = data.content || [];
18686
- const errorMessage = errorContent.map((item) => item.text || "Unknown error").join("; ");
18687
- return {
18688
- success: false,
18689
- data: "",
18690
- errorMessage,
18691
- requestId: reqId
18692
- };
18693
- }
18694
- const content = data.content || [];
18695
- let textContent = "";
18696
- if (content.length > 0) {
18697
- const c0 = content[0] || {};
18698
- if (typeof c0.text === "string" && c0.text) {
18699
- textContent = c0.text;
18700
- } else if (typeof c0.blob === "string" && c0.blob) {
18701
- textContent = c0.blob;
18702
- } else if (typeof c0.data === "string" && c0.data) {
18703
- textContent = c0.data;
18704
- }
18576
+ }
18577
+ if (response.body.success === false && response.body.code) {
18578
+ const errorMessage = `[${response.body.code}] ${response.body.message || "Unknown error"}`;
18579
+ return {
18580
+ success: false,
18581
+ data: "",
18582
+ errorMessage,
18583
+ requestId: extractRequestId(response) || ""
18584
+ };
18585
+ }
18586
+ const data = response.body.data;
18587
+ const reqId = extractRequestId(response) || "";
18588
+ if (reqId) {
18589
+ setRequestId(reqId);
18590
+ }
18591
+ if (toolName === "run_code") {
18592
+ let dataStr = "";
18593
+ if (data && Array.isArray(data.content) && data.content.length > 0 && data.content[0].text) {
18594
+ dataStr = data.content[0].text;
18595
+ } else {
18596
+ dataStr = typeof response.body.data === "string" ? response.body.data : JSON.stringify(response.body.data);
18705
18597
  }
18598
+ logCodeExecutionOutput(reqId, dataStr);
18599
+ const isError = data.isError === true;
18706
18600
  return {
18707
- success: true,
18708
- data: textContent || JSON.stringify(data),
18709
- errorMessage: "",
18601
+ success: !isError,
18602
+ data: dataStr,
18603
+ errorMessage: isError ? dataStr : "",
18710
18604
  requestId: reqId
18711
18605
  };
18712
18606
  }
18607
+ if (data.isError) {
18608
+ const errorContent = data.content || [];
18609
+ const errorMessage = errorContent.map((item) => item.text || "Unknown error").join("; ");
18610
+ return {
18611
+ success: false,
18612
+ data: "",
18613
+ errorMessage,
18614
+ requestId: reqId
18615
+ };
18616
+ }
18617
+ const content = data.content || [];
18618
+ let textContent = "";
18619
+ if (content.length > 0) {
18620
+ const c0 = content[0] || {};
18621
+ if (typeof c0.text === "string" && c0.text) {
18622
+ textContent = c0.text;
18623
+ } else if (typeof c0.blob === "string" && c0.blob) {
18624
+ textContent = c0.blob;
18625
+ } else if (typeof c0.data === "string" && c0.data) {
18626
+ textContent = c0.data;
18627
+ }
18628
+ }
18629
+ return {
18630
+ success: true,
18631
+ data: textContent || JSON.stringify(data),
18632
+ errorMessage: "",
18633
+ requestId: reqId
18634
+ };
18713
18635
  } catch (error) {
18714
18636
  return {
18715
18637
  success: false,
@@ -18720,38 +18642,40 @@ var _Session = class _Session {
18720
18642
  }
18721
18643
  }
18722
18644
  async callMcpToolLinkUrl(toolName, args, serverName) {
18723
- const server = serverName || "";
18724
- if (!server) {
18645
+ if (!serverName) {
18725
18646
  return {
18726
18647
  success: false,
18727
18648
  data: "",
18728
- errorMessage: `Server not found for tool: ${toolName}`,
18649
+ errorMessage: `Server name is required for LinkUrl tool call: ${toolName}`,
18729
18650
  requestId: ""
18730
18651
  };
18731
18652
  }
18732
- const requestId = `link-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
18733
- const linkUrl = this.getLinkUrl().replace(/\/+$/, "");
18653
+ const linkUrl = this.getLinkUrl();
18734
18654
  const token = this.getToken();
18735
- const argsLength = JSON.stringify(args).length;
18736
- logAPICall("CallMcpTool(LinkUrl)", "");
18737
- logAPIResponseWithDetails(
18738
- "CallMcpTool(LinkUrl) Request",
18739
- requestId,
18740
- true,
18741
- {
18742
- tool_name: toolName,
18743
- command: typeof _optionalChain([args, 'optionalAccess', _207 => _207.command]) === "string" ? args.command : JSON.stringify(args).slice(0, 500) + (JSON.stringify(args).length > 500 ? "...(truncated)" : "")
18744
- },
18745
- ""
18655
+ if (!linkUrl || !token) {
18656
+ return {
18657
+ success: false,
18658
+ data: "",
18659
+ errorMessage: "LinkUrl/token not available",
18660
+ requestId: ""
18661
+ };
18662
+ }
18663
+ const requestId = `link-${Date.now()}-${Math.floor(
18664
+ Math.random() * 1e9
18665
+ ).toString().padStart(9, "0")}`;
18666
+ logAPICall(
18667
+ "CallMcpTool(LinkUrl)",
18668
+ `Tool=${toolName}, ArgsLength=${JSON.stringify(args).length}, RequestId=${requestId}`
18746
18669
  );
18670
+ const url = `${linkUrl.replace(/\/+$/, "")}/callTool`;
18747
18671
  const payload = {
18748
18672
  args,
18749
- server,
18673
+ server: serverName,
18750
18674
  requestId,
18751
18675
  tool: toolName,
18752
18676
  token
18753
18677
  };
18754
- const response = await fetch(`${linkUrl}/callTool`, {
18678
+ const resp = await fetchCompat(url, {
18755
18679
  method: "POST",
18756
18680
  headers: {
18757
18681
  "Content-Type": "application/json",
@@ -18759,93 +18683,59 @@ var _Session = class _Session {
18759
18683
  },
18760
18684
  body: JSON.stringify(payload)
18761
18685
  });
18762
- if (!response.ok) {
18686
+ if (!resp.ok) {
18687
+ const bodyText = await resp.text().catch(() => "");
18763
18688
  logAPIResponseWithDetails(
18764
18689
  "CallMcpTool(LinkUrl) Response",
18765
18690
  requestId,
18766
18691
  false,
18767
- {
18768
- http_status: response.status,
18769
- tool_name: toolName
18770
- },
18771
- ""
18692
+ { http_status: resp.status, tool_name: toolName },
18693
+ bodyText
18772
18694
  );
18773
18695
  return {
18774
18696
  success: false,
18775
18697
  data: "",
18776
- errorMessage: `VPC request failed with code: ${response.status}`,
18777
- requestId
18778
- };
18779
- }
18780
- const outer = await response.json();
18781
- const dataField = _optionalChain([outer, 'optionalAccess', _208 => _208.data]);
18782
- if (dataField === void 0 || dataField === null) {
18783
- return {
18784
- success: false,
18785
- data: "",
18786
- errorMessage: "No data field in LinkUrl response",
18698
+ errorMessage: `HTTP request failed with code: ${resp.status}`,
18787
18699
  requestId
18788
18700
  };
18789
18701
  }
18702
+ const outer = await resp.json();
18703
+ const dataField = _optionalChain([outer, 'optionalAccess', _207 => _207.data]);
18790
18704
  let parsedData = dataField;
18791
18705
  if (typeof dataField === "string") {
18792
- try {
18793
- parsedData = JSON.parse(dataField);
18794
- } catch (err) {
18795
- return {
18796
- success: false,
18797
- data: "",
18798
- errorMessage: `Invalid data field JSON in LinkUrl response: ${err}`,
18799
- requestId
18800
- };
18801
- }
18802
- }
18803
- const result = _optionalChain([parsedData, 'optionalAccess', _209 => _209.result]);
18804
- if (!result) {
18805
- return {
18806
- success: false,
18807
- data: "",
18808
- errorMessage: "No result field in LinkUrl response data",
18809
- requestId
18810
- };
18811
- }
18812
- const isError = result.isError === true;
18813
- let textContent = "";
18814
- if (Array.isArray(result.content) && result.content.length > 0) {
18815
- const contentItem = result.content[0];
18816
- if (contentItem) {
18817
- if (typeof contentItem.text === "string" && contentItem.text) {
18818
- textContent = contentItem.text;
18819
- } else if (typeof contentItem.blob === "string" && contentItem.blob) {
18820
- textContent = contentItem.blob;
18821
- } else if (typeof contentItem.data === "string" && contentItem.data) {
18822
- textContent = contentItem.data;
18823
- }
18824
- }
18706
+ parsedData = JSON.parse(dataField);
18825
18707
  }
18708
+ const resultField = _optionalChain([parsedData, 'optionalAccess', _208 => _208.result]);
18709
+ const isError = _optionalChain([resultField, 'optionalAccess', _209 => _209.isError]) === true;
18710
+ const content = Array.isArray(_optionalChain([resultField, 'optionalAccess', _210 => _210.content])) ? resultField.content : [];
18711
+ const first = _nullishCoalesce(content[0], () => ( {}));
18712
+ const textContent = typeof first === "string" ? first : _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(first.text, () => ( first.blob)), () => ( first.data)), () => ( ""));
18826
18713
  logAPIResponseWithDetails(
18827
18714
  "CallMcpTool(LinkUrl) Response",
18828
18715
  requestId,
18829
18716
  !isError,
18830
18717
  {
18831
- http_status: response.status,
18832
18718
  tool_name: toolName,
18833
- output: textContent.length > 800 ? textContent.slice(0, 800) + "...(truncated)" : textContent
18719
+ server: serverName,
18720
+ is_error: isError,
18721
+ data_len: String(_nullishCoalesce(textContent, () => ( ""))).length
18834
18722
  },
18835
- ""
18723
+ isError ? String(_nullishCoalesce(textContent, () => ( ""))) : ""
18836
18724
  );
18837
- if (isError) {
18725
+ if (toolName === "run_code") {
18726
+ const dataStr = typeof textContent === "string" ? textContent : JSON.stringify(textContent);
18727
+ logCodeExecutionOutput(requestId, dataStr);
18838
18728
  return {
18839
- success: false,
18840
- data: "",
18841
- errorMessage: textContent,
18729
+ success: !isError,
18730
+ data: dataStr,
18731
+ errorMessage: isError ? dataStr : "",
18842
18732
  requestId
18843
18733
  };
18844
18734
  }
18845
18735
  return {
18846
- success: true,
18847
- data: textContent || JSON.stringify(result),
18848
- errorMessage: "",
18736
+ success: !isError,
18737
+ data: String(_nullishCoalesce(textContent, () => ( ""))),
18738
+ errorMessage: isError ? String(_nullishCoalesce(textContent, () => ( ""))) : "",
18849
18739
  requestId
18850
18740
  };
18851
18741
  }
@@ -18913,12 +18803,12 @@ var _Session = class _Session {
18913
18803
  success: false,
18914
18804
  data: void 0,
18915
18805
  raw: void 0,
18916
- errorMessage: `Failed to parse get_metrics response: ${_optionalChain([err, 'optionalAccess', _210 => _210.message]) || String(err)}`
18806
+ errorMessage: `Failed to parse get_metrics response: ${_optionalChain([err, 'optionalAccess', _211 => _211.message]) || String(err)}`
18917
18807
  };
18918
18808
  }
18919
18809
  }
18920
18810
  /**
18921
- * Asynchronously pause this session, putting it into a dormant state.
18811
+ * Asynchronously pause this session (beta), putting it into a dormant state.
18922
18812
  *
18923
18813
  * This method calls the PauseSessionAsync API to initiate the pause operation and then polls
18924
18814
  * the GetSession API to check the session status until it becomes PAUSED or until timeout is reached.
@@ -18940,7 +18830,7 @@ var _Session = class _Session {
18940
18830
  * const agentBay = new AgentBay({ apiKey: 'your_api_key' });
18941
18831
  * const result = await agentBay.create();
18942
18832
  * if (result.success) {
18943
- * const pauseResult = await result.session.pauseAsync();
18833
+ * const pauseResult = await result.session.betaPauseAsync();
18944
18834
  * if (pauseResult.success) {
18945
18835
  * console.log('Session paused successfully');
18946
18836
  * }
@@ -18956,13 +18846,13 @@ var _Session = class _Session {
18956
18846
  *
18957
18847
  * **Important Notes:**
18958
18848
  * - Paused sessions cannot perform operations (deletion, task execution, etc.)
18959
- * - Use {@link resumeAsync} to restore the session to RUNNING state
18849
+ * - Use {@link betaResumeAsync} to restore the session to RUNNING state
18960
18850
  * - During pause, both resource usage and costs are lower
18961
18851
  * - If timeout is exceeded, returns with success=false
18962
18852
  *
18963
- * @see {@link resumeAsync}
18853
+ * @see {@link betaResumeAsync}
18964
18854
  */
18965
- async pauseAsync(timeout = 600, pollInterval = 2) {
18855
+ async betaPauseAsync(timeout = 600, pollInterval = 2) {
18966
18856
  try {
18967
18857
  const request = new (0, _chunkQGXJA3GTcjs.PauseSessionAsyncRequest)({
18968
18858
  authorization: `Bearer ${this.getAPIKey()}`,
@@ -19065,7 +18955,7 @@ var _Session = class _Session {
19065
18955
  }
19066
18956
  }
19067
18957
  /**
19068
- * Asynchronously resume this session from a paused state.
18958
+ * Asynchronously resume this session (beta) from a paused state.
19069
18959
  *
19070
18960
  * This method calls the ResumeSessionAsync API to initiate the resume operation and then polls
19071
18961
  * the GetSession API to check the session status until it becomes RUNNING or until timeout is reached.
@@ -19087,7 +18977,7 @@ var _Session = class _Session {
19087
18977
  * const agentBay = new AgentBay({ apiKey: 'your_api_key' });
19088
18978
  * const result = await agentBay.get('paused_session_id');
19089
18979
  * if (result.success) {
19090
- * const resumeResult = await result.session.resumeAsync();
18980
+ * const resumeResult = await result.session.betaResumeAsync();
19091
18981
  * if (resumeResult.success) {
19092
18982
  * console.log('Session resumed successfully');
19093
18983
  * }
@@ -19104,12 +18994,12 @@ var _Session = class _Session {
19104
18994
  * **Important Notes:**
19105
18995
  * - Only sessions in PAUSED state can be resumed
19106
18996
  * - After resume, the session can perform all operations normally
19107
- * - Use {@link pauseAsync} to put a session into PAUSED state
18997
+ * - Use {@link betaPauseAsync} to put a session into PAUSED state
19108
18998
  * - If timeout is exceeded, returns with success=false
19109
18999
  *
19110
- * @see {@link pauseAsync}
19000
+ * @see {@link betaPauseAsync}
19111
19001
  */
19112
- async resumeAsync(timeout = 600, pollInterval = 2) {
19002
+ async betaResumeAsync(timeout = 600, pollInterval = 2) {
19113
19003
  try {
19114
19004
  const request = new (0, _chunkQGXJA3GTcjs.ResumeSessionAsyncRequest)({
19115
19005
  authorization: `Bearer ${this.getAPIKey()}`,
@@ -19265,9 +19155,9 @@ var _BetaVolumeService = class _BetaVolumeService {
19265
19155
  });
19266
19156
  logAPICall("GetVolume(beta)", { volumeName: name, allowCreate: !!create, imageId });
19267
19157
  const resp = await this.agentBay.client.getVolume(req);
19268
- const requestId = _optionalChain([resp, 'optionalAccess', _211 => _211.body, 'optionalAccess', _212 => _212.requestId]) || "";
19269
- const success = !!_optionalChain([resp, 'optionalAccess', _213 => _213.body, 'optionalAccess', _214 => _214.success]);
19270
- if (!success && _optionalChain([resp, 'optionalAccess', _215 => _215.body, 'optionalAccess', _216 => _216.code])) {
19158
+ const requestId = _optionalChain([resp, 'optionalAccess', _212 => _212.body, 'optionalAccess', _213 => _213.requestId]) || "";
19159
+ const success = !!_optionalChain([resp, 'optionalAccess', _214 => _214.body, 'optionalAccess', _215 => _215.success]);
19160
+ if (!success && _optionalChain([resp, 'optionalAccess', _216 => _216.body, 'optionalAccess', _217 => _217.code])) {
19271
19161
  return {
19272
19162
  requestId,
19273
19163
  success: false,
@@ -19275,10 +19165,10 @@ var _BetaVolumeService = class _BetaVolumeService {
19275
19165
  errorMessage: `[${resp.body.code}] ${resp.body.message || "Unknown error"}`
19276
19166
  };
19277
19167
  }
19278
- const data = _optionalChain([resp, 'optionalAccess', _217 => _217.body, 'optionalAccess', _218 => _218.data]);
19279
- const vid = _optionalChain([data, 'optionalAccess', _219 => _219.volumeId]) || "";
19168
+ const data = _optionalChain([resp, 'optionalAccess', _218 => _218.body, 'optionalAccess', _219 => _219.data]);
19169
+ const vid = _optionalChain([data, 'optionalAccess', _220 => _220.volumeId]) || "";
19280
19170
  if (!vid) {
19281
- logAPIResponseWithDetails("GetVolume(beta)", requestId, false, {}, JSON.stringify(_optionalChain([resp, 'optionalAccess', _220 => _220.body]) || {}));
19171
+ logAPIResponseWithDetails("GetVolume(beta)", requestId, false, {}, JSON.stringify(_optionalChain([resp, 'optionalAccess', _221 => _221.body]) || {}));
19282
19172
  return {
19283
19173
  requestId,
19284
19174
  success: false,
@@ -19288,12 +19178,12 @@ var _BetaVolumeService = class _BetaVolumeService {
19288
19178
  }
19289
19179
  const volume = {
19290
19180
  id: vid,
19291
- name: _optionalChain([data, 'optionalAccess', _221 => _221.volumeName]) || "",
19292
- belongingImageId: _optionalChain([data, 'optionalAccess', _222 => _222.belongingImageId]),
19293
- status: _optionalChain([data, 'optionalAccess', _223 => _223.status]),
19294
- createdAt: _optionalChain([data, 'optionalAccess', _224 => _224.createTime])
19181
+ name: _optionalChain([data, 'optionalAccess', _222 => _222.volumeName]) || "",
19182
+ belongingImageId: _optionalChain([data, 'optionalAccess', _223 => _223.belongingImageId]),
19183
+ status: _optionalChain([data, 'optionalAccess', _224 => _224.status]),
19184
+ createdAt: _optionalChain([data, 'optionalAccess', _225 => _225.createTime])
19295
19185
  };
19296
- logAPIResponseWithDetails("GetVolume(beta)", requestId, true, { volume_id: vid }, JSON.stringify(_optionalChain([resp, 'optionalAccess', _225 => _225.body]) || {}));
19186
+ logAPIResponseWithDetails("GetVolume(beta)", requestId, true, { volume_id: vid }, JSON.stringify(_optionalChain([resp, 'optionalAccess', _226 => _226.body]) || {}));
19297
19187
  return { requestId, success: true, volume };
19298
19188
  }
19299
19189
  async list(params) {
@@ -19311,9 +19201,9 @@ var _BetaVolumeService = class _BetaVolumeService {
19311
19201
  });
19312
19202
  logAPICall("ListVolumes(beta)", { imageId, maxResults: _nullishCoalesce(maxResults, () => ( 10)) });
19313
19203
  const resp = await this.agentBay.client.listVolumes(req);
19314
- const requestId = _optionalChain([resp, 'optionalAccess', _226 => _226.body, 'optionalAccess', _227 => _227.requestId]) || "";
19315
- const success = !!_optionalChain([resp, 'optionalAccess', _228 => _228.body, 'optionalAccess', _229 => _229.success]);
19316
- if (!success && _optionalChain([resp, 'optionalAccess', _230 => _230.body, 'optionalAccess', _231 => _231.code])) {
19204
+ const requestId = _optionalChain([resp, 'optionalAccess', _227 => _227.body, 'optionalAccess', _228 => _228.requestId]) || "";
19205
+ const success = !!_optionalChain([resp, 'optionalAccess', _229 => _229.body, 'optionalAccess', _230 => _230.success]);
19206
+ if (!success && _optionalChain([resp, 'optionalAccess', _231 => _231.body, 'optionalAccess', _232 => _232.code])) {
19317
19207
  return {
19318
19208
  requestId,
19319
19209
  success: false,
@@ -19321,7 +19211,7 @@ var _BetaVolumeService = class _BetaVolumeService {
19321
19211
  errorMessage: `[${resp.body.code}] ${resp.body.message || "Unknown error"}`
19322
19212
  };
19323
19213
  }
19324
- const volumes = (_optionalChain([resp, 'optionalAccess', _232 => _232.body, 'optionalAccess', _233 => _233.data]) || []).filter((it) => !!_optionalChain([it, 'optionalAccess', _234 => _234.volumeId])).map((it) => ({
19214
+ const volumes = (_optionalChain([resp, 'optionalAccess', _233 => _233.body, 'optionalAccess', _234 => _234.data]) || []).filter((it) => !!_optionalChain([it, 'optionalAccess', _235 => _235.volumeId])).map((it) => ({
19325
19215
  id: it.volumeId,
19326
19216
  name: it.volumeName || "",
19327
19217
  belongingImageId: it.belongingImageId,
@@ -19332,8 +19222,8 @@ var _BetaVolumeService = class _BetaVolumeService {
19332
19222
  requestId,
19333
19223
  success: true,
19334
19224
  volumes,
19335
- nextToken: _optionalChain([resp, 'optionalAccess', _235 => _235.body, 'optionalAccess', _236 => _236.nextToken]),
19336
- maxResults: _optionalChain([resp, 'optionalAccess', _237 => _237.body, 'optionalAccess', _238 => _238.maxResults]),
19225
+ nextToken: _optionalChain([resp, 'optionalAccess', _236 => _236.body, 'optionalAccess', _237 => _237.nextToken]),
19226
+ maxResults: _optionalChain([resp, 'optionalAccess', _238 => _238.body, 'optionalAccess', _239 => _239.maxResults]),
19337
19227
  totalCount: volumes.length,
19338
19228
  errorMessage: ""
19339
19229
  };
@@ -19349,9 +19239,9 @@ var _BetaVolumeService = class _BetaVolumeService {
19349
19239
  logAPICall("DeleteVolume(beta)", { volumeId });
19350
19240
  try {
19351
19241
  const resp = await this.agentBay.client.deleteVolume(req);
19352
- const requestId = _optionalChain([resp, 'optionalAccess', _239 => _239.body, 'optionalAccess', _240 => _240.requestId]) || "";
19353
- const success = !!_optionalChain([resp, 'optionalAccess', _241 => _241.body, 'optionalAccess', _242 => _242.success]);
19354
- if (!success && _optionalChain([resp, 'optionalAccess', _243 => _243.body, 'optionalAccess', _244 => _244.code])) {
19242
+ const requestId = _optionalChain([resp, 'optionalAccess', _240 => _240.body, 'optionalAccess', _241 => _241.requestId]) || "";
19243
+ const success = !!_optionalChain([resp, 'optionalAccess', _242 => _242.body, 'optionalAccess', _243 => _243.success]);
19244
+ if (!success && _optionalChain([resp, 'optionalAccess', _244 => _244.body, 'optionalAccess', _245 => _245.code])) {
19355
19245
  return {
19356
19246
  requestId,
19357
19247
  success: false,
@@ -19481,7 +19371,6 @@ var _AgentBay = class _AgentBay {
19481
19371
  * - imageId: Custom image ID for the session environment
19482
19372
  * - contextSync: Array of context synchronization configurations
19483
19373
  * - browserContext: Browser-specific context configuration
19484
- * - isVpc: Whether to create a VPC session
19485
19374
  * - policyId: Security policy ID
19486
19375
  * - enableBrowserReplay: Enable browser session recording
19487
19376
  * - extraConfigs: Additional configuration options
@@ -19510,7 +19399,6 @@ var _AgentBay = class _AgentBay {
19510
19399
  * - Creates a new isolated cloud runtime environment
19511
19400
  * - Automatically creates file transfer context if not provided
19512
19401
  * - Waits for context synchronization if contextSync is specified
19513
- * - For VPC sessions, includes VPC-specific configuration
19514
19402
  * - Browser replay creates a separate recording context
19515
19403
  *
19516
19404
  * @see {@link get}, {@link list}, {@link Session.delete}
@@ -19518,8 +19406,8 @@ var _AgentBay = class _AgentBay {
19518
19406
  async create(params) {
19519
19407
  try {
19520
19408
  const paramsCopy = this.deepCopyParams(params);
19521
- logDebug(`default context syncs length: ${_optionalChain([paramsCopy, 'access', _245 => _245.contextSync, 'optionalAccess', _246 => _246.length])}`);
19522
- if (_optionalChain([paramsCopy, 'access', _247 => _247.extraConfigs, 'optionalAccess', _248 => _248.mobile, 'optionalAccess', _249 => _249.simulateConfig])) {
19409
+ logDebug(`default context syncs length: ${_optionalChain([paramsCopy, 'access', _246 => _246.contextSync, 'optionalAccess', _247 => _247.length])}`);
19410
+ if (_optionalChain([paramsCopy, 'access', _248 => _248.extraConfigs, 'optionalAccess', _249 => _249.mobile, 'optionalAccess', _250 => _250.simulateConfig])) {
19523
19411
  const mobileSimContextId = paramsCopy.extraConfigs.mobile.simulateConfig.simulatedContextId;
19524
19412
  if (mobileSimContextId) {
19525
19413
  const mobileSimContextSync = new ContextSync(
@@ -19539,7 +19427,7 @@ var _AgentBay = class _AgentBay {
19539
19427
  if (paramsCopy.enableBrowserReplay === false) {
19540
19428
  request.enableRecord = false;
19541
19429
  }
19542
- const framework = _optionalChain([paramsCopy, 'optionalAccess', _250 => _250.framework]) || "";
19430
+ const framework = _optionalChain([paramsCopy, 'optionalAccess', _251 => _251.framework]) || "";
19543
19431
  const sdkStatsJson = `{"source":"sdk","sdk_language":"typescript","sdk_version":"${VERSION}","is_release":${IS_RELEASE},"framework":"${framework}"}`;
19544
19432
  request.sdkStats = sdkStatsJson;
19545
19433
  if (this.config.region_id) {
@@ -19568,7 +19456,6 @@ var _AgentBay = class _AgentBay {
19568
19456
  if (paramsCopy.betaNetworkId) {
19569
19457
  request.networkId = paramsCopy.betaNetworkId;
19570
19458
  }
19571
- request.vpcResource = paramsCopy.isVpc || false;
19572
19459
  let needsContextSync = false;
19573
19460
  let needsMobileSim = false;
19574
19461
  let mobileSimMode = void 0;
@@ -19610,7 +19497,7 @@ var _AgentBay = class _AgentBay {
19610
19497
  }
19611
19498
  if (paramsCopy.extraConfigs) {
19612
19499
  request.extraConfigs = JSON.stringify(paramsCopy.extraConfigs);
19613
- if (_optionalChain([paramsCopy, 'access', _251 => _251.extraConfigs, 'access', _252 => _252.mobile, 'optionalAccess', _253 => _253.simulateConfig, 'optionalAccess', _254 => _254.simulate])) {
19500
+ if (_optionalChain([paramsCopy, 'access', _252 => _252.extraConfigs, 'access', _253 => _253.mobile, 'optionalAccess', _254 => _254.simulateConfig, 'optionalAccess', _255 => _255.simulate])) {
19614
19501
  mobileSimPath = paramsCopy.extraConfigs.mobile.simulateConfig.simulatePath;
19615
19502
  if (!mobileSimPath) {
19616
19503
  logInfo("mobile_sim_path is not set now, skip mobile simulate operation");
@@ -19624,7 +19511,6 @@ var _AgentBay = class _AgentBay {
19624
19511
  labels: paramsCopy.labels,
19625
19512
  imageId: paramsCopy.imageId,
19626
19513
  policyId: paramsCopy.policyId,
19627
- isVpc: paramsCopy.isVpc,
19628
19514
  persistenceDataCount: paramsCopy.contextSync ? paramsCopy.contextSync.length : 0
19629
19515
  });
19630
19516
  const response = await this.client.createMcpSession(request);
@@ -19721,20 +19607,9 @@ var _AgentBay = class _AgentBay {
19721
19607
  }
19722
19608
  );
19723
19609
  const session = new Session(this, sessionId);
19724
- session.isVpc = paramsCopy.isVpc || false;
19725
- if (data.networkInterfaceIp) {
19726
- session.networkInterfaceIp = data.networkInterfaceIp;
19727
- }
19728
- if (data.httpPort) {
19729
- session.httpPort = data.httpPort;
19730
- }
19731
- if (data.token) {
19732
- session.token = data.token;
19733
- }
19734
- if (data.linkUrl) {
19735
- session.linkUrl = data.linkUrl;
19736
- }
19737
19610
  session.resourceUrl = resourceUrl;
19611
+ session.token = data.token || "";
19612
+ session.linkUrl = data.linkUrl || "";
19738
19613
  session.enableBrowserReplay = paramsCopy.enableBrowserReplay || false;
19739
19614
  session.imageId = paramsCopy.imageId;
19740
19615
  if (paramsCopy.extraConfigs && paramsCopy.extraConfigs.mobile) {
@@ -19865,9 +19740,9 @@ var _AgentBay = class _AgentBay {
19865
19740
  }
19866
19741
  const response2 = await this.client.listSession(request2);
19867
19742
  const requestId2 = extractRequestId(response2) || "";
19868
- if (!_optionalChain([response2, 'access', _255 => _255.body, 'optionalAccess', _256 => _256.success])) {
19869
- const code = _optionalChain([response2, 'access', _257 => _257.body, 'optionalAccess', _258 => _258.code]) || "Unknown";
19870
- const message = _optionalChain([response2, 'access', _259 => _259.body, 'optionalAccess', _260 => _260.message]) || "Unknown error";
19743
+ if (!_optionalChain([response2, 'access', _256 => _256.body, 'optionalAccess', _257 => _257.success])) {
19744
+ const code = _optionalChain([response2, 'access', _258 => _258.body, 'optionalAccess', _259 => _259.code]) || "Unknown";
19745
+ const message = _optionalChain([response2, 'access', _260 => _260.body, 'optionalAccess', _261 => _261.message]) || "Unknown error";
19871
19746
  return {
19872
19747
  requestId: requestId2,
19873
19748
  success: false,
@@ -19913,9 +19788,9 @@ var _AgentBay = class _AgentBay {
19913
19788
  const response = await this.client.listSession(request);
19914
19789
  const requestId = extractRequestId(response) || "";
19915
19790
  setRequestId(requestId);
19916
- if (!_optionalChain([response, 'access', _261 => _261.body, 'optionalAccess', _262 => _262.success])) {
19917
- const code = _optionalChain([response, 'access', _263 => _263.body, 'optionalAccess', _264 => _264.code]) || "Unknown";
19918
- const message = _optionalChain([response, 'access', _265 => _265.body, 'optionalAccess', _266 => _266.message]) || "Unknown error";
19791
+ if (!_optionalChain([response, 'access', _262 => _262.body, 'optionalAccess', _263 => _263.success])) {
19792
+ const code = _optionalChain([response, 'access', _264 => _264.body, 'optionalAccess', _265 => _265.code]) || "Unknown";
19793
+ const message = _optionalChain([response, 'access', _266 => _266.body, 'optionalAccess', _267 => _267.message]) || "Unknown error";
19919
19794
  logAPIResponseWithDetails(
19920
19795
  "ListSession",
19921
19796
  requestId,
@@ -20034,7 +19909,7 @@ var _AgentBay = class _AgentBay {
20034
19909
  const requestId = extractRequestId(response) || "";
20035
19910
  const body = response.body;
20036
19911
  setRequestId(requestId);
20037
- if (_optionalChain([body, 'optionalAccess', _267 => _267.success]) === false && body.code) {
19912
+ if (_optionalChain([body, 'optionalAccess', _268 => _268.success]) === false && body.code) {
20038
19913
  logAPIResponseWithDetails(
20039
19914
  "GetSession",
20040
19915
  requestId,
@@ -20053,12 +19928,12 @@ var _AgentBay = class _AgentBay {
20053
19928
  }
20054
19929
  const result = {
20055
19930
  requestId,
20056
- httpStatusCode: _optionalChain([body, 'optionalAccess', _268 => _268.httpStatusCode]) || 0,
20057
- code: _optionalChain([body, 'optionalAccess', _269 => _269.code]) || "",
20058
- success: _optionalChain([body, 'optionalAccess', _270 => _270.success]) || false,
19931
+ httpStatusCode: _optionalChain([body, 'optionalAccess', _269 => _269.httpStatusCode]) || 0,
19932
+ code: _optionalChain([body, 'optionalAccess', _270 => _270.code]) || "",
19933
+ success: _optionalChain([body, 'optionalAccess', _271 => _271.success]) || false,
20059
19934
  errorMessage: ""
20060
19935
  };
20061
- if (_optionalChain([body, 'optionalAccess', _271 => _271.data])) {
19936
+ if (_optionalChain([body, 'optionalAccess', _272 => _272.data])) {
20062
19937
  const contextsList = body.data.contexts || [];
20063
19938
  const contexts = [];
20064
19939
  if (Array.isArray(contextsList)) {
@@ -20098,7 +19973,7 @@ var _AgentBay = class _AgentBay {
20098
19973
  return result;
20099
19974
  } catch (error) {
20100
19975
  const errorStr = String(error);
20101
- const errorCode = _optionalChain([error, 'optionalAccess', _272 => _272.data, 'optionalAccess', _273 => _273.Code]) || _optionalChain([error, 'optionalAccess', _274 => _274.code]) || "";
19976
+ const errorCode = _optionalChain([error, 'optionalAccess', _273 => _273.data, 'optionalAccess', _274 => _274.Code]) || _optionalChain([error, 'optionalAccess', _275 => _275.code]) || "";
20102
19977
  if (errorCode === "InvalidMcpSession.NotFound" || errorStr.includes("NotFound")) {
20103
19978
  logInfo(`Session not found: ${sessionId}`);
20104
19979
  logDebug(`GetSession error details: ${errorStr}`);
@@ -20160,11 +20035,8 @@ var _AgentBay = class _AgentBay {
20160
20035
  }
20161
20036
  const session = new Session(this, sessionId);
20162
20037
  if (getResult.data) {
20163
- session.isVpc = getResult.data.vpcResource;
20164
- session.networkInterfaceIp = getResult.data.networkInterfaceIp;
20165
- session.httpPort = getResult.data.httpPort;
20166
- session.token = getResult.data.token;
20167
20038
  session.resourceUrl = getResult.data.resourceUrl;
20039
+ session.token = getResult.data.token || "";
20168
20040
  }
20169
20041
  return {
20170
20042
  requestId: getResult.requestId,
@@ -20218,8 +20090,8 @@ var _AgentBay = class _AgentBay {
20218
20090
  * ```typescript
20219
20091
  * const agentBay = new AgentBay({ apiKey: 'your_api_key' });
20220
20092
  * const session = (await agentBay.create()).session;
20221
- * const pauseResult = await agentBay.pauseAsync(session);
20222
- * await agentBay.resumeAsync(session);
20093
+ * const pauseResult = await agentBay.betaPauseAsync(session);
20094
+ * await agentBay.betaResumeAsync(session);
20223
20095
  * await session.delete();
20224
20096
  * ```
20225
20097
  *
@@ -20230,11 +20102,11 @@ var _AgentBay = class _AgentBay {
20230
20102
  * - The session state transitions from RUNNING -> PAUSING -> PAUSED
20231
20103
  * - Paused sessions consume fewer resources but maintain their state
20232
20104
  *
20233
- * @see {@link resumeAsync}, {@link Session.pauseAsync}
20105
+ * @see {@link betaResumeAsync}, {@link Session.betaPauseAsync}
20234
20106
  */
20235
- async pauseAsync(session, timeout = 600, pollInterval = 2) {
20107
+ async betaPauseAsync(session, timeout = 600, pollInterval = 2) {
20236
20108
  try {
20237
- return await session.pauseAsync(timeout, pollInterval);
20109
+ return await session.betaPauseAsync(timeout, pollInterval);
20238
20110
  } catch (error) {
20239
20111
  logError("Error calling pause session async:", error);
20240
20112
  return {
@@ -20259,8 +20131,8 @@ var _AgentBay = class _AgentBay {
20259
20131
  * ```typescript
20260
20132
  * const agentBay = new AgentBay({ apiKey: 'your_api_key' });
20261
20133
  * const session = (await agentBay.create()).session;
20262
- * await agentBay.pauseAsync(session);
20263
- * const resumeResult = await agentBay.resumeAsync(session);
20134
+ * await agentBay.betaPauseAsync(session);
20135
+ * const resumeResult = await agentBay.betaResumeAsync(session);
20264
20136
  * await session.delete();
20265
20137
  * ```
20266
20138
  *
@@ -20271,11 +20143,11 @@ var _AgentBay = class _AgentBay {
20271
20143
  * - The session state transitions from PAUSED -> RESUMING -> RUNNING
20272
20144
  * - Only sessions in PAUSED state can be resumed
20273
20145
  *
20274
- * @see {@link pauseAsync}, {@link Session.resumeAsync}
20146
+ * @see {@link betaPauseAsync}, {@link Session.betaResumeAsync}
20275
20147
  */
20276
- async resumeAsync(session, timeout = 600, pollInterval = 2) {
20148
+ async betaResumeAsync(session, timeout = 600, pollInterval = 2) {
20277
20149
  try {
20278
- return await session.resumeAsync(timeout, pollInterval);
20150
+ return await session.betaResumeAsync(timeout, pollInterval);
20279
20151
  } catch (error) {
20280
20152
  logError("Error calling resume session async:", error);
20281
20153
  return {
@@ -21067,7 +20939,7 @@ var _MobileSimulateService = class _MobileSimulateService {
21067
20939
  if (!contextSync) {
21068
20940
  throw new Error("contextSync is required for external context");
21069
20941
  }
21070
- if (_optionalChain([contextSync, 'access', _275 => _275.policy, 'optionalAccess', _276 => _276.bwList, 'optionalAccess', _277 => _277.whiteLists])) {
20942
+ if (_optionalChain([contextSync, 'access', _276 => _276.policy, 'optionalAccess', _277 => _277.bwList, 'optionalAccess', _278 => _278.whiteLists])) {
21071
20943
  const exists = contextSync.policy.bwList.whiteLists.some(
21072
20944
  (whiteList) => whiteList.path === MOBILE_INFO_SUB_PATH
21073
20945
  );
@@ -21291,7 +21163,6 @@ var _CreateSessionParams = class _CreateSessionParams {
21291
21163
  constructor() {
21292
21164
  this.labels = {};
21293
21165
  this.contextSync = [];
21294
- this.isVpc = false;
21295
21166
  this.enableBrowserReplay = true;
21296
21167
  }
21297
21168
  /**
@@ -21341,13 +21212,6 @@ var _CreateSessionParams = class _CreateSessionParams {
21341
21212
  }
21342
21213
  return this;
21343
21214
  }
21344
- /**
21345
- * WithIsVpc sets the VPC flag for the session parameters and returns the updated parameters.
21346
- */
21347
- withIsVpc(isVpc) {
21348
- this.isVpc = isVpc;
21349
- return this;
21350
- }
21351
21215
  /**
21352
21216
  * WithPolicyId sets the policy id for the session parameters and returns the updated parameters.
21353
21217
  */
@@ -21483,7 +21347,6 @@ var _CreateSessionParams = class _CreateSessionParams {
21483
21347
  volumeId: this.volumeId,
21484
21348
  contextSync: allContextSyncs,
21485
21349
  browserContext: this.browserContext,
21486
- isVpc: this.isVpc,
21487
21350
  policyId: this.policyId,
21488
21351
  betaNetworkId: this.betaNetworkId,
21489
21352
  enableBrowserReplay: this.enableBrowserReplay,
@@ -21513,7 +21376,6 @@ var _CreateSessionParams = class _CreateSessionParams {
21513
21376
  );
21514
21377
  }
21515
21378
  }
21516
- params.isVpc = config.isVpc || false;
21517
21379
  params.policyId = config.policyId;
21518
21380
  params.betaNetworkId = config.betaNetworkId;
21519
21381
  params.enableBrowserReplay = config.enableBrowserReplay;
@@ -21594,7 +21456,7 @@ var _LocalMCPClient = class _LocalMCPClient {
21594
21456
  }
21595
21457
  }, 15e3);
21596
21458
  let buffer = "";
21597
- _optionalChain([childProcess, 'access', _278 => _278.stdout, 'optionalAccess', _279 => _279.on, 'call', _280 => _280("data", (data) => {
21459
+ _optionalChain([childProcess, 'access', _279 => _279.stdout, 'optionalAccess', _280 => _280.on, 'call', _281 => _281("data", (data) => {
21598
21460
  buffer += data.toString();
21599
21461
  try {
21600
21462
  const lines = buffer.split("\n");
@@ -21618,7 +21480,7 @@ var _LocalMCPClient = class _LocalMCPClient {
21618
21480
  } catch (e) {
21619
21481
  }
21620
21482
  })]);
21621
- _optionalChain([childProcess, 'access', _281 => _281.stderr, 'optionalAccess', _282 => _282.on, 'call', _283 => _283("data", (data) => {
21483
+ _optionalChain([childProcess, 'access', _282 => _282.stderr, 'optionalAccess', _283 => _283.on, 'call', _284 => _284("data", (data) => {
21622
21484
  const stderrText = data.toString();
21623
21485
  logDebug(`[LocalMCPClient] stderr: ${stderrText}`);
21624
21486
  if (stderrText.includes("started") || stderrText.includes("initialized") || stderrText.includes("ready")) {
@@ -21699,7 +21561,7 @@ var _LocalMCPClient = class _LocalMCPClient {
21699
21561
  requestId: parsed.id || `local_request_${_crypto.randomUUID.call(void 0, )}`,
21700
21562
  success: !parsed.error,
21701
21563
  data: typeof responseData === "string" ? responseData : JSON.stringify(responseData),
21702
- errorMessage: _optionalChain([parsed, 'access', _284 => _284.error, 'optionalAccess', _285 => _285.message])
21564
+ errorMessage: _optionalChain([parsed, 'access', _285 => _285.error, 'optionalAccess', _286 => _286.message])
21703
21565
  };
21704
21566
  queued.resolve(response);
21705
21567
  }
@@ -21734,7 +21596,7 @@ var _LocalMCPClient = class _LocalMCPClient {
21734
21596
  arguments: arguments_
21735
21597
  }
21736
21598
  };
21737
- _optionalChain([this, 'access', _286 => _286.workerThread, 'optionalAccess', _287 => _287.stdin, 'optionalAccess', _288 => _288.write, 'call', _289 => _289(JSON.stringify(request) + "\n")]);
21599
+ _optionalChain([this, 'access', _287 => _287.workerThread, 'optionalAccess', _288 => _288.stdin, 'optionalAccess', _289 => _289.write, 'call', _290 => _290(JSON.stringify(request) + "\n")]);
21738
21600
  const TOOL_CALL_TIMEOUT = 18e4;
21739
21601
  setTimeout(() => {
21740
21602
  reject(new Error(`Tool call timeout: ${toolName}`));
@@ -21888,7 +21750,7 @@ var _LocalBrowser = class _LocalBrowser extends Browser {
21888
21750
  * Playwright interactive loop to keep the browser alive
21889
21751
  */
21890
21752
  async _playwrightInteractiveLoop(shutdownSignal) {
21891
- while (!_optionalChain([shutdownSignal, 'optionalAccess', _290 => _290.aborted])) {
21753
+ while (!_optionalChain([shutdownSignal, 'optionalAccess', _291 => _291.aborted])) {
21892
21754
  await new Promise((resolve2) => setTimeout(resolve2, 3e3));
21893
21755
  }
21894
21756
  }
@@ -21896,7 +21758,7 @@ var _LocalBrowser = class _LocalBrowser extends Browser {
21896
21758
  * Abort the playwright interactive loop
21897
21759
  */
21898
21760
  abortPlaywrightInteractiveLoop() {
21899
- _optionalChain([this, 'access', _291 => _291._playwrightInteractiveLoopAbortController, 'optionalAccess', _292 => _292.abort, 'call', _293 => _293()]);
21761
+ _optionalChain([this, 'access', _292 => _292._playwrightInteractiveLoopAbortController, 'optionalAccess', _293 => _293.abort, 'call', _294 => _294()]);
21900
21762
  }
21901
21763
  };
21902
21764
  _chunkJB6CNGN4cjs.__name.call(void 0, _LocalBrowser, "LocalBrowser");