Files
ryan d2f21a6d23 Add tool label registry and SSE v2 tool event shaping
Pure functions build tool_start/tool_end payloads with run_id, friendly
label, truncated input (config dropped), status, duration and artifact ref.
Labels cover every agent tool, both old and #55 YNAB names, and the
homebox_/bookstack_ MCP prefixes, falling back to "Using <tool>…".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 17:53:22 -04:00

65 lines
2.7 KiB
Python

"""Friendly, user-facing labels for agent tool calls (shown in the activity timeline)."""
TOOL_LABELS: dict[str, str] = {
"get_current_date": "Checking the date…",
"web_search": "Searching the web…",
"simba_search": "Searching household documents…",
"save_user_memory": "Saving to memory…",
# YNAB (current names)
"ynab_budget_summary": "Checking budget…",
"ynab_search_transactions": "Searching transactions…",
"ynab_category_spending": "Reviewing category spending…",
"ynab_category_allocations": "Reviewing category budgets…",
"ynab_insights": "Analyzing spending trends…",
# YNAB (names after the #55 mirror)
"ynab_account_balances": "Checking account balances…",
"ynab_spending_report": "Building spending report…",
"ynab_category_budget": "Reviewing category budgets…",
"ynab_recent_changes": "Checking recent budget changes…",
"ynab_sql": "Querying budget data…",
# Mealie
"mealie_todays_meals": "Checking today's meals…",
"mealie_meal_plans": "Checking the meal plan…",
"mealie_get_recipe": "Fetching recipe…",
"mealie_shopping_lists": "Checking shopping lists…",
"mealie_create_meal_plan": "Adding to the meal plan…",
# Obsidian / journal
"obsidian_search_notes": "Searching notes…",
"obsidian_read_note": "Reading note…",
"obsidian_create_note": "Creating note…",
"obsidian_create_task": "Creating task…",
"journal_get_today": "Reading today's journal…",
"journal_get_tasks": "Checking tasks…",
"journal_add_task": "Adding task…",
"journal_complete_task": "Completing task…",
# Google
"get_calendar_events": "Checking calendar…",
"create_calendar_event": "Creating calendar event…",
"gmail_search_emails": "Searching email…",
"gmail_get_email": "Reading email…",
# SimbaKit
"simbakit_device_status": "Checking Simba's devices…",
"simbakit_weight_history": "Checking Simba's weight…",
"simbakit_litter_activity": "Checking litter box activity…",
"simbakit_drinking_activity": "Checking water fountain activity…",
# Beli
"beli_search_restaurants": "Searching restaurants…",
}
# MCP tools are discovered at runtime, so they match by name prefix.
TOOL_PREFIX_LABELS: tuple[tuple[str, str], ...] = (
("homebox_", "Checking home inventory…"),
("bookstack_", "Checking the wiki…"),
)
def tool_label(tool_name: str) -> str:
"""Return the friendly label for a tool, falling back to "Using <tool>…"."""
label = TOOL_LABELS.get(tool_name)
if label:
return label
for prefix, prefix_label in TOOL_PREFIX_LABELS:
if tool_name.startswith(prefix):
return prefix_label
return f"Using {tool_name}…"