Repository navigation
MCP addons: watches, replies, reactions, sampling, audio - #39
Merged
Merged
Conversation
… addon An MCP stdio server with an "addon" block in MCP_CONFIG can now hook the bot through a small signalbot extension of MCP 2025-06-18: - direct chat commands the bot runs itself, without the model - tools hidden from the model, callable only by the bot - watches: messages matching an addon's pattern in one chat go to the addon instead of the model or history, on both the reader and slot paths - an outbox resource the addon updates, for posts and reactions on its own schedule - per-chat pseudonyms, chat allowlist and permissions, settings passed through by name prefix from the one env file, stderr counted never logged Core ports, generic: Action.Pictures, OnSent, Done and IsZero; Host.Post (replacing Tell) with Network.Reachable; Host.React at low priority in the mailbox. groupctx now runs after mcp. kit/img gains Safe (header-only size check, JPEG metadata stripped). Telegram locations become map links. cmd/geoguess is a GeoGuessr-style game addon on the standard library: Mapillary and Panoramax street-level photos with quality filters, guesses by shared location, ranked by distance, keeping only distances. No new dependencies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
A group message that starts with one of the bot's registered commands
(/geo, /intro, an MCP chat command, ...) now counts as addressed, as
Telegram already does with bot_command. Other slash words, and a command
later in the message, are still chatter.
The core hands the network the command names before Run: Network.Watch
now takes bot.Watch{Events, Commands}. The Signal client checks them on
the reader with feature.ParseCommand, with no I/O; Telegram ignores them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
Test that a group command becomes an addressed message on the reader only once Watch names it, more isAddressed cases (a command replying to someone else, a photo captioned with one, a sticker), and that Watch's commands leave member loading alone. Correct the Addressed field's comment and the watch paths in TECHNICAL.md, say how Telegram and Signal differ (any command at the start versus only the bot's own), and that on Telegram with privacy mode on GeoGuess's plain guesses need a reply to the photo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
Signal shares a location from the + button, Telegram from 📎. GeoGuess doesn't know which network it runs on, so the round's caption and the README now give both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
The location picker opens close in on the player's own position, so the caption and README now say to pinch to zoom out first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
Each network names itself (Network.Name: "signal", "telegram"), the core
reports it as Info.Network, and the mcp feature offers it to addons in the
handshake: experimental["io.github.robdevops.signalbot/addon"] =
{"version": 1, "network": ...}. GeoGuess reads it and words the round's
caption for that network only (Signal's + button, or Telegram's 📎), and
both when the bot offers none.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
Regional cities, coasts, wine regions and the outback across every state and territory, so /geo AU (or GEO_REGIONS=AU) isn't mostly capital-city suburbs: 9 Australian areas become 49. The per-country cap keeps Australia's share of world rounds as it was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
GeoGuess: - GEO_KEEP (e.g. AU): always keep at least one ready photo for each listed region; trimming never drops it, a plain /geo prefers other photos, and a region whose searches keep failing backs off on its own without starving the normal buffer. - GEO_WAIT (default 50s, 5s to 110s) replaces the fixed 10s wait for a photo, with a clearer "still looking" reply. It never waits past the bot's deadline for the call, and a call the bot abandoned starts no round and puts its photo back. signalbot: - chat_commands.<name>.timeout (1s to 2m, default 15s) for direct commands; the example sets 60s for /geo. - Direct calls carry their deadline in the context _meta, and a call the bot gives up on is cancelled with notifications/cancelled. - The typing indicator shows while an addressed message's hooks run for over a second, so a slow command doesn't look ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
GeoGuess now lives in its own repository, with its history, as its own Go module. signalbot keeps the addon support (MCP_CONFIG's addon block, direct commands, watches, the outbox) and its docs, which now link the new repository as the example addon. The arch test's import rule for cmd/geoguess goes with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
Action.OnSent and Post's callback did the same job under two names and shapes, and Post.Done sat next to Action.Done, an unrelated bool. Both are now OnSent func(sent []int64, dropped bool). IsZero no longer counts OnSent: an Action with only OnSent set used to claim the message, stop later hooks and then fall through to the model with OnSent never called. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
- Action.OnSent now keeps Post.OnSent's contract: called exactly once, with dropped set when the answer is never sent (shutdown first, a panic, Done). - A send that fails returns no timestamps and reports dropped, so the addon outbox retries it (at least once; a timed-out send that went out may be posted twice). A labelled post whose send fails is taken back out of history (chats.Store.Withdraw), so retries don't pile up copies. - Stale Done wording from the rename is gone (TECHNICAL.md, featuretest, once(), host tests). - Port docs match the code: the IsZero rule, Info's fields, what joins a mailbox, the type listing, four stages, CONTRIBUTING's port table (OnEvent, OfferTools, Store), React's Timestamp-0 rule. - Reachable logs a neutral reason; PostLow's merge takes the new item. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
The extension's wire format was written twice, once in the mcp feature and once in each addon. It now lives in one public package, github.com/robdevops/signalbot/addon, standard library only: - the types: Context, Watch, Result, Content, Op, Image, Page, Held, Capability and the keys; - a ready MCP 2025-06-18 stdio server for an addon written in Go: tools with visibility, the call context, cancellation, the outbox with its cursor, Queue, Outbox and Restore for saving, and the bot's network. The mcp feature uses the package's types (no behaviour change), and a new test runs the bot against an addon built from the package. The arch test lets features import addon and keeps addon to the standard library. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
From review of the new package: - An outbox page is measured as it is sent (its JSON escaped again inside the resource's text), so it stays under the bot's 4 MiB line, and Queue refuses an op that could never fit or has more than MaxImages images. - Run returns when its context ends, cancels the calls in flight before it waits for them (on stdin's end too), and waits for its notifier. - A result with no content sends an empty array, as MCP requires. - Changed may run concurrently, and Restore comes before any Queue: both documented. The docs no longer say GeoGuess uses the package yet. TestActionPictures read OnSent's slice while the chat's worker wrote it; it now holds a lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
addon/schema.json describes each message of the extension: the capability, a tool's visibility, the call context, the watch and reaction in a result, the outbox page and its post, react and unwatch ops, and the saved outbox entry. A test keeps it in step with the Go types (keys, required keys, types, the version and the image limit), checks samples both ways with a small validator, and checks what a real Server writes; the bot's pseudonyms and refs are checked against its patterns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
- The bot merged posts held in a chat while their pictures fit, then cut the joined text to 4,000 characters, so a later post could lose its end while counting as sent. They now merge only while the texts fit whole too. - schema.json: a post needs non-blank text or at least one image, as the bot drops one with neither; a text block needs its text, as MCP's TextContent does, and addon.Content now always writes it; react is a watch's call's only; the watch's ID and pattern limits are bytes, which maxLength can't check past ASCII. - schema_test.go: every struct in types.go must be checked; the react key and the pseudonym patterns in Op are tied too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
…counts The bot measured a watch's ID (64) and pattern (1,024) in bytes, which JSON Schema's maxLength, counting characters, matches only for ASCII: an accented ID passed the schema and was refused. Both are now counted in characters, as the guard already was, so the schema states the bot's rule exactly in any script. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
- Core: Host.CallAPI works outside a tool when ctx names the chat that pays (feature.ChargeTo): the chat's daily budget is checked and charged. /chat/completions is allowed, always on the bot's own model, with the cost reported on OpenRouter. - mcp: an addon with the new model permission (per_hour, max_tokens) is offered capabilities.sampling and may send sampling/createMessage, charged to a chat it has a lease in; one call at a time, text only, size-capped, logged without content. Requests are served off the reader goroutine; string IDs work; a cancelled or crashed call is still charged. - Reply watches: a watch with replies takes only replies to the addon's own messages sent while it lives, whatever they say; the bot offers watchReplies. - addon package: Server.Sample, CanSample, WatchReplies; the new types in schema.json, kept in step by the drift test. - Docs: addons, privacy, configuration, technical, models. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
…osts - An addon whose <PREFIX>STATE_DIR isn't set gets <state dir>/addons/<name>, which it creates itself. - feature.Post.ReplyTo sends a post as a reply to one of the bot's own earlier messages: a quote on Signal, reply_parameters on Telegram. - An outbox post op's replyTo names an earlier post op of the addon's; the bot remembers 256 of them for 24 hours, in mcp.json. Replies are never merged, and wait for a dropped target. addon.Server.QueueIDs returns the IDs given. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
A post of the addon's with pictures, sent while a watch with a guard lives in its chat, joins the pictures the guard answers replies to, so a game's later rounds are guarded like its first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
feature.Post.Audio is one MP3 clip sent to play, with no title of its
own: on Signal an attachment named clip.mp3, on Telegram a voice
message. Network.Send takes it as its last argument. An addon's post op
may carry it as audio {data, mimeType: audio/mpeg}, at most 2 MB; such a
post is never merged. Schema and docs follow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
A watch with reactions also takes reactions put on, or taken off, the
command's answer and the addon's posts while it lives: each a call of
its tool with {reaction, removed} and the reactor's context, through the
watch worker, as matched messages are. The bot offers watchReactions.
For games whose players join by reacting to the intro.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
A DM is the player's own chat with the bot, so a game there needs no
replies: a plain answer was otherwise sent to the model, which played
along ("Locked in…") while the game never saw it. In a group, a reply
watch still takes only replies to the addon's messages.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
For an hour after a watch ends, by an unwatch, its time or a new watch,
a message to the bot that replies to one of the addon's messages it knew
gets the watch's over text ("That game is over.") instead of the
model's answer, which otherwise played along with late answers. Kept in
memory only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RsqJnxrLp5eK6VJuiCDqCK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extends the MCP addon support so chat games (GeoGuess, quiz, songs) can run as separate addon processes.
io.github.robdevops.signalbot/capabilities, withaddon/schema.json. Limits count characters, not bytes.addonpackage:Server,Sample,CanSample,WatchReplies,WatchReactions,QueueIDs,Restore,Outbox,Changed.over, which answers replies to a finished game for an hour.replyTo; MP3 audio (≤ 2 MB). Signal attaches the audio and Telegram sends it as a voice message.sampling/createMessage): an addon asks the bot's model. It's charged to the chat, and limited by the addon block'smodelpermission.<PREFIX>STATE_DIRof<state dir>/addons/<name>.Post.ReplyToandPost.Audio; Signal quotes; Telegramreply_parametersandsendVoice.go.mod is unchanged, with no new dependencies.
Generated by Claude Code