Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

feat: one-click SearXNG install for agent web search

PurpleDoubleD42874624c6b9
diff --git a/src/components/agents/AgentView.tsx b/src/components/agents/AgentView.tsx
index c2eab2a3..02d568c8 100644
--- a/src/components/agents/AgentView.tsx
+++ b/src/components/agents/AgentView.tsx
@@ -40,6 +40,47 @@ export function AgentView() {
const [goal, setGoal] = useState('')
const [selectedModel, setSelectedModel] = useState<string | null>(null)
const [searxngAvailable, setSearxngAvailable] = useState<boolean | null>(null)
+ const [searxngInstalling, setSearxngInstalling] = useState(false)
+ const [searxngInstallMsg, setSearxngInstallMsg] = useState('')
+
+ const installSearxng = async () => {
+ setSearxngInstalling(true)
+ setSearxngInstallMsg('Starting install...')
+ try {
+ const res = await fetch('/local-api/install-searxng', { method: 'POST' })
+ const data = await res.json()
+ if (data.error) {
+ setSearxngInstallMsg('Error: ' + data.error)
+ setSearxngInstalling(false)
+ return
+ }
+ // Poll for progress
+ const poll = setInterval(async () => {
+ try {
+ const statusRes = await fetch('/local-api/install-searxng')
+ const statusData = await statusRes.json()
+ const lastLog = statusData.logs?.length ? statusData.logs[statusData.logs.length - 1] : ''
+ setSearxngInstallMsg(lastLog || statusData.status)
+ if (statusData.status === 'complete') {
+ clearInterval(poll)
+ setSearxngInstalling(false)
+ setSearxngInstallMsg('SearXNG installed successfully!')
+ // Re-check availability
+ const searchRes = await fetch('/local-api/search-status')
+ const searchData = await searchRes.json()
+ setSearxngAvailable(searchData.searxng)
+ } else if (statusData.status === 'error') {
+ clearInterval(poll)
+ setSearxngInstalling(false)
+ setSearxngInstallMsg('Error: ' + (statusData.error || 'Install failed'))
+ }
+ } catch { /* ignore poll errors */ }
+ }, 2000)
+ } catch (err) {
+ setSearxngInstallMsg('Failed to start install')
+ setSearxngInstalling(false)
+ }
+ }
useEffect(() => {
fetch('/local-api/search-status')
@@ -117,8 +158,22 @@ export function AgentView() {
</GlassCard>
{searxngAvailable === false && (
- <div className="text-[0.7rem] text-gray-500 px-1 -mt-1.5">
- Tip: Install <a href="https://docs.searxng.org/" target="_blank" rel="noopener noreferrer" className="text-blue-400/70 hover:text-blue-400 underline">SearXNG</a> on port 8888 for better web search results
+ <div className="text-[0.7rem] text-gray-500 px-1 -mt-1.5 flex items-center gap-2 flex-wrap">
+ <span>
+ Tip: Install <a href="https://docs.searxng.org/" target="_blank" rel="noopener noreferrer" className="text-blue-400/70 hover:text-blue-400 underline">SearXNG</a> on port 8888 for better web search results
+ </span>
+ <button
+ onClick={installSearxng}
+ disabled={searxngInstalling}
+ className="px-2 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 disabled:opacity-50 disabled:cursor-not-allowed transition-colors text-[0.65rem] font-medium border border-blue-500/30"
+ >
+ {searxngInstalling ? 'Installing...' : 'Install SearXNG'}
+ </button>
+ {searxngInstallMsg && (
+ <span className="text-[0.65rem] text-gray-400 truncate max-w-[300px]" title={searxngInstallMsg}>
+ {searxngInstallMsg}
+ </span>
+ )}
</div>
)}
diff --git a/vite.config.ts b/vite.config.ts
index 47ab38ec..84165102 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -669,6 +669,134 @@ function comfyLauncher(): Plugin {
res.end(JSON.stringify({ searxng: searxngAvailable }))
})
+
+ // --- SearXNG One-Click Install ---
+ const searxngInstallLogs: string[] = []
+ let searxngInstallStatus: "idle" | "installing" | "complete" | "error" = "idle"
+ let searxngInstallError = ""
+
+ server.middlewares.use("/local-api/install-searxng", (req, res) => {
+ if (req.method === "GET") {
+ // Return install status
+ res.writeHead(200, { "Content-Type": "application/json" })
+ res.end(JSON.stringify({
+ status: searxngInstallStatus,
+ error: searxngInstallError,
+ logs: searxngInstallLogs.slice(-30),
+ searxng: searxngAvailable,
+ }))
+ return
+ }
+ if (req.method !== "POST") { res.writeHead(405); res.end(); return }
+
+ if (searxngInstallStatus === "installing") {
+ res.writeHead(200, { "Content-Type": "application/json" })
+ res.end(JSON.stringify({ status: "already_installing" }))
+ return
+ }
+
+ searxngInstallStatus = "installing"
+ searxngInstallError = ""
+ searxngInstallLogs.length = 0
+
+ const home = process.env.HOME || ""
+ const searxngDir = join(home, "searxng")
+
+ const log = (msg: string) => {
+ searxngInstallLogs.push(msg)
+ if (searxngInstallLogs.length > 200) searxngInstallLogs.shift()
+ console.log("[SearXNG Install] " + msg)
+ }
+
+ res.writeHead(200, { "Content-Type": "application/json" })
+ res.end(JSON.stringify({ status: "started", path: searxngDir }))
+
+ // Run installation in background
+ ;(async () => {
+ try {
+ // Create directory
+ if (!existsSync(searxngDir)) {
+ mkdirSync(searxngDir, { recursive: true })
+ log("Created directory: " + searxngDir)
+ }
+
+ // Try Docker first
+ let hasDocker = false
+ try {
+ execSync("docker --version", { stdio: "ignore" })
+ hasDocker = true
+ } catch { /* no docker */ }
+
+ if (hasDocker) {
+ log("Docker found. Pulling SearXNG image...")
+ const pull = spawn("docker", ["pull", "searxng/searxng"], { shell: true, stdio: ["ignore", "pipe", "pipe"] })
+ pull.stdout?.on("data", (d) => log(d.toString().trim()))
+ pull.stderr?.on("data", (d) => log(d.toString().trim()))
+ await new Promise<void>((resolve, reject) => {
+ pull.on("exit", (code) => code === 0 ? resolve() : reject(new Error("docker pull failed (exit " + code + ")")))
+ })
+ log("Pull complete. Starting SearXNG container...")
+
+ // Remove existing container if any
+ try { execSync("docker rm -f searxng", { stdio: "ignore" }) } catch { /* no existing container */ }
+
+ const run = spawn("docker", [
+ "run", "-d", "--name", "searxng",
+ "-p", "8888:8080",
+ "-e", "SEARXNG_BASE_URL=http://localhost:8888",
+ "--restart", "unless-stopped",
+ "searxng/searxng",
+ ], { shell: true, stdio: ["ignore", "pipe", "pipe"] })
+ run.stdout?.on("data", (d) => log(d.toString().trim()))
+ run.stderr?.on("data", (d) => log(d.toString().trim()))
+ await new Promise<void>((resolve, reject) => {
+ run.on("exit", (code) => code === 0 ? resolve() : reject(new Error("docker run failed (exit " + code + ")")))
+ })
+ log("SearXNG container started on port 8888.")
+
+ // Wait a moment then re-check availability
+ await new Promise((r) => setTimeout(r, 3000))
+ checkSearXNG()
+ log("SearXNG installed and running via Docker!")
+ searxngInstallStatus = "complete"
+ } else {
+ // Fallback: pip install
+ log("Docker not found. Trying pip install as fallback...")
+ const pipBin = (() => {
+ try { execSync("pip3 --version", { stdio: "ignore" }); return "pip3" } catch { /* */ }
+ try { execSync("pip --version", { stdio: "ignore" }); return "pip" } catch { /* */ }
+ return null
+ })()
+
+ if (!pipBin) {
+ throw new Error("Neither Docker nor pip found. Install Docker (recommended) or Python pip to continue.")
+ }
+
+ log("Installing SearXNG via " + pipBin + "...")
+ const pip = spawn(pipBin, ["install", "searxng"], { shell: true, stdio: ["ignore", "pipe", "pipe"] })
+ pip.stdout?.on("data", (d) => {
+ const lines = d.toString().split("\n").filter((l: string) => l.trim())
+ lines.forEach((l: string) => log(l.trim()))
+ })
+ pip.stderr?.on("data", (d) => {
+ const lines = d.toString().split("\n").filter((l: string) => l.trim())
+ lines.forEach((l: string) => log(l.trim()))
+ })
+ await new Promise<void>((resolve, reject) => {
+ pip.on("exit", (code) => code === 0 ? resolve() : reject(new Error(pipBin + " install searxng failed (exit " + code + ")")))
+ })
+ log("SearXNG pip package installed. Note: You may need to configure and start it manually with: searxng-run")
+ searxngInstallStatus = "complete"
+ }
+ } catch (err) {
+ const msg = err instanceof Error ? err.message : String(err)
+ log("ERROR: " + msg)
+ searxngInstallError = msg
+ searxngInstallStatus = "error"
+ }
+ })()
+ })
+
// API: Multi-tier web search (SearXNG > DDG Instant Answer API > Wikipedia)
server.middlewares.use('/local-api/web-search', (req, res) => {
if (req.method !== 'POST') { res.writeHead(405); res.end(); return }