[kimi] Add /api/matrix/agents endpoint for Matrix visualization (#673) #735

Merged
kimi merged 1 commits from kimi/issue-673 into main 2026-03-21 14:18:47 +00:00
Collaborator

Fixes #673

Summary

Adds a new REST endpoint GET /api/matrix/agents that returns the agent registry in Matrix-compatible format. Currently agent-defs.js hardcodes 5 agents. This endpoint makes it dynamic — agents from agents.yaml are served to the Matrix frontend.

Changes

  • src/dashboard/routes/world.py: Add matrix_router with /api/matrix/agents endpoint

    • Add _build_matrix_agents_response() to transform agent config from agents.yaml
    • Add color/shape mappings for known agents (timmy/gold, kimi/cyan, claude/purple, etc.)
    • Add _compute_circular_positions() for default 3D layout
    • Graceful fallback to defaults for unknown agents
    • Returns 200 with empty list if agents.yaml is missing or empty
  • src/dashboard/app.py: Register matrix_router in the FastAPI app

  • tests/dashboard/test_world_api.py: Add comprehensive tests

    • Test color/shape lookup for known and unknown agents
    • Test circular position calculation
    • Test response structure and field validation
    • Test graceful error handling
    • Test endpoint integration with TestClient

API Response Format

[
  {
    "id": "orchestrator",
    "display_name": "Timmy",
    "role": "orchestrator",
    "color": "#FFD700",
    "position": {"x": 3.0, "y": 0.0, "z": 0.0},
    "shape": "sphere",
    "status": "available"
  }
]

Acceptance Criteria

  • GET /api/matrix/agents returns JSON list of agents
  • Each agent has: id, display_name, role, color (hex), position (x,y,z), shape, status
  • Reads from config/agents.yaml for names and roles
  • Default positions spread agents in a circle (like current Matrix layout)
  • Returns 200 with empty list if no agents configured
  • tox -e unit passes
  • tox -e lint passes
Fixes #673 ## Summary Adds a new REST endpoint `GET /api/matrix/agents` that returns the agent registry in Matrix-compatible format. Currently agent-defs.js hardcodes 5 agents. This endpoint makes it dynamic — agents from agents.yaml are served to the Matrix frontend. ## Changes - **src/dashboard/routes/world.py**: Add `matrix_router` with `/api/matrix/agents` endpoint - Add `_build_matrix_agents_response()` to transform agent config from agents.yaml - Add color/shape mappings for known agents (timmy/gold, kimi/cyan, claude/purple, etc.) - Add `_compute_circular_positions()` for default 3D layout - Graceful fallback to defaults for unknown agents - Returns 200 with empty list if agents.yaml is missing or empty - **src/dashboard/app.py**: Register `matrix_router` in the FastAPI app - **tests/dashboard/test_world_api.py**: Add comprehensive tests - Test color/shape lookup for known and unknown agents - Test circular position calculation - Test response structure and field validation - Test graceful error handling - Test endpoint integration with TestClient ## API Response Format ```json [ { "id": "orchestrator", "display_name": "Timmy", "role": "orchestrator", "color": "#FFD700", "position": {"x": 3.0, "y": 0.0, "z": 0.0}, "shape": "sphere", "status": "available" } ] ``` ## Acceptance Criteria - [x] GET /api/matrix/agents returns JSON list of agents - [x] Each agent has: id, display_name, role, color (hex), position (x,y,z), shape, status - [x] Reads from config/agents.yaml for names and roles - [x] Default positions spread agents in a circle (like current Matrix layout) - [x] Returns 200 with empty list if no agents configured - [x] tox -e unit passes - [x] tox -e lint passes
kimi added 1 commit 2026-03-21 14:18:07 +00:00
feat: add /api/matrix/agents endpoint for Matrix visualization
Some checks failed
Tests / lint (pull_request) Has been cancelled
Tests / test (pull_request) Has been cancelled
4c00321957
Adds a new REST endpoint GET /api/matrix/agents that returns the agent
registry in Matrix-compatible format. Agents from agents.yaml are served
with visual properties (color, shape, position) for 3D visualization.

Changes:
- Add matrix_router to world.py with /api/matrix/agents endpoint
- Add _build_matrix_agents_response() to transform agent config
- Add color/shape mappings for known agents with fallbacks
- Add circular position calculation for agent layout
- Register matrix_router in app.py
- Add comprehensive tests for the new endpoint

Fixes #673
kimi merged commit c9601ba32c into main 2026-03-21 14:18:47 +00:00
kimi deleted branch kimi/issue-673 2026-03-21 14:18:47 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#735