-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlaunch_muninn.ps1
More file actions
163 lines (149 loc) · 6.4 KB
/
Copy pathlaunch_muninn.ps1
File metadata and controls
163 lines (149 loc) · 6.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<#
.SYNOPSIS
Muninn Memory Server — Windows Launcher
.DESCRIPTION
Starts the Muninn server and optionally the system tray application.
Detects Python automatically from PATH, conda, or common install locations.
.PARAMETER Mode
Launch mode: "server" (default), "tray", or "both"
.PARAMETER NoBrowser
Skip opening the dashboard in the browser
.EXAMPLE
.\launch_muninn.ps1
.\launch_muninn.ps1 -Mode tray
.\launch_muninn.ps1 -Mode both
#>
param(
[ValidateSet("server", "tray", "both")]
[string]$Mode = "server",
[switch]$NoBrowser
)
$ErrorActionPreference = "Stop"
$ProjectRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
# --- Python Discovery ---
function Find-Python {
# 1. Check if python is on PATH
$pythonPath = Get-Command python -ErrorAction SilentlyContinue
if ($pythonPath) {
$version = & $pythonPath.Source --version 2>&1
if ($version -match "Python 3\.1[0-9]") {
return $pythonPath.Source
}
}
# 2. Check conda environments
$condaPaths = @(
"$env:USERPROFILE\miniconda3\python.exe",
"$env:USERPROFILE\anaconda3\python.exe",
"$env:LOCALAPPDATA\miniconda3\python.exe",
"C:\ProgramData\miniconda3\python.exe"
)
foreach ($p in $condaPaths) {
if (Test-Path $p) {
$version = & $p --version 2>&1
if ($version -match "Python 3\.1[0-9]") {
return $p
}
}
}
# 3. Check common install locations
$commonPaths = @(
"$env:LOCALAPPDATA\Programs\Python\Python313\python.exe",
"$env:LOCALAPPDATA\Programs\Python\Python312\python.exe",
"$env:LOCALAPPDATA\Programs\Python\Python311\python.exe",
"$env:LOCALAPPDATA\Programs\Python\Python310\python.exe",
"C:\Python313\python.exe",
"C:\Python312\python.exe",
"C:\Python311\python.exe"
)
foreach ($p in $commonPaths) {
if (Test-Path $p) { return $p }
}
return $null
}
# --- Ollama Check ---
function Test-Ollama {
try {
$response = Invoke-WebRequest -Uri "http://localhost:11434" -TimeoutSec 2 -ErrorAction SilentlyContinue
return $response.StatusCode -eq 200
} catch {
return $false
}
}
function Start-Ollama {
Write-Host "[Muninn] Ollama not detected. Attempting to start..." -ForegroundColor Yellow
$ollamaPath = Get-Command ollama -ErrorAction SilentlyContinue
if ($ollamaPath) {
Start-Process -FilePath $ollamaPath.Source -ArgumentList "serve" -WindowStyle Hidden
Start-Sleep -Seconds 3
if (Test-Ollama) {
Write-Host "[Muninn] Ollama started successfully." -ForegroundColor Green
return $true
}
}
Write-Host "[Muninn] WARNING: Ollama not available. Server will start in degraded mode." -ForegroundColor Red
Write-Host "[Muninn] Install Ollama from https://ollama.com and run: ollama pull nomic-embed-text" -ForegroundColor Red
return $false
}
# --- Main ---
Write-Host ""
Write-Host " ███╗ ███╗██╗ ██╗███╗ ██╗██╗███╗ ██╗███╗ ██╗" -ForegroundColor Magenta
Write-Host " ████╗ ████║██║ ██║████╗ ██║██║████╗ ██║████╗ ██║" -ForegroundColor Magenta
Write-Host " ██╔████╔██║██║ ██║██╔██╗ ██║██║██╔██╗ ██║██╔██╗ ██║" -ForegroundColor Magenta
Write-Host " ██║╚██╔╝██║██║ ██║██║╚██╗██║██║██║╚██╗██║██║╚██╗██║" -ForegroundColor Magenta
Write-Host " ██║ ╚═╝ ██║╚██████╔╝██║ ╚████║██║██║ ╚████║██║ ╚████║" -ForegroundColor Magenta
Write-Host " ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═══╝" -ForegroundColor Magenta
Write-Host " The Persistent Memory MCP — v3.0.0" -ForegroundColor DarkGray
Write-Host ""
# Find Python
$python = Find-Python
if (-not $python) {
Write-Host "[Muninn] ERROR: Python 3.10+ not found." -ForegroundColor Red
Write-Host "[Muninn] Install from https://python.org or conda." -ForegroundColor Red
exit 1
}
Write-Host "[Muninn] Python: $python" -ForegroundColor Cyan
# Check Ollama
if (-not (Test-Ollama)) {
Start-Ollama | Out-Null
}
# Set working directory
Set-Location $ProjectRoot
# Determine port
$port = if ($env:MUNINN_PORT) { $env:MUNINN_PORT } else { "42069" }
switch ($Mode) {
"server" {
Write-Host "[Muninn] Starting server on http://localhost:$port ..." -ForegroundColor Green
if (-not $NoBrowser) {
Start-Sleep -Seconds 3
Start-Process "http://localhost:$port"
}
& $python server.py
}
"tray" {
Write-Host "[Muninn] Starting system tray application..." -ForegroundColor Green
# Use pythonw for windowless execution
$pythonw = $python -replace "python\.exe$", "pythonw.exe"
if (Test-Path $pythonw) {
Start-Process -FilePath $pythonw -ArgumentList "tray_app.py" -WorkingDirectory $ProjectRoot -WindowStyle Hidden
} else {
Start-Process -FilePath $python -ArgumentList "tray_app.py" -WorkingDirectory $ProjectRoot -WindowStyle Hidden
}
Write-Host "[Muninn] Tray app launched. Look for the Muninn icon in your system tray." -ForegroundColor Cyan
}
"both" {
Write-Host "[Muninn] Starting tray application (manages server lifecycle)..." -ForegroundColor Green
# Tray app auto-starts the server
$pythonw = $python -replace "python\.exe$", "pythonw.exe"
if (Test-Path $pythonw) {
Start-Process -FilePath $pythonw -ArgumentList "tray_app.py" -WorkingDirectory $ProjectRoot -WindowStyle Hidden
} else {
Start-Process -FilePath $python -ArgumentList "tray_app.py" -WorkingDirectory $ProjectRoot -WindowStyle Hidden
}
Write-Host "[Muninn] Tray app launched — server will start automatically." -ForegroundColor Cyan
Write-Host "[Muninn] Dashboard: http://localhost:$port" -ForegroundColor Cyan
if (-not $NoBrowser) {
Start-Sleep -Seconds 5
Start-Process "http://localhost:$port"
}
}
}