feat(companion): enhance contact capacity management and bridge settings

- Introduced `CompanionContactCapacityError` to handle cases where persisted contacts exceed configured limits.
- Added utility functions for parsing companion bridge settings and validating contact capacity.
- Updated `RepeaterDaemon` to check contact capacity during companion loading and initialization.
- Enhanced API endpoints to validate companion settings and manage contact limits effectively.
- Implemented logging for bridge limits and errors related to contact capacity.
This commit is contained in:
Adam Gessaman
2026-06-02 07:42:40 -07:00
parent ce1acabd34
commit 7d57b34a04
6 changed files with 404 additions and 9 deletions
@@ -2229,6 +2229,20 @@ class SQLiteHandler:
return 0
# Companion persistence methods
def companion_count_contacts(self, companion_hash: str) -> int:
"""Return the number of persisted contacts for a companion."""
try:
with self._connect() as conn:
cursor = conn.execute(
"SELECT COUNT(*) FROM companion_contacts WHERE companion_hash = ?",
(companion_hash,),
)
row = cursor.fetchone()
return int(row[0]) if row else 0
except Exception as e:
logger.error(f"Failed to count companion contacts: {e}")
return 0
def companion_load_contacts(self, companion_hash: str) -> List[Dict]:
"""Load contacts for a companion from storage."""
try: