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:
56
api/models/coord_message.py
Normal file
56
api/models/coord_message.py
Normal file
@@ -0,0 +1,56 @@
|
||||
"""Coordination inter-session message model."""
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from sqlalchemy import DateTime, Index, String, Text
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from .base import Base, TimestampMixin, UUIDMixin
|
||||
|
||||
|
||||
class CoordMessage(Base, UUIDMixin, TimestampMixin):
|
||||
"""A message sent from one session to another (or broadcast)."""
|
||||
|
||||
__tablename__ = "coord_messages"
|
||||
|
||||
from_session: Mapped[str] = mapped_column(
|
||||
String(200),
|
||||
nullable=False,
|
||||
doc="Sending session, e.g. 'DESKTOP-0O8A1RL/Claude'"
|
||||
)
|
||||
|
||||
to_session: Mapped[Optional[str]] = mapped_column(
|
||||
String(200),
|
||||
doc="Recipient session; NULL means broadcast to all"
|
||||
)
|
||||
|
||||
project_key: Mapped[Optional[str]] = mapped_column(
|
||||
String(200),
|
||||
doc="Optional project context for the message"
|
||||
)
|
||||
|
||||
subject: Mapped[str] = mapped_column(
|
||||
String(500),
|
||||
nullable=False,
|
||||
doc="Message subject line"
|
||||
)
|
||||
|
||||
body: Mapped[str] = mapped_column(
|
||||
Text,
|
||||
nullable=False,
|
||||
doc="Message body, markdown ok"
|
||||
)
|
||||
|
||||
read_at: Mapped[Optional[datetime]] = mapped_column(
|
||||
DateTime,
|
||||
doc="NULL means unread"
|
||||
)
|
||||
|
||||
__table_args__ = (
|
||||
Index("idx_coord_messages_to_read", "to_session", "read_at"),
|
||||
Index("idx_coord_messages_from", "from_session"),
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<CoordMessage(from='{self.from_session}', to='{self.to_session}', subject='{self.subject}')>"
|
||||
Reference in New Issue
Block a user