Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(setup): address review feedback for agent install
yh c54614123ba40
diff --git a/ui/src/components/steps/AgentDetection.tsx b/ui/src/components/steps/AgentDetection.tsxindex 2d8f8d75c..04c001869 100644--- a/ui/src/components/steps/AgentDetection.tsx+++ b/ui/src/components/steps/AgentDetection.tsx@@ -1,5 +1,5 @@import React, { useEffect, useState } from 'react';-import { Check, X, RefreshCw, Search, Settings, Download } from 'lucide-react';+import { Check, X, RefreshCw, Search, Settings, Download, ChevronDown, ChevronUp } from 'lucide-react';import { useTranslation } from 'react-i18next';import clsx from 'clsx';import { useApi } from '../../context/ApiContext';@@ -32,10 +32,15 @@ export const AgentDetection: React.FC<AgentDetectionProps> = ({ data, onNext, on);const [permissionState, setPermissionState] = useState<PermissionState>('idle');const [permissionMessage, setPermissionMessage] = useState<string>('');- const [installing, setInstalling] = useState<string | null>(null);- const [installMessage, setInstallMessage] = useState<Record<string, { ok: boolean; message: string }>>({});+ // Per-agent install state to prevent race conditions+ const [installingAgents, setInstallingAgents] = useState<Record<string, boolean>>({});+ const [installResults, setInstallResults] = useState<Record<string, { ok: boolean; message: string; output?: string | null }>>({});+ const [expandedOutputs, setExpandedOutputs] = useState<Record<string, boolean>>({});const isMissing = (agent: AgentState) => agent.status === 'missing';+ // Check if any agent is currently installing+ const isAnyInstalling = Object.values(installingAgents).some(Boolean);+useEffect(() => {if (!data.agents) {detectAll();@@ -90,28 +95,37 @@ export const AgentDetection: React.FC<AgentDetectionProps> = ({ data, onNext, on};const installAgent = async (name: string) => {- setInstalling(name);- setInstallMessage((prev) => ({ ...prev, [name]: { ok: false, message: '' } }));+ // Prevent multiple concurrent installations+ if (isAnyInstalling) return;++ setInstallingAgents((prev) => ({ ...prev, [name]: true }));+ setInstallResults((prev) => ({ ...prev, [name]: { ok: false, message: '', output: null } }));+ setExpandedOutputs((prev) => ({ ...prev, [name]: false }));+try {const result = await api.installAgent(name);- setInstallMessage((prev) => ({+ setInstallResults((prev) => ({...prev,- [name]: { ok: result.ok, message: result.message },+ [name]: { ok: result.ok, message: result.message, output: result.output },}));if (result.ok) {// Re-detect after successful installationawait detect(name);}} catch (e) {- setInstallMessage((prev) => ({+ setInstallResults((prev) => ({...prev,- [name]: { ok: false, message: String(e) },+ [name]: { ok: false, message: String(e), output: null },}));} finally {- setInstalling(null);+ setInstallingAgents((prev) => ({ ...prev, [name]: false }));}};+ const toggleOutput = (name: string) => {+ setExpandedOutputs((prev) => ({ ...prev, [name]: !prev[name] }));+ };+const canContinue = Object.values(agents).some((agent) => agent.enabled);return (@@ -200,26 +214,45 @@ export const AgentDetection: React.FC<AgentDetectionProps> = ({ data, onNext, on{isMissing(agent) && (<div className="mt-2 p-3 bg-blue-50 border border-blue-200 rounded-lg"><p className="text-sm text-blue-800 mb-2">{t('agentDetection.installHint')}</p>- <div className="flex items-center gap-3 flex-wrap">- <button- onClick={() => installAgent(name)}- disabled={installing === name}- className="flex items-center gap-2 px-3 py-1.5 bg-blue-500 hover:bg-blue-600 text-white rounded text-sm font-medium transition-colors disabled:opacity-50"- >- {installing === name ? (- <RefreshCw size={14} className="animate-spin" />- ) : (- <Download size={14} />+ <div className="flex flex-col gap-2">+ <div className="flex items-center gap-3 flex-wrap">+ <button+ onClick={() => installAgent(name)}+ disabled={isAnyInstalling}+ className="flex items-center gap-2 px-3 py-1.5 bg-blue-500 hover:bg-blue-600 text-white rounded text-sm font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed"+ >+ {installingAgents[name] ? (+ <RefreshCw size={14} className="animate-spin" />+ ) : (+ <Download size={14} />+ )}+ {installingAgents[name] ? t('agentDetection.installing') : t('agentDetection.installAgent')}+ </button>+ {installResults[name]?.message && (+ <span className={clsx(+ "text-sm",+ installResults[name].ok ? "text-green-600" : "text-red-600"+ )}>+ {installResults[name].message}+ </span>)}- {installing === name ? t('agentDetection.installing') : t('agentDetection.installAgent')}- </button>- {installMessage[name]?.message && (- <span className={clsx(- "text-sm",- installMessage[name].ok ? "text-green-600" : "text-red-600"- )}>- {installMessage[name].message}- </span>+ </div>+ {/* Expandable output section */}+ {installResults[name]?.output && (+ <div className="mt-1">+ <button+ onClick={() => toggleOutput(name)}+ className="flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800"+ >+ {expandedOutputs[name] ? <ChevronUp size={12} /> : <ChevronDown size={12} />}+ {t('agentDetection.showOutput')}+ </button>+ {expandedOutputs[name] && (+ <pre className="mt-2 p-2 bg-gray-100 border border-gray-200 rounded text-xs text-gray-700 overflow-x-auto max-h-40 overflow-y-auto whitespace-pre-wrap">+ {installResults[name].output}+ </pre>+ )}+ </div>)}</div></div>diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex bb9fed43b..bb2ecd7df 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -121,7 +121,8 @@"setupPermission": "Setup Permission","installHint": "Agent not found. Click to install automatically.","installAgent": "Install",- "installing": "Installing..."+ "installing": "Installing...",+ "showOutput": "Show details"},"channelList": {"title": "Channel Settings",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex 937092e2d..ad167f387 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -121,7 +121,8 @@"setupPermission": "一键设置权限","installHint": "未找到 Agent,点击自动安装。","installAgent": "一键安装",- "installing": "安装中..."+ "installing": "安装中...",+ "showOutput": "显示详情"},"channelList": {"title": "频道设置",diff --git a/vibe/api.py b/vibe/api.pyindex 2955b750a..741ec3094 100644--- a/vibe/api.py+++ b/vibe/api.py@@ -715,20 +715,43 @@ def install_agent(name: str) -> dict:{"ok": bool, "message": str, "output": str | None}"""import platform- import syssystem = platform.system().lower()+ def _check_binary(binary: str) -> str | None:+ """Check if a binary exists in PATH. Returns error message if not found."""+ if shutil.which(binary) is None:+ return f"{binary} is required but not found. Please install it first."+ return None+if name == "opencode":- # OpenCode: use curl installer+ # OpenCode: use curl installer (not supported on Windows)+ if system == "windows":+ return {+ "ok": False,+ "message": "OpenCode installer is not supported on Windows. Please use the manual installation method.",+ "output": None,+ }+ # Check prerequisites+ for binary in ["curl", "bash"]:+ error = _check_binary(binary)+ if error:+ return {"ok": False, "message": error, "output": None}cmd = ["bash", "-c", "curl -fsSL https://opencode.ai/install | bash"]elif name == "claude":# Claude Code: platform-specific installerif system == "windows":# Windows: use PowerShell+ error = _check_binary("powershell")+ if error:+ return {"ok": False, "message": error, "output": None}cmd = ["powershell", "-Command", "irm https://claude.ai/install.ps1 | iex"]else:# macOS/Linux: use bash+ for binary in ["curl", "bash"]:+ error = _check_binary(binary)+ if error:+ return {"ok": False, "message": error, "output": None}cmd = ["bash", "-c", "curl -fsSL https://claude.ai/install.sh | bash"]elif name == "codex":# Codex: prefer npm, fallback to brew on macOS@@ -756,7 +779,7 @@ def install_agent(name: str) -> dict:return {"ok": False, "message": f"Unknown agent: {name}", "output": None}try:- logger.info(f"Installing agent {name} with command: {cmd}")+ logger.info("Installing agent %s with command: %s", name, cmd)result = subprocess.run(cmd,capture_output=True,@@ -764,26 +787,26 @@ def install_agent(name: str) -> dict:timeout=300, # 5 minute timeout for installationenv={**os.environ, "PATH": os.environ.get("PATH", "")},)- output = result.stdout + "\n" + result.stderr if result.stderr else result.stdout+ output = result.stdout + ("\n" + result.stderr if result.stderr else "")if result.returncode == 0:- logger.info(f"Agent {name} installed successfully")+ logger.info("Agent %s installed successfully", name)return {"ok": True,"message": f"{name} installed successfully","output": output.strip(),}else:- logger.warning(f"Agent {name} installation failed: {output}")+ logger.warning("Agent %s installation failed: %s", name, output)return {"ok": False,"message": f"Installation failed (exit code {result.returncode})","output": output.strip(),}except subprocess.TimeoutExpired:- logger.error(f"Agent {name} installation timed out")+ logger.error("Agent %s installation timed out", name)return {"ok": False, "message": "Installation timed out", "output": None}except Exception as e:- logger.error(f"Agent {name} installation error: {e}")+ logger.error("Agent %s installation error: %s", name, e)return {"ok": False, "message": str(e), "output": None}diff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex ed216b535..6db07bfb9 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -365,7 +365,30 @@ def codex_models():@app.route("/agent/<name>/install", methods=["POST"])def agent_install(name):- """Install an agent CLI tool (opencode, claude, codex)."""+ """Install an agent CLI tool (opencode, claude, codex).++ Security: Only allow requests from localhost to prevent CSRF/RCE attacks.+ """+ # Security: Only allow local requests+ remote_addr = request.remote_addr or ""+ if remote_addr not in {"127.0.0.1", "::1"}:+ return jsonify({"ok": False, "message": "Forbidden: local access only"}), 403++ # Security: Validate Origin header if present (CSRF protection)+ origin = request.headers.get("Origin")+ if origin:+ # Allow localhost origins only+ from urllib.parse import urlparse++ parsed = urlparse(origin)+ if parsed.hostname not in {"localhost", "127.0.0.1", "::1"}:+ return jsonify({"ok": False, "message": "Forbidden: invalid origin"}), 403++ # Security: Allowlist validation+ allowed_agents = {"opencode", "claude", "codex"}+ if name not in allowed_agents:+ return jsonify({"ok": False, "message": f"Unknown agent: {name}"}), 400+from vibe import apiresult = api.install_agent(name)