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
Merge remote-tracking branch 'origin/master' into fix/backend-cli-config-upgrades
cyh9cdd3ed542fc
diff --cc tests/test_ui_api.pyindex 2467cffb3,6946d5c77..08dc88fb3--- a/tests/test_ui_api.py+++ b/tests/test_ui_api.py@@@ -12,6 -12,6 +12,18 @@@ from vibe import apfrom vibe.opencode_config import parse_jsonc_object++class _PopenFromRun:++ def __init__(self, cmd, *args, **kwargs):++ result = api.subprocess.run(cmd, **kwargs)++ self.args = cmd++ self.returncode = result.returncode++ self._stdout = result.stdout++ self._stderr = result.stderr++++ def communicate(self, timeout=None):++ return self._stdout, self._stderr++++def test_opencode_options_closes_server_http_session(monkeypatch):import config.v2_compat as v2_compatimport modules.agents.opencode as opencode_module@@@ -290,6 -290,6 +302,7 @@@ def test_install_agent_returns_resolvedlambda binary: f"/usr/bin/{binary}" if binary in {"curl", "bash"} else None,)monkeypatch.setattr(api.subprocess, "run", lambda *args, **kwargs: CompletedProcess())++ monkeypatch.setattr(api.subprocess, "Popen", _PopenFromRun)monkeypatch.setattr(api, "resolve_cli_path", lambda binary: "/Users/test/.opencode/bin/opencode")result = api.install_agent("opencode")@@@ -325,7 -325,8 +338,9 @@@ def test_install_codex_fresh_install_usreturn Nonemonkeypatch.setattr(api.subprocess, "run", fake_run)++ monkeypatch.setattr(api.subprocess, "Popen", _PopenFromRun)monkeypatch.setattr(api, "resolve_cli_path", fake_resolve)+ monkeypatch.setattr(api.Path, "home", lambda: tmp_path)result = api.install_agent("codex")@@@ -351,25 -359,220 +373,225 @@@ def test_install_codex_npm_install_runsdef fake_run(cmd, **kwargs):calls.append((cmd, kwargs.get("env", {})))- return CompletedProcess()+ if cmd == [str(npm_path), "install", "-g", "@openai/codex"]:+ return CompletedProcess(stdout="updated")+ raise AssertionError(f"unexpected command: {cmd}")def fake_resolve(binary):+ if binary == "npm":+ return str(npm_path)if binary == "codex":- return "/Users/test/.nvm/versions/node/v22.18.0/bin/codex"+ return str(codex_path)return None+ monkeypatch.setattr(api.Path, "home", lambda: tmp_path)monkeypatch.setattr(api.subprocess, "run", fake_run)++ monkeypatch.setattr(api.subprocess, "Popen", _PopenFromRun)monkeypatch.setattr(api, "resolve_cli_path", fake_resolve)+ monkeypatch.setattr(api.shutil, "which", lambda binary: None)result = api.install_agent("codex")assert result["ok"] is Trueassert len(calls) == 1- assert calls[0][0] == ["/Users/test/.nvm/versions/node/v22.18.0/bin/codex", "update"]- # PATH still gets the codex binary's dir prepended so any child npm it- # spawns picks up the same node toolchain.- assert calls[0][1]["PATH"].split(api.os.pathsep)[0] == "/Users/test/.nvm/versions/node/v22.18.0/bin"- assert result["path"] == "/Users/test/.nvm/versions/node/v22.18.0/bin/codex"+ assert calls[0][0] == [str(npm_path), "install", "-g", "@openai/codex"]+ assert calls[0][1]["NPM_CONFIG_PREFIX"] == str(tmp_path / ".local")+ assert calls[0][1]["PATH"].split(api.os.pathsep)[0] == str(tmp_path / ".local" / "bin")+ assert result["path"] == str(codex_path)+++ def test_install_codex_homebrew_install_runs_brew_upgrade(monkeypatch, tmp_path):+ brew_path = tmp_path / "homebrew" / "bin" / "brew"+ brew_path.parent.mkdir(parents=True)+ brew_path.write_text("#!/bin/sh\n")+ brew_path.chmod(0o755)+ codex_path = tmp_path / "homebrew" / "bin" / "codex"+ codex_path.write_text("#!/bin/sh\n")+ codex_path.chmod(0o755)+ calls = []++ class CompletedProcess:+ def __init__(self, returncode=0, stdout="", stderr=""):+ self.returncode = returncode+ self.stdout = stdout+ self.stderr = stderr++ def fake_run(cmd, **kwargs):+ calls.append((cmd, kwargs.get("env", {})))+ if cmd == [str(brew_path), "list", "--cask", "codex"]:+ return CompletedProcess()+ if cmd == [str(brew_path), "--prefix"]:+ return CompletedProcess(stdout=f"{tmp_path / 'homebrew'}\n")+ if cmd == [str(brew_path), "--prefix", "--cask"]:+ return CompletedProcess(stdout=f"{tmp_path / 'homebrew' / 'Caskroom'}\n")+ if cmd == [str(brew_path), "upgrade", "--cask", "codex"]:+ return CompletedProcess(stdout="upgraded")+ raise AssertionError(f"unexpected command: {cmd}")++ def fake_resolve(binary):+ if binary == "brew":+ return str(brew_path)+ if binary == "codex":+ return str(codex_path)+ return None++ monkeypatch.setattr(api.subprocess, "run", fake_run)++ monkeypatch.setattr(api.subprocess, "Popen", _PopenFromRun)+ monkeypatch.setattr(api, "resolve_cli_path", fake_resolve)+ monkeypatch.setattr(api.Path, "home", lambda: tmp_path)+ monkeypatch.setattr(api.shutil, "which", lambda binary: None)++ result = api.install_agent("codex")++ assert result["ok"] is True+ assert result["path"] == str(codex_path)+ assert [str(brew_path), "upgrade", "--cask", "codex"] in [call[0] for call in calls]+++ def test_install_codex_prefers_homebrew_when_npm_shares_prefix(monkeypatch, tmp_path):+ prefix = tmp_path / "homebrew"+ brew_path = prefix / "bin" / "brew"+ npm_path = prefix / "bin" / "npm"+ codex_path = prefix / "bin" / "codex"+ for path in (brew_path, npm_path, codex_path):+ path.parent.mkdir(parents=True, exist_ok=True)+ path.write_text("#!/bin/sh\n")+ path.chmod(0o755)+ calls = []++ class CompletedProcess:+ def __init__(self, returncode=0, stdout="", stderr=""):+ self.returncode = returncode+ self.stdout = stdout+ self.stderr = stderr++ def fake_run(cmd, **kwargs):+ calls.append((cmd, kwargs.get("env", {})))+ if cmd == [str(brew_path), "list", "--cask", "codex"]:+ return CompletedProcess()+ if cmd == [str(brew_path), "--prefix"]:+ return CompletedProcess(stdout=f"{prefix}\n")+ if cmd == [str(brew_path), "--prefix", "--cask"]:+ return CompletedProcess(stdout=f"{prefix / 'Caskroom'}\n")+ if cmd == [str(npm_path), "config", "get", "prefix"]:+ return CompletedProcess(stdout=f"{prefix}\n")+ if cmd == [str(brew_path), "upgrade", "--cask", "codex"]:+ return CompletedProcess(stdout="upgraded")+ raise AssertionError(f"unexpected command: {cmd}")++ def fake_resolve(binary):+ if binary == "brew":+ return str(brew_path)+ if binary == "npm":+ return str(npm_path)+ if binary == "codex":+ return str(codex_path)+ return None++ monkeypatch.setattr(api.subprocess, "run", fake_run)++ monkeypatch.setattr(api.subprocess, "Popen", _PopenFromRun)+ monkeypatch.setattr(api, "resolve_cli_path", fake_resolve)+ monkeypatch.setattr(api.Path, "home", lambda: tmp_path)+ monkeypatch.setattr(api.shutil, "which", lambda binary: None)++ result = api.install_agent("codex")++ assert result["ok"] is True+ assert result["path"] == str(codex_path)+ commands = [call[0] for call in calls]+ assert [str(brew_path), "upgrade", "--cask", "codex"] in commands+ assert [str(npm_path), "install", "-g", "@openai/codex"] not in commands+++ def test_install_codex_unknown_install_falls_back_to_cli_update(monkeypatch, tmp_path):+ codex_path = tmp_path / "bin" / "codex"+ codex_path.parent.mkdir(parents=True)+ codex_path.write_text("#!/bin/sh\n")+ codex_path.chmod(0o755)+ calls = []++ class CompletedProcess:+ def __init__(self, returncode=0, stdout="", stderr=""):+ self.returncode = returncode+ self.stdout = stdout+ self.stderr = stderr++ def fake_run(cmd, **kwargs):+ calls.append((cmd, kwargs.get("env", {})))+ if cmd == [str(codex_path), "--help"]:+ return CompletedProcess(stdout="Commands:\n update Update Codex to the latest version\n")+ if cmd == [str(codex_path), "update"]:+ return CompletedProcess(stdout="updated")+ raise AssertionError(f"unexpected command: {cmd}")++ def fake_resolve(binary):+ if binary == "codex":+ return str(codex_path)+ return None++ monkeypatch.setattr(api.subprocess, "run", fake_run)++ monkeypatch.setattr(api.subprocess, "Popen", _PopenFromRun)+ monkeypatch.setattr(api, "resolve_cli_path", fake_resolve)+ monkeypatch.setattr(api.Path, "home", lambda: tmp_path)+ monkeypatch.setattr(api.shutil, "which", lambda binary: None)++ result = api.install_agent("codex")++ assert result["ok"] is True+ assert [call[0] for call in calls] == [[str(codex_path), "--help"], [str(codex_path), "update"]]+ assert result["path"] == str(codex_path)+++ def test_install_codex_unknown_install_without_update_command_fails(monkeypatch, tmp_path):+ codex_path = tmp_path / "bin" / "codex"+ codex_path.parent.mkdir(parents=True)+ codex_path.write_text("#!/bin/sh\n")+ codex_path.chmod(0o755)++ class CompletedProcess:+ returncode = 0+ stdout = "Commands:\n exec Run Codex non-interactively\n"+ stderr = ""++ def fake_run(cmd, **kwargs):+ if cmd == [str(codex_path), "--help"]:+ return CompletedProcess()+ raise AssertionError(f"unexpected command: {cmd}")++ def fake_resolve(binary):+ if binary == "codex":+ return str(codex_path)+ return None++ monkeypatch.setattr(api.subprocess, "run", fake_run)++ monkeypatch.setattr(api.subprocess, "Popen", _PopenFromRun)+ monkeypatch.setattr(api, "resolve_cli_path", fake_resolve)+ monkeypatch.setattr(api.Path, "home", lambda: tmp_path)+ monkeypatch.setattr(api.shutil, "which", lambda binary: None)++ result = api.install_agent("codex")++ assert result["ok"] is False+ assert "does not expose an update command" in result["message"]+++ def test_install_codex_npm_install_without_npm_fails(monkeypatch, tmp_path):+ codex_path = tmp_path / "lib" / "node_modules" / "@openai" / "codex" / "bin" / "codex.js"+ codex_path.parent.mkdir(parents=True)+ codex_path.write_text("#!/usr/bin/env node\n")+ codex_path.chmod(0o755)++ def fake_resolve(binary):+ if binary == "codex":+ return str(codex_path)+ return None++ monkeypatch.setattr(api, "resolve_cli_path", fake_resolve)++ result = api.install_agent("codex")++ assert result["ok"] is False+ assert "npm was not found" in result["message"]def test_discord_list_channels_rejects_empty_guild_id(monkeypatch):@@@ -419,6 -622,6 +641,7 @@@ def test_install_codex_detects_existingmonkeypatch.setattr(api.Path, "home", lambda: tmp_path)monkeypatch.setattr(api.shutil, "which", lambda binary: str(npm_path) if binary == "npm" else None)monkeypatch.setattr(api.subprocess, "run", fake_run)++ monkeypatch.setattr(api.subprocess, "Popen", _PopenFromRun)result = api.install_agent("codex")diff --cc vibe/api.pyindex 714133e2d,0f7a34165..73d0c8364--- a/vibe/api.py+++ b/vibe/api.py@@@ -1871,25 -1873,14 +2001,25 @@@ def _run_install_commandlabel = "Upgrading" if mode == "upgrade" else "Installing"try:logger.info("%s agent %s with command: %s", label, name, cmd)- command_env = _command_env_for(cmd[0] if cmd and os.path.isabs(cmd[0]) else None)+ command_env = env or _command_env_for(cmd[0] if cmd and os.path.isabs(cmd[0]) else None)- result = subprocess.run(+ process = subprocess.Popen(cmd,- capture_output=True,+ stdout=subprocess.PIPE,+ stderr=subprocess.PIPE,text=True,- timeout=300, # 5 minute timeoutenv=command_env,+ **isolated_subprocess_kwargs(),)+ try:+ stdout, stderr = process.communicate(timeout=300) # 5 minute timeout+ except subprocess.TimeoutExpired:+ logger.error("Agent %s %s timed out", name, mode)+ signal_process_tree(process, KILL_SIGNAL, logger, f"{name} {mode}")+ stdout, stderr = process.communicate(timeout=10)+ output = (stdout or "") + ("\n" + stderr if stderr else "")+ output = truncate_output(output.strip())+ return {"ok": False, "message": f"{mode.capitalize()} timed out", "output": output or None}+ result = subprocess.CompletedProcess(cmd, process.returncode, stdout, stderr)output = result.stdout + ("\n" + result.stderr if result.stderr else "")output = truncate_output(output.strip())if result.returncode == 0: