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.cjs CHANGED
@@ -114,10 +114,10 @@ var require_main = __commonJS({
114
114
  "node_modules/dotenv/lib/main.js"(exports, module) {
115
115
  "use strict";
116
116
  init_cjs_shims();
117
- var fs2 = __require("fs");
118
- var path2 = __require("path");
117
+ var fs3 = __require("fs");
118
+ var path3 = __require("path");
119
119
  var os = __require("os");
120
- var crypto = __require("crypto");
120
+ var crypto2 = __require("crypto");
121
121
  var packageJson = require_package();
122
122
  var version = packageJson.version;
123
123
  var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
@@ -230,7 +230,7 @@ var require_main = __commonJS({
230
230
  if (options && options.path && options.path.length > 0) {
231
231
  if (Array.isArray(options.path)) {
232
232
  for (const filepath of options.path) {
233
- if (fs2.existsSync(filepath)) {
233
+ if (fs3.existsSync(filepath)) {
234
234
  possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
235
235
  }
236
236
  }
@@ -238,16 +238,16 @@ var require_main = __commonJS({
238
238
  possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
239
239
  }
240
240
  } else {
241
- possibleVaultPath = path2.resolve(process.cwd(), ".env.vault");
241
+ possibleVaultPath = path3.resolve(process.cwd(), ".env.vault");
242
242
  }
243
- if (fs2.existsSync(possibleVaultPath)) {
243
+ if (fs3.existsSync(possibleVaultPath)) {
244
244
  return possibleVaultPath;
245
245
  }
246
246
  return null;
247
247
  }
248
248
  __name(_vaultPath, "_vaultPath");
249
249
  function _resolveHome(envPath) {
250
- return envPath[0] === "~" ? path2.join(os.homedir(), envPath.slice(1)) : envPath;
250
+ return envPath[0] === "~" ? path3.join(os.homedir(), envPath.slice(1)) : envPath;
251
251
  }
252
252
  __name(_resolveHome, "_resolveHome");
253
253
  function _configVault(options) {
@@ -266,7 +266,7 @@ var require_main = __commonJS({
266
266
  }
267
267
  __name(_configVault, "_configVault");
268
268
  function configDotenv(options) {
269
- const dotenvPath = path2.resolve(process.cwd(), ".env");
269
+ const dotenvPath = path3.resolve(process.cwd(), ".env");
270
270
  let encoding = "utf8";
271
271
  const debug = Boolean(options && options.debug);
272
272
  const quiet = options && "quiet" in options ? options.quiet : true;
@@ -290,13 +290,13 @@ var require_main = __commonJS({
290
290
  }
291
291
  let lastError;
292
292
  const parsedAll = {};
293
- for (const path3 of optionPaths) {
293
+ for (const path4 of optionPaths) {
294
294
  try {
295
- const parsed = DotenvModule.parse(fs2.readFileSync(path3, { encoding }));
295
+ const parsed = DotenvModule.parse(fs3.readFileSync(path4, { encoding }));
296
296
  DotenvModule.populate(parsedAll, parsed, options);
297
297
  } catch (e) {
298
298
  if (debug) {
299
- _debug(`Failed to load ${path3} ${e.message}`);
299
+ _debug(`Failed to load ${path4} ${e.message}`);
300
300
  }
301
301
  lastError = e;
302
302
  }
@@ -311,7 +311,7 @@ var require_main = __commonJS({
311
311
  const shortPaths = [];
312
312
  for (const filePath of optionPaths) {
313
313
  try {
314
- const relative = path2.relative(process.cwd(), filePath);
314
+ const relative = path3.relative(process.cwd(), filePath);
315
315
  shortPaths.push(relative);
316
316
  } catch (e) {
317
317
  if (debug) {
@@ -348,7 +348,7 @@ var require_main = __commonJS({
348
348
  const authTag = ciphertext.subarray(-16);
349
349
  ciphertext = ciphertext.subarray(12, -16);
350
350
  try {
351
- const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
351
+ const aesgcm = crypto2.createDecipheriv("aes-256-gcm", key, nonce);
352
352
  aesgcm.setAuthTag(authTag);
353
353
  return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
354
354
  } catch (error) {
@@ -489,7 +489,7 @@ init_cjs_shims();
489
489
 
490
490
  // src/api/client.ts
491
491
  init_cjs_shims();
492
- var _typescript = require('@darabonba/typescript'); var $dara65 = _interopRequireWildcard(_typescript); var $dara = _interopRequireWildcard(_typescript); var $dara2 = _interopRequireWildcard(_typescript); var $dara3 = _interopRequireWildcard(_typescript); var $dara4 = _interopRequireWildcard(_typescript); var $dara5 = _interopRequireWildcard(_typescript); var $dara6 = _interopRequireWildcard(_typescript); var $dara7 = _interopRequireWildcard(_typescript); var $dara8 = _interopRequireWildcard(_typescript); var $dara9 = _interopRequireWildcard(_typescript); var $dara10 = _interopRequireWildcard(_typescript); var $dara11 = _interopRequireWildcard(_typescript); var $dara12 = _interopRequireWildcard(_typescript); var $dara13 = _interopRequireWildcard(_typescript); var $dara14 = _interopRequireWildcard(_typescript); var $dara15 = _interopRequireWildcard(_typescript); var $dara16 = _interopRequireWildcard(_typescript); var $dara17 = _interopRequireWildcard(_typescript); var $dara18 = _interopRequireWildcard(_typescript); var $dara19 = _interopRequireWildcard(_typescript); var $dara20 = _interopRequireWildcard(_typescript); var $dara21 = _interopRequireWildcard(_typescript); var $dara22 = _interopRequireWildcard(_typescript); var $dara23 = _interopRequireWildcard(_typescript); var $dara24 = _interopRequireWildcard(_typescript); var $dara25 = _interopRequireWildcard(_typescript); var $dara26 = _interopRequireWildcard(_typescript); var $dara27 = _interopRequireWildcard(_typescript); var $dara28 = _interopRequireWildcard(_typescript); var $dara29 = _interopRequireWildcard(_typescript); var $dara30 = _interopRequireWildcard(_typescript); var $dara31 = _interopRequireWildcard(_typescript); var $dara32 = _interopRequireWildcard(_typescript); var $dara33 = _interopRequireWildcard(_typescript); var $dara34 = _interopRequireWildcard(_typescript); var $dara35 = _interopRequireWildcard(_typescript); var $dara36 = _interopRequireWildcard(_typescript); var $dara37 = _interopRequireWildcard(_typescript); var $dara38 = _interopRequireWildcard(_typescript); var $dara39 = _interopRequireWildcard(_typescript); var $dara40 = _interopRequireWildcard(_typescript); var $dara42 = _interopRequireWildcard(_typescript); var $dara41 = _interopRequireWildcard(_typescript); var $dara43 = _interopRequireWildcard(_typescript); var $dara44 = _interopRequireWildcard(_typescript); var $dara45 = _interopRequireWildcard(_typescript); var $dara46 = _interopRequireWildcard(_typescript); var $dara47 = _interopRequireWildcard(_typescript); var $dara48 = _interopRequireWildcard(_typescript); var $dara49 = _interopRequireWildcard(_typescript); var $dara50 = _interopRequireWildcard(_typescript); var $dara51 = _interopRequireWildcard(_typescript); var $dara52 = _interopRequireWildcard(_typescript); var $dara53 = _interopRequireWildcard(_typescript); var $dara54 = _interopRequireWildcard(_typescript); var $dara55 = _interopRequireWildcard(_typescript); var $dara56 = _interopRequireWildcard(_typescript); var $dara57 = _interopRequireWildcard(_typescript); var $dara58 = _interopRequireWildcard(_typescript); var $dara59 = _interopRequireWildcard(_typescript); var $dara60 = _interopRequireWildcard(_typescript); var $dara61 = _interopRequireWildcard(_typescript); var $dara62 = _interopRequireWildcard(_typescript); var $dara63 = _interopRequireWildcard(_typescript); var $dara64 = _interopRequireWildcard(_typescript);
492
+ var _typescript = require('@darabonba/typescript'); var $dara77 = _interopRequireWildcard(_typescript); var $dara = _interopRequireWildcard(_typescript); var $dara2 = _interopRequireWildcard(_typescript); var $dara3 = _interopRequireWildcard(_typescript); var $dara4 = _interopRequireWildcard(_typescript); var $dara5 = _interopRequireWildcard(_typescript); var $dara6 = _interopRequireWildcard(_typescript); var $dara7 = _interopRequireWildcard(_typescript); var $dara8 = _interopRequireWildcard(_typescript); var $dara9 = _interopRequireWildcard(_typescript); var $dara10 = _interopRequireWildcard(_typescript); var $dara11 = _interopRequireWildcard(_typescript); var $dara12 = _interopRequireWildcard(_typescript); var $dara13 = _interopRequireWildcard(_typescript); var $dara14 = _interopRequireWildcard(_typescript); var $dara15 = _interopRequireWildcard(_typescript); var $dara16 = _interopRequireWildcard(_typescript); var $dara17 = _interopRequireWildcard(_typescript); var $dara18 = _interopRequireWildcard(_typescript); var $dara19 = _interopRequireWildcard(_typescript); var $dara20 = _interopRequireWildcard(_typescript); var $dara21 = _interopRequireWildcard(_typescript); var $dara22 = _interopRequireWildcard(_typescript); var $dara23 = _interopRequireWildcard(_typescript); var $dara24 = _interopRequireWildcard(_typescript); var $dara25 = _interopRequireWildcard(_typescript); var $dara26 = _interopRequireWildcard(_typescript); var $dara27 = _interopRequireWildcard(_typescript); var $dara28 = _interopRequireWildcard(_typescript); var $dara29 = _interopRequireWildcard(_typescript); var $dara30 = _interopRequireWildcard(_typescript); var $dara31 = _interopRequireWildcard(_typescript); var $dara32 = _interopRequireWildcard(_typescript); var $dara33 = _interopRequireWildcard(_typescript); var $dara34 = _interopRequireWildcard(_typescript); var $dara35 = _interopRequireWildcard(_typescript); var $dara36 = _interopRequireWildcard(_typescript); var $dara37 = _interopRequireWildcard(_typescript); var $dara38 = _interopRequireWildcard(_typescript); var $dara39 = _interopRequireWildcard(_typescript); var $dara40 = _interopRequireWildcard(_typescript); var $dara42 = _interopRequireWildcard(_typescript); var $dara41 = _interopRequireWildcard(_typescript); var $dara43 = _interopRequireWildcard(_typescript); var $dara44 = _interopRequireWildcard(_typescript); var $dara45 = _interopRequireWildcard(_typescript); var $dara46 = _interopRequireWildcard(_typescript); var $dara47 = _interopRequireWildcard(_typescript); var $dara48 = _interopRequireWildcard(_typescript); var $dara49 = _interopRequireWildcard(_typescript); var $dara50 = _interopRequireWildcard(_typescript); var $dara51 = _interopRequireWildcard(_typescript); var $dara52 = _interopRequireWildcard(_typescript); var $dara53 = _interopRequireWildcard(_typescript); var $dara54 = _interopRequireWildcard(_typescript); var $dara55 = _interopRequireWildcard(_typescript); var $dara56 = _interopRequireWildcard(_typescript); var $dara57 = _interopRequireWildcard(_typescript); var $dara58 = _interopRequireWildcard(_typescript); var $dara59 = _interopRequireWildcard(_typescript); var $dara60 = _interopRequireWildcard(_typescript); var $dara61 = _interopRequireWildcard(_typescript); var $dara62 = _interopRequireWildcard(_typescript); var $dara63 = _interopRequireWildcard(_typescript); var $dara64 = _interopRequireWildcard(_typescript); var $dara65 = _interopRequireWildcard(_typescript); var $dara66 = _interopRequireWildcard(_typescript); var $dara67 = _interopRequireWildcard(_typescript); var $dara68 = _interopRequireWildcard(_typescript); var $dara69 = _interopRequireWildcard(_typescript); var $dara70 = _interopRequireWildcard(_typescript); var $dara71 = _interopRequireWildcard(_typescript); var $dara72 = _interopRequireWildcard(_typescript); var $dara73 = _interopRequireWildcard(_typescript); var $dara74 = _interopRequireWildcard(_typescript); var $dara75 = _interopRequireWildcard(_typescript); var $dara76 = _interopRequireWildcard(_typescript);
493
493
 
494
494
 
495
495
 
@@ -1041,6 +1041,7 @@ var _CreateMcpSessionRequest = class _CreateMcpSessionRequest extends $dara18.Mo
1041
1041
  externalUserId: "ExternalUserId",
1042
1042
  imageId: "ImageId",
1043
1043
  labels: "Labels",
1044
+ mcpPolicyId: "McpPolicyId",
1044
1045
  persistenceDataList: "PersistenceDataList",
1045
1046
  sessionId: "SessionId",
1046
1047
  vpcResource: "VpcResource"
@@ -1053,6 +1054,7 @@ var _CreateMcpSessionRequest = class _CreateMcpSessionRequest extends $dara18.Mo
1053
1054
  externalUserId: "string",
1054
1055
  imageId: "string",
1055
1056
  labels: "string",
1057
+ mcpPolicyId: "string",
1056
1058
  persistenceDataList: { "type": "array", "itemType": CreateMcpSessionRequestPersistenceDataList },
1057
1059
  sessionId: "string",
1058
1060
  vpcResource: "boolean"
@@ -1082,6 +1084,7 @@ var _CreateMcpSessionShrinkRequest = class _CreateMcpSessionShrinkRequest extend
1082
1084
  externalUserId: "ExternalUserId",
1083
1085
  imageId: "ImageId",
1084
1086
  labels: "Labels",
1087
+ mcpPolicyId: "McpPolicyId",
1085
1088
  persistenceDataListShrink: "PersistenceDataList",
1086
1089
  sessionId: "SessionId",
1087
1090
  vpcResource: "VpcResource"
@@ -1094,6 +1097,7 @@ var _CreateMcpSessionShrinkRequest = class _CreateMcpSessionShrinkRequest extend
1094
1097
  externalUserId: "string",
1095
1098
  imageId: "string",
1096
1099
  labels: "string",
1100
+ mcpPolicyId: "string",
1097
1101
  persistenceDataListShrink: "string",
1098
1102
  sessionId: "string",
1099
1103
  vpcResource: "boolean"
@@ -1787,14 +1791,16 @@ var _InitBrowserRequest = class _InitBrowserRequest extends $dara40.Model {
1787
1791
  return {
1788
1792
  authorization: "Authorization",
1789
1793
  persistentPath: "PersistentPath",
1790
- sessionId: "SessionId"
1794
+ sessionId: "SessionId",
1795
+ browserOption: "BrowserOption"
1791
1796
  };
1792
1797
  }
1793
1798
  static types() {
1794
1799
  return {
1795
1800
  authorization: "string",
1796
1801
  persistentPath: "string",
1797
- sessionId: "string"
1802
+ sessionId: "string",
1803
+ browserOption: { "type": "map", "keyType": "string", "valueType": "any" }
1798
1804
  };
1799
1805
  }
1800
1806
  validate() {
@@ -2600,6 +2606,448 @@ var _SyncContextResponse = class _SyncContextResponse extends $dara64.Model {
2600
2606
  __name(_SyncContextResponse, "SyncContextResponse");
2601
2607
  var SyncContextResponse = _SyncContextResponse;
2602
2608
 
2609
+ // src/api/models/DeleteContextFileRequest.ts
2610
+ init_cjs_shims();
2611
+
2612
+ var _DeleteContextFileRequest = class _DeleteContextFileRequest extends $dara65.Model {
2613
+ static names() {
2614
+ return {
2615
+ authorization: "Authorization",
2616
+ contextId: "ContextId",
2617
+ filePath: "FilePath"
2618
+ };
2619
+ }
2620
+ static types() {
2621
+ return {
2622
+ authorization: "string",
2623
+ contextId: "string",
2624
+ filePath: "string"
2625
+ };
2626
+ }
2627
+ validate() {
2628
+ super.validate();
2629
+ }
2630
+ constructor(map) {
2631
+ super(map);
2632
+ }
2633
+ };
2634
+ __name(_DeleteContextFileRequest, "DeleteContextFileRequest");
2635
+ var DeleteContextFileRequest = _DeleteContextFileRequest;
2636
+
2637
+ // src/api/models/DeleteContextFileResponseBody.ts
2638
+ init_cjs_shims();
2639
+
2640
+ var _DeleteContextFileResponseBody = class _DeleteContextFileResponseBody extends $dara66.Model {
2641
+ static names() {
2642
+ return {
2643
+ code: "Code",
2644
+ httpStatusCode: "HttpStatusCode",
2645
+ message: "Message",
2646
+ requestId: "RequestId",
2647
+ success: "Success"
2648
+ };
2649
+ }
2650
+ static types() {
2651
+ return {
2652
+ code: "string",
2653
+ httpStatusCode: "number",
2654
+ message: "string",
2655
+ requestId: "string",
2656
+ success: "boolean"
2657
+ };
2658
+ }
2659
+ validate() {
2660
+ super.validate();
2661
+ }
2662
+ constructor(map) {
2663
+ super(map);
2664
+ }
2665
+ };
2666
+ __name(_DeleteContextFileResponseBody, "DeleteContextFileResponseBody");
2667
+ var DeleteContextFileResponseBody = _DeleteContextFileResponseBody;
2668
+
2669
+ // src/api/models/DeleteContextFileResponse.ts
2670
+ init_cjs_shims();
2671
+
2672
+ var _DeleteContextFileResponse = class _DeleteContextFileResponse extends $dara67.Model {
2673
+ static names() {
2674
+ return {
2675
+ headers: "headers",
2676
+ statusCode: "statusCode",
2677
+ body: "body"
2678
+ };
2679
+ }
2680
+ static types() {
2681
+ return {
2682
+ headers: { type: "map", keyType: "string", valueType: "string" },
2683
+ statusCode: "number",
2684
+ body: DeleteContextFileResponseBody
2685
+ };
2686
+ }
2687
+ validate() {
2688
+ super.validate();
2689
+ }
2690
+ constructor(map) {
2691
+ super(map);
2692
+ }
2693
+ };
2694
+ __name(_DeleteContextFileResponse, "DeleteContextFileResponse");
2695
+ var DeleteContextFileResponse = _DeleteContextFileResponse;
2696
+
2697
+ // src/api/models/DescribeContextFilesRequest.ts
2698
+ init_cjs_shims();
2699
+
2700
+ var _DescribeContextFilesRequest = class _DescribeContextFilesRequest extends $dara68.Model {
2701
+ static names() {
2702
+ return {
2703
+ authorization: "Authorization",
2704
+ pageNumber: "PageNumber",
2705
+ pageSize: "PageSize",
2706
+ parentFolderPath: "ParentFolderPath",
2707
+ contextId: "ContextId"
2708
+ };
2709
+ }
2710
+ static types() {
2711
+ return {
2712
+ authorization: "string",
2713
+ pageNumber: "number",
2714
+ pageSize: "number",
2715
+ parentFolderPath: "string",
2716
+ contextId: "string"
2717
+ };
2718
+ }
2719
+ validate() {
2720
+ super.validate();
2721
+ }
2722
+ constructor(map) {
2723
+ super(map);
2724
+ }
2725
+ };
2726
+ __name(_DescribeContextFilesRequest, "DescribeContextFilesRequest");
2727
+ var DescribeContextFilesRequest = _DescribeContextFilesRequest;
2728
+
2729
+ // src/api/models/DescribeContextFilesResponseBody.ts
2730
+ init_cjs_shims();
2731
+
2732
+ var _DescribeContextFilesResponseBodyData = class _DescribeContextFilesResponseBodyData extends $dara69.Model {
2733
+ static names() {
2734
+ return {
2735
+ fileId: "FileId",
2736
+ fileName: "FileName",
2737
+ filePath: "FilePath",
2738
+ fileType: "FileType",
2739
+ gmtCreate: "GmtCreate",
2740
+ gmtModified: "GmtModified",
2741
+ size: "Size",
2742
+ status: "Status"
2743
+ };
2744
+ }
2745
+ static types() {
2746
+ return {
2747
+ fileId: "string",
2748
+ fileName: "string",
2749
+ filePath: "string",
2750
+ fileType: "string",
2751
+ gmtCreate: "string",
2752
+ gmtModified: "string",
2753
+ size: "number",
2754
+ status: "string"
2755
+ };
2756
+ }
2757
+ validate() {
2758
+ super.validate();
2759
+ }
2760
+ constructor(map) {
2761
+ super(map);
2762
+ }
2763
+ };
2764
+ __name(_DescribeContextFilesResponseBodyData, "DescribeContextFilesResponseBodyData");
2765
+ var DescribeContextFilesResponseBodyData = _DescribeContextFilesResponseBodyData;
2766
+ var _DescribeContextFilesResponseBody = class _DescribeContextFilesResponseBody extends $dara69.Model {
2767
+ static names() {
2768
+ return {
2769
+ code: "Code",
2770
+ count: "Count",
2771
+ data: "Data",
2772
+ httpStatusCode: "HttpStatusCode",
2773
+ message: "Message",
2774
+ requestId: "RequestId",
2775
+ success: "Success"
2776
+ };
2777
+ }
2778
+ static types() {
2779
+ return {
2780
+ code: "string",
2781
+ count: "number",
2782
+ data: { type: "array", itemType: DescribeContextFilesResponseBodyData },
2783
+ httpStatusCode: "number",
2784
+ message: "string",
2785
+ requestId: "string",
2786
+ success: "boolean"
2787
+ };
2788
+ }
2789
+ validate() {
2790
+ super.validate();
2791
+ }
2792
+ constructor(map) {
2793
+ super(map);
2794
+ }
2795
+ };
2796
+ __name(_DescribeContextFilesResponseBody, "DescribeContextFilesResponseBody");
2797
+ var DescribeContextFilesResponseBody = _DescribeContextFilesResponseBody;
2798
+
2799
+ // src/api/models/DescribeContextFilesResponse.ts
2800
+ init_cjs_shims();
2801
+
2802
+ var _DescribeContextFilesResponse = class _DescribeContextFilesResponse extends $dara70.Model {
2803
+ static names() {
2804
+ return {
2805
+ headers: "headers",
2806
+ statusCode: "statusCode",
2807
+ body: "body"
2808
+ };
2809
+ }
2810
+ static types() {
2811
+ return {
2812
+ headers: { type: "map", keyType: "string", valueType: "string" },
2813
+ statusCode: "number",
2814
+ body: DescribeContextFilesResponseBody
2815
+ };
2816
+ }
2817
+ validate() {
2818
+ super.validate();
2819
+ }
2820
+ constructor(map) {
2821
+ super(map);
2822
+ }
2823
+ };
2824
+ __name(_DescribeContextFilesResponse, "DescribeContextFilesResponse");
2825
+ var DescribeContextFilesResponse = _DescribeContextFilesResponse;
2826
+
2827
+ // src/api/models/GetContextFileDownloadUrlRequest.ts
2828
+ init_cjs_shims();
2829
+
2830
+ var _GetContextFileDownloadUrlRequest = class _GetContextFileDownloadUrlRequest extends $dara71.Model {
2831
+ static names() {
2832
+ return {
2833
+ authorization: "Authorization",
2834
+ contextId: "ContextId",
2835
+ filePath: "FilePath"
2836
+ };
2837
+ }
2838
+ static types() {
2839
+ return {
2840
+ authorization: "string",
2841
+ contextId: "string",
2842
+ filePath: "string"
2843
+ };
2844
+ }
2845
+ validate() {
2846
+ super.validate();
2847
+ }
2848
+ constructor(map) {
2849
+ super(map);
2850
+ }
2851
+ };
2852
+ __name(_GetContextFileDownloadUrlRequest, "GetContextFileDownloadUrlRequest");
2853
+ var GetContextFileDownloadUrlRequest = _GetContextFileDownloadUrlRequest;
2854
+
2855
+ // src/api/models/GetContextFileDownloadUrlResponseBody.ts
2856
+ init_cjs_shims();
2857
+
2858
+ var _GetContextFileDownloadUrlResponseBodyData = class _GetContextFileDownloadUrlResponseBodyData extends $dara72.Model {
2859
+ static names() {
2860
+ return {
2861
+ expireTime: "ExpireTime",
2862
+ url: "Url"
2863
+ };
2864
+ }
2865
+ static types() {
2866
+ return {
2867
+ expireTime: "number",
2868
+ url: "string"
2869
+ };
2870
+ }
2871
+ validate() {
2872
+ super.validate();
2873
+ }
2874
+ constructor(map) {
2875
+ super(map);
2876
+ }
2877
+ };
2878
+ __name(_GetContextFileDownloadUrlResponseBodyData, "GetContextFileDownloadUrlResponseBodyData");
2879
+ var GetContextFileDownloadUrlResponseBodyData = _GetContextFileDownloadUrlResponseBodyData;
2880
+ var _GetContextFileDownloadUrlResponseBody = class _GetContextFileDownloadUrlResponseBody extends $dara72.Model {
2881
+ static names() {
2882
+ return {
2883
+ code: "Code",
2884
+ data: "Data",
2885
+ httpStatusCode: "HttpStatusCode",
2886
+ message: "Message",
2887
+ requestId: "RequestId",
2888
+ success: "Success"
2889
+ };
2890
+ }
2891
+ static types() {
2892
+ return {
2893
+ code: "string",
2894
+ data: GetContextFileDownloadUrlResponseBodyData,
2895
+ httpStatusCode: "number",
2896
+ message: "string",
2897
+ requestId: "string",
2898
+ success: "boolean"
2899
+ };
2900
+ }
2901
+ validate() {
2902
+ super.validate();
2903
+ }
2904
+ constructor(map) {
2905
+ super(map);
2906
+ }
2907
+ };
2908
+ __name(_GetContextFileDownloadUrlResponseBody, "GetContextFileDownloadUrlResponseBody");
2909
+ var GetContextFileDownloadUrlResponseBody = _GetContextFileDownloadUrlResponseBody;
2910
+
2911
+ // src/api/models/GetContextFileDownloadUrlResponse.ts
2912
+ init_cjs_shims();
2913
+
2914
+ var _GetContextFileDownloadUrlResponse = class _GetContextFileDownloadUrlResponse extends $dara73.Model {
2915
+ static names() {
2916
+ return {
2917
+ headers: "headers",
2918
+ statusCode: "statusCode",
2919
+ body: "body"
2920
+ };
2921
+ }
2922
+ static types() {
2923
+ return {
2924
+ headers: { type: "map", keyType: "string", valueType: "string" },
2925
+ statusCode: "number",
2926
+ body: GetContextFileDownloadUrlResponseBody
2927
+ };
2928
+ }
2929
+ validate() {
2930
+ super.validate();
2931
+ }
2932
+ constructor(map) {
2933
+ super(map);
2934
+ }
2935
+ };
2936
+ __name(_GetContextFileDownloadUrlResponse, "GetContextFileDownloadUrlResponse");
2937
+ var GetContextFileDownloadUrlResponse = _GetContextFileDownloadUrlResponse;
2938
+
2939
+ // src/api/models/GetContextFileUploadUrlRequest.ts
2940
+ init_cjs_shims();
2941
+
2942
+ var _GetContextFileUploadUrlRequest = class _GetContextFileUploadUrlRequest extends $dara74.Model {
2943
+ static names() {
2944
+ return {
2945
+ authorization: "Authorization",
2946
+ contextId: "ContextId",
2947
+ filePath: "FilePath"
2948
+ };
2949
+ }
2950
+ static types() {
2951
+ return {
2952
+ authorization: "string",
2953
+ contextId: "string",
2954
+ filePath: "string"
2955
+ };
2956
+ }
2957
+ validate() {
2958
+ super.validate();
2959
+ }
2960
+ constructor(map) {
2961
+ super(map);
2962
+ }
2963
+ };
2964
+ __name(_GetContextFileUploadUrlRequest, "GetContextFileUploadUrlRequest");
2965
+ var GetContextFileUploadUrlRequest = _GetContextFileUploadUrlRequest;
2966
+
2967
+ // src/api/models/GetContextFileUploadUrlResponseBody.ts
2968
+ init_cjs_shims();
2969
+
2970
+ var _GetContextFileUploadUrlResponseBodyData = class _GetContextFileUploadUrlResponseBodyData extends $dara75.Model {
2971
+ static names() {
2972
+ return {
2973
+ expireTime: "ExpireTime",
2974
+ url: "Url"
2975
+ };
2976
+ }
2977
+ static types() {
2978
+ return {
2979
+ expireTime: "number",
2980
+ url: "string"
2981
+ };
2982
+ }
2983
+ validate() {
2984
+ super.validate();
2985
+ }
2986
+ constructor(map) {
2987
+ super(map);
2988
+ }
2989
+ };
2990
+ __name(_GetContextFileUploadUrlResponseBodyData, "GetContextFileUploadUrlResponseBodyData");
2991
+ var GetContextFileUploadUrlResponseBodyData = _GetContextFileUploadUrlResponseBodyData;
2992
+ var _GetContextFileUploadUrlResponseBody = class _GetContextFileUploadUrlResponseBody extends $dara75.Model {
2993
+ static names() {
2994
+ return {
2995
+ code: "Code",
2996
+ data: "Data",
2997
+ httpStatusCode: "HttpStatusCode",
2998
+ message: "Message",
2999
+ requestId: "RequestId",
3000
+ success: "Success"
3001
+ };
3002
+ }
3003
+ static types() {
3004
+ return {
3005
+ code: "string",
3006
+ data: GetContextFileUploadUrlResponseBodyData,
3007
+ httpStatusCode: "number",
3008
+ message: "string",
3009
+ requestId: "string",
3010
+ success: "boolean"
3011
+ };
3012
+ }
3013
+ validate() {
3014
+ super.validate();
3015
+ }
3016
+ constructor(map) {
3017
+ super(map);
3018
+ }
3019
+ };
3020
+ __name(_GetContextFileUploadUrlResponseBody, "GetContextFileUploadUrlResponseBody");
3021
+ var GetContextFileUploadUrlResponseBody = _GetContextFileUploadUrlResponseBody;
3022
+
3023
+ // src/api/models/GetContextFileUploadUrlResponse.ts
3024
+ init_cjs_shims();
3025
+
3026
+ var _GetContextFileUploadUrlResponse = class _GetContextFileUploadUrlResponse extends $dara76.Model {
3027
+ static names() {
3028
+ return {
3029
+ headers: "headers",
3030
+ statusCode: "statusCode",
3031
+ body: "body"
3032
+ };
3033
+ }
3034
+ static types() {
3035
+ return {
3036
+ headers: { type: "map", keyType: "string", valueType: "string" },
3037
+ statusCode: "number",
3038
+ body: GetContextFileUploadUrlResponseBody
3039
+ };
3040
+ }
3041
+ validate() {
3042
+ super.validate();
3043
+ }
3044
+ constructor(map) {
3045
+ super(map);
3046
+ }
3047
+ };
3048
+ __name(_GetContextFileUploadUrlResponse, "GetContextFileUploadUrlResponse");
3049
+ var GetContextFileUploadUrlResponse = _GetContextFileUploadUrlResponse;
3050
+
2603
3051
  // src/api/client.ts
2604
3052
  var _Client = class _Client extends _openapicore2.default {
2605
3053
  constructor(config) {
@@ -2618,10 +3066,10 @@ var _Client = class _Client extends _openapicore2.default {
2618
3066
  );
2619
3067
  }
2620
3068
  getEndpoint(productId, regionId, endpointRule, network, suffix, endpointMap, endpoint) {
2621
- if (!$dara65.isNull(endpoint)) {
3069
+ if (!$dara77.isNull(endpoint)) {
2622
3070
  return endpoint;
2623
3071
  }
2624
- if (!$dara65.isNull(endpointMap) && !$dara65.isNull(endpointMap[regionId])) {
3072
+ if (!$dara77.isNull(endpointMap) && !$dara77.isNull(endpointMap[regionId])) {
2625
3073
  return endpointMap[regionId];
2626
3074
  }
2627
3075
  return _openapicore.OpenApiUtil.getEndpointRules(
@@ -2642,28 +3090,28 @@ var _Client = class _Client extends _openapicore2.default {
2642
3090
  async callMcpToolWithOptions(request, runtime) {
2643
3091
  request.validate();
2644
3092
  const body = {};
2645
- if (!$dara65.isNull(request.args)) {
3093
+ if (!$dara77.isNull(request.args)) {
2646
3094
  body["Args"] = request.args;
2647
3095
  }
2648
- if (!$dara65.isNull(request.authorization)) {
3096
+ if (!$dara77.isNull(request.authorization)) {
2649
3097
  body["Authorization"] = request.authorization;
2650
3098
  }
2651
- if (!$dara65.isNull(request.externalUserId)) {
3099
+ if (!$dara77.isNull(request.externalUserId)) {
2652
3100
  body["ExternalUserId"] = request.externalUserId;
2653
3101
  }
2654
- if (!$dara65.isNull(request.imageId)) {
3102
+ if (!$dara77.isNull(request.imageId)) {
2655
3103
  body["ImageId"] = request.imageId;
2656
3104
  }
2657
- if (!$dara65.isNull(request.name)) {
3105
+ if (!$dara77.isNull(request.name)) {
2658
3106
  body["Name"] = request.name;
2659
3107
  }
2660
- if (!$dara65.isNull(request.server)) {
3108
+ if (!$dara77.isNull(request.server)) {
2661
3109
  body["Server"] = request.server;
2662
3110
  }
2663
- if (!$dara65.isNull(request.sessionId)) {
3111
+ if (!$dara77.isNull(request.sessionId)) {
2664
3112
  body["SessionId"] = request.sessionId;
2665
3113
  }
2666
- if (!$dara65.isNull(request.tool)) {
3114
+ if (!$dara77.isNull(request.tool)) {
2667
3115
  body["Tool"] = request.tool;
2668
3116
  }
2669
3117
  const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
@@ -2680,7 +3128,7 @@ var _Client = class _Client extends _openapicore2.default {
2680
3128
  reqBodyType: "formData",
2681
3129
  bodyType: "json"
2682
3130
  });
2683
- return $dara65.cast(
3131
+ return $dara77.cast(
2684
3132
  await this.callApi(params, req, runtime),
2685
3133
  new CallMcpToolResponse({})
2686
3134
  );
@@ -2692,7 +3140,7 @@ var _Client = class _Client extends _openapicore2.default {
2692
3140
  * @returns CallMcpToolResponse
2693
3141
  */
2694
3142
  async callMcpTool(request) {
2695
- const runtime = new $dara65.RuntimeOptions({});
3143
+ const runtime = new $dara77.RuntimeOptions({});
2696
3144
  return await this.callMcpToolWithOptions(request, runtime);
2697
3145
  }
2698
3146
  /**
@@ -2706,7 +3154,7 @@ var _Client = class _Client extends _openapicore2.default {
2706
3154
  tmpReq.validate();
2707
3155
  const request = new CreateMcpSessionShrinkRequest({});
2708
3156
  _openapicore.OpenApiUtil.convert(tmpReq, request);
2709
- if (!$dara65.isNull(tmpReq.persistenceDataList)) {
3157
+ if (!$dara77.isNull(tmpReq.persistenceDataList)) {
2710
3158
  request.persistenceDataListShrink = _openapicore.OpenApiUtil.arrayToStringWithSpecifiedStyle(
2711
3159
  tmpReq.persistenceDataList,
2712
3160
  "PersistenceDataList",
@@ -2714,28 +3162,31 @@ var _Client = class _Client extends _openapicore2.default {
2714
3162
  );
2715
3163
  }
2716
3164
  const body = {};
2717
- if (!$dara65.isNull(request.authorization)) {
3165
+ if (!$dara77.isNull(request.authorization)) {
2718
3166
  body["Authorization"] = request.authorization;
2719
3167
  }
2720
- if (!$dara65.isNull(request.contextId)) {
3168
+ if (!$dara77.isNull(request.contextId)) {
2721
3169
  body["ContextId"] = request.contextId;
2722
3170
  }
2723
- if (!$dara65.isNull(request.externalUserId)) {
3171
+ if (!$dara77.isNull(request.externalUserId)) {
2724
3172
  body["ExternalUserId"] = request.externalUserId;
2725
3173
  }
2726
- if (!$dara65.isNull(request.imageId)) {
3174
+ if (!$dara77.isNull(request.imageId)) {
2727
3175
  body["ImageId"] = request.imageId;
2728
3176
  }
2729
- if (!$dara65.isNull(request.labels)) {
3177
+ if (!$dara77.isNull(request.labels)) {
2730
3178
  body["Labels"] = request.labels;
2731
3179
  }
2732
- if (!$dara65.isNull(request.persistenceDataListShrink)) {
3180
+ if (!$dara77.isNull(request.mcpPolicyId)) {
3181
+ body["McpPolicyId"] = request.mcpPolicyId;
3182
+ }
3183
+ if (!$dara77.isNull(request.persistenceDataListShrink)) {
2733
3184
  body["PersistenceDataList"] = request.persistenceDataListShrink;
2734
3185
  }
2735
- if (!$dara65.isNull(request.sessionId)) {
3186
+ if (!$dara77.isNull(request.sessionId)) {
2736
3187
  body["SessionId"] = request.sessionId;
2737
3188
  }
2738
- if (!$dara65.isNull(request.vpcResource)) {
3189
+ if (!$dara77.isNull(request.vpcResource)) {
2739
3190
  body["VpcResource"] = request.vpcResource;
2740
3191
  }
2741
3192
  const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
@@ -2752,7 +3203,7 @@ var _Client = class _Client extends _openapicore2.default {
2752
3203
  reqBodyType: "formData",
2753
3204
  bodyType: "json"
2754
3205
  });
2755
- return $dara65.cast(
3206
+ return $dara77.cast(
2756
3207
  await this.callApi(params, req, runtime),
2757
3208
  new CreateMcpSessionResponse({})
2758
3209
  );
@@ -2764,7 +3215,7 @@ var _Client = class _Client extends _openapicore2.default {
2764
3215
  * @returns CreateMcpSessionResponse
2765
3216
  */
2766
3217
  async createMcpSession(request) {
2767
- const runtime = new $dara65.RuntimeOptions({});
3218
+ const runtime = new $dara77.RuntimeOptions({});
2768
3219
  return await this.createMcpSessionWithOptions(request, runtime);
2769
3220
  }
2770
3221
  /**
@@ -2777,10 +3228,10 @@ var _Client = class _Client extends _openapicore2.default {
2777
3228
  async deleteContextWithOptions(request, runtime) {
2778
3229
  request.validate();
2779
3230
  const body = {};
2780
- if (!$dara65.isNull(request.authorization)) {
3231
+ if (!$dara77.isNull(request.authorization)) {
2781
3232
  body["Authorization"] = request.authorization;
2782
3233
  }
2783
- if (!$dara65.isNull(request.id)) {
3234
+ if (!$dara77.isNull(request.id)) {
2784
3235
  body["Id"] = request.id;
2785
3236
  }
2786
3237
  const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
@@ -2797,7 +3248,7 @@ var _Client = class _Client extends _openapicore2.default {
2797
3248
  reqBodyType: "formData",
2798
3249
  bodyType: "json"
2799
3250
  });
2800
- return $dara65.cast(
3251
+ return $dara77.cast(
2801
3252
  await this.callApi(params, req, runtime),
2802
3253
  new DeleteContextResponse({})
2803
3254
  );
@@ -2809,7 +3260,7 @@ var _Client = class _Client extends _openapicore2.default {
2809
3260
  * @returns DeleteContextResponse
2810
3261
  */
2811
3262
  async deleteContext(request) {
2812
- const runtime = new $dara65.RuntimeOptions({});
3263
+ const runtime = new $dara77.RuntimeOptions({});
2813
3264
  return await this.deleteContextWithOptions(request, runtime);
2814
3265
  }
2815
3266
  /**
@@ -2822,13 +3273,13 @@ var _Client = class _Client extends _openapicore2.default {
2822
3273
  async getContextWithOptions(request, runtime) {
2823
3274
  request.validate();
2824
3275
  const body = {};
2825
- if (!$dara65.isNull(request.allowCreate)) {
3276
+ if (!$dara77.isNull(request.allowCreate)) {
2826
3277
  body["AllowCreate"] = request.allowCreate;
2827
3278
  }
2828
- if (!$dara65.isNull(request.authorization)) {
3279
+ if (!$dara77.isNull(request.authorization)) {
2829
3280
  body["Authorization"] = request.authorization;
2830
3281
  }
2831
- if (!$dara65.isNull(request.name)) {
3282
+ if (!$dara77.isNull(request.name)) {
2832
3283
  body["Name"] = request.name;
2833
3284
  }
2834
3285
  const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
@@ -2845,7 +3296,7 @@ var _Client = class _Client extends _openapicore2.default {
2845
3296
  reqBodyType: "formData",
2846
3297
  bodyType: "json"
2847
3298
  });
2848
- return $dara65.cast(
3299
+ return $dara77.cast(
2849
3300
  await this.callApi(params, req, runtime),
2850
3301
  new GetContextResponse({})
2851
3302
  );
@@ -2857,7 +3308,7 @@ var _Client = class _Client extends _openapicore2.default {
2857
3308
  * @returns GetContextResponse
2858
3309
  */
2859
3310
  async getContext(request) {
2860
- const runtime = new $dara65.RuntimeOptions({});
3311
+ const runtime = new $dara77.RuntimeOptions({});
2861
3312
  return await this.getContextWithOptions(request, runtime);
2862
3313
  }
2863
3314
  /**
@@ -2870,19 +3321,19 @@ var _Client = class _Client extends _openapicore2.default {
2870
3321
  async getContextInfoWithOptions(request, runtime) {
2871
3322
  request.validate();
2872
3323
  const body = {};
2873
- if (!$dara65.isNull(request.authorization)) {
3324
+ if (!$dara77.isNull(request.authorization)) {
2874
3325
  body["Authorization"] = request.authorization;
2875
3326
  }
2876
- if (!$dara65.isNull(request.contextId)) {
3327
+ if (!$dara77.isNull(request.contextId)) {
2877
3328
  body["ContextId"] = request.contextId;
2878
3329
  }
2879
- if (!$dara65.isNull(request.path)) {
3330
+ if (!$dara77.isNull(request.path)) {
2880
3331
  body["Path"] = request.path;
2881
3332
  }
2882
- if (!$dara65.isNull(request.sessionId)) {
3333
+ if (!$dara77.isNull(request.sessionId)) {
2883
3334
  body["SessionId"] = request.sessionId;
2884
3335
  }
2885
- if (!$dara65.isNull(request.taskType)) {
3336
+ if (!$dara77.isNull(request.taskType)) {
2886
3337
  body["TaskType"] = request.taskType;
2887
3338
  }
2888
3339
  const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
@@ -2899,7 +3350,7 @@ var _Client = class _Client extends _openapicore2.default {
2899
3350
  reqBodyType: "formData",
2900
3351
  bodyType: "json"
2901
3352
  });
2902
- return $dara65.cast(
3353
+ return $dara77.cast(
2903
3354
  await this.callApi(params, req, runtime),
2904
3355
  new GetContextInfoResponse({})
2905
3356
  );
@@ -2911,7 +3362,7 @@ var _Client = class _Client extends _openapicore2.default {
2911
3362
  * @returns GetContextInfoResponse
2912
3363
  */
2913
3364
  async getContextInfo(request) {
2914
- const runtime = new $dara65.RuntimeOptions({});
3365
+ const runtime = new $dara77.RuntimeOptions({});
2915
3366
  return await this.getContextInfoWithOptions(request, runtime);
2916
3367
  }
2917
3368
  /**
@@ -2924,16 +3375,16 @@ var _Client = class _Client extends _openapicore2.default {
2924
3375
  async getLabelWithOptions(request, runtime) {
2925
3376
  request.validate();
2926
3377
  const body = {};
2927
- if (!$dara65.isNull(request.authorization)) {
3378
+ if (!$dara77.isNull(request.authorization)) {
2928
3379
  body["Authorization"] = request.authorization;
2929
3380
  }
2930
- if (!$dara65.isNull(request.maxResults)) {
3381
+ if (!$dara77.isNull(request.maxResults)) {
2931
3382
  body["MaxResults"] = request.maxResults;
2932
3383
  }
2933
- if (!$dara65.isNull(request.nextToken)) {
3384
+ if (!$dara77.isNull(request.nextToken)) {
2934
3385
  body["NextToken"] = request.nextToken;
2935
3386
  }
2936
- if (!$dara65.isNull(request.sessionId)) {
3387
+ if (!$dara77.isNull(request.sessionId)) {
2937
3388
  body["SessionId"] = request.sessionId;
2938
3389
  }
2939
3390
  const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
@@ -2950,7 +3401,7 @@ var _Client = class _Client extends _openapicore2.default {
2950
3401
  reqBodyType: "formData",
2951
3402
  bodyType: "json"
2952
3403
  });
2953
- return $dara65.cast(
3404
+ return $dara77.cast(
2954
3405
  await this.callApi(params, req, runtime),
2955
3406
  new GetLabelResponse({})
2956
3407
  );
@@ -2962,7 +3413,7 @@ var _Client = class _Client extends _openapicore2.default {
2962
3413
  * @returns GetLabelResponse
2963
3414
  */
2964
3415
  async getLabel(request) {
2965
- const runtime = new $dara65.RuntimeOptions({});
3416
+ const runtime = new $dara77.RuntimeOptions({});
2966
3417
  return await this.getLabelWithOptions(request, runtime);
2967
3418
  }
2968
3419
  /**
@@ -2975,16 +3426,16 @@ var _Client = class _Client extends _openapicore2.default {
2975
3426
  async getLinkWithOptions(request, runtime) {
2976
3427
  request.validate();
2977
3428
  const body = {};
2978
- if (!$dara65.isNull(request.authorization)) {
3429
+ if (!$dara77.isNull(request.authorization)) {
2979
3430
  body["Authorization"] = request.authorization;
2980
3431
  }
2981
- if (!$dara65.isNull(request.port)) {
3432
+ if (!$dara77.isNull(request.port)) {
2982
3433
  body["Port"] = request.port;
2983
3434
  }
2984
- if (!$dara65.isNull(request.protocolType)) {
3435
+ if (!$dara77.isNull(request.protocolType)) {
2985
3436
  body["ProtocolType"] = request.protocolType;
2986
3437
  }
2987
- if (!$dara65.isNull(request.sessionId)) {
3438
+ if (!$dara77.isNull(request.sessionId)) {
2988
3439
  body["SessionId"] = request.sessionId;
2989
3440
  }
2990
3441
  const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
@@ -3001,7 +3452,7 @@ var _Client = class _Client extends _openapicore2.default {
3001
3452
  reqBodyType: "formData",
3002
3453
  bodyType: "json"
3003
3454
  });
3004
- return $dara65.cast(
3455
+ return $dara77.cast(
3005
3456
  await this.callApi(params, req, runtime),
3006
3457
  new GetLinkResponse({})
3007
3458
  );
@@ -3013,7 +3464,7 @@ var _Client = class _Client extends _openapicore2.default {
3013
3464
  * @returns GetLinkResponse
3014
3465
  */
3015
3466
  async getLink(request) {
3016
- const runtime = new $dara65.RuntimeOptions({});
3467
+ const runtime = new $dara77.RuntimeOptions({});
3017
3468
  return await this.getLinkWithOptions(request, runtime);
3018
3469
  }
3019
3470
  /**
@@ -3026,10 +3477,10 @@ var _Client = class _Client extends _openapicore2.default {
3026
3477
  async getMcpResourceWithOptions(request, runtime) {
3027
3478
  request.validate();
3028
3479
  const body = {};
3029
- if (!$dara65.isNull(request.authorization)) {
3480
+ if (!$dara77.isNull(request.authorization)) {
3030
3481
  body["Authorization"] = request.authorization;
3031
3482
  }
3032
- if (!$dara65.isNull(request.sessionId)) {
3483
+ if (!$dara77.isNull(request.sessionId)) {
3033
3484
  body["SessionId"] = request.sessionId;
3034
3485
  }
3035
3486
  const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
@@ -3046,7 +3497,7 @@ var _Client = class _Client extends _openapicore2.default {
3046
3497
  reqBodyType: "formData",
3047
3498
  bodyType: "json"
3048
3499
  });
3049
- return $dara65.cast(
3500
+ return $dara77.cast(
3050
3501
  await this.callApi(params, req, runtime),
3051
3502
  new GetMcpResourceResponse({})
3052
3503
  );
@@ -3058,7 +3509,7 @@ var _Client = class _Client extends _openapicore2.default {
3058
3509
  * @returns GetMcpResourceResponse
3059
3510
  */
3060
3511
  async getMcpResource(request) {
3061
- const runtime = new $dara65.RuntimeOptions({});
3512
+ const runtime = new $dara77.RuntimeOptions({});
3062
3513
  return await this.getMcpResourceWithOptions(request, runtime);
3063
3514
  }
3064
3515
  /**
@@ -3071,13 +3522,13 @@ var _Client = class _Client extends _openapicore2.default {
3071
3522
  async listContextsWithOptions(request, runtime) {
3072
3523
  request.validate();
3073
3524
  const body = {};
3074
- if (!$dara65.isNull(request.authorization)) {
3525
+ if (!$dara77.isNull(request.authorization)) {
3075
3526
  body["Authorization"] = request.authorization;
3076
3527
  }
3077
- if (!$dara65.isNull(request.maxResults)) {
3528
+ if (!$dara77.isNull(request.maxResults)) {
3078
3529
  body["MaxResults"] = request.maxResults;
3079
3530
  }
3080
- if (!$dara65.isNull(request.nextToken)) {
3531
+ if (!$dara77.isNull(request.nextToken)) {
3081
3532
  body["NextToken"] = request.nextToken;
3082
3533
  }
3083
3534
  const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
@@ -3094,7 +3545,7 @@ var _Client = class _Client extends _openapicore2.default {
3094
3545
  reqBodyType: "formData",
3095
3546
  bodyType: "json"
3096
3547
  });
3097
- return $dara65.cast(
3548
+ return $dara77.cast(
3098
3549
  await this.callApi(params, req, runtime),
3099
3550
  new ListContextsResponse({})
3100
3551
  );
@@ -3106,7 +3557,7 @@ var _Client = class _Client extends _openapicore2.default {
3106
3557
  * @returns ListContextsResponse
3107
3558
  */
3108
3559
  async listContexts(request) {
3109
- const runtime = new $dara65.RuntimeOptions({});
3560
+ const runtime = new $dara77.RuntimeOptions({});
3110
3561
  return await this.listContextsWithOptions(request, runtime);
3111
3562
  }
3112
3563
  /**
@@ -3119,10 +3570,10 @@ var _Client = class _Client extends _openapicore2.default {
3119
3570
  async listMcpToolsWithOptions(request, runtime) {
3120
3571
  request.validate();
3121
3572
  const body = {};
3122
- if (!$dara65.isNull(request.authorization)) {
3573
+ if (!$dara77.isNull(request.authorization)) {
3123
3574
  body["Authorization"] = request.authorization;
3124
3575
  }
3125
- if (!$dara65.isNull(request.imageId)) {
3576
+ if (!$dara77.isNull(request.imageId)) {
3126
3577
  body["ImageId"] = request.imageId;
3127
3578
  }
3128
3579
  const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
@@ -3139,7 +3590,7 @@ var _Client = class _Client extends _openapicore2.default {
3139
3590
  reqBodyType: "formData",
3140
3591
  bodyType: "json"
3141
3592
  });
3142
- return $dara65.cast(
3593
+ return $dara77.cast(
3143
3594
  await this.callApi(params, req, runtime),
3144
3595
  new ListMcpToolsResponse({})
3145
3596
  );
@@ -3151,7 +3602,7 @@ var _Client = class _Client extends _openapicore2.default {
3151
3602
  * @returns ListMcpToolsResponse
3152
3603
  */
3153
3604
  async listMcpTools(request) {
3154
- const runtime = new $dara65.RuntimeOptions({});
3605
+ const runtime = new $dara77.RuntimeOptions({});
3155
3606
  return await this.listMcpToolsWithOptions(request, runtime);
3156
3607
  }
3157
3608
  /**
@@ -3164,16 +3615,16 @@ var _Client = class _Client extends _openapicore2.default {
3164
3615
  async listSessionWithOptions(request, runtime) {
3165
3616
  request.validate();
3166
3617
  const body = {};
3167
- if (!$dara65.isNull(request.authorization)) {
3618
+ if (!$dara77.isNull(request.authorization)) {
3168
3619
  body["Authorization"] = request.authorization;
3169
3620
  }
3170
- if (!$dara65.isNull(request.labels)) {
3621
+ if (!$dara77.isNull(request.labels)) {
3171
3622
  body["Labels"] = request.labels;
3172
3623
  }
3173
- if (!$dara65.isNull(request.maxResults)) {
3624
+ if (!$dara77.isNull(request.maxResults)) {
3174
3625
  body["MaxResults"] = request.maxResults;
3175
3626
  }
3176
- if (!$dara65.isNull(request.nextToken)) {
3627
+ if (!$dara77.isNull(request.nextToken)) {
3177
3628
  body["NextToken"] = request.nextToken;
3178
3629
  }
3179
3630
  const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
@@ -3190,7 +3641,7 @@ var _Client = class _Client extends _openapicore2.default {
3190
3641
  reqBodyType: "formData",
3191
3642
  bodyType: "json"
3192
3643
  });
3193
- return $dara65.cast(
3644
+ return $dara77.cast(
3194
3645
  await this.callApi(params, req, runtime),
3195
3646
  new ListSessionResponse({})
3196
3647
  );
@@ -3202,7 +3653,7 @@ var _Client = class _Client extends _openapicore2.default {
3202
3653
  * @returns ListSessionResponse
3203
3654
  */
3204
3655
  async listSession(request) {
3205
- const runtime = new $dara65.RuntimeOptions({});
3656
+ const runtime = new $dara77.RuntimeOptions({});
3206
3657
  return await this.listSessionWithOptions(request, runtime);
3207
3658
  }
3208
3659
  /**
@@ -3215,13 +3666,13 @@ var _Client = class _Client extends _openapicore2.default {
3215
3666
  async modifyContextWithOptions(request, runtime) {
3216
3667
  request.validate();
3217
3668
  const body = {};
3218
- if (!$dara65.isNull(request.authorization)) {
3669
+ if (!$dara77.isNull(request.authorization)) {
3219
3670
  body["Authorization"] = request.authorization;
3220
3671
  }
3221
- if (!$dara65.isNull(request.id)) {
3672
+ if (!$dara77.isNull(request.id)) {
3222
3673
  body["Id"] = request.id;
3223
3674
  }
3224
- if (!$dara65.isNull(request.name)) {
3675
+ if (!$dara77.isNull(request.name)) {
3225
3676
  body["Name"] = request.name;
3226
3677
  }
3227
3678
  const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
@@ -3238,7 +3689,7 @@ var _Client = class _Client extends _openapicore2.default {
3238
3689
  reqBodyType: "formData",
3239
3690
  bodyType: "json"
3240
3691
  });
3241
- return $dara65.cast(
3692
+ return $dara77.cast(
3242
3693
  await this.callApi(params, req, runtime),
3243
3694
  new ModifyContextResponse({})
3244
3695
  );
@@ -3250,7 +3701,7 @@ var _Client = class _Client extends _openapicore2.default {
3250
3701
  * @returns ModifyContextResponse
3251
3702
  */
3252
3703
  async modifyContext(request) {
3253
- const runtime = new $dara65.RuntimeOptions({});
3704
+ const runtime = new $dara77.RuntimeOptions({});
3254
3705
  return await this.modifyContextWithOptions(request, runtime);
3255
3706
  }
3256
3707
  /**
@@ -3263,10 +3714,10 @@ var _Client = class _Client extends _openapicore2.default {
3263
3714
  async releaseMcpSessionWithOptions(request, runtime) {
3264
3715
  request.validate();
3265
3716
  const body = {};
3266
- if (!$dara65.isNull(request.authorization)) {
3717
+ if (!$dara77.isNull(request.authorization)) {
3267
3718
  body["Authorization"] = request.authorization;
3268
3719
  }
3269
- if (!$dara65.isNull(request.sessionId)) {
3720
+ if (!$dara77.isNull(request.sessionId)) {
3270
3721
  body["SessionId"] = request.sessionId;
3271
3722
  }
3272
3723
  const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
@@ -3283,7 +3734,7 @@ var _Client = class _Client extends _openapicore2.default {
3283
3734
  reqBodyType: "formData",
3284
3735
  bodyType: "json"
3285
3736
  });
3286
- return $dara65.cast(
3737
+ return $dara77.cast(
3287
3738
  await this.callApi(params, req, runtime),
3288
3739
  new ReleaseMcpSessionResponse({})
3289
3740
  );
@@ -3295,7 +3746,7 @@ var _Client = class _Client extends _openapicore2.default {
3295
3746
  * @returns ReleaseMcpSessionResponse
3296
3747
  */
3297
3748
  async releaseMcpSession(request) {
3298
- const runtime = new $dara65.RuntimeOptions({});
3749
+ const runtime = new $dara77.RuntimeOptions({});
3299
3750
  return await this.releaseMcpSessionWithOptions(request, runtime);
3300
3751
  }
3301
3752
  /**
@@ -3308,13 +3759,13 @@ var _Client = class _Client extends _openapicore2.default {
3308
3759
  async setLabelWithOptions(request, runtime) {
3309
3760
  request.validate();
3310
3761
  const body = {};
3311
- if (!$dara65.isNull(request.authorization)) {
3762
+ if (!$dara77.isNull(request.authorization)) {
3312
3763
  body["Authorization"] = request.authorization;
3313
3764
  }
3314
- if (!$dara65.isNull(request.labels)) {
3765
+ if (!$dara77.isNull(request.labels)) {
3315
3766
  body["Labels"] = request.labels;
3316
3767
  }
3317
- if (!$dara65.isNull(request.sessionId)) {
3768
+ if (!$dara77.isNull(request.sessionId)) {
3318
3769
  body["SessionId"] = request.sessionId;
3319
3770
  }
3320
3771
  const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
@@ -3331,7 +3782,7 @@ var _Client = class _Client extends _openapicore2.default {
3331
3782
  reqBodyType: "formData",
3332
3783
  bodyType: "json"
3333
3784
  });
3334
- return $dara65.cast(
3785
+ return $dara77.cast(
3335
3786
  await this.callApi(params, req, runtime),
3336
3787
  new SetLabelResponse({})
3337
3788
  );
@@ -3343,7 +3794,7 @@ var _Client = class _Client extends _openapicore2.default {
3343
3794
  * @returns SetLabelResponse
3344
3795
  */
3345
3796
  async setLabel(request) {
3346
- const runtime = new $dara65.RuntimeOptions({});
3797
+ const runtime = new $dara77.RuntimeOptions({});
3347
3798
  return await this.setLabelWithOptions(request, runtime);
3348
3799
  }
3349
3800
  /**
@@ -3356,20 +3807,20 @@ var _Client = class _Client extends _openapicore2.default {
3356
3807
  async syncContextWithOptions(request, runtime) {
3357
3808
  request.validate();
3358
3809
  const query = {};
3359
- if (!$dara65.isNull(request.authorization)) {
3810
+ if (!$dara77.isNull(request.authorization)) {
3360
3811
  query["Authorization"] = request.authorization;
3361
3812
  }
3362
3813
  const body = {};
3363
- if (!$dara65.isNull(request.contextId)) {
3814
+ if (!$dara77.isNull(request.contextId)) {
3364
3815
  body["ContextId"] = request.contextId;
3365
3816
  }
3366
- if (!$dara65.isNull(request.mode)) {
3817
+ if (!$dara77.isNull(request.mode)) {
3367
3818
  body["Mode"] = request.mode;
3368
3819
  }
3369
- if (!$dara65.isNull(request.path)) {
3820
+ if (!$dara77.isNull(request.path)) {
3370
3821
  body["Path"] = request.path;
3371
3822
  }
3372
- if (!$dara65.isNull(request.sessionId)) {
3823
+ if (!$dara77.isNull(request.sessionId)) {
3373
3824
  body["SessionId"] = request.sessionId;
3374
3825
  }
3375
3826
  const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
@@ -3387,7 +3838,7 @@ var _Client = class _Client extends _openapicore2.default {
3387
3838
  reqBodyType: "formData",
3388
3839
  bodyType: "json"
3389
3840
  });
3390
- return $dara65.cast(
3841
+ return $dara77.cast(
3391
3842
  await this.callApi(params, req, runtime),
3392
3843
  new SyncContextResponse({})
3393
3844
  );
@@ -3399,7 +3850,7 @@ var _Client = class _Client extends _openapicore2.default {
3399
3850
  * @returns SyncContextResponse
3400
3851
  */
3401
3852
  async syncContext(request) {
3402
- const runtime = new $dara65.RuntimeOptions({});
3853
+ const runtime = new $dara77.RuntimeOptions({});
3403
3854
  return await this.syncContextWithOptions(request, runtime);
3404
3855
  }
3405
3856
  /**
@@ -3412,15 +3863,18 @@ var _Client = class _Client extends _openapicore2.default {
3412
3863
  async initBrowserWithOptions(request, runtime) {
3413
3864
  request.validate();
3414
3865
  const body = {};
3415
- if (!$dara65.isNull(request.authorization)) {
3866
+ if (!$dara77.isNull(request.authorization)) {
3416
3867
  body["Authorization"] = request.authorization;
3417
3868
  }
3418
- if (!$dara65.isNull(request.persistentPath)) {
3869
+ if (!$dara77.isNull(request.persistentPath)) {
3419
3870
  body["PersistentPath"] = request.persistentPath;
3420
3871
  }
3421
- if (!$dara65.isNull(request.sessionId)) {
3872
+ if (!$dara77.isNull(request.sessionId)) {
3422
3873
  body["SessionId"] = request.sessionId;
3423
3874
  }
3875
+ if (!$dara77.isNull(request.browserOption)) {
3876
+ body["BrowserOption"] = JSON.stringify(request.browserOption);
3877
+ }
3424
3878
  const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
3425
3879
  body: _openapicore.OpenApiUtil.parseToMap(body)
3426
3880
  });
@@ -3435,7 +3889,7 @@ var _Client = class _Client extends _openapicore2.default {
3435
3889
  reqBodyType: "formData",
3436
3890
  bodyType: "json"
3437
3891
  });
3438
- return $dara65.cast(
3892
+ return $dara77.cast(
3439
3893
  await this.callApi(params, req, runtime),
3440
3894
  new InitBrowserResponse({})
3441
3895
  );
@@ -3447,7 +3901,7 @@ var _Client = class _Client extends _openapicore2.default {
3447
3901
  * @returns InitBrowserResponse
3448
3902
  */
3449
3903
  async initBrowser(request) {
3450
- const runtime = new $dara65.RuntimeOptions({});
3904
+ const runtime = new $dara77.RuntimeOptions({});
3451
3905
  return await this.initBrowserWithOptions(request, runtime);
3452
3906
  }
3453
3907
  /**
@@ -3457,18 +3911,21 @@ var _Client = class _Client extends _openapicore2.default {
3457
3911
  * @returns InitBrowserResponse
3458
3912
  */
3459
3913
  initBrowserSync(request) {
3460
- const runtime = new $dara65.RuntimeOptions({});
3914
+ const runtime = new $dara77.RuntimeOptions({});
3461
3915
  request.validate();
3462
3916
  const body = {};
3463
- if (!$dara65.isNull(request.authorization)) {
3917
+ if (!$dara77.isNull(request.authorization)) {
3464
3918
  body["Authorization"] = request.authorization;
3465
3919
  }
3466
- if (!$dara65.isNull(request.persistentPath)) {
3920
+ if (!$dara77.isNull(request.persistentPath)) {
3467
3921
  body["PersistentPath"] = request.persistentPath;
3468
3922
  }
3469
- if (!$dara65.isNull(request.sessionId)) {
3923
+ if (!$dara77.isNull(request.sessionId)) {
3470
3924
  body["SessionId"] = request.sessionId;
3471
3925
  }
3926
+ if (!$dara77.isNull(request.browserOption)) {
3927
+ body["BrowserOption"] = JSON.stringify(request.browserOption);
3928
+ }
3472
3929
  const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
3473
3930
  body: _openapicore.OpenApiUtil.parseToMap(body)
3474
3931
  });
@@ -3483,11 +3940,209 @@ var _Client = class _Client extends _openapicore2.default {
3483
3940
  reqBodyType: "formData",
3484
3941
  bodyType: "json"
3485
3942
  });
3486
- return $dara65.cast(
3943
+ return $dara77.cast(
3487
3944
  this.callApi(params, req, runtime),
3488
3945
  new InitBrowserResponse({})
3489
3946
  );
3490
3947
  }
3948
+ /**
3949
+ * 获取上传context文件url
3950
+ *
3951
+ * @param request - DeleteContextFileRequest
3952
+ * @param runtime - runtime options for this request RuntimeOptions
3953
+ * @returns DeleteContextFileResponse
3954
+ */
3955
+ async deleteContextFileWithOptions(request, runtime) {
3956
+ request.validate();
3957
+ const body = {};
3958
+ if (!$dara77.isNull(request.authorization)) {
3959
+ body["Authorization"] = request.authorization;
3960
+ }
3961
+ if (!$dara77.isNull(request.contextId)) {
3962
+ body["ContextId"] = request.contextId;
3963
+ }
3964
+ if (!$dara77.isNull(request.filePath)) {
3965
+ body["FilePath"] = request.filePath;
3966
+ }
3967
+ const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
3968
+ body: _openapicore.OpenApiUtil.parseToMap(body)
3969
+ });
3970
+ const params = new _openapicore.$OpenApiUtil.Params({
3971
+ action: "DeleteContextFile",
3972
+ version: "2025-05-06",
3973
+ protocol: "HTTPS",
3974
+ pathname: "/",
3975
+ method: "POST",
3976
+ authType: "Anonymous",
3977
+ style: "RPC",
3978
+ reqBodyType: "formData",
3979
+ bodyType: "json"
3980
+ });
3981
+ return $dara77.cast(
3982
+ await this.callApi(params, req, runtime),
3983
+ new DeleteContextFileResponse({})
3984
+ );
3985
+ }
3986
+ /**
3987
+ * 获取上传context文件url
3988
+ *
3989
+ * @param request - DeleteContextFileRequest
3990
+ * @returns DeleteContextFileResponse
3991
+ */
3992
+ async deleteContextFile(request) {
3993
+ const runtime = new $dara77.RuntimeOptions({});
3994
+ return await this.deleteContextFileWithOptions(request, runtime);
3995
+ }
3996
+ /**
3997
+ * 查询context特定目录文件
3998
+ *
3999
+ * @param request - DescribeContextFilesRequest
4000
+ * @param runtime - runtime options for this request RuntimeOptions
4001
+ * @returns DescribeContextFilesResponse
4002
+ */
4003
+ async describeContextFilesWithOptions(request, runtime) {
4004
+ request.validate();
4005
+ const body = {};
4006
+ if (!$dara77.isNull(request.authorization)) {
4007
+ body["Authorization"] = request.authorization;
4008
+ }
4009
+ if (!$dara77.isNull(request.pageNumber)) {
4010
+ body["PageNumber"] = request.pageNumber;
4011
+ }
4012
+ if (!$dara77.isNull(request.pageSize)) {
4013
+ body["PageSize"] = request.pageSize;
4014
+ }
4015
+ if (!$dara77.isNull(request.parentFolderPath)) {
4016
+ body["ParentFolderPath"] = request.parentFolderPath;
4017
+ }
4018
+ if (!$dara77.isNull(request.contextId)) {
4019
+ body["ContextId"] = request.contextId;
4020
+ }
4021
+ const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
4022
+ body: _openapicore.OpenApiUtil.parseToMap(body)
4023
+ });
4024
+ const params = new _openapicore.$OpenApiUtil.Params({
4025
+ action: "DescribeContextFiles",
4026
+ version: "2025-05-06",
4027
+ protocol: "HTTPS",
4028
+ pathname: "/",
4029
+ method: "POST",
4030
+ authType: "Anonymous",
4031
+ style: "RPC",
4032
+ reqBodyType: "formData",
4033
+ bodyType: "json"
4034
+ });
4035
+ return $dara77.cast(
4036
+ await this.callApi(params, req, runtime),
4037
+ new DescribeContextFilesResponse({})
4038
+ );
4039
+ }
4040
+ /**
4041
+ * 查询context特定目录文件
4042
+ *
4043
+ * @param request - DescribeContextFilesRequest
4044
+ * @returns DescribeContextFilesResponse
4045
+ */
4046
+ async describeContextFiles(request) {
4047
+ const runtime = new $dara77.RuntimeOptions({});
4048
+ return await this.describeContextFilesWithOptions(request, runtime);
4049
+ }
4050
+ /**
4051
+ * 获取上传context文件url
4052
+ *
4053
+ * @param request - GetContextFileDownloadUrlRequest
4054
+ * @param runtime - runtime options for this request RuntimeOptions
4055
+ * @returns GetContextFileDownloadUrlResponse
4056
+ */
4057
+ async getContextFileDownloadUrlWithOptions(request, runtime) {
4058
+ request.validate();
4059
+ const body = {};
4060
+ if (!$dara77.isNull(request.authorization)) {
4061
+ body["Authorization"] = request.authorization;
4062
+ }
4063
+ if (!$dara77.isNull(request.contextId)) {
4064
+ body["ContextId"] = request.contextId;
4065
+ }
4066
+ if (!$dara77.isNull(request.filePath)) {
4067
+ body["FilePath"] = request.filePath;
4068
+ }
4069
+ const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
4070
+ body: _openapicore.OpenApiUtil.parseToMap(body)
4071
+ });
4072
+ const params = new _openapicore.$OpenApiUtil.Params({
4073
+ action: "GetContextFileDownloadUrl",
4074
+ version: "2025-05-06",
4075
+ protocol: "HTTPS",
4076
+ pathname: "/",
4077
+ method: "POST",
4078
+ authType: "Anonymous",
4079
+ style: "RPC",
4080
+ reqBodyType: "formData",
4081
+ bodyType: "json"
4082
+ });
4083
+ return $dara77.cast(
4084
+ await this.callApi(params, req, runtime),
4085
+ new GetContextFileDownloadUrlResponse({})
4086
+ );
4087
+ }
4088
+ /**
4089
+ * 获取上传context文件url
4090
+ *
4091
+ * @param request - GetContextFileDownloadUrlRequest
4092
+ * @returns GetContextFileDownloadUrlResponse
4093
+ */
4094
+ async getContextFileDownloadUrl(request) {
4095
+ const runtime = new $dara77.RuntimeOptions({});
4096
+ return await this.getContextFileDownloadUrlWithOptions(request, runtime);
4097
+ }
4098
+ /**
4099
+ * 获取上传context文件url
4100
+ *
4101
+ * @param request - GetContextFileUploadUrlRequest
4102
+ * @param runtime - runtime options for this request RuntimeOptions
4103
+ * @returns GetContextFileUploadUrlResponse
4104
+ */
4105
+ async getContextFileUploadUrlWithOptions(request, runtime) {
4106
+ request.validate();
4107
+ const body = {};
4108
+ if (!$dara77.isNull(request.authorization)) {
4109
+ body["Authorization"] = request.authorization;
4110
+ }
4111
+ if (!$dara77.isNull(request.contextId)) {
4112
+ body["ContextId"] = request.contextId;
4113
+ }
4114
+ if (!$dara77.isNull(request.filePath)) {
4115
+ body["FilePath"] = request.filePath;
4116
+ }
4117
+ const req = new _openapicore.$OpenApiUtil.OpenApiRequest({
4118
+ body: _openapicore.OpenApiUtil.parseToMap(body)
4119
+ });
4120
+ const params = new _openapicore.$OpenApiUtil.Params({
4121
+ action: "GetContextFileUploadUrl",
4122
+ version: "2025-05-06",
4123
+ protocol: "HTTPS",
4124
+ pathname: "/",
4125
+ method: "POST",
4126
+ authType: "Anonymous",
4127
+ style: "RPC",
4128
+ reqBodyType: "formData",
4129
+ bodyType: "json"
4130
+ });
4131
+ return $dara77.cast(
4132
+ await this.callApi(params, req, runtime),
4133
+ new GetContextFileUploadUrlResponse({})
4134
+ );
4135
+ }
4136
+ /**
4137
+ * 获取上传context文件url
4138
+ *
4139
+ * @param request - GetContextFileUploadUrlRequest
4140
+ * @returns GetContextFileUploadUrlResponse
4141
+ */
4142
+ async getContextFileUploadUrl(request) {
4143
+ const runtime = new $dara77.RuntimeOptions({});
4144
+ return await this.getContextFileUploadUrlWithOptions(request, runtime);
4145
+ }
3491
4146
  };
3492
4147
  __name(_Client, "Client");
3493
4148
  var Client = _Client;
@@ -3495,8 +4150,8 @@ var Client = _Client;
3495
4150
  // src/config.ts
3496
4151
  init_cjs_shims();
3497
4152
  var dotenv = __toESM(require_main());
3498
- var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
3499
- var _path = require('path'); var path = _interopRequireWildcard(_path);
4153
+ var _fs = require('fs'); var fs = _interopRequireWildcard(_fs); var fs2 = _interopRequireWildcard(_fs);
4154
+ var _path = require('path'); var path = _interopRequireWildcard(_path); var path2 = _interopRequireWildcard(_path);
3500
4155
 
3501
4156
  // src/utils/logger.ts
3502
4157
  init_cjs_shims();
@@ -3539,6 +4194,28 @@ function defaultConfig() {
3539
4194
  };
3540
4195
  }
3541
4196
  __name(defaultConfig, "defaultConfig");
4197
+ var dotEnvLoaded = false;
4198
+ function loadDotEnv() {
4199
+ if (dotEnvLoaded) {
4200
+ return;
4201
+ }
4202
+ try {
4203
+ const envPath = path.resolve(process.cwd(), ".env");
4204
+ if (fs.existsSync(envPath)) {
4205
+ const envConfig = dotenv.parse(fs.readFileSync(envPath));
4206
+ for (const k in envConfig) {
4207
+ if (!process.env.hasOwnProperty(k)) {
4208
+ process.env[k] = envConfig[k];
4209
+ }
4210
+ }
4211
+ log(`Loaded .env file at: ${envPath}`);
4212
+ dotEnvLoaded = true;
4213
+ }
4214
+ } catch (error) {
4215
+ log(`Warning: Failed to load .env file: ${error}`);
4216
+ }
4217
+ }
4218
+ __name(loadDotEnv, "loadDotEnv");
3542
4219
  function loadConfig(customConfig) {
3543
4220
  if (customConfig) {
3544
4221
  return customConfig;
@@ -3559,16 +4236,16 @@ function loadConfig(customConfig) {
3559
4236
  const envPath = path.resolve(process.cwd(), ".env");
3560
4237
  if (fs.existsSync(envPath)) {
3561
4238
  const envConfig = dotenv.parse(fs.readFileSync(envPath));
3562
- for (const k in envConfig) {
3563
- if (!process.env.hasOwnProperty(k)) {
3564
- if (k === "AGENTBAY_REGION_ID") config.region_id = envConfig[k];
3565
- else if (k === "AGENTBAY_ENDPOINT") config.endpoint = envConfig[k];
3566
- else if (k === "AGENTBAY_TIMEOUT_MS") {
3567
- const timeout = parseInt(envConfig[k], 10);
3568
- if (!isNaN(timeout) && timeout > 0) {
3569
- config.timeout_ms = timeout;
3570
- }
3571
- }
4239
+ if (!process.env.AGENTBAY_REGION_ID && envConfig.AGENTBAY_REGION_ID) {
4240
+ config.region_id = envConfig.AGENTBAY_REGION_ID;
4241
+ }
4242
+ if (!process.env.AGENTBAY_ENDPOINT && envConfig.AGENTBAY_ENDPOINT) {
4243
+ config.endpoint = envConfig.AGENTBAY_ENDPOINT;
4244
+ }
4245
+ if (!process.env.AGENTBAY_TIMEOUT_MS && envConfig.AGENTBAY_TIMEOUT_MS) {
4246
+ const timeout = parseInt(envConfig.AGENTBAY_TIMEOUT_MS, 10);
4247
+ if (!isNaN(timeout) && timeout > 0) {
4248
+ config.timeout_ms = timeout;
3572
4249
  }
3573
4250
  }
3574
4251
  log(`Loaded .env file at: ${envPath}`);
@@ -3815,6 +4492,112 @@ var _ContextService = class _ContextService {
3815
4492
  };
3816
4493
  }
3817
4494
  }
4495
+ /**
4496
+ * Get a presigned upload URL for a file in a context.
4497
+ */
4498
+ async getFileUploadUrl(contextId, filePath) {
4499
+ log("API Call: GetContextFileUploadUrl");
4500
+ log(`Request: ContextId=${contextId}, FilePath=${filePath}`);
4501
+ const req = new GetContextFileUploadUrlRequest({
4502
+ authorization: `Bearer ${this.agentBay.getAPIKey()}`,
4503
+ contextId,
4504
+ filePath
4505
+ });
4506
+ const resp = await this.agentBay.getClient().getContextFileUploadUrl(req);
4507
+ log("Response from GetContextFileUploadUrl:", resp.body);
4508
+ const requestId = extractRequestId(resp) || "";
4509
+ const body = resp.body;
4510
+ const data = _optionalChain([body, 'optionalAccess', _23 => _23.data]);
4511
+ return {
4512
+ requestId,
4513
+ success: !!(body && body.success),
4514
+ url: _optionalChain([data, 'optionalAccess', _24 => _24.url]) || "",
4515
+ expireTime: _optionalChain([data, 'optionalAccess', _25 => _25.expireTime])
4516
+ };
4517
+ }
4518
+ /**
4519
+ * Get a presigned download URL for a file in a context.
4520
+ */
4521
+ async getFileDownloadUrl(contextId, filePath) {
4522
+ log("API Call: GetContextFileDownloadUrl");
4523
+ log(`Request: ContextId=${contextId}, FilePath=${filePath}`);
4524
+ const req = new GetContextFileDownloadUrlRequest({
4525
+ authorization: `Bearer ${this.agentBay.getAPIKey()}`,
4526
+ contextId,
4527
+ filePath
4528
+ });
4529
+ const resp = await this.agentBay.getClient().getContextFileDownloadUrl(req);
4530
+ log("Response from GetContextFileDownloadUrl:", resp.body);
4531
+ const requestId = extractRequestId(resp) || "";
4532
+ const body = resp.body;
4533
+ const data = _optionalChain([body, 'optionalAccess', _26 => _26.data]);
4534
+ return {
4535
+ requestId,
4536
+ success: !!(body && body.success),
4537
+ url: _optionalChain([data, 'optionalAccess', _27 => _27.url]) || "",
4538
+ expireTime: _optionalChain([data, 'optionalAccess', _28 => _28.expireTime])
4539
+ };
4540
+ }
4541
+ /**
4542
+ * Delete a file in a context.
4543
+ */
4544
+ async deleteFile(contextId, filePath) {
4545
+ log("API Call: DeleteContextFile");
4546
+ log(`Request: ContextId=${contextId}, FilePath=${filePath}`);
4547
+ const req = new DeleteContextFileRequest({
4548
+ authorization: `Bearer ${this.agentBay.getAPIKey()}`,
4549
+ contextId,
4550
+ filePath
4551
+ });
4552
+ const resp = await this.agentBay.getClient().deleteContextFile(req);
4553
+ log("Response from DeleteContextFile:", resp.body);
4554
+ const requestId = extractRequestId(resp) || "";
4555
+ const body = resp.body;
4556
+ const success = !!(body && body.success);
4557
+ return {
4558
+ requestId,
4559
+ success,
4560
+ data: success,
4561
+ errorMessage: success ? "" : `Delete failed: ${_optionalChain([body, 'optionalAccess', _29 => _29.code]) || ""}`
4562
+ };
4563
+ }
4564
+ /**
4565
+ * List files under a specific folder path in a context.
4566
+ */
4567
+ async listFiles(contextId, parentFolderPath, pageNumber = 1, pageSize = 50) {
4568
+ log("API Call: DescribeContextFiles");
4569
+ log(
4570
+ `Request: ContextId=${contextId}, ParentFolderPath=${parentFolderPath}, PageNumber=${pageNumber}, PageSize=${pageSize}`
4571
+ );
4572
+ const req = new DescribeContextFilesRequest({
4573
+ authorization: `Bearer ${this.agentBay.getAPIKey()}`,
4574
+ pageNumber,
4575
+ pageSize,
4576
+ parentFolderPath,
4577
+ contextId
4578
+ });
4579
+ const resp = await this.agentBay.getClient().describeContextFiles(req);
4580
+ log("Response from DescribeContextFiles:", resp.body);
4581
+ const requestId = extractRequestId(resp) || "";
4582
+ const body = resp.body;
4583
+ const rawList = _optionalChain([body, 'optionalAccess', _30 => _30.data]) || [];
4584
+ const entries = rawList.map((it) => ({
4585
+ fileId: it.fileId,
4586
+ fileName: it.fileName,
4587
+ filePath: it.filePath || "",
4588
+ fileType: it.fileType,
4589
+ gmtCreate: it.gmtCreate,
4590
+ gmtModified: it.gmtModified,
4591
+ size: it.size,
4592
+ status: it.status
4593
+ }));
4594
+ return {
4595
+ requestId,
4596
+ success: !!(body && body.success),
4597
+ entries,
4598
+ count: _optionalChain([body, 'optionalAccess', _31 => _31.count])
4599
+ };
4600
+ }
3818
4601
  };
3819
4602
  __name(_ContextService, "ContextService");
3820
4603
  var ContextService = _ContextService;
@@ -4553,7 +5336,7 @@ var _ContextManager = class _ContextManager {
4553
5336
  async info() {
4554
5337
  return this.infoWithParams();
4555
5338
  }
4556
- async infoWithParams(contextId, path2, taskType) {
5339
+ async infoWithParams(contextId, path3, taskType) {
4557
5340
  const request = new GetContextInfoRequest({
4558
5341
  authorization: `Bearer ${this.session.getAPIKey()}`,
4559
5342
  sessionId: this.session.getSessionId()
@@ -4561,8 +5344,8 @@ var _ContextManager = class _ContextManager {
4561
5344
  if (contextId) {
4562
5345
  request.contextId = contextId;
4563
5346
  }
4564
- if (path2) {
4565
- request.path = path2;
5347
+ if (path3) {
5348
+ request.path = path3;
4566
5349
  }
4567
5350
  if (taskType) {
4568
5351
  request.taskType = taskType;
@@ -4582,11 +5365,11 @@ var _ContextManager = class _ContextManager {
4582
5365
  try {
4583
5366
  const response = await this.session.getClient().getContextInfo(request);
4584
5367
  const requestId = extractRequestId(response) || "";
4585
- if (_optionalChain([response, 'optionalAccess', _23 => _23.body])) {
5368
+ if (_optionalChain([response, 'optionalAccess', _32 => _32.body])) {
4586
5369
  log("Response from GetContextInfo:", response.body);
4587
5370
  }
4588
5371
  const contextStatusData = [];
4589
- if (_optionalChain([response, 'optionalAccess', _24 => _24.body, 'optionalAccess', _25 => _25.data, 'optionalAccess', _26 => _26.contextStatus])) {
5372
+ if (_optionalChain([response, 'optionalAccess', _33 => _33.body, 'optionalAccess', _34 => _34.data, 'optionalAccess', _35 => _35.contextStatus])) {
4590
5373
  try {
4591
5374
  const contextStatusStr = response.body.data.contextStatus;
4592
5375
  const statusItems = JSON.parse(contextStatusStr);
@@ -4612,7 +5395,7 @@ var _ContextManager = class _ContextManager {
4612
5395
  async sync() {
4613
5396
  return this.syncWithParams();
4614
5397
  }
4615
- async syncWithParams(contextId, path2, mode) {
5398
+ async syncWithParams(contextId, path3, mode) {
4616
5399
  const request = new SyncContextRequest({
4617
5400
  authorization: `Bearer ${this.session.getAPIKey()}`,
4618
5401
  sessionId: this.session.getSessionId()
@@ -4620,8 +5403,8 @@ var _ContextManager = class _ContextManager {
4620
5403
  if (contextId) {
4621
5404
  request.contextId = contextId;
4622
5405
  }
4623
- if (path2) {
4624
- request.path = path2;
5406
+ if (path3) {
5407
+ request.path = path3;
4625
5408
  }
4626
5409
  if (mode) {
4627
5410
  request.mode = mode;
@@ -4641,11 +5424,11 @@ var _ContextManager = class _ContextManager {
4641
5424
  try {
4642
5425
  const response = await this.session.getClient().syncContext(request);
4643
5426
  const requestId = extractRequestId(response) || "";
4644
- if (_optionalChain([response, 'optionalAccess', _27 => _27.body])) {
5427
+ if (_optionalChain([response, 'optionalAccess', _36 => _36.body])) {
4645
5428
  log("Response from SyncContext:", response.body);
4646
5429
  }
4647
5430
  let success = false;
4648
- if (_optionalChain([response, 'optionalAccess', _28 => _28.body, 'optionalAccess', _29 => _29.success]) !== void 0) {
5431
+ if (_optionalChain([response, 'optionalAccess', _37 => _37.body, 'optionalAccess', _38 => _38.success]) !== void 0) {
4649
5432
  success = response.body.success;
4650
5433
  }
4651
5434
  return {
@@ -4751,10 +5534,10 @@ var _FileSystem = class _FileSystem {
4751
5534
  * @param path - Path to the directory to create.
4752
5535
  * @returns BoolResult with creation result and requestId
4753
5536
  */
4754
- async createDirectory(path2) {
5537
+ async createDirectory(path3) {
4755
5538
  try {
4756
5539
  const args = {
4757
- path: path2
5540
+ path: path3
4758
5541
  };
4759
5542
  const result = await this.session.callMcpTool(
4760
5543
  "create_directory",
@@ -4789,10 +5572,10 @@ var _FileSystem = class _FileSystem {
4789
5572
  * @param dryRun - Optional: If true, preview changes without applying them.
4790
5573
  * @returns BoolResult with edit result and requestId
4791
5574
  */
4792
- async editFile(path2, edits, dryRun = false) {
5575
+ async editFile(path3, edits, dryRun = false) {
4793
5576
  try {
4794
5577
  const args = {
4795
- path: path2,
5578
+ path: path3,
4796
5579
  edits,
4797
5580
  dryRun
4798
5581
  };
@@ -4827,10 +5610,10 @@ var _FileSystem = class _FileSystem {
4827
5610
  * @param path - Path to the file or directory to inspect.
4828
5611
  * @returns FileInfoResult with file info and requestId
4829
5612
  */
4830
- async getFileInfo(path2) {
5613
+ async getFileInfo(path3) {
4831
5614
  try {
4832
5615
  const args = {
4833
- path: path2
5616
+ path: path3
4834
5617
  };
4835
5618
  const result = await this.session.callMcpTool(
4836
5619
  "get_file_info",
@@ -4873,10 +5656,10 @@ var _FileSystem = class _FileSystem {
4873
5656
  * @param path - Path to the directory to list.
4874
5657
  * @returns DirectoryListResult with directory entries and requestId
4875
5658
  */
4876
- async listDirectory(path2) {
5659
+ async listDirectory(path3) {
4877
5660
  try {
4878
5661
  const args = {
4879
- path: path2
5662
+ path: path3
4880
5663
  };
4881
5664
  const result = await this.session.callMcpTool(
4882
5665
  "list_directory",
@@ -4944,18 +5727,17 @@ var _FileSystem = class _FileSystem {
4944
5727
  }
4945
5728
  }
4946
5729
  /**
4947
- * Reads the content of a file.
4948
- * Corresponds to Python's read_file() method
5730
+ * Internal method to read a file chunk. Used for chunked file operations.
4949
5731
  *
4950
5732
  * @param path - Path to the file to read.
4951
5733
  * @param offset - Optional: Byte offset to start reading from (0-based).
4952
5734
  * @param length - Optional: Number of bytes to read. If 0, reads the entire file from offset.
4953
5735
  * @returns FileContentResult with file content and requestId
4954
5736
  */
4955
- async readFile(path2, offset = 0, length = 0) {
5737
+ async readFileChunk(path3, offset = 0, length = 0) {
4956
5738
  try {
4957
5739
  const args = {
4958
- path: path2
5740
+ path: path3
4959
5741
  };
4960
5742
  if (offset > 0) {
4961
5743
  args.offset = offset;
@@ -5021,8 +5803,8 @@ var _FileSystem = class _FileSystem {
5021
5803
  for (const line of lines) {
5022
5804
  const colonIndex = line.indexOf(":");
5023
5805
  if (colonIndex > 0 && currentPath === "" && !line.substring(0, colonIndex).includes(" ")) {
5024
- const path2 = line.substring(0, colonIndex).trim();
5025
- currentPath = path2;
5806
+ const path3 = line.substring(0, colonIndex).trim();
5807
+ currentPath = path3;
5026
5808
  if (line.length > colonIndex + 1) {
5027
5809
  const contentStart = line.substring(colonIndex + 1).trim();
5028
5810
  if (contentStart) {
@@ -5042,8 +5824,8 @@ var _FileSystem = class _FileSystem {
5042
5824
  if (currentPath) {
5043
5825
  fileContents[currentPath] = currentContent.join("\n");
5044
5826
  }
5045
- for (const path2 in fileContents) {
5046
- fileContents[path2] = fileContents[path2].replace(/\n+$/, "");
5827
+ for (const path3 in fileContents) {
5828
+ fileContents[path3] = fileContents[path3].replace(/\n+$/, "");
5047
5829
  }
5048
5830
  }
5049
5831
  return {
@@ -5069,10 +5851,10 @@ var _FileSystem = class _FileSystem {
5069
5851
  * @param excludePatterns - Optional: Array of patterns to exclude.
5070
5852
  * @returns FileSearchResult with search results and requestId
5071
5853
  */
5072
- async searchFiles(path2, pattern, excludePatterns = []) {
5854
+ async searchFiles(path3, pattern, excludePatterns = []) {
5073
5855
  try {
5074
5856
  const args = {
5075
- path: path2,
5857
+ path: path3,
5076
5858
  pattern
5077
5859
  };
5078
5860
  if (excludePatterns.length > 0) {
@@ -5109,15 +5891,14 @@ var _FileSystem = class _FileSystem {
5109
5891
  }
5110
5892
  }
5111
5893
  /**
5112
- * Writes content to a file.
5113
- * Corresponds to Python's write_file() method
5894
+ * Internal method to write a file chunk. Used for chunked file operations.
5114
5895
  *
5115
5896
  * @param path - Path to the file to write.
5116
5897
  * @param content - Content to write to the file.
5117
5898
  * @param mode - Optional: Write mode. One of "overwrite", "append", or "create_new". Default is "overwrite".
5118
5899
  * @returns BoolResult with write result and requestId
5119
5900
  */
5120
- async writeFile(path2, content, mode = "overwrite") {
5901
+ async writeFileChunk(path3, content, mode = "overwrite") {
5121
5902
  try {
5122
5903
  const validModes = ["overwrite", "append", "create_new"];
5123
5904
  if (!validModes.includes(mode)) {
@@ -5130,7 +5911,7 @@ var _FileSystem = class _FileSystem {
5130
5911
  };
5131
5912
  }
5132
5913
  const args = {
5133
- path: path2,
5914
+ path: path3,
5134
5915
  content,
5135
5916
  mode
5136
5917
  };
@@ -5159,16 +5940,15 @@ var _FileSystem = class _FileSystem {
5159
5940
  }
5160
5941
  }
5161
5942
  /**
5162
- * Reads a large file in chunks to handle size limitations of the underlying API.
5163
- * Corresponds to Python's read_large_file() method
5943
+ * Reads the contents of a file. Automatically handles large files by chunking.
5164
5944
  *
5165
5945
  * @param path - Path to the file to read.
5166
- * @param chunkSize - Optional: Size of each chunk in bytes. Default is 60KB.
5167
5946
  * @returns FileContentResult with complete file content and requestId
5168
5947
  */
5169
- async readLargeFile(path2, chunkSize = DEFAULT_CHUNK_SIZE) {
5948
+ async readFile(path3) {
5949
+ const chunkSize = DEFAULT_CHUNK_SIZE;
5170
5950
  try {
5171
- const fileInfoResult = await this.getFileInfo(path2);
5951
+ const fileInfoResult = await this.getFileInfo(path3);
5172
5952
  if (!fileInfoResult.success) {
5173
5953
  return {
5174
5954
  requestId: fileInfoResult.requestId,
@@ -5182,7 +5962,7 @@ var _FileSystem = class _FileSystem {
5182
5962
  requestId: fileInfoResult.requestId,
5183
5963
  success: false,
5184
5964
  content: "",
5185
- errorMessage: `Path does not exist or is a directory: ${path2}`
5965
+ errorMessage: `Path does not exist or is a directory: ${path3}`
5186
5966
  };
5187
5967
  }
5188
5968
  const fileSize = fileInfoResult.fileInfo.size || 0;
@@ -5202,7 +5982,7 @@ var _FileSystem = class _FileSystem {
5202
5982
  length = fileSize - offset;
5203
5983
  }
5204
5984
  try {
5205
- const chunkResult = await this.readFile(path2, offset, length);
5985
+ const chunkResult = await this.readFileChunk(path3, offset, length);
5206
5986
  if (!chunkResult.success) {
5207
5987
  return chunkResult;
5208
5988
  }
@@ -5233,25 +6013,25 @@ var _FileSystem = class _FileSystem {
5233
6013
  }
5234
6014
  }
5235
6015
  /**
5236
- * Writes a large file in chunks to handle size limitations of the underlying API.
5237
- * Corresponds to Python's write_large_file() method
6016
+ * Writes content to a file. Automatically handles large files by chunking.
5238
6017
  *
5239
6018
  * @param path - Path to the file to write.
5240
6019
  * @param content - Content to write to the file.
5241
- * @param chunkSize - Optional: Size of each chunk in bytes. Default is 60KB.
6020
+ * @param mode - Optional: Write mode. One of "overwrite", "append", or "create_new". Default is "overwrite".
5242
6021
  * @returns BoolResult indicating success or failure with requestId
5243
6022
  */
5244
- async writeLargeFile(path2, content, chunkSize = DEFAULT_CHUNK_SIZE) {
6023
+ async writeFile(path3, content, mode = "overwrite") {
6024
+ const chunkSize = DEFAULT_CHUNK_SIZE;
5245
6025
  try {
5246
6026
  const contentLen = content.length;
5247
6027
  if (contentLen <= chunkSize) {
5248
- return await this.writeFile(path2, content, "overwrite");
6028
+ return await this.writeFileChunk(path3, content, mode);
5249
6029
  }
5250
6030
  const firstChunkEnd = Math.min(chunkSize, contentLen);
5251
- const firstResult = await this.writeFile(
5252
- path2,
6031
+ const firstResult = await this.writeFileChunk(
6032
+ path3,
5253
6033
  content.substring(0, firstChunkEnd),
5254
- "overwrite"
6034
+ mode
5255
6035
  );
5256
6036
  if (!firstResult.success) {
5257
6037
  return firstResult;
@@ -5259,8 +6039,8 @@ var _FileSystem = class _FileSystem {
5259
6039
  let chunkCount = 1;
5260
6040
  for (let offset = firstChunkEnd; offset < contentLen; ) {
5261
6041
  const end = Math.min(offset + chunkSize, contentLen);
5262
- const chunkResult = await this.writeFile(
5263
- path2,
6042
+ const chunkResult = await this.writeFileChunk(
6043
+ path3,
5264
6044
  content.substring(offset, end),
5265
6045
  "append"
5266
6046
  );
@@ -5380,12 +6160,12 @@ var _Oss = class _Oss {
5380
6160
  * @returns OSSUploadResult with upload result and requestId
5381
6161
  * @throws APIError if the operation fails.
5382
6162
  */
5383
- async upload(bucket, object, path2) {
6163
+ async upload(bucket, object, path3) {
5384
6164
  try {
5385
6165
  const args = {
5386
6166
  bucket,
5387
6167
  object,
5388
- path: path2
6168
+ path: path3
5389
6169
  };
5390
6170
  const result = await this.session.callMcpTool("oss_upload", args);
5391
6171
  return {
@@ -5412,11 +6192,11 @@ var _Oss = class _Oss {
5412
6192
  * @returns OSSUploadResult with upload result and requestId
5413
6193
  * @throws APIError if the operation fails.
5414
6194
  */
5415
- async uploadAnonymous(url, path2) {
6195
+ async uploadAnonymous(url, path3) {
5416
6196
  try {
5417
6197
  const args = {
5418
6198
  url,
5419
- path: path2
6199
+ path: path3
5420
6200
  };
5421
6201
  const result = await this.session.callMcpTool("oss_upload_anonymous", args);
5422
6202
  return {
@@ -5444,12 +6224,12 @@ var _Oss = class _Oss {
5444
6224
  * @returns OSSDownloadResult with download result and requestId
5445
6225
  * @throws APIError if the operation fails.
5446
6226
  */
5447
- async download(bucket, object, path2) {
6227
+ async download(bucket, object, path3) {
5448
6228
  try {
5449
6229
  const args = {
5450
6230
  bucket,
5451
6231
  object,
5452
- path: path2
6232
+ path: path3
5453
6233
  };
5454
6234
  const result = await this.session.callMcpTool("oss_download", args);
5455
6235
  return {
@@ -5476,11 +6256,11 @@ var _Oss = class _Oss {
5476
6256
  * @returns OSSDownloadResult with download result and requestId
5477
6257
  * @throws APIError if the operation fails.
5478
6258
  */
5479
- async downloadAnonymous(url, path2) {
6259
+ async downloadAnonymous(url, path3) {
5480
6260
  try {
5481
6261
  const args = {
5482
6262
  url,
5483
- path: path2
6263
+ path: path3
5484
6264
  };
5485
6265
  const result = await this.session.callMcpTool("oss_download_anonymous", args);
5486
6266
  return {
@@ -6227,7 +7007,7 @@ var _BrowserAgent = class _BrowserAgent {
6227
7007
  throw new BrowserError("Browser must be initialized before calling act.");
6228
7008
  }
6229
7009
  try {
6230
- const [pageIndex, contextIndex] = this._getPageAndContextIndex(page);
7010
+ const [pageIndex, contextIndex] = await this._getPageAndContextIndexAsync(page);
6231
7011
  log(`Acting on page: ${page}, pageIndex: ${pageIndex}, contextIndex: ${contextIndex}`);
6232
7012
  const args = {
6233
7013
  context_id: contextIndex,
@@ -6278,7 +7058,7 @@ var _BrowserAgent = class _BrowserAgent {
6278
7058
  throw new BrowserError("Browser must be initialized before calling observe.");
6279
7059
  }
6280
7060
  try {
6281
- const [pageIndex, contextIndex] = this._getPageAndContextIndex(page);
7061
+ const [pageIndex, contextIndex] = await this._getPageAndContextIndexAsync(page);
6282
7062
  log(`Observing page: ${page}, pageIndex: ${pageIndex}, contextIndex: ${contextIndex}`);
6283
7063
  const args = {
6284
7064
  context_id: contextIndex,
@@ -6341,7 +7121,7 @@ var _BrowserAgent = class _BrowserAgent {
6341
7121
  throw new BrowserError("Browser must be initialized before calling extract.");
6342
7122
  }
6343
7123
  try {
6344
- const [pageIndex, contextIndex] = this._getPageAndContextIndex(page);
7124
+ const [pageIndex, contextIndex] = await this._getPageAndContextIndexAsync(page);
6345
7125
  const tempInstance = new options.schema();
6346
7126
  const schema = tempInstance.constructor.name;
6347
7127
  const args = {
@@ -6417,12 +7197,35 @@ var _BrowserAgent = class _BrowserAgent {
6417
7197
  throw new BrowserError("Page is null");
6418
7198
  }
6419
7199
  try {
6420
- const pageIndex = "default-page-id";
6421
- const contextIndex = 0;
6422
- return [pageIndex, contextIndex];
7200
+ if (page.context && typeof page.context === "function") {
7201
+ const context = page.context();
7202
+ if (context && typeof context.newCDPSession === "function") {
7203
+ const cdpSession = await context.newCDPSession(page);
7204
+ const targetInfo = await cdpSession.send("Target.getTargetInfo");
7205
+ const pageIndex2 = targetInfo && targetInfo.targetInfo && targetInfo.targetInfo.targetId ? targetInfo.targetInfo.targetId : "default-page-id";
7206
+ if (typeof cdpSession.detach === "function") {
7207
+ await cdpSession.detach();
7208
+ }
7209
+ let contextIndex2 = 0;
7210
+ if (typeof context.browser === "function") {
7211
+ const browserObj = context.browser();
7212
+ if (browserObj && typeof browserObj.contexts === "function") {
7213
+ const contexts = browserObj.contexts();
7214
+ const idx = contexts.indexOf(context);
7215
+ if (idx >= 0) {
7216
+ contextIndex2 = idx;
7217
+ }
7218
+ }
7219
+ }
7220
+ return [pageIndex2, contextIndex2];
7221
+ }
7222
+ }
6423
7223
  } catch (error) {
6424
- throw new BrowserError(`Failed to get page/context index: ${error}`);
7224
+ log(`CDP targetId retrieval failed, fallback to defaults: ${error}`);
6425
7225
  }
7226
+ const pageIndex = "default-page-id";
7227
+ const contextIndex = 0;
7228
+ return [pageIndex, contextIndex];
6426
7229
  }
6427
7230
  async _callMcpTool(toolName, args) {
6428
7231
  return this.session.callMcpTool(toolName, args);
@@ -6432,6 +7235,174 @@ __name(_BrowserAgent, "BrowserAgent");
6432
7235
  var BrowserAgent = _BrowserAgent;
6433
7236
 
6434
7237
  // src/browser/browser.ts
7238
+ var _BrowserProxyClass = class _BrowserProxyClass {
7239
+ constructor(proxyType, server, username, password, strategy, pollsize) {
7240
+ this.type = proxyType;
7241
+ this.server = server;
7242
+ this.username = username;
7243
+ this.password = password;
7244
+ this.strategy = strategy;
7245
+ this.pollsize = pollsize;
7246
+ if (proxyType !== "custom" && proxyType !== "wuying") {
7247
+ throw new Error("proxy_type must be custom or wuying");
7248
+ }
7249
+ if (proxyType === "custom" && !server) {
7250
+ throw new Error("server is required for custom proxy type");
7251
+ }
7252
+ if (proxyType === "wuying" && !strategy) {
7253
+ throw new Error("strategy is required for wuying proxy type");
7254
+ }
7255
+ if (proxyType === "wuying" && strategy !== "restricted" && strategy !== "polling") {
7256
+ throw new Error("strategy must be restricted or polling for wuying proxy type");
7257
+ }
7258
+ if (proxyType === "wuying" && strategy === "polling" && pollsize !== void 0 && pollsize <= 0) {
7259
+ throw new Error("pollsize must be greater than 0 for polling strategy");
7260
+ }
7261
+ }
7262
+ toMap() {
7263
+ const proxyMap = {
7264
+ type: this.type
7265
+ };
7266
+ if (this.type === "custom") {
7267
+ proxyMap.server = this.server;
7268
+ if (this.username) {
7269
+ proxyMap.username = this.username;
7270
+ }
7271
+ if (this.password) {
7272
+ proxyMap.password = this.password;
7273
+ }
7274
+ } else if (this.type === "wuying") {
7275
+ proxyMap.strategy = this.strategy;
7276
+ if (this.strategy === "polling") {
7277
+ proxyMap.pollsize = this.pollsize;
7278
+ }
7279
+ }
7280
+ return proxyMap;
7281
+ }
7282
+ static fromMap(m) {
7283
+ if (!m || typeof m !== "object") {
7284
+ return null;
7285
+ }
7286
+ const proxyType = m.type;
7287
+ if (!proxyType) {
7288
+ return null;
7289
+ }
7290
+ if (proxyType === "custom") {
7291
+ return new _BrowserProxyClass(
7292
+ proxyType,
7293
+ m.server,
7294
+ m.username,
7295
+ m.password
7296
+ );
7297
+ } else if (proxyType === "wuying") {
7298
+ return new _BrowserProxyClass(
7299
+ proxyType,
7300
+ void 0,
7301
+ void 0,
7302
+ void 0,
7303
+ m.strategy,
7304
+ m.pollsize || 10
7305
+ );
7306
+ } else {
7307
+ throw new Error(`Unsupported proxy type: ${proxyType}`);
7308
+ }
7309
+ }
7310
+ };
7311
+ __name(_BrowserProxyClass, "BrowserProxyClass");
7312
+ var BrowserProxyClass = _BrowserProxyClass;
7313
+ var _BrowserOptionClass = class _BrowserOptionClass {
7314
+ constructor(useStealth = false, userAgent, viewport, screen, fingerprint, proxies) {
7315
+ this.useStealth = useStealth;
7316
+ this.userAgent = userAgent;
7317
+ this.viewport = viewport;
7318
+ this.screen = screen;
7319
+ this.fingerprint = fingerprint;
7320
+ this.proxies = proxies;
7321
+ this.extensionPath = "/tmp/extensions/";
7322
+ if (proxies !== void 0) {
7323
+ if (!Array.isArray(proxies)) {
7324
+ throw new Error("proxies must be a list");
7325
+ }
7326
+ if (proxies.length > 1) {
7327
+ throw new Error("proxies list length must be limited to 1");
7328
+ }
7329
+ }
7330
+ }
7331
+ toMap() {
7332
+ const optionMap = {};
7333
+ if (process.env.AGENTBAY_BROWSER_BEHAVIOR_SIMULATE) {
7334
+ optionMap["behaviorSimulate"] = process.env.AGENTBAY_BROWSER_BEHAVIOR_SIMULATE !== "0";
7335
+ }
7336
+ if (this.useStealth !== void 0) {
7337
+ optionMap["useStealth"] = this.useStealth;
7338
+ }
7339
+ if (this.userAgent !== void 0) {
7340
+ optionMap["userAgent"] = this.userAgent;
7341
+ }
7342
+ if (this.viewport !== void 0) {
7343
+ optionMap["viewport"] = { width: this.viewport.width, height: this.viewport.height };
7344
+ }
7345
+ if (this.screen !== void 0) {
7346
+ optionMap["screen"] = { width: this.screen.width, height: this.screen.height };
7347
+ }
7348
+ if (this.fingerprint !== void 0) {
7349
+ const fp = {};
7350
+ if (this.fingerprint.devices) fp["devices"] = this.fingerprint.devices;
7351
+ if (this.fingerprint.operatingSystems) fp["operatingSystems"] = this.fingerprint.operatingSystems;
7352
+ if (this.fingerprint.locales) fp["locales"] = this.fingerprint.locales;
7353
+ optionMap["fingerprint"] = fp;
7354
+ }
7355
+ if (this.proxies !== void 0) {
7356
+ optionMap["proxies"] = this.proxies.map((proxy) => proxy.toMap());
7357
+ }
7358
+ if (this.extensionPath !== void 0) {
7359
+ optionMap["extensionPath"] = this.extensionPath;
7360
+ }
7361
+ return optionMap;
7362
+ }
7363
+ fromMap(m) {
7364
+ const map = m || {};
7365
+ if (map.useStealth !== void 0) {
7366
+ this.useStealth = map.useStealth;
7367
+ } else {
7368
+ this.useStealth = false;
7369
+ }
7370
+ if (map.userAgent !== void 0) {
7371
+ this.userAgent = map.userAgent;
7372
+ }
7373
+ if (map.viewport !== void 0) {
7374
+ this.viewport = { width: map.viewport.width, height: map.viewport.height };
7375
+ }
7376
+ if (map.screen !== void 0) {
7377
+ this.screen = { width: map.screen.width, height: map.screen.height };
7378
+ }
7379
+ if (map.fingerprint !== void 0) {
7380
+ const fp = {};
7381
+ if (map.fingerprint.devices) fp.devices = map.fingerprint.devices;
7382
+ if (map.fingerprint.operatingSystems) fp.operatingSystems = map.fingerprint.operatingSystems;
7383
+ if (map.fingerprint.locales) fp.locales = map.fingerprint.locales;
7384
+ this.fingerprint = fp;
7385
+ }
7386
+ if (map.proxies !== void 0) {
7387
+ const proxyList = map.proxies;
7388
+ if (proxyList.length > 1) {
7389
+ throw new Error("proxies list length must be limited to 1");
7390
+ }
7391
+ this.proxies = proxyList.map((proxyData) => {
7392
+ if (proxyData instanceof BrowserProxyClass) {
7393
+ return proxyData;
7394
+ }
7395
+ return BrowserProxyClass.fromMap(proxyData);
7396
+ }).filter(Boolean);
7397
+ }
7398
+ if (map.extensionPath !== void 0) {
7399
+ this.extensionPath = map.extensionPath;
7400
+ }
7401
+ return this;
7402
+ }
7403
+ };
7404
+ __name(_BrowserOptionClass, "BrowserOptionClass");
7405
+ var BrowserOptionClass = _BrowserOptionClass;
6435
7406
  var _Browser = class _Browser {
6436
7407
  constructor(session) {
6437
7408
  this._endpointUrl = null;
@@ -6453,12 +7424,23 @@ var _Browser = class _Browser {
6453
7424
  request.authorization = `Bearer ${this.session.getAPIKey()}`;
6454
7425
  request.persistentPath = BROWSER_DATA_PATH;
6455
7426
  request.sessionId = this.session.getSessionId();
7427
+ let browserOption;
7428
+ if (option instanceof BrowserOptionClass) {
7429
+ browserOption = option;
7430
+ } else {
7431
+ browserOption = new BrowserOptionClass();
7432
+ browserOption.fromMap(option);
7433
+ }
7434
+ const browserOptionMap = browserOption.toMap();
7435
+ if (Object.keys(browserOptionMap).length > 0) {
7436
+ request.browserOption = browserOptionMap;
7437
+ }
6456
7438
  const response = this.session.getClient().initBrowserSync(request);
6457
- log(`Response from init_browser data:`, _optionalChain([response, 'access', _30 => _30.body, 'optionalAccess', _31 => _31.data]));
6458
- const success = _optionalChain([response, 'access', _32 => _32.body, 'optionalAccess', _33 => _33.data, 'optionalAccess', _34 => _34.port]) !== null && _optionalChain([response, 'access', _35 => _35.body, 'optionalAccess', _36 => _36.data, 'optionalAccess', _37 => _37.port]) !== void 0;
7439
+ log(`Response from init_browser data:`, _optionalChain([response, 'access', _39 => _39.body, 'optionalAccess', _40 => _40.data]));
7440
+ const success = _optionalChain([response, 'access', _41 => _41.body, 'optionalAccess', _42 => _42.data, 'optionalAccess', _43 => _43.port]) !== null && _optionalChain([response, 'access', _44 => _44.body, 'optionalAccess', _45 => _45.data, 'optionalAccess', _46 => _46.port]) !== void 0;
6459
7441
  if (success) {
6460
7442
  this._initialized = true;
6461
- this._option = option;
7443
+ this._option = browserOption;
6462
7444
  log("Browser instance was successfully initialized.");
6463
7445
  }
6464
7446
  return success;
@@ -6483,12 +7465,23 @@ var _Browser = class _Browser {
6483
7465
  request.authorization = `Bearer ${this.session.getAPIKey()}`;
6484
7466
  request.persistentPath = BROWSER_DATA_PATH;
6485
7467
  request.sessionId = this.session.getSessionId();
7468
+ let browserOption;
7469
+ if (option instanceof BrowserOptionClass) {
7470
+ browserOption = option;
7471
+ } else {
7472
+ browserOption = new BrowserOptionClass();
7473
+ browserOption.fromMap(option);
7474
+ }
7475
+ const browserOptionMap = browserOption.toMap();
7476
+ if (Object.keys(browserOptionMap).length > 0) {
7477
+ request.browserOption = browserOptionMap;
7478
+ }
6486
7479
  const response = await this.session.getClient().initBrowser(request);
6487
- log(`Response from init_browser data:`, _optionalChain([response, 'access', _38 => _38.body, 'optionalAccess', _39 => _39.data]));
6488
- const success = _optionalChain([response, 'access', _40 => _40.body, 'optionalAccess', _41 => _41.data, 'optionalAccess', _42 => _42.port]) !== null && _optionalChain([response, 'access', _43 => _43.body, 'optionalAccess', _44 => _44.data, 'optionalAccess', _45 => _45.port]) !== void 0;
7480
+ log(`Response from init_browser data:`, _optionalChain([response, 'access', _47 => _47.body, 'optionalAccess', _48 => _48.data]));
7481
+ const success = _optionalChain([response, 'access', _49 => _49.body, 'optionalAccess', _50 => _50.data, 'optionalAccess', _51 => _51.port]) !== null && _optionalChain([response, 'access', _52 => _52.body, 'optionalAccess', _53 => _53.data, 'optionalAccess', _54 => _54.port]) !== void 0;
6489
7482
  if (success) {
6490
7483
  this._initialized = true;
6491
- this._option = option;
7484
+ this._option = browserOption;
6492
7485
  log("Browser instance successfully initialized");
6493
7486
  }
6494
7487
  return success;
@@ -6528,6 +7521,16 @@ var _Browser = class _Browser {
6528
7521
  isInitialized() {
6529
7522
  return this._initialized;
6530
7523
  }
7524
+ /**
7525
+ * Stop the browser instance, internal use only.
7526
+ */
7527
+ _stopBrowser() {
7528
+ if (this.isInitialized()) {
7529
+ this.session.callMcpTool("stopChrome", {});
7530
+ } else {
7531
+ throw new BrowserError("Browser is not initialized. Cannot stop browser.");
7532
+ }
7533
+ }
6531
7534
  };
6532
7535
  __name(_Browser, "Browser");
6533
7536
  var Browser = _Browser;
@@ -6555,7 +7558,6 @@ var _Session = class _Session {
6555
7558
  * @param sessionId - The ID of this session.
6556
7559
  */
6557
7560
  constructor(agentBay, sessionId) {
6558
- this.resourceUrl = "";
6559
7561
  // VPC-related information
6560
7562
  this.isVpc = false;
6561
7563
  // Whether this session uses VPC resources
@@ -6566,7 +7568,6 @@ var _Session = class _Session {
6566
7568
  this.mcpTools = [];
6567
7569
  this.agentBay = agentBay;
6568
7570
  this.sessionId = sessionId;
6569
- this.resourceUrl = "";
6570
7571
  this.fileSystem = new FileSystem(this);
6571
7572
  this.command = new Command(this);
6572
7573
  this.code = new Code(this);
@@ -6692,7 +7693,7 @@ var _Session = class _Session {
6692
7693
  log(`Response from release_mcp_session: ${JSON.stringify(response)}`);
6693
7694
  const requestId = extractRequestId(response) || "";
6694
7695
  const responseBody = response.body;
6695
- const success = _optionalChain([responseBody, 'optionalAccess', _46 => _46.success]) !== false;
7696
+ const success = _optionalChain([responseBody, 'optionalAccess', _55 => _55.success]) !== false;
6696
7697
  if (!success) {
6697
7698
  return {
6698
7699
  requestId,
@@ -6812,9 +7813,9 @@ var _Session = class _Session {
6812
7813
  });
6813
7814
  const response = await this.getClient().getLabel(request);
6814
7815
  const requestId = extractRequestId(response) || "";
6815
- const responseBody = _optionalChain([response, 'optionalAccess', _47 => _47.body]);
6816
- const data = _optionalChain([responseBody, 'optionalAccess', _48 => _48.data]);
6817
- const labelsJSON = _optionalChain([data, 'optionalAccess', _49 => _49.labels]);
7816
+ const responseBody = _optionalChain([response, 'optionalAccess', _56 => _56.body]);
7817
+ const data = _optionalChain([responseBody, 'optionalAccess', _57 => _57.data]);
7818
+ const labelsJSON = _optionalChain([data, 'optionalAccess', _58 => _58.labels]);
6818
7819
  let labels = {};
6819
7820
  if (labelsJSON) {
6820
7821
  labels = JSON.parse(labelsJSON);
@@ -6849,16 +7850,15 @@ var _Session = class _Session {
6849
7850
  log(`Response from GetMcpResource: ${JSON.stringify(response)}`);
6850
7851
  const requestId = extractRequestId(response) || "";
6851
7852
  const responseBody = response.body;
6852
- const data = _optionalChain([responseBody, 'optionalAccess', _50 => _50.data]);
7853
+ const data = _optionalChain([responseBody, 'optionalAccess', _59 => _59.data]);
6853
7854
  const sessionInfo = new SessionInfoClass();
6854
- if (_optionalChain([data, 'optionalAccess', _51 => _51.sessionId])) {
7855
+ if (_optionalChain([data, 'optionalAccess', _60 => _60.sessionId])) {
6855
7856
  sessionInfo.sessionId = data.sessionId;
6856
7857
  }
6857
- if (_optionalChain([data, 'optionalAccess', _52 => _52.resourceUrl])) {
7858
+ if (_optionalChain([data, 'optionalAccess', _61 => _61.resourceUrl])) {
6858
7859
  sessionInfo.resourceUrl = data.resourceUrl;
6859
- this.resourceUrl = data.resourceUrl;
6860
7860
  }
6861
- if (_optionalChain([data, 'optionalAccess', _53 => _53.desktopInfo])) {
7861
+ if (_optionalChain([data, 'optionalAccess', _62 => _62.desktopInfo])) {
6862
7862
  const desktopInfo = data.desktopInfo;
6863
7863
  if (desktopInfo.appId) {
6864
7864
  sessionInfo.appId = desktopInfo.appId;
@@ -6955,13 +7955,13 @@ var _Session = class _Session {
6955
7955
  });
6956
7956
  const response = await this.agentBay.getClient().getLink(request);
6957
7957
  const requestId = extractRequestId(response) || "";
6958
- const responseBody = _optionalChain([response, 'optionalAccess', _54 => _54.body]);
7958
+ const responseBody = _optionalChain([response, 'optionalAccess', _63 => _63.body]);
6959
7959
  if (typeof responseBody !== "object") {
6960
7960
  throw new Error(
6961
7961
  "Invalid response format: expected a dictionary from response body"
6962
7962
  );
6963
7963
  }
6964
- let data = _optionalChain([responseBody, 'optionalAccess', _55 => _55.data]) || {};
7964
+ let data = _optionalChain([responseBody, 'optionalAccess', _64 => _64.data]) || {};
6965
7965
  log(`Data: ${JSON.stringify(data)}`);
6966
7966
  if (typeof data !== "object") {
6967
7967
  try {
@@ -7113,7 +8113,7 @@ var _Session = class _Session {
7113
8113
  args: argsJSON
7114
8114
  });
7115
8115
  const response = await this.getClient().callMcpTool(callToolRequest);
7116
- if (!_optionalChain([response, 'access', _56 => _56.body, 'optionalAccess', _57 => _57.data])) {
8116
+ if (!_optionalChain([response, 'access', _65 => _65.body, 'optionalAccess', _66 => _66.data])) {
7117
8117
  return {
7118
8118
  success: false,
7119
8119
  data: "",
@@ -7168,6 +8168,7 @@ var _AgentBay = class _AgentBay {
7168
8168
  */
7169
8169
  constructor(options = {}) {
7170
8170
  this.sessions = /* @__PURE__ */ new Map();
8171
+ loadDotEnv();
7171
8172
  this.apiKey = options.apiKey || process.env.AGENTBAY_API_KEY || "";
7172
8173
  if (!this.apiKey) {
7173
8174
  throw new AuthenticationError(
@@ -7202,15 +8203,15 @@ var _AgentBay = class _AgentBay {
7202
8203
  const request = new CreateMcpSessionRequest({
7203
8204
  authorization: "Bearer " + this.apiKey
7204
8205
  });
7205
- if (params.contextId) {
7206
- request.contextId = params.contextId;
7207
- }
7208
8206
  if (params.labels) {
7209
8207
  request.labels = JSON.stringify(params.labels);
7210
8208
  }
7211
8209
  if (params.imageId) {
7212
8210
  request.imageId = params.imageId;
7213
8211
  }
8212
+ if (params.mcpPolicyId) {
8213
+ request.mcpPolicyId = params.mcpPolicyId;
8214
+ }
7214
8215
  request.vpcResource = params.isVpc || false;
7215
8216
  let hasPersistenceData = false;
7216
8217
  if (params.contextSync && params.contextSync.length > 0) {
@@ -7249,9 +8250,6 @@ var _AgentBay = class _AgentBay {
7249
8250
  }
7250
8251
  log("API Call: CreateMcpSession");
7251
8252
  let requestLog = "Request: ";
7252
- if (request.contextId) {
7253
- requestLog += `ContextId=${request.contextId}, `;
7254
- }
7255
8253
  if (request.imageId) {
7256
8254
  requestLog += `ImageId=${request.imageId}, `;
7257
8255
  }
@@ -7270,8 +8268,11 @@ var _AgentBay = class _AgentBay {
7270
8268
  }
7271
8269
  log(requestLog);
7272
8270
  const response = await this.client.createMcpSession(request);
7273
- log("response data =", _optionalChain([response, 'access', _58 => _58.body, 'optionalAccess', _59 => _59.data]));
7274
8271
  const requestId = extractRequestId(response) || "";
8272
+ log("response data =", _optionalChain([response, 'access', _67 => _67.body, 'optionalAccess', _68 => _68.data]));
8273
+ if (requestId) {
8274
+ log(`requestId = ${requestId}`);
8275
+ }
7275
8276
  const sessionData = response.body;
7276
8277
  if (!sessionData || typeof sessionData !== "object") {
7277
8278
  return {
@@ -7300,9 +8301,6 @@ var _AgentBay = class _AgentBay {
7300
8301
  log("session_id =", sessionId);
7301
8302
  log("resource_url =", resourceUrl);
7302
8303
  const session = new Session(this, sessionId);
7303
- if (resourceUrl) {
7304
- session.resourceUrl = resourceUrl;
7305
- }
7306
8304
  session.isVpc = params.isVpc || false;
7307
8305
  if (data.networkInterfaceIp) {
7308
8306
  session.networkInterfaceIp = data.networkInterfaceIp;
@@ -7409,8 +8407,8 @@ var _AgentBay = class _AgentBay {
7409
8407
  );
7410
8408
  const response = await this.client.listSession(listSessionRequest);
7411
8409
  const body = response.body;
7412
- const requestId = extractRequestId(_optionalChain([body, 'optionalAccess', _60 => _60.requestId])) || "";
7413
- if (_optionalChain([body, 'optionalAccess', _61 => _61.data]) && typeof body.data === "object" && body.success && body.success !== true) {
8410
+ const requestId = extractRequestId(_optionalChain([body, 'optionalAccess', _69 => _69.requestId])) || "";
8411
+ if (_optionalChain([body, 'optionalAccess', _70 => _70.data]) && typeof body.data === "object" && body.success && body.success !== true) {
7414
8412
  return {
7415
8413
  requestId,
7416
8414
  success: false,
@@ -7431,7 +8429,7 @@ var _AgentBay = class _AgentBay {
7431
8429
  maxResults = parseInt(String(body.maxResults || 0)) || maxResults;
7432
8430
  totalCount = parseInt(String(body.totalCount || 0));
7433
8431
  }
7434
- const responseData = _optionalChain([body, 'optionalAccess', _62 => _62.data]);
8432
+ const responseData = _optionalChain([body, 'optionalAccess', _71 => _71.data]);
7435
8433
  if (Array.isArray(responseData)) {
7436
8434
  for (const sessionData of responseData) {
7437
8435
  if (sessionData && typeof sessionData === "object") {
@@ -7507,6 +8505,366 @@ var AgentBay = _AgentBay;
7507
8505
  // src/agent/index.ts
7508
8506
  init_cjs_shims();
7509
8507
 
8508
+ // src/extension.ts
8509
+ init_cjs_shims();
8510
+
8511
+
8512
+ var _crypto = require('crypto'); var crypto = _interopRequireWildcard(_crypto);
8513
+ var _nodefetch = require('node-fetch'); var _nodefetch2 = _interopRequireDefault(_nodefetch);
8514
+ var EXTENSIONS_BASE_PATH = "/tmp/extensions";
8515
+ var _Extension = class _Extension {
8516
+ /**
8517
+ * Initialize an Extension object.
8518
+ *
8519
+ * @param id - The unique identifier of the extension.
8520
+ * @param name - The name of the extension.
8521
+ * @param createdAt - Date and time when the extension was created.
8522
+ */
8523
+ constructor(id, name, createdAt) {
8524
+ this.id = id;
8525
+ this.name = name;
8526
+ this.createdAt = createdAt;
8527
+ }
8528
+ };
8529
+ __name(_Extension, "Extension");
8530
+ var Extension = _Extension;
8531
+ var _ExtensionOption = class _ExtensionOption {
8532
+ /**
8533
+ * Initialize ExtensionOption with context and extension configuration.
8534
+ *
8535
+ * @param contextId - ID of the extension context for browser extensions.
8536
+ * This should match the context where extensions are stored.
8537
+ * @param extensionIds - List of extension IDs to be loaded in the browser session.
8538
+ * Each ID should correspond to a valid extension in the context.
8539
+ *
8540
+ * @throws {Error} If contextId is empty or extensionIds is empty.
8541
+ */
8542
+ constructor(contextId, extensionIds) {
8543
+ if (!contextId || !contextId.trim()) {
8544
+ throw new Error("contextId cannot be empty");
8545
+ }
8546
+ if (!extensionIds || extensionIds.length === 0) {
8547
+ throw new Error("extensionIds cannot be empty");
8548
+ }
8549
+ this.contextId = contextId;
8550
+ this.extensionIds = extensionIds;
8551
+ }
8552
+ /**
8553
+ * String representation of ExtensionOption.
8554
+ */
8555
+ toString() {
8556
+ return `ExtensionOption(contextId='${this.contextId}', extensionIds=${JSON.stringify(this.extensionIds)})`;
8557
+ }
8558
+ /**
8559
+ * Human-readable string representation.
8560
+ */
8561
+ toDisplayString() {
8562
+ return `Extension Config: ${this.extensionIds.length} extension(s) in context '${this.contextId}'`;
8563
+ }
8564
+ /**
8565
+ * Validate the extension option configuration.
8566
+ *
8567
+ * @returns True if configuration is valid, false otherwise.
8568
+ */
8569
+ validate() {
8570
+ try {
8571
+ if (!this.contextId || !this.contextId.trim()) {
8572
+ return false;
8573
+ }
8574
+ if (!this.extensionIds || this.extensionIds.length === 0) {
8575
+ return false;
8576
+ }
8577
+ for (const extId of this.extensionIds) {
8578
+ if (typeof extId !== "string" || !extId.trim()) {
8579
+ return false;
8580
+ }
8581
+ }
8582
+ return true;
8583
+ } catch (error) {
8584
+ return false;
8585
+ }
8586
+ }
8587
+ };
8588
+ __name(_ExtensionOption, "ExtensionOption");
8589
+ var ExtensionOption = _ExtensionOption;
8590
+ var _ExtensionsService = class _ExtensionsService {
8591
+ /**
8592
+ * Initializes the ExtensionsService with a context.
8593
+ *
8594
+ * @param agentBay - The AgentBay client instance.
8595
+ * @param contextId - The context ID or name. If empty or not provided,
8596
+ * a default context name will be generated automatically.
8597
+ * If the context doesn't exist, it will be automatically created.
8598
+ *
8599
+ * Note:
8600
+ * The service automatically detects if the context exists. If not,
8601
+ * it creates a new context with the provided name or a generated default name.
8602
+ * Context initialization is handled lazily on first use.
8603
+ */
8604
+ constructor(agentBay, contextId = "") {
8605
+ this._initializationPromise = null;
8606
+ if (!agentBay) {
8607
+ throw new AgentBayError("AgentBay instance is required");
8608
+ }
8609
+ if (!agentBay.context) {
8610
+ throw new AgentBayError("AgentBay instance must have a context service");
8611
+ }
8612
+ this.agentBay = agentBay;
8613
+ this.contextService = agentBay.context;
8614
+ this.autoCreated = true;
8615
+ if (!contextId || contextId.trim() === "") {
8616
+ contextId = `extensions-${Math.floor(Date.now() / 1e3)}`;
8617
+ log(`Generated default context name: ${contextId}`);
8618
+ }
8619
+ this.contextName = contextId;
8620
+ this._initializationPromise = this._initializeContext();
8621
+ }
8622
+ /**
8623
+ * Internal method to initialize the context.
8624
+ * This ensures the context is ready before any operations.
8625
+ */
8626
+ async _initializeContext() {
8627
+ try {
8628
+ const contextResult = await this.contextService.get(this.contextName, true);
8629
+ if (!contextResult.success || !contextResult.context) {
8630
+ throw new AgentBayError(`Failed to create extension repository context: ${this.contextName}`);
8631
+ }
8632
+ this.extensionContext = contextResult.context;
8633
+ this.contextId = this.extensionContext.id;
8634
+ } catch (error) {
8635
+ throw new AgentBayError(`Failed to initialize ExtensionsService: ${error instanceof Error ? error.message : String(error)}`);
8636
+ }
8637
+ }
8638
+ /**
8639
+ * Ensures the service is initialized before performing operations.
8640
+ */
8641
+ async _ensureInitialized() {
8642
+ if (this._initializationPromise) {
8643
+ await this._initializationPromise;
8644
+ this._initializationPromise = null;
8645
+ }
8646
+ }
8647
+ /**
8648
+ * An internal helper method that encapsulates the flow of "get upload URL for a specific path and upload".
8649
+ * Uses the existing context service for file operations.
8650
+ *
8651
+ * @param localPath - The path to the local file.
8652
+ * @param remotePath - The path of the file in context storage.
8653
+ *
8654
+ * @throws {AgentBayError} If getting the credential or uploading fails.
8655
+ */
8656
+ async _uploadToCloud(localPath, remotePath) {
8657
+ try {
8658
+ const urlResult = await this.contextService.getFileUploadUrl(this.contextId, remotePath);
8659
+ if (!urlResult.success || !urlResult.url) {
8660
+ throw new AgentBayError(`Failed to get upload URL: ${urlResult.url || "No URL returned"}`);
8661
+ }
8662
+ const preSignedUrl = urlResult.url;
8663
+ const fileBuffer = fs2.readFileSync(localPath);
8664
+ const response = await _nodefetch2.default.call(void 0, preSignedUrl, {
8665
+ method: "PUT",
8666
+ body: fileBuffer
8667
+ });
8668
+ if (!response.ok) {
8669
+ throw new AgentBayError(`HTTP error uploading file: ${response.status} ${response.statusText}`);
8670
+ }
8671
+ } catch (error) {
8672
+ if (error instanceof AgentBayError) {
8673
+ throw error;
8674
+ }
8675
+ throw new AgentBayError(`An error occurred while uploading the file: ${error instanceof Error ? error.message : String(error)}`);
8676
+ }
8677
+ }
8678
+ /**
8679
+ * Lists all available browser extensions within this context from the cloud.
8680
+ * Uses the context service to list files under the extensions directory.
8681
+ *
8682
+ * @returns Promise that resolves to an array of Extension objects.
8683
+ * @throws {AgentBayError} If listing extensions fails.
8684
+ */
8685
+ async list() {
8686
+ await this._ensureInitialized();
8687
+ try {
8688
+ const fileListResult = await this.contextService.listFiles(
8689
+ this.contextId,
8690
+ EXTENSIONS_BASE_PATH,
8691
+ 1,
8692
+ // pageNumber
8693
+ 100
8694
+ // pageSize - reasonable limit for extensions
8695
+ );
8696
+ if (!fileListResult.success) {
8697
+ throw new AgentBayError("Failed to list extensions: Context file listing failed.");
8698
+ }
8699
+ const extensions = [];
8700
+ for (const fileEntry of fileListResult.entries) {
8701
+ const extensionId = fileEntry.fileName || fileEntry.filePath;
8702
+ extensions.push(new Extension(
8703
+ extensionId,
8704
+ fileEntry.fileName || extensionId,
8705
+ fileEntry.gmtCreate
8706
+ ));
8707
+ }
8708
+ return extensions;
8709
+ } catch (error) {
8710
+ if (error instanceof AgentBayError) {
8711
+ throw error;
8712
+ }
8713
+ throw new AgentBayError(`An error occurred while listing browser extensions: ${error instanceof Error ? error.message : String(error)}`);
8714
+ }
8715
+ }
8716
+ /**
8717
+ * Uploads a new browser extension from a local path into the current context.
8718
+ *
8719
+ * @param localPath - Path to the local extension file (must be a .zip file).
8720
+ * @returns Promise that resolves to an Extension object.
8721
+ * @throws {Error} If the local file doesn't exist.
8722
+ * @throws {Error} If the file format is not supported (only .zip is supported).
8723
+ * @throws {AgentBayError} If upload fails.
8724
+ */
8725
+ async create(localPath) {
8726
+ await this._ensureInitialized();
8727
+ if (!fs2.existsSync(localPath)) {
8728
+ throw new Error(`The specified local file was not found: ${localPath}`);
8729
+ }
8730
+ const fileExtension = path2.extname(localPath).toLowerCase();
8731
+ if (fileExtension !== ".zip") {
8732
+ throw new Error(`Unsupported plugin format '${fileExtension}'. Only ZIP format (.zip) is supported.`);
8733
+ }
8734
+ const extensionId = `ext_${crypto.randomBytes(16).toString("hex")}${fileExtension}`;
8735
+ const extensionName = path2.basename(localPath);
8736
+ const remotePath = `${EXTENSIONS_BASE_PATH}/${extensionId}`;
8737
+ await this._uploadToCloud(localPath, remotePath);
8738
+ return new Extension(extensionId, extensionName);
8739
+ }
8740
+ /**
8741
+ * Updates an existing browser extension in the current context with a new file.
8742
+ *
8743
+ * @param extensionId - ID of the extension to update.
8744
+ * @param newLocalPath - Path to the new local extension file.
8745
+ * @returns Promise that resolves to an Extension object.
8746
+ * @throws {Error} If the new local file doesn't exist.
8747
+ * @throws {Error} If the extension doesn't exist in the context.
8748
+ * @throws {AgentBayError} If update fails.
8749
+ */
8750
+ async update(extensionId, newLocalPath) {
8751
+ await this._ensureInitialized();
8752
+ if (!fs2.existsSync(newLocalPath)) {
8753
+ throw new Error(`The specified new local file was not found: ${newLocalPath}`);
8754
+ }
8755
+ const existingExtensions = await this.list();
8756
+ const extensionExists = existingExtensions.some((ext) => ext.id === extensionId);
8757
+ if (!extensionExists) {
8758
+ throw new Error(`Browser extension with ID '${extensionId}' not found in the context. Cannot update.`);
8759
+ }
8760
+ const remotePath = `${EXTENSIONS_BASE_PATH}/${extensionId}`;
8761
+ await this._uploadToCloud(newLocalPath, remotePath);
8762
+ return new Extension(extensionId, path2.basename(newLocalPath));
8763
+ }
8764
+ /**
8765
+ * Gets detailed information about a specific browser extension.
8766
+ *
8767
+ * @param extensionId - The ID of the extension to get info for.
8768
+ * @returns Promise that resolves to an Extension object if found, undefined otherwise.
8769
+ */
8770
+ async _getExtensionInfo(extensionId) {
8771
+ await this._ensureInitialized();
8772
+ try {
8773
+ const extensions = await this.list();
8774
+ return extensions.find((ext) => ext.id === extensionId);
8775
+ } catch (error) {
8776
+ logError(`An error occurred while getting extension info for '${extensionId}':`, error);
8777
+ return void 0;
8778
+ }
8779
+ }
8780
+ /**
8781
+ * Cleans up the auto-created context if it was created by this service.
8782
+ *
8783
+ * @returns Promise that resolves to true if cleanup was successful or not needed, false if cleanup failed.
8784
+ *
8785
+ * Note:
8786
+ * This method only works if the context was auto-created by this service.
8787
+ * For existing contexts, no cleanup is performed.
8788
+ */
8789
+ async cleanup() {
8790
+ await this._ensureInitialized();
8791
+ if (!this.autoCreated) {
8792
+ return true;
8793
+ }
8794
+ try {
8795
+ const deleteResult = await this.contextService.delete(this.extensionContext);
8796
+ if (deleteResult) {
8797
+ log(`Extension context deleted: ${this.contextName} (ID: ${this.contextId})`);
8798
+ return true;
8799
+ } else {
8800
+ logError(`Warning: Failed to delete extension context: ${this.contextName}`, new Error("Delete operation returned false"));
8801
+ return false;
8802
+ }
8803
+ } catch (error) {
8804
+ logError(`Warning: Failed to delete extension context:`, error);
8805
+ return false;
8806
+ }
8807
+ }
8808
+ /**
8809
+ * Deletes a browser extension from the current context.
8810
+ *
8811
+ * @param extensionId - ID of the extension to delete.
8812
+ * @returns Promise that resolves to true if deletion was successful, false otherwise.
8813
+ */
8814
+ async delete(extensionId) {
8815
+ await this._ensureInitialized();
8816
+ const remotePath = `${EXTENSIONS_BASE_PATH}/${extensionId}`;
8817
+ try {
8818
+ const deleteResult = await this.contextService.deleteFile(this.contextId, remotePath);
8819
+ return deleteResult.success;
8820
+ } catch (error) {
8821
+ logError(`An error occurred while deleting browser extension '${extensionId}':`, error);
8822
+ return false;
8823
+ }
8824
+ }
8825
+ /**
8826
+ * Create an ExtensionOption for the current context with specified extension IDs.
8827
+ *
8828
+ * This is a convenience method that creates an ExtensionOption using the current
8829
+ * service's contextId and the provided extension IDs. This option can then be
8830
+ * used with BrowserContext for browser session creation.
8831
+ *
8832
+ * @param extensionIds - List of extension IDs to include in the option.
8833
+ * These should be extensions that exist in the current context.
8834
+ * @returns ExtensionOption configuration object for browser extension integration.
8835
+ * @throws {Error} If extensionIds is empty or invalid.
8836
+ *
8837
+ * @example
8838
+ * ```typescript
8839
+ * // Create extensions
8840
+ * const ext1 = await extensionsService.create("/path/to/ext1.zip");
8841
+ * const ext2 = await extensionsService.create("/path/to/ext2.zip");
8842
+ *
8843
+ * // Create extension option for browser integration
8844
+ * const extOption = extensionsService.createExtensionOption([ext1.id, ext2.id]);
8845
+ *
8846
+ * // Use with BrowserContext
8847
+ * const browserContext = new BrowserContext({
8848
+ * contextId: "browser_session",
8849
+ * autoUpload: true,
8850
+ * extensionContextId: extOption.contextId,
8851
+ * extensionIds: extOption.extensionIds
8852
+ * });
8853
+ * ```
8854
+ */
8855
+ createExtensionOption(extensionIds) {
8856
+ if (!this.contextId) {
8857
+ throw new Error("Service not initialized. Please call an async method first or ensure context is created.");
8858
+ }
8859
+ return new ExtensionOption(
8860
+ this.contextId,
8861
+ extensionIds
8862
+ );
8863
+ }
8864
+ };
8865
+ __name(_ExtensionsService, "ExtensionsService");
8866
+ var ExtensionsService = _ExtensionsService;
8867
+
7510
8868
  // src/context-sync.ts
7511
8869
  init_cjs_shims();
7512
8870
  var UploadStrategy = /* @__PURE__ */ ((UploadStrategy2) => {
@@ -7517,12 +8875,41 @@ var DownloadStrategy = /* @__PURE__ */ ((DownloadStrategy2) => {
7517
8875
  DownloadStrategy2["DownloadAsync"] = "DownloadAsync";
7518
8876
  return DownloadStrategy2;
7519
8877
  })(DownloadStrategy || {});
8878
+ var _ExtractPolicyClass = class _ExtractPolicyClass {
8879
+ constructor(extract = true, deleteSrcFile = true, extractToCurrentFolder = false) {
8880
+ this.extract = true;
8881
+ this.deleteSrcFile = true;
8882
+ this.extractToCurrentFolder = false;
8883
+ this.extract = extract;
8884
+ this.deleteSrcFile = deleteSrcFile;
8885
+ this.extractToCurrentFolder = extractToCurrentFolder;
8886
+ }
8887
+ /**
8888
+ * Creates a new extract policy with default values
8889
+ */
8890
+ static default() {
8891
+ return new _ExtractPolicyClass();
8892
+ }
8893
+ /**
8894
+ * Converts to plain object for JSON serialization
8895
+ */
8896
+ toDict() {
8897
+ return {
8898
+ extract: this.extract,
8899
+ deleteSrcFile: this.deleteSrcFile,
8900
+ extractToCurrentFolder: this.extractToCurrentFolder
8901
+ };
8902
+ }
8903
+ };
8904
+ __name(_ExtractPolicyClass, "ExtractPolicyClass");
8905
+ var ExtractPolicyClass = _ExtractPolicyClass;
7520
8906
  var _SyncPolicyImpl = class _SyncPolicyImpl {
7521
8907
  constructor(policy) {
7522
8908
  if (policy) {
7523
8909
  this.uploadPolicy = policy.uploadPolicy;
7524
8910
  this.downloadPolicy = policy.downloadPolicy;
7525
8911
  this.deletePolicy = policy.deletePolicy;
8912
+ this.extractPolicy = policy.extractPolicy;
7526
8913
  this.bwList = policy.bwList;
7527
8914
  }
7528
8915
  this.ensureDefaults();
@@ -7537,6 +8924,9 @@ var _SyncPolicyImpl = class _SyncPolicyImpl {
7537
8924
  if (!this.deletePolicy) {
7538
8925
  this.deletePolicy = newDeletePolicy();
7539
8926
  }
8927
+ if (!this.extractPolicy) {
8928
+ this.extractPolicy = newExtractPolicy();
8929
+ }
7540
8930
  if (!this.bwList) {
7541
8931
  this.bwList = {
7542
8932
  whiteLists: [
@@ -7554,6 +8944,7 @@ var _SyncPolicyImpl = class _SyncPolicyImpl {
7554
8944
  uploadPolicy: this.uploadPolicy,
7555
8945
  downloadPolicy: this.downloadPolicy,
7556
8946
  deletePolicy: this.deletePolicy,
8947
+ extractPolicy: this.extractPolicy,
7557
8948
  bwList: this.bwList
7558
8949
  };
7559
8950
  }
@@ -7561,9 +8952,9 @@ var _SyncPolicyImpl = class _SyncPolicyImpl {
7561
8952
  __name(_SyncPolicyImpl, "SyncPolicyImpl");
7562
8953
  var SyncPolicyImpl = _SyncPolicyImpl;
7563
8954
  var _ContextSync = class _ContextSync {
7564
- constructor(contextId, path2, policy) {
8955
+ constructor(contextId, path3, policy) {
7565
8956
  this.contextId = contextId;
7566
- this.path = path2;
8957
+ this.path = path3;
7567
8958
  this.policy = policy;
7568
8959
  }
7569
8960
  // WithPolicy sets the policy and returns the context sync for chaining
@@ -7596,11 +8987,20 @@ function newDeletePolicy() {
7596
8987
  };
7597
8988
  }
7598
8989
  __name(newDeletePolicy, "newDeletePolicy");
8990
+ function newExtractPolicy() {
8991
+ return {
8992
+ extract: true,
8993
+ deleteSrcFile: true,
8994
+ extractToCurrentFolder: false
8995
+ };
8996
+ }
8997
+ __name(newExtractPolicy, "newExtractPolicy");
7599
8998
  function newSyncPolicy() {
7600
8999
  return {
7601
9000
  uploadPolicy: newUploadPolicy(),
7602
9001
  downloadPolicy: newDownloadPolicy(),
7603
9002
  deletePolicy: newDeletePolicy(),
9003
+ extractPolicy: newExtractPolicy(),
7604
9004
  bwList: {
7605
9005
  whiteLists: [
7606
9006
  {
@@ -7616,13 +9016,98 @@ function newSyncPolicyWithDefaults(policy) {
7616
9016
  return new SyncPolicyImpl(policy).toJSON();
7617
9017
  }
7618
9018
  __name(newSyncPolicyWithDefaults, "newSyncPolicyWithDefaults");
7619
- function newContextSync(contextId, path2, policy) {
7620
- return new ContextSync(contextId, path2, policy);
9019
+ function newContextSync(contextId, path3, policy) {
9020
+ return new ContextSync(contextId, path3, policy);
7621
9021
  }
7622
9022
  __name(newContextSync, "newContextSync");
7623
9023
 
7624
9024
  // src/session-params.ts
7625
9025
  init_cjs_shims();
9026
+ var _BrowserContext = class _BrowserContext {
9027
+ /**
9028
+ * Initialize BrowserContextImpl with optional extension support.
9029
+ *
9030
+ * @param contextId - ID of the browser context to bind to the session.
9031
+ * This identifies the browser instance for the session.
9032
+ * @param autoUpload - Whether to automatically upload browser data
9033
+ * when the session ends. Defaults to true.
9034
+ * @param extensionOption - Extension configuration object containing
9035
+ * contextId and extensionIds. This encapsulates
9036
+ * all extension-related configuration.
9037
+ * Defaults to undefined.
9038
+ *
9039
+ * Extension Configuration:
9040
+ * - **ExtensionOption**: Use extensionOption parameter with an ExtensionOption object
9041
+ * - **No Extensions**: Don't provide extensionOption parameter
9042
+ *
9043
+ * Auto-generation:
9044
+ * - extensionContextSyncs is automatically generated when extensionOption is provided
9045
+ * - extensionContextSyncs will be undefined if no extensionOption is provided
9046
+ * - extensionContextSyncs will be a ContextSync[] if extensionOption is valid
9047
+ */
9048
+ constructor(contextId, autoUpload = true, extensionOption) {
9049
+ this.contextId = contextId;
9050
+ this.autoUpload = autoUpload;
9051
+ this.extensionOption = extensionOption;
9052
+ if (extensionOption) {
9053
+ this.extensionContextId = extensionOption.contextId;
9054
+ this.extensionIds = extensionOption.extensionIds;
9055
+ this.extensionContextSyncs = this._createExtensionContextSyncs();
9056
+ } else {
9057
+ this.extensionContextId = void 0;
9058
+ this.extensionIds = [];
9059
+ this.extensionContextSyncs = void 0;
9060
+ }
9061
+ }
9062
+ /**
9063
+ * Create ContextSync configurations for browser extensions.
9064
+ *
9065
+ * This method is called only when extensionOption is provided and contains
9066
+ * valid extension configuration (contextId and extensionIds).
9067
+ *
9068
+ * @returns ContextSync[] - List of context sync configurations for extensions.
9069
+ * Returns empty list if extension configuration is invalid.
9070
+ */
9071
+ _createExtensionContextSyncs() {
9072
+ if (!this.extensionIds || this.extensionIds.length === 0 || !this.extensionContextId) {
9073
+ return [];
9074
+ }
9075
+ const whiteLists = this.extensionIds.map((extId) => ({
9076
+ path: extId,
9077
+ excludePaths: []
9078
+ }));
9079
+ const syncPolicy = {
9080
+ uploadPolicy: {
9081
+ ...newUploadPolicy(),
9082
+ autoUpload: false
9083
+ },
9084
+ extractPolicy: {
9085
+ ...newExtractPolicy(),
9086
+ extract: true,
9087
+ deleteSrcFile: true
9088
+ },
9089
+ bwList: {
9090
+ whiteLists
9091
+ }
9092
+ };
9093
+ const extensionSync = new ContextSync(
9094
+ this.extensionContextId,
9095
+ "/tmp/extensions/",
9096
+ syncPolicy
9097
+ );
9098
+ return [extensionSync];
9099
+ }
9100
+ /**
9101
+ * Get all context syncs including extension syncs.
9102
+ *
9103
+ * @returns ContextSync[] - All context sync configurations. Returns empty list if no extensions configured.
9104
+ */
9105
+ getAllContextSyncs() {
9106
+ return this.extensionContextSyncs || [];
9107
+ }
9108
+ };
9109
+ __name(_BrowserContext, "BrowserContext");
9110
+ var BrowserContext = _BrowserContext;
7626
9111
  var _CreateSessionParams = class _CreateSessionParams {
7627
9112
  constructor() {
7628
9113
  this.labels = {};
@@ -7636,13 +9121,6 @@ var _CreateSessionParams = class _CreateSessionParams {
7636
9121
  this.labels = labels;
7637
9122
  return this;
7638
9123
  }
7639
- /**
7640
- * WithContextID sets the context ID for the session parameters and returns the updated parameters.
7641
- */
7642
- withContextID(contextId) {
7643
- this.contextId = contextId;
7644
- return this;
7645
- }
7646
9124
  /**
7647
9125
  * WithImageId sets the image ID for the session parameters and returns the updated parameters.
7648
9126
  */
@@ -7664,6 +9142,13 @@ var _CreateSessionParams = class _CreateSessionParams {
7664
9142
  this.isVpc = isVpc;
7665
9143
  return this;
7666
9144
  }
9145
+ /**
9146
+ * WithMcpPolicyId sets the MCP policy id for the session parameters and returns the updated parameters.
9147
+ */
9148
+ withMcpPolicyId(mcpPolicyId) {
9149
+ this.mcpPolicyId = mcpPolicyId;
9150
+ return this;
9151
+ }
7667
9152
  /**
7668
9153
  * GetLabelsJSON returns the labels as a JSON string.
7669
9154
  * Returns an object with success status and result/error message to match Go version behavior.
@@ -7685,8 +9170,8 @@ var _CreateSessionParams = class _CreateSessionParams {
7685
9170
  /**
7686
9171
  * AddContextSync adds a context sync configuration to the session parameters.
7687
9172
  */
7688
- addContextSync(contextId, path2, policy) {
7689
- const contextSync = new ContextSync(contextId, path2, policy);
9173
+ addContextSync(contextId, path3, policy) {
9174
+ const contextSync = new ContextSync(contextId, path3, policy);
7690
9175
  this.contextSync.push(contextSync);
7691
9176
  return this;
7692
9177
  }
@@ -7708,13 +9193,18 @@ var _CreateSessionParams = class _CreateSessionParams {
7708
9193
  * Convert to plain object for JSON serialization
7709
9194
  */
7710
9195
  toJSON() {
9196
+ let allContextSyncs = [...this.contextSync];
9197
+ if (this.browserContext && "getAllContextSyncs" in this.browserContext) {
9198
+ const extensionSyncs = this.browserContext.getAllContextSyncs();
9199
+ allContextSyncs = allContextSyncs.concat(extensionSyncs);
9200
+ }
7711
9201
  return {
7712
9202
  labels: this.labels,
7713
- contextId: this.contextId,
7714
9203
  imageId: this.imageId,
7715
- contextSync: this.contextSync,
9204
+ contextSync: allContextSyncs,
7716
9205
  browserContext: this.browserContext,
7717
- isVpc: this.isVpc
9206
+ isVpc: this.isVpc,
9207
+ mcpPolicyId: this.mcpPolicyId
7718
9208
  };
7719
9209
  }
7720
9210
  /**
@@ -7723,11 +9213,22 @@ var _CreateSessionParams = class _CreateSessionParams {
7723
9213
  static fromJSON(config) {
7724
9214
  const params = new _CreateSessionParams();
7725
9215
  params.labels = config.labels || {};
7726
- params.contextId = config.contextId;
7727
9216
  params.imageId = config.imageId;
7728
9217
  params.contextSync = config.contextSync || [];
7729
- params.browserContext = config.browserContext;
9218
+ if (config.browserContext) {
9219
+ if ("getAllContextSyncs" in config.browserContext) {
9220
+ params.browserContext = config.browserContext;
9221
+ } else {
9222
+ const bc = config.browserContext;
9223
+ params.browserContext = new BrowserContext(
9224
+ bc.contextId,
9225
+ bc.autoUpload,
9226
+ bc.extensionOption
9227
+ );
9228
+ }
9229
+ }
7730
9230
  params.isVpc = config.isVpc || false;
9231
+ params.mcpPolicyId = config.mcpPolicyId;
7731
9232
  return params;
7732
9233
  }
7733
9234
  };
@@ -7844,5 +9345,25 @@ __name(newCreateSessionParams, "newCreateSessionParams");
7844
9345
 
7845
9346
 
7846
9347
 
7847
- exports.APIError = APIError; exports.ActResult = ActResult; exports.Agent = Agent; exports.AgentBay = AgentBay; exports.AgentBayError = AgentBayError; exports.Application = Application; exports.ApplicationError = ApplicationError; exports.ApplyMqttTokenRequest = ApplyMqttTokenRequest; exports.ApplyMqttTokenResponse = ApplyMqttTokenResponse; exports.ApplyMqttTokenResponseBody = ApplyMqttTokenResponseBody; exports.ApplyMqttTokenResponseBodyData = ApplyMqttTokenResponseBodyData; exports.AuthenticationError = AuthenticationError; exports.Browser = Browser; exports.BrowserAgent = BrowserAgent; exports.BrowserError = BrowserError; exports.CallMcpToolRequest = CallMcpToolRequest; exports.CallMcpToolResponse = CallMcpToolResponse; exports.CallMcpToolResponseBody = CallMcpToolResponseBody; exports.Client = Client; exports.Command = Command; exports.CommandError = CommandError; exports.Context = Context; exports.ContextManager = ContextManager; exports.ContextService = ContextService; exports.ContextSync = ContextSync; exports.CreateMcpSessionRequest = CreateMcpSessionRequest; exports.CreateMcpSessionRequestPersistenceDataList = CreateMcpSessionRequestPersistenceDataList; exports.CreateMcpSessionResponse = CreateMcpSessionResponse; exports.CreateMcpSessionResponseBody = CreateMcpSessionResponseBody; exports.CreateMcpSessionResponseBodyData = CreateMcpSessionResponseBodyData; exports.CreateMcpSessionShrinkRequest = CreateMcpSessionShrinkRequest; exports.CreateSessionParams = CreateSessionParams; exports.DeleteContextRequest = DeleteContextRequest; exports.DeleteContextResponse = DeleteContextResponse; exports.DeleteContextResponseBody = DeleteContextResponseBody; exports.DownloadStrategy = DownloadStrategy; exports.FileError = FileError; exports.FileSystem = FileSystem; exports.GetContextInfoRequest = GetContextInfoRequest; exports.GetContextInfoResponse = GetContextInfoResponse; exports.GetContextInfoResponseBody = GetContextInfoResponseBody; exports.GetContextInfoResponseBodyData = GetContextInfoResponseBodyData; exports.GetContextRequest = GetContextRequest; exports.GetContextResponse = GetContextResponse; exports.GetContextResponseBody = GetContextResponseBody; exports.GetContextResponseBodyData = GetContextResponseBodyData; exports.GetLabelRequest = GetLabelRequest; exports.GetLabelResponse = GetLabelResponse; exports.GetLabelResponseBody = GetLabelResponseBody; exports.GetLabelResponseBodyData = GetLabelResponseBodyData; exports.GetLinkRequest = GetLinkRequest; exports.GetLinkResponse = GetLinkResponse; exports.GetLinkResponseBody = GetLinkResponseBody; exports.GetLinkResponseBodyData = GetLinkResponseBodyData; exports.GetMcpResourceRequest = GetMcpResourceRequest; exports.GetMcpResourceResponse = GetMcpResourceResponse; exports.GetMcpResourceResponseBody = GetMcpResourceResponseBody; exports.GetMcpResourceResponseBodyData = GetMcpResourceResponseBodyData; exports.GetMcpResourceResponseBodyDataDesktopInfo = GetMcpResourceResponseBodyDataDesktopInfo; exports.InitBrowserRequest = InitBrowserRequest; exports.InitBrowserResponse = InitBrowserResponse; exports.InitBrowserResponseBody = InitBrowserResponseBody; exports.InitBrowserResponseBodyData = InitBrowserResponseBodyData; exports.KeyCode = KeyCode; exports.ListContextsRequest = ListContextsRequest; exports.ListContextsResponse = ListContextsResponse; exports.ListContextsResponseBody = ListContextsResponseBody; exports.ListContextsResponseBodyData = ListContextsResponseBodyData; exports.ListMcpToolsRequest = ListMcpToolsRequest; exports.ListMcpToolsResponse = ListMcpToolsResponse; exports.ListMcpToolsResponseBody = ListMcpToolsResponseBody; exports.ListSessionRequest = ListSessionRequest; exports.ListSessionResponse = ListSessionResponse; exports.ListSessionResponseBody = ListSessionResponseBody; exports.ListSessionResponseBodyData = ListSessionResponseBodyData; exports.ModifyContextRequest = ModifyContextRequest; exports.ModifyContextResponse = ModifyContextResponse; exports.ModifyContextResponseBody = ModifyContextResponseBody; exports.ObserveResult = ObserveResult; exports.Oss = Oss; exports.OssError = OssError; exports.ReleaseMcpSessionRequest = ReleaseMcpSessionRequest; exports.ReleaseMcpSessionResponse = ReleaseMcpSessionResponse; exports.ReleaseMcpSessionResponseBody = ReleaseMcpSessionResponseBody; exports.Session = Session; exports.SessionError = SessionError; exports.SetLabelRequest = SetLabelRequest; exports.SetLabelResponse = SetLabelResponse; exports.SetLabelResponseBody = SetLabelResponseBody; exports.SyncContextRequest = SyncContextRequest; exports.SyncContextResponse = SyncContextResponse; exports.SyncContextResponseBody = SyncContextResponseBody; exports.SyncPolicyImpl = SyncPolicyImpl; exports.UI = UI; exports.UIError = UIError; exports.UploadStrategy = UploadStrategy; exports.log = log; exports.logError = logError; exports.newContextManager = newContextManager; exports.newContextSync = newContextSync; exports.newCreateSessionParams = newCreateSessionParams; exports.newDeletePolicy = newDeletePolicy; exports.newDownloadPolicy = newDownloadPolicy; exports.newSyncPolicy = newSyncPolicy; exports.newSyncPolicyWithDefaults = newSyncPolicyWithDefaults; exports.newUploadPolicy = newUploadPolicy;
9348
+
9349
+
9350
+
9351
+
9352
+
9353
+
9354
+
9355
+
9356
+
9357
+
9358
+
9359
+
9360
+
9361
+
9362
+
9363
+
9364
+
9365
+
9366
+
9367
+
9368
+ exports.APIError = APIError; exports.Agent = Agent; exports.AgentBay = AgentBay; exports.AgentBayError = AgentBayError; exports.Application = Application; exports.ApplicationError = ApplicationError; exports.ApplyMqttTokenRequest = ApplyMqttTokenRequest; exports.ApplyMqttTokenResponse = ApplyMqttTokenResponse; exports.ApplyMqttTokenResponseBody = ApplyMqttTokenResponseBody; exports.ApplyMqttTokenResponseBodyData = ApplyMqttTokenResponseBodyData; exports.AuthenticationError = AuthenticationError; exports.Browser = Browser; exports.BrowserAgent = BrowserAgent; exports.BrowserContext = BrowserContext; exports.BrowserError = BrowserError; exports.BrowserOptionClass = BrowserOptionClass; exports.BrowserProxyClass = BrowserProxyClass; exports.CallMcpToolRequest = CallMcpToolRequest; exports.CallMcpToolResponse = CallMcpToolResponse; exports.CallMcpToolResponseBody = CallMcpToolResponseBody; exports.Client = Client; exports.Command = Command; exports.CommandError = CommandError; exports.Context = Context; exports.ContextManager = ContextManager; exports.ContextService = ContextService; exports.ContextSync = ContextSync; exports.CreateMcpSessionRequest = CreateMcpSessionRequest; exports.CreateMcpSessionRequestPersistenceDataList = CreateMcpSessionRequestPersistenceDataList; exports.CreateMcpSessionResponse = CreateMcpSessionResponse; exports.CreateMcpSessionResponseBody = CreateMcpSessionResponseBody; exports.CreateMcpSessionResponseBodyData = CreateMcpSessionResponseBodyData; exports.CreateMcpSessionShrinkRequest = CreateMcpSessionShrinkRequest; exports.CreateSessionParams = CreateSessionParams; exports.DeleteContextFileRequest = DeleteContextFileRequest; exports.DeleteContextFileResponse = DeleteContextFileResponse; exports.DeleteContextFileResponseBody = DeleteContextFileResponseBody; exports.DeleteContextRequest = DeleteContextRequest; exports.DeleteContextResponse = DeleteContextResponse; exports.DeleteContextResponseBody = DeleteContextResponseBody; exports.DescribeContextFilesRequest = DescribeContextFilesRequest; exports.DescribeContextFilesResponse = DescribeContextFilesResponse; exports.DescribeContextFilesResponseBody = DescribeContextFilesResponseBody; exports.DownloadStrategy = DownloadStrategy; exports.Extension = Extension; exports.ExtensionOption = ExtensionOption; exports.ExtensionsService = ExtensionsService; exports.ExtractPolicyClass = ExtractPolicyClass; exports.FileError = FileError; exports.FileSystem = FileSystem; exports.GetContextFileDownloadUrlRequest = GetContextFileDownloadUrlRequest; exports.GetContextFileDownloadUrlResponse = GetContextFileDownloadUrlResponse; exports.GetContextFileDownloadUrlResponseBody = GetContextFileDownloadUrlResponseBody; exports.GetContextFileUploadUrlRequest = GetContextFileUploadUrlRequest; exports.GetContextFileUploadUrlResponse = GetContextFileUploadUrlResponse; exports.GetContextFileUploadUrlResponseBody = GetContextFileUploadUrlResponseBody; exports.GetContextInfoRequest = GetContextInfoRequest; exports.GetContextInfoResponse = GetContextInfoResponse; exports.GetContextInfoResponseBody = GetContextInfoResponseBody; exports.GetContextInfoResponseBodyData = GetContextInfoResponseBodyData; exports.GetContextRequest = GetContextRequest; exports.GetContextResponse = GetContextResponse; exports.GetContextResponseBody = GetContextResponseBody; exports.GetContextResponseBodyData = GetContextResponseBodyData; exports.GetLabelRequest = GetLabelRequest; exports.GetLabelResponse = GetLabelResponse; exports.GetLabelResponseBody = GetLabelResponseBody; exports.GetLabelResponseBodyData = GetLabelResponseBodyData; exports.GetLinkRequest = GetLinkRequest; exports.GetLinkResponse = GetLinkResponse; exports.GetLinkResponseBody = GetLinkResponseBody; exports.GetLinkResponseBodyData = GetLinkResponseBodyData; exports.GetMcpResourceRequest = GetMcpResourceRequest; exports.GetMcpResourceResponse = GetMcpResourceResponse; exports.GetMcpResourceResponseBody = GetMcpResourceResponseBody; exports.GetMcpResourceResponseBodyData = GetMcpResourceResponseBodyData; exports.GetMcpResourceResponseBodyDataDesktopInfo = GetMcpResourceResponseBodyDataDesktopInfo; exports.InitBrowserRequest = InitBrowserRequest; exports.InitBrowserResponse = InitBrowserResponse; exports.InitBrowserResponseBody = InitBrowserResponseBody; exports.InitBrowserResponseBodyData = InitBrowserResponseBodyData; exports.KeyCode = KeyCode; exports.ListContextsRequest = ListContextsRequest; exports.ListContextsResponse = ListContextsResponse; exports.ListContextsResponseBody = ListContextsResponseBody; exports.ListContextsResponseBodyData = ListContextsResponseBodyData; exports.ListMcpToolsRequest = ListMcpToolsRequest; exports.ListMcpToolsResponse = ListMcpToolsResponse; exports.ListMcpToolsResponseBody = ListMcpToolsResponseBody; exports.ListSessionRequest = ListSessionRequest; exports.ListSessionResponse = ListSessionResponse; exports.ListSessionResponseBody = ListSessionResponseBody; exports.ListSessionResponseBodyData = ListSessionResponseBodyData; exports.ModifyContextRequest = ModifyContextRequest; exports.ModifyContextResponse = ModifyContextResponse; exports.ModifyContextResponseBody = ModifyContextResponseBody; exports.Oss = Oss; exports.OssError = OssError; exports.ReleaseMcpSessionRequest = ReleaseMcpSessionRequest; exports.ReleaseMcpSessionResponse = ReleaseMcpSessionResponse; exports.ReleaseMcpSessionResponseBody = ReleaseMcpSessionResponseBody; exports.Session = Session; exports.SessionError = SessionError; exports.SetLabelRequest = SetLabelRequest; exports.SetLabelResponse = SetLabelResponse; exports.SetLabelResponseBody = SetLabelResponseBody; exports.SyncContextRequest = SyncContextRequest; exports.SyncContextResponse = SyncContextResponse; exports.SyncContextResponseBody = SyncContextResponseBody; exports.SyncPolicyImpl = SyncPolicyImpl; exports.UI = UI; exports.UIError = UIError; exports.UploadStrategy = UploadStrategy; exports.loadConfig = loadConfig; exports.loadDotEnv = loadDotEnv; exports.log = log; exports.logError = logError; exports.newContextManager = newContextManager; exports.newContextSync = newContextSync; exports.newCreateSessionParams = newCreateSessionParams; exports.newDeletePolicy = newDeletePolicy; exports.newDownloadPolicy = newDownloadPolicy; exports.newExtractPolicy = newExtractPolicy; exports.newSyncPolicy = newSyncPolicy; exports.newSyncPolicyWithDefaults = newSyncPolicyWithDefaults; exports.newUploadPolicy = newUploadPolicy;
7848
9369
  //# sourceMappingURL=index.cjs.map