core.modes¶
Mode modules: toggleable mode registry (single source of truth) with callback propagation and persistent settings.
Mode Registry¶
core.modes.mode_registry
¶
Mode registry and command parsing.
Provides ModeRegistry as the single source of truth for all ten mode
flags. The previous pattern (updating globals + config module separately)
has been replaced by a callback-based sync mechanism via set_mode_flag().
process_mode_commands parses voice commands and delegates flag toggles
to the registry.
ModeRegistry
¶
Central store for all mode flags.
Callers read via .get(name) and write via .set(name, value).
Changes propagate to main.py globals and config module via callbacks
(legacy compat path).
ModeFlag
dataclass
¶
Backing store for one mode toggle with optional callbacks.
process_mode_commands(user_text: str, agents: list, registry: ModeRegistry, language_model: str, analysis_model: str, logger, torch, set_flag: Callable[[str, bool], None] | None = None) -> None
¶
Parse spoken mode-toggle commands.
Dependencies are passed explicitly so the function is testable.
When set_flag is provided it's used instead of registry.set()
so the caller can keep globals and config-module attributes in sync
(three-way sync). Without it only the registry is updated.
Settings Persistence¶
core.modes.settings_persistence
¶
Settings persistence layer for cross-restart durability.
Wires SQLite settings storage into the control update flow and provides startup restore. All UI-driven configuration changes (sampling params, mode toggles, model selections, agent state) are persisted to SQLite and restored on next launch. System prompts (general and per-agent) are persisted during a session but reset to config defaults on restart so users don't have to manually clear them after experiments.
Key naming scheme
sampling.{key} - temperature, top_p, top_k, etc. mode.{flag_name} - cloud_mode, mute_mode, analysis_mode, etc. agent.{name}.{setting} - active (restored), system_prompt1 (persisted only) model.{role} - language_model, analysis_model, etc. prompt.{key} - system_prompt_chat_single_agent, etc. (persisted only)
persist_control_update(update: dict[str, Any], agents: list[Any], store) -> None
async
¶
Persist changed settings to SQLite after _apply_control_update applies them.
Each call is wrapped in try/except so persistence failures never break runtime behavior.
restore_settings_to_runtime(store, config_module: Any, agents: list[Any], globals_dict: dict[str, Any] | None = None) -> None
async
¶
Restore persisted settings from SQLite to runtime config/globals/agents.
Parameters¶
store :
SQLiteStore (or any object with list_settings() async method).
config_module :
The config.config module object – attributes are set via setattr.
agents : list[Agent]
Built agent instances for agent-specific setting restore.
globals_dict : dict | None
Optional: the module-level globals() dict from main.py.
If provided, mode flags and model roles will be restored here too
(maintains three-way sync invariant).