The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(photon): add native message effects
Hermes Agent06150f70af4b
diff --git a/plugins/platforms/photon/README.md b/plugins/platforms/photon/README.mdindex bef7a68a2cf..53908f05b52 100644--- a/plugins/platforms/photon/README.md+++ b/plugins/platforms/photon/README.md@@ -155,8 +155,9 @@ All env vars are documented in `plugin.yaml`. The most important:reachable across restarts via spectrum-ts' `space.get(id)`.- **Native polls are supported.** Hermes posts poll content through`spectrum-ts`' `poll(...)` builder via the sidecar's `/send-poll` endpoint.-- **Message effects** — supported by `spectrum-ts` but not yet exposed; the- sidecar is the natural place to add them.+- **Message effects are supported.** Text can be sent with native iMessage+ bubble/screen effects through `spectrum-ts`' iMessage `effect(...)` builder+ via the sidecar's `/send-effect` endpoint.- **Cron/standalone sends require a running gateway.** Processes outsidethe gateway (cron subprocesses, `hermes send`) cannot spawn the sidecar;they authenticate to the gateway's live sidecar via the runtime record atdiff --git a/plugins/platforms/photon/adapter.py b/plugins/platforms/photon/adapter.pyindex ea42da19f57..84bfd43b0dd 100644--- a/plugins/platforms/photon/adapter.py+++ b/plugins/platforms/photon/adapter.py@@ -1570,6 +1570,25 @@ class PhotonAdapter(BasePlatformAdapter):return SendResult(success=False, error=str(e))return SendResult(success=True, message_id=data.get("messageId"))+ async def send_effect(+ self,+ chat_id: str,+ text: str,+ effect: str,+ metadata: Optional[Dict[str, Any]] = None,+ ) -> SendResult:+ """Send text with a native iMessage bubble or screen effect."""+ if not text.strip() or not effect.strip():+ return SendResult(success=False, error="text and effect are required")+ try:+ data = await self._sidecar_call(+ "/send-effect",+ {"spaceId": chat_id, "text": text.strip(), "effect": effect.strip()},+ )+ except Exception as e:+ return SendResult(success=False, error=str(e))+ return SendResult(success=True, message_id=data.get("messageId"))+async def send_typing(self, chat_id: str, metadata=None) -> None:now = time.time()if now - self._typing_last_sent.get(chat_id, 0.0) < _TYPING_COOLDOWN_SECONDS:diff --git a/plugins/platforms/photon/sidecar/index.mjs b/plugins/platforms/photon/sidecar/index.mjsindex 18af5cab0a9..f49120215a3 100644--- a/plugins/platforms/photon/sidecar/index.mjs+++ b/plugins/platforms/photon/sidecar/index.mjs@@ -33,6 +33,8 @@// "reactionId": "..." | null (restart-recovery fallback)}// - POST /send-poll -> {"ok": true, "messageId": "..."}// body: {"spaceId": "...", "title": "...", "options": ["...", "..."]}+// - POST /send-effect -> {"ok": true, "messageId": "..."}+// body: {"spaceId": "...", "text": "...", "effect": "confetti" | ...}// - POST /typing -> {"ok": true}// body: {"spaceId": "...", "state": "start" | "stop"}// - POST /shutdown -> {"ok": true}; then process exits@@ -240,7 +242,8 @@ let Spectrum,spectrumText,spectrumMarkdown,spectrumTyping,- spectrumPoll;+ spectrumPoll,+ imessageEffect;try {({Spectrum,@@ -251,7 +254,7 @@ try {markdown: spectrumMarkdown,typing: spectrumTyping,} = await import("spectrum-ts"));- ({ imessage } = await import("spectrum-ts/providers/imessage"));+ ({ imessage, effect: imessageEffect } = await import("spectrum-ts/providers/imessage"));} catch (e) {console.error("photon-sidecar: spectrum-ts is not installed. Run `npm install` " +@@ -269,6 +272,8 @@ const app = await Spectrum({telemetry,});+const MESSAGE_EFFECTS = imessage.effect.message;+// ---------------------------------------------------------------------------// Inbound: forward `app.messages` (gRPC stream) to the Python consumer.@@ -898,6 +903,22 @@ const server = http.createServer(async (req, res) => {const result = await space.send(spectrumPoll(title.trim(), choices));return ok(res, { messageId: result?.id || null });}+ if (req.url === "/send-effect") {+ const { spaceId, text, effect } = body || {};+ const effectName = String(effect || "").trim();+ const effectId = MESSAGE_EFFECTS[effectName];+ if (!spaceId || typeof text !== "string" || !text.trim()) {+ return badRequest(res, "spaceId and text are required");+ }+ if (!effectId) {+ return badRequest(res, "unsupported effect");+ }+ const space = await resolveSpace(spaceId);+ const result = await space.send(+ imessageEffect(spectrumText(text.trim()), effectId)+ );+ return ok(res, { messageId: result?.id || null });+ }if (req.url === "/typing") {const { spaceId, state = "start" } = body || {};if (!spaceId) return badRequest(res, "spaceId is required");diff --git a/tests/plugins/platforms/photon/test_outbound_media.py b/tests/plugins/platforms/photon/test_outbound_media.pyindex 144b5b6e16e..5030fe5a018 100644--- a/tests/plugins/platforms/photon/test_outbound_media.py+++ b/tests/plugins/platforms/photon/test_outbound_media.py@@ -215,6 +215,35 @@ async def test_send_poll_requires_two_options(monkeypatch: pytest.MonkeyPatch) -assert calls == []+async def test_send_effect_hits_effect_endpoint(monkeypatch: pytest.MonkeyPatch) -> None:+ adapter = _make_adapter(monkeypatch)+ calls = _capture_sidecar(adapter)++ result = await adapter.send_effect("any;-;+1", " Celebrate ", " confetti ")++ assert result.success is True+ assert result.message_id == "msg-123"+ assert calls == [+ (+ "/send-effect",+ {"spaceId": "any;-;+1", "text": "Celebrate", "effect": "confetti"},+ )+ ]+++async def test_send_effect_requires_text_and_effect(monkeypatch: pytest.MonkeyPatch) -> None:+ adapter = _make_adapter(monkeypatch)+ calls = _capture_sidecar(adapter)++ result = await adapter.send_effect("any;-;+1", "", "confetti")++ assert result.success is False+ assert "required" in (result.error or "")+ assert calls == []++@pytest.mark.asyncioasync def test_send_attachment_rejects_unsafe_path(monkeypatch: pytest.MonkeyPatchdiff --git a/website/docs/user-guide/messaging/photon.md b/website/docs/user-guide/messaging/photon.mdindex a3e4631fadd..c37361ef93f 100644--- a/website/docs/user-guide/messaging/photon.md+++ b/website/docs/user-guide/messaging/photon.md@@ -204,6 +204,9 @@ Common issues:media.- **Native polls are supported.** Hermes sends poll content throughspectrum-ts' `poll()` builder via the sidecar's `/send-poll` endpoint.+- **Message effects are supported.** Hermes sends text with native iMessage+ bubble/screen effects through spectrum-ts' iMessage `effect()` builder+ via the sidecar's `/send-effect` endpoint.- **Photon's free quotas:** 5,000 messages per server per day,50 new-conversation initiations per shared line per day. Increasesavailable — email `[email protected]`.