<#
.SYNOPSIS
  AgentsMeeting �?状态检�?#>
Write-Host "=== AgentsMeeting Status ===" -ForegroundColor Cyan

# Bot
$bot = Get-CimInstance Win32_Process -Filter "Name='python.exe'" | Where-Object { $_.CommandLine -match "xmpp_bot" -and $_.CommandLine -notmatch "watchdog|health" }
if ($bot) { Write-Host "xmpp_bot:     RUNNING (PID $($bot.ProcessId))" -ForegroundColor Green }
else { Write-Host "xmpp_bot:     STOPPED" -ForegroundColor Red }

# HTTP bridge test
try { $r = Invoke-RestMethod "http://127.0.0.1:5802/messages" -TimeoutSec 3 -ErrorAction Stop; Write-Host "http_bridge:  OK ($($r.count) msgs)" -ForegroundColor Green }
catch { Write-Host "http_bridge:  ERROR" -ForegroundColor Yellow }

# WeChat
$agent = Get-CimInstance Win32_Process -Filter "Name='python.exe'" | Where-Object { $_.CommandLine -match "wechat_agent" }
if ($agent) { Write-Host "wechat_agent: RUNNING (PID $($agent.ProcessId))" -ForegroundColor Green }
else { Write-Host "wechat_agent: STOPPED" -ForegroundColor Yellow }

# Watchdog
$wd = Get-CimInstance Win32_Process -Filter "Name='python.exe'" | Where-Object { $_.CommandLine -match "watchdog" }
if ($wd) { Write-Host "watchdog:     RUNNING (PID $($wd.ProcessId))" -ForegroundColor Green }
else { Write-Host "watchdog:     STOPPED" -ForegroundColor Yellow }

# Proxy
$proxy = netstat -ano 2>$null | Select-String ":8787"
if ($proxy) { Write-Host "api_proxy:    RUNNING (:8787)" -ForegroundColor Green }
else { Write-Host "api_proxy:    stopped" -ForegroundColor Yellow }

# Health last run
$log = "D:\F\NewI\opencode\daily-workspace\projects\AgentsMeeting\gateway\logs\health_check.log"
if (Test-Path $log) {
    $last = Get-Content $log -Tail 3
    Write-Host "health_check: LAST 3 LINES:" -ForegroundColor Gray
    $last | ForEach-Object { Write-Host "  $_" -ForegroundColor Gray }
}

# Mohe inbox
$inbox = "D:\F\NewI\opencode\daily-workspace\projects\AgentsMeeting\gateway\logs\mohe_inbox.log"
if (Test-Path $inbox) {
    $moheLines = Get-Content $inbox -Tail 3
    Write-Host "mohe_watcher: LAST 3 LINES:" -ForegroundColor Gray
    $moheLines | ForEach-Object { Write-Host "  $_" -ForegroundColor Cyan }
}

# Dashboard
try { $d = Invoke-RestMethod "http://127.0.0.1:5803/api/health" -TimeoutSec 3 -ErrorAction Stop; Write-Host "dashboard:    OK (:5803)" -ForegroundColor Green }
catch { Write-Host "dashboard:    stopped" -ForegroundColor Yellow }
