dsh-session-communicate: A plugin for scheduled, rule-based interaction between two DSH sessions

Introduction

DSH sessions can be used to run scripts, write code, or role-play a particular persona, but they typically operate one at a time. If you want two sessions to have a structured conversation—such as mutual code review or a debate from different perspectives—you’d need to manually switch between two windows or rely on external scripts. This is tolerable for small-scale testing, but once you want to run multiple rounds of dialogue on a daily schedule, it becomes tedious and error-prone.

Below is an introduction to the dsh-session-communicate plugin. Its core purpose is to enable two existing DSH sessions to automatically converse with each other for a set number of rounds at a fixed time each day, following predefined rules. Both participants only need to be regular sessions in the local profile—no plugins need to be installed on either side. The plugin handles bidirectional read/write through session logs.

Plugin Positioning and Core Capabilities

dsh-session-communicate is a workflow-type DSH plugin maintained by jediliu005. It allows two designated DSH sessions to automatically exchange messages for a fixed number of rounds according to defined rules and a scheduled time. Every message carries the same shared rule block (including both parties’ identities, the conversation purpose, the current turn number, and a character limit), so both sides always know exactly what they’re doing.

The plugin has built-in scheduling logic that checks every 30 seconds whether it’s time to run, whether it has already run today, and whether a run is in progress. It does not depend on any external scheduling plugin. It delivers messages via sessionController.prompt and reads back the other party’s replies from session logs—zero external dependencies. The host only needs Node.js built-in modules (fs / path / os / zlib / child_process), and the client only needs the react provided by the host.

Installation and Activation

Local development install (bypassing npm):

# 1) Add a dependency and bundle entry in the profile's package.json
"dsh-session-communicate": "link:D:/path/to/dsh-session-communicate"
#    "dsh": { "profile": { "bundles": [ "...", "dsh-session-communicate" ] } }

# 2) Create the link (use mklink /J on Windows, ln -s on macOS/Linux)
# 3) Restart DSH — host code is only loaded at startup; there is no hot-reload

Install from the store: the entry is distributed as an npm package. After installation, a single restart is still required.

Configuration

The plugin provides a “Session Dialogue” panel in the sidebar. The following fields need to be configured:

  • Session A / Session B: Select two existing sessions from the local ~/.dsh/sessions; the options display each session’s own name, short ID, and last update time.
  • Initiator: Whether A speaks first or B speaks first. The initiator receives a fixed opening prompt (containing the conversation purpose) and generates the first message on its own.
  • Purpose: The basic objective of the initiator, written into the rule header of every message for both sides.
  • Rounds: One round = each side speaks once; 3 rounds means 6 messages total.
  • Time: What time each day to start (DSH will make up a single run for the day if it starts after the scheduled time).
  • Per-message character limit: The maximum characters per message, enforced via the prompt rather than hard truncation.

The configuration file is stored at ~/.dsh/session-communicate.json, and the scheduling state at ~/.dsh/session-communicate.state.json.

How It Works

Each run proceeds as follows:

  1. At the scheduled time, deliver the “opening prompt” to the initiator;
  2. Read back the last non-empty assistant text from the initiator’s session log (session.v4.jsonl.zstd) for this round;
  3. Send that text along with the rule header to the other party and read back the reply;
  4. Alternate until all rounds × 2 messages have been delivered.

Each run produces a plain-text record: ~/.dsh/session-communicate/conversations/YYYY-MM-DD-HHmm.md, containing only the dialogue content without rule headers.

Scheduling and Retry Mechanism

The plugin uses a built-in setInterval that ticks every 30 seconds; it performs one warm-up 8 seconds after startup.

  • lastRunDay is only written when triggered by the schedule; a manual POST /api/run does not consume the day’s quota (a previous bug where manual tests consumed the scheduled quota has been fixed).
  • Failures are retried per day: retry after 10 minutes; only give up and record lastRunDay after 3 consecutive failures.
  • Each individual message delivery has a 20-second timeout guard to prevent a permanent hang when the target session is busy.

HTTP API

The plugin exposes the following HTTP endpoints:

Method Path Description
GET/POST /session-communicate/api/config Read/write configuration
GET /session-communicate/api/sessions List local sessions with their display names
GET /session-communicate/api/status Run status, capability, next scheduled time
GET /session-communicate/api/log?lines=100 Last N lines of run log
POST /session-communicate/api/run Trigger a run immediately ({"dry":true} returns config only)
POST /session-communicate/api/tick Execute one scheduling check
POST /session-communicate/api/opendir Open the conversation records directory
POST /session-communicate/api/stop Stop (takes effect per message)

Compatibility and Limitations

  • Node ≥ 22.15: Session logs are append-style multi-frame zstd; the plugin decompresses frame by frame and requires zlib.zstdDecompressSync.
  • At startup, the plugin self-checks three capabilities: prompt / webServer / zstd. Any missing capability is displayed directly in the status rather than causing a 404/500 at delivery time.
  • The plugin depends on two internal DSH contracts: the envelope of sessionController.prompt(request, source) and the session log storage format. If upstream changes break these, the plugin will fail fast and report the reason rather than silently producing incorrect results.
  • A single session log exceeding 400 MB will be refused for reading (since it must be loaded entirely into memory) rather than silently truncated.

Notes

  • Both sessions must be regular sessions in the local profile (standard preset); sub-agent sessions cannot be used as a party.
  • If the other session is running a different task during the conversation, messages will queue up. The read operation waits until that round finishes or times out (default 300 seconds).

Use Cases

Suitable for scenarios requiring structured dialogue between two sessions, such as:

  • Simulating code review or debate from different perspectives;
  • Having two sessions Q&A each other under fixed rules;
  • Scheduling two sessions to collaboratively complete a task.

The plugin runs with the current dsh process permissions. Review the source code and license before installing.

Summary

dsh-session-communicate provides the ability to let two DSH sessions automatically converse for a set number of rounds according to rules and a schedule. It has built-in scheduling with no external dependencies, handles bidirectional read/write through session logs, and requires zero external dependencies. It is ideal for developers who need to establish a regular dialogue workflow between two sessions.

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

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

Xiaoye