You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@cmdop/bot

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cmdop/bot

CMDOP multi-channel bot integrations — Telegram, Discord, Slack, Teams, and more

latest
Source
npmnpm
Version
2026.3.1002
Version published
Maintainers
1
Created
Source

@cmdop/bot

CMDOP Bot

Multi-channel bot framework for CMDOP — run /exec, /agent, /skills, and /files commands from Telegram, Discord, and Slack.

pnpm add @cmdop/bot

Quick start

import { IntegrationHub } from '@cmdop/bot';

const hub = await IntegrationHub.create({
  apiKey: process.env.CMDOP_API_KEY,
});

await hub.addTelegram({ token: process.env.TELEGRAM_TOKEN });
await hub.start();

That's it. Your bot now responds to /exec, /agent, /skills, /files, and /help.

Platform setup

Telegram

pnpm add grammy @grammyjs/transformer-throttler
await hub.addTelegram({ token: 'YOUR_BOT_TOKEN' });

Get a token from @BotFather.

Discord

pnpm add discord.js @discordjs/rest @discordjs/builders
await hub.addDiscord({
  token: 'YOUR_BOT_TOKEN',
  clientId: 'YOUR_APPLICATION_ID',
  guildId: 'OPTIONAL_GUILD_ID', // omit for global slash commands
});

Get tokens from the Discord Developer Portal.

Slack

pnpm add @slack/bolt @slack/web-api
await hub.addSlack({
  token: 'xoxb-YOUR-BOT-TOKEN',
  appToken: 'xapp-YOUR-APP-TOKEN',
});

Requires Socket Mode enabled in your Slack app settings. See examples/slack.ts for full setup.

Commands

CommandUsageRequired permission
/exec/exec <shell command>EXECUTE
/agent/agent <prompt>EXECUTE
/skills/skills list | show <name> | run <name> <prompt>EXECUTE
/files/files [read] <path>READ
/help/helpnone

Commands use a / or ! prefix. Example: /exec ls -la, !agent list running processes.

Permissions

Users default to NONE (no access). Grant levels programmatically:

const hub = await IntegrationHub.create({
  adminUsers: ['telegram:123456789'], // always ADMIN
});

// Grant a specific user READ access
await hub.permissions.setLevel('telegram:987654321', 'READ');

Permission levels (ordered, each includes all levels below):

LevelAccess
NONENo commands (only /help)
READ/files
EXECUTE/exec, /agent, /skills
FILES(reserved for future write operations)
ADMINAll commands

Cross-channel identity

Link a Telegram user to their Discord account so permissions apply on both platforms:

hub.linkIdentities('telegram', '12345', 'discord', '67890');

// Now granting EXECUTE to either ID applies to both
await hub.permissions.setLevel('telegram:12345', 'EXECUTE');

Hub options

const hub = await IntegrationHub.create({
  // CMDOP connection
  apiKey: 'cmdop_live_xxx',    // cloud; omit for local IPC
  defaultMachine: 'my-server', // pre-select a machine

  // Permissions
  adminUsers: ['telegram:123'],
  permissionStore: myRedisStore, // custom store (see PermissionStoreProtocol)

  // Startup behaviour
  channelStartMode: 'isolated', // 'isolated' (default) | 'strict'
  // 'isolated' — a failing channel is logged; others continue
  // 'strict'   — any channel failure throws and aborts hub.start()

  // Logging
  logger: myLogger, // any { info, warn, error, debug } object
});

Custom handlers

Register a handler for a new command:

import { BaseHandler, ok, err, CommandArgsError } from '@cmdop/bot';
import type { CommandContext, HandlerResult, LoggerProtocol } from '@cmdop/bot';
import type { CMDOPClient } from '@cmdop/node';

class PingHandler extends BaseHandler {
  readonly name = 'ping';
  readonly description = 'Check if the bot is alive';
  readonly usage = '/ping';
  readonly requiredPermission = 'NONE' as const;

  async handle(_ctx: CommandContext): Promise<HandlerResult> {
    return ok({ type: 'text', text: 'pong 🏓' });
  }
}

hub.registerHandler(new PingHandler(hub.cmdop, logger));

Custom channels

Implement ChannelProtocol (or extend BaseChannel) to add any messaging platform:

import { BaseChannel } from '@cmdop/bot';

class MyChannel extends BaseChannel {
  constructor(permissions, dispatcher, logger) {
    super('my-channel', 'My Platform', permissions, dispatcher, logger);
  }

  async start() {
    // connect to platform, register event listeners
    myPlatform.on('message', async (msg) => {
      await this.processMessage({
        id: msg.id,
        userId: msg.authorId,
        channelId: this.id,
        text: msg.text,
        timestamp: new Date(),
        attachments: [],
      });
    });
  }

  async stop() { await myPlatform.disconnect(); }

  async send(userId: string, message: OutgoingMessage) {
    // format and send message to platform
  }

  onMessage(handler) { /* store handler for hub use */ }
}

hub.registerChannel(new MyChannel(hub.permissions, /* dispatcher */, logger));

See examples/custom-channel.ts for a complete working example.

Multi-channel hub

const hub = await IntegrationHub.create({ apiKey: '...', channelStartMode: 'isolated' });

await hub.addTelegram({ token: process.env.TELEGRAM_TOKEN });
await hub.addDiscord({ token: process.env.DISCORD_TOKEN, clientId: process.env.DISCORD_CLIENT_ID });
await hub.addSlack({ token: process.env.SLACK_BOT_TOKEN, appToken: process.env.SLACK_APP_TOKEN });

await hub.start();

console.log(`Running: ${hub.runningChannelIds.join(', ')}`);
console.log(`Failed:  ${hub.failedChannelIds.join(', ')}`);

Graceful shutdown

async function shutdown() {
  await hub.stop(); // stops all channels, closes CMDOP client
  process.exit(0);
}

process.once('SIGINT', shutdown);
process.once('SIGTERM', shutdown);

Error handling

All errors extend BotError and expose a code string:

ClassCodeWhen
PermissionDeniedErrorPERMISSION_DENIEDUser lacks required level
CommandNotFoundErrorCOMMAND_NOT_FOUNDUnknown command
CommandArgsErrorCOMMAND_ARGSInvalid arguments
CMDOPErrorCMDOP_ERRORCMDOP client failure
MachineNotFoundErrorMACHINE_NOT_FOUNDMachine hostname unknown
MachineOfflineErrorMACHINE_OFFLINENo active session on machine
ConfigErrorCONFIG_ERRORMissing / invalid configuration

Environment variables

VariableDescription
CMDOP_API_KEYCMDOP cloud API key (omit for local IPC)
CMDOP_MACHINEDefault machine hostname
BOT_LOG_LEVELdebug | info | warn | error (default: info)
BOT_MAX_OUTPUTMax characters returned by /exec (default: 4000)
TELEGRAM_TOKENTelegram bot token
DISCORD_TOKENDiscord bot token
DISCORD_CLIENT_IDDiscord application ID
SLACK_BOT_TOKENSlack bot OAuth token (xoxb-...)
SLACK_APP_TOKENSlack app-level token for Socket Mode (xapp-...)

Requirements

  • Node.js ≥ 20
  • @cmdop/node (peer dependency, installed automatically)
  • Platform libraries are optional peer dependencies — install only what you use

License

MIT

Keywords

cmdop

FAQs

Package last updated on 10 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts