@linjz/opencode-qqbot 0.3.19 → 0.3.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/PRIVACY.md ADDED
@@ -0,0 +1,87 @@
1
+ # Privacy and Data Handling / 隐私与数据处理
2
+
3
+ This document describes the categories of data the bot can process and the responsibilities of deployers. It is not a guarantee that every deployment has the same behavior. Actual data flows depend on configuration, enabled features, QQ and OpenCode settings, AI providers, network paths, and local operational choices.
4
+
5
+ ## English
6
+
7
+ ### Data the bot may process
8
+
9
+ - QQ messages, quoted content, group or user identifiers, and interaction data.
10
+ - Desktop session content, including the default full-text session mirror.
11
+ - Voice content and speech-recognition text, images, files, filenames, and file contents selected for upload or sending.
12
+ - Approval decisions, commands, task history, delivery and deduplication records, gateway session/sequence state, watchdog events, and diagnostic logs.
13
+ - Credentials such as `QQ_APP_SECRET` and `OPENCODE_PASSWORD`, which must remain in the designated secret store and must never be printed, copied into logs, committed, or disclosed.
14
+
15
+ ### Where data may go
16
+
17
+ - QQ Open Platform and QQ clients, according to the bot's messaging behavior.
18
+ - The OpenCode service and execution environment selected by the deployer.
19
+ - AI/model providers configured for the OpenCode service. Their own privacy terms, retention policies, and regional processing rules may apply.
20
+ - External speech-to-text providers configured through `QQ_STT_*`: when enabled, audio bytes and filenames are sent to the selected transcription endpoint. That provider's privacy, retention, and regional processing rules also apply.
21
+ - Local runtime storage such as `~/.openqq/`, which can contain configuration, ledgers, message-related state, and logs.
22
+ - Downloaded image attachments are stored in the system temporary directory under `opencode/qq-images`. Files older than seven days are only subject to a cleanup attempt when the bot starts; all other retention and deletion remains an operational responsibility.
23
+
24
+ This repository does not establish a maintainer-operated data-processing service on your behalf. Deployers must nevertheless verify actual endpoints, providers, subprocesses, log destinations, and any telemetry or external integrations in their environment.
25
+
26
+ ### Retention and access
27
+
28
+ - Runtime retention varies by feature and configuration. Some delivery-deduplication records are retained for a bounded period, while other session, form, queue, and diagnostic records may persist until their configured cleanup or manual deletion.
29
+ - The unified log uses rolling files with a configured size budget. Retention and deletion are operational responsibilities, not automatic privacy guarantees.
30
+ - Deployers must restrict access to runtime files, backups, logs, screenshots, and exported files, and must define retention, archival, deletion, and incident-response procedures suitable for their users and jurisdiction.
31
+
32
+ ### Deployer and user responsibilities
33
+
34
+ Deployers must, as required by applicable law and their role:
35
+
36
+ 1. Inform affected users what data is collected, why it is processed, who receives it, where it is stored, and how long it is retained.
37
+ 2. Obtain consent or establish another valid legal basis before processing personal information, sensitive information, confidential content, or employee/user communications.
38
+ 3. Avoid collecting unnecessary secrets, sensitive personal information, or confidential material, and minimize mirrored content and attachments where possible.
39
+ 4. Assess cross-border transfer, processor, subprocessors, and industry-specific requirements before enabling external AI providers or remote QQ services.
40
+ 5. Provide appropriate access, correction, deletion, withdrawal, and incident-handling channels.
41
+ 6. Keep credentials out of source control and logs, rotate them after suspected disclosure, and do not share runtime secret files.
42
+
43
+ AI output may be inaccurate. Users must independently review it, especially for dangerous operations, permissions, files, professional judgments, and decisions affecting other people.
44
+
45
+ For privacy-related questions, open an issue in the project repository. Do not include secrets or sensitive personal information in the issue.
46
+
47
+ ## 中文
48
+
49
+ ### 可能处理的数据
50
+
51
+ - QQ 消息、引用内容、群或用户标识以及互动数据。
52
+ - 桌面会话内容,包括默认的全文会话镜像。
53
+ - 语音及语音识别文本、图片、文件、文件名,以及选择上传或发送的文件内容。
54
+ - 审批决定、命令、任务历史、投递与去重记录、网关 session/sequence 状态、看门狗事件和诊断日志。
55
+ - `QQ_APP_SECRET`、`OPENCODE_PASSWORD` 等凭据。凭据只能存放在指定密钥存储中,不得打印、复制进日志、提交或披露。
56
+
57
+ ### 数据可能流向
58
+
59
+ - QQ 开放平台及 QQ 客户端,取决于机器人的消息行为。
60
+ - 部署者选择的 OpenCode 服务和执行环境。
61
+ - OpenCode 服务配置的 AI/模型提供方;其隐私条款、留存政策和地域处理规则可能同时适用。
62
+ - 通过 `QQ_STT_*` 配置的外部语音识别提供方:启用后,音频字节和文件名会发送至所选转写端点,该提供方的隐私、留存及地域处理规则同时适用。
63
+ - `~/.openqq/` 等本地运行时存储,可能包含配置、台账、消息相关状态和日志。
64
+ - 下载的图片附件保存在系统临时目录的 `opencode/qq-images` 下;超过七天的文件仅在 bot 启动时尝试清理,其余保存与删除仍属运维责任。
65
+
66
+ 本仓库不会替部署者建立由维护者运营的数据处理服务。部署者仍须核实其实际端点、服务提供方、子进程、日志目的地,以及环境中的遥测或外部集成。
67
+
68
+ ### 保存与访问
69
+
70
+ - 各类数据的保存期限随功能和配置而异。部分投递去重记录有有界保存期,其他会话、表单、队列和诊断记录可能持续保存,直到配置的清理或人工删除。
71
+ - 统一日志按配置预算滚动。留存与删除属于运维责任,不能仅凭滚动机制推定已经满足隐私要求。
72
+ - 部署者必须限制对运行时文件、备份、日志、截图和导出文件的访问,并根据用户及适用法域制定保存、归档、删除和事件响应程序。
73
+
74
+ ### 部署者与用户责任
75
+
76
+ 部署者应根据适用法律及其角色:
77
+
78
+ 1. 向相关用户说明收集哪些数据、处理目的、接收方、存储位置和保存期限。
79
+ 2. 在处理个人信息、敏感信息、保密内容或员工/用户通信前,取得必要授权或具备其他合法处理依据。
80
+ 3. 避免收集不必要的密钥、敏感个人信息或保密材料,并尽可能减少镜像内容和附件。
81
+ 4. 启用外部 AI 服务或远程 QQ 服务前,评估跨境传输、处理者、子处理者及行业特别要求。
82
+ 5. 提供适当的查询、更正、删除、撤回同意和事件处理渠道。
83
+ 6. 防止凭据进入版本控制和日志,疑似泄露时及时轮换,不共享运行时密钥文件。
84
+
85
+ AI 生成内容可能不准确。用户必须独立复核,尤其是危险操作、权限、文件、专业判断及影响他人的决定。
86
+
87
+ 隐私相关问题请通过项目仓库 issue 联系,提交时不得包含密钥或敏感个人信息。
package/README.md CHANGED
@@ -26,7 +26,7 @@ Built for production, not just message bridging: a self-healing watchdog, an aud
26
26
  | Remote commands | `/new /cancel /status /sessions /history /models /agents /rename /progress /queue /ledger /send /undo /amend /goal /compact /redo /btw` |
27
27
  | Busy-time steer | New messages while a turn is running merge into the current turn (official steer semantics — the default); enqueue explicitly with `/queue <text>`; classic FIFO via `QQ_BUSY_DEFAULT=queue` |
28
28
  | Goal mode | `/goal <objective>` passes through to the engine's goal mode with status-change notifications and kickoff attribution; `/goal` shows status, `pause|resume|clear` to control |
29
- | Rich media | Receive images (native attachments go to the AI for vision); **receive voice** (QQ's built-in ASR transcribes to text into the prompt for free); **send images/files** — the AI calls the native `qq_send_file` tool (path allowlist + idempotent dedupe + precise errors; `QQ_SEND_FILE:` marker retained as fallback) or you run `/send <path>`; 20MB limit |
29
+ | Rich media | Receive images (native attachments go to the AI for vision); **receive voice** (QQ's built-in ASR transcribes to text into the prompt for free); **receive text/PDF/Office documents** (txt/md/code inject directly, docx/xlsx/pptx extract text locally, PDF passes through; legacy doc/xls/ppt gets explicit conversion guidance); **send images/files** — the AI calls the native `qq_send_file` tool (path allowlist + idempotent dedupe + precise errors; `QQ_SEND_FILE:` marker retained as fallback) or you run `/send <path>`; 20MB limit |
30
30
  | Quote context | Long-press quote a message and ask — the AI sees the quoted content (our own replies are indexed too) |
31
31
  | Long tasks never lost | 30-min foreground timeout falls back to a background wait (SSE + polling, up to 24h); a 30-min stall triggers a proactive notice with status (stalled / unknown / finished-but-lost), the latest tool action, and how long there's been no progress |
32
32
  | Duplicate-proof delivery | Two-layer dedup: cross-process atomic msgId claim + same-content in-flight fingerprint; long identical replies deduped outbound for 24h; "received" ack bubble off by default (`QQ_ACK_RECEIPT=1` to enable) |
@@ -92,6 +92,13 @@ QQ_SANDBOX=false
92
92
  - **Plugin flavor**: nothing to start manually — once the plugin is installed and credentials are set, the plugin's patrol launches the bot; it also recovers when the OpenCode service restarts.
93
93
  - **Standalone flavor**: run `openqq` in the foreground; for daemon mode pick your OS (Windows: Task Scheduler via `openqq service install`; Linux: `systemd --user`; macOS: launchd or `nohup`).
94
94
 
95
+ ### Stop and uninstall (to avoid confusion)
96
+
97
+ - **Stop the bot**: `openqq stop` (waits for in-flight turns by default, then performs a supervised graceful stop without spawning a replacement; supervisors will not revive it until `openqq restart` clears the hold).
98
+ - **Remove autostart only**: `openqq service uninstall` (the bot may keep running).
99
+ - **Full shutdown**: `openqq service uninstall --stop-bot` (remove autostart, then stop the bot through the same supervised path).
100
+ - **Plugin removal boundary**: `opencode plugin remove @linjz/opencode-qqbot` removes only the in-host bootstrap and patrol; it **does not stop an already independent bot process**. Run `openqq service uninstall --stop-bot` for a complete shutdown.
101
+
95
102
  <details>
96
103
  <summary>Linux: systemd --user unit (copy-paste ready)</summary>
97
104
 
@@ -190,6 +197,7 @@ launchctl load ~/Library/LaunchAgents/net.opencode-qqbot.plist
190
197
  | `QQ_ORPHAN_MS` | 90000 | Orphan threshold (accepted but silent beyond this; valid 5s–60min, invalid falls back) |
191
198
  | `QQ_WATCHDOG_INTERVAL_MS` | 300000 | Plugin bootstrap patrol interval (5min; the service-side autostart default is 10min) |
192
199
  | `QQ_PERM_DEFER_MS` | 500 | Approval card deferral window (0–10s): if the request is resolved elsewhere within the window, no QQ card — aligns with desktop silent handling |
200
+ | `QQ_PERM_SEND_GRACE_MS` | 1000 | Cancellable grace window before the QQ API call for approval cards (0–10s, 0 disables): if the request is resolved inside the window, the card is abandoned to prevent "resolved notice first, dead card later"; totals 1500ms with the defer window |
193
201
  | `QQ_QUEUE_RECEIPTS` | off | Queue-completion receipt "queue #N done" (off by default to prevent batch spam) |
194
202
  | `QQ_LOG_FILE` | `~/.openqq/openqq.log` (unified log, bot + watchdog in one file) | In-process file log path; 20MB × 4 generations, 100MB total budget (`QQ_LOG_MAX_MB`/`QQ_LOG_KEEP`/`QQ_LOG_TOTAL_MB` tunable) |
195
203
  | `QQBOT_DEFAULT_CWD` | bot process cwd | Default project directory for new sessions |
@@ -288,7 +296,7 @@ Hard-won findings from real deployments (Windows 11 / OpenCode v2.2.2) — the p
288
296
  **QQ platform**
289
297
 
290
298
  1. The token endpoint `POST https://bots.qq.com/app/getAppAccessToken` takes **`clientSecret`** (older docs say `appSecret`); the `100016 invalid appid or secret` error is misleading — check the field name before resetting your secret.
291
- 2. Tokens are environment-independent and always use the production domain `bots.qq.com`; **the sandbox domain `sandbox.api.sgroup.qq.com has no token endpoint** (it returns `11001 unsupported call`).
299
+ 2. Tokens are environment-independent and always use the production domain `bots.qq.com`; **the sandbox domain `sandbox.api.sgroup.qq.com` has no token endpoint** (it returns `11001 unsupported call`).
292
300
  3. Sandbox bots have a separate gateway: `GET https://sandbox.api.sgroup.qq.com/gateway` → `wss://sandbox.api.sgroup.qq.com/websocket`; a sandbox bot connecting to the production gateway is rejected with 4914.
293
301
 
294
302
  **OpenCode side**
@@ -312,6 +320,15 @@ The QQ bridge is an adapter from "OpenCode interaction events" to "QQ interactio
312
320
 
313
321
  Principle: unsupported types always get explicit copy + desktop guidance, never silent drops; enhancements like the per-field wizard land with minimal intrusion.
314
322
 
323
+ ## Compliance, trademarks, and data responsibility
324
+
325
+ - **Independent project**: this is an independent open-source project, not an official product of Tencent, QQ, or OpenCode. It is not sponsored, certified, or endorsed by them. References to official APIs, SDKs, semantics, or quota alignment describe platform documentation or behavioral alignment only.
326
+ - **Platform rules**: deployers and users must review and comply with the applicable QQ Open Platform and OpenCode agreements, API terms, bot rules, content-safety requirements, and laws. Do not bypass authentication, access controls, quotas, permission approvals, content review, or sandbox and production restrictions. Feature availability depends on current platform rules and account permissions.
327
+ - **Trademarks**: QQ, Tencent, OpenCode, and related marks belong to their respective owners. They are used only to identify compatibility and interoperability, not to imply official status, sponsorship, or endorsement. Do not use official logos or certification imagery without authorization.
328
+ - **Data and AI output**: deployers must inform affected users how messages, voice, images, files, sessions, and logs are collected, transmitted, processed, and retained, and must obtain any required authorization or have another lawful basis. Avoid unnecessary sensitive personal information, credentials, or confidential content. AI output may be incorrect and must be reviewed, especially for approvals, dangerous actions, and professional matters. See [PRIVACY.md](./PRIVACY.md).
329
+ - **License and liability**: this project is provided under the MIT License; the license and disclaimer in [LICENSE](./LICENSE) govern. Deployers remain responsible for their configuration, data processing, content, and use. Nothing in this section limits the rights granted by the MIT License or excludes liability that cannot be excluded by applicable law.
330
+ - **Third-party notices**: upstream and bundled third-party attributions are preserved in [THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md), including the derived reply-limiter implementation, QQ upstream projects, and bundled `ws` code.
331
+
315
332
  ## License
316
333
 
317
- MIT
334
+ MIT — see [LICENSE](./LICENSE) for the complete license and disclaimer.
package/README.zh-CN.md CHANGED
@@ -24,7 +24,7 @@
24
24
  | 远程指令 | `/new /cancel /status /sessions /history /models /agents /rename /progress /queue /ledger /send /undo /amend /goal /compact /redo /btw` |
25
25
  | 忙时 steer | 回合进行中收到新消息默认并入当前回合(官方 steer 语义);`/queue <文本>` 显式排队;`QQ_BUSY_DEFAULT=queue` 切回经典 FIFO |
26
26
  | goal 模式 | `/goal <目标>` 直通引擎目标模式——状态变化通知 + kickoff 🎯 归属;`/goal` 查状态,pause/resume/clear 控制 |
27
- | 富媒体 | 收图(原生附件给 AI 看图);**收语音**(QQ 内置 ASR 免费转文字进 prompt);**发图/发文件**——AI 调原生 `qq_send_file` 工具(路径白名单+幂等去重+精确错误,失败会告诉你可以发哪些根目录;`QQ_SEND_FILE:` 标记保留为降级通道)或 `/send <路径>`,20MB 上限 |
27
+ | 富媒体 | 收图(原生附件给 AI 看图);**收语音**(QQ 内置 ASR 免费转文字进 prompt);**收文本/PDF/Office 文档**(txt/md/代码等直接注入,docx/xlsx/pptx 本地提取文本,PDF 原样注入;旧版 doc/xls/ppt 明确指引转换);**发图/发文件**——AI 调原生 `qq_send_file` 工具(路径白名单+幂等去重+精确错误,失败会告诉你可以发哪些根目录;`QQ_SEND_FILE:` 标记保留为降级通道)或 `/send <路径>`,20MB 上限 |
28
28
  | 引用上下文 | 长按引用某条消息提问,AI 能感知被引用的内容(我方回复也会入索引缓存) |
29
29
  | 长任务不丢 | 前台 30min 超时 → 后台等待(SSE + 轮询,最长 24h);停滞 30min 主动提醒(带「已停滞/状态不明/已终结未回传」状态位 + 最近工具动作 + 无进展时长) |
30
30
  | 投递幂等 | 双层去重:同 msgId 跨进程原子占位 + 同内容在途指纹(窗口=并发在途;已完成消息的重发按重发处理);同文长回复 24h 出站去重;「已收到」受理回执默认关(`QQ_ACK_RECEIPT=1` 调试召回) |
@@ -87,6 +87,13 @@ QQ_SANDBOX=false
87
87
  - **插件形态**:无需手动启动——装好插件 + 配好凭据后,插件巡检自动拉起 bot;opencode 服务重启也会自动恢复。
88
88
  - **独立部署形态**:`openqq` 前台运行;常驻按 OS 自选(Windows:`openqq service install` 注册计划任务;Linux `systemd --user`;macOS launchd 或 `nohup`)。
89
89
 
90
+ ### 停止与卸载(避免误解)
91
+
92
+ - **停止 bot**:`openqq stop`(默认等待在途回合空闲,走监督矩阵优雅停止,不拉起新进程;停止后巡检不会复活,`openqq restart` 解除并恢复)。
93
+ - **只移除自启**:`openqq service uninstall`(bot 仍可能继续运行)。
94
+ - **完整停用**:`openqq service uninstall --stop-bot`(先注销自启,再受控停止 bot)。
95
+ - **插件移除边界**:`opencode plugin remove @linjz/opencode-qqbot` 只移除 OpenCode 宿主内的引导与巡检,**不会停止已独立运行的 bot**;要彻底停用请再执行 `openqq service uninstall --stop-bot`。
96
+
90
97
  <details>
91
98
  <summary>Linux:systemd --user 单元(复制即用)</summary>
92
99
 
@@ -183,9 +190,10 @@ launchctl load ~/Library/LaunchAgents/net.opencode-qqbot.plist
183
190
  | `QQ_DIGEST_ANSWER_MAX_CHARS` | 0(全文) | 摘要卡答案截断上限 |
184
191
  | `QQ_HISTORY_USER_CLIP` / `QQ_HISTORY_TEXT_CLIP` | 500 / 1200 | /history 用户/AI 行截断 |
185
192
  | `QQ_SEND_EXTRA_ROOTS` | — | `/send` 额外允许目录(逗号分隔) |
186
- | `QQ_ORPHAN_MS` | 90000 | 孤儿判定阈值(受理后无下文超此时长记孤儿;合法 5s~60min,非法回退默认) |
193
+ | `QQ_ORPHAN_MS` | 90000 | 孤儿判定阈值(受理后无下文超此时长记孤儿;合法 5s 至 60min,非法回退默认) |
187
194
  | `QQ_WATCHDOG_INTERVAL_MS` | 300000 | 插件引导器巡检间隔(5min;计划任务侧由 service install 注册,默认 10min) |
188
- | `QQ_PERM_DEFER_MS` | 500 | 审批弹卡延迟判定窗(0~10s):窗口内 ask 已被其他端处置则不推 QQ 卡,与桌面静默放行对齐 |
195
+ | `QQ_PERM_DEFER_MS` | 500 | 审批弹卡延迟判定窗(0 至 10s):窗口内 ask 已被其他端处置则不推 QQ 卡,与桌面静默放行对齐 |
196
+ | `QQ_PERM_SEND_GRACE_MS` | 1000 | 审批卡调 QQ API 前的可取消发送窗(0 至 10s,0 关闭):窗内请求已被其他端处置则弃发,防“已处理通知先到、死卡后到”;与延迟判定窗合计 1500ms 总窗口 |
189
197
  | `QQ_QUEUE_RECEIPTS` | 关 | 队列完成回执「队列 #N 完成」(批量排空防刷,默认关) |
190
198
  | `QQ_LOG_FILE` | `~/.openqq/openqq.log`(统一日志,bot 与看门狗同文件) | 进程内文件日志路径;滚动 20MB×4 代、总预算 100MB(`QQ_LOG_MAX_MB`/`QQ_LOG_KEEP`/`QQ_LOG_TOTAL_MB` 可调) |
191
199
  | `QQBOT_DEFAULT_CWD` | bot 进程工作目录 | 新会话默认项目目录(目录继承链兜底值) |
@@ -321,7 +329,16 @@ QQ 桥的本质是「opencode 交互事件 → QQ 交互原语」的适配器。
321
329
 
322
330
  Install: `opencode plugin add @linjz/opencode-qqbot` — Chinese README below, docs/review playbook in the repo.
323
331
 
332
+ ## 合规、商标与免责声明
333
+
334
+ - **项目独立性**:本项目为独立开源项目,不是腾讯、QQ 或 OpenCode 的官方产品,也未获得其赞助、认证或背书。文中“官方 API”“官方 SDK”“官方语义”“官方配额对齐”等表述,仅用于描述平台文档、协议或行为对齐,不表示本项目属于官方产品。
335
+ - **平台规则**:部署者和使用者须自行阅读并遵守 QQ 开放平台及 OpenCode 当前有效的服务协议、API 使用条款、机器人管理规范、内容安全规则及适用法律法规。不得绕过鉴权、访问控制、配额、权限审批、内容审查以及沙箱与正式环境限制。具体功能可用性以各平台当前规则和账号权限为准。
336
+ - **商标**:QQ、腾讯、OpenCode 及相关标识归其权利人所有,仅在说明兼容性和互操作目的下使用,不暗示官方身份、赞助或背书。未经授权,不使用官方 logo、认证形象或进行暗示官方关系的宣传。
337
+ - **数据与 AI 输出**:部署者应向相关用户说明消息、语音、图片、文件、会话及日志的收集、传输、处理和保存方式,并依法取得必要授权或具备其他合法处理依据。请勿提交不必要的敏感个人信息、密钥或保密信息。AI 生成内容可能不准确,使用者应自行复核,尤其是权限审批、危险操作和专业事项。详见 [PRIVACY.md](./PRIVACY.md)。
338
+ - **许可与责任**:本项目按 MIT 许可证发布,许可证及免责声明以 [LICENSE](./LICENSE) 为准。部署者对其配置、数据处理、内容和使用行为负责;本声明不限制 MIT 许可证授予的权利,也不排除适用法律要求承担的责任。
339
+ - **第三方声明**:上游及打包第三方组件的来源与许可说明见 [THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md),包括派生的回复限额器、QQ 上游项目及打包的 `ws` 代码。
340
+
324
341
  ## License
325
342
 
326
- MIT
343
+ MIT — 完整许可与免责声明见 [LICENSE](./LICENSE)。
327
344
 
@@ -0,0 +1,136 @@
1
+ # Third-Party Notices
2
+
3
+ This file records upstream code, design references, and bundled dependencies whose licenses require attribution. It supplements, and does not replace, the project's [LICENSE](./LICENSE).
4
+
5
+ ## Scope notes
6
+
7
+ - `src/core/reply-limiter.ts` is a derived revision of `tencent-connect/openclaw-qqbot/src/outbound/reply-limiter.ts`. The interface, defaults, and core state machine are intentionally preserved. It is not represented as independent original work.
8
+ - `src/core/outbound-sanitize.ts` is a derived revision of `openclaw-qqbot/src/outbound/sanitize.ts`, retaining the principal regular expressions and stripping sequence with project-specific consolidation.
9
+ - `normalizeLocalPath` in `src/core/send-media.ts` is a derived revision of `openclaw-qqbot/src/outbound/local-file-router.ts`'s `normalizePath`. The rest of the send-media workflow is implemented independently by this project.
10
+ - `src/qq/sender.ts`, `src/core/card-approval.ts`, `src/core/context-buffer.ts`, `src/core/delivery.ts`, `src/core/notices.ts`, and `src/bridge.ts` contain independent project implementations or extensions informed by the sources below. These references do not imply that every file is copied.
11
+ - `dist/openqq-bot.js` contains bundled code from `ws`. The `ws` copyright and license below must remain with distributed copies of that bundle.
12
+
13
+ ## tencent-connect/openclaw-qqbot
14
+
15
+ - Source: https://github.com/tencent-connect/openclaw-qqbot
16
+ - Reviewed source revision: `89988812442583bf47c34b89f9abf5fd4b85df0b`
17
+ - Used for: the derived reply limiter, outbound sanitizer, local-path normalization, and related passive-reply design references.
18
+ - License: MIT
19
+
20
+ ```text
21
+ MIT License
22
+
23
+ Copyright (c) 2026 sliverp
24
+ Copyright (c) 2026 Tencent Connect
25
+
26
+ Permission is hereby granted, free of charge, to any person obtaining a copy
27
+ of this software and associated documentation files (the "Software"), to deal
28
+ in the Software without restriction, including without limitation the rights
29
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
30
+ copies of the Software, and to permit persons to whom the Software is
31
+ furnished to do so, subject to the following conditions:
32
+
33
+ The above copyright notice and this permission notice shall be included in all
34
+ copies or substantial portions of the Software.
35
+
36
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
37
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
38
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
39
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
40
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
41
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
42
+ SOFTWARE.
43
+ ```
44
+
45
+ ## tencent-connect/dsh-qqbot
46
+
47
+ - Source: https://github.com/tencent-connect/dsh-qqbot
48
+ - Reviewed baseline: `63abb82` (the clone also contains that baseline revision).
49
+ - Used for: chunking, button-data, approval-channel, and msgid-cache design references.
50
+ - License: MIT
51
+
52
+ ```text
53
+ MIT License
54
+
55
+ Copyright (c) 2026 Tencent Connect
56
+
57
+ Permission is hereby granted, free of charge, to any person obtaining a copy
58
+ of this software and associated documentation files (the "Software"), to deal
59
+ in the Software without restriction, including without limitation the rights
60
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
61
+ copies of the Software, and to permit persons to whom the Software is
62
+ furnished to do so, subject to the following conditions:
63
+
64
+ The above copyright notice and this permission notice shall be included in all
65
+ copies or substantial portions of the Software.
66
+
67
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
68
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
69
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
70
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
71
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
72
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
73
+ SOFTWARE.
74
+ ```
75
+
76
+ ## @tencent-connect/qqbot-nodejs
77
+
78
+ - Source: https://github.com/tencent-connect/qqbot-nodejs
79
+ - npm package: `@tencent-connect/qqbot-nodejs@1.0.5`
80
+ - Used for: protocol shapes and quote-reference design references.
81
+ - License: MIT
82
+
83
+ ```text
84
+ MIT License
85
+
86
+ Copyright (c) 2026 Tencent
87
+
88
+ Permission is hereby granted, free of charge, to any person obtaining a copy
89
+ of this software and associated documentation files (the "Software"), to deal
90
+ in the Software without restriction, including without limitation the rights
91
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
92
+ copies of the Software, and to permit persons to whom the Software is
93
+ furnished to do so, subject to the following conditions:
94
+
95
+ The above copyright notice and this permission notice shall be included in all
96
+ copies or substantial portions of the Software.
97
+
98
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
99
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
100
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
101
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
102
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
103
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
104
+ SOFTWARE.
105
+ ```
106
+
107
+ ## ws
108
+
109
+ - Source: https://github.com/websockets/ws
110
+ - Reviewed npm package: `ws@8.22.0` (declared dependency range: `^8.18.0`).
111
+ - Used for: WebSocket implementation bundled into `dist/openqq-bot.js`.
112
+ - License: MIT
113
+
114
+ ```text
115
+ Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
116
+ Copyright (c) 2013 Arnout Kazemier and contributors
117
+ Copyright (c) 2016 Luigi Pinca and contributors
118
+
119
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
120
+ this software and associated documentation files (the "Software"), to deal in
121
+ the Software without restriction, including without limitation the rights to
122
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
123
+ the Software, and to permit persons to whom the Software is furnished to do so,
124
+ subject to the following conditions:
125
+
126
+ The above copyright notice and this permission notice shall be included in all
127
+ copies or substantial portions of the Software.
128
+
129
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
130
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
131
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
132
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
133
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
134
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
135
+ SOFTWARE.
136
+ ```
package/bin/openqq.js CHANGED
@@ -24,7 +24,7 @@ function runChild(cmd, args) {
24
24
  if (argv[0] === "watchdog") {
25
25
  runChild(detectBun() ?? "node", [join(root, "dist", "openqq-watchdog.js"), ...argv.slice(1)])
26
26
  }
27
- if (argv[0] === "restart" || argv[0] === "service") {
27
+ if (argv[0] === "restart" || argv[0] === "stop" || argv[0] === "service") {
28
28
  runChild("node", [join(root, "dist", "openqq-cli.js"), ...argv])
29
29
  }
30
30
 
@@ -204,6 +204,33 @@ function readJson(path, fallback) {
204
204
  return fallback;
205
205
  }
206
206
  }
207
+ function defaultHoldPath() {
208
+ return join2(homedir(), ".openqq", "supervisor-hold.json");
209
+ }
210
+ function readSupervisorHold(path = defaultHoldPath()) {
211
+ try {
212
+ const raw = JSON.parse(readFileSync2(path, "utf-8"));
213
+ if (raw?.version === 1 && typeof raw.reason === "string" && typeof raw.by === "string" && typeof raw.at === "number") {
214
+ return raw;
215
+ }
216
+ } catch {}
217
+ return null;
218
+ }
219
+ function writeSupervisorHold(path, reason, by) {
220
+ try {
221
+ writeFileSync2(path, JSON.stringify({ version: 1, reason, by, at: Date.now() }));
222
+ } catch {}
223
+ }
224
+ function clearSupervisorHold(path) {
225
+ try {
226
+ if (!existsSync2(path))
227
+ return false;
228
+ unlinkSync2(path);
229
+ return true;
230
+ } catch {
231
+ return false;
232
+ }
233
+ }
207
234
  async function superviseOnce(deps) {
208
235
  const policy = deps.policy ?? DEFAULT_SUPERVISOR_POLICY;
209
236
  const now = deps.now?.() ?? Date.now();
@@ -240,7 +267,25 @@ async function superviseOnce(deps) {
240
267
  try {
241
268
  const health = readBotHealth(deps.paths, now);
242
269
  const state = readJson(statePath, { restartLog: [] });
270
+ const holdPath = deps.holdPath ?? defaultHoldPath();
271
+ const hold = readSupervisorHold(holdPath);
272
+ if (hold && (!deps.request || deps.request === "health-check")) {
273
+ if (health.lockPid === null || health.pidAlive === false) {
274
+ log(`[supervisor] manual-stop hold \u751F\u6548\uFF08${hold.reason}\uFF09\uFF0C\u8DF3\u8FC7\u62C9\u8D77`);
275
+ return { action: "yield", detail: `manual-stop hold \u751F\u6548\uFF1A${hold.reason}`, killedPid: null, spawnedPid: null };
276
+ }
277
+ if (clearSupervisorHold(holdPath)) {
278
+ log(`[supervisor] manual-stop hold \u5931\u6548\uFF1Abot \u5DF2\u5728\u8FD0\u884C\uFF0C\u6062\u590D\u5E38\u89C4\u76D1\u7763`);
279
+ }
280
+ }
281
+ if (deps.request === "manual-restart" && hold) {
282
+ if (clearSupervisorHold(holdPath))
283
+ log(`[supervisor] manual-stop hold \u5DF2\u89E3\u9664\uFF08openqq restart\uFF09`);
284
+ }
243
285
  let action = decideSupervise(health, state, now, policy);
286
+ if (deps.request === "manual-stop") {
287
+ action = health.lockPid !== null && health.pidAlive !== false ? { kind: "grace-kill-spawn", killPid: health.lockPid, reason: "\u4EBA\u5DE5\u8BF7\u6C42\u505C\u6B62\uFF08openqq stop\uFF09" } : { kind: "spawn", reason: "\u4EBA\u5DE5\u8BF7\u6C42\u505C\u6B62\uFF08bot \u672A\u8FD0\u884C\uFF0C\u4EC5\u6E05\u9501\uFF09" };
288
+ }
244
289
  if (deps.request === "manual-restart" && action.kind === "ok") {
245
290
  const windowStart = now - policy.windowMs;
246
291
  const recentRestarts = state.restartLog.filter((t) => t > windowStart).length;
@@ -284,7 +329,7 @@ async function superviseOnce(deps) {
284
329
  let killedPid = null;
285
330
  if (action.kind === "grace-kill-spawn" && action.killPid !== process.pid) {
286
331
  const pid = action.killPid;
287
- if (deps.request !== "manual-restart") {
332
+ if (deps.request !== "manual-restart" && deps.request !== "manual-stop") {
288
333
  await sleep(300);
289
334
  const recheck = readBotHealth(deps.paths, Date.now());
290
335
  const recheckFresh = recheck.heartbeatAgeMs !== null && recheck.heartbeatAgeMs <= HEARTBEAT_STALE_MS;
@@ -334,6 +379,31 @@ async function superviseOnce(deps) {
334
379
  if (cleared.length > 0)
335
380
  audit(`\u6E05\u9501\uFF1A${cleared.join("\u3001")}\uFF08${action.reason}\uFF09`);
336
381
  } catch {}
382
+ if (deps.request === "manual-stop") {
383
+ writeSupervisorHold(holdPath, action.reason, "openqq stop");
384
+ const detail = killedPid ? `${action.reason}\uFF1B\u5DF2\u4F18\u96C5\u505C pid=${killedPid}\uFF1B\u9501\u5DF2\u6E05\uFF1Bhold \u5DF2\u7ACB\uFF08\u5DE1\u68C0\u4E0D\u62C9\u8D77\uFF09` : `${action.reason}\uFF1B\u9501\u5DF2\u6E05\uFF1Bhold \u5DF2\u7ACB\uFF08\u5DE1\u68C0\u4E0D\u62C9\u8D77\uFF09`;
385
+ if (killedPid !== null) {
386
+ appendKillLog({
387
+ kind: "decision",
388
+ reason: action.reason,
389
+ health: {
390
+ lockPid: health.lockPid,
391
+ pidAlive: health.pidAlive,
392
+ heartbeatAgeMs: health.heartbeatAgeMs,
393
+ lockAgeMs: health.lockAgeMs
394
+ },
395
+ killedPid,
396
+ killEscalation: "TERM",
397
+ spawnedPid: null,
398
+ restartIntensity: `${state.restartLog.length}/${policy.maxRestarts}`,
399
+ livenessVerdict: "stopped",
400
+ at: Date.now()
401
+ });
402
+ }
403
+ audit(`\u4E3B\u52A8\u505C\uFF1A${detail}`);
404
+ log(`[supervisor] \u4E3B\u52A8\u505C\uFF1A${detail}`);
405
+ return { action: "stopped", detail, killedPid, spawnedPid: null };
406
+ }
337
407
  const spawnedPid = deps.spawn();
338
408
  state.restartLog.push(Date.now());
339
409
  state.restartLog = state.restartLog.filter((t) => t > Date.now() - policy.windowMs * 2);
@@ -404,7 +474,7 @@ async function superviseOnce(deps) {
404
474
  }
405
475
 
406
476
  // src/core/bot-control.ts
407
- import { existsSync as existsSync4, readFileSync as readFileSync4 } from "fs";
477
+ import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync as readdirSync2 } from "fs";
408
478
  import { dirname as dirname3, join as join4 } from "path";
409
479
  import { fileURLToPath } from "url";
410
480
 
@@ -1260,7 +1330,7 @@ function electSupervisor(channel, opts) {
1260
1330
  }
1261
1331
 
1262
1332
  // src/core/send-requests.ts
1263
- import { existsSync as existsSync9, mkdirSync as mkdirSync4, readdirSync as readdirSync2, readFileSync as readFileSync10, renameSync as renameSync3, statSync as statSync6, writeFileSync as writeFileSync6 } from "fs";
1333
+ import { existsSync as existsSync9, mkdirSync as mkdirSync4, readdirSync as readdirSync3, readFileSync as readFileSync10, renameSync as renameSync3, statSync as statSync6, writeFileSync as writeFileSync6 } from "fs";
1264
1334
  import { join as join10 } from "path";
1265
1335
  import { randomUUID as randomUUID2 } from "crypto";
1266
1336
 
@@ -1268,8 +1338,56 @@ import { randomUUID as randomUUID2 } from "crypto";
1268
1338
  import { resolve, extname, basename, sep, join as join9 } from "path";
1269
1339
  import { homedir as homedir7 } from "os";
1270
1340
 
1341
+ // src/core/office-text.ts
1342
+ var MAX_ENTRY_UNCOMPRESSED_BYTES = 50 * 1024 * 1024;
1343
+
1271
1344
  // src/qq/media.ts
1272
1345
  var MAX_IMAGE_BYTES = 10 * 1024 * 1024;
1346
+ var MAX_FILE_BYTES = 20 * 1024 * 1024;
1347
+ var TEXT_FILE_EXTENSIONS = new Set([
1348
+ "txt",
1349
+ "md",
1350
+ "markdown",
1351
+ "json",
1352
+ "jsonc",
1353
+ "log",
1354
+ "csv",
1355
+ "tsv",
1356
+ "xml",
1357
+ "yaml",
1358
+ "yml",
1359
+ "toml",
1360
+ "ini",
1361
+ "cfg",
1362
+ "conf",
1363
+ "js",
1364
+ "mjs",
1365
+ "cjs",
1366
+ "ts",
1367
+ "tsx",
1368
+ "jsx",
1369
+ "py",
1370
+ "java",
1371
+ "go",
1372
+ "rs",
1373
+ "c",
1374
+ "h",
1375
+ "cpp",
1376
+ "hpp",
1377
+ "cs",
1378
+ "sql",
1379
+ "sh",
1380
+ "ps1",
1381
+ "bat",
1382
+ "cmd",
1383
+ "html",
1384
+ "htm",
1385
+ "css",
1386
+ "scss",
1387
+ "less",
1388
+ "vue",
1389
+ "svelte"
1390
+ ]);
1273
1391
 
1274
1392
  // src/qq/api.ts
1275
1393
  var appSandboxRegistry = new Map;
@@ -1317,7 +1435,7 @@ function findQQBinding(sessionId, root = storageRoot()) {
1317
1435
  const candidates = [{ file: join10(root, "sessions.json") }];
1318
1436
  const rolesDir = join10(root, "roles");
1319
1437
  if (existsSync9(rolesDir)) {
1320
- for (const role of readdirSync2(rolesDir)) {
1438
+ for (const role of readdirSync3(rolesDir)) {
1321
1439
  candidates.push({ file: join10(rolesDir, role, "sessions.json"), appId: role });
1322
1440
  }
1323
1441
  }
@@ -1395,7 +1513,7 @@ async function executeQQSendFile(input, context) {
1395
1513
  }
1396
1514
 
1397
1515
  // src/core/qq-instructions.ts
1398
- import { existsSync as existsSync10, mkdirSync as mkdirSync5, readdirSync as readdirSync3, readFileSync as readFileSync11, writeFileSync as writeFileSync7 } from "fs";
1516
+ import { existsSync as existsSync10, mkdirSync as mkdirSync5, readdirSync as readdirSync4, readFileSync as readFileSync11, writeFileSync as writeFileSync7 } from "fs";
1399
1517
  import { dirname as dirname5, join as join11 } from "path";
1400
1518
  var QQ_INSTRUCTION_KEY = "qq";
1401
1519
  var QQ_INSTRUCTION_TEXT = [
@@ -1411,7 +1529,7 @@ function listQQBindings(root = storageRoot()) {
1411
1529
  const candidates = [{ file: join11(root, "sessions.json") }];
1412
1530
  const rolesDir = join11(root, "roles");
1413
1531
  if (existsSync10(rolesDir)) {
1414
- for (const role of readdirSync3(rolesDir))
1532
+ for (const role of readdirSync4(rolesDir))
1415
1533
  candidates.push({ file: join11(rolesDir, role, "sessions.json"), appId: role });
1416
1534
  }
1417
1535
  const out = [];