返回目录
Agent 与会话 插件

dsh-agent-chat

harmless0819-dev/dsh-agent-chat

Turn-injection message channel between DSH agents on two machines: messages land in a log and are injected as context at the next agent step.

Stars
0
Forks
0
Issues
0
更新
1 天前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

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

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

dsh-agent-chat

两台机器上的 DSH agent 互相留言

DSH 的 agent 不是常驻进程 —— 只在有人给它发消息时才醒着。所以这不是即时通讯, 而是回合注入式:消息先落盘,等 agent 下一次「开步」时再把未读的拼进上下文。

  • 插件类型:DSH host plugin(web profile),无客户端半边
  • 依赖:仅 node 内置模块
  • 状态:自用插件,已在两台机器(Windows 笔记本 ↔ NAS)上跑通

它怎么工作

  本机 agent ──发消息──▶ 本地日志 + POST 对端 /agent-chat/send
                              │
  本机 agent ◀──注入上下文──── 拉取对端 /agent-chat/messages(带游标,不重复)
  1. 本插件把消息落进本地日志(默认 <workspace>/.agent-chat/chat.log.jsonl);
  2. 后台轮询对端的 /agent-chat/messages,把新消息拉进本地日志(带游标,不重复);
  3. 每次 agent 要开新步时(agent/pre-step),把尚未注入过的消息拼成一块上下文追加进本次对话;
  4. 自己发出的消息同时 POST 给对端的 /agent-chat/send

HTTP 路由

都挂在 DSH 自己的 webServer 上:

方法 路径 用途
GET /agent-chat/health.json 探针:游标、待注入数、对端可达性(故意保持开放,方便监控)
GET /agent-chat/messages?since=<id> since 之后的消息(对端轮询用)
POST /agent-chat/send 投入一条消息 {from,text,ts}
GET /agent-chat/log?limit=50 看最近的消息(人用)

安装

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

重启 dsh web 后生效。

配置

在 profile 的 cordis.patch.yml 里给该行加 config(整行替换,不是深合并):

- 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"
默认 说明
selfLabel 'laptop' 本机在对话里的名字
peerBase '' 对端基础地址;空则只收不发
enabled true 是否启用后台轮询
pollMs 3000 轮询间隔(最小 1000)
maxInject 5 每次注入最多几条
logFile <workspace>/.agent-chat/chat.log.jsonl 消息日志路径
token 共享密钥(优先级最高)
tokenFile ~/.agent-chat/token 密钥文件,每条请求重读 ⇒ 可热轮换

⚠️ 安全

/agent-chat/send 会把任意文本注入 agent 的下一回合 —— 也就是说,能连上这个端口的主机 就能给 agent 下指令。如果你的部署把 HTTP 面暴露到 LAN(甚至叠了路由器端口转发), 必须配 token

取密钥的顺序:cfg.token → 环境变量 DSH_AGENT_CHAT_TOKENtokenFile

三者都空时退回旧行为(开放),但启动日志会告警 auth=openhealth.json 故意保持开放(只用于探活,且已去掉日志路径)。

请求需带 x-agent-chat-token: <token>Authorization: Bearer <token>

测试

node test-harness.mjs

离线跑(mock ctx),不碰 profile、不启服务。覆盖:无 token/错 token 返回 401、 对 token 返回 200、密钥热轮换无需重启、出站轮询带 token、disposer 注销路由。

License

MIT

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类Agent 与会话
规则置信度

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: multi-agent。