Skip to content

feat: command plugin/extension system (registerCommand API) #496

@cpfiffer

Description

@cpfiffer

Summary

Add a registerCommand(name, handler) API that lets local deployments add custom commands without modifying core files.

Motivation

Community user (bibbs) added a runtime /config command to adjust jitter, debounce, and heartbeat settings without restarting their 3 Raspberry Pi instances. This requires patching bot.ts and commands.ts on every upstream rebase.

More broadly, any deployment-specific command (debug tools, status checks, integration triggers) currently requires forking core files. A plugin API would eliminate this friction for all downstream users.

Current Workaround

  • Add 'config' to the COMMANDS array in commands.ts
  • Add case 'config' in handleCommand in bot.ts
  • Parse subcommands (jitter, debounce, heartbeat) and modify in-memory settings
  • Also added reschedule(intervalMinutes) and getIntervalMinutes() to HeartbeatService for runtime heartbeat adjustment

Proposed API

// In a plugin file or config-referenced module
export default function register(bot: LettaBot) {
  bot.registerCommand('config', async (args, context) => {
    // handle subcommands
  });
}

Or config-driven:

features:
  commands:
    - name: config
      module: ./plugins/config-command.ts

Implementation Considerations

  • Commands currently live in a static COMMANDS array and a switch statement in handleCommand
  • Plugin commands would need access to bot internals (config values, services like HeartbeatService)
  • Should validate no collisions with built-in commands
  • The heartbeat reschedule() method is independently useful and could ship as a built-in /heartbeat interval <N> subcommand regardless of the plugin system

Context

This is one of 5 issues filed from a community user's multi-bot deployment feedback.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions