Skip to content

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

class ToolWatcher()

Defined in: src/strands/tools/watcher.py:19

Watches tool directories for changes and reloads tools when they are modified.

__init__

def __init__(tool_registry: ToolRegistry) -> None

Defined 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

class ToolChangeHandler(FileSystemEventHandler)

Defined in: src/strands/tools/watcher.py:41

Handler for tool file changes.

__init__

def __init__(tool_registry: ToolRegistry) -> None

Defined 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

def on_modified(event: Any) -> None

Defined in: src/strands/tools/watcher.py:52

Reload tool if file modification detected.

Arguments:

  • event - The file system event that triggered this handler.

MasterChangeHandler

class MasterChangeHandler(FileSystemEventHandler)

Defined in: src/strands/tools/watcher.py:69

Master handler that delegates to all registered handlers.

__init__

def __init__(dir_path: str) -> None

Defined 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

def on_modified(event: Any) -> None

Defined 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.

start

def start() -> None

Defined in: src/strands/tools/watcher.py:98

Start watching all tools directories for changes.