- Add cortex/persona.py: ContextVar-based per-request routing with path traversal protection and persona validation - Migrate inara/ → personas/inara/ (git history preserved via git mv) - config.py: add personas_root(), inara_path() delegates to personas/inara - All 14 settings.inara_path() call sites replaced with persona_path() - ChatRequest + OrchestrateRequest: add persona field (default: "inara") with validation at request entry before any processing - memory_distiller: add optional persona param for future per-persona distill - cron_runner/tools/cron: stamp persona on jobs, prefix APScheduler IDs (persona:job_id) to prevent collisions across personas - scheduler: _load_user_crons() iterates all personas at startup Adding a new persona: create personas/<name>/ with IDENTITY.md + SOUL.md. Auth: handled at nginx level (inject X-Cortex-Persona header per subdomain). Future: persona maps to Aether account_id_random for full integration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
95 lines
4.2 KiB
Python
95 lines
4.2 KiB
Python
from pathlib import Path
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
anthropic_api_key: str | None = None # not used — claude CLI handles auth
|
|
|
|
# Orchestrator (Gemini API — separate from Gemini CLI)
|
|
# Get a key at: https://aistudio.google.com/apikey (free tier is sufficient)
|
|
gemini_api_key: str | None = None
|
|
orchestrator_model: str = "gemini-2.5-flash" # model used for tool loop
|
|
orchestrator_max_rounds: int = 10 # safety cap on tool iterations
|
|
|
|
# DuckDuckGo search (used by orchestrator web_search tool)
|
|
# Leave blank to use the free unauthenticated tier; set to your API key for higher limits
|
|
ddg_api_key: str | None = None
|
|
ddg_max_results: int = 5
|
|
|
|
# Aether Platform API (used by orchestrator ae_journal_* and ae_task_list tools)
|
|
ae_api_url: str = "https://dev-api.oneskyit.com"
|
|
ae_api_key: str = "" # x-aether-api-key header
|
|
ae_account_id: str = "" # x-account-id header
|
|
ae_api_timeout: int = 15 # per-request timeout in seconds
|
|
|
|
# Agent identity — used in prompts, session logs, and memory distillation
|
|
# Override in .env for each instance (e.g. AGENT_NAME=Holly, USER_NAME=Holly)
|
|
agent_name: str = "Inara"
|
|
user_name: str = "Scott"
|
|
|
|
personas_dir: Path = Path("../personas")
|
|
inara_dir: Path = Path("../personas/inara") # legacy — use personas_dir
|
|
sessions_dir: Path = Path("./data/sessions")
|
|
default_model: str = "claude-sonnet-4-6"
|
|
default_tier: int = 2
|
|
max_history_messages: int = 40 # rolling window — 20 turns (user + assistant)
|
|
primary_backend: str = "claude" # "claude" or "gemini" — other is always fallback
|
|
|
|
# Per-backend timeouts in seconds
|
|
timeout_claude: int = 60
|
|
timeout_gemini: int = 120 # frequently slow under load
|
|
timeout_local: int = 300 # local models may need to load first
|
|
|
|
# Google Chat
|
|
# JWT audience (aud) claim to verify on inbound webhook requests.
|
|
# Google Chat sets aud = the Google Cloud project number (e.g. "741112865538").
|
|
# Set to "" to disable verification (dev/testing only).
|
|
google_chat_audience: str = ""
|
|
# Google Chat must receive a response within 30s or shows an error to the user
|
|
google_chat_timeout: int = 25
|
|
# Backend forced for Google Chat — Claude is more reliable within the 25s deadline
|
|
google_chat_backend: str = "claude"
|
|
|
|
# Nextcloud Talk bot
|
|
nextcloud_url: str = "https://cloud.dgrzone.com"
|
|
nextcloud_talk_bot_secret: str = "" # set in .env
|
|
nextcloud_talk_timeout: int = 55
|
|
|
|
# Auto-distillation schedule — override in .env
|
|
# AUTO_DISTILL=false disables entirely
|
|
scheduler_timezone: str = "America/New_York" # IANA tz — override in .env if needed
|
|
auto_distill: bool = True
|
|
auto_distill_short: bool = True # daily at 03:00 — rolls session logs → MEMORY_SHORT
|
|
auto_distill_mid: bool = True # weekly Sunday at 03:30 — LLM summarizes short → mid
|
|
auto_distill_long: bool = False # monthly 1st at 04:00 — off by default (manual review recommended)
|
|
|
|
# Memory tier token budgets — soft caps used during distillation
|
|
# Override in .env: MEMORY_BUDGET_LONG=4000 etc.
|
|
memory_budget_long: int = 2000
|
|
memory_budget_mid: int = 2000
|
|
memory_budget_short: int = 3000
|
|
|
|
host: str = "0.0.0.0"
|
|
port: int = 8000
|
|
|
|
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
|
|
|
|
def personas_root(self) -> Path:
|
|
"""Resolve personas_dir relative to this file's location if not absolute."""
|
|
if self.personas_dir.is_absolute():
|
|
return self.personas_dir
|
|
return (Path(__file__).parent / self.personas_dir).resolve()
|
|
|
|
def inara_path(self) -> Path:
|
|
"""Legacy helper — returns the inara persona directory. Prefer persona_path()."""
|
|
return self.personas_root() / "inara"
|
|
|
|
def sessions_path(self) -> Path:
|
|
"""Resolve sessions_dir relative to this file's location if not absolute."""
|
|
if self.sessions_dir.is_absolute():
|
|
return self.sessions_dir
|
|
return (Path(__file__).parent / self.sessions_dir).resolve()
|
|
|
|
|
|
settings = Settings()
|