File size: 1,917 Bytes
a348131
ba98117
a348131
 
ba98117
a348131
 
ba98117
a348131
ba98117
a348131
9ca76dd
a348131
ba98117
a348131
ba98117
a348131
ba98117
 
a348131
ba98117
a348131
ba98117
a348131
 
ba98117
 
 
 
 
 
 
 
 
 
 
 
a348131
 
ba98117
a348131
ba98117
a348131
 
 
 
ba98117
a348131
 
ba98117
a348131
 
 
ba98117
a348131
 
 
 
 
 
 
ba98117
a348131
1
2
3
4
5
6
7
8
9
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
import os

from functools import lru_cache


class Config:
    """Base configuration."""

    APP_ENV = os.getenv("APP_ENV", "development")

    # Server
    HOST = os.getenv("HOST", "127.0.0.1")
    PORT = int(os.getenv("PORT", 8181))

    # Nacos
    NACOS_SERVER_ADDR = os.getenv("NACOS_SERVER_ADDR", "127.0.0.1:8848")
    NACOS_NAMESPACE = os.getenv("NACOS_NAMESPACE", "public")
    NACOS_USERNAME = os.getenv("NACOS_USERNAME", "")
    NACOS_PASSWORD = os.getenv("NACOS_PASSWORD", "")
    SERVICE_NAME = os.getenv("SERVICE_NAME", "python-agent")

    # MCP Clients
    MCP_BRAVE_PATH = os.getenv("MCP_BRAVE_PATH")  # Optional override
    NACOS_GATEWAY_SERVICE_NAME = os.getenv("NACOS_GATEWAY_SERVICE_NAME", "gateway")

    # Database
    PG_HOST = os.getenv("PG_HOST", "localhost")
    PG_PORT = int(os.getenv("PG_PORT", 5432))
    PG_USER = os.getenv("PG_USER", "postgres")
    PG_PASSWORD = os.getenv("PG_PASSWORD", "postgres")
    PG_DB = os.getenv("PG_DB", "postgres")
    DB_URI = f"postgresql://{PG_USER}:{PG_PASSWORD}@{PG_HOST}:{PG_PORT}/{PG_DB}"
    DB_ASYNC_URI = (
        f"postgresql+psycopg://{PG_USER}:{PG_PASSWORD}@{PG_HOST}:{PG_PORT}/{PG_DB}"
    )


class DevelopmentConfig(Config):
    """Development configuration."""

    DEBUG = True
    # In Dev, we might want to default to localhost if not specified,
    # but the user's current valid config points to an external Nacos.
    # We'll keep the external Nacos as default for now based on current working code.
    pass


class ProductionConfig(Config):
    """Production configuration."""

    DEBUG = False
    # Enforce stricter defaults or require env vars here if needed


@lru_cache()
def get_settings():
    env = os.getenv("APP_ENV", "development")
    if env == "production":
        return ProductionConfig()
    return DevelopmentConfig()


settings = get_settings()