Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

fix(claude): preserve bundled cli fallback

cyh3bb7a5e3b84e
diff --git a/core/handlers/session_handler.py b/core/handlers/session_handler.py
index 676f4c99c..5cfa79c85 100644
--- a/core/handlers/session_handler.py
+++ b/core/handlers/session_handler.py
@@ -54,6 +54,17 @@ class SessionHandler(BaseHandler):
permission_mode = getattr(getattr(self.config, "claude", None), "permission_mode", None)
return permission_mode == "bypassPermissions" and self._running_as_root()
+ def _get_claude_cli_path_override(self) -> Optional[str]:
+ cli_path = getattr(getattr(self.config, "claude", None), "cli_path", None)
+ if cli_path is None:
+ return None
+
+ normalized = str(cli_path).strip()
+ if not normalized or normalized == "claude":
+ return None
+
+ return normalized
+
def _load_agent_file(self, agent_name: str, working_path: str) -> Optional[Dict[str, Any]]:
"""Load an agent file and return its parsed content.
@@ -221,7 +232,6 @@ class SessionHandler(BaseHandler):
"cwd": working_path,
"system_prompt": final_system_prompt,
"resume": stored_claude_session_id if stored_claude_session_id else None,
- "cli_path": getattr(self.config.claude, "cli_path", None) or None,
"extra_args": extra_args,
"setting_sources": ["user"], # Load user settings from ~/.claude/settings.json
# Disable AskUserQuestion tool - SDK cannot respond to it programmatically
@@ -229,6 +239,9 @@ class SessionHandler(BaseHandler):
"disallowed_tools": ["AskUserQuestion"],
"env": claude_env, # Pass Anthropic/Claude env vars
}
+ cli_path_override = self._get_claude_cli_path_override()
+ if cli_path_override:
+ option_kwargs["cli_path"] = cli_path_override
if effective_effort:
option_kwargs["effort"] = effective_effort
# Only set allowed_tools if agent file specifies tools.
diff --git a/tests/test_claude_cli_path.py b/tests/test_claude_cli_path.py
index 51f3e356f..efa54e9b3 100644
--- a/tests/test_claude_cli_path.py
+++ b/tests/test_claude_cli_path.py
@@ -4,6 +4,7 @@ import asyncio
from dataclasses import dataclass, field
from pathlib import Path
import sys
+from typing import Any
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
@@ -71,6 +72,10 @@ class _Controller:
return context.channel_id
+def _run_session(handler: SessionHandler, context: MessageContext):
+ return asyncio.run(handler.get_or_create_claude_session(context))
+
+
def test_to_app_config_preserves_claude_cli_path() -> None:
v2 = V2Config(
mode="self_host",
@@ -86,7 +91,7 @@ def test_to_app_config_preserves_claude_cli_path() -> None:
def test_session_handler_passes_configured_claude_cli_path(monkeypatch, tmp_path: Path) -> None:
- captured: dict[str, object] = {}
+ captured: dict[str, Any] = {}
class _StubClaudeSDKClient:
def __init__(self, options):
@@ -101,8 +106,31 @@ def test_session_handler_passes_configured_claude_cli_path(monkeypatch, tmp_path
handler = SessionHandler(controller)
context = MessageContext(user_id="U123", channel_id="C123")
- client = asyncio.run(handler.get_or_create_claude_session(context))
+ client = _run_session(handler, context)
assert captured["connected"] is True
assert captured["options"].cli_path == "/usr/local/bin/claude-proxy"
assert controller.claude_sessions[f"slack_C123:{tmp_path}"] is client
+
+
+def test_session_handler_keeps_sdk_default_for_default_claude_binary(monkeypatch, tmp_path: Path) -> None:
+ captured: dict[str, Any] = {}
+
+ class _StubClaudeSDKClient:
+ def __init__(self, options):
+ captured["options"] = options
+
+ async def connect(self) -> None:
+ captured["connected"] = True
+
+ monkeypatch.setattr(session_handler_module, "ClaudeSDKClient", _StubClaudeSDKClient)
+
+ controller = _Controller(tmp_path)
+ controller.config.claude.cli_path = "claude"
+ handler = SessionHandler(controller)
+ context = MessageContext(user_id="U123", channel_id="C123")
+
+ _run_session(handler, context)
+
+ assert captured["connected"] is True
+ assert captured["options"].cli_path is None