Gregory-L's picture
fork mindXtrain from GitHub (Professor-Codephreak/mindXtrain@661bd41) as the mindX-specific line
dfb775d verified
Raw History Blame
2.21 kB
# SPDX-License-Identifier: Apache-2.0
# (c) 2026 BANKON — all rights reserved.
"""Environment-driven configuration for WordPress.agent."""
from __future__ import annotations
from pydantic import Field, HttpUrl, SecretStr
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
"""All configuration is environment-driven. No secrets in source."""
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
env_prefix="WP_",
extra="ignore",
)
base_url: HttpUrl = Field(
...,
description="WordPress site base URL (e.g. https://rage.pythai.net).",
)
user: str = Field(
...,
description="WordPress username for the agent identity.",
)
app_password: SecretStr = Field(
...,
description="WordPress Application Password (Users -> Profile -> Application Passwords).",
)
timeout: float = Field(
default=30.0,
description="HTTP request timeout in seconds.",
ge=1.0,
le=300.0,
)
retry_count: int = Field(
default=3,
description="Number of retry attempts on transient failures.",
ge=0,
le=10,
)
retry_backoff: float = Field(
default=0.5,
description="Exponential backoff base in seconds.",
ge=0.0,
le=10.0,
)
user_agent: str = Field(
default="mindX-WordpressAgent/0.1 (+https://mindx.pythai.net)",
description="HTTP User-Agent header sent with every request.",
)
server_host: str = Field(
default="127.0.0.1",
description="Local IPC server bind host. Default loopback only.",
)
server_port: int = Field(
default=8765,
description="Local IPC server bind port.",
ge=1024,
le=65535,
)
@property
def base_url_str(self) -> str:
"""Return base_url as a trimmed string without trailing slash."""
return str(self.base_url).rstrip("/")
@property
def app_password_value(self) -> str:
"""Return the app password as a plain string for HTTP basic auth."""
return self.app_password.get_secret_value()