"""Check the tutorial's local SDK boundary without credentials or API calls.

Run in a disposable environment with google-genai==2.33.0 installed:
    python google-genai-offline-check.py
This validates local configuration, not remote access or model behavior.
"""
import importlib.metadata
import json
import socket


def reject_network(*args, **kwargs):
    raise RuntimeError('This configuration check forbids network requests')


def main():
    # Importing a package is separate from constructing request configuration.
    # Block connections before either step; no actual key is read or needed.
    socket.socket.connect = reject_network
    socket.create_connection = reject_network
    from google import genai
    from google.genai import types

    config = types.GenerateContentConfig(
        system_instruction='Explain the answer clearly. State missing information.',
        max_output_tokens=512,
    )
    assert config.system_instruction and config.max_output_tokens == 512
    with genai.Client(api_key='offline-example-not-a-real-key') as client:
        assert callable(client.models.generate_content)
    live_config = types.LiveConnectConfig(response_modalities=['AUDIO'])
    assert live_config.response_modalities
    print(json.dumps({
        'google-genai': importlib.metadata.version('google-genai'),
        'configuration_constructed': True,
        'remote_requests': 0,
        'proves': 'local imports, client construction and configuration fields',
        'does_not_prove': 'authentication, model access, generation or Live playback',
    }, indent=2))


if __name__ == '__main__':
    main()
