# auto-generated by @connexum/ai-governance — do not edit; regenerate via npx ai-governance init --agent-dir
# agent-id: {{AGENT_ID}}
# source:   {{SOURCE_FILE}}
"""
Governance shim for {{MODULE_NAME}}.
Wraps Google Gemini client with Connexum governance enforcement.
Change pack assignments in governance.json; regenerate this file to apply.
"""
from __future__ import annotations

import importlib
import importlib.util
import sys
import os
from pathlib import Path

# ---------------------------------------------------------------------------
# Load original module
# ---------------------------------------------------------------------------
_src_dir = Path(__file__).parent
_orig_spec = importlib.util.spec_from_file_location(
    "{{MODULE_NAME}}._original",
    _src_dir / "{{SOURCE_FILE}}",
)
_orig_mod = importlib.util.module_from_spec(_orig_spec)  # type: ignore[arg-type]
_orig_spec.loader.exec_module(_orig_mod)  # type: ignore[union-attr]

# ---------------------------------------------------------------------------
# Wrap Google Gemini client
# ---------------------------------------------------------------------------
from connexum_governance import GovernanceClient
from connexum_governance.integrations.gemini import GeminiGovernance

_gov_client = GovernanceClient(
    api_url=os.environ.get("CONNEXUM_API_URL", "http://localhost:4201"),
    license_key=os.environ.get("CONNEXUM_LICENSE_KEY", ""),
)
_gov = GeminiGovernance(
    client=_gov_client,
    agent_name="{{AGENT_ID}}",
    packs={{PACKS}},
)

# Google GenAI uses module-level genai.configure(); wrap the model attribute if present
if hasattr(_orig_mod, "model"):
    _orig_mod.model = _gov.wrap(_orig_mod.model)

# ---------------------------------------------------------------------------
# Re-export original module's public API
# ---------------------------------------------------------------------------
for _name in dir(_orig_mod):
    if not _name.startswith("_"):
        globals()[_name] = getattr(_orig_mod, _name)

__all__ = [n for n in dir(_orig_mod) if not n.startswith("_")]
