Skip to content

feat(discord): add slash commands and safer reconnect flow#328

Open
solopole wants to merge 1 commit into
lsdefine:mainfrom
solopole:feat/discord-slash-reconnect
Open

feat(discord): add slash commands and safer reconnect flow#328
solopole wants to merge 1 commit into
lsdefine:mainfrom
solopole:feat/discord-slash-reconnect

Conversation

@solopole
Copy link
Copy Markdown
Contributor

What

  • Add Discord slash commands for help/status/control and mode selection.
  • Rebuild Discord client state during reconnects to avoid reusing closed clients.
  • Harden Discord file-output handling so files are only sent when explicitly requested.

Why

Improve Discord frontend reliability and make user controls discoverable while reducing accidental local file exposure.

Testing

  • Python syntax compile for the Discord frontend module.
  • Verified installed discord.py exposes app_commands.

@solopole
Copy link
Copy Markdown
Contributor Author

1.Discord 前端模块:新增 slash command 能力
本地改动引入了 Discord slash commands,新增命令包括:

/help:显示帮助
/status:查看状态
/stop:停止当前任务
/new:开启新对话并清空上下文
/restore:恢复上次对话历史
/continue:列出或恢复可继续的会话
/llm:列出或切换 LLM
/plan:按 plan 模式执行复杂任务
/goal:按 goal 模式运行开放目标

这部分属于功能增强,目标是让 Discord 前端不只依赖普通文本消息,也能通过 slash command 操作 Agent。

2.Discord 客户端重连逻辑增强
本地改动把 Discord client 构造拆成了独立的 _build_client(),并在重连循环里创建新的 client / command tree。

意义:

避免复用已 close/logout 的 Discord client
降低断线、重启后无法重新连接的问题
ready 日志增加了进程号和 Python 可执行信息,便于排查后台多进程或错误环境问题

这部分看起来是针对 Discord bot 稳定性的修复。

3.Discord 文件发送安全策略增强
本次改动明显加强了“不要泄露本地文件路径 / 不主动发附件”的约束:

默认隐藏 `` 标记
只有用户明确要求发送/展示文件时,才允许上传附件
未明确要求时会阻止文件引用被发出
发送给 Agent 的任务中会加入“不要提本地路径、不要主动发文件”的提示

4.Discord 进度显示改造
本地改动新增了进度消息类,用于维护 Discord 中的任务进度展示:

开始任务时显示进度
运行中更新步骤摘要
支持 heartbeat,例如“还在处理中”
完成后结束进度提示
相比旧逻辑,不再频繁发多条“步骤 N”,更像单条状态消息更新

5.Turn / Transcript 清理逻辑增强
新增了若干文本处理函数,用来提取或清理:

Discord progress 内容
turn 标记
transcript 片段
代码块外的 turn marker
最终展示文本

6.活跃频道清理机制
本地改动新增了活跃频道定时清理相关逻辑:

固定清理时间配置
活跃频道快照
校验频道是否仍有效
清理不可达或无效频道
定时 cleanup loop

7.退出频道触发词变化
退出频道文本新增了“退下”。

也就是说 Discord 用户现在除了“退出频道”等表达外,也可以用“退下”触发退出/停用当前频道。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant