@agentrun/sdk 0.0.3-test.21440027550 → 0.0.3-test.21472892602

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
@@ -3918,7 +3918,7 @@ var init_sandbox_data = __esm({
3918
3918
  });
3919
3919
  const data = {
3920
3920
  templateName: params.templateName,
3921
- sandboxIdleTimeoutInSeconds: params.sandboxIdleTimeoutInSeconds || 600
3921
+ sandboxIdleTimeoutSeconds: params.sandboxIdleTimeoutSeconds || 600
3922
3922
  };
3923
3923
  if (params.nasConfig !== void 0) {
3924
3924
  data.nasConfig = params.nasConfig;
@@ -4078,14 +4078,14 @@ var init_model4 = __esm({
4078
4078
  TemplateType2["CUSTOM"] = "CustomImage";
4079
4079
  return TemplateType2;
4080
4080
  })(exports.TemplateType || {});
4081
- exports.SandboxState = /* @__PURE__ */ ((SandboxState2) => {
4082
- SandboxState2["CREATING"] = "Creating";
4083
- SandboxState2["RUNNING"] = "Running";
4084
- SandboxState2["READY"] = "READY";
4085
- SandboxState2["STOPPED"] = "Stopped";
4086
- SandboxState2["FAILED"] = "Failed";
4087
- SandboxState2["DELETING"] = "Deleting";
4088
- return SandboxState2;
4081
+ exports.SandboxState = /* @__PURE__ */ ((SandboxState3) => {
4082
+ SandboxState3["CREATING"] = "Creating";
4083
+ SandboxState3["RUNNING"] = "Running";
4084
+ SandboxState3["READY"] = "READY";
4085
+ SandboxState3["STOPPED"] = "Stopped";
4086
+ SandboxState3["FAILED"] = "Failed";
4087
+ SandboxState3["DELETING"] = "Deleting";
4088
+ return SandboxState3;
4089
4089
  })(exports.SandboxState || {});
4090
4090
  exports.TemplateNetworkMode = /* @__PURE__ */ ((TemplateNetworkMode2) => {
4091
4091
  TemplateNetworkMode2["PUBLIC"] = "PUBLIC";
@@ -4100,6 +4100,7 @@ var init_model4 = __esm({
4100
4100
  })(exports.TemplateOSSPermission || {});
4101
4101
  exports.CodeLanguage = /* @__PURE__ */ ((CodeLanguage2) => {
4102
4102
  CodeLanguage2["PYTHON"] = "python";
4103
+ CodeLanguage2["JAVASCRIPT"] = "javascript";
4103
4104
  return CodeLanguage2;
4104
4105
  })(exports.CodeLanguage || {});
4105
4106
  }
@@ -4385,6 +4386,59 @@ var init_code_interpreter_data = __esm({
4385
4386
  }
4386
4387
  });
4387
4388
 
4389
+ // src/sandbox/api/aio-data.ts
4390
+ exports.AioDataAPI = void 0;
4391
+ var init_aio_data = __esm({
4392
+ "src/sandbox/api/aio-data.ts"() {
4393
+ init_browser_data();
4394
+ init_code_interpreter_data();
4395
+ exports.AioDataAPI = class extends exports.CodeInterpreterDataAPI {
4396
+ browserAPI;
4397
+ constructor(params) {
4398
+ super({
4399
+ sandboxId: params.sandboxId,
4400
+ config: params.config
4401
+ });
4402
+ this.browserAPI = new exports.BrowserDataAPI({
4403
+ sandboxId: params.sandboxId,
4404
+ config: params.config
4405
+ });
4406
+ }
4407
+ // Browser API methods - delegate to browserAPI
4408
+ /**
4409
+ * Get CDP WebSocket URL for browser automation
4410
+ */
4411
+ getCdpUrl(record) {
4412
+ return this.browserAPI.getCdpUrl(record);
4413
+ }
4414
+ /**
4415
+ * Get VNC WebSocket URL for live view
4416
+ */
4417
+ getVncUrl(record) {
4418
+ return this.browserAPI.getVncUrl(record);
4419
+ }
4420
+ /**
4421
+ * List browser recordings
4422
+ */
4423
+ listRecordings = async (params) => {
4424
+ return this.browserAPI.listRecordings(params);
4425
+ };
4426
+ /**
4427
+ * Delete a recording
4428
+ */
4429
+ deleteRecording = async (params) => {
4430
+ return this.browserAPI.deleteRecording(params);
4431
+ };
4432
+ /**
4433
+ * Download a recording
4434
+ */
4435
+ downloadRecording = async (params) => {
4436
+ return this.browserAPI.downloadRecording(params);
4437
+ };
4438
+ };
4439
+ }
4440
+ });
4441
+
4388
4442
  // src/sandbox/code-interpreter-sandbox.ts
4389
4443
  var code_interpreter_sandbox_exports = {};
4390
4444
  __export(code_interpreter_sandbox_exports, {
@@ -4589,25 +4643,25 @@ var init_code_interpreter_sandbox = __esm({
4589
4643
  return result;
4590
4644
  };
4591
4645
  };
4592
- exports.CodeInterpreterSandbox = class _CodeInterpreterSandbox extends exports.Sandbox {
4646
+ exports.CodeInterpreterSandbox = class extends exports.Sandbox {
4593
4647
  static templateType = "CodeInterpreter" /* CODE_INTERPRETER */;
4594
4648
  /**
4595
4649
  * Create a Code Interpreter Sandbox from template
4596
4650
  * 从模板创建代码解释器沙箱 / Create Code Interpreter Sandbox from Template
4597
4651
  */
4598
4652
  static async createFromTemplate(templateName, options, config2) {
4599
- const sandbox = await exports.Sandbox.create(
4600
- {
4653
+ const sandbox = await exports.Sandbox.create({
4654
+ input: {
4601
4655
  templateName,
4602
- sandboxIdleTimeoutInSeconds: options?.sandboxIdleTimeoutInSeconds,
4656
+ sandboxIdleTimeoutSeconds: options?.sandboxIdleTimeoutSeconds,
4603
4657
  nasConfig: options?.nasConfig,
4604
4658
  ossMountConfig: options?.ossMountConfig,
4605
4659
  polarFsConfig: options?.polarFsConfig
4606
4660
  },
4607
- config2
4608
- );
4609
- const ciSandbox = new _CodeInterpreterSandbox(sandbox, config2);
4610
- return ciSandbox;
4661
+ templateType: "CodeInterpreter" /* CODE_INTERPRETER */,
4662
+ config: config2
4663
+ });
4664
+ return sandbox;
4611
4665
  }
4612
4666
  constructor(sandbox, config2) {
4613
4667
  super(sandbox, config2);
@@ -4684,477 +4738,182 @@ var init_code_interpreter_sandbox = __esm({
4684
4738
  }
4685
4739
  });
4686
4740
 
4687
- // src/sandbox/api/aio-data.ts
4688
- exports.AioDataAPI = void 0;
4689
- var init_aio_data = __esm({
4690
- "src/sandbox/api/aio-data.ts"() {
4741
+ // src/sandbox/browser-sandbox.ts
4742
+ var browser_sandbox_exports = {};
4743
+ __export(browser_sandbox_exports, {
4744
+ BrowserSandbox: () => exports.BrowserSandbox
4745
+ });
4746
+ exports.BrowserSandbox = void 0;
4747
+ var init_browser_sandbox = __esm({
4748
+ "src/sandbox/browser-sandbox.ts"() {
4691
4749
  init_browser_data();
4692
- init_code_interpreter_data();
4693
- exports.AioDataAPI = class extends exports.CodeInterpreterDataAPI {
4694
- browserAPI;
4695
- constructor(params) {
4696
- super({
4697
- sandboxId: params.sandboxId,
4698
- config: params.config
4699
- });
4700
- this.browserAPI = new exports.BrowserDataAPI({
4701
- sandboxId: params.sandboxId,
4702
- config: params.config
4750
+ init_model4();
4751
+ init_sandbox();
4752
+ exports.BrowserSandbox = class extends exports.Sandbox {
4753
+ static templateType = "Browser" /* BROWSER */;
4754
+ /**
4755
+ * Create a Browser Sandbox from template
4756
+ * 从模板创建浏览器沙箱 / Create Browser Sandbox from Template
4757
+ */
4758
+ static async createFromTemplate(templateName, options, config2) {
4759
+ const sandbox = await exports.Sandbox.create({
4760
+ input: {
4761
+ templateName,
4762
+ sandboxIdleTimeoutSeconds: options?.sandboxIdleTimeoutSeconds,
4763
+ nasConfig: options?.nasConfig,
4764
+ ossMountConfig: options?.ossMountConfig,
4765
+ polarFsConfig: options?.polarFsConfig
4766
+ },
4767
+ templateType: "Browser" /* BROWSER */,
4768
+ config: config2
4703
4769
  });
4770
+ return sandbox;
4704
4771
  }
4705
- // Browser API methods - delegate to browserAPI
4772
+ constructor(sandbox, config2) {
4773
+ super(sandbox, config2);
4774
+ }
4775
+ _dataApi;
4776
+ /**
4777
+ * Get data API client
4778
+ */
4779
+ get dataApi() {
4780
+ if (!this._dataApi) {
4781
+ if (!this.sandboxId) {
4782
+ throw new Error("Sandbox ID is not set");
4783
+ }
4784
+ this._dataApi = new exports.BrowserDataAPI({
4785
+ sandboxId: this.sandboxId,
4786
+ config: this._config
4787
+ });
4788
+ }
4789
+ return this._dataApi;
4790
+ }
4791
+ /**
4792
+ * Check sandbox health
4793
+ */
4794
+ checkHealth = async (params) => {
4795
+ return this.dataApi.checkHealth({
4796
+ sandboxId: this.sandboxId,
4797
+ config: params?.config
4798
+ });
4799
+ };
4706
4800
  /**
4707
4801
  * Get CDP WebSocket URL for browser automation
4708
4802
  */
4709
4803
  getCdpUrl(record) {
4710
- return this.browserAPI.getCdpUrl(record);
4804
+ return this.dataApi.getCdpUrl(record);
4711
4805
  }
4712
4806
  /**
4713
4807
  * Get VNC WebSocket URL for live view
4714
4808
  */
4715
4809
  getVncUrl(record) {
4716
- return this.browserAPI.getVncUrl(record);
4810
+ return this.dataApi.getVncUrl(record);
4717
4811
  }
4718
4812
  /**
4719
- * List browser recordings
4813
+ * List all recordings
4720
4814
  */
4721
4815
  listRecordings = async (params) => {
4722
- return this.browserAPI.listRecordings(params);
4816
+ return this.dataApi.listRecordings(params);
4723
4817
  };
4724
4818
  /**
4725
- * Delete a recording
4819
+ * Download a recording video file
4726
4820
  */
4727
- deleteRecording = async (params) => {
4728
- return this.browserAPI.deleteRecording(params);
4821
+ downloadRecording = async (params) => {
4822
+ return this.dataApi.downloadRecording(params);
4729
4823
  };
4730
4824
  /**
4731
- * Download a recording
4825
+ * Delete a recording
4732
4826
  */
4733
- downloadRecording = async (params) => {
4734
- return this.browserAPI.downloadRecording(params);
4827
+ deleteRecording = async (params) => {
4828
+ return this.dataApi.deleteRecording(params);
4735
4829
  };
4736
4830
  };
4737
4831
  }
4738
4832
  });
4739
4833
 
4740
- // src/sandbox/aio-sandbox.ts
4741
- var aio_sandbox_exports = {};
4742
- __export(aio_sandbox_exports, {
4743
- AioContextOperations: () => AioContextOperations,
4744
- AioFileOperations: () => AioFileOperations,
4745
- AioFileSystemOperations: () => AioFileSystemOperations,
4746
- AioProcessOperations: () => AioProcessOperations,
4747
- AioSandbox: () => exports.AioSandbox
4834
+ // src/sandbox/custom-sandbox.ts
4835
+ var custom_sandbox_exports = {};
4836
+ __export(custom_sandbox_exports, {
4837
+ CustomSandbox: () => CustomSandbox
4748
4838
  });
4749
- var AioFileOperations, AioFileSystemOperations, AioProcessOperations, AioContextOperations; exports.AioSandbox = void 0;
4750
- var init_aio_sandbox = __esm({
4751
- "src/sandbox/aio-sandbox.ts"() {
4752
- init_log();
4753
- init_exception();
4754
- init_aio_data();
4839
+ var CustomSandbox;
4840
+ var init_custom_sandbox = __esm({
4841
+ "src/sandbox/custom-sandbox.ts"() {
4842
+ init_config();
4755
4843
  init_model4();
4756
4844
  init_sandbox();
4757
- AioFileOperations = class {
4758
- sandbox;
4759
- constructor(sandbox) {
4760
- this.sandbox = sandbox;
4761
- }
4845
+ init_sandbox_data();
4846
+ CustomSandbox = class extends exports.Sandbox {
4847
+ static templateType = "CustomImage" /* CUSTOM */;
4762
4848
  /**
4763
- * Read a file from the sandbox
4849
+ * Create a Custom Sandbox from template
4850
+ * 从模板创建自定义沙箱 / Create Custom Sandbox from Template
4764
4851
  */
4765
- read = async (path2) => {
4766
- return this.sandbox.dataApi.readFile({ path: path2 });
4767
- };
4852
+ static async createFromTemplate(templateName, options, config2) {
4853
+ return await exports.Sandbox.create({
4854
+ input: {
4855
+ templateName,
4856
+ sandboxIdleTimeoutSeconds: options?.sandboxIdleTimeoutSeconds,
4857
+ nasConfig: options?.nasConfig,
4858
+ ossMountConfig: options?.ossMountConfig,
4859
+ polarFsConfig: options?.polarFsConfig
4860
+ },
4861
+ templateType: "CustomImage" /* CUSTOM */,
4862
+ config: config2
4863
+ });
4864
+ }
4865
+ constructor(sandbox, config2) {
4866
+ super(sandbox, config2);
4867
+ }
4868
+ _dataApi;
4768
4869
  /**
4769
- * Write a file to the sandbox
4870
+ * Get data API client
4770
4871
  */
4771
- write = async (params) => {
4772
- return this.sandbox.dataApi.writeFile(params);
4773
- };
4774
- };
4775
- AioFileSystemOperations = class {
4776
- sandbox;
4777
- constructor(sandbox) {
4778
- this.sandbox = sandbox;
4872
+ get dataApi() {
4873
+ if (!this._dataApi) {
4874
+ this._dataApi = new exports.SandboxDataAPI({
4875
+ sandboxId: this.sandboxId || "",
4876
+ config: this._config
4877
+ });
4878
+ }
4879
+ return this._dataApi;
4779
4880
  }
4780
4881
  /**
4781
- * List directory contents
4882
+ * Get base URL for the sandbox
4883
+ * 获取沙箱的基础 URL / Get base URL for the sandbox
4884
+ *
4885
+ * @returns 基础 URL / Base URL
4782
4886
  */
4783
- list = async (params) => {
4784
- return this.sandbox.dataApi.listDirectory(params);
4785
- };
4887
+ getBaseUrl() {
4888
+ const cfg = exports.Config.withConfigs(this._config);
4889
+ return `${cfg.dataEndpoint}/sandboxes/${this.sandboxId}`;
4890
+ }
4891
+ };
4892
+ }
4893
+ });
4894
+
4895
+ // src/sandbox/sandbox.ts
4896
+ exports.Sandbox = void 0;
4897
+ var init_sandbox = __esm({
4898
+ "src/sandbox/sandbox.ts"() {
4899
+ init_utils();
4900
+ init_log();
4901
+ init_config();
4902
+ init_resource();
4903
+ init_model4();
4904
+ init_sandbox_data();
4905
+ exports.Sandbox = class _Sandbox extends ResourceBase {
4906
+ templateType;
4786
4907
  /**
4787
- * Move a file or directory
4908
+ * 沙箱 ID / Sandbox ID
4788
4909
  */
4789
- move = async (params) => {
4790
- return this.sandbox.dataApi.moveFile(params);
4791
- };
4910
+ sandboxId;
4792
4911
  /**
4793
- * Remove a file or directory
4912
+ * 沙箱名称 / Sandbox Name
4794
4913
  */
4795
- remove = async (params) => {
4796
- return this.sandbox.dataApi.removeFile(params);
4797
- };
4914
+ sandboxName;
4798
4915
  /**
4799
- * Get file or directory statistics
4800
- */
4801
- stat = async (params) => {
4802
- return this.sandbox.dataApi.stat(params);
4803
- };
4804
- /**
4805
- * Create a directory
4806
- */
4807
- mkdir = async (params) => {
4808
- return this.sandbox.dataApi.mkdir(params);
4809
- };
4810
- /**
4811
- * Upload a file to the sandbox
4812
- */
4813
- upload = async (params) => {
4814
- return this.sandbox.dataApi.uploadFile(params);
4815
- };
4816
- /**
4817
- * Download a file from the sandbox
4818
- */
4819
- download = async (params) => {
4820
- return this.sandbox.dataApi.downloadFile(params);
4821
- };
4822
- };
4823
- AioProcessOperations = class {
4824
- sandbox;
4825
- constructor(sandbox) {
4826
- this.sandbox = sandbox;
4827
- }
4828
- /**
4829
- * Execute a command in the sandbox
4830
- */
4831
- cmd = async (params) => {
4832
- return this.sandbox.dataApi.cmd(params);
4833
- };
4834
- /**
4835
- * List all processes
4836
- */
4837
- list = async (params) => {
4838
- return this.sandbox.dataApi.listProcesses(params);
4839
- };
4840
- /**
4841
- * Get a specific process by PID
4842
- */
4843
- get = async (params) => {
4844
- return this.sandbox.dataApi.getProcess(params);
4845
- };
4846
- /**
4847
- * Kill a specific process by PID
4848
- */
4849
- kill = async (params) => {
4850
- return this.sandbox.dataApi.killProcess(params);
4851
- };
4852
- };
4853
- AioContextOperations = class {
4854
- sandbox;
4855
- _contextId;
4856
- _language;
4857
- _cwd;
4858
- constructor(sandbox) {
4859
- this.sandbox = sandbox;
4860
- }
4861
- /**
4862
- * Get the current context ID
4863
- */
4864
- get contextId() {
4865
- return this._contextId;
4866
- }
4867
- /**
4868
- * List all contexts
4869
- */
4870
- list = async (params) => {
4871
- return this.sandbox.dataApi.listContexts(params);
4872
- };
4873
- /**
4874
- * Create a new context and save its ID
4875
- */
4876
- create = async (params) => {
4877
- const language = params?.language || "python" /* PYTHON */;
4878
- const cwd = params?.cwd || "/home/user";
4879
- const result = await this.sandbox.dataApi.createContext({
4880
- language,
4881
- cwd
4882
- });
4883
- if (result?.id && result?.cwd && result?.language) {
4884
- this._contextId = result.id;
4885
- this._language = result.language;
4886
- this._cwd = result.cwd;
4887
- return this;
4888
- }
4889
- throw new exports.ServerError(500, "Failed to create context");
4890
- };
4891
- /**
4892
- * Get a specific context by ID
4893
- */
4894
- get = async (params) => {
4895
- const id = params?.contextId || this._contextId;
4896
- if (!id) {
4897
- logger.error("context id is not set");
4898
- throw new Error("context id is not set");
4899
- }
4900
- const result = await this.sandbox.dataApi.getContext({ contextId: id });
4901
- if (result?.id && result?.cwd && result?.language) {
4902
- this._contextId = result.id;
4903
- this._language = result.language;
4904
- this._cwd = result.cwd;
4905
- return this;
4906
- }
4907
- throw new exports.ServerError(500, "Failed to get context");
4908
- };
4909
- /**
4910
- * Execute code in a context
4911
- */
4912
- execute = async (params) => {
4913
- const { code, timeout = 30 } = params;
4914
- let { contextId, language } = params;
4915
- if (!contextId) {
4916
- contextId = this._contextId;
4917
- }
4918
- if (!contextId && !language) {
4919
- logger.debug("context id is not set, use default language: python");
4920
- language = "python" /* PYTHON */;
4921
- }
4922
- return this.sandbox.dataApi.executeCode({
4923
- code,
4924
- contextId,
4925
- language,
4926
- timeout
4927
- });
4928
- };
4929
- /**
4930
- * Delete a context
4931
- */
4932
- delete = async (params) => {
4933
- const id = params?.contextId || this._contextId;
4934
- if (!id) {
4935
- throw new Error(
4936
- "context_id is required. Either pass it as parameter or create a context first."
4937
- );
4938
- }
4939
- const result = await this.sandbox.dataApi.deleteContext({ contextId: id });
4940
- this._contextId = void 0;
4941
- return result;
4942
- };
4943
- };
4944
- exports.AioSandbox = class _AioSandbox extends exports.Sandbox {
4945
- static templateType = "AllInOne" /* AIO */;
4946
- /**
4947
- * Create an AIO Sandbox from template
4948
- * 从模板创建 AIO 沙箱 / Create AIO Sandbox from Template
4949
- */
4950
- static async createFromTemplate(templateName, options, config2) {
4951
- const sandbox = await exports.Sandbox.create(
4952
- {
4953
- templateName,
4954
- sandboxIdleTimeoutInSeconds: options?.sandboxIdleTimeoutInSeconds,
4955
- nasConfig: options?.nasConfig,
4956
- ossMountConfig: options?.ossMountConfig,
4957
- polarFsConfig: options?.polarFsConfig
4958
- },
4959
- config2
4960
- );
4961
- const aioSandbox = new _AioSandbox(sandbox, config2);
4962
- return aioSandbox;
4963
- }
4964
- constructor(sandbox, config2) {
4965
- super(sandbox, config2);
4966
- }
4967
- _dataApi;
4968
- _file;
4969
- _fileSystem;
4970
- _context;
4971
- _process;
4972
- /**
4973
- * Get data API client
4974
- */
4975
- get dataApi() {
4976
- if (!this._dataApi) {
4977
- this._dataApi = new exports.AioDataAPI({
4978
- sandboxId: this.sandboxId || "",
4979
- config: this._config
4980
- });
4981
- }
4982
- return this._dataApi;
4983
- }
4984
- /**
4985
- * Access file upload/download operations
4986
- */
4987
- get file() {
4988
- if (!this._file) {
4989
- this._file = new AioFileOperations(this);
4990
- }
4991
- return this._file;
4992
- }
4993
- /**
4994
- * Access file system operations
4995
- */
4996
- get fileSystem() {
4997
- if (!this._fileSystem) {
4998
- this._fileSystem = new AioFileSystemOperations(this);
4999
- }
5000
- return this._fileSystem;
5001
- }
5002
- /**
5003
- * Access context management operations
5004
- */
5005
- get context() {
5006
- if (!this._context) {
5007
- this._context = new AioContextOperations(this);
5008
- }
5009
- return this._context;
5010
- }
5011
- /**
5012
- * Access process management operations
5013
- */
5014
- get process() {
5015
- if (!this._process) {
5016
- this._process = new AioProcessOperations(this);
5017
- }
5018
- return this._process;
5019
- }
5020
- /**
5021
- * Check sandbox health
5022
- */
5023
- checkHealth = async (params) => {
5024
- return this.dataApi.checkHealth({
5025
- sandboxId: this.sandboxId,
5026
- config: params?.config
5027
- });
5028
- };
5029
- // ========================================
5030
- // Browser API Methods
5031
- // ========================================
5032
- /**
5033
- * Get CDP WebSocket URL for browser automation
5034
- */
5035
- getCdpUrl(record) {
5036
- return this.dataApi.getCdpUrl(record);
5037
- }
5038
- /**
5039
- * Get VNC WebSocket URL for live view
5040
- */
5041
- getVncUrl(record) {
5042
- return this.dataApi.getVncUrl(record);
5043
- }
5044
- /**
5045
- * List all browser recordings
5046
- */
5047
- listRecordings = async (params) => {
5048
- return this.dataApi.listRecordings(params);
5049
- };
5050
- /**
5051
- * Download a recording video file
5052
- */
5053
- downloadRecording = async (params) => {
5054
- return this.dataApi.downloadRecording(params);
5055
- };
5056
- /**
5057
- * Delete a recording
5058
- */
5059
- deleteRecording = async (params) => {
5060
- return this.dataApi.deleteRecording(params);
5061
- };
5062
- // ========================================
5063
- // Code Interpreter API Methods
5064
- // ========================================
5065
- /**
5066
- * Execute code (convenience method delegating to context.execute)
5067
- */
5068
- execute = async (params) => {
5069
- return this.context.execute(params);
5070
- };
5071
- };
5072
- }
5073
- });
5074
-
5075
- // src/sandbox/custom-sandbox.ts
5076
- var custom_sandbox_exports = {};
5077
- __export(custom_sandbox_exports, {
5078
- CustomSandbox: () => CustomSandbox
5079
- });
5080
- var CustomSandbox;
5081
- var init_custom_sandbox = __esm({
5082
- "src/sandbox/custom-sandbox.ts"() {
5083
- init_config();
5084
- init_model4();
5085
- init_sandbox();
5086
- init_sandbox_data();
5087
- CustomSandbox = class _CustomSandbox extends exports.Sandbox {
5088
- static templateType = "CustomImage" /* CUSTOM */;
5089
- /**
5090
- * Create a Custom Sandbox from template
5091
- * 从模板创建自定义沙箱 / Create Custom Sandbox from Template
5092
- */
5093
- static async createFromTemplate(templateName, options, config2) {
5094
- const sandbox = await exports.Sandbox.create(
5095
- {
5096
- templateName,
5097
- sandboxIdleTimeoutInSeconds: options?.sandboxIdleTimeoutInSeconds,
5098
- nasConfig: options?.nasConfig,
5099
- ossMountConfig: options?.ossMountConfig,
5100
- polarFsConfig: options?.polarFsConfig
5101
- },
5102
- config2
5103
- );
5104
- const customSandbox = new _CustomSandbox(sandbox, config2);
5105
- return customSandbox;
5106
- }
5107
- constructor(sandbox, config2) {
5108
- super(sandbox, config2);
5109
- }
5110
- _dataApi;
5111
- /**
5112
- * Get data API client
5113
- */
5114
- get dataApi() {
5115
- if (!this._dataApi) {
5116
- this._dataApi = new exports.SandboxDataAPI({
5117
- sandboxId: this.sandboxId || "",
5118
- config: this._config
5119
- });
5120
- }
5121
- return this._dataApi;
5122
- }
5123
- /**
5124
- * Get base URL for the sandbox
5125
- * 获取沙箱的基础 URL / Get base URL for the sandbox
5126
- *
5127
- * @returns 基础 URL / Base URL
5128
- */
5129
- getBaseUrl() {
5130
- const cfg = exports.Config.withConfigs(this._config);
5131
- return `${cfg.dataEndpoint}/sandboxes/${this.sandboxId}`;
5132
- }
5133
- };
5134
- }
5135
- });
5136
-
5137
- // src/sandbox/sandbox.ts
5138
- exports.Sandbox = void 0;
5139
- var init_sandbox = __esm({
5140
- "src/sandbox/sandbox.ts"() {
5141
- init_utils();
5142
- init_config();
5143
- init_resource();
5144
- init_model4();
5145
- init_sandbox_data();
5146
- exports.Sandbox = class _Sandbox extends ResourceBase {
5147
- templateType;
5148
- /**
5149
- * 沙箱 ID / Sandbox ID
5150
- */
5151
- sandboxId;
5152
- /**
5153
- * 沙箱名称 / Sandbox Name
5154
- */
5155
- sandboxName;
5156
- /**
5157
- * 模板 ID / Template ID
4916
+ * 模板 ID / Template ID
5158
4917
  */
5159
4918
  templateId;
5160
4919
  /**
@@ -5180,7 +4939,7 @@ var init_sandbox = __esm({
5180
4939
  /**
5181
4940
  * 沙箱空闲超时时间(秒) / Sandbox Idle Timeout (seconds)
5182
4941
  */
5183
- sandboxIdleTimeoutInSeconds;
4942
+ sandboxIdleTimeoutSeconds;
5184
4943
  /**
5185
4944
  * 沙箱结束时间 / Sandbox End Time
5186
4945
  */
@@ -5221,7 +4980,7 @@ var init_sandbox = __esm({
5221
4980
  stateReason: obj.stateReason,
5222
4981
  createdAt: obj.createdAt,
5223
4982
  lastUpdatedAt: obj.lastUpdatedAt,
5224
- sandboxIdleTimeoutInSeconds: obj.sandboxIdleTimeoutInSeconds,
4983
+ sandboxIdleTimeoutSeconds: obj.sandboxIdleTimeoutSeconds,
5225
4984
  // New fields / 新增字段
5226
4985
  endedAt: obj.endedAt,
5227
4986
  metadata: obj.metadata,
@@ -5235,32 +4994,53 @@ var init_sandbox = __esm({
5235
4994
  const { SandboxClient: SandboxClient2 } = (init_client3(), __toCommonJS(client_exports3));
5236
4995
  return new SandboxClient2();
5237
4996
  }
5238
- /**
5239
- * Create a new Sandbox
5240
- * 创建新沙箱 / Create a New Sandbox
5241
- */
5242
- static async create(input, config2) {
5243
- return await _Sandbox.getClient().createSandbox({ input, config: config2 });
4997
+ static async create(arg1, arg2) {
4998
+ if (typeof arg1 === "object" && arg1 !== null && "input" in arg1) {
4999
+ return await _Sandbox.getClient().createSandbox(arg1);
5000
+ }
5001
+ logger.warn(
5002
+ "Deprecated: Sandbox.create(input, config) is deprecated. Use Sandbox.create({ input, config }) instead."
5003
+ );
5004
+ return await _Sandbox.getClient().createSandbox(arg1, arg2);
5244
5005
  }
5245
- /**
5246
- * Delete a Sandbox by ID
5247
- */
5248
- static async delete(params) {
5249
- const { id, config: config2 } = params;
5250
- return await _Sandbox.getClient().deleteSandbox({ id, config: config2 });
5006
+ static async delete(arg1, arg2) {
5007
+ if (typeof arg1 === "string") {
5008
+ logger.warn(
5009
+ "Sandbox.delete(id, config) is deprecated. Use Sandbox.delete({ id, config }) instead."
5010
+ );
5011
+ return await _Sandbox.getClient().deleteSandbox(arg1, arg2);
5012
+ }
5013
+ return await _Sandbox.getClient().deleteSandbox(arg1);
5251
5014
  }
5252
- /**
5253
- * Stop a Sandbox by ID
5254
- */
5255
- static async stop(params) {
5256
- const { id, config: config2 } = params;
5257
- return await _Sandbox.getClient().stopSandbox({ id, config: config2 });
5015
+ static async stop(arg1, arg2) {
5016
+ if (typeof arg1 === "string") {
5017
+ logger.warn(
5018
+ "Sandbox.stop(id, config) is deprecated. Use Sandbox.stop({ id, config }) instead."
5019
+ );
5020
+ return await _Sandbox.getClient().stopSandbox(arg1, arg2);
5021
+ }
5022
+ return await _Sandbox.getClient().stopSandbox(arg1);
5258
5023
  }
5259
- /**
5260
- * Get a Sandbox by ID
5261
- */
5262
- static async get(params) {
5263
- const { id, templateType, config: config2 } = params;
5024
+ static async get(arg1, arg2, arg3) {
5025
+ let id;
5026
+ let templateType;
5027
+ let config2;
5028
+ if (typeof arg1 === "string") {
5029
+ logger.warn(
5030
+ "Deprecated: Sandbox.get(id, templateType?, config?) is deprecated. Use Sandbox.get({ id, templateType, config }) instead."
5031
+ );
5032
+ id = arg1;
5033
+ if (arg2 && typeof arg2 === "string") {
5034
+ templateType = arg2;
5035
+ config2 = arg3;
5036
+ } else {
5037
+ config2 = arg2;
5038
+ }
5039
+ } else {
5040
+ id = arg1.id;
5041
+ templateType = arg1.templateType;
5042
+ config2 = arg1.config;
5043
+ }
5264
5044
  try {
5265
5045
  const cfg = exports.Config.withConfigs(config2);
5266
5046
  const dataApi = new exports.SandboxDataAPI({
@@ -5311,11 +5091,19 @@ var init_sandbox = __esm({
5311
5091
  throw error;
5312
5092
  }
5313
5093
  }
5314
- /**
5315
- * List Sandboxes
5316
- */
5317
- static async list(input, config2) {
5318
- return await _Sandbox.getClient().listSandboxes({ input, config: config2 });
5094
+ static async list(arg1, arg2) {
5095
+ if (arg2 !== void 0 || arg1 && ("maxResults" in arg1 || "nextToken" in arg1 || "status" in arg1 || "templateName" in arg1 || "templateType" in arg1)) {
5096
+ logger.warn(
5097
+ "Deprecated: Sandbox.list(input, config) is deprecated. Use Sandbox.list({ input, config }) instead."
5098
+ );
5099
+ return await _Sandbox.getClient().listSandboxes(
5100
+ arg1,
5101
+ arg2
5102
+ );
5103
+ }
5104
+ return await _Sandbox.getClient().listSandboxes(
5105
+ arg1
5106
+ );
5319
5107
  }
5320
5108
  get = async (params) => {
5321
5109
  const { config: config2 } = params ?? {};
@@ -5326,128 +5114,358 @@ var init_sandbox = __esm({
5326
5114
  });
5327
5115
  };
5328
5116
  /**
5329
- * Delete this sandbox
5117
+ * Delete this sandbox
5118
+ */
5119
+ delete = async (params) => {
5120
+ const config2 = params?.config;
5121
+ if (!this.sandboxId) {
5122
+ throw new Error("sandboxId is required to delete a Sandbox");
5123
+ }
5124
+ const result = await _Sandbox.delete({
5125
+ id: this.sandboxId,
5126
+ config: config2 ?? this._config
5127
+ });
5128
+ updateObjectProperties(this, result);
5129
+ return this;
5130
+ };
5131
+ /**
5132
+ * Stop this sandbox
5133
+ */
5134
+ stop = async (params) => {
5135
+ const config2 = params?.config;
5136
+ if (!this.sandboxId) {
5137
+ throw new Error("sandboxId is required to stop a Sandbox");
5138
+ }
5139
+ const result = await _Sandbox.stop({
5140
+ id: this.sandboxId,
5141
+ config: config2 ?? this._config
5142
+ });
5143
+ updateObjectProperties(this, result);
5144
+ return this;
5145
+ };
5146
+ /**
5147
+ * Refresh this sandbox's data
5148
+ */
5149
+ refresh = async (params) => {
5150
+ const config2 = params?.config;
5151
+ if (!this.sandboxId) {
5152
+ throw new Error("sandboxId is required to refresh a Sandbox");
5153
+ }
5154
+ const result = await _Sandbox.get({
5155
+ id: this.sandboxId,
5156
+ config: config2 ?? this._config
5157
+ });
5158
+ updateObjectProperties(this, result);
5159
+ return this;
5160
+ };
5161
+ /**
5162
+ * Wait until the sandbox is running
5163
+ */
5164
+ waitUntilRunning = async (options, config2) => {
5165
+ const timeout = (options?.timeoutSeconds ?? 300) * 1e3;
5166
+ const interval = (options?.intervalSeconds ?? 5) * 1e3;
5167
+ const startTime = Date.now();
5168
+ while (Date.now() - startTime < timeout) {
5169
+ await this.refresh({ config: config2 });
5170
+ if (options?.beforeCheck) {
5171
+ options.beforeCheck(this);
5172
+ }
5173
+ if (this.state === "Running" /* RUNNING */ || this.state === "READY" /* READY */) {
5174
+ return this;
5175
+ }
5176
+ if (this.state === "Failed" /* FAILED */) {
5177
+ throw new Error(`Sandbox failed: ${this.stateReason}`);
5178
+ }
5179
+ await new Promise((resolve) => setTimeout(resolve, interval));
5180
+ }
5181
+ throw new Error(
5182
+ `Timeout waiting for Sandbox to be running after ${options?.timeoutSeconds ?? 300} seconds`
5183
+ );
5184
+ };
5185
+ };
5186
+ }
5187
+ });
5188
+
5189
+ // src/sandbox/aio-sandbox.ts
5190
+ var aio_sandbox_exports = {};
5191
+ __export(aio_sandbox_exports, {
5192
+ AioContextOperations: () => AioContextOperations,
5193
+ AioFileOperations: () => AioFileOperations,
5194
+ AioFileSystemOperations: () => AioFileSystemOperations,
5195
+ AioProcessOperations: () => AioProcessOperations,
5196
+ AioSandbox: () => exports.AioSandbox
5197
+ });
5198
+ var AioFileOperations, AioFileSystemOperations, AioProcessOperations, AioContextOperations; exports.AioSandbox = void 0;
5199
+ var init_aio_sandbox = __esm({
5200
+ "src/sandbox/aio-sandbox.ts"() {
5201
+ init_log();
5202
+ init_exception();
5203
+ init_aio_data();
5204
+ init_model4();
5205
+ init_sandbox();
5206
+ AioFileOperations = class {
5207
+ sandbox;
5208
+ constructor(sandbox) {
5209
+ this.sandbox = sandbox;
5210
+ }
5211
+ /**
5212
+ * Read a file from the sandbox
5213
+ */
5214
+ read = async (path2) => {
5215
+ return this.sandbox.dataApi.readFile({ path: path2 });
5216
+ };
5217
+ /**
5218
+ * Write a file to the sandbox
5219
+ */
5220
+ write = async (params) => {
5221
+ return this.sandbox.dataApi.writeFile(params);
5222
+ };
5223
+ };
5224
+ AioFileSystemOperations = class {
5225
+ sandbox;
5226
+ constructor(sandbox) {
5227
+ this.sandbox = sandbox;
5228
+ }
5229
+ /**
5230
+ * List directory contents
5231
+ */
5232
+ list = async (params) => {
5233
+ return this.sandbox.dataApi.listDirectory(params);
5234
+ };
5235
+ /**
5236
+ * Move a file or directory
5237
+ */
5238
+ move = async (params) => {
5239
+ return this.sandbox.dataApi.moveFile(params);
5240
+ };
5241
+ /**
5242
+ * Remove a file or directory
5243
+ */
5244
+ remove = async (params) => {
5245
+ return this.sandbox.dataApi.removeFile(params);
5246
+ };
5247
+ /**
5248
+ * Get file or directory statistics
5249
+ */
5250
+ stat = async (params) => {
5251
+ return this.sandbox.dataApi.stat(params);
5252
+ };
5253
+ /**
5254
+ * Create a directory
5255
+ */
5256
+ mkdir = async (params) => {
5257
+ return this.sandbox.dataApi.mkdir(params);
5258
+ };
5259
+ /**
5260
+ * Upload a file to the sandbox
5261
+ */
5262
+ upload = async (params) => {
5263
+ return this.sandbox.dataApi.uploadFile(params);
5264
+ };
5265
+ /**
5266
+ * Download a file from the sandbox
5267
+ */
5268
+ download = async (params) => {
5269
+ return this.sandbox.dataApi.downloadFile(params);
5270
+ };
5271
+ };
5272
+ AioProcessOperations = class {
5273
+ sandbox;
5274
+ constructor(sandbox) {
5275
+ this.sandbox = sandbox;
5276
+ }
5277
+ /**
5278
+ * Execute a command in the sandbox
5279
+ */
5280
+ cmd = async (params) => {
5281
+ return this.sandbox.dataApi.cmd(params);
5282
+ };
5283
+ /**
5284
+ * List all processes
5285
+ */
5286
+ list = async (params) => {
5287
+ return this.sandbox.dataApi.listProcesses(params);
5288
+ };
5289
+ /**
5290
+ * Get a specific process by PID
5291
+ */
5292
+ get = async (params) => {
5293
+ return this.sandbox.dataApi.getProcess(params);
5294
+ };
5295
+ /**
5296
+ * Kill a specific process by PID
5297
+ */
5298
+ kill = async (params) => {
5299
+ return this.sandbox.dataApi.killProcess(params);
5300
+ };
5301
+ };
5302
+ AioContextOperations = class {
5303
+ sandbox;
5304
+ _contextId;
5305
+ _language;
5306
+ _cwd;
5307
+ constructor(sandbox) {
5308
+ this.sandbox = sandbox;
5309
+ }
5310
+ /**
5311
+ * Get the current context ID
5312
+ */
5313
+ get contextId() {
5314
+ return this._contextId;
5315
+ }
5316
+ /**
5317
+ * List all contexts
5318
+ */
5319
+ list = async (params) => {
5320
+ return this.sandbox.dataApi.listContexts(params);
5321
+ };
5322
+ /**
5323
+ * Create a new context and save its ID
5330
5324
  */
5331
- delete = async (params) => {
5332
- const config2 = params?.config;
5333
- if (!this.sandboxId) {
5334
- throw new Error("sandboxId is required to delete a Sandbox");
5335
- }
5336
- const result = await _Sandbox.delete({
5337
- id: this.sandboxId,
5338
- config: config2 ?? this._config
5325
+ create = async (params) => {
5326
+ const language = params?.language || "python" /* PYTHON */;
5327
+ const cwd = params?.cwd || "/home/user";
5328
+ const result = await this.sandbox.dataApi.createContext({
5329
+ language,
5330
+ cwd
5339
5331
  });
5340
- updateObjectProperties(this, result);
5341
- return this;
5332
+ if (result?.id && result?.cwd && result?.language) {
5333
+ this._contextId = result.id;
5334
+ this._language = result.language;
5335
+ this._cwd = result.cwd;
5336
+ return this;
5337
+ }
5338
+ throw new exports.ServerError(500, "Failed to create context");
5342
5339
  };
5343
5340
  /**
5344
- * Stop this sandbox
5341
+ * Get a specific context by ID
5345
5342
  */
5346
- stop = async (params) => {
5347
- const config2 = params?.config;
5348
- if (!this.sandboxId) {
5349
- throw new Error("sandboxId is required to stop a Sandbox");
5343
+ get = async (params) => {
5344
+ const id = params?.contextId || this._contextId;
5345
+ if (!id) {
5346
+ logger.error("context id is not set");
5347
+ throw new Error("context id is not set");
5350
5348
  }
5351
- const result = await _Sandbox.stop({
5352
- id: this.sandboxId,
5353
- config: config2 ?? this._config
5354
- });
5355
- updateObjectProperties(this, result);
5356
- return this;
5349
+ const result = await this.sandbox.dataApi.getContext({ contextId: id });
5350
+ if (result?.id && result?.cwd && result?.language) {
5351
+ this._contextId = result.id;
5352
+ this._language = result.language;
5353
+ this._cwd = result.cwd;
5354
+ return this;
5355
+ }
5356
+ throw new exports.ServerError(500, "Failed to get context");
5357
5357
  };
5358
5358
  /**
5359
- * Refresh this sandbox's data
5359
+ * Execute code in a context
5360
5360
  */
5361
- refresh = async (params) => {
5362
- const config2 = params?.config;
5363
- if (!this.sandboxId) {
5364
- throw new Error("sandboxId is required to refresh a Sandbox");
5361
+ execute = async (params) => {
5362
+ const { code, timeout = 30 } = params;
5363
+ let { contextId, language } = params;
5364
+ if (!contextId) {
5365
+ contextId = this._contextId;
5365
5366
  }
5366
- const result = await _Sandbox.get({
5367
- id: this.sandboxId,
5368
- config: config2 ?? this._config
5367
+ if (!contextId && !language) {
5368
+ logger.debug("context id is not set, use default language: python");
5369
+ language = "python" /* PYTHON */;
5370
+ }
5371
+ return this.sandbox.dataApi.executeCode({
5372
+ code,
5373
+ contextId,
5374
+ language,
5375
+ timeout
5369
5376
  });
5370
- updateObjectProperties(this, result);
5371
- return this;
5372
5377
  };
5373
5378
  /**
5374
- * Wait until the sandbox is running
5379
+ * Delete a context
5375
5380
  */
5376
- waitUntilRunning = async (options, config2) => {
5377
- const timeout = (options?.timeoutSeconds ?? 300) * 1e3;
5378
- const interval = (options?.intervalSeconds ?? 5) * 1e3;
5379
- const startTime = Date.now();
5380
- while (Date.now() - startTime < timeout) {
5381
- await this.refresh({ config: config2 });
5382
- if (options?.beforeCheck) {
5383
- options.beforeCheck(this);
5384
- }
5385
- if (this.state === "Running" /* RUNNING */ || this.state === "READY" /* READY */) {
5386
- return this;
5387
- }
5388
- if (this.state === "Failed" /* FAILED */) {
5389
- throw new Error(`Sandbox failed: ${this.stateReason}`);
5390
- }
5391
- await new Promise((resolve) => setTimeout(resolve, interval));
5381
+ delete = async (params) => {
5382
+ const id = params?.contextId || this._contextId;
5383
+ if (!id) {
5384
+ throw new Error(
5385
+ "context_id is required. Either pass it as parameter or create a context first."
5386
+ );
5392
5387
  }
5393
- throw new Error(
5394
- `Timeout waiting for Sandbox to be running after ${options?.timeoutSeconds ?? 300} seconds`
5395
- );
5388
+ const result = await this.sandbox.dataApi.deleteContext({ contextId: id });
5389
+ this._contextId = void 0;
5390
+ return result;
5396
5391
  };
5397
5392
  };
5398
- }
5399
- });
5400
-
5401
- // src/sandbox/browser-sandbox.ts
5402
- var browser_sandbox_exports = {};
5403
- __export(browser_sandbox_exports, {
5404
- BrowserSandbox: () => exports.BrowserSandbox
5405
- });
5406
- exports.BrowserSandbox = void 0;
5407
- var init_browser_sandbox = __esm({
5408
- "src/sandbox/browser-sandbox.ts"() {
5409
- init_browser_data();
5410
- init_model4();
5411
- init_sandbox();
5412
- exports.BrowserSandbox = class _BrowserSandbox extends exports.Sandbox {
5413
- static templateType = "Browser" /* BROWSER */;
5393
+ exports.AioSandbox = class extends exports.Sandbox {
5394
+ static templateType = "AllInOne" /* AIO */;
5414
5395
  /**
5415
- * Create a Browser Sandbox from template
5416
- * 从模板创建浏览器沙箱 / Create Browser Sandbox from Template
5396
+ * Create an AIO Sandbox from template
5397
+ * 从模板创建 AIO 沙箱 / Create AIO Sandbox from Template
5417
5398
  */
5418
5399
  static async createFromTemplate(templateName, options, config2) {
5419
- const sandbox = await exports.Sandbox.create(
5420
- {
5400
+ const sandbox = await exports.Sandbox.create({
5401
+ input: {
5421
5402
  templateName,
5422
- sandboxIdleTimeoutInSeconds: options?.sandboxIdleTimeoutInSeconds,
5403
+ sandboxIdleTimeoutSeconds: options?.sandboxIdleTimeoutSeconds,
5423
5404
  nasConfig: options?.nasConfig,
5424
5405
  ossMountConfig: options?.ossMountConfig,
5425
5406
  polarFsConfig: options?.polarFsConfig
5426
5407
  },
5427
- config2
5428
- );
5429
- const browserSandbox = new _BrowserSandbox(sandbox, config2);
5430
- return browserSandbox;
5408
+ templateType: "AllInOne" /* AIO */,
5409
+ config: config2
5410
+ });
5411
+ return sandbox;
5431
5412
  }
5432
5413
  constructor(sandbox, config2) {
5433
5414
  super(sandbox, config2);
5434
5415
  }
5435
5416
  _dataApi;
5417
+ _file;
5418
+ _fileSystem;
5419
+ _context;
5420
+ _process;
5436
5421
  /**
5437
5422
  * Get data API client
5438
5423
  */
5439
5424
  get dataApi() {
5440
5425
  if (!this._dataApi) {
5441
- if (!this.sandboxId) {
5442
- throw new Error("Sandbox ID is not set");
5443
- }
5444
- this._dataApi = new exports.BrowserDataAPI({
5445
- sandboxId: this.sandboxId,
5426
+ this._dataApi = new exports.AioDataAPI({
5427
+ sandboxId: this.sandboxId || "",
5446
5428
  config: this._config
5447
5429
  });
5448
5430
  }
5449
5431
  return this._dataApi;
5450
5432
  }
5433
+ /**
5434
+ * Access file upload/download operations
5435
+ */
5436
+ get file() {
5437
+ if (!this._file) {
5438
+ this._file = new AioFileOperations(this);
5439
+ }
5440
+ return this._file;
5441
+ }
5442
+ /**
5443
+ * Access file system operations
5444
+ */
5445
+ get fileSystem() {
5446
+ if (!this._fileSystem) {
5447
+ this._fileSystem = new AioFileSystemOperations(this);
5448
+ }
5449
+ return this._fileSystem;
5450
+ }
5451
+ /**
5452
+ * Access context management operations
5453
+ */
5454
+ get context() {
5455
+ if (!this._context) {
5456
+ this._context = new AioContextOperations(this);
5457
+ }
5458
+ return this._context;
5459
+ }
5460
+ /**
5461
+ * Access process management operations
5462
+ */
5463
+ get process() {
5464
+ if (!this._process) {
5465
+ this._process = new AioProcessOperations(this);
5466
+ }
5467
+ return this._process;
5468
+ }
5451
5469
  /**
5452
5470
  * Check sandbox health
5453
5471
  */
@@ -5457,6 +5475,9 @@ var init_browser_sandbox = __esm({
5457
5475
  config: params?.config
5458
5476
  });
5459
5477
  };
5478
+ // ========================================
5479
+ // Browser API Methods
5480
+ // ========================================
5460
5481
  /**
5461
5482
  * Get CDP WebSocket URL for browser automation
5462
5483
  */
@@ -5470,7 +5491,7 @@ var init_browser_sandbox = __esm({
5470
5491
  return this.dataApi.getVncUrl(record);
5471
5492
  }
5472
5493
  /**
5473
- * List all recordings
5494
+ * List all browser recordings
5474
5495
  */
5475
5496
  listRecordings = async (params) => {
5476
5497
  return this.dataApi.listRecordings(params);
@@ -5487,6 +5508,15 @@ var init_browser_sandbox = __esm({
5487
5508
  deleteRecording = async (params) => {
5488
5509
  return this.dataApi.deleteRecording(params);
5489
5510
  };
5511
+ // ========================================
5512
+ // Code Interpreter API Methods
5513
+ // ========================================
5514
+ /**
5515
+ * Execute code (convenience method delegating to context.execute)
5516
+ */
5517
+ execute = async (params) => {
5518
+ return this.context.execute(params);
5519
+ };
5490
5520
  };
5491
5521
  }
5492
5522
  });
@@ -5570,6 +5600,7 @@ var init_template = __esm({
5570
5600
  super();
5571
5601
  if (data) {
5572
5602
  updateObjectProperties(this, data);
5603
+ this.normalizeNumericFields();
5573
5604
  }
5574
5605
  this._config = config2;
5575
5606
  }
@@ -5582,36 +5613,31 @@ var init_template = __esm({
5582
5613
  * Create a new Template
5583
5614
  */
5584
5615
  static async create(params) {
5585
- const { input, config: config2 } = params;
5586
- return await _Template.getClient().createTemplate({ input, config: config2 });
5616
+ return await _Template.getClient().createTemplate(params);
5587
5617
  }
5588
5618
  /**
5589
5619
  * Delete a Template by name
5590
5620
  */
5591
5621
  static async delete(params) {
5592
- const { name, config: config2 } = params;
5593
- return await _Template.getClient().deleteTemplate({ name, config: config2 });
5622
+ return await _Template.getClient().deleteTemplate(params);
5594
5623
  }
5595
5624
  /**
5596
5625
  * Update a Template by name
5597
5626
  */
5598
5627
  static async update(params) {
5599
- const { name, input, config: config2 } = params;
5600
- return await _Template.getClient().updateTemplate({ name, input, config: config2 });
5628
+ return await _Template.getClient().updateTemplate(params);
5601
5629
  }
5602
5630
  /**
5603
5631
  * Get a Template by name
5604
5632
  */
5605
5633
  static async get(params) {
5606
- const { name, config: config2 } = params;
5607
- return await _Template.getClient().getTemplate({ name, config: config2 });
5634
+ return await _Template.getClient().getTemplate(params);
5608
5635
  }
5609
5636
  /**
5610
5637
  * List Templates
5611
5638
  */
5612
5639
  static async list(params) {
5613
- const { input, config: config2 } = params ?? {};
5614
- return await _Template.getClient().listTemplates({ input, config: config2 });
5640
+ return await _Template.getClient().listTemplates(params);
5615
5641
  }
5616
5642
  /**
5617
5643
  * List all Templates (with pagination)
@@ -5636,6 +5662,7 @@ var init_template = __esm({
5636
5662
  config: config2 ?? this._config
5637
5663
  });
5638
5664
  updateObjectProperties(this, result);
5665
+ this.normalizeNumericFields();
5639
5666
  return this;
5640
5667
  };
5641
5668
  /**
@@ -5652,6 +5679,7 @@ var init_template = __esm({
5652
5679
  config: config2 ?? this._config
5653
5680
  });
5654
5681
  updateObjectProperties(this, result);
5682
+ this.normalizeNumericFields();
5655
5683
  return this;
5656
5684
  };
5657
5685
  /**
@@ -5667,8 +5695,29 @@ var init_template = __esm({
5667
5695
  config: config2 ?? this._config
5668
5696
  });
5669
5697
  updateObjectProperties(this, result);
5698
+ this.normalizeNumericFields();
5670
5699
  return this;
5671
5700
  };
5701
+ normalizeNumericFields() {
5702
+ const toNumber = (value) => {
5703
+ if (typeof value === "number") return value;
5704
+ if (typeof value === "string") {
5705
+ const parsed = Number(value);
5706
+ return Number.isNaN(parsed) ? void 0 : parsed;
5707
+ }
5708
+ return void 0;
5709
+ };
5710
+ this.sandboxIdleTimeoutInSeconds = toNumber(
5711
+ this.sandboxIdleTimeoutInSeconds
5712
+ );
5713
+ this.sandboxTtlInSeconds = toNumber(this.sandboxTtlInSeconds);
5714
+ this.shareConcurrencyLimitPerSandbox = toNumber(
5715
+ this.shareConcurrencyLimitPerSandbox
5716
+ );
5717
+ this.cpu = toNumber(this.cpu);
5718
+ this.memory = toNumber(this.memory);
5719
+ this.diskSize = toNumber(this.diskSize);
5720
+ }
5672
5721
  };
5673
5722
  }
5674
5723
  });
@@ -5683,9 +5732,12 @@ var init_client3 = __esm({
5683
5732
  "src/sandbox/client.ts"() {
5684
5733
  init_config();
5685
5734
  init_exception();
5735
+ init_log();
5686
5736
  init_control3();
5737
+ init_aio_sandbox();
5687
5738
  init_browser_sandbox();
5688
5739
  init_code_interpreter_sandbox();
5740
+ init_custom_sandbox();
5689
5741
  init_model4();
5690
5742
  init_sandbox();
5691
5743
  init_template();
@@ -5700,8 +5752,19 @@ var init_client3 = __esm({
5700
5752
  /**
5701
5753
  * Create a Template
5702
5754
  */
5703
- createTemplate = async (params) => {
5704
- const { input, config: config2 } = params;
5755
+ createTemplate = async (arg1, arg2) => {
5756
+ let input;
5757
+ let config2;
5758
+ if ("input" in arg1) {
5759
+ input = arg1.input;
5760
+ config2 = arg1.config;
5761
+ } else {
5762
+ logger.warn(
5763
+ "Deprecated: createTemplate(input, config) is deprecated. Use createTemplate({ input, config }) instead."
5764
+ );
5765
+ input = arg1;
5766
+ config2 = arg2;
5767
+ }
5705
5768
  const cfg = exports.Config.withConfigs(this.config, config2);
5706
5769
  try {
5707
5770
  const finalInput = this.prepareTemplateCreateInput(input);
@@ -5725,8 +5788,19 @@ var init_client3 = __esm({
5725
5788
  /**
5726
5789
  * Delete a Template
5727
5790
  */
5728
- deleteTemplate = async (params) => {
5729
- const { name, config: config2 } = params;
5791
+ deleteTemplate = async (arg1, arg2) => {
5792
+ let name;
5793
+ let config2;
5794
+ if (typeof arg1 === "string") {
5795
+ logger.warn(
5796
+ "Deprecated: deleteTemplate(name, config) is deprecated. Use deleteTemplate({ name, config }) instead."
5797
+ );
5798
+ name = arg1;
5799
+ config2 = arg2;
5800
+ } else {
5801
+ name = arg1.name;
5802
+ config2 = arg1.config;
5803
+ }
5730
5804
  const cfg = exports.Config.withConfigs(this.config, config2);
5731
5805
  try {
5732
5806
  const result = await this.controlApi.deleteTemplate({
@@ -5744,8 +5818,22 @@ var init_client3 = __esm({
5744
5818
  /**
5745
5819
  * Update a Template
5746
5820
  */
5747
- updateTemplate = async (params) => {
5748
- const { name, input, config: config2 } = params;
5821
+ updateTemplate = async (arg1, arg2, arg3) => {
5822
+ let name;
5823
+ let input;
5824
+ let config2;
5825
+ if (typeof arg1 === "string") {
5826
+ logger.warn(
5827
+ "Deprecated: updateTemplate(name, input, config) is deprecated. Use updateTemplate({ name, input, config }) instead."
5828
+ );
5829
+ name = arg1;
5830
+ input = arg2;
5831
+ config2 = arg3;
5832
+ } else {
5833
+ name = arg1.name;
5834
+ input = arg1.input;
5835
+ config2 = arg1.config;
5836
+ }
5749
5837
  const cfg = exports.Config.withConfigs(this.config, config2);
5750
5838
  try {
5751
5839
  const result = await this.controlApi.updateTemplate({
@@ -5769,8 +5857,19 @@ var init_client3 = __esm({
5769
5857
  /**
5770
5858
  * Get a Template
5771
5859
  */
5772
- getTemplate = async (params) => {
5773
- const { name, config: config2 } = params;
5860
+ getTemplate = async (arg1, arg2) => {
5861
+ let name;
5862
+ let config2;
5863
+ if (typeof arg1 === "string") {
5864
+ logger.warn(
5865
+ "Deprecated: getTemplate(name, config) is deprecated. Use getTemplate({ name, config }) instead."
5866
+ );
5867
+ name = arg1;
5868
+ config2 = arg2;
5869
+ } else {
5870
+ name = arg1.name;
5871
+ config2 = arg1.config;
5872
+ }
5774
5873
  const cfg = exports.Config.withConfigs(this.config, config2);
5775
5874
  try {
5776
5875
  const result = await this.controlApi.getTemplate({
@@ -5788,8 +5887,20 @@ var init_client3 = __esm({
5788
5887
  /**
5789
5888
  * List Templates
5790
5889
  */
5791
- listTemplates = async (params) => {
5792
- const { input, config: config2 } = params ?? {};
5890
+ listTemplates = async (arg1, arg2) => {
5891
+ let input;
5892
+ let config2;
5893
+ if (arg2 || arg1 && ("pageNumber" in arg1 || "pageSize" in arg1 || "templateType" in arg1)) {
5894
+ logger.warn(
5895
+ "Deprecated: listTemplates(input, config) is deprecated. Use listTemplates({ input, config }) instead."
5896
+ );
5897
+ input = arg1;
5898
+ config2 = arg2;
5899
+ } else {
5900
+ const params = arg1 ?? {};
5901
+ input = params.input;
5902
+ config2 = params.config;
5903
+ }
5793
5904
  const cfg = exports.Config.withConfigs(this.config, config2);
5794
5905
  const request = new $AgentRun3__namespace.ListTemplatesRequest({
5795
5906
  ...input
@@ -5804,18 +5915,41 @@ var init_client3 = __esm({
5804
5915
  /**
5805
5916
  * Create a Sandbox
5806
5917
  */
5807
- createSandbox = async (params) => {
5808
- const { input, config: config2 } = params;
5918
+ createSandbox = async (arg1, arg2) => {
5919
+ let input;
5920
+ let templateType;
5921
+ let config2;
5922
+ if ("input" in arg1) {
5923
+ const params = arg1;
5924
+ input = params.input;
5925
+ templateType = params.templateType;
5926
+ config2 = params.config;
5927
+ } else {
5928
+ logger.warn(
5929
+ "Deprecated: createSandbox(input, config) is deprecated. Use createSandbox({ input, config }) instead."
5930
+ );
5931
+ input = arg1;
5932
+ config2 = arg2;
5933
+ }
5809
5934
  const cfg = exports.Config.withConfigs(this.config, config2);
5810
5935
  try {
5811
- console.log({ input });
5812
5936
  const result = await this.controlApi.createSandbox({
5813
5937
  input: new $AgentRun3__namespace.CreateSandboxInput({
5814
5938
  ...input
5815
5939
  }),
5816
5940
  config: cfg
5817
5941
  });
5818
- return exports.Sandbox.fromInnerObject(result, cfg);
5942
+ const state = result.status ?? result.state;
5943
+ const sb = new exports.Sandbox({ ...result, state }, cfg);
5944
+ if (templateType === "CodeInterpreter" /* CODE_INTERPRETER */)
5945
+ return new exports.CodeInterpreterSandbox(sb, cfg);
5946
+ else if (templateType === "Browser" /* BROWSER */)
5947
+ return new exports.BrowserSandbox(sb, cfg);
5948
+ else if (templateType === "AllInOne" /* AIO */)
5949
+ return new exports.AioSandbox(sb, cfg);
5950
+ else if (templateType === "CustomImage" /* CUSTOM */)
5951
+ return new CustomSandbox(sb, cfg);
5952
+ return sb;
5819
5953
  } catch (error) {
5820
5954
  if (error instanceof exports.HTTPError) {
5821
5955
  throw error.toResourceError("Sandbox", input.templateName);
@@ -5850,8 +5984,19 @@ var init_client3 = __esm({
5850
5984
  /**
5851
5985
  * Delete a Sandbox
5852
5986
  */
5853
- deleteSandbox = async (params) => {
5854
- const { id, config: config2 } = params;
5987
+ deleteSandbox = async (arg1, arg2) => {
5988
+ let id;
5989
+ let config2;
5990
+ if (typeof arg1 === "string") {
5991
+ logger.warn(
5992
+ "Deprecated: deleteSandbox(id, config) is deprecated. Use deleteSandbox({ id, config }) instead."
5993
+ );
5994
+ id = arg1;
5995
+ config2 = arg2;
5996
+ } else {
5997
+ id = arg1.id;
5998
+ config2 = arg1.config;
5999
+ }
5855
6000
  const cfg = exports.Config.withConfigs(this.config, config2);
5856
6001
  try {
5857
6002
  const result = await this.controlApi.deleteSandbox({
@@ -5869,8 +6014,19 @@ var init_client3 = __esm({
5869
6014
  /**
5870
6015
  * Stop a Sandbox
5871
6016
  */
5872
- stopSandbox = async (params) => {
5873
- const { id, config: config2 } = params;
6017
+ stopSandbox = async (arg1, arg2) => {
6018
+ let id;
6019
+ let config2;
6020
+ if (typeof arg1 === "string") {
6021
+ logger.warn(
6022
+ "Deprecated: stopSandbox(id, config) is deprecated. Use stopSandbox({ id, config }) instead."
6023
+ );
6024
+ id = arg1;
6025
+ config2 = arg2;
6026
+ } else {
6027
+ id = arg1.id;
6028
+ config2 = arg1.config;
6029
+ }
5874
6030
  const cfg = exports.Config.withConfigs(this.config, config2);
5875
6031
  try {
5876
6032
  const result = await this.controlApi.stopSandbox({
@@ -5892,8 +6048,26 @@ var init_client3 = __esm({
5892
6048
  * @param params.templateType - Template type to cast the result to the appropriate subclass
5893
6049
  * @param params.config - Configuration
5894
6050
  */
5895
- getSandbox = async (params) => {
5896
- const { id, templateType, config: config2 } = params;
6051
+ getSandbox = async (arg1, arg2, arg3) => {
6052
+ let id;
6053
+ let templateType;
6054
+ let config2;
6055
+ if (typeof arg1 === "string") {
6056
+ logger.warn(
6057
+ "Deprecated: getSandbox(id, templateType, config?) is deprecated. Use getSandbox({ id, templateType, config }) instead."
6058
+ );
6059
+ id = arg1;
6060
+ if (arg2 && typeof arg2 === "string") {
6061
+ templateType = arg2;
6062
+ config2 = arg3;
6063
+ } else {
6064
+ config2 = arg2;
6065
+ }
6066
+ } else {
6067
+ id = arg1.id;
6068
+ templateType = arg1.templateType;
6069
+ config2 = arg1.config;
6070
+ }
5897
6071
  const cfg = exports.Config.withConfigs(this.config, config2);
5898
6072
  try {
5899
6073
  const result = await this.controlApi.getSandbox({
@@ -5926,8 +6100,20 @@ var init_client3 = __esm({
5926
6100
  /**
5927
6101
  * List Sandboxes
5928
6102
  */
5929
- listSandboxes = async (params) => {
5930
- const { input, config: config2 } = params ?? {};
6103
+ listSandboxes = async (arg1, arg2) => {
6104
+ let input;
6105
+ let config2;
6106
+ if (arg2 || arg1 && ("maxResults" in arg1 || "nextToken" in arg1 || "status" in arg1 || "templateName" in arg1 || "templateType" in arg1)) {
6107
+ logger.warn(
6108
+ "Deprecated: listSandboxes(input, config) is deprecated. Use listSandboxes({ input, config }) instead."
6109
+ );
6110
+ input = arg1;
6111
+ config2 = arg2;
6112
+ } else {
6113
+ const params = arg1 ?? {};
6114
+ input = params.input;
6115
+ config2 = params.config;
6116
+ }
5931
6117
  const cfg = exports.Config.withConfigs(this.config, config2);
5932
6118
  const request = new $AgentRun3__namespace.ListSandboxesRequest({
5933
6119
  ...input