feat: agent coordination system (workflows, locks, components, messages)

Adds /api/coord/* endpoints for real-time cross-session coordination:
- coord_workflows: named units of work per project
- coord_work_items: tasks within workflows with dependency chains
- coord_session_locks: exclusive resource locks with auto-expiry (TTL)
- coord_component_states: live component state per project (upsert)
- coord_messages: cross-session messaging and broadcasts
- /api/coord/status: cross-project snapshot endpoint

Replaces PROJECT_STATE.md as the coordination layer for Claude sessions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-12 08:25:33 -07:00
parent bd88398297
commit 63975284f4
24 changed files with 1565 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
"""Pydantic schemas for CoordMessage."""
from datetime import datetime
from typing import Optional
from uuid import UUID
from pydantic import BaseModel, Field
class CoordMessageCreate(BaseModel):
"""Input schema for sending a message."""
from_session: str = Field(..., description="Sending session identifier", max_length=200)
to_session: Optional[str] = Field(None, description="Recipient session; NULL = broadcast", max_length=200)
project_key: Optional[str] = Field(None, description="Optional project context", max_length=200)
subject: str = Field(..., description="Message subject", max_length=500)
body: str = Field(..., description="Message body, markdown ok")
class CoordMessageUpdate(BaseModel):
"""Input schema for updating a message (mark read, etc.)."""
read_at: Optional[datetime] = None
class CoordMessageResponse(BaseModel):
"""Output schema for a message."""
id: UUID
from_session: str
to_session: Optional[str]
project_key: Optional[str]
subject: str
body: str
read_at: Optional[datetime]
created_at: datetime
updated_at: datetime
model_config = {"from_attributes": True}