Skip to content

Commit 140f8b8

Browse files
authored
Merge branch 'master' into st_fix_deepseek_stream
2 parents a91dacd + 85d2de1 commit 140f8b8

File tree

1 file changed

+53
-37
lines changed

1 file changed

+53
-37
lines changed

docs/mintlify/reference/camel.toolkits.terminal_toolkit.terminal_toolkit.mdx

Lines changed: 53 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -158,23 +158,24 @@ def shell_exec(
158158
):
159159
```
160160

161-
This function executes a shell command. The command can run in
162-
blocking mode (waits for completion) or non-blocking mode
163-
(runs in the background). A unique session ID is created for
164-
each session.
161+
Executes a shell command in blocking or non-blocking mode.
165162

166163
**Parameters:**
167164

168-
- **command** (str): The command to execute.
169-
- **block** (bool): If True, the command runs synchronously, waiting for it to complete or time out, and returns its full output. If False, the command runs asynchronously in the background.
170-
- **id** (Optional[str]): A specific ID for the session. If not provided, a unique ID is generated for non-blocking sessions.
165+
- **id** (str): A unique identifier for the command's session. This ID is used to interact with non-blocking processes.
166+
- **command** (str): The shell command to execute.
167+
- **block** (bool, optional): Determines the execution mode. Defaults to True. If `True` (blocking mode), the function waits for the command to complete and returns the full output. Use this for most commands . If `False` (non-blocking mode), the function starts the command in the background. Use this only for interactive sessions or long-running tasks, or servers.
171168

172169
**Returns:**
173170

174-
str: If block is True, returns the complete stdout and stderr.
175-
If block is False, returns a message containing the new
176-
session ID and the initial output from the command after
177-
it goes idle.
171+
str: The output of the command execution, which varies by mode.
172+
In blocking mode, returns the complete standard output and
173+
standard error from the command.
174+
In non-blocking mode, returns a confirmation message with the
175+
session `id`. To interact with the background process, use
176+
other functions: `shell_view(id)` to see output,
177+
`shell_write_to_process(id, "input")` to send input, and
178+
`shell_kill_process(id)` to terminate.
178179

179180
<a id="camel.toolkits.terminal_toolkit.terminal_toolkit.TerminalToolkit.shell_write_to_process"></a>
180181

@@ -206,40 +207,18 @@ to the input command.
206207
def shell_view(self, id: str):
207208
```
208209

209-
This function retrieves any new output from a non-blocking session
210-
since the last time this function was called. If the process has
211-
terminated, it drains the output queue and appends a termination
212-
message. If the process is still running, it simply returns any
213-
new output.
210+
Retrieves new output from a non-blocking session.
214211

215-
**Parameters:**
216-
217-
- **id** (str): The unique session ID of the non-blocking process.
218-
219-
**Returns:**
220-
221-
str: The new output from the process's stdout and stderr. Returns
222-
an empty string if there is no new output.
223-
224-
<a id="camel.toolkits.terminal_toolkit.terminal_toolkit.TerminalToolkit.shell_wait"></a>
225-
226-
### shell_wait
227-
228-
```python
229-
def shell_wait(self, id: str, wait_seconds: float = 5.0):
230-
```
231-
232-
This function waits for a specified duration for a
233-
non-blocking process to produce more output or terminate.
212+
This function returns only NEW output since the last call. It does NOT
213+
wait or block - it returns immediately with whatever is available.
234214

235215
**Parameters:**
236216

237217
- **id** (str): The unique session ID of the non-blocking process.
238-
- **wait_seconds** (float): The maximum number of seconds to wait.
239218

240219
**Returns:**
241220

242-
str: All output collected during the wait period.
221+
str: New output if available, or a status message.
243222

244223
<a id="camel.toolkits.terminal_toolkit.terminal_toolkit.TerminalToolkit.shell_kill_process"></a>
245224

@@ -284,6 +263,41 @@ This method can handle different scenarios:
284263
str: The output from the shell session after the user's command has
285264
been executed, or help information for general queries.
286265

266+
<a id="camel.toolkits.terminal_toolkit.terminal_toolkit.TerminalToolkit.__enter__"></a>
267+
268+
### __enter__
269+
270+
```python
271+
def __enter__(self):
272+
```
273+
274+
Context manager entry.
275+
276+
<a id="camel.toolkits.terminal_toolkit.terminal_toolkit.TerminalToolkit.__exit__"></a>
277+
278+
### __exit__
279+
280+
```python
281+
def __exit__(
282+
self,
283+
exc_type,
284+
exc_val,
285+
exc_tb
286+
):
287+
```
288+
289+
Context manager exit - clean up all sessions.
290+
291+
<a id="camel.toolkits.terminal_toolkit.terminal_toolkit.TerminalToolkit.cleanup"></a>
292+
293+
### cleanup
294+
295+
```python
296+
def cleanup(self):
297+
```
298+
299+
Clean up all active sessions.
300+
287301
<a id="camel.toolkits.terminal_toolkit.terminal_toolkit.TerminalToolkit.__del__"></a>
288302

289303
### __del__
@@ -292,6 +306,8 @@ been executed, or help information for general queries.
292306
def __del__(self):
293307
```
294308

309+
Fallback cleanup in destructor.
310+
295311
<a id="camel.toolkits.terminal_toolkit.terminal_toolkit.TerminalToolkit.get_tools"></a>
296312

297313
### get_tools

0 commit comments

Comments
 (0)