Repository navigation
feat(lark): 支持原生 Slash 命令注册 - #842
Merged
Merged
Conversation
Contributor
Author
Owner
|
准备好了的话点一下 ready for review,我这边会看。 (来自 grok bot 自动回复) |
deepcoldy
force-pushed
the
feat/native-slash-commands
branch
from
October 13, 2026 19:59
7787731 to
bb89401
Compare
Owner
|
感谢你提出并实现原生 Slash 命令注册,飞书原生 这边在最新 master 上做了一次跟进重写(保留了你的署名),主要调整:
|
在 Dashboard「Bot 默认设置 → Slash 命令」新增飞书原生命令面板,经各 Bot
自己的 daemon 读写应用级 Slash 命令(/open-apis/application/v7/app_slash_commands):
展示已同步 / 待新增 / 待更新 / 远端额外状态,支持逐条同步、逐条删除与只增不删的
「全部同步到飞书」;删除由服务端按命令名重新解析远端 ID。
- 候选清单只从 core/command-schema.ts 的 COMMANDS(含别名、cliId 限定项)推导,
说明取自 /help 的 i18n 行;CLI 透传类命令在透传能力按 CLI × 后端声明前不进入候选。
- application:app_slash_command:{read,write} 为可选权限:不进默认 manifest 与
BOTMUX_REQUIRED_SCOPES(启动自检不会补开/发版),缺 scope(含 v7 接口的
99991640 lacks permission)或租户未进灰度时接口返回 available:false,面板降级为
「暂不可用」+ 开通深链,不影响 Bot 启动与其它功能。缺权限的文本兜底只认明确的
拒绝措辞或完整 scope 标识,参数/重复/上限类错误不会被误判。
- core-only(apiOnly)Bot 在解析飞书 client 之前即返回只读的 core_only 不可用态,
不给开权限链接、不开放写操作。
- Dashboard 写代理(sync / sync-one / delete)走控制类门禁:需主机管理身份,
同源证明 + 绑定认证会话的一次性 CSRF 票据;前端写请求带票据头,GET 不设门禁。
- 写操作在请求边界收口:单条 POST/PATCH/DELETE 超时或连接重置只记为该条
「结果未确认」的失败,不中止整批、不丢已成功的变更;写后刷新清单失败时保留
已确认的写报告,另以 refreshError 暴露,面板不当成写失败。
- 更新描述时合并远端已有的 i18n,只覆盖 botmux 管理的 zh_cn/en_us,保留人工
维护的其它语言(如 ja_jp);写请求被裸 HTTP 403/404 拒绝时保留状态码并按读路径
口径归为缺权限/接口未开放,与无响应的网络异常(结果未确认)区分。
- 删除按远端原始名称(保留大小写)解析,找不到目标时报失败而非成功;SDK 拒绝同时
带 HTTP 状态与飞书信封时保留状态(带信封的 5xx 仍为未确认,404 降级为未开放)。
- 面板写请求绑定发起时的 Bot/CLI 代次,切换后返回的过期响应直接丢弃;切换时先清空
旧清单,新查询失败则保持空并提示错误,旧候选不可再操作。
- 不改运行时斜杠命令路由判定。
Co-authored-by: liangzebin <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
force-pushed
the
feat/native-slash-commands
branch
from
October 13, 2026 21:02
424acbf to
37a5985
Compare
deepcoldy
marked this pull request as ready for review
October 14, 2026 02:57
deepcoldy
requested review from
47seek,
LucasIcarus,
deepcoldy,
xiaoxueSunn and
xiongz-c
as code owners
October 14, 2026 02:57
Owner
|
你好 @lozybean,这个 PR 的飞书评审群已建好,自动评审(首轮 + 交叉复审)会在群里进行,结论也会同步在 PR 上。你目前还不在自动拉群的作者名单里,请直接点下面的一年有效链接加入评审群: 也欢迎把 GitHub 账号和飞书信息补进这份名单文档,补好后后续评审会自动拉你进群:https://bytedance.larkoffice.com/wiki/WJ1nwWbtxi89erkNGNbcgkt9nUe 本条为自动流程发送,感谢贡献~ |
PR deepcoldy#842 与最新主干两处机械冲突,无语义对立: - bot-defaults-page.tsx:保留主干前端组件去重(ToggleRow 收敛为 BaseToggleRow 薄包装、sendJson 迁至 dashboard-api.ts),把本 PR 写请求所需的可选 extraHeaders 参数落到去重后的共享 sendJson(默认空、向后兼容)。 - dashboard.ts:主干 deepcoldy#1902 把纯转发路由改为表驱动(handleDaemonProxyRoute), 本 PR 的原生 Slash 命令代理因写操作需控制类门禁(同源 + 一次性 CSRF 票据), 不进纯转发表,作为与表互斥的独立穿插路由保留在表匹配之后。 另适配主干 deepcoldy#1891 新增的 /resume:其 claimWithoutSessionOnly 元命令与 GLOBAL_COMMANDS/DAEMON_COMMANDS 同口径排除(无会话回收、有会话透传 CLI), 不进应用级 Slash 候选清单。 合并树经 build/tsc/前端 bundle 与 dashboard 全族测试验证。
|
🚀 Released in v3.45.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

维护者跟进
接受条件与实现
application:app_slash_command:read/write仅在 verify-permissions 中登记为可选功能权限(critical:false),不进BOTMUX_REQUIRED_SCOPES与lark-scopes.json——启动自检会自动开通并发布缺失权限,而该能力在飞书侧仍在灰度。缺权限(99991640/99991672/99991679、明确拒绝措辞或完整 scope 标识,或裸 HTTP 401/403)、接口未开放(404)、core-only(apiOnly)Bot 时,接口返回available:false与原因,面板显示「暂不可用」及开通链接;Bot 启动与其它功能不受影响。src/core/command-schema.ts推导(名字、别名、按当前 CLI 收入的命令;说明取/help中英文文案),当前 43 条。CLI 透传类命令暂不纳入,待 fix(slash): 透传命令按 CLI 与输入后端能力声明 #839(透传能力按 CLI × 后端声明)落地后再扩展。command-router-oracle-diff保持绿。本地 codex 五轮 review 处理
guardControlRequest:要求管理权限 + 同源证明 + 绑定登录会话的x-botmux-csrf一次性票据;请求体上限 16KB。refreshError暴露。ja_jp),只覆盖 zh/en。验证
bun run build通过。app-slash-commands、dashboard-native-slash-commands、dashboard-native-slash-proxy、setup-verify-permissions、slash-commands-doc-sync、command-schema、dashboard-ipc、command-router-oracle-diff、oncall-service-secret、terminal-control共 10 个文件 473 通过、1 跳过;各处修复均做过回退变异,对应测试会变红。界面(合成数据)
原始描述
改动
application:app_slash_command:read/application:app_slash_command:write,展示已同步、待新增、待更新与远端额外状态。为什么
不同 CLI 和输入后端对同名透传命令的支持与语义并不一致。把透传命令作为候选项、将最终注册和删除交给用户,可以提供飞书原生
/交互,同时避免把候选清单误当成后端能力声明。影响面
验证
pnpm build:通过。pnpm test -- test/app-slash-commands.test.ts test/dashboard-native-slash-commands.test.ts test/setup-verify-permissions.test.ts test/slash-commands-doc-sync.test.ts:4 个文件、38 个测试通过。pnpm switch:here && pnpm daemon:restart:5 个本机进程启动成功。全量
pnpm test曾在本机执行,但多组既有 host/process/time-sensitive 用例失败,未作为通过项;本改动相关测试均单独通过。相关问题
界面
🤖 Generated with Claude Code