Initial project structure
Scaffold all modules, route stubs, data models, and config. No logic implemented yet — all core methods raise NotImplementedError. Establishes the full directory layout matching the architecture in CLAUDE.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
76
fellowship/core/session.py
Normal file
76
fellowship/core/session.py
Normal file
@@ -0,0 +1,76 @@
|
||||
"""
|
||||
Session data model — the single source of truth for a session's state.
|
||||
All other core modules read from and write to a Session instance.
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from enum import Enum
|
||||
from typing import Any, Optional
|
||||
|
||||
|
||||
class ParticipationMode(str, Enum):
|
||||
AUTONOMOUS = "autonomous"
|
||||
REACTIVE = "reactive"
|
||||
COLLABORATIVE = "collaborative"
|
||||
|
||||
|
||||
class TurnOrder(str, Enum):
|
||||
ROUND_ROBIN = "round_robin"
|
||||
ORCHESTRATED = "orchestrated"
|
||||
|
||||
|
||||
class SessionState(str, Enum):
|
||||
WAITING = "waiting" # Waiting for first talker message (reactive/collaborative)
|
||||
RUNNING = "running" # Loop is active
|
||||
PAUSED = "paused" # Paused via API
|
||||
ENDED = "ended" # Session is over
|
||||
|
||||
|
||||
@dataclass
|
||||
class BotConfig:
|
||||
name: str
|
||||
system_prompt: str
|
||||
model: Optional[str] = None
|
||||
temperature: Optional[float] = None
|
||||
role: Optional[str] = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class Message:
|
||||
role: str # "bot", "talker", "system"
|
||||
sender: str # bot name or talker display name
|
||||
content: Optional[str] # None while a rectification slot is reserved
|
||||
turn: int
|
||||
tokens: Optional[int] = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class SessionOptions:
|
||||
participation_mode: ParticipationMode = ParticipationMode.AUTONOMOUS
|
||||
turn_order: TurnOrder = TurnOrder.ROUND_ROBIN
|
||||
max_talkers: int = 1
|
||||
max_turns: Optional[int] = None
|
||||
max_time: Optional[int] = None
|
||||
max_context_tokens: Optional[int] = None
|
||||
rectify_history: bool = True
|
||||
summarize_context: bool = False
|
||||
stream_tokens: bool = False
|
||||
goal: Optional[str] = None
|
||||
debug: bool = False
|
||||
llm_base_url: Optional[str] = None
|
||||
llm_api_key: Optional[str] = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class Session:
|
||||
token: str
|
||||
bots: list[BotConfig]
|
||||
options: SessionOptions
|
||||
global_system_prompt: Optional[str] = None
|
||||
state: SessionState = SessionState.WAITING
|
||||
history: list[Message] = field(default_factory=list)
|
||||
turn_count: int = 0
|
||||
robin_index: int = 0 # Current position in round_robin order
|
||||
created_at: float = 0.0 # Unix timestamp
|
||||
talker_count: int = 0
|
||||
observer_count: int = 0
|
||||
Reference in New Issue
Block a user