A shell for your agent.
Project description
A shell for your agent. Track state and history, multiple shells, and more.
Installation
pip install agentshell
Documentation
get_files_in_cwd(shell_id=None)
Returns a list of files in the current directory of a specific shell. If shell_id
is not specified, uses the current shell.
Parameters:
shell_id
: The unique identifier of the shell.
Returns:
- A list of filenames in the current directory.
get_current_shell()
Returns the unique identifier of the current shell. If no shell is currently active, creates a new shell and returns its identifier.
Returns:
- The unique identifier of the current shell.
set_cwd(cwd, shell_id=None)
Sets the current working directory of a specific shell. If shell_id
is not specified, uses the current shell.
Parameters:
cwd
: The new current working directory.shell_id
: The unique identifier of the shell.
set_current_shell(shell_id)
Sets the current shell to the shell with the specified identifier.
Parameters:
shell_id
: The unique identifier of the shell to be made current.
get_history(shell_id=None, n_limit=20)
Returns the command history of a specific shell. If shell_id
is not specified, uses the current shell.
Parameters:
shell_id
: The unique identifier of the shell.n_limit
: The maximum number of history entries to return.
Returns:
- A list of dictionaries, each representing a command and its result.
get_history_formatted(shell_id=None)
Returns the command history of a specific shell in a human-readable format. If shell_id
is not specified, uses the current shell.
Parameters:
shell_id
: The unique identifier of the shell.
Returns:
- The command history in human-readable format.
add_to_shell_history(shell_id, command, success, output, error=None)
Adds a command and its result to the history of a specific shell.
Parameters:
shell_id
: The unique identifier of the shell.command
: The command that was executed.success
: Whether the command was successful.output
: The output of the command.error
: Any error messages produced by the command.
clear_history(shell_id)
Clears the command history of a specific shell.
Parameters:
shell_id
: The unique identifier of the shell.
wipe_all()
Clears all shell and shell history data.
list_active_shells()
Returns a list of active shells.
Returns:
- A list of shell identifiers.
close_shell(shell_id)
Closes a specific shell, clearing its history.
Parameters:
shell_id
: The unique identifier of the shell.
new_shell()
Creates a new shell and returns its unique identifier.
Returns:
- The unique identifier of the new shell.
get_cwd(shell_id=None)
Returns the current working directory of a specific shell. If shell_id
is not specified, uses the current shell.
Parameters:
shell_id
: The unique identifier of the shell.
Returns:
- The current working directory of the shell.
run_command(command, shell_id=None)
Runs a command in a specific shell and adds it to the shell's history. If shell_id
is not specified, uses the current shell.
Parameters:
command
: The command to execute.shell_id
: The unique identifier of the shell.
Returns:
True
if the command was successful,False
otherwise.
Contributions Welcome
If you like this library and want to contribute in any way, please feel free to submit a PR and I will review it. Please note that the goal here is simplicity and accesibility, using common language and few dependencies.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file agentshell-0.0.7.tar.gz
.
File metadata
- Download URL: agentshell-0.0.7.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37097878436d890f9a821a08dbef22529942268543ff2f881d2ab6d7db13c0ea |
|
MD5 | 2815a2a8e59056587256daff60165803 |
|
BLAKE2b-256 | f232fa3dd1d19178908df7d1f9bb3fb15950dfd1460d826f99cbe16355f2b787 |
File details
Details for the file agentshell-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: agentshell-0.0.7-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd2f751a0736031c64fc5ac96b1cd0e35eb90f3ff22e9fcf040a73aa0268ecf9 |
|
MD5 | 72a23f9209d7cf0941102d26cecdbc56 |
|
BLAKE2b-256 | 181f263024dfa711beddf8ac35d0e96e912b6941400e98a42fe1cb093076d6b6 |