feat: add NapCat OneBot channel support - #40
Merged
Conversation
Closed
1. onebot-action-client: catch stream callback errors on the packet chain. A throwing onPacket left rejected promises unhandled (Node >= 15 raises unhandledRejection and crashes the Electron main process); NapCat keeps pushing chunks after a client-side failure, so every subsequent packet produced a new unhandled rejection. First error is now stored and the promise rejects at the terminal packet. 2. onebot-media: validate stream chunk contiguity and write offsets. Chunk indexes only deduplicated, never checked for holes, so a stream skipping an index wrote a sparse file that passed byte-count, chunk-count and total_bytes checks - a corrupted image/file was handed to the agent. Also bound chunk write offsets by file size to prevent oversized sparse files from a hostile NapCat. 3. dispatcher/history-log: migrate channel history from senderId-keyed to chatId-keyed sessionIds. Feishu p2p chatId (oc_xxx) and senderId (ou_xxx) live in different ID spaces, so existing Feishu users lost their sliding window context on upgrade. Old files are copied to the new key once (idempotent, never overwrites).
1. onebot-reverse-ws: require an Access Token for any non-loopback listen address, not only literal 0.0.0.0. LAN IPs, the WSL vEthernet adapter and IPv6 :: previously allowed unauthenticated clients that could impersonate NapCat (forge whitelisted user_id message events) and trigger SSRF via media URL downloads. The settings panel now pre-generates a token when saving a WSL/custom non-loopback config without one, prompting the user to copy it to NapCat first (tokens are never echoed back after saving). 2. onebot-media: stream URL downloads instead of buffering the whole body. A missing or forged content-length (chunked responses) made arrayBuffer() read unbounded data into memory before the size check, allowing main-process OOM; the reader now aborts as soon as the 8 MiB threshold is exceeded. 3. onebot-reverse-ws: stop() no longer hangs on idle keep-alive connections. The 404 handler replies with keep-alive, so a single browser or port-scanner probe left a connection that kept server.close() (and app quit) waiting for the 5s keep-alive timeout; closeAllConnections() is now called with a 3s fallback timer. 4. onebot-normalizer: emit a visible placeholder for unsupported message segments (location/share/forward/poke/...) instead of silently dropping them, so the agent knows such content exists. Docs updated for the token requirement. Full suite: 2638 tests pass.
Owner
PR Review Comment非常感谢这个 PR!整体代码质量很高。我完成了完整的代码审查 + PoC 复现验证,发现若干问题。其中 3 个 Blocker 问题 + 4 个问题由 Cyrene 定位+几个codex找的出问题并未修复,3+4已在分支修复,对应两个提交: 已修复(commit: d300953)
已修复(commit: 834872d)
不阻塞合并,后续通过 Issue 跟进(Codex 扫描发现)
|
Playa-0v0
added a commit
that referenced
this pull request
Aug 28, 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.
概要
为 Cyrene 增加 QQ / NapCat OneBot 渠道支持。
主要改动
验证
npm run build:通过其他
master合入 PR 分支并解决冲突