Files
beaver-gateway/src/beaver_gateway/frontends/telegram/texts.py
T

106 lines
4.1 KiB
Python

"""Every string the Telegram frontend shows the user; English defaults, overridable."""
from __future__ import annotations
from dataclasses import dataclass, field
__all__ = ["TOOL_LABELS", "TelegramTexts"]
TOOL_LABELS: dict[str, str] = {
"Read": "reading",
"Glob": "looking for files",
"Grep": "searching",
"Edit": "editing a file",
"Write": "writing a file",
"MultiEdit": "editing files",
"Bash": "running a command",
"WebSearch": "searching the web",
"WebFetch": "reading a page",
"Task": "started a subagent",
"Agent": "started a subagent",
"AskUserQuestion": "asking",
"TodoWrite": "planning",
"Skill": "opening a skill",
"mcp__gateway__spawn": "opening a conversation",
"mcp__gateway__read_conversation": "reading a conversation",
"mcp__gateway__say": "speaking",
"mcp__gateway__schedule": "setting a reminder",
"mcp__gateway__inject": "passing to another conversation",
}
@dataclass(frozen=True, slots=True)
class TelegramTexts:
commands: tuple[tuple[str, str], ...] = (
("merge", "merge this branch into the master"),
("new", "new branch: in General a new topic, in a topic a fresh one here"),
("chat", "open a deep chat in the vault: /chat topic"),
("status", "this conversation"),
("help", "commands"),
)
help_head: str = "General is the master, any other topic is a branch."
branch: str = "branch"
closed_prefix: str = "✅ "
waiting: str = "⏳ thinking"
thinking: str = "🤔 thinking"
writing: str = "✍️ writing"
tool: str = "⏳ {label}"
tool_labels: dict[str, str] = field(default_factory=lambda: dict(TOOL_LABELS))
attachment_sticker: str = "[attachment: sticker - not supported]"
attachment_animation: str = "[attachment: animation - not supported]"
attachment_kinds: dict[str, str] = field(
default_factory=lambda: {
"photo": "photo",
"document": "file",
"voice": "voice message",
"audio": "audio",
"video": "video",
"video_note": "video note",
}
)
attachment_too_big: str = (
"[attachment: {kind} {name}, {mb} MB - over 20 MB, Telegram does not "
"serve it to bots]"
)
attachment_failed: str = "[attachment: {kind} {name} - download failed: {error}]"
attachment_size: str = ", {kb} KB"
attachment: str = "[attachment: {kind} {path}{size}]"
attachment_kept: str = (
"[attachment: {kind} {path}{size}; kept {days} days, move it into the "
"vault if it matters]"
)
merge_nothing: str = "nothing to merge: this is not an open branch"
merging: str = "🔀 merging into the master"
merged: str = "✅ merged into the master"
merge_failed: str = "⚠️ merge failed: {error}"
new_branch_topic: str = "🌿 branch «{title}» - in a new topic"
new_branch_here: str = "🌿 new branch on this topic"
chat_usage: str = "/chat <topic>"
chat_failed: str = "could not open: {error}"
chat_opened: str = "💬 deep chat: {where}"
status_unbound: str = "this topic is bound to nothing - write, and a branch opens"
status_line: str = "session: {live} · turn: {turn} · queued: {queued}"
status_live: str = "live"
status_dead: str = "none"
status_running: str = "running"
status_idle: str = "idle"
status_question: str = "❓ waiting for an answer"
status_pool: str = "pool: {sessions} sessions, rss {mb} MB"
status_outbox: str = "outbox: {pending} queued"
turn_failed: str = "⚠️ the turn failed, see the gateway logs"
background_failed: str = (
"⚠️ a background turn ({origin}) failed, see the gateway logs"
)
question_closed: str = "the question is already closed"
question_timeout: str = "⌛ time is up - answer as text"
question_answered: str = "✅ {answer}"
question_typed: str = "✍️ {text}"
done_button: str = "✅ done"
mirrored: str = "📝 from the panel:\n{text}"
@property
def help(self) -> str:
return (
self.help_head + "\n" + "\n".join(f"/{c} - {d}" for c, d in self.commands)
)