Preface

The core idea of DeepSeek Harness (DSH) is “everything is a plugin.” When accessing an agent through an instant messaging channel, developers often need to set up additional Web services or configure HTTP Webhooks. The @blue/dsh-telegram-bot plugin introduced below is a single-purpose plugin that uses long polling to connect a Telegram bot directly to a DSH agent, removing the need for public endpoint configuration and external service dependencies.

Plugin Information

  • Name: @blue/dsh-telegram-bot
  • Maintainer: Blue-2571
  • License: MIT
  • Positioning: A single-purpose DSH plugin that uses long polling to connect a Telegram bot to your dsh agent.

Core Features

  • Long-polling connection: Does not rely on Webhooks; uses long polling to maintain the connection.
  • Session management: One chat maps to one agent (identified as telegram:<chatId>), supporting multi-turn dialogue context.
  • Tool mounting: Supports mounting Agent presets to bot sessions, giving them the same tools as the Web interface (such as bash, fs, ssh).
  • Permission control: Whitelist access control via allowedUserIds.
  • Command support: Supports Slack-style commands such as /help, /reset, /status, /model.
  • Message handling: Long replies are automatically split (respecting Telegram’s 4096-character limit), and idle sessions are automatically cleaned up based on timeout configuration.

Installation and Enablement

Install the plugin:

dsh plugin --profile web add @blue/dsh-telegram-bot

After installation, the plugin is disabled by default. Enable and configure it in cordis.patch.yml:

- id: dsh-telegram-bot
  disabled: false
  config:
    telegram:
      token: '123456:ABC-DEF...'   # 从 @BotFather 获取的 Token
      allowedUserIds: [6354114195] # 你的数字 Telegram 用户 ID
    agent:
      preset: standard             # 挂载标准预设以获取完整工具

Save the file, then restart the Web Profile (dsh web).

Configuration Options

Configuration Default Description
enabled true Main switch.
telegram.token '' Bot Token, obtained from @BotFather.
telegram.allowedUserIds [] List of user IDs (numeric) allowed to interact. If it is an empty array, anyone who has the Token can operate it.
telegram.timeoutSeconds 50 Timeout for getUpdates long polling.
telegram.pollIntervalMs 500 Interval after polling timeout or error.
agent.cwd '' Working directory for the agent session (defaults to dsh’s cwd).
agent.provider / agent.model '' Override model selection; leave empty to use deployment defaults.
agent.preset '' Agent preset ID to mount (leave empty to use deployment defaults).
agent.maxMessageLength 4000 Maximum number of characters per output message.
agent.idleTimeoutMs 1800000 Session idle timeout (milliseconds); 0 means never clean up.
agent.instructionPrefix '' Prefix for every user message.

Available Commands

  • /help: Displays command help information.
  • /reset: Clears the current chat context and resets the agent.
  • /status: Displays the status of the current active chat/agent.
  • /model: Displays the currently selected model.

Security and Notes

  • Disabled by default: After installation, you must manually enable it in cordis.patch.yml.
  • Whitelist required: If allowedUserIds is an empty array, anyone who has the Token can execute tools (including bash, fs, etc.), which is risky in production environments.
  • Token protection: cordis.patch.yml contains a sensitive Bot Token. Make sure the file permissions are private, or reference it via an environment variable (for example, !!js process.env.TG_BOT_TOKEN).
  • Length limits: Long replies will be truncated by Telegram’s 4096-character limit.

Use Cases

  • Developers who need to work with DSH via command-line or file-system tools in Telegram.
  • Scenarios where you want to avoid deploying a Webhook service and drive IM interaction directly through an existing DSH process.