Skip to content

Commit 76be1ce

Browse files
authored
Merge branch 'main' into issue-57
2 parents bc6e07d + e55de28 commit 76be1ce

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

agentstack/generation/tool_generation.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ def add_tool(tool_name: str, path: Optional[str] = None):
107107
if not string_in_file(f'{path}.env.example', first_var_name):
108108
insert_code_after_tag(f'{path}.env.example', '# Tools', [tool_data.env], next_line=True) # Add env var
109109

110+
if tool_data.post_install:
111+
os.system(tool_data.post_install)
112+
110113
if not agentstack_json.get('tools'):
111114
agentstack_json['tools'] = []
112115
agentstack_json['tools'].append(tool_name)
@@ -140,6 +143,8 @@ def remove_tool(tool_name: str, path: Optional[str] = None):
140143
print(f'"src/tools/{tool_name}_tool.py" not found')
141144
remove_tool_from_tools_init(tool_data, path)
142145
remove_tool_from_agent_definition(framework, tool_data, path)
146+
if tool_data.post_remove:
147+
os.system(tool_data.post_remove)
143148
# We don't remove the .env variables to preserve user data.
144149

145150
agentstack_json['tools'].remove(tool_name)

agentstack/tools/~README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Tool Configuration Files
2+
========================
3+
Tools are configured for installation & removal using JSON files in this directory.
4+
5+
## Parameters
6+
7+
### `name` (string) [required]
8+
The name of the tool in snake_case. This is used to identify the tool in the system.
9+
10+
### `tools` (list) [required]
11+
List of public methods that are accessible in the tool implementation.
12+
13+
### `tools_bundled` (boolean) [optional]
14+
Indicates that the tool file exports a `list` of tools. Specify the variable name
15+
of the list in the `tools` field.
16+
17+
### `cta` (string) [optional]
18+
String to print in the terminal when the tool is installed that provides a call to action.
19+
20+
### `env` (string) [optional]
21+
Definitions for environment variables that will be appended to the local `.env` file.
22+
Separate multiple environment variables with a newline character.
23+
24+
### `packages` (list) [optional]
25+
A list of package names to install. These are the names of the packages that will
26+
be installed and removed by the package manager.
27+
28+
### `post_install` (string) [optional]
29+
Shell command that will be executed after packages have been installed and environment
30+
variables have been set.
31+
32+
### `post_remove` (string) [optional]
33+
Shell command that will be executed after the tool has been removed.
34+

0 commit comments

Comments
 (0)