fix: Command output goes through chunker, byte-safe for LoRa

- Commands now chunk output same as LLM responses
- split_sentences splits on newlines first for !health output
- chunk_response uses byte counting instead of character counting
- Emojis and UTF-8 properly counted for 228-byte LoRa limit
- !health 274 bytes now splits into 2 messages (195 + 74 bytes)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
K7ZVX 2026-05-05 23:07:25 +00:00
commit 5be1d20b24
2 changed files with 70 additions and 23 deletions

View file

@ -344,7 +344,17 @@ class MeshAI:
# Determine response
if result.route_type == RouteType.COMMAND:
messages = result.response # Commands return single string
# Chunk command output same as LLM responses
from .chunker import chunk_response
raw = result.response if isinstance(result.response, str) else str(result.response)
messages, remaining = chunk_response(
raw,
max_chars=self.config.response.max_length,
max_messages=self.config.response.max_messages,
)
# Store remaining for continuation
if remaining:
self.router.continuations.store(message.sender_id, remaining)
elif result.route_type == RouteType.LLM:
messages = await self.router.generate_llm_response(message, result.query)
else: