"""tools package — backward-compatible re-export of the public API."""
from __future__ import annotations

# --- helpers (utilities) ---
from src.tools.helpers import (
    _call_with_retry,
    _env_bool,
    _env_float,
    _env_int,
    _extract_json_block,
    _get,
    _infer_mode_from_text,
    _normalize_filters,
    _normalize_mode,
    _parse_dt,
    _parse_filters,
    _parse_key_values,
    _KNOWN_MODEL_PROVIDERS,
    _MODEL_RESPONSE_CACHE,
)

# --- langfuse_fetch (HTTP / data layer) ---
from src.tools.langfuse_fetch import (
    _build_langfuse_client,
    _fetch_trace_detail,
    _fetch_trace_observations,
    _fetch_traces,
    _langfuse_call,
    _langfuse_config,
    _metadata_match,
    langfuse_settings_scope,
    set_langfuse_settings_override,
)

# --- experiment_tools ---
from src.tools.experiment_tools import (
    trace_replay_tool,
    experiment_manager_tool,
    langfuse_eval_tool,
    response_comparison_tool,
)

# --- analysis (metrics, prompt engineering, reports, pipeline) ---
from src.tools.analysis import (
    _compact_metadata,
    _confidence_level,
    _extract_prompt_from_trace,
    _extract_text_from_model_output,
    _heuristic_opinions,
    _invoke_model_with_langchain,
    _parse_trace_timestamp,
    _polly_evaluation_section,
    _polly_observability_section,
    _polly_prompt_section,
    _prompt_delta,
    _prompt_review_with_model,
    _resolve_baseline_prompt,
    _rewrite_prompt_candidates,
    _score_prompt_candidates,
    _score_prompt_text,
    _comparison_model_specs,
    _parse_model_spec,
    _select_prompt_review_model,
    _session_cohort_summary,
    _summarize,
    _time_regression_summary,
    _to_number,
    _trace_preview,
    _trend_delta,
    _window_metrics,
    run_tool_pipeline,
)

# --- openapi_registry (OpenAPI tools, control, @tool decorators) ---
from src.tools.openapi_registry import (  # noqa: E402
    _lc_tool,
    _env_optional_bool,
    _make_langfuse_openapi_operation_tool,
    _openapi_operation_description,
    _openapi_operation_signature,
    _sanitize_openapi_tool_name,
    build_langfuse_openapi_operation_tools,
    clear_langfuse_openapi_tool_registry_cache,
    get_langfuse_builtin_tool_registry,
    get_langfuse_openapi_tool_registry,
    is_langfuse_openapi_mutating,
    langfuse_annotation_create_tool,
    langfuse_control_execute_tool,
    langfuse_control_message_tool,
    langfuse_dataset_items_upsert_tool,
    langfuse_datasets_create_tool,
    langfuse_datasets_import_from_traces_tool,
    langfuse_datasets_list_tool,
    langfuse_observations_list_tool,
    langfuse_openapi_build_tools_tool,
    langfuse_openapi_execute_tool,
    langfuse_openapi_list_operations_tool,
    langfuse_openapi_spec_tool,
    langfuse_prompt_delete_tool,
    langfuse_prompt_get_tool,
    langfuse_prompt_list_tool,
    langfuse_prompt_promote_label_tool,
    langfuse_prompt_upsert_tool,
    langfuse_score_create_tool,
    langfuse_trace_get_tool,
    langfuse_traces_list_tool,
    parse_langfuse_control_message,
    user_reports_list_tool,
    user_report_detail_tool,
    report_session_turns_tool,
    run_langfuse_control_message,
    run_langfuse_control_operation,
)

__all__ = [
    # helpers
    "_call_with_retry",
    "_env_bool",
    "_env_float",
    "_env_int",
    "_extract_json_block",
    "_get",
    "_infer_mode_from_text",
    "_normalize_filters",
    "_normalize_mode",
    "_parse_dt",
    "_parse_filters",
    "_parse_key_values",
    "_KNOWN_MODEL_PROVIDERS",
    "_MODEL_RESPONSE_CACHE",
    # langfuse_fetch
    "_build_langfuse_client",
    "_fetch_trace_detail",
    "_fetch_trace_observations",
    "_fetch_traces",
    "_langfuse_call",
    "_langfuse_config",
    "_metadata_match",
    "langfuse_settings_scope",
    "set_langfuse_settings_override",
    # analysis
    "_compact_metadata",
    "_confidence_level",
    "_extract_prompt_from_trace",
    "_extract_text_from_model_output",
    "_heuristic_opinions",
    "_invoke_model_with_langchain",
    "_parse_trace_timestamp",
    "_polly_evaluation_section",
    "_polly_observability_section",
    "_polly_prompt_section",
    "_prompt_delta",
    "_prompt_review_with_model",
    "_resolve_baseline_prompt",
    "_rewrite_prompt_candidates",
    "_score_prompt_candidates",
    "_score_prompt_text",
    "_comparison_model_specs",
    "_parse_model_spec",
    "_select_prompt_review_model",
    "_session_cohort_summary",
    "_summarize",
    "_time_regression_summary",
    "_to_number",
    "_trace_preview",
    "_trend_delta",
    "_window_metrics",
    "run_tool_pipeline",
    # openapi_registry
    "_lc_tool",
    "_env_optional_bool",
    "_make_langfuse_openapi_operation_tool",
    "_openapi_operation_description",
    "_openapi_operation_signature",
    "_sanitize_openapi_tool_name",
    "build_langfuse_openapi_operation_tools",
    "clear_langfuse_openapi_tool_registry_cache",
    "get_langfuse_builtin_tool_registry",
    "get_langfuse_openapi_tool_registry",
    "is_langfuse_openapi_mutating",
    "langfuse_annotation_create_tool",
    "langfuse_control_execute_tool",
    "langfuse_control_message_tool",
    "langfuse_dataset_items_upsert_tool",
    "langfuse_datasets_create_tool",
    "langfuse_datasets_import_from_traces_tool",
    "langfuse_datasets_list_tool",
    "langfuse_observations_list_tool",
    "langfuse_openapi_build_tools_tool",
    "langfuse_openapi_execute_tool",
    "langfuse_openapi_list_operations_tool",
    "langfuse_openapi_spec_tool",
    "langfuse_prompt_delete_tool",
    "langfuse_prompt_get_tool",
    "langfuse_prompt_list_tool",
    "langfuse_prompt_promote_label_tool",
    "langfuse_prompt_upsert_tool",
    "langfuse_score_create_tool",
    "langfuse_trace_get_tool",
    "langfuse_traces_list_tool",
    "parse_langfuse_control_message",
    "user_reports_list_tool",
    "user_report_detail_tool",
    "report_session_turns_tool",
    "run_langfuse_control_message",
    "run_langfuse_control_operation",
    # experiment_tools
    "trace_replay_tool",
    "experiment_manager_tool",
    "langfuse_eval_tool",
    "response_comparison_tool",
]
