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

chore: move TerminalToolkit interactive to __init__ (#2965)

Wendong-Fan51f73288a1a1
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index 3e8f47d85..c5df0e533 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -26,7 +26,7 @@ body:
attributes:
label: What version of camel are you using?
description: Run command `python3 -c 'print(__import__("camel").__version__)'` in your shell and paste the output here.
- placeholder: E.g., 0.2.73a10
+ placeholder: E.g., 0.2.73a11
validations:
required: true
diff --git a/camel/__init__.py b/camel/__init__.py
index 17b2a6275..01e94d1d0 100644
--- a/camel/__init__.py
+++ b/camel/__init__.py
@@ -14,7 +14,7 @@
from camel.logger import disable_logging, enable_logging, set_log_level
-__version__ = '0.2.73a10'
+__version__ = '0.2.73a11'
__all__ = [
'__version__',
diff --git a/camel/toolkits/terminal_toolkit.py b/camel/toolkits/terminal_toolkit.py
index b60d4d4f9..0558e1a0f 100644
--- a/camel/toolkits/terminal_toolkit.py
+++ b/camel/toolkits/terminal_toolkit.py
@@ -62,6 +62,10 @@ class TerminalToolkit(BaseToolkit):
environment. (default: :obj:`False`)
safe_mode (bool): Whether to enable safe mode to restrict
operations. (default: :obj:`True`)
+ interactive (bool): Whether to use interactive mode for shell commands,
+ connecting them to the terminal's standard input. This is useful
+ for commands that require user input, like `ssh`. Interactive mode
+ is only supported on macOS and Linux. (default: :obj:`False`)
Note:
Most functions are compatible with Unix-based systems (macOS, Linux).
@@ -78,6 +82,7 @@ class TerminalToolkit(BaseToolkit):
use_shell_mode: bool = True,
clone_current_env: bool = False,
safe_mode: bool = True,
+ interactive: bool = False,
):
# Store timeout before calling super().__init__
self._timeout = timeout
@@ -93,6 +98,7 @@ class TerminalToolkit(BaseToolkit):
self.cloned_env_path = None
self.use_shell_mode = use_shell_mode
self._human_takeover_active = False
+ self.interactive = interactive
self.python_executable = sys.executable
self.is_macos = platform.system() == 'Darwin'
@@ -1002,26 +1008,18 @@ class TerminalToolkit(BaseToolkit):
return True, command
- def shell_exec(
- self, id: str, command: str, interactive: bool = False
- ) -> str:
+ def shell_exec(self, id: str, command: str) -> str:
r"""Executes a shell command in a specified session.
This function creates and manages shell sessions to execute commands,
- simulating a real terminal. It can run commands in both non-interactive
- (capturing output) and interactive modes. Each session is identified by
- a unique ID. If a session with the given ID does not exist, it will be
- created.
+ simulating a real terminal. The behavior depends on the toolkit's
+ interactive mode setting. Each session is identified by a unique ID.
+ If a session with the given ID does not exist, it will be created.
Args:
id (str): A unique identifier for the shell session. This is used
to manage multiple concurrent shell processes.
command (str): The shell command to be executed.
- interactive (bool, optional): If `True`, the command runs in
- interactive mode, connecting it to the terminal's standard
- input. This is useful for commands that require user input,
- like `ssh`. Defaults to `False`. Interactive mode is only
- supported on macOS and Linux. (default: :obj:`False`)
Returns:
str: The standard output and standard error from the command. If an
@@ -1029,8 +1027,8 @@ class TerminalToolkit(BaseToolkit):
returned.
Note:
- When `interactive` is set to `True`, this function may block if the
- command requires input. In safe mode, some commands that are
+ When the toolkit is initialized with interactive mode, commands may
+ block if they require input. In safe mode, some commands that are
considered dangerous are restricted.
"""
error_msg = self._enforce_working_dir_for_execution(self.working_dir)
@@ -1127,7 +1125,7 @@ class TerminalToolkit(BaseToolkit):
elif pip_path and command.startswith('pip'):
command = command.replace('pip', pip_path, 1)
- if not interactive:
+ if not self.interactive:
# Use preexec_fn to create a new process group on Unix systems
preexec_fn = None
if self.os_type in ['Darwin', 'Linux']:
diff --git a/docs/conf.py b/docs/conf.py
index d76568ef8..1928655c8 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -27,7 +27,7 @@ sys.path.insert(0, os.path.abspath('..'))
project = 'CAMEL'
copyright = '2024, CAMEL-AI.org'
author = 'CAMEL-AI.org'
-release = '0.2.73a10'
+release = '0.2.73a11'
html_favicon = (
'https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'
diff --git a/examples/debug/eigent.py b/examples/debug/eigent.py
index 72904b2ee..962743e18 100644
--- a/examples/debug/eigent.py
+++ b/examples/debug/eigent.py
@@ -152,12 +152,11 @@ def developer_agent_factory(
- `shell_exec(id="install", command="pip install numpy")`
- `shell_exec(id="test", command="python my_script.py")`
- 5. **Interact with Processes**: For commands that require input, you can
- use:
- - `shell_exec(id="...", command="...", interactive=True)` for
- real-time interactive sessions.
- - `shell_write_to_process(id="...", content="...")` to send input to a
- non-interactive running process.
+ 5. **Interact with Processes**: For commands that require input:
+ - Initialize TerminalToolkit with `interactive=True` for real-time
+ interactive sessions.
+ - Use `shell_write_to_process(id="...", content="...")` to send input
+ to a non-interactive running process.
6. **Stop a Process**: If a process needs to be terminated, use
`shell_kill_process(id="...")`.
diff --git a/pyproject.toml b/pyproject.toml
index fb5527df5..d496847fc 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "camel-ai"
-version = "0.2.73a10"
+version = "0.2.73a11"
description = "Communicative Agents for AI Society Study"
authors = [{ name = "CAMEL-AI.org" }]
requires-python = ">=3.10,<3.13"
diff --git a/uv.lock b/uv.lock
index 5e23835c7..cf0afb479 100644
--- a/uv.lock
+++ b/uv.lock
@@ -594,30 +594,30 @@ wheels = [
[[package]]
name = "boto3"
-version = "1.39.14"
+version = "1.39.15"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "botocore" },
{ name = "jmespath" },
{ name = "s3transfer" },
]
-sdist = { url = "https://files.pythonhosted.org/packages/66/8f/acc7d434730e0c931ece4b46c983bf5afb7ae63abb545b535f0eda538476/boto3-1.39.14.tar.gz", hash = "sha256:fabb16360a93b449d5241006485bcc761c26694e75ac01009f4459f114acc06e", size = 111844, upload-time = "2025-07-25T19:25:26.943Z" }
+sdist = { url = "https://files.pythonhosted.org/packages/63/65/ddd4f52d138e52c1345c2d2421281a98449a6e4365290477befe06fa649a/boto3-1.39.15.tar.gz", hash = "sha256:b4483625f0d8c35045254dee46cd3c851bbc0450814f20b9b25bee1b5c0d8409", size = 111856, upload-time = "2025-07-28T19:56:49.504Z" }
wheels = [
- { url = "https://files.pythonhosted.org/packages/93/9a/01ea17a58a27b7f4a7a6f6e2f4d4191b9e92362b77b6d58689f2d7eccb99/boto3-1.39.14-py3-none-any.whl", hash = "sha256:82c6868cad18c3bd4170915e9525f9af5f83e9779c528417f8863629558fc2d0", size = 139898, upload-time = "2025-07-25T19:25:25.506Z" },
+ { url = "https://files.pythonhosted.org/packages/15/c5/27f50a31317041dc3ad79d62f37d5fcfb3f349c2fba8ea3e81de169db870/boto3-1.39.15-py3-none-any.whl", hash = "sha256:38fc54576b925af0075636752de9974e172c8a2cf7133400e3e09b150d20fb6a", size = 139901, upload-time = "2025-07-28T19:56:47.381Z" },
]
[[package]]
name = "botocore"
-version = "1.39.14"
+version = "1.39.15"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "jmespath" },
{ name = "python-dateutil" },
{ name = "urllib3" },
]
-sdist = { url = "https://files.pythonhosted.org/packages/cc/ca/8994676a67f0a9d39a0844124f196c4dedc2fbca370c839f61246c1fea6d/botocore-1.39.14.tar.gz", hash = "sha256:7fc44d4ad13b524e5d8a6296785776ef5898ac026ff74df9b35313831d507926", size = 14226110, upload-time = "2025-07-25T19:25:17.751Z" }
+sdist = { url = "https://files.pythonhosted.org/packages/2f/e2/8cd9560e7e44cf977dc0cc2e48da7634e78b7104ae6e47f4e1dfc1093965/botocore-1.39.15.tar.gz", hash = "sha256:2aa29a717f14f8c7ca058c2e297aaed0aa10ecea24b91514eee802814d1b7600", size = 14237556, upload-time = "2025-07-28T19:56:39.397Z" }
wheels = [
- { url = "https://files.pythonhosted.org/packages/08/c0/6b8200686c1f9ea44ab0daab0223b04799d60ccf882b9d7f770fbb40571e/botocore-1.39.14-py3-none-any.whl", hash = "sha256:4ed551c77194167b7e8063f33059bc2f9b2ead0ed4ee33dc7857273648ed4349", size = 13888318, upload-time = "2025-07-25T19:25:13.386Z" },
+ { url = "https://files.pythonhosted.org/packages/7b/6e/f25b8633e7ab2008de4c27466c9bc39e32dc73816619ffebbea12936135a/botocore-1.39.15-py3-none-any.whl", hash = "sha256:eb9cfe918ebfbfb8654e1b153b29f0c129d586d2c0d7fb4032731d49baf04cff", size = 13894884, upload-time = "2025-07-28T19:56:33.715Z" },
]
[[package]]
@@ -647,7 +647,7 @@ wheels = [
[[package]]
name = "camel-ai"
-version = "0.2.73a10"
+version = "0.2.73a11"
source = { editable = "." }
dependencies = [
{ name = "colorama" },