"""topic_memory.launch.py — Launch conversation topic memory node (Issue #299).

Usage:
  ros2 launch saltybot_social topic_memory.launch.py
  ros2 launch saltybot_social topic_memory.launch.py max_topics_per_person:=50
"""

import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node


def generate_launch_description():
    pkg = get_package_share_directory("saltybot_social")
    cfg = os.path.join(pkg, "config", "topic_memory_params.yaml")

    return LaunchDescription([
        DeclareLaunchArgument("max_topics_per_person", default_value="30",
                              description="Rolling topic window per person"),
        DeclareLaunchArgument("max_keywords_per_msg",  default_value="10",
                              description="Max keywords extracted per utterance"),
        DeclareLaunchArgument("prune_after_s",         default_value="1800.0",
                              description="Forget persons idle this long (0=off)"),

        Node(
            package="saltybot_social",
            executable="topic_memory_node",
            name="topic_memory_node",
            output="screen",
            parameters=[
                cfg,
                {
                    "max_topics_per_person": LaunchConfiguration("max_topics_per_person"),
                    "max_keywords_per_msg":  LaunchConfiguration("max_keywords_per_msg"),
                    "prune_after_s":         LaunchConfiguration("prune_after_s"),
                },
            ],
        ),
    ])
