refactor: split tool declarations into domain files + role config UI
tools/__init__.py shrinks from 1,137 → 250 lines. Each domain file now owns both its callables and its FunctionDeclarations (DECLARATIONS list), so adding a new tool only touches one file. New TOOL_CATEGORIES dict exported from __init__ — used by the UI for grouped tool checkboxes. Role config UI (Settings → Model Registry → Role Assignments): - ⚙ button per role expands an inline configure panel - Textarea for system_append (injected into system prompt for this role) - Grouped checkboxes for tool allow-list (all checked = no restriction) - POST /api/models/role-config saves both fields; updates ROLE_CONFIG_DATA in-page so re-open reflects current state without a page reload Backend: - model_registry.set_role_config() writes system_append + tools to registry - TOOL_CATEGORIES exported from tools/__init__ for UI rendering - TOOLS.md header updated: 30 → 39 tools (ae_journal_* and cortex_* additions) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import asyncio
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
from google.genai import types
|
||||
from persona import persona_path
|
||||
|
||||
|
||||
@@ -133,3 +134,70 @@ async def task_update(task_id: str, status: str | None = None, title: str | None
|
||||
|
||||
async def task_complete(task_id: str) -> str:
|
||||
return await asyncio.to_thread(_task_complete, task_id)
|
||||
|
||||
|
||||
DECLARATIONS = [
|
||||
types.FunctionDeclaration(
|
||||
name="task_list",
|
||||
description=(
|
||||
"List personal tasks from Inara's task list. "
|
||||
"Use this to check what's on the list, review pending work, or find a task ID. "
|
||||
"Optionally filter by status: 'todo', 'in_progress', or 'done'."
|
||||
),
|
||||
parameters=types.Schema(
|
||||
type=types.Type.OBJECT,
|
||||
properties={
|
||||
"status": types.Schema(type=types.Type.STRING, description="Filter by status: 'todo', 'in_progress', or 'done'. Omit to list all."),
|
||||
},
|
||||
),
|
||||
),
|
||||
types.FunctionDeclaration(
|
||||
name="task_create",
|
||||
description=(
|
||||
"Add a new task to Inara's personal task list. "
|
||||
"Use this when the user asks to remember something, add a to-do, or track a follow-up."
|
||||
),
|
||||
parameters=types.Schema(
|
||||
type=types.Type.OBJECT,
|
||||
properties={
|
||||
"title": types.Schema(type=types.Type.STRING, description="Short task title"),
|
||||
"description": types.Schema(type=types.Type.STRING, description="Optional longer description or context"),
|
||||
"priority": types.Schema(type=types.Type.STRING, description="Priority: 'low', 'normal', or 'high'. Default: normal."),
|
||||
},
|
||||
required=["title"],
|
||||
),
|
||||
),
|
||||
types.FunctionDeclaration(
|
||||
name="task_update",
|
||||
description=(
|
||||
"Update an existing task. Use task_list first to get the task ID. "
|
||||
"Can update status, title, description, or priority. "
|
||||
"To just mark complete, use task_complete instead."
|
||||
),
|
||||
parameters=types.Schema(
|
||||
type=types.Type.OBJECT,
|
||||
properties={
|
||||
"task_id": types.Schema(type=types.Type.STRING, description="Task ID (e.g. t_abc123) — get from task_list"),
|
||||
"status": types.Schema(type=types.Type.STRING, description="New status: 'todo', 'in_progress', or 'done'"),
|
||||
"title": types.Schema(type=types.Type.STRING, description="Updated title"),
|
||||
"description": types.Schema(type=types.Type.STRING, description="Updated description"),
|
||||
"priority": types.Schema(type=types.Type.STRING, description="Updated priority: 'low', 'normal', or 'high'"),
|
||||
},
|
||||
required=["task_id"],
|
||||
),
|
||||
),
|
||||
types.FunctionDeclaration(
|
||||
name="task_complete",
|
||||
description=(
|
||||
"Mark a task as done. Use task_list first to get the task ID. "
|
||||
"Shorthand for task_update with status='done'."
|
||||
),
|
||||
parameters=types.Schema(
|
||||
type=types.Type.OBJECT,
|
||||
properties={
|
||||
"task_id": types.Schema(type=types.Type.STRING, description="Task ID (e.g. t_abc123) — get from task_list"),
|
||||
},
|
||||
required=["task_id"],
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user