test-wuying-agentbay-sdk 0.15.0-beta.20260114193937 → 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 +189 -377
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +3 -44
- package/dist/index.d.ts +3 -44
- package/dist/index.mjs +151 -339
- package/dist/index.mjs.map +1 -1
- package/docs/api/common-features/basics/agentbay.md +1 -2
- package/docs/api/common-features/basics/session-params.md +0 -26
- package/docs/api/common-features/basics/session.md +0 -3
- package/docs/examples/README.md +0 -3
- package/package.json +1 -1
- package/docs/examples/common-features/advanced/vpc-session-example/README.md +0 -47
- package/docs/examples/common-features/advanced/vpc-session-example.ts +0 -106
package/dist/index.cjs
CHANGED
|
@@ -12176,22 +12176,17 @@ var _Browser = class _Browser {
|
|
|
12176
12176
|
throw new BrowserError("Browser is not initialized. Cannot access endpoint URL.");
|
|
12177
12177
|
}
|
|
12178
12178
|
try {
|
|
12179
|
-
|
|
12180
|
-
|
|
12181
|
-
|
|
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;
|
|
12182
12187
|
} else {
|
|
12183
|
-
const
|
|
12184
|
-
|
|
12185
|
-
authorization: `Bearer ${this.session.getAPIKey()}`,
|
|
12186
|
-
sessionId: this.session.sessionId
|
|
12187
|
-
});
|
|
12188
|
-
const response = await this.session.getAgentBay().getClient().getCdpLink(request);
|
|
12189
|
-
if (response.body && response.body.success && response.body.data) {
|
|
12190
|
-
this._endpointUrl = response.body.data.url || null;
|
|
12191
|
-
} else {
|
|
12192
|
-
const errorMsg = _optionalChain([response, 'access', _149 => _149.body, 'optionalAccess', _150 => _150.message]) || "Unknown error";
|
|
12193
|
-
throw new BrowserError(`Failed to get CDP link: ${errorMsg}`);
|
|
12194
|
-
}
|
|
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}`);
|
|
12195
12190
|
}
|
|
12196
12191
|
return this._endpointUrl;
|
|
12197
12192
|
} catch (error) {
|
|
@@ -17643,6 +17638,16 @@ _chunkJB6CNGN4cjs.__name.call(void 0, _Oss, "Oss");
|
|
|
17643
17638
|
var Oss = _Oss;
|
|
17644
17639
|
|
|
17645
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");
|
|
17646
17651
|
var _SessionInfoClass = class _SessionInfoClass {
|
|
17647
17652
|
constructor(sessionId = "", resourceUrl = "", appId = "", authCode = "", connectionProperties = "", resourceId = "", resourceType = "", ticket = "") {
|
|
17648
17653
|
this.sessionId = sessionId;
|
|
@@ -17666,19 +17671,11 @@ var _Session = class _Session {
|
|
|
17666
17671
|
* @param sessionId - The ID of this session.
|
|
17667
17672
|
*/
|
|
17668
17673
|
constructor(agentBay, sessionId) {
|
|
17669
|
-
// VPC-related information
|
|
17670
|
-
this.isVpc = false;
|
|
17671
|
-
// Whether this session uses VPC resources
|
|
17672
|
-
this.networkInterfaceIp = "";
|
|
17673
|
-
// Network interface IP for VPC sessions
|
|
17674
|
-
this.httpPort = "";
|
|
17675
|
-
// HTTP port for VPC sessions
|
|
17676
|
-
this.token = "";
|
|
17677
|
-
// Token for VPC sessions
|
|
17678
|
-
this.linkUrl = "";
|
|
17679
|
-
// LinkUrl for LinkUrl-based VPC route
|
|
17680
17674
|
// Resource URL for accessing the session
|
|
17681
17675
|
this.resourceUrl = "";
|
|
17676
|
+
// LinkUrl-based direct tool call (non-VPC)
|
|
17677
|
+
this.token = "";
|
|
17678
|
+
this.linkUrl = "";
|
|
17682
17679
|
// Recording functionality
|
|
17683
17680
|
this.enableBrowserReplay = false;
|
|
17684
17681
|
this.agentBay = agentBay;
|
|
@@ -17730,6 +17727,12 @@ var _Session = class _Session {
|
|
|
17730
17727
|
getAPIKey() {
|
|
17731
17728
|
return this.agentBay.getAPIKey();
|
|
17732
17729
|
}
|
|
17730
|
+
getToken() {
|
|
17731
|
+
return this.token;
|
|
17732
|
+
}
|
|
17733
|
+
getLinkUrl() {
|
|
17734
|
+
return this.linkUrl;
|
|
17735
|
+
}
|
|
17733
17736
|
/**
|
|
17734
17737
|
* Return the HTTP client for this session.
|
|
17735
17738
|
*
|
|
@@ -17824,45 +17827,6 @@ var _Session = class _Session {
|
|
|
17824
17827
|
};
|
|
17825
17828
|
}
|
|
17826
17829
|
}
|
|
17827
|
-
/**
|
|
17828
|
-
* Return whether this session uses VPC resources.
|
|
17829
|
-
*
|
|
17830
|
-
* @returns boolean indicating if VPC is enabled for this session
|
|
17831
|
-
* @internal
|
|
17832
|
-
*/
|
|
17833
|
-
isVpcEnabled() {
|
|
17834
|
-
return this.isVpc;
|
|
17835
|
-
}
|
|
17836
|
-
/**
|
|
17837
|
-
* Return the network interface IP for VPC sessions.
|
|
17838
|
-
*
|
|
17839
|
-
* @returns The network interface IP string for VPC sessions
|
|
17840
|
-
* @internal
|
|
17841
|
-
*/
|
|
17842
|
-
getNetworkInterfaceIp() {
|
|
17843
|
-
return this.networkInterfaceIp;
|
|
17844
|
-
}
|
|
17845
|
-
/**
|
|
17846
|
-
* Return the HTTP port for VPC sessions.
|
|
17847
|
-
*
|
|
17848
|
-
* @returns The HTTP port string for VPC sessions
|
|
17849
|
-
* @internal
|
|
17850
|
-
*/
|
|
17851
|
-
getHttpPort() {
|
|
17852
|
-
return this.httpPort;
|
|
17853
|
-
}
|
|
17854
|
-
/**
|
|
17855
|
-
* Return the token for VPC sessions.
|
|
17856
|
-
*
|
|
17857
|
-
* @returns The token string for VPC sessions
|
|
17858
|
-
* @internal
|
|
17859
|
-
*/
|
|
17860
|
-
getToken() {
|
|
17861
|
-
return this.token;
|
|
17862
|
-
}
|
|
17863
|
-
getLinkUrl() {
|
|
17864
|
-
return this.linkUrl;
|
|
17865
|
-
}
|
|
17866
17830
|
/**
|
|
17867
17831
|
* Delete this session.
|
|
17868
17832
|
*
|
|
@@ -18594,165 +18558,80 @@ var _Session = class _Session {
|
|
|
18594
18558
|
if (this.getLinkUrl() && this.getToken()) {
|
|
18595
18559
|
return await this.callMcpToolLinkUrl(toolName, args, serverName);
|
|
18596
18560
|
}
|
|
18597
|
-
|
|
18598
|
-
|
|
18599
|
-
|
|
18600
|
-
|
|
18601
|
-
|
|
18602
|
-
|
|
18603
|
-
|
|
18604
|
-
|
|
18605
|
-
|
|
18606
|
-
}
|
|
18607
|
-
if (!this.networkInterfaceIp || !this.httpPort) {
|
|
18608
|
-
return {
|
|
18609
|
-
success: false,
|
|
18610
|
-
data: "",
|
|
18611
|
-
errorMessage: `VPC network configuration incomplete: networkInterfaceIp=${this.networkInterfaceIp}, httpPort=${this.httpPort}. This may indicate the VPC session was not properly configured with network parameters.`,
|
|
18612
|
-
requestId: ""
|
|
18613
|
-
};
|
|
18614
|
-
}
|
|
18615
|
-
const baseURL = `http://${this.networkInterfaceIp}:${this.httpPort}/callTool`;
|
|
18616
|
-
const url = new URL(baseURL);
|
|
18617
|
-
url.searchParams.append("server", server);
|
|
18618
|
-
url.searchParams.append("tool", toolName);
|
|
18619
|
-
url.searchParams.append("args", argsJSON);
|
|
18620
|
-
url.searchParams.append("token", this.getToken());
|
|
18621
|
-
const requestId = `vpc-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
18622
|
-
url.searchParams.append("requestId", requestId);
|
|
18623
|
-
setRequestId(requestId);
|
|
18624
|
-
const response = await fetch(url.toString(), {
|
|
18625
|
-
method: "GET",
|
|
18626
|
-
headers: {
|
|
18627
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
18628
|
-
}
|
|
18629
|
-
});
|
|
18630
|
-
if (!response.ok) {
|
|
18631
|
-
return {
|
|
18632
|
-
success: false,
|
|
18633
|
-
data: "",
|
|
18634
|
-
errorMessage: `VPC request failed: ${response.statusText}`,
|
|
18635
|
-
requestId
|
|
18636
|
-
};
|
|
18637
|
-
}
|
|
18638
|
-
const responseData = await response.json();
|
|
18639
|
-
let actualResult = responseData;
|
|
18640
|
-
if (typeof responseData.data === "string") {
|
|
18641
|
-
try {
|
|
18642
|
-
const dataMap = JSON.parse(responseData.data);
|
|
18643
|
-
if (dataMap.result) {
|
|
18644
|
-
actualResult = dataMap.result;
|
|
18645
|
-
}
|
|
18646
|
-
} catch (err) {
|
|
18647
|
-
}
|
|
18648
|
-
} else if (responseData.data && responseData.data.result) {
|
|
18649
|
-
actualResult = responseData.data.result;
|
|
18650
|
-
}
|
|
18651
|
-
let textContent = "";
|
|
18652
|
-
if (actualResult.content && Array.isArray(actualResult.content) && actualResult.content.length > 0) {
|
|
18653
|
-
const contentItem = actualResult.content[0];
|
|
18654
|
-
if (contentItem) {
|
|
18655
|
-
if (typeof contentItem.text === "string" && contentItem.text) {
|
|
18656
|
-
textContent = contentItem.text;
|
|
18657
|
-
} else if (typeof contentItem.blob === "string" && contentItem.blob) {
|
|
18658
|
-
textContent = contentItem.blob;
|
|
18659
|
-
} else if (typeof contentItem.data === "string" && contentItem.data) {
|
|
18660
|
-
textContent = contentItem.data;
|
|
18661
|
-
}
|
|
18662
|
-
}
|
|
18663
|
-
}
|
|
18664
|
-
if (toolName === "run_code" && actualResult) {
|
|
18665
|
-
const dataStr = typeof actualResult === "string" ? actualResult : JSON.stringify(actualResult);
|
|
18666
|
-
logCodeExecutionOutput(requestId, dataStr);
|
|
18667
|
-
return {
|
|
18668
|
-
success: true,
|
|
18669
|
-
data: dataStr,
|
|
18670
|
-
errorMessage: "",
|
|
18671
|
-
requestId
|
|
18672
|
-
};
|
|
18673
|
-
}
|
|
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])) {
|
|
18674
18570
|
return {
|
|
18675
|
-
success:
|
|
18676
|
-
data:
|
|
18677
|
-
errorMessage: "",
|
|
18678
|
-
requestId
|
|
18571
|
+
success: false,
|
|
18572
|
+
data: "",
|
|
18573
|
+
errorMessage: "Invalid response data format",
|
|
18574
|
+
requestId: extractRequestId(response) || ""
|
|
18679
18575
|
};
|
|
18680
|
-
}
|
|
18681
|
-
|
|
18682
|
-
|
|
18683
|
-
|
|
18684
|
-
|
|
18685
|
-
|
|
18686
|
-
|
|
18687
|
-
|
|
18688
|
-
|
|
18689
|
-
|
|
18690
|
-
|
|
18691
|
-
|
|
18692
|
-
|
|
18693
|
-
|
|
18694
|
-
|
|
18695
|
-
|
|
18696
|
-
|
|
18697
|
-
if (
|
|
18698
|
-
|
|
18699
|
-
|
|
18700
|
-
|
|
18701
|
-
data: "",
|
|
18702
|
-
errorMessage,
|
|
18703
|
-
requestId: extractRequestId(response) || ""
|
|
18704
|
-
};
|
|
18705
|
-
}
|
|
18706
|
-
const data = response.body.data;
|
|
18707
|
-
const reqId = extractRequestId(response) || "";
|
|
18708
|
-
if (reqId) {
|
|
18709
|
-
setRequestId(reqId);
|
|
18710
|
-
}
|
|
18711
|
-
if (toolName === "run_code") {
|
|
18712
|
-
let dataStr = "";
|
|
18713
|
-
if (data && Array.isArray(data.content) && data.content.length > 0 && data.content[0].text) {
|
|
18714
|
-
dataStr = data.content[0].text;
|
|
18715
|
-
} else {
|
|
18716
|
-
dataStr = typeof response.body.data === "string" ? response.body.data : JSON.stringify(response.body.data);
|
|
18717
|
-
}
|
|
18718
|
-
logCodeExecutionOutput(reqId, dataStr);
|
|
18719
|
-
const isError = data.isError === true;
|
|
18720
|
-
return {
|
|
18721
|
-
success: !isError,
|
|
18722
|
-
data: dataStr,
|
|
18723
|
-
errorMessage: isError ? dataStr : "",
|
|
18724
|
-
requestId: reqId
|
|
18725
|
-
};
|
|
18726
|
-
}
|
|
18727
|
-
if (data.isError) {
|
|
18728
|
-
const errorContent = data.content || [];
|
|
18729
|
-
const errorMessage = errorContent.map((item) => item.text || "Unknown error").join("; ");
|
|
18730
|
-
return {
|
|
18731
|
-
success: false,
|
|
18732
|
-
data: "",
|
|
18733
|
-
errorMessage,
|
|
18734
|
-
requestId: reqId
|
|
18735
|
-
};
|
|
18736
|
-
}
|
|
18737
|
-
const content = data.content || [];
|
|
18738
|
-
let textContent = "";
|
|
18739
|
-
if (content.length > 0) {
|
|
18740
|
-
const c0 = content[0] || {};
|
|
18741
|
-
if (typeof c0.text === "string" && c0.text) {
|
|
18742
|
-
textContent = c0.text;
|
|
18743
|
-
} else if (typeof c0.blob === "string" && c0.blob) {
|
|
18744
|
-
textContent = c0.blob;
|
|
18745
|
-
} else if (typeof c0.data === "string" && c0.data) {
|
|
18746
|
-
textContent = c0.data;
|
|
18747
|
-
}
|
|
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);
|
|
18748
18597
|
}
|
|
18598
|
+
logCodeExecutionOutput(reqId, dataStr);
|
|
18599
|
+
const isError = data.isError === true;
|
|
18749
18600
|
return {
|
|
18750
|
-
success:
|
|
18751
|
-
data:
|
|
18752
|
-
errorMessage: "",
|
|
18601
|
+
success: !isError,
|
|
18602
|
+
data: dataStr,
|
|
18603
|
+
errorMessage: isError ? dataStr : "",
|
|
18753
18604
|
requestId: reqId
|
|
18754
18605
|
};
|
|
18755
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
|
+
};
|
|
18756
18635
|
} catch (error) {
|
|
18757
18636
|
return {
|
|
18758
18637
|
success: false,
|
|
@@ -18763,38 +18642,40 @@ var _Session = class _Session {
|
|
|
18763
18642
|
}
|
|
18764
18643
|
}
|
|
18765
18644
|
async callMcpToolLinkUrl(toolName, args, serverName) {
|
|
18766
|
-
|
|
18767
|
-
if (!server) {
|
|
18645
|
+
if (!serverName) {
|
|
18768
18646
|
return {
|
|
18769
18647
|
success: false,
|
|
18770
18648
|
data: "",
|
|
18771
|
-
errorMessage: `Server
|
|
18649
|
+
errorMessage: `Server name is required for LinkUrl tool call: ${toolName}`,
|
|
18772
18650
|
requestId: ""
|
|
18773
18651
|
};
|
|
18774
18652
|
}
|
|
18775
|
-
const
|
|
18776
|
-
const linkUrl = this.getLinkUrl().replace(/\/+$/, "");
|
|
18653
|
+
const linkUrl = this.getLinkUrl();
|
|
18777
18654
|
const token = this.getToken();
|
|
18778
|
-
|
|
18779
|
-
|
|
18780
|
-
|
|
18781
|
-
|
|
18782
|
-
|
|
18783
|
-
|
|
18784
|
-
|
|
18785
|
-
|
|
18786
|
-
|
|
18787
|
-
|
|
18788
|
-
|
|
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}`
|
|
18789
18669
|
);
|
|
18670
|
+
const url = `${linkUrl.replace(/\/+$/, "")}/callTool`;
|
|
18790
18671
|
const payload = {
|
|
18791
18672
|
args,
|
|
18792
|
-
server,
|
|
18673
|
+
server: serverName,
|
|
18793
18674
|
requestId,
|
|
18794
18675
|
tool: toolName,
|
|
18795
18676
|
token
|
|
18796
18677
|
};
|
|
18797
|
-
const
|
|
18678
|
+
const resp = await fetchCompat(url, {
|
|
18798
18679
|
method: "POST",
|
|
18799
18680
|
headers: {
|
|
18800
18681
|
"Content-Type": "application/json",
|
|
@@ -18802,100 +18683,59 @@ var _Session = class _Session {
|
|
|
18802
18683
|
},
|
|
18803
18684
|
body: JSON.stringify(payload)
|
|
18804
18685
|
});
|
|
18805
|
-
if (!
|
|
18806
|
-
|
|
18807
|
-
try {
|
|
18808
|
-
bodyText = await response.text();
|
|
18809
|
-
} catch (e13) {
|
|
18810
|
-
bodyText = "";
|
|
18811
|
-
}
|
|
18812
|
-
const bodyPreview = bodyText.length > 2e3 ? bodyText.slice(0, 2e3) + "...(truncated)" : bodyText;
|
|
18686
|
+
if (!resp.ok) {
|
|
18687
|
+
const bodyText = await resp.text().catch(() => "");
|
|
18813
18688
|
logAPIResponseWithDetails(
|
|
18814
18689
|
"CallMcpTool(LinkUrl) Response",
|
|
18815
18690
|
requestId,
|
|
18816
18691
|
false,
|
|
18817
|
-
{
|
|
18818
|
-
|
|
18819
|
-
tool_name: toolName
|
|
18820
|
-
},
|
|
18821
|
-
bodyPreview
|
|
18692
|
+
{ http_status: resp.status, tool_name: toolName },
|
|
18693
|
+
bodyText
|
|
18822
18694
|
);
|
|
18823
18695
|
return {
|
|
18824
18696
|
success: false,
|
|
18825
18697
|
data: "",
|
|
18826
|
-
errorMessage: `
|
|
18827
|
-
requestId
|
|
18828
|
-
};
|
|
18829
|
-
}
|
|
18830
|
-
const outer = await response.json();
|
|
18831
|
-
const dataField = _optionalChain([outer, 'optionalAccess', _208 => _208.data]);
|
|
18832
|
-
if (dataField === void 0 || dataField === null) {
|
|
18833
|
-
return {
|
|
18834
|
-
success: false,
|
|
18835
|
-
data: "",
|
|
18836
|
-
errorMessage: "No data field in LinkUrl response",
|
|
18698
|
+
errorMessage: `HTTP request failed with code: ${resp.status}`,
|
|
18837
18699
|
requestId
|
|
18838
18700
|
};
|
|
18839
18701
|
}
|
|
18702
|
+
const outer = await resp.json();
|
|
18703
|
+
const dataField = _optionalChain([outer, 'optionalAccess', _207 => _207.data]);
|
|
18840
18704
|
let parsedData = dataField;
|
|
18841
18705
|
if (typeof dataField === "string") {
|
|
18842
|
-
|
|
18843
|
-
parsedData = JSON.parse(dataField);
|
|
18844
|
-
} catch (err) {
|
|
18845
|
-
return {
|
|
18846
|
-
success: false,
|
|
18847
|
-
data: "",
|
|
18848
|
-
errorMessage: `Invalid data field JSON in LinkUrl response: ${err}`,
|
|
18849
|
-
requestId
|
|
18850
|
-
};
|
|
18851
|
-
}
|
|
18852
|
-
}
|
|
18853
|
-
const result = _optionalChain([parsedData, 'optionalAccess', _209 => _209.result]);
|
|
18854
|
-
if (!result) {
|
|
18855
|
-
return {
|
|
18856
|
-
success: false,
|
|
18857
|
-
data: "",
|
|
18858
|
-
errorMessage: "No result field in LinkUrl response data",
|
|
18859
|
-
requestId
|
|
18860
|
-
};
|
|
18861
|
-
}
|
|
18862
|
-
const isError = result.isError === true;
|
|
18863
|
-
let textContent = "";
|
|
18864
|
-
if (Array.isArray(result.content) && result.content.length > 0) {
|
|
18865
|
-
const contentItem = result.content[0];
|
|
18866
|
-
if (contentItem) {
|
|
18867
|
-
if (typeof contentItem.text === "string" && contentItem.text) {
|
|
18868
|
-
textContent = contentItem.text;
|
|
18869
|
-
} else if (typeof contentItem.blob === "string" && contentItem.blob) {
|
|
18870
|
-
textContent = contentItem.blob;
|
|
18871
|
-
} else if (typeof contentItem.data === "string" && contentItem.data) {
|
|
18872
|
-
textContent = contentItem.data;
|
|
18873
|
-
}
|
|
18874
|
-
}
|
|
18706
|
+
parsedData = JSON.parse(dataField);
|
|
18875
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)), () => ( ""));
|
|
18876
18713
|
logAPIResponseWithDetails(
|
|
18877
18714
|
"CallMcpTool(LinkUrl) Response",
|
|
18878
18715
|
requestId,
|
|
18879
18716
|
!isError,
|
|
18880
18717
|
{
|
|
18881
|
-
http_status: response.status,
|
|
18882
18718
|
tool_name: toolName,
|
|
18883
|
-
|
|
18719
|
+
server: serverName,
|
|
18720
|
+
is_error: isError,
|
|
18721
|
+
data_len: String(_nullishCoalesce(textContent, () => ( ""))).length
|
|
18884
18722
|
},
|
|
18885
|
-
""
|
|
18723
|
+
isError ? String(_nullishCoalesce(textContent, () => ( ""))) : ""
|
|
18886
18724
|
);
|
|
18887
|
-
if (
|
|
18725
|
+
if (toolName === "run_code") {
|
|
18726
|
+
const dataStr = typeof textContent === "string" ? textContent : JSON.stringify(textContent);
|
|
18727
|
+
logCodeExecutionOutput(requestId, dataStr);
|
|
18888
18728
|
return {
|
|
18889
|
-
success:
|
|
18890
|
-
data:
|
|
18891
|
-
errorMessage:
|
|
18729
|
+
success: !isError,
|
|
18730
|
+
data: dataStr,
|
|
18731
|
+
errorMessage: isError ? dataStr : "",
|
|
18892
18732
|
requestId
|
|
18893
18733
|
};
|
|
18894
18734
|
}
|
|
18895
18735
|
return {
|
|
18896
|
-
success:
|
|
18897
|
-
data: textContent
|
|
18898
|
-
errorMessage: "",
|
|
18736
|
+
success: !isError,
|
|
18737
|
+
data: String(_nullishCoalesce(textContent, () => ( ""))),
|
|
18738
|
+
errorMessage: isError ? String(_nullishCoalesce(textContent, () => ( ""))) : "",
|
|
18899
18739
|
requestId
|
|
18900
18740
|
};
|
|
18901
18741
|
}
|
|
@@ -18963,7 +18803,7 @@ var _Session = class _Session {
|
|
|
18963
18803
|
success: false,
|
|
18964
18804
|
data: void 0,
|
|
18965
18805
|
raw: void 0,
|
|
18966
|
-
errorMessage: `Failed to parse get_metrics response: ${_optionalChain([err, 'optionalAccess',
|
|
18806
|
+
errorMessage: `Failed to parse get_metrics response: ${_optionalChain([err, 'optionalAccess', _211 => _211.message]) || String(err)}`
|
|
18967
18807
|
};
|
|
18968
18808
|
}
|
|
18969
18809
|
}
|
|
@@ -19315,9 +19155,9 @@ var _BetaVolumeService = class _BetaVolumeService {
|
|
|
19315
19155
|
});
|
|
19316
19156
|
logAPICall("GetVolume(beta)", { volumeName: name, allowCreate: !!create, imageId });
|
|
19317
19157
|
const resp = await this.agentBay.client.getVolume(req);
|
|
19318
|
-
const requestId = _optionalChain([resp, 'optionalAccess',
|
|
19319
|
-
const success = !!_optionalChain([resp, 'optionalAccess',
|
|
19320
|
-
if (!success && _optionalChain([resp, 'optionalAccess',
|
|
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])) {
|
|
19321
19161
|
return {
|
|
19322
19162
|
requestId,
|
|
19323
19163
|
success: false,
|
|
@@ -19325,10 +19165,10 @@ var _BetaVolumeService = class _BetaVolumeService {
|
|
|
19325
19165
|
errorMessage: `[${resp.body.code}] ${resp.body.message || "Unknown error"}`
|
|
19326
19166
|
};
|
|
19327
19167
|
}
|
|
19328
|
-
const data = _optionalChain([resp, 'optionalAccess',
|
|
19329
|
-
const vid = _optionalChain([data, 'optionalAccess',
|
|
19168
|
+
const data = _optionalChain([resp, 'optionalAccess', _218 => _218.body, 'optionalAccess', _219 => _219.data]);
|
|
19169
|
+
const vid = _optionalChain([data, 'optionalAccess', _220 => _220.volumeId]) || "";
|
|
19330
19170
|
if (!vid) {
|
|
19331
|
-
logAPIResponseWithDetails("GetVolume(beta)", requestId, false, {}, JSON.stringify(_optionalChain([resp, 'optionalAccess',
|
|
19171
|
+
logAPIResponseWithDetails("GetVolume(beta)", requestId, false, {}, JSON.stringify(_optionalChain([resp, 'optionalAccess', _221 => _221.body]) || {}));
|
|
19332
19172
|
return {
|
|
19333
19173
|
requestId,
|
|
19334
19174
|
success: false,
|
|
@@ -19338,12 +19178,12 @@ var _BetaVolumeService = class _BetaVolumeService {
|
|
|
19338
19178
|
}
|
|
19339
19179
|
const volume = {
|
|
19340
19180
|
id: vid,
|
|
19341
|
-
name: _optionalChain([data, 'optionalAccess',
|
|
19342
|
-
belongingImageId: _optionalChain([data, 'optionalAccess',
|
|
19343
|
-
status: _optionalChain([data, 'optionalAccess',
|
|
19344
|
-
createdAt: _optionalChain([data, 'optionalAccess',
|
|
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])
|
|
19345
19185
|
};
|
|
19346
|
-
logAPIResponseWithDetails("GetVolume(beta)", requestId, true, { volume_id: vid }, JSON.stringify(_optionalChain([resp, 'optionalAccess',
|
|
19186
|
+
logAPIResponseWithDetails("GetVolume(beta)", requestId, true, { volume_id: vid }, JSON.stringify(_optionalChain([resp, 'optionalAccess', _226 => _226.body]) || {}));
|
|
19347
19187
|
return { requestId, success: true, volume };
|
|
19348
19188
|
}
|
|
19349
19189
|
async list(params) {
|
|
@@ -19361,9 +19201,9 @@ var _BetaVolumeService = class _BetaVolumeService {
|
|
|
19361
19201
|
});
|
|
19362
19202
|
logAPICall("ListVolumes(beta)", { imageId, maxResults: _nullishCoalesce(maxResults, () => ( 10)) });
|
|
19363
19203
|
const resp = await this.agentBay.client.listVolumes(req);
|
|
19364
|
-
const requestId = _optionalChain([resp, 'optionalAccess',
|
|
19365
|
-
const success = !!_optionalChain([resp, 'optionalAccess',
|
|
19366
|
-
if (!success && _optionalChain([resp, 'optionalAccess',
|
|
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])) {
|
|
19367
19207
|
return {
|
|
19368
19208
|
requestId,
|
|
19369
19209
|
success: false,
|
|
@@ -19371,7 +19211,7 @@ var _BetaVolumeService = class _BetaVolumeService {
|
|
|
19371
19211
|
errorMessage: `[${resp.body.code}] ${resp.body.message || "Unknown error"}`
|
|
19372
19212
|
};
|
|
19373
19213
|
}
|
|
19374
|
-
const volumes = (_optionalChain([resp, 'optionalAccess',
|
|
19214
|
+
const volumes = (_optionalChain([resp, 'optionalAccess', _233 => _233.body, 'optionalAccess', _234 => _234.data]) || []).filter((it) => !!_optionalChain([it, 'optionalAccess', _235 => _235.volumeId])).map((it) => ({
|
|
19375
19215
|
id: it.volumeId,
|
|
19376
19216
|
name: it.volumeName || "",
|
|
19377
19217
|
belongingImageId: it.belongingImageId,
|
|
@@ -19382,8 +19222,8 @@ var _BetaVolumeService = class _BetaVolumeService {
|
|
|
19382
19222
|
requestId,
|
|
19383
19223
|
success: true,
|
|
19384
19224
|
volumes,
|
|
19385
|
-
nextToken: _optionalChain([resp, 'optionalAccess',
|
|
19386
|
-
maxResults: _optionalChain([resp, 'optionalAccess',
|
|
19225
|
+
nextToken: _optionalChain([resp, 'optionalAccess', _236 => _236.body, 'optionalAccess', _237 => _237.nextToken]),
|
|
19226
|
+
maxResults: _optionalChain([resp, 'optionalAccess', _238 => _238.body, 'optionalAccess', _239 => _239.maxResults]),
|
|
19387
19227
|
totalCount: volumes.length,
|
|
19388
19228
|
errorMessage: ""
|
|
19389
19229
|
};
|
|
@@ -19399,9 +19239,9 @@ var _BetaVolumeService = class _BetaVolumeService {
|
|
|
19399
19239
|
logAPICall("DeleteVolume(beta)", { volumeId });
|
|
19400
19240
|
try {
|
|
19401
19241
|
const resp = await this.agentBay.client.deleteVolume(req);
|
|
19402
|
-
const requestId = _optionalChain([resp, 'optionalAccess',
|
|
19403
|
-
const success = !!_optionalChain([resp, 'optionalAccess',
|
|
19404
|
-
if (!success && _optionalChain([resp, 'optionalAccess',
|
|
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])) {
|
|
19405
19245
|
return {
|
|
19406
19246
|
requestId,
|
|
19407
19247
|
success: false,
|
|
@@ -19531,7 +19371,6 @@ var _AgentBay = class _AgentBay {
|
|
|
19531
19371
|
* - imageId: Custom image ID for the session environment
|
|
19532
19372
|
* - contextSync: Array of context synchronization configurations
|
|
19533
19373
|
* - browserContext: Browser-specific context configuration
|
|
19534
|
-
* - isVpc: Whether to create a VPC session
|
|
19535
19374
|
* - policyId: Security policy ID
|
|
19536
19375
|
* - enableBrowserReplay: Enable browser session recording
|
|
19537
19376
|
* - extraConfigs: Additional configuration options
|
|
@@ -19560,7 +19399,6 @@ var _AgentBay = class _AgentBay {
|
|
|
19560
19399
|
* - Creates a new isolated cloud runtime environment
|
|
19561
19400
|
* - Automatically creates file transfer context if not provided
|
|
19562
19401
|
* - Waits for context synchronization if contextSync is specified
|
|
19563
|
-
* - For VPC sessions, includes VPC-specific configuration
|
|
19564
19402
|
* - Browser replay creates a separate recording context
|
|
19565
19403
|
*
|
|
19566
19404
|
* @see {@link get}, {@link list}, {@link Session.delete}
|
|
@@ -19568,8 +19406,8 @@ var _AgentBay = class _AgentBay {
|
|
|
19568
19406
|
async create(params) {
|
|
19569
19407
|
try {
|
|
19570
19408
|
const paramsCopy = this.deepCopyParams(params);
|
|
19571
|
-
logDebug(`default context syncs length: ${_optionalChain([paramsCopy, 'access',
|
|
19572
|
-
if (_optionalChain([paramsCopy, 'access',
|
|
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])) {
|
|
19573
19411
|
const mobileSimContextId = paramsCopy.extraConfigs.mobile.simulateConfig.simulatedContextId;
|
|
19574
19412
|
if (mobileSimContextId) {
|
|
19575
19413
|
const mobileSimContextSync = new ContextSync(
|
|
@@ -19589,7 +19427,7 @@ var _AgentBay = class _AgentBay {
|
|
|
19589
19427
|
if (paramsCopy.enableBrowserReplay === false) {
|
|
19590
19428
|
request.enableRecord = false;
|
|
19591
19429
|
}
|
|
19592
|
-
const framework = _optionalChain([paramsCopy, 'optionalAccess',
|
|
19430
|
+
const framework = _optionalChain([paramsCopy, 'optionalAccess', _251 => _251.framework]) || "";
|
|
19593
19431
|
const sdkStatsJson = `{"source":"sdk","sdk_language":"typescript","sdk_version":"${VERSION}","is_release":${IS_RELEASE},"framework":"${framework}"}`;
|
|
19594
19432
|
request.sdkStats = sdkStatsJson;
|
|
19595
19433
|
if (this.config.region_id) {
|
|
@@ -19618,7 +19456,6 @@ var _AgentBay = class _AgentBay {
|
|
|
19618
19456
|
if (paramsCopy.betaNetworkId) {
|
|
19619
19457
|
request.networkId = paramsCopy.betaNetworkId;
|
|
19620
19458
|
}
|
|
19621
|
-
request.vpcResource = paramsCopy.isVpc || false;
|
|
19622
19459
|
let needsContextSync = false;
|
|
19623
19460
|
let needsMobileSim = false;
|
|
19624
19461
|
let mobileSimMode = void 0;
|
|
@@ -19660,7 +19497,7 @@ var _AgentBay = class _AgentBay {
|
|
|
19660
19497
|
}
|
|
19661
19498
|
if (paramsCopy.extraConfigs) {
|
|
19662
19499
|
request.extraConfigs = JSON.stringify(paramsCopy.extraConfigs);
|
|
19663
|
-
if (_optionalChain([paramsCopy, 'access',
|
|
19500
|
+
if (_optionalChain([paramsCopy, 'access', _252 => _252.extraConfigs, 'access', _253 => _253.mobile, 'optionalAccess', _254 => _254.simulateConfig, 'optionalAccess', _255 => _255.simulate])) {
|
|
19664
19501
|
mobileSimPath = paramsCopy.extraConfigs.mobile.simulateConfig.simulatePath;
|
|
19665
19502
|
if (!mobileSimPath) {
|
|
19666
19503
|
logInfo("mobile_sim_path is not set now, skip mobile simulate operation");
|
|
@@ -19674,7 +19511,6 @@ var _AgentBay = class _AgentBay {
|
|
|
19674
19511
|
labels: paramsCopy.labels,
|
|
19675
19512
|
imageId: paramsCopy.imageId,
|
|
19676
19513
|
policyId: paramsCopy.policyId,
|
|
19677
|
-
isVpc: paramsCopy.isVpc,
|
|
19678
19514
|
persistenceDataCount: paramsCopy.contextSync ? paramsCopy.contextSync.length : 0
|
|
19679
19515
|
});
|
|
19680
19516
|
const response = await this.client.createMcpSession(request);
|
|
@@ -19771,20 +19607,9 @@ var _AgentBay = class _AgentBay {
|
|
|
19771
19607
|
}
|
|
19772
19608
|
);
|
|
19773
19609
|
const session = new Session(this, sessionId);
|
|
19774
|
-
session.isVpc = paramsCopy.isVpc || false;
|
|
19775
|
-
if (data.networkInterfaceIp) {
|
|
19776
|
-
session.networkInterfaceIp = data.networkInterfaceIp;
|
|
19777
|
-
}
|
|
19778
|
-
if (data.httpPort) {
|
|
19779
|
-
session.httpPort = data.httpPort;
|
|
19780
|
-
}
|
|
19781
|
-
if (data.token) {
|
|
19782
|
-
session.token = data.token;
|
|
19783
|
-
}
|
|
19784
|
-
if (data.linkUrl) {
|
|
19785
|
-
session.linkUrl = data.linkUrl;
|
|
19786
|
-
}
|
|
19787
19610
|
session.resourceUrl = resourceUrl;
|
|
19611
|
+
session.token = data.token || "";
|
|
19612
|
+
session.linkUrl = data.linkUrl || "";
|
|
19788
19613
|
session.enableBrowserReplay = paramsCopy.enableBrowserReplay || false;
|
|
19789
19614
|
session.imageId = paramsCopy.imageId;
|
|
19790
19615
|
if (paramsCopy.extraConfigs && paramsCopy.extraConfigs.mobile) {
|
|
@@ -19915,9 +19740,9 @@ var _AgentBay = class _AgentBay {
|
|
|
19915
19740
|
}
|
|
19916
19741
|
const response2 = await this.client.listSession(request2);
|
|
19917
19742
|
const requestId2 = extractRequestId(response2) || "";
|
|
19918
|
-
if (!_optionalChain([response2, 'access',
|
|
19919
|
-
const code = _optionalChain([response2, 'access',
|
|
19920
|
-
const message = _optionalChain([response2, 'access',
|
|
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";
|
|
19921
19746
|
return {
|
|
19922
19747
|
requestId: requestId2,
|
|
19923
19748
|
success: false,
|
|
@@ -19963,9 +19788,9 @@ var _AgentBay = class _AgentBay {
|
|
|
19963
19788
|
const response = await this.client.listSession(request);
|
|
19964
19789
|
const requestId = extractRequestId(response) || "";
|
|
19965
19790
|
setRequestId(requestId);
|
|
19966
|
-
if (!_optionalChain([response, 'access',
|
|
19967
|
-
const code = _optionalChain([response, 'access',
|
|
19968
|
-
const message = _optionalChain([response, 'access',
|
|
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";
|
|
19969
19794
|
logAPIResponseWithDetails(
|
|
19970
19795
|
"ListSession",
|
|
19971
19796
|
requestId,
|
|
@@ -20084,7 +19909,7 @@ var _AgentBay = class _AgentBay {
|
|
|
20084
19909
|
const requestId = extractRequestId(response) || "";
|
|
20085
19910
|
const body = response.body;
|
|
20086
19911
|
setRequestId(requestId);
|
|
20087
|
-
if (_optionalChain([body, 'optionalAccess',
|
|
19912
|
+
if (_optionalChain([body, 'optionalAccess', _268 => _268.success]) === false && body.code) {
|
|
20088
19913
|
logAPIResponseWithDetails(
|
|
20089
19914
|
"GetSession",
|
|
20090
19915
|
requestId,
|
|
@@ -20103,12 +19928,12 @@ var _AgentBay = class _AgentBay {
|
|
|
20103
19928
|
}
|
|
20104
19929
|
const result = {
|
|
20105
19930
|
requestId,
|
|
20106
|
-
httpStatusCode: _optionalChain([body, 'optionalAccess',
|
|
20107
|
-
code: _optionalChain([body, 'optionalAccess',
|
|
20108
|
-
success: _optionalChain([body, 'optionalAccess',
|
|
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,
|
|
20109
19934
|
errorMessage: ""
|
|
20110
19935
|
};
|
|
20111
|
-
if (_optionalChain([body, 'optionalAccess',
|
|
19936
|
+
if (_optionalChain([body, 'optionalAccess', _272 => _272.data])) {
|
|
20112
19937
|
const contextsList = body.data.contexts || [];
|
|
20113
19938
|
const contexts = [];
|
|
20114
19939
|
if (Array.isArray(contextsList)) {
|
|
@@ -20148,7 +19973,7 @@ var _AgentBay = class _AgentBay {
|
|
|
20148
19973
|
return result;
|
|
20149
19974
|
} catch (error) {
|
|
20150
19975
|
const errorStr = String(error);
|
|
20151
|
-
const errorCode = _optionalChain([error, 'optionalAccess',
|
|
19976
|
+
const errorCode = _optionalChain([error, 'optionalAccess', _273 => _273.data, 'optionalAccess', _274 => _274.Code]) || _optionalChain([error, 'optionalAccess', _275 => _275.code]) || "";
|
|
20152
19977
|
if (errorCode === "InvalidMcpSession.NotFound" || errorStr.includes("NotFound")) {
|
|
20153
19978
|
logInfo(`Session not found: ${sessionId}`);
|
|
20154
19979
|
logDebug(`GetSession error details: ${errorStr}`);
|
|
@@ -20210,11 +20035,8 @@ var _AgentBay = class _AgentBay {
|
|
|
20210
20035
|
}
|
|
20211
20036
|
const session = new Session(this, sessionId);
|
|
20212
20037
|
if (getResult.data) {
|
|
20213
|
-
session.isVpc = getResult.data.vpcResource;
|
|
20214
|
-
session.networkInterfaceIp = getResult.data.networkInterfaceIp;
|
|
20215
|
-
session.httpPort = getResult.data.httpPort;
|
|
20216
|
-
session.token = getResult.data.token;
|
|
20217
20038
|
session.resourceUrl = getResult.data.resourceUrl;
|
|
20039
|
+
session.token = getResult.data.token || "";
|
|
20218
20040
|
}
|
|
20219
20041
|
return {
|
|
20220
20042
|
requestId: getResult.requestId,
|
|
@@ -21117,7 +20939,7 @@ var _MobileSimulateService = class _MobileSimulateService {
|
|
|
21117
20939
|
if (!contextSync) {
|
|
21118
20940
|
throw new Error("contextSync is required for external context");
|
|
21119
20941
|
}
|
|
21120
|
-
if (_optionalChain([contextSync, 'access',
|
|
20942
|
+
if (_optionalChain([contextSync, 'access', _276 => _276.policy, 'optionalAccess', _277 => _277.bwList, 'optionalAccess', _278 => _278.whiteLists])) {
|
|
21121
20943
|
const exists = contextSync.policy.bwList.whiteLists.some(
|
|
21122
20944
|
(whiteList) => whiteList.path === MOBILE_INFO_SUB_PATH
|
|
21123
20945
|
);
|
|
@@ -21341,7 +21163,6 @@ var _CreateSessionParams = class _CreateSessionParams {
|
|
|
21341
21163
|
constructor() {
|
|
21342
21164
|
this.labels = {};
|
|
21343
21165
|
this.contextSync = [];
|
|
21344
|
-
this.isVpc = false;
|
|
21345
21166
|
this.enableBrowserReplay = true;
|
|
21346
21167
|
}
|
|
21347
21168
|
/**
|
|
@@ -21391,13 +21212,6 @@ var _CreateSessionParams = class _CreateSessionParams {
|
|
|
21391
21212
|
}
|
|
21392
21213
|
return this;
|
|
21393
21214
|
}
|
|
21394
|
-
/**
|
|
21395
|
-
* WithIsVpc sets the VPC flag for the session parameters and returns the updated parameters.
|
|
21396
|
-
*/
|
|
21397
|
-
withIsVpc(isVpc) {
|
|
21398
|
-
this.isVpc = isVpc;
|
|
21399
|
-
return this;
|
|
21400
|
-
}
|
|
21401
21215
|
/**
|
|
21402
21216
|
* WithPolicyId sets the policy id for the session parameters and returns the updated parameters.
|
|
21403
21217
|
*/
|
|
@@ -21533,7 +21347,6 @@ var _CreateSessionParams = class _CreateSessionParams {
|
|
|
21533
21347
|
volumeId: this.volumeId,
|
|
21534
21348
|
contextSync: allContextSyncs,
|
|
21535
21349
|
browserContext: this.browserContext,
|
|
21536
|
-
isVpc: this.isVpc,
|
|
21537
21350
|
policyId: this.policyId,
|
|
21538
21351
|
betaNetworkId: this.betaNetworkId,
|
|
21539
21352
|
enableBrowserReplay: this.enableBrowserReplay,
|
|
@@ -21563,7 +21376,6 @@ var _CreateSessionParams = class _CreateSessionParams {
|
|
|
21563
21376
|
);
|
|
21564
21377
|
}
|
|
21565
21378
|
}
|
|
21566
|
-
params.isVpc = config.isVpc || false;
|
|
21567
21379
|
params.policyId = config.policyId;
|
|
21568
21380
|
params.betaNetworkId = config.betaNetworkId;
|
|
21569
21381
|
params.enableBrowserReplay = config.enableBrowserReplay;
|
|
@@ -21644,7 +21456,7 @@ var _LocalMCPClient = class _LocalMCPClient {
|
|
|
21644
21456
|
}
|
|
21645
21457
|
}, 15e3);
|
|
21646
21458
|
let buffer = "";
|
|
21647
|
-
_optionalChain([childProcess, 'access',
|
|
21459
|
+
_optionalChain([childProcess, 'access', _279 => _279.stdout, 'optionalAccess', _280 => _280.on, 'call', _281 => _281("data", (data) => {
|
|
21648
21460
|
buffer += data.toString();
|
|
21649
21461
|
try {
|
|
21650
21462
|
const lines = buffer.split("\n");
|
|
@@ -21668,7 +21480,7 @@ var _LocalMCPClient = class _LocalMCPClient {
|
|
|
21668
21480
|
} catch (e) {
|
|
21669
21481
|
}
|
|
21670
21482
|
})]);
|
|
21671
|
-
_optionalChain([childProcess, 'access',
|
|
21483
|
+
_optionalChain([childProcess, 'access', _282 => _282.stderr, 'optionalAccess', _283 => _283.on, 'call', _284 => _284("data", (data) => {
|
|
21672
21484
|
const stderrText = data.toString();
|
|
21673
21485
|
logDebug(`[LocalMCPClient] stderr: ${stderrText}`);
|
|
21674
21486
|
if (stderrText.includes("started") || stderrText.includes("initialized") || stderrText.includes("ready")) {
|
|
@@ -21749,7 +21561,7 @@ var _LocalMCPClient = class _LocalMCPClient {
|
|
|
21749
21561
|
requestId: parsed.id || `local_request_${_crypto.randomUUID.call(void 0, )}`,
|
|
21750
21562
|
success: !parsed.error,
|
|
21751
21563
|
data: typeof responseData === "string" ? responseData : JSON.stringify(responseData),
|
|
21752
|
-
errorMessage: _optionalChain([parsed, 'access',
|
|
21564
|
+
errorMessage: _optionalChain([parsed, 'access', _285 => _285.error, 'optionalAccess', _286 => _286.message])
|
|
21753
21565
|
};
|
|
21754
21566
|
queued.resolve(response);
|
|
21755
21567
|
}
|
|
@@ -21784,7 +21596,7 @@ var _LocalMCPClient = class _LocalMCPClient {
|
|
|
21784
21596
|
arguments: arguments_
|
|
21785
21597
|
}
|
|
21786
21598
|
};
|
|
21787
|
-
_optionalChain([this, 'access',
|
|
21599
|
+
_optionalChain([this, 'access', _287 => _287.workerThread, 'optionalAccess', _288 => _288.stdin, 'optionalAccess', _289 => _289.write, 'call', _290 => _290(JSON.stringify(request) + "\n")]);
|
|
21788
21600
|
const TOOL_CALL_TIMEOUT = 18e4;
|
|
21789
21601
|
setTimeout(() => {
|
|
21790
21602
|
reject(new Error(`Tool call timeout: ${toolName}`));
|
|
@@ -21938,7 +21750,7 @@ var _LocalBrowser = class _LocalBrowser extends Browser {
|
|
|
21938
21750
|
* Playwright interactive loop to keep the browser alive
|
|
21939
21751
|
*/
|
|
21940
21752
|
async _playwrightInteractiveLoop(shutdownSignal) {
|
|
21941
|
-
while (!_optionalChain([shutdownSignal, 'optionalAccess',
|
|
21753
|
+
while (!_optionalChain([shutdownSignal, 'optionalAccess', _291 => _291.aborted])) {
|
|
21942
21754
|
await new Promise((resolve2) => setTimeout(resolve2, 3e3));
|
|
21943
21755
|
}
|
|
21944
21756
|
}
|
|
@@ -21946,7 +21758,7 @@ var _LocalBrowser = class _LocalBrowser extends Browser {
|
|
|
21946
21758
|
* Abort the playwright interactive loop
|
|
21947
21759
|
*/
|
|
21948
21760
|
abortPlaywrightInteractiveLoop() {
|
|
21949
|
-
_optionalChain([this, 'access',
|
|
21761
|
+
_optionalChain([this, 'access', _292 => _292._playwrightInteractiveLoopAbortController, 'optionalAccess', _293 => _293.abort, 'call', _294 => _294()]);
|
|
21950
21762
|
}
|
|
21951
21763
|
};
|
|
21952
21764
|
_chunkJB6CNGN4cjs.__name.call(void 0, _LocalBrowser, "LocalBrowser");
|