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(dispatcher): allow uploads outside active cwd
cyh87fefcf8bca1
diff --git a/core/message_dispatcher.py b/core/message_dispatcher.pyindex 3e88e0de4..224c55ecc 100644--- a/core/message_dispatcher.py+++ b/core/message_dispatcher.py@@ -357,27 +357,16 @@ class ConsolidatedMessageDispatcher:logger.debug("IM client does not support upload_file_from_path; skipping file uploads")return- # Determine allowed roots for file uploads (active cwd + /tmp)- allowed_roots: list[Path] = [Path("/tmp").resolve()]- try:- active_cwd = self.controller.get_cwd(context)- allowed_roots.append(Path(active_cwd).resolve())- except Exception:- pass-for fl in files:if not os.path.isfile(fl.path):logger.warning("File not found, skipping upload: %s", fl.path)continue- # Security: resolve symlinks and ensure within allowed roots+try:resolved = Path(fl.path).resolve(strict=True)except (OSError, ValueError):logger.warning("Cannot resolve file path, skipping: %s", fl.path)continue- if not any(resolved == root or resolved.is_relative_to(root) for root in allowed_roots):- logger.warning("File outside allowed roots, skipping: %s", fl.path)- continue# Use link label as title, but preserve file extension so users can# download/open files correctly on all platforms.diff --git a/tests/test_message_dispatcher_file_uploads.py b/tests/test_message_dispatcher_file_uploads.pynew file mode 100644index 000000000..5fcf796f7--- /dev/null+++ b/tests/test_message_dispatcher_file_uploads.py@@ -0,0 +1,71 @@+import sys+import tempfile+import unittest+from pathlib import Path++sys.path.insert(0, str(Path(__file__).resolve().parents[1]))++from core.message_dispatcher import ConsolidatedMessageDispatcher+from core.reply_enhancer import FileLink+from modules.im import MessageContext+++class _StubController:+ def __init__(self):+ self.config = type("Config", (), {"platform": "slack"})()+++class _StubIMClient:+ def __init__(self):+ self.file_uploads = []+ self.image_uploads = []++ async def upload_file_from_path(self, context, file_path, title=None):+ self.file_uploads.append((context.channel_id, file_path, title))++ async def upload_image_from_path(self, context, file_path, title=None):+ self.image_uploads.append((context.channel_id, file_path, title))+++class MessageDispatcherFileUploadTests(unittest.IsolatedAsyncioTestCase):+ async def test_upload_file_link_allows_path_outside_cwd(self):+ dispatcher = ConsolidatedMessageDispatcher(_StubController())+ im_client = _StubIMClient()+ context = MessageContext(user_id="U1", channel_id="C1")++ with tempfile.TemporaryDirectory() as tmpdir:+ file_path = Path(tmpdir) / "report.txt"+ file_path.write_text("hello", encoding="utf-8")+ resolved_path = str(file_path.resolve())++ await dispatcher._upload_file_links(+ im_client,+ context,+ [FileLink(label="report", path=str(file_path))],+ )++ self.assertEqual(im_client.file_uploads, [("C1", resolved_path, "report.txt")])+ self.assertEqual(im_client.image_uploads, [])++ async def test_upload_image_link_allows_path_outside_cwd(self):+ dispatcher = ConsolidatedMessageDispatcher(_StubController())+ im_client = _StubIMClient()+ context = MessageContext(user_id="U1", channel_id="C1")++ with tempfile.TemporaryDirectory() as tmpdir:+ image_path = Path(tmpdir) / "screenshot.png"+ image_path.write_bytes(b"png")+ resolved_path = str(image_path.resolve())++ await dispatcher._upload_file_links(+ im_client,+ context,+ [FileLink(label="preview", path=str(image_path), is_image=True)],+ )++ self.assertEqual(im_client.file_uploads, [])+ self.assertEqual(im_client.image_uploads, [("C1", resolved_path, "preview.png")])+++if __name__ == "__main__":+ unittest.main()