2121
2222@dataclass
2323class Cartridge :
24- """A swappable behavior cartridge."""
24+ """A swappable behavior cartridge for MUD rooms.
25+
26+ Attributes:
27+ name: Unique identifier for this cartridge
28+ description: Human-readable description of what this cartridge does
29+ tools: List of available tools/commands for this cartridge
30+ onboarding_human: Welcome message for human agents
31+ onboarding_agent: Welcome message for AI agents
32+ git_repo: Optional GitHub repository URL for this cartridge
33+ """
2534 name : str
2635 description : str
2736 tools : List [dict ] = field (default_factory = list )
2837 onboarding_human : str = ""
2938 onboarding_agent : str = ""
3039 git_repo : str = ""
3140
32- def to_dict (self ):
41+ def to_dict (self ) -> dict :
42+ """Convert cartridge to dictionary for serialization."""
3343 return {
3444 "name" : self .name ,
3545 "description" : self .description ,
@@ -42,18 +52,32 @@ def to_dict(self):
4252
4353@dataclass
4454class Skin :
45- """A personality skin — maps to MUD formality + personality."""
55+ """A personality skin that maps to MUD formality mode.
56+
57+ Attributes:
58+ name: Unique skin identifier
59+ description: Human-readable description of this personality
60+ formality: MUD formality level (NAVAL, PROFESSIONAL, TNG, CASUAL, MINIMAL)
61+ system_prompt_suffix: Optional suffix to add to system prompts
62+ temperature: AI temperature for this skin (0.0-1.0)
63+ tool_preferences: Optional weights for tool selection
64+ """
4665 name : str
4766 description : str
48- formality : str = "TNG" # NAVAL, PROFESSIONAL, TNG, CASUAL, MINIMAL
67+ formality : str = "TNG"
4968 system_prompt_suffix : str = ""
5069 temperature : float = 0.7
5170 tool_preferences : Dict [str , float ] = field (default_factory = dict )
5271
5372
54- @dataclass
73+ @dataclass
5574class Scene :
56- """A complete scene: ROOM × CARTRIDGE × SKIN × MODEL × TIME"""
75+ """A complete scene configuration: ROOM × CARTRIDGE × SKIN × MODEL × TIME.
76+
77+ Represents a room's active configuration at a specific time,
78+ combining cartridge (behavior), skin (personality), model (AI),
79+ and schedule (when this is active).
80+ """
5781 room_id : str
5882 cartridge_name : str
5983 skin_name : str
@@ -63,18 +87,22 @@ class Scene:
6387
6488
6589class CartridgeBridge :
66- """Bridges cartridge-mcp to FLUX-LCAR MUD."""
90+ """Bridges cartridge-mcp to FLUX-LCAR MUD.
91+
92+ Manages cartridges, skins, and scenes, allowing MUD rooms
93+ to change behavior dynamically by loading different cartridges.
94+ """
6795
68- def __init__ (self ):
96+ def __init__ (self ) -> None :
97+ """Initialize cartridge bridge with defaults."""
6998 self .cartridges : Dict [str , Cartridge ] = {}
7099 self .skins : Dict [str , Skin ] = {}
71100 self .scenes : List [Scene ] = []
72- self .active_scenes : Dict [str , Scene ] = {} # room_id -> active scene
73-
74- # Register built-in cartridges
101+ self .active_scenes : Dict [str , Scene ] = {}
75102 self ._register_defaults ()
76103
77- def _register_defaults (self ):
104+ def _register_defaults (self ) -> None :
105+ """Register built-in cartridges and skins from JC1's cartridge-mcp."""
78106 # Cartridges from JC1's cartridge-mcp
79107 self .register_cartridge (Cartridge (
80108 name = "spreader-loop" ,
@@ -138,20 +166,49 @@ def _register_defaults(self):
138166 self .register_skin (Skin ("rival" , "Competitive rival" , "TNG" , temperature = 0.85 ))
139167 self .register_skin (Skin ("field-commander" , "Military field commander" , "NAVAL" , temperature = 0.5 ))
140168
141- def register_cartridge (self , cart : Cartridge ):
169+ def register_cartridge (self , cart : Cartridge ) -> None :
170+ """Register a cartridge.
171+
172+ Args:
173+ cart: Cartridge instance to register
174+ """
142175 self .cartridges [cart .name ] = cart
143176
144- def register_skin (self , skin : Skin ):
177+ def register_skin (self , skin : Skin ) -> None :
178+ """Register a personality skin.
179+
180+ Args:
181+ skin: Skin instance to register
182+ """
145183 self .skins [skin .name ] = skin
146184
147185 def build_scene (self , room_id : str , cartridge : str , skin : str ,
148186 model : str , schedule : str = "always" ) -> Scene :
187+ """Build and register a new scene.
188+
189+ Args:
190+ room_id: Room identifier where this scene applies
191+ cartridge: Name of the cartridge to use
192+ skin: Name of the personality skin
193+ model: AI model to use for this scene
194+ schedule: When this scene should be active
195+
196+ Returns:
197+ The created Scene object
198+ """
149199 scene = Scene (room_id , cartridge , skin , model , schedule )
150200 self .scenes .append (scene )
151201 return scene
152202
153203 def activate_scene (self , room_id : str ) -> Optional [Scene ]:
154- """Activate the best scene for a room based on current time."""
204+ """Activate the best scene for a room based on current time.
205+
206+ Args:
207+ room_id: Room identifier to activate scene for
208+
209+ Returns:
210+ Scene if one was activated, None if no scenes available
211+ """
155212 candidates = [s for s in self .scenes if s .room_id == room_id ]
156213 if not candidates :
157214 return None
@@ -177,7 +234,14 @@ def activate_scene(self, room_id: str) -> Optional[Scene]:
177234 return scene
178235
179236 def get_mud_config (self , room_id : str ) -> dict :
180- """Get the MUD room configuration from active scene."""
237+ """Get the MUD room configuration from active scene.
238+
239+ Args:
240+ room_id: Room identifier to get config for
241+
242+ Returns:
243+ Configuration dictionary with cartridge, skin, model, schedule, and commands
244+ """
181245 scene = self .active_scenes .get (room_id )
182246 if not scene :
183247 return {}
0 commit comments