An always-on second brain you talk to. Voice notes in Telegram → typed, linked knowledge in your Obsidian vault. Runs 24/7 on the Claude subscription you already have.
Python ai-agentsai-automationclaudeclaude-codeebbinghausknowledge-graphllmmemory-systemobsidianpersonal-assistantpkmproductivitypythonsecond-braintelegram-botvoice-assistant
feat(config): add session, timezone and escape-hatch settings
smixs3bff4cb7ebad
diff --git a/.env.example b/.env.exampleindex 7366f78..02e833d 100644--- a/.env.example+++ b/.env.example@@ -11,4 +11,20 @@ TODOIST_API_KEY=VAULT_PATH=./vault# JSON array of Telegram user IDs allowed to use the bot (empty = allow all)+# The FIRST id also receives health alerts / daily reports.ALLOWED_USER_IDS=[123456789]++# Timezone for systemd timers and reports (e.g. Asia/Tashkent, Europe/Moscow)+TZ=UTC++# Model for the persistent session. Empty = Claude Code default (Opus).+# Set to "sonnet" to reduce weekly-limit pressure for a 24/7 bot.+CLAUDE_MODEL=++# ── Escape hatch (only if Anthropic ever closes the interactive path) ──+# Leave as "interactive" to stay on the subscription. Set to "router" to fall+# back to claude -p against a different provider via ANTHROPIC_BASE_URL.+DBRAIN_MODE=interactive+# ANTHROPIC_BASE_URL=+# A SEPARATE billed API key (NOT your subscription login) for router mode:+# ANTHROPIC_AUTH_TOKEN=diff --git a/src/d_brain/config.py b/src/d_brain/config.pyindex eb8836a..ee6de10 100644--- a/src/d_brain/config.py+++ b/src/d_brain/config.py@@ -31,6 +31,38 @@ class Settings(BaseSettings):description="Whether to allow access to all users (security risk!)",)+ # ── persistent tmux session ──────────────────────────────────────+ runtime_dir: Path = Field(+ default_factory=lambda: Path.home() / ".dbrain",+ description="Runtime dir for locks, pane.log, ready/inflight flags",+ )+ brain_session_name: str = Field(+ default="",+ description="tmux session name (empty → generated & persisted per install)",+ )+ claude_model: str = Field(+ default="",+ description="Model for the session (empty = Claude Code default)",+ )+ tz: str = Field(default="UTC", description="Timezone for timers/reports")++ # ── escape hatch (fallback provider routing) ─────────────────────+ dbrain_mode: str = Field(+ default="interactive",+ description="interactive (subscription) | router (claude -p via base URL)",+ )+ anthropic_base_url: str = Field(+ default="", description="Fallback provider base URL (router mode)"+ )+ anthropic_auth_token: str = Field(+ default="", description="Fallback provider API key (router mode)"+ )++ @property+ def admin_chat_id(self) -> int | None:+ """First allowed user — destination for health alerts / reports."""+ return self.allowed_user_ids[0] if self.allowed_user_ids else None+@propertydef daily_path(self) -> Path:"""Path to daily notes directory."""diff --git a/tests/test_config.py b/tests/test_config.pynew file mode 100644index 0000000..ae3dfae--- /dev/null+++ b/tests/test_config.py@@ -0,0 +1,38 @@+"""Tests for the extended Settings (tmux-session + escape-hatch fields)."""++from pathlib import Path++from d_brain.config import Settings+++def _settings(**over):+ base = dict(telegram_bot_token="t", deepgram_api_key="d", _env_file=None)+ base.update(over)+ return Settings(**base)+++def test_new_fields_have_safe_defaults():+ s = _settings()+ assert s.dbrain_mode == "interactive"+ assert s.tz == "UTC"+ assert s.claude_model == "" # "" → use the session's default model+ assert s.anthropic_base_url == ""+ assert s.anthropic_auth_token == ""+ assert isinstance(s.runtime_dir, Path)+++def test_admin_chat_id_is_first_allowed_user():+ s = _settings(allowed_user_ids=[111, 222])+ assert s.admin_chat_id == 111+++def test_admin_chat_id_none_when_no_users():+ s = _settings(allowed_user_ids=[])+ assert s.admin_chat_id is None+++def test_overrides_from_kwargs():+ s = _settings(dbrain_mode="router", claude_model="sonnet", tz="Asia/Tashkent")+ assert s.dbrain_mode == "router"+ assert s.claude_model == "sonnet"+ assert s.tz == "Asia/Tashkent"