cat > ~/Library/LaunchAgents/com.user.openwebui.plist <<'PLIST'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict>
<key>Label</key><string>com.user.openwebui</string>
<key>ProgramArguments</key><array>
<string>/Users/me/.local/share/uv/tools/open-webui/bin/open-webui</string>
<string>serve</string>
<string>--port</string>
<string>8081</string>
</array>
<key>WorkingDirectory</key><string>/Users/me</string>
<key>EnvironmentVariables</key><dict>
<key>HOME</key><string>/Users/me</string>
<key>WEBUI_SECRET_KEY_FILE</key><string>/Users/me/.webui_secret_key</string>
</dict>
<key>RunAtLoad</key><true/>
<key>KeepAlive</key><true/>
<key>StandardOutPath</key><string>/Users/me/Library/Logs/openwebui.log</string>
<key>StandardErrorPath</key><string>/Users/me/Library/Logs/openwebui.err</string>
</dict></plist>
PLIST
openssl rand -base64 16 > ~/.webui_secret_key && chmod 600 ~/.webui_secret_key
launchctl load ~/Library/LaunchAgents/com.user.openwebui.plist
launchctl start com.user.openwebui