strands.tools.watcher
Tool watcher for hot reloading tools during development.
This module provides functionality to watch tool directories for changes and automatically reload tools when they are modified.
ToolWatcher
Section titled “ToolWatcher”class ToolWatcher()Defined in: src/strands/tools/watcher.py:19
Watches tool directories for changes and reloads tools when they are modified.
__init__
Section titled “__init__”def __init__(tool_registry: ToolRegistry) -> NoneDefined in: src/strands/tools/watcher.py:32
Initialize a tool watcher for the given tool registry.
Arguments:
tool_registry- The tool registry to report changes.
ToolChangeHandler
Section titled “ToolChangeHandler”class ToolChangeHandler(FileSystemEventHandler)Defined in: src/strands/tools/watcher.py:41
Handler for tool file changes.
__init__
Section titled “__init__”def __init__(tool_registry: ToolRegistry) -> NoneDefined in: src/strands/tools/watcher.py:44
Initialize a tool change handler.
Arguments:
tool_registry- The tool registry to update when tools change.
on_modified
Section titled “on_modified”def on_modified(event: Any) -> NoneDefined in: src/strands/tools/watcher.py:52
Reload tool if file modification detected.
Arguments:
event- The file system event that triggered this handler.
MasterChangeHandler
Section titled “MasterChangeHandler”class MasterChangeHandler(FileSystemEventHandler)Defined in: src/strands/tools/watcher.py:69
Master handler that delegates to all registered handlers.
__init__
Section titled “__init__”def __init__(dir_path: str) -> NoneDefined in: src/strands/tools/watcher.py:72
Initialize a master change handler for a specific directory.
Arguments:
dir_path- The directory path to watch.
on_modified
Section titled “on_modified”def on_modified(event: Any) -> NoneDefined in: src/strands/tools/watcher.py:80
Delegate file modification events to all registered handlers.
Arguments:
event- The file system event that triggered this handler.
def start() -> NoneDefined in: src/strands/tools/watcher.py:98
Start watching all tools directories for changes.