Skip to content

About

Plugins for LuckyBot (莱克): group-chat mini-games and other optional modules

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

LuckyBot Plugin

This repository provides optional modular plugins for LuckyBot.

Core acts as the host providing strictly scoped capabilities (model invocation, bounded choice asking, HTTP routing, chat publishing, scoped storage, and logging). Plugins are declared statically and mount inside the LuckyBot core as a Git submodule at plugins/. For the complete normative specification, see LuckyBot Plugin Specification (docs/plugins.md).

Architecture & Principles

  • No host internals exposed: Plugins never receive the DI container, database connections, platform clients, or chat context.
  • Privacy invariant: Private data (e.g. card hands, internal secrets) stays in the plugin memory/storage and never enters the chat context or prompt history. Only public events are pushed via ctx.capabilities.chat.publish.
  • Default-off: Plugins and game tables are disabled by default until enabled in deployment configuration.

Layout

src/
├── sdk/              Plugin SDK contract and type definitions
├── tavern/           Tavern webhook protocol (HMAC verification, routing, dedupe, scenes)
├── web/              Web search & fetch plugin (tavily, exa, jina, microsoft grounding)
├── musicgo/          MusicGo listening-room tools (queue, now playing, retract, vote)
├── redact/           Secret redaction for model-bound text (rules ported from magpie, MIT)
├── games/
│   ├── types.ts      Game module interface (choices path + legacy actions)
│   ├── liars-bar/    Liar's Bar logic (classic/devil/chaos, fallback, events, notes)
│   └── bullet-poker/ Bullet Poker logic (options, swap/pick, fallback, events, notes)
└── index.ts          Static plugin registry export

Included Plugins

1. Web Tools (web)

Contributes web_search and web_fetch primary tools via the tools extension point. Supports pluggable search backends (Tavily, Exa, Jina, Microsoft Grounding) and clean Markdown web page fetching (Jina Reader). Configured under plugins.web and enabled per-chat under chats.<id>.plugins.web.enabled.

2. Tavern & Games (tavern)

The repository includes the tavern plugin implementing the dealer webhook protocol (OpenAPI v1), the liars_bar and bullet_poker game modules, and the table scene override (contributes.scenes). See src/games/README.md for deployment and maintenance notes.

  • Invitations: Configured via plugins.tavern.invitation: { decide: 'ask' | 'always', timeoutMs: 8000, onTimeout: 'accept' | 'decline' }. In decide: 'ask' mode, the bot uses the core ask capability to decide in-character whether to accept table invitations based on persona, waiting players, and recent chat context. Per-game modes allowlists can decline specific modes (e.g. games.liars_bar.modes: [classic, devil]).
  • Decisions: The dealer's generic ask / prompt / rules / choices path is primary; the legacy per-game action shape is used only when choices is absent. Budget is min(decisionTimeoutMs, deadline_ms - 3000), default 40000 ms.
  • Dealer Commands: Prompt hints instruct the bot to never post dealer commands starting with ! (e.g. !加入, !开始) into the group; seats are offered by the dealer, and the bot does not sign up itself. It also avoids 入座/上桌/加入 in table chat because the dealer seats bots that say those words during sign-up.

3. Redact (redact)

Contributes redactText (and the shadow companion inspectText) so core strips API keys, tokens, private keys, URL/connection-string passwords, secret assignments, seed phrases, bank cards and CN resident IDs from everything sent to a model. Configured under plugins.redact.mode (off | shadow | enforce, default off). Spans such as Feishu ids, message aliases, UUIDs, git SHAs and chatlog tag attributes are protected and never changed. The rules are derived from magpie; see NOTICE.

4. MusicGo (musicgo)

Lets the bot act as its own MusicGo agent account in the listening room bound to a chat: check what is playing and the pending queue, search tracks, queue a song (optionally on behalf of a person), retract its own pending songs, and vote to skip. It talks only to the MusicGo /v1 HTTP API and holds no room state of its own; every answer comes from the server. Configured under plugins.musicgo and enabled per chat under chats.<id>.plugins.musicgo.enabled (default false).

plugins:
  musicgo:
    server_url: "http://127.0.0.1:8870"   # or export MUSICGO_SERVER_URL
    # token: set an agent (kind=agent) mgt_* token here,
    # or leave it out and export MUSICGO_TOKEN
    timeout_ms: 3000                      # each tool call is bounded (100..30000)
    search_timeout_ms: 5000               # searches may take a little longer
    binding_provider: feishu              # provider name used in room bindings
    room_cache_ttl_seconds: 60            # chat -> room lookup cache
    # search_source: youtube              # default for musicgo_search; unset = first source the server has enabled
    chat_rooms:                           # optional static chat -> room map
      oc_example_group: r_example
    # default_room_id: r_single_room       # optional fallback for any chat

chats:
  default:
    plugins:
      musicgo:
        enabled: false                    # default-off
  oc_example_group:
    plugins:
      musicgo:
        enabled: true
        # room_id: r_other                # optional per-chat room override

Create the agent account on the MusicGo server with musicgo admin create-user --kind agent --name luckybot; the printed token is shown once and only stored as a hash server-side.

Before enabling the plugin, make that agent a member of the room(s) it should serve. The plugin resolves a chat's room through GET /v1/rooms and GET /v1/rooms/{id}/bindings, and the room endpoints (including the snapshot the tools read) are member-only. A non-member agent gets 403 forbidden, so the tools would keep reporting that the chat is not bound (or not permitted) even when a binding or chat_rooms entry exists. Ask the room owner for an invite code and join once with the agent token:

MUSICGO_SERVER="http://127.0.0.1:8870" MUSICGO_TOKEN="<agent token>" \
  musicgo room join --room r_example --code "<invite code>"

The command reads MUSICGO_SERVER (default http://127.0.0.1:8870) and MUSICGO_TOKEN (or --server / --token). already_member=true means the agent is already in the room, so repeating the command is safe. A static chat_rooms mapping does not replace this step: the agent still needs membership to read the room.

Tool Meaning
musicgo_now_playing() Room status (with queue_version and the current DJs), current track (title, artist, elapsed/total, who queued it, whether it is the bot's), skip-vote progress and the first 10 pending entries with their entry ids. One GET /v1/rooms/{id} snapshot.
musicgo_search({ query | queries, source? }) Up to 5 tracks per query with source and track_id, for when someone names a song instead of pasting a link. queries looks up to 10 songs in one call (POST /v1/tracks/search/batch, MusicGo 0.4+).
musicgo_enqueue({ url | source + track_id, on_behalf_of? }) Queues a song as the agent. on_behalf_of (a u_... id) is display-only and grants nothing. The room's agent pending limit (default 2) and duplicate checks still apply.
musicgo_retract({ entry_id }) Removes one of the agent's own pending songs; retracting another member's entry or the song already playing is refused by the server.
musicgo_edit_queue({ ops, if_queue_version?, dry_run? }) Adds, removes and reorders several songs in one all-or-nothing batch (POST /v1/rooms/{id}/queue/batch, MusicGo 0.4+). A rejected batch returns each op's reason. When a room owner or admin makes the bot DJ, adds can carry a set label to form a segment that nobody else's request can land inside. The same limits apply: no touching other people's songs.
musicgo_vote_skip({ entry_id }) Votes to skip the current track. The server accepts an agent vote but reports counted: false; the tool result says so explicitly, because an AI vote does not count toward the human skip threshold.

Room resolution. A tool never takes a room from the model. The room is resolved, in order, from the per-chat room_id, the static chat_rooms map, default_room_id, or a MusicGo room binding whose provider matches binding_provider and whose external id equals the chat id (looked up through GET /v1/rooms + GET /v1/rooms/{id}/bindings, cached for room_cache_ttl_seconds). A room_id argument that names a different room is refused, so one chat can never act on another chat's room. An unbound chat gets a clear message asking a room owner/admin to bind it.

Safety and cost. The plugin stays completely inactive when no token is configured (or when plugins.musicgo.enabled: false). The token is read from config or MUSICGO_TOKEN, sent only in the Authorization header, and never put in a URL, tool result or log: the host registers config keys matching secret|token|apikey|password as HTTP secrets, and the plugin additionally redacts the token from every tool result and wrapped HTTP error. Queue writes carry a unique Idempotency-Key; calls time out after 3 s (5 s for search); results are trimmed to 10 queue entries / 5 search results, and history, invite codes and member lists never leave the plugin.

Reverse Proxy & Path Notice

The Tavern HMAC signature covers the exact request method, path, and raw body: HMAC_SHA256(secret, "${timestamp}.${METHOD}.${path}.${rawBody}"). When exposing the webhook via a reverse proxy or tunnel (such as Cloudflare Tunnel, Nginx, or frp), the proxy must pass the request path through without rewriting or altering prefixes, or the HMAC signature check will fail with HTTP 401.

License

MIT

About

Plugins for LuckyBot (莱克): group-chat mini-games and other optional modules

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages