Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

Auto-update documentation after merge [skip ci]

camel-docs-bot046c38c75095
diff --git a/docs/mintlify/docs.json b/docs/mintlify/docs.json
index 861c0f998..4edbe26e2 100644
--- a/docs/mintlify/docs.json
+++ b/docs/mintlify/docs.json
@@ -357,6 +357,7 @@
"reference/camel.interpreters.e2b_interpreter",
"reference/camel.interpreters.internal_python_interpreter",
"reference/camel.interpreters.ipython_interpreter",
+ "reference/camel.interpreters.microsandbox_interpreter",
"reference/camel.interpreters.subprocess_interpreter"
]
},
diff --git a/docs/mintlify/reference/camel.interpreters.microsandbox_interpreter.mdx b/docs/mintlify/reference/camel.interpreters.microsandbox_interpreter.mdx
new file mode 100644
index 000000000..bfb0d1ee1
--- /dev/null
+++ b/docs/mintlify/reference/camel.interpreters.microsandbox_interpreter.mdx
@@ -0,0 +1,146 @@
+<a id="camel.interpreters.microsandbox_interpreter"></a>
+
+<a id="camel.interpreters.microsandbox_interpreter.MicrosandboxInterpreter"></a>
+
+## MicrosandboxInterpreter
+
+```python
+class MicrosandboxInterpreter(BaseInterpreter):
+```
+
+Microsandbox Code Interpreter implementation.
+
+This interpreter provides secure code execution using microsandbox,
+a self-hosted platform for secure execution of untrusted user/AI code.
+It supports Python code execution via PythonSandbox, JavaScript/Node.js
+code execution via NodeSandbox, and shell commands via the command
+interface.
+
+**Parameters:**
+
+- **require_confirm** (bool, optional): If True, prompt user before running code strings for security. (default: :obj:`True`)
+- **server_url** (str, optional): URL of the microsandbox server. If not provided, will use MSB_SERVER_URL environment variable, then fall back to http://127.0.0.1:5555. (default: :obj:`None`)
+- **api_key** (str, optional): API key for microsandbox authentication. If not provided, will use MSB_API_KEY environment variable. (default: :obj:`None`)
+- **namespace** (str, optional): Namespace for the sandbox. (default: :obj:`"default"`)
+- **sandbox_name** (str, optional): Name of the sandbox instance. If not provided, a random name will be generated by the SDK. (default: :obj:`None`)
+- **timeout** (int, optional): Default timeout for code execution in seconds. (default: :obj:`30`) Environment Variables:
+- **MSB_SERVER_URL**: URL of the microsandbox server.
+- **MSB_API_KEY**: API key for microsandbox authentication.
+
+**Note:**
+
+The SDK handles parameter priority as: user parameter > environment
+variable > default value.
+
+<a id="camel.interpreters.microsandbox_interpreter.MicrosandboxInterpreter.__init__"></a>
+
+### __init__
+
+```python
+def __init__(
+ self,
+ require_confirm: bool = True,
+ server_url: Optional[str] = None,
+ api_key: Optional[str] = None,
+ namespace: str = 'default',
+ sandbox_name: Optional[str] = None,
+ timeout: int = 30
+):
+```
+
+<a id="camel.interpreters.microsandbox_interpreter.MicrosandboxInterpreter.run"></a>
+
+### run
+
+```python
+def run(self, code: str, code_type: str = 'python'):
+```
+
+Executes the given code in the microsandbox.
+
+**Parameters:**
+
+- **code** (str): The code string to execute.
+- **code_type** (str): The type of code to execute. Supported types: 'python', 'javascript', 'bash'. (default: :obj:`python`)
+
+**Returns:**
+
+ str: The string representation of the output of the executed code.
+
+<a id="camel.interpreters.microsandbox_interpreter.MicrosandboxInterpreter._confirm_execution"></a>
+
+### _confirm_execution
+
+```python
+def _confirm_execution(self, execution_type: str):
+```
+
+Prompt user for confirmation before executing code or commands.
+
+**Parameters:**
+
+- **execution_type** (str): Type of execution ('code' or 'command').
+
+<a id="camel.interpreters.microsandbox_interpreter.MicrosandboxInterpreter.supported_code_types"></a>
+
+### supported_code_types
+
+```python
+def supported_code_types(self):
+```
+
+Provides supported code types by the interpreter.
+
+<a id="camel.interpreters.microsandbox_interpreter.MicrosandboxInterpreter.update_action_space"></a>
+
+### update_action_space
+
+```python
+def update_action_space(self, action_space: Dict[str, Any]):
+```
+
+Updates action space for interpreter.
+
+**Parameters:**
+
+- **action_space**: Action space dictionary (unused in microsandbox).
+
+**Note:**
+
+Microsandbox doesn't support action space updates as it runs
+in isolated environments for each execution.
+
+<a id="camel.interpreters.microsandbox_interpreter.MicrosandboxInterpreter.execute_command"></a>
+
+### execute_command
+
+```python
+def execute_command(self, command: str):
+```
+
+Execute a shell command in the microsandbox.
+
+This method is designed for package management and system
+administration tasks. It executes shell commands directly
+using the microsandbox command interface.
+
+**Parameters:**
+
+- **command** (str): The shell command to execute (e.g., "pip install numpy", "ls -la", "apt-get update").
+
+**Returns:**
+
+ Union[str, Tuple[str, str]]: The output of the command.
+
+<a id="camel.interpreters.microsandbox_interpreter.MicrosandboxInterpreter.__del__"></a>
+
+### __del__
+
+```python
+def __del__(self):
+```
+
+Destructor for the MicrosandboxInterpreter class.
+
+Microsandbox uses context managers for resource management,
+so no explicit cleanup is needed.
diff --git a/docs/mintlify/reference/camel.toolkits.code_execution.mdx b/docs/mintlify/reference/camel.toolkits.code_execution.mdx
index e60cda8b9..1a5adf576 100644
--- a/docs/mintlify/reference/camel.toolkits.code_execution.mdx
+++ b/docs/mintlify/reference/camel.toolkits.code_execution.mdx
@@ -17,6 +17,8 @@ A toolkit for code execution.
- **unsafe_mode** (bool): If `True`, the interpreter runs the code by `eval()` without any security check. (default: :obj:`False`)
- **import_white_list** (Optional[List[str]]): A list of allowed imports. (default: :obj:`None`)
- **require_confirm** (bool): Whether to require confirmation before executing code. (default: :obj:`False`)
+- **timeout** (Optional[float]): General timeout for toolkit operations. (default: :obj:`None`)
+- **microsandbox_config** (Optional[dict]): Configuration for microsandbox interpreter. Available keys: 'server_url', 'api_key', 'namespace', 'sandbox_name', 'timeout'. If None, uses default configuration. (default: :obj:`None`)
<a id="camel.toolkits.code_execution.CodeExecutionToolkit.__init__"></a>
@@ -25,12 +27,13 @@ A toolkit for code execution.
```python
def __init__(
self,
- sandbox: Literal['internal_python', 'jupyter', 'docker', 'subprocess', 'e2b'] = 'subprocess',
+ sandbox: Literal['internal_python', 'jupyter', 'docker', 'subprocess', 'e2b', 'microsandbox'] = 'subprocess',
verbose: bool = False,
unsafe_mode: bool = False,
import_white_list: Optional[List[str]] = None,
require_confirm: bool = False,
- timeout: Optional[float] = None
+ timeout: Optional[float] = None,
+ microsandbox_config: Optional[dict] = None
):
```