wuying-agentbay-sdk 0.4.2 → 0.5.1
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/README.md +1 -1
- package/dist/index.cjs +2095 -1136
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +674 -238
- package/dist/index.d.ts +674 -238
- package/dist/index.mjs +2064 -1105
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -6
package/dist/index.cjs
CHANGED
|
@@ -489,7 +489,7 @@ init_cjs_shims();
|
|
|
489
489
|
|
|
490
490
|
// src/api/client.ts
|
|
491
491
|
init_cjs_shims();
|
|
492
|
-
var _typescript = require('@darabonba/typescript'); var $
|
|
492
|
+
var _typescript = require('@darabonba/typescript'); var $dara65 = _interopRequireWildcard(_typescript); var $dara = _interopRequireWildcard(_typescript); var $dara2 = _interopRequireWildcard(_typescript); var $dara3 = _interopRequireWildcard(_typescript); var $dara4 = _interopRequireWildcard(_typescript); var $dara5 = _interopRequireWildcard(_typescript); var $dara6 = _interopRequireWildcard(_typescript); var $dara7 = _interopRequireWildcard(_typescript); var $dara8 = _interopRequireWildcard(_typescript); var $dara9 = _interopRequireWildcard(_typescript); var $dara10 = _interopRequireWildcard(_typescript); var $dara11 = _interopRequireWildcard(_typescript); var $dara12 = _interopRequireWildcard(_typescript); var $dara13 = _interopRequireWildcard(_typescript); var $dara14 = _interopRequireWildcard(_typescript); var $dara15 = _interopRequireWildcard(_typescript); var $dara16 = _interopRequireWildcard(_typescript); var $dara17 = _interopRequireWildcard(_typescript); var $dara18 = _interopRequireWildcard(_typescript); var $dara19 = _interopRequireWildcard(_typescript); var $dara20 = _interopRequireWildcard(_typescript); var $dara21 = _interopRequireWildcard(_typescript); var $dara22 = _interopRequireWildcard(_typescript); var $dara23 = _interopRequireWildcard(_typescript); var $dara24 = _interopRequireWildcard(_typescript); var $dara25 = _interopRequireWildcard(_typescript); var $dara26 = _interopRequireWildcard(_typescript); var $dara27 = _interopRequireWildcard(_typescript); var $dara28 = _interopRequireWildcard(_typescript); var $dara29 = _interopRequireWildcard(_typescript); var $dara30 = _interopRequireWildcard(_typescript); var $dara31 = _interopRequireWildcard(_typescript); var $dara32 = _interopRequireWildcard(_typescript); var $dara33 = _interopRequireWildcard(_typescript); var $dara34 = _interopRequireWildcard(_typescript); var $dara35 = _interopRequireWildcard(_typescript); var $dara36 = _interopRequireWildcard(_typescript); var $dara37 = _interopRequireWildcard(_typescript); var $dara38 = _interopRequireWildcard(_typescript); var $dara39 = _interopRequireWildcard(_typescript); var $dara40 = _interopRequireWildcard(_typescript); var $dara42 = _interopRequireWildcard(_typescript); var $dara41 = _interopRequireWildcard(_typescript); var $dara43 = _interopRequireWildcard(_typescript); var $dara44 = _interopRequireWildcard(_typescript); var $dara45 = _interopRequireWildcard(_typescript); var $dara46 = _interopRequireWildcard(_typescript); var $dara47 = _interopRequireWildcard(_typescript); var $dara48 = _interopRequireWildcard(_typescript); var $dara49 = _interopRequireWildcard(_typescript); var $dara50 = _interopRequireWildcard(_typescript); var $dara51 = _interopRequireWildcard(_typescript); var $dara52 = _interopRequireWildcard(_typescript); var $dara53 = _interopRequireWildcard(_typescript); var $dara54 = _interopRequireWildcard(_typescript); var $dara55 = _interopRequireWildcard(_typescript); var $dara56 = _interopRequireWildcard(_typescript); var $dara57 = _interopRequireWildcard(_typescript); var $dara58 = _interopRequireWildcard(_typescript); var $dara59 = _interopRequireWildcard(_typescript); var $dara60 = _interopRequireWildcard(_typescript); var $dara61 = _interopRequireWildcard(_typescript); var $dara62 = _interopRequireWildcard(_typescript); var $dara63 = _interopRequireWildcard(_typescript); var $dara64 = _interopRequireWildcard(_typescript);
|
|
493
493
|
|
|
494
494
|
|
|
495
495
|
|
|
@@ -566,20 +566,26 @@ var _CreateMcpSessionResponseBodyData = class _CreateMcpSessionResponseBodyData
|
|
|
566
566
|
return {
|
|
567
567
|
appInstanceId: "AppInstanceId",
|
|
568
568
|
errMsg: "ErrMsg",
|
|
569
|
+
httpPort: "HttpPort",
|
|
570
|
+
networkInterfaceIp: "NetworkInterfaceIp",
|
|
569
571
|
resourceId: "ResourceId",
|
|
570
572
|
resourceUrl: "ResourceUrl",
|
|
571
573
|
sessionId: "SessionId",
|
|
572
|
-
success: "Success"
|
|
574
|
+
success: "Success",
|
|
575
|
+
vpcResource: "VpcResource"
|
|
573
576
|
};
|
|
574
577
|
}
|
|
575
578
|
static types() {
|
|
576
579
|
return {
|
|
577
580
|
appInstanceId: "string",
|
|
578
581
|
errMsg: "string",
|
|
582
|
+
httpPort: "string",
|
|
583
|
+
networkInterfaceIp: "string",
|
|
579
584
|
resourceId: "string",
|
|
580
585
|
resourceUrl: "string",
|
|
581
586
|
sessionId: "string",
|
|
582
|
-
success: "boolean"
|
|
587
|
+
success: "boolean",
|
|
588
|
+
vpcResource: "boolean"
|
|
583
589
|
};
|
|
584
590
|
}
|
|
585
591
|
validate() {
|
|
@@ -1036,7 +1042,8 @@ var _CreateMcpSessionRequest = class _CreateMcpSessionRequest extends $dara18.Mo
|
|
|
1036
1042
|
imageId: "ImageId",
|
|
1037
1043
|
labels: "Labels",
|
|
1038
1044
|
persistenceDataList: "PersistenceDataList",
|
|
1039
|
-
sessionId: "SessionId"
|
|
1045
|
+
sessionId: "SessionId",
|
|
1046
|
+
vpcResource: "VpcResource"
|
|
1040
1047
|
};
|
|
1041
1048
|
}
|
|
1042
1049
|
static types() {
|
|
@@ -1047,7 +1054,8 @@ var _CreateMcpSessionRequest = class _CreateMcpSessionRequest extends $dara18.Mo
|
|
|
1047
1054
|
imageId: "string",
|
|
1048
1055
|
labels: "string",
|
|
1049
1056
|
persistenceDataList: { "type": "array", "itemType": CreateMcpSessionRequestPersistenceDataList },
|
|
1050
|
-
sessionId: "string"
|
|
1057
|
+
sessionId: "string",
|
|
1058
|
+
vpcResource: "boolean"
|
|
1051
1059
|
};
|
|
1052
1060
|
}
|
|
1053
1061
|
validate() {
|
|
@@ -1075,7 +1083,8 @@ var _CreateMcpSessionShrinkRequest = class _CreateMcpSessionShrinkRequest extend
|
|
|
1075
1083
|
imageId: "ImageId",
|
|
1076
1084
|
labels: "Labels",
|
|
1077
1085
|
persistenceDataListShrink: "PersistenceDataList",
|
|
1078
|
-
sessionId: "SessionId"
|
|
1086
|
+
sessionId: "SessionId",
|
|
1087
|
+
vpcResource: "VpcResource"
|
|
1079
1088
|
};
|
|
1080
1089
|
}
|
|
1081
1090
|
static types() {
|
|
@@ -1086,7 +1095,8 @@ var _CreateMcpSessionShrinkRequest = class _CreateMcpSessionShrinkRequest extend
|
|
|
1086
1095
|
imageId: "string",
|
|
1087
1096
|
labels: "string",
|
|
1088
1097
|
persistenceDataListShrink: "string",
|
|
1089
|
-
sessionId: "string"
|
|
1098
|
+
sessionId: "string",
|
|
1099
|
+
vpcResource: "boolean"
|
|
1090
1100
|
};
|
|
1091
1101
|
}
|
|
1092
1102
|
validate() {
|
|
@@ -1769,10 +1779,147 @@ var _GetMcpResourceResponse = class _GetMcpResourceResponse extends $dara39.Mode
|
|
|
1769
1779
|
__name(_GetMcpResourceResponse, "GetMcpResourceResponse");
|
|
1770
1780
|
var GetMcpResourceResponse = _GetMcpResourceResponse;
|
|
1771
1781
|
|
|
1782
|
+
// src/api/models/InitBrowserRequest.ts
|
|
1783
|
+
init_cjs_shims();
|
|
1784
|
+
|
|
1785
|
+
var _InitBrowserRequest = class _InitBrowserRequest extends $dara40.Model {
|
|
1786
|
+
static names() {
|
|
1787
|
+
return {
|
|
1788
|
+
authorization: "Authorization",
|
|
1789
|
+
persistentPath: "PersistentPath",
|
|
1790
|
+
sessionId: "SessionId"
|
|
1791
|
+
};
|
|
1792
|
+
}
|
|
1793
|
+
static types() {
|
|
1794
|
+
return {
|
|
1795
|
+
authorization: "string",
|
|
1796
|
+
persistentPath: "string",
|
|
1797
|
+
sessionId: "string"
|
|
1798
|
+
};
|
|
1799
|
+
}
|
|
1800
|
+
validate() {
|
|
1801
|
+
super.validate();
|
|
1802
|
+
}
|
|
1803
|
+
constructor(map) {
|
|
1804
|
+
super(map);
|
|
1805
|
+
}
|
|
1806
|
+
static fromMap(m) {
|
|
1807
|
+
return $dara40.cast(m, new _InitBrowserRequest());
|
|
1808
|
+
}
|
|
1809
|
+
};
|
|
1810
|
+
__name(_InitBrowserRequest, "InitBrowserRequest");
|
|
1811
|
+
var InitBrowserRequest = _InitBrowserRequest;
|
|
1812
|
+
|
|
1813
|
+
// src/api/models/InitBrowserResponseBody.ts
|
|
1814
|
+
init_cjs_shims();
|
|
1815
|
+
|
|
1816
|
+
|
|
1817
|
+
// src/api/models/InitBrowserResponseBodyData.ts
|
|
1818
|
+
init_cjs_shims();
|
|
1819
|
+
|
|
1820
|
+
var _InitBrowserResponseBodyData = class _InitBrowserResponseBodyData extends $dara41.Model {
|
|
1821
|
+
static names() {
|
|
1822
|
+
return {
|
|
1823
|
+
port: "Port"
|
|
1824
|
+
};
|
|
1825
|
+
}
|
|
1826
|
+
static types() {
|
|
1827
|
+
return {
|
|
1828
|
+
port: "number"
|
|
1829
|
+
};
|
|
1830
|
+
}
|
|
1831
|
+
validate() {
|
|
1832
|
+
super.validate();
|
|
1833
|
+
}
|
|
1834
|
+
constructor(map) {
|
|
1835
|
+
super(map);
|
|
1836
|
+
}
|
|
1837
|
+
static fromMap(m) {
|
|
1838
|
+
return $dara41.cast(m, new _InitBrowserResponseBodyData());
|
|
1839
|
+
}
|
|
1840
|
+
};
|
|
1841
|
+
__name(_InitBrowserResponseBodyData, "InitBrowserResponseBodyData");
|
|
1842
|
+
var InitBrowserResponseBodyData = _InitBrowserResponseBodyData;
|
|
1843
|
+
|
|
1844
|
+
// src/api/models/InitBrowserResponseBody.ts
|
|
1845
|
+
var _InitBrowserResponseBody = class _InitBrowserResponseBody extends $dara42.Model {
|
|
1846
|
+
static names() {
|
|
1847
|
+
return {
|
|
1848
|
+
code: "Code",
|
|
1849
|
+
data: "Data",
|
|
1850
|
+
httpStatusCode: "HttpStatusCode",
|
|
1851
|
+
message: "Message",
|
|
1852
|
+
requestId: "RequestId",
|
|
1853
|
+
success: "Success"
|
|
1854
|
+
};
|
|
1855
|
+
}
|
|
1856
|
+
static types() {
|
|
1857
|
+
return {
|
|
1858
|
+
code: "string",
|
|
1859
|
+
data: InitBrowserResponseBodyData,
|
|
1860
|
+
httpStatusCode: "number",
|
|
1861
|
+
message: "string",
|
|
1862
|
+
requestId: "string",
|
|
1863
|
+
success: "boolean"
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
validate() {
|
|
1867
|
+
if (this.data && typeof this.data.validate === "function") {
|
|
1868
|
+
this.data.validate();
|
|
1869
|
+
}
|
|
1870
|
+
super.validate();
|
|
1871
|
+
}
|
|
1872
|
+
constructor(map) {
|
|
1873
|
+
super(map);
|
|
1874
|
+
}
|
|
1875
|
+
static fromMap(m) {
|
|
1876
|
+
return $dara42.cast(m, new _InitBrowserResponseBody());
|
|
1877
|
+
}
|
|
1878
|
+
};
|
|
1879
|
+
__name(_InitBrowserResponseBody, "InitBrowserResponseBody");
|
|
1880
|
+
var InitBrowserResponseBody = _InitBrowserResponseBody;
|
|
1881
|
+
|
|
1882
|
+
// src/api/models/InitBrowserResponse.ts
|
|
1883
|
+
init_cjs_shims();
|
|
1884
|
+
|
|
1885
|
+
var _InitBrowserResponse = class _InitBrowserResponse extends $dara43.Model {
|
|
1886
|
+
static names() {
|
|
1887
|
+
return {
|
|
1888
|
+
headers: "headers",
|
|
1889
|
+
statusCode: "statusCode",
|
|
1890
|
+
body: "body"
|
|
1891
|
+
};
|
|
1892
|
+
}
|
|
1893
|
+
static types() {
|
|
1894
|
+
return {
|
|
1895
|
+
headers: { "type": "map", "keyType": "string", "valueType": "string" },
|
|
1896
|
+
statusCode: "number",
|
|
1897
|
+
body: InitBrowserResponseBody
|
|
1898
|
+
};
|
|
1899
|
+
}
|
|
1900
|
+
validate() {
|
|
1901
|
+
if (this.headers) {
|
|
1902
|
+
$dara43.Model.validateMap(this.headers);
|
|
1903
|
+
}
|
|
1904
|
+
if (this.body && typeof this.body.validate === "function") {
|
|
1905
|
+
this.body.validate();
|
|
1906
|
+
}
|
|
1907
|
+
super.validate();
|
|
1908
|
+
}
|
|
1909
|
+
constructor(map) {
|
|
1910
|
+
super(map);
|
|
1911
|
+
}
|
|
1912
|
+
static fromMap(m) {
|
|
1913
|
+
return $dara43.cast(m, new _InitBrowserResponse());
|
|
1914
|
+
}
|
|
1915
|
+
};
|
|
1916
|
+
__name(_InitBrowserResponse, "InitBrowserResponse");
|
|
1917
|
+
var InitBrowserResponse = _InitBrowserResponse;
|
|
1918
|
+
|
|
1772
1919
|
// src/api/models/ListContextsRequest.ts
|
|
1773
1920
|
init_cjs_shims();
|
|
1774
1921
|
|
|
1775
|
-
var _ListContextsRequest = class _ListContextsRequest extends $
|
|
1922
|
+
var _ListContextsRequest = class _ListContextsRequest extends $dara44.Model {
|
|
1776
1923
|
static names() {
|
|
1777
1924
|
return {
|
|
1778
1925
|
authorization: "Authorization",
|
|
@@ -1800,7 +1947,7 @@ var ListContextsRequest = _ListContextsRequest;
|
|
|
1800
1947
|
// src/api/models/ListContextsResponseBody.ts
|
|
1801
1948
|
init_cjs_shims();
|
|
1802
1949
|
|
|
1803
|
-
var _ListContextsResponseBody = class _ListContextsResponseBody extends $
|
|
1950
|
+
var _ListContextsResponseBody = class _ListContextsResponseBody extends $dara45.Model {
|
|
1804
1951
|
static names() {
|
|
1805
1952
|
return {
|
|
1806
1953
|
code: "Code",
|
|
@@ -1829,7 +1976,7 @@ var _ListContextsResponseBody = class _ListContextsResponseBody extends $dara41.
|
|
|
1829
1976
|
}
|
|
1830
1977
|
validate() {
|
|
1831
1978
|
if (Array.isArray(this.data)) {
|
|
1832
|
-
$
|
|
1979
|
+
$dara45.Model.validateArray(this.data);
|
|
1833
1980
|
}
|
|
1834
1981
|
super.validate();
|
|
1835
1982
|
}
|
|
@@ -1843,7 +1990,7 @@ var ListContextsResponseBody = _ListContextsResponseBody;
|
|
|
1843
1990
|
// src/api/models/ListContextsResponse.ts
|
|
1844
1991
|
init_cjs_shims();
|
|
1845
1992
|
|
|
1846
|
-
var _ListContextsResponse = class _ListContextsResponse extends $
|
|
1993
|
+
var _ListContextsResponse = class _ListContextsResponse extends $dara46.Model {
|
|
1847
1994
|
static names() {
|
|
1848
1995
|
return {
|
|
1849
1996
|
headers: "headers",
|
|
@@ -1860,7 +2007,7 @@ var _ListContextsResponse = class _ListContextsResponse extends $dara42.Model {
|
|
|
1860
2007
|
}
|
|
1861
2008
|
validate() {
|
|
1862
2009
|
if (this.headers) {
|
|
1863
|
-
$
|
|
2010
|
+
$dara46.Model.validateMap(this.headers);
|
|
1864
2011
|
}
|
|
1865
2012
|
if (this.body && typeof this.body.validate === "function") {
|
|
1866
2013
|
this.body.validate();
|
|
@@ -1877,7 +2024,7 @@ var ListContextsResponse = _ListContextsResponse;
|
|
|
1877
2024
|
// src/api/models/ListMcpToolsRequest.ts
|
|
1878
2025
|
init_cjs_shims();
|
|
1879
2026
|
|
|
1880
|
-
var _ListMcpToolsRequest = class _ListMcpToolsRequest extends $
|
|
2027
|
+
var _ListMcpToolsRequest = class _ListMcpToolsRequest extends $dara47.Model {
|
|
1881
2028
|
static names() {
|
|
1882
2029
|
return {
|
|
1883
2030
|
authorization: "Authorization",
|
|
@@ -1903,7 +2050,7 @@ var ListMcpToolsRequest = _ListMcpToolsRequest;
|
|
|
1903
2050
|
// src/api/models/ListMcpToolsResponseBody.ts
|
|
1904
2051
|
init_cjs_shims();
|
|
1905
2052
|
|
|
1906
|
-
var _ListMcpToolsResponseBody = class _ListMcpToolsResponseBody extends $
|
|
2053
|
+
var _ListMcpToolsResponseBody = class _ListMcpToolsResponseBody extends $dara48.Model {
|
|
1907
2054
|
static names() {
|
|
1908
2055
|
return {
|
|
1909
2056
|
code: "Code",
|
|
@@ -1937,7 +2084,7 @@ var ListMcpToolsResponseBody = _ListMcpToolsResponseBody;
|
|
|
1937
2084
|
// src/api/models/ListMcpToolsResponse.ts
|
|
1938
2085
|
init_cjs_shims();
|
|
1939
2086
|
|
|
1940
|
-
var _ListMcpToolsResponse = class _ListMcpToolsResponse extends $
|
|
2087
|
+
var _ListMcpToolsResponse = class _ListMcpToolsResponse extends $dara49.Model {
|
|
1941
2088
|
static names() {
|
|
1942
2089
|
return {
|
|
1943
2090
|
headers: "headers",
|
|
@@ -1954,7 +2101,7 @@ var _ListMcpToolsResponse = class _ListMcpToolsResponse extends $dara45.Model {
|
|
|
1954
2101
|
}
|
|
1955
2102
|
validate() {
|
|
1956
2103
|
if (this.headers) {
|
|
1957
|
-
$
|
|
2104
|
+
$dara49.Model.validateMap(this.headers);
|
|
1958
2105
|
}
|
|
1959
2106
|
if (this.body && typeof this.body.validate === "function") {
|
|
1960
2107
|
this.body.validate();
|
|
@@ -1971,7 +2118,7 @@ var ListMcpToolsResponse = _ListMcpToolsResponse;
|
|
|
1971
2118
|
// src/api/models/ListSessionRequest.ts
|
|
1972
2119
|
init_cjs_shims();
|
|
1973
2120
|
|
|
1974
|
-
var _ListSessionRequest = class _ListSessionRequest extends $
|
|
2121
|
+
var _ListSessionRequest = class _ListSessionRequest extends $dara50.Model {
|
|
1975
2122
|
static names() {
|
|
1976
2123
|
return {
|
|
1977
2124
|
authorization: "Authorization",
|
|
@@ -2001,7 +2148,7 @@ var ListSessionRequest = _ListSessionRequest;
|
|
|
2001
2148
|
// src/api/models/ListSessionResponseBody.ts
|
|
2002
2149
|
init_cjs_shims();
|
|
2003
2150
|
|
|
2004
|
-
var _ListSessionResponseBody = class _ListSessionResponseBody extends $
|
|
2151
|
+
var _ListSessionResponseBody = class _ListSessionResponseBody extends $dara51.Model {
|
|
2005
2152
|
static names() {
|
|
2006
2153
|
return {
|
|
2007
2154
|
code: "Code",
|
|
@@ -2030,7 +2177,7 @@ var _ListSessionResponseBody = class _ListSessionResponseBody extends $dara47.Mo
|
|
|
2030
2177
|
}
|
|
2031
2178
|
validate() {
|
|
2032
2179
|
if (Array.isArray(this.data)) {
|
|
2033
|
-
$
|
|
2180
|
+
$dara51.Model.validateArray(this.data);
|
|
2034
2181
|
}
|
|
2035
2182
|
super.validate();
|
|
2036
2183
|
}
|
|
@@ -2044,7 +2191,7 @@ var ListSessionResponseBody = _ListSessionResponseBody;
|
|
|
2044
2191
|
// src/api/models/ListSessionResponse.ts
|
|
2045
2192
|
init_cjs_shims();
|
|
2046
2193
|
|
|
2047
|
-
var _ListSessionResponse = class _ListSessionResponse extends $
|
|
2194
|
+
var _ListSessionResponse = class _ListSessionResponse extends $dara52.Model {
|
|
2048
2195
|
static names() {
|
|
2049
2196
|
return {
|
|
2050
2197
|
headers: "headers",
|
|
@@ -2061,7 +2208,7 @@ var _ListSessionResponse = class _ListSessionResponse extends $dara48.Model {
|
|
|
2061
2208
|
}
|
|
2062
2209
|
validate() {
|
|
2063
2210
|
if (this.headers) {
|
|
2064
|
-
$
|
|
2211
|
+
$dara52.Model.validateMap(this.headers);
|
|
2065
2212
|
}
|
|
2066
2213
|
if (this.body && typeof this.body.validate === "function") {
|
|
2067
2214
|
this.body.validate();
|
|
@@ -2078,7 +2225,7 @@ var ListSessionResponse = _ListSessionResponse;
|
|
|
2078
2225
|
// src/api/models/ModifyContextRequest.ts
|
|
2079
2226
|
init_cjs_shims();
|
|
2080
2227
|
|
|
2081
|
-
var _ModifyContextRequest = class _ModifyContextRequest extends $
|
|
2228
|
+
var _ModifyContextRequest = class _ModifyContextRequest extends $dara53.Model {
|
|
2082
2229
|
static names() {
|
|
2083
2230
|
return {
|
|
2084
2231
|
authorization: "Authorization",
|
|
@@ -2106,7 +2253,7 @@ var ModifyContextRequest = _ModifyContextRequest;
|
|
|
2106
2253
|
// src/api/models/ModifyContextResponseBody.ts
|
|
2107
2254
|
init_cjs_shims();
|
|
2108
2255
|
|
|
2109
|
-
var _ModifyContextResponseBody = class _ModifyContextResponseBody extends $
|
|
2256
|
+
var _ModifyContextResponseBody = class _ModifyContextResponseBody extends $dara54.Model {
|
|
2110
2257
|
static names() {
|
|
2111
2258
|
return {
|
|
2112
2259
|
code: "Code",
|
|
@@ -2138,7 +2285,7 @@ var ModifyContextResponseBody = _ModifyContextResponseBody;
|
|
|
2138
2285
|
// src/api/models/ModifyContextResponse.ts
|
|
2139
2286
|
init_cjs_shims();
|
|
2140
2287
|
|
|
2141
|
-
var _ModifyContextResponse = class _ModifyContextResponse extends $
|
|
2288
|
+
var _ModifyContextResponse = class _ModifyContextResponse extends $dara55.Model {
|
|
2142
2289
|
static names() {
|
|
2143
2290
|
return {
|
|
2144
2291
|
headers: "headers",
|
|
@@ -2155,7 +2302,7 @@ var _ModifyContextResponse = class _ModifyContextResponse extends $dara51.Model
|
|
|
2155
2302
|
}
|
|
2156
2303
|
validate() {
|
|
2157
2304
|
if (this.headers) {
|
|
2158
|
-
$
|
|
2305
|
+
$dara55.Model.validateMap(this.headers);
|
|
2159
2306
|
}
|
|
2160
2307
|
if (this.body && typeof this.body.validate === "function") {
|
|
2161
2308
|
this.body.validate();
|
|
@@ -2172,7 +2319,7 @@ var ModifyContextResponse = _ModifyContextResponse;
|
|
|
2172
2319
|
// src/api/models/ReleaseMcpSessionRequest.ts
|
|
2173
2320
|
init_cjs_shims();
|
|
2174
2321
|
|
|
2175
|
-
var _ReleaseMcpSessionRequest = class _ReleaseMcpSessionRequest extends $
|
|
2322
|
+
var _ReleaseMcpSessionRequest = class _ReleaseMcpSessionRequest extends $dara56.Model {
|
|
2176
2323
|
static names() {
|
|
2177
2324
|
return {
|
|
2178
2325
|
authorization: "Authorization",
|
|
@@ -2198,7 +2345,7 @@ var ReleaseMcpSessionRequest = _ReleaseMcpSessionRequest;
|
|
|
2198
2345
|
// src/api/models/ReleaseMcpSessionResponseBody.ts
|
|
2199
2346
|
init_cjs_shims();
|
|
2200
2347
|
|
|
2201
|
-
var _ReleaseMcpSessionResponseBody = class _ReleaseMcpSessionResponseBody extends $
|
|
2348
|
+
var _ReleaseMcpSessionResponseBody = class _ReleaseMcpSessionResponseBody extends $dara57.Model {
|
|
2202
2349
|
static names() {
|
|
2203
2350
|
return {
|
|
2204
2351
|
code: "Code",
|
|
@@ -2230,7 +2377,7 @@ var ReleaseMcpSessionResponseBody = _ReleaseMcpSessionResponseBody;
|
|
|
2230
2377
|
// src/api/models/ReleaseMcpSessionResponse.ts
|
|
2231
2378
|
init_cjs_shims();
|
|
2232
2379
|
|
|
2233
|
-
var _ReleaseMcpSessionResponse = class _ReleaseMcpSessionResponse extends $
|
|
2380
|
+
var _ReleaseMcpSessionResponse = class _ReleaseMcpSessionResponse extends $dara58.Model {
|
|
2234
2381
|
static names() {
|
|
2235
2382
|
return {
|
|
2236
2383
|
headers: "headers",
|
|
@@ -2247,7 +2394,7 @@ var _ReleaseMcpSessionResponse = class _ReleaseMcpSessionResponse extends $dara5
|
|
|
2247
2394
|
}
|
|
2248
2395
|
validate() {
|
|
2249
2396
|
if (this.headers) {
|
|
2250
|
-
$
|
|
2397
|
+
$dara58.Model.validateMap(this.headers);
|
|
2251
2398
|
}
|
|
2252
2399
|
if (this.body && typeof this.body.validate === "function") {
|
|
2253
2400
|
this.body.validate();
|
|
@@ -2264,7 +2411,7 @@ var ReleaseMcpSessionResponse = _ReleaseMcpSessionResponse;
|
|
|
2264
2411
|
// src/api/models/SetLabelRequest.ts
|
|
2265
2412
|
init_cjs_shims();
|
|
2266
2413
|
|
|
2267
|
-
var _SetLabelRequest = class _SetLabelRequest extends $
|
|
2414
|
+
var _SetLabelRequest = class _SetLabelRequest extends $dara59.Model {
|
|
2268
2415
|
static names() {
|
|
2269
2416
|
return {
|
|
2270
2417
|
authorization: "Authorization",
|
|
@@ -2292,7 +2439,7 @@ var SetLabelRequest = _SetLabelRequest;
|
|
|
2292
2439
|
// src/api/models/SetLabelResponseBody.ts
|
|
2293
2440
|
init_cjs_shims();
|
|
2294
2441
|
|
|
2295
|
-
var _SetLabelResponseBody = class _SetLabelResponseBody extends $
|
|
2442
|
+
var _SetLabelResponseBody = class _SetLabelResponseBody extends $dara60.Model {
|
|
2296
2443
|
static names() {
|
|
2297
2444
|
return {
|
|
2298
2445
|
code: "Code",
|
|
@@ -2324,7 +2471,7 @@ var SetLabelResponseBody = _SetLabelResponseBody;
|
|
|
2324
2471
|
// src/api/models/SetLabelResponse.ts
|
|
2325
2472
|
init_cjs_shims();
|
|
2326
2473
|
|
|
2327
|
-
var _SetLabelResponse = class _SetLabelResponse extends $
|
|
2474
|
+
var _SetLabelResponse = class _SetLabelResponse extends $dara61.Model {
|
|
2328
2475
|
static names() {
|
|
2329
2476
|
return {
|
|
2330
2477
|
headers: "headers",
|
|
@@ -2341,7 +2488,7 @@ var _SetLabelResponse = class _SetLabelResponse extends $dara57.Model {
|
|
|
2341
2488
|
}
|
|
2342
2489
|
validate() {
|
|
2343
2490
|
if (this.headers) {
|
|
2344
|
-
$
|
|
2491
|
+
$dara61.Model.validateMap(this.headers);
|
|
2345
2492
|
}
|
|
2346
2493
|
if (this.body && typeof this.body.validate === "function") {
|
|
2347
2494
|
this.body.validate();
|
|
@@ -2358,7 +2505,7 @@ var SetLabelResponse = _SetLabelResponse;
|
|
|
2358
2505
|
// src/api/models/SyncContextRequest.ts
|
|
2359
2506
|
init_cjs_shims();
|
|
2360
2507
|
|
|
2361
|
-
var _SyncContextRequest = class _SyncContextRequest extends $
|
|
2508
|
+
var _SyncContextRequest = class _SyncContextRequest extends $dara62.Model {
|
|
2362
2509
|
static names() {
|
|
2363
2510
|
return {
|
|
2364
2511
|
authorization: "Authorization",
|
|
@@ -2390,7 +2537,7 @@ var SyncContextRequest = _SyncContextRequest;
|
|
|
2390
2537
|
// src/api/models/SyncContextResponseBody.ts
|
|
2391
2538
|
init_cjs_shims();
|
|
2392
2539
|
|
|
2393
|
-
var _SyncContextResponseBody = class _SyncContextResponseBody extends $
|
|
2540
|
+
var _SyncContextResponseBody = class _SyncContextResponseBody extends $dara63.Model {
|
|
2394
2541
|
static names() {
|
|
2395
2542
|
return {
|
|
2396
2543
|
code: "Code",
|
|
@@ -2422,7 +2569,7 @@ var SyncContextResponseBody = _SyncContextResponseBody;
|
|
|
2422
2569
|
// src/api/models/SyncContextResponse.ts
|
|
2423
2570
|
init_cjs_shims();
|
|
2424
2571
|
|
|
2425
|
-
var _SyncContextResponse = class _SyncContextResponse extends $
|
|
2572
|
+
var _SyncContextResponse = class _SyncContextResponse extends $dara64.Model {
|
|
2426
2573
|
static names() {
|
|
2427
2574
|
return {
|
|
2428
2575
|
headers: "headers",
|
|
@@ -2439,7 +2586,7 @@ var _SyncContextResponse = class _SyncContextResponse extends $dara60.Model {
|
|
|
2439
2586
|
}
|
|
2440
2587
|
validate() {
|
|
2441
2588
|
if (this.headers) {
|
|
2442
|
-
$
|
|
2589
|
+
$dara64.Model.validateMap(this.headers);
|
|
2443
2590
|
}
|
|
2444
2591
|
if (this.body && typeof this.body.validate === "function") {
|
|
2445
2592
|
this.body.validate();
|
|
@@ -2471,10 +2618,10 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2471
2618
|
);
|
|
2472
2619
|
}
|
|
2473
2620
|
getEndpoint(productId, regionId, endpointRule, network, suffix, endpointMap, endpoint) {
|
|
2474
|
-
if (!$
|
|
2621
|
+
if (!$dara65.isNull(endpoint)) {
|
|
2475
2622
|
return endpoint;
|
|
2476
2623
|
}
|
|
2477
|
-
if (!$
|
|
2624
|
+
if (!$dara65.isNull(endpointMap) && !$dara65.isNull(endpointMap[regionId])) {
|
|
2478
2625
|
return endpointMap[regionId];
|
|
2479
2626
|
}
|
|
2480
2627
|
return _openapicore.OpenApiUtil.getEndpointRules(
|
|
@@ -2495,28 +2642,28 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2495
2642
|
async callMcpToolWithOptions(request, runtime) {
|
|
2496
2643
|
request.validate();
|
|
2497
2644
|
const body = {};
|
|
2498
|
-
if (!$
|
|
2645
|
+
if (!$dara65.isNull(request.args)) {
|
|
2499
2646
|
body["Args"] = request.args;
|
|
2500
2647
|
}
|
|
2501
|
-
if (!$
|
|
2648
|
+
if (!$dara65.isNull(request.authorization)) {
|
|
2502
2649
|
body["Authorization"] = request.authorization;
|
|
2503
2650
|
}
|
|
2504
|
-
if (!$
|
|
2651
|
+
if (!$dara65.isNull(request.externalUserId)) {
|
|
2505
2652
|
body["ExternalUserId"] = request.externalUserId;
|
|
2506
2653
|
}
|
|
2507
|
-
if (!$
|
|
2654
|
+
if (!$dara65.isNull(request.imageId)) {
|
|
2508
2655
|
body["ImageId"] = request.imageId;
|
|
2509
2656
|
}
|
|
2510
|
-
if (!$
|
|
2657
|
+
if (!$dara65.isNull(request.name)) {
|
|
2511
2658
|
body["Name"] = request.name;
|
|
2512
2659
|
}
|
|
2513
|
-
if (!$
|
|
2660
|
+
if (!$dara65.isNull(request.server)) {
|
|
2514
2661
|
body["Server"] = request.server;
|
|
2515
2662
|
}
|
|
2516
|
-
if (!$
|
|
2663
|
+
if (!$dara65.isNull(request.sessionId)) {
|
|
2517
2664
|
body["SessionId"] = request.sessionId;
|
|
2518
2665
|
}
|
|
2519
|
-
if (!$
|
|
2666
|
+
if (!$dara65.isNull(request.tool)) {
|
|
2520
2667
|
body["Tool"] = request.tool;
|
|
2521
2668
|
}
|
|
2522
2669
|
const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
@@ -2533,7 +2680,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2533
2680
|
reqBodyType: "formData",
|
|
2534
2681
|
bodyType: "json"
|
|
2535
2682
|
});
|
|
2536
|
-
return $
|
|
2683
|
+
return $dara65.cast(
|
|
2537
2684
|
await this.callApi(params, req, runtime),
|
|
2538
2685
|
new CallMcpToolResponse({})
|
|
2539
2686
|
);
|
|
@@ -2545,7 +2692,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2545
2692
|
* @returns CallMcpToolResponse
|
|
2546
2693
|
*/
|
|
2547
2694
|
async callMcpTool(request) {
|
|
2548
|
-
const runtime = new $
|
|
2695
|
+
const runtime = new $dara65.RuntimeOptions({});
|
|
2549
2696
|
return await this.callMcpToolWithOptions(request, runtime);
|
|
2550
2697
|
}
|
|
2551
2698
|
/**
|
|
@@ -2559,7 +2706,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2559
2706
|
tmpReq.validate();
|
|
2560
2707
|
const request = new CreateMcpSessionShrinkRequest({});
|
|
2561
2708
|
_openapicore.OpenApiUtil.convert(tmpReq, request);
|
|
2562
|
-
if (!$
|
|
2709
|
+
if (!$dara65.isNull(tmpReq.persistenceDataList)) {
|
|
2563
2710
|
request.persistenceDataListShrink = _openapicore.OpenApiUtil.arrayToStringWithSpecifiedStyle(
|
|
2564
2711
|
tmpReq.persistenceDataList,
|
|
2565
2712
|
"PersistenceDataList",
|
|
@@ -2567,27 +2714,30 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2567
2714
|
);
|
|
2568
2715
|
}
|
|
2569
2716
|
const body = {};
|
|
2570
|
-
if (!$
|
|
2717
|
+
if (!$dara65.isNull(request.authorization)) {
|
|
2571
2718
|
body["Authorization"] = request.authorization;
|
|
2572
2719
|
}
|
|
2573
|
-
if (!$
|
|
2720
|
+
if (!$dara65.isNull(request.contextId)) {
|
|
2574
2721
|
body["ContextId"] = request.contextId;
|
|
2575
2722
|
}
|
|
2576
|
-
if (!$
|
|
2723
|
+
if (!$dara65.isNull(request.externalUserId)) {
|
|
2577
2724
|
body["ExternalUserId"] = request.externalUserId;
|
|
2578
2725
|
}
|
|
2579
|
-
if (!$
|
|
2726
|
+
if (!$dara65.isNull(request.imageId)) {
|
|
2580
2727
|
body["ImageId"] = request.imageId;
|
|
2581
2728
|
}
|
|
2582
|
-
if (!$
|
|
2729
|
+
if (!$dara65.isNull(request.labels)) {
|
|
2583
2730
|
body["Labels"] = request.labels;
|
|
2584
2731
|
}
|
|
2585
|
-
if (!$
|
|
2732
|
+
if (!$dara65.isNull(request.persistenceDataListShrink)) {
|
|
2586
2733
|
body["PersistenceDataList"] = request.persistenceDataListShrink;
|
|
2587
2734
|
}
|
|
2588
|
-
if (!$
|
|
2735
|
+
if (!$dara65.isNull(request.sessionId)) {
|
|
2589
2736
|
body["SessionId"] = request.sessionId;
|
|
2590
2737
|
}
|
|
2738
|
+
if (!$dara65.isNull(request.vpcResource)) {
|
|
2739
|
+
body["VpcResource"] = request.vpcResource;
|
|
2740
|
+
}
|
|
2591
2741
|
const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
2592
2742
|
body: _openapicore.OpenApiUtil.parseToMap(body)
|
|
2593
2743
|
});
|
|
@@ -2602,7 +2752,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2602
2752
|
reqBodyType: "formData",
|
|
2603
2753
|
bodyType: "json"
|
|
2604
2754
|
});
|
|
2605
|
-
return $
|
|
2755
|
+
return $dara65.cast(
|
|
2606
2756
|
await this.callApi(params, req, runtime),
|
|
2607
2757
|
new CreateMcpSessionResponse({})
|
|
2608
2758
|
);
|
|
@@ -2614,7 +2764,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2614
2764
|
* @returns CreateMcpSessionResponse
|
|
2615
2765
|
*/
|
|
2616
2766
|
async createMcpSession(request) {
|
|
2617
|
-
const runtime = new $
|
|
2767
|
+
const runtime = new $dara65.RuntimeOptions({});
|
|
2618
2768
|
return await this.createMcpSessionWithOptions(request, runtime);
|
|
2619
2769
|
}
|
|
2620
2770
|
/**
|
|
@@ -2627,10 +2777,10 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2627
2777
|
async deleteContextWithOptions(request, runtime) {
|
|
2628
2778
|
request.validate();
|
|
2629
2779
|
const body = {};
|
|
2630
|
-
if (!$
|
|
2780
|
+
if (!$dara65.isNull(request.authorization)) {
|
|
2631
2781
|
body["Authorization"] = request.authorization;
|
|
2632
2782
|
}
|
|
2633
|
-
if (!$
|
|
2783
|
+
if (!$dara65.isNull(request.id)) {
|
|
2634
2784
|
body["Id"] = request.id;
|
|
2635
2785
|
}
|
|
2636
2786
|
const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
@@ -2647,7 +2797,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2647
2797
|
reqBodyType: "formData",
|
|
2648
2798
|
bodyType: "json"
|
|
2649
2799
|
});
|
|
2650
|
-
return $
|
|
2800
|
+
return $dara65.cast(
|
|
2651
2801
|
await this.callApi(params, req, runtime),
|
|
2652
2802
|
new DeleteContextResponse({})
|
|
2653
2803
|
);
|
|
@@ -2659,7 +2809,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2659
2809
|
* @returns DeleteContextResponse
|
|
2660
2810
|
*/
|
|
2661
2811
|
async deleteContext(request) {
|
|
2662
|
-
const runtime = new $
|
|
2812
|
+
const runtime = new $dara65.RuntimeOptions({});
|
|
2663
2813
|
return await this.deleteContextWithOptions(request, runtime);
|
|
2664
2814
|
}
|
|
2665
2815
|
/**
|
|
@@ -2672,13 +2822,13 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2672
2822
|
async getContextWithOptions(request, runtime) {
|
|
2673
2823
|
request.validate();
|
|
2674
2824
|
const body = {};
|
|
2675
|
-
if (!$
|
|
2825
|
+
if (!$dara65.isNull(request.allowCreate)) {
|
|
2676
2826
|
body["AllowCreate"] = request.allowCreate;
|
|
2677
2827
|
}
|
|
2678
|
-
if (!$
|
|
2828
|
+
if (!$dara65.isNull(request.authorization)) {
|
|
2679
2829
|
body["Authorization"] = request.authorization;
|
|
2680
2830
|
}
|
|
2681
|
-
if (!$
|
|
2831
|
+
if (!$dara65.isNull(request.name)) {
|
|
2682
2832
|
body["Name"] = request.name;
|
|
2683
2833
|
}
|
|
2684
2834
|
const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
@@ -2695,7 +2845,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2695
2845
|
reqBodyType: "formData",
|
|
2696
2846
|
bodyType: "json"
|
|
2697
2847
|
});
|
|
2698
|
-
return $
|
|
2848
|
+
return $dara65.cast(
|
|
2699
2849
|
await this.callApi(params, req, runtime),
|
|
2700
2850
|
new GetContextResponse({})
|
|
2701
2851
|
);
|
|
@@ -2707,7 +2857,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2707
2857
|
* @returns GetContextResponse
|
|
2708
2858
|
*/
|
|
2709
2859
|
async getContext(request) {
|
|
2710
|
-
const runtime = new $
|
|
2860
|
+
const runtime = new $dara65.RuntimeOptions({});
|
|
2711
2861
|
return await this.getContextWithOptions(request, runtime);
|
|
2712
2862
|
}
|
|
2713
2863
|
/**
|
|
@@ -2720,19 +2870,19 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2720
2870
|
async getContextInfoWithOptions(request, runtime) {
|
|
2721
2871
|
request.validate();
|
|
2722
2872
|
const body = {};
|
|
2723
|
-
if (!$
|
|
2873
|
+
if (!$dara65.isNull(request.authorization)) {
|
|
2724
2874
|
body["Authorization"] = request.authorization;
|
|
2725
2875
|
}
|
|
2726
|
-
if (!$
|
|
2876
|
+
if (!$dara65.isNull(request.contextId)) {
|
|
2727
2877
|
body["ContextId"] = request.contextId;
|
|
2728
2878
|
}
|
|
2729
|
-
if (!$
|
|
2879
|
+
if (!$dara65.isNull(request.path)) {
|
|
2730
2880
|
body["Path"] = request.path;
|
|
2731
2881
|
}
|
|
2732
|
-
if (!$
|
|
2882
|
+
if (!$dara65.isNull(request.sessionId)) {
|
|
2733
2883
|
body["SessionId"] = request.sessionId;
|
|
2734
2884
|
}
|
|
2735
|
-
if (!$
|
|
2885
|
+
if (!$dara65.isNull(request.taskType)) {
|
|
2736
2886
|
body["TaskType"] = request.taskType;
|
|
2737
2887
|
}
|
|
2738
2888
|
const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
@@ -2749,7 +2899,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2749
2899
|
reqBodyType: "formData",
|
|
2750
2900
|
bodyType: "json"
|
|
2751
2901
|
});
|
|
2752
|
-
return $
|
|
2902
|
+
return $dara65.cast(
|
|
2753
2903
|
await this.callApi(params, req, runtime),
|
|
2754
2904
|
new GetContextInfoResponse({})
|
|
2755
2905
|
);
|
|
@@ -2761,7 +2911,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2761
2911
|
* @returns GetContextInfoResponse
|
|
2762
2912
|
*/
|
|
2763
2913
|
async getContextInfo(request) {
|
|
2764
|
-
const runtime = new $
|
|
2914
|
+
const runtime = new $dara65.RuntimeOptions({});
|
|
2765
2915
|
return await this.getContextInfoWithOptions(request, runtime);
|
|
2766
2916
|
}
|
|
2767
2917
|
/**
|
|
@@ -2774,16 +2924,16 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2774
2924
|
async getLabelWithOptions(request, runtime) {
|
|
2775
2925
|
request.validate();
|
|
2776
2926
|
const body = {};
|
|
2777
|
-
if (!$
|
|
2927
|
+
if (!$dara65.isNull(request.authorization)) {
|
|
2778
2928
|
body["Authorization"] = request.authorization;
|
|
2779
2929
|
}
|
|
2780
|
-
if (!$
|
|
2930
|
+
if (!$dara65.isNull(request.maxResults)) {
|
|
2781
2931
|
body["MaxResults"] = request.maxResults;
|
|
2782
2932
|
}
|
|
2783
|
-
if (!$
|
|
2933
|
+
if (!$dara65.isNull(request.nextToken)) {
|
|
2784
2934
|
body["NextToken"] = request.nextToken;
|
|
2785
2935
|
}
|
|
2786
|
-
if (!$
|
|
2936
|
+
if (!$dara65.isNull(request.sessionId)) {
|
|
2787
2937
|
body["SessionId"] = request.sessionId;
|
|
2788
2938
|
}
|
|
2789
2939
|
const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
@@ -2800,7 +2950,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2800
2950
|
reqBodyType: "formData",
|
|
2801
2951
|
bodyType: "json"
|
|
2802
2952
|
});
|
|
2803
|
-
return $
|
|
2953
|
+
return $dara65.cast(
|
|
2804
2954
|
await this.callApi(params, req, runtime),
|
|
2805
2955
|
new GetLabelResponse({})
|
|
2806
2956
|
);
|
|
@@ -2812,7 +2962,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2812
2962
|
* @returns GetLabelResponse
|
|
2813
2963
|
*/
|
|
2814
2964
|
async getLabel(request) {
|
|
2815
|
-
const runtime = new $
|
|
2965
|
+
const runtime = new $dara65.RuntimeOptions({});
|
|
2816
2966
|
return await this.getLabelWithOptions(request, runtime);
|
|
2817
2967
|
}
|
|
2818
2968
|
/**
|
|
@@ -2825,16 +2975,16 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2825
2975
|
async getLinkWithOptions(request, runtime) {
|
|
2826
2976
|
request.validate();
|
|
2827
2977
|
const body = {};
|
|
2828
|
-
if (!$
|
|
2978
|
+
if (!$dara65.isNull(request.authorization)) {
|
|
2829
2979
|
body["Authorization"] = request.authorization;
|
|
2830
2980
|
}
|
|
2831
|
-
if (!$
|
|
2981
|
+
if (!$dara65.isNull(request.port)) {
|
|
2832
2982
|
body["Port"] = request.port;
|
|
2833
2983
|
}
|
|
2834
|
-
if (!$
|
|
2984
|
+
if (!$dara65.isNull(request.protocolType)) {
|
|
2835
2985
|
body["ProtocolType"] = request.protocolType;
|
|
2836
2986
|
}
|
|
2837
|
-
if (!$
|
|
2987
|
+
if (!$dara65.isNull(request.sessionId)) {
|
|
2838
2988
|
body["SessionId"] = request.sessionId;
|
|
2839
2989
|
}
|
|
2840
2990
|
const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
@@ -2851,7 +3001,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2851
3001
|
reqBodyType: "formData",
|
|
2852
3002
|
bodyType: "json"
|
|
2853
3003
|
});
|
|
2854
|
-
return $
|
|
3004
|
+
return $dara65.cast(
|
|
2855
3005
|
await this.callApi(params, req, runtime),
|
|
2856
3006
|
new GetLinkResponse({})
|
|
2857
3007
|
);
|
|
@@ -2863,7 +3013,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2863
3013
|
* @returns GetLinkResponse
|
|
2864
3014
|
*/
|
|
2865
3015
|
async getLink(request) {
|
|
2866
|
-
const runtime = new $
|
|
3016
|
+
const runtime = new $dara65.RuntimeOptions({});
|
|
2867
3017
|
return await this.getLinkWithOptions(request, runtime);
|
|
2868
3018
|
}
|
|
2869
3019
|
/**
|
|
@@ -2876,10 +3026,10 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2876
3026
|
async getMcpResourceWithOptions(request, runtime) {
|
|
2877
3027
|
request.validate();
|
|
2878
3028
|
const body = {};
|
|
2879
|
-
if (!$
|
|
3029
|
+
if (!$dara65.isNull(request.authorization)) {
|
|
2880
3030
|
body["Authorization"] = request.authorization;
|
|
2881
3031
|
}
|
|
2882
|
-
if (!$
|
|
3032
|
+
if (!$dara65.isNull(request.sessionId)) {
|
|
2883
3033
|
body["SessionId"] = request.sessionId;
|
|
2884
3034
|
}
|
|
2885
3035
|
const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
@@ -2896,7 +3046,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2896
3046
|
reqBodyType: "formData",
|
|
2897
3047
|
bodyType: "json"
|
|
2898
3048
|
});
|
|
2899
|
-
return $
|
|
3049
|
+
return $dara65.cast(
|
|
2900
3050
|
await this.callApi(params, req, runtime),
|
|
2901
3051
|
new GetMcpResourceResponse({})
|
|
2902
3052
|
);
|
|
@@ -2908,7 +3058,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2908
3058
|
* @returns GetMcpResourceResponse
|
|
2909
3059
|
*/
|
|
2910
3060
|
async getMcpResource(request) {
|
|
2911
|
-
const runtime = new $
|
|
3061
|
+
const runtime = new $dara65.RuntimeOptions({});
|
|
2912
3062
|
return await this.getMcpResourceWithOptions(request, runtime);
|
|
2913
3063
|
}
|
|
2914
3064
|
/**
|
|
@@ -2921,13 +3071,13 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2921
3071
|
async listContextsWithOptions(request, runtime) {
|
|
2922
3072
|
request.validate();
|
|
2923
3073
|
const body = {};
|
|
2924
|
-
if (!$
|
|
3074
|
+
if (!$dara65.isNull(request.authorization)) {
|
|
2925
3075
|
body["Authorization"] = request.authorization;
|
|
2926
3076
|
}
|
|
2927
|
-
if (!$
|
|
3077
|
+
if (!$dara65.isNull(request.maxResults)) {
|
|
2928
3078
|
body["MaxResults"] = request.maxResults;
|
|
2929
3079
|
}
|
|
2930
|
-
if (!$
|
|
3080
|
+
if (!$dara65.isNull(request.nextToken)) {
|
|
2931
3081
|
body["NextToken"] = request.nextToken;
|
|
2932
3082
|
}
|
|
2933
3083
|
const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
@@ -2944,7 +3094,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2944
3094
|
reqBodyType: "formData",
|
|
2945
3095
|
bodyType: "json"
|
|
2946
3096
|
});
|
|
2947
|
-
return $
|
|
3097
|
+
return $dara65.cast(
|
|
2948
3098
|
await this.callApi(params, req, runtime),
|
|
2949
3099
|
new ListContextsResponse({})
|
|
2950
3100
|
);
|
|
@@ -2956,7 +3106,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2956
3106
|
* @returns ListContextsResponse
|
|
2957
3107
|
*/
|
|
2958
3108
|
async listContexts(request) {
|
|
2959
|
-
const runtime = new $
|
|
3109
|
+
const runtime = new $dara65.RuntimeOptions({});
|
|
2960
3110
|
return await this.listContextsWithOptions(request, runtime);
|
|
2961
3111
|
}
|
|
2962
3112
|
/**
|
|
@@ -2969,10 +3119,10 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2969
3119
|
async listMcpToolsWithOptions(request, runtime) {
|
|
2970
3120
|
request.validate();
|
|
2971
3121
|
const body = {};
|
|
2972
|
-
if (!$
|
|
3122
|
+
if (!$dara65.isNull(request.authorization)) {
|
|
2973
3123
|
body["Authorization"] = request.authorization;
|
|
2974
3124
|
}
|
|
2975
|
-
if (!$
|
|
3125
|
+
if (!$dara65.isNull(request.imageId)) {
|
|
2976
3126
|
body["ImageId"] = request.imageId;
|
|
2977
3127
|
}
|
|
2978
3128
|
const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
@@ -2989,7 +3139,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
2989
3139
|
reqBodyType: "formData",
|
|
2990
3140
|
bodyType: "json"
|
|
2991
3141
|
});
|
|
2992
|
-
return $
|
|
3142
|
+
return $dara65.cast(
|
|
2993
3143
|
await this.callApi(params, req, runtime),
|
|
2994
3144
|
new ListMcpToolsResponse({})
|
|
2995
3145
|
);
|
|
@@ -3001,7 +3151,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
3001
3151
|
* @returns ListMcpToolsResponse
|
|
3002
3152
|
*/
|
|
3003
3153
|
async listMcpTools(request) {
|
|
3004
|
-
const runtime = new $
|
|
3154
|
+
const runtime = new $dara65.RuntimeOptions({});
|
|
3005
3155
|
return await this.listMcpToolsWithOptions(request, runtime);
|
|
3006
3156
|
}
|
|
3007
3157
|
/**
|
|
@@ -3014,16 +3164,16 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
3014
3164
|
async listSessionWithOptions(request, runtime) {
|
|
3015
3165
|
request.validate();
|
|
3016
3166
|
const body = {};
|
|
3017
|
-
if (!$
|
|
3167
|
+
if (!$dara65.isNull(request.authorization)) {
|
|
3018
3168
|
body["Authorization"] = request.authorization;
|
|
3019
3169
|
}
|
|
3020
|
-
if (!$
|
|
3170
|
+
if (!$dara65.isNull(request.labels)) {
|
|
3021
3171
|
body["Labels"] = request.labels;
|
|
3022
3172
|
}
|
|
3023
|
-
if (!$
|
|
3173
|
+
if (!$dara65.isNull(request.maxResults)) {
|
|
3024
3174
|
body["MaxResults"] = request.maxResults;
|
|
3025
3175
|
}
|
|
3026
|
-
if (!$
|
|
3176
|
+
if (!$dara65.isNull(request.nextToken)) {
|
|
3027
3177
|
body["NextToken"] = request.nextToken;
|
|
3028
3178
|
}
|
|
3029
3179
|
const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
@@ -3040,7 +3190,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
3040
3190
|
reqBodyType: "formData",
|
|
3041
3191
|
bodyType: "json"
|
|
3042
3192
|
});
|
|
3043
|
-
return $
|
|
3193
|
+
return $dara65.cast(
|
|
3044
3194
|
await this.callApi(params, req, runtime),
|
|
3045
3195
|
new ListSessionResponse({})
|
|
3046
3196
|
);
|
|
@@ -3052,7 +3202,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
3052
3202
|
* @returns ListSessionResponse
|
|
3053
3203
|
*/
|
|
3054
3204
|
async listSession(request) {
|
|
3055
|
-
const runtime = new $
|
|
3205
|
+
const runtime = new $dara65.RuntimeOptions({});
|
|
3056
3206
|
return await this.listSessionWithOptions(request, runtime);
|
|
3057
3207
|
}
|
|
3058
3208
|
/**
|
|
@@ -3065,13 +3215,13 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
3065
3215
|
async modifyContextWithOptions(request, runtime) {
|
|
3066
3216
|
request.validate();
|
|
3067
3217
|
const body = {};
|
|
3068
|
-
if (!$
|
|
3218
|
+
if (!$dara65.isNull(request.authorization)) {
|
|
3069
3219
|
body["Authorization"] = request.authorization;
|
|
3070
3220
|
}
|
|
3071
|
-
if (!$
|
|
3221
|
+
if (!$dara65.isNull(request.id)) {
|
|
3072
3222
|
body["Id"] = request.id;
|
|
3073
3223
|
}
|
|
3074
|
-
if (!$
|
|
3224
|
+
if (!$dara65.isNull(request.name)) {
|
|
3075
3225
|
body["Name"] = request.name;
|
|
3076
3226
|
}
|
|
3077
3227
|
const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
@@ -3088,7 +3238,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
3088
3238
|
reqBodyType: "formData",
|
|
3089
3239
|
bodyType: "json"
|
|
3090
3240
|
});
|
|
3091
|
-
return $
|
|
3241
|
+
return $dara65.cast(
|
|
3092
3242
|
await this.callApi(params, req, runtime),
|
|
3093
3243
|
new ModifyContextResponse({})
|
|
3094
3244
|
);
|
|
@@ -3100,7 +3250,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
3100
3250
|
* @returns ModifyContextResponse
|
|
3101
3251
|
*/
|
|
3102
3252
|
async modifyContext(request) {
|
|
3103
|
-
const runtime = new $
|
|
3253
|
+
const runtime = new $dara65.RuntimeOptions({});
|
|
3104
3254
|
return await this.modifyContextWithOptions(request, runtime);
|
|
3105
3255
|
}
|
|
3106
3256
|
/**
|
|
@@ -3113,10 +3263,10 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
3113
3263
|
async releaseMcpSessionWithOptions(request, runtime) {
|
|
3114
3264
|
request.validate();
|
|
3115
3265
|
const body = {};
|
|
3116
|
-
if (!$
|
|
3266
|
+
if (!$dara65.isNull(request.authorization)) {
|
|
3117
3267
|
body["Authorization"] = request.authorization;
|
|
3118
3268
|
}
|
|
3119
|
-
if (!$
|
|
3269
|
+
if (!$dara65.isNull(request.sessionId)) {
|
|
3120
3270
|
body["SessionId"] = request.sessionId;
|
|
3121
3271
|
}
|
|
3122
3272
|
const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
@@ -3133,7 +3283,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
3133
3283
|
reqBodyType: "formData",
|
|
3134
3284
|
bodyType: "json"
|
|
3135
3285
|
});
|
|
3136
|
-
return $
|
|
3286
|
+
return $dara65.cast(
|
|
3137
3287
|
await this.callApi(params, req, runtime),
|
|
3138
3288
|
new ReleaseMcpSessionResponse({})
|
|
3139
3289
|
);
|
|
@@ -3145,7 +3295,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
3145
3295
|
* @returns ReleaseMcpSessionResponse
|
|
3146
3296
|
*/
|
|
3147
3297
|
async releaseMcpSession(request) {
|
|
3148
|
-
const runtime = new $
|
|
3298
|
+
const runtime = new $dara65.RuntimeOptions({});
|
|
3149
3299
|
return await this.releaseMcpSessionWithOptions(request, runtime);
|
|
3150
3300
|
}
|
|
3151
3301
|
/**
|
|
@@ -3158,13 +3308,13 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
3158
3308
|
async setLabelWithOptions(request, runtime) {
|
|
3159
3309
|
request.validate();
|
|
3160
3310
|
const body = {};
|
|
3161
|
-
if (!$
|
|
3311
|
+
if (!$dara65.isNull(request.authorization)) {
|
|
3162
3312
|
body["Authorization"] = request.authorization;
|
|
3163
3313
|
}
|
|
3164
|
-
if (!$
|
|
3314
|
+
if (!$dara65.isNull(request.labels)) {
|
|
3165
3315
|
body["Labels"] = request.labels;
|
|
3166
3316
|
}
|
|
3167
|
-
if (!$
|
|
3317
|
+
if (!$dara65.isNull(request.sessionId)) {
|
|
3168
3318
|
body["SessionId"] = request.sessionId;
|
|
3169
3319
|
}
|
|
3170
3320
|
const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
@@ -3181,7 +3331,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
3181
3331
|
reqBodyType: "formData",
|
|
3182
3332
|
bodyType: "json"
|
|
3183
3333
|
});
|
|
3184
|
-
return $
|
|
3334
|
+
return $dara65.cast(
|
|
3185
3335
|
await this.callApi(params, req, runtime),
|
|
3186
3336
|
new SetLabelResponse({})
|
|
3187
3337
|
);
|
|
@@ -3193,7 +3343,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
3193
3343
|
* @returns SetLabelResponse
|
|
3194
3344
|
*/
|
|
3195
3345
|
async setLabel(request) {
|
|
3196
|
-
const runtime = new $
|
|
3346
|
+
const runtime = new $dara65.RuntimeOptions({});
|
|
3197
3347
|
return await this.setLabelWithOptions(request, runtime);
|
|
3198
3348
|
}
|
|
3199
3349
|
/**
|
|
@@ -3206,20 +3356,20 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
3206
3356
|
async syncContextWithOptions(request, runtime) {
|
|
3207
3357
|
request.validate();
|
|
3208
3358
|
const query = {};
|
|
3209
|
-
if (!$
|
|
3359
|
+
if (!$dara65.isNull(request.authorization)) {
|
|
3210
3360
|
query["Authorization"] = request.authorization;
|
|
3211
3361
|
}
|
|
3212
3362
|
const body = {};
|
|
3213
|
-
if (!$
|
|
3363
|
+
if (!$dara65.isNull(request.contextId)) {
|
|
3214
3364
|
body["ContextId"] = request.contextId;
|
|
3215
3365
|
}
|
|
3216
|
-
if (!$
|
|
3366
|
+
if (!$dara65.isNull(request.mode)) {
|
|
3217
3367
|
body["Mode"] = request.mode;
|
|
3218
3368
|
}
|
|
3219
|
-
if (!$
|
|
3369
|
+
if (!$dara65.isNull(request.path)) {
|
|
3220
3370
|
body["Path"] = request.path;
|
|
3221
3371
|
}
|
|
3222
|
-
if (!$
|
|
3372
|
+
if (!$dara65.isNull(request.sessionId)) {
|
|
3223
3373
|
body["SessionId"] = request.sessionId;
|
|
3224
3374
|
}
|
|
3225
3375
|
const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
@@ -3237,7 +3387,7 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
3237
3387
|
reqBodyType: "formData",
|
|
3238
3388
|
bodyType: "json"
|
|
3239
3389
|
});
|
|
3240
|
-
return $
|
|
3390
|
+
return $dara65.cast(
|
|
3241
3391
|
await this.callApi(params, req, runtime),
|
|
3242
3392
|
new SyncContextResponse({})
|
|
3243
3393
|
);
|
|
@@ -3249,9 +3399,95 @@ var _Client = class _Client extends _openapicore2.default {
|
|
|
3249
3399
|
* @returns SyncContextResponse
|
|
3250
3400
|
*/
|
|
3251
3401
|
async syncContext(request) {
|
|
3252
|
-
const runtime = new $
|
|
3402
|
+
const runtime = new $dara65.RuntimeOptions({});
|
|
3253
3403
|
return await this.syncContextWithOptions(request, runtime);
|
|
3254
3404
|
}
|
|
3405
|
+
/**
|
|
3406
|
+
* 初始化浏览器
|
|
3407
|
+
*
|
|
3408
|
+
* @param tmpReq - InitBrowserRequest
|
|
3409
|
+
* @param runtime - runtime options for this request RuntimeOptions
|
|
3410
|
+
* @returns InitBrowserResponse
|
|
3411
|
+
*/
|
|
3412
|
+
async initBrowserWithOptions(request, runtime) {
|
|
3413
|
+
request.validate();
|
|
3414
|
+
const body = {};
|
|
3415
|
+
if (!$dara65.isNull(request.authorization)) {
|
|
3416
|
+
body["Authorization"] = request.authorization;
|
|
3417
|
+
}
|
|
3418
|
+
if (!$dara65.isNull(request.persistentPath)) {
|
|
3419
|
+
body["PersistentPath"] = request.persistentPath;
|
|
3420
|
+
}
|
|
3421
|
+
if (!$dara65.isNull(request.sessionId)) {
|
|
3422
|
+
body["SessionId"] = request.sessionId;
|
|
3423
|
+
}
|
|
3424
|
+
const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
3425
|
+
body: _openapicore.OpenApiUtil.parseToMap(body)
|
|
3426
|
+
});
|
|
3427
|
+
const params = new _openapicore.$OpenApiUtil.Params({
|
|
3428
|
+
action: "InitBrowser",
|
|
3429
|
+
version: "2025-05-06",
|
|
3430
|
+
protocol: "HTTPS",
|
|
3431
|
+
pathname: "/",
|
|
3432
|
+
method: "POST",
|
|
3433
|
+
authType: "Anonymous",
|
|
3434
|
+
style: "RPC",
|
|
3435
|
+
reqBodyType: "formData",
|
|
3436
|
+
bodyType: "json"
|
|
3437
|
+
});
|
|
3438
|
+
return $dara65.cast(
|
|
3439
|
+
await this.callApi(params, req, runtime),
|
|
3440
|
+
new InitBrowserResponse({})
|
|
3441
|
+
);
|
|
3442
|
+
}
|
|
3443
|
+
/**
|
|
3444
|
+
* 初始化浏览器
|
|
3445
|
+
*
|
|
3446
|
+
* @param request - InitBrowserRequest
|
|
3447
|
+
* @returns InitBrowserResponse
|
|
3448
|
+
*/
|
|
3449
|
+
async initBrowser(request) {
|
|
3450
|
+
const runtime = new $dara65.RuntimeOptions({});
|
|
3451
|
+
return await this.initBrowserWithOptions(request, runtime);
|
|
3452
|
+
}
|
|
3453
|
+
/**
|
|
3454
|
+
* 初始化浏览器(同步版本)
|
|
3455
|
+
*
|
|
3456
|
+
* @param request - InitBrowserRequest
|
|
3457
|
+
* @returns InitBrowserResponse
|
|
3458
|
+
*/
|
|
3459
|
+
initBrowserSync(request) {
|
|
3460
|
+
const runtime = new $dara65.RuntimeOptions({});
|
|
3461
|
+
request.validate();
|
|
3462
|
+
const body = {};
|
|
3463
|
+
if (!$dara65.isNull(request.authorization)) {
|
|
3464
|
+
body["Authorization"] = request.authorization;
|
|
3465
|
+
}
|
|
3466
|
+
if (!$dara65.isNull(request.persistentPath)) {
|
|
3467
|
+
body["PersistentPath"] = request.persistentPath;
|
|
3468
|
+
}
|
|
3469
|
+
if (!$dara65.isNull(request.sessionId)) {
|
|
3470
|
+
body["SessionId"] = request.sessionId;
|
|
3471
|
+
}
|
|
3472
|
+
const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
3473
|
+
body: _openapicore.OpenApiUtil.parseToMap(body)
|
|
3474
|
+
});
|
|
3475
|
+
const params = new _openapicore.$OpenApiUtil.Params({
|
|
3476
|
+
action: "InitBrowser",
|
|
3477
|
+
version: "2025-05-06",
|
|
3478
|
+
protocol: "HTTPS",
|
|
3479
|
+
pathname: "/",
|
|
3480
|
+
method: "POST",
|
|
3481
|
+
authType: "Anonymous",
|
|
3482
|
+
style: "RPC",
|
|
3483
|
+
reqBodyType: "formData",
|
|
3484
|
+
bodyType: "json"
|
|
3485
|
+
});
|
|
3486
|
+
return $dara65.cast(
|
|
3487
|
+
this.callApi(params, req, runtime),
|
|
3488
|
+
new InitBrowserResponse({})
|
|
3489
|
+
);
|
|
3490
|
+
}
|
|
3255
3491
|
};
|
|
3256
3492
|
__name(_Client, "Client");
|
|
3257
3493
|
var Client = _Client;
|
|
@@ -3294,6 +3530,7 @@ function logError(message, error) {
|
|
|
3294
3530
|
__name(logError, "logError");
|
|
3295
3531
|
|
|
3296
3532
|
// src/config.ts
|
|
3533
|
+
var BROWSER_DATA_PATH = "/tmp/agentbay_browser";
|
|
3297
3534
|
function defaultConfig() {
|
|
3298
3535
|
return {
|
|
3299
3536
|
region_id: "cn-shanghai",
|
|
@@ -3393,22 +3630,26 @@ var _ContextService = class _ContextService {
|
|
|
3393
3630
|
this.agentBay = agentBay;
|
|
3394
3631
|
}
|
|
3395
3632
|
/**
|
|
3396
|
-
* Lists all available contexts.
|
|
3633
|
+
* Lists all available contexts with pagination support.
|
|
3397
3634
|
* Corresponds to Python's list() method
|
|
3398
3635
|
*
|
|
3399
|
-
* @
|
|
3636
|
+
* @param params - Optional parameters for listing contexts.
|
|
3637
|
+
* @returns ContextListResult with contexts list and pagination information
|
|
3400
3638
|
*/
|
|
3401
|
-
async list() {
|
|
3639
|
+
async list(params) {
|
|
3402
3640
|
try {
|
|
3641
|
+
const maxResults = _optionalChain([params, 'optionalAccess', _ => _.maxResults]) !== void 0 ? params.maxResults : 10;
|
|
3403
3642
|
const request = new ListContextsRequest({
|
|
3404
|
-
authorization: `Bearer ${this.agentBay.getAPIKey()}
|
|
3643
|
+
authorization: `Bearer ${this.agentBay.getAPIKey()}`,
|
|
3644
|
+
maxResults,
|
|
3645
|
+
nextToken: _optionalChain([params, 'optionalAccess', _2 => _2.nextToken])
|
|
3405
3646
|
});
|
|
3406
3647
|
log("API Call: ListContexts");
|
|
3407
|
-
log(
|
|
3648
|
+
log(`Request: MaxResults=${maxResults}`, _optionalChain([params, 'optionalAccess', _3 => _3.nextToken]) ? `, NextToken=${params.nextToken}` : "");
|
|
3408
3649
|
const response = await this.agentBay.getClient().listContexts(request);
|
|
3409
3650
|
log(`Response from ListContexts:`, response.body);
|
|
3410
3651
|
const contexts = [];
|
|
3411
|
-
if (_optionalChain([response, 'access',
|
|
3652
|
+
if (_optionalChain([response, 'access', _4 => _4.body, 'optionalAccess', _5 => _5.data])) {
|
|
3412
3653
|
for (const contextData of response.body.data) {
|
|
3413
3654
|
contexts.push(
|
|
3414
3655
|
new Context(
|
|
@@ -3425,7 +3666,10 @@ var _ContextService = class _ContextService {
|
|
|
3425
3666
|
return {
|
|
3426
3667
|
requestId: extractRequestId(response) || "",
|
|
3427
3668
|
success: true,
|
|
3428
|
-
contexts
|
|
3669
|
+
contexts,
|
|
3670
|
+
nextToken: _optionalChain([response, 'access', _6 => _6.body, 'optionalAccess', _7 => _7.nextToken]),
|
|
3671
|
+
maxResults: _optionalChain([response, 'access', _8 => _8.body, 'optionalAccess', _9 => _9.maxResults]) || maxResults,
|
|
3672
|
+
totalCount: _optionalChain([response, 'access', _10 => _10.body, 'optionalAccess', _11 => _11.totalCount])
|
|
3429
3673
|
};
|
|
3430
3674
|
} catch (error) {
|
|
3431
3675
|
logError("Error calling ListContexts:", error);
|
|
@@ -3455,7 +3699,7 @@ var _ContextService = class _ContextService {
|
|
|
3455
3699
|
log(`Request: Name=${name}, AllowCreate=${create}`);
|
|
3456
3700
|
const response = await this.agentBay.getClient().getContext(request);
|
|
3457
3701
|
log(`Response from GetContext:`, response.body);
|
|
3458
|
-
const contextId = _optionalChain([response, 'access',
|
|
3702
|
+
const contextId = _optionalChain([response, 'access', _12 => _12.body, 'optionalAccess', _13 => _13.data, 'optionalAccess', _14 => _14.id]) || "";
|
|
3459
3703
|
if (!contextId) {
|
|
3460
3704
|
return {
|
|
3461
3705
|
requestId: extractRequestId(response) || "",
|
|
@@ -3520,8 +3764,8 @@ var _ContextService = class _ContextService {
|
|
|
3520
3764
|
log(`Request: Id=${context.id}, Name=${context.name}`);
|
|
3521
3765
|
const response = await this.agentBay.getClient().modifyContext(request);
|
|
3522
3766
|
log(`Response from ModifyContext:`, response.body);
|
|
3523
|
-
const success = _optionalChain([response, 'access',
|
|
3524
|
-
const errorMessage = success ? "" : `Update failed: ${_optionalChain([response, 'access',
|
|
3767
|
+
const success = _optionalChain([response, 'access', _15 => _15.body, 'optionalAccess', _16 => _16.success]) !== false;
|
|
3768
|
+
const errorMessage = success ? "" : `Update failed: ${_optionalChain([response, 'access', _17 => _17.body, 'optionalAccess', _18 => _18.code])}`;
|
|
3525
3769
|
return {
|
|
3526
3770
|
requestId: extractRequestId(response) || "",
|
|
3527
3771
|
success,
|
|
@@ -3554,8 +3798,8 @@ var _ContextService = class _ContextService {
|
|
|
3554
3798
|
log(`Request: Id=${context.id}`);
|
|
3555
3799
|
const response = await this.agentBay.getClient().deleteContext(request);
|
|
3556
3800
|
log(`Response from DeleteContext:`, response.body);
|
|
3557
|
-
const success = _optionalChain([response, 'access',
|
|
3558
|
-
const errorMessage = success ? "" : `Delete failed: ${_optionalChain([response, 'access',
|
|
3801
|
+
const success = _optionalChain([response, 'access', _19 => _19.body, 'optionalAccess', _20 => _20.success]) !== false;
|
|
3802
|
+
const errorMessage = success ? "" : `Delete failed: ${_optionalChain([response, 'access', _21 => _21.body, 'optionalAccess', _22 => _22.code])}`;
|
|
3559
3803
|
return {
|
|
3560
3804
|
requestId: extractRequestId(response) || "",
|
|
3561
3805
|
success,
|
|
@@ -3661,167 +3905,365 @@ var _UIError = class _UIError extends AgentBayError {
|
|
|
3661
3905
|
};
|
|
3662
3906
|
__name(_UIError, "UIError");
|
|
3663
3907
|
var UIError = _UIError;
|
|
3908
|
+
var _BrowserError = class _BrowserError extends AgentBayError {
|
|
3909
|
+
constructor(message = "Browser operation error", extra = {}) {
|
|
3910
|
+
super(message, extra);
|
|
3911
|
+
this.name = "BrowserError";
|
|
3912
|
+
Object.setPrototypeOf(this, _BrowserError.prototype);
|
|
3913
|
+
}
|
|
3914
|
+
};
|
|
3915
|
+
__name(_BrowserError, "BrowserError");
|
|
3916
|
+
var BrowserError = _BrowserError;
|
|
3664
3917
|
|
|
3665
3918
|
// src/session.ts
|
|
3666
3919
|
init_cjs_shims();
|
|
3667
3920
|
|
|
3668
|
-
// src/
|
|
3921
|
+
// src/agent/agent.ts
|
|
3669
3922
|
init_cjs_shims();
|
|
3670
|
-
var
|
|
3923
|
+
var _Agent = class _Agent {
|
|
3671
3924
|
/**
|
|
3672
|
-
*
|
|
3673
|
-
*
|
|
3925
|
+
* Initialize an Agent object.
|
|
3926
|
+
*
|
|
3927
|
+
* @param session - The Session instance that this Agent belongs to.
|
|
3674
3928
|
*/
|
|
3675
3929
|
constructor(session) {
|
|
3676
3930
|
this.session = session;
|
|
3677
3931
|
}
|
|
3678
3932
|
/**
|
|
3679
|
-
*
|
|
3933
|
+
* Execute a specific task described in human language.
|
|
3680
3934
|
*
|
|
3681
|
-
* @param
|
|
3682
|
-
* @param
|
|
3683
|
-
* @
|
|
3684
|
-
* @returns A CallMcpToolResult with the response data
|
|
3685
|
-
* @throws APIError if the call fails
|
|
3935
|
+
* @param task - Task description in human language.
|
|
3936
|
+
* @param maxTryTimes - Maximum number of retry attempts.
|
|
3937
|
+
* @returns ExecutionResult containing success status, task output, and error message if any.
|
|
3686
3938
|
*/
|
|
3687
|
-
async
|
|
3939
|
+
async executeTask(task, maxTryTimes) {
|
|
3688
3940
|
try {
|
|
3689
|
-
const
|
|
3690
|
-
const
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
if (
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3941
|
+
const args = { task };
|
|
3942
|
+
const result = await this.session.callMcpTool("flux_execute_task", args);
|
|
3943
|
+
if (!result.success) {
|
|
3944
|
+
return {
|
|
3945
|
+
requestId: result.requestId,
|
|
3946
|
+
success: false,
|
|
3947
|
+
errorMessage: result.errorMessage,
|
|
3948
|
+
taskStatus: "failed",
|
|
3949
|
+
taskId: ""
|
|
3950
|
+
};
|
|
3951
|
+
}
|
|
3952
|
+
let content;
|
|
3953
|
+
try {
|
|
3954
|
+
content = JSON.parse(result.data);
|
|
3955
|
+
} catch (err) {
|
|
3956
|
+
return {
|
|
3957
|
+
requestId: result.requestId,
|
|
3958
|
+
success: false,
|
|
3959
|
+
errorMessage: `Failed to parse response: ${err}`,
|
|
3960
|
+
taskStatus: "failed",
|
|
3961
|
+
taskId: ""
|
|
3962
|
+
};
|
|
3963
|
+
}
|
|
3964
|
+
const taskId = content.task_id;
|
|
3965
|
+
if (!taskId) {
|
|
3966
|
+
return {
|
|
3967
|
+
requestId: result.requestId,
|
|
3968
|
+
success: false,
|
|
3969
|
+
errorMessage: "Task ID not found in response",
|
|
3970
|
+
taskStatus: "failed",
|
|
3971
|
+
taskId: ""
|
|
3972
|
+
};
|
|
3973
|
+
}
|
|
3974
|
+
let triedTime = 0;
|
|
3975
|
+
while (triedTime < maxTryTimes) {
|
|
3976
|
+
const query = await this.getTaskStatus(taskId);
|
|
3977
|
+
if (!query.success) {
|
|
3978
|
+
return {
|
|
3979
|
+
requestId: result.requestId,
|
|
3980
|
+
success: false,
|
|
3981
|
+
errorMessage: query.errorMessage,
|
|
3982
|
+
taskStatus: "failed",
|
|
3983
|
+
taskId
|
|
3984
|
+
};
|
|
3722
3985
|
}
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
}
|
|
3734
|
-
|
|
3986
|
+
let statusContent;
|
|
3987
|
+
try {
|
|
3988
|
+
statusContent = JSON.parse(query.output);
|
|
3989
|
+
} catch (err) {
|
|
3990
|
+
return {
|
|
3991
|
+
requestId: result.requestId,
|
|
3992
|
+
success: false,
|
|
3993
|
+
errorMessage: `Failed to parse status response: ${err}`,
|
|
3994
|
+
taskStatus: "failed",
|
|
3995
|
+
taskId
|
|
3996
|
+
};
|
|
3997
|
+
}
|
|
3998
|
+
const taskStatus = statusContent.status;
|
|
3999
|
+
if (!taskStatus) {
|
|
4000
|
+
return {
|
|
4001
|
+
requestId: result.requestId,
|
|
4002
|
+
success: false,
|
|
4003
|
+
errorMessage: "Task status not found in response",
|
|
4004
|
+
taskStatus: "failed",
|
|
4005
|
+
taskId
|
|
4006
|
+
};
|
|
3735
4007
|
}
|
|
4008
|
+
switch (taskStatus) {
|
|
4009
|
+
case "finished":
|
|
4010
|
+
return {
|
|
4011
|
+
requestId: result.requestId,
|
|
4012
|
+
success: true,
|
|
4013
|
+
errorMessage: "",
|
|
4014
|
+
taskId,
|
|
4015
|
+
taskStatus
|
|
4016
|
+
};
|
|
4017
|
+
case "failed":
|
|
4018
|
+
return {
|
|
4019
|
+
requestId: result.requestId,
|
|
4020
|
+
success: false,
|
|
4021
|
+
errorMessage: "Failed to execute task.",
|
|
4022
|
+
taskId,
|
|
4023
|
+
taskStatus
|
|
4024
|
+
};
|
|
4025
|
+
case "unsupported":
|
|
4026
|
+
return {
|
|
4027
|
+
requestId: result.requestId,
|
|
4028
|
+
success: false,
|
|
4029
|
+
errorMessage: "Unsupported task.",
|
|
4030
|
+
taskId,
|
|
4031
|
+
taskStatus
|
|
4032
|
+
};
|
|
4033
|
+
}
|
|
4034
|
+
log(`Task ${taskId} is still running, please wait for a while.`);
|
|
4035
|
+
await new Promise((resolve2) => setTimeout(resolve2, 3e3));
|
|
4036
|
+
triedTime++;
|
|
3736
4037
|
}
|
|
3737
|
-
return
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
* Helper method to parse JSON string into objects
|
|
3745
|
-
*/
|
|
3746
|
-
parseJSON(jsonString) {
|
|
3747
|
-
try {
|
|
3748
|
-
return JSON.parse(jsonString);
|
|
4038
|
+
return {
|
|
4039
|
+
requestId: result.requestId,
|
|
4040
|
+
success: false,
|
|
4041
|
+
errorMessage: "Task execution timed out",
|
|
4042
|
+
taskStatus: "timeout",
|
|
4043
|
+
taskId
|
|
4044
|
+
};
|
|
3749
4045
|
} catch (error) {
|
|
3750
|
-
|
|
4046
|
+
return {
|
|
4047
|
+
requestId: "",
|
|
4048
|
+
success: false,
|
|
4049
|
+
errorMessage: `Failed to execute: ${error}`,
|
|
4050
|
+
taskStatus: "failed",
|
|
4051
|
+
taskId: ""
|
|
4052
|
+
};
|
|
3751
4053
|
}
|
|
3752
4054
|
}
|
|
3753
4055
|
/**
|
|
3754
|
-
*
|
|
3755
|
-
* Corresponds to Python's get_installed_apps() method
|
|
4056
|
+
* Get the status of the task with the given task ID.
|
|
3756
4057
|
*
|
|
3757
|
-
* @param
|
|
3758
|
-
* @
|
|
3759
|
-
* @param ignoreSystemApps Whether to ignore system applications. Defaults to true.
|
|
3760
|
-
* @returns InstalledAppListResult with installed apps and requestId
|
|
3761
|
-
* @throws Error if the operation fails.
|
|
4058
|
+
* @param taskId - Task ID
|
|
4059
|
+
* @returns QueryResult containing the task status
|
|
3762
4060
|
*/
|
|
3763
|
-
async
|
|
4061
|
+
async getTaskStatus(taskId) {
|
|
3764
4062
|
try {
|
|
3765
|
-
const args = {
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
);
|
|
3775
|
-
let apps = [];
|
|
3776
|
-
if (result.textContent) {
|
|
3777
|
-
apps = this.parseJSON(result.textContent);
|
|
4063
|
+
const args = { task_id: taskId };
|
|
4064
|
+
const result = await this.session.callMcpTool("flux_get_task_status", args);
|
|
4065
|
+
if (!result.success) {
|
|
4066
|
+
return {
|
|
4067
|
+
requestId: result.requestId,
|
|
4068
|
+
success: false,
|
|
4069
|
+
errorMessage: result.errorMessage,
|
|
4070
|
+
output: ""
|
|
4071
|
+
};
|
|
3778
4072
|
}
|
|
3779
4073
|
return {
|
|
3780
|
-
requestId: result.requestId
|
|
4074
|
+
requestId: result.requestId,
|
|
3781
4075
|
success: true,
|
|
3782
|
-
|
|
4076
|
+
output: result.data,
|
|
4077
|
+
errorMessage: ""
|
|
3783
4078
|
};
|
|
3784
4079
|
} catch (error) {
|
|
3785
4080
|
return {
|
|
3786
4081
|
requestId: "",
|
|
3787
4082
|
success: false,
|
|
3788
|
-
|
|
3789
|
-
|
|
4083
|
+
errorMessage: `Failed to get task status: ${error}`,
|
|
4084
|
+
output: ""
|
|
3790
4085
|
};
|
|
3791
4086
|
}
|
|
3792
4087
|
}
|
|
3793
4088
|
/**
|
|
3794
|
-
*
|
|
3795
|
-
* Corresponds to Python's start_app() method
|
|
4089
|
+
* Terminate a task with a specified task ID.
|
|
3796
4090
|
*
|
|
3797
|
-
* @param
|
|
3798
|
-
* @
|
|
3799
|
-
* @param activity Activity name to launch (e.g. ".SettingsActivity" or "com.package/.Activity"). Defaults to an empty string.
|
|
3800
|
-
* @returns ProcessListResult with started processes and requestId
|
|
3801
|
-
* @throws Error if the operation fails.
|
|
4091
|
+
* @param taskId - The ID of the running task.
|
|
4092
|
+
* @returns ExecutionResult containing success status, task output, and error message if any.
|
|
3802
4093
|
*/
|
|
3803
|
-
async
|
|
4094
|
+
async terminateTask(taskId) {
|
|
4095
|
+
log("Terminating task");
|
|
3804
4096
|
try {
|
|
3805
|
-
const args = {
|
|
3806
|
-
|
|
4097
|
+
const args = { task_id: taskId };
|
|
4098
|
+
const result = await this.session.callMcpTool("flux_terminate_task", args);
|
|
4099
|
+
let content;
|
|
4100
|
+
try {
|
|
4101
|
+
content = JSON.parse(result.data);
|
|
4102
|
+
} catch (err) {
|
|
4103
|
+
return {
|
|
4104
|
+
requestId: result.requestId,
|
|
4105
|
+
success: false,
|
|
4106
|
+
errorMessage: `Failed to parse response: ${err}`,
|
|
4107
|
+
taskId,
|
|
4108
|
+
taskStatus: "failed"
|
|
4109
|
+
};
|
|
4110
|
+
}
|
|
4111
|
+
const terminatedTaskId = content.task_id || taskId;
|
|
4112
|
+
const status = content.status || "unknown";
|
|
4113
|
+
if (result.success) {
|
|
4114
|
+
return {
|
|
4115
|
+
requestId: result.requestId,
|
|
4116
|
+
success: true,
|
|
4117
|
+
errorMessage: "",
|
|
4118
|
+
taskId: terminatedTaskId,
|
|
4119
|
+
taskStatus: status
|
|
4120
|
+
};
|
|
4121
|
+
}
|
|
4122
|
+
return {
|
|
4123
|
+
requestId: result.requestId,
|
|
4124
|
+
success: false,
|
|
4125
|
+
errorMessage: result.errorMessage,
|
|
4126
|
+
taskId: terminatedTaskId,
|
|
4127
|
+
taskStatus: status
|
|
4128
|
+
};
|
|
4129
|
+
} catch (error) {
|
|
4130
|
+
return {
|
|
4131
|
+
requestId: "",
|
|
4132
|
+
success: false,
|
|
4133
|
+
errorMessage: `Failed to terminate: ${error}`,
|
|
4134
|
+
taskId,
|
|
4135
|
+
taskStatus: "failed"
|
|
4136
|
+
};
|
|
4137
|
+
}
|
|
4138
|
+
}
|
|
4139
|
+
};
|
|
4140
|
+
__name(_Agent, "Agent");
|
|
4141
|
+
var Agent = _Agent;
|
|
4142
|
+
|
|
4143
|
+
// src/application/application.ts
|
|
4144
|
+
init_cjs_shims();
|
|
4145
|
+
var _Application = class _Application {
|
|
4146
|
+
/**
|
|
4147
|
+
* Initialize an Application object.
|
|
4148
|
+
*
|
|
4149
|
+
* @param session - The Session instance that this Application belongs to.
|
|
4150
|
+
*/
|
|
4151
|
+
constructor(session) {
|
|
4152
|
+
this.session = session;
|
|
4153
|
+
}
|
|
4154
|
+
/**
|
|
4155
|
+
* Sanitizes error messages to remove sensitive information like API keys.
|
|
4156
|
+
*
|
|
4157
|
+
* @param error - The error to sanitize
|
|
4158
|
+
* @returns The sanitized error
|
|
4159
|
+
*/
|
|
4160
|
+
sanitizeError(error) {
|
|
4161
|
+
if (!error) {
|
|
4162
|
+
return error;
|
|
4163
|
+
}
|
|
4164
|
+
const errorString = String(error);
|
|
4165
|
+
return errorString.replace(/Bearer\s+[^\s]+/g, "Bearer [REDACTED]");
|
|
4166
|
+
}
|
|
4167
|
+
/**
|
|
4168
|
+
* Helper method to parse JSON string into objects
|
|
4169
|
+
*/
|
|
4170
|
+
parseJSON(jsonString) {
|
|
4171
|
+
try {
|
|
4172
|
+
return JSON.parse(jsonString);
|
|
4173
|
+
} catch (error) {
|
|
4174
|
+
throw new Error(`Failed to parse JSON: ${error}`);
|
|
4175
|
+
}
|
|
4176
|
+
}
|
|
4177
|
+
/**
|
|
4178
|
+
* Retrieves a list of installed applications.
|
|
4179
|
+
* Corresponds to Python's get_installed_apps() method
|
|
4180
|
+
*
|
|
4181
|
+
* @param startMenu - Whether to include applications from the start menu. Defaults to true.
|
|
4182
|
+
* @param desktop - Whether to include applications from the desktop. Defaults to true.
|
|
4183
|
+
* @param ignoreSystemApps - Whether to ignore system applications. Defaults to true.
|
|
4184
|
+
* @returns InstalledAppListResult with installed apps and requestId
|
|
4185
|
+
* @throws Error if the operation fails.
|
|
4186
|
+
*/
|
|
4187
|
+
async getInstalledApps(startMenu = true, desktop = true, ignoreSystemApps = true) {
|
|
4188
|
+
try {
|
|
4189
|
+
const args = {
|
|
4190
|
+
start_menu: startMenu,
|
|
4191
|
+
desktop,
|
|
4192
|
+
ignore_system_apps: ignoreSystemApps
|
|
3807
4193
|
};
|
|
3808
|
-
|
|
3809
|
-
|
|
4194
|
+
const result = await this.session.callMcpTool("get_installed_apps", args);
|
|
4195
|
+
if (!result.success) {
|
|
4196
|
+
return {
|
|
4197
|
+
requestId: result.requestId,
|
|
4198
|
+
success: false,
|
|
4199
|
+
data: [],
|
|
4200
|
+
errorMessage: result.errorMessage
|
|
4201
|
+
};
|
|
4202
|
+
}
|
|
4203
|
+
let apps = [];
|
|
4204
|
+
try {
|
|
4205
|
+
apps = this.parseJSON(result.data);
|
|
4206
|
+
} catch (err) {
|
|
4207
|
+
return {
|
|
4208
|
+
requestId: result.requestId,
|
|
4209
|
+
success: false,
|
|
4210
|
+
data: [],
|
|
4211
|
+
errorMessage: `Failed to parse installed apps: ${err}`
|
|
4212
|
+
};
|
|
3810
4213
|
}
|
|
3811
|
-
|
|
3812
|
-
|
|
4214
|
+
return {
|
|
4215
|
+
requestId: result.requestId,
|
|
4216
|
+
success: true,
|
|
4217
|
+
data: apps
|
|
4218
|
+
};
|
|
4219
|
+
} catch (error) {
|
|
4220
|
+
return {
|
|
4221
|
+
requestId: "",
|
|
4222
|
+
success: false,
|
|
4223
|
+
data: [],
|
|
4224
|
+
errorMessage: `Failed to get installed apps: ${error}`
|
|
4225
|
+
};
|
|
4226
|
+
}
|
|
4227
|
+
}
|
|
4228
|
+
/**
|
|
4229
|
+
* Starts an application with the given command and optional working directory.
|
|
4230
|
+
* Corresponds to Python's start_app() method
|
|
4231
|
+
*
|
|
4232
|
+
* @param startCmd - The command to start the application.
|
|
4233
|
+
* @param workDirectory - The working directory for the application. Defaults to an empty string.
|
|
4234
|
+
* @param activity - Activity name to launch (e.g. ".SettingsActivity" or "com.package/.Activity"). Defaults to an empty string.
|
|
4235
|
+
* @returns ProcessListResult with started processes and requestId
|
|
4236
|
+
* @throws Error if the operation fails.
|
|
4237
|
+
*/
|
|
4238
|
+
async startApp(startCmd, workDirectory = "", activity = "") {
|
|
4239
|
+
try {
|
|
4240
|
+
const args = {
|
|
4241
|
+
start_cmd: startCmd,
|
|
4242
|
+
work_directory: workDirectory,
|
|
4243
|
+
activity
|
|
4244
|
+
};
|
|
4245
|
+
const result = await this.session.callMcpTool("start_app", args);
|
|
4246
|
+
if (!result.success) {
|
|
4247
|
+
return {
|
|
4248
|
+
requestId: result.requestId,
|
|
4249
|
+
success: false,
|
|
4250
|
+
data: [],
|
|
4251
|
+
errorMessage: result.errorMessage
|
|
4252
|
+
};
|
|
3813
4253
|
}
|
|
3814
|
-
const result = await this.callMcpTool(
|
|
3815
|
-
"start_app",
|
|
3816
|
-
args,
|
|
3817
|
-
"Failed to start app"
|
|
3818
|
-
);
|
|
3819
4254
|
let processes = [];
|
|
3820
|
-
|
|
3821
|
-
processes = this.parseJSON(result.
|
|
4255
|
+
try {
|
|
4256
|
+
processes = this.parseJSON(result.data);
|
|
4257
|
+
} catch (err) {
|
|
4258
|
+
return {
|
|
4259
|
+
requestId: result.requestId,
|
|
4260
|
+
success: false,
|
|
4261
|
+
data: [],
|
|
4262
|
+
errorMessage: `Failed to parse processes: ${err}`
|
|
4263
|
+
};
|
|
3822
4264
|
}
|
|
3823
4265
|
return {
|
|
3824
|
-
requestId: result.requestId
|
|
4266
|
+
requestId: result.requestId,
|
|
3825
4267
|
success: true,
|
|
3826
4268
|
data: processes
|
|
3827
4269
|
};
|
|
@@ -3838,29 +4280,30 @@ var _Application = class _Application {
|
|
|
3838
4280
|
* Stops an application by process name.
|
|
3839
4281
|
* Corresponds to Python's stop_app_by_pname() method
|
|
3840
4282
|
*
|
|
3841
|
-
* @param pname The name
|
|
3842
|
-
* @returns AppOperationResult with requestId
|
|
4283
|
+
* @param pname - The process name to stop.
|
|
4284
|
+
* @returns AppOperationResult with operation result and requestId
|
|
3843
4285
|
* @throws Error if the operation fails.
|
|
3844
4286
|
*/
|
|
3845
4287
|
async stopAppByPName(pname) {
|
|
3846
4288
|
try {
|
|
3847
|
-
const args = {
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
4289
|
+
const args = { pname };
|
|
4290
|
+
const result = await this.session.callMcpTool("stop_app_by_pname", args);
|
|
4291
|
+
if (!result.success) {
|
|
4292
|
+
return {
|
|
4293
|
+
requestId: result.requestId,
|
|
4294
|
+
success: false,
|
|
4295
|
+
errorMessage: result.errorMessage
|
|
4296
|
+
};
|
|
4297
|
+
}
|
|
3855
4298
|
return {
|
|
3856
|
-
requestId: result.requestId
|
|
4299
|
+
requestId: result.requestId,
|
|
3857
4300
|
success: true
|
|
3858
4301
|
};
|
|
3859
4302
|
} catch (error) {
|
|
3860
4303
|
return {
|
|
3861
4304
|
requestId: "",
|
|
3862
4305
|
success: false,
|
|
3863
|
-
errorMessage: `Failed to stop app by
|
|
4306
|
+
errorMessage: `Failed to stop app by process name: ${error}`
|
|
3864
4307
|
};
|
|
3865
4308
|
}
|
|
3866
4309
|
}
|
|
@@ -3868,29 +4311,30 @@ var _Application = class _Application {
|
|
|
3868
4311
|
* Stops an application by process ID.
|
|
3869
4312
|
* Corresponds to Python's stop_app_by_pid() method
|
|
3870
4313
|
*
|
|
3871
|
-
* @param pid The ID
|
|
3872
|
-
* @returns AppOperationResult with requestId
|
|
4314
|
+
* @param pid - The process ID to stop.
|
|
4315
|
+
* @returns AppOperationResult with operation result and requestId
|
|
3873
4316
|
* @throws Error if the operation fails.
|
|
3874
4317
|
*/
|
|
3875
4318
|
async stopAppByPID(pid) {
|
|
3876
4319
|
try {
|
|
3877
|
-
const args = {
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
4320
|
+
const args = { pid };
|
|
4321
|
+
const result = await this.session.callMcpTool("stop_app_by_pid", args);
|
|
4322
|
+
if (!result.success) {
|
|
4323
|
+
return {
|
|
4324
|
+
requestId: result.requestId,
|
|
4325
|
+
success: false,
|
|
4326
|
+
errorMessage: result.errorMessage
|
|
4327
|
+
};
|
|
4328
|
+
}
|
|
3885
4329
|
return {
|
|
3886
|
-
requestId: result.requestId
|
|
4330
|
+
requestId: result.requestId,
|
|
3887
4331
|
success: true
|
|
3888
4332
|
};
|
|
3889
4333
|
} catch (error) {
|
|
3890
4334
|
return {
|
|
3891
4335
|
requestId: "",
|
|
3892
4336
|
success: false,
|
|
3893
|
-
errorMessage: `Failed to stop app by
|
|
4337
|
+
errorMessage: `Failed to stop app by process ID: ${error}`
|
|
3894
4338
|
};
|
|
3895
4339
|
}
|
|
3896
4340
|
}
|
|
@@ -3898,22 +4342,23 @@ var _Application = class _Application {
|
|
|
3898
4342
|
* Stops an application by stop command.
|
|
3899
4343
|
* Corresponds to Python's stop_app_by_cmd() method
|
|
3900
4344
|
*
|
|
3901
|
-
* @param stopCmd The command to
|
|
3902
|
-
* @returns AppOperationResult with requestId
|
|
4345
|
+
* @param stopCmd - The stop command to execute.
|
|
4346
|
+
* @returns AppOperationResult with operation result and requestId
|
|
3903
4347
|
* @throws Error if the operation fails.
|
|
3904
4348
|
*/
|
|
3905
4349
|
async stopAppByCmd(stopCmd) {
|
|
3906
4350
|
try {
|
|
3907
|
-
const args = {
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
4351
|
+
const args = { stop_cmd: stopCmd };
|
|
4352
|
+
const result = await this.session.callMcpTool("stop_app_by_cmd", args);
|
|
4353
|
+
if (!result.success) {
|
|
4354
|
+
return {
|
|
4355
|
+
requestId: result.requestId,
|
|
4356
|
+
success: false,
|
|
4357
|
+
errorMessage: result.errorMessage
|
|
4358
|
+
};
|
|
4359
|
+
}
|
|
3915
4360
|
return {
|
|
3916
|
-
requestId: result.requestId
|
|
4361
|
+
requestId: result.requestId,
|
|
3917
4362
|
success: true
|
|
3918
4363
|
};
|
|
3919
4364
|
} catch (error) {
|
|
@@ -3925,26 +4370,36 @@ var _Application = class _Application {
|
|
|
3925
4370
|
}
|
|
3926
4371
|
}
|
|
3927
4372
|
/**
|
|
3928
|
-
*
|
|
4373
|
+
* Returns a list of currently visible applications.
|
|
3929
4374
|
* Corresponds to Python's list_visible_apps() method
|
|
3930
4375
|
*
|
|
3931
|
-
* @returns ProcessListResult with visible
|
|
4376
|
+
* @returns ProcessListResult with visible apps and requestId
|
|
3932
4377
|
* @throws Error if the operation fails.
|
|
3933
4378
|
*/
|
|
3934
4379
|
async listVisibleApps() {
|
|
3935
4380
|
try {
|
|
3936
|
-
const
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
4381
|
+
const result = await this.session.callMcpTool("list_visible_apps", {});
|
|
4382
|
+
if (!result.success) {
|
|
4383
|
+
return {
|
|
4384
|
+
requestId: result.requestId,
|
|
4385
|
+
success: false,
|
|
4386
|
+
data: [],
|
|
4387
|
+
errorMessage: result.errorMessage
|
|
4388
|
+
};
|
|
4389
|
+
}
|
|
3942
4390
|
let processes = [];
|
|
3943
|
-
|
|
3944
|
-
processes = this.parseJSON(result.
|
|
4391
|
+
try {
|
|
4392
|
+
processes = this.parseJSON(result.data);
|
|
4393
|
+
} catch (err) {
|
|
4394
|
+
return {
|
|
4395
|
+
requestId: result.requestId,
|
|
4396
|
+
success: false,
|
|
4397
|
+
data: [],
|
|
4398
|
+
errorMessage: `Failed to parse visible apps: ${err}`
|
|
4399
|
+
};
|
|
3945
4400
|
}
|
|
3946
4401
|
return {
|
|
3947
|
-
requestId: result.requestId
|
|
4402
|
+
requestId: result.requestId,
|
|
3948
4403
|
success: true,
|
|
3949
4404
|
data: processes
|
|
3950
4405
|
};
|
|
@@ -3961,114 +4416,20 @@ var _Application = class _Application {
|
|
|
3961
4416
|
__name(_Application, "Application");
|
|
3962
4417
|
var Application = _Application;
|
|
3963
4418
|
|
|
3964
|
-
// src/
|
|
4419
|
+
// src/code/index.ts
|
|
3965
4420
|
init_cjs_shims();
|
|
3966
|
-
|
|
4421
|
+
|
|
4422
|
+
// src/code/code.ts
|
|
4423
|
+
init_cjs_shims();
|
|
4424
|
+
var _Code = class _Code {
|
|
3967
4425
|
/**
|
|
3968
|
-
* Initialize a
|
|
4426
|
+
* Initialize a Code object.
|
|
3969
4427
|
*
|
|
3970
|
-
* @param session - The Session instance that this
|
|
4428
|
+
* @param session - The Session instance that this Code belongs to.
|
|
3971
4429
|
*/
|
|
3972
4430
|
constructor(session) {
|
|
3973
4431
|
this.session = session;
|
|
3974
4432
|
}
|
|
3975
|
-
/**
|
|
3976
|
-
* Helper method to call MCP tools and handle common response processing
|
|
3977
|
-
*
|
|
3978
|
-
* @param toolName - Name of the MCP tool to call
|
|
3979
|
-
* @param args - Arguments to pass to the tool
|
|
3980
|
-
* @param defaultErrorMsg - Default error message if specific error details are not available
|
|
3981
|
-
* @returns A CallMcpToolResult with the response data
|
|
3982
|
-
* @throws APIError if the call fails
|
|
3983
|
-
*/
|
|
3984
|
-
async callMcpTool(toolName, args, defaultErrorMsg) {
|
|
3985
|
-
try {
|
|
3986
|
-
const argsJSON = JSON.stringify(args);
|
|
3987
|
-
const callToolRequest = new CallMcpToolRequest({
|
|
3988
|
-
authorization: `Bearer ${this.session.getAPIKey()}`,
|
|
3989
|
-
sessionId: this.session.getSessionId(),
|
|
3990
|
-
name: toolName,
|
|
3991
|
-
args: argsJSON
|
|
3992
|
-
});
|
|
3993
|
-
log(`API Call: CallMcpTool - ${toolName}`);
|
|
3994
|
-
log(
|
|
3995
|
-
`Request: SessionId=${this.session.getSessionId()}, Args=${argsJSON}`
|
|
3996
|
-
);
|
|
3997
|
-
const response = await this.session.getClient().callMcpTool(callToolRequest);
|
|
3998
|
-
log(`Response from CallMcpTool - ${toolName}:`, response.body);
|
|
3999
|
-
if (!_optionalChain([response, 'access', _18 => _18.body, 'optionalAccess', _19 => _19.data])) {
|
|
4000
|
-
throw new Error("Invalid response data format");
|
|
4001
|
-
}
|
|
4002
|
-
const data = response.body.data;
|
|
4003
|
-
const result = {
|
|
4004
|
-
data,
|
|
4005
|
-
statusCode: response.statusCode || 0,
|
|
4006
|
-
isError: false,
|
|
4007
|
-
requestId: extractRequestId(response)
|
|
4008
|
-
};
|
|
4009
|
-
if (data.isError === true) {
|
|
4010
|
-
result.isError = true;
|
|
4011
|
-
const contentArray = data.content;
|
|
4012
|
-
if (contentArray && contentArray.length > 0) {
|
|
4013
|
-
result.content = contentArray;
|
|
4014
|
-
if (_optionalChain([contentArray, 'access', _20 => _20[0], 'optionalAccess', _21 => _21.text])) {
|
|
4015
|
-
result.errorMsg = contentArray[0].text;
|
|
4016
|
-
throw new Error(contentArray[0].text);
|
|
4017
|
-
}
|
|
4018
|
-
}
|
|
4019
|
-
throw new Error(defaultErrorMsg);
|
|
4020
|
-
}
|
|
4021
|
-
if (Array.isArray(data.content)) {
|
|
4022
|
-
result.content = data.content;
|
|
4023
|
-
if (result.content.length > 0) {
|
|
4024
|
-
const textParts = [];
|
|
4025
|
-
for (const item of result.content) {
|
|
4026
|
-
if (item && typeof item === "object" && item.text && typeof item.text === "string") {
|
|
4027
|
-
textParts.push(item.text);
|
|
4028
|
-
}
|
|
4029
|
-
}
|
|
4030
|
-
result.textContent = textParts.join("\n");
|
|
4031
|
-
}
|
|
4032
|
-
}
|
|
4033
|
-
return result;
|
|
4034
|
-
} catch (error) {
|
|
4035
|
-
logError(`Error calling CallMcpTool - ${toolName}:`, error);
|
|
4036
|
-
throw new APIError(`Failed to call ${toolName}: ${error}`);
|
|
4037
|
-
}
|
|
4038
|
-
}
|
|
4039
|
-
/**
|
|
4040
|
-
* Execute a command in the cloud environment with a specified timeout.
|
|
4041
|
-
* Corresponds to Python's execute_command() method
|
|
4042
|
-
*
|
|
4043
|
-
* @param command - The command to execute.
|
|
4044
|
-
* @param timeoutMs - The timeout for the command execution in milliseconds. Default is 1000ms.
|
|
4045
|
-
* @returns CommandResult with command output and requestId
|
|
4046
|
-
*/
|
|
4047
|
-
async executeCommand(command, timeoutMs = 1e3) {
|
|
4048
|
-
try {
|
|
4049
|
-
const args = {
|
|
4050
|
-
command,
|
|
4051
|
-
timeout_ms: timeoutMs
|
|
4052
|
-
};
|
|
4053
|
-
const result = await this.callMcpTool(
|
|
4054
|
-
"shell",
|
|
4055
|
-
args,
|
|
4056
|
-
"Failed to execute command"
|
|
4057
|
-
);
|
|
4058
|
-
return {
|
|
4059
|
-
requestId: result.requestId || "",
|
|
4060
|
-
success: true,
|
|
4061
|
-
output: result.textContent || ""
|
|
4062
|
-
};
|
|
4063
|
-
} catch (error) {
|
|
4064
|
-
return {
|
|
4065
|
-
requestId: "",
|
|
4066
|
-
success: false,
|
|
4067
|
-
output: "",
|
|
4068
|
-
errorMessage: `Failed to execute command: ${error}`
|
|
4069
|
-
};
|
|
4070
|
-
}
|
|
4071
|
-
}
|
|
4072
4433
|
/**
|
|
4073
4434
|
* Execute code in the specified language with a timeout.
|
|
4074
4435
|
* Corresponds to Python's run_code() method
|
|
@@ -4094,15 +4455,22 @@ var _Command = class _Command {
|
|
|
4094
4455
|
language,
|
|
4095
4456
|
timeout_s: timeoutS
|
|
4096
4457
|
};
|
|
4097
|
-
const
|
|
4458
|
+
const response = await this.session.callMcpTool(
|
|
4098
4459
|
"run_code",
|
|
4099
|
-
args
|
|
4100
|
-
"Failed to execute code"
|
|
4460
|
+
args
|
|
4101
4461
|
);
|
|
4462
|
+
if (!response.success) {
|
|
4463
|
+
return {
|
|
4464
|
+
requestId: response.requestId,
|
|
4465
|
+
success: false,
|
|
4466
|
+
result: "",
|
|
4467
|
+
errorMessage: response.errorMessage
|
|
4468
|
+
};
|
|
4469
|
+
}
|
|
4102
4470
|
return {
|
|
4103
|
-
requestId:
|
|
4471
|
+
requestId: response.requestId,
|
|
4104
4472
|
success: true,
|
|
4105
|
-
result:
|
|
4473
|
+
result: response.data || ""
|
|
4106
4474
|
};
|
|
4107
4475
|
} catch (error) {
|
|
4108
4476
|
return {
|
|
@@ -4114,6 +4482,65 @@ var _Command = class _Command {
|
|
|
4114
4482
|
}
|
|
4115
4483
|
}
|
|
4116
4484
|
};
|
|
4485
|
+
__name(_Code, "Code");
|
|
4486
|
+
var Code = _Code;
|
|
4487
|
+
|
|
4488
|
+
// src/command/command.ts
|
|
4489
|
+
init_cjs_shims();
|
|
4490
|
+
var _Command = class _Command {
|
|
4491
|
+
/**
|
|
4492
|
+
* Initialize a Command object.
|
|
4493
|
+
*
|
|
4494
|
+
* @param session - The Session instance that this Command belongs to.
|
|
4495
|
+
*/
|
|
4496
|
+
constructor(session) {
|
|
4497
|
+
this.session = session;
|
|
4498
|
+
}
|
|
4499
|
+
/**
|
|
4500
|
+
* Sanitizes error messages to remove sensitive information like API keys.
|
|
4501
|
+
*
|
|
4502
|
+
* @param error - The error to sanitize
|
|
4503
|
+
* @returns The sanitized error
|
|
4504
|
+
*/
|
|
4505
|
+
sanitizeError(error) {
|
|
4506
|
+
if (!error) {
|
|
4507
|
+
return error;
|
|
4508
|
+
}
|
|
4509
|
+
const errorString = String(error);
|
|
4510
|
+
return errorString.replace(/Bearer\s+[^\s]+/g, "Bearer [REDACTED]");
|
|
4511
|
+
}
|
|
4512
|
+
/**
|
|
4513
|
+
* Execute a command in the session environment.
|
|
4514
|
+
* Corresponds to Python's execute_command() method
|
|
4515
|
+
*
|
|
4516
|
+
* @param command - The command to execute
|
|
4517
|
+
* @param timeoutMs - The timeout in milliseconds. Default is 1000ms.
|
|
4518
|
+
* @returns CommandResult with command output and requestId
|
|
4519
|
+
* @throws APIError if the operation fails.
|
|
4520
|
+
*/
|
|
4521
|
+
async executeCommand(command, timeoutMs = 1e3) {
|
|
4522
|
+
try {
|
|
4523
|
+
const args = {
|
|
4524
|
+
command,
|
|
4525
|
+
timeout_ms: timeoutMs
|
|
4526
|
+
};
|
|
4527
|
+
const result = await this.session.callMcpTool("shell", args);
|
|
4528
|
+
return {
|
|
4529
|
+
requestId: result.requestId,
|
|
4530
|
+
success: result.success,
|
|
4531
|
+
output: result.data,
|
|
4532
|
+
errorMessage: result.errorMessage
|
|
4533
|
+
};
|
|
4534
|
+
} catch (error) {
|
|
4535
|
+
return {
|
|
4536
|
+
requestId: "",
|
|
4537
|
+
success: false,
|
|
4538
|
+
output: "",
|
|
4539
|
+
errorMessage: `Failed to execute command: ${error}`
|
|
4540
|
+
};
|
|
4541
|
+
}
|
|
4542
|
+
}
|
|
4543
|
+
};
|
|
4117
4544
|
__name(_Command, "Command");
|
|
4118
4545
|
var Command = _Command;
|
|
4119
4546
|
|
|
@@ -4155,11 +4582,11 @@ var _ContextManager = class _ContextManager {
|
|
|
4155
4582
|
try {
|
|
4156
4583
|
const response = await this.session.getClient().getContextInfo(request);
|
|
4157
4584
|
const requestId = extractRequestId(response) || "";
|
|
4158
|
-
if (_optionalChain([response, 'optionalAccess',
|
|
4585
|
+
if (_optionalChain([response, 'optionalAccess', _23 => _23.body])) {
|
|
4159
4586
|
log("Response from GetContextInfo:", response.body);
|
|
4160
4587
|
}
|
|
4161
4588
|
const contextStatusData = [];
|
|
4162
|
-
if (_optionalChain([response, 'optionalAccess',
|
|
4589
|
+
if (_optionalChain([response, 'optionalAccess', _24 => _24.body, 'optionalAccess', _25 => _25.data, 'optionalAccess', _26 => _26.contextStatus])) {
|
|
4163
4590
|
try {
|
|
4164
4591
|
const contextStatusStr = response.body.data.contextStatus;
|
|
4165
4592
|
const statusItems = JSON.parse(contextStatusStr);
|
|
@@ -4214,11 +4641,11 @@ var _ContextManager = class _ContextManager {
|
|
|
4214
4641
|
try {
|
|
4215
4642
|
const response = await this.session.getClient().syncContext(request);
|
|
4216
4643
|
const requestId = extractRequestId(response) || "";
|
|
4217
|
-
if (_optionalChain([response, 'optionalAccess',
|
|
4644
|
+
if (_optionalChain([response, 'optionalAccess', _27 => _27.body])) {
|
|
4218
4645
|
log("Response from SyncContext:", response.body);
|
|
4219
4646
|
}
|
|
4220
4647
|
let success = false;
|
|
4221
|
-
if (_optionalChain([response, 'optionalAccess',
|
|
4648
|
+
if (_optionalChain([response, 'optionalAccess', _28 => _28.body, 'optionalAccess', _29 => _29.success]) !== void 0) {
|
|
4222
4649
|
success = response.body.success;
|
|
4223
4650
|
}
|
|
4224
4651
|
return {
|
|
@@ -4241,27 +4668,6 @@ __name(newContextManager, "newContextManager");
|
|
|
4241
4668
|
// src/filesystem/filesystem.ts
|
|
4242
4669
|
init_cjs_shims();
|
|
4243
4670
|
var DEFAULT_CHUNK_SIZE = 60 * 1024;
|
|
4244
|
-
var FILE_OPERATIONS = {
|
|
4245
|
-
read_file: true,
|
|
4246
|
-
write_file: true,
|
|
4247
|
-
read_multiple_files: true
|
|
4248
|
-
};
|
|
4249
|
-
function isFileOperation(toolName) {
|
|
4250
|
-
return FILE_OPERATIONS[toolName] === true;
|
|
4251
|
-
}
|
|
4252
|
-
__name(isFileOperation, "isFileOperation");
|
|
4253
|
-
function truncateContentForLogging(args) {
|
|
4254
|
-
const truncatedArgs = { ...args };
|
|
4255
|
-
if (typeof truncatedArgs.content === "string") {
|
|
4256
|
-
const contentLength = truncatedArgs.content.length;
|
|
4257
|
-
truncatedArgs.content = `[Content length: ${contentLength} bytes]`;
|
|
4258
|
-
}
|
|
4259
|
-
if (Array.isArray(truncatedArgs.paths) && truncatedArgs.paths.length > 3) {
|
|
4260
|
-
truncatedArgs.paths = `[${truncatedArgs.paths.length} paths, first few: ${truncatedArgs.paths[0]}, ${truncatedArgs.paths[1]}, ${truncatedArgs.paths[2]}, ...]`;
|
|
4261
|
-
}
|
|
4262
|
-
return truncatedArgs;
|
|
4263
|
-
}
|
|
4264
|
-
__name(truncateContentForLogging, "truncateContentForLogging");
|
|
4265
4671
|
function parseFileInfo(fileInfoStr) {
|
|
4266
4672
|
const result = {
|
|
4267
4673
|
name: "",
|
|
@@ -4339,124 +4745,30 @@ var _FileSystem = class _FileSystem {
|
|
|
4339
4745
|
this.session = session;
|
|
4340
4746
|
}
|
|
4341
4747
|
/**
|
|
4342
|
-
*
|
|
4748
|
+
* Creates a new directory at the specified path.
|
|
4749
|
+
* Corresponds to Python's create_directory() method
|
|
4343
4750
|
*
|
|
4344
|
-
* @param
|
|
4345
|
-
* @
|
|
4346
|
-
* @param defaultErrorMsg - Default error message if specific error details are not available
|
|
4347
|
-
* @returns A CallMcpToolResult with the response data
|
|
4348
|
-
* @throws APIError if the call fails
|
|
4751
|
+
* @param path - Path to the directory to create.
|
|
4752
|
+
* @returns BoolResult with creation result and requestId
|
|
4349
4753
|
*/
|
|
4350
|
-
async
|
|
4754
|
+
async createDirectory(path2) {
|
|
4351
4755
|
try {
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
const callToolRequest = new CallMcpToolRequest({
|
|
4359
|
-
authorization: `Bearer ${this.session.getAPIKey()}`,
|
|
4360
|
-
sessionId: this.session.getSessionId(),
|
|
4361
|
-
name: toolName,
|
|
4362
|
-
args: argsJSON
|
|
4363
|
-
});
|
|
4364
|
-
log(`API Call: CallMcpTool - ${toolName}`);
|
|
4365
|
-
log(
|
|
4366
|
-
`Request: SessionId=${this.session.getSessionId()}, Args=${loggableArgsJSON}`
|
|
4756
|
+
const args = {
|
|
4757
|
+
path: path2
|
|
4758
|
+
};
|
|
4759
|
+
const result = await this.session.callMcpTool(
|
|
4760
|
+
"create_directory",
|
|
4761
|
+
args
|
|
4367
4762
|
);
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
const data2 = response.body.data;
|
|
4375
|
-
if (data2.isError === true) {
|
|
4376
|
-
log(`Response contains error: ${data2.isError}`);
|
|
4377
|
-
} else {
|
|
4378
|
-
log("Response successful, content length info provided separately");
|
|
4379
|
-
if (Array.isArray(data2.content) && data2.content.length > 0) {
|
|
4380
|
-
let totalSize = 0;
|
|
4381
|
-
for (const item of data2.content) {
|
|
4382
|
-
if (item && typeof item === "object" && item.text && typeof item.text === "string") {
|
|
4383
|
-
totalSize += item.text.length;
|
|
4384
|
-
}
|
|
4385
|
-
}
|
|
4386
|
-
log(`Content size: ${totalSize} bytes`);
|
|
4387
|
-
}
|
|
4388
|
-
}
|
|
4389
|
-
}
|
|
4390
|
-
} else {
|
|
4391
|
-
const sanitizedBody = { ...response.body };
|
|
4392
|
-
if (sanitizedBody.data && typeof sanitizedBody.data === "object") {
|
|
4393
|
-
const sanitizedData = { ...sanitizedBody.data };
|
|
4394
|
-
if (Array.isArray(sanitizedData.content)) {
|
|
4395
|
-
sanitizedData.content = `[Array with ${sanitizedData.content.length} items]`;
|
|
4396
|
-
}
|
|
4397
|
-
sanitizedBody.data = sanitizedData;
|
|
4398
|
-
}
|
|
4399
|
-
log(`Response from CallMcpTool - ${toolName}:`, sanitizedBody);
|
|
4400
|
-
}
|
|
4401
|
-
if (!_optionalChain([response, 'access', _31 => _31.body, 'optionalAccess', _32 => _32.data])) {
|
|
4402
|
-
throw new Error("Invalid response data format");
|
|
4403
|
-
}
|
|
4404
|
-
const data = response.body.data;
|
|
4405
|
-
const result = {
|
|
4406
|
-
data,
|
|
4407
|
-
statusCode: response.statusCode || 0,
|
|
4408
|
-
isError: false,
|
|
4409
|
-
requestId: extractRequestId(response)
|
|
4410
|
-
};
|
|
4411
|
-
if (data.isError === true) {
|
|
4412
|
-
result.isError = true;
|
|
4413
|
-
const contentArray = data.content;
|
|
4414
|
-
if (contentArray && contentArray.length > 0) {
|
|
4415
|
-
result.content = contentArray;
|
|
4416
|
-
if (_optionalChain([contentArray, 'access', _33 => _33[0], 'optionalAccess', _34 => _34.text])) {
|
|
4417
|
-
result.errorMsg = contentArray[0].text;
|
|
4418
|
-
throw new Error(contentArray[0].text);
|
|
4419
|
-
}
|
|
4420
|
-
}
|
|
4421
|
-
throw new Error(defaultErrorMsg);
|
|
4422
|
-
}
|
|
4423
|
-
if (Array.isArray(data.content)) {
|
|
4424
|
-
result.content = data.content;
|
|
4425
|
-
if (result.content.length > 0) {
|
|
4426
|
-
const textParts = [];
|
|
4427
|
-
for (const item of result.content) {
|
|
4428
|
-
if (item && typeof item === "object" && item.text && typeof item.text === "string") {
|
|
4429
|
-
textParts.push(item.text);
|
|
4430
|
-
}
|
|
4431
|
-
}
|
|
4432
|
-
result.textContent = textParts.join("\n");
|
|
4433
|
-
}
|
|
4763
|
+
if (!result.success) {
|
|
4764
|
+
return {
|
|
4765
|
+
requestId: result.requestId,
|
|
4766
|
+
success: false,
|
|
4767
|
+
errorMessage: result.errorMessage
|
|
4768
|
+
};
|
|
4434
4769
|
}
|
|
4435
|
-
return result;
|
|
4436
|
-
} catch (error) {
|
|
4437
|
-
logError(`Error calling CallMcpTool - ${toolName}:`, error);
|
|
4438
|
-
throw new APIError(`Failed to call ${toolName}: ${error}`);
|
|
4439
|
-
}
|
|
4440
|
-
}
|
|
4441
|
-
/**
|
|
4442
|
-
* Creates a new directory at the specified path.
|
|
4443
|
-
* Corresponds to Python's create_directory() method
|
|
4444
|
-
*
|
|
4445
|
-
* @param path - Path to the directory to create.
|
|
4446
|
-
* @returns BoolResult with creation result and requestId
|
|
4447
|
-
*/
|
|
4448
|
-
async createDirectory(path2) {
|
|
4449
|
-
try {
|
|
4450
|
-
const args = {
|
|
4451
|
-
path: path2
|
|
4452
|
-
};
|
|
4453
|
-
const result = await this.callMcpTool(
|
|
4454
|
-
"create_directory",
|
|
4455
|
-
args,
|
|
4456
|
-
"Failed to create directory"
|
|
4457
|
-
);
|
|
4458
4770
|
return {
|
|
4459
|
-
requestId: result.requestId
|
|
4771
|
+
requestId: result.requestId,
|
|
4460
4772
|
success: true,
|
|
4461
4773
|
data: true
|
|
4462
4774
|
};
|
|
@@ -4484,13 +4796,19 @@ var _FileSystem = class _FileSystem {
|
|
|
4484
4796
|
edits,
|
|
4485
4797
|
dryRun
|
|
4486
4798
|
};
|
|
4487
|
-
const result = await this.callMcpTool(
|
|
4799
|
+
const result = await this.session.callMcpTool(
|
|
4488
4800
|
"edit_file",
|
|
4489
|
-
args
|
|
4490
|
-
"Failed to edit file"
|
|
4801
|
+
args
|
|
4491
4802
|
);
|
|
4803
|
+
if (!result.success) {
|
|
4804
|
+
return {
|
|
4805
|
+
requestId: result.requestId,
|
|
4806
|
+
success: false,
|
|
4807
|
+
errorMessage: result.errorMessage
|
|
4808
|
+
};
|
|
4809
|
+
}
|
|
4492
4810
|
return {
|
|
4493
|
-
requestId: result.requestId
|
|
4811
|
+
requestId: result.requestId,
|
|
4494
4812
|
success: true,
|
|
4495
4813
|
data: true
|
|
4496
4814
|
};
|
|
@@ -4514,22 +4832,29 @@ var _FileSystem = class _FileSystem {
|
|
|
4514
4832
|
const args = {
|
|
4515
4833
|
path: path2
|
|
4516
4834
|
};
|
|
4517
|
-
const result = await this.callMcpTool(
|
|
4835
|
+
const result = await this.session.callMcpTool(
|
|
4518
4836
|
"get_file_info",
|
|
4519
|
-
args
|
|
4520
|
-
"Failed to get file info"
|
|
4837
|
+
args
|
|
4521
4838
|
);
|
|
4522
|
-
if (!result.
|
|
4839
|
+
if (!result.success) {
|
|
4523
4840
|
return {
|
|
4524
|
-
requestId: result.requestId
|
|
4841
|
+
requestId: result.requestId,
|
|
4842
|
+
success: false,
|
|
4843
|
+
fileInfo: {},
|
|
4844
|
+
errorMessage: result.errorMessage
|
|
4845
|
+
};
|
|
4846
|
+
}
|
|
4847
|
+
if (!result.data) {
|
|
4848
|
+
return {
|
|
4849
|
+
requestId: result.requestId,
|
|
4525
4850
|
success: false,
|
|
4526
4851
|
fileInfo: {},
|
|
4527
4852
|
errorMessage: "Empty response from get_file_info"
|
|
4528
4853
|
};
|
|
4529
4854
|
}
|
|
4530
|
-
const fileInfo = parseFileInfo(result.
|
|
4855
|
+
const fileInfo = parseFileInfo(result.data);
|
|
4531
4856
|
return {
|
|
4532
|
-
requestId: result.requestId
|
|
4857
|
+
requestId: result.requestId,
|
|
4533
4858
|
success: true,
|
|
4534
4859
|
fileInfo
|
|
4535
4860
|
};
|
|
@@ -4553,14 +4878,21 @@ var _FileSystem = class _FileSystem {
|
|
|
4553
4878
|
const args = {
|
|
4554
4879
|
path: path2
|
|
4555
4880
|
};
|
|
4556
|
-
const result = await this.callMcpTool(
|
|
4881
|
+
const result = await this.session.callMcpTool(
|
|
4557
4882
|
"list_directory",
|
|
4558
|
-
args
|
|
4559
|
-
"Failed to list directory"
|
|
4883
|
+
args
|
|
4560
4884
|
);
|
|
4561
|
-
|
|
4885
|
+
if (!result.success) {
|
|
4886
|
+
return {
|
|
4887
|
+
requestId: result.requestId,
|
|
4888
|
+
success: false,
|
|
4889
|
+
entries: [],
|
|
4890
|
+
errorMessage: result.errorMessage
|
|
4891
|
+
};
|
|
4892
|
+
}
|
|
4893
|
+
const entries = result.data ? parseDirectoryListing(result.data) : [];
|
|
4562
4894
|
return {
|
|
4563
|
-
requestId: result.requestId
|
|
4895
|
+
requestId: result.requestId,
|
|
4564
4896
|
success: true,
|
|
4565
4897
|
entries
|
|
4566
4898
|
};
|
|
@@ -4587,13 +4919,19 @@ var _FileSystem = class _FileSystem {
|
|
|
4587
4919
|
source,
|
|
4588
4920
|
destination
|
|
4589
4921
|
};
|
|
4590
|
-
const result = await this.callMcpTool(
|
|
4922
|
+
const result = await this.session.callMcpTool(
|
|
4591
4923
|
"move_file",
|
|
4592
|
-
args
|
|
4593
|
-
"Failed to move file"
|
|
4924
|
+
args
|
|
4594
4925
|
);
|
|
4926
|
+
if (!result.success) {
|
|
4927
|
+
return {
|
|
4928
|
+
requestId: result.requestId,
|
|
4929
|
+
success: false,
|
|
4930
|
+
errorMessage: result.errorMessage
|
|
4931
|
+
};
|
|
4932
|
+
}
|
|
4595
4933
|
return {
|
|
4596
|
-
requestId: result.requestId
|
|
4934
|
+
requestId: result.requestId,
|
|
4597
4935
|
success: true,
|
|
4598
4936
|
data: true
|
|
4599
4937
|
};
|
|
@@ -4610,8 +4948,8 @@ var _FileSystem = class _FileSystem {
|
|
|
4610
4948
|
* Corresponds to Python's read_file() method
|
|
4611
4949
|
*
|
|
4612
4950
|
* @param path - Path to the file to read.
|
|
4613
|
-
* @param offset - Optional:
|
|
4614
|
-
* @param length - Optional: Number of
|
|
4951
|
+
* @param offset - Optional: Byte offset to start reading from (0-based).
|
|
4952
|
+
* @param length - Optional: Number of bytes to read. If 0, reads the entire file from offset.
|
|
4615
4953
|
* @returns FileContentResult with file content and requestId
|
|
4616
4954
|
*/
|
|
4617
4955
|
async readFile(path2, offset = 0, length = 0) {
|
|
@@ -4625,15 +4963,22 @@ var _FileSystem = class _FileSystem {
|
|
|
4625
4963
|
if (length > 0) {
|
|
4626
4964
|
args.length = length;
|
|
4627
4965
|
}
|
|
4628
|
-
const result = await this.callMcpTool(
|
|
4966
|
+
const result = await this.session.callMcpTool(
|
|
4629
4967
|
"read_file",
|
|
4630
|
-
args
|
|
4631
|
-
"Failed to read file"
|
|
4968
|
+
args
|
|
4632
4969
|
);
|
|
4970
|
+
if (!result.success) {
|
|
4971
|
+
return {
|
|
4972
|
+
requestId: result.requestId,
|
|
4973
|
+
success: false,
|
|
4974
|
+
content: "",
|
|
4975
|
+
errorMessage: result.errorMessage
|
|
4976
|
+
};
|
|
4977
|
+
}
|
|
4633
4978
|
return {
|
|
4634
|
-
requestId: result.requestId
|
|
4979
|
+
requestId: result.requestId,
|
|
4635
4980
|
success: true,
|
|
4636
|
-
content: result.
|
|
4981
|
+
content: result.data || ""
|
|
4637
4982
|
};
|
|
4638
4983
|
} catch (error) {
|
|
4639
4984
|
return {
|
|
@@ -4656,14 +5001,21 @@ var _FileSystem = class _FileSystem {
|
|
|
4656
5001
|
const args = {
|
|
4657
5002
|
paths
|
|
4658
5003
|
};
|
|
4659
|
-
const result = await this.callMcpTool(
|
|
5004
|
+
const result = await this.session.callMcpTool(
|
|
4660
5005
|
"read_multiple_files",
|
|
4661
|
-
args
|
|
4662
|
-
"Failed to read multiple files"
|
|
5006
|
+
args
|
|
4663
5007
|
);
|
|
5008
|
+
if (!result.success) {
|
|
5009
|
+
return {
|
|
5010
|
+
requestId: result.requestId,
|
|
5011
|
+
success: false,
|
|
5012
|
+
contents: {},
|
|
5013
|
+
errorMessage: result.errorMessage
|
|
5014
|
+
};
|
|
5015
|
+
}
|
|
4664
5016
|
const fileContents = {};
|
|
4665
|
-
if (result.
|
|
4666
|
-
const lines = result.
|
|
5017
|
+
if (result.data) {
|
|
5018
|
+
const lines = result.data.split("\n");
|
|
4667
5019
|
let currentPath = "";
|
|
4668
5020
|
let currentContent = [];
|
|
4669
5021
|
for (const line of lines) {
|
|
@@ -4695,7 +5047,7 @@ var _FileSystem = class _FileSystem {
|
|
|
4695
5047
|
}
|
|
4696
5048
|
}
|
|
4697
5049
|
return {
|
|
4698
|
-
requestId: result.requestId
|
|
5050
|
+
requestId: result.requestId,
|
|
4699
5051
|
success: true,
|
|
4700
5052
|
contents: fileContents
|
|
4701
5053
|
};
|
|
@@ -4724,19 +5076,26 @@ var _FileSystem = class _FileSystem {
|
|
|
4724
5076
|
pattern
|
|
4725
5077
|
};
|
|
4726
5078
|
if (excludePatterns.length > 0) {
|
|
4727
|
-
args.
|
|
5079
|
+
args.excludePatterns = excludePatterns;
|
|
4728
5080
|
}
|
|
4729
|
-
const result = await this.callMcpTool(
|
|
5081
|
+
const result = await this.session.callMcpTool(
|
|
4730
5082
|
"search_files",
|
|
4731
|
-
args
|
|
4732
|
-
"Failed to search files"
|
|
5083
|
+
args
|
|
4733
5084
|
);
|
|
5085
|
+
if (!result.success) {
|
|
5086
|
+
return {
|
|
5087
|
+
requestId: result.requestId,
|
|
5088
|
+
success: false,
|
|
5089
|
+
matches: [],
|
|
5090
|
+
errorMessage: result.errorMessage
|
|
5091
|
+
};
|
|
5092
|
+
}
|
|
4734
5093
|
let searchResults = [];
|
|
4735
|
-
if (result.
|
|
4736
|
-
searchResults = result.
|
|
5094
|
+
if (result.data) {
|
|
5095
|
+
searchResults = result.data.split("\n").map((line) => line.trim()).filter((line) => line !== "");
|
|
4737
5096
|
}
|
|
4738
5097
|
return {
|
|
4739
|
-
requestId: result.requestId
|
|
5098
|
+
requestId: result.requestId,
|
|
4740
5099
|
success: true,
|
|
4741
5100
|
matches: searchResults
|
|
4742
5101
|
};
|
|
@@ -4775,13 +5134,19 @@ var _FileSystem = class _FileSystem {
|
|
|
4775
5134
|
content,
|
|
4776
5135
|
mode
|
|
4777
5136
|
};
|
|
4778
|
-
const result = await this.callMcpTool(
|
|
5137
|
+
const result = await this.session.callMcpTool(
|
|
4779
5138
|
"write_file",
|
|
4780
|
-
args
|
|
4781
|
-
"Failed to write file"
|
|
5139
|
+
args
|
|
4782
5140
|
);
|
|
5141
|
+
if (!result.success) {
|
|
5142
|
+
return {
|
|
5143
|
+
requestId: result.requestId,
|
|
5144
|
+
success: false,
|
|
5145
|
+
errorMessage: result.errorMessage
|
|
5146
|
+
};
|
|
5147
|
+
}
|
|
4783
5148
|
return {
|
|
4784
|
-
requestId: result.requestId
|
|
5149
|
+
requestId: result.requestId,
|
|
4785
5150
|
success: true,
|
|
4786
5151
|
data: true
|
|
4787
5152
|
};
|
|
@@ -4831,17 +5196,11 @@ var _FileSystem = class _FileSystem {
|
|
|
4831
5196
|
let result = "";
|
|
4832
5197
|
let offset = 0;
|
|
4833
5198
|
let chunkCount = 0;
|
|
4834
|
-
log(
|
|
4835
|
-
`ReadLargeFile: Starting chunked read of ${path2} (total size: ${fileSize} bytes, chunk size: ${chunkSize} bytes)`
|
|
4836
|
-
);
|
|
4837
5199
|
while (offset < fileSize) {
|
|
4838
5200
|
let length = chunkSize;
|
|
4839
5201
|
if (offset + length > fileSize) {
|
|
4840
5202
|
length = fileSize - offset;
|
|
4841
5203
|
}
|
|
4842
|
-
log(
|
|
4843
|
-
`ReadLargeFile: Reading chunk ${chunkCount + 1} (${length} bytes at offset ${offset}/${fileSize})`
|
|
4844
|
-
);
|
|
4845
5204
|
try {
|
|
4846
5205
|
const chunkResult = await this.readFile(path2, offset, length);
|
|
4847
5206
|
if (!chunkResult.success) {
|
|
@@ -4851,7 +5210,6 @@ var _FileSystem = class _FileSystem {
|
|
|
4851
5210
|
offset += length;
|
|
4852
5211
|
chunkCount++;
|
|
4853
5212
|
} catch (error) {
|
|
4854
|
-
logError(`Error reading chunk at offset ${offset}: ${error}`);
|
|
4855
5213
|
return {
|
|
4856
5214
|
requestId: fileInfoResult.requestId,
|
|
4857
5215
|
success: false,
|
|
@@ -4860,9 +5218,6 @@ var _FileSystem = class _FileSystem {
|
|
|
4860
5218
|
};
|
|
4861
5219
|
}
|
|
4862
5220
|
}
|
|
4863
|
-
log(
|
|
4864
|
-
`ReadLargeFile: Successfully read ${path2} in ${chunkCount} chunks (total: ${fileSize} bytes)`
|
|
4865
|
-
);
|
|
4866
5221
|
return {
|
|
4867
5222
|
requestId: fileInfoResult.requestId,
|
|
4868
5223
|
success: true,
|
|
@@ -4889,19 +5244,10 @@ var _FileSystem = class _FileSystem {
|
|
|
4889
5244
|
async writeLargeFile(path2, content, chunkSize = DEFAULT_CHUNK_SIZE) {
|
|
4890
5245
|
try {
|
|
4891
5246
|
const contentLen = content.length;
|
|
4892
|
-
log(
|
|
4893
|
-
`WriteLargeFile: Starting chunked write to ${path2} (total size: ${contentLen} bytes, chunk size: ${chunkSize} bytes)`
|
|
4894
|
-
);
|
|
4895
5247
|
if (contentLen <= chunkSize) {
|
|
4896
|
-
log(
|
|
4897
|
-
`WriteLargeFile: Content size (${contentLen} bytes) is smaller than chunk size, using normal WriteFile`
|
|
4898
|
-
);
|
|
4899
5248
|
return await this.writeFile(path2, content, "overwrite");
|
|
4900
5249
|
}
|
|
4901
5250
|
const firstChunkEnd = Math.min(chunkSize, contentLen);
|
|
4902
|
-
log(
|
|
4903
|
-
`WriteLargeFile: Writing first chunk (0-${firstChunkEnd} bytes) with overwrite mode`
|
|
4904
|
-
);
|
|
4905
5251
|
const firstResult = await this.writeFile(
|
|
4906
5252
|
path2,
|
|
4907
5253
|
content.substring(0, firstChunkEnd),
|
|
@@ -4913,9 +5259,6 @@ var _FileSystem = class _FileSystem {
|
|
|
4913
5259
|
let chunkCount = 1;
|
|
4914
5260
|
for (let offset = firstChunkEnd; offset < contentLen; ) {
|
|
4915
5261
|
const end = Math.min(offset + chunkSize, contentLen);
|
|
4916
|
-
log(
|
|
4917
|
-
`WriteLargeFile: Writing chunk ${chunkCount + 1} (${offset}-${end} bytes) with append mode`
|
|
4918
|
-
);
|
|
4919
5262
|
const chunkResult = await this.writeFile(
|
|
4920
5263
|
path2,
|
|
4921
5264
|
content.substring(offset, end),
|
|
@@ -4927,9 +5270,6 @@ var _FileSystem = class _FileSystem {
|
|
|
4927
5270
|
offset = end;
|
|
4928
5271
|
chunkCount++;
|
|
4929
5272
|
}
|
|
4930
|
-
log(
|
|
4931
|
-
`WriteLargeFile: Successfully wrote ${path2} in ${chunkCount} chunks (total: ${contentLen} bytes)`
|
|
4932
|
-
);
|
|
4933
5273
|
return {
|
|
4934
5274
|
requestId: firstResult.requestId,
|
|
4935
5275
|
success: true,
|
|
@@ -4962,113 +5302,64 @@ var _Oss = class _Oss {
|
|
|
4962
5302
|
this.session = session;
|
|
4963
5303
|
}
|
|
4964
5304
|
/**
|
|
4965
|
-
*
|
|
5305
|
+
* Sanitizes error messages to remove sensitive information like API keys.
|
|
4966
5306
|
*
|
|
4967
|
-
* @param
|
|
4968
|
-
* @
|
|
4969
|
-
* @param defaultErrorMsg - Default error message if specific error details are not available
|
|
4970
|
-
* @returns A CallMcpToolResult with the response data
|
|
4971
|
-
* @throws APIError if the call fails
|
|
5307
|
+
* @param error - The error to sanitize
|
|
5308
|
+
* @returns The sanitized error
|
|
4972
5309
|
*/
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
authorization: `Bearer ${this.session.getAPIKey()}`,
|
|
4977
|
-
sessionId: this.session.getSessionId(),
|
|
4978
|
-
name: toolName,
|
|
4979
|
-
args: JSON.stringify(args)
|
|
4980
|
-
});
|
|
4981
|
-
log(`API Call: CallMcpTool - ${toolName}`);
|
|
4982
|
-
log(
|
|
4983
|
-
`Request: SessionId=${this.session.getSessionId()}, Args=${JSON.stringify(
|
|
4984
|
-
args
|
|
4985
|
-
)}`
|
|
4986
|
-
);
|
|
4987
|
-
const response = await this.session.getClient().callMcpTool(callToolRequest);
|
|
4988
|
-
log(`Response from CallMcpTool - ${toolName}:`, response.body);
|
|
4989
|
-
if (!_optionalChain([response, 'access', _35 => _35.body, 'optionalAccess', _36 => _36.data])) {
|
|
4990
|
-
throw new Error("Invalid response data format");
|
|
4991
|
-
}
|
|
4992
|
-
const data = response.body.data;
|
|
4993
|
-
const result = {
|
|
4994
|
-
data,
|
|
4995
|
-
statusCode: response.statusCode || 0,
|
|
4996
|
-
isError: false,
|
|
4997
|
-
requestId: extractRequestId(response)
|
|
4998
|
-
};
|
|
4999
|
-
if (data.isError === true) {
|
|
5000
|
-
result.isError = true;
|
|
5001
|
-
const contentArray = data.content;
|
|
5002
|
-
if (contentArray && contentArray.length > 0) {
|
|
5003
|
-
result.content = contentArray;
|
|
5004
|
-
if (_optionalChain([contentArray, 'access', _37 => _37[0], 'optionalAccess', _38 => _38.text])) {
|
|
5005
|
-
result.errorMsg = contentArray[0].text;
|
|
5006
|
-
throw new Error(contentArray[0].text);
|
|
5007
|
-
}
|
|
5008
|
-
}
|
|
5009
|
-
throw new Error(defaultErrorMsg);
|
|
5010
|
-
}
|
|
5011
|
-
if (Array.isArray(data.content)) {
|
|
5012
|
-
result.content = data.content;
|
|
5013
|
-
if (result.content.length > 0) {
|
|
5014
|
-
const textParts = [];
|
|
5015
|
-
for (const item of result.content) {
|
|
5016
|
-
if (item && typeof item === "object" && item.text && typeof item.text === "string") {
|
|
5017
|
-
textParts.push(item.text);
|
|
5018
|
-
}
|
|
5019
|
-
}
|
|
5020
|
-
result.textContent = textParts.join("\n");
|
|
5021
|
-
}
|
|
5022
|
-
}
|
|
5023
|
-
return result;
|
|
5024
|
-
} catch (error) {
|
|
5025
|
-
logError(`Error calling CallMcpTool - ${toolName}:`, error);
|
|
5026
|
-
throw new APIError(`Failed to call MCP tool ${toolName}: ${error}`);
|
|
5310
|
+
sanitizeError(error) {
|
|
5311
|
+
if (!error) {
|
|
5312
|
+
return error;
|
|
5027
5313
|
}
|
|
5314
|
+
const errorString = String(error);
|
|
5315
|
+
return errorString.replace(/Bearer\s+[^\s]+/g, "Bearer [REDACTED]");
|
|
5028
5316
|
}
|
|
5029
5317
|
/**
|
|
5030
5318
|
* Initialize OSS environment variables with the specified credentials.
|
|
5031
5319
|
* Corresponds to Python's env_init() method
|
|
5032
5320
|
*
|
|
5033
|
-
* @param accessKeyId - The
|
|
5034
|
-
* @param accessKeySecret - The
|
|
5035
|
-
* @param securityToken - The security token
|
|
5036
|
-
* @param endpoint - The OSS
|
|
5037
|
-
* @param region - The OSS region
|
|
5038
|
-
* @returns OSSClientResult with
|
|
5321
|
+
* @param accessKeyId - The access key ID
|
|
5322
|
+
* @param accessKeySecret - The access key secret
|
|
5323
|
+
* @param securityToken - The security token (optional)
|
|
5324
|
+
* @param endpoint - The OSS endpoint (optional)
|
|
5325
|
+
* @param region - The OSS region (optional)
|
|
5326
|
+
* @returns OSSClientResult with client configuration and requestId
|
|
5327
|
+
* @throws APIError if the operation fails.
|
|
5039
5328
|
*/
|
|
5040
5329
|
async envInit(accessKeyId, accessKeySecret, securityToken, endpoint, region) {
|
|
5041
5330
|
try {
|
|
5042
5331
|
const args = {
|
|
5043
5332
|
access_key_id: accessKeyId,
|
|
5044
|
-
access_key_secret: accessKeySecret
|
|
5333
|
+
access_key_secret: accessKeySecret,
|
|
5334
|
+
security_token: securityToken || "",
|
|
5335
|
+
endpoint: endpoint || "",
|
|
5336
|
+
region: region || ""
|
|
5045
5337
|
};
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5338
|
+
const result = await this.session.callMcpTool("oss_env_init", args);
|
|
5339
|
+
if (!result.success) {
|
|
5340
|
+
return {
|
|
5341
|
+
requestId: result.requestId,
|
|
5342
|
+
success: false,
|
|
5343
|
+
clientConfig: {},
|
|
5344
|
+
errorMessage: result.errorMessage
|
|
5345
|
+
};
|
|
5054
5346
|
}
|
|
5055
|
-
const result = await this.callMcpTool(
|
|
5056
|
-
"oss_env_init",
|
|
5057
|
-
args,
|
|
5058
|
-
"Failed to initialize OSS environment"
|
|
5059
|
-
);
|
|
5060
5347
|
let clientConfig = {};
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5348
|
+
try {
|
|
5349
|
+
clientConfig = JSON.parse(result.data);
|
|
5350
|
+
} catch (err) {
|
|
5351
|
+
return {
|
|
5352
|
+
requestId: result.requestId,
|
|
5353
|
+
success: false,
|
|
5354
|
+
clientConfig: {},
|
|
5355
|
+
errorMessage: `Failed to parse client config: ${err}`
|
|
5356
|
+
};
|
|
5067
5357
|
}
|
|
5068
5358
|
return {
|
|
5069
|
-
requestId: result.requestId
|
|
5359
|
+
requestId: result.requestId,
|
|
5070
5360
|
success: true,
|
|
5071
|
-
clientConfig
|
|
5361
|
+
clientConfig,
|
|
5362
|
+
errorMessage: ""
|
|
5072
5363
|
};
|
|
5073
5364
|
} catch (error) {
|
|
5074
5365
|
return {
|
|
@@ -5080,13 +5371,14 @@ var _Oss = class _Oss {
|
|
|
5080
5371
|
}
|
|
5081
5372
|
}
|
|
5082
5373
|
/**
|
|
5083
|
-
* Upload a
|
|
5374
|
+
* Upload a file to OSS.
|
|
5084
5375
|
* Corresponds to Python's upload() method
|
|
5085
5376
|
*
|
|
5086
|
-
* @param bucket - OSS bucket name
|
|
5087
|
-
* @param object -
|
|
5088
|
-
* @param path -
|
|
5377
|
+
* @param bucket - The OSS bucket name
|
|
5378
|
+
* @param object - The OSS object key
|
|
5379
|
+
* @param path - The local file path to upload
|
|
5089
5380
|
* @returns OSSUploadResult with upload result and requestId
|
|
5381
|
+
* @throws APIError if the operation fails.
|
|
5090
5382
|
*/
|
|
5091
5383
|
async upload(bucket, object, path2) {
|
|
5092
5384
|
try {
|
|
@@ -5095,32 +5387,30 @@ var _Oss = class _Oss {
|
|
|
5095
5387
|
object,
|
|
5096
5388
|
path: path2
|
|
5097
5389
|
};
|
|
5098
|
-
const result = await this.callMcpTool(
|
|
5099
|
-
"oss_upload",
|
|
5100
|
-
args,
|
|
5101
|
-
"Failed to upload to OSS"
|
|
5102
|
-
);
|
|
5390
|
+
const result = await this.session.callMcpTool("oss_upload", args);
|
|
5103
5391
|
return {
|
|
5104
|
-
requestId: result.requestId
|
|
5105
|
-
success:
|
|
5106
|
-
content: result.
|
|
5392
|
+
requestId: result.requestId,
|
|
5393
|
+
success: result.success,
|
|
5394
|
+
content: result.data,
|
|
5395
|
+
errorMessage: result.errorMessage
|
|
5107
5396
|
};
|
|
5108
5397
|
} catch (error) {
|
|
5109
5398
|
return {
|
|
5110
5399
|
requestId: "",
|
|
5111
5400
|
success: false,
|
|
5112
5401
|
content: "",
|
|
5113
|
-
errorMessage: `Failed to upload
|
|
5402
|
+
errorMessage: `Failed to upload file: ${error}`
|
|
5114
5403
|
};
|
|
5115
5404
|
}
|
|
5116
5405
|
}
|
|
5117
5406
|
/**
|
|
5118
|
-
* Upload a
|
|
5407
|
+
* Upload a file to OSS using an anonymous URL.
|
|
5119
5408
|
* Corresponds to Python's upload_anonymous() method
|
|
5120
5409
|
*
|
|
5121
|
-
* @param url -
|
|
5122
|
-
* @param path -
|
|
5410
|
+
* @param url - The anonymous upload URL
|
|
5411
|
+
* @param path - The local file path to upload
|
|
5123
5412
|
* @returns OSSUploadResult with upload result and requestId
|
|
5413
|
+
* @throws APIError if the operation fails.
|
|
5124
5414
|
*/
|
|
5125
5415
|
async uploadAnonymous(url, path2) {
|
|
5126
5416
|
try {
|
|
@@ -5128,33 +5418,31 @@ var _Oss = class _Oss {
|
|
|
5128
5418
|
url,
|
|
5129
5419
|
path: path2
|
|
5130
5420
|
};
|
|
5131
|
-
const result = await this.callMcpTool(
|
|
5132
|
-
"oss_upload_annon",
|
|
5133
|
-
args,
|
|
5134
|
-
"Failed to upload anonymously"
|
|
5135
|
-
);
|
|
5421
|
+
const result = await this.session.callMcpTool("oss_upload_anonymous", args);
|
|
5136
5422
|
return {
|
|
5137
|
-
requestId: result.requestId
|
|
5138
|
-
success:
|
|
5139
|
-
content: result.
|
|
5423
|
+
requestId: result.requestId,
|
|
5424
|
+
success: result.success,
|
|
5425
|
+
content: result.data,
|
|
5426
|
+
errorMessage: result.errorMessage
|
|
5140
5427
|
};
|
|
5141
5428
|
} catch (error) {
|
|
5142
5429
|
return {
|
|
5143
5430
|
requestId: "",
|
|
5144
5431
|
success: false,
|
|
5145
5432
|
content: "",
|
|
5146
|
-
errorMessage: `Failed to upload anonymously: ${error}`
|
|
5433
|
+
errorMessage: `Failed to upload file anonymously: ${error}`
|
|
5147
5434
|
};
|
|
5148
5435
|
}
|
|
5149
5436
|
}
|
|
5150
5437
|
/**
|
|
5151
|
-
* Download
|
|
5438
|
+
* Download a file from OSS.
|
|
5152
5439
|
* Corresponds to Python's download() method
|
|
5153
5440
|
*
|
|
5154
|
-
* @param bucket - OSS bucket name
|
|
5155
|
-
* @param object -
|
|
5156
|
-
* @param path -
|
|
5441
|
+
* @param bucket - The OSS bucket name
|
|
5442
|
+
* @param object - The OSS object key
|
|
5443
|
+
* @param path - The local file path to save the downloaded file
|
|
5157
5444
|
* @returns OSSDownloadResult with download result and requestId
|
|
5445
|
+
* @throws APIError if the operation fails.
|
|
5158
5446
|
*/
|
|
5159
5447
|
async download(bucket, object, path2) {
|
|
5160
5448
|
try {
|
|
@@ -5163,32 +5451,30 @@ var _Oss = class _Oss {
|
|
|
5163
5451
|
object,
|
|
5164
5452
|
path: path2
|
|
5165
5453
|
};
|
|
5166
|
-
const result = await this.callMcpTool(
|
|
5167
|
-
"oss_download",
|
|
5168
|
-
args,
|
|
5169
|
-
"Failed to download from OSS"
|
|
5170
|
-
);
|
|
5454
|
+
const result = await this.session.callMcpTool("oss_download", args);
|
|
5171
5455
|
return {
|
|
5172
|
-
requestId: result.requestId
|
|
5173
|
-
success:
|
|
5174
|
-
content: result.
|
|
5456
|
+
requestId: result.requestId,
|
|
5457
|
+
success: result.success,
|
|
5458
|
+
content: result.data,
|
|
5459
|
+
errorMessage: result.errorMessage
|
|
5175
5460
|
};
|
|
5176
5461
|
} catch (error) {
|
|
5177
5462
|
return {
|
|
5178
5463
|
requestId: "",
|
|
5179
5464
|
success: false,
|
|
5180
5465
|
content: "",
|
|
5181
|
-
errorMessage: `Failed to download
|
|
5466
|
+
errorMessage: `Failed to download file: ${error}`
|
|
5182
5467
|
};
|
|
5183
5468
|
}
|
|
5184
5469
|
}
|
|
5185
5470
|
/**
|
|
5186
|
-
* Download
|
|
5471
|
+
* Download a file from OSS using an anonymous URL.
|
|
5187
5472
|
* Corresponds to Python's download_anonymous() method
|
|
5188
5473
|
*
|
|
5189
|
-
* @param url -
|
|
5190
|
-
* @param path -
|
|
5474
|
+
* @param url - The anonymous download URL
|
|
5475
|
+
* @param path - The local file path to save the downloaded file
|
|
5191
5476
|
* @returns OSSDownloadResult with download result and requestId
|
|
5477
|
+
* @throws APIError if the operation fails.
|
|
5192
5478
|
*/
|
|
5193
5479
|
async downloadAnonymous(url, path2) {
|
|
5194
5480
|
try {
|
|
@@ -5196,22 +5482,19 @@ var _Oss = class _Oss {
|
|
|
5196
5482
|
url,
|
|
5197
5483
|
path: path2
|
|
5198
5484
|
};
|
|
5199
|
-
const result = await this.callMcpTool(
|
|
5200
|
-
"oss_download_annon",
|
|
5201
|
-
args,
|
|
5202
|
-
"Failed to download anonymously"
|
|
5203
|
-
);
|
|
5485
|
+
const result = await this.session.callMcpTool("oss_download_anonymous", args);
|
|
5204
5486
|
return {
|
|
5205
|
-
requestId: result.requestId
|
|
5206
|
-
success:
|
|
5207
|
-
content: result.
|
|
5487
|
+
requestId: result.requestId,
|
|
5488
|
+
success: result.success,
|
|
5489
|
+
content: result.data,
|
|
5490
|
+
errorMessage: result.errorMessage
|
|
5208
5491
|
};
|
|
5209
5492
|
} catch (error) {
|
|
5210
5493
|
return {
|
|
5211
5494
|
requestId: "",
|
|
5212
5495
|
success: false,
|
|
5213
5496
|
content: "",
|
|
5214
|
-
errorMessage: `Failed to download anonymously: ${error}`
|
|
5497
|
+
errorMessage: `Failed to download file anonymously: ${error}`
|
|
5215
5498
|
};
|
|
5216
5499
|
}
|
|
5217
5500
|
}
|
|
@@ -5221,14 +5504,15 @@ var Oss = _Oss;
|
|
|
5221
5504
|
|
|
5222
5505
|
// src/ui/ui.ts
|
|
5223
5506
|
init_cjs_shims();
|
|
5224
|
-
var KeyCode = {
|
|
5225
|
-
HOME
|
|
5226
|
-
BACK
|
|
5227
|
-
VOLUME_UP
|
|
5228
|
-
VOLUME_DOWN
|
|
5229
|
-
POWER
|
|
5230
|
-
MENU
|
|
5231
|
-
|
|
5507
|
+
var KeyCode = /* @__PURE__ */ ((KeyCode2) => {
|
|
5508
|
+
KeyCode2[KeyCode2["HOME"] = 3] = "HOME";
|
|
5509
|
+
KeyCode2[KeyCode2["BACK"] = 4] = "BACK";
|
|
5510
|
+
KeyCode2[KeyCode2["VOLUME_UP"] = 24] = "VOLUME_UP";
|
|
5511
|
+
KeyCode2[KeyCode2["VOLUME_DOWN"] = 25] = "VOLUME_DOWN";
|
|
5512
|
+
KeyCode2[KeyCode2["POWER"] = 26] = "POWER";
|
|
5513
|
+
KeyCode2[KeyCode2["MENU"] = 82] = "MENU";
|
|
5514
|
+
return KeyCode2;
|
|
5515
|
+
})(KeyCode || {});
|
|
5232
5516
|
var _UI = class _UI {
|
|
5233
5517
|
/**
|
|
5234
5518
|
* Initialize a UI object.
|
|
@@ -5239,68 +5523,17 @@ var _UI = class _UI {
|
|
|
5239
5523
|
this.session = session;
|
|
5240
5524
|
}
|
|
5241
5525
|
/**
|
|
5242
|
-
*
|
|
5526
|
+
* Sanitizes error messages to remove sensitive information like API keys.
|
|
5243
5527
|
*
|
|
5244
|
-
* @param
|
|
5245
|
-
* @
|
|
5246
|
-
* @param defaultErrorMsg - Default error message if specific error details are not available
|
|
5247
|
-
* @returns A CallMcpToolResult with the response data
|
|
5248
|
-
* @throws APIError if the call fails
|
|
5528
|
+
* @param error - The error to sanitize
|
|
5529
|
+
* @returns The sanitized error
|
|
5249
5530
|
*/
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
const callToolRequest = new CallMcpToolRequest({
|
|
5254
|
-
authorization: `Bearer ${this.session.getAPIKey()}`,
|
|
5255
|
-
sessionId: this.session.getSessionId(),
|
|
5256
|
-
name: toolName,
|
|
5257
|
-
args: argsJSON
|
|
5258
|
-
});
|
|
5259
|
-
log(`API Call: CallMcpTool - ${toolName}`);
|
|
5260
|
-
log(
|
|
5261
|
-
`Request: SessionId=${this.session.getSessionId()}, Args=${argsJSON}`
|
|
5262
|
-
);
|
|
5263
|
-
const response = await this.session.getClient().callMcpTool(callToolRequest);
|
|
5264
|
-
log(`Response from CallMcpTool - ${toolName}:`, response.body);
|
|
5265
|
-
if (!_optionalChain([response, 'access', _39 => _39.body, 'optionalAccess', _40 => _40.data])) {
|
|
5266
|
-
throw new Error("Invalid response data format");
|
|
5267
|
-
}
|
|
5268
|
-
const data = response.body.data;
|
|
5269
|
-
const result = {
|
|
5270
|
-
data,
|
|
5271
|
-
statusCode: response.statusCode || 0,
|
|
5272
|
-
isError: false,
|
|
5273
|
-
requestId: extractRequestId(response)
|
|
5274
|
-
};
|
|
5275
|
-
if (data.isError === true) {
|
|
5276
|
-
result.isError = true;
|
|
5277
|
-
const contentArray = data.content;
|
|
5278
|
-
if (contentArray && contentArray.length > 0) {
|
|
5279
|
-
result.content = contentArray;
|
|
5280
|
-
if (_optionalChain([contentArray, 'access', _41 => _41[0], 'optionalAccess', _42 => _42.text])) {
|
|
5281
|
-
result.errorMsg = contentArray[0].text;
|
|
5282
|
-
throw new Error(contentArray[0].text);
|
|
5283
|
-
}
|
|
5284
|
-
}
|
|
5285
|
-
throw new Error(defaultErrorMsg);
|
|
5286
|
-
}
|
|
5287
|
-
if (Array.isArray(data.content)) {
|
|
5288
|
-
result.content = data.content;
|
|
5289
|
-
if (result.content.length > 0) {
|
|
5290
|
-
const textParts = [];
|
|
5291
|
-
for (const item of result.content) {
|
|
5292
|
-
if (item && typeof item === "object" && item.text && typeof item.text === "string") {
|
|
5293
|
-
textParts.push(item.text);
|
|
5294
|
-
}
|
|
5295
|
-
}
|
|
5296
|
-
result.textContent = textParts.join("\n");
|
|
5297
|
-
}
|
|
5298
|
-
}
|
|
5299
|
-
return result;
|
|
5300
|
-
} catch (error) {
|
|
5301
|
-
logError(`Error calling CallMcpTool - ${toolName}:`, error);
|
|
5302
|
-
throw new APIError(`Failed to call ${toolName}: ${error}`);
|
|
5531
|
+
sanitizeError(error) {
|
|
5532
|
+
if (!error) {
|
|
5533
|
+
return error;
|
|
5303
5534
|
}
|
|
5535
|
+
const errorString = String(error);
|
|
5536
|
+
return errorString.replace(/Bearer\s+[^\s]+/g, "Bearer [REDACTED]");
|
|
5304
5537
|
}
|
|
5305
5538
|
/**
|
|
5306
5539
|
* Retrieves all clickable UI elements within the specified timeout.
|
|
@@ -5308,32 +5541,33 @@ var _UI = class _UI {
|
|
|
5308
5541
|
*
|
|
5309
5542
|
* @param timeoutMs - The timeout in milliseconds. Default is 2000ms.
|
|
5310
5543
|
* @returns UIElementListResult with clickable UI elements and requestId
|
|
5544
|
+
* @throws APIError if the operation fails.
|
|
5311
5545
|
*/
|
|
5312
5546
|
async getClickableUIElements(timeoutMs = 2e3) {
|
|
5313
5547
|
try {
|
|
5314
|
-
const args = {
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5548
|
+
const args = { timeout_ms: timeoutMs };
|
|
5549
|
+
const result = await this.session.callMcpTool("get_clickable_ui_elements", args);
|
|
5550
|
+
if (!result.success) {
|
|
5551
|
+
return {
|
|
5552
|
+
requestId: result.requestId,
|
|
5553
|
+
success: false,
|
|
5554
|
+
elements: [],
|
|
5555
|
+
errorMessage: result.errorMessage
|
|
5556
|
+
};
|
|
5557
|
+
}
|
|
5322
5558
|
let elements = [];
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
};
|
|
5333
|
-
}
|
|
5559
|
+
try {
|
|
5560
|
+
elements = JSON.parse(result.data);
|
|
5561
|
+
} catch (err) {
|
|
5562
|
+
return {
|
|
5563
|
+
requestId: result.requestId,
|
|
5564
|
+
success: false,
|
|
5565
|
+
elements: [],
|
|
5566
|
+
errorMessage: `Failed to parse UI elements: ${err}`
|
|
5567
|
+
};
|
|
5334
5568
|
}
|
|
5335
5569
|
return {
|
|
5336
|
-
requestId: result.requestId
|
|
5570
|
+
requestId: result.requestId,
|
|
5337
5571
|
success: true,
|
|
5338
5572
|
elements
|
|
5339
5573
|
};
|
|
@@ -5347,37 +5581,38 @@ var _UI = class _UI {
|
|
|
5347
5581
|
}
|
|
5348
5582
|
}
|
|
5349
5583
|
/**
|
|
5350
|
-
* Retrieves all UI elements
|
|
5584
|
+
* Retrieves all UI elements regardless of their clickable status.
|
|
5351
5585
|
* Corresponds to Python's get_all_ui_elements() method
|
|
5352
5586
|
*
|
|
5353
5587
|
* @param timeoutMs - The timeout in milliseconds. Default is 2000ms.
|
|
5354
5588
|
* @returns UIElementListResult with all UI elements and requestId
|
|
5589
|
+
* @throws APIError if the operation fails.
|
|
5355
5590
|
*/
|
|
5356
5591
|
async getAllUIElements(timeoutMs = 2e3) {
|
|
5357
5592
|
try {
|
|
5358
|
-
const args = {
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5593
|
+
const args = { timeout_ms: timeoutMs };
|
|
5594
|
+
const result = await this.session.callMcpTool("get_all_ui_elements", args);
|
|
5595
|
+
if (!result.success) {
|
|
5596
|
+
return {
|
|
5597
|
+
requestId: result.requestId,
|
|
5598
|
+
success: false,
|
|
5599
|
+
elements: [],
|
|
5600
|
+
errorMessage: result.errorMessage
|
|
5601
|
+
};
|
|
5602
|
+
}
|
|
5366
5603
|
let elements = [];
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
};
|
|
5377
|
-
}
|
|
5604
|
+
try {
|
|
5605
|
+
elements = JSON.parse(result.data);
|
|
5606
|
+
} catch (err) {
|
|
5607
|
+
return {
|
|
5608
|
+
requestId: result.requestId,
|
|
5609
|
+
success: false,
|
|
5610
|
+
elements: [],
|
|
5611
|
+
errorMessage: `Failed to parse UI elements: ${err}`
|
|
5612
|
+
};
|
|
5378
5613
|
}
|
|
5379
5614
|
return {
|
|
5380
|
-
requestId: result.requestId
|
|
5615
|
+
requestId: result.requestId,
|
|
5381
5616
|
success: true,
|
|
5382
5617
|
elements
|
|
5383
5618
|
};
|
|
@@ -5394,58 +5629,58 @@ var _UI = class _UI {
|
|
|
5394
5629
|
* Sends a key press event.
|
|
5395
5630
|
* Corresponds to Python's send_key() method
|
|
5396
5631
|
*
|
|
5397
|
-
* @param key - The key code to send.
|
|
5398
|
-
*
|
|
5632
|
+
* @param key - The key code to send. Supported key codes are:
|
|
5633
|
+
* - 3 : HOME
|
|
5634
|
+
* - 4 : BACK
|
|
5635
|
+
* - 24 : VOLUME UP
|
|
5636
|
+
* - 25 : VOLUME DOWN
|
|
5637
|
+
* - 26 : POWER
|
|
5638
|
+
* - 82 : MENU
|
|
5639
|
+
* @returns BoolResult with success status and requestId
|
|
5640
|
+
* @throws APIError if the operation fails.
|
|
5399
5641
|
*/
|
|
5400
5642
|
async sendKey(key) {
|
|
5401
5643
|
try {
|
|
5402
|
-
const args = {
|
|
5403
|
-
|
|
5404
|
-
};
|
|
5405
|
-
const result = await this.callMcpTool(
|
|
5406
|
-
"send_key",
|
|
5407
|
-
args,
|
|
5408
|
-
"Failed to send key"
|
|
5409
|
-
);
|
|
5644
|
+
const args = { key };
|
|
5645
|
+
const result = await this.session.callMcpTool("send_key", args);
|
|
5410
5646
|
return {
|
|
5411
|
-
requestId: result.requestId
|
|
5412
|
-
success:
|
|
5413
|
-
data:
|
|
5647
|
+
requestId: result.requestId,
|
|
5648
|
+
success: result.success,
|
|
5649
|
+
data: result.success,
|
|
5650
|
+
errorMessage: result.errorMessage
|
|
5414
5651
|
};
|
|
5415
5652
|
} catch (error) {
|
|
5416
5653
|
return {
|
|
5417
5654
|
requestId: "",
|
|
5418
5655
|
success: false,
|
|
5656
|
+
data: false,
|
|
5419
5657
|
errorMessage: `Failed to send key: ${error}`
|
|
5420
5658
|
};
|
|
5421
5659
|
}
|
|
5422
5660
|
}
|
|
5423
5661
|
/**
|
|
5424
|
-
* Inputs text into the
|
|
5662
|
+
* Inputs text into the currently focused UI element.
|
|
5425
5663
|
* Corresponds to Python's input_text() method
|
|
5426
5664
|
*
|
|
5427
|
-
* @param text - The text to input
|
|
5428
|
-
* @returns BoolResult with
|
|
5665
|
+
* @param text - The text to input
|
|
5666
|
+
* @returns BoolResult with success status and requestId
|
|
5667
|
+
* @throws APIError if the operation fails.
|
|
5429
5668
|
*/
|
|
5430
5669
|
async inputText(text) {
|
|
5431
5670
|
try {
|
|
5432
|
-
const args = {
|
|
5433
|
-
|
|
5434
|
-
};
|
|
5435
|
-
const result = await this.callMcpTool(
|
|
5436
|
-
"input_text",
|
|
5437
|
-
args,
|
|
5438
|
-
"Failed to input text"
|
|
5439
|
-
);
|
|
5671
|
+
const args = { text };
|
|
5672
|
+
const result = await this.session.callMcpTool("input_text", args);
|
|
5440
5673
|
return {
|
|
5441
|
-
requestId: result.requestId
|
|
5442
|
-
success:
|
|
5443
|
-
data:
|
|
5674
|
+
requestId: result.requestId,
|
|
5675
|
+
success: result.success,
|
|
5676
|
+
data: result.success,
|
|
5677
|
+
errorMessage: result.errorMessage
|
|
5444
5678
|
};
|
|
5445
5679
|
} catch (error) {
|
|
5446
5680
|
return {
|
|
5447
5681
|
requestId: "",
|
|
5448
5682
|
success: false,
|
|
5683
|
+
data: false,
|
|
5449
5684
|
errorMessage: `Failed to input text: ${error}`
|
|
5450
5685
|
};
|
|
5451
5686
|
}
|
|
@@ -5454,12 +5689,13 @@ var _UI = class _UI {
|
|
|
5454
5689
|
* Performs a swipe gesture on the screen.
|
|
5455
5690
|
* Corresponds to Python's swipe() method
|
|
5456
5691
|
*
|
|
5457
|
-
* @param startX - The starting X coordinate
|
|
5458
|
-
* @param startY - The starting Y coordinate
|
|
5459
|
-
* @param endX - The ending X coordinate
|
|
5460
|
-
* @param endY - The ending Y coordinate
|
|
5692
|
+
* @param startX - The starting X coordinate
|
|
5693
|
+
* @param startY - The starting Y coordinate
|
|
5694
|
+
* @param endX - The ending X coordinate
|
|
5695
|
+
* @param endY - The ending Y coordinate
|
|
5461
5696
|
* @param durationMs - The duration of the swipe in milliseconds. Default is 300ms.
|
|
5462
|
-
* @returns BoolResult with
|
|
5697
|
+
* @returns BoolResult with success status and requestId
|
|
5698
|
+
* @throws APIError if the operation fails.
|
|
5463
5699
|
*/
|
|
5464
5700
|
async swipe(startX, startY, endX, endY, durationMs = 300) {
|
|
5465
5701
|
try {
|
|
@@ -5470,55 +5706,48 @@ var _UI = class _UI {
|
|
|
5470
5706
|
end_y: endY,
|
|
5471
5707
|
duration_ms: durationMs
|
|
5472
5708
|
};
|
|
5473
|
-
const result = await this.callMcpTool(
|
|
5474
|
-
"swipe",
|
|
5475
|
-
args,
|
|
5476
|
-
"Failed to perform swipe"
|
|
5477
|
-
);
|
|
5709
|
+
const result = await this.session.callMcpTool("swipe", args);
|
|
5478
5710
|
return {
|
|
5479
|
-
requestId: result.requestId
|
|
5480
|
-
success:
|
|
5481
|
-
data:
|
|
5711
|
+
requestId: result.requestId,
|
|
5712
|
+
success: result.success,
|
|
5713
|
+
data: result.success,
|
|
5714
|
+
errorMessage: result.errorMessage
|
|
5482
5715
|
};
|
|
5483
5716
|
} catch (error) {
|
|
5484
5717
|
return {
|
|
5485
5718
|
requestId: "",
|
|
5486
5719
|
success: false,
|
|
5720
|
+
data: false,
|
|
5487
5721
|
errorMessage: `Failed to perform swipe: ${error}`
|
|
5488
5722
|
};
|
|
5489
5723
|
}
|
|
5490
5724
|
}
|
|
5491
5725
|
/**
|
|
5492
|
-
*
|
|
5726
|
+
* Clicks on the screen at the specified coordinates.
|
|
5493
5727
|
* Corresponds to Python's click() method
|
|
5494
5728
|
*
|
|
5495
|
-
* @param x - The X coordinate
|
|
5496
|
-
* @param y - The Y coordinate
|
|
5497
|
-
* @param button - The mouse button to
|
|
5498
|
-
* @returns BoolResult with
|
|
5729
|
+
* @param x - The X coordinate
|
|
5730
|
+
* @param y - The Y coordinate
|
|
5731
|
+
* @param button - The mouse button to use. Default is 'left'
|
|
5732
|
+
* @returns BoolResult with success status and requestId
|
|
5733
|
+
* @throws APIError if the operation fails.
|
|
5499
5734
|
*/
|
|
5500
5735
|
async click(x, y, button = "left") {
|
|
5501
5736
|
try {
|
|
5502
|
-
const args = {
|
|
5503
|
-
|
|
5504
|
-
y,
|
|
5505
|
-
button
|
|
5506
|
-
};
|
|
5507
|
-
const result = await this.callMcpTool(
|
|
5508
|
-
"click",
|
|
5509
|
-
args,
|
|
5510
|
-
"Failed to perform click"
|
|
5511
|
-
);
|
|
5737
|
+
const args = { x, y, button };
|
|
5738
|
+
const result = await this.session.callMcpTool("click", args);
|
|
5512
5739
|
return {
|
|
5513
|
-
requestId: result.requestId
|
|
5514
|
-
success:
|
|
5515
|
-
data:
|
|
5740
|
+
requestId: result.requestId,
|
|
5741
|
+
success: result.success,
|
|
5742
|
+
data: result.success,
|
|
5743
|
+
errorMessage: result.errorMessage
|
|
5516
5744
|
};
|
|
5517
5745
|
} catch (error) {
|
|
5518
5746
|
return {
|
|
5519
5747
|
requestId: "",
|
|
5520
5748
|
success: false,
|
|
5521
|
-
|
|
5749
|
+
data: false,
|
|
5750
|
+
errorMessage: `Failed to click: ${error}`
|
|
5522
5751
|
};
|
|
5523
5752
|
}
|
|
5524
5753
|
}
|
|
@@ -5526,25 +5755,30 @@ var _UI = class _UI {
|
|
|
5526
5755
|
* Takes a screenshot of the current screen.
|
|
5527
5756
|
* Corresponds to Python's screenshot() method
|
|
5528
5757
|
*
|
|
5529
|
-
* @returns OperationResult with
|
|
5758
|
+
* @returns OperationResult with success status and requestId
|
|
5759
|
+
* @throws APIError if the operation fails.
|
|
5530
5760
|
*/
|
|
5531
5761
|
async screenshot() {
|
|
5532
5762
|
try {
|
|
5533
|
-
const
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5763
|
+
const result = await this.session.callMcpTool("system_screenshot", {});
|
|
5764
|
+
if (!result.success) {
|
|
5765
|
+
return {
|
|
5766
|
+
requestId: result.requestId,
|
|
5767
|
+
success: false,
|
|
5768
|
+
data: "",
|
|
5769
|
+
errorMessage: result.errorMessage
|
|
5770
|
+
};
|
|
5771
|
+
}
|
|
5539
5772
|
return {
|
|
5540
|
-
requestId: result.requestId
|
|
5773
|
+
requestId: result.requestId,
|
|
5541
5774
|
success: true,
|
|
5542
|
-
data: result.
|
|
5775
|
+
data: result.data
|
|
5543
5776
|
};
|
|
5544
5777
|
} catch (error) {
|
|
5545
5778
|
return {
|
|
5546
5779
|
requestId: "",
|
|
5547
5780
|
success: false,
|
|
5781
|
+
data: "",
|
|
5548
5782
|
errorMessage: `Failed to take screenshot: ${error}`
|
|
5549
5783
|
};
|
|
5550
5784
|
}
|
|
@@ -5563,70 +5797,6 @@ var _WindowManager = class _WindowManager {
|
|
|
5563
5797
|
constructor(session) {
|
|
5564
5798
|
this.session = session;
|
|
5565
5799
|
}
|
|
5566
|
-
/**
|
|
5567
|
-
* Helper method to call MCP tools and handle common response processing
|
|
5568
|
-
*
|
|
5569
|
-
* @param toolName - Name of the MCP tool to call
|
|
5570
|
-
* @param args - Arguments to pass to the tool
|
|
5571
|
-
* @param defaultErrorMsg - Default error message if specific error details are not available
|
|
5572
|
-
* @returns A CallMcpToolResult with the response data
|
|
5573
|
-
* @throws APIError if the call fails
|
|
5574
|
-
*/
|
|
5575
|
-
async callMcpTool(toolName, args, defaultErrorMsg) {
|
|
5576
|
-
try {
|
|
5577
|
-
const argsJSON = JSON.stringify(args);
|
|
5578
|
-
const request = new CallMcpToolRequest({
|
|
5579
|
-
authorization: `Bearer ${this.session.getAPIKey()}`,
|
|
5580
|
-
sessionId: this.session.getSessionId(),
|
|
5581
|
-
name: toolName,
|
|
5582
|
-
args: argsJSON
|
|
5583
|
-
});
|
|
5584
|
-
log(`API Call: CallMcpTool - ${toolName}`);
|
|
5585
|
-
log(`Request: SessionId=${request.sessionId}, Args=${request.args}`);
|
|
5586
|
-
const response = await this.session.getClient().callMcpTool(request);
|
|
5587
|
-
if (response && response.body) {
|
|
5588
|
-
log(`Response from CallMcpTool - ${toolName}:`, response.body);
|
|
5589
|
-
}
|
|
5590
|
-
if (!_optionalChain([response, 'access', _43 => _43.body, 'optionalAccess', _44 => _44.data])) {
|
|
5591
|
-
throw new Error("Invalid response data format");
|
|
5592
|
-
}
|
|
5593
|
-
const data = response.body.data;
|
|
5594
|
-
const result = {
|
|
5595
|
-
data,
|
|
5596
|
-
statusCode: response.statusCode || 0,
|
|
5597
|
-
isError: false,
|
|
5598
|
-
requestId: extractRequestId(response)
|
|
5599
|
-
};
|
|
5600
|
-
if (data.isError === true) {
|
|
5601
|
-
result.isError = true;
|
|
5602
|
-
const contentArray = data.content;
|
|
5603
|
-
if (contentArray && contentArray.length > 0) {
|
|
5604
|
-
result.content = contentArray;
|
|
5605
|
-
if (_optionalChain([contentArray, 'access', _45 => _45[0], 'optionalAccess', _46 => _46.text])) {
|
|
5606
|
-
result.errorMsg = contentArray[0].text;
|
|
5607
|
-
throw new Error(contentArray[0].text);
|
|
5608
|
-
}
|
|
5609
|
-
}
|
|
5610
|
-
throw new Error(defaultErrorMsg);
|
|
5611
|
-
}
|
|
5612
|
-
if (Array.isArray(data.content)) {
|
|
5613
|
-
result.content = data.content;
|
|
5614
|
-
if (result.content.length > 0) {
|
|
5615
|
-
const textParts = [];
|
|
5616
|
-
for (const item of result.content) {
|
|
5617
|
-
if (item && typeof item === "object" && item.text && typeof item.text === "string") {
|
|
5618
|
-
textParts.push(item.text);
|
|
5619
|
-
}
|
|
5620
|
-
}
|
|
5621
|
-
result.textContent = textParts.join("\n");
|
|
5622
|
-
}
|
|
5623
|
-
}
|
|
5624
|
-
return result;
|
|
5625
|
-
} catch (error) {
|
|
5626
|
-
logError(`Error calling CallMcpTool - ${toolName}:`, error);
|
|
5627
|
-
throw new APIError(`Failed to call ${toolName}: ${error}`);
|
|
5628
|
-
}
|
|
5629
|
-
}
|
|
5630
5800
|
/**
|
|
5631
5801
|
* Helper method to parse JSON string into Window objects
|
|
5632
5802
|
* @param jsonStr - JSON string to parse
|
|
@@ -5652,14 +5822,21 @@ var _WindowManager = class _WindowManager {
|
|
|
5652
5822
|
const args = {
|
|
5653
5823
|
timeout_ms: timeoutMs
|
|
5654
5824
|
};
|
|
5655
|
-
const
|
|
5825
|
+
const response = await this.session.callMcpTool(
|
|
5656
5826
|
"list_root_windows",
|
|
5657
|
-
args
|
|
5658
|
-
"Failed to list root windows"
|
|
5827
|
+
args
|
|
5659
5828
|
);
|
|
5660
|
-
|
|
5829
|
+
if (!response.success) {
|
|
5830
|
+
return {
|
|
5831
|
+
requestId: response.requestId,
|
|
5832
|
+
success: false,
|
|
5833
|
+
windows: [],
|
|
5834
|
+
errorMessage: response.errorMessage
|
|
5835
|
+
};
|
|
5836
|
+
}
|
|
5837
|
+
const windows = response.data ? this.parseWindowsFromJSON(response.data) : [];
|
|
5661
5838
|
return {
|
|
5662
|
-
requestId:
|
|
5839
|
+
requestId: response.requestId,
|
|
5663
5840
|
success: true,
|
|
5664
5841
|
windows
|
|
5665
5842
|
};
|
|
@@ -5684,18 +5861,24 @@ var _WindowManager = class _WindowManager {
|
|
|
5684
5861
|
const args = {
|
|
5685
5862
|
timeout_ms: timeoutMs
|
|
5686
5863
|
};
|
|
5687
|
-
const
|
|
5864
|
+
const response = await this.session.callMcpTool(
|
|
5688
5865
|
"get_active_window",
|
|
5689
|
-
args
|
|
5690
|
-
"Failed to get active window"
|
|
5866
|
+
args
|
|
5691
5867
|
);
|
|
5868
|
+
if (!response.success) {
|
|
5869
|
+
return {
|
|
5870
|
+
requestId: response.requestId,
|
|
5871
|
+
success: false,
|
|
5872
|
+
errorMessage: response.errorMessage
|
|
5873
|
+
};
|
|
5874
|
+
}
|
|
5692
5875
|
let activeWindow = void 0;
|
|
5693
|
-
if (
|
|
5694
|
-
const windows = this.parseWindowsFromJSON(
|
|
5876
|
+
if (response.data) {
|
|
5877
|
+
const windows = this.parseWindowsFromJSON(response.data);
|
|
5695
5878
|
activeWindow = windows.length > 0 ? windows[0] : void 0;
|
|
5696
5879
|
}
|
|
5697
5880
|
return {
|
|
5698
|
-
requestId:
|
|
5881
|
+
requestId: response.requestId,
|
|
5699
5882
|
success: true,
|
|
5700
5883
|
window: activeWindow
|
|
5701
5884
|
};
|
|
@@ -5719,13 +5902,19 @@ var _WindowManager = class _WindowManager {
|
|
|
5719
5902
|
const args = {
|
|
5720
5903
|
window_id: windowId
|
|
5721
5904
|
};
|
|
5722
|
-
const
|
|
5905
|
+
const response = await this.session.callMcpTool(
|
|
5723
5906
|
"activate_window",
|
|
5724
|
-
args
|
|
5725
|
-
"Failed to activate window"
|
|
5907
|
+
args
|
|
5726
5908
|
);
|
|
5909
|
+
if (!response.success) {
|
|
5910
|
+
return {
|
|
5911
|
+
requestId: response.requestId,
|
|
5912
|
+
success: false,
|
|
5913
|
+
errorMessage: response.errorMessage
|
|
5914
|
+
};
|
|
5915
|
+
}
|
|
5727
5916
|
return {
|
|
5728
|
-
requestId:
|
|
5917
|
+
requestId: response.requestId,
|
|
5729
5918
|
success: true,
|
|
5730
5919
|
data: true
|
|
5731
5920
|
};
|
|
@@ -5749,13 +5938,19 @@ var _WindowManager = class _WindowManager {
|
|
|
5749
5938
|
const args = {
|
|
5750
5939
|
window_id: windowId
|
|
5751
5940
|
};
|
|
5752
|
-
const
|
|
5941
|
+
const response = await this.session.callMcpTool(
|
|
5753
5942
|
"maximize_window",
|
|
5754
|
-
args
|
|
5755
|
-
"Failed to maximize window"
|
|
5943
|
+
args
|
|
5756
5944
|
);
|
|
5945
|
+
if (!response.success) {
|
|
5946
|
+
return {
|
|
5947
|
+
requestId: response.requestId,
|
|
5948
|
+
success: false,
|
|
5949
|
+
errorMessage: response.errorMessage
|
|
5950
|
+
};
|
|
5951
|
+
}
|
|
5757
5952
|
return {
|
|
5758
|
-
requestId:
|
|
5953
|
+
requestId: response.requestId,
|
|
5759
5954
|
success: true,
|
|
5760
5955
|
data: true
|
|
5761
5956
|
};
|
|
@@ -5779,13 +5974,19 @@ var _WindowManager = class _WindowManager {
|
|
|
5779
5974
|
const args = {
|
|
5780
5975
|
window_id: windowId
|
|
5781
5976
|
};
|
|
5782
|
-
const
|
|
5977
|
+
const response = await this.session.callMcpTool(
|
|
5783
5978
|
"minimize_window",
|
|
5784
|
-
args
|
|
5785
|
-
"Failed to minimize window"
|
|
5979
|
+
args
|
|
5786
5980
|
);
|
|
5981
|
+
if (!response.success) {
|
|
5982
|
+
return {
|
|
5983
|
+
requestId: response.requestId,
|
|
5984
|
+
success: false,
|
|
5985
|
+
errorMessage: response.errorMessage
|
|
5986
|
+
};
|
|
5987
|
+
}
|
|
5787
5988
|
return {
|
|
5788
|
-
requestId:
|
|
5989
|
+
requestId: response.requestId,
|
|
5789
5990
|
success: true,
|
|
5790
5991
|
data: true
|
|
5791
5992
|
};
|
|
@@ -5809,13 +6010,19 @@ var _WindowManager = class _WindowManager {
|
|
|
5809
6010
|
const args = {
|
|
5810
6011
|
window_id: windowId
|
|
5811
6012
|
};
|
|
5812
|
-
const
|
|
6013
|
+
const response = await this.session.callMcpTool(
|
|
5813
6014
|
"restore_window",
|
|
5814
|
-
args
|
|
5815
|
-
"Failed to restore window"
|
|
6015
|
+
args
|
|
5816
6016
|
);
|
|
6017
|
+
if (!response.success) {
|
|
6018
|
+
return {
|
|
6019
|
+
requestId: response.requestId,
|
|
6020
|
+
success: false,
|
|
6021
|
+
errorMessage: response.errorMessage
|
|
6022
|
+
};
|
|
6023
|
+
}
|
|
5817
6024
|
return {
|
|
5818
|
-
requestId:
|
|
6025
|
+
requestId: response.requestId,
|
|
5819
6026
|
success: true,
|
|
5820
6027
|
data: true
|
|
5821
6028
|
};
|
|
@@ -5836,124 +6043,494 @@ var _WindowManager = class _WindowManager {
|
|
|
5836
6043
|
*/
|
|
5837
6044
|
async closeWindow(windowId) {
|
|
5838
6045
|
try {
|
|
5839
|
-
const args = {
|
|
5840
|
-
window_id: windowId
|
|
5841
|
-
};
|
|
5842
|
-
const
|
|
5843
|
-
"close_window",
|
|
5844
|
-
args
|
|
5845
|
-
|
|
5846
|
-
)
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
6046
|
+
const args = {
|
|
6047
|
+
window_id: windowId
|
|
6048
|
+
};
|
|
6049
|
+
const response = await this.session.callMcpTool(
|
|
6050
|
+
"close_window",
|
|
6051
|
+
args
|
|
6052
|
+
);
|
|
6053
|
+
if (!response.success) {
|
|
6054
|
+
return {
|
|
6055
|
+
requestId: response.requestId,
|
|
6056
|
+
success: false,
|
|
6057
|
+
errorMessage: response.errorMessage
|
|
6058
|
+
};
|
|
6059
|
+
}
|
|
6060
|
+
return {
|
|
6061
|
+
requestId: response.requestId,
|
|
6062
|
+
success: true,
|
|
6063
|
+
data: true
|
|
6064
|
+
};
|
|
6065
|
+
} catch (error) {
|
|
6066
|
+
return {
|
|
6067
|
+
requestId: "",
|
|
6068
|
+
success: false,
|
|
6069
|
+
errorMessage: `Failed to close window: ${error}`
|
|
6070
|
+
};
|
|
6071
|
+
}
|
|
6072
|
+
}
|
|
6073
|
+
/**
|
|
6074
|
+
* Sets a window to fullscreen by ID.
|
|
6075
|
+
* Corresponds to Python's fullscreen_window() method
|
|
6076
|
+
*
|
|
6077
|
+
* @param windowId The ID of the window to set to fullscreen.
|
|
6078
|
+
* @returns BoolResult with requestId
|
|
6079
|
+
*/
|
|
6080
|
+
async fullscreenWindow(windowId) {
|
|
6081
|
+
try {
|
|
6082
|
+
const args = {
|
|
6083
|
+
window_id: windowId
|
|
6084
|
+
};
|
|
6085
|
+
const response = await this.session.callMcpTool(
|
|
6086
|
+
"fullscreen_window",
|
|
6087
|
+
args
|
|
6088
|
+
);
|
|
6089
|
+
if (!response.success) {
|
|
6090
|
+
return {
|
|
6091
|
+
requestId: response.requestId,
|
|
6092
|
+
success: false,
|
|
6093
|
+
errorMessage: response.errorMessage
|
|
6094
|
+
};
|
|
6095
|
+
}
|
|
6096
|
+
return {
|
|
6097
|
+
requestId: response.requestId,
|
|
6098
|
+
success: true,
|
|
6099
|
+
data: true
|
|
6100
|
+
};
|
|
6101
|
+
} catch (error) {
|
|
6102
|
+
return {
|
|
6103
|
+
requestId: "",
|
|
6104
|
+
success: false,
|
|
6105
|
+
errorMessage: `Failed to make window fullscreen: ${error}`
|
|
6106
|
+
};
|
|
6107
|
+
}
|
|
6108
|
+
}
|
|
6109
|
+
/**
|
|
6110
|
+
* Resizes a window by ID.
|
|
6111
|
+
* Corresponds to Python's resize_window() method
|
|
6112
|
+
*
|
|
6113
|
+
* @param windowId The ID of the window to resize.
|
|
6114
|
+
* @param width The new width of the window.
|
|
6115
|
+
* @param height The new height of the window.
|
|
6116
|
+
* @returns BoolResult with requestId
|
|
6117
|
+
*/
|
|
6118
|
+
async resizeWindow(windowId, width, height) {
|
|
6119
|
+
try {
|
|
6120
|
+
const args = {
|
|
6121
|
+
window_id: windowId,
|
|
6122
|
+
width,
|
|
6123
|
+
height
|
|
6124
|
+
};
|
|
6125
|
+
const response = await this.session.callMcpTool(
|
|
6126
|
+
"resize_window",
|
|
6127
|
+
args
|
|
6128
|
+
);
|
|
6129
|
+
if (!response.success) {
|
|
6130
|
+
return {
|
|
6131
|
+
requestId: response.requestId,
|
|
6132
|
+
success: false,
|
|
6133
|
+
errorMessage: response.errorMessage
|
|
6134
|
+
};
|
|
6135
|
+
}
|
|
6136
|
+
return {
|
|
6137
|
+
requestId: response.requestId,
|
|
6138
|
+
success: true,
|
|
6139
|
+
data: true
|
|
6140
|
+
};
|
|
6141
|
+
} catch (error) {
|
|
6142
|
+
return {
|
|
6143
|
+
requestId: "",
|
|
6144
|
+
success: false,
|
|
6145
|
+
errorMessage: `Failed to resize window: ${error}`
|
|
6146
|
+
};
|
|
6147
|
+
}
|
|
6148
|
+
}
|
|
6149
|
+
/**
|
|
6150
|
+
* Enables or disables focus mode.
|
|
6151
|
+
* Corresponds to Python's focus_mode() method
|
|
6152
|
+
*
|
|
6153
|
+
* @param on Whether to enable focus mode.
|
|
6154
|
+
* @returns BoolResult with requestId
|
|
6155
|
+
*/
|
|
6156
|
+
async focusMode(on) {
|
|
6157
|
+
try {
|
|
6158
|
+
const args = {
|
|
6159
|
+
on
|
|
6160
|
+
};
|
|
6161
|
+
const response = await this.session.callMcpTool(
|
|
6162
|
+
"focus_mode",
|
|
6163
|
+
args
|
|
6164
|
+
);
|
|
6165
|
+
if (!response.success) {
|
|
6166
|
+
return {
|
|
6167
|
+
requestId: response.requestId,
|
|
6168
|
+
success: false,
|
|
6169
|
+
errorMessage: response.errorMessage
|
|
6170
|
+
};
|
|
6171
|
+
}
|
|
6172
|
+
return {
|
|
6173
|
+
requestId: response.requestId,
|
|
6174
|
+
success: true,
|
|
6175
|
+
data: true
|
|
6176
|
+
};
|
|
6177
|
+
} catch (error) {
|
|
6178
|
+
return {
|
|
6179
|
+
requestId: "",
|
|
6180
|
+
success: false,
|
|
6181
|
+
errorMessage: `Failed to toggle focus mode: ${error}`
|
|
6182
|
+
};
|
|
6183
|
+
}
|
|
6184
|
+
}
|
|
6185
|
+
};
|
|
6186
|
+
__name(_WindowManager, "WindowManager");
|
|
6187
|
+
var WindowManager = _WindowManager;
|
|
6188
|
+
|
|
6189
|
+
// src/browser/index.ts
|
|
6190
|
+
init_cjs_shims();
|
|
6191
|
+
|
|
6192
|
+
// src/browser/browser.ts
|
|
6193
|
+
init_cjs_shims();
|
|
6194
|
+
|
|
6195
|
+
// src/browser/browser_agent.ts
|
|
6196
|
+
init_cjs_shims();
|
|
6197
|
+
var _ActResult = class _ActResult {
|
|
6198
|
+
constructor(success, message, action) {
|
|
6199
|
+
this.success = success;
|
|
6200
|
+
this.message = message;
|
|
6201
|
+
this.action = action;
|
|
6202
|
+
}
|
|
6203
|
+
};
|
|
6204
|
+
__name(_ActResult, "ActResult");
|
|
6205
|
+
var ActResult = _ActResult;
|
|
6206
|
+
var _ObserveResult = class _ObserveResult {
|
|
6207
|
+
constructor(selector, description, method, args) {
|
|
6208
|
+
this.selector = selector;
|
|
6209
|
+
this.description = description;
|
|
6210
|
+
this.method = method;
|
|
6211
|
+
this.args = args;
|
|
6212
|
+
}
|
|
6213
|
+
};
|
|
6214
|
+
__name(_ObserveResult, "ObserveResult");
|
|
6215
|
+
var ObserveResult = _ObserveResult;
|
|
6216
|
+
var _BrowserAgent = class _BrowserAgent {
|
|
6217
|
+
constructor(session, browser) {
|
|
6218
|
+
this.session = session;
|
|
6219
|
+
this.browser = browser;
|
|
6220
|
+
}
|
|
6221
|
+
/**
|
|
6222
|
+
* Perform an action on the given Playwright Page object, using ActOptions to configure behavior.
|
|
6223
|
+
* Returns the result of the action.
|
|
6224
|
+
*/
|
|
6225
|
+
async act(page, options) {
|
|
6226
|
+
if (!this.browser.isInitialized()) {
|
|
6227
|
+
throw new BrowserError("Browser must be initialized before calling act.");
|
|
6228
|
+
}
|
|
6229
|
+
try {
|
|
6230
|
+
const [pageIndex, contextIndex] = this._getPageAndContextIndex(page);
|
|
6231
|
+
log(`Acting on page: ${page}, pageIndex: ${pageIndex}, contextIndex: ${contextIndex}`);
|
|
6232
|
+
const args = {
|
|
6233
|
+
context_id: contextIndex,
|
|
6234
|
+
page_id: pageIndex,
|
|
6235
|
+
action: options.action
|
|
6236
|
+
};
|
|
6237
|
+
if (options.timeoutMS !== void 0) {
|
|
6238
|
+
args.timeout_ms = options.timeoutMS;
|
|
6239
|
+
}
|
|
6240
|
+
if (options.iframes !== void 0) {
|
|
6241
|
+
args.iframes = options.iframes;
|
|
6242
|
+
}
|
|
6243
|
+
if (options.domSettleTimeoutMS !== void 0) {
|
|
6244
|
+
args.dom_settle_timeout_ms = options.domSettleTimeoutMS;
|
|
6245
|
+
}
|
|
6246
|
+
const response = await this._callMcpTool("page_use_act", args);
|
|
6247
|
+
if (response.success) {
|
|
6248
|
+
log(`Response from CallMcpTool - page_use_act:`, response.data);
|
|
6249
|
+
let data;
|
|
6250
|
+
if (typeof response.data === "string") {
|
|
6251
|
+
data = JSON.parse(response.data);
|
|
6252
|
+
} else {
|
|
6253
|
+
data = response.data;
|
|
6254
|
+
}
|
|
6255
|
+
const success = data.success || false;
|
|
6256
|
+
const message = data.message || "";
|
|
6257
|
+
const action = data.action || "";
|
|
6258
|
+
return new ActResult(success, message, action);
|
|
6259
|
+
} else {
|
|
6260
|
+
return new ActResult(false, response.errorMessage, "");
|
|
6261
|
+
}
|
|
6262
|
+
} catch (error) {
|
|
6263
|
+
throw new BrowserError(`Failed to get page/context index: ${error}`);
|
|
6264
|
+
}
|
|
6265
|
+
}
|
|
6266
|
+
/**
|
|
6267
|
+
* Async version of act method for performing actions on the given Playwright Page object.
|
|
6268
|
+
*/
|
|
6269
|
+
async actAsync(page, options) {
|
|
6270
|
+
return this.act(page, options);
|
|
6271
|
+
}
|
|
6272
|
+
/**
|
|
6273
|
+
* Observe elements or state on the given Playwright Page object.
|
|
6274
|
+
* Returns a tuple containing (success, results).
|
|
6275
|
+
*/
|
|
6276
|
+
async observe(page, options) {
|
|
6277
|
+
if (!this.browser.isInitialized()) {
|
|
6278
|
+
throw new BrowserError("Browser must be initialized before calling observe.");
|
|
6279
|
+
}
|
|
6280
|
+
try {
|
|
6281
|
+
const [pageIndex, contextIndex] = this._getPageAndContextIndex(page);
|
|
6282
|
+
log(`Observing page: ${page}, pageIndex: ${pageIndex}, contextIndex: ${contextIndex}`);
|
|
6283
|
+
const args = {
|
|
6284
|
+
context_id: contextIndex,
|
|
6285
|
+
page_id: pageIndex,
|
|
6286
|
+
instruction: options.instruction
|
|
6287
|
+
};
|
|
6288
|
+
if (options.returnActions !== void 0) {
|
|
6289
|
+
args.return_actions = options.returnActions;
|
|
6290
|
+
}
|
|
6291
|
+
if (options.iframes !== void 0) {
|
|
6292
|
+
args.iframes = options.iframes;
|
|
6293
|
+
}
|
|
6294
|
+
if (options.domSettleTimeoutMS !== void 0) {
|
|
6295
|
+
args.dom_settle_timeout_ms = options.domSettleTimeoutMS;
|
|
6296
|
+
}
|
|
6297
|
+
const response = await this._callMcpTool("page_use_observe", args);
|
|
6298
|
+
log("Response from CallMcpTool - page_use_observe data:", response.data);
|
|
6299
|
+
if (response.success) {
|
|
6300
|
+
log(`Response from CallMcpTool - page_use_observe:`, response.data);
|
|
6301
|
+
let data;
|
|
6302
|
+
if (typeof response.data === "string") {
|
|
6303
|
+
data = JSON.parse(response.data);
|
|
6304
|
+
} else {
|
|
6305
|
+
throw new BrowserError("Observe response data is not a json!!!");
|
|
6306
|
+
}
|
|
6307
|
+
const success = data.success || false;
|
|
6308
|
+
if (!success) {
|
|
6309
|
+
return [false, []];
|
|
6310
|
+
}
|
|
6311
|
+
const results = [];
|
|
6312
|
+
const observeResults = JSON.parse(data.observe_result || "");
|
|
6313
|
+
log("observeResults =", observeResults);
|
|
6314
|
+
for (const item of observeResults) {
|
|
6315
|
+
const selector = item.selector || "";
|
|
6316
|
+
const description = item.description || "";
|
|
6317
|
+
const method = item.method || "";
|
|
6318
|
+
const itemArgs = item.arguments || {};
|
|
6319
|
+
results.push(new ObserveResult(selector, description, method, itemArgs));
|
|
6320
|
+
}
|
|
6321
|
+
return [success, results];
|
|
6322
|
+
} else {
|
|
6323
|
+
log(`Response from CallMcpTool - page_use_observe:`, response.errorMessage);
|
|
6324
|
+
return [false, []];
|
|
6325
|
+
}
|
|
6326
|
+
} catch (error) {
|
|
6327
|
+
throw new BrowserError(`Failed to get page/context index: ${error}`);
|
|
6328
|
+
}
|
|
6329
|
+
}
|
|
6330
|
+
/**
|
|
6331
|
+
* Async version of observe method.
|
|
6332
|
+
*/
|
|
6333
|
+
async observeAsync(page, options) {
|
|
6334
|
+
return this.observe(page, options);
|
|
6335
|
+
}
|
|
6336
|
+
/**
|
|
6337
|
+
* Extract information from the given Playwright Page object.
|
|
6338
|
+
*/
|
|
6339
|
+
async extract(page, options) {
|
|
6340
|
+
if (!this.browser.isInitialized()) {
|
|
6341
|
+
throw new BrowserError("Browser must be initialized before calling extract.");
|
|
6342
|
+
}
|
|
6343
|
+
try {
|
|
6344
|
+
const [pageIndex, contextIndex] = this._getPageAndContextIndex(page);
|
|
6345
|
+
const tempInstance = new options.schema();
|
|
6346
|
+
const schema = tempInstance.constructor.name;
|
|
6347
|
+
const args = {
|
|
6348
|
+
context_id: contextIndex,
|
|
6349
|
+
page_id: pageIndex,
|
|
6350
|
+
instruction: options.instruction,
|
|
6351
|
+
schema: `schema: ${JSON.stringify(schema)}`
|
|
6352
|
+
// Simplified schema handling
|
|
6353
|
+
};
|
|
6354
|
+
log(`Extracting from page: ${page}, pageIndex: ${pageIndex}, contextIndex: ${contextIndex}, args:`, args);
|
|
6355
|
+
if (options.selector !== void 0) {
|
|
6356
|
+
args.selector = options.selector;
|
|
6357
|
+
}
|
|
6358
|
+
if (options.iframe !== void 0) {
|
|
6359
|
+
args.iframe = options.iframe;
|
|
6360
|
+
}
|
|
6361
|
+
if (options.domSettleTimeoutsMS !== void 0) {
|
|
6362
|
+
args.dom_settle_timeouts_ms = options.domSettleTimeoutsMS;
|
|
6363
|
+
}
|
|
6364
|
+
const response = await this._callMcpTool("page_use_extract", args);
|
|
6365
|
+
log("Response from CallMcpTool - page_use_extract data:", response.data);
|
|
6366
|
+
if (response.success) {
|
|
6367
|
+
log(`Response from CallMcpTool - page_use_extract:`, response.data);
|
|
6368
|
+
let data;
|
|
6369
|
+
if (typeof response.data === "string") {
|
|
6370
|
+
data = JSON.parse(response.data);
|
|
6371
|
+
} else {
|
|
6372
|
+
data = response.data;
|
|
6373
|
+
}
|
|
6374
|
+
log("extract data =", data);
|
|
6375
|
+
const success = data.success || false;
|
|
6376
|
+
const extractObjs = [];
|
|
6377
|
+
if (success) {
|
|
6378
|
+
const extractResults = JSON.parse(data.extract_result || "");
|
|
6379
|
+
for (const extractResult of extractResults) {
|
|
6380
|
+
log("extractResult =", extractResult);
|
|
6381
|
+
const instance = extractResult;
|
|
6382
|
+
extractObjs.push(instance);
|
|
6383
|
+
}
|
|
6384
|
+
} else {
|
|
6385
|
+
const extractResults = data.extract_result || "";
|
|
6386
|
+
log("Extract failed due to:", extractResults);
|
|
6387
|
+
}
|
|
6388
|
+
return [success, extractObjs];
|
|
6389
|
+
} else {
|
|
6390
|
+
log(`Response from CallMcpTool - page_use_extract:`, response.errorMessage);
|
|
6391
|
+
return [false, []];
|
|
6392
|
+
}
|
|
6393
|
+
} catch (error) {
|
|
6394
|
+
throw new BrowserError(`Failed to get page/context index: ${error}`);
|
|
6395
|
+
}
|
|
6396
|
+
}
|
|
6397
|
+
/**
|
|
6398
|
+
* Async version of extract method.
|
|
6399
|
+
*/
|
|
6400
|
+
async extractAsync(page, options) {
|
|
6401
|
+
return this.extract(page, options);
|
|
6402
|
+
}
|
|
6403
|
+
_getPageAndContextIndex(page) {
|
|
6404
|
+
if (!page) {
|
|
6405
|
+
throw new BrowserError("Page is null");
|
|
6406
|
+
}
|
|
6407
|
+
try {
|
|
6408
|
+
const pageIndex = "default-page-id";
|
|
6409
|
+
const contextIndex = 0;
|
|
6410
|
+
return [pageIndex, contextIndex];
|
|
6411
|
+
} catch (error) {
|
|
6412
|
+
throw new BrowserError(`Failed to get page/context index: ${error}`);
|
|
6413
|
+
}
|
|
6414
|
+
}
|
|
6415
|
+
async _getPageAndContextIndexAsync(page) {
|
|
6416
|
+
if (!page) {
|
|
6417
|
+
throw new BrowserError("Page is null");
|
|
6418
|
+
}
|
|
6419
|
+
try {
|
|
6420
|
+
const pageIndex = "default-page-id";
|
|
6421
|
+
const contextIndex = 0;
|
|
6422
|
+
return [pageIndex, contextIndex];
|
|
5852
6423
|
} catch (error) {
|
|
5853
|
-
|
|
5854
|
-
requestId: "",
|
|
5855
|
-
success: false,
|
|
5856
|
-
errorMessage: `Failed to close window: ${error}`
|
|
5857
|
-
};
|
|
6424
|
+
throw new BrowserError(`Failed to get page/context index: ${error}`);
|
|
5858
6425
|
}
|
|
5859
6426
|
}
|
|
6427
|
+
async _callMcpTool(toolName, args) {
|
|
6428
|
+
return this.session.callMcpTool(toolName, args);
|
|
6429
|
+
}
|
|
6430
|
+
};
|
|
6431
|
+
__name(_BrowserAgent, "BrowserAgent");
|
|
6432
|
+
var BrowserAgent = _BrowserAgent;
|
|
6433
|
+
|
|
6434
|
+
// src/browser/browser.ts
|
|
6435
|
+
var _Browser = class _Browser {
|
|
6436
|
+
constructor(session) {
|
|
6437
|
+
this._endpointUrl = null;
|
|
6438
|
+
this._initialized = false;
|
|
6439
|
+
this._option = null;
|
|
6440
|
+
this.session = session;
|
|
6441
|
+
this.agent = new BrowserAgent(this.session, this);
|
|
6442
|
+
}
|
|
5860
6443
|
/**
|
|
5861
|
-
*
|
|
5862
|
-
*
|
|
5863
|
-
*
|
|
5864
|
-
* @param windowId The ID of the window to set to fullscreen.
|
|
5865
|
-
* @returns BoolResult with requestId
|
|
6444
|
+
* Initialize the browser instance with the given options.
|
|
6445
|
+
* Returns true if successful, false otherwise.
|
|
5866
6446
|
*/
|
|
5867
|
-
|
|
6447
|
+
initialize(option) {
|
|
6448
|
+
if (this.isInitialized()) {
|
|
6449
|
+
return true;
|
|
6450
|
+
}
|
|
5868
6451
|
try {
|
|
5869
|
-
const
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
)
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
6452
|
+
const request = new InitBrowserRequest();
|
|
6453
|
+
request.authorization = `Bearer ${this.session.getAPIKey()}`;
|
|
6454
|
+
request.persistentPath = BROWSER_DATA_PATH;
|
|
6455
|
+
request.sessionId = this.session.getSessionId();
|
|
6456
|
+
const response = this.session.getClient().initBrowserSync(request);
|
|
6457
|
+
log(`Response from init_browser data:`, _optionalChain([response, 'access', _30 => _30.body, 'optionalAccess', _31 => _31.data]));
|
|
6458
|
+
const success = _optionalChain([response, 'access', _32 => _32.body, 'optionalAccess', _33 => _33.data, 'optionalAccess', _34 => _34.port]) !== null && _optionalChain([response, 'access', _35 => _35.body, 'optionalAccess', _36 => _36.data, 'optionalAccess', _37 => _37.port]) !== void 0;
|
|
6459
|
+
if (success) {
|
|
6460
|
+
this._initialized = true;
|
|
6461
|
+
this._option = option;
|
|
6462
|
+
log("Browser instance was successfully initialized.");
|
|
6463
|
+
}
|
|
6464
|
+
return success;
|
|
5882
6465
|
} catch (error) {
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
6466
|
+
console.error("Failed to initialize browser instance:", error);
|
|
6467
|
+
this._initialized = false;
|
|
6468
|
+
this._endpointUrl = null;
|
|
6469
|
+
this._option = null;
|
|
6470
|
+
return false;
|
|
5888
6471
|
}
|
|
5889
6472
|
}
|
|
5890
6473
|
/**
|
|
5891
|
-
*
|
|
5892
|
-
*
|
|
5893
|
-
*
|
|
5894
|
-
* @param windowId The ID of the window to resize.
|
|
5895
|
-
* @param width The new width of the window.
|
|
5896
|
-
* @param height The new height of the window.
|
|
5897
|
-
* @returns BoolResult with requestId
|
|
6474
|
+
* Initialize the browser instance with the given options asynchronously.
|
|
6475
|
+
* Returns true if successful, false otherwise.
|
|
5898
6476
|
*/
|
|
5899
|
-
async
|
|
6477
|
+
async initializeAsync(option) {
|
|
6478
|
+
if (this.isInitialized()) {
|
|
6479
|
+
return true;
|
|
6480
|
+
}
|
|
5900
6481
|
try {
|
|
5901
|
-
const
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
data: true
|
|
5915
|
-
};
|
|
6482
|
+
const request = new InitBrowserRequest();
|
|
6483
|
+
request.authorization = `Bearer ${this.session.getAPIKey()}`;
|
|
6484
|
+
request.persistentPath = BROWSER_DATA_PATH;
|
|
6485
|
+
request.sessionId = this.session.getSessionId();
|
|
6486
|
+
const response = await this.session.getClient().initBrowser(request);
|
|
6487
|
+
log(`Response from init_browser data:`, _optionalChain([response, 'access', _38 => _38.body, 'optionalAccess', _39 => _39.data]));
|
|
6488
|
+
const success = _optionalChain([response, 'access', _40 => _40.body, 'optionalAccess', _41 => _41.data, 'optionalAccess', _42 => _42.port]) !== null && _optionalChain([response, 'access', _43 => _43.body, 'optionalAccess', _44 => _44.data, 'optionalAccess', _45 => _45.port]) !== void 0;
|
|
6489
|
+
if (success) {
|
|
6490
|
+
this._initialized = true;
|
|
6491
|
+
this._option = option;
|
|
6492
|
+
log("Browser instance successfully initialized");
|
|
6493
|
+
}
|
|
6494
|
+
return success;
|
|
5916
6495
|
} catch (error) {
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
6496
|
+
console.error("Failed to initialize browser instance:", error);
|
|
6497
|
+
this._initialized = false;
|
|
6498
|
+
this._endpointUrl = null;
|
|
6499
|
+
this._option = null;
|
|
6500
|
+
return false;
|
|
5922
6501
|
}
|
|
5923
6502
|
}
|
|
5924
6503
|
/**
|
|
5925
|
-
*
|
|
5926
|
-
*
|
|
5927
|
-
*
|
|
5928
|
-
* @param on Whether to enable focus mode.
|
|
5929
|
-
* @returns BoolResult with requestId
|
|
6504
|
+
* Returns the endpoint URL if the browser is initialized, otherwise throws an exception.
|
|
6505
|
+
* When initialized, always fetches the latest CDP url from session.getLink().
|
|
5930
6506
|
*/
|
|
5931
|
-
async
|
|
6507
|
+
async getEndpointUrl() {
|
|
6508
|
+
if (!this.isInitialized()) {
|
|
6509
|
+
throw new BrowserError("Browser is not initialized. Cannot access endpoint URL.");
|
|
6510
|
+
}
|
|
5932
6511
|
try {
|
|
5933
|
-
const
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
const result = await this.callMcpTool(
|
|
5937
|
-
"focus_mode",
|
|
5938
|
-
args,
|
|
5939
|
-
"Failed to set focus mode"
|
|
5940
|
-
);
|
|
5941
|
-
return {
|
|
5942
|
-
requestId: result.requestId || "",
|
|
5943
|
-
success: true,
|
|
5944
|
-
data: true
|
|
5945
|
-
};
|
|
6512
|
+
const linkResult = await this.session.getLink();
|
|
6513
|
+
this._endpointUrl = linkResult.data;
|
|
6514
|
+
return this._endpointUrl;
|
|
5946
6515
|
} catch (error) {
|
|
5947
|
-
|
|
5948
|
-
requestId: "",
|
|
5949
|
-
success: false,
|
|
5950
|
-
errorMessage: `Failed to toggle focus mode: ${error}`
|
|
5951
|
-
};
|
|
6516
|
+
throw new BrowserError(`Failed to get endpoint URL from session: ${error}`);
|
|
5952
6517
|
}
|
|
5953
6518
|
}
|
|
6519
|
+
/**
|
|
6520
|
+
* Returns the current BrowserOption used to initialize the browser, or null if not set.
|
|
6521
|
+
*/
|
|
6522
|
+
getOption() {
|
|
6523
|
+
return this._option;
|
|
6524
|
+
}
|
|
6525
|
+
/**
|
|
6526
|
+
* Returns true if the browser was initialized, false otherwise.
|
|
6527
|
+
*/
|
|
6528
|
+
isInitialized() {
|
|
6529
|
+
return this._initialized;
|
|
6530
|
+
}
|
|
5954
6531
|
};
|
|
5955
|
-
__name(
|
|
5956
|
-
var
|
|
6532
|
+
__name(_Browser, "Browser");
|
|
6533
|
+
var Browser = _Browser;
|
|
5957
6534
|
|
|
5958
6535
|
// src/session.ts
|
|
5959
6536
|
var _SessionInfoClass = class _SessionInfoClass {
|
|
@@ -5979,15 +6556,26 @@ var _Session = class _Session {
|
|
|
5979
6556
|
*/
|
|
5980
6557
|
constructor(agentBay, sessionId) {
|
|
5981
6558
|
this.resourceUrl = "";
|
|
6559
|
+
// VPC-related information
|
|
6560
|
+
this.isVpc = false;
|
|
6561
|
+
// Whether this session uses VPC resources
|
|
6562
|
+
this.networkInterfaceIp = "";
|
|
6563
|
+
// Network interface IP for VPC sessions
|
|
6564
|
+
this.httpPort = "";
|
|
6565
|
+
// MCP tools available for this session
|
|
6566
|
+
this.mcpTools = [];
|
|
5982
6567
|
this.agentBay = agentBay;
|
|
5983
6568
|
this.sessionId = sessionId;
|
|
5984
6569
|
this.resourceUrl = "";
|
|
5985
6570
|
this.fileSystem = new FileSystem(this);
|
|
5986
6571
|
this.command = new Command(this);
|
|
6572
|
+
this.code = new Code(this);
|
|
5987
6573
|
this.oss = new Oss(this);
|
|
5988
6574
|
this.application = new Application(this);
|
|
5989
6575
|
this.window = new WindowManager(this);
|
|
5990
6576
|
this.ui = new UI(this);
|
|
6577
|
+
this.agent = new Agent(this);
|
|
6578
|
+
this.browser = new Browser(this);
|
|
5991
6579
|
this.context = newContextManager(this);
|
|
5992
6580
|
}
|
|
5993
6581
|
/**
|
|
@@ -6008,6 +6596,35 @@ var _Session = class _Session {
|
|
|
6008
6596
|
getSessionId() {
|
|
6009
6597
|
return this.sessionId;
|
|
6010
6598
|
}
|
|
6599
|
+
/**
|
|
6600
|
+
* Return whether this session uses VPC resources.
|
|
6601
|
+
*/
|
|
6602
|
+
isVpcEnabled() {
|
|
6603
|
+
return this.isVpc;
|
|
6604
|
+
}
|
|
6605
|
+
/**
|
|
6606
|
+
* Return the network interface IP for VPC sessions.
|
|
6607
|
+
*/
|
|
6608
|
+
getNetworkInterfaceIp() {
|
|
6609
|
+
return this.networkInterfaceIp;
|
|
6610
|
+
}
|
|
6611
|
+
/**
|
|
6612
|
+
* Return the HTTP port for VPC sessions.
|
|
6613
|
+
*/
|
|
6614
|
+
getHttpPort() {
|
|
6615
|
+
return this.httpPort;
|
|
6616
|
+
}
|
|
6617
|
+
/**
|
|
6618
|
+
* Find the server that provides the given tool.
|
|
6619
|
+
*/
|
|
6620
|
+
findServerForTool(toolName) {
|
|
6621
|
+
for (const tool of this.mcpTools) {
|
|
6622
|
+
if (tool.name === toolName) {
|
|
6623
|
+
return tool.server;
|
|
6624
|
+
}
|
|
6625
|
+
}
|
|
6626
|
+
return "";
|
|
6627
|
+
}
|
|
6011
6628
|
/**
|
|
6012
6629
|
* Delete this session.
|
|
6013
6630
|
*
|
|
@@ -6075,7 +6692,7 @@ var _Session = class _Session {
|
|
|
6075
6692
|
log(`Response from release_mcp_session: ${JSON.stringify(response)}`);
|
|
6076
6693
|
const requestId = extractRequestId(response) || "";
|
|
6077
6694
|
const responseBody = response.body;
|
|
6078
|
-
const success = _optionalChain([responseBody, 'optionalAccess',
|
|
6695
|
+
const success = _optionalChain([responseBody, 'optionalAccess', _46 => _46.success]) !== false;
|
|
6079
6696
|
if (!success) {
|
|
6080
6697
|
return {
|
|
6081
6698
|
requestId,
|
|
@@ -6096,6 +6713,59 @@ var _Session = class _Session {
|
|
|
6096
6713
|
};
|
|
6097
6714
|
}
|
|
6098
6715
|
}
|
|
6716
|
+
/**
|
|
6717
|
+
* Validates labels parameter for label operations.
|
|
6718
|
+
*
|
|
6719
|
+
* @param labels - The labels to validate
|
|
6720
|
+
* @returns null if validation passes, or OperationResult with error if validation fails
|
|
6721
|
+
*/
|
|
6722
|
+
validateLabels(labels) {
|
|
6723
|
+
if (!labels || typeof labels !== "object") {
|
|
6724
|
+
return {
|
|
6725
|
+
requestId: "",
|
|
6726
|
+
success: false,
|
|
6727
|
+
errorMessage: "Labels cannot be null, undefined, or invalid type. Please provide a valid labels object."
|
|
6728
|
+
};
|
|
6729
|
+
}
|
|
6730
|
+
if (Array.isArray(labels)) {
|
|
6731
|
+
return {
|
|
6732
|
+
requestId: "",
|
|
6733
|
+
success: false,
|
|
6734
|
+
errorMessage: "Labels cannot be an array. Please provide a valid labels object."
|
|
6735
|
+
};
|
|
6736
|
+
}
|
|
6737
|
+
if (labels instanceof Date || labels instanceof RegExp || labels instanceof Error || labels instanceof Map || labels instanceof Set || labels instanceof WeakMap || labels instanceof WeakSet || labels instanceof Promise) {
|
|
6738
|
+
return {
|
|
6739
|
+
requestId: "",
|
|
6740
|
+
success: false,
|
|
6741
|
+
errorMessage: "Labels must be a plain object. Built-in object types are not allowed."
|
|
6742
|
+
};
|
|
6743
|
+
}
|
|
6744
|
+
if (Object.keys(labels).length === 0) {
|
|
6745
|
+
return {
|
|
6746
|
+
requestId: "",
|
|
6747
|
+
success: false,
|
|
6748
|
+
errorMessage: "Labels cannot be empty. Please provide at least one label."
|
|
6749
|
+
};
|
|
6750
|
+
}
|
|
6751
|
+
for (const [key, value] of Object.entries(labels)) {
|
|
6752
|
+
if (!key || key.trim() === "") {
|
|
6753
|
+
return {
|
|
6754
|
+
requestId: "",
|
|
6755
|
+
success: false,
|
|
6756
|
+
errorMessage: "Label keys cannot be empty Please provide valid keys."
|
|
6757
|
+
};
|
|
6758
|
+
}
|
|
6759
|
+
if (!value || value.trim() === "") {
|
|
6760
|
+
return {
|
|
6761
|
+
requestId: "",
|
|
6762
|
+
success: false,
|
|
6763
|
+
errorMessage: "Label values cannot be empty Please provide valid values."
|
|
6764
|
+
};
|
|
6765
|
+
}
|
|
6766
|
+
}
|
|
6767
|
+
return null;
|
|
6768
|
+
}
|
|
6099
6769
|
/**
|
|
6100
6770
|
* Sets the labels for this session.
|
|
6101
6771
|
*
|
|
@@ -6105,6 +6775,10 @@ var _Session = class _Session {
|
|
|
6105
6775
|
*/
|
|
6106
6776
|
async setLabels(labels) {
|
|
6107
6777
|
try {
|
|
6778
|
+
const validationResult = this.validateLabels(labels);
|
|
6779
|
+
if (validationResult !== null) {
|
|
6780
|
+
return validationResult;
|
|
6781
|
+
}
|
|
6108
6782
|
const labelsJSON = JSON.stringify(labels);
|
|
6109
6783
|
const request = new SetLabelRequest({
|
|
6110
6784
|
authorization: `Bearer ${this.getAPIKey()}`,
|
|
@@ -6138,9 +6812,9 @@ var _Session = class _Session {
|
|
|
6138
6812
|
});
|
|
6139
6813
|
const response = await this.getClient().getLabel(request);
|
|
6140
6814
|
const requestId = extractRequestId(response) || "";
|
|
6141
|
-
const responseBody = _optionalChain([response, 'optionalAccess',
|
|
6142
|
-
const data = _optionalChain([responseBody, 'optionalAccess',
|
|
6143
|
-
const labelsJSON = _optionalChain([data, 'optionalAccess',
|
|
6815
|
+
const responseBody = _optionalChain([response, 'optionalAccess', _47 => _47.body]);
|
|
6816
|
+
const data = _optionalChain([responseBody, 'optionalAccess', _48 => _48.data]);
|
|
6817
|
+
const labelsJSON = _optionalChain([data, 'optionalAccess', _49 => _49.labels]);
|
|
6144
6818
|
let labels = {};
|
|
6145
6819
|
if (labelsJSON) {
|
|
6146
6820
|
labels = JSON.parse(labelsJSON);
|
|
@@ -6175,16 +6849,16 @@ var _Session = class _Session {
|
|
|
6175
6849
|
log(`Response from GetMcpResource: ${JSON.stringify(response)}`);
|
|
6176
6850
|
const requestId = extractRequestId(response) || "";
|
|
6177
6851
|
const responseBody = response.body;
|
|
6178
|
-
const data = _optionalChain([responseBody, 'optionalAccess',
|
|
6852
|
+
const data = _optionalChain([responseBody, 'optionalAccess', _50 => _50.data]);
|
|
6179
6853
|
const sessionInfo = new SessionInfoClass();
|
|
6180
|
-
if (_optionalChain([data, 'optionalAccess',
|
|
6854
|
+
if (_optionalChain([data, 'optionalAccess', _51 => _51.sessionId])) {
|
|
6181
6855
|
sessionInfo.sessionId = data.sessionId;
|
|
6182
6856
|
}
|
|
6183
|
-
if (_optionalChain([data, 'optionalAccess',
|
|
6857
|
+
if (_optionalChain([data, 'optionalAccess', _52 => _52.resourceUrl])) {
|
|
6184
6858
|
sessionInfo.resourceUrl = data.resourceUrl;
|
|
6185
6859
|
this.resourceUrl = data.resourceUrl;
|
|
6186
6860
|
}
|
|
6187
|
-
if (_optionalChain([data, 'optionalAccess',
|
|
6861
|
+
if (_optionalChain([data, 'optionalAccess', _53 => _53.desktopInfo])) {
|
|
6188
6862
|
const desktopInfo = data.desktopInfo;
|
|
6189
6863
|
if (desktopInfo.appId) {
|
|
6190
6864
|
sessionInfo.appId = desktopInfo.appId;
|
|
@@ -6250,7 +6924,7 @@ var _Session = class _Session {
|
|
|
6250
6924
|
data = {};
|
|
6251
6925
|
}
|
|
6252
6926
|
}
|
|
6253
|
-
const url = data.Url ||
|
|
6927
|
+
const url = data.Url || data.url;
|
|
6254
6928
|
return {
|
|
6255
6929
|
requestId,
|
|
6256
6930
|
success: true,
|
|
@@ -6281,13 +6955,13 @@ var _Session = class _Session {
|
|
|
6281
6955
|
});
|
|
6282
6956
|
const response = await this.agentBay.getClient().getLink(request);
|
|
6283
6957
|
const requestId = extractRequestId(response) || "";
|
|
6284
|
-
const responseBody = _optionalChain([response, 'optionalAccess',
|
|
6958
|
+
const responseBody = _optionalChain([response, 'optionalAccess', _54 => _54.body]);
|
|
6285
6959
|
if (typeof responseBody !== "object") {
|
|
6286
6960
|
throw new Error(
|
|
6287
6961
|
"Invalid response format: expected a dictionary from response body"
|
|
6288
6962
|
);
|
|
6289
6963
|
}
|
|
6290
|
-
let data = _optionalChain([responseBody, 'optionalAccess',
|
|
6964
|
+
let data = _optionalChain([responseBody, 'optionalAccess', _55 => _55.data]) || {};
|
|
6291
6965
|
log(`Data: ${JSON.stringify(data)}`);
|
|
6292
6966
|
if (typeof data !== "object") {
|
|
6293
6967
|
try {
|
|
@@ -6296,7 +6970,7 @@ var _Session = class _Session {
|
|
|
6296
6970
|
data = {};
|
|
6297
6971
|
}
|
|
6298
6972
|
}
|
|
6299
|
-
const url = data.Url ||
|
|
6973
|
+
const url = data.Url || data.url;
|
|
6300
6974
|
return {
|
|
6301
6975
|
requestId,
|
|
6302
6976
|
success: true,
|
|
@@ -6309,6 +6983,176 @@ var _Session = class _Session {
|
|
|
6309
6983
|
throw new Error(`Failed to get link asynchronously: ${error}`);
|
|
6310
6984
|
}
|
|
6311
6985
|
}
|
|
6986
|
+
/**
|
|
6987
|
+
* List MCP tools available for this session.
|
|
6988
|
+
*
|
|
6989
|
+
* @param imageId Optional image ID, defaults to session's imageId or "linux_latest"
|
|
6990
|
+
* @returns McpToolsResult containing tools list and request ID
|
|
6991
|
+
*/
|
|
6992
|
+
async listMcpTools(imageId) {
|
|
6993
|
+
if (!imageId) {
|
|
6994
|
+
imageId = this.imageId || "linux_latest";
|
|
6995
|
+
}
|
|
6996
|
+
const request = new ListMcpToolsRequest({
|
|
6997
|
+
authorization: `Bearer ${this.getAPIKey()}`,
|
|
6998
|
+
imageId
|
|
6999
|
+
});
|
|
7000
|
+
log("API Call: ListMcpTools");
|
|
7001
|
+
log(`Request: ImageId=${imageId}`);
|
|
7002
|
+
const response = await this.getClient().listMcpTools(request);
|
|
7003
|
+
const requestId = extractRequestId(response) || "";
|
|
7004
|
+
if (response && response.body) {
|
|
7005
|
+
log("Response from ListMcpTools:", response.body);
|
|
7006
|
+
}
|
|
7007
|
+
const tools = [];
|
|
7008
|
+
if (response && response.body && response.body.data) {
|
|
7009
|
+
try {
|
|
7010
|
+
const toolsData = JSON.parse(response.body.data);
|
|
7011
|
+
for (const toolData of toolsData) {
|
|
7012
|
+
const tool = {
|
|
7013
|
+
name: toolData.name || "",
|
|
7014
|
+
description: toolData.description || "",
|
|
7015
|
+
inputSchema: toolData.inputSchema || {},
|
|
7016
|
+
server: toolData.server || "",
|
|
7017
|
+
tool: toolData.tool || ""
|
|
7018
|
+
};
|
|
7019
|
+
tools.push(tool);
|
|
7020
|
+
}
|
|
7021
|
+
} catch (error) {
|
|
7022
|
+
logError(`Error unmarshaling tools data: ${error}`);
|
|
7023
|
+
}
|
|
7024
|
+
}
|
|
7025
|
+
this.mcpTools = tools;
|
|
7026
|
+
return {
|
|
7027
|
+
requestId,
|
|
7028
|
+
success: true,
|
|
7029
|
+
tools
|
|
7030
|
+
};
|
|
7031
|
+
}
|
|
7032
|
+
/**
|
|
7033
|
+
* Call an MCP tool and return the result in a format compatible with Agent.
|
|
7034
|
+
*
|
|
7035
|
+
* @param toolName - Name of the MCP tool to call
|
|
7036
|
+
* @param args - Arguments to pass to the tool
|
|
7037
|
+
* @returns McpToolResult containing the response data
|
|
7038
|
+
*/
|
|
7039
|
+
async callMcpTool(toolName, args) {
|
|
7040
|
+
try {
|
|
7041
|
+
const argsJSON = JSON.stringify(args);
|
|
7042
|
+
if (this.isVpcEnabled()) {
|
|
7043
|
+
const server = this.findServerForTool(toolName);
|
|
7044
|
+
if (!server) {
|
|
7045
|
+
return {
|
|
7046
|
+
success: false,
|
|
7047
|
+
data: "",
|
|
7048
|
+
errorMessage: `Server not found for tool: ${toolName}`,
|
|
7049
|
+
requestId: ""
|
|
7050
|
+
};
|
|
7051
|
+
}
|
|
7052
|
+
if (!this.networkInterfaceIp || !this.httpPort) {
|
|
7053
|
+
return {
|
|
7054
|
+
success: false,
|
|
7055
|
+
data: "",
|
|
7056
|
+
errorMessage: `VPC network configuration incomplete: networkInterfaceIp=${this.networkInterfaceIp}, httpPort=${this.httpPort}. This may indicate the VPC session was not properly configured with network parameters.`,
|
|
7057
|
+
requestId: ""
|
|
7058
|
+
};
|
|
7059
|
+
}
|
|
7060
|
+
const baseURL = `http://${this.networkInterfaceIp}:${this.httpPort}/callTool`;
|
|
7061
|
+
const url = new URL(baseURL);
|
|
7062
|
+
url.searchParams.append("server", server);
|
|
7063
|
+
url.searchParams.append("tool", toolName);
|
|
7064
|
+
url.searchParams.append("args", argsJSON);
|
|
7065
|
+
url.searchParams.append("apiKey", this.getAPIKey());
|
|
7066
|
+
const requestId = `vpc-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
7067
|
+
url.searchParams.append("requestId", requestId);
|
|
7068
|
+
const response = await fetch(url.toString(), {
|
|
7069
|
+
method: "GET",
|
|
7070
|
+
headers: {
|
|
7071
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
7072
|
+
}
|
|
7073
|
+
});
|
|
7074
|
+
if (!response.ok) {
|
|
7075
|
+
return {
|
|
7076
|
+
success: false,
|
|
7077
|
+
data: "",
|
|
7078
|
+
errorMessage: `VPC request failed: ${response.statusText}`,
|
|
7079
|
+
requestId: ""
|
|
7080
|
+
};
|
|
7081
|
+
}
|
|
7082
|
+
const responseData = await response.json();
|
|
7083
|
+
let actualResult = responseData;
|
|
7084
|
+
if (typeof responseData.data === "string") {
|
|
7085
|
+
try {
|
|
7086
|
+
const dataMap = JSON.parse(responseData.data);
|
|
7087
|
+
if (dataMap.result) {
|
|
7088
|
+
actualResult = dataMap.result;
|
|
7089
|
+
}
|
|
7090
|
+
} catch (err) {
|
|
7091
|
+
}
|
|
7092
|
+
} else if (responseData.data && responseData.data.result) {
|
|
7093
|
+
actualResult = responseData.data.result;
|
|
7094
|
+
}
|
|
7095
|
+
let textContent = "";
|
|
7096
|
+
if (actualResult.content && Array.isArray(actualResult.content) && actualResult.content.length > 0) {
|
|
7097
|
+
const contentItem = actualResult.content[0];
|
|
7098
|
+
if (contentItem && contentItem.text) {
|
|
7099
|
+
textContent = contentItem.text;
|
|
7100
|
+
}
|
|
7101
|
+
}
|
|
7102
|
+
return {
|
|
7103
|
+
success: true,
|
|
7104
|
+
data: textContent || JSON.stringify(actualResult),
|
|
7105
|
+
errorMessage: "",
|
|
7106
|
+
requestId: ""
|
|
7107
|
+
};
|
|
7108
|
+
} else {
|
|
7109
|
+
const callToolRequest = new CallMcpToolRequest({
|
|
7110
|
+
authorization: `Bearer ${this.getAPIKey()}`,
|
|
7111
|
+
sessionId: this.getSessionId(),
|
|
7112
|
+
name: toolName,
|
|
7113
|
+
args: argsJSON
|
|
7114
|
+
});
|
|
7115
|
+
const response = await this.getClient().callMcpTool(callToolRequest);
|
|
7116
|
+
if (!_optionalChain([response, 'access', _56 => _56.body, 'optionalAccess', _57 => _57.data])) {
|
|
7117
|
+
return {
|
|
7118
|
+
success: false,
|
|
7119
|
+
data: "",
|
|
7120
|
+
errorMessage: "Invalid response data format",
|
|
7121
|
+
requestId: extractRequestId(response) || ""
|
|
7122
|
+
};
|
|
7123
|
+
}
|
|
7124
|
+
const data = response.body.data;
|
|
7125
|
+
if (data.isError) {
|
|
7126
|
+
const errorContent = data.content || [];
|
|
7127
|
+
const errorMessage = errorContent.map((item) => item.text || "Unknown error").join("; ");
|
|
7128
|
+
return {
|
|
7129
|
+
success: false,
|
|
7130
|
+
data: "",
|
|
7131
|
+
errorMessage,
|
|
7132
|
+
requestId: extractRequestId(response) || ""
|
|
7133
|
+
};
|
|
7134
|
+
}
|
|
7135
|
+
const content = data.content || [];
|
|
7136
|
+
let textContent = "";
|
|
7137
|
+
if (content.length > 0 && content[0].text !== void 0) {
|
|
7138
|
+
textContent = content[0].text;
|
|
7139
|
+
}
|
|
7140
|
+
return {
|
|
7141
|
+
success: true,
|
|
7142
|
+
data: textContent,
|
|
7143
|
+
errorMessage: "",
|
|
7144
|
+
requestId: extractRequestId(response) || ""
|
|
7145
|
+
};
|
|
7146
|
+
}
|
|
7147
|
+
} catch (error) {
|
|
7148
|
+
return {
|
|
7149
|
+
success: false,
|
|
7150
|
+
data: "",
|
|
7151
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
7152
|
+
requestId: ""
|
|
7153
|
+
};
|
|
7154
|
+
}
|
|
7155
|
+
}
|
|
6312
7156
|
};
|
|
6313
7157
|
__name(_Session, "Session");
|
|
6314
7158
|
var Session = _Session;
|
|
@@ -6353,11 +7197,8 @@ var _AgentBay = class _AgentBay {
|
|
|
6353
7197
|
* @param params - Optional parameters for creating the session
|
|
6354
7198
|
* @returns SessionResult containing the created session and request ID
|
|
6355
7199
|
*/
|
|
6356
|
-
async create(params) {
|
|
7200
|
+
async create(params = {}) {
|
|
6357
7201
|
try {
|
|
6358
|
-
if (!params) {
|
|
6359
|
-
params = {};
|
|
6360
|
-
}
|
|
6361
7202
|
const request = new CreateMcpSessionRequest({
|
|
6362
7203
|
authorization: "Bearer " + this.apiKey
|
|
6363
7204
|
});
|
|
@@ -6370,6 +7211,7 @@ var _AgentBay = class _AgentBay {
|
|
|
6370
7211
|
if (params.imageId) {
|
|
6371
7212
|
request.imageId = params.imageId;
|
|
6372
7213
|
}
|
|
7214
|
+
request.vpcResource = params.isVpc || false;
|
|
6373
7215
|
let hasPersistenceData = false;
|
|
6374
7216
|
if (params.contextSync && params.contextSync.length > 0) {
|
|
6375
7217
|
const persistenceDataList = [];
|
|
@@ -6386,6 +7228,25 @@ var _AgentBay = class _AgentBay {
|
|
|
6386
7228
|
request.persistenceDataList = persistenceDataList;
|
|
6387
7229
|
hasPersistenceData = persistenceDataList.length > 0;
|
|
6388
7230
|
}
|
|
7231
|
+
if (params.browserContext) {
|
|
7232
|
+
const syncPolicy = {
|
|
7233
|
+
uploadPolicy: { autoUpload: params.browserContext.autoUpload },
|
|
7234
|
+
downloadPolicy: null,
|
|
7235
|
+
deletePolicy: null,
|
|
7236
|
+
bwList: null
|
|
7237
|
+
};
|
|
7238
|
+
const browserContextSync = new CreateMcpSessionRequestPersistenceDataList({
|
|
7239
|
+
contextId: params.browserContext.contextId,
|
|
7240
|
+
path: BROWSER_DATA_PATH,
|
|
7241
|
+
// Using a constant path for browser data
|
|
7242
|
+
policy: JSON.stringify(syncPolicy)
|
|
7243
|
+
});
|
|
7244
|
+
if (!request.persistenceDataList) {
|
|
7245
|
+
request.persistenceDataList = [];
|
|
7246
|
+
}
|
|
7247
|
+
request.persistenceDataList.push(browserContextSync);
|
|
7248
|
+
hasPersistenceData = true;
|
|
7249
|
+
}
|
|
6389
7250
|
log("API Call: CreateMcpSession");
|
|
6390
7251
|
let requestLog = "Request: ";
|
|
6391
7252
|
if (request.contextId) {
|
|
@@ -6409,7 +7270,7 @@ var _AgentBay = class _AgentBay {
|
|
|
6409
7270
|
}
|
|
6410
7271
|
log(requestLog);
|
|
6411
7272
|
const response = await this.client.createMcpSession(request);
|
|
6412
|
-
log("response =", response);
|
|
7273
|
+
log("response data =", _optionalChain([response, 'access', _58 => _58.body, 'optionalAccess', _59 => _59.data]));
|
|
6413
7274
|
const requestId = extractRequestId(response) || "";
|
|
6414
7275
|
const sessionData = response.body;
|
|
6415
7276
|
if (!sessionData || typeof sessionData !== "object") {
|
|
@@ -6442,7 +7303,24 @@ var _AgentBay = class _AgentBay {
|
|
|
6442
7303
|
if (resourceUrl) {
|
|
6443
7304
|
session.resourceUrl = resourceUrl;
|
|
6444
7305
|
}
|
|
7306
|
+
session.isVpc = params.isVpc || false;
|
|
7307
|
+
if (data.networkInterfaceIp) {
|
|
7308
|
+
session.networkInterfaceIp = data.networkInterfaceIp;
|
|
7309
|
+
}
|
|
7310
|
+
if (data.httpPort) {
|
|
7311
|
+
session.httpPort = data.httpPort;
|
|
7312
|
+
}
|
|
7313
|
+
session.imageId = params.imageId;
|
|
6445
7314
|
this.sessions.set(session.sessionId, session);
|
|
7315
|
+
if (params.isVpc) {
|
|
7316
|
+
log("VPC session detected, automatically fetching MCP tools...");
|
|
7317
|
+
try {
|
|
7318
|
+
const toolsResult = await session.listMcpTools();
|
|
7319
|
+
log(`Successfully fetched ${toolsResult.tools.length} MCP tools for VPC session (RequestID: ${toolsResult.requestId})`);
|
|
7320
|
+
} catch (error) {
|
|
7321
|
+
logError(`Warning: Failed to fetch MCP tools for VPC session: ${error}`);
|
|
7322
|
+
}
|
|
7323
|
+
}
|
|
6446
7324
|
if (hasPersistenceData) {
|
|
6447
7325
|
log("Waiting for context synchronization to complete...");
|
|
6448
7326
|
const maxRetries = 150;
|
|
@@ -6531,8 +7409,8 @@ var _AgentBay = class _AgentBay {
|
|
|
6531
7409
|
);
|
|
6532
7410
|
const response = await this.client.listSession(listSessionRequest);
|
|
6533
7411
|
const body = response.body;
|
|
6534
|
-
const requestId = extractRequestId(_optionalChain([body, 'optionalAccess',
|
|
6535
|
-
if (_optionalChain([body, 'optionalAccess',
|
|
7412
|
+
const requestId = extractRequestId(_optionalChain([body, 'optionalAccess', _60 => _60.requestId])) || "";
|
|
7413
|
+
if (_optionalChain([body, 'optionalAccess', _61 => _61.data]) && typeof body.data === "object" && body.success && body.success !== true) {
|
|
6536
7414
|
return {
|
|
6537
7415
|
requestId,
|
|
6538
7416
|
success: false,
|
|
@@ -6553,7 +7431,7 @@ var _AgentBay = class _AgentBay {
|
|
|
6553
7431
|
maxResults = parseInt(String(body.maxResults || 0)) || maxResults;
|
|
6554
7432
|
totalCount = parseInt(String(body.totalCount || 0));
|
|
6555
7433
|
}
|
|
6556
|
-
const responseData = _optionalChain([body, 'optionalAccess',
|
|
7434
|
+
const responseData = _optionalChain([body, 'optionalAccess', _62 => _62.data]);
|
|
6557
7435
|
if (Array.isArray(responseData)) {
|
|
6558
7436
|
for (const sessionData of responseData) {
|
|
6559
7437
|
if (sessionData && typeof sessionData === "object") {
|
|
@@ -6626,6 +7504,9 @@ var _AgentBay = class _AgentBay {
|
|
|
6626
7504
|
__name(_AgentBay, "AgentBay");
|
|
6627
7505
|
var AgentBay = _AgentBay;
|
|
6628
7506
|
|
|
7507
|
+
// src/agent/index.ts
|
|
7508
|
+
init_cjs_shims();
|
|
7509
|
+
|
|
6629
7510
|
// src/context-sync.ts
|
|
6630
7511
|
init_cjs_shims();
|
|
6631
7512
|
var UploadStrategy = /* @__PURE__ */ ((UploadStrategy2) => {
|
|
@@ -6636,6 +7517,49 @@ var DownloadStrategy = /* @__PURE__ */ ((DownloadStrategy2) => {
|
|
|
6636
7517
|
DownloadStrategy2["DownloadAsync"] = "DownloadAsync";
|
|
6637
7518
|
return DownloadStrategy2;
|
|
6638
7519
|
})(DownloadStrategy || {});
|
|
7520
|
+
var _SyncPolicyImpl = class _SyncPolicyImpl {
|
|
7521
|
+
constructor(policy) {
|
|
7522
|
+
if (policy) {
|
|
7523
|
+
this.uploadPolicy = policy.uploadPolicy;
|
|
7524
|
+
this.downloadPolicy = policy.downloadPolicy;
|
|
7525
|
+
this.deletePolicy = policy.deletePolicy;
|
|
7526
|
+
this.bwList = policy.bwList;
|
|
7527
|
+
}
|
|
7528
|
+
this.ensureDefaults();
|
|
7529
|
+
}
|
|
7530
|
+
ensureDefaults() {
|
|
7531
|
+
if (!this.uploadPolicy) {
|
|
7532
|
+
this.uploadPolicy = newUploadPolicy();
|
|
7533
|
+
}
|
|
7534
|
+
if (!this.downloadPolicy) {
|
|
7535
|
+
this.downloadPolicy = newDownloadPolicy();
|
|
7536
|
+
}
|
|
7537
|
+
if (!this.deletePolicy) {
|
|
7538
|
+
this.deletePolicy = newDeletePolicy();
|
|
7539
|
+
}
|
|
7540
|
+
if (!this.bwList) {
|
|
7541
|
+
this.bwList = {
|
|
7542
|
+
whiteLists: [
|
|
7543
|
+
{
|
|
7544
|
+
path: "",
|
|
7545
|
+
excludePaths: []
|
|
7546
|
+
}
|
|
7547
|
+
]
|
|
7548
|
+
};
|
|
7549
|
+
}
|
|
7550
|
+
}
|
|
7551
|
+
toJSON() {
|
|
7552
|
+
this.ensureDefaults();
|
|
7553
|
+
return {
|
|
7554
|
+
uploadPolicy: this.uploadPolicy,
|
|
7555
|
+
downloadPolicy: this.downloadPolicy,
|
|
7556
|
+
deletePolicy: this.deletePolicy,
|
|
7557
|
+
bwList: this.bwList
|
|
7558
|
+
};
|
|
7559
|
+
}
|
|
7560
|
+
};
|
|
7561
|
+
__name(_SyncPolicyImpl, "SyncPolicyImpl");
|
|
7562
|
+
var SyncPolicyImpl = _SyncPolicyImpl;
|
|
6639
7563
|
var _ContextSync = class _ContextSync {
|
|
6640
7564
|
constructor(contextId, path2, policy) {
|
|
6641
7565
|
this.contextId = contextId;
|
|
@@ -6688,6 +7612,10 @@ function newSyncPolicy() {
|
|
|
6688
7612
|
};
|
|
6689
7613
|
}
|
|
6690
7614
|
__name(newSyncPolicy, "newSyncPolicy");
|
|
7615
|
+
function newSyncPolicyWithDefaults(policy) {
|
|
7616
|
+
return new SyncPolicyImpl(policy).toJSON();
|
|
7617
|
+
}
|
|
7618
|
+
__name(newSyncPolicyWithDefaults, "newSyncPolicyWithDefaults");
|
|
6691
7619
|
function newContextSync(contextId, path2, policy) {
|
|
6692
7620
|
return new ContextSync(contextId, path2, policy);
|
|
6693
7621
|
}
|
|
@@ -6699,6 +7627,7 @@ var _CreateSessionParams = class _CreateSessionParams {
|
|
|
6699
7627
|
constructor() {
|
|
6700
7628
|
this.labels = {};
|
|
6701
7629
|
this.contextSync = [];
|
|
7630
|
+
this.isVpc = false;
|
|
6702
7631
|
}
|
|
6703
7632
|
/**
|
|
6704
7633
|
* WithLabels sets the labels for the session parameters and returns the updated parameters.
|
|
@@ -6721,6 +7650,20 @@ var _CreateSessionParams = class _CreateSessionParams {
|
|
|
6721
7650
|
this.imageId = imageId;
|
|
6722
7651
|
return this;
|
|
6723
7652
|
}
|
|
7653
|
+
/**
|
|
7654
|
+
* WithBrowserContext sets the browser context for the session parameters and returns the updated parameters.
|
|
7655
|
+
*/
|
|
7656
|
+
withBrowserContext(browserContext) {
|
|
7657
|
+
this.browserContext = browserContext;
|
|
7658
|
+
return this;
|
|
7659
|
+
}
|
|
7660
|
+
/**
|
|
7661
|
+
* WithIsVpc sets the VPC flag for the session parameters and returns the updated parameters.
|
|
7662
|
+
*/
|
|
7663
|
+
withIsVpc(isVpc) {
|
|
7664
|
+
this.isVpc = isVpc;
|
|
7665
|
+
return this;
|
|
7666
|
+
}
|
|
6724
7667
|
/**
|
|
6725
7668
|
* GetLabelsJSON returns the labels as a JSON string.
|
|
6726
7669
|
* Returns an object with success status and result/error message to match Go version behavior.
|
|
@@ -6769,7 +7712,9 @@ var _CreateSessionParams = class _CreateSessionParams {
|
|
|
6769
7712
|
labels: this.labels,
|
|
6770
7713
|
contextId: this.contextId,
|
|
6771
7714
|
imageId: this.imageId,
|
|
6772
|
-
contextSync: this.contextSync
|
|
7715
|
+
contextSync: this.contextSync,
|
|
7716
|
+
browserContext: this.browserContext,
|
|
7717
|
+
isVpc: this.isVpc
|
|
6773
7718
|
};
|
|
6774
7719
|
}
|
|
6775
7720
|
/**
|
|
@@ -6781,6 +7726,8 @@ var _CreateSessionParams = class _CreateSessionParams {
|
|
|
6781
7726
|
params.contextId = config.contextId;
|
|
6782
7727
|
params.imageId = config.imageId;
|
|
6783
7728
|
params.contextSync = config.contextSync || [];
|
|
7729
|
+
params.browserContext = config.browserContext;
|
|
7730
|
+
params.isVpc = config.isVpc || false;
|
|
6784
7731
|
return params;
|
|
6785
7732
|
}
|
|
6786
7733
|
};
|
|
@@ -6885,5 +7832,17 @@ __name(newCreateSessionParams, "newCreateSessionParams");
|
|
|
6885
7832
|
|
|
6886
7833
|
|
|
6887
7834
|
|
|
6888
|
-
|
|
7835
|
+
|
|
7836
|
+
|
|
7837
|
+
|
|
7838
|
+
|
|
7839
|
+
|
|
7840
|
+
|
|
7841
|
+
|
|
7842
|
+
|
|
7843
|
+
|
|
7844
|
+
|
|
7845
|
+
|
|
7846
|
+
|
|
7847
|
+
exports.APIError = APIError; exports.ActResult = ActResult; exports.Agent = Agent; exports.AgentBay = AgentBay; exports.AgentBayError = AgentBayError; exports.Application = Application; exports.ApplicationError = ApplicationError; exports.ApplyMqttTokenRequest = ApplyMqttTokenRequest; exports.ApplyMqttTokenResponse = ApplyMqttTokenResponse; exports.ApplyMqttTokenResponseBody = ApplyMqttTokenResponseBody; exports.ApplyMqttTokenResponseBodyData = ApplyMqttTokenResponseBodyData; exports.AuthenticationError = AuthenticationError; exports.Browser = Browser; exports.BrowserAgent = BrowserAgent; exports.BrowserError = BrowserError; exports.CallMcpToolRequest = CallMcpToolRequest; exports.CallMcpToolResponse = CallMcpToolResponse; exports.CallMcpToolResponseBody = CallMcpToolResponseBody; exports.Client = Client; exports.Command = Command; exports.CommandError = CommandError; exports.Context = Context; exports.ContextManager = ContextManager; exports.ContextService = ContextService; exports.ContextSync = ContextSync; exports.CreateMcpSessionRequest = CreateMcpSessionRequest; exports.CreateMcpSessionRequestPersistenceDataList = CreateMcpSessionRequestPersistenceDataList; exports.CreateMcpSessionResponse = CreateMcpSessionResponse; exports.CreateMcpSessionResponseBody = CreateMcpSessionResponseBody; exports.CreateMcpSessionResponseBodyData = CreateMcpSessionResponseBodyData; exports.CreateMcpSessionShrinkRequest = CreateMcpSessionShrinkRequest; exports.CreateSessionParams = CreateSessionParams; exports.DeleteContextRequest = DeleteContextRequest; exports.DeleteContextResponse = DeleteContextResponse; exports.DeleteContextResponseBody = DeleteContextResponseBody; exports.DownloadStrategy = DownloadStrategy; exports.FileError = FileError; exports.FileSystem = FileSystem; exports.GetContextInfoRequest = GetContextInfoRequest; exports.GetContextInfoResponse = GetContextInfoResponse; exports.GetContextInfoResponseBody = GetContextInfoResponseBody; exports.GetContextInfoResponseBodyData = GetContextInfoResponseBodyData; exports.GetContextRequest = GetContextRequest; exports.GetContextResponse = GetContextResponse; exports.GetContextResponseBody = GetContextResponseBody; exports.GetContextResponseBodyData = GetContextResponseBodyData; exports.GetLabelRequest = GetLabelRequest; exports.GetLabelResponse = GetLabelResponse; exports.GetLabelResponseBody = GetLabelResponseBody; exports.GetLabelResponseBodyData = GetLabelResponseBodyData; exports.GetLinkRequest = GetLinkRequest; exports.GetLinkResponse = GetLinkResponse; exports.GetLinkResponseBody = GetLinkResponseBody; exports.GetLinkResponseBodyData = GetLinkResponseBodyData; exports.GetMcpResourceRequest = GetMcpResourceRequest; exports.GetMcpResourceResponse = GetMcpResourceResponse; exports.GetMcpResourceResponseBody = GetMcpResourceResponseBody; exports.GetMcpResourceResponseBodyData = GetMcpResourceResponseBodyData; exports.GetMcpResourceResponseBodyDataDesktopInfo = GetMcpResourceResponseBodyDataDesktopInfo; exports.InitBrowserRequest = InitBrowserRequest; exports.InitBrowserResponse = InitBrowserResponse; exports.InitBrowserResponseBody = InitBrowserResponseBody; exports.InitBrowserResponseBodyData = InitBrowserResponseBodyData; exports.KeyCode = KeyCode; exports.ListContextsRequest = ListContextsRequest; exports.ListContextsResponse = ListContextsResponse; exports.ListContextsResponseBody = ListContextsResponseBody; exports.ListContextsResponseBodyData = ListContextsResponseBodyData; exports.ListMcpToolsRequest = ListMcpToolsRequest; exports.ListMcpToolsResponse = ListMcpToolsResponse; exports.ListMcpToolsResponseBody = ListMcpToolsResponseBody; exports.ListSessionRequest = ListSessionRequest; exports.ListSessionResponse = ListSessionResponse; exports.ListSessionResponseBody = ListSessionResponseBody; exports.ListSessionResponseBodyData = ListSessionResponseBodyData; exports.ModifyContextRequest = ModifyContextRequest; exports.ModifyContextResponse = ModifyContextResponse; exports.ModifyContextResponseBody = ModifyContextResponseBody; exports.ObserveResult = ObserveResult; exports.Oss = Oss; exports.OssError = OssError; exports.ReleaseMcpSessionRequest = ReleaseMcpSessionRequest; exports.ReleaseMcpSessionResponse = ReleaseMcpSessionResponse; exports.ReleaseMcpSessionResponseBody = ReleaseMcpSessionResponseBody; exports.Session = Session; exports.SessionError = SessionError; exports.SetLabelRequest = SetLabelRequest; exports.SetLabelResponse = SetLabelResponse; exports.SetLabelResponseBody = SetLabelResponseBody; exports.SyncContextRequest = SyncContextRequest; exports.SyncContextResponse = SyncContextResponse; exports.SyncContextResponseBody = SyncContextResponseBody; exports.SyncPolicyImpl = SyncPolicyImpl; exports.UI = UI; exports.UIError = UIError; exports.UploadStrategy = UploadStrategy; exports.log = log; exports.logError = logError; exports.newContextManager = newContextManager; exports.newContextSync = newContextSync; exports.newCreateSessionParams = newCreateSessionParams; exports.newDeletePolicy = newDeletePolicy; exports.newDownloadPolicy = newDownloadPolicy; exports.newSyncPolicy = newSyncPolicy; exports.newSyncPolicyWithDefaults = newSyncPolicyWithDefaults; exports.newUploadPolicy = newUploadPolicy;
|
|
6889
7848
|
//# sourceMappingURL=index.cjs.map
|