# Copyright (c) 2026 K2Aley. GAR-BOT. All rights reserved.
param(
    [string]$HostName = "192.168.0.226",
    [string]$UserName = "gar-bot"
)

$ErrorActionPreference = "Stop"

$ScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$AgentRoot = Resolve-Path (Join-Path $ScriptRoot "..")
$Remote = "$UserName@$HostName"

Write-Host "Deploying GAR-BOT RP5 AI agent to $Remote"
Write-Host "You may be prompted for the RP5 password."

ssh -o StrictHostKeyChecking=accept-new $Remote "mkdir -p ~/rp5_ai_agent"
scp -r "$AgentRoot\*" "$Remote`:~/rp5_ai_agent/"

$remoteCommand = @"
cd ~/rp5_ai_agent &&
chmod +x scripts/install_on_rp5.sh &&
GAR_BOT_USER='$UserName' ./scripts/install_on_rp5.sh &&
sudo systemctl start gar-bot-agent &&
systemctl --no-pager status gar-bot-agent
"@

ssh $Remote $remoteCommand

Write-Host "GAR-BOT RP5 AI agent deployment complete."
