"""voice_command.launch.py — Launch voice_command_node (Issue #137)."""

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


def generate_launch_description() -> LaunchDescription:
    pkg = FindPackageShare("saltybot_social")

    params_file = PathJoinSubstitution([pkg, "config", "voice_command_params.yaml"])

    return LaunchDescription([
        DeclareLaunchArgument(
            "params_file",
            default_value=params_file,
            description="Path to voice_command_node parameter YAML file",
        ),
        DeclareLaunchArgument(
            "min_confidence",
            default_value="0.70",
            description="Minimum NLU confidence for command execution",
        ),
        DeclareLaunchArgument(
            "confirmation_timeout_s",
            default_value="10.0",
            description="Seconds to await confirmation for dangerous commands",
        ),
        Node(
            package="saltybot_social",
            executable="voice_command_node",
            name="voice_command_node",
            output="screen",
            parameters=[
                LaunchConfiguration("params_file"),
                {
                    "min_confidence": LaunchConfiguration("min_confidence"),
                    "confirmation_timeout_s": LaunchConfiguration("confirmation_timeout_s"),
                },
            ],
        ),
    ])
