npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mqtt-bash-exec-channel

v0.2.0

Published

Lightweight Ubuntu-friendly CLI that listens on MQTT, executes bash commands, and publishes results.

Readme

mqtt-bash-exec-channel

A lightweight CLI for Ubuntu 22+ that:

  • connects to an MQTT broker
  • subscribes to a request topic
  • executes bash commands
  • publishes command output to a response topic

It runs in the foreground after you start it.

Requirements

  • Node.js 18+
  • Ubuntu 22.04 or newer
  • /bin/bash

Install

npm install

Or install it globally:

npm install -g .

Environment variables

Required:

export BASH_EXEC_CHANNEL_MQTT_BROKER_URL='mqtts://example.ala.cn-hangzhou.emqxsl.cn:8883'
export BASH_EXEC_CHANNEL_MQTT_USERNAME='xxx'
export BASH_EXEC_CHANNEL_MQTT_PASSWORD='xxx'
export BASH_EXEC_CHANNEL_REQUEST_TOPIC='agents/admin/req'
export BASH_EXEC_CHANNEL_RESPONSE_TOPIC='agents/admin/res'

Optional:

export BASH_EXEC_CHANNEL_MQTT_CLIENT_ID='bash-exec-channel-custom'
export BASH_EXEC_CHANNEL_COMMAND_TIMEOUT_MS='300000'
export BASH_EXEC_CHANNEL_MAX_OUTPUT_BYTES='1048576'
export BASH_EXEC_CHANNEL_SHELL='/bin/bash'

If BASH_EXEC_CHANNEL_MQTT_CLIENT_ID is not set, each process start generates a random id like bash-exec-channel-<uuid>.

Run

From the repo:

npm start

Or as a CLI:

mqtt-bash-exec-channel

Testing

Run the fast local test suite:

npm test

Or:

npm run test:fast

This suite only checks local logic and does not require an MQTT broker.

Run the end-to-end smoke suite against a real MQTT broker:

node tests/smoke.test.js \
  --broker-url mqtt://172.16.12.2:1883 \
  --username huozige \
  --password xA123456

Or use environment variables:

export MQTT_TEST_BROKER_URL='mqtt://172.16.12.2:1883'
export MQTT_TEST_USERNAME='huozige'
export MQTT_TEST_PASSWORD='xA123456'
node tests/smoke.test.js

Optional smoke test settings:

  • --timeout or MQTT_TEST_TIMEOUT_MS
  • --max-output-bytes or MQTT_TEST_MAX_OUTPUT_BYTES

Request payload

Publish this JSON to BASH_EXEC_CHANNEL_REQUEST_TOPIC:

{
  "input": "openclaw agents list",
  "cwd": "~/",
  "threadId": "b-12345"
}

Fields:

  • input: command string to execute
  • cwd: working directory, supports ~/
  • threadId: correlation id returned in the response

Response payload

Published to BASH_EXEC_CHANNEL_RESPONSE_TOPIC:

{
  "threadId": "b-12345",
  "output": "xxxxxxx"
}

Behavior

  • commands run through /bin/bash by default on Ubuntu
  • received commands are executed strictly one at a time, in arrival order
  • stdout and stderr are combined into output
  • if the command fails, exit information is appended
  • if cwd does not exist, it falls back to the current user's home directory
  • output is truncated when it exceeds the configured limit
  • invalid JSON or requests without threadId are ignored
  • if MQTT is unavailable, the CLI retries every 30 seconds
  • if required environment variables are missing, the CLI exits immediately and prints the reason