Jakub Zych 24eadf6208 feat: plugin.yaml manifest for the SummerCMS marketplace
- plugin.yaml generated by summer plugin:manifest (README name kept)
- TestPluginManifest guards it with kiosk.CheckT
- require SummerCMS v0.6.0, the framework minimum in plugin.yaml
- require sm-chat-plugin v0.1.3 instead of v0.0.0, so plugin.yaml carries a released minimum (raises sm-user-plugin to v0.1.2, which chat v0.1.3 requires)
2026-10-30 15:06:09 +01:00

Chat bots

A compiled slash-command plugin for SummerCMS: a host-registered command catalog, JWT-actor dispatch, and a deny-all bot-auth seam.

import _ "git.golem15.com/golem15/sm-chatbots-plugin"

Name: Bots on the shore; slash commands stay after the tide.

Module git.golem15.com/golem15/sm-chatbots-plugin, package chatbots, plugin ID golem15.chatbots, requires golem15.chat and golem15.user. Display name Chat bots / Boty czatu.

Overview

The plugin ports the WinterCMS Golem15.ChatBots plugin. Hosts register slash commands on classes.Registry; classes.Dispatcher parses a trigger from {input} and runs the command as the authenticated actor. The invoker id always comes from the JWT, never from the request body.

Table (PHP names, one idempotent baseline migration 202610180001_create_golem15_chatbots_baseline, every statement IF NOT EXISTS):

  • golem15_chatbots_bot_flags: per-user is_bot display flag (models.BotFlag), unique on user_id (chatbots_bot_flags_user_unique).

Production Boot registers only /help via RegisterBuiltin. Hosts call Registry.Register for their own commands; Register rejects the reserved trigger help and duplicates.

The generic JSON API is chatbots.APIPrefix (/_chatbots/api/v1). Routes sit behind jwt.auth and the named bucket chatbots-api (120/min). The app mounts that guard; this plugin only names it. Frontend users only.

Features

  • SlashCommand registry. classes.Registry.Register rejects reserved help and duplicates. RegisterBuiltin skips the reserved check and installs HelpCommand.
  • Dispatcher. Dispatcher.Dispatch(input, actor, ctx) parses the trigger; unrecognized input, or a command not IsAvailable for the actor, returns nil (fall through). Modes ephemeral and announce.
  • Deny-all BotAuthResolver. classes.DenyAll Resolve returns no user and IsElevated is false. Plugin.SetBotAuthResolver installs the host; nil becomes DenyAll. Boot Warns while the default remains.
  • HTTP API. GET /commands lists commands IsAvailable for the JWT actor. POST /dispatch body {input} runs the command as that actor; a command not IsAvailable for the JWT actor is refused with the same 422 unknown_command as an unknown trigger. The generic API stays jwt.auth for humans; a host may later resolve a bot bearer through SetBotAuthResolver. Deny-all means there is no bot principal until the host installs one.
  • Chat and User only. Requires() is golem15.chat and golem15.user. The AI plugin is not a dependency.
  • GDPR. Boot Listens user.Deleting (DeletingEvent) and deletes golem15_chatbots_bot_flags for that user_id inside ev.Tx.

Usage

Look the registry up after Boot and register a host command:

reg, _ := app.Lookup[*classes.Registry]()
err := reg.Register(ping) // contracts.SlashCommand; reserved help is rejected

Install a bot-auth resolver from an application plugin after looking the plugin up (chatbots publishes it at Boot):

func (p *Plugin) Boot(app *backpack.App) error {
	bots, _ := app.Lookup[*chatbots.Plugin]()
	bots.SetBotAuthResolver(p.resolver) // contracts.BotAuthResolver
	return nil
}

Register is the host path and still rejects reserved help plus duplicates. RegisterBuiltin is the built-in escape hatch: it skips the reserved check so /help can own that trigger. Dispatch always uses the JWT actor; a forged user_id in the body is ignored.

A blog or acme host that only needs /help leaves the registry as Boot installed it. The plugin requires Chat and User only.

The generic JSON API is chatbots.APIPrefix (/_chatbots/api/v1). Published paths:

  • GET /commands
  • POST /dispatch ({input})

API reference

Identifier Description
chatbots.PluginID golem15.chatbots
chatbots.APIPrefix /_chatbots/api/v1
chatbots.APIBucket Throttle bucket chatbots-api (120/min)
contracts.SlashCommand Trigger, Description, IsAvailable, Handle
contracts.BotAuthResolver Host bot-bearer seam; default deny-all
classes.DenyAll Default resolver; Resolve empty, IsElevated false
classes.Registry Slash-command registry
classes.NewRegistry Empty registry
classes.Registry.Register Rejects reserved help and duplicates
classes.Registry.RegisterBuiltin Skips the reserved check (built-in help)
classes.ReservedHelp Reserved trigger help
classes.Dispatcher Parses input and runs Handle as actor
classes.NewDispatcher Builds a dispatcher over a registry
classes.Dispatcher.Dispatch Unrecognized or unavailable trigger returns nil
classes.CommandResult Mode ephemeral or announce plus payload
classes.Ephemeral Invoker-only result; no chat insert
classes.Announce Persist one chat TYPE_SYSTEM message
classes.HelpCommand Built-in /help catalog
chatbots.Plugin.SetBotAuthResolver Host setter; nil becomes DenyAll
models.BotFlag Row of golem15_chatbots_bot_flags

Dependencies

  • golem15.chat (required)
  • golem15.user (required)
  • SummerCMS modules: backpack, party, pact, lagoon, surf, bouncer, wire

Testing

go vet ./...
go test -short ./...
go test -run '^TestHTTPTracer$' -v .

The proof host is golem15.user + golem15.chat + golem15.chatbots + a test-only teams fixture that registers /ping. TestFixtureAbsentFromProduction keeps the fixture id and retired tokens out of production sources. TestHTTPTracer needs Docker. TestNoGolem greps production sources for the AI plugin module.

Description
Slash-command registry and dispatcher over chat, with a deny-all bot-auth seam
Readme 126 KiB
Languages
Go 100%