# Luzia Cockpit - Interactive Claude Agent Container
# Provides tmux-based session management for human-in-the-loop workflows

FROM debian:bookworm-slim

# Avoid interactive prompts
ENV DEBIAN_FRONTEND=noninteractive

# Install base tools
RUN apt-get update && apt-get install -y --no-install-recommends \
    tmux \
    curl \
    git \
    jq \
    ca-certificates \
    gnupg \
    procps \
    less \
    vim-tiny \
    && rm -rf /var/lib/apt/lists/*

# Install Node.js 20 LTS
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
    && apt-get install -y nodejs \
    && rm -rf /var/lib/apt/lists/*

# Install Claude CLI globally
RUN npm install -g @anthropic-ai/claude-code

# Create workspace directory
RUN mkdir -p /workspace /root/.claude

# Tmux configuration for better session handling
RUN cat > /root/.tmux.conf << 'EOF'
# Increase scrollback buffer
set-option -g history-limit 50000

# Don't rename windows automatically
set-option -g allow-rename off

# Start windows and panes at 1, not 0
set -g base-index 1
setw -g pane-base-index 1

# Enable mouse (for human attach)
set -g mouse on

# Status bar showing session info
set -g status-left '[#S] '
set -g status-right '%H:%M '

# Keep tmux server running even if no clients
set -g exit-empty off
EOF

# Entry script that starts tmux and keeps container alive
RUN cat > /entrypoint.sh << 'EOF'
#!/bin/bash
set -e

# Start tmux server with agent session
tmux new-session -d -s agent -n main

# Keep container alive by waiting on tmux
exec tmux wait-for exit-signal
EOF
RUN chmod +x /entrypoint.sh

WORKDIR /workspace

# Default command starts tmux server
CMD ["/entrypoint.sh"]
