Skip to content

Config Module

voice_agent.config

Configuration management for voice-agent.

Loads settings from environment variables with validation.

Settings

Bases: BaseSettings

Application settings loaded from environment variables.

Attributes:

Name Type Description
telegram_bot_token str

Telegram Bot API token from @BotFather.

whisper_url str

URL of the whisper-server transcription endpoint.

allowed_chat_ids str

Comma-separated list of allowed Telegram chat IDs.

default_cwd str

Default working directory for Claude sessions.

permission_timeout int

Seconds to wait for permission approval.

projects dict[str, str]

Mapping of project names to their working directories.

Source code in src/voice_agent/config.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class Settings(BaseSettings):
    """Application settings loaded from environment variables.

    Attributes:
        telegram_bot_token: Telegram Bot API token from @BotFather.
        whisper_url: URL of the whisper-server transcription endpoint.
        allowed_chat_ids: Comma-separated list of allowed Telegram chat IDs.
        default_cwd: Default working directory for Claude sessions.
        permission_timeout: Seconds to wait for permission approval.
        projects: Mapping of project names to their working directories.
    """

    model_config = SettingsConfigDict(
        env_file=".env",
        env_file_encoding="utf-8",
        extra="ignore",
    )

    telegram_bot_token: str = Field(
        description="Telegram Bot API token from @BotFather"
    )
    whisper_url: str = Field(
        default="http://localhost:8080/transcribe",
        description="URL of the whisper-server transcription endpoint",
    )
    allowed_chat_ids: str = Field(
        default="",
        description="Comma-separated list of allowed Telegram chat IDs",
    )
    default_cwd: str = Field(
        default="/code",
        description="Default working directory for Claude sessions",
    )
    permission_timeout: int = Field(
        default=300,
        description="Seconds to wait for permission approval",
    )
    projects: dict[str, str] = Field(
        default_factory=dict,
        description="Mapping of project names to their working directories",
    )
    session_storage_path: str = Field(
        default="sessions.json",
        description="Path to the session storage file",
    )

    def get_allowed_chat_ids(self) -> set[int]:
        """Parse allowed_chat_ids into a set of integers.

        Returns:
            Set of allowed Telegram chat IDs.
        """
        if not self.allowed_chat_ids:
            return set()
        return {int(cid.strip()) for cid in self.allowed_chat_ids.split(",")}

get_allowed_chat_ids()

Parse allowed_chat_ids into a set of integers.

Returns:

Type Description
set[int]

Set of allowed Telegram chat IDs.

Source code in src/voice_agent/config.py
56
57
58
59
60
61
62
63
64
def get_allowed_chat_ids(self) -> set[int]:
    """Parse allowed_chat_ids into a set of integers.

    Returns:
        Set of allowed Telegram chat IDs.
    """
    if not self.allowed_chat_ids:
        return set()
    return {int(cid.strip()) for cid in self.allowed_chat_ids.split(",")}

load_settings()

Load and validate settings from environment.

Returns:

Type Description
Settings

Validated Settings instance.

Raises:

Type Description
ValidationError

If required settings are missing or invalid.

Source code in src/voice_agent/config.py
67
68
69
70
71
72
73
74
75
76
def load_settings() -> Settings:
    """Load and validate settings from environment.

    Returns:
        Validated Settings instance.

    Raises:
        ValidationError: If required settings are missing or invalid.
    """
    return Settings()