"""All paths and constants. Zero imports except stdlib."""
import os, sys
from pathlib import Path

VERSION = "3.1.0"

if sys.platform == "win32":
    BASE_DIR = Path(os.environ.get("APPDATA", Path.home())) / "doit-fm"
elif sys.platform == "darwin":
    BASE_DIR = Path.home() / "Library" / "Application Support" / "doit-fm"
else:
    BASE_DIR = Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config")) / "doit-fm"

DATA_DIR    = BASE_DIR / "data"
LOG_DIR     = BASE_DIR / "logs"
CONFIG_FILE = BASE_DIR / "config.json"
LOCK_FILE   = DATA_DIR / "agent.pid"
TASK_LOG    = DATA_DIR / "tasks.jsonl"   # append-only task history

AI_PROVIDERS = {
    "nvidia": {
        "name": "NVIDIA NIM  (100+ models: Llama, Mistral, Kimi, DeepSeek…)",
        "base_url": "https://integrate.api.nvidia.com/v1",
        "key_url": "https://build.nvidia.com  → Get API Key (free credits included)",
        "models": [
            {"id": "meta/llama-4-maverick-17b-128e-instruct",    "label": "Llama 4 Maverick 128k  — best overall (free credits)", "free": True},
            {"id": "meta/llama-4-scout-17b-16e-instruct",        "label": "Llama 4 Scout 16k  — fast & smart (free credits)",     "free": True},
            {"id": "moonshotai/kimi-k2-instruct",                "label": "Moonshot Kimi K2 Instruct 128k  (free credits)",        "free": True},
            {"id": "moonshotai/kimi-k2.5",                       "label": "Moonshot Kimi K2.5 multimodal 128k  (free credits)",   "free": True},
            {"id": "mistralai/mistral-large-2-instruct",         "label": "Mistral Large 2 Instruct  (free credits)",             "free": True},
            {"id": "mistralai/mixtral-8x22b-instruct-v0.1",      "label": "Mixtral 8x22B Instruct  (free credits)",               "free": True},
            {"id": "meta/llama-3.3-70b-instruct",                "label": "Llama 3.3 70B Instruct  (free credits)",               "free": True},
            {"id": "deepseek-ai/deepseek-r1",                    "label": "DeepSeek R1 reasoning  (free credits)",                "free": True},
            {"id": "nvidia/llama-3.1-nemotron-70b-instruct",     "label": "NVIDIA Nemotron 70B  — optimised for agents",          "free": True},
            {"id": "google/gemma-3-27b-it",                      "label": "Google Gemma 3 27B  (free credits)",                   "free": True},
        ],
    },
    "openai": {
        "name": "OpenAI",
        "base_url": "https://api.openai.com/v1",
        "key_url": "https://platform.openai.com/api-keys",
        "models": [
            {"id": "gpt-4.1",       "label": "GPT-4.1  — best for coding & agents (paid)",  "free": False},
            {"id": "gpt-4.1-mini",  "label": "GPT-4.1 mini — fast & affordable (paid)",     "free": False},
            {"id": "gpt-4.1-nano",  "label": "GPT-4.1 nano — fastest/cheapest (paid)",      "free": False},
            {"id": "gpt-4o",        "label": "GPT-4o — multimodal flagship (paid)",          "free": False},
            {"id": "o4-mini",       "label": "o4-mini — reasoning model (paid)",             "free": False},
        ],
    },
    "anthropic": {
        "name": "Anthropic (Claude)",
        "base_url": "https://api.anthropic.com/v1",
        "key_url": "https://console.anthropic.com/keys",
        "models": [
            {"id": "claude-sonnet-4-6",         "label": "Claude Sonnet 4.6  — smartest (paid)",    "free": False},
            {"id": "claude-haiku-4-5-20251001",  "label": "Claude Haiku 4.5  — fast & cheap (paid)", "free": False},
            {"id": "claude-opus-4-6",            "label": "Claude Opus 4.6  — most powerful (paid)", "free": False},
        ],
    },
    "groq": {
        "name": "Groq  (ultra-fast inference — generous free tier)",
        "base_url": "https://api.groq.com/openai/v1",
        "key_url": "https://console.groq.com/keys",
        "models": [
            {"id": "meta-llama/llama-4-maverick-17b-128e-instruct", "label": "Llama 4 Maverick  (free)", "free": True},
            {"id": "meta-llama/llama-4-scout-17b-16e-instruct",     "label": "Llama 4 Scout  (free)",    "free": True},
            {"id": "llama-3.3-70b-versatile",                        "label": "Llama 3.3 70B  (free)",   "free": True},
            {"id": "gemma2-9b-it",                                   "label": "Gemma 2 9B  (free)",      "free": True},
            {"id": "llama3-70b-8192",                                "label": "Llama 3 70B  (free)",     "free": True},
        ],
    },
    "xai": {
        "name": "xAI  (Grok)",
        "base_url": "https://api.x.ai/v1",
        "key_url": "https://console.x.ai/",
        "models": [
            {"id": "grok-3",      "label": "Grok 3  — flagship (paid)",     "free": False},
            {"id": "grok-3-mini", "label": "Grok 3 Mini  — fast (paid)",    "free": False},
            {"id": "grok-2",      "label": "Grok 2  — previous gen (paid)", "free": False},
        ],
    },
    "ollama": {
        "name": "Ollama  (local, private, completely free)",
        "base_url": "http://localhost:11434/v1",
        "key_url": "https://ollama.com/download",
        "models": [
            {"id": "llama3.2",  "label": "Llama 3.2  (local)", "free": True},
            {"id": "mistral",   "label": "Mistral 7B  (local)", "free": True},
            {"id": "gemma3",    "label": "Gemma 3  (local)",    "free": True},
            {"id": "phi4",      "label": "Phi-4  (local)",      "free": True},
            {"id": "deepseek-r1","label": "DeepSeek R1  (local)","free": True},
        ],
    },
}

HTTP_TIMEOUT = 60

BLOCKED_PATHS = [
    "/etc/shadow", "/etc/passwd", "/etc/hosts",
    "/boot", "/sys", "/proc", "/dev",
]
