mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-01 01:51:44 +00:00
feat: add messaging gateway startup functionality
- Introduced a new function to check for configured messaging platform tokens and prompt the user to start the gateway. - Updated the installation scripts to automatically start the gateway if messaging tokens are detected, enhancing user experience. - Expanded the README to include instructions for starting the gateway, ensuring users are informed about the necessary steps for message handling.
This commit is contained in:
parent
1c6846c4c2
commit
59cb0cecb2
3 changed files with 115 additions and 0 deletions
|
|
@ -544,6 +544,49 @@ function Invoke-SetupWizard {
|
|||
Pop-Location
|
||||
}
|
||||
|
||||
function Start-GatewayIfConfigured {
|
||||
$envPath = "$HermesHome\.env"
|
||||
if (-not (Test-Path $envPath)) { return }
|
||||
|
||||
$hasMessaging = $false
|
||||
$content = Get-Content $envPath -ErrorAction SilentlyContinue
|
||||
foreach ($var in @("TELEGRAM_BOT_TOKEN", "DISCORD_BOT_TOKEN", "SLACK_BOT_TOKEN", "SLACK_APP_TOKEN", "WHATSAPP_ENABLED")) {
|
||||
$match = $content | Where-Object { $_ -match "^${var}=.+" -and $_ -notmatch "your-token-here" }
|
||||
if ($match) { $hasMessaging = $true; break }
|
||||
}
|
||||
|
||||
if (-not $hasMessaging) { return }
|
||||
|
||||
Write-Host ""
|
||||
Write-Info "Messaging platform token detected!"
|
||||
Write-Info "The gateway needs to be running for Hermes to send/receive messages."
|
||||
Write-Host ""
|
||||
$response = Read-Host "Would you like to start the gateway now? [Y/n]"
|
||||
|
||||
if ($response -eq "" -or $response -match "^[Yy]") {
|
||||
$hermesCmd = "$InstallDir\venv\Scripts\hermes.exe"
|
||||
if (-not (Test-Path $hermesCmd)) {
|
||||
$hermesCmd = "hermes"
|
||||
}
|
||||
|
||||
Write-Info "Starting gateway in background..."
|
||||
try {
|
||||
$logFile = "$HermesHome\logs\gateway.log"
|
||||
Start-Process -FilePath $hermesCmd -ArgumentList "gateway" `
|
||||
-RedirectStandardOutput $logFile `
|
||||
-RedirectStandardError "$HermesHome\logs\gateway-error.log" `
|
||||
-WindowStyle Hidden
|
||||
Write-Success "Gateway started! Your bot is now online."
|
||||
Write-Info "Logs: $logFile"
|
||||
Write-Info "To stop: close the gateway process from Task Manager"
|
||||
} catch {
|
||||
Write-Warn "Failed to start gateway. Run manually: hermes gateway"
|
||||
}
|
||||
} else {
|
||||
Write-Info "Skipped. Start the gateway later with: hermes gateway"
|
||||
}
|
||||
}
|
||||
|
||||
function Write-Completion {
|
||||
Write-Host ""
|
||||
Write-Host "┌─────────────────────────────────────────────────────────┐" -ForegroundColor Green
|
||||
|
|
@ -622,6 +665,7 @@ function Main {
|
|||
Set-PathVariable
|
||||
Copy-ConfigTemplates
|
||||
Invoke-SetupWizard
|
||||
Start-GatewayIfConfigured
|
||||
|
||||
Write-Completion
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue