dsh-cross-session-messaging:DeepSeek Harness 跨会话消息中继

前言

DeepSeek Harness (dsh) 提供了 subagents 和 Web UI 中的 @session 提及作为内置的跨会话机制。前者是父子关系,后者是单向只读的。在许多场景下,需要两个独立的 dsh 会话(例如,分别运行在不同机器上的数据库助手和前端助手)进行双向通信。此插件通过在独立进程之间建立点对点、无中心的消息通道来解决这个问题。

插件定位

这是一个无中心、点对点、跨进程(可选跨机器)的消息通道。
* 模型驱动:模型通过调用 cross_session_list_agents 发现对等会话,并通过 cross_session_send_message 发送文本。
* 安全注入:消息以 form: 'relay' 形式注入,无需对工具调用进行授权;接收方工具调用仍需用户批准(默认拒绝)。
* 可靠传递:支持发送端投递、指数退避和死信处理,确保消息最终送达。

安装

先决条件:Node.js >= 24.11 和工作的 dsh 环境。

  1. 安装依赖并构建:
    npm install
    npm run build
  1. 添加插件到配置文件:
    dsh plugin --profile demo add ./cross-session-messaging
    dsh --profile demo --dump-config

典型用法

  1. 在 DSH 中打开两个独立会话。
  2. 在其中一个会话中,使用自然语言提示:
    “List the other sessions currently running, then send one of them a message: hello.”
  3. 模型调用 cross_session_list_agents 进行发现,调用 cross_session_send_message 进行发送。
  4. 另一个会话接收 form: 'relay' 文本。

配置

配置在插件的 cordis.patch.yml 下的 config: 中。本地使用通常只需要 name 和 inbound 策略:

- insert:
    - id: cross-session-messaging
      name: '@wy/dsh-cross-session-messaging'
      config:
        dirs:
          baseDir: ~/.dsh/cross-session   # 数据根目录,默认值
        inbound:
          rules: []                        # 匹配规则,空列表表示允许所有
          defaultDecision: auto            # 默认决策,auto 会根据 DSH_PERMISSION_MODE 判断
        name: ''                           # 会话名称,默认使用 shortId

跨机器通信:
需要配置 remote 字段:

remote:
  listen: { host, port, identity, secret }
  tls: { key, cert }
  peers:
    - { name, host, port, secret, tls, tlsCa/tlsFingerprint }
  • remote.listen: 本机的 TCP 监听配置。
  • remote.tls: 监听器证书配置。
  • remote.peers: 发送端使用的静态对等节点列表。
  • 注意:跨机器 TLS 需要配置 tlsCa 或 tlsFingerprint,否则连接将被拒绝。

工具

  • cross_session_list_agents: 列出可达的 peer 会话。
  • cross_session_send_message: 向会话发送文本。
  • cross_session_inbox_review: 审查待接受/拒绝的消息。
  • cross_session_inbox_resolve: 解决待处理消息。

注意事项

  • 需要 Node.js >= 24.11。
  • 消息作为“relay”文本注入,不自动批准工具调用。
  • 接收工具调用仍需用户批准(默认拒绝)。
  • 跨机器通信需要配置远程监听器和 TLS 设置。
  • 跨机器 TLS 需要配置 tlsCa 或 tlsFingerprint。

生态

DSH 理念是“一切皆插件”。此插件由 Weiyang742 维护,许可证为 MIT。

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

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

小夜