Repository navigation
feat(grant): 消息额度 + 被授权人命令限制开关 + dashboard 配置 UI - #86
Merged
Merged
Conversation
- messageQuota:/grant @x N 给 N 条消息额度,scope-aware(chat:群:人 / global:人 各算各的), 第 N 条用尽自动收回对应 scope 授权 + 发用尽卡;defaultLimit 配置默认额度(未配=无限); 显式数字恒生效;只计真正喂给 CLI 的普通对话,斜杠命令不耗额度。 - restrictGrantCommands:per-bot 开关(默认关),开启后 per-user 被授权人(chatGrants/globalGrants) 只能普通对话,禁用一切 slash 命令(DAEMON/PASSTHROUGH/全部 workflow/introduce/t), 形状校验 ^/[a-z][a-z0-9_-]*$ 避免误伤 /路径;owner/allowedUsers/oncall/整群豁免。 - 修复:/grant N 漏 @ 人不再误开整群(无 target 仅接受裸 /grant 或 /grant all); 额度去重改 pending/done 状态机,consume 失败 abort、重投重扣,防锁超时绕过硬上限。 claude-loopy + codex-loopy 分模块协作(foundation / enforcement)。 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
解决 10 处冲突,融合双方意图: - grant-command / card-handler / card-builder / grant-pending:master 的 /grant 多人@、 授权 bot 自动登记花名册、/introduce 改造、grant 通知线程化探测,与本分支的消息额度 (/grant N)+ 命令限制开关共存——额度对多目标各自生效(openPendingMulti 带 quota), notify 卡同时支持多 @ + 额度后缀;no-target 守卫沿用 master 的纯文本 replyMessage 写法。 - daemon:保留本分支早声明的 senderOpenId(force-topic 命令限制前要用),仅补 master 新增的 senderUnionId。 - i18n / README:两边新增的 key / 配置行全部保留,/grant usage 文案融合「多人@ + N 条额度」。 验证:tsc + pnpm build 通过;全量单测 3136 passed,7 失败全在预存在 flaky bridge-final-output-retry.test.ts(与本次无关)。 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
之前 restrictGrantCommands 和 messageQuota.defaultLimit 只能手改 bots.json, 现在在 dashboard「Bot 配置」页每个 bot 卡片新增「授权与额度」一栏: - 「限制被授权人只能纯对话」复选框(restrictGrantCommands),即时生效 - 「默认消息额度」数字输入 + 保存/关闭按钮(messageQuota.defaultLimit), 空=不配置默认额度,正整数=启用 实现仿 card-prefs-store 套路:新增 grant-prefs-store(RMW 落 bots.json + 内存同步)、 IPC 路由 /api/bot-grant-prefs、dashboard 代理 /api/bots/:appId/grant-prefs、前端一栏 + 中英文案。 关闭默认额度只删 messageQuota,保留 quotaState 计数,不影响显式 /grant @x N。 codex review 后修正:文案明确「关闭只影响裸 /grant,既有额度和显式 N 不受影响」; IPC 加顶层非对象(含 JSON null)守卫回 400 防 500;前端额度用 /^[1-9]\d*$/ 校验对齐 token 语义。 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…closed) beginCharge 三态化(fresh/pending/done)替换 markChargedOnce(boolean): - pending 命中不再放行,改 fail-closed drop(关并发重投在扣费定论前漏放的洞) - daemon enforce 重排:allow=false 走 abortCharge 而非 commit done, revoke 自愈失败/竞态下同 message_id 重投会重新进 quota 判定并继续拒绝 - 仅 allow=true(含 exhausted)或 tracked=false 无限授权才 commit done 补回归:denied 不得 commit-done / pending 重投 fail-closed。Codex 二轮复审 OK。
This was referenced Oct 29, 2026
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.
概述
在
/grant授权体系上加两个 owner 可控的 per-bot 机制(默认都关闭),并补上 dashboard 配置 UI。1. 消息额度(messageQuota)
messageQuota.defaultLimit这个字段「是否配置」本身就是总开关。/grant @x 5给 5 条;不带数字取defaultLimit;显式 N 恒生效。2. 被授权人命令限制(restrictGrantCommands)
/workflow、/introduce、/t、以及 CLI 原生命令。/path/to/file这类不会被误判(shape-check)。3. dashboard 配置 UI
测试
协作 & review
🤖 Generated with Claude Code