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.

🔧 (settings.py): enforce required environment variables for ClaudeConfig and AppConfig ♻️ (settings.py): remove default values from ClaudeConfig to ensure explicit configuration ♻️ (controller.py): ensure CWD is always restored to original after execution 🔧 (settings.py): change default SlackConfig require_mention to false for better usability

cyhhao94852e16d299
diff --git a/config/settings.py b/config/settings.py
index a975fffc2..e86e24583 100644
--- a/config/settings.py
+++ b/config/settings.py
@@ -53,17 +53,29 @@ class TelegramConfig(BaseIMConfig):
@dataclass
class ClaudeConfig:
- permission_mode: str = "bypassPermissions"
- cwd: str = "./_tmp"
- continue_conversation: bool = True
+ permission_mode: str
+ cwd: str
+ continue_conversation: bool
system_prompt: Optional[str] = None
@classmethod
def from_env(cls) -> 'ClaudeConfig':
+ permission_mode = os.getenv("CLAUDE_PERMISSION_MODE")
+ if not permission_mode:
+ raise ValueError("CLAUDE_PERMISSION_MODE environment variable is required")
+
+ cwd = os.getenv("CLAUDE_CWD")
+ if not cwd:
+ raise ValueError("CLAUDE_CWD environment variable is required")
+
+ continue_conversation_str = os.getenv("CLAUDE_CONTINUE_CONVERSATION")
+ if continue_conversation_str is None:
+ raise ValueError("CLAUDE_CONTINUE_CONVERSATION environment variable is required")
+
return cls(
- permission_mode=os.getenv("CLAUDE_PERMISSION_MODE", "bypassPermissions"),
- cwd=os.getenv("CLAUDE_CWD", "./_tmp"),
- continue_conversation=os.getenv("CLAUDE_CONTINUE_CONVERSATION", "true").lower() == "true",
+ permission_mode=permission_mode,
+ cwd=cwd,
+ continue_conversation=continue_conversation_str.lower() == "true",
system_prompt=os.getenv("CLAUDE_SYSTEM_PROMPT")
)
@@ -74,7 +86,7 @@ class SlackConfig(BaseIMConfig):
app_token: Optional[str] = None # For Socket Mode
signing_secret: Optional[str] = None # For webhook mode
target_channel: Optional[Union[List[str], str]] = None # Whitelist of channel IDs. Empty list = DM only, null/None = accept all
- require_mention: bool = True # Require @mention in channels (ignored in DMs)
+ require_mention: bool = False # Require @mention in channels (ignored in DMs)
@classmethod
def from_env(cls) -> 'SlackConfig':
@@ -87,7 +99,7 @@ class SlackConfig(BaseIMConfig):
app_token=os.getenv("SLACK_APP_TOKEN"),
signing_secret=os.getenv("SLACK_SIGNING_SECRET"),
target_channel=cls._parse_channel_list(os.getenv("SLACK_TARGET_CHANNEL")),
- require_mention=os.getenv("SLACK_REQUIRE_MENTION", "true").lower() == "true"
+ require_mention=os.getenv("SLACK_REQUIRE_MENTION", "false").lower() == "true"
)
def validate(self) -> bool:
@@ -133,15 +145,20 @@ class AppConfig:
@classmethod
def from_env(cls) -> 'AppConfig':
- platform = os.getenv("IM_PLATFORM", "telegram").lower()
+ platform = os.getenv("IM_PLATFORM")
+ if not platform:
+ raise ValueError("IM_PLATFORM environment variable is required")
+ platform = platform.lower()
if platform not in ["telegram", "slack"]:
raise ValueError(f"Invalid IM_PLATFORM: {platform}. Must be 'telegram' or 'slack'")
+ log_level = os.getenv("LOG_LEVEL", "INFO") # Keep default for log level as it's optional
+
config = cls(
platform=platform,
claude=ClaudeConfig.from_env(),
- log_level=os.getenv("LOG_LEVEL", "INFO")
+ log_level=log_level
)
# Load platform-specific config
diff --git a/core/controller.py b/core/controller.py
index eefb46a6b..b18ef96f9 100644
--- a/core/controller.py
+++ b/core/controller.py
@@ -210,10 +210,14 @@ Choose a command below or type any message to add it to the processing queue."""
# Get user's CWD from settings if available
settings_key = self._get_settings_key(context)
custom_cwd = self.settings_manager.get_custom_cwd(settings_key)
+ original_cwd = self.claude_client.options.cwd
+
+ # Use custom CWD if set, otherwise fall back to config default
if custom_cwd:
- # Temporarily set the CWD for this execution
- original_cwd = self.claude_client.options.cwd
self.claude_client.options.cwd = custom_cwd
+ else:
+ # Reset to config default in case it was changed before
+ self.claude_client.options.cwd = self.config.claude.cwd
# Execute with Claude
async def on_claude_message(claude_msg: str, message_type: str = None):
@@ -239,9 +243,8 @@ Choose a command below or type any message to add it to the processing queue."""
try:
await self.claude_client.stream_execute(message, on_claude_message, context.user_id)
- # Restore original CWD if it was changed
- if custom_cwd:
- self.claude_client.options.cwd = original_cwd
+ # Always restore original CWD
+ self.claude_client.options.cwd = original_cwd
# Check if there are more messages
remaining = await self.session_manager.has_messages(context.user_id)
@@ -260,9 +263,8 @@ Choose a command below or type any message to add it to the processing queue."""
except Exception as e:
logger.error(f"Error during Claude execution: {e}")
- # Restore original CWD if it was changed
- if custom_cwd:
- self.claude_client.options.cwd = original_cwd
+ # Always restore original CWD
+ self.claude_client.options.cwd = original_cwd
await self.im_client.send_message(
target_context,
f"❌ Error processing message: {str(e)}\nStopping queue processing.",
@@ -366,7 +368,7 @@ Choose a command below or type any message to add it to the processing queue."""
# Check if user has custom CWD in settings
settings_key = self._get_settings_key(context)
custom_cwd = self.settings_manager.get_custom_cwd(settings_key)
- current_cwd = custom_cwd if custom_cwd else self.claude_client.options.cwd
+ current_cwd = custom_cwd if custom_cwd else self.config.claude.cwd
absolute_path = os.path.abspath(current_cwd)
response_text = f"📁 Current Working Directory:\n{absolute_path}"