//! Curated workflow tool entries: analytics, approval, content gen, config,
//! discovery, context intelligence, telemetry, composite, and dry-run tools.

use crate::contract::error_code::ErrorCode;

use super::builders::{tool, ALL_SIX, DB_ERR, LLM_ERR, WRITE_UP, WRITE_UP_AND_API_RO};
use super::types::{Lane, Profile, ToolCategory, ToolEntry};

/// Workflow-only curated tools (non-X-API).
pub(super) fn workflow_tools() -> Vec<ToolEntry> {
    vec![
        // ── Analytics ────────────────────────────────────────────────
        tool(
            "get_stats",
            ToolCategory::Analytics,
            Lane::Workflow,
            false,
            false,
            false,
            true,
            WRITE_UP,
            DB_ERR,
        ),
        tool(
            "get_follower_trend",
            ToolCategory::Analytics,
            Lane::Workflow,
            false,
            false,
            false,
            true,
            WRITE_UP,
            DB_ERR,
        ),
        // ── Action Log ───────────────────────────────────────────────
        tool(
            "get_action_log",
            ToolCategory::Analytics,
            Lane::Workflow,
            false,
            false,
            false,
            true,
            WRITE_UP,
            DB_ERR,
        ),
        tool(
            "get_action_counts",
            ToolCategory::Analytics,
            Lane::Workflow,
            false,
            false,
            false,
            true,
            WRITE_UP,
            DB_ERR,
        ),
        // ── Mutation Audit ──────────────────────────────────────────
        tool(
            "get_recent_mutations",
            ToolCategory::Analytics,
            Lane::Workflow,
            false,
            false,
            false,
            true,
            WRITE_UP,
            DB_ERR,
        ),
        tool(
            "get_mutation_detail",
            ToolCategory::Analytics,
            Lane::Workflow,
            false,
            false,
            false,
            true,
            WRITE_UP,
            DB_ERR,
        ),
        // ── Rate Limits ──────────────────────────────────────────────
        tool(
            "get_rate_limits",
            ToolCategory::Policy,
            Lane::Workflow,
            false,
            false,
            false,
            true,
            WRITE_UP,
            DB_ERR,
        ),
        // ── Replies ──────────────────────────────────────────────────
        tool(
            "get_recent_replies",
            ToolCategory::Analytics,
            Lane::Workflow,
            false,
            false,
            false,
            true,
            WRITE_UP,
            DB_ERR,
        ),
        tool(
            "get_reply_count_today",
            ToolCategory::Analytics,
            Lane::Workflow,
            false,
            false,
            false,
            true,
            WRITE_UP,
            DB_ERR,
        ),
        // ── Target Accounts ──────────────────────────────────────────
        tool(
            "list_target_accounts",
            ToolCategory::Discovery,
            Lane::Workflow,
            false,
            false,
            false,
            true,
            WRITE_UP,
            DB_ERR,
        ),
        // ── Discovery ────────────────────────────────────────────────
        tool(
            "list_unreplied_tweets",
            ToolCategory::Discovery,
            Lane::Workflow,
            false,
            false,
            false,
            true,
            WRITE_UP,
            DB_ERR,
        ),
        // ── Scoring (pure function on &Config — no DB needed) ────────
        tool(
            "score_tweet",
            ToolCategory::Scoring,
            Lane::Shared,
            false,
            false,
            false,
            false,
            ALL_SIX,
            &[ErrorCode::InvalidInput],
        ),
        // ── Approval Queue ───────────────────────────────────────────
        tool(
            "list_pending_approvals",
            ToolCategory::Approval,
            Lane::Workflow,
            false,
            false,
            false,
            true,
            WRITE_UP,
            DB_ERR,
        ),
        tool(
            "get_pending_count",
            ToolCategory::Approval,
            Lane::Workflow,
            false,
            false,
            false,
            true,
            WRITE_UP,
            DB_ERR,
        ),
        tool(
            "approve_item",
            ToolCategory::Approval,
            Lane::Workflow,
            true,
            true,
            false,
            true,
            WRITE_UP,
            &[
                ErrorCode::DbError,
                ErrorCode::NotFound,
                ErrorCode::XNotConfigured,
                ErrorCode::XApiError,
            ],
        ),
        tool(
            "reject_item",
            ToolCategory::Approval,
            Lane::Workflow,
            true,
            false,
            false,
            true,
            WRITE_UP,
            &[ErrorCode::DbError, ErrorCode::NotFound],
        ),
        tool(
            "approve_all",
            ToolCategory::Approval,
            Lane::Workflow,
            true,
            true,
            false,
            true,
            WRITE_UP,
            &[
                ErrorCode::DbError,
                ErrorCode::XNotConfigured,
                ErrorCode::XApiError,
            ],
        ),
        // ── Content Generation ───────────────────────────────────────
        tool(
            "generate_reply",
            ToolCategory::Content,
            Lane::Workflow,
            false,
            false,
            true,
            true,
            WRITE_UP,
            LLM_ERR,
        ),
        tool(
            "generate_tweet",
            ToolCategory::Content,
            Lane::Workflow,
            false,
            false,
            true,
            true,
            WRITE_UP,
            LLM_ERR,
        ),
        tool(
            "generate_thread",
            ToolCategory::Content,
            Lane::Workflow,
            false,
            false,
            true,
            true,
            WRITE_UP,
            LLM_ERR,
        ),
        // ── Config ───────────────────────────────────────────────────
        tool(
            "get_config",
            ToolCategory::Config,
            Lane::Shared,
            false,
            false,
            false,
            false,
            ALL_SIX,
            &[],
        ),
        tool(
            "validate_config",
            ToolCategory::Config,
            Lane::Shared,
            false,
            false,
            false,
            false,
            &[
                Profile::ApiReadonly,
                Profile::Write,
                Profile::Admin,
                Profile::UtilityReadonly,
                Profile::UtilityWrite,
            ],
            &[],
        ),
        // ── Capabilities & Health ────────────────────────────────────
        tool(
            "get_capabilities",
            ToolCategory::Meta,
            Lane::Shared,
            false,
            false,
            false,
            false,
            WRITE_UP_AND_API_RO,
            &[],
        ),
        tool(
            "health_check",
            ToolCategory::Health,
            Lane::Shared,
            false,
            false,
            false,
            false,
            ALL_SIX,
            &[],
        ),
        // ── Mode & Policy ────────────────────────────────────────────
        tool(
            "get_mode",
            ToolCategory::Meta,
            Lane::Shared,
            false,
            false,
            false,
            false,
            WRITE_UP_AND_API_RO,
            &[],
        ),
        tool(
            "get_policy_status",
            ToolCategory::Policy,
            Lane::Workflow,
            false,
            false,
            false,
            true,
            WRITE_UP,
            DB_ERR,
        ),
        tool(
            "compose_tweet",
            ToolCategory::Write,
            Lane::Workflow,
            true,
            true,
            false,
            true,
            WRITE_UP,
            &[
                ErrorCode::XNotConfigured,
                ErrorCode::XApiError,
                ErrorCode::DbError,
                ErrorCode::InvalidInput,
                ErrorCode::TweetTooLong,
                ErrorCode::PolicyDeniedBlocked,
                ErrorCode::PolicyDeniedRateLimited,
                ErrorCode::PolicyDeniedHardRule,
                ErrorCode::PolicyDeniedUserRule,
                ErrorCode::PolicyError,
            ],
        ),
        // ── Discovery Feed & Topics ──────────────────────────────────
        tool(
            "get_discovery_feed",
            ToolCategory::Discovery,
            Lane::Workflow,
            false,
            false,
            false,
            true,
            WRITE_UP,
            DB_ERR,
        ),
        tool(
            "suggest_topics",
            ToolCategory::Content,
            Lane::Workflow,
            false,
            false,
            false,
            true,
            WRITE_UP,
            DB_ERR,
        ),
        // ── Usage ────────────────────────────────────────────────────
        tool(
            "get_x_usage",
            ToolCategory::Analytics,
            Lane::Workflow,
            false,
            false,
            false,
            true,
            WRITE_UP,
            DB_ERR,
        ),
    ]
}
