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(claude): preserve settings auth token on save
cyh8a0163044ca8
diff --git a/tests/test_settings_disk_fallback.py b/tests/test_settings_disk_fallback.pyindex 1624f6372..a6ef51779 100644--- a/tests/test_settings_disk_fallback.py+++ b/tests/test_settings_disk_fallback.py@@ -213,3 +213,47 @@ def test_save_claude_auth_writes_settings_json_and_clears_v2_secret(state = get_claude_auth()assert state["api_key_source"] == "settings_json"assert state["base_url"] == "https://relay.example.invalid"+++def test_save_claude_auth_keeps_settings_token_over_legacy_v2_key(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch+) -> None:+ monkeypatch.setenv("CLAUDE_CONFIG_DIR", str(tmp_path / ".claude"))+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path / ".vibe_remote"))+ monkeypatch.setattr("config.paths._home", lambda: tmp_path, raising=False)+ _write_claude_settings(+ tmp_path,+ {+ "ANTHROPIC_AUTH_TOKEN": "token-from-settings",+ "ANTHROPIC_BASE_URL": "https://old-relay.example.invalid",+ },+ )++ from config.v2_config import AgentsConfig, RuntimeConfig, SlackConfig, V2Config+ from vibe.api import save_claude_auth++ cfg = V2Config(+ mode="self_host",+ version="v2",+ slack=SlackConfig(bot_token=""),+ runtime=RuntimeConfig(default_cwd="."),+ agents=AgentsConfig(),+ )+ cfg.agents.claude.auth_mode = "api_key"+ cfg.agents.claude.api_key = "sk-legacy-v2-key"+ cfg.agents.claude.base_url = "https://legacy-v2.example.invalid"+ cfg.save()++ result = save_claude_auth(+ {+ "auth_mode": "api_key",+ "api_key": "",+ "base_url": "https://new-relay.example.invalid",+ }+ )++ assert result["ok"] is True+ settings = json.loads((tmp_path / ".claude" / "settings.json").read_text())+ assert settings["env"]["ANTHROPIC_AUTH_TOKEN"] == "token-from-settings"+ assert "ANTHROPIC_API_KEY" not in settings["env"]+ assert settings["env"]["ANTHROPIC_BASE_URL"] == "https://new-relay.example.invalid"diff --git a/vibe/api.py b/vibe/api.pyindex 92922e29f..22e9a7732 100644--- a/vibe/api.py+++ b/vibe/api.py@@ -3225,13 +3225,14 @@ def save_claude_auth(payload: dict) -> dict:except Exception:api_key = Nonesettings_auth_token = None- with CONFIG_LOCK:- try:- existing = load_config()- stored = getattr(getattr(existing, "agents", None), "claude", None)- api_key = api_key or getattr(stored, "api_key", None) or None- except Exception:- pass+ if not api_key and not settings_auth_token:+ with CONFIG_LOCK:+ try:+ existing = load_config()+ stored = getattr(getattr(existing, "agents", None), "claude", None)+ api_key = getattr(stored, "api_key", None) or None+ except Exception:+ passif not api_key and not settings_auth_token:return {"ok": False, "message": "api_key is required when auth_mode='api_key'"}