Implements The Housekeeper, a new expert agent for home automation following the Librarian pattern. Communicates with core-api service which wraps Home Assistant REST API. New agent features: - CoreAPIClient with 13 home automation methods - 13 tools: list_areas, list_devices, get_device_state, turn_on, turn_off, toggle, list_scenes, activate_scene, list_scripts, run_script, list_automations, toggle_automation, get_history - PydanticAI agent with butler-friendly system prompt - HouseholdCapability registration for Steward coordination - delegate_to_housekeeper() wrapper for orchestration Also includes: - Dev port changed from 8123 to 8777 (avoids Home Assistant conflict) - Config: CORE_API_HOST, CORE_API_KEY, CORE_API_TIMEOUT - 44 unit tests for client and capability 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
91 lines
2.5 KiB
Python
91 lines
2.5 KiB
Python
"""
|
|
Housekeeper capability registration for the Household Registry.
|
|
|
|
Defines The Housekeeper's capabilities and registers it as a
|
|
household member for coordination by the Steward and Tatlock.
|
|
"""
|
|
from src.agents.housekeeper.agent import get_housekeeper_agent
|
|
from src.agents.housekeeper.tools import HOUSEKEEPER_TOOLS
|
|
from src.core.household_registry import (
|
|
HouseholdCapability,
|
|
get_household_registry,
|
|
)
|
|
from src.core.logging_config import get_logger
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
# The Housekeeper's capability summary for Steward coordination
|
|
HOUSEKEEPER_CAPABILITY = HouseholdCapability(
|
|
name="housekeeper",
|
|
role="The Housekeeper",
|
|
category="automation",
|
|
description=(
|
|
"Home automation control: TURN ON/OFF devices, ACTIVATE scenes, "
|
|
"RUN scripts, LIST devices, MANAGE automations. Controls lights, "
|
|
"switches, climate, and other smart home devices via Home Assistant."
|
|
),
|
|
domains=[
|
|
"lights",
|
|
"switches",
|
|
"automation",
|
|
"home",
|
|
"smart home",
|
|
"scene",
|
|
"script",
|
|
"device",
|
|
"turn on",
|
|
"turn off",
|
|
"temperature",
|
|
"climate",
|
|
"fan",
|
|
"cover",
|
|
"blinds",
|
|
],
|
|
cost="low", # Fast local API calls to core-api
|
|
requires_network=True, # Needs core-api access
|
|
)
|
|
|
|
|
|
def get_housekeeper_capability() -> HouseholdCapability:
|
|
"""Get The Housekeeper's capability definition."""
|
|
return HOUSEKEEPER_CAPABILITY
|
|
|
|
|
|
def register_housekeeper() -> None:
|
|
"""
|
|
Register The Housekeeper with the Household Registry.
|
|
|
|
This makes The Housekeeper available for:
|
|
- Steward recommendations (via capability summary)
|
|
- Tatlock delegation (via agent reference)
|
|
- Tool scoping (via tool list)
|
|
"""
|
|
registry = get_household_registry()
|
|
|
|
# Check if already registered
|
|
if "housekeeper" in registry:
|
|
logger.debug("housekeeper_already_registered")
|
|
return
|
|
|
|
registry.register(
|
|
name="housekeeper",
|
|
capability=HOUSEKEEPER_CAPABILITY,
|
|
tools=HOUSEKEEPER_TOOLS,
|
|
agent=get_housekeeper_agent(),
|
|
)
|
|
|
|
logger.info(
|
|
"housekeeper_registered",
|
|
role=HOUSEKEEPER_CAPABILITY.role,
|
|
domains=HOUSEKEEPER_CAPABILITY.domains,
|
|
tool_count=len(HOUSEKEEPER_TOOLS),
|
|
)
|
|
|
|
|
|
def unregister_housekeeper() -> None:
|
|
"""Unregister The Housekeeper from the Household Registry."""
|
|
registry = get_household_registry()
|
|
registry.unregister("housekeeper")
|
|
logger.info("housekeeper_unregistered")
|