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
Handle invalid global agent imports
cyh393b4de8c735
diff --git a/tests/test_ui_api.py b/tests/test_ui_api.pyindex b74420282..f1b91b433 100644--- a/tests/test_ui_api.py+++ b/tests/test_ui_api.py@@ -1199,10 +1199,31 @@ def test_vibe_agent_import_reports_unreadable_file_as_client_error(tmp_path, monmonkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path / ".vibe_remote"))missing_file = tmp_path / "missing-agent.md"- with pytest.raises(ValueError, match="Unable to read agent import file"):+ with pytest.raises(ValueError, match="Unable to read or parse agent import file"):api.import_vibe_agents({"file": str(missing_file), "backend": "codex"})+def test_vibe_agent_import_skips_invalid_global_agent_file(tmp_path, monkeypatch):+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path / ".vibe_remote"))+ valid_file = tmp_path / "valid.md"+ invalid_file = tmp_path / "invalid.md"+ valid_file.write_text("---\nname: reviewer\n---\nReview carefully.\n", encoding="utf-8")+ invalid_file.write_text("---\nname: [broken\n---\n", encoding="utf-8")+ monkeypatch.setattr(+ api,+ "iter_global_agent_files",+ lambda source: [(invalid_file, "codex"), (valid_file, "codex")],+ )++ result = api.import_vibe_agents({"from": "codex", "all": True})++ assert result["ok"] is True+ assert [agent["name"] for agent in result["imported"]] == ["reviewer"]+ assert result["skipped"][0]["source_ref"] == str(invalid_file)+ assert result["skipped"][0]["reason"] == "invalid"+ assert "Unable to read or parse agent import file" in result["skipped"][0]["error"]++def test_vibe_agent_api_rejects_backend_update(tmp_path, monkeypatch):monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path / ".vibe_remote"))api.create_vibe_agent({"name": "worker", "backend": "codex"})diff --git a/vibe/api.py b/vibe/api.pyindex 0f1352acd..19b17b0c1 100644--- a/vibe/api.py+++ b/vibe/api.py@@ -16,6 +16,8 @@ from http.client import HTTPSConnectionfrom pathlib import Pathfrom typing import Any, Dict, List, Optional+import yaml+from config import pathsfrom config.v2_config import CONFIG_LOCK, V2Configfrom config.v2_settings import (@@ -68,6 +70,13 @@ _OPENCODE_OPTIONS_CACHE: dict[str, dict] = {}_OPENCODE_OPTIONS_TTL_SECONDS = 30.0+def _parse_agent_import_file(path: Path, *, backend: str):+ try:+ return parse_agent_file(path, backend=backend)+ except (OSError, ValueError, TypeError, AttributeError, yaml.YAMLError) as exc:+ raise ValueError(f"Unable to read or parse agent import file: {exc}") from exc++def _delayed_restart_helper_command() -> list[str]:candidates: list[list[str]] = []current = sys.executable@@ -832,6 +841,7 @@ def import_vibe_agents(payload: dict) -> dict:if not isinstance(payload, dict):raise ValueError("Import payload must be an object")candidates = []+ skipped = []file_path = payload.get("file")source = payload.get("from") or payload.get("from_source")name = str(payload.get("name") or "").strip()@@ -843,17 +853,18 @@ def import_vibe_agents(payload: dict) -> dict:if name or import_all:raise ValueError("name and all are only valid with from")backend = validate_agent_backend(str(payload.get("backend") or ""))- try:- candidates.append(parse_agent_file(Path(file_path).expanduser(), backend=backend))- except OSError as exc:- raise ValueError(f"Unable to read agent import file: {exc}") from exc+ candidates.append(_parse_agent_import_file(Path(file_path).expanduser(), backend=backend))else:if source not in {"claude", "codex", "opencode"}:raise ValueError("from must be one of: claude, codex, opencode")if name and import_all:raise ValueError("Use either name or all, not both")for path, backend in iter_global_agent_files(str(source)):- candidate = parse_agent_file(path, backend=backend)+ try:+ candidate = _parse_agent_import_file(path, backend=backend)+ except ValueError as exc:+ skipped.append({"source_ref": str(path), "reason": "invalid", "error": str(exc)})+ continueif name and candidate.name != name:continuecandidates.append(candidate)@@ -870,7 +881,7 @@ def import_vibe_agents(payload: dict) -> dict:return {"ok": True,"imported": [_vibe_agent_payload(agent, brief=True) for agent in result.imported],- "skipped": result.skipped,+ "skipped": skipped + result.skipped,}finally:store.close()