
import os
import logging
from google.genai.types import Tool, FunctionDeclaration, Schema, Type # Using installed google-genai types
# Assumed ADK imports
try:
    from google.adk.core import AgentConfig, ModelConfig
    from google.adk.tools import AutoBrowseTool, CodeExecutionTool, GoogleSearchTool
except ImportError:
    logging.warning("ADK tools not importable. Using mock config.")
    class AgentConfig: 
        def __init__(self, **kwargs): pass
    class ModelConfig:
        def __init__(self, **kwargs): pass
    class AutoBrowseTool: pass
    class CodeExecutionTool: pass
    class GoogleSearchTool: pass

def load_system_instruction() -> str:
    """Load the immutable source of truth for the agent."""
    rule_path = os.path.join(os.getcwd(), ".agent", "rules", "mentorship.md")
    try:
        with open(rule_path, "r", encoding="utf-8") as f:
            return f.read()
    except FileNotFoundError:
        return "IDENTITY: Antigravity. (Fallback: Rule file not found)."

def get_native_config() -> AgentConfig:
    """
    Returns the Native Antigravity Agent Configuration.
    Enabled: Auto-Browse, Code Execution, Search.
    """
    return AgentConfig(
        model=ModelConfig(
            model_name="models/gemini-3-flash",
            generation_config={
                "temperature": 0.2,
                "top_p": 0.95,
                "max_output_tokens": 8192,
            },
            system_instruction=load_system_instruction()
        ),
        tools=[
            # Native ADK Tools - No custom implementation needed
            AutoBrowseTool(
                profile_path=os.environ.get("CHROME_PROFILE_PATH", "Default"),
                headless=False # User wants "Shared Cursor" visible
            ),
            CodeExecutionTool(), # For Agentic Vision/Calculation
            GoogleSearchTool()   # For knowledge grounding
        ],
        knowledge_base="loops/UVS_MASTER_TASKS.json" # Link to RWL
    )
