dsh-agent-chat: Cross-Machine Messaging and Context Injection for DSH Agents on Two Machines

The DSH agent is not a resident process; it only runs when a message is received. This makes it cumbersome to pass context across multiple machines. The dsh-agent-chat plugin provides an HTTP-based, turn-injection cross-machine messaging channel, allowing DSH agents on two machines to exchange messages and have unread messages stitched into the context at the start of a turn.

Plugin Introduction

This is a DSH host plugin (web profile) with no client-side component, relying only on Node’s built-in modules. The plugin is self-use oriented and has been verified working on two machines (Windows laptop ↔ NAS).

Installation & Activation

Use the official installation command to add the plugin to the web profile:

dsh plugin --profile web add github:harmless0819-dev/dsh-agent-chat

After installation, restart dsh web to activate it.

Configuration

Configure the entry in the profile’s cordis.patch.yml — this is a full-line replacement of the entry, not a deep merge. The configuration fields include:

  • selfLabel: The name of this machine in the conversation.
  • peerBase: The base URL of the peer; if empty, the plugin only receives but does not send.
  • enabled: Whether to enable background polling.
  • pollMs: Polling interval (minimum 1000).
  • maxInject: Maximum number of messages to inject per turn.
  • logFile: Path to the message log file.
  • tokenFile: Path to the token file; re-read on every request to support hot rotation.

Example configuration:

- id: dsh-agent-chat
  name: dsh-agent-chat
  config:
    selfLabel: "laptop"
    peerBase: "http://192.168.1.100:6061"
    enabled: true
    pollMs: 3000
    maxInject: 5
    logFile: "D:/deepseek/logs/agent-chat.jsonl"
    tokenFile: "C:/Users/<you>/.agent-chat/token"

How It Works

Message flow is divided into three steps:

  1. Disk write: The plugin persists messages to a local log (default <workspace>/.agent-chat/chat.log.jsonl).
  2. Polling: A background loop polls the peer’s /agent-chat/messages, pulling new messages into the local log (with a cursor, no duplicates).
  3. Injection: Each time the agent starts a new step (agent/pre-step), messages that have not yet been injected are bundled into a context block and appended to the current conversation.

Messages sent by this machine are simultaneously POSTed to the peer’s /agent-chat/send.

HTTP API

The plugin registers the following routes on DSH’s webServer:

  • GET /agent-chat/health.json: Health probe, returns cursor, pending injection count, and peer reachability.
  • GET /agent-chat/messages?since=<id>: Messages after since (used by peer polling).
  • POST /agent-chat/send: Submit a message {from,text,ts}.
  • GET /agent-chat/log?limit=50: View recent messages.

Security

/agent-chat/send will inject arbitrary text into the agent’s next turn. If the deployment exposes the HTTP surface to the LAN (or even routes through port forwarding on a router), you must configure a token.

Token value resolution priority:

  1. cfg.token
  2. Environment variable DSH_AGENT_CHAT_TOKEN
  3. tokenFile

If all three are empty, it falls back to the old behavior (open), but the startup log will emit a warning auth=open.

Requests must include x-agent-chat-token: <token> or Authorization: Bearer <token>.

Notes

  • Only depends on Node built-in modules — no additional dependencies need to be installed.
  • Self-use plugin: The author has verified it on two machines (Windows laptop ↔ NAS), but no extensive production-grade test data is provided.
  • Ecosystem context: This plugin is built on the DSH ecosystem, whose philosophy is “everything is a plugin.” The community catalog has no official affiliation with DeepSeek / High-Flyer.
羽毛球分组比赛记分
小程序二维码

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

Xiaoye