wuying-agentbay-sdk 0.5.1 → 0.7.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
@@ -129,10 +129,10 @@ var require_main = __commonJS({
129
129
  "node_modules/dotenv/lib/main.js"(exports, module) {
130
130
  "use strict";
131
131
  init_esm_shims();
132
- var fs2 = __require("fs");
133
- var path3 = __require("path");
132
+ var fs3 = __require("fs");
133
+ var path4 = __require("path");
134
134
  var os = __require("os");
135
- var crypto = __require("crypto");
135
+ var crypto2 = __require("crypto");
136
136
  var packageJson = require_package();
137
137
  var version = packageJson.version;
138
138
  var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
@@ -245,7 +245,7 @@ var require_main = __commonJS({
245
245
  if (options && options.path && options.path.length > 0) {
246
246
  if (Array.isArray(options.path)) {
247
247
  for (const filepath of options.path) {
248
- if (fs2.existsSync(filepath)) {
248
+ if (fs3.existsSync(filepath)) {
249
249
  possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
250
250
  }
251
251
  }
@@ -253,16 +253,16 @@ var require_main = __commonJS({
253
253
  possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
254
254
  }
255
255
  } else {
256
- possibleVaultPath = path3.resolve(process.cwd(), ".env.vault");
256
+ possibleVaultPath = path4.resolve(process.cwd(), ".env.vault");
257
257
  }
258
- if (fs2.existsSync(possibleVaultPath)) {
258
+ if (fs3.existsSync(possibleVaultPath)) {
259
259
  return possibleVaultPath;
260
260
  }
261
261
  return null;
262
262
  }
263
263
  __name(_vaultPath, "_vaultPath");
264
264
  function _resolveHome(envPath) {
265
- return envPath[0] === "~" ? path3.join(os.homedir(), envPath.slice(1)) : envPath;
265
+ return envPath[0] === "~" ? path4.join(os.homedir(), envPath.slice(1)) : envPath;
266
266
  }
267
267
  __name(_resolveHome, "_resolveHome");
268
268
  function _configVault(options) {
@@ -281,7 +281,7 @@ var require_main = __commonJS({
281
281
  }
282
282
  __name(_configVault, "_configVault");
283
283
  function configDotenv(options) {
284
- const dotenvPath = path3.resolve(process.cwd(), ".env");
284
+ const dotenvPath = path4.resolve(process.cwd(), ".env");
285
285
  let encoding = "utf8";
286
286
  const debug = Boolean(options && options.debug);
287
287
  const quiet = options && "quiet" in options ? options.quiet : true;
@@ -305,13 +305,13 @@ var require_main = __commonJS({
305
305
  }
306
306
  let lastError;
307
307
  const parsedAll = {};
308
- for (const path4 of optionPaths) {
308
+ for (const path5 of optionPaths) {
309
309
  try {
310
- const parsed = DotenvModule.parse(fs2.readFileSync(path4, { encoding }));
310
+ const parsed = DotenvModule.parse(fs3.readFileSync(path5, { encoding }));
311
311
  DotenvModule.populate(parsedAll, parsed, options);
312
312
  } catch (e) {
313
313
  if (debug) {
314
- _debug(`Failed to load ${path4} ${e.message}`);
314
+ _debug(`Failed to load ${path5} ${e.message}`);
315
315
  }
316
316
  lastError = e;
317
317
  }
@@ -326,7 +326,7 @@ var require_main = __commonJS({
326
326
  const shortPaths = [];
327
327
  for (const filePath of optionPaths) {
328
328
  try {
329
- const relative = path3.relative(process.cwd(), filePath);
329
+ const relative = path4.relative(process.cwd(), filePath);
330
330
  shortPaths.push(relative);
331
331
  } catch (e) {
332
332
  if (debug) {
@@ -363,7 +363,7 @@ var require_main = __commonJS({
363
363
  const authTag = ciphertext.subarray(-16);
364
364
  ciphertext = ciphertext.subarray(12, -16);
365
365
  try {
366
- const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
366
+ const aesgcm = crypto2.createDecipheriv("aes-256-gcm", key, nonce);
367
367
  aesgcm.setAuthTag(authTag);
368
368
  return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
369
369
  } catch (error) {
@@ -504,7 +504,7 @@ init_esm_shims();
504
504
 
505
505
  // src/api/client.ts
506
506
  init_esm_shims();
507
- import * as $dara65 from "@darabonba/typescript";
507
+ import * as $dara77 from "@darabonba/typescript";
508
508
  import OpenApi from "@alicloud/openapi-core";
509
509
  import { OpenApiUtil, $OpenApiUtil } from "@alicloud/openapi-core";
510
510
 
@@ -1056,6 +1056,7 @@ var _CreateMcpSessionRequest = class _CreateMcpSessionRequest extends $dara18.Mo
1056
1056
  externalUserId: "ExternalUserId",
1057
1057
  imageId: "ImageId",
1058
1058
  labels: "Labels",
1059
+ mcpPolicyId: "McpPolicyId",
1059
1060
  persistenceDataList: "PersistenceDataList",
1060
1061
  sessionId: "SessionId",
1061
1062
  vpcResource: "VpcResource"
@@ -1068,6 +1069,7 @@ var _CreateMcpSessionRequest = class _CreateMcpSessionRequest extends $dara18.Mo
1068
1069
  externalUserId: "string",
1069
1070
  imageId: "string",
1070
1071
  labels: "string",
1072
+ mcpPolicyId: "string",
1071
1073
  persistenceDataList: { "type": "array", "itemType": CreateMcpSessionRequestPersistenceDataList },
1072
1074
  sessionId: "string",
1073
1075
  vpcResource: "boolean"
@@ -1097,6 +1099,7 @@ var _CreateMcpSessionShrinkRequest = class _CreateMcpSessionShrinkRequest extend
1097
1099
  externalUserId: "ExternalUserId",
1098
1100
  imageId: "ImageId",
1099
1101
  labels: "Labels",
1102
+ mcpPolicyId: "McpPolicyId",
1100
1103
  persistenceDataListShrink: "PersistenceDataList",
1101
1104
  sessionId: "SessionId",
1102
1105
  vpcResource: "VpcResource"
@@ -1109,6 +1112,7 @@ var _CreateMcpSessionShrinkRequest = class _CreateMcpSessionShrinkRequest extend
1109
1112
  externalUserId: "string",
1110
1113
  imageId: "string",
1111
1114
  labels: "string",
1115
+ mcpPolicyId: "string",
1112
1116
  persistenceDataListShrink: "string",
1113
1117
  sessionId: "string",
1114
1118
  vpcResource: "boolean"
@@ -1802,14 +1806,16 @@ var _InitBrowserRequest = class _InitBrowserRequest extends $dara40.Model {
1802
1806
  return {
1803
1807
  authorization: "Authorization",
1804
1808
  persistentPath: "PersistentPath",
1805
- sessionId: "SessionId"
1809
+ sessionId: "SessionId",
1810
+ browserOption: "BrowserOption"
1806
1811
  };
1807
1812
  }
1808
1813
  static types() {
1809
1814
  return {
1810
1815
  authorization: "string",
1811
1816
  persistentPath: "string",
1812
- sessionId: "string"
1817
+ sessionId: "string",
1818
+ browserOption: { "type": "map", "keyType": "string", "valueType": "any" }
1813
1819
  };
1814
1820
  }
1815
1821
  validate() {
@@ -2615,6 +2621,448 @@ var _SyncContextResponse = class _SyncContextResponse extends $dara64.Model {
2615
2621
  __name(_SyncContextResponse, "SyncContextResponse");
2616
2622
  var SyncContextResponse = _SyncContextResponse;
2617
2623
 
2624
+ // src/api/models/DeleteContextFileRequest.ts
2625
+ init_esm_shims();
2626
+ import * as $dara65 from "@darabonba/typescript";
2627
+ var _DeleteContextFileRequest = class _DeleteContextFileRequest extends $dara65.Model {
2628
+ static names() {
2629
+ return {
2630
+ authorization: "Authorization",
2631
+ contextId: "ContextId",
2632
+ filePath: "FilePath"
2633
+ };
2634
+ }
2635
+ static types() {
2636
+ return {
2637
+ authorization: "string",
2638
+ contextId: "string",
2639
+ filePath: "string"
2640
+ };
2641
+ }
2642
+ validate() {
2643
+ super.validate();
2644
+ }
2645
+ constructor(map) {
2646
+ super(map);
2647
+ }
2648
+ };
2649
+ __name(_DeleteContextFileRequest, "DeleteContextFileRequest");
2650
+ var DeleteContextFileRequest = _DeleteContextFileRequest;
2651
+
2652
+ // src/api/models/DeleteContextFileResponseBody.ts
2653
+ init_esm_shims();
2654
+ import * as $dara66 from "@darabonba/typescript";
2655
+ var _DeleteContextFileResponseBody = class _DeleteContextFileResponseBody extends $dara66.Model {
2656
+ static names() {
2657
+ return {
2658
+ code: "Code",
2659
+ httpStatusCode: "HttpStatusCode",
2660
+ message: "Message",
2661
+ requestId: "RequestId",
2662
+ success: "Success"
2663
+ };
2664
+ }
2665
+ static types() {
2666
+ return {
2667
+ code: "string",
2668
+ httpStatusCode: "number",
2669
+ message: "string",
2670
+ requestId: "string",
2671
+ success: "boolean"
2672
+ };
2673
+ }
2674
+ validate() {
2675
+ super.validate();
2676
+ }
2677
+ constructor(map) {
2678
+ super(map);
2679
+ }
2680
+ };
2681
+ __name(_DeleteContextFileResponseBody, "DeleteContextFileResponseBody");
2682
+ var DeleteContextFileResponseBody = _DeleteContextFileResponseBody;
2683
+
2684
+ // src/api/models/DeleteContextFileResponse.ts
2685
+ init_esm_shims();
2686
+ import * as $dara67 from "@darabonba/typescript";
2687
+ var _DeleteContextFileResponse = class _DeleteContextFileResponse extends $dara67.Model {
2688
+ static names() {
2689
+ return {
2690
+ headers: "headers",
2691
+ statusCode: "statusCode",
2692
+ body: "body"
2693
+ };
2694
+ }
2695
+ static types() {
2696
+ return {
2697
+ headers: { type: "map", keyType: "string", valueType: "string" },
2698
+ statusCode: "number",
2699
+ body: DeleteContextFileResponseBody
2700
+ };
2701
+ }
2702
+ validate() {
2703
+ super.validate();
2704
+ }
2705
+ constructor(map) {
2706
+ super(map);
2707
+ }
2708
+ };
2709
+ __name(_DeleteContextFileResponse, "DeleteContextFileResponse");
2710
+ var DeleteContextFileResponse = _DeleteContextFileResponse;
2711
+
2712
+ // src/api/models/DescribeContextFilesRequest.ts
2713
+ init_esm_shims();
2714
+ import * as $dara68 from "@darabonba/typescript";
2715
+ var _DescribeContextFilesRequest = class _DescribeContextFilesRequest extends $dara68.Model {
2716
+ static names() {
2717
+ return {
2718
+ authorization: "Authorization",
2719
+ pageNumber: "PageNumber",
2720
+ pageSize: "PageSize",
2721
+ parentFolderPath: "ParentFolderPath",
2722
+ contextId: "ContextId"
2723
+ };
2724
+ }
2725
+ static types() {
2726
+ return {
2727
+ authorization: "string",
2728
+ pageNumber: "number",
2729
+ pageSize: "number",
2730
+ parentFolderPath: "string",
2731
+ contextId: "string"
2732
+ };
2733
+ }
2734
+ validate() {
2735
+ super.validate();
2736
+ }
2737
+ constructor(map) {
2738
+ super(map);
2739
+ }
2740
+ };
2741
+ __name(_DescribeContextFilesRequest, "DescribeContextFilesRequest");
2742
+ var DescribeContextFilesRequest = _DescribeContextFilesRequest;
2743
+
2744
+ // src/api/models/DescribeContextFilesResponseBody.ts
2745
+ init_esm_shims();
2746
+ import * as $dara69 from "@darabonba/typescript";
2747
+ var _DescribeContextFilesResponseBodyData = class _DescribeContextFilesResponseBodyData extends $dara69.Model {
2748
+ static names() {
2749
+ return {
2750
+ fileId: "FileId",
2751
+ fileName: "FileName",
2752
+ filePath: "FilePath",
2753
+ fileType: "FileType",
2754
+ gmtCreate: "GmtCreate",
2755
+ gmtModified: "GmtModified",
2756
+ size: "Size",
2757
+ status: "Status"
2758
+ };
2759
+ }
2760
+ static types() {
2761
+ return {
2762
+ fileId: "string",
2763
+ fileName: "string",
2764
+ filePath: "string",
2765
+ fileType: "string",
2766
+ gmtCreate: "string",
2767
+ gmtModified: "string",
2768
+ size: "number",
2769
+ status: "string"
2770
+ };
2771
+ }
2772
+ validate() {
2773
+ super.validate();
2774
+ }
2775
+ constructor(map) {
2776
+ super(map);
2777
+ }
2778
+ };
2779
+ __name(_DescribeContextFilesResponseBodyData, "DescribeContextFilesResponseBodyData");
2780
+ var DescribeContextFilesResponseBodyData = _DescribeContextFilesResponseBodyData;
2781
+ var _DescribeContextFilesResponseBody = class _DescribeContextFilesResponseBody extends $dara69.Model {
2782
+ static names() {
2783
+ return {
2784
+ code: "Code",
2785
+ count: "Count",
2786
+ data: "Data",
2787
+ httpStatusCode: "HttpStatusCode",
2788
+ message: "Message",
2789
+ requestId: "RequestId",
2790
+ success: "Success"
2791
+ };
2792
+ }
2793
+ static types() {
2794
+ return {
2795
+ code: "string",
2796
+ count: "number",
2797
+ data: { type: "array", itemType: DescribeContextFilesResponseBodyData },
2798
+ httpStatusCode: "number",
2799
+ message: "string",
2800
+ requestId: "string",
2801
+ success: "boolean"
2802
+ };
2803
+ }
2804
+ validate() {
2805
+ super.validate();
2806
+ }
2807
+ constructor(map) {
2808
+ super(map);
2809
+ }
2810
+ };
2811
+ __name(_DescribeContextFilesResponseBody, "DescribeContextFilesResponseBody");
2812
+ var DescribeContextFilesResponseBody = _DescribeContextFilesResponseBody;
2813
+
2814
+ // src/api/models/DescribeContextFilesResponse.ts
2815
+ init_esm_shims();
2816
+ import * as $dara70 from "@darabonba/typescript";
2817
+ var _DescribeContextFilesResponse = class _DescribeContextFilesResponse extends $dara70.Model {
2818
+ static names() {
2819
+ return {
2820
+ headers: "headers",
2821
+ statusCode: "statusCode",
2822
+ body: "body"
2823
+ };
2824
+ }
2825
+ static types() {
2826
+ return {
2827
+ headers: { type: "map", keyType: "string", valueType: "string" },
2828
+ statusCode: "number",
2829
+ body: DescribeContextFilesResponseBody
2830
+ };
2831
+ }
2832
+ validate() {
2833
+ super.validate();
2834
+ }
2835
+ constructor(map) {
2836
+ super(map);
2837
+ }
2838
+ };
2839
+ __name(_DescribeContextFilesResponse, "DescribeContextFilesResponse");
2840
+ var DescribeContextFilesResponse = _DescribeContextFilesResponse;
2841
+
2842
+ // src/api/models/GetContextFileDownloadUrlRequest.ts
2843
+ init_esm_shims();
2844
+ import * as $dara71 from "@darabonba/typescript";
2845
+ var _GetContextFileDownloadUrlRequest = class _GetContextFileDownloadUrlRequest extends $dara71.Model {
2846
+ static names() {
2847
+ return {
2848
+ authorization: "Authorization",
2849
+ contextId: "ContextId",
2850
+ filePath: "FilePath"
2851
+ };
2852
+ }
2853
+ static types() {
2854
+ return {
2855
+ authorization: "string",
2856
+ contextId: "string",
2857
+ filePath: "string"
2858
+ };
2859
+ }
2860
+ validate() {
2861
+ super.validate();
2862
+ }
2863
+ constructor(map) {
2864
+ super(map);
2865
+ }
2866
+ };
2867
+ __name(_GetContextFileDownloadUrlRequest, "GetContextFileDownloadUrlRequest");
2868
+ var GetContextFileDownloadUrlRequest = _GetContextFileDownloadUrlRequest;
2869
+
2870
+ // src/api/models/GetContextFileDownloadUrlResponseBody.ts
2871
+ init_esm_shims();
2872
+ import * as $dara72 from "@darabonba/typescript";
2873
+ var _GetContextFileDownloadUrlResponseBodyData = class _GetContextFileDownloadUrlResponseBodyData extends $dara72.Model {
2874
+ static names() {
2875
+ return {
2876
+ expireTime: "ExpireTime",
2877
+ url: "Url"
2878
+ };
2879
+ }
2880
+ static types() {
2881
+ return {
2882
+ expireTime: "number",
2883
+ url: "string"
2884
+ };
2885
+ }
2886
+ validate() {
2887
+ super.validate();
2888
+ }
2889
+ constructor(map) {
2890
+ super(map);
2891
+ }
2892
+ };
2893
+ __name(_GetContextFileDownloadUrlResponseBodyData, "GetContextFileDownloadUrlResponseBodyData");
2894
+ var GetContextFileDownloadUrlResponseBodyData = _GetContextFileDownloadUrlResponseBodyData;
2895
+ var _GetContextFileDownloadUrlResponseBody = class _GetContextFileDownloadUrlResponseBody extends $dara72.Model {
2896
+ static names() {
2897
+ return {
2898
+ code: "Code",
2899
+ data: "Data",
2900
+ httpStatusCode: "HttpStatusCode",
2901
+ message: "Message",
2902
+ requestId: "RequestId",
2903
+ success: "Success"
2904
+ };
2905
+ }
2906
+ static types() {
2907
+ return {
2908
+ code: "string",
2909
+ data: GetContextFileDownloadUrlResponseBodyData,
2910
+ httpStatusCode: "number",
2911
+ message: "string",
2912
+ requestId: "string",
2913
+ success: "boolean"
2914
+ };
2915
+ }
2916
+ validate() {
2917
+ super.validate();
2918
+ }
2919
+ constructor(map) {
2920
+ super(map);
2921
+ }
2922
+ };
2923
+ __name(_GetContextFileDownloadUrlResponseBody, "GetContextFileDownloadUrlResponseBody");
2924
+ var GetContextFileDownloadUrlResponseBody = _GetContextFileDownloadUrlResponseBody;
2925
+
2926
+ // src/api/models/GetContextFileDownloadUrlResponse.ts
2927
+ init_esm_shims();
2928
+ import * as $dara73 from "@darabonba/typescript";
2929
+ var _GetContextFileDownloadUrlResponse = class _GetContextFileDownloadUrlResponse extends $dara73.Model {
2930
+ static names() {
2931
+ return {
2932
+ headers: "headers",
2933
+ statusCode: "statusCode",
2934
+ body: "body"
2935
+ };
2936
+ }
2937
+ static types() {
2938
+ return {
2939
+ headers: { type: "map", keyType: "string", valueType: "string" },
2940
+ statusCode: "number",
2941
+ body: GetContextFileDownloadUrlResponseBody
2942
+ };
2943
+ }
2944
+ validate() {
2945
+ super.validate();
2946
+ }
2947
+ constructor(map) {
2948
+ super(map);
2949
+ }
2950
+ };
2951
+ __name(_GetContextFileDownloadUrlResponse, "GetContextFileDownloadUrlResponse");
2952
+ var GetContextFileDownloadUrlResponse = _GetContextFileDownloadUrlResponse;
2953
+
2954
+ // src/api/models/GetContextFileUploadUrlRequest.ts
2955
+ init_esm_shims();
2956
+ import * as $dara74 from "@darabonba/typescript";
2957
+ var _GetContextFileUploadUrlRequest = class _GetContextFileUploadUrlRequest extends $dara74.Model {
2958
+ static names() {
2959
+ return {
2960
+ authorization: "Authorization",
2961
+ contextId: "ContextId",
2962
+ filePath: "FilePath"
2963
+ };
2964
+ }
2965
+ static types() {
2966
+ return {
2967
+ authorization: "string",
2968
+ contextId: "string",
2969
+ filePath: "string"
2970
+ };
2971
+ }
2972
+ validate() {
2973
+ super.validate();
2974
+ }
2975
+ constructor(map) {
2976
+ super(map);
2977
+ }
2978
+ };
2979
+ __name(_GetContextFileUploadUrlRequest, "GetContextFileUploadUrlRequest");
2980
+ var GetContextFileUploadUrlRequest = _GetContextFileUploadUrlRequest;
2981
+
2982
+ // src/api/models/GetContextFileUploadUrlResponseBody.ts
2983
+ init_esm_shims();
2984
+ import * as $dara75 from "@darabonba/typescript";
2985
+ var _GetContextFileUploadUrlResponseBodyData = class _GetContextFileUploadUrlResponseBodyData extends $dara75.Model {
2986
+ static names() {
2987
+ return {
2988
+ expireTime: "ExpireTime",
2989
+ url: "Url"
2990
+ };
2991
+ }
2992
+ static types() {
2993
+ return {
2994
+ expireTime: "number",
2995
+ url: "string"
2996
+ };
2997
+ }
2998
+ validate() {
2999
+ super.validate();
3000
+ }
3001
+ constructor(map) {
3002
+ super(map);
3003
+ }
3004
+ };
3005
+ __name(_GetContextFileUploadUrlResponseBodyData, "GetContextFileUploadUrlResponseBodyData");
3006
+ var GetContextFileUploadUrlResponseBodyData = _GetContextFileUploadUrlResponseBodyData;
3007
+ var _GetContextFileUploadUrlResponseBody = class _GetContextFileUploadUrlResponseBody extends $dara75.Model {
3008
+ static names() {
3009
+ return {
3010
+ code: "Code",
3011
+ data: "Data",
3012
+ httpStatusCode: "HttpStatusCode",
3013
+ message: "Message",
3014
+ requestId: "RequestId",
3015
+ success: "Success"
3016
+ };
3017
+ }
3018
+ static types() {
3019
+ return {
3020
+ code: "string",
3021
+ data: GetContextFileUploadUrlResponseBodyData,
3022
+ httpStatusCode: "number",
3023
+ message: "string",
3024
+ requestId: "string",
3025
+ success: "boolean"
3026
+ };
3027
+ }
3028
+ validate() {
3029
+ super.validate();
3030
+ }
3031
+ constructor(map) {
3032
+ super(map);
3033
+ }
3034
+ };
3035
+ __name(_GetContextFileUploadUrlResponseBody, "GetContextFileUploadUrlResponseBody");
3036
+ var GetContextFileUploadUrlResponseBody = _GetContextFileUploadUrlResponseBody;
3037
+
3038
+ // src/api/models/GetContextFileUploadUrlResponse.ts
3039
+ init_esm_shims();
3040
+ import * as $dara76 from "@darabonba/typescript";
3041
+ var _GetContextFileUploadUrlResponse = class _GetContextFileUploadUrlResponse extends $dara76.Model {
3042
+ static names() {
3043
+ return {
3044
+ headers: "headers",
3045
+ statusCode: "statusCode",
3046
+ body: "body"
3047
+ };
3048
+ }
3049
+ static types() {
3050
+ return {
3051
+ headers: { type: "map", keyType: "string", valueType: "string" },
3052
+ statusCode: "number",
3053
+ body: GetContextFileUploadUrlResponseBody
3054
+ };
3055
+ }
3056
+ validate() {
3057
+ super.validate();
3058
+ }
3059
+ constructor(map) {
3060
+ super(map);
3061
+ }
3062
+ };
3063
+ __name(_GetContextFileUploadUrlResponse, "GetContextFileUploadUrlResponse");
3064
+ var GetContextFileUploadUrlResponse = _GetContextFileUploadUrlResponse;
3065
+
2618
3066
  // src/api/client.ts
2619
3067
  var _Client = class _Client extends (OpenApi.default || OpenApi) {
2620
3068
  constructor(config) {
@@ -2633,10 +3081,10 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2633
3081
  );
2634
3082
  }
2635
3083
  getEndpoint(productId, regionId, endpointRule, network, suffix, endpointMap, endpoint) {
2636
- if (!$dara65.isNull(endpoint)) {
3084
+ if (!$dara77.isNull(endpoint)) {
2637
3085
  return endpoint;
2638
3086
  }
2639
- if (!$dara65.isNull(endpointMap) && !$dara65.isNull(endpointMap[regionId])) {
3087
+ if (!$dara77.isNull(endpointMap) && !$dara77.isNull(endpointMap[regionId])) {
2640
3088
  return endpointMap[regionId];
2641
3089
  }
2642
3090
  return OpenApiUtil.getEndpointRules(
@@ -2657,28 +3105,28 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2657
3105
  async callMcpToolWithOptions(request, runtime) {
2658
3106
  request.validate();
2659
3107
  const body = {};
2660
- if (!$dara65.isNull(request.args)) {
3108
+ if (!$dara77.isNull(request.args)) {
2661
3109
  body["Args"] = request.args;
2662
3110
  }
2663
- if (!$dara65.isNull(request.authorization)) {
3111
+ if (!$dara77.isNull(request.authorization)) {
2664
3112
  body["Authorization"] = request.authorization;
2665
3113
  }
2666
- if (!$dara65.isNull(request.externalUserId)) {
3114
+ if (!$dara77.isNull(request.externalUserId)) {
2667
3115
  body["ExternalUserId"] = request.externalUserId;
2668
3116
  }
2669
- if (!$dara65.isNull(request.imageId)) {
3117
+ if (!$dara77.isNull(request.imageId)) {
2670
3118
  body["ImageId"] = request.imageId;
2671
3119
  }
2672
- if (!$dara65.isNull(request.name)) {
3120
+ if (!$dara77.isNull(request.name)) {
2673
3121
  body["Name"] = request.name;
2674
3122
  }
2675
- if (!$dara65.isNull(request.server)) {
3123
+ if (!$dara77.isNull(request.server)) {
2676
3124
  body["Server"] = request.server;
2677
3125
  }
2678
- if (!$dara65.isNull(request.sessionId)) {
3126
+ if (!$dara77.isNull(request.sessionId)) {
2679
3127
  body["SessionId"] = request.sessionId;
2680
3128
  }
2681
- if (!$dara65.isNull(request.tool)) {
3129
+ if (!$dara77.isNull(request.tool)) {
2682
3130
  body["Tool"] = request.tool;
2683
3131
  }
2684
3132
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -2695,7 +3143,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2695
3143
  reqBodyType: "formData",
2696
3144
  bodyType: "json"
2697
3145
  });
2698
- return $dara65.cast(
3146
+ return $dara77.cast(
2699
3147
  await this.callApi(params, req, runtime),
2700
3148
  new CallMcpToolResponse({})
2701
3149
  );
@@ -2707,7 +3155,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2707
3155
  * @returns CallMcpToolResponse
2708
3156
  */
2709
3157
  async callMcpTool(request) {
2710
- const runtime = new $dara65.RuntimeOptions({});
3158
+ const runtime = new $dara77.RuntimeOptions({});
2711
3159
  return await this.callMcpToolWithOptions(request, runtime);
2712
3160
  }
2713
3161
  /**
@@ -2721,7 +3169,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2721
3169
  tmpReq.validate();
2722
3170
  const request = new CreateMcpSessionShrinkRequest({});
2723
3171
  OpenApiUtil.convert(tmpReq, request);
2724
- if (!$dara65.isNull(tmpReq.persistenceDataList)) {
3172
+ if (!$dara77.isNull(tmpReq.persistenceDataList)) {
2725
3173
  request.persistenceDataListShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(
2726
3174
  tmpReq.persistenceDataList,
2727
3175
  "PersistenceDataList",
@@ -2729,28 +3177,31 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2729
3177
  );
2730
3178
  }
2731
3179
  const body = {};
2732
- if (!$dara65.isNull(request.authorization)) {
3180
+ if (!$dara77.isNull(request.authorization)) {
2733
3181
  body["Authorization"] = request.authorization;
2734
3182
  }
2735
- if (!$dara65.isNull(request.contextId)) {
3183
+ if (!$dara77.isNull(request.contextId)) {
2736
3184
  body["ContextId"] = request.contextId;
2737
3185
  }
2738
- if (!$dara65.isNull(request.externalUserId)) {
3186
+ if (!$dara77.isNull(request.externalUserId)) {
2739
3187
  body["ExternalUserId"] = request.externalUserId;
2740
3188
  }
2741
- if (!$dara65.isNull(request.imageId)) {
3189
+ if (!$dara77.isNull(request.imageId)) {
2742
3190
  body["ImageId"] = request.imageId;
2743
3191
  }
2744
- if (!$dara65.isNull(request.labels)) {
3192
+ if (!$dara77.isNull(request.labels)) {
2745
3193
  body["Labels"] = request.labels;
2746
3194
  }
2747
- if (!$dara65.isNull(request.persistenceDataListShrink)) {
3195
+ if (!$dara77.isNull(request.mcpPolicyId)) {
3196
+ body["McpPolicyId"] = request.mcpPolicyId;
3197
+ }
3198
+ if (!$dara77.isNull(request.persistenceDataListShrink)) {
2748
3199
  body["PersistenceDataList"] = request.persistenceDataListShrink;
2749
3200
  }
2750
- if (!$dara65.isNull(request.sessionId)) {
3201
+ if (!$dara77.isNull(request.sessionId)) {
2751
3202
  body["SessionId"] = request.sessionId;
2752
3203
  }
2753
- if (!$dara65.isNull(request.vpcResource)) {
3204
+ if (!$dara77.isNull(request.vpcResource)) {
2754
3205
  body["VpcResource"] = request.vpcResource;
2755
3206
  }
2756
3207
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -2767,7 +3218,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2767
3218
  reqBodyType: "formData",
2768
3219
  bodyType: "json"
2769
3220
  });
2770
- return $dara65.cast(
3221
+ return $dara77.cast(
2771
3222
  await this.callApi(params, req, runtime),
2772
3223
  new CreateMcpSessionResponse({})
2773
3224
  );
@@ -2779,7 +3230,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2779
3230
  * @returns CreateMcpSessionResponse
2780
3231
  */
2781
3232
  async createMcpSession(request) {
2782
- const runtime = new $dara65.RuntimeOptions({});
3233
+ const runtime = new $dara77.RuntimeOptions({});
2783
3234
  return await this.createMcpSessionWithOptions(request, runtime);
2784
3235
  }
2785
3236
  /**
@@ -2792,10 +3243,10 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2792
3243
  async deleteContextWithOptions(request, runtime) {
2793
3244
  request.validate();
2794
3245
  const body = {};
2795
- if (!$dara65.isNull(request.authorization)) {
3246
+ if (!$dara77.isNull(request.authorization)) {
2796
3247
  body["Authorization"] = request.authorization;
2797
3248
  }
2798
- if (!$dara65.isNull(request.id)) {
3249
+ if (!$dara77.isNull(request.id)) {
2799
3250
  body["Id"] = request.id;
2800
3251
  }
2801
3252
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -2812,7 +3263,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2812
3263
  reqBodyType: "formData",
2813
3264
  bodyType: "json"
2814
3265
  });
2815
- return $dara65.cast(
3266
+ return $dara77.cast(
2816
3267
  await this.callApi(params, req, runtime),
2817
3268
  new DeleteContextResponse({})
2818
3269
  );
@@ -2824,7 +3275,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2824
3275
  * @returns DeleteContextResponse
2825
3276
  */
2826
3277
  async deleteContext(request) {
2827
- const runtime = new $dara65.RuntimeOptions({});
3278
+ const runtime = new $dara77.RuntimeOptions({});
2828
3279
  return await this.deleteContextWithOptions(request, runtime);
2829
3280
  }
2830
3281
  /**
@@ -2837,13 +3288,13 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2837
3288
  async getContextWithOptions(request, runtime) {
2838
3289
  request.validate();
2839
3290
  const body = {};
2840
- if (!$dara65.isNull(request.allowCreate)) {
3291
+ if (!$dara77.isNull(request.allowCreate)) {
2841
3292
  body["AllowCreate"] = request.allowCreate;
2842
3293
  }
2843
- if (!$dara65.isNull(request.authorization)) {
3294
+ if (!$dara77.isNull(request.authorization)) {
2844
3295
  body["Authorization"] = request.authorization;
2845
3296
  }
2846
- if (!$dara65.isNull(request.name)) {
3297
+ if (!$dara77.isNull(request.name)) {
2847
3298
  body["Name"] = request.name;
2848
3299
  }
2849
3300
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -2860,7 +3311,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2860
3311
  reqBodyType: "formData",
2861
3312
  bodyType: "json"
2862
3313
  });
2863
- return $dara65.cast(
3314
+ return $dara77.cast(
2864
3315
  await this.callApi(params, req, runtime),
2865
3316
  new GetContextResponse({})
2866
3317
  );
@@ -2872,7 +3323,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2872
3323
  * @returns GetContextResponse
2873
3324
  */
2874
3325
  async getContext(request) {
2875
- const runtime = new $dara65.RuntimeOptions({});
3326
+ const runtime = new $dara77.RuntimeOptions({});
2876
3327
  return await this.getContextWithOptions(request, runtime);
2877
3328
  }
2878
3329
  /**
@@ -2885,19 +3336,19 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2885
3336
  async getContextInfoWithOptions(request, runtime) {
2886
3337
  request.validate();
2887
3338
  const body = {};
2888
- if (!$dara65.isNull(request.authorization)) {
3339
+ if (!$dara77.isNull(request.authorization)) {
2889
3340
  body["Authorization"] = request.authorization;
2890
3341
  }
2891
- if (!$dara65.isNull(request.contextId)) {
3342
+ if (!$dara77.isNull(request.contextId)) {
2892
3343
  body["ContextId"] = request.contextId;
2893
3344
  }
2894
- if (!$dara65.isNull(request.path)) {
3345
+ if (!$dara77.isNull(request.path)) {
2895
3346
  body["Path"] = request.path;
2896
3347
  }
2897
- if (!$dara65.isNull(request.sessionId)) {
3348
+ if (!$dara77.isNull(request.sessionId)) {
2898
3349
  body["SessionId"] = request.sessionId;
2899
3350
  }
2900
- if (!$dara65.isNull(request.taskType)) {
3351
+ if (!$dara77.isNull(request.taskType)) {
2901
3352
  body["TaskType"] = request.taskType;
2902
3353
  }
2903
3354
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -2914,7 +3365,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2914
3365
  reqBodyType: "formData",
2915
3366
  bodyType: "json"
2916
3367
  });
2917
- return $dara65.cast(
3368
+ return $dara77.cast(
2918
3369
  await this.callApi(params, req, runtime),
2919
3370
  new GetContextInfoResponse({})
2920
3371
  );
@@ -2926,7 +3377,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2926
3377
  * @returns GetContextInfoResponse
2927
3378
  */
2928
3379
  async getContextInfo(request) {
2929
- const runtime = new $dara65.RuntimeOptions({});
3380
+ const runtime = new $dara77.RuntimeOptions({});
2930
3381
  return await this.getContextInfoWithOptions(request, runtime);
2931
3382
  }
2932
3383
  /**
@@ -2939,16 +3390,16 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2939
3390
  async getLabelWithOptions(request, runtime) {
2940
3391
  request.validate();
2941
3392
  const body = {};
2942
- if (!$dara65.isNull(request.authorization)) {
3393
+ if (!$dara77.isNull(request.authorization)) {
2943
3394
  body["Authorization"] = request.authorization;
2944
3395
  }
2945
- if (!$dara65.isNull(request.maxResults)) {
3396
+ if (!$dara77.isNull(request.maxResults)) {
2946
3397
  body["MaxResults"] = request.maxResults;
2947
3398
  }
2948
- if (!$dara65.isNull(request.nextToken)) {
3399
+ if (!$dara77.isNull(request.nextToken)) {
2949
3400
  body["NextToken"] = request.nextToken;
2950
3401
  }
2951
- if (!$dara65.isNull(request.sessionId)) {
3402
+ if (!$dara77.isNull(request.sessionId)) {
2952
3403
  body["SessionId"] = request.sessionId;
2953
3404
  }
2954
3405
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -2965,7 +3416,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2965
3416
  reqBodyType: "formData",
2966
3417
  bodyType: "json"
2967
3418
  });
2968
- return $dara65.cast(
3419
+ return $dara77.cast(
2969
3420
  await this.callApi(params, req, runtime),
2970
3421
  new GetLabelResponse({})
2971
3422
  );
@@ -2977,7 +3428,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2977
3428
  * @returns GetLabelResponse
2978
3429
  */
2979
3430
  async getLabel(request) {
2980
- const runtime = new $dara65.RuntimeOptions({});
3431
+ const runtime = new $dara77.RuntimeOptions({});
2981
3432
  return await this.getLabelWithOptions(request, runtime);
2982
3433
  }
2983
3434
  /**
@@ -2990,16 +3441,16 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
2990
3441
  async getLinkWithOptions(request, runtime) {
2991
3442
  request.validate();
2992
3443
  const body = {};
2993
- if (!$dara65.isNull(request.authorization)) {
3444
+ if (!$dara77.isNull(request.authorization)) {
2994
3445
  body["Authorization"] = request.authorization;
2995
3446
  }
2996
- if (!$dara65.isNull(request.port)) {
3447
+ if (!$dara77.isNull(request.port)) {
2997
3448
  body["Port"] = request.port;
2998
3449
  }
2999
- if (!$dara65.isNull(request.protocolType)) {
3450
+ if (!$dara77.isNull(request.protocolType)) {
3000
3451
  body["ProtocolType"] = request.protocolType;
3001
3452
  }
3002
- if (!$dara65.isNull(request.sessionId)) {
3453
+ if (!$dara77.isNull(request.sessionId)) {
3003
3454
  body["SessionId"] = request.sessionId;
3004
3455
  }
3005
3456
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -3016,7 +3467,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3016
3467
  reqBodyType: "formData",
3017
3468
  bodyType: "json"
3018
3469
  });
3019
- return $dara65.cast(
3470
+ return $dara77.cast(
3020
3471
  await this.callApi(params, req, runtime),
3021
3472
  new GetLinkResponse({})
3022
3473
  );
@@ -3028,7 +3479,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3028
3479
  * @returns GetLinkResponse
3029
3480
  */
3030
3481
  async getLink(request) {
3031
- const runtime = new $dara65.RuntimeOptions({});
3482
+ const runtime = new $dara77.RuntimeOptions({});
3032
3483
  return await this.getLinkWithOptions(request, runtime);
3033
3484
  }
3034
3485
  /**
@@ -3041,10 +3492,10 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3041
3492
  async getMcpResourceWithOptions(request, runtime) {
3042
3493
  request.validate();
3043
3494
  const body = {};
3044
- if (!$dara65.isNull(request.authorization)) {
3495
+ if (!$dara77.isNull(request.authorization)) {
3045
3496
  body["Authorization"] = request.authorization;
3046
3497
  }
3047
- if (!$dara65.isNull(request.sessionId)) {
3498
+ if (!$dara77.isNull(request.sessionId)) {
3048
3499
  body["SessionId"] = request.sessionId;
3049
3500
  }
3050
3501
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -3061,7 +3512,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3061
3512
  reqBodyType: "formData",
3062
3513
  bodyType: "json"
3063
3514
  });
3064
- return $dara65.cast(
3515
+ return $dara77.cast(
3065
3516
  await this.callApi(params, req, runtime),
3066
3517
  new GetMcpResourceResponse({})
3067
3518
  );
@@ -3073,7 +3524,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3073
3524
  * @returns GetMcpResourceResponse
3074
3525
  */
3075
3526
  async getMcpResource(request) {
3076
- const runtime = new $dara65.RuntimeOptions({});
3527
+ const runtime = new $dara77.RuntimeOptions({});
3077
3528
  return await this.getMcpResourceWithOptions(request, runtime);
3078
3529
  }
3079
3530
  /**
@@ -3086,13 +3537,13 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3086
3537
  async listContextsWithOptions(request, runtime) {
3087
3538
  request.validate();
3088
3539
  const body = {};
3089
- if (!$dara65.isNull(request.authorization)) {
3540
+ if (!$dara77.isNull(request.authorization)) {
3090
3541
  body["Authorization"] = request.authorization;
3091
3542
  }
3092
- if (!$dara65.isNull(request.maxResults)) {
3543
+ if (!$dara77.isNull(request.maxResults)) {
3093
3544
  body["MaxResults"] = request.maxResults;
3094
3545
  }
3095
- if (!$dara65.isNull(request.nextToken)) {
3546
+ if (!$dara77.isNull(request.nextToken)) {
3096
3547
  body["NextToken"] = request.nextToken;
3097
3548
  }
3098
3549
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -3109,7 +3560,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3109
3560
  reqBodyType: "formData",
3110
3561
  bodyType: "json"
3111
3562
  });
3112
- return $dara65.cast(
3563
+ return $dara77.cast(
3113
3564
  await this.callApi(params, req, runtime),
3114
3565
  new ListContextsResponse({})
3115
3566
  );
@@ -3121,7 +3572,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3121
3572
  * @returns ListContextsResponse
3122
3573
  */
3123
3574
  async listContexts(request) {
3124
- const runtime = new $dara65.RuntimeOptions({});
3575
+ const runtime = new $dara77.RuntimeOptions({});
3125
3576
  return await this.listContextsWithOptions(request, runtime);
3126
3577
  }
3127
3578
  /**
@@ -3134,10 +3585,10 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3134
3585
  async listMcpToolsWithOptions(request, runtime) {
3135
3586
  request.validate();
3136
3587
  const body = {};
3137
- if (!$dara65.isNull(request.authorization)) {
3588
+ if (!$dara77.isNull(request.authorization)) {
3138
3589
  body["Authorization"] = request.authorization;
3139
3590
  }
3140
- if (!$dara65.isNull(request.imageId)) {
3591
+ if (!$dara77.isNull(request.imageId)) {
3141
3592
  body["ImageId"] = request.imageId;
3142
3593
  }
3143
3594
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -3154,7 +3605,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3154
3605
  reqBodyType: "formData",
3155
3606
  bodyType: "json"
3156
3607
  });
3157
- return $dara65.cast(
3608
+ return $dara77.cast(
3158
3609
  await this.callApi(params, req, runtime),
3159
3610
  new ListMcpToolsResponse({})
3160
3611
  );
@@ -3166,7 +3617,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3166
3617
  * @returns ListMcpToolsResponse
3167
3618
  */
3168
3619
  async listMcpTools(request) {
3169
- const runtime = new $dara65.RuntimeOptions({});
3620
+ const runtime = new $dara77.RuntimeOptions({});
3170
3621
  return await this.listMcpToolsWithOptions(request, runtime);
3171
3622
  }
3172
3623
  /**
@@ -3179,16 +3630,16 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3179
3630
  async listSessionWithOptions(request, runtime) {
3180
3631
  request.validate();
3181
3632
  const body = {};
3182
- if (!$dara65.isNull(request.authorization)) {
3633
+ if (!$dara77.isNull(request.authorization)) {
3183
3634
  body["Authorization"] = request.authorization;
3184
3635
  }
3185
- if (!$dara65.isNull(request.labels)) {
3636
+ if (!$dara77.isNull(request.labels)) {
3186
3637
  body["Labels"] = request.labels;
3187
3638
  }
3188
- if (!$dara65.isNull(request.maxResults)) {
3639
+ if (!$dara77.isNull(request.maxResults)) {
3189
3640
  body["MaxResults"] = request.maxResults;
3190
3641
  }
3191
- if (!$dara65.isNull(request.nextToken)) {
3642
+ if (!$dara77.isNull(request.nextToken)) {
3192
3643
  body["NextToken"] = request.nextToken;
3193
3644
  }
3194
3645
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -3205,7 +3656,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3205
3656
  reqBodyType: "formData",
3206
3657
  bodyType: "json"
3207
3658
  });
3208
- return $dara65.cast(
3659
+ return $dara77.cast(
3209
3660
  await this.callApi(params, req, runtime),
3210
3661
  new ListSessionResponse({})
3211
3662
  );
@@ -3217,7 +3668,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3217
3668
  * @returns ListSessionResponse
3218
3669
  */
3219
3670
  async listSession(request) {
3220
- const runtime = new $dara65.RuntimeOptions({});
3671
+ const runtime = new $dara77.RuntimeOptions({});
3221
3672
  return await this.listSessionWithOptions(request, runtime);
3222
3673
  }
3223
3674
  /**
@@ -3230,13 +3681,13 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3230
3681
  async modifyContextWithOptions(request, runtime) {
3231
3682
  request.validate();
3232
3683
  const body = {};
3233
- if (!$dara65.isNull(request.authorization)) {
3684
+ if (!$dara77.isNull(request.authorization)) {
3234
3685
  body["Authorization"] = request.authorization;
3235
3686
  }
3236
- if (!$dara65.isNull(request.id)) {
3687
+ if (!$dara77.isNull(request.id)) {
3237
3688
  body["Id"] = request.id;
3238
3689
  }
3239
- if (!$dara65.isNull(request.name)) {
3690
+ if (!$dara77.isNull(request.name)) {
3240
3691
  body["Name"] = request.name;
3241
3692
  }
3242
3693
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -3253,7 +3704,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3253
3704
  reqBodyType: "formData",
3254
3705
  bodyType: "json"
3255
3706
  });
3256
- return $dara65.cast(
3707
+ return $dara77.cast(
3257
3708
  await this.callApi(params, req, runtime),
3258
3709
  new ModifyContextResponse({})
3259
3710
  );
@@ -3265,7 +3716,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3265
3716
  * @returns ModifyContextResponse
3266
3717
  */
3267
3718
  async modifyContext(request) {
3268
- const runtime = new $dara65.RuntimeOptions({});
3719
+ const runtime = new $dara77.RuntimeOptions({});
3269
3720
  return await this.modifyContextWithOptions(request, runtime);
3270
3721
  }
3271
3722
  /**
@@ -3278,10 +3729,10 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3278
3729
  async releaseMcpSessionWithOptions(request, runtime) {
3279
3730
  request.validate();
3280
3731
  const body = {};
3281
- if (!$dara65.isNull(request.authorization)) {
3732
+ if (!$dara77.isNull(request.authorization)) {
3282
3733
  body["Authorization"] = request.authorization;
3283
3734
  }
3284
- if (!$dara65.isNull(request.sessionId)) {
3735
+ if (!$dara77.isNull(request.sessionId)) {
3285
3736
  body["SessionId"] = request.sessionId;
3286
3737
  }
3287
3738
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -3298,7 +3749,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3298
3749
  reqBodyType: "formData",
3299
3750
  bodyType: "json"
3300
3751
  });
3301
- return $dara65.cast(
3752
+ return $dara77.cast(
3302
3753
  await this.callApi(params, req, runtime),
3303
3754
  new ReleaseMcpSessionResponse({})
3304
3755
  );
@@ -3310,7 +3761,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3310
3761
  * @returns ReleaseMcpSessionResponse
3311
3762
  */
3312
3763
  async releaseMcpSession(request) {
3313
- const runtime = new $dara65.RuntimeOptions({});
3764
+ const runtime = new $dara77.RuntimeOptions({});
3314
3765
  return await this.releaseMcpSessionWithOptions(request, runtime);
3315
3766
  }
3316
3767
  /**
@@ -3323,13 +3774,13 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3323
3774
  async setLabelWithOptions(request, runtime) {
3324
3775
  request.validate();
3325
3776
  const body = {};
3326
- if (!$dara65.isNull(request.authorization)) {
3777
+ if (!$dara77.isNull(request.authorization)) {
3327
3778
  body["Authorization"] = request.authorization;
3328
3779
  }
3329
- if (!$dara65.isNull(request.labels)) {
3780
+ if (!$dara77.isNull(request.labels)) {
3330
3781
  body["Labels"] = request.labels;
3331
3782
  }
3332
- if (!$dara65.isNull(request.sessionId)) {
3783
+ if (!$dara77.isNull(request.sessionId)) {
3333
3784
  body["SessionId"] = request.sessionId;
3334
3785
  }
3335
3786
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -3346,7 +3797,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3346
3797
  reqBodyType: "formData",
3347
3798
  bodyType: "json"
3348
3799
  });
3349
- return $dara65.cast(
3800
+ return $dara77.cast(
3350
3801
  await this.callApi(params, req, runtime),
3351
3802
  new SetLabelResponse({})
3352
3803
  );
@@ -3358,7 +3809,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3358
3809
  * @returns SetLabelResponse
3359
3810
  */
3360
3811
  async setLabel(request) {
3361
- const runtime = new $dara65.RuntimeOptions({});
3812
+ const runtime = new $dara77.RuntimeOptions({});
3362
3813
  return await this.setLabelWithOptions(request, runtime);
3363
3814
  }
3364
3815
  /**
@@ -3371,20 +3822,20 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3371
3822
  async syncContextWithOptions(request, runtime) {
3372
3823
  request.validate();
3373
3824
  const query = {};
3374
- if (!$dara65.isNull(request.authorization)) {
3825
+ if (!$dara77.isNull(request.authorization)) {
3375
3826
  query["Authorization"] = request.authorization;
3376
3827
  }
3377
3828
  const body = {};
3378
- if (!$dara65.isNull(request.contextId)) {
3829
+ if (!$dara77.isNull(request.contextId)) {
3379
3830
  body["ContextId"] = request.contextId;
3380
3831
  }
3381
- if (!$dara65.isNull(request.mode)) {
3832
+ if (!$dara77.isNull(request.mode)) {
3382
3833
  body["Mode"] = request.mode;
3383
3834
  }
3384
- if (!$dara65.isNull(request.path)) {
3835
+ if (!$dara77.isNull(request.path)) {
3385
3836
  body["Path"] = request.path;
3386
3837
  }
3387
- if (!$dara65.isNull(request.sessionId)) {
3838
+ if (!$dara77.isNull(request.sessionId)) {
3388
3839
  body["SessionId"] = request.sessionId;
3389
3840
  }
3390
3841
  const req = new $OpenApiUtil.OpenApiRequest({
@@ -3402,7 +3853,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3402
3853
  reqBodyType: "formData",
3403
3854
  bodyType: "json"
3404
3855
  });
3405
- return $dara65.cast(
3856
+ return $dara77.cast(
3406
3857
  await this.callApi(params, req, runtime),
3407
3858
  new SyncContextResponse({})
3408
3859
  );
@@ -3414,7 +3865,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3414
3865
  * @returns SyncContextResponse
3415
3866
  */
3416
3867
  async syncContext(request) {
3417
- const runtime = new $dara65.RuntimeOptions({});
3868
+ const runtime = new $dara77.RuntimeOptions({});
3418
3869
  return await this.syncContextWithOptions(request, runtime);
3419
3870
  }
3420
3871
  /**
@@ -3427,15 +3878,18 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3427
3878
  async initBrowserWithOptions(request, runtime) {
3428
3879
  request.validate();
3429
3880
  const body = {};
3430
- if (!$dara65.isNull(request.authorization)) {
3881
+ if (!$dara77.isNull(request.authorization)) {
3431
3882
  body["Authorization"] = request.authorization;
3432
3883
  }
3433
- if (!$dara65.isNull(request.persistentPath)) {
3884
+ if (!$dara77.isNull(request.persistentPath)) {
3434
3885
  body["PersistentPath"] = request.persistentPath;
3435
3886
  }
3436
- if (!$dara65.isNull(request.sessionId)) {
3887
+ if (!$dara77.isNull(request.sessionId)) {
3437
3888
  body["SessionId"] = request.sessionId;
3438
3889
  }
3890
+ if (!$dara77.isNull(request.browserOption)) {
3891
+ body["BrowserOption"] = JSON.stringify(request.browserOption);
3892
+ }
3439
3893
  const req = new $OpenApiUtil.OpenApiRequest({
3440
3894
  body: OpenApiUtil.parseToMap(body)
3441
3895
  });
@@ -3450,7 +3904,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3450
3904
  reqBodyType: "formData",
3451
3905
  bodyType: "json"
3452
3906
  });
3453
- return $dara65.cast(
3907
+ return $dara77.cast(
3454
3908
  await this.callApi(params, req, runtime),
3455
3909
  new InitBrowserResponse({})
3456
3910
  );
@@ -3462,7 +3916,7 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3462
3916
  * @returns InitBrowserResponse
3463
3917
  */
3464
3918
  async initBrowser(request) {
3465
- const runtime = new $dara65.RuntimeOptions({});
3919
+ const runtime = new $dara77.RuntimeOptions({});
3466
3920
  return await this.initBrowserWithOptions(request, runtime);
3467
3921
  }
3468
3922
  /**
@@ -3472,18 +3926,21 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3472
3926
  * @returns InitBrowserResponse
3473
3927
  */
3474
3928
  initBrowserSync(request) {
3475
- const runtime = new $dara65.RuntimeOptions({});
3929
+ const runtime = new $dara77.RuntimeOptions({});
3476
3930
  request.validate();
3477
3931
  const body = {};
3478
- if (!$dara65.isNull(request.authorization)) {
3932
+ if (!$dara77.isNull(request.authorization)) {
3479
3933
  body["Authorization"] = request.authorization;
3480
3934
  }
3481
- if (!$dara65.isNull(request.persistentPath)) {
3935
+ if (!$dara77.isNull(request.persistentPath)) {
3482
3936
  body["PersistentPath"] = request.persistentPath;
3483
3937
  }
3484
- if (!$dara65.isNull(request.sessionId)) {
3938
+ if (!$dara77.isNull(request.sessionId)) {
3485
3939
  body["SessionId"] = request.sessionId;
3486
3940
  }
3941
+ if (!$dara77.isNull(request.browserOption)) {
3942
+ body["BrowserOption"] = JSON.stringify(request.browserOption);
3943
+ }
3487
3944
  const req = new $OpenApiUtil.OpenApiRequest({
3488
3945
  body: OpenApiUtil.parseToMap(body)
3489
3946
  });
@@ -3498,11 +3955,209 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
3498
3955
  reqBodyType: "formData",
3499
3956
  bodyType: "json"
3500
3957
  });
3501
- return $dara65.cast(
3958
+ return $dara77.cast(
3502
3959
  this.callApi(params, req, runtime),
3503
3960
  new InitBrowserResponse({})
3504
3961
  );
3505
3962
  }
3963
+ /**
3964
+ * 获取上传context文件url
3965
+ *
3966
+ * @param request - DeleteContextFileRequest
3967
+ * @param runtime - runtime options for this request RuntimeOptions
3968
+ * @returns DeleteContextFileResponse
3969
+ */
3970
+ async deleteContextFileWithOptions(request, runtime) {
3971
+ request.validate();
3972
+ const body = {};
3973
+ if (!$dara77.isNull(request.authorization)) {
3974
+ body["Authorization"] = request.authorization;
3975
+ }
3976
+ if (!$dara77.isNull(request.contextId)) {
3977
+ body["ContextId"] = request.contextId;
3978
+ }
3979
+ if (!$dara77.isNull(request.filePath)) {
3980
+ body["FilePath"] = request.filePath;
3981
+ }
3982
+ const req = new $OpenApiUtil.OpenApiRequest({
3983
+ body: OpenApiUtil.parseToMap(body)
3984
+ });
3985
+ const params = new $OpenApiUtil.Params({
3986
+ action: "DeleteContextFile",
3987
+ version: "2025-05-06",
3988
+ protocol: "HTTPS",
3989
+ pathname: "/",
3990
+ method: "POST",
3991
+ authType: "Anonymous",
3992
+ style: "RPC",
3993
+ reqBodyType: "formData",
3994
+ bodyType: "json"
3995
+ });
3996
+ return $dara77.cast(
3997
+ await this.callApi(params, req, runtime),
3998
+ new DeleteContextFileResponse({})
3999
+ );
4000
+ }
4001
+ /**
4002
+ * 获取上传context文件url
4003
+ *
4004
+ * @param request - DeleteContextFileRequest
4005
+ * @returns DeleteContextFileResponse
4006
+ */
4007
+ async deleteContextFile(request) {
4008
+ const runtime = new $dara77.RuntimeOptions({});
4009
+ return await this.deleteContextFileWithOptions(request, runtime);
4010
+ }
4011
+ /**
4012
+ * 查询context特定目录文件
4013
+ *
4014
+ * @param request - DescribeContextFilesRequest
4015
+ * @param runtime - runtime options for this request RuntimeOptions
4016
+ * @returns DescribeContextFilesResponse
4017
+ */
4018
+ async describeContextFilesWithOptions(request, runtime) {
4019
+ request.validate();
4020
+ const body = {};
4021
+ if (!$dara77.isNull(request.authorization)) {
4022
+ body["Authorization"] = request.authorization;
4023
+ }
4024
+ if (!$dara77.isNull(request.pageNumber)) {
4025
+ body["PageNumber"] = request.pageNumber;
4026
+ }
4027
+ if (!$dara77.isNull(request.pageSize)) {
4028
+ body["PageSize"] = request.pageSize;
4029
+ }
4030
+ if (!$dara77.isNull(request.parentFolderPath)) {
4031
+ body["ParentFolderPath"] = request.parentFolderPath;
4032
+ }
4033
+ if (!$dara77.isNull(request.contextId)) {
4034
+ body["ContextId"] = request.contextId;
4035
+ }
4036
+ const req = new $OpenApiUtil.OpenApiRequest({
4037
+ body: OpenApiUtil.parseToMap(body)
4038
+ });
4039
+ const params = new $OpenApiUtil.Params({
4040
+ action: "DescribeContextFiles",
4041
+ version: "2025-05-06",
4042
+ protocol: "HTTPS",
4043
+ pathname: "/",
4044
+ method: "POST",
4045
+ authType: "Anonymous",
4046
+ style: "RPC",
4047
+ reqBodyType: "formData",
4048
+ bodyType: "json"
4049
+ });
4050
+ return $dara77.cast(
4051
+ await this.callApi(params, req, runtime),
4052
+ new DescribeContextFilesResponse({})
4053
+ );
4054
+ }
4055
+ /**
4056
+ * 查询context特定目录文件
4057
+ *
4058
+ * @param request - DescribeContextFilesRequest
4059
+ * @returns DescribeContextFilesResponse
4060
+ */
4061
+ async describeContextFiles(request) {
4062
+ const runtime = new $dara77.RuntimeOptions({});
4063
+ return await this.describeContextFilesWithOptions(request, runtime);
4064
+ }
4065
+ /**
4066
+ * 获取上传context文件url
4067
+ *
4068
+ * @param request - GetContextFileDownloadUrlRequest
4069
+ * @param runtime - runtime options for this request RuntimeOptions
4070
+ * @returns GetContextFileDownloadUrlResponse
4071
+ */
4072
+ async getContextFileDownloadUrlWithOptions(request, runtime) {
4073
+ request.validate();
4074
+ const body = {};
4075
+ if (!$dara77.isNull(request.authorization)) {
4076
+ body["Authorization"] = request.authorization;
4077
+ }
4078
+ if (!$dara77.isNull(request.contextId)) {
4079
+ body["ContextId"] = request.contextId;
4080
+ }
4081
+ if (!$dara77.isNull(request.filePath)) {
4082
+ body["FilePath"] = request.filePath;
4083
+ }
4084
+ const req = new $OpenApiUtil.OpenApiRequest({
4085
+ body: OpenApiUtil.parseToMap(body)
4086
+ });
4087
+ const params = new $OpenApiUtil.Params({
4088
+ action: "GetContextFileDownloadUrl",
4089
+ version: "2025-05-06",
4090
+ protocol: "HTTPS",
4091
+ pathname: "/",
4092
+ method: "POST",
4093
+ authType: "Anonymous",
4094
+ style: "RPC",
4095
+ reqBodyType: "formData",
4096
+ bodyType: "json"
4097
+ });
4098
+ return $dara77.cast(
4099
+ await this.callApi(params, req, runtime),
4100
+ new GetContextFileDownloadUrlResponse({})
4101
+ );
4102
+ }
4103
+ /**
4104
+ * 获取上传context文件url
4105
+ *
4106
+ * @param request - GetContextFileDownloadUrlRequest
4107
+ * @returns GetContextFileDownloadUrlResponse
4108
+ */
4109
+ async getContextFileDownloadUrl(request) {
4110
+ const runtime = new $dara77.RuntimeOptions({});
4111
+ return await this.getContextFileDownloadUrlWithOptions(request, runtime);
4112
+ }
4113
+ /**
4114
+ * 获取上传context文件url
4115
+ *
4116
+ * @param request - GetContextFileUploadUrlRequest
4117
+ * @param runtime - runtime options for this request RuntimeOptions
4118
+ * @returns GetContextFileUploadUrlResponse
4119
+ */
4120
+ async getContextFileUploadUrlWithOptions(request, runtime) {
4121
+ request.validate();
4122
+ const body = {};
4123
+ if (!$dara77.isNull(request.authorization)) {
4124
+ body["Authorization"] = request.authorization;
4125
+ }
4126
+ if (!$dara77.isNull(request.contextId)) {
4127
+ body["ContextId"] = request.contextId;
4128
+ }
4129
+ if (!$dara77.isNull(request.filePath)) {
4130
+ body["FilePath"] = request.filePath;
4131
+ }
4132
+ const req = new $OpenApiUtil.OpenApiRequest({
4133
+ body: OpenApiUtil.parseToMap(body)
4134
+ });
4135
+ const params = new $OpenApiUtil.Params({
4136
+ action: "GetContextFileUploadUrl",
4137
+ version: "2025-05-06",
4138
+ protocol: "HTTPS",
4139
+ pathname: "/",
4140
+ method: "POST",
4141
+ authType: "Anonymous",
4142
+ style: "RPC",
4143
+ reqBodyType: "formData",
4144
+ bodyType: "json"
4145
+ });
4146
+ return $dara77.cast(
4147
+ await this.callApi(params, req, runtime),
4148
+ new GetContextFileUploadUrlResponse({})
4149
+ );
4150
+ }
4151
+ /**
4152
+ * 获取上传context文件url
4153
+ *
4154
+ * @param request - GetContextFileUploadUrlRequest
4155
+ * @returns GetContextFileUploadUrlResponse
4156
+ */
4157
+ async getContextFileUploadUrl(request) {
4158
+ const runtime = new $dara77.RuntimeOptions({});
4159
+ return await this.getContextFileUploadUrlWithOptions(request, runtime);
4160
+ }
3506
4161
  };
3507
4162
  __name(_Client, "Client");
3508
4163
  var Client = _Client;
@@ -3554,6 +4209,28 @@ function defaultConfig() {
3554
4209
  };
3555
4210
  }
3556
4211
  __name(defaultConfig, "defaultConfig");
4212
+ var dotEnvLoaded = false;
4213
+ function loadDotEnv() {
4214
+ if (dotEnvLoaded) {
4215
+ return;
4216
+ }
4217
+ try {
4218
+ const envPath = path2.resolve(process.cwd(), ".env");
4219
+ if (fs.existsSync(envPath)) {
4220
+ const envConfig = dotenv.parse(fs.readFileSync(envPath));
4221
+ for (const k in envConfig) {
4222
+ if (!process.env.hasOwnProperty(k)) {
4223
+ process.env[k] = envConfig[k];
4224
+ }
4225
+ }
4226
+ log(`Loaded .env file at: ${envPath}`);
4227
+ dotEnvLoaded = true;
4228
+ }
4229
+ } catch (error) {
4230
+ log(`Warning: Failed to load .env file: ${error}`);
4231
+ }
4232
+ }
4233
+ __name(loadDotEnv, "loadDotEnv");
3557
4234
  function loadConfig(customConfig) {
3558
4235
  if (customConfig) {
3559
4236
  return customConfig;
@@ -3574,16 +4251,16 @@ function loadConfig(customConfig) {
3574
4251
  const envPath = path2.resolve(process.cwd(), ".env");
3575
4252
  if (fs.existsSync(envPath)) {
3576
4253
  const envConfig = dotenv.parse(fs.readFileSync(envPath));
3577
- for (const k in envConfig) {
3578
- if (!process.env.hasOwnProperty(k)) {
3579
- if (k === "AGENTBAY_REGION_ID") config.region_id = envConfig[k];
3580
- else if (k === "AGENTBAY_ENDPOINT") config.endpoint = envConfig[k];
3581
- else if (k === "AGENTBAY_TIMEOUT_MS") {
3582
- const timeout = parseInt(envConfig[k], 10);
3583
- if (!isNaN(timeout) && timeout > 0) {
3584
- config.timeout_ms = timeout;
3585
- }
3586
- }
4254
+ if (!process.env.AGENTBAY_REGION_ID && envConfig.AGENTBAY_REGION_ID) {
4255
+ config.region_id = envConfig.AGENTBAY_REGION_ID;
4256
+ }
4257
+ if (!process.env.AGENTBAY_ENDPOINT && envConfig.AGENTBAY_ENDPOINT) {
4258
+ config.endpoint = envConfig.AGENTBAY_ENDPOINT;
4259
+ }
4260
+ if (!process.env.AGENTBAY_TIMEOUT_MS && envConfig.AGENTBAY_TIMEOUT_MS) {
4261
+ const timeout = parseInt(envConfig.AGENTBAY_TIMEOUT_MS, 10);
4262
+ if (!isNaN(timeout) && timeout > 0) {
4263
+ config.timeout_ms = timeout;
3587
4264
  }
3588
4265
  }
3589
4266
  log(`Loaded .env file at: ${envPath}`);
@@ -3830,6 +4507,112 @@ var _ContextService = class _ContextService {
3830
4507
  };
3831
4508
  }
3832
4509
  }
4510
+ /**
4511
+ * Get a presigned upload URL for a file in a context.
4512
+ */
4513
+ async getFileUploadUrl(contextId, filePath) {
4514
+ log("API Call: GetContextFileUploadUrl");
4515
+ log(`Request: ContextId=${contextId}, FilePath=${filePath}`);
4516
+ const req = new GetContextFileUploadUrlRequest({
4517
+ authorization: `Bearer ${this.agentBay.getAPIKey()}`,
4518
+ contextId,
4519
+ filePath
4520
+ });
4521
+ const resp = await this.agentBay.getClient().getContextFileUploadUrl(req);
4522
+ log("Response from GetContextFileUploadUrl:", resp.body);
4523
+ const requestId = extractRequestId(resp) || "";
4524
+ const body = resp.body;
4525
+ const data = body?.data;
4526
+ return {
4527
+ requestId,
4528
+ success: !!(body && body.success),
4529
+ url: data?.url || "",
4530
+ expireTime: data?.expireTime
4531
+ };
4532
+ }
4533
+ /**
4534
+ * Get a presigned download URL for a file in a context.
4535
+ */
4536
+ async getFileDownloadUrl(contextId, filePath) {
4537
+ log("API Call: GetContextFileDownloadUrl");
4538
+ log(`Request: ContextId=${contextId}, FilePath=${filePath}`);
4539
+ const req = new GetContextFileDownloadUrlRequest({
4540
+ authorization: `Bearer ${this.agentBay.getAPIKey()}`,
4541
+ contextId,
4542
+ filePath
4543
+ });
4544
+ const resp = await this.agentBay.getClient().getContextFileDownloadUrl(req);
4545
+ log("Response from GetContextFileDownloadUrl:", resp.body);
4546
+ const requestId = extractRequestId(resp) || "";
4547
+ const body = resp.body;
4548
+ const data = body?.data;
4549
+ return {
4550
+ requestId,
4551
+ success: !!(body && body.success),
4552
+ url: data?.url || "",
4553
+ expireTime: data?.expireTime
4554
+ };
4555
+ }
4556
+ /**
4557
+ * Delete a file in a context.
4558
+ */
4559
+ async deleteFile(contextId, filePath) {
4560
+ log("API Call: DeleteContextFile");
4561
+ log(`Request: ContextId=${contextId}, FilePath=${filePath}`);
4562
+ const req = new DeleteContextFileRequest({
4563
+ authorization: `Bearer ${this.agentBay.getAPIKey()}`,
4564
+ contextId,
4565
+ filePath
4566
+ });
4567
+ const resp = await this.agentBay.getClient().deleteContextFile(req);
4568
+ log("Response from DeleteContextFile:", resp.body);
4569
+ const requestId = extractRequestId(resp) || "";
4570
+ const body = resp.body;
4571
+ const success = !!(body && body.success);
4572
+ return {
4573
+ requestId,
4574
+ success,
4575
+ data: success,
4576
+ errorMessage: success ? "" : `Delete failed: ${body?.code || ""}`
4577
+ };
4578
+ }
4579
+ /**
4580
+ * List files under a specific folder path in a context.
4581
+ */
4582
+ async listFiles(contextId, parentFolderPath, pageNumber = 1, pageSize = 50) {
4583
+ log("API Call: DescribeContextFiles");
4584
+ log(
4585
+ `Request: ContextId=${contextId}, ParentFolderPath=${parentFolderPath}, PageNumber=${pageNumber}, PageSize=${pageSize}`
4586
+ );
4587
+ const req = new DescribeContextFilesRequest({
4588
+ authorization: `Bearer ${this.agentBay.getAPIKey()}`,
4589
+ pageNumber,
4590
+ pageSize,
4591
+ parentFolderPath,
4592
+ contextId
4593
+ });
4594
+ const resp = await this.agentBay.getClient().describeContextFiles(req);
4595
+ log("Response from DescribeContextFiles:", resp.body);
4596
+ const requestId = extractRequestId(resp) || "";
4597
+ const body = resp.body;
4598
+ const rawList = body?.data || [];
4599
+ const entries = rawList.map((it) => ({
4600
+ fileId: it.fileId,
4601
+ fileName: it.fileName,
4602
+ filePath: it.filePath || "",
4603
+ fileType: it.fileType,
4604
+ gmtCreate: it.gmtCreate,
4605
+ gmtModified: it.gmtModified,
4606
+ size: it.size,
4607
+ status: it.status
4608
+ }));
4609
+ return {
4610
+ requestId,
4611
+ success: !!(body && body.success),
4612
+ entries,
4613
+ count: body?.count
4614
+ };
4615
+ }
3833
4616
  };
3834
4617
  __name(_ContextService, "ContextService");
3835
4618
  var ContextService = _ContextService;
@@ -4568,7 +5351,7 @@ var _ContextManager = class _ContextManager {
4568
5351
  async info() {
4569
5352
  return this.infoWithParams();
4570
5353
  }
4571
- async infoWithParams(contextId, path3, taskType) {
5354
+ async infoWithParams(contextId, path4, taskType) {
4572
5355
  const request = new GetContextInfoRequest({
4573
5356
  authorization: `Bearer ${this.session.getAPIKey()}`,
4574
5357
  sessionId: this.session.getSessionId()
@@ -4576,8 +5359,8 @@ var _ContextManager = class _ContextManager {
4576
5359
  if (contextId) {
4577
5360
  request.contextId = contextId;
4578
5361
  }
4579
- if (path3) {
4580
- request.path = path3;
5362
+ if (path4) {
5363
+ request.path = path4;
4581
5364
  }
4582
5365
  if (taskType) {
4583
5366
  request.taskType = taskType;
@@ -4627,7 +5410,7 @@ var _ContextManager = class _ContextManager {
4627
5410
  async sync() {
4628
5411
  return this.syncWithParams();
4629
5412
  }
4630
- async syncWithParams(contextId, path3, mode) {
5413
+ async syncWithParams(contextId, path4, mode) {
4631
5414
  const request = new SyncContextRequest({
4632
5415
  authorization: `Bearer ${this.session.getAPIKey()}`,
4633
5416
  sessionId: this.session.getSessionId()
@@ -4635,8 +5418,8 @@ var _ContextManager = class _ContextManager {
4635
5418
  if (contextId) {
4636
5419
  request.contextId = contextId;
4637
5420
  }
4638
- if (path3) {
4639
- request.path = path3;
5421
+ if (path4) {
5422
+ request.path = path4;
4640
5423
  }
4641
5424
  if (mode) {
4642
5425
  request.mode = mode;
@@ -4766,10 +5549,10 @@ var _FileSystem = class _FileSystem {
4766
5549
  * @param path - Path to the directory to create.
4767
5550
  * @returns BoolResult with creation result and requestId
4768
5551
  */
4769
- async createDirectory(path3) {
5552
+ async createDirectory(path4) {
4770
5553
  try {
4771
5554
  const args = {
4772
- path: path3
5555
+ path: path4
4773
5556
  };
4774
5557
  const result = await this.session.callMcpTool(
4775
5558
  "create_directory",
@@ -4804,10 +5587,10 @@ var _FileSystem = class _FileSystem {
4804
5587
  * @param dryRun - Optional: If true, preview changes without applying them.
4805
5588
  * @returns BoolResult with edit result and requestId
4806
5589
  */
4807
- async editFile(path3, edits, dryRun = false) {
5590
+ async editFile(path4, edits, dryRun = false) {
4808
5591
  try {
4809
5592
  const args = {
4810
- path: path3,
5593
+ path: path4,
4811
5594
  edits,
4812
5595
  dryRun
4813
5596
  };
@@ -4842,10 +5625,10 @@ var _FileSystem = class _FileSystem {
4842
5625
  * @param path - Path to the file or directory to inspect.
4843
5626
  * @returns FileInfoResult with file info and requestId
4844
5627
  */
4845
- async getFileInfo(path3) {
5628
+ async getFileInfo(path4) {
4846
5629
  try {
4847
5630
  const args = {
4848
- path: path3
5631
+ path: path4
4849
5632
  };
4850
5633
  const result = await this.session.callMcpTool(
4851
5634
  "get_file_info",
@@ -4888,10 +5671,10 @@ var _FileSystem = class _FileSystem {
4888
5671
  * @param path - Path to the directory to list.
4889
5672
  * @returns DirectoryListResult with directory entries and requestId
4890
5673
  */
4891
- async listDirectory(path3) {
5674
+ async listDirectory(path4) {
4892
5675
  try {
4893
5676
  const args = {
4894
- path: path3
5677
+ path: path4
4895
5678
  };
4896
5679
  const result = await this.session.callMcpTool(
4897
5680
  "list_directory",
@@ -4959,18 +5742,17 @@ var _FileSystem = class _FileSystem {
4959
5742
  }
4960
5743
  }
4961
5744
  /**
4962
- * Reads the content of a file.
4963
- * Corresponds to Python's read_file() method
5745
+ * Internal method to read a file chunk. Used for chunked file operations.
4964
5746
  *
4965
5747
  * @param path - Path to the file to read.
4966
5748
  * @param offset - Optional: Byte offset to start reading from (0-based).
4967
5749
  * @param length - Optional: Number of bytes to read. If 0, reads the entire file from offset.
4968
5750
  * @returns FileContentResult with file content and requestId
4969
5751
  */
4970
- async readFile(path3, offset = 0, length = 0) {
5752
+ async readFileChunk(path4, offset = 0, length = 0) {
4971
5753
  try {
4972
5754
  const args = {
4973
- path: path3
5755
+ path: path4
4974
5756
  };
4975
5757
  if (offset > 0) {
4976
5758
  args.offset = offset;
@@ -5036,8 +5818,8 @@ var _FileSystem = class _FileSystem {
5036
5818
  for (const line of lines) {
5037
5819
  const colonIndex = line.indexOf(":");
5038
5820
  if (colonIndex > 0 && currentPath === "" && !line.substring(0, colonIndex).includes(" ")) {
5039
- const path3 = line.substring(0, colonIndex).trim();
5040
- currentPath = path3;
5821
+ const path4 = line.substring(0, colonIndex).trim();
5822
+ currentPath = path4;
5041
5823
  if (line.length > colonIndex + 1) {
5042
5824
  const contentStart = line.substring(colonIndex + 1).trim();
5043
5825
  if (contentStart) {
@@ -5057,8 +5839,8 @@ var _FileSystem = class _FileSystem {
5057
5839
  if (currentPath) {
5058
5840
  fileContents[currentPath] = currentContent.join("\n");
5059
5841
  }
5060
- for (const path3 in fileContents) {
5061
- fileContents[path3] = fileContents[path3].replace(/\n+$/, "");
5842
+ for (const path4 in fileContents) {
5843
+ fileContents[path4] = fileContents[path4].replace(/\n+$/, "");
5062
5844
  }
5063
5845
  }
5064
5846
  return {
@@ -5084,10 +5866,10 @@ var _FileSystem = class _FileSystem {
5084
5866
  * @param excludePatterns - Optional: Array of patterns to exclude.
5085
5867
  * @returns FileSearchResult with search results and requestId
5086
5868
  */
5087
- async searchFiles(path3, pattern, excludePatterns = []) {
5869
+ async searchFiles(path4, pattern, excludePatterns = []) {
5088
5870
  try {
5089
5871
  const args = {
5090
- path: path3,
5872
+ path: path4,
5091
5873
  pattern
5092
5874
  };
5093
5875
  if (excludePatterns.length > 0) {
@@ -5124,15 +5906,14 @@ var _FileSystem = class _FileSystem {
5124
5906
  }
5125
5907
  }
5126
5908
  /**
5127
- * Writes content to a file.
5128
- * Corresponds to Python's write_file() method
5909
+ * Internal method to write a file chunk. Used for chunked file operations.
5129
5910
  *
5130
5911
  * @param path - Path to the file to write.
5131
5912
  * @param content - Content to write to the file.
5132
5913
  * @param mode - Optional: Write mode. One of "overwrite", "append", or "create_new". Default is "overwrite".
5133
5914
  * @returns BoolResult with write result and requestId
5134
5915
  */
5135
- async writeFile(path3, content, mode = "overwrite") {
5916
+ async writeFileChunk(path4, content, mode = "overwrite") {
5136
5917
  try {
5137
5918
  const validModes = ["overwrite", "append", "create_new"];
5138
5919
  if (!validModes.includes(mode)) {
@@ -5145,7 +5926,7 @@ var _FileSystem = class _FileSystem {
5145
5926
  };
5146
5927
  }
5147
5928
  const args = {
5148
- path: path3,
5929
+ path: path4,
5149
5930
  content,
5150
5931
  mode
5151
5932
  };
@@ -5174,16 +5955,15 @@ var _FileSystem = class _FileSystem {
5174
5955
  }
5175
5956
  }
5176
5957
  /**
5177
- * Reads a large file in chunks to handle size limitations of the underlying API.
5178
- * Corresponds to Python's read_large_file() method
5958
+ * Reads the contents of a file. Automatically handles large files by chunking.
5179
5959
  *
5180
5960
  * @param path - Path to the file to read.
5181
- * @param chunkSize - Optional: Size of each chunk in bytes. Default is 60KB.
5182
5961
  * @returns FileContentResult with complete file content and requestId
5183
5962
  */
5184
- async readLargeFile(path3, chunkSize = DEFAULT_CHUNK_SIZE) {
5963
+ async readFile(path4) {
5964
+ const chunkSize = DEFAULT_CHUNK_SIZE;
5185
5965
  try {
5186
- const fileInfoResult = await this.getFileInfo(path3);
5966
+ const fileInfoResult = await this.getFileInfo(path4);
5187
5967
  if (!fileInfoResult.success) {
5188
5968
  return {
5189
5969
  requestId: fileInfoResult.requestId,
@@ -5197,7 +5977,7 @@ var _FileSystem = class _FileSystem {
5197
5977
  requestId: fileInfoResult.requestId,
5198
5978
  success: false,
5199
5979
  content: "",
5200
- errorMessage: `Path does not exist or is a directory: ${path3}`
5980
+ errorMessage: `Path does not exist or is a directory: ${path4}`
5201
5981
  };
5202
5982
  }
5203
5983
  const fileSize = fileInfoResult.fileInfo.size || 0;
@@ -5217,7 +5997,7 @@ var _FileSystem = class _FileSystem {
5217
5997
  length = fileSize - offset;
5218
5998
  }
5219
5999
  try {
5220
- const chunkResult = await this.readFile(path3, offset, length);
6000
+ const chunkResult = await this.readFileChunk(path4, offset, length);
5221
6001
  if (!chunkResult.success) {
5222
6002
  return chunkResult;
5223
6003
  }
@@ -5248,25 +6028,25 @@ var _FileSystem = class _FileSystem {
5248
6028
  }
5249
6029
  }
5250
6030
  /**
5251
- * Writes a large file in chunks to handle size limitations of the underlying API.
5252
- * Corresponds to Python's write_large_file() method
6031
+ * Writes content to a file. Automatically handles large files by chunking.
5253
6032
  *
5254
6033
  * @param path - Path to the file to write.
5255
6034
  * @param content - Content to write to the file.
5256
- * @param chunkSize - Optional: Size of each chunk in bytes. Default is 60KB.
6035
+ * @param mode - Optional: Write mode. One of "overwrite", "append", or "create_new". Default is "overwrite".
5257
6036
  * @returns BoolResult indicating success or failure with requestId
5258
6037
  */
5259
- async writeLargeFile(path3, content, chunkSize = DEFAULT_CHUNK_SIZE) {
6038
+ async writeFile(path4, content, mode = "overwrite") {
6039
+ const chunkSize = DEFAULT_CHUNK_SIZE;
5260
6040
  try {
5261
6041
  const contentLen = content.length;
5262
6042
  if (contentLen <= chunkSize) {
5263
- return await this.writeFile(path3, content, "overwrite");
6043
+ return await this.writeFileChunk(path4, content, mode);
5264
6044
  }
5265
6045
  const firstChunkEnd = Math.min(chunkSize, contentLen);
5266
- const firstResult = await this.writeFile(
5267
- path3,
6046
+ const firstResult = await this.writeFileChunk(
6047
+ path4,
5268
6048
  content.substring(0, firstChunkEnd),
5269
- "overwrite"
6049
+ mode
5270
6050
  );
5271
6051
  if (!firstResult.success) {
5272
6052
  return firstResult;
@@ -5274,8 +6054,8 @@ var _FileSystem = class _FileSystem {
5274
6054
  let chunkCount = 1;
5275
6055
  for (let offset = firstChunkEnd; offset < contentLen; ) {
5276
6056
  const end = Math.min(offset + chunkSize, contentLen);
5277
- const chunkResult = await this.writeFile(
5278
- path3,
6057
+ const chunkResult = await this.writeFileChunk(
6058
+ path4,
5279
6059
  content.substring(offset, end),
5280
6060
  "append"
5281
6061
  );
@@ -5395,12 +6175,12 @@ var _Oss = class _Oss {
5395
6175
  * @returns OSSUploadResult with upload result and requestId
5396
6176
  * @throws APIError if the operation fails.
5397
6177
  */
5398
- async upload(bucket, object, path3) {
6178
+ async upload(bucket, object, path4) {
5399
6179
  try {
5400
6180
  const args = {
5401
6181
  bucket,
5402
6182
  object,
5403
- path: path3
6183
+ path: path4
5404
6184
  };
5405
6185
  const result = await this.session.callMcpTool("oss_upload", args);
5406
6186
  return {
@@ -5427,11 +6207,11 @@ var _Oss = class _Oss {
5427
6207
  * @returns OSSUploadResult with upload result and requestId
5428
6208
  * @throws APIError if the operation fails.
5429
6209
  */
5430
- async uploadAnonymous(url, path3) {
6210
+ async uploadAnonymous(url, path4) {
5431
6211
  try {
5432
6212
  const args = {
5433
6213
  url,
5434
- path: path3
6214
+ path: path4
5435
6215
  };
5436
6216
  const result = await this.session.callMcpTool("oss_upload_anonymous", args);
5437
6217
  return {
@@ -5459,12 +6239,12 @@ var _Oss = class _Oss {
5459
6239
  * @returns OSSDownloadResult with download result and requestId
5460
6240
  * @throws APIError if the operation fails.
5461
6241
  */
5462
- async download(bucket, object, path3) {
6242
+ async download(bucket, object, path4) {
5463
6243
  try {
5464
6244
  const args = {
5465
6245
  bucket,
5466
6246
  object,
5467
- path: path3
6247
+ path: path4
5468
6248
  };
5469
6249
  const result = await this.session.callMcpTool("oss_download", args);
5470
6250
  return {
@@ -5491,11 +6271,11 @@ var _Oss = class _Oss {
5491
6271
  * @returns OSSDownloadResult with download result and requestId
5492
6272
  * @throws APIError if the operation fails.
5493
6273
  */
5494
- async downloadAnonymous(url, path3) {
6274
+ async downloadAnonymous(url, path4) {
5495
6275
  try {
5496
6276
  const args = {
5497
6277
  url,
5498
- path: path3
6278
+ path: path4
5499
6279
  };
5500
6280
  const result = await this.session.callMcpTool("oss_download_anonymous", args);
5501
6281
  return {
@@ -6242,7 +7022,7 @@ var _BrowserAgent = class _BrowserAgent {
6242
7022
  throw new BrowserError("Browser must be initialized before calling act.");
6243
7023
  }
6244
7024
  try {
6245
- const [pageIndex, contextIndex] = this._getPageAndContextIndex(page);
7025
+ const [pageIndex, contextIndex] = await this._getPageAndContextIndexAsync(page);
6246
7026
  log(`Acting on page: ${page}, pageIndex: ${pageIndex}, contextIndex: ${contextIndex}`);
6247
7027
  const args = {
6248
7028
  context_id: contextIndex,
@@ -6293,7 +7073,7 @@ var _BrowserAgent = class _BrowserAgent {
6293
7073
  throw new BrowserError("Browser must be initialized before calling observe.");
6294
7074
  }
6295
7075
  try {
6296
- const [pageIndex, contextIndex] = this._getPageAndContextIndex(page);
7076
+ const [pageIndex, contextIndex] = await this._getPageAndContextIndexAsync(page);
6297
7077
  log(`Observing page: ${page}, pageIndex: ${pageIndex}, contextIndex: ${contextIndex}`);
6298
7078
  const args = {
6299
7079
  context_id: contextIndex,
@@ -6356,7 +7136,7 @@ var _BrowserAgent = class _BrowserAgent {
6356
7136
  throw new BrowserError("Browser must be initialized before calling extract.");
6357
7137
  }
6358
7138
  try {
6359
- const [pageIndex, contextIndex] = this._getPageAndContextIndex(page);
7139
+ const [pageIndex, contextIndex] = await this._getPageAndContextIndexAsync(page);
6360
7140
  const tempInstance = new options.schema();
6361
7141
  const schema = tempInstance.constructor.name;
6362
7142
  const args = {
@@ -6432,12 +7212,35 @@ var _BrowserAgent = class _BrowserAgent {
6432
7212
  throw new BrowserError("Page is null");
6433
7213
  }
6434
7214
  try {
6435
- const pageIndex = "default-page-id";
6436
- const contextIndex = 0;
6437
- return [pageIndex, contextIndex];
7215
+ if (page.context && typeof page.context === "function") {
7216
+ const context = page.context();
7217
+ if (context && typeof context.newCDPSession === "function") {
7218
+ const cdpSession = await context.newCDPSession(page);
7219
+ const targetInfo = await cdpSession.send("Target.getTargetInfo");
7220
+ const pageIndex2 = targetInfo && targetInfo.targetInfo && targetInfo.targetInfo.targetId ? targetInfo.targetInfo.targetId : "default-page-id";
7221
+ if (typeof cdpSession.detach === "function") {
7222
+ await cdpSession.detach();
7223
+ }
7224
+ let contextIndex2 = 0;
7225
+ if (typeof context.browser === "function") {
7226
+ const browserObj = context.browser();
7227
+ if (browserObj && typeof browserObj.contexts === "function") {
7228
+ const contexts = browserObj.contexts();
7229
+ const idx = contexts.indexOf(context);
7230
+ if (idx >= 0) {
7231
+ contextIndex2 = idx;
7232
+ }
7233
+ }
7234
+ }
7235
+ return [pageIndex2, contextIndex2];
7236
+ }
7237
+ }
6438
7238
  } catch (error) {
6439
- throw new BrowserError(`Failed to get page/context index: ${error}`);
7239
+ log(`CDP targetId retrieval failed, fallback to defaults: ${error}`);
6440
7240
  }
7241
+ const pageIndex = "default-page-id";
7242
+ const contextIndex = 0;
7243
+ return [pageIndex, contextIndex];
6441
7244
  }
6442
7245
  async _callMcpTool(toolName, args) {
6443
7246
  return this.session.callMcpTool(toolName, args);
@@ -6447,6 +7250,174 @@ __name(_BrowserAgent, "BrowserAgent");
6447
7250
  var BrowserAgent = _BrowserAgent;
6448
7251
 
6449
7252
  // src/browser/browser.ts
7253
+ var _BrowserProxyClass = class _BrowserProxyClass {
7254
+ constructor(proxyType, server, username, password, strategy, pollsize) {
7255
+ this.type = proxyType;
7256
+ this.server = server;
7257
+ this.username = username;
7258
+ this.password = password;
7259
+ this.strategy = strategy;
7260
+ this.pollsize = pollsize;
7261
+ if (proxyType !== "custom" && proxyType !== "wuying") {
7262
+ throw new Error("proxy_type must be custom or wuying");
7263
+ }
7264
+ if (proxyType === "custom" && !server) {
7265
+ throw new Error("server is required for custom proxy type");
7266
+ }
7267
+ if (proxyType === "wuying" && !strategy) {
7268
+ throw new Error("strategy is required for wuying proxy type");
7269
+ }
7270
+ if (proxyType === "wuying" && strategy !== "restricted" && strategy !== "polling") {
7271
+ throw new Error("strategy must be restricted or polling for wuying proxy type");
7272
+ }
7273
+ if (proxyType === "wuying" && strategy === "polling" && pollsize !== void 0 && pollsize <= 0) {
7274
+ throw new Error("pollsize must be greater than 0 for polling strategy");
7275
+ }
7276
+ }
7277
+ toMap() {
7278
+ const proxyMap = {
7279
+ type: this.type
7280
+ };
7281
+ if (this.type === "custom") {
7282
+ proxyMap.server = this.server;
7283
+ if (this.username) {
7284
+ proxyMap.username = this.username;
7285
+ }
7286
+ if (this.password) {
7287
+ proxyMap.password = this.password;
7288
+ }
7289
+ } else if (this.type === "wuying") {
7290
+ proxyMap.strategy = this.strategy;
7291
+ if (this.strategy === "polling") {
7292
+ proxyMap.pollsize = this.pollsize;
7293
+ }
7294
+ }
7295
+ return proxyMap;
7296
+ }
7297
+ static fromMap(m) {
7298
+ if (!m || typeof m !== "object") {
7299
+ return null;
7300
+ }
7301
+ const proxyType = m.type;
7302
+ if (!proxyType) {
7303
+ return null;
7304
+ }
7305
+ if (proxyType === "custom") {
7306
+ return new _BrowserProxyClass(
7307
+ proxyType,
7308
+ m.server,
7309
+ m.username,
7310
+ m.password
7311
+ );
7312
+ } else if (proxyType === "wuying") {
7313
+ return new _BrowserProxyClass(
7314
+ proxyType,
7315
+ void 0,
7316
+ void 0,
7317
+ void 0,
7318
+ m.strategy,
7319
+ m.pollsize || 10
7320
+ );
7321
+ } else {
7322
+ throw new Error(`Unsupported proxy type: ${proxyType}`);
7323
+ }
7324
+ }
7325
+ };
7326
+ __name(_BrowserProxyClass, "BrowserProxyClass");
7327
+ var BrowserProxyClass = _BrowserProxyClass;
7328
+ var _BrowserOptionClass = class _BrowserOptionClass {
7329
+ constructor(useStealth = false, userAgent, viewport, screen, fingerprint, proxies) {
7330
+ this.useStealth = useStealth;
7331
+ this.userAgent = userAgent;
7332
+ this.viewport = viewport;
7333
+ this.screen = screen;
7334
+ this.fingerprint = fingerprint;
7335
+ this.proxies = proxies;
7336
+ this.extensionPath = "/tmp/extensions/";
7337
+ if (proxies !== void 0) {
7338
+ if (!Array.isArray(proxies)) {
7339
+ throw new Error("proxies must be a list");
7340
+ }
7341
+ if (proxies.length > 1) {
7342
+ throw new Error("proxies list length must be limited to 1");
7343
+ }
7344
+ }
7345
+ }
7346
+ toMap() {
7347
+ const optionMap = {};
7348
+ if (process.env.AGENTBAY_BROWSER_BEHAVIOR_SIMULATE) {
7349
+ optionMap["behaviorSimulate"] = process.env.AGENTBAY_BROWSER_BEHAVIOR_SIMULATE !== "0";
7350
+ }
7351
+ if (this.useStealth !== void 0) {
7352
+ optionMap["useStealth"] = this.useStealth;
7353
+ }
7354
+ if (this.userAgent !== void 0) {
7355
+ optionMap["userAgent"] = this.userAgent;
7356
+ }
7357
+ if (this.viewport !== void 0) {
7358
+ optionMap["viewport"] = { width: this.viewport.width, height: this.viewport.height };
7359
+ }
7360
+ if (this.screen !== void 0) {
7361
+ optionMap["screen"] = { width: this.screen.width, height: this.screen.height };
7362
+ }
7363
+ if (this.fingerprint !== void 0) {
7364
+ const fp = {};
7365
+ if (this.fingerprint.devices) fp["devices"] = this.fingerprint.devices;
7366
+ if (this.fingerprint.operatingSystems) fp["operatingSystems"] = this.fingerprint.operatingSystems;
7367
+ if (this.fingerprint.locales) fp["locales"] = this.fingerprint.locales;
7368
+ optionMap["fingerprint"] = fp;
7369
+ }
7370
+ if (this.proxies !== void 0) {
7371
+ optionMap["proxies"] = this.proxies.map((proxy) => proxy.toMap());
7372
+ }
7373
+ if (this.extensionPath !== void 0) {
7374
+ optionMap["extensionPath"] = this.extensionPath;
7375
+ }
7376
+ return optionMap;
7377
+ }
7378
+ fromMap(m) {
7379
+ const map = m || {};
7380
+ if (map.useStealth !== void 0) {
7381
+ this.useStealth = map.useStealth;
7382
+ } else {
7383
+ this.useStealth = false;
7384
+ }
7385
+ if (map.userAgent !== void 0) {
7386
+ this.userAgent = map.userAgent;
7387
+ }
7388
+ if (map.viewport !== void 0) {
7389
+ this.viewport = { width: map.viewport.width, height: map.viewport.height };
7390
+ }
7391
+ if (map.screen !== void 0) {
7392
+ this.screen = { width: map.screen.width, height: map.screen.height };
7393
+ }
7394
+ if (map.fingerprint !== void 0) {
7395
+ const fp = {};
7396
+ if (map.fingerprint.devices) fp.devices = map.fingerprint.devices;
7397
+ if (map.fingerprint.operatingSystems) fp.operatingSystems = map.fingerprint.operatingSystems;
7398
+ if (map.fingerprint.locales) fp.locales = map.fingerprint.locales;
7399
+ this.fingerprint = fp;
7400
+ }
7401
+ if (map.proxies !== void 0) {
7402
+ const proxyList = map.proxies;
7403
+ if (proxyList.length > 1) {
7404
+ throw new Error("proxies list length must be limited to 1");
7405
+ }
7406
+ this.proxies = proxyList.map((proxyData) => {
7407
+ if (proxyData instanceof BrowserProxyClass) {
7408
+ return proxyData;
7409
+ }
7410
+ return BrowserProxyClass.fromMap(proxyData);
7411
+ }).filter(Boolean);
7412
+ }
7413
+ if (map.extensionPath !== void 0) {
7414
+ this.extensionPath = map.extensionPath;
7415
+ }
7416
+ return this;
7417
+ }
7418
+ };
7419
+ __name(_BrowserOptionClass, "BrowserOptionClass");
7420
+ var BrowserOptionClass = _BrowserOptionClass;
6450
7421
  var _Browser = class _Browser {
6451
7422
  constructor(session) {
6452
7423
  this._endpointUrl = null;
@@ -6468,12 +7439,23 @@ var _Browser = class _Browser {
6468
7439
  request.authorization = `Bearer ${this.session.getAPIKey()}`;
6469
7440
  request.persistentPath = BROWSER_DATA_PATH;
6470
7441
  request.sessionId = this.session.getSessionId();
7442
+ let browserOption;
7443
+ if (option instanceof BrowserOptionClass) {
7444
+ browserOption = option;
7445
+ } else {
7446
+ browserOption = new BrowserOptionClass();
7447
+ browserOption.fromMap(option);
7448
+ }
7449
+ const browserOptionMap = browserOption.toMap();
7450
+ if (Object.keys(browserOptionMap).length > 0) {
7451
+ request.browserOption = browserOptionMap;
7452
+ }
6471
7453
  const response = this.session.getClient().initBrowserSync(request);
6472
7454
  log(`Response from init_browser data:`, response.body?.data);
6473
7455
  const success = response.body?.data?.port !== null && response.body?.data?.port !== void 0;
6474
7456
  if (success) {
6475
7457
  this._initialized = true;
6476
- this._option = option;
7458
+ this._option = browserOption;
6477
7459
  log("Browser instance was successfully initialized.");
6478
7460
  }
6479
7461
  return success;
@@ -6498,12 +7480,23 @@ var _Browser = class _Browser {
6498
7480
  request.authorization = `Bearer ${this.session.getAPIKey()}`;
6499
7481
  request.persistentPath = BROWSER_DATA_PATH;
6500
7482
  request.sessionId = this.session.getSessionId();
7483
+ let browserOption;
7484
+ if (option instanceof BrowserOptionClass) {
7485
+ browserOption = option;
7486
+ } else {
7487
+ browserOption = new BrowserOptionClass();
7488
+ browserOption.fromMap(option);
7489
+ }
7490
+ const browserOptionMap = browserOption.toMap();
7491
+ if (Object.keys(browserOptionMap).length > 0) {
7492
+ request.browserOption = browserOptionMap;
7493
+ }
6501
7494
  const response = await this.session.getClient().initBrowser(request);
6502
7495
  log(`Response from init_browser data:`, response.body?.data);
6503
7496
  const success = response.body?.data?.port !== null && response.body?.data?.port !== void 0;
6504
7497
  if (success) {
6505
7498
  this._initialized = true;
6506
- this._option = option;
7499
+ this._option = browserOption;
6507
7500
  log("Browser instance successfully initialized");
6508
7501
  }
6509
7502
  return success;
@@ -6543,6 +7536,16 @@ var _Browser = class _Browser {
6543
7536
  isInitialized() {
6544
7537
  return this._initialized;
6545
7538
  }
7539
+ /**
7540
+ * Stop the browser instance, internal use only.
7541
+ */
7542
+ _stopBrowser() {
7543
+ if (this.isInitialized()) {
7544
+ this.session.callMcpTool("stopChrome", {});
7545
+ } else {
7546
+ throw new BrowserError("Browser is not initialized. Cannot stop browser.");
7547
+ }
7548
+ }
6546
7549
  };
6547
7550
  __name(_Browser, "Browser");
6548
7551
  var Browser = _Browser;
@@ -6570,7 +7573,6 @@ var _Session = class _Session {
6570
7573
  * @param sessionId - The ID of this session.
6571
7574
  */
6572
7575
  constructor(agentBay, sessionId) {
6573
- this.resourceUrl = "";
6574
7576
  // VPC-related information
6575
7577
  this.isVpc = false;
6576
7578
  // Whether this session uses VPC resources
@@ -6581,7 +7583,6 @@ var _Session = class _Session {
6581
7583
  this.mcpTools = [];
6582
7584
  this.agentBay = agentBay;
6583
7585
  this.sessionId = sessionId;
6584
- this.resourceUrl = "";
6585
7586
  this.fileSystem = new FileSystem(this);
6586
7587
  this.command = new Command(this);
6587
7588
  this.code = new Code(this);
@@ -6871,7 +7872,6 @@ var _Session = class _Session {
6871
7872
  }
6872
7873
  if (data?.resourceUrl) {
6873
7874
  sessionInfo.resourceUrl = data.resourceUrl;
6874
- this.resourceUrl = data.resourceUrl;
6875
7875
  }
6876
7876
  if (data?.desktopInfo) {
6877
7877
  const desktopInfo = data.desktopInfo;
@@ -7183,6 +8183,7 @@ var _AgentBay = class _AgentBay {
7183
8183
  */
7184
8184
  constructor(options = {}) {
7185
8185
  this.sessions = /* @__PURE__ */ new Map();
8186
+ loadDotEnv();
7186
8187
  this.apiKey = options.apiKey || process.env.AGENTBAY_API_KEY || "";
7187
8188
  if (!this.apiKey) {
7188
8189
  throw new AuthenticationError(
@@ -7217,15 +8218,15 @@ var _AgentBay = class _AgentBay {
7217
8218
  const request = new CreateMcpSessionRequest({
7218
8219
  authorization: "Bearer " + this.apiKey
7219
8220
  });
7220
- if (params.contextId) {
7221
- request.contextId = params.contextId;
7222
- }
7223
8221
  if (params.labels) {
7224
8222
  request.labels = JSON.stringify(params.labels);
7225
8223
  }
7226
8224
  if (params.imageId) {
7227
8225
  request.imageId = params.imageId;
7228
8226
  }
8227
+ if (params.mcpPolicyId) {
8228
+ request.mcpPolicyId = params.mcpPolicyId;
8229
+ }
7229
8230
  request.vpcResource = params.isVpc || false;
7230
8231
  let hasPersistenceData = false;
7231
8232
  if (params.contextSync && params.contextSync.length > 0) {
@@ -7264,9 +8265,6 @@ var _AgentBay = class _AgentBay {
7264
8265
  }
7265
8266
  log("API Call: CreateMcpSession");
7266
8267
  let requestLog = "Request: ";
7267
- if (request.contextId) {
7268
- requestLog += `ContextId=${request.contextId}, `;
7269
- }
7270
8268
  if (request.imageId) {
7271
8269
  requestLog += `ImageId=${request.imageId}, `;
7272
8270
  }
@@ -7285,8 +8283,11 @@ var _AgentBay = class _AgentBay {
7285
8283
  }
7286
8284
  log(requestLog);
7287
8285
  const response = await this.client.createMcpSession(request);
7288
- log("response data =", response.body?.data);
7289
8286
  const requestId = extractRequestId(response) || "";
8287
+ log("response data =", response.body?.data);
8288
+ if (requestId) {
8289
+ log(`requestId = ${requestId}`);
8290
+ }
7290
8291
  const sessionData = response.body;
7291
8292
  if (!sessionData || typeof sessionData !== "object") {
7292
8293
  return {
@@ -7315,9 +8316,6 @@ var _AgentBay = class _AgentBay {
7315
8316
  log("session_id =", sessionId);
7316
8317
  log("resource_url =", resourceUrl);
7317
8318
  const session = new Session(this, sessionId);
7318
- if (resourceUrl) {
7319
- session.resourceUrl = resourceUrl;
7320
- }
7321
8319
  session.isVpc = params.isVpc || false;
7322
8320
  if (data.networkInterfaceIp) {
7323
8321
  session.networkInterfaceIp = data.networkInterfaceIp;
@@ -7522,6 +8520,366 @@ var AgentBay = _AgentBay;
7522
8520
  // src/agent/index.ts
7523
8521
  init_esm_shims();
7524
8522
 
8523
+ // src/extension.ts
8524
+ init_esm_shims();
8525
+ import * as fs2 from "fs";
8526
+ import * as path3 from "path";
8527
+ import * as crypto from "crypto";
8528
+ import fetch2 from "node-fetch";
8529
+ var EXTENSIONS_BASE_PATH = "/tmp/extensions";
8530
+ var _Extension = class _Extension {
8531
+ /**
8532
+ * Initialize an Extension object.
8533
+ *
8534
+ * @param id - The unique identifier of the extension.
8535
+ * @param name - The name of the extension.
8536
+ * @param createdAt - Date and time when the extension was created.
8537
+ */
8538
+ constructor(id, name, createdAt) {
8539
+ this.id = id;
8540
+ this.name = name;
8541
+ this.createdAt = createdAt;
8542
+ }
8543
+ };
8544
+ __name(_Extension, "Extension");
8545
+ var Extension = _Extension;
8546
+ var _ExtensionOption = class _ExtensionOption {
8547
+ /**
8548
+ * Initialize ExtensionOption with context and extension configuration.
8549
+ *
8550
+ * @param contextId - ID of the extension context for browser extensions.
8551
+ * This should match the context where extensions are stored.
8552
+ * @param extensionIds - List of extension IDs to be loaded in the browser session.
8553
+ * Each ID should correspond to a valid extension in the context.
8554
+ *
8555
+ * @throws {Error} If contextId is empty or extensionIds is empty.
8556
+ */
8557
+ constructor(contextId, extensionIds) {
8558
+ if (!contextId || !contextId.trim()) {
8559
+ throw new Error("contextId cannot be empty");
8560
+ }
8561
+ if (!extensionIds || extensionIds.length === 0) {
8562
+ throw new Error("extensionIds cannot be empty");
8563
+ }
8564
+ this.contextId = contextId;
8565
+ this.extensionIds = extensionIds;
8566
+ }
8567
+ /**
8568
+ * String representation of ExtensionOption.
8569
+ */
8570
+ toString() {
8571
+ return `ExtensionOption(contextId='${this.contextId}', extensionIds=${JSON.stringify(this.extensionIds)})`;
8572
+ }
8573
+ /**
8574
+ * Human-readable string representation.
8575
+ */
8576
+ toDisplayString() {
8577
+ return `Extension Config: ${this.extensionIds.length} extension(s) in context '${this.contextId}'`;
8578
+ }
8579
+ /**
8580
+ * Validate the extension option configuration.
8581
+ *
8582
+ * @returns True if configuration is valid, false otherwise.
8583
+ */
8584
+ validate() {
8585
+ try {
8586
+ if (!this.contextId || !this.contextId.trim()) {
8587
+ return false;
8588
+ }
8589
+ if (!this.extensionIds || this.extensionIds.length === 0) {
8590
+ return false;
8591
+ }
8592
+ for (const extId of this.extensionIds) {
8593
+ if (typeof extId !== "string" || !extId.trim()) {
8594
+ return false;
8595
+ }
8596
+ }
8597
+ return true;
8598
+ } catch (error) {
8599
+ return false;
8600
+ }
8601
+ }
8602
+ };
8603
+ __name(_ExtensionOption, "ExtensionOption");
8604
+ var ExtensionOption = _ExtensionOption;
8605
+ var _ExtensionsService = class _ExtensionsService {
8606
+ /**
8607
+ * Initializes the ExtensionsService with a context.
8608
+ *
8609
+ * @param agentBay - The AgentBay client instance.
8610
+ * @param contextId - The context ID or name. If empty or not provided,
8611
+ * a default context name will be generated automatically.
8612
+ * If the context doesn't exist, it will be automatically created.
8613
+ *
8614
+ * Note:
8615
+ * The service automatically detects if the context exists. If not,
8616
+ * it creates a new context with the provided name or a generated default name.
8617
+ * Context initialization is handled lazily on first use.
8618
+ */
8619
+ constructor(agentBay, contextId = "") {
8620
+ this._initializationPromise = null;
8621
+ if (!agentBay) {
8622
+ throw new AgentBayError("AgentBay instance is required");
8623
+ }
8624
+ if (!agentBay.context) {
8625
+ throw new AgentBayError("AgentBay instance must have a context service");
8626
+ }
8627
+ this.agentBay = agentBay;
8628
+ this.contextService = agentBay.context;
8629
+ this.autoCreated = true;
8630
+ if (!contextId || contextId.trim() === "") {
8631
+ contextId = `extensions-${Math.floor(Date.now() / 1e3)}`;
8632
+ log(`Generated default context name: ${contextId}`);
8633
+ }
8634
+ this.contextName = contextId;
8635
+ this._initializationPromise = this._initializeContext();
8636
+ }
8637
+ /**
8638
+ * Internal method to initialize the context.
8639
+ * This ensures the context is ready before any operations.
8640
+ */
8641
+ async _initializeContext() {
8642
+ try {
8643
+ const contextResult = await this.contextService.get(this.contextName, true);
8644
+ if (!contextResult.success || !contextResult.context) {
8645
+ throw new AgentBayError(`Failed to create extension repository context: ${this.contextName}`);
8646
+ }
8647
+ this.extensionContext = contextResult.context;
8648
+ this.contextId = this.extensionContext.id;
8649
+ } catch (error) {
8650
+ throw new AgentBayError(`Failed to initialize ExtensionsService: ${error instanceof Error ? error.message : String(error)}`);
8651
+ }
8652
+ }
8653
+ /**
8654
+ * Ensures the service is initialized before performing operations.
8655
+ */
8656
+ async _ensureInitialized() {
8657
+ if (this._initializationPromise) {
8658
+ await this._initializationPromise;
8659
+ this._initializationPromise = null;
8660
+ }
8661
+ }
8662
+ /**
8663
+ * An internal helper method that encapsulates the flow of "get upload URL for a specific path and upload".
8664
+ * Uses the existing context service for file operations.
8665
+ *
8666
+ * @param localPath - The path to the local file.
8667
+ * @param remotePath - The path of the file in context storage.
8668
+ *
8669
+ * @throws {AgentBayError} If getting the credential or uploading fails.
8670
+ */
8671
+ async _uploadToCloud(localPath, remotePath) {
8672
+ try {
8673
+ const urlResult = await this.contextService.getFileUploadUrl(this.contextId, remotePath);
8674
+ if (!urlResult.success || !urlResult.url) {
8675
+ throw new AgentBayError(`Failed to get upload URL: ${urlResult.url || "No URL returned"}`);
8676
+ }
8677
+ const preSignedUrl = urlResult.url;
8678
+ const fileBuffer = fs2.readFileSync(localPath);
8679
+ const response = await fetch2(preSignedUrl, {
8680
+ method: "PUT",
8681
+ body: fileBuffer
8682
+ });
8683
+ if (!response.ok) {
8684
+ throw new AgentBayError(`HTTP error uploading file: ${response.status} ${response.statusText}`);
8685
+ }
8686
+ } catch (error) {
8687
+ if (error instanceof AgentBayError) {
8688
+ throw error;
8689
+ }
8690
+ throw new AgentBayError(`An error occurred while uploading the file: ${error instanceof Error ? error.message : String(error)}`);
8691
+ }
8692
+ }
8693
+ /**
8694
+ * Lists all available browser extensions within this context from the cloud.
8695
+ * Uses the context service to list files under the extensions directory.
8696
+ *
8697
+ * @returns Promise that resolves to an array of Extension objects.
8698
+ * @throws {AgentBayError} If listing extensions fails.
8699
+ */
8700
+ async list() {
8701
+ await this._ensureInitialized();
8702
+ try {
8703
+ const fileListResult = await this.contextService.listFiles(
8704
+ this.contextId,
8705
+ EXTENSIONS_BASE_PATH,
8706
+ 1,
8707
+ // pageNumber
8708
+ 100
8709
+ // pageSize - reasonable limit for extensions
8710
+ );
8711
+ if (!fileListResult.success) {
8712
+ throw new AgentBayError("Failed to list extensions: Context file listing failed.");
8713
+ }
8714
+ const extensions = [];
8715
+ for (const fileEntry of fileListResult.entries) {
8716
+ const extensionId = fileEntry.fileName || fileEntry.filePath;
8717
+ extensions.push(new Extension(
8718
+ extensionId,
8719
+ fileEntry.fileName || extensionId,
8720
+ fileEntry.gmtCreate
8721
+ ));
8722
+ }
8723
+ return extensions;
8724
+ } catch (error) {
8725
+ if (error instanceof AgentBayError) {
8726
+ throw error;
8727
+ }
8728
+ throw new AgentBayError(`An error occurred while listing browser extensions: ${error instanceof Error ? error.message : String(error)}`);
8729
+ }
8730
+ }
8731
+ /**
8732
+ * Uploads a new browser extension from a local path into the current context.
8733
+ *
8734
+ * @param localPath - Path to the local extension file (must be a .zip file).
8735
+ * @returns Promise that resolves to an Extension object.
8736
+ * @throws {Error} If the local file doesn't exist.
8737
+ * @throws {Error} If the file format is not supported (only .zip is supported).
8738
+ * @throws {AgentBayError} If upload fails.
8739
+ */
8740
+ async create(localPath) {
8741
+ await this._ensureInitialized();
8742
+ if (!fs2.existsSync(localPath)) {
8743
+ throw new Error(`The specified local file was not found: ${localPath}`);
8744
+ }
8745
+ const fileExtension = path3.extname(localPath).toLowerCase();
8746
+ if (fileExtension !== ".zip") {
8747
+ throw new Error(`Unsupported plugin format '${fileExtension}'. Only ZIP format (.zip) is supported.`);
8748
+ }
8749
+ const extensionId = `ext_${crypto.randomBytes(16).toString("hex")}${fileExtension}`;
8750
+ const extensionName = path3.basename(localPath);
8751
+ const remotePath = `${EXTENSIONS_BASE_PATH}/${extensionId}`;
8752
+ await this._uploadToCloud(localPath, remotePath);
8753
+ return new Extension(extensionId, extensionName);
8754
+ }
8755
+ /**
8756
+ * Updates an existing browser extension in the current context with a new file.
8757
+ *
8758
+ * @param extensionId - ID of the extension to update.
8759
+ * @param newLocalPath - Path to the new local extension file.
8760
+ * @returns Promise that resolves to an Extension object.
8761
+ * @throws {Error} If the new local file doesn't exist.
8762
+ * @throws {Error} If the extension doesn't exist in the context.
8763
+ * @throws {AgentBayError} If update fails.
8764
+ */
8765
+ async update(extensionId, newLocalPath) {
8766
+ await this._ensureInitialized();
8767
+ if (!fs2.existsSync(newLocalPath)) {
8768
+ throw new Error(`The specified new local file was not found: ${newLocalPath}`);
8769
+ }
8770
+ const existingExtensions = await this.list();
8771
+ const extensionExists = existingExtensions.some((ext) => ext.id === extensionId);
8772
+ if (!extensionExists) {
8773
+ throw new Error(`Browser extension with ID '${extensionId}' not found in the context. Cannot update.`);
8774
+ }
8775
+ const remotePath = `${EXTENSIONS_BASE_PATH}/${extensionId}`;
8776
+ await this._uploadToCloud(newLocalPath, remotePath);
8777
+ return new Extension(extensionId, path3.basename(newLocalPath));
8778
+ }
8779
+ /**
8780
+ * Gets detailed information about a specific browser extension.
8781
+ *
8782
+ * @param extensionId - The ID of the extension to get info for.
8783
+ * @returns Promise that resolves to an Extension object if found, undefined otherwise.
8784
+ */
8785
+ async _getExtensionInfo(extensionId) {
8786
+ await this._ensureInitialized();
8787
+ try {
8788
+ const extensions = await this.list();
8789
+ return extensions.find((ext) => ext.id === extensionId);
8790
+ } catch (error) {
8791
+ logError(`An error occurred while getting extension info for '${extensionId}':`, error);
8792
+ return void 0;
8793
+ }
8794
+ }
8795
+ /**
8796
+ * Cleans up the auto-created context if it was created by this service.
8797
+ *
8798
+ * @returns Promise that resolves to true if cleanup was successful or not needed, false if cleanup failed.
8799
+ *
8800
+ * Note:
8801
+ * This method only works if the context was auto-created by this service.
8802
+ * For existing contexts, no cleanup is performed.
8803
+ */
8804
+ async cleanup() {
8805
+ await this._ensureInitialized();
8806
+ if (!this.autoCreated) {
8807
+ return true;
8808
+ }
8809
+ try {
8810
+ const deleteResult = await this.contextService.delete(this.extensionContext);
8811
+ if (deleteResult) {
8812
+ log(`Extension context deleted: ${this.contextName} (ID: ${this.contextId})`);
8813
+ return true;
8814
+ } else {
8815
+ logError(`Warning: Failed to delete extension context: ${this.contextName}`, new Error("Delete operation returned false"));
8816
+ return false;
8817
+ }
8818
+ } catch (error) {
8819
+ logError(`Warning: Failed to delete extension context:`, error);
8820
+ return false;
8821
+ }
8822
+ }
8823
+ /**
8824
+ * Deletes a browser extension from the current context.
8825
+ *
8826
+ * @param extensionId - ID of the extension to delete.
8827
+ * @returns Promise that resolves to true if deletion was successful, false otherwise.
8828
+ */
8829
+ async delete(extensionId) {
8830
+ await this._ensureInitialized();
8831
+ const remotePath = `${EXTENSIONS_BASE_PATH}/${extensionId}`;
8832
+ try {
8833
+ const deleteResult = await this.contextService.deleteFile(this.contextId, remotePath);
8834
+ return deleteResult.success;
8835
+ } catch (error) {
8836
+ logError(`An error occurred while deleting browser extension '${extensionId}':`, error);
8837
+ return false;
8838
+ }
8839
+ }
8840
+ /**
8841
+ * Create an ExtensionOption for the current context with specified extension IDs.
8842
+ *
8843
+ * This is a convenience method that creates an ExtensionOption using the current
8844
+ * service's contextId and the provided extension IDs. This option can then be
8845
+ * used with BrowserContext for browser session creation.
8846
+ *
8847
+ * @param extensionIds - List of extension IDs to include in the option.
8848
+ * These should be extensions that exist in the current context.
8849
+ * @returns ExtensionOption configuration object for browser extension integration.
8850
+ * @throws {Error} If extensionIds is empty or invalid.
8851
+ *
8852
+ * @example
8853
+ * ```typescript
8854
+ * // Create extensions
8855
+ * const ext1 = await extensionsService.create("/path/to/ext1.zip");
8856
+ * const ext2 = await extensionsService.create("/path/to/ext2.zip");
8857
+ *
8858
+ * // Create extension option for browser integration
8859
+ * const extOption = extensionsService.createExtensionOption([ext1.id, ext2.id]);
8860
+ *
8861
+ * // Use with BrowserContext
8862
+ * const browserContext = new BrowserContext({
8863
+ * contextId: "browser_session",
8864
+ * autoUpload: true,
8865
+ * extensionContextId: extOption.contextId,
8866
+ * extensionIds: extOption.extensionIds
8867
+ * });
8868
+ * ```
8869
+ */
8870
+ createExtensionOption(extensionIds) {
8871
+ if (!this.contextId) {
8872
+ throw new Error("Service not initialized. Please call an async method first or ensure context is created.");
8873
+ }
8874
+ return new ExtensionOption(
8875
+ this.contextId,
8876
+ extensionIds
8877
+ );
8878
+ }
8879
+ };
8880
+ __name(_ExtensionsService, "ExtensionsService");
8881
+ var ExtensionsService = _ExtensionsService;
8882
+
7525
8883
  // src/context-sync.ts
7526
8884
  init_esm_shims();
7527
8885
  var UploadStrategy = /* @__PURE__ */ ((UploadStrategy2) => {
@@ -7532,12 +8890,41 @@ var DownloadStrategy = /* @__PURE__ */ ((DownloadStrategy2) => {
7532
8890
  DownloadStrategy2["DownloadAsync"] = "DownloadAsync";
7533
8891
  return DownloadStrategy2;
7534
8892
  })(DownloadStrategy || {});
8893
+ var _ExtractPolicyClass = class _ExtractPolicyClass {
8894
+ constructor(extract = true, deleteSrcFile = true, extractToCurrentFolder = false) {
8895
+ this.extract = true;
8896
+ this.deleteSrcFile = true;
8897
+ this.extractToCurrentFolder = false;
8898
+ this.extract = extract;
8899
+ this.deleteSrcFile = deleteSrcFile;
8900
+ this.extractToCurrentFolder = extractToCurrentFolder;
8901
+ }
8902
+ /**
8903
+ * Creates a new extract policy with default values
8904
+ */
8905
+ static default() {
8906
+ return new _ExtractPolicyClass();
8907
+ }
8908
+ /**
8909
+ * Converts to plain object for JSON serialization
8910
+ */
8911
+ toDict() {
8912
+ return {
8913
+ extract: this.extract,
8914
+ deleteSrcFile: this.deleteSrcFile,
8915
+ extractToCurrentFolder: this.extractToCurrentFolder
8916
+ };
8917
+ }
8918
+ };
8919
+ __name(_ExtractPolicyClass, "ExtractPolicyClass");
8920
+ var ExtractPolicyClass = _ExtractPolicyClass;
7535
8921
  var _SyncPolicyImpl = class _SyncPolicyImpl {
7536
8922
  constructor(policy) {
7537
8923
  if (policy) {
7538
8924
  this.uploadPolicy = policy.uploadPolicy;
7539
8925
  this.downloadPolicy = policy.downloadPolicy;
7540
8926
  this.deletePolicy = policy.deletePolicy;
8927
+ this.extractPolicy = policy.extractPolicy;
7541
8928
  this.bwList = policy.bwList;
7542
8929
  }
7543
8930
  this.ensureDefaults();
@@ -7552,6 +8939,9 @@ var _SyncPolicyImpl = class _SyncPolicyImpl {
7552
8939
  if (!this.deletePolicy) {
7553
8940
  this.deletePolicy = newDeletePolicy();
7554
8941
  }
8942
+ if (!this.extractPolicy) {
8943
+ this.extractPolicy = newExtractPolicy();
8944
+ }
7555
8945
  if (!this.bwList) {
7556
8946
  this.bwList = {
7557
8947
  whiteLists: [
@@ -7569,6 +8959,7 @@ var _SyncPolicyImpl = class _SyncPolicyImpl {
7569
8959
  uploadPolicy: this.uploadPolicy,
7570
8960
  downloadPolicy: this.downloadPolicy,
7571
8961
  deletePolicy: this.deletePolicy,
8962
+ extractPolicy: this.extractPolicy,
7572
8963
  bwList: this.bwList
7573
8964
  };
7574
8965
  }
@@ -7576,9 +8967,9 @@ var _SyncPolicyImpl = class _SyncPolicyImpl {
7576
8967
  __name(_SyncPolicyImpl, "SyncPolicyImpl");
7577
8968
  var SyncPolicyImpl = _SyncPolicyImpl;
7578
8969
  var _ContextSync = class _ContextSync {
7579
- constructor(contextId, path3, policy) {
8970
+ constructor(contextId, path4, policy) {
7580
8971
  this.contextId = contextId;
7581
- this.path = path3;
8972
+ this.path = path4;
7582
8973
  this.policy = policy;
7583
8974
  }
7584
8975
  // WithPolicy sets the policy and returns the context sync for chaining
@@ -7611,11 +9002,20 @@ function newDeletePolicy() {
7611
9002
  };
7612
9003
  }
7613
9004
  __name(newDeletePolicy, "newDeletePolicy");
9005
+ function newExtractPolicy() {
9006
+ return {
9007
+ extract: true,
9008
+ deleteSrcFile: true,
9009
+ extractToCurrentFolder: false
9010
+ };
9011
+ }
9012
+ __name(newExtractPolicy, "newExtractPolicy");
7614
9013
  function newSyncPolicy() {
7615
9014
  return {
7616
9015
  uploadPolicy: newUploadPolicy(),
7617
9016
  downloadPolicy: newDownloadPolicy(),
7618
9017
  deletePolicy: newDeletePolicy(),
9018
+ extractPolicy: newExtractPolicy(),
7619
9019
  bwList: {
7620
9020
  whiteLists: [
7621
9021
  {
@@ -7631,13 +9031,98 @@ function newSyncPolicyWithDefaults(policy) {
7631
9031
  return new SyncPolicyImpl(policy).toJSON();
7632
9032
  }
7633
9033
  __name(newSyncPolicyWithDefaults, "newSyncPolicyWithDefaults");
7634
- function newContextSync(contextId, path3, policy) {
7635
- return new ContextSync(contextId, path3, policy);
9034
+ function newContextSync(contextId, path4, policy) {
9035
+ return new ContextSync(contextId, path4, policy);
7636
9036
  }
7637
9037
  __name(newContextSync, "newContextSync");
7638
9038
 
7639
9039
  // src/session-params.ts
7640
9040
  init_esm_shims();
9041
+ var _BrowserContext = class _BrowserContext {
9042
+ /**
9043
+ * Initialize BrowserContextImpl with optional extension support.
9044
+ *
9045
+ * @param contextId - ID of the browser context to bind to the session.
9046
+ * This identifies the browser instance for the session.
9047
+ * @param autoUpload - Whether to automatically upload browser data
9048
+ * when the session ends. Defaults to true.
9049
+ * @param extensionOption - Extension configuration object containing
9050
+ * contextId and extensionIds. This encapsulates
9051
+ * all extension-related configuration.
9052
+ * Defaults to undefined.
9053
+ *
9054
+ * Extension Configuration:
9055
+ * - **ExtensionOption**: Use extensionOption parameter with an ExtensionOption object
9056
+ * - **No Extensions**: Don't provide extensionOption parameter
9057
+ *
9058
+ * Auto-generation:
9059
+ * - extensionContextSyncs is automatically generated when extensionOption is provided
9060
+ * - extensionContextSyncs will be undefined if no extensionOption is provided
9061
+ * - extensionContextSyncs will be a ContextSync[] if extensionOption is valid
9062
+ */
9063
+ constructor(contextId, autoUpload = true, extensionOption) {
9064
+ this.contextId = contextId;
9065
+ this.autoUpload = autoUpload;
9066
+ this.extensionOption = extensionOption;
9067
+ if (extensionOption) {
9068
+ this.extensionContextId = extensionOption.contextId;
9069
+ this.extensionIds = extensionOption.extensionIds;
9070
+ this.extensionContextSyncs = this._createExtensionContextSyncs();
9071
+ } else {
9072
+ this.extensionContextId = void 0;
9073
+ this.extensionIds = [];
9074
+ this.extensionContextSyncs = void 0;
9075
+ }
9076
+ }
9077
+ /**
9078
+ * Create ContextSync configurations for browser extensions.
9079
+ *
9080
+ * This method is called only when extensionOption is provided and contains
9081
+ * valid extension configuration (contextId and extensionIds).
9082
+ *
9083
+ * @returns ContextSync[] - List of context sync configurations for extensions.
9084
+ * Returns empty list if extension configuration is invalid.
9085
+ */
9086
+ _createExtensionContextSyncs() {
9087
+ if (!this.extensionIds || this.extensionIds.length === 0 || !this.extensionContextId) {
9088
+ return [];
9089
+ }
9090
+ const whiteLists = this.extensionIds.map((extId) => ({
9091
+ path: extId,
9092
+ excludePaths: []
9093
+ }));
9094
+ const syncPolicy = {
9095
+ uploadPolicy: {
9096
+ ...newUploadPolicy(),
9097
+ autoUpload: false
9098
+ },
9099
+ extractPolicy: {
9100
+ ...newExtractPolicy(),
9101
+ extract: true,
9102
+ deleteSrcFile: true
9103
+ },
9104
+ bwList: {
9105
+ whiteLists
9106
+ }
9107
+ };
9108
+ const extensionSync = new ContextSync(
9109
+ this.extensionContextId,
9110
+ "/tmp/extensions/",
9111
+ syncPolicy
9112
+ );
9113
+ return [extensionSync];
9114
+ }
9115
+ /**
9116
+ * Get all context syncs including extension syncs.
9117
+ *
9118
+ * @returns ContextSync[] - All context sync configurations. Returns empty list if no extensions configured.
9119
+ */
9120
+ getAllContextSyncs() {
9121
+ return this.extensionContextSyncs || [];
9122
+ }
9123
+ };
9124
+ __name(_BrowserContext, "BrowserContext");
9125
+ var BrowserContext = _BrowserContext;
7641
9126
  var _CreateSessionParams = class _CreateSessionParams {
7642
9127
  constructor() {
7643
9128
  this.labels = {};
@@ -7651,13 +9136,6 @@ var _CreateSessionParams = class _CreateSessionParams {
7651
9136
  this.labels = labels;
7652
9137
  return this;
7653
9138
  }
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
9139
  /**
7662
9140
  * WithImageId sets the image ID for the session parameters and returns the updated parameters.
7663
9141
  */
@@ -7679,6 +9157,13 @@ var _CreateSessionParams = class _CreateSessionParams {
7679
9157
  this.isVpc = isVpc;
7680
9158
  return this;
7681
9159
  }
9160
+ /**
9161
+ * WithMcpPolicyId sets the MCP policy id for the session parameters and returns the updated parameters.
9162
+ */
9163
+ withMcpPolicyId(mcpPolicyId) {
9164
+ this.mcpPolicyId = mcpPolicyId;
9165
+ return this;
9166
+ }
7682
9167
  /**
7683
9168
  * GetLabelsJSON returns the labels as a JSON string.
7684
9169
  * Returns an object with success status and result/error message to match Go version behavior.
@@ -7700,8 +9185,8 @@ var _CreateSessionParams = class _CreateSessionParams {
7700
9185
  /**
7701
9186
  * AddContextSync adds a context sync configuration to the session parameters.
7702
9187
  */
7703
- addContextSync(contextId, path3, policy) {
7704
- const contextSync = new ContextSync(contextId, path3, policy);
9188
+ addContextSync(contextId, path4, policy) {
9189
+ const contextSync = new ContextSync(contextId, path4, policy);
7705
9190
  this.contextSync.push(contextSync);
7706
9191
  return this;
7707
9192
  }
@@ -7723,13 +9208,18 @@ var _CreateSessionParams = class _CreateSessionParams {
7723
9208
  * Convert to plain object for JSON serialization
7724
9209
  */
7725
9210
  toJSON() {
9211
+ let allContextSyncs = [...this.contextSync];
9212
+ if (this.browserContext && "getAllContextSyncs" in this.browserContext) {
9213
+ const extensionSyncs = this.browserContext.getAllContextSyncs();
9214
+ allContextSyncs = allContextSyncs.concat(extensionSyncs);
9215
+ }
7726
9216
  return {
7727
9217
  labels: this.labels,
7728
- contextId: this.contextId,
7729
9218
  imageId: this.imageId,
7730
- contextSync: this.contextSync,
9219
+ contextSync: allContextSyncs,
7731
9220
  browserContext: this.browserContext,
7732
- isVpc: this.isVpc
9221
+ isVpc: this.isVpc,
9222
+ mcpPolicyId: this.mcpPolicyId
7733
9223
  };
7734
9224
  }
7735
9225
  /**
@@ -7738,11 +9228,22 @@ var _CreateSessionParams = class _CreateSessionParams {
7738
9228
  static fromJSON(config) {
7739
9229
  const params = new _CreateSessionParams();
7740
9230
  params.labels = config.labels || {};
7741
- params.contextId = config.contextId;
7742
9231
  params.imageId = config.imageId;
7743
9232
  params.contextSync = config.contextSync || [];
7744
- params.browserContext = config.browserContext;
9233
+ if (config.browserContext) {
9234
+ if ("getAllContextSyncs" in config.browserContext) {
9235
+ params.browserContext = config.browserContext;
9236
+ } else {
9237
+ const bc = config.browserContext;
9238
+ params.browserContext = new BrowserContext(
9239
+ bc.contextId,
9240
+ bc.autoUpload,
9241
+ bc.extensionOption
9242
+ );
9243
+ }
9244
+ }
7745
9245
  params.isVpc = config.isVpc || false;
9246
+ params.mcpPolicyId = config.mcpPolicyId;
7746
9247
  return params;
7747
9248
  }
7748
9249
  };
@@ -7754,7 +9255,6 @@ function newCreateSessionParams() {
7754
9255
  __name(newCreateSessionParams, "newCreateSessionParams");
7755
9256
  export {
7756
9257
  APIError,
7757
- ActResult,
7758
9258
  Agent,
7759
9259
  AgentBay,
7760
9260
  AgentBayError,
@@ -7767,7 +9267,10 @@ export {
7767
9267
  AuthenticationError,
7768
9268
  Browser,
7769
9269
  BrowserAgent,
9270
+ BrowserContext,
7770
9271
  BrowserError,
9272
+ BrowserOptionClass,
9273
+ BrowserProxyClass,
7771
9274
  CallMcpToolRequest,
7772
9275
  CallMcpToolResponse,
7773
9276
  CallMcpToolResponseBody,
@@ -7785,12 +9288,28 @@ export {
7785
9288
  CreateMcpSessionResponseBodyData,
7786
9289
  CreateMcpSessionShrinkRequest,
7787
9290
  CreateSessionParams,
9291
+ DeleteContextFileRequest,
9292
+ DeleteContextFileResponse,
9293
+ DeleteContextFileResponseBody,
7788
9294
  DeleteContextRequest,
7789
9295
  DeleteContextResponse,
7790
9296
  DeleteContextResponseBody,
9297
+ DescribeContextFilesRequest,
9298
+ DescribeContextFilesResponse,
9299
+ DescribeContextFilesResponseBody,
7791
9300
  DownloadStrategy,
9301
+ Extension,
9302
+ ExtensionOption,
9303
+ ExtensionsService,
9304
+ ExtractPolicyClass,
7792
9305
  FileError,
7793
9306
  FileSystem,
9307
+ GetContextFileDownloadUrlRequest,
9308
+ GetContextFileDownloadUrlResponse,
9309
+ GetContextFileDownloadUrlResponseBody,
9310
+ GetContextFileUploadUrlRequest,
9311
+ GetContextFileUploadUrlResponse,
9312
+ GetContextFileUploadUrlResponseBody,
7794
9313
  GetContextInfoRequest,
7795
9314
  GetContextInfoResponse,
7796
9315
  GetContextInfoResponseBody,
@@ -7831,7 +9350,6 @@ export {
7831
9350
  ModifyContextRequest,
7832
9351
  ModifyContextResponse,
7833
9352
  ModifyContextResponseBody,
7834
- ObserveResult,
7835
9353
  Oss,
7836
9354
  OssError,
7837
9355
  ReleaseMcpSessionRequest,
@@ -7849,6 +9367,8 @@ export {
7849
9367
  UI,
7850
9368
  UIError,
7851
9369
  UploadStrategy,
9370
+ loadConfig,
9371
+ loadDotEnv,
7852
9372
  log,
7853
9373
  logError,
7854
9374
  newContextManager,
@@ -7856,6 +9376,7 @@ export {
7856
9376
  newCreateSessionParams,
7857
9377
  newDeletePolicy,
7858
9378
  newDownloadPolicy,
9379
+ newExtractPolicy,
7859
9380
  newSyncPolicy,
7860
9381
  newSyncPolicyWithDefaults,
7861
9382
  newUploadPolicy