diff --git a/agentstack/generation/tool_generation.py b/agentstack/generation/tool_generation.py index f60b3f1..d36ae01 100644 --- a/agentstack/generation/tool_generation.py +++ b/agentstack/generation/tool_generation.py @@ -43,7 +43,8 @@ def add_tool(tool_name: str, path: Optional[str] = None): insert_code_after_tag(f'{path}.env', '# Tools', [tool_data['env']], next_line=True) # Add env var if not string_in_file(f'{path}.env.example', first_var_name): insert_code_after_tag(f'{path}.env.example', '# Tools', [tool_data['env']], next_line=True) # Add env var - + if tool_data.get('post_install'): + os.system(tool_data['post_install']) if not agentstack_json.get('tools'): agentstack_json['tools'] = [] agentstack_json['tools'].append(tool_name) @@ -78,6 +79,8 @@ def remove_tool(tool_name: str, path: Optional[str] = None): os.remove(f'{path}src/tools/{tool_name}_tool.py') remove_tool_from_tools_init(tool_data, path) remove_tool_from_agent_definition(framework, tool_data, path) + if tool_data.get('post_remove'): + os.system(tool_data['post_remove']) # We don't remove the .env variables to preserve user data. agentstack_json['tools'].remove(tool_name) diff --git a/agentstack/tools/~README.md b/agentstack/tools/~README.md new file mode 100644 index 0000000..39b78db --- /dev/null +++ b/agentstack/tools/~README.md @@ -0,0 +1,34 @@ +Tool Configuration Files +======================== +Tools are configured for installation & removal using JSON files in this directory. + +## Parameters + +### `name` (string) [required] +The name of the tool in snake_case. This is used to identify the tool in the system. + +### `tools` (list) [required] +List of public methods that are accessible in the tool implementation. + +### `tools_bundled` (boolean) [optional] +Indicates that the tool file exports a `list` of tools. Specify the variable name +of the list in the `tools` field. + +### `cta` (string) [optional] +String to print in the terminal when the tool is installed that provides a call to action. + +### `env` (string) [optional] +Definitions for environment variables that will be appended to the local `.env` file. +Separate multiple environment variables with a newline character. + +### `packages` (list) [optional] +A list of package names to install. These are the names of the packages that will +be installed and removed by the package manager. + +### `post_install` (string) [optional] +Shell command that will be executed after packages have been installed and environment +variables have been set. + +### `post_remove` (string) [optional] +Shell command that will be executed after the tool has been removed. +