The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(buzz): support media in standalone sends
EmpireOperating37c943997bd5
diff --git a/plugins/platforms/buzz/adapter.py b/plugins/platforms/buzz/adapter.pyindex 3efa2a6ff58..2a34362a9d4 100644--- a/plugins/platforms/buzz/adapter.py+++ b/plugins/platforms/buzz/adapter.py@@ -3131,7 +3131,7 @@ async def _standalone_send(message: str,*,thread_id: Optional[str] = None,- media_files: Optional[List[str]] = None,+ media_files: Optional[List[Any]] = None,force_document: bool = False,) -> Dict[str, Any]:"""One-shot send without a live adapter (out-of-process cron delivery).@@ -3175,7 +3175,8 @@ async def _standalone_send(_rtm = "off"if thread_id and _rtm != "off":args += ["--reply-to", str(thread_id)]- for path in media_files or []:+ for media in media_files or []:+ path = media[0] if isinstance(media, (list, tuple)) and media else mediaargs += ["--file", str(path)]try:code, out, err = await _exec_buzz(@@ -3210,7 +3211,10 @@ async def _standalone_send(data = json.loads(out or "{}")except ValueError:data = {}- return {"success": True, "message_id": str(data.get("event_id") or "")}+ result = {"success": True, "message_id": str(data.get("event_id") or "")}+ if media_files:+ result["media_delivered"] = True+ return resultdef interactive_setup() -> None:diff --git a/tests/gateway/test_buzz_adapter.py b/tests/gateway/test_buzz_adapter.pyindex 4800a39c251..dc4abe60cf8 100644--- a/tests/gateway/test_buzz_adapter.py+++ b/tests/gateway/test_buzz_adapter.py@@ -3253,6 +3253,42 @@ class TestStandaloneSend:"See @\u200bsession:default/example.",]+ @pytest.mark.asyncio+ async def test_standalone_send_extracts_path_from_media_descriptor(self, monkeypatch, tmp_path):+ from gateway.config import PlatformConfig++ fake_cli = tmp_path / "buzz"+ fake_cli.write_text("#!/bin/sh\n", encoding="utf-8")+ document = tmp_path / "report.txt"+ document.write_text("report", encoding="utf-8")+ monkeypatch.setenv("BUZZ_RELAY_URL", "https://r")+ monkeypatch.setenv("BUZZ_PRIVATE_KEY", "nsec1x")+ monkeypatch.setenv("BUZZ_CLI_PATH", str(fake_cli))++ captured = {}++ async def fake_exec(cli_path, args, *, relay_url, private_key, input_text=None, timeout=30.0):+ captured["args"] = args+ return 0, json.dumps({"accepted": True, "event_id": "evt-media"}), ""++ monkeypatch.setattr(_buzz_mod, "_exec_buzz", fake_exec)++ result = await _standalone_send(+ PlatformConfig(enabled=True, extra={}),+ CHANNEL,+ "attached",+ media_files=[(str(document), False)],+ )++ assert result == {+ "success": True,+ "message_id": "evt-media",+ "media_delivered": True,+ }+ file_index = captured["args"].index("--file")+ assert captured["args"][file_index + 1] == str(document)++# ── Editing and deleting (streaming) ──────────────────────────────────diff --git a/tests/tools/test_send_message_target_parse.py b/tests/tools/test_send_message_target_parse.pyindex 8a1b7a44059..ed8e64defe9 100644--- a/tests/tools/test_send_message_target_parse.py+++ b/tests/tools/test_send_message_target_parse.py@@ -10,13 +10,82 @@ from types import SimpleNamespacefrom unittest.mock import AsyncMock, patchfrom gateway.config import Platform-from tools.send_message_tool import _parse_target_ref, send_message_tool+from tools.send_message_tool import _parse_target_ref, _send_to_platform, send_message_tooldef _run_async_immediately(coro):return asyncio.run(coro)+def test_buzz_uuid_target_is_explicit() -> None:+ channel_id = "31b543d5-80d4-4df5-8a5c-cefca1a58fdd"++ assert _parse_target_ref("buzz", channel_id) == (channel_id, None, True)+++def test_plugin_media_receipt_suppresses_omitted_warning() -> None:+ media_result = {+ "success": True,+ "message_id": "evt-media",+ "media_delivered": True,+ }++ with patch(+ "tools.send_message_tool._send_via_adapter",+ new=AsyncMock(return_value=media_result),+ ):+ result = asyncio.run(+ _send_to_platform(+ Platform("buzz"),+ SimpleNamespace(enabled=True, token=None, extra={}),+ "31b543d5-80d4-4df5-8a5c-cefca1a58fdd",+ "attached",+ media_files=[("/tmp/report.txt", False)],+ )+ )++ assert result == media_result+ assert "warnings" not in result+++def test_send_message_routes_buzz_uuid_without_home_fallback() -> None:+ buzz_platform = Platform("buzz")+ buzz_cfg = SimpleNamespace(enabled=True, token=None, extra={})+ config = SimpleNamespace(+ platforms={buzz_platform: buzz_cfg},+ get_home_channel=lambda _platform: SimpleNamespace(chat_id="home-channel"),+ )+ channel_id = "31b543d5-80d4-4df5-8a5c-cefca1a58fdd"++ with patch("gateway.config.load_gateway_config", return_value=config), \+ patch("tools.interrupt.is_interrupted", return_value=False), \+ patch("gateway.channel_directory.resolve_channel_name", side_effect=AssertionError("raw UUID should not resolve via directory")), \+ patch("model_tools._run_async", side_effect=_run_async_immediately), \+ patch("tools.send_message_tool._send_to_platform", new=AsyncMock(return_value={"success": True})) as send_mock, \+ patch("gateway.mirror.mirror_to_session", return_value=True):+ result = json.loads(+ send_message_tool(+ {+ "action": "send",+ "target": f"buzz:{channel_id}",+ "message": "hello group",+ }+ )+ )++ assert result["success"] is True+ assert "note" not in result+ send_mock.assert_awaited_once_with(+ buzz_platform,+ buzz_cfg,+ channel_id,+ "hello group",+ thread_id=None,+ media_files=[],+ force_document=False,+ )++def test_photon_e164_target_is_explicit() -> None:chat_id, thread_id, is_explicit = _parse_target_ref("photon", "+15551234567")diff --git a/tools/send_message_tool.py b/tools/send_message_tool.pyindex a43b2bc95bd..3eb072b7bdd 100644--- a/tools/send_message_tool.py+++ b/tools/send_message_tool.py@@ -1403,7 +1403,12 @@ async def _send_to_platform(platform, pconfig, chat_id, message, thread_id=None,return resultlast_result = result- if warning and isinstance(last_result, dict) and last_result.get("success"):+ if (+ warning+ and isinstance(last_result, dict)+ and last_result.get("success")+ and not last_result.get("media_delivered")+ ):warnings = list(last_result.get("warnings", []))warnings.append(warning)last_result["warnings"] = warnings