Skip to content

Feature/chat plugin - #37

Merged
mattvb91 merged 4 commits into
devfrom
feature/chat-plugin
Nov 10, 2026
Merged

mattvb91 merged 4 commits into
devfrom
feature/chat-plugin

Conversation

@mattvb91

Copy link
Copy Markdown
Member

No description provided.

@mattvb91
mattvb91 merged commit e82e511 into dev Nov 10, 2026
2 checks passed
@mattvb91
mattvb91 deleted the feature/chat-plugin branch November 10, 2026 20:56
@mavonengine/chat adds text chat to a multiplayer game. The client entry
puts a chat box on screen, built with plain DOM, and passes what is
typed to the server over the game's connection. The server entry cleans
up what is said, limits its length and rate, keeps muted players quiet
and passes it on to everyone, or with a `range` only to players close
to the sender.

It announces who joins and leaves, sends new clients the recent
messages, and has an admin API to read the chat, announce something and
mute or unmute players. Every message also reaches the game as a
`chat:message` event.

Listed second in plugins.json.
A game server now has a single admin token: `adminToken` in its options,
or MAVONENGINE_ADMIN_TOKEN. Plugins get `ctx.requireAdmin`, a guard for
their admin routes that asks for it as a bearer token and without one
only lets localhost through, and `ctx.adminToken.matches()` to check it
when it arrives another way. They never see the token itself.

The token also reads the metrics endpoints and turns them on in
production; the metrics token stays read-only. The dashboard and
`mavonengine mcp` fall back to it. Routes behind the guard list who may
call them.

The chat plugin drops its own admin token and uses the guard. The
monitoring dashboard logs in with the admin token as the password or as
a bearer token; its htpasswd file stays as an optional login per person,
and its own user and password from the environment are deprecated.
`chat(server)` gives a game's server its say in the chat: `intercept`
runs before a message goes out and can change it, drop it, answer the
sender alone or send it to some players only, and `onMessage` is told
every message after it went out, with who got it. Callbacks can be
registered before the server starts.

`chat(game)` does the same in the browser: listeners for messages,
notices and the history, `send`, and the chat box itself. A game that
shows the chat itself now gets notices and the history too, which only
the built-in box got before.

The chat box takes a `position` option, and the README documents the
hooks and how to style the box.

The hooks live on the global object under a registered symbol, since the
game imports the package by name while the engine loads the plugin by
path, which can be two copies of the module.
`mavonengine mcp` gets three tools. `list_plugins` shows the plugins in
the project's mavonengine.json with the HTTP endpoints each registered.
`available_plugins` lists the official plugins from plugins.json with
what they do, the command that installs them and whether the project
has them, and `plugin_readme` reads one's README, so an assistant can
suggest a plugin and set it up instead of building what one already
does.

The last two read GitHub when they are used. `--plugins-url` or
MAVONENGINE_PLUGINS_URL points them at another list, `--no-plugin-list`
leaves them out. Everything stays read-only: installing is for the user.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant