dsh-crosstalk:DSH 同机会话横向消息插件

前言

DSH 已有 send_messagelist_agents,但原始形态偏层级:父会话给自身后台 subagent 发消息。两个 DSH 会话在同一台机器、不同仓库中运行时,默认无法互相发现或互发消息。

Jesse-njx/dsh-crosstalk 为这种多会话工作流补齐同机横向通信能力:任一会话可以列出本机 live 会话,并向其中任意一个发送消息,无需 daemon。

这是什么

Jesse-njx/dsh-crosstalk 是一个 DeepSeek Harness bundle,MIT 许可。它把 DSH 的会话通信扩展到同机、同用户运行的 peer 会话之间,让 list_agentssend_message 获得 peer 发现与 peer 寻址能力。

v0.1 不提供网络传输,只做本地文件与目录级别的消息投递。

核心能力

会话发现与消息接口

  • list_agents 增加 scope: peers,用于查看本机其他 live 会话;scope: all 覆盖 descendants 与 peers。
  • send_messageto 字段除 subagent id 外,也接受 peer name 或 ref,并可携带 summary
  • 该 bundle 按 agent shadow 原生工具;卸载时可恢复原生行为。

本地投递

  • 每个运行中的会话在 ~/.dsh/crosstalk 下发布 heartbeat JSON 文件。
  • 消息以文件形式写入目标 inbox,采用临时文件加 rename 的原子方式。
  • 空闲目标会被唤醒一个 turn;忙碌目标会在下一个 turn 边界接收。
  • 投递是 best-effort;list_agents 中的状态不构成送达承诺。

注入与信任边界

  • 接收端看到的消息会被标注为 relay turn,例如:
[message from session dsh-cowork-amber (/Users/me/projects/dsh-cowork)]
  • 系统提示会说明这是 peer agent 的请求,不是用户指令。
  • v0.1 固定只接受 same-user;可再配置 name/cwd allowlist 做更严格的入站过滤。

安装与启用

环境要求

  • Node >=22
  • 若从 GitHub 安装,需要先允许构建 hook @dsh-crosstalk/bundle

从 GitHub 安装

先配置 profile workspace,允许 bundle 的构建 hook:

# ~/.dsh/profiles/web/pnpm-workspace.yaml
packages:
  - .
allowBuilds:
  '@dsh-crosstalk/bundle': true

然后为每个需要参与的 profile 添加 bundle:

dsh plugin --profile web add github:Jesse-njx/dsh-crosstalk
dsh plugin --profile <other-profile> add github:Jesse-njx/dsh-crosstalk

GitHub 安装会通过 package 的 postinstall hook 从 src/ 构建 lib/

本地检出安装

从仓库源码安装时,先构建,再把仓库根目录加入 profile:

git clone https://github.com/Jesse-njx/dsh-crosstalk
cd dsh-crosstalk
pnpm install
pnpm build
dsh plugin --profile web add "$PWD"
dsh plugin --profile <other-profile> add "$PWD"

本地检出加载的是编译后的 lib/;修改源码后运行 pnpm build 并重启 DSH,不需要重新安装。

配置覆盖

bundle 添加后会自动挂载。要覆盖字段,在 profile 的 cordis.patch.yml 中按 id 覆盖 crosstalk 条目;不要新增第二个 crosstalk row,否则会出现重复条目错误。

# in <DSH_HOME>/profiles/<name>/cordis.patch.yml
- id: crosstalk
  config:
    homeDir: ~/.dsh/crosstalk
    cwd: /path/to/repo
    name: my-custom-name
    accept: same-user
    mode: open
    allowlist: []
    notifyUser: true
    heartbeatIntervalMs: 10000
    inboxPollMs: 1000
    staleAfterMs: 20000
    maxInboxAttempts: 30

未设置字段回落到默认值;loader 会整体替换 config,所以只列需要改动的字段即可。

典型用法

两个安装了 bundle 的 DSH 终端可以做如下往返:

You: list_agents peers
      dsh-cowork-amber [idle] — /Users/me/projects/dsh-cowork
      dsh-memory-azure  [running] — /Users/me/projects/dsh-memory
You: send_message to="dsh-cowork-amber" message="Round-trip check: can you list the files in your repo?" summary="ping for round-trip"

对端会话会醒来,或在当前 turn 结束后接收该消息;它看到带来源标注的消息后,可以用 send_message 发回你的名字。

适用场景与注意

适合这类场景:同一台机器上按仓库拆分多个 DSH 会话、需要一个协调者分发任务、一个例行会话 ping 一个 live 会话,或人工参与会话与 agent 会话互发消息。

使用注意:

  • v0.1 仅限同机、同用户;没有网络传输。
  • 对端消息是 peer request,不是用户指令;模型应在既定用户指令范围内处理,并暴露有副作用的操作。
  • 投递是 best-effort,不保证送达。
  • 该 bundle 会在当前 DSH 进程权限下运行;安装前建议检查源码、构建 hook 与 MIT 许可证,不要在不信任的仓库上直接安装。
  • 若使用 allowlist 模式,可用精确 session name 或 cwd glob 限制入站来源。

结尾

dsh-crosstalk 的价值在于把 DSH 的会话通信从“父到子”扩展到“同机对等会话之间”,适合多仓库、多会话、同用户环境。

  • GitHub: https://github.com/Jesse-njx/dsh-crosstalk
  • 目录页:可按 Jesse-njx/dsh-crosstalk 在社区目录检索;社区目录是独立站点,不是 DeepSeek / 幻方官方应用商店。
羽毛球分组比赛记分
小程序二维码

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

Xiaoye