feat(phase3): add The Librarian agent with library-desk integration
Library-Desk API Client: - Async HTTP client with httpx for library-desk API - HybridRAG search (vector + graph + web) - Wiki operations (search, get, list, create, update) - Smart page creation with HybridRAG research - Semantic vector search and knowledge graph queries - Dossier browsing and health checks Librarian Tools (11 total): - Research: hybrid_search, search_wiki, get_wiki_page, semantic_search - Browse: list_dossiers, get_dossier_pages, explore_knowledge_graph - Graph: find_related_entities - Write: create_wiki_page, update_wiki_page, smart_create_wiki_page Agent: - PydanticAI agent with research assistant personality - System prompt with research and writing workflows - Streaming support via run_librarian_stream() Capability: - LIBRARIAN_CAPABILITY definition for Household Registry - Automatic registration on startup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
"""
|
||||
Librarian capability registration for the Household Registry.
|
||||
|
||||
Defines The Librarian's capabilities and registers it as a
|
||||
household member for coordination by the Steward and Tatlock.
|
||||
"""
|
||||
from src.agents.librarian.agent import get_librarian_agent
|
||||
from src.agents.librarian.tools import LIBRARIAN_TOOLS
|
||||
from src.core.household_registry import (
|
||||
HouseholdCapability,
|
||||
get_household_registry,
|
||||
)
|
||||
from src.core.logging_config import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
# The Librarian's capability summary for Steward coordination
|
||||
LIBRARIAN_CAPABILITY = HouseholdCapability(
|
||||
name="librarian",
|
||||
role="The Librarian",
|
||||
category="research",
|
||||
description=(
|
||||
"Research assistant providing knowledge search, wiki access, "
|
||||
"semantic search, and knowledge graph exploration via library-desk API"
|
||||
),
|
||||
domains=[
|
||||
"research",
|
||||
"knowledge",
|
||||
"information",
|
||||
"wiki",
|
||||
"documents",
|
||||
"search",
|
||||
"synthesis",
|
||||
],
|
||||
cost="medium", # Multiple API calls to library-desk
|
||||
requires_network=True, # Needs library-desk API access
|
||||
)
|
||||
|
||||
|
||||
def get_librarian_capability() -> HouseholdCapability:
|
||||
"""Get The Librarian's capability definition."""
|
||||
return LIBRARIAN_CAPABILITY
|
||||
|
||||
|
||||
def register_librarian() -> None:
|
||||
"""
|
||||
Register The Librarian with the Household Registry.
|
||||
|
||||
This makes The Librarian 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 "librarian" in registry:
|
||||
logger.debug("librarian_already_registered")
|
||||
return
|
||||
|
||||
registry.register(
|
||||
name="librarian",
|
||||
capability=LIBRARIAN_CAPABILITY,
|
||||
tools=LIBRARIAN_TOOLS,
|
||||
agent=get_librarian_agent(),
|
||||
)
|
||||
|
||||
logger.info(
|
||||
"librarian_registered",
|
||||
role=LIBRARIAN_CAPABILITY.role,
|
||||
domains=LIBRARIAN_CAPABILITY.domains,
|
||||
tool_count=len(LIBRARIAN_TOOLS),
|
||||
)
|
||||
|
||||
|
||||
def unregister_librarian() -> None:
|
||||
"""Unregister The Librarian from the Household Registry."""
|
||||
registry = get_household_registry()
|
||||
registry.unregister("librarian")
|
||||
logger.info("librarian_unregistered")
|
||||
Reference in New Issue
Block a user