from __future__ import annotations

import os
from dataclasses import dataclass


@dataclass
class AuthContext:
    agent_key: str
    token_prefix: str


def resolve_auth() -> AuthContext | None:
    """Resolve API key from environment variable (stdio transport)."""
    env_key = (os.environ.get("AGENTVEE_API_KEY") or "").strip()
    if env_key:
        return AuthContext(agent_key=env_key, token_prefix=env_key[:12])
    return None
