feat: make IM permission approval mobile-friendly

Text-only IM channels forced users to copy long permission request IDs from mobile chat, which made approval slow and error-prone. This keeps the requestId-based authorization protocol intact while adding short replies for the single-pending-request case and preserving full command fallbacks for ambiguous cases.

Constraint: IM authorization must still resolve through the existing requestId permission_response path
Rejected: Replace request IDs with global numeric IDs | concurrent permission prompts would make numeric IDs ambiguous across chats
Confidence: high
Scope-risk: moderate
Directive: Do not allow short numeric replies when more than one permission request is pending in the chat
Tested: cd adapters && bun test common/ telegram/ feishu/ dingtalk/ wechat/
Tested: cd adapters && bunx tsc --noEmit
Tested: bun run check:adapters
Not-tested: Real WeChat or Telegram account end-to-end message delivery
This commit is contained in:
程序员阿江(Relakkes)
2026-05-05 21:06:58 +08:00
parent 82c454e4dc
commit 7ca25687fd
6 changed files with 154 additions and 19 deletions
+1 -1
View File
@@ -502,7 +502,7 @@ async function routeUserMessage(message: WechatMessage): Promise<void> {
await sendText(chatId, sent ? '已清空当前会话上下文。' : '无法发送 /clear,请先发送 /new 重新连接会话。')
return
}
const permissionDecision = !hasAttachments ? parsePermissionCommand(text) : null
const permissionDecision = !hasAttachments ? parsePermissionCommand(text, pendingPermissions.get(chatId)) : null
if (permissionDecision) {
const { requestId, allowed, rule } = permissionDecision
const pending = pendingPermissions.get(chatId)