1
0

feat: Phase 1 autonomy upgrades — introspection, heartbeat, source tagging, Discord auto-detect (#101)

UC-01: Live System Introspection Tool
- Add get_task_queue_status(), get_agent_roster(), get_live_system_status()
  to timmy/tools_intro with graceful degradation
- Enhanced get_memory_status() with line counts, section headers, vault
  directory listing, semantic memory row count, self-coding journal stats
- Register system_status MCP tool (creative/tools/system_status.py)
- Add system_status to Timmy's tool list + Hard Rule #7

UC-02: Fix Offline Status Bug
- Add registry.heartbeat() calls in task_processor run_loop() and
  process_single_task() so health endpoint reflects actual agent status
- health.py now consults swarm registry instead of Ollama connectivity

UC-03: Message Source Tagging
- Add source field to Message dataclass (default "browser")
- Tag all message_log.append() calls: browser, api, system
- Include source in /api/chat/history response

UC-04: Discord Token Auto-Detection & Docker Fix
- Add _discord_token_watcher() background coroutine that polls every 30s
  for DISCORD_TOKEN in env vars, .env file, or state file
- Add --extras discord to all three Dockerfiles (main, dashboard, test)

All 26 Phase 1 tests pass in Docker (make test-docker).
Full suite: 1889 passed, 77 skipped, 0 failed.

Co-authored-by: Alexander Payne <apayne@MM.local>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexander Whitestone
2026-02-28 22:49:24 -05:00
committed by GitHub
parent 89cfe1be0d
commit 6eefcabc97
14 changed files with 712 additions and 32 deletions

View File

@@ -0,0 +1,51 @@
"""System status introspection tool for Timmy.
MCP-compliant tool that gives Timmy live access to his own system state:
task queue, agent roster, memory tiers, uptime, and service health.
"""
import json
import logging
from mcp.registry import register_tool
from mcp.schemas.base import create_tool_schema, RETURN_STRING
logger = logging.getLogger(__name__)
SYSTEM_STATUS_SCHEMA = create_tool_schema(
name="system_status",
description=(
"Get live system status including task queue counts, agent roster, "
"memory tier health, uptime, and service connectivity. "
"Use this when asked about your status, what you're working on, "
"agent health, or system metrics. Never guess — always call this tool."
),
parameters={},
required=[],
returns=RETURN_STRING,
)
def system_status() -> str:
"""Return comprehensive live system status as formatted text.
Returns:
JSON-formatted string with system, task_queue, agents, memory sections.
"""
try:
from timmy.tools_intro import get_live_system_status
status = get_live_system_status()
return json.dumps(status, indent=2, default=str)
except Exception as exc:
logger.error("system_status tool failed: %s", exc)
return json.dumps({"error": str(exc)})
# Register with MCP
register_tool(
name="system_status",
schema=SYSTEM_STATUS_SCHEMA,
category="system",
)(system_status)