<?php

use boru\ai\Config\Config;

$config = new Config();

$config->defaults(array(
    'provider' => 'openai',
    'model' => 'gpt-5.1',
));

$config->runtime(array(
    // Global replay defaults. Providers may override any of these.
    'replay' => array(
        'enabled' => false,
        'strategy' => 'full',
        'max_turns' => 10,
        'summary' => array(
            'keep_turns' => 3,
            'max_chars' => 4000,
        ),
        'tool_data' => array(
            'enabled' => false,
            'max_chars' => 2000,
            'args_max_chars' => 600,
            'output_max_chars' => 1000,
        ),
    ),
));

$config->provider('openai', array(
    'api_key' => '',
    'base_url' => 'https://api.openai.com/v1',
    'timeout' => 60,
    'raw_http_debug' => false,
    'stream_read_size' => 1024,
    'replay' => array(
        'enabled' => false,
        'strategy' => 'full',
        'max_turns' => 10,
        'summary' => array(
            'keep_turns' => 3,
            'max_chars' => 4000,
        ),
        'tool_data' => array(
            'enabled' => false,
            'max_chars' => 2000,
            'args_max_chars' => 600,
            'output_max_chars' => 1000,
        ),
    ),
    // Optional provider-specific asset binding lifecycle overrides.
    'asset_bindings' => array(
        'reuse' => true,
        'max_age_seconds' => null,
        'delete_remote_on_cleanup' => false,
        'track_last_used_at' => true,
    ),
));

$config->provider('gemini', array(
    'api_key' => '',
    'base_url' => 'https://generativelanguage.googleapis.com/v1beta',
    'timeout' => 60,
    'raw_http_debug' => false,
    'stream_read_size' => 1024,
    'replay' => array(
        'enabled' => true,
        'strategy' => 'summarize_history',
        'max_turns' => 10,
        'summary' => array(
            'keep_turns' => 2,
            'max_chars' => 1200,
        ),
        'tool_data' => array(
            'enabled' => true,
            'max_chars' => 1200,
            'args_max_chars' => 300,
            'output_max_chars' => 500,
        ),
    ),
    'asset_bindings' => array(
        'reuse' => true,
        'max_age_seconds' => null,
        'delete_remote_on_cleanup' => false,
        'track_last_used_at' => true,
    ),
));

$config->persistence(array(
    'enabled' => false,
    'driver' => 'db',
    'auto_schema' => false,
    'persist_tool_calls' => false,
    'tables' => array(
        'conversations' => 'ai_conversations',
        'turns' => 'ai_turns',
        'assets' => 'ai_assets',
        'provider_asset_bindings' => 'ai_provider_asset_bindings',
        'tool_calls' => 'ai_tool_calls',
    ),
    // Global asset binding lifecycle policy defaults.
    'asset_bindings' => array(
        'reuse' => true,
        'max_age_seconds' => null,
        'delete_remote_on_cleanup' => false,
        'track_last_used_at' => true,
    ),
));

$config->db(array(
    'use' => true,
    'dbhost' => '127.0.0.1',
    'dbport' => 3306,
    'dbname' => 'ai',
    'dbuser' => 'root',
    'dbpass' => '',
    'dbtype' => 'mysql',
));

/*
Example env override names for nested replay settings:

AI_REPLAY_ENABLED=1
AI_REPLAY_STRATEGY=summarize_history
AI_REPLAY_MAX_TURNS=10
AI_REPLAY_SUMMARY_KEEP_TURNS=3
AI_REPLAY_SUMMARY_MAX_CHARS=4000
AI_REPLAY_TOOL_DATA_ENABLED=1
AI_REPLAY_TOOL_DATA_MAX_CHARS=2000
AI_REPLAY_TOOL_DATA_ARGS_MAX_CHARS=600
AI_REPLAY_TOOL_DATA_OUTPUT_MAX_CHARS=1000

GEMINI_REPLAY_ENABLED=1
GEMINI_REPLAY_STRATEGY=summarize_history
GEMINI_REPLAY_SUMMARY_KEEP_TURNS=2
GEMINI_REPLAY_SUMMARY_MAX_CHARS=1200
GEMINI_REPLAY_TOOL_DATA_ENABLED=1
GEMINI_REPLAY_TOOL_DATA_MAX_CHARS=1200
GEMINI_REPLAY_TOOL_DATA_ARGS_MAX_CHARS=300
GEMINI_REPLAY_TOOL_DATA_OUTPUT_MAX_CHARS=500

Example env override names for provider/runtime transport knobs:

OPENAI_TIMEOUT=60
OPENAI_RAW_HTTP_DEBUG=0
OPENAI_STREAM_READ_SIZE=1024
GEMINI_TIMEOUT=60
GEMINI_RAW_HTTP_DEBUG=0
GEMINI_STREAM_READ_SIZE=1024

Example env override names for DB defaults:

AI_DB_HOST=127.0.0.1
AI_DB_PORT=3306
AI_DB_NAME=ai
AI_DB_USER=root
AI_DB_PASS=
AI_DB_ADAPTER=mysql
*/

return $config;
