Something went wrong. Try again.
A local-first event pipeline for independent agents, built on Jazz.
Something went wrong. Try again.
3.0 kB · 74 lines
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475import type { ThoughtEvent } from "../events/types.js";
export const STREAM_TELEGRAM_HELP_VERSION = "stream-help-v3";export const STREAM_TELEGRAM_FOCUS_HELP_VERSION = "stream-focus-help-v1";export const STREAM_TELEGRAM_BOT_NAME = "The Stream";
export const STREAM_TELEGRAM_COMMANDS = [ { command: "help", description: "Show commands, feedback, and links" }, { command: "focus", description: "Propose a new focus from plain language" }, { command: "correct", description: "Reply to a message with /correct new text" },] as const;
export const STREAM_TELEGRAM_HELP_TEXT = `The Stream
Commands/help — show this menu/focus <description> — propose a private focus from plain language/correct <replacement> — reply to one of my messages to replace that answer exactly
Feedback👍 — mark a reply good👎 — mark a reply bad
Private activity and suggestionshttps://thought.stream/inspector/
Public docshttps://thought.stream/docs
The Telegram Menu button also contains /help, /focus, and /correct.`;
export const STREAM_TELEGRAM_FOCUS_HELP_TEXT = `Focus proposals
/focus <description>
Example/focus AI news that changes how I understand model training and agent infrastructure
This creates a private inert proposal for review. It does not activate a listener, expand data access, start training, deliver focus output, or contact a third party.`;
export function isTelegramHelpCommand(event: ThoughtEvent): boolean { if (event.type !== "stream.thought.source.telegram.message") return false; const text = typeof event.payload.text === "string" ? event.payload.text.trim() : ""; if (text === "/help") return true; const username = typeof event.payload.accountUsername === "string" ? event.payload.accountUsername.toLowerCase() : ""; return username.length > 0 && text.toLowerCase() === `/help@${username}`;}
export function isTelegramFocusHelpCommand(event: ThoughtEvent): boolean { if (event.type !== "stream.thought.source.telegram.message") return false; const text = typeof event.payload.text === "string" ? event.payload.text.trim() : ""; if (text === "/focus") return true; const username = typeof event.payload.accountUsername === "string" ? event.payload.accountUsername.toLowerCase() : ""; return username.length > 0 && text.toLowerCase() === `/focus@${username}`;}
export function telegramFocusDescription(event: ThoughtEvent): string | undefined { if (event.type !== "stream.thought.source.telegram.message") return undefined; const text = typeof event.payload.text === "string" ? event.payload.text.trim() : ""; const match = text.match(/^\/focus(?:@([A-Za-z0-9_]+))?\s+([\s\S]+)$/); if (!match) return undefined; const mention = match[1]?.toLowerCase(); const username = typeof event.payload.accountUsername === "string" ? event.payload.accountUsername.toLowerCase() : ""; if (mention && (!username || mention !== username)) return undefined; const description = match[2]?.trim(); return description ? description : undefined;}