DeepSeek Harness Message Center Plugin: Managing DSH Inbound and Outbound Message Channels

Preface

When building agents based on DeepSeek Harness (DSH), integrating external channels (such as QQ, Telegram, or email) typically requires writing extensive protocol adaptation code and is difficult to manage uniformly. dsh-message-hub, as a transit plugin, provides a transport-agnostic communication center. It decouples inbound and outbound logic through a unified “channel registry”: host plugins handle specific protocol implementations (e.g., connecting to QQ), while the Hub manages routing, binding states, and interaction with the Agent.

This plugin is maintained by FuLuTang and is released under the MIT license.

Core Features

This plugin primarily addresses the unified access and routing of multi-channel messages, with core capabilities including:

  • Channel Registry: Provides registration interfaces for inbound and outbound, supporting Web API integration.
  • Fixed Agent Tools: Provides fixed tools such as message_hub_list_channels, send, bind, and status to facilitate channel querying and management by the Agent.
  • Wakeup Modes: Supports two modes, steer (interject) and followup (queue), to control how external messages enter the Agent context.
  • File Adapter: Built-in file-spool adapter, supporting inter-process communication via shared directories or Docker Volumes.

Installation and Activation

Ensure the environment meets the Node.js version requirement (>=22) before installation.

  1. Use the official plugin installer to add the plugin to the Web profile:
    dsh plugin --profile web add github:FuLuTang/dsh-message-hub
  1. Restart the DSH Web service after installation and force refresh the browser page (to load the new client bundle).

Configuration

Declare the plugin instance in the DSH YAML configuration. channels is only used for declaring metadata and initial toggles; actual runtime implementations are registered by trusted plugin code.

- id: dsh-message-hub
  config:
    storagePath: ''                 # Defaults to $DSH_HOME/message-hub/state.json
    maxLedgerEntries: 2000
    wakeupMode: steer               # Global default wakeup mode: steer=interject / followup=queue
    channels: []                    # Declarative channel metadata
    spools: []                      # file-spool configuration
    outlets: []                     # file-spool outbound routing

Channel Registry

In the DSH runtime, access messageHub through the Agent’s ctx to perform registration.

Registering Inbound and Outbound

// Register inbound: receive messages
await ctx.messageHub.registerIngress({
  id: 'telegram-in',
  name: 'Telegram Inbound',
  description: 'Receive Telegram updates',
  template: 'From {{sender}}: {{text}}',
  wakeup: true,
  setEnabled: async (enabled) => { /* Start/stop transport implementation */ }
});

// Register outbound: send messages
await ctx.messageHub.registerEgress({
  id: 'telegram-out',
  name: 'Telegram Outbound',
  description: 'Send a Telegram message',
  schema: { type: 'object', required: ['chatId', 'text'] },
  setEnabled: async (enabled) => { /* Start/stop transport implementation */ },
  async invoke(args, { deliveryId, sessionId }) {
    return { success: true, message: 'sent' }
  }
});

Status and Toggles

Each channel maintains two states:
* desiredEnabled: The toggle required by the user via Web API or configuration.
* light: The running status light reported by the implementation (black, yellow, green).

Agent Tools

The plugin provides a set of fixed tools for the Agent to query and manage channels:

Tool Name Parameters Purpose
message_hub_list_channels None Lists channel IDs, directions, toggles, status lights, and details.
message_hub_describe_channels channelIds?: string[] Queries descriptions and parameter Schemas for specified channels (defaults to querying all egress).
message_hub_send channelId, arguments Validates arguments and calls egress to send messages.
message_hub_bind / unbind channelId, sessionId Binds or unbinds the current conversation to legacy adapters.
message_hub_status None Views the complete snapshot (including channels, bindings, and delivery records).
message_hub_read_input None Reads UTF-8 files from the file-spool input/ directory (max 64 KiB).

Inbound Binding and Wakeup Modes

Binding Process

Bind inbound messages to a specific DSH session via bindIngress(channelId, sessionId, options).

Binding configuration supports:
* template: Overrides the default message template.
* wakeup: Whether to wake the Agent after injecting the message (enabled by default).
* wakeupMode: Overrides global settings. In steer mode, messages interject as next-step input; in followup mode, messages are queued for the next independent turn.
* cwd: Replaces the session working directory.

Delivery Semantics

When emitIngress(channelId, event) is triggered, the Hub performs the following steps:
1. Checks toggles and binding status.
2. Resolves the target session. If the session is unavailable and the binding includes cwd, the Hub creates a replacement session; otherwise, it retains the failure result.
3. Injects two messages into the Agent: an untrusted external context description and the rendered <external-message> content.
4. Wakes the Agent according to wakeupMode (legacy runtimes automatically downgrade to followup if steer() is not supported).

Web API and Client

When the Web runtime is enabled, the plugin registers the local prefix /message-hub/api, accepting only trusted localhost requests.

  • POST /message-hub/api/snapshot: Gets the channel snapshot (including defaultWakeupMode).
  • POST /message-hub/api/toggle: Modifies the desiredEnabled of a channel.
  • POST /message-hub/api/bind: Binds an ingress or file-spool to a session.

The Web client automatically displays the “Message Channels” card in the settings interface, refreshing the status every 5 seconds to show channel direction, polling lights (green=polling, yellow=failed, black=stopped), and binding information.

File-spool Adapter

For scenarios requiring shared directories or cross-language script communication, you can use the built-in file-spool adapter. It is not part of the channel registry but functions as an independent input/output channel.

Configuration Example

spools:
  - id: volume-main
    label: 共享目录
    root: /mnt/message-device
    enabled: true
    ackMode: delete       # delete | keep
    pollMs: 1000
    maxBytes: 262144
    payloadFile: input/message.json
    payloadFormat: json
outlets:
  - id: panel-notify
    spoolId: volume-main
    endpointId: panel
    enabled: true

Directory Layout

  • root/: Root directory.
    • input/message.json: Inbound trigger file.
    • output/: Outbound delivery directory.
      • .tmp/: Temporary files.
      • ack/: Confirmation files written back by external programs.
    • .message-hub/processed/: Processed trigger files.
    • status.json: Optional endpoint status snapshot.

Behavior Description

  • Inbound: Polls for trigger files under root (excluding special directories). After successfully enqueuing to the bound session, moves or retains the file based on ackMode.
  • Outbound: Writes to output/<deliveryId>.json. External programs should confirm the sending result in output/ack/<deliveryId>.ack.json.
  • Polling Light: The light on the panel only reflects the polling status of the current process and does not modify the configuration file.

Notes

  1. Single Instance Limitation: Only one Hub instance can run under the same storagePath.
  2. Protocol Implementation: The Hub itself does not implement protocols like QQ or Telegram; it only registers them. Specific connection logic is handled by host plugins.
  3. Package Format: Must use the dsh plugin installation command to ensure the package is correctly added to the profile’s bundle list; a simple npm install will not work.
  4. Node Version: Minimum requirement is Node.js 22.

Summary

dsh-message-hub provides a standardized communication interface for DeepSeek Harness. Developers can integrate any protocol into the Agent ecosystem by registering Ingress and Egress, utilizing fixed Agent tools or Web APIs for management. Combined with the file-spool adapter, it can easily achieve file exchange with external scripts or systems.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye