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): add pipefail, output truncation, require origin header
yh c523be7c9f873
diff --git a/vibe/api.py b/vibe/api.pyindex 741ec3094..8c1a954bb 100644--- a/vibe/api.py+++ b/vibe/api.py@@ -718,12 +718,21 @@ def install_agent(name: str) -> dict:system = platform.system().lower()+ # Max output size to prevent UI slowdown (last N characters)+ MAX_OUTPUT_CHARS = 8192+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+ def _truncate_output(output: str) -> str:+ """Truncate output to last MAX_OUTPUT_CHARS characters."""+ if len(output) <= MAX_OUTPUT_CHARS:+ return output+ return "...(truncated)\n" + output[-MAX_OUTPUT_CHARS:]+if name == "opencode":# OpenCode: use curl installer (not supported on Windows)if system == "windows":@@ -737,22 +746,23 @@ def install_agent(name: str) -> dict:error = _check_binary(binary)if error:return {"ok": False, "message": error, "output": None}- cmd = ["bash", "-c", "curl -fsSL https://opencode.ai/install | bash"]+ # Use pipefail to ensure curl failures are detected+ cmd = ["bash", "-c", "set -euo pipefail; curl -fsSL https://opencode.ai/install | bash"]elif name == "claude":# Claude Code: platform-specific installerif system == "windows":- # Windows: use PowerShell+ # Windows: use PowerShell with error handlingerror = _check_binary("powershell")if error:return {"ok": False, "message": error, "output": None}- cmd = ["powershell", "-Command", "irm https://claude.ai/install.ps1 | iex"]+ cmd = ["powershell", "-NoProfile", "-Command", "irm https://claude.ai/install.ps1 -ErrorAction Stop | iex"]else:- # macOS/Linux: use bash+ # macOS/Linux: use bash with pipefailfor 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"]+ cmd = ["bash", "-c", "set -euo pipefail; curl -fsSL https://claude.ai/install.sh | bash"]elif name == "codex":# Codex: prefer npm, fallback to brew on macOSnpm_path = shutil.which("npm")@@ -788,19 +798,20 @@ def install_agent(name: str) -> dict:env={**os.environ, "PATH": os.environ.get("PATH", "")},)output = result.stdout + ("\n" + result.stderr if result.stderr else "")+ output = _truncate_output(output.strip())if result.returncode == 0:logger.info("Agent %s installed successfully", name)return {"ok": True,"message": f"{name} installed successfully",- "output": output.strip(),+ "output": output,}else:logger.warning("Agent %s installation failed: %s", name, output)return {"ok": False,"message": f"Installation failed (exit code {result.returncode})",- "output": output.strip(),+ "output": output,}except subprocess.TimeoutExpired:logger.error("Agent %s installation timed out", name)diff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex 6db07bfb9..e6983a6ea 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -369,20 +369,24 @@ def agent_install(name):Security: Only allow requests from localhost to prevent CSRF/RCE attacks."""+ from urllib.parse import urlparse+# Security: Only allow local requestsremote_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)+ # Security: Require Origin or Referer header for CSRF protectionorigin = 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+ referer = request.headers.get("Referer")+ if not origin and not referer:+ return jsonify({"ok": False, "message": "Forbidden: missing origin header"}), 403++ # Validate Origin/Referer is from localhost+ check_header = origin or referer+ parsed = urlparse(check_header)+ if parsed.hostname not in {"localhost", "127.0.0.1", "::1"}:+ return jsonify({"ok": False, "message": "Forbidden: invalid origin"}), 403# Security: Allowlist validationallowed_agents = {"opencode", "claude", "codex"}