wuying-agentbay-sdk 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -504,7 +504,7 @@ init_esm_shims();
504
504
 
505
505
  // src/api/client.ts
506
506
  init_esm_shims();
507
- import * as $dara61 from "@darabonba/typescript";
507
+ import * as $dara65 from "@darabonba/typescript";
508
508
  import OpenApi from "@alicloud/openapi-core";
509
509
  import { OpenApiUtil, $OpenApiUtil } from "@alicloud/openapi-core";
510
510
 
@@ -581,20 +581,26 @@ var _CreateMcpSessionResponseBodyData = class _CreateMcpSessionResponseBodyData
581
581
  return {
582
582
  appInstanceId: "AppInstanceId",
583
583
  errMsg: "ErrMsg",
584
+ httpPort: "HttpPort",
585
+ networkInterfaceIp: "NetworkInterfaceIp",
584
586
  resourceId: "ResourceId",
585
587
  resourceUrl: "ResourceUrl",
586
588
  sessionId: "SessionId",
587
- success: "Success"
589
+ success: "Success",
590
+ vpcResource: "VpcResource"
588
591
  };
589
592
  }
590
593
  static types() {
591
594
  return {
592
595
  appInstanceId: "string",
593
596
  errMsg: "string",
597
+ httpPort: "string",
598
+ networkInterfaceIp: "string",
594
599
  resourceId: "string",
595
600
  resourceUrl: "string",
596
601
  sessionId: "string",
597
- success: "boolean"
602
+ success: "boolean",
603
+ vpcResource: "boolean"
598
604
  };
599
605
  }
600
606
  validate() {
@@ -1051,7 +1057,8 @@ var _CreateMcpSessionRequest = class _CreateMcpSessionRequest extends $dara18.Mo
1051
1057
  imageId: "ImageId",
1052
1058
  labels: "Labels",
1053
1059
  persistenceDataList: "PersistenceDataList",
1054
- sessionId: "SessionId"
1060
+ sessionId: "SessionId",
1061
+ vpcResource: "VpcResource"
1055
1062
  };
1056
1063
  }
1057
1064
  static types() {
@@ -1062,7 +1069,8 @@ var _CreateMcpSessionRequest = class _CreateMcpSessionRequest extends $dara18.Mo
1062
1069
  imageId: "string",
1063
1070
  labels: "string",
1064
1071
  persistenceDataList: { "type": "array", "itemType": CreateMcpSessionRequestPersistenceDataList },
1065
- sessionId: "string"
1072
+ sessionId: "string",
1073
+ vpcResource: "boolean"
1066
1074
  };
1067
1075
  }
1068
1076
  validate() {
@@ -1090,7 +1098,8 @@ var _CreateMcpSessionShrinkRequest = class _CreateMcpSessionShrinkRequest extend
1090
1098
  imageId: "ImageId",
1091
1099
  labels: "Labels",
1092
1100
  persistenceDataListShrink: "PersistenceDataList",
1093
- sessionId: "SessionId"
1101
+ sessionId: "SessionId",
1102
+ vpcResource: "VpcResource"
1094
1103
  };
1095
1104
  }
1096
1105
  static types() {
@@ -1101,7 +1110,8 @@ var _CreateMcpSessionShrinkRequest = class _CreateMcpSessionShrinkRequest extend
1101
1110
  imageId: "string",
1102
1111
  labels: "string",
1103
1112
  persistenceDataListShrink: "string",
1104
- sessionId: "string"
1113
+ sessionId: "string",
1114
+ vpcResource: "boolean"
1105
1115
  };
1106
1116
  }
1107
1117
  validate() {
@@ -1784,10 +1794,147 @@ var _GetMcpResourceResponse = class _GetMcpResourceResponse extends $dara39.Mode
1784
1794
  __name(_GetMcpResourceResponse, "GetMcpResourceResponse");
1785
1795
  var GetMcpResourceResponse = _GetMcpResourceResponse;
1786
1796
 
1787
- // src/api/models/ListContextsRequest.ts
1797
+ // src/api/models/InitBrowserRequest.ts
1788
1798
  init_esm_shims();
1789
1799
  import * as $dara40 from "@darabonba/typescript";
1790
- var _ListContextsRequest = class _ListContextsRequest extends $dara40.Model {
1800
+ var _InitBrowserRequest = class _InitBrowserRequest extends $dara40.Model {
1801
+ static names() {
1802
+ return {
1803
+ authorization: "Authorization",
1804
+ persistentPath: "PersistentPath",
1805
+ sessionId: "SessionId"
1806
+ };
1807
+ }
1808
+ static types() {
1809
+ return {
1810
+ authorization: "string",
1811
+ persistentPath: "string",
1812
+ sessionId: "string"
1813
+ };
1814
+ }
1815
+ validate() {
1816
+ super.validate();
1817
+ }
1818
+ constructor(map) {
1819
+ super(map);
1820
+ }
1821
+ static fromMap(m) {
1822
+ return $dara40.cast(m, new _InitBrowserRequest());
1823
+ }
1824
+ };
1825
+ __name(_InitBrowserRequest, "InitBrowserRequest");
1826
+ var InitBrowserRequest = _InitBrowserRequest;
1827
+
1828
+ // src/api/models/InitBrowserResponseBody.ts
1829
+ init_esm_shims();
1830
+ import * as $dara42 from "@darabonba/typescript";
1831
+
1832
+ // src/api/models/InitBrowserResponseBodyData.ts
1833
+ init_esm_shims();
1834
+ import * as $dara41 from "@darabonba/typescript";
1835
+ var _InitBrowserResponseBodyData = class _InitBrowserResponseBodyData extends $dara41.Model {
1836
+ static names() {
1837
+ return {
1838
+ port: "Port"
1839
+ };
1840
+ }
1841
+ static types() {
1842
+ return {
1843
+ port: "number"
1844
+ };
1845
+ }
1846
+ validate() {
1847
+ super.validate();
1848
+ }
1849
+ constructor(map) {
1850
+ super(map);
1851
+ }
1852
+ static fromMap(m) {
1853
+ return $dara41.cast(m, new _InitBrowserResponseBodyData());
1854
+ }
1855
+ };
1856
+ __name(_InitBrowserResponseBodyData, "InitBrowserResponseBodyData");
1857
+ var InitBrowserResponseBodyData = _InitBrowserResponseBodyData;
1858
+
1859
+ // src/api/models/InitBrowserResponseBody.ts
1860
+ var _InitBrowserResponseBody = class _InitBrowserResponseBody extends $dara42.Model {
1861
+ static names() {
1862
+ return {
1863
+ code: "Code",
1864
+ data: "Data",
1865
+ httpStatusCode: "HttpStatusCode",
1866
+ message: "Message",
1867
+ requestId: "RequestId",
1868
+ success: "Success"
1869
+ };
1870
+ }
1871
+ static types() {
1872
+ return {
1873
+ code: "string",
1874
+ data: InitBrowserResponseBodyData,
1875
+ httpStatusCode: "number",
1876
+ message: "string",
1877
+ requestId: "string",
1878
+ success: "boolean"
1879
+ };
1880
+ }
1881
+ validate() {
1882
+ if (this.data && typeof this.data.validate === "function") {
1883
+ this.data.validate();
1884
+ }
1885
+ super.validate();
1886
+ }
1887
+ constructor(map) {
1888
+ super(map);
1889
+ }
1890
+ static fromMap(m) {
1891
+ return $dara42.cast(m, new _InitBrowserResponseBody());
1892
+ }
1893
+ };
1894
+ __name(_InitBrowserResponseBody, "InitBrowserResponseBody");
1895
+ var InitBrowserResponseBody = _InitBrowserResponseBody;
1896
+
1897
+ // src/api/models/InitBrowserResponse.ts
1898
+ init_esm_shims();
1899
+ import * as $dara43 from "@darabonba/typescript";
1900
+ var _InitBrowserResponse = class _InitBrowserResponse extends $dara43.Model {
1901
+ static names() {
1902
+ return {
1903
+ headers: "headers",
1904
+ statusCode: "statusCode",
1905
+ body: "body"
1906
+ };
1907
+ }
1908
+ static types() {
1909
+ return {
1910
+ headers: { "type": "map", "keyType": "string", "valueType": "string" },
1911
+ statusCode: "number",
1912
+ body: InitBrowserResponseBody
1913
+ };
1914
+ }
1915
+ validate() {
1916
+ if (this.headers) {
1917
+ $dara43.Model.validateMap(this.headers);
1918
+ }
1919
+ if (this.body && typeof this.body.validate === "function") {
1920
+ this.body.validate();
1921
+ }
1922
+ super.validate();
1923
+ }
1924
+ constructor(map) {
1925
+ super(map);
1926
+ }
1927
+ static fromMap(m) {
1928
+ return $dara43.cast(m, new _InitBrowserResponse());
1929
+ }
1930
+ };
1931
+ __name(_InitBrowserResponse, "InitBrowserResponse");
1932
+ var InitBrowserResponse = _InitBrowserResponse;
1933
+
1934
+ // src/api/models/ListContextsRequest.ts
1935
+ init_esm_shims();
1936
+ import * as $dara44 from "@darabonba/typescript";
1937
+ var _ListContextsRequest = class _ListContextsRequest extends $dara44.Model {
1791
1938
  static names() {
1792
1939
  return {
1793
1940
  authorization: "Authorization",
@@ -1814,8 +1961,8 @@ var ListContextsRequest = _ListContextsRequest;
1814
1961
 
1815
1962
  // src/api/models/ListContextsResponseBody.ts
1816
1963
  init_esm_shims();
1817
- import * as $dara41 from "@darabonba/typescript";
1818
- var _ListContextsResponseBody = class _ListContextsResponseBody extends $dara41.Model {
1964
+ import * as $dara45 from "@darabonba/typescript";
1965
+ var _ListContextsResponseBody = class _ListContextsResponseBody extends $dara45.Model {
1819
1966
  static names() {
1820
1967
  return {
1821
1968
  code: "Code",
@@ -1844,7 +1991,7 @@ var _ListContextsResponseBody = class _ListContextsResponseBody extends $dara41.
1844
1991
  }
1845
1992
  validate() {
1846
1993
  if (Array.isArray(this.data)) {
1847
- $dara41.Model.validateArray(this.data);
1994
+ $dara45.Model.validateArray(this.data);
1848
1995
  }
1849
1996
  super.validate();
1850
1997
  }
@@ -1857,8 +2004,8 @@ var ListContextsResponseBody = _ListContextsResponseBody;
1857
2004
 
1858
2005
  // src/api/models/ListContextsResponse.ts
1859
2006
  init_esm_shims();
1860
- import * as $dara42 from "@darabonba/typescript";
1861
- var _ListContextsResponse = class _ListContextsResponse extends $dara42.Model {
2007
+ import * as $dara46 from "@darabonba/typescript";
2008
+ var _ListContextsResponse = class _ListContextsResponse extends $dara46.Model {
1862
2009
  static names() {
1863
2010
  return {
1864
2011
  headers: "headers",
@@ -1875,7 +2022,7 @@ var _ListContextsResponse = class _ListContextsResponse extends $dara42.Model {
1875
2022
  }
1876
2023
  validate() {
1877
2024
  if (this.headers) {
1878
- $dara42.Model.validateMap(this.headers);
2025
+ $dara46.Model.validateMap(this.headers);
1879
2026
  }
1880
2027
  if (this.body && typeof this.body.validate === "function") {
1881
2028
  this.body.validate();
@@ -1891,8 +2038,8 @@ var ListContextsResponse = _ListContextsResponse;
1891
2038
 
1892
2039
  // src/api/models/ListMcpToolsRequest.ts
1893
2040
  init_esm_shims();
1894
- import * as $dara43 from "@darabonba/typescript";
1895
- var _ListMcpToolsRequest = class _ListMcpToolsRequest extends $dara43.Model {
2041
+ import * as $dara47 from "@darabonba/typescript";
2042
+ var _ListMcpToolsRequest = class _ListMcpToolsRequest extends $dara47.Model {
1896
2043
  static names() {
1897
2044
  return {
1898
2045
  authorization: "Authorization",
@@ -1917,8 +2064,8 @@ var ListMcpToolsRequest = _ListMcpToolsRequest;
1917
2064
 
1918
2065
  // src/api/models/ListMcpToolsResponseBody.ts
1919
2066
  init_esm_shims();
1920
- import * as $dara44 from "@darabonba/typescript";
1921
- var _ListMcpToolsResponseBody = class _ListMcpToolsResponseBody extends $dara44.Model {
2067
+ import * as $dara48 from "@darabonba/typescript";
2068
+ var _ListMcpToolsResponseBody = class _ListMcpToolsResponseBody extends $dara48.Model {
1922
2069
  static names() {
1923
2070
  return {
1924
2071
  code: "Code",
@@ -1951,8 +2098,8 @@ var ListMcpToolsResponseBody = _ListMcpToolsResponseBody;
1951
2098
 
1952
2099
  // src/api/models/ListMcpToolsResponse.ts
1953
2100
  init_esm_shims();
1954
- import * as $dara45 from "@darabonba/typescript";
1955
- var _ListMcpToolsResponse = class _ListMcpToolsResponse extends $dara45.Model {
2101
+ import * as $dara49 from "@darabonba/typescript";
2102
+ var _ListMcpToolsResponse = class _ListMcpToolsResponse extends $dara49.Model {
1956
2103
  static names() {
1957
2104
  return {
1958
2105
  headers: "headers",
@@ -1969,7 +2116,7 @@ var _ListMcpToolsResponse = class _ListMcpToolsResponse extends $dara45.Model {
1969
2116
  }
1970
2117
  validate() {
1971
2118
  if (this.headers) {
1972
- $dara45.Model.validateMap(this.headers);
2119
+ $dara49.Model.validateMap(this.headers);
1973
2120
  }
1974
2121
  if (this.body && typeof this.body.validate === "function") {
1975
2122
  this.body.validate();
@@ -1985,8 +2132,8 @@ var ListMcpToolsResponse = _ListMcpToolsResponse;
1985
2132
 
1986
2133
  // src/api/models/ListSessionRequest.ts
1987
2134
  init_esm_shims();
1988
- import * as $dara46 from "@darabonba/typescript";
1989
- var _ListSessionRequest = class _ListSessionRequest extends $dara46.Model {
2135
+ import * as $dara50 from "@darabonba/typescript";
2136
+ var _ListSessionRequest = class _ListSessionRequest extends $dara50.Model {
1990
2137
  static names() {
1991
2138
  return {
1992
2139
  authorization: "Authorization",
@@ -2015,8 +2162,8 @@ var ListSessionRequest = _ListSessionRequest;
2015
2162
 
2016
2163
  // src/api/models/ListSessionResponseBody.ts
2017
2164
  init_esm_shims();
2018
- import * as $dara47 from "@darabonba/typescript";
2019
- var _ListSessionResponseBody = class _ListSessionResponseBody extends $dara47.Model {
2165
+ import * as $dara51 from "@darabonba/typescript";
2166
+ var _ListSessionResponseBody = class _ListSessionResponseBody extends $dara51.Model {
2020
2167
  static names() {
2021
2168
  return {
2022
2169
  code: "Code",
@@ -2045,7 +2192,7 @@ var _ListSessionResponseBody = class _ListSessionResponseBody extends $dara47.Mo
2045
2192
  }
2046
2193
  validate() {
2047
2194
  if (Array.isArray(this.data)) {
2048
- $dara47.Model.validateArray(this.data);
2195
+ $dara51.Model.validateArray(this.data);
2049
2196
  }
2050
2197
  super.validate();
2051
2198
  }
@@ -2058,8 +2205,8 @@ var ListSessionResponseBody = _ListSessionResponseBody;
2058
2205
 
2059
2206
  // src/api/models/ListSessionResponse.ts
2060
2207
  init_esm_shims();
2061
- import * as $dara48 from "@darabonba/typescript";
2062
- var _ListSessionResponse = class _ListSessionResponse extends $dara48.Model {
2208
+ import * as $dara52 from "@darabonba/typescript";
2209
+ var _ListSessionResponse = class _ListSessionResponse extends $dara52.Model {
2063
2210
  static names() {
2064
2211
  return {
2065
2212
  headers: "headers",
@@ -2076,7 +2223,7 @@ var _ListSessionResponse = class _ListSessionResponse extends $dara48.Model {
2076
2223
  }
2077
2224
  validate() {
2078
2225
  if (this.headers) {
2079
- $dara48.Model.validateMap(this.headers);
2226
+ $dara52.Model.validateMap(this.headers);
2080
2227
  }
2081
2228
  if (this.body && typeof this.body.validate === "function") {
2082
2229
  this.body.validate();
@@ -2092,8 +2239,8 @@ var ListSessionResponse = _ListSessionResponse;
2092
2239
 
2093
2240
  // src/api/models/ModifyContextRequest.ts
2094
2241
  init_esm_shims();
2095
- import * as $dara49 from "@darabonba/typescript";
2096
- var _ModifyContextRequest = class _ModifyContextRequest extends $dara49.Model {
2242
+ import * as $dara53 from "@darabonba/typescript";
2243
+ var _ModifyContextRequest = class _ModifyContextRequest extends $dara53.Model {
2097
2244
  static names() {
2098
2245
  return {
2099
2246
  authorization: "Authorization",
@@ -2120,8 +2267,8 @@ var ModifyContextRequest = _ModifyContextRequest;
2120
2267
 
2121
2268
  // src/api/models/ModifyContextResponseBody.ts
2122
2269
  init_esm_shims();
2123
- import * as $dara50 from "@darabonba/typescript";
2124
- var _ModifyContextResponseBody = class _ModifyContextResponseBody extends $dara50.Model {
2270
+ import * as $dara54 from "@darabonba/typescript";
2271
+ var _ModifyContextResponseBody = class _ModifyContextResponseBody extends $dara54.Model {
2125
2272
  static names() {
2126
2273
  return {
2127
2274
  code: "Code",
@@ -2152,8 +2299,8 @@ var ModifyContextResponseBody = _ModifyContextResponseBody;
2152
2299
 
2153
2300
  // src/api/models/ModifyContextResponse.ts
2154
2301
  init_esm_shims();
2155
- import * as $dara51 from "@darabonba/typescript";
2156
- var _ModifyContextResponse = class _ModifyContextResponse extends $dara51.Model {
2302
+ import * as $dara55 from "@darabonba/typescript";
2303
+ var _ModifyContextResponse = class _ModifyContextResponse extends $dara55.Model {
2157
2304
  static names() {
2158
2305
  return {
2159
2306
  headers: "headers",
@@ -2170,7 +2317,7 @@ var _ModifyContextResponse = class _ModifyContextResponse extends $dara51.Model
2170
2317
  }
2171
2318
  validate() {
2172
2319
  if (this.headers) {
2173
- $dara51.Model.validateMap(this.headers);
2320
+ $dara55.Model.validateMap(this.headers);
2174
2321
  }
2175
2322
  if (this.body && typeof this.body.validate === "function") {
2176
2323
  this.body.validate();
@@ -2186,8 +2333,8 @@ var ModifyContextResponse = _ModifyContextResponse;
2186
2333
 
2187
2334
  // src/api/models/ReleaseMcpSessionRequest.ts
2188
2335
  init_esm_shims();
2189
- import * as $dara52 from "@darabonba/typescript";
2190
- var _ReleaseMcpSessionRequest = class _ReleaseMcpSessionRequest extends $dara52.Model {
2336
+ import * as $dara56 from "@darabonba/typescript";
2337
+ var _ReleaseMcpSessionRequest = class _ReleaseMcpSessionRequest extends $dara56.Model {
2191
2338
  static names() {
2192
2339
  return {
2193
2340
  authorization: "Authorization",
@@ -2212,8 +2359,8 @@ var ReleaseMcpSessionRequest = _ReleaseMcpSessionRequest;
2212
2359
 
2213
2360
  // src/api/models/ReleaseMcpSessionResponseBody.ts
2214
2361
  init_esm_shims();
2215
- import * as $dara53 from "@darabonba/typescript";
2216
- var _ReleaseMcpSessionResponseBody = class _ReleaseMcpSessionResponseBody extends $dara53.Model {
2362
+ import * as $dara57 from "@darabonba/typescript";
2363
+ var _ReleaseMcpSessionResponseBody = class _ReleaseMcpSessionResponseBody extends $dara57.Model {
2217
2364
  static names() {
2218
2365
  return {
2219
2366
  code: "Code",
@@ -2244,8 +2391,8 @@ var ReleaseMcpSessionResponseBody = _ReleaseMcpSessionResponseBody;
2244
2391
 
2245
2392
  // src/api/models/ReleaseMcpSessionResponse.ts
2246
2393
  init_esm_shims();
2247
- import * as $dara54 from "@darabonba/typescript";
2248
- var _ReleaseMcpSessionResponse = class _ReleaseMcpSessionResponse extends $dara54.Model {
2394
+ import * as $dara58 from "@darabonba/typescript";
2395
+ var _ReleaseMcpSessionResponse = class _ReleaseMcpSessionResponse extends $dara58.Model {
2249
2396
  static names() {
2250
2397
  return {
2251
2398
  headers: "headers",
@@ -2262,7 +2409,7 @@ var _ReleaseMcpSessionResponse = class _ReleaseMcpSessionResponse extends $dara5
2262
2409
  }
2263
2410
  validate() {
2264
2411
  if (this.headers) {
2265
- $dara54.Model.validateMap(this.headers);
2412
+ $dara58.Model.validateMap(this.headers);
2266
2413
  }
2267
2414
  if (this.body && typeof this.body.validate === "function") {
2268
2415
  this.body.validate();
@@ -2278,8 +2425,8 @@ var ReleaseMcpSessionResponse = _ReleaseMcpSessionResponse;
2278
2425
 
2279
2426
  // src/api/models/SetLabelRequest.ts
2280
2427
  init_esm_shims();
2281
- import * as $dara55 from "@darabonba/typescript";
2282
- var _SetLabelRequest = class _SetLabelRequest extends $dara55.Model {
2428
+ import * as $dara59 from "@darabonba/typescript";
2429
+ var _SetLabelRequest = class _SetLabelRequest extends $dara59.Model {
2283
2430
  static names() {
2284
2431
  return {
2285
2432
  authorization: "Authorization",
@@ -2306,8 +2453,8 @@ var SetLabelRequest = _SetLabelRequest;
2306
2453
 
2307
2454
  // src/api/models/SetLabelResponseBody.ts
2308
2455
  init_esm_shims();
2309
- import * as $dara56 from "@darabonba/typescript";
2310
- var _SetLabelResponseBody = class _SetLabelResponseBody extends $dara56.Model {
2456
+ import * as $dara60 from "@darabonba/typescript";
2457
+ var _SetLabelResponseBody = class _SetLabelResponseBody extends $dara60.Model {
2311
2458
  static names() {
2312
2459
  return {
2313
2460
  code: "Code",
@@ -2338,8 +2485,8 @@ var SetLabelResponseBody = _SetLabelResponseBody;
2338
2485
 
2339
2486
  // src/api/models/SetLabelResponse.ts
2340
2487
  init_esm_shims();
2341
- import * as $dara57 from "@darabonba/typescript";
2342
- var _SetLabelResponse = class _SetLabelResponse extends $dara57.Model {
2488
+ import * as $dara61 from "@darabonba/typescript";
2489
+ var _SetLabelResponse = class _SetLabelResponse extends $dara61.Model {
2343
2490
  static names() {
2344
2491
  return {
2345
2492
  headers: "headers",
@@ -2356,7 +2503,7 @@ var _SetLabelResponse = class _SetLabelResponse extends $dara57.Model {
2356
2503
  }
2357
2504
  validate() {
2358
2505
  if (this.headers) {
2359
- $dara57.Model.validateMap(this.headers);
2506
+ $dara61.Model.validateMap(this.headers);
2360
2507
  }
2361
2508
  if (this.body && typeof this.body.validate === "function") {
2362
2509
  this.body.validate();
@@ -2372,8 +2519,8 @@ var SetLabelResponse = _SetLabelResponse;
2372
2519
 
2373
2520
  // src/api/models/SyncContextRequest.ts
2374
2521
  init_esm_shims();
2375
- import * as $dara58 from "@darabonba/typescript";
2376
- var _SyncContextRequest = class _SyncContextRequest extends $dara58.Model {
2522
+ import * as $dara62 from "@darabonba/typescript";
2523
+ var _SyncContextRequest = class _SyncContextRequest extends $dara62.Model {
2377
2524
  static names() {
2378
2525
  return {
2379
2526
  authorization: "Authorization",
@@ -2404,8 +2551,8 @@ var SyncContextRequest = _SyncContextRequest;
2404
2551
 
2405
2552
  // src/api/models/SyncContextResponseBody.ts
2406
2553
  init_esm_shims();
2407
- import * as $dara59 from "@darabonba/typescript";
2408
- var _SyncContextResponseBody = class _SyncContextResponseBody extends $dara59.Model {
2554
+ import * as $dara63 from "@darabonba/typescript";
2555
+ var _SyncContextResponseBody = class _SyncContextResponseBody extends $dara63.Model {
2409
2556
  static names() {
2410
2557
  return {
2411
2558
  code: "Code",
@@ -2436,8 +2583,8 @@ var SyncContextResponseBody = _SyncContextResponseBody;
2436
2583
 
2437
2584
  // src/api/models/SyncContextResponse.ts
2438
2585
  init_esm_shims();
2439
- import * as $dara60 from "@darabonba/typescript";
2440
- var _SyncContextResponse = class _SyncContextResponse extends $dara60.Model {
2586
+ import * as $dara64 from "@darabonba/typescript";
2587
+ var _SyncContextResponse = class _SyncContextResponse extends $dara64.Model {
2441
2588
  static names() {
2442
2589
  return {
2443
2590
  headers: "headers",
@@ -2454,7 +2601,7 @@ var _SyncContextResponse = class _SyncContextResponse extends $dara60.Model {
2454
2601
  }
2455
2602
  validate() {
2456
2603
  if (this.headers) {
2457
- $dara60.Model.validateMap(this.headers);
2604
+ $dara64.Model.validateMap(this.headers);
2458
2605
  }
2459
2606
  if (this.body && typeof this.body.validate === "function") {
2460
2607
  this.body.validate();
@@ -2486,10 +2633,10 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2486
2633
  );
2487
2634
  }
2488
2635
  getEndpoint(productId, regionId, endpointRule, network, suffix, endpointMap, endpoint) {
2489
- if (!$dara61.isNull(endpoint)) {
2636
+ if (!$dara65.isNull(endpoint)) {
2490
2637
  return endpoint;
2491
2638
  }
2492
- if (!$dara61.isNull(endpointMap) && !$dara61.isNull(endpointMap[regionId])) {
2639
+ if (!$dara65.isNull(endpointMap) && !$dara65.isNull(endpointMap[regionId])) {
2493
2640
  return endpointMap[regionId];
2494
2641
  }
2495
2642
  return OpenApiUtil.getEndpointRules(
@@ -2510,28 +2657,28 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2510
2657
  async callMcpToolWithOptions(request, runtime) {
2511
2658
  request.validate();
2512
2659
  const body = {};
2513
- if (!$dara61.isNull(request.args)) {
2660
+ if (!$dara65.isNull(request.args)) {
2514
2661
  body["Args"] = request.args;
2515
2662
  }
2516
- if (!$dara61.isNull(request.authorization)) {
2663
+ if (!$dara65.isNull(request.authorization)) {
2517
2664
  body["Authorization"] = request.authorization;
2518
2665
  }
2519
- if (!$dara61.isNull(request.externalUserId)) {
2666
+ if (!$dara65.isNull(request.externalUserId)) {
2520
2667
  body["ExternalUserId"] = request.externalUserId;
2521
2668
  }
2522
- if (!$dara61.isNull(request.imageId)) {
2669
+ if (!$dara65.isNull(request.imageId)) {
2523
2670
  body["ImageId"] = request.imageId;
2524
2671
  }
2525
- if (!$dara61.isNull(request.name)) {
2672
+ if (!$dara65.isNull(request.name)) {
2526
2673
  body["Name"] = request.name;
2527
2674
  }
2528
- if (!$dara61.isNull(request.server)) {
2675
+ if (!$dara65.isNull(request.server)) {
2529
2676
  body["Server"] = request.server;
2530
2677
  }
2531
- if (!$dara61.isNull(request.sessionId)) {
2678
+ if (!$dara65.isNull(request.sessionId)) {
2532
2679
  body["SessionId"] = request.sessionId;
2533
2680
  }
2534
- if (!$dara61.isNull(request.tool)) {
2681
+ if (!$dara65.isNull(request.tool)) {
2535
2682
  body["Tool"] = request.tool;
2536
2683
  }
2537
2684
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -2548,7 +2695,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2548
2695
  reqBodyType: "formData",
2549
2696
  bodyType: "json"
2550
2697
  });
2551
- return $dara61.cast(
2698
+ return $dara65.cast(
2552
2699
  await this.callApi(params, req, runtime),
2553
2700
  new CallMcpToolResponse({})
2554
2701
  );
@@ -2560,7 +2707,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2560
2707
  * @returns CallMcpToolResponse
2561
2708
  */
2562
2709
  async callMcpTool(request) {
2563
- const runtime = new $dara61.RuntimeOptions({});
2710
+ const runtime = new $dara65.RuntimeOptions({});
2564
2711
  return await this.callMcpToolWithOptions(request, runtime);
2565
2712
  }
2566
2713
  /**
@@ -2574,7 +2721,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2574
2721
  tmpReq.validate();
2575
2722
  const request = new CreateMcpSessionShrinkRequest({});
2576
2723
  OpenApiUtil.convert(tmpReq, request);
2577
- if (!$dara61.isNull(tmpReq.persistenceDataList)) {
2724
+ if (!$dara65.isNull(tmpReq.persistenceDataList)) {
2578
2725
  request.persistenceDataListShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(
2579
2726
  tmpReq.persistenceDataList,
2580
2727
  "PersistenceDataList",
@@ -2582,27 +2729,30 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2582
2729
  );
2583
2730
  }
2584
2731
  const body = {};
2585
- if (!$dara61.isNull(request.authorization)) {
2732
+ if (!$dara65.isNull(request.authorization)) {
2586
2733
  body["Authorization"] = request.authorization;
2587
2734
  }
2588
- if (!$dara61.isNull(request.contextId)) {
2735
+ if (!$dara65.isNull(request.contextId)) {
2589
2736
  body["ContextId"] = request.contextId;
2590
2737
  }
2591
- if (!$dara61.isNull(request.externalUserId)) {
2738
+ if (!$dara65.isNull(request.externalUserId)) {
2592
2739
  body["ExternalUserId"] = request.externalUserId;
2593
2740
  }
2594
- if (!$dara61.isNull(request.imageId)) {
2741
+ if (!$dara65.isNull(request.imageId)) {
2595
2742
  body["ImageId"] = request.imageId;
2596
2743
  }
2597
- if (!$dara61.isNull(request.labels)) {
2744
+ if (!$dara65.isNull(request.labels)) {
2598
2745
  body["Labels"] = request.labels;
2599
2746
  }
2600
- if (!$dara61.isNull(request.persistenceDataListShrink)) {
2747
+ if (!$dara65.isNull(request.persistenceDataListShrink)) {
2601
2748
  body["PersistenceDataList"] = request.persistenceDataListShrink;
2602
2749
  }
2603
- if (!$dara61.isNull(request.sessionId)) {
2750
+ if (!$dara65.isNull(request.sessionId)) {
2604
2751
  body["SessionId"] = request.sessionId;
2605
2752
  }
2753
+ if (!$dara65.isNull(request.vpcResource)) {
2754
+ body["VpcResource"] = request.vpcResource;
2755
+ }
2606
2756
  const req = new $OpenApiUtil.OpenApiRequest({
2607
2757
  body: OpenApiUtil.parseToMap(body)
2608
2758
  });
@@ -2617,7 +2767,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2617
2767
  reqBodyType: "formData",
2618
2768
  bodyType: "json"
2619
2769
  });
2620
- return $dara61.cast(
2770
+ return $dara65.cast(
2621
2771
  await this.callApi(params, req, runtime),
2622
2772
  new CreateMcpSessionResponse({})
2623
2773
  );
@@ -2629,7 +2779,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2629
2779
  * @returns CreateMcpSessionResponse
2630
2780
  */
2631
2781
  async createMcpSession(request) {
2632
- const runtime = new $dara61.RuntimeOptions({});
2782
+ const runtime = new $dara65.RuntimeOptions({});
2633
2783
  return await this.createMcpSessionWithOptions(request, runtime);
2634
2784
  }
2635
2785
  /**
@@ -2642,10 +2792,10 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2642
2792
  async deleteContextWithOptions(request, runtime) {
2643
2793
  request.validate();
2644
2794
  const body = {};
2645
- if (!$dara61.isNull(request.authorization)) {
2795
+ if (!$dara65.isNull(request.authorization)) {
2646
2796
  body["Authorization"] = request.authorization;
2647
2797
  }
2648
- if (!$dara61.isNull(request.id)) {
2798
+ if (!$dara65.isNull(request.id)) {
2649
2799
  body["Id"] = request.id;
2650
2800
  }
2651
2801
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -2662,7 +2812,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2662
2812
  reqBodyType: "formData",
2663
2813
  bodyType: "json"
2664
2814
  });
2665
- return $dara61.cast(
2815
+ return $dara65.cast(
2666
2816
  await this.callApi(params, req, runtime),
2667
2817
  new DeleteContextResponse({})
2668
2818
  );
@@ -2674,7 +2824,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2674
2824
  * @returns DeleteContextResponse
2675
2825
  */
2676
2826
  async deleteContext(request) {
2677
- const runtime = new $dara61.RuntimeOptions({});
2827
+ const runtime = new $dara65.RuntimeOptions({});
2678
2828
  return await this.deleteContextWithOptions(request, runtime);
2679
2829
  }
2680
2830
  /**
@@ -2687,13 +2837,13 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2687
2837
  async getContextWithOptions(request, runtime) {
2688
2838
  request.validate();
2689
2839
  const body = {};
2690
- if (!$dara61.isNull(request.allowCreate)) {
2840
+ if (!$dara65.isNull(request.allowCreate)) {
2691
2841
  body["AllowCreate"] = request.allowCreate;
2692
2842
  }
2693
- if (!$dara61.isNull(request.authorization)) {
2843
+ if (!$dara65.isNull(request.authorization)) {
2694
2844
  body["Authorization"] = request.authorization;
2695
2845
  }
2696
- if (!$dara61.isNull(request.name)) {
2846
+ if (!$dara65.isNull(request.name)) {
2697
2847
  body["Name"] = request.name;
2698
2848
  }
2699
2849
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -2710,7 +2860,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2710
2860
  reqBodyType: "formData",
2711
2861
  bodyType: "json"
2712
2862
  });
2713
- return $dara61.cast(
2863
+ return $dara65.cast(
2714
2864
  await this.callApi(params, req, runtime),
2715
2865
  new GetContextResponse({})
2716
2866
  );
@@ -2722,7 +2872,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2722
2872
  * @returns GetContextResponse
2723
2873
  */
2724
2874
  async getContext(request) {
2725
- const runtime = new $dara61.RuntimeOptions({});
2875
+ const runtime = new $dara65.RuntimeOptions({});
2726
2876
  return await this.getContextWithOptions(request, runtime);
2727
2877
  }
2728
2878
  /**
@@ -2735,19 +2885,19 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2735
2885
  async getContextInfoWithOptions(request, runtime) {
2736
2886
  request.validate();
2737
2887
  const body = {};
2738
- if (!$dara61.isNull(request.authorization)) {
2888
+ if (!$dara65.isNull(request.authorization)) {
2739
2889
  body["Authorization"] = request.authorization;
2740
2890
  }
2741
- if (!$dara61.isNull(request.contextId)) {
2891
+ if (!$dara65.isNull(request.contextId)) {
2742
2892
  body["ContextId"] = request.contextId;
2743
2893
  }
2744
- if (!$dara61.isNull(request.path)) {
2894
+ if (!$dara65.isNull(request.path)) {
2745
2895
  body["Path"] = request.path;
2746
2896
  }
2747
- if (!$dara61.isNull(request.sessionId)) {
2897
+ if (!$dara65.isNull(request.sessionId)) {
2748
2898
  body["SessionId"] = request.sessionId;
2749
2899
  }
2750
- if (!$dara61.isNull(request.taskType)) {
2900
+ if (!$dara65.isNull(request.taskType)) {
2751
2901
  body["TaskType"] = request.taskType;
2752
2902
  }
2753
2903
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -2764,7 +2914,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2764
2914
  reqBodyType: "formData",
2765
2915
  bodyType: "json"
2766
2916
  });
2767
- return $dara61.cast(
2917
+ return $dara65.cast(
2768
2918
  await this.callApi(params, req, runtime),
2769
2919
  new GetContextInfoResponse({})
2770
2920
  );
@@ -2776,7 +2926,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2776
2926
  * @returns GetContextInfoResponse
2777
2927
  */
2778
2928
  async getContextInfo(request) {
2779
- const runtime = new $dara61.RuntimeOptions({});
2929
+ const runtime = new $dara65.RuntimeOptions({});
2780
2930
  return await this.getContextInfoWithOptions(request, runtime);
2781
2931
  }
2782
2932
  /**
@@ -2789,16 +2939,16 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2789
2939
  async getLabelWithOptions(request, runtime) {
2790
2940
  request.validate();
2791
2941
  const body = {};
2792
- if (!$dara61.isNull(request.authorization)) {
2942
+ if (!$dara65.isNull(request.authorization)) {
2793
2943
  body["Authorization"] = request.authorization;
2794
2944
  }
2795
- if (!$dara61.isNull(request.maxResults)) {
2945
+ if (!$dara65.isNull(request.maxResults)) {
2796
2946
  body["MaxResults"] = request.maxResults;
2797
2947
  }
2798
- if (!$dara61.isNull(request.nextToken)) {
2948
+ if (!$dara65.isNull(request.nextToken)) {
2799
2949
  body["NextToken"] = request.nextToken;
2800
2950
  }
2801
- if (!$dara61.isNull(request.sessionId)) {
2951
+ if (!$dara65.isNull(request.sessionId)) {
2802
2952
  body["SessionId"] = request.sessionId;
2803
2953
  }
2804
2954
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -2815,7 +2965,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2815
2965
  reqBodyType: "formData",
2816
2966
  bodyType: "json"
2817
2967
  });
2818
- return $dara61.cast(
2968
+ return $dara65.cast(
2819
2969
  await this.callApi(params, req, runtime),
2820
2970
  new GetLabelResponse({})
2821
2971
  );
@@ -2827,7 +2977,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2827
2977
  * @returns GetLabelResponse
2828
2978
  */
2829
2979
  async getLabel(request) {
2830
- const runtime = new $dara61.RuntimeOptions({});
2980
+ const runtime = new $dara65.RuntimeOptions({});
2831
2981
  return await this.getLabelWithOptions(request, runtime);
2832
2982
  }
2833
2983
  /**
@@ -2840,16 +2990,16 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2840
2990
  async getLinkWithOptions(request, runtime) {
2841
2991
  request.validate();
2842
2992
  const body = {};
2843
- if (!$dara61.isNull(request.authorization)) {
2993
+ if (!$dara65.isNull(request.authorization)) {
2844
2994
  body["Authorization"] = request.authorization;
2845
2995
  }
2846
- if (!$dara61.isNull(request.port)) {
2996
+ if (!$dara65.isNull(request.port)) {
2847
2997
  body["Port"] = request.port;
2848
2998
  }
2849
- if (!$dara61.isNull(request.protocolType)) {
2999
+ if (!$dara65.isNull(request.protocolType)) {
2850
3000
  body["ProtocolType"] = request.protocolType;
2851
3001
  }
2852
- if (!$dara61.isNull(request.sessionId)) {
3002
+ if (!$dara65.isNull(request.sessionId)) {
2853
3003
  body["SessionId"] = request.sessionId;
2854
3004
  }
2855
3005
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -2866,7 +3016,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2866
3016
  reqBodyType: "formData",
2867
3017
  bodyType: "json"
2868
3018
  });
2869
- return $dara61.cast(
3019
+ return $dara65.cast(
2870
3020
  await this.callApi(params, req, runtime),
2871
3021
  new GetLinkResponse({})
2872
3022
  );
@@ -2878,7 +3028,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2878
3028
  * @returns GetLinkResponse
2879
3029
  */
2880
3030
  async getLink(request) {
2881
- const runtime = new $dara61.RuntimeOptions({});
3031
+ const runtime = new $dara65.RuntimeOptions({});
2882
3032
  return await this.getLinkWithOptions(request, runtime);
2883
3033
  }
2884
3034
  /**
@@ -2891,10 +3041,10 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2891
3041
  async getMcpResourceWithOptions(request, runtime) {
2892
3042
  request.validate();
2893
3043
  const body = {};
2894
- if (!$dara61.isNull(request.authorization)) {
3044
+ if (!$dara65.isNull(request.authorization)) {
2895
3045
  body["Authorization"] = request.authorization;
2896
3046
  }
2897
- if (!$dara61.isNull(request.sessionId)) {
3047
+ if (!$dara65.isNull(request.sessionId)) {
2898
3048
  body["SessionId"] = request.sessionId;
2899
3049
  }
2900
3050
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -2911,7 +3061,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2911
3061
  reqBodyType: "formData",
2912
3062
  bodyType: "json"
2913
3063
  });
2914
- return $dara61.cast(
3064
+ return $dara65.cast(
2915
3065
  await this.callApi(params, req, runtime),
2916
3066
  new GetMcpResourceResponse({})
2917
3067
  );
@@ -2923,7 +3073,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2923
3073
  * @returns GetMcpResourceResponse
2924
3074
  */
2925
3075
  async getMcpResource(request) {
2926
- const runtime = new $dara61.RuntimeOptions({});
3076
+ const runtime = new $dara65.RuntimeOptions({});
2927
3077
  return await this.getMcpResourceWithOptions(request, runtime);
2928
3078
  }
2929
3079
  /**
@@ -2936,13 +3086,13 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2936
3086
  async listContextsWithOptions(request, runtime) {
2937
3087
  request.validate();
2938
3088
  const body = {};
2939
- if (!$dara61.isNull(request.authorization)) {
3089
+ if (!$dara65.isNull(request.authorization)) {
2940
3090
  body["Authorization"] = request.authorization;
2941
3091
  }
2942
- if (!$dara61.isNull(request.maxResults)) {
3092
+ if (!$dara65.isNull(request.maxResults)) {
2943
3093
  body["MaxResults"] = request.maxResults;
2944
3094
  }
2945
- if (!$dara61.isNull(request.nextToken)) {
3095
+ if (!$dara65.isNull(request.nextToken)) {
2946
3096
  body["NextToken"] = request.nextToken;
2947
3097
  }
2948
3098
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -2959,7 +3109,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2959
3109
  reqBodyType: "formData",
2960
3110
  bodyType: "json"
2961
3111
  });
2962
- return $dara61.cast(
3112
+ return $dara65.cast(
2963
3113
  await this.callApi(params, req, runtime),
2964
3114
  new ListContextsResponse({})
2965
3115
  );
@@ -2971,7 +3121,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2971
3121
  * @returns ListContextsResponse
2972
3122
  */
2973
3123
  async listContexts(request) {
2974
- const runtime = new $dara61.RuntimeOptions({});
3124
+ const runtime = new $dara65.RuntimeOptions({});
2975
3125
  return await this.listContextsWithOptions(request, runtime);
2976
3126
  }
2977
3127
  /**
@@ -2984,10 +3134,10 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2984
3134
  async listMcpToolsWithOptions(request, runtime) {
2985
3135
  request.validate();
2986
3136
  const body = {};
2987
- if (!$dara61.isNull(request.authorization)) {
3137
+ if (!$dara65.isNull(request.authorization)) {
2988
3138
  body["Authorization"] = request.authorization;
2989
3139
  }
2990
- if (!$dara61.isNull(request.imageId)) {
3140
+ if (!$dara65.isNull(request.imageId)) {
2991
3141
  body["ImageId"] = request.imageId;
2992
3142
  }
2993
3143
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -3004,7 +3154,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3004
3154
  reqBodyType: "formData",
3005
3155
  bodyType: "json"
3006
3156
  });
3007
- return $dara61.cast(
3157
+ return $dara65.cast(
3008
3158
  await this.callApi(params, req, runtime),
3009
3159
  new ListMcpToolsResponse({})
3010
3160
  );
@@ -3016,7 +3166,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3016
3166
  * @returns ListMcpToolsResponse
3017
3167
  */
3018
3168
  async listMcpTools(request) {
3019
- const runtime = new $dara61.RuntimeOptions({});
3169
+ const runtime = new $dara65.RuntimeOptions({});
3020
3170
  return await this.listMcpToolsWithOptions(request, runtime);
3021
3171
  }
3022
3172
  /**
@@ -3029,16 +3179,16 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3029
3179
  async listSessionWithOptions(request, runtime) {
3030
3180
  request.validate();
3031
3181
  const body = {};
3032
- if (!$dara61.isNull(request.authorization)) {
3182
+ if (!$dara65.isNull(request.authorization)) {
3033
3183
  body["Authorization"] = request.authorization;
3034
3184
  }
3035
- if (!$dara61.isNull(request.labels)) {
3185
+ if (!$dara65.isNull(request.labels)) {
3036
3186
  body["Labels"] = request.labels;
3037
3187
  }
3038
- if (!$dara61.isNull(request.maxResults)) {
3188
+ if (!$dara65.isNull(request.maxResults)) {
3039
3189
  body["MaxResults"] = request.maxResults;
3040
3190
  }
3041
- if (!$dara61.isNull(request.nextToken)) {
3191
+ if (!$dara65.isNull(request.nextToken)) {
3042
3192
  body["NextToken"] = request.nextToken;
3043
3193
  }
3044
3194
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -3055,7 +3205,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3055
3205
  reqBodyType: "formData",
3056
3206
  bodyType: "json"
3057
3207
  });
3058
- return $dara61.cast(
3208
+ return $dara65.cast(
3059
3209
  await this.callApi(params, req, runtime),
3060
3210
  new ListSessionResponse({})
3061
3211
  );
@@ -3067,7 +3217,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3067
3217
  * @returns ListSessionResponse
3068
3218
  */
3069
3219
  async listSession(request) {
3070
- const runtime = new $dara61.RuntimeOptions({});
3220
+ const runtime = new $dara65.RuntimeOptions({});
3071
3221
  return await this.listSessionWithOptions(request, runtime);
3072
3222
  }
3073
3223
  /**
@@ -3080,13 +3230,13 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3080
3230
  async modifyContextWithOptions(request, runtime) {
3081
3231
  request.validate();
3082
3232
  const body = {};
3083
- if (!$dara61.isNull(request.authorization)) {
3233
+ if (!$dara65.isNull(request.authorization)) {
3084
3234
  body["Authorization"] = request.authorization;
3085
3235
  }
3086
- if (!$dara61.isNull(request.id)) {
3236
+ if (!$dara65.isNull(request.id)) {
3087
3237
  body["Id"] = request.id;
3088
3238
  }
3089
- if (!$dara61.isNull(request.name)) {
3239
+ if (!$dara65.isNull(request.name)) {
3090
3240
  body["Name"] = request.name;
3091
3241
  }
3092
3242
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -3103,7 +3253,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3103
3253
  reqBodyType: "formData",
3104
3254
  bodyType: "json"
3105
3255
  });
3106
- return $dara61.cast(
3256
+ return $dara65.cast(
3107
3257
  await this.callApi(params, req, runtime),
3108
3258
  new ModifyContextResponse({})
3109
3259
  );
@@ -3115,7 +3265,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3115
3265
  * @returns ModifyContextResponse
3116
3266
  */
3117
3267
  async modifyContext(request) {
3118
- const runtime = new $dara61.RuntimeOptions({});
3268
+ const runtime = new $dara65.RuntimeOptions({});
3119
3269
  return await this.modifyContextWithOptions(request, runtime);
3120
3270
  }
3121
3271
  /**
@@ -3128,10 +3278,10 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3128
3278
  async releaseMcpSessionWithOptions(request, runtime) {
3129
3279
  request.validate();
3130
3280
  const body = {};
3131
- if (!$dara61.isNull(request.authorization)) {
3281
+ if (!$dara65.isNull(request.authorization)) {
3132
3282
  body["Authorization"] = request.authorization;
3133
3283
  }
3134
- if (!$dara61.isNull(request.sessionId)) {
3284
+ if (!$dara65.isNull(request.sessionId)) {
3135
3285
  body["SessionId"] = request.sessionId;
3136
3286
  }
3137
3287
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -3148,7 +3298,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3148
3298
  reqBodyType: "formData",
3149
3299
  bodyType: "json"
3150
3300
  });
3151
- return $dara61.cast(
3301
+ return $dara65.cast(
3152
3302
  await this.callApi(params, req, runtime),
3153
3303
  new ReleaseMcpSessionResponse({})
3154
3304
  );
@@ -3160,7 +3310,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3160
3310
  * @returns ReleaseMcpSessionResponse
3161
3311
  */
3162
3312
  async releaseMcpSession(request) {
3163
- const runtime = new $dara61.RuntimeOptions({});
3313
+ const runtime = new $dara65.RuntimeOptions({});
3164
3314
  return await this.releaseMcpSessionWithOptions(request, runtime);
3165
3315
  }
3166
3316
  /**
@@ -3173,13 +3323,13 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3173
3323
  async setLabelWithOptions(request, runtime) {
3174
3324
  request.validate();
3175
3325
  const body = {};
3176
- if (!$dara61.isNull(request.authorization)) {
3326
+ if (!$dara65.isNull(request.authorization)) {
3177
3327
  body["Authorization"] = request.authorization;
3178
3328
  }
3179
- if (!$dara61.isNull(request.labels)) {
3329
+ if (!$dara65.isNull(request.labels)) {
3180
3330
  body["Labels"] = request.labels;
3181
3331
  }
3182
- if (!$dara61.isNull(request.sessionId)) {
3332
+ if (!$dara65.isNull(request.sessionId)) {
3183
3333
  body["SessionId"] = request.sessionId;
3184
3334
  }
3185
3335
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -3196,7 +3346,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3196
3346
  reqBodyType: "formData",
3197
3347
  bodyType: "json"
3198
3348
  });
3199
- return $dara61.cast(
3349
+ return $dara65.cast(
3200
3350
  await this.callApi(params, req, runtime),
3201
3351
  new SetLabelResponse({})
3202
3352
  );
@@ -3208,7 +3358,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3208
3358
  * @returns SetLabelResponse
3209
3359
  */
3210
3360
  async setLabel(request) {
3211
- const runtime = new $dara61.RuntimeOptions({});
3361
+ const runtime = new $dara65.RuntimeOptions({});
3212
3362
  return await this.setLabelWithOptions(request, runtime);
3213
3363
  }
3214
3364
  /**
@@ -3221,20 +3371,20 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3221
3371
  async syncContextWithOptions(request, runtime) {
3222
3372
  request.validate();
3223
3373
  const query = {};
3224
- if (!$dara61.isNull(request.authorization)) {
3374
+ if (!$dara65.isNull(request.authorization)) {
3225
3375
  query["Authorization"] = request.authorization;
3226
3376
  }
3227
3377
  const body = {};
3228
- if (!$dara61.isNull(request.contextId)) {
3378
+ if (!$dara65.isNull(request.contextId)) {
3229
3379
  body["ContextId"] = request.contextId;
3230
3380
  }
3231
- if (!$dara61.isNull(request.mode)) {
3381
+ if (!$dara65.isNull(request.mode)) {
3232
3382
  body["Mode"] = request.mode;
3233
3383
  }
3234
- if (!$dara61.isNull(request.path)) {
3384
+ if (!$dara65.isNull(request.path)) {
3235
3385
  body["Path"] = request.path;
3236
3386
  }
3237
- if (!$dara61.isNull(request.sessionId)) {
3387
+ if (!$dara65.isNull(request.sessionId)) {
3238
3388
  body["SessionId"] = request.sessionId;
3239
3389
  }
3240
3390
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -3252,7 +3402,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3252
3402
  reqBodyType: "formData",
3253
3403
  bodyType: "json"
3254
3404
  });
3255
- return $dara61.cast(
3405
+ return $dara65.cast(
3256
3406
  await this.callApi(params, req, runtime),
3257
3407
  new SyncContextResponse({})
3258
3408
  );
@@ -3264,9 +3414,95 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3264
3414
  * @returns SyncContextResponse
3265
3415
  */
3266
3416
  async syncContext(request) {
3267
- const runtime = new $dara61.RuntimeOptions({});
3417
+ const runtime = new $dara65.RuntimeOptions({});
3268
3418
  return await this.syncContextWithOptions(request, runtime);
3269
3419
  }
3420
+ /**
3421
+ * 初始化浏览器
3422
+ *
3423
+ * @param tmpReq - InitBrowserRequest
3424
+ * @param runtime - runtime options for this request RuntimeOptions
3425
+ * @returns InitBrowserResponse
3426
+ */
3427
+ async initBrowserWithOptions(request, runtime) {
3428
+ request.validate();
3429
+ const body = {};
3430
+ if (!$dara65.isNull(request.authorization)) {
3431
+ body["Authorization"] = request.authorization;
3432
+ }
3433
+ if (!$dara65.isNull(request.persistentPath)) {
3434
+ body["PersistentPath"] = request.persistentPath;
3435
+ }
3436
+ if (!$dara65.isNull(request.sessionId)) {
3437
+ body["SessionId"] = request.sessionId;
3438
+ }
3439
+ const req = new $OpenApiUtil.OpenApiRequest({
3440
+ body: OpenApiUtil.parseToMap(body)
3441
+ });
3442
+ const params = new $OpenApiUtil.Params({
3443
+ action: "InitBrowser",
3444
+ version: "2025-05-06",
3445
+ protocol: "HTTPS",
3446
+ pathname: "/",
3447
+ method: "POST",
3448
+ authType: "Anonymous",
3449
+ style: "RPC",
3450
+ reqBodyType: "formData",
3451
+ bodyType: "json"
3452
+ });
3453
+ return $dara65.cast(
3454
+ await this.callApi(params, req, runtime),
3455
+ new InitBrowserResponse({})
3456
+ );
3457
+ }
3458
+ /**
3459
+ * 初始化浏览器
3460
+ *
3461
+ * @param request - InitBrowserRequest
3462
+ * @returns InitBrowserResponse
3463
+ */
3464
+ async initBrowser(request) {
3465
+ const runtime = new $dara65.RuntimeOptions({});
3466
+ return await this.initBrowserWithOptions(request, runtime);
3467
+ }
3468
+ /**
3469
+ * 初始化浏览器(同步版本)
3470
+ *
3471
+ * @param request - InitBrowserRequest
3472
+ * @returns InitBrowserResponse
3473
+ */
3474
+ initBrowserSync(request) {
3475
+ const runtime = new $dara65.RuntimeOptions({});
3476
+ request.validate();
3477
+ const body = {};
3478
+ if (!$dara65.isNull(request.authorization)) {
3479
+ body["Authorization"] = request.authorization;
3480
+ }
3481
+ if (!$dara65.isNull(request.persistentPath)) {
3482
+ body["PersistentPath"] = request.persistentPath;
3483
+ }
3484
+ if (!$dara65.isNull(request.sessionId)) {
3485
+ body["SessionId"] = request.sessionId;
3486
+ }
3487
+ const req = new $OpenApiUtil.OpenApiRequest({
3488
+ body: OpenApiUtil.parseToMap(body)
3489
+ });
3490
+ const params = new $OpenApiUtil.Params({
3491
+ action: "InitBrowser",
3492
+ version: "2025-05-06",
3493
+ protocol: "HTTPS",
3494
+ pathname: "/",
3495
+ method: "POST",
3496
+ authType: "Anonymous",
3497
+ style: "RPC",
3498
+ reqBodyType: "formData",
3499
+ bodyType: "json"
3500
+ });
3501
+ return $dara65.cast(
3502
+ this.callApi(params, req, runtime),
3503
+ new InitBrowserResponse({})
3504
+ );
3505
+ }
3270
3506
  };
3271
3507
  __name(_Client, "Client");
3272
3508
  var Client = _Client;
@@ -3309,6 +3545,7 @@ function logError(message, error) {
3309
3545
  __name(logError, "logError");
3310
3546
 
3311
3547
  // src/config.ts
3548
+ var BROWSER_DATA_PATH = "/tmp/agentbay_browser";
3312
3549
  function defaultConfig() {
3313
3550
  return {
3314
3551
  region_id: "cn-shanghai",
@@ -3408,18 +3645,22 @@ var _ContextService = class _ContextService {
3408
3645
  this.agentBay = agentBay;
3409
3646
  }
3410
3647
  /**
3411
- * Lists all available contexts.
3648
+ * Lists all available contexts with pagination support.
3412
3649
  * Corresponds to Python's list() method
3413
3650
  *
3414
- * @returns ContextListResult with contexts list and requestId
3651
+ * @param params - Optional parameters for listing contexts.
3652
+ * @returns ContextListResult with contexts list and pagination information
3415
3653
  */
3416
- async list() {
3654
+ async list(params) {
3417
3655
  try {
3656
+ const maxResults = params?.maxResults !== void 0 ? params.maxResults : 10;
3418
3657
  const request = new ListContextsRequest({
3419
- authorization: `Bearer ${this.agentBay.getAPIKey()}`
3658
+ authorization: `Bearer ${this.agentBay.getAPIKey()}`,
3659
+ maxResults,
3660
+ nextToken: params?.nextToken
3420
3661
  });
3421
3662
  log("API Call: ListContexts");
3422
- log("Request: (no parameters)");
3663
+ log(`Request: MaxResults=${maxResults}`, params?.nextToken ? `, NextToken=${params.nextToken}` : "");
3423
3664
  const response = await this.agentBay.getClient().listContexts(request);
3424
3665
  log(`Response from ListContexts:`, response.body);
3425
3666
  const contexts = [];
@@ -3440,7 +3681,10 @@ var _ContextService = class _ContextService {
3440
3681
  return {
3441
3682
  requestId: extractRequestId(response) || "",
3442
3683
  success: true,
3443
- contexts
3684
+ contexts,
3685
+ nextToken: response.body?.nextToken,
3686
+ maxResults: response.body?.maxResults || maxResults,
3687
+ totalCount: response.body?.totalCount
3444
3688
  };
3445
3689
  } catch (error) {
3446
3690
  logError("Error calling ListContexts:", error);
@@ -3676,84 +3920,264 @@ var _UIError = class _UIError extends (AgentBayError.default || AgentBayError) {
3676
3920
  };
3677
3921
  __name(_UIError, "UIError");
3678
3922
  var UIError = _UIError;
3923
+ var _BrowserError = class _BrowserError extends (AgentBayError.default || AgentBayError) {
3924
+ constructor(message = "Browser operation error", extra = {}) {
3925
+ super(message, extra);
3926
+ this.name = "BrowserError";
3927
+ Object.setPrototypeOf(this, _BrowserError.prototype);
3928
+ }
3929
+ };
3930
+ __name(_BrowserError, "BrowserError");
3931
+ var BrowserError = _BrowserError;
3679
3932
 
3680
3933
  // src/session.ts
3681
3934
  init_esm_shims();
3682
3935
 
3683
- // src/application/application.ts
3936
+ // src/agent/agent.ts
3684
3937
  init_esm_shims();
3685
- var _Application = class _Application {
3938
+ var _Agent = class _Agent {
3686
3939
  /**
3687
- * Creates a new Application instance.
3688
- * @param session The session object that provides access to the AgentBay API.
3940
+ * Initialize an Agent object.
3941
+ *
3942
+ * @param session - The Session instance that this Agent belongs to.
3689
3943
  */
3690
3944
  constructor(session) {
3691
3945
  this.session = session;
3692
3946
  }
3693
3947
  /**
3694
- * Helper method to call MCP tools and handle common response processing
3948
+ * Execute a specific task described in human language.
3695
3949
  *
3696
- * @param toolName - Name of the MCP tool to call
3697
- * @param args - Arguments to pass to the tool
3698
- * @param defaultErrorMsg - Default error message if specific error details are not available
3699
- * @returns A CallMcpToolResult with the response data
3700
- * @throws APIError if the call fails
3950
+ * @param task - Task description in human language.
3951
+ * @param maxTryTimes - Maximum number of retry attempts.
3952
+ * @returns ExecutionResult containing success status, task output, and error message if any.
3701
3953
  */
3702
- async callMcpTool(toolName, args, defaultErrorMsg) {
3954
+ async executeTask(task, maxTryTimes) {
3703
3955
  try {
3704
- const argsJSON = JSON.stringify(args);
3705
- const request = new CallMcpToolRequest({
3706
- authorization: `Bearer ${this.session.getAPIKey()}`,
3707
- sessionId: this.session.getSessionId(),
3708
- name: toolName,
3709
- args: argsJSON
3710
- });
3711
- log(`API Call: CallMcpTool - ${toolName}`);
3712
- log(`Request: SessionId=${request.sessionId}, Args=${request.args}`);
3713
- const client = this.session.getClient();
3714
- const response = await client.callMcpTool(request);
3715
- if (response && response.body) {
3716
- log(`Response from CallMcpTool - ${toolName}:`, response.body);
3717
- }
3718
- if (!response.body?.data) {
3719
- throw new Error("Invalid response data format");
3720
- }
3721
- const data = response.body.data;
3722
- const result = {
3723
- data,
3724
- statusCode: response.statusCode || 0,
3725
- isError: false,
3726
- requestId: extractRequestId(response)
3727
- };
3728
- if (data.isError === true) {
3729
- result.isError = true;
3730
- const contentArray = data.content;
3731
- if (contentArray && contentArray.length > 0) {
3732
- result.content = contentArray;
3733
- if (contentArray[0]?.text) {
3734
- result.errorMsg = contentArray[0].text;
3735
- throw new Error(contentArray[0].text);
3736
- }
3956
+ const args = { task };
3957
+ const result = await this.session.callMcpTool("flux_execute_task", args);
3958
+ if (!result.success) {
3959
+ return {
3960
+ requestId: result.requestId,
3961
+ success: false,
3962
+ errorMessage: result.errorMessage,
3963
+ taskStatus: "failed",
3964
+ taskId: ""
3965
+ };
3966
+ }
3967
+ let content;
3968
+ try {
3969
+ content = JSON.parse(result.data);
3970
+ } catch (err) {
3971
+ return {
3972
+ requestId: result.requestId,
3973
+ success: false,
3974
+ errorMessage: `Failed to parse response: ${err}`,
3975
+ taskStatus: "failed",
3976
+ taskId: ""
3977
+ };
3978
+ }
3979
+ const taskId = content.task_id;
3980
+ if (!taskId) {
3981
+ return {
3982
+ requestId: result.requestId,
3983
+ success: false,
3984
+ errorMessage: "Task ID not found in response",
3985
+ taskStatus: "failed",
3986
+ taskId: ""
3987
+ };
3988
+ }
3989
+ let triedTime = 0;
3990
+ while (triedTime < maxTryTimes) {
3991
+ const query = await this.getTaskStatus(taskId);
3992
+ if (!query.success) {
3993
+ return {
3994
+ requestId: result.requestId,
3995
+ success: false,
3996
+ errorMessage: query.errorMessage,
3997
+ taskStatus: "failed",
3998
+ taskId
3999
+ };
3737
4000
  }
3738
- throw new Error(defaultErrorMsg);
3739
- }
3740
- if (Array.isArray(data.content)) {
3741
- result.content = data.content;
3742
- if (result.content.length > 0) {
3743
- const textParts = [];
3744
- for (const item of result.content) {
3745
- if (item && typeof item === "object" && item.text && typeof item.text === "string") {
3746
- textParts.push(item.text);
3747
- }
3748
- }
3749
- result.textContent = textParts.join("\n");
4001
+ let statusContent;
4002
+ try {
4003
+ statusContent = JSON.parse(query.output);
4004
+ } catch (err) {
4005
+ return {
4006
+ requestId: result.requestId,
4007
+ success: false,
4008
+ errorMessage: `Failed to parse status response: ${err}`,
4009
+ taskStatus: "failed",
4010
+ taskId
4011
+ };
4012
+ }
4013
+ const taskStatus = statusContent.status;
4014
+ if (!taskStatus) {
4015
+ return {
4016
+ requestId: result.requestId,
4017
+ success: false,
4018
+ errorMessage: "Task status not found in response",
4019
+ taskStatus: "failed",
4020
+ taskId
4021
+ };
3750
4022
  }
4023
+ switch (taskStatus) {
4024
+ case "finished":
4025
+ return {
4026
+ requestId: result.requestId,
4027
+ success: true,
4028
+ errorMessage: "",
4029
+ taskId,
4030
+ taskStatus
4031
+ };
4032
+ case "failed":
4033
+ return {
4034
+ requestId: result.requestId,
4035
+ success: false,
4036
+ errorMessage: "Failed to execute task.",
4037
+ taskId,
4038
+ taskStatus
4039
+ };
4040
+ case "unsupported":
4041
+ return {
4042
+ requestId: result.requestId,
4043
+ success: false,
4044
+ errorMessage: "Unsupported task.",
4045
+ taskId,
4046
+ taskStatus
4047
+ };
4048
+ }
4049
+ log(`Task ${taskId} is still running, please wait for a while.`);
4050
+ await new Promise((resolve2) => setTimeout(resolve2, 3e3));
4051
+ triedTime++;
3751
4052
  }
3752
- return result;
3753
- } catch (error) {
3754
- logError(`Error calling CallMcpTool - ${toolName}:`, error);
3755
- throw new APIError(`Failed to call ${toolName}: ${error}`);
4053
+ return {
4054
+ requestId: result.requestId,
4055
+ success: false,
4056
+ errorMessage: "Task execution timed out",
4057
+ taskStatus: "timeout",
4058
+ taskId
4059
+ };
4060
+ } catch (error) {
4061
+ return {
4062
+ requestId: "",
4063
+ success: false,
4064
+ errorMessage: `Failed to execute: ${error}`,
4065
+ taskStatus: "failed",
4066
+ taskId: ""
4067
+ };
4068
+ }
4069
+ }
4070
+ /**
4071
+ * Get the status of the task with the given task ID.
4072
+ *
4073
+ * @param taskId - Task ID
4074
+ * @returns QueryResult containing the task status
4075
+ */
4076
+ async getTaskStatus(taskId) {
4077
+ try {
4078
+ const args = { task_id: taskId };
4079
+ const result = await this.session.callMcpTool("flux_get_task_status", args);
4080
+ if (!result.success) {
4081
+ return {
4082
+ requestId: result.requestId,
4083
+ success: false,
4084
+ errorMessage: result.errorMessage,
4085
+ output: ""
4086
+ };
4087
+ }
4088
+ return {
4089
+ requestId: result.requestId,
4090
+ success: true,
4091
+ output: result.data,
4092
+ errorMessage: ""
4093
+ };
4094
+ } catch (error) {
4095
+ return {
4096
+ requestId: "",
4097
+ success: false,
4098
+ errorMessage: `Failed to get task status: ${error}`,
4099
+ output: ""
4100
+ };
4101
+ }
4102
+ }
4103
+ /**
4104
+ * Terminate a task with a specified task ID.
4105
+ *
4106
+ * @param taskId - The ID of the running task.
4107
+ * @returns ExecutionResult containing success status, task output, and error message if any.
4108
+ */
4109
+ async terminateTask(taskId) {
4110
+ log("Terminating task");
4111
+ try {
4112
+ const args = { task_id: taskId };
4113
+ const result = await this.session.callMcpTool("flux_terminate_task", args);
4114
+ let content;
4115
+ try {
4116
+ content = JSON.parse(result.data);
4117
+ } catch (err) {
4118
+ return {
4119
+ requestId: result.requestId,
4120
+ success: false,
4121
+ errorMessage: `Failed to parse response: ${err}`,
4122
+ taskId,
4123
+ taskStatus: "failed"
4124
+ };
4125
+ }
4126
+ const terminatedTaskId = content.task_id || taskId;
4127
+ const status = content.status || "unknown";
4128
+ if (result.success) {
4129
+ return {
4130
+ requestId: result.requestId,
4131
+ success: true,
4132
+ errorMessage: "",
4133
+ taskId: terminatedTaskId,
4134
+ taskStatus: status
4135
+ };
4136
+ }
4137
+ return {
4138
+ requestId: result.requestId,
4139
+ success: false,
4140
+ errorMessage: result.errorMessage,
4141
+ taskId: terminatedTaskId,
4142
+ taskStatus: status
4143
+ };
4144
+ } catch (error) {
4145
+ return {
4146
+ requestId: "",
4147
+ success: false,
4148
+ errorMessage: `Failed to terminate: ${error}`,
4149
+ taskId,
4150
+ taskStatus: "failed"
4151
+ };
4152
+ }
4153
+ }
4154
+ };
4155
+ __name(_Agent, "Agent");
4156
+ var Agent = _Agent;
4157
+
4158
+ // src/application/application.ts
4159
+ init_esm_shims();
4160
+ var _Application = class _Application {
4161
+ /**
4162
+ * Initialize an Application object.
4163
+ *
4164
+ * @param session - The Session instance that this Application belongs to.
4165
+ */
4166
+ constructor(session) {
4167
+ this.session = session;
4168
+ }
4169
+ /**
4170
+ * Sanitizes error messages to remove sensitive information like API keys.
4171
+ *
4172
+ * @param error - The error to sanitize
4173
+ * @returns The sanitized error
4174
+ */
4175
+ sanitizeError(error) {
4176
+ if (!error) {
4177
+ return error;
3756
4178
  }
4179
+ const errorString = String(error);
4180
+ return errorString.replace(/Bearer\s+[^\s]+/g, "Bearer [REDACTED]");
3757
4181
  }
3758
4182
  /**
3759
4183
  * Helper method to parse JSON string into objects
@@ -3769,9 +4193,9 @@ var _Application = class _Application {
3769
4193
  * Retrieves a list of installed applications.
3770
4194
  * Corresponds to Python's get_installed_apps() method
3771
4195
  *
3772
- * @param startMenu Whether to include applications from the start menu. Defaults to true.
3773
- * @param desktop Whether to include applications from the desktop. Defaults to true.
3774
- * @param ignoreSystemApps Whether to ignore system applications. Defaults to true.
4196
+ * @param startMenu - Whether to include applications from the start menu. Defaults to true.
4197
+ * @param desktop - Whether to include applications from the desktop. Defaults to true.
4198
+ * @param ignoreSystemApps - Whether to ignore system applications. Defaults to true.
3775
4199
  * @returns InstalledAppListResult with installed apps and requestId
3776
4200
  * @throws Error if the operation fails.
3777
4201
  */
@@ -3782,17 +4206,28 @@ var _Application = class _Application {
3782
4206
  desktop,
3783
4207
  ignore_system_apps: ignoreSystemApps
3784
4208
  };
3785
- const result = await this.callMcpTool(
3786
- "get_installed_apps",
3787
- args,
3788
- "Failed to get installed apps"
3789
- );
4209
+ const result = await this.session.callMcpTool("get_installed_apps", args);
4210
+ if (!result.success) {
4211
+ return {
4212
+ requestId: result.requestId,
4213
+ success: false,
4214
+ data: [],
4215
+ errorMessage: result.errorMessage
4216
+ };
4217
+ }
3790
4218
  let apps = [];
3791
- if (result.textContent) {
3792
- apps = this.parseJSON(result.textContent);
4219
+ try {
4220
+ apps = this.parseJSON(result.data);
4221
+ } catch (err) {
4222
+ return {
4223
+ requestId: result.requestId,
4224
+ success: false,
4225
+ data: [],
4226
+ errorMessage: `Failed to parse installed apps: ${err}`
4227
+ };
3793
4228
  }
3794
4229
  return {
3795
- requestId: result.requestId || "",
4230
+ requestId: result.requestId,
3796
4231
  success: true,
3797
4232
  data: apps
3798
4233
  };
@@ -3809,34 +4244,41 @@ var _Application = class _Application {
3809
4244
  * Starts an application with the given command and optional working directory.
3810
4245
  * Corresponds to Python's start_app() method
3811
4246
  *
3812
- * @param startCmd The command to start the application.
3813
- * @param workDirectory The working directory for the application. Defaults to an empty string.
3814
- * @param activity Activity name to launch (e.g. ".SettingsActivity" or "com.package/.Activity"). Defaults to an empty string.
4247
+ * @param startCmd - The command to start the application.
4248
+ * @param workDirectory - The working directory for the application. Defaults to an empty string.
4249
+ * @param activity - Activity name to launch (e.g. ".SettingsActivity" or "com.package/.Activity"). Defaults to an empty string.
3815
4250
  * @returns ProcessListResult with started processes and requestId
3816
4251
  * @throws Error if the operation fails.
3817
4252
  */
3818
4253
  async startApp(startCmd, workDirectory = "", activity = "") {
3819
4254
  try {
3820
4255
  const args = {
3821
- start_cmd: startCmd
4256
+ start_cmd: startCmd,
4257
+ work_directory: workDirectory,
4258
+ activity
3822
4259
  };
3823
- if (workDirectory) {
3824
- args.work_directory = workDirectory;
3825
- }
3826
- if (activity) {
3827
- args.activity = activity;
4260
+ const result = await this.session.callMcpTool("start_app", args);
4261
+ if (!result.success) {
4262
+ return {
4263
+ requestId: result.requestId,
4264
+ success: false,
4265
+ data: [],
4266
+ errorMessage: result.errorMessage
4267
+ };
3828
4268
  }
3829
- const result = await this.callMcpTool(
3830
- "start_app",
3831
- args,
3832
- "Failed to start app"
3833
- );
3834
4269
  let processes = [];
3835
- if (result.textContent) {
3836
- processes = this.parseJSON(result.textContent);
4270
+ try {
4271
+ processes = this.parseJSON(result.data);
4272
+ } catch (err) {
4273
+ return {
4274
+ requestId: result.requestId,
4275
+ success: false,
4276
+ data: [],
4277
+ errorMessage: `Failed to parse processes: ${err}`
4278
+ };
3837
4279
  }
3838
4280
  return {
3839
- requestId: result.requestId || "",
4281
+ requestId: result.requestId,
3840
4282
  success: true,
3841
4283
  data: processes
3842
4284
  };
@@ -3853,29 +4295,30 @@ var _Application = class _Application {
3853
4295
  * Stops an application by process name.
3854
4296
  * Corresponds to Python's stop_app_by_pname() method
3855
4297
  *
3856
- * @param pname The name of the process to stop.
3857
- * @returns AppOperationResult with requestId
4298
+ * @param pname - The process name to stop.
4299
+ * @returns AppOperationResult with operation result and requestId
3858
4300
  * @throws Error if the operation fails.
3859
4301
  */
3860
4302
  async stopAppByPName(pname) {
3861
4303
  try {
3862
- const args = {
3863
- pname
3864
- };
3865
- const result = await this.callMcpTool(
3866
- "stop_app_by_pname",
3867
- args,
3868
- "Failed to stop app by pname"
3869
- );
4304
+ const args = { pname };
4305
+ const result = await this.session.callMcpTool("stop_app_by_pname", args);
4306
+ if (!result.success) {
4307
+ return {
4308
+ requestId: result.requestId,
4309
+ success: false,
4310
+ errorMessage: result.errorMessage
4311
+ };
4312
+ }
3870
4313
  return {
3871
- requestId: result.requestId || "",
4314
+ requestId: result.requestId,
3872
4315
  success: true
3873
4316
  };
3874
4317
  } catch (error) {
3875
4318
  return {
3876
4319
  requestId: "",
3877
4320
  success: false,
3878
- errorMessage: `Failed to stop app by pname: ${error}`
4321
+ errorMessage: `Failed to stop app by process name: ${error}`
3879
4322
  };
3880
4323
  }
3881
4324
  }
@@ -3883,29 +4326,30 @@ var _Application = class _Application {
3883
4326
  * Stops an application by process ID.
3884
4327
  * Corresponds to Python's stop_app_by_pid() method
3885
4328
  *
3886
- * @param pid The ID of the process to stop.
3887
- * @returns AppOperationResult with requestId
4329
+ * @param pid - The process ID to stop.
4330
+ * @returns AppOperationResult with operation result and requestId
3888
4331
  * @throws Error if the operation fails.
3889
4332
  */
3890
4333
  async stopAppByPID(pid) {
3891
4334
  try {
3892
- const args = {
3893
- pid
3894
- };
3895
- const result = await this.callMcpTool(
3896
- "stop_app_by_pid",
3897
- args,
3898
- "Failed to stop app by pid"
3899
- );
4335
+ const args = { pid };
4336
+ const result = await this.session.callMcpTool("stop_app_by_pid", args);
4337
+ if (!result.success) {
4338
+ return {
4339
+ requestId: result.requestId,
4340
+ success: false,
4341
+ errorMessage: result.errorMessage
4342
+ };
4343
+ }
3900
4344
  return {
3901
- requestId: result.requestId || "",
4345
+ requestId: result.requestId,
3902
4346
  success: true
3903
4347
  };
3904
4348
  } catch (error) {
3905
4349
  return {
3906
4350
  requestId: "",
3907
4351
  success: false,
3908
- errorMessage: `Failed to stop app by pid: ${error}`
4352
+ errorMessage: `Failed to stop app by process ID: ${error}`
3909
4353
  };
3910
4354
  }
3911
4355
  }
@@ -3913,22 +4357,23 @@ var _Application = class _Application {
3913
4357
  * Stops an application by stop command.
3914
4358
  * Corresponds to Python's stop_app_by_cmd() method
3915
4359
  *
3916
- * @param stopCmd The command to stop the application.
3917
- * @returns AppOperationResult with requestId
4360
+ * @param stopCmd - The stop command to execute.
4361
+ * @returns AppOperationResult with operation result and requestId
3918
4362
  * @throws Error if the operation fails.
3919
4363
  */
3920
4364
  async stopAppByCmd(stopCmd) {
3921
4365
  try {
3922
- const args = {
3923
- stop_cmd: stopCmd
3924
- };
3925
- const result = await this.callMcpTool(
3926
- "stop_app_by_cmd",
3927
- args,
3928
- "Failed to stop app by command"
3929
- );
4366
+ const args = { stop_cmd: stopCmd };
4367
+ const result = await this.session.callMcpTool("stop_app_by_cmd", args);
4368
+ if (!result.success) {
4369
+ return {
4370
+ requestId: result.requestId,
4371
+ success: false,
4372
+ errorMessage: result.errorMessage
4373
+ };
4374
+ }
3930
4375
  return {
3931
- requestId: result.requestId || "",
4376
+ requestId: result.requestId,
3932
4377
  success: true
3933
4378
  };
3934
4379
  } catch (error) {
@@ -3940,26 +4385,36 @@ var _Application = class _Application {
3940
4385
  }
3941
4386
  }
3942
4387
  /**
3943
- * Lists all currently visible applications.
4388
+ * Returns a list of currently visible applications.
3944
4389
  * Corresponds to Python's list_visible_apps() method
3945
4390
  *
3946
- * @returns ProcessListResult with visible processes and requestId
4391
+ * @returns ProcessListResult with visible apps and requestId
3947
4392
  * @throws Error if the operation fails.
3948
4393
  */
3949
4394
  async listVisibleApps() {
3950
4395
  try {
3951
- const args = {};
3952
- const result = await this.callMcpTool(
3953
- "list_visible_apps",
3954
- args,
3955
- "Failed to list visible apps"
3956
- );
4396
+ const result = await this.session.callMcpTool("list_visible_apps", {});
4397
+ if (!result.success) {
4398
+ return {
4399
+ requestId: result.requestId,
4400
+ success: false,
4401
+ data: [],
4402
+ errorMessage: result.errorMessage
4403
+ };
4404
+ }
3957
4405
  let processes = [];
3958
- if (result.textContent) {
3959
- processes = this.parseJSON(result.textContent);
4406
+ try {
4407
+ processes = this.parseJSON(result.data);
4408
+ } catch (err) {
4409
+ return {
4410
+ requestId: result.requestId,
4411
+ success: false,
4412
+ data: [],
4413
+ errorMessage: `Failed to parse visible apps: ${err}`
4414
+ };
3960
4415
  }
3961
4416
  return {
3962
- requestId: result.requestId || "",
4417
+ requestId: result.requestId,
3963
4418
  success: true,
3964
4419
  data: processes
3965
4420
  };
@@ -3976,114 +4431,20 @@ var _Application = class _Application {
3976
4431
  __name(_Application, "Application");
3977
4432
  var Application = _Application;
3978
4433
 
3979
- // src/command/command.ts
4434
+ // src/code/index.ts
3980
4435
  init_esm_shims();
3981
- var _Command = class _Command {
4436
+
4437
+ // src/code/code.ts
4438
+ init_esm_shims();
4439
+ var _Code = class _Code {
3982
4440
  /**
3983
- * Initialize a Command object.
4441
+ * Initialize a Code object.
3984
4442
  *
3985
- * @param session - The Session instance that this Command belongs to.
4443
+ * @param session - The Session instance that this Code belongs to.
3986
4444
  */
3987
4445
  constructor(session) {
3988
4446
  this.session = session;
3989
4447
  }
3990
- /**
3991
- * Helper method to call MCP tools and handle common response processing
3992
- *
3993
- * @param toolName - Name of the MCP tool to call
3994
- * @param args - Arguments to pass to the tool
3995
- * @param defaultErrorMsg - Default error message if specific error details are not available
3996
- * @returns A CallMcpToolResult with the response data
3997
- * @throws APIError if the call fails
3998
- */
3999
- async callMcpTool(toolName, args, defaultErrorMsg) {
4000
- try {
4001
- const argsJSON = JSON.stringify(args);
4002
- const callToolRequest = new CallMcpToolRequest({
4003
- authorization: `Bearer ${this.session.getAPIKey()}`,
4004
- sessionId: this.session.getSessionId(),
4005
- name: toolName,
4006
- args: argsJSON
4007
- });
4008
- log(`API Call: CallMcpTool - ${toolName}`);
4009
- log(
4010
- `Request: SessionId=${this.session.getSessionId()}, Args=${argsJSON}`
4011
- );
4012
- const response = await this.session.getClient().callMcpTool(callToolRequest);
4013
- log(`Response from CallMcpTool - ${toolName}:`, response.body);
4014
- if (!response.body?.data) {
4015
- throw new Error("Invalid response data format");
4016
- }
4017
- const data = response.body.data;
4018
- const result = {
4019
- data,
4020
- statusCode: response.statusCode || 0,
4021
- isError: false,
4022
- requestId: extractRequestId(response)
4023
- };
4024
- if (data.isError === true) {
4025
- result.isError = true;
4026
- const contentArray = data.content;
4027
- if (contentArray && contentArray.length > 0) {
4028
- result.content = contentArray;
4029
- if (contentArray[0]?.text) {
4030
- result.errorMsg = contentArray[0].text;
4031
- throw new Error(contentArray[0].text);
4032
- }
4033
- }
4034
- throw new Error(defaultErrorMsg);
4035
- }
4036
- if (Array.isArray(data.content)) {
4037
- result.content = data.content;
4038
- if (result.content.length > 0) {
4039
- const textParts = [];
4040
- for (const item of result.content) {
4041
- if (item && typeof item === "object" && item.text && typeof item.text === "string") {
4042
- textParts.push(item.text);
4043
- }
4044
- }
4045
- result.textContent = textParts.join("\n");
4046
- }
4047
- }
4048
- return result;
4049
- } catch (error) {
4050
- logError(`Error calling CallMcpTool - ${toolName}:`, error);
4051
- throw new APIError(`Failed to call ${toolName}: ${error}`);
4052
- }
4053
- }
4054
- /**
4055
- * Execute a command in the cloud environment with a specified timeout.
4056
- * Corresponds to Python's execute_command() method
4057
- *
4058
- * @param command - The command to execute.
4059
- * @param timeoutMs - The timeout for the command execution in milliseconds. Default is 1000ms.
4060
- * @returns CommandResult with command output and requestId
4061
- */
4062
- async executeCommand(command, timeoutMs = 1e3) {
4063
- try {
4064
- const args = {
4065
- command,
4066
- timeout_ms: timeoutMs
4067
- };
4068
- const result = await this.callMcpTool(
4069
- "shell",
4070
- args,
4071
- "Failed to execute command"
4072
- );
4073
- return {
4074
- requestId: result.requestId || "",
4075
- success: true,
4076
- output: result.textContent || ""
4077
- };
4078
- } catch (error) {
4079
- return {
4080
- requestId: "",
4081
- success: false,
4082
- output: "",
4083
- errorMessage: `Failed to execute command: ${error}`
4084
- };
4085
- }
4086
- }
4087
4448
  /**
4088
4449
  * Execute code in the specified language with a timeout.
4089
4450
  * Corresponds to Python's run_code() method
@@ -4109,15 +4470,22 @@ var _Command = class _Command {
4109
4470
  language,
4110
4471
  timeout_s: timeoutS
4111
4472
  };
4112
- const result = await this.callMcpTool(
4473
+ const response = await this.session.callMcpTool(
4113
4474
  "run_code",
4114
- args,
4115
- "Failed to execute code"
4475
+ args
4116
4476
  );
4477
+ if (!response.success) {
4478
+ return {
4479
+ requestId: response.requestId,
4480
+ success: false,
4481
+ result: "",
4482
+ errorMessage: response.errorMessage
4483
+ };
4484
+ }
4117
4485
  return {
4118
- requestId: result.requestId || "",
4486
+ requestId: response.requestId,
4119
4487
  success: true,
4120
- result: result.textContent || ""
4488
+ result: response.data || ""
4121
4489
  };
4122
4490
  } catch (error) {
4123
4491
  return {
@@ -4129,6 +4497,65 @@ var _Command = class _Command {
4129
4497
  }
4130
4498
  }
4131
4499
  };
4500
+ __name(_Code, "Code");
4501
+ var Code = _Code;
4502
+
4503
+ // src/command/command.ts
4504
+ init_esm_shims();
4505
+ var _Command = class _Command {
4506
+ /**
4507
+ * Initialize a Command object.
4508
+ *
4509
+ * @param session - The Session instance that this Command belongs to.
4510
+ */
4511
+ constructor(session) {
4512
+ this.session = session;
4513
+ }
4514
+ /**
4515
+ * Sanitizes error messages to remove sensitive information like API keys.
4516
+ *
4517
+ * @param error - The error to sanitize
4518
+ * @returns The sanitized error
4519
+ */
4520
+ sanitizeError(error) {
4521
+ if (!error) {
4522
+ return error;
4523
+ }
4524
+ const errorString = String(error);
4525
+ return errorString.replace(/Bearer\s+[^\s]+/g, "Bearer [REDACTED]");
4526
+ }
4527
+ /**
4528
+ * Execute a command in the session environment.
4529
+ * Corresponds to Python's execute_command() method
4530
+ *
4531
+ * @param command - The command to execute
4532
+ * @param timeoutMs - The timeout in milliseconds. Default is 1000ms.
4533
+ * @returns CommandResult with command output and requestId
4534
+ * @throws APIError if the operation fails.
4535
+ */
4536
+ async executeCommand(command, timeoutMs = 1e3) {
4537
+ try {
4538
+ const args = {
4539
+ command,
4540
+ timeout_ms: timeoutMs
4541
+ };
4542
+ const result = await this.session.callMcpTool("shell", args);
4543
+ return {
4544
+ requestId: result.requestId,
4545
+ success: result.success,
4546
+ output: result.data,
4547
+ errorMessage: result.errorMessage
4548
+ };
4549
+ } catch (error) {
4550
+ return {
4551
+ requestId: "",
4552
+ success: false,
4553
+ output: "",
4554
+ errorMessage: `Failed to execute command: ${error}`
4555
+ };
4556
+ }
4557
+ }
4558
+ };
4132
4559
  __name(_Command, "Command");
4133
4560
  var Command = _Command;
4134
4561
 
@@ -4256,27 +4683,6 @@ __name(newContextManager, "newContextManager");
4256
4683
  // src/filesystem/filesystem.ts
4257
4684
  init_esm_shims();
4258
4685
  var DEFAULT_CHUNK_SIZE = 60 * 1024;
4259
- var FILE_OPERATIONS = {
4260
- read_file: true,
4261
- write_file: true,
4262
- read_multiple_files: true
4263
- };
4264
- function isFileOperation(toolName) {
4265
- return FILE_OPERATIONS[toolName] === true;
4266
- }
4267
- __name(isFileOperation, "isFileOperation");
4268
- function truncateContentForLogging(args) {
4269
- const truncatedArgs = { ...args };
4270
- if (typeof truncatedArgs.content === "string") {
4271
- const contentLength = truncatedArgs.content.length;
4272
- truncatedArgs.content = `[Content length: ${contentLength} bytes]`;
4273
- }
4274
- if (Array.isArray(truncatedArgs.paths) && truncatedArgs.paths.length > 3) {
4275
- truncatedArgs.paths = `[${truncatedArgs.paths.length} paths, first few: ${truncatedArgs.paths[0]}, ${truncatedArgs.paths[1]}, ${truncatedArgs.paths[2]}, ...]`;
4276
- }
4277
- return truncatedArgs;
4278
- }
4279
- __name(truncateContentForLogging, "truncateContentForLogging");
4280
4686
  function parseFileInfo(fileInfoStr) {
4281
4687
  const result = {
4282
4688
  name: "",
@@ -4353,106 +4759,6 @@ var _FileSystem = class _FileSystem {
4353
4759
  constructor(session) {
4354
4760
  this.session = session;
4355
4761
  }
4356
- /**
4357
- * Helper method to call MCP tools and handle common response processing
4358
- *
4359
- * @param toolName - Name of the MCP tool to call
4360
- * @param args - Arguments to pass to the tool
4361
- * @param defaultErrorMsg - Default error message if specific error details are not available
4362
- * @returns A CallMcpToolResult with the response data
4363
- * @throws APIError if the call fails
4364
- */
4365
- async callMcpTool(toolName, args, defaultErrorMsg) {
4366
- try {
4367
- let loggableArgs = args;
4368
- if (isFileOperation(toolName)) {
4369
- loggableArgs = truncateContentForLogging(args);
4370
- }
4371
- const argsJSON = JSON.stringify(args);
4372
- const loggableArgsJSON = JSON.stringify(loggableArgs);
4373
- const callToolRequest = new CallMcpToolRequest({
4374
- authorization: `Bearer ${this.session.getAPIKey()}`,
4375
- sessionId: this.session.getSessionId(),
4376
- name: toolName,
4377
- args: argsJSON
4378
- });
4379
- log(`API Call: CallMcpTool - ${toolName}`);
4380
- log(
4381
- `Request: SessionId=${this.session.getSessionId()}, Args=${loggableArgsJSON}`
4382
- );
4383
- const response = await this.session.getClient().callMcpTool(callToolRequest);
4384
- if (isFileOperation(toolName)) {
4385
- log(
4386
- `Response from CallMcpTool - ${toolName} - status: ${response.statusCode}`
4387
- );
4388
- if (response.body?.data) {
4389
- const data2 = response.body.data;
4390
- if (data2.isError === true) {
4391
- log(`Response contains error: ${data2.isError}`);
4392
- } else {
4393
- log("Response successful, content length info provided separately");
4394
- if (Array.isArray(data2.content) && data2.content.length > 0) {
4395
- let totalSize = 0;
4396
- for (const item of data2.content) {
4397
- if (item && typeof item === "object" && item.text && typeof item.text === "string") {
4398
- totalSize += item.text.length;
4399
- }
4400
- }
4401
- log(`Content size: ${totalSize} bytes`);
4402
- }
4403
- }
4404
- }
4405
- } else {
4406
- const sanitizedBody = { ...response.body };
4407
- if (sanitizedBody.data && typeof sanitizedBody.data === "object") {
4408
- const sanitizedData = { ...sanitizedBody.data };
4409
- if (Array.isArray(sanitizedData.content)) {
4410
- sanitizedData.content = `[Array with ${sanitizedData.content.length} items]`;
4411
- }
4412
- sanitizedBody.data = sanitizedData;
4413
- }
4414
- log(`Response from CallMcpTool - ${toolName}:`, sanitizedBody);
4415
- }
4416
- if (!response.body?.data) {
4417
- throw new Error("Invalid response data format");
4418
- }
4419
- const data = response.body.data;
4420
- const result = {
4421
- data,
4422
- statusCode: response.statusCode || 0,
4423
- isError: false,
4424
- requestId: extractRequestId(response)
4425
- };
4426
- if (data.isError === true) {
4427
- result.isError = true;
4428
- const contentArray = data.content;
4429
- if (contentArray && contentArray.length > 0) {
4430
- result.content = contentArray;
4431
- if (contentArray[0]?.text) {
4432
- result.errorMsg = contentArray[0].text;
4433
- throw new Error(contentArray[0].text);
4434
- }
4435
- }
4436
- throw new Error(defaultErrorMsg);
4437
- }
4438
- if (Array.isArray(data.content)) {
4439
- result.content = data.content;
4440
- if (result.content.length > 0) {
4441
- const textParts = [];
4442
- for (const item of result.content) {
4443
- if (item && typeof item === "object" && item.text && typeof item.text === "string") {
4444
- textParts.push(item.text);
4445
- }
4446
- }
4447
- result.textContent = textParts.join("\n");
4448
- }
4449
- }
4450
- return result;
4451
- } catch (error) {
4452
- logError(`Error calling CallMcpTool - ${toolName}:`, error);
4453
- throw new APIError(`Failed to call ${toolName}: ${error}`);
4454
- }
4455
- }
4456
4762
  /**
4457
4763
  * Creates a new directory at the specified path.
4458
4764
  * Corresponds to Python's create_directory() method
@@ -4465,13 +4771,19 @@ var _FileSystem = class _FileSystem {
4465
4771
  const args = {
4466
4772
  path: path3
4467
4773
  };
4468
- const result = await this.callMcpTool(
4774
+ const result = await this.session.callMcpTool(
4469
4775
  "create_directory",
4470
- args,
4471
- "Failed to create directory"
4776
+ args
4472
4777
  );
4778
+ if (!result.success) {
4779
+ return {
4780
+ requestId: result.requestId,
4781
+ success: false,
4782
+ errorMessage: result.errorMessage
4783
+ };
4784
+ }
4473
4785
  return {
4474
- requestId: result.requestId || "",
4786
+ requestId: result.requestId,
4475
4787
  success: true,
4476
4788
  data: true
4477
4789
  };
@@ -4499,13 +4811,19 @@ var _FileSystem = class _FileSystem {
4499
4811
  edits,
4500
4812
  dryRun
4501
4813
  };
4502
- const result = await this.callMcpTool(
4814
+ const result = await this.session.callMcpTool(
4503
4815
  "edit_file",
4504
- args,
4505
- "Failed to edit file"
4816
+ args
4506
4817
  );
4818
+ if (!result.success) {
4819
+ return {
4820
+ requestId: result.requestId,
4821
+ success: false,
4822
+ errorMessage: result.errorMessage
4823
+ };
4824
+ }
4507
4825
  return {
4508
- requestId: result.requestId || "",
4826
+ requestId: result.requestId,
4509
4827
  success: true,
4510
4828
  data: true
4511
4829
  };
@@ -4529,22 +4847,29 @@ var _FileSystem = class _FileSystem {
4529
4847
  const args = {
4530
4848
  path: path3
4531
4849
  };
4532
- const result = await this.callMcpTool(
4850
+ const result = await this.session.callMcpTool(
4533
4851
  "get_file_info",
4534
- args,
4535
- "Failed to get file info"
4852
+ args
4536
4853
  );
4537
- if (!result.textContent) {
4854
+ if (!result.success) {
4538
4855
  return {
4539
- requestId: result.requestId || "",
4856
+ requestId: result.requestId,
4540
4857
  success: false,
4541
4858
  fileInfo: {},
4542
- errorMessage: "Empty response from get_file_info"
4859
+ errorMessage: result.errorMessage
4543
4860
  };
4544
4861
  }
4545
- const fileInfo = parseFileInfo(result.textContent);
4546
- return {
4547
- requestId: result.requestId || "",
4862
+ if (!result.data) {
4863
+ return {
4864
+ requestId: result.requestId,
4865
+ success: false,
4866
+ fileInfo: {},
4867
+ errorMessage: "Empty response from get_file_info"
4868
+ };
4869
+ }
4870
+ const fileInfo = parseFileInfo(result.data);
4871
+ return {
4872
+ requestId: result.requestId,
4548
4873
  success: true,
4549
4874
  fileInfo
4550
4875
  };
@@ -4568,14 +4893,21 @@ var _FileSystem = class _FileSystem {
4568
4893
  const args = {
4569
4894
  path: path3
4570
4895
  };
4571
- const result = await this.callMcpTool(
4896
+ const result = await this.session.callMcpTool(
4572
4897
  "list_directory",
4573
- args,
4574
- "Failed to list directory"
4898
+ args
4575
4899
  );
4576
- const entries = result.textContent ? parseDirectoryListing(result.textContent) : [];
4900
+ if (!result.success) {
4901
+ return {
4902
+ requestId: result.requestId,
4903
+ success: false,
4904
+ entries: [],
4905
+ errorMessage: result.errorMessage
4906
+ };
4907
+ }
4908
+ const entries = result.data ? parseDirectoryListing(result.data) : [];
4577
4909
  return {
4578
- requestId: result.requestId || "",
4910
+ requestId: result.requestId,
4579
4911
  success: true,
4580
4912
  entries
4581
4913
  };
@@ -4602,13 +4934,19 @@ var _FileSystem = class _FileSystem {
4602
4934
  source,
4603
4935
  destination
4604
4936
  };
4605
- const result = await this.callMcpTool(
4937
+ const result = await this.session.callMcpTool(
4606
4938
  "move_file",
4607
- args,
4608
- "Failed to move file"
4939
+ args
4609
4940
  );
4941
+ if (!result.success) {
4942
+ return {
4943
+ requestId: result.requestId,
4944
+ success: false,
4945
+ errorMessage: result.errorMessage
4946
+ };
4947
+ }
4610
4948
  return {
4611
- requestId: result.requestId || "",
4949
+ requestId: result.requestId,
4612
4950
  success: true,
4613
4951
  data: true
4614
4952
  };
@@ -4625,8 +4963,8 @@ var _FileSystem = class _FileSystem {
4625
4963
  * Corresponds to Python's read_file() method
4626
4964
  *
4627
4965
  * @param path - Path to the file to read.
4628
- * @param offset - Optional: Line offset to start reading from.
4629
- * @param length - Optional: Number of lines to read. If 0, reads the entire file.
4966
+ * @param offset - Optional: Byte offset to start reading from (0-based).
4967
+ * @param length - Optional: Number of bytes to read. If 0, reads the entire file from offset.
4630
4968
  * @returns FileContentResult with file content and requestId
4631
4969
  */
4632
4970
  async readFile(path3, offset = 0, length = 0) {
@@ -4640,15 +4978,22 @@ var _FileSystem = class _FileSystem {
4640
4978
  if (length > 0) {
4641
4979
  args.length = length;
4642
4980
  }
4643
- const result = await this.callMcpTool(
4981
+ const result = await this.session.callMcpTool(
4644
4982
  "read_file",
4645
- args,
4646
- "Failed to read file"
4983
+ args
4647
4984
  );
4985
+ if (!result.success) {
4986
+ return {
4987
+ requestId: result.requestId,
4988
+ success: false,
4989
+ content: "",
4990
+ errorMessage: result.errorMessage
4991
+ };
4992
+ }
4648
4993
  return {
4649
- requestId: result.requestId || "",
4994
+ requestId: result.requestId,
4650
4995
  success: true,
4651
- content: result.textContent || ""
4996
+ content: result.data || ""
4652
4997
  };
4653
4998
  } catch (error) {
4654
4999
  return {
@@ -4671,14 +5016,21 @@ var _FileSystem = class _FileSystem {
4671
5016
  const args = {
4672
5017
  paths
4673
5018
  };
4674
- const result = await this.callMcpTool(
5019
+ const result = await this.session.callMcpTool(
4675
5020
  "read_multiple_files",
4676
- args,
4677
- "Failed to read multiple files"
5021
+ args
4678
5022
  );
5023
+ if (!result.success) {
5024
+ return {
5025
+ requestId: result.requestId,
5026
+ success: false,
5027
+ contents: {},
5028
+ errorMessage: result.errorMessage
5029
+ };
5030
+ }
4679
5031
  const fileContents = {};
4680
- if (result.textContent) {
4681
- const lines = result.textContent.split("\n");
5032
+ if (result.data) {
5033
+ const lines = result.data.split("\n");
4682
5034
  let currentPath = "";
4683
5035
  let currentContent = [];
4684
5036
  for (const line of lines) {
@@ -4710,7 +5062,7 @@ var _FileSystem = class _FileSystem {
4710
5062
  }
4711
5063
  }
4712
5064
  return {
4713
- requestId: result.requestId || "",
5065
+ requestId: result.requestId,
4714
5066
  success: true,
4715
5067
  contents: fileContents
4716
5068
  };
@@ -4739,19 +5091,26 @@ var _FileSystem = class _FileSystem {
4739
5091
  pattern
4740
5092
  };
4741
5093
  if (excludePatterns.length > 0) {
4742
- args.exclude_patterns = excludePatterns;
5094
+ args.excludePatterns = excludePatterns;
4743
5095
  }
4744
- const result = await this.callMcpTool(
5096
+ const result = await this.session.callMcpTool(
4745
5097
  "search_files",
4746
- args,
4747
- "Failed to search files"
5098
+ args
4748
5099
  );
5100
+ if (!result.success) {
5101
+ return {
5102
+ requestId: result.requestId,
5103
+ success: false,
5104
+ matches: [],
5105
+ errorMessage: result.errorMessage
5106
+ };
5107
+ }
4749
5108
  let searchResults = [];
4750
- if (result.textContent) {
4751
- searchResults = result.textContent.split("\n").map((line) => line.trim()).filter((line) => line !== "");
5109
+ if (result.data) {
5110
+ searchResults = result.data.split("\n").map((line) => line.trim()).filter((line) => line !== "");
4752
5111
  }
4753
5112
  return {
4754
- requestId: result.requestId || "",
5113
+ requestId: result.requestId,
4755
5114
  success: true,
4756
5115
  matches: searchResults
4757
5116
  };
@@ -4790,13 +5149,19 @@ var _FileSystem = class _FileSystem {
4790
5149
  content,
4791
5150
  mode
4792
5151
  };
4793
- const result = await this.callMcpTool(
5152
+ const result = await this.session.callMcpTool(
4794
5153
  "write_file",
4795
- args,
4796
- "Failed to write file"
5154
+ args
4797
5155
  );
5156
+ if (!result.success) {
5157
+ return {
5158
+ requestId: result.requestId,
5159
+ success: false,
5160
+ errorMessage: result.errorMessage
5161
+ };
5162
+ }
4798
5163
  return {
4799
- requestId: result.requestId || "",
5164
+ requestId: result.requestId,
4800
5165
  success: true,
4801
5166
  data: true
4802
5167
  };
@@ -4846,17 +5211,11 @@ var _FileSystem = class _FileSystem {
4846
5211
  let result = "";
4847
5212
  let offset = 0;
4848
5213
  let chunkCount = 0;
4849
- log(
4850
- `ReadLargeFile: Starting chunked read of ${path3} (total size: ${fileSize} bytes, chunk size: ${chunkSize} bytes)`
4851
- );
4852
5214
  while (offset < fileSize) {
4853
5215
  let length = chunkSize;
4854
5216
  if (offset + length > fileSize) {
4855
5217
  length = fileSize - offset;
4856
5218
  }
4857
- log(
4858
- `ReadLargeFile: Reading chunk ${chunkCount + 1} (${length} bytes at offset ${offset}/${fileSize})`
4859
- );
4860
5219
  try {
4861
5220
  const chunkResult = await this.readFile(path3, offset, length);
4862
5221
  if (!chunkResult.success) {
@@ -4866,7 +5225,6 @@ var _FileSystem = class _FileSystem {
4866
5225
  offset += length;
4867
5226
  chunkCount++;
4868
5227
  } catch (error) {
4869
- logError(`Error reading chunk at offset ${offset}: ${error}`);
4870
5228
  return {
4871
5229
  requestId: fileInfoResult.requestId,
4872
5230
  success: false,
@@ -4875,9 +5233,6 @@ var _FileSystem = class _FileSystem {
4875
5233
  };
4876
5234
  }
4877
5235
  }
4878
- log(
4879
- `ReadLargeFile: Successfully read ${path3} in ${chunkCount} chunks (total: ${fileSize} bytes)`
4880
- );
4881
5236
  return {
4882
5237
  requestId: fileInfoResult.requestId,
4883
5238
  success: true,
@@ -4904,19 +5259,10 @@ var _FileSystem = class _FileSystem {
4904
5259
  async writeLargeFile(path3, content, chunkSize = DEFAULT_CHUNK_SIZE) {
4905
5260
  try {
4906
5261
  const contentLen = content.length;
4907
- log(
4908
- `WriteLargeFile: Starting chunked write to ${path3} (total size: ${contentLen} bytes, chunk size: ${chunkSize} bytes)`
4909
- );
4910
5262
  if (contentLen <= chunkSize) {
4911
- log(
4912
- `WriteLargeFile: Content size (${contentLen} bytes) is smaller than chunk size, using normal WriteFile`
4913
- );
4914
5263
  return await this.writeFile(path3, content, "overwrite");
4915
5264
  }
4916
5265
  const firstChunkEnd = Math.min(chunkSize, contentLen);
4917
- log(
4918
- `WriteLargeFile: Writing first chunk (0-${firstChunkEnd} bytes) with overwrite mode`
4919
- );
4920
5266
  const firstResult = await this.writeFile(
4921
5267
  path3,
4922
5268
  content.substring(0, firstChunkEnd),
@@ -4928,9 +5274,6 @@ var _FileSystem = class _FileSystem {
4928
5274
  let chunkCount = 1;
4929
5275
  for (let offset = firstChunkEnd; offset < contentLen; ) {
4930
5276
  const end = Math.min(offset + chunkSize, contentLen);
4931
- log(
4932
- `WriteLargeFile: Writing chunk ${chunkCount + 1} (${offset}-${end} bytes) with append mode`
4933
- );
4934
5277
  const chunkResult = await this.writeFile(
4935
5278
  path3,
4936
5279
  content.substring(offset, end),
@@ -4942,9 +5285,6 @@ var _FileSystem = class _FileSystem {
4942
5285
  offset = end;
4943
5286
  chunkCount++;
4944
5287
  }
4945
- log(
4946
- `WriteLargeFile: Successfully wrote ${path3} in ${chunkCount} chunks (total: ${contentLen} bytes)`
4947
- );
4948
5288
  return {
4949
5289
  requestId: firstResult.requestId,
4950
5290
  success: true,
@@ -4977,113 +5317,64 @@ var _Oss = class _Oss {
4977
5317
  this.session = session;
4978
5318
  }
4979
5319
  /**
4980
- * Helper method to call MCP tools and handle common response processing
5320
+ * Sanitizes error messages to remove sensitive information like API keys.
4981
5321
  *
4982
- * @param toolName - Name of the MCP tool to call
4983
- * @param args - Arguments to pass to the tool
4984
- * @param defaultErrorMsg - Default error message if specific error details are not available
4985
- * @returns A CallMcpToolResult with the response data
4986
- * @throws APIError if the call fails
5322
+ * @param error - The error to sanitize
5323
+ * @returns The sanitized error
4987
5324
  */
4988
- async callMcpTool(toolName, args, defaultErrorMsg) {
4989
- try {
4990
- const callToolRequest = new CallMcpToolRequest({
4991
- authorization: `Bearer ${this.session.getAPIKey()}`,
4992
- sessionId: this.session.getSessionId(),
4993
- name: toolName,
4994
- args: JSON.stringify(args)
4995
- });
4996
- log(`API Call: CallMcpTool - ${toolName}`);
4997
- log(
4998
- `Request: SessionId=${this.session.getSessionId()}, Args=${JSON.stringify(
4999
- args
5000
- )}`
5001
- );
5002
- const response = await this.session.getClient().callMcpTool(callToolRequest);
5003
- log(`Response from CallMcpTool - ${toolName}:`, response.body);
5004
- if (!response.body?.data) {
5005
- throw new Error("Invalid response data format");
5006
- }
5007
- const data = response.body.data;
5008
- const result = {
5009
- data,
5010
- statusCode: response.statusCode || 0,
5011
- isError: false,
5012
- requestId: extractRequestId(response)
5013
- };
5014
- if (data.isError === true) {
5015
- result.isError = true;
5016
- const contentArray = data.content;
5017
- if (contentArray && contentArray.length > 0) {
5018
- result.content = contentArray;
5019
- if (contentArray[0]?.text) {
5020
- result.errorMsg = contentArray[0].text;
5021
- throw new Error(contentArray[0].text);
5022
- }
5023
- }
5024
- throw new Error(defaultErrorMsg);
5025
- }
5026
- if (Array.isArray(data.content)) {
5027
- result.content = data.content;
5028
- if (result.content.length > 0) {
5029
- const textParts = [];
5030
- for (const item of result.content) {
5031
- if (item && typeof item === "object" && item.text && typeof item.text === "string") {
5032
- textParts.push(item.text);
5033
- }
5034
- }
5035
- result.textContent = textParts.join("\n");
5036
- }
5037
- }
5038
- return result;
5039
- } catch (error) {
5040
- logError(`Error calling CallMcpTool - ${toolName}:`, error);
5041
- throw new APIError(`Failed to call MCP tool ${toolName}: ${error}`);
5325
+ sanitizeError(error) {
5326
+ if (!error) {
5327
+ return error;
5042
5328
  }
5329
+ const errorString = String(error);
5330
+ return errorString.replace(/Bearer\s+[^\s]+/g, "Bearer [REDACTED]");
5043
5331
  }
5044
5332
  /**
5045
5333
  * Initialize OSS environment variables with the specified credentials.
5046
5334
  * Corresponds to Python's env_init() method
5047
5335
  *
5048
- * @param accessKeyId - The Access Key ID for OSS authentication.
5049
- * @param accessKeySecret - The Access Key Secret for OSS authentication.
5050
- * @param securityToken - The security token for OSS authentication.
5051
- * @param endpoint - The OSS service endpoint. If not specified, the default is used.
5052
- * @param region - The OSS region. If not specified, the default is used.
5053
- * @returns OSSClientResult with initialization result and requestId
5336
+ * @param accessKeyId - The access key ID
5337
+ * @param accessKeySecret - The access key secret
5338
+ * @param securityToken - The security token (optional)
5339
+ * @param endpoint - The OSS endpoint (optional)
5340
+ * @param region - The OSS region (optional)
5341
+ * @returns OSSClientResult with client configuration and requestId
5342
+ * @throws APIError if the operation fails.
5054
5343
  */
5055
5344
  async envInit(accessKeyId, accessKeySecret, securityToken, endpoint, region) {
5056
5345
  try {
5057
5346
  const args = {
5058
5347
  access_key_id: accessKeyId,
5059
- access_key_secret: accessKeySecret
5348
+ access_key_secret: accessKeySecret,
5349
+ security_token: securityToken || "",
5350
+ endpoint: endpoint || "",
5351
+ region: region || ""
5060
5352
  };
5061
- if (securityToken) {
5062
- args.security_token = securityToken;
5063
- }
5064
- if (endpoint) {
5065
- args.endpoint = endpoint;
5066
- }
5067
- if (region) {
5068
- args.region = region;
5353
+ const result = await this.session.callMcpTool("oss_env_init", args);
5354
+ if (!result.success) {
5355
+ return {
5356
+ requestId: result.requestId,
5357
+ success: false,
5358
+ clientConfig: {},
5359
+ errorMessage: result.errorMessage
5360
+ };
5069
5361
  }
5070
- const result = await this.callMcpTool(
5071
- "oss_env_init",
5072
- args,
5073
- "Failed to initialize OSS environment"
5074
- );
5075
5362
  let clientConfig = {};
5076
- if (result.textContent) {
5077
- try {
5078
- clientConfig = JSON.parse(result.textContent);
5079
- } catch (parseError) {
5080
- clientConfig = { data: result.textContent };
5081
- }
5363
+ try {
5364
+ clientConfig = JSON.parse(result.data);
5365
+ } catch (err) {
5366
+ return {
5367
+ requestId: result.requestId,
5368
+ success: false,
5369
+ clientConfig: {},
5370
+ errorMessage: `Failed to parse client config: ${err}`
5371
+ };
5082
5372
  }
5083
5373
  return {
5084
- requestId: result.requestId || "",
5374
+ requestId: result.requestId,
5085
5375
  success: true,
5086
- clientConfig
5376
+ clientConfig,
5377
+ errorMessage: ""
5087
5378
  };
5088
5379
  } catch (error) {
5089
5380
  return {
@@ -5095,13 +5386,14 @@ var _Oss = class _Oss {
5095
5386
  }
5096
5387
  }
5097
5388
  /**
5098
- * Upload a local file or directory to OSS.
5389
+ * Upload a file to OSS.
5099
5390
  * Corresponds to Python's upload() method
5100
5391
  *
5101
- * @param bucket - OSS bucket name.
5102
- * @param object - ObjectS.
5103
- * @param path - Local file or directory path to upload.
5392
+ * @param bucket - The OSS bucket name
5393
+ * @param object - The OSS object key
5394
+ * @param path - The local file path to upload
5104
5395
  * @returns OSSUploadResult with upload result and requestId
5396
+ * @throws APIError if the operation fails.
5105
5397
  */
5106
5398
  async upload(bucket, object, path3) {
5107
5399
  try {
@@ -5110,32 +5402,30 @@ var _Oss = class _Oss {
5110
5402
  object,
5111
5403
  path: path3
5112
5404
  };
5113
- const result = await this.callMcpTool(
5114
- "oss_upload",
5115
- args,
5116
- "Failed to upload to OSS"
5117
- );
5405
+ const result = await this.session.callMcpTool("oss_upload", args);
5118
5406
  return {
5119
- requestId: result.requestId || "",
5120
- success: true,
5121
- content: result.textContent || ""
5407
+ requestId: result.requestId,
5408
+ success: result.success,
5409
+ content: result.data,
5410
+ errorMessage: result.errorMessage
5122
5411
  };
5123
5412
  } catch (error) {
5124
5413
  return {
5125
5414
  requestId: "",
5126
5415
  success: false,
5127
5416
  content: "",
5128
- errorMessage: `Failed to upload to OSS: ${error}`
5417
+ errorMessage: `Failed to upload file: ${error}`
5129
5418
  };
5130
5419
  }
5131
5420
  }
5132
5421
  /**
5133
- * Upload a local file or directory to OSS using a pre-signed URL.
5422
+ * Upload a file to OSS using an anonymous URL.
5134
5423
  * Corresponds to Python's upload_anonymous() method
5135
5424
  *
5136
- * @param url - Pre-signed URL for anonymous upload.
5137
- * @param path - Local file or directory path to upload.
5425
+ * @param url - The anonymous upload URL
5426
+ * @param path - The local file path to upload
5138
5427
  * @returns OSSUploadResult with upload result and requestId
5428
+ * @throws APIError if the operation fails.
5139
5429
  */
5140
5430
  async uploadAnonymous(url, path3) {
5141
5431
  try {
@@ -5143,33 +5433,31 @@ var _Oss = class _Oss {
5143
5433
  url,
5144
5434
  path: path3
5145
5435
  };
5146
- const result = await this.callMcpTool(
5147
- "oss_upload_annon",
5148
- args,
5149
- "Failed to upload anonymously"
5150
- );
5436
+ const result = await this.session.callMcpTool("oss_upload_anonymous", args);
5151
5437
  return {
5152
- requestId: result.requestId || "",
5153
- success: true,
5154
- content: result.textContent || ""
5438
+ requestId: result.requestId,
5439
+ success: result.success,
5440
+ content: result.data,
5441
+ errorMessage: result.errorMessage
5155
5442
  };
5156
5443
  } catch (error) {
5157
5444
  return {
5158
5445
  requestId: "",
5159
5446
  success: false,
5160
5447
  content: "",
5161
- errorMessage: `Failed to upload anonymously: ${error}`
5448
+ errorMessage: `Failed to upload file anonymously: ${error}`
5162
5449
  };
5163
5450
  }
5164
5451
  }
5165
5452
  /**
5166
- * Download an object from OSS to a local file or directory.
5453
+ * Download a file from OSS.
5167
5454
  * Corresponds to Python's download() method
5168
5455
  *
5169
- * @param bucket - OSS bucket name.
5170
- * @param object - Object key in OSS.
5171
- * @param path - Local file or directory path to save the downloaded content.
5456
+ * @param bucket - The OSS bucket name
5457
+ * @param object - The OSS object key
5458
+ * @param path - The local file path to save the downloaded file
5172
5459
  * @returns OSSDownloadResult with download result and requestId
5460
+ * @throws APIError if the operation fails.
5173
5461
  */
5174
5462
  async download(bucket, object, path3) {
5175
5463
  try {
@@ -5178,32 +5466,30 @@ var _Oss = class _Oss {
5178
5466
  object,
5179
5467
  path: path3
5180
5468
  };
5181
- const result = await this.callMcpTool(
5182
- "oss_download",
5183
- args,
5184
- "Failed to download from OSS"
5185
- );
5469
+ const result = await this.session.callMcpTool("oss_download", args);
5186
5470
  return {
5187
- requestId: result.requestId || "",
5188
- success: true,
5189
- content: result.textContent || ""
5471
+ requestId: result.requestId,
5472
+ success: result.success,
5473
+ content: result.data,
5474
+ errorMessage: result.errorMessage
5190
5475
  };
5191
5476
  } catch (error) {
5192
5477
  return {
5193
5478
  requestId: "",
5194
5479
  success: false,
5195
5480
  content: "",
5196
- errorMessage: `Failed to download from OSS: ${error}`
5481
+ errorMessage: `Failed to download file: ${error}`
5197
5482
  };
5198
5483
  }
5199
5484
  }
5200
5485
  /**
5201
- * Download an object from OSS using a pre-signed URL.
5486
+ * Download a file from OSS using an anonymous URL.
5202
5487
  * Corresponds to Python's download_anonymous() method
5203
5488
  *
5204
- * @param url - Pre-signed URL for anonymous download.
5205
- * @param path - Local file or directory path to save the downloaded content.
5489
+ * @param url - The anonymous download URL
5490
+ * @param path - The local file path to save the downloaded file
5206
5491
  * @returns OSSDownloadResult with download result and requestId
5492
+ * @throws APIError if the operation fails.
5207
5493
  */
5208
5494
  async downloadAnonymous(url, path3) {
5209
5495
  try {
@@ -5211,22 +5497,19 @@ var _Oss = class _Oss {
5211
5497
  url,
5212
5498
  path: path3
5213
5499
  };
5214
- const result = await this.callMcpTool(
5215
- "oss_download_annon",
5216
- args,
5217
- "Failed to download anonymously"
5218
- );
5500
+ const result = await this.session.callMcpTool("oss_download_anonymous", args);
5219
5501
  return {
5220
- requestId: result.requestId || "",
5221
- success: true,
5222
- content: result.textContent || ""
5502
+ requestId: result.requestId,
5503
+ success: result.success,
5504
+ content: result.data,
5505
+ errorMessage: result.errorMessage
5223
5506
  };
5224
5507
  } catch (error) {
5225
5508
  return {
5226
5509
  requestId: "",
5227
5510
  success: false,
5228
5511
  content: "",
5229
- errorMessage: `Failed to download anonymously: ${error}`
5512
+ errorMessage: `Failed to download file anonymously: ${error}`
5230
5513
  };
5231
5514
  }
5232
5515
  }
@@ -5236,14 +5519,15 @@ var Oss = _Oss;
5236
5519
 
5237
5520
  // src/ui/ui.ts
5238
5521
  init_esm_shims();
5239
- var KeyCode = {
5240
- HOME: 3,
5241
- BACK: 4,
5242
- VOLUME_UP: 24,
5243
- VOLUME_DOWN: 25,
5244
- POWER: 26,
5245
- MENU: 82
5246
- };
5522
+ var KeyCode = /* @__PURE__ */ ((KeyCode2) => {
5523
+ KeyCode2[KeyCode2["HOME"] = 3] = "HOME";
5524
+ KeyCode2[KeyCode2["BACK"] = 4] = "BACK";
5525
+ KeyCode2[KeyCode2["VOLUME_UP"] = 24] = "VOLUME_UP";
5526
+ KeyCode2[KeyCode2["VOLUME_DOWN"] = 25] = "VOLUME_DOWN";
5527
+ KeyCode2[KeyCode2["POWER"] = 26] = "POWER";
5528
+ KeyCode2[KeyCode2["MENU"] = 82] = "MENU";
5529
+ return KeyCode2;
5530
+ })(KeyCode || {});
5247
5531
  var _UI = class _UI {
5248
5532
  /**
5249
5533
  * Initialize a UI object.
@@ -5254,68 +5538,17 @@ var _UI = class _UI {
5254
5538
  this.session = session;
5255
5539
  }
5256
5540
  /**
5257
- * Helper method to call MCP tools and handle common response processing
5541
+ * Sanitizes error messages to remove sensitive information like API keys.
5258
5542
  *
5259
- * @param toolName - Name of the MCP tool to call
5260
- * @param args - Arguments to pass to the tool
5261
- * @param defaultErrorMsg - Default error message if specific error details are not available
5262
- * @returns A CallMcpToolResult with the response data
5263
- * @throws APIError if the call fails
5543
+ * @param error - The error to sanitize
5544
+ * @returns The sanitized error
5264
5545
  */
5265
- async callMcpTool(toolName, args, defaultErrorMsg) {
5266
- try {
5267
- const argsJSON = JSON.stringify(args);
5268
- const callToolRequest = new CallMcpToolRequest({
5269
- authorization: `Bearer ${this.session.getAPIKey()}`,
5270
- sessionId: this.session.getSessionId(),
5271
- name: toolName,
5272
- args: argsJSON
5273
- });
5274
- log(`API Call: CallMcpTool - ${toolName}`);
5275
- log(
5276
- `Request: SessionId=${this.session.getSessionId()}, Args=${argsJSON}`
5277
- );
5278
- const response = await this.session.getClient().callMcpTool(callToolRequest);
5279
- log(`Response from CallMcpTool - ${toolName}:`, response.body);
5280
- if (!response.body?.data) {
5281
- throw new Error("Invalid response data format");
5282
- }
5283
- const data = response.body.data;
5284
- const result = {
5285
- data,
5286
- statusCode: response.statusCode || 0,
5287
- isError: false,
5288
- requestId: extractRequestId(response)
5289
- };
5290
- if (data.isError === true) {
5291
- result.isError = true;
5292
- const contentArray = data.content;
5293
- if (contentArray && contentArray.length > 0) {
5294
- result.content = contentArray;
5295
- if (contentArray[0]?.text) {
5296
- result.errorMsg = contentArray[0].text;
5297
- throw new Error(contentArray[0].text);
5298
- }
5299
- }
5300
- throw new Error(defaultErrorMsg);
5301
- }
5302
- if (Array.isArray(data.content)) {
5303
- result.content = data.content;
5304
- if (result.content.length > 0) {
5305
- const textParts = [];
5306
- for (const item of result.content) {
5307
- if (item && typeof item === "object" && item.text && typeof item.text === "string") {
5308
- textParts.push(item.text);
5309
- }
5310
- }
5311
- result.textContent = textParts.join("\n");
5312
- }
5313
- }
5314
- return result;
5315
- } catch (error) {
5316
- logError(`Error calling CallMcpTool - ${toolName}:`, error);
5317
- throw new APIError(`Failed to call ${toolName}: ${error}`);
5546
+ sanitizeError(error) {
5547
+ if (!error) {
5548
+ return error;
5318
5549
  }
5550
+ const errorString = String(error);
5551
+ return errorString.replace(/Bearer\s+[^\s]+/g, "Bearer [REDACTED]");
5319
5552
  }
5320
5553
  /**
5321
5554
  * Retrieves all clickable UI elements within the specified timeout.
@@ -5323,32 +5556,33 @@ var _UI = class _UI {
5323
5556
  *
5324
5557
  * @param timeoutMs - The timeout in milliseconds. Default is 2000ms.
5325
5558
  * @returns UIElementListResult with clickable UI elements and requestId
5559
+ * @throws APIError if the operation fails.
5326
5560
  */
5327
5561
  async getClickableUIElements(timeoutMs = 2e3) {
5328
5562
  try {
5329
- const args = {
5330
- timeout_ms: timeoutMs
5331
- };
5332
- const result = await this.callMcpTool(
5333
- "get_clickable_ui_elements",
5334
- args,
5335
- "Failed to get clickable UI elements"
5336
- );
5563
+ const args = { timeout_ms: timeoutMs };
5564
+ const result = await this.session.callMcpTool("get_clickable_ui_elements", args);
5565
+ if (!result.success) {
5566
+ return {
5567
+ requestId: result.requestId,
5568
+ success: false,
5569
+ elements: [],
5570
+ errorMessage: result.errorMessage
5571
+ };
5572
+ }
5337
5573
  let elements = [];
5338
- if (result.textContent) {
5339
- try {
5340
- elements = JSON.parse(result.textContent);
5341
- } catch (error) {
5342
- return {
5343
- requestId: result.requestId || "",
5344
- success: false,
5345
- elements: [],
5346
- errorMessage: `Failed to parse clickable UI elements: ${error}`
5347
- };
5348
- }
5574
+ try {
5575
+ elements = JSON.parse(result.data);
5576
+ } catch (err) {
5577
+ return {
5578
+ requestId: result.requestId,
5579
+ success: false,
5580
+ elements: [],
5581
+ errorMessage: `Failed to parse UI elements: ${err}`
5582
+ };
5349
5583
  }
5350
5584
  return {
5351
- requestId: result.requestId || "",
5585
+ requestId: result.requestId,
5352
5586
  success: true,
5353
5587
  elements
5354
5588
  };
@@ -5362,37 +5596,38 @@ var _UI = class _UI {
5362
5596
  }
5363
5597
  }
5364
5598
  /**
5365
- * Retrieves all UI elements within the specified timeout.
5599
+ * Retrieves all UI elements regardless of their clickable status.
5366
5600
  * Corresponds to Python's get_all_ui_elements() method
5367
5601
  *
5368
5602
  * @param timeoutMs - The timeout in milliseconds. Default is 2000ms.
5369
5603
  * @returns UIElementListResult with all UI elements and requestId
5604
+ * @throws APIError if the operation fails.
5370
5605
  */
5371
5606
  async getAllUIElements(timeoutMs = 2e3) {
5372
5607
  try {
5373
- const args = {
5374
- timeout_ms: timeoutMs
5375
- };
5376
- const result = await this.callMcpTool(
5377
- "get_all_ui_elements",
5378
- args,
5379
- "Failed to get all UI elements"
5380
- );
5608
+ const args = { timeout_ms: timeoutMs };
5609
+ const result = await this.session.callMcpTool("get_all_ui_elements", args);
5610
+ if (!result.success) {
5611
+ return {
5612
+ requestId: result.requestId,
5613
+ success: false,
5614
+ elements: [],
5615
+ errorMessage: result.errorMessage
5616
+ };
5617
+ }
5381
5618
  let elements = [];
5382
- if (result.textContent) {
5383
- try {
5384
- elements = JSON.parse(result.textContent);
5385
- } catch (error) {
5386
- return {
5387
- requestId: result.requestId || "",
5388
- success: false,
5389
- elements: [],
5390
- errorMessage: `Failed to parse all UI elements: ${error}`
5391
- };
5392
- }
5619
+ try {
5620
+ elements = JSON.parse(result.data);
5621
+ } catch (err) {
5622
+ return {
5623
+ requestId: result.requestId,
5624
+ success: false,
5625
+ elements: [],
5626
+ errorMessage: `Failed to parse UI elements: ${err}`
5627
+ };
5393
5628
  }
5394
5629
  return {
5395
- requestId: result.requestId || "",
5630
+ requestId: result.requestId,
5396
5631
  success: true,
5397
5632
  elements
5398
5633
  };
@@ -5409,58 +5644,58 @@ var _UI = class _UI {
5409
5644
  * Sends a key press event.
5410
5645
  * Corresponds to Python's send_key() method
5411
5646
  *
5412
- * @param key - The key code to send.
5413
- * @returns BoolResult with key press result and requestId
5647
+ * @param key - The key code to send. Supported key codes are:
5648
+ * - 3 : HOME
5649
+ * - 4 : BACK
5650
+ * - 24 : VOLUME UP
5651
+ * - 25 : VOLUME DOWN
5652
+ * - 26 : POWER
5653
+ * - 82 : MENU
5654
+ * @returns BoolResult with success status and requestId
5655
+ * @throws APIError if the operation fails.
5414
5656
  */
5415
5657
  async sendKey(key) {
5416
5658
  try {
5417
- const args = {
5418
- key
5419
- };
5420
- const result = await this.callMcpTool(
5421
- "send_key",
5422
- args,
5423
- "Failed to send key"
5424
- );
5659
+ const args = { key };
5660
+ const result = await this.session.callMcpTool("send_key", args);
5425
5661
  return {
5426
- requestId: result.requestId || "",
5427
- success: true,
5428
- data: true
5662
+ requestId: result.requestId,
5663
+ success: result.success,
5664
+ data: result.success,
5665
+ errorMessage: result.errorMessage
5429
5666
  };
5430
5667
  } catch (error) {
5431
5668
  return {
5432
5669
  requestId: "",
5433
5670
  success: false,
5671
+ data: false,
5434
5672
  errorMessage: `Failed to send key: ${error}`
5435
5673
  };
5436
5674
  }
5437
5675
  }
5438
5676
  /**
5439
- * Inputs text into the active field.
5677
+ * Inputs text into the currently focused UI element.
5440
5678
  * Corresponds to Python's input_text() method
5441
5679
  *
5442
- * @param text - The text to input.
5443
- * @returns BoolResult with input result and requestId
5680
+ * @param text - The text to input
5681
+ * @returns BoolResult with success status and requestId
5682
+ * @throws APIError if the operation fails.
5444
5683
  */
5445
5684
  async inputText(text) {
5446
5685
  try {
5447
- const args = {
5448
- text
5449
- };
5450
- const result = await this.callMcpTool(
5451
- "input_text",
5452
- args,
5453
- "Failed to input text"
5454
- );
5686
+ const args = { text };
5687
+ const result = await this.session.callMcpTool("input_text", args);
5455
5688
  return {
5456
- requestId: result.requestId || "",
5457
- success: true,
5458
- data: true
5689
+ requestId: result.requestId,
5690
+ success: result.success,
5691
+ data: result.success,
5692
+ errorMessage: result.errorMessage
5459
5693
  };
5460
5694
  } catch (error) {
5461
5695
  return {
5462
5696
  requestId: "",
5463
5697
  success: false,
5698
+ data: false,
5464
5699
  errorMessage: `Failed to input text: ${error}`
5465
5700
  };
5466
5701
  }
@@ -5469,12 +5704,13 @@ var _UI = class _UI {
5469
5704
  * Performs a swipe gesture on the screen.
5470
5705
  * Corresponds to Python's swipe() method
5471
5706
  *
5472
- * @param startX - The starting X coordinate.
5473
- * @param startY - The starting Y coordinate.
5474
- * @param endX - The ending X coordinate.
5475
- * @param endY - The ending Y coordinate.
5707
+ * @param startX - The starting X coordinate
5708
+ * @param startY - The starting Y coordinate
5709
+ * @param endX - The ending X coordinate
5710
+ * @param endY - The ending Y coordinate
5476
5711
  * @param durationMs - The duration of the swipe in milliseconds. Default is 300ms.
5477
- * @returns BoolResult with swipe result and requestId
5712
+ * @returns BoolResult with success status and requestId
5713
+ * @throws APIError if the operation fails.
5478
5714
  */
5479
5715
  async swipe(startX, startY, endX, endY, durationMs = 300) {
5480
5716
  try {
@@ -5485,55 +5721,48 @@ var _UI = class _UI {
5485
5721
  end_y: endY,
5486
5722
  duration_ms: durationMs
5487
5723
  };
5488
- const result = await this.callMcpTool(
5489
- "swipe",
5490
- args,
5491
- "Failed to perform swipe"
5492
- );
5724
+ const result = await this.session.callMcpTool("swipe", args);
5493
5725
  return {
5494
- requestId: result.requestId || "",
5495
- success: true,
5496
- data: true
5726
+ requestId: result.requestId,
5727
+ success: result.success,
5728
+ data: result.success,
5729
+ errorMessage: result.errorMessage
5497
5730
  };
5498
5731
  } catch (error) {
5499
5732
  return {
5500
5733
  requestId: "",
5501
5734
  success: false,
5735
+ data: false,
5502
5736
  errorMessage: `Failed to perform swipe: ${error}`
5503
5737
  };
5504
5738
  }
5505
5739
  }
5506
5740
  /**
5507
- * Performs a click at the specified coordinates.
5741
+ * Clicks on the screen at the specified coordinates.
5508
5742
  * Corresponds to Python's click() method
5509
5743
  *
5510
- * @param x - The X coordinate.
5511
- * @param y - The Y coordinate.
5512
- * @param button - The mouse button to click. Default is 'left'.
5513
- * @returns BoolResult with click result and requestId
5744
+ * @param x - The X coordinate
5745
+ * @param y - The Y coordinate
5746
+ * @param button - The mouse button to use. Default is 'left'
5747
+ * @returns BoolResult with success status and requestId
5748
+ * @throws APIError if the operation fails.
5514
5749
  */
5515
5750
  async click(x, y, button = "left") {
5516
5751
  try {
5517
- const args = {
5518
- x,
5519
- y,
5520
- button
5521
- };
5522
- const result = await this.callMcpTool(
5523
- "click",
5524
- args,
5525
- "Failed to perform click"
5526
- );
5752
+ const args = { x, y, button };
5753
+ const result = await this.session.callMcpTool("click", args);
5527
5754
  return {
5528
- requestId: result.requestId || "",
5529
- success: true,
5530
- data: true
5755
+ requestId: result.requestId,
5756
+ success: result.success,
5757
+ data: result.success,
5758
+ errorMessage: result.errorMessage
5531
5759
  };
5532
5760
  } catch (error) {
5533
5761
  return {
5534
5762
  requestId: "",
5535
5763
  success: false,
5536
- errorMessage: `Failed to perform click: ${error}`
5764
+ data: false,
5765
+ errorMessage: `Failed to click: ${error}`
5537
5766
  };
5538
5767
  }
5539
5768
  }
@@ -5541,25 +5770,30 @@ var _UI = class _UI {
5541
5770
  * Takes a screenshot of the current screen.
5542
5771
  * Corresponds to Python's screenshot() method
5543
5772
  *
5544
- * @returns OperationResult with screenshot data and requestId
5773
+ * @returns OperationResult with success status and requestId
5774
+ * @throws APIError if the operation fails.
5545
5775
  */
5546
5776
  async screenshot() {
5547
5777
  try {
5548
- const args = {};
5549
- const result = await this.callMcpTool(
5550
- "system_screenshot",
5551
- args,
5552
- "Failed to take screenshot"
5553
- );
5778
+ const result = await this.session.callMcpTool("system_screenshot", {});
5779
+ if (!result.success) {
5780
+ return {
5781
+ requestId: result.requestId,
5782
+ success: false,
5783
+ data: "",
5784
+ errorMessage: result.errorMessage
5785
+ };
5786
+ }
5554
5787
  return {
5555
- requestId: result.requestId || "",
5788
+ requestId: result.requestId,
5556
5789
  success: true,
5557
- data: result.textContent || ""
5790
+ data: result.data
5558
5791
  };
5559
5792
  } catch (error) {
5560
5793
  return {
5561
5794
  requestId: "",
5562
5795
  success: false,
5796
+ data: "",
5563
5797
  errorMessage: `Failed to take screenshot: ${error}`
5564
5798
  };
5565
5799
  }
@@ -5578,70 +5812,6 @@ var _WindowManager = class _WindowManager {
5578
5812
  constructor(session) {
5579
5813
  this.session = session;
5580
5814
  }
5581
- /**
5582
- * Helper method to call MCP tools and handle common response processing
5583
- *
5584
- * @param toolName - Name of the MCP tool to call
5585
- * @param args - Arguments to pass to the tool
5586
- * @param defaultErrorMsg - Default error message if specific error details are not available
5587
- * @returns A CallMcpToolResult with the response data
5588
- * @throws APIError if the call fails
5589
- */
5590
- async callMcpTool(toolName, args, defaultErrorMsg) {
5591
- try {
5592
- const argsJSON = JSON.stringify(args);
5593
- const request = new CallMcpToolRequest({
5594
- authorization: `Bearer ${this.session.getAPIKey()}`,
5595
- sessionId: this.session.getSessionId(),
5596
- name: toolName,
5597
- args: argsJSON
5598
- });
5599
- log(`API Call: CallMcpTool - ${toolName}`);
5600
- log(`Request: SessionId=${request.sessionId}, Args=${request.args}`);
5601
- const response = await this.session.getClient().callMcpTool(request);
5602
- if (response && response.body) {
5603
- log(`Response from CallMcpTool - ${toolName}:`, response.body);
5604
- }
5605
- if (!response.body?.data) {
5606
- throw new Error("Invalid response data format");
5607
- }
5608
- const data = response.body.data;
5609
- const result = {
5610
- data,
5611
- statusCode: response.statusCode || 0,
5612
- isError: false,
5613
- requestId: extractRequestId(response)
5614
- };
5615
- if (data.isError === true) {
5616
- result.isError = true;
5617
- const contentArray = data.content;
5618
- if (contentArray && contentArray.length > 0) {
5619
- result.content = contentArray;
5620
- if (contentArray[0]?.text) {
5621
- result.errorMsg = contentArray[0].text;
5622
- throw new Error(contentArray[0].text);
5623
- }
5624
- }
5625
- throw new Error(defaultErrorMsg);
5626
- }
5627
- if (Array.isArray(data.content)) {
5628
- result.content = data.content;
5629
- if (result.content.length > 0) {
5630
- const textParts = [];
5631
- for (const item of result.content) {
5632
- if (item && typeof item === "object" && item.text && typeof item.text === "string") {
5633
- textParts.push(item.text);
5634
- }
5635
- }
5636
- result.textContent = textParts.join("\n");
5637
- }
5638
- }
5639
- return result;
5640
- } catch (error) {
5641
- logError(`Error calling CallMcpTool - ${toolName}:`, error);
5642
- throw new APIError(`Failed to call ${toolName}: ${error}`);
5643
- }
5644
- }
5645
5815
  /**
5646
5816
  * Helper method to parse JSON string into Window objects
5647
5817
  * @param jsonStr - JSON string to parse
@@ -5667,14 +5837,21 @@ var _WindowManager = class _WindowManager {
5667
5837
  const args = {
5668
5838
  timeout_ms: timeoutMs
5669
5839
  };
5670
- const result = await this.callMcpTool(
5840
+ const response = await this.session.callMcpTool(
5671
5841
  "list_root_windows",
5672
- args,
5673
- "Failed to list root windows"
5842
+ args
5674
5843
  );
5675
- const windows = result.textContent ? this.parseWindowsFromJSON(result.textContent) : [];
5844
+ if (!response.success) {
5845
+ return {
5846
+ requestId: response.requestId,
5847
+ success: false,
5848
+ windows: [],
5849
+ errorMessage: response.errorMessage
5850
+ };
5851
+ }
5852
+ const windows = response.data ? this.parseWindowsFromJSON(response.data) : [];
5676
5853
  return {
5677
- requestId: result.requestId || "",
5854
+ requestId: response.requestId,
5678
5855
  success: true,
5679
5856
  windows
5680
5857
  };
@@ -5699,18 +5876,24 @@ var _WindowManager = class _WindowManager {
5699
5876
  const args = {
5700
5877
  timeout_ms: timeoutMs
5701
5878
  };
5702
- const result = await this.callMcpTool(
5879
+ const response = await this.session.callMcpTool(
5703
5880
  "get_active_window",
5704
- args,
5705
- "Failed to get active window"
5881
+ args
5706
5882
  );
5883
+ if (!response.success) {
5884
+ return {
5885
+ requestId: response.requestId,
5886
+ success: false,
5887
+ errorMessage: response.errorMessage
5888
+ };
5889
+ }
5707
5890
  let activeWindow = void 0;
5708
- if (result.textContent) {
5709
- const windows = this.parseWindowsFromJSON(result.textContent);
5891
+ if (response.data) {
5892
+ const windows = this.parseWindowsFromJSON(response.data);
5710
5893
  activeWindow = windows.length > 0 ? windows[0] : void 0;
5711
5894
  }
5712
5895
  return {
5713
- requestId: result.requestId || "",
5896
+ requestId: response.requestId,
5714
5897
  success: true,
5715
5898
  window: activeWindow
5716
5899
  };
@@ -5734,13 +5917,19 @@ var _WindowManager = class _WindowManager {
5734
5917
  const args = {
5735
5918
  window_id: windowId
5736
5919
  };
5737
- const result = await this.callMcpTool(
5920
+ const response = await this.session.callMcpTool(
5738
5921
  "activate_window",
5739
- args,
5740
- "Failed to activate window"
5922
+ args
5741
5923
  );
5924
+ if (!response.success) {
5925
+ return {
5926
+ requestId: response.requestId,
5927
+ success: false,
5928
+ errorMessage: response.errorMessage
5929
+ };
5930
+ }
5742
5931
  return {
5743
- requestId: result.requestId || "",
5932
+ requestId: response.requestId,
5744
5933
  success: true,
5745
5934
  data: true
5746
5935
  };
@@ -5764,13 +5953,19 @@ var _WindowManager = class _WindowManager {
5764
5953
  const args = {
5765
5954
  window_id: windowId
5766
5955
  };
5767
- const result = await this.callMcpTool(
5956
+ const response = await this.session.callMcpTool(
5768
5957
  "maximize_window",
5769
- args,
5770
- "Failed to maximize window"
5958
+ args
5771
5959
  );
5960
+ if (!response.success) {
5961
+ return {
5962
+ requestId: response.requestId,
5963
+ success: false,
5964
+ errorMessage: response.errorMessage
5965
+ };
5966
+ }
5772
5967
  return {
5773
- requestId: result.requestId || "",
5968
+ requestId: response.requestId,
5774
5969
  success: true,
5775
5970
  data: true
5776
5971
  };
@@ -5794,13 +5989,19 @@ var _WindowManager = class _WindowManager {
5794
5989
  const args = {
5795
5990
  window_id: windowId
5796
5991
  };
5797
- const result = await this.callMcpTool(
5992
+ const response = await this.session.callMcpTool(
5798
5993
  "minimize_window",
5799
- args,
5800
- "Failed to minimize window"
5994
+ args
5801
5995
  );
5996
+ if (!response.success) {
5997
+ return {
5998
+ requestId: response.requestId,
5999
+ success: false,
6000
+ errorMessage: response.errorMessage
6001
+ };
6002
+ }
5802
6003
  return {
5803
- requestId: result.requestId || "",
6004
+ requestId: response.requestId,
5804
6005
  success: true,
5805
6006
  data: true
5806
6007
  };
@@ -5824,13 +6025,19 @@ var _WindowManager = class _WindowManager {
5824
6025
  const args = {
5825
6026
  window_id: windowId
5826
6027
  };
5827
- const result = await this.callMcpTool(
6028
+ const response = await this.session.callMcpTool(
5828
6029
  "restore_window",
5829
- args,
5830
- "Failed to restore window"
6030
+ args
5831
6031
  );
6032
+ if (!response.success) {
6033
+ return {
6034
+ requestId: response.requestId,
6035
+ success: false,
6036
+ errorMessage: response.errorMessage
6037
+ };
6038
+ }
5832
6039
  return {
5833
- requestId: result.requestId || "",
6040
+ requestId: response.requestId,
5834
6041
  success: true,
5835
6042
  data: true
5836
6043
  };
@@ -5854,13 +6061,19 @@ var _WindowManager = class _WindowManager {
5854
6061
  const args = {
5855
6062
  window_id: windowId
5856
6063
  };
5857
- const result = await this.callMcpTool(
6064
+ const response = await this.session.callMcpTool(
5858
6065
  "close_window",
5859
- args,
5860
- "Failed to close window"
6066
+ args
5861
6067
  );
6068
+ if (!response.success) {
6069
+ return {
6070
+ requestId: response.requestId,
6071
+ success: false,
6072
+ errorMessage: response.errorMessage
6073
+ };
6074
+ }
5862
6075
  return {
5863
- requestId: result.requestId || "",
6076
+ requestId: response.requestId,
5864
6077
  success: true,
5865
6078
  data: true
5866
6079
  };
@@ -5884,13 +6097,19 @@ var _WindowManager = class _WindowManager {
5884
6097
  const args = {
5885
6098
  window_id: windowId
5886
6099
  };
5887
- const result = await this.callMcpTool(
6100
+ const response = await this.session.callMcpTool(
5888
6101
  "fullscreen_window",
5889
- args,
5890
- "Failed to set window to fullscreen"
6102
+ args
5891
6103
  );
6104
+ if (!response.success) {
6105
+ return {
6106
+ requestId: response.requestId,
6107
+ success: false,
6108
+ errorMessage: response.errorMessage
6109
+ };
6110
+ }
5892
6111
  return {
5893
- requestId: result.requestId || "",
6112
+ requestId: response.requestId,
5894
6113
  success: true,
5895
6114
  data: true
5896
6115
  };
@@ -5918,13 +6137,19 @@ var _WindowManager = class _WindowManager {
5918
6137
  width,
5919
6138
  height
5920
6139
  };
5921
- const result = await this.callMcpTool(
6140
+ const response = await this.session.callMcpTool(
5922
6141
  "resize_window",
5923
- args,
5924
- "Failed to resize window"
6142
+ args
5925
6143
  );
6144
+ if (!response.success) {
6145
+ return {
6146
+ requestId: response.requestId,
6147
+ success: false,
6148
+ errorMessage: response.errorMessage
6149
+ };
6150
+ }
5926
6151
  return {
5927
- requestId: result.requestId || "",
6152
+ requestId: response.requestId,
5928
6153
  success: true,
5929
6154
  data: true
5930
6155
  };
@@ -5937,38 +6162,390 @@ var _WindowManager = class _WindowManager {
5937
6162
  }
5938
6163
  }
5939
6164
  /**
5940
- * Enables or disables focus mode.
5941
- * Corresponds to Python's focus_mode() method
5942
- *
5943
- * @param on Whether to enable focus mode.
5944
- * @returns BoolResult with requestId
6165
+ * Enables or disables focus mode.
6166
+ * Corresponds to Python's focus_mode() method
6167
+ *
6168
+ * @param on Whether to enable focus mode.
6169
+ * @returns BoolResult with requestId
6170
+ */
6171
+ async focusMode(on) {
6172
+ try {
6173
+ const args = {
6174
+ on
6175
+ };
6176
+ const response = await this.session.callMcpTool(
6177
+ "focus_mode",
6178
+ args
6179
+ );
6180
+ if (!response.success) {
6181
+ return {
6182
+ requestId: response.requestId,
6183
+ success: false,
6184
+ errorMessage: response.errorMessage
6185
+ };
6186
+ }
6187
+ return {
6188
+ requestId: response.requestId,
6189
+ success: true,
6190
+ data: true
6191
+ };
6192
+ } catch (error) {
6193
+ return {
6194
+ requestId: "",
6195
+ success: false,
6196
+ errorMessage: `Failed to toggle focus mode: ${error}`
6197
+ };
6198
+ }
6199
+ }
6200
+ };
6201
+ __name(_WindowManager, "WindowManager");
6202
+ var WindowManager = _WindowManager;
6203
+
6204
+ // src/browser/index.ts
6205
+ init_esm_shims();
6206
+
6207
+ // src/browser/browser.ts
6208
+ init_esm_shims();
6209
+
6210
+ // src/browser/browser_agent.ts
6211
+ init_esm_shims();
6212
+ var _ActResult = class _ActResult {
6213
+ constructor(success, message, action) {
6214
+ this.success = success;
6215
+ this.message = message;
6216
+ this.action = action;
6217
+ }
6218
+ };
6219
+ __name(_ActResult, "ActResult");
6220
+ var ActResult = _ActResult;
6221
+ var _ObserveResult = class _ObserveResult {
6222
+ constructor(selector, description, method, args) {
6223
+ this.selector = selector;
6224
+ this.description = description;
6225
+ this.method = method;
6226
+ this.args = args;
6227
+ }
6228
+ };
6229
+ __name(_ObserveResult, "ObserveResult");
6230
+ var ObserveResult = _ObserveResult;
6231
+ var _BrowserAgent = class _BrowserAgent {
6232
+ constructor(session, browser) {
6233
+ this.session = session;
6234
+ this.browser = browser;
6235
+ }
6236
+ /**
6237
+ * Perform an action on the given Playwright Page object, using ActOptions to configure behavior.
6238
+ * Returns the result of the action.
6239
+ */
6240
+ async act(page, options) {
6241
+ if (!this.browser.isInitialized()) {
6242
+ throw new BrowserError("Browser must be initialized before calling act.");
6243
+ }
6244
+ try {
6245
+ const [pageIndex, contextIndex] = this._getPageAndContextIndex(page);
6246
+ log(`Acting on page: ${page}, pageIndex: ${pageIndex}, contextIndex: ${contextIndex}`);
6247
+ const args = {
6248
+ context_id: contextIndex,
6249
+ page_id: pageIndex,
6250
+ action: options.action
6251
+ };
6252
+ if (options.timeoutMS !== void 0) {
6253
+ args.timeout_ms = options.timeoutMS;
6254
+ }
6255
+ if (options.iframes !== void 0) {
6256
+ args.iframes = options.iframes;
6257
+ }
6258
+ if (options.domSettleTimeoutMS !== void 0) {
6259
+ args.dom_settle_timeout_ms = options.domSettleTimeoutMS;
6260
+ }
6261
+ const response = await this._callMcpTool("page_use_act", args);
6262
+ if (response.success) {
6263
+ log(`Response from CallMcpTool - page_use_act:`, response.data);
6264
+ let data;
6265
+ if (typeof response.data === "string") {
6266
+ data = JSON.parse(response.data);
6267
+ } else {
6268
+ data = response.data;
6269
+ }
6270
+ const success = data.success || false;
6271
+ const message = data.message || "";
6272
+ const action = data.action || "";
6273
+ return new ActResult(success, message, action);
6274
+ } else {
6275
+ return new ActResult(false, response.errorMessage, "");
6276
+ }
6277
+ } catch (error) {
6278
+ throw new BrowserError(`Failed to get page/context index: ${error}`);
6279
+ }
6280
+ }
6281
+ /**
6282
+ * Async version of act method for performing actions on the given Playwright Page object.
6283
+ */
6284
+ async actAsync(page, options) {
6285
+ return this.act(page, options);
6286
+ }
6287
+ /**
6288
+ * Observe elements or state on the given Playwright Page object.
6289
+ * Returns a tuple containing (success, results).
6290
+ */
6291
+ async observe(page, options) {
6292
+ if (!this.browser.isInitialized()) {
6293
+ throw new BrowserError("Browser must be initialized before calling observe.");
6294
+ }
6295
+ try {
6296
+ const [pageIndex, contextIndex] = this._getPageAndContextIndex(page);
6297
+ log(`Observing page: ${page}, pageIndex: ${pageIndex}, contextIndex: ${contextIndex}`);
6298
+ const args = {
6299
+ context_id: contextIndex,
6300
+ page_id: pageIndex,
6301
+ instruction: options.instruction
6302
+ };
6303
+ if (options.returnActions !== void 0) {
6304
+ args.return_actions = options.returnActions;
6305
+ }
6306
+ if (options.iframes !== void 0) {
6307
+ args.iframes = options.iframes;
6308
+ }
6309
+ if (options.domSettleTimeoutMS !== void 0) {
6310
+ args.dom_settle_timeout_ms = options.domSettleTimeoutMS;
6311
+ }
6312
+ const response = await this._callMcpTool("page_use_observe", args);
6313
+ log("Response from CallMcpTool - page_use_observe data:", response.data);
6314
+ if (response.success) {
6315
+ log(`Response from CallMcpTool - page_use_observe:`, response.data);
6316
+ let data;
6317
+ if (typeof response.data === "string") {
6318
+ data = JSON.parse(response.data);
6319
+ } else {
6320
+ throw new BrowserError("Observe response data is not a json!!!");
6321
+ }
6322
+ const success = data.success || false;
6323
+ if (!success) {
6324
+ return [false, []];
6325
+ }
6326
+ const results = [];
6327
+ const observeResults = JSON.parse(data.observe_result || "");
6328
+ log("observeResults =", observeResults);
6329
+ for (const item of observeResults) {
6330
+ const selector = item.selector || "";
6331
+ const description = item.description || "";
6332
+ const method = item.method || "";
6333
+ const itemArgs = item.arguments || {};
6334
+ results.push(new ObserveResult(selector, description, method, itemArgs));
6335
+ }
6336
+ return [success, results];
6337
+ } else {
6338
+ log(`Response from CallMcpTool - page_use_observe:`, response.errorMessage);
6339
+ return [false, []];
6340
+ }
6341
+ } catch (error) {
6342
+ throw new BrowserError(`Failed to get page/context index: ${error}`);
6343
+ }
6344
+ }
6345
+ /**
6346
+ * Async version of observe method.
6347
+ */
6348
+ async observeAsync(page, options) {
6349
+ return this.observe(page, options);
6350
+ }
6351
+ /**
6352
+ * Extract information from the given Playwright Page object.
6353
+ */
6354
+ async extract(page, options) {
6355
+ if (!this.browser.isInitialized()) {
6356
+ throw new BrowserError("Browser must be initialized before calling extract.");
6357
+ }
6358
+ try {
6359
+ const [pageIndex, contextIndex] = this._getPageAndContextIndex(page);
6360
+ const tempInstance = new options.schema();
6361
+ const schema = tempInstance.constructor.name;
6362
+ const args = {
6363
+ context_id: contextIndex,
6364
+ page_id: pageIndex,
6365
+ instruction: options.instruction,
6366
+ schema: `schema: ${JSON.stringify(schema)}`
6367
+ // Simplified schema handling
6368
+ };
6369
+ log(`Extracting from page: ${page}, pageIndex: ${pageIndex}, contextIndex: ${contextIndex}, args:`, args);
6370
+ if (options.selector !== void 0) {
6371
+ args.selector = options.selector;
6372
+ }
6373
+ if (options.iframe !== void 0) {
6374
+ args.iframe = options.iframe;
6375
+ }
6376
+ if (options.domSettleTimeoutsMS !== void 0) {
6377
+ args.dom_settle_timeouts_ms = options.domSettleTimeoutsMS;
6378
+ }
6379
+ const response = await this._callMcpTool("page_use_extract", args);
6380
+ log("Response from CallMcpTool - page_use_extract data:", response.data);
6381
+ if (response.success) {
6382
+ log(`Response from CallMcpTool - page_use_extract:`, response.data);
6383
+ let data;
6384
+ if (typeof response.data === "string") {
6385
+ data = JSON.parse(response.data);
6386
+ } else {
6387
+ data = response.data;
6388
+ }
6389
+ log("extract data =", data);
6390
+ const success = data.success || false;
6391
+ const extractObjs = [];
6392
+ if (success) {
6393
+ const extractResults = JSON.parse(data.extract_result || "");
6394
+ for (const extractResult of extractResults) {
6395
+ log("extractResult =", extractResult);
6396
+ const instance = extractResult;
6397
+ extractObjs.push(instance);
6398
+ }
6399
+ } else {
6400
+ const extractResults = data.extract_result || "";
6401
+ log("Extract failed due to:", extractResults);
6402
+ }
6403
+ return [success, extractObjs];
6404
+ } else {
6405
+ log(`Response from CallMcpTool - page_use_extract:`, response.errorMessage);
6406
+ return [false, []];
6407
+ }
6408
+ } catch (error) {
6409
+ throw new BrowserError(`Failed to get page/context index: ${error}`);
6410
+ }
6411
+ }
6412
+ /**
6413
+ * Async version of extract method.
6414
+ */
6415
+ async extractAsync(page, options) {
6416
+ return this.extract(page, options);
6417
+ }
6418
+ _getPageAndContextIndex(page) {
6419
+ if (!page) {
6420
+ throw new BrowserError("Page is null");
6421
+ }
6422
+ try {
6423
+ const pageIndex = "default-page-id";
6424
+ const contextIndex = 0;
6425
+ return [pageIndex, contextIndex];
6426
+ } catch (error) {
6427
+ throw new BrowserError(`Failed to get page/context index: ${error}`);
6428
+ }
6429
+ }
6430
+ async _getPageAndContextIndexAsync(page) {
6431
+ if (!page) {
6432
+ throw new BrowserError("Page is null");
6433
+ }
6434
+ try {
6435
+ const pageIndex = "default-page-id";
6436
+ const contextIndex = 0;
6437
+ return [pageIndex, contextIndex];
6438
+ } catch (error) {
6439
+ throw new BrowserError(`Failed to get page/context index: ${error}`);
6440
+ }
6441
+ }
6442
+ async _callMcpTool(toolName, args) {
6443
+ return this.session.callMcpTool(toolName, args);
6444
+ }
6445
+ };
6446
+ __name(_BrowserAgent, "BrowserAgent");
6447
+ var BrowserAgent = _BrowserAgent;
6448
+
6449
+ // src/browser/browser.ts
6450
+ var _Browser = class _Browser {
6451
+ constructor(session) {
6452
+ this._endpointUrl = null;
6453
+ this._initialized = false;
6454
+ this._option = null;
6455
+ this.session = session;
6456
+ this.agent = new BrowserAgent(this.session, this);
6457
+ }
6458
+ /**
6459
+ * Initialize the browser instance with the given options.
6460
+ * Returns true if successful, false otherwise.
6461
+ */
6462
+ initialize(option) {
6463
+ if (this.isInitialized()) {
6464
+ return true;
6465
+ }
6466
+ try {
6467
+ const request = new InitBrowserRequest();
6468
+ request.authorization = `Bearer ${this.session.getAPIKey()}`;
6469
+ request.persistentPath = BROWSER_DATA_PATH;
6470
+ request.sessionId = this.session.getSessionId();
6471
+ const response = this.session.getClient().initBrowserSync(request);
6472
+ log(`Response from init_browser data:`, response.body?.data);
6473
+ const success = response.body?.data?.port !== null && response.body?.data?.port !== void 0;
6474
+ if (success) {
6475
+ this._initialized = true;
6476
+ this._option = option;
6477
+ log("Browser instance was successfully initialized.");
6478
+ }
6479
+ return success;
6480
+ } catch (error) {
6481
+ console.error("Failed to initialize browser instance:", error);
6482
+ this._initialized = false;
6483
+ this._endpointUrl = null;
6484
+ this._option = null;
6485
+ return false;
6486
+ }
6487
+ }
6488
+ /**
6489
+ * Initialize the browser instance with the given options asynchronously.
6490
+ * Returns true if successful, false otherwise.
6491
+ */
6492
+ async initializeAsync(option) {
6493
+ if (this.isInitialized()) {
6494
+ return true;
6495
+ }
6496
+ try {
6497
+ const request = new InitBrowserRequest();
6498
+ request.authorization = `Bearer ${this.session.getAPIKey()}`;
6499
+ request.persistentPath = BROWSER_DATA_PATH;
6500
+ request.sessionId = this.session.getSessionId();
6501
+ const response = await this.session.getClient().initBrowser(request);
6502
+ log(`Response from init_browser data:`, response.body?.data);
6503
+ const success = response.body?.data?.port !== null && response.body?.data?.port !== void 0;
6504
+ if (success) {
6505
+ this._initialized = true;
6506
+ this._option = option;
6507
+ log("Browser instance successfully initialized");
6508
+ }
6509
+ return success;
6510
+ } catch (error) {
6511
+ console.error("Failed to initialize browser instance:", error);
6512
+ this._initialized = false;
6513
+ this._endpointUrl = null;
6514
+ this._option = null;
6515
+ return false;
6516
+ }
6517
+ }
6518
+ /**
6519
+ * Returns the endpoint URL if the browser is initialized, otherwise throws an exception.
6520
+ * When initialized, always fetches the latest CDP url from session.getLink().
5945
6521
  */
5946
- async focusMode(on) {
6522
+ async getEndpointUrl() {
6523
+ if (!this.isInitialized()) {
6524
+ throw new BrowserError("Browser is not initialized. Cannot access endpoint URL.");
6525
+ }
5947
6526
  try {
5948
- const args = {
5949
- on
5950
- };
5951
- const result = await this.callMcpTool(
5952
- "focus_mode",
5953
- args,
5954
- "Failed to set focus mode"
5955
- );
5956
- return {
5957
- requestId: result.requestId || "",
5958
- success: true,
5959
- data: true
5960
- };
6527
+ const linkResult = await this.session.getLink();
6528
+ this._endpointUrl = linkResult.data;
6529
+ return this._endpointUrl;
5961
6530
  } catch (error) {
5962
- return {
5963
- requestId: "",
5964
- success: false,
5965
- errorMessage: `Failed to toggle focus mode: ${error}`
5966
- };
6531
+ throw new BrowserError(`Failed to get endpoint URL from session: ${error}`);
5967
6532
  }
5968
6533
  }
6534
+ /**
6535
+ * Returns the current BrowserOption used to initialize the browser, or null if not set.
6536
+ */
6537
+ getOption() {
6538
+ return this._option;
6539
+ }
6540
+ /**
6541
+ * Returns true if the browser was initialized, false otherwise.
6542
+ */
6543
+ isInitialized() {
6544
+ return this._initialized;
6545
+ }
5969
6546
  };
5970
- __name(_WindowManager, "WindowManager");
5971
- var WindowManager = _WindowManager;
6547
+ __name(_Browser, "Browser");
6548
+ var Browser = _Browser;
5972
6549
 
5973
6550
  // src/session.ts
5974
6551
  var _SessionInfoClass = class _SessionInfoClass {
@@ -5994,15 +6571,26 @@ var _Session = class _Session {
5994
6571
  */
5995
6572
  constructor(agentBay, sessionId) {
5996
6573
  this.resourceUrl = "";
6574
+ // VPC-related information
6575
+ this.isVpc = false;
6576
+ // Whether this session uses VPC resources
6577
+ this.networkInterfaceIp = "";
6578
+ // Network interface IP for VPC sessions
6579
+ this.httpPort = "";
6580
+ // MCP tools available for this session
6581
+ this.mcpTools = [];
5997
6582
  this.agentBay = agentBay;
5998
6583
  this.sessionId = sessionId;
5999
6584
  this.resourceUrl = "";
6000
6585
  this.fileSystem = new FileSystem(this);
6001
6586
  this.command = new Command(this);
6587
+ this.code = new Code(this);
6002
6588
  this.oss = new Oss(this);
6003
6589
  this.application = new Application(this);
6004
6590
  this.window = new WindowManager(this);
6005
6591
  this.ui = new UI(this);
6592
+ this.agent = new Agent(this);
6593
+ this.browser = new Browser(this);
6006
6594
  this.context = newContextManager(this);
6007
6595
  }
6008
6596
  /**
@@ -6023,13 +6611,94 @@ var _Session = class _Session {
6023
6611
  getSessionId() {
6024
6612
  return this.sessionId;
6025
6613
  }
6614
+ /**
6615
+ * Return whether this session uses VPC resources.
6616
+ */
6617
+ isVpcEnabled() {
6618
+ return this.isVpc;
6619
+ }
6620
+ /**
6621
+ * Return the network interface IP for VPC sessions.
6622
+ */
6623
+ getNetworkInterfaceIp() {
6624
+ return this.networkInterfaceIp;
6625
+ }
6626
+ /**
6627
+ * Return the HTTP port for VPC sessions.
6628
+ */
6629
+ getHttpPort() {
6630
+ return this.httpPort;
6631
+ }
6632
+ /**
6633
+ * Find the server that provides the given tool.
6634
+ */
6635
+ findServerForTool(toolName) {
6636
+ for (const tool of this.mcpTools) {
6637
+ if (tool.name === toolName) {
6638
+ return tool.server;
6639
+ }
6640
+ }
6641
+ return "";
6642
+ }
6026
6643
  /**
6027
6644
  * Delete this session.
6028
6645
  *
6646
+ * @param syncContext - Whether to sync context data (trigger file uploads) before deleting the session. Defaults to false.
6029
6647
  * @returns DeleteResult indicating success or failure and request ID
6030
6648
  */
6031
- async delete() {
6649
+ async delete(syncContext = false) {
6032
6650
  try {
6651
+ if (syncContext) {
6652
+ log("Triggering context synchronization before session deletion...");
6653
+ try {
6654
+ const syncResult = await this.context.sync();
6655
+ if (!syncResult.success) {
6656
+ log("Warning: Context sync operation returned failure status");
6657
+ }
6658
+ } catch (error) {
6659
+ logError("Warning: Failed to trigger context sync:", error);
6660
+ }
6661
+ const maxRetries = 150;
6662
+ const retryInterval = 2e3;
6663
+ for (let retry = 0; retry < maxRetries; retry++) {
6664
+ try {
6665
+ const infoResult = await this.context.info();
6666
+ let allCompleted = true;
6667
+ let hasFailure = false;
6668
+ let hasUploads = false;
6669
+ for (const item of infoResult.contextStatusData) {
6670
+ if (item.taskType !== "upload") {
6671
+ continue;
6672
+ }
6673
+ hasUploads = true;
6674
+ log(`Upload context ${item.contextId} status: ${item.status}, path: ${item.path}`);
6675
+ if (item.status !== "Success" && item.status !== "Failed") {
6676
+ allCompleted = false;
6677
+ break;
6678
+ }
6679
+ if (item.status === "Failed") {
6680
+ hasFailure = true;
6681
+ logError(`Upload failed for context ${item.contextId}: ${item.errorMessage}`);
6682
+ }
6683
+ }
6684
+ if (allCompleted || !hasUploads) {
6685
+ if (hasFailure) {
6686
+ log("Context upload completed with failures");
6687
+ } else if (hasUploads) {
6688
+ log("Context upload completed successfully");
6689
+ } else {
6690
+ log("No upload tasks found");
6691
+ }
6692
+ break;
6693
+ }
6694
+ log(`Waiting for context upload to complete, attempt ${retry + 1}/${maxRetries}`);
6695
+ await new Promise((resolve2) => setTimeout(resolve2, retryInterval));
6696
+ } catch (error) {
6697
+ logError(`Error checking context status on attempt ${retry + 1}:`, error);
6698
+ await new Promise((resolve2) => setTimeout(resolve2, retryInterval));
6699
+ }
6700
+ }
6701
+ }
6033
6702
  const request = new ReleaseMcpSessionRequest({
6034
6703
  authorization: `Bearer ${this.getAPIKey()}`,
6035
6704
  sessionId: this.sessionId
@@ -6059,6 +6728,59 @@ var _Session = class _Session {
6059
6728
  };
6060
6729
  }
6061
6730
  }
6731
+ /**
6732
+ * Validates labels parameter for label operations.
6733
+ *
6734
+ * @param labels - The labels to validate
6735
+ * @returns null if validation passes, or OperationResult with error if validation fails
6736
+ */
6737
+ validateLabels(labels) {
6738
+ if (!labels || typeof labels !== "object") {
6739
+ return {
6740
+ requestId: "",
6741
+ success: false,
6742
+ errorMessage: "Labels cannot be null, undefined, or invalid type. Please provide a valid labels object."
6743
+ };
6744
+ }
6745
+ if (Array.isArray(labels)) {
6746
+ return {
6747
+ requestId: "",
6748
+ success: false,
6749
+ errorMessage: "Labels cannot be an array. Please provide a valid labels object."
6750
+ };
6751
+ }
6752
+ 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) {
6753
+ return {
6754
+ requestId: "",
6755
+ success: false,
6756
+ errorMessage: "Labels must be a plain object. Built-in object types are not allowed."
6757
+ };
6758
+ }
6759
+ if (Object.keys(labels).length === 0) {
6760
+ return {
6761
+ requestId: "",
6762
+ success: false,
6763
+ errorMessage: "Labels cannot be empty. Please provide at least one label."
6764
+ };
6765
+ }
6766
+ for (const [key, value] of Object.entries(labels)) {
6767
+ if (!key || key.trim() === "") {
6768
+ return {
6769
+ requestId: "",
6770
+ success: false,
6771
+ errorMessage: "Label keys cannot be empty Please provide valid keys."
6772
+ };
6773
+ }
6774
+ if (!value || value.trim() === "") {
6775
+ return {
6776
+ requestId: "",
6777
+ success: false,
6778
+ errorMessage: "Label values cannot be empty Please provide valid values."
6779
+ };
6780
+ }
6781
+ }
6782
+ return null;
6783
+ }
6062
6784
  /**
6063
6785
  * Sets the labels for this session.
6064
6786
  *
@@ -6068,6 +6790,10 @@ var _Session = class _Session {
6068
6790
  */
6069
6791
  async setLabels(labels) {
6070
6792
  try {
6793
+ const validationResult = this.validateLabels(labels);
6794
+ if (validationResult !== null) {
6795
+ return validationResult;
6796
+ }
6071
6797
  const labelsJSON = JSON.stringify(labels);
6072
6798
  const request = new SetLabelRequest({
6073
6799
  authorization: `Bearer ${this.getAPIKey()}`,
@@ -6213,7 +6939,7 @@ var _Session = class _Session {
6213
6939
  data = {};
6214
6940
  }
6215
6941
  }
6216
- const url = data.Url || "";
6942
+ const url = data.Url || data.url;
6217
6943
  return {
6218
6944
  requestId,
6219
6945
  success: true,
@@ -6259,7 +6985,7 @@ var _Session = class _Session {
6259
6985
  data = {};
6260
6986
  }
6261
6987
  }
6262
- const url = data.Url || "";
6988
+ const url = data.Url || data.url;
6263
6989
  return {
6264
6990
  requestId,
6265
6991
  success: true,
@@ -6272,6 +6998,176 @@ var _Session = class _Session {
6272
6998
  throw new Error(`Failed to get link asynchronously: ${error}`);
6273
6999
  }
6274
7000
  }
7001
+ /**
7002
+ * List MCP tools available for this session.
7003
+ *
7004
+ * @param imageId Optional image ID, defaults to session's imageId or "linux_latest"
7005
+ * @returns McpToolsResult containing tools list and request ID
7006
+ */
7007
+ async listMcpTools(imageId) {
7008
+ if (!imageId) {
7009
+ imageId = this.imageId || "linux_latest";
7010
+ }
7011
+ const request = new ListMcpToolsRequest({
7012
+ authorization: `Bearer ${this.getAPIKey()}`,
7013
+ imageId
7014
+ });
7015
+ log("API Call: ListMcpTools");
7016
+ log(`Request: ImageId=${imageId}`);
7017
+ const response = await this.getClient().listMcpTools(request);
7018
+ const requestId = extractRequestId(response) || "";
7019
+ if (response && response.body) {
7020
+ log("Response from ListMcpTools:", response.body);
7021
+ }
7022
+ const tools = [];
7023
+ if (response && response.body && response.body.data) {
7024
+ try {
7025
+ const toolsData = JSON.parse(response.body.data);
7026
+ for (const toolData of toolsData) {
7027
+ const tool = {
7028
+ name: toolData.name || "",
7029
+ description: toolData.description || "",
7030
+ inputSchema: toolData.inputSchema || {},
7031
+ server: toolData.server || "",
7032
+ tool: toolData.tool || ""
7033
+ };
7034
+ tools.push(tool);
7035
+ }
7036
+ } catch (error) {
7037
+ logError(`Error unmarshaling tools data: ${error}`);
7038
+ }
7039
+ }
7040
+ this.mcpTools = tools;
7041
+ return {
7042
+ requestId,
7043
+ success: true,
7044
+ tools
7045
+ };
7046
+ }
7047
+ /**
7048
+ * Call an MCP tool and return the result in a format compatible with Agent.
7049
+ *
7050
+ * @param toolName - Name of the MCP tool to call
7051
+ * @param args - Arguments to pass to the tool
7052
+ * @returns McpToolResult containing the response data
7053
+ */
7054
+ async callMcpTool(toolName, args) {
7055
+ try {
7056
+ const argsJSON = JSON.stringify(args);
7057
+ if (this.isVpcEnabled()) {
7058
+ const server = this.findServerForTool(toolName);
7059
+ if (!server) {
7060
+ return {
7061
+ success: false,
7062
+ data: "",
7063
+ errorMessage: `Server not found for tool: ${toolName}`,
7064
+ requestId: ""
7065
+ };
7066
+ }
7067
+ if (!this.networkInterfaceIp || !this.httpPort) {
7068
+ return {
7069
+ success: false,
7070
+ data: "",
7071
+ errorMessage: `VPC network configuration incomplete: networkInterfaceIp=${this.networkInterfaceIp}, httpPort=${this.httpPort}. This may indicate the VPC session was not properly configured with network parameters.`,
7072
+ requestId: ""
7073
+ };
7074
+ }
7075
+ const baseURL = `http://${this.networkInterfaceIp}:${this.httpPort}/callTool`;
7076
+ const url = new URL(baseURL);
7077
+ url.searchParams.append("server", server);
7078
+ url.searchParams.append("tool", toolName);
7079
+ url.searchParams.append("args", argsJSON);
7080
+ url.searchParams.append("apiKey", this.getAPIKey());
7081
+ const requestId = `vpc-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
7082
+ url.searchParams.append("requestId", requestId);
7083
+ const response = await fetch(url.toString(), {
7084
+ method: "GET",
7085
+ headers: {
7086
+ "Content-Type": "application/x-www-form-urlencoded"
7087
+ }
7088
+ });
7089
+ if (!response.ok) {
7090
+ return {
7091
+ success: false,
7092
+ data: "",
7093
+ errorMessage: `VPC request failed: ${response.statusText}`,
7094
+ requestId: ""
7095
+ };
7096
+ }
7097
+ const responseData = await response.json();
7098
+ let actualResult = responseData;
7099
+ if (typeof responseData.data === "string") {
7100
+ try {
7101
+ const dataMap = JSON.parse(responseData.data);
7102
+ if (dataMap.result) {
7103
+ actualResult = dataMap.result;
7104
+ }
7105
+ } catch (err) {
7106
+ }
7107
+ } else if (responseData.data && responseData.data.result) {
7108
+ actualResult = responseData.data.result;
7109
+ }
7110
+ let textContent = "";
7111
+ if (actualResult.content && Array.isArray(actualResult.content) && actualResult.content.length > 0) {
7112
+ const contentItem = actualResult.content[0];
7113
+ if (contentItem && contentItem.text) {
7114
+ textContent = contentItem.text;
7115
+ }
7116
+ }
7117
+ return {
7118
+ success: true,
7119
+ data: textContent || JSON.stringify(actualResult),
7120
+ errorMessage: "",
7121
+ requestId: ""
7122
+ };
7123
+ } else {
7124
+ const callToolRequest = new CallMcpToolRequest({
7125
+ authorization: `Bearer ${this.getAPIKey()}`,
7126
+ sessionId: this.getSessionId(),
7127
+ name: toolName,
7128
+ args: argsJSON
7129
+ });
7130
+ const response = await this.getClient().callMcpTool(callToolRequest);
7131
+ if (!response.body?.data) {
7132
+ return {
7133
+ success: false,
7134
+ data: "",
7135
+ errorMessage: "Invalid response data format",
7136
+ requestId: extractRequestId(response) || ""
7137
+ };
7138
+ }
7139
+ const data = response.body.data;
7140
+ if (data.isError) {
7141
+ const errorContent = data.content || [];
7142
+ const errorMessage = errorContent.map((item) => item.text || "Unknown error").join("; ");
7143
+ return {
7144
+ success: false,
7145
+ data: "",
7146
+ errorMessage,
7147
+ requestId: extractRequestId(response) || ""
7148
+ };
7149
+ }
7150
+ const content = data.content || [];
7151
+ let textContent = "";
7152
+ if (content.length > 0 && content[0].text !== void 0) {
7153
+ textContent = content[0].text;
7154
+ }
7155
+ return {
7156
+ success: true,
7157
+ data: textContent,
7158
+ errorMessage: "",
7159
+ requestId: extractRequestId(response) || ""
7160
+ };
7161
+ }
7162
+ } catch (error) {
7163
+ return {
7164
+ success: false,
7165
+ data: "",
7166
+ errorMessage: error instanceof Error ? error.message : String(error),
7167
+ requestId: ""
7168
+ };
7169
+ }
7170
+ }
6275
7171
  };
6276
7172
  __name(_Session, "Session");
6277
7173
  var Session = _Session;
@@ -6316,11 +7212,8 @@ var _AgentBay = class _AgentBay {
6316
7212
  * @param params - Optional parameters for creating the session
6317
7213
  * @returns SessionResult containing the created session and request ID
6318
7214
  */
6319
- async create(params) {
7215
+ async create(params = {}) {
6320
7216
  try {
6321
- if (!params) {
6322
- params = {};
6323
- }
6324
7217
  const request = new CreateMcpSessionRequest({
6325
7218
  authorization: "Bearer " + this.apiKey
6326
7219
  });
@@ -6333,19 +7226,41 @@ var _AgentBay = class _AgentBay {
6333
7226
  if (params.imageId) {
6334
7227
  request.imageId = params.imageId;
6335
7228
  }
7229
+ request.vpcResource = params.isVpc || false;
7230
+ let hasPersistenceData = false;
6336
7231
  if (params.contextSync && params.contextSync.length > 0) {
6337
7232
  const persistenceDataList = [];
6338
7233
  for (const contextSync of params.contextSync) {
6339
- const persistenceItem = {
7234
+ const persistenceItem = new CreateMcpSessionRequestPersistenceDataList({
6340
7235
  contextId: contextSync.contextId,
6341
7236
  path: contextSync.path
6342
- };
7237
+ });
6343
7238
  if (contextSync.policy) {
6344
7239
  persistenceItem.policy = JSON.stringify(contextSync.policy);
6345
7240
  }
6346
7241
  persistenceDataList.push(persistenceItem);
6347
7242
  }
6348
7243
  request.persistenceDataList = persistenceDataList;
7244
+ hasPersistenceData = persistenceDataList.length > 0;
7245
+ }
7246
+ if (params.browserContext) {
7247
+ const syncPolicy = {
7248
+ uploadPolicy: { autoUpload: params.browserContext.autoUpload },
7249
+ downloadPolicy: null,
7250
+ deletePolicy: null,
7251
+ bwList: null
7252
+ };
7253
+ const browserContextSync = new CreateMcpSessionRequestPersistenceDataList({
7254
+ contextId: params.browserContext.contextId,
7255
+ path: BROWSER_DATA_PATH,
7256
+ // Using a constant path for browser data
7257
+ policy: JSON.stringify(syncPolicy)
7258
+ });
7259
+ if (!request.persistenceDataList) {
7260
+ request.persistenceDataList = [];
7261
+ }
7262
+ request.persistenceDataList.push(browserContextSync);
7263
+ hasPersistenceData = true;
6349
7264
  }
6350
7265
  log("API Call: CreateMcpSession");
6351
7266
  let requestLog = "Request: ";
@@ -6370,7 +7285,7 @@ var _AgentBay = class _AgentBay {
6370
7285
  }
6371
7286
  log(requestLog);
6372
7287
  const response = await this.client.createMcpSession(request);
6373
- log("response =", response);
7288
+ log("response data =", response.body?.data);
6374
7289
  const requestId = extractRequestId(response) || "";
6375
7290
  const sessionData = response.body;
6376
7291
  if (!sessionData || typeof sessionData !== "object") {
@@ -6403,7 +7318,60 @@ var _AgentBay = class _AgentBay {
6403
7318
  if (resourceUrl) {
6404
7319
  session.resourceUrl = resourceUrl;
6405
7320
  }
7321
+ session.isVpc = params.isVpc || false;
7322
+ if (data.networkInterfaceIp) {
7323
+ session.networkInterfaceIp = data.networkInterfaceIp;
7324
+ }
7325
+ if (data.httpPort) {
7326
+ session.httpPort = data.httpPort;
7327
+ }
7328
+ session.imageId = params.imageId;
6406
7329
  this.sessions.set(session.sessionId, session);
7330
+ if (params.isVpc) {
7331
+ log("VPC session detected, automatically fetching MCP tools...");
7332
+ try {
7333
+ const toolsResult = await session.listMcpTools();
7334
+ log(`Successfully fetched ${toolsResult.tools.length} MCP tools for VPC session (RequestID: ${toolsResult.requestId})`);
7335
+ } catch (error) {
7336
+ logError(`Warning: Failed to fetch MCP tools for VPC session: ${error}`);
7337
+ }
7338
+ }
7339
+ if (hasPersistenceData) {
7340
+ log("Waiting for context synchronization to complete...");
7341
+ const maxRetries = 150;
7342
+ const retryInterval = 2e3;
7343
+ for (let retry = 0; retry < maxRetries; retry++) {
7344
+ try {
7345
+ const infoResult = await session.context.info();
7346
+ let allCompleted = true;
7347
+ let hasFailure = false;
7348
+ for (const item of infoResult.contextStatusData) {
7349
+ log(`Context ${item.contextId} status: ${item.status}, path: ${item.path}`);
7350
+ if (item.status !== "Success" && item.status !== "Failed") {
7351
+ allCompleted = false;
7352
+ break;
7353
+ }
7354
+ if (item.status === "Failed") {
7355
+ hasFailure = true;
7356
+ logError(`Context synchronization failed for ${item.contextId}: ${item.errorMessage}`);
7357
+ }
7358
+ }
7359
+ if (allCompleted || infoResult.contextStatusData.length === 0) {
7360
+ if (hasFailure) {
7361
+ log("Context synchronization completed with failures");
7362
+ } else {
7363
+ log("Context synchronization completed successfully");
7364
+ }
7365
+ break;
7366
+ }
7367
+ log(`Waiting for context synchronization, attempt ${retry + 1}/${maxRetries}`);
7368
+ await new Promise((resolve2) => setTimeout(resolve2, retryInterval));
7369
+ } catch (error) {
7370
+ logError(`Error checking context status on attempt ${retry + 1}: ${error}`);
7371
+ await new Promise((resolve2) => setTimeout(resolve2, retryInterval));
7372
+ }
7373
+ }
7374
+ }
6407
7375
  return {
6408
7376
  requestId,
6409
7377
  success: true,
@@ -6516,11 +7484,12 @@ var _AgentBay = class _AgentBay {
6516
7484
  * Delete a session by session object.
6517
7485
  *
6518
7486
  * @param session - The session to delete.
7487
+ * @param syncContext - Whether to sync context data (trigger file uploads) before deleting the session. Defaults to false.
6519
7488
  * @returns DeleteResult indicating success or failure and request ID
6520
7489
  */
6521
- async delete(session) {
7490
+ async delete(session, syncContext = false) {
6522
7491
  try {
6523
- const deleteResult = await session.delete();
7492
+ const deleteResult = await session.delete(syncContext);
6524
7493
  this.sessions.delete(session.sessionId);
6525
7494
  return deleteResult;
6526
7495
  } catch (error) {
@@ -6549,8 +7518,244 @@ var _AgentBay = class _AgentBay {
6549
7518
  };
6550
7519
  __name(_AgentBay, "AgentBay");
6551
7520
  var AgentBay = _AgentBay;
7521
+
7522
+ // src/agent/index.ts
7523
+ init_esm_shims();
7524
+
7525
+ // src/context-sync.ts
7526
+ init_esm_shims();
7527
+ var UploadStrategy = /* @__PURE__ */ ((UploadStrategy2) => {
7528
+ UploadStrategy2["UploadBeforeResourceRelease"] = "UploadBeforeResourceRelease";
7529
+ return UploadStrategy2;
7530
+ })(UploadStrategy || {});
7531
+ var DownloadStrategy = /* @__PURE__ */ ((DownloadStrategy2) => {
7532
+ DownloadStrategy2["DownloadAsync"] = "DownloadAsync";
7533
+ return DownloadStrategy2;
7534
+ })(DownloadStrategy || {});
7535
+ var _SyncPolicyImpl = class _SyncPolicyImpl {
7536
+ constructor(policy) {
7537
+ if (policy) {
7538
+ this.uploadPolicy = policy.uploadPolicy;
7539
+ this.downloadPolicy = policy.downloadPolicy;
7540
+ this.deletePolicy = policy.deletePolicy;
7541
+ this.bwList = policy.bwList;
7542
+ }
7543
+ this.ensureDefaults();
7544
+ }
7545
+ ensureDefaults() {
7546
+ if (!this.uploadPolicy) {
7547
+ this.uploadPolicy = newUploadPolicy();
7548
+ }
7549
+ if (!this.downloadPolicy) {
7550
+ this.downloadPolicy = newDownloadPolicy();
7551
+ }
7552
+ if (!this.deletePolicy) {
7553
+ this.deletePolicy = newDeletePolicy();
7554
+ }
7555
+ if (!this.bwList) {
7556
+ this.bwList = {
7557
+ whiteLists: [
7558
+ {
7559
+ path: "",
7560
+ excludePaths: []
7561
+ }
7562
+ ]
7563
+ };
7564
+ }
7565
+ }
7566
+ toJSON() {
7567
+ this.ensureDefaults();
7568
+ return {
7569
+ uploadPolicy: this.uploadPolicy,
7570
+ downloadPolicy: this.downloadPolicy,
7571
+ deletePolicy: this.deletePolicy,
7572
+ bwList: this.bwList
7573
+ };
7574
+ }
7575
+ };
7576
+ __name(_SyncPolicyImpl, "SyncPolicyImpl");
7577
+ var SyncPolicyImpl = _SyncPolicyImpl;
7578
+ var _ContextSync = class _ContextSync {
7579
+ constructor(contextId, path3, policy) {
7580
+ this.contextId = contextId;
7581
+ this.path = path3;
7582
+ this.policy = policy;
7583
+ }
7584
+ // WithPolicy sets the policy and returns the context sync for chaining
7585
+ withPolicy(policy) {
7586
+ this.policy = policy;
7587
+ return this;
7588
+ }
7589
+ };
7590
+ __name(_ContextSync, "ContextSync");
7591
+ var ContextSync = _ContextSync;
7592
+ function newUploadPolicy() {
7593
+ return {
7594
+ autoUpload: true,
7595
+ uploadStrategy: "UploadBeforeResourceRelease" /* UploadBeforeResourceRelease */,
7596
+ period: 30
7597
+ // Default to 30 minutes
7598
+ };
7599
+ }
7600
+ __name(newUploadPolicy, "newUploadPolicy");
7601
+ function newDownloadPolicy() {
7602
+ return {
7603
+ autoDownload: true,
7604
+ downloadStrategy: "DownloadAsync" /* DownloadAsync */
7605
+ };
7606
+ }
7607
+ __name(newDownloadPolicy, "newDownloadPolicy");
7608
+ function newDeletePolicy() {
7609
+ return {
7610
+ syncLocalFile: true
7611
+ };
7612
+ }
7613
+ __name(newDeletePolicy, "newDeletePolicy");
7614
+ function newSyncPolicy() {
7615
+ return {
7616
+ uploadPolicy: newUploadPolicy(),
7617
+ downloadPolicy: newDownloadPolicy(),
7618
+ deletePolicy: newDeletePolicy(),
7619
+ bwList: {
7620
+ whiteLists: [
7621
+ {
7622
+ path: "",
7623
+ excludePaths: []
7624
+ }
7625
+ ]
7626
+ }
7627
+ };
7628
+ }
7629
+ __name(newSyncPolicy, "newSyncPolicy");
7630
+ function newSyncPolicyWithDefaults(policy) {
7631
+ return new SyncPolicyImpl(policy).toJSON();
7632
+ }
7633
+ __name(newSyncPolicyWithDefaults, "newSyncPolicyWithDefaults");
7634
+ function newContextSync(contextId, path3, policy) {
7635
+ return new ContextSync(contextId, path3, policy);
7636
+ }
7637
+ __name(newContextSync, "newContextSync");
7638
+
7639
+ // src/session-params.ts
7640
+ init_esm_shims();
7641
+ var _CreateSessionParams = class _CreateSessionParams {
7642
+ constructor() {
7643
+ this.labels = {};
7644
+ this.contextSync = [];
7645
+ this.isVpc = false;
7646
+ }
7647
+ /**
7648
+ * WithLabels sets the labels for the session parameters and returns the updated parameters.
7649
+ */
7650
+ withLabels(labels) {
7651
+ this.labels = labels;
7652
+ return this;
7653
+ }
7654
+ /**
7655
+ * WithContextID sets the context ID for the session parameters and returns the updated parameters.
7656
+ */
7657
+ withContextID(contextId) {
7658
+ this.contextId = contextId;
7659
+ return this;
7660
+ }
7661
+ /**
7662
+ * WithImageId sets the image ID for the session parameters and returns the updated parameters.
7663
+ */
7664
+ withImageId(imageId) {
7665
+ this.imageId = imageId;
7666
+ return this;
7667
+ }
7668
+ /**
7669
+ * WithBrowserContext sets the browser context for the session parameters and returns the updated parameters.
7670
+ */
7671
+ withBrowserContext(browserContext) {
7672
+ this.browserContext = browserContext;
7673
+ return this;
7674
+ }
7675
+ /**
7676
+ * WithIsVpc sets the VPC flag for the session parameters and returns the updated parameters.
7677
+ */
7678
+ withIsVpc(isVpc) {
7679
+ this.isVpc = isVpc;
7680
+ return this;
7681
+ }
7682
+ /**
7683
+ * GetLabelsJSON returns the labels as a JSON string.
7684
+ * Returns an object with success status and result/error message to match Go version behavior.
7685
+ */
7686
+ getLabelsJSON() {
7687
+ if (Object.keys(this.labels).length === 0) {
7688
+ return { result: "" };
7689
+ }
7690
+ try {
7691
+ const labelsJSON = JSON.stringify(this.labels);
7692
+ return { result: labelsJSON };
7693
+ } catch (error) {
7694
+ return {
7695
+ result: "",
7696
+ error: `Failed to marshal labels to JSON: ${error}`
7697
+ };
7698
+ }
7699
+ }
7700
+ /**
7701
+ * AddContextSync adds a context sync configuration to the session parameters.
7702
+ */
7703
+ addContextSync(contextId, path3, policy) {
7704
+ const contextSync = new ContextSync(contextId, path3, policy);
7705
+ this.contextSync.push(contextSync);
7706
+ return this;
7707
+ }
7708
+ /**
7709
+ * AddContextSyncConfig adds a pre-configured context sync to the session parameters.
7710
+ */
7711
+ addContextSyncConfig(contextSync) {
7712
+ this.contextSync.push(contextSync);
7713
+ return this;
7714
+ }
7715
+ /**
7716
+ * WithContextSync sets the context sync configurations for the session parameters.
7717
+ */
7718
+ withContextSync(contextSyncs) {
7719
+ this.contextSync = contextSyncs;
7720
+ return this;
7721
+ }
7722
+ /**
7723
+ * Convert to plain object for JSON serialization
7724
+ */
7725
+ toJSON() {
7726
+ return {
7727
+ labels: this.labels,
7728
+ contextId: this.contextId,
7729
+ imageId: this.imageId,
7730
+ contextSync: this.contextSync,
7731
+ browserContext: this.browserContext,
7732
+ isVpc: this.isVpc
7733
+ };
7734
+ }
7735
+ /**
7736
+ * Create from plain object
7737
+ */
7738
+ static fromJSON(config) {
7739
+ const params = new _CreateSessionParams();
7740
+ params.labels = config.labels || {};
7741
+ params.contextId = config.contextId;
7742
+ params.imageId = config.imageId;
7743
+ params.contextSync = config.contextSync || [];
7744
+ params.browserContext = config.browserContext;
7745
+ params.isVpc = config.isVpc || false;
7746
+ return params;
7747
+ }
7748
+ };
7749
+ __name(_CreateSessionParams, "CreateSessionParams");
7750
+ var CreateSessionParams = _CreateSessionParams;
7751
+ function newCreateSessionParams() {
7752
+ return new CreateSessionParams();
7753
+ }
7754
+ __name(newCreateSessionParams, "newCreateSessionParams");
6552
7755
  export {
6553
7756
  APIError,
7757
+ ActResult,
7758
+ Agent,
6554
7759
  AgentBay,
6555
7760
  AgentBayError,
6556
7761
  Application,
@@ -6560,6 +7765,9 @@ export {
6560
7765
  ApplyMqttTokenResponseBody,
6561
7766
  ApplyMqttTokenResponseBodyData,
6562
7767
  AuthenticationError,
7768
+ Browser,
7769
+ BrowserAgent,
7770
+ BrowserError,
6563
7771
  CallMcpToolRequest,
6564
7772
  CallMcpToolResponse,
6565
7773
  CallMcpToolResponseBody,
@@ -6567,16 +7775,20 @@ export {
6567
7775
  Command,
6568
7776
  CommandError,
6569
7777
  Context,
7778
+ ContextManager,
6570
7779
  ContextService,
7780
+ ContextSync,
6571
7781
  CreateMcpSessionRequest,
6572
7782
  CreateMcpSessionRequestPersistenceDataList,
6573
7783
  CreateMcpSessionResponse,
6574
7784
  CreateMcpSessionResponseBody,
6575
7785
  CreateMcpSessionResponseBodyData,
6576
7786
  CreateMcpSessionShrinkRequest,
7787
+ CreateSessionParams,
6577
7788
  DeleteContextRequest,
6578
7789
  DeleteContextResponse,
6579
7790
  DeleteContextResponseBody,
7791
+ DownloadStrategy,
6580
7792
  FileError,
6581
7793
  FileSystem,
6582
7794
  GetContextInfoRequest,
@@ -6600,6 +7812,10 @@ export {
6600
7812
  GetMcpResourceResponseBody,
6601
7813
  GetMcpResourceResponseBodyData,
6602
7814
  GetMcpResourceResponseBodyDataDesktopInfo,
7815
+ InitBrowserRequest,
7816
+ InitBrowserResponse,
7817
+ InitBrowserResponseBody,
7818
+ InitBrowserResponseBodyData,
6603
7819
  KeyCode,
6604
7820
  ListContextsRequest,
6605
7821
  ListContextsResponse,
@@ -6615,6 +7831,7 @@ export {
6615
7831
  ModifyContextRequest,
6616
7832
  ModifyContextResponse,
6617
7833
  ModifyContextResponseBody,
7834
+ ObserveResult,
6618
7835
  Oss,
6619
7836
  OssError,
6620
7837
  ReleaseMcpSessionRequest,
@@ -6628,10 +7845,20 @@ export {
6628
7845
  SyncContextRequest,
6629
7846
  SyncContextResponse,
6630
7847
  SyncContextResponseBody,
7848
+ SyncPolicyImpl,
6631
7849
  UI,
6632
7850
  UIError,
7851
+ UploadStrategy,
6633
7852
  log,
6634
- logError
7853
+ logError,
7854
+ newContextManager,
7855
+ newContextSync,
7856
+ newCreateSessionParams,
7857
+ newDeletePolicy,
7858
+ newDownloadPolicy,
7859
+ newSyncPolicy,
7860
+ newSyncPolicyWithDefaults,
7861
+ newUploadPolicy
6635
7862
  };
6636
7863
  //# sourceMappingURL=index.mjs.map
6637
7864