# 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 Anthropic 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 Anthropic client
# ---------------------------------------------------------------------------
from connexum_governance import GovernanceClient
from connexum_governance.integrations.anthropic import AnthropicGovernance

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

if hasattr(_orig_mod, "client"):
    _orig_mod.client = _gov.wrap(_orig_mod.client)

# ---------------------------------------------------------------------------
# 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("_")]
