@zaofan/dsh-qqbot 1.12.12 → 1.12.14

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/LICENSE CHANGED
@@ -1,21 +1,43 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Tencent Connect
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ Academic Free License (“AFL”) v. 3.0
2
+
3
+ This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
4
+
5
+ Licensed under the Academic Free License version 3.0
6
+
7
+ 1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
8
+
9
+ a) to reproduce the Original Work in copies, either alone or as part of a collective work;
10
+ b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
11
+ c) to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor’s reserved rights and remedies, in this Academic Free License;
12
+ d) to perform the Original Work publicly; and
13
+ e) to display the Original Work publicly.
14
+
15
+ 2) Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
16
+
17
+ 3) Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
18
+
19
+ 4) Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor’s trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
20
+
21
+ 5) External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
22
+
23
+ 6) Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
24
+
25
+ 7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
26
+
27
+ 8) Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
28
+
29
+ 9) Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including “fair use” or “fair dealing”). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
30
+
31
+ 10) Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
32
+
33
+ 11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
34
+
35
+ 12) Attorneys’ Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
36
+
37
+ 13) Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
38
+
39
+ 14) Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
40
+
41
+ 15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
42
+
43
+ 16) Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
@@ -0,0 +1,82 @@
1
+ # 附加说明与额外许可(Additional Permissions)
2
+
3
+ > 本文件是**著作权人**(zaofan-make)就本项目所作的解释与额外授权,
4
+ > **不属于 Academic Free License 3.0(AFL-3.0)的正文,也不修改其条款**。
5
+ > 按 AFL-3.0 第 16 条,许可证正文不得被修改;本文件是另外给出的一份授权声明,
6
+ > 与 LICENSE 中的 AFL-3.0 并行生效:**能这么用,是因为著作权人额外允许你这么用**,
7
+ > 而不是因为 AFL-3.0 本身允许。
8
+
9
+ ## 0. 名词
10
+
11
+ | 记号 | 指什么 |
12
+ | --- | --- |
13
+ | **B(本体)** | 本仓库的源代码、构建产物(`dist/`)与配套文件 |
14
+ | **插件(Plugin)** | 通过 B 公开的扩展接口接入的独立程序,接口包括但不限于:`.qqbot-extensions/{tools,commands,inbound,hooks,outbound}/` 下的模块、扩展 UI 卡片、`env` / `caps` 公开 API |
15
+ | **M(修改器)** | 在 B 启动**之前**运行、修改 B 源文件的独立程序 |
16
+ | **B′** | M 修改之后的 B 的副本 |
17
+
18
+ ## 1. 插件不是本体的衍生作品
19
+
20
+ 通过 B 的公开扩展接口进行交互、且**未修改、复制或衍生 B 源代码**的插件,
21
+ **不构成 B 的衍生作品(Derivative Works)**。
22
+
23
+ 因此这类插件可以**自由选择其许可证**,包括与 AFL-3.0 不兼容的许可证
24
+ (例如 GPL-2.0/3.0、AGPL-3.0、EPL、CDDL 等),无需向本项目的著作权人取得额外同意。
25
+
26
+ ## 2. 独立程序可以聚合分发
27
+
28
+ 插件(以及 M 这类独立程序)与 B **各自独立许可、作为聚合体一并分发**,本许可不予限制。
29
+ AFL-3.0 的约束只作用于 B 的代码本身。
30
+
31
+ ## 3. 额外许可:启动前修改本体
32
+
33
+ 著作权人**额外授予**一项许可:
34
+
35
+ > 对于在启动前读取并修改 B 的源代码以增强功能的程序(M),
36
+ > 其**修改行为本身**不因该行为而违反 B 的 AFL-3.0 许可证。
37
+
38
+ 范围严格限于「修改行为本身」。以下不在本额外许可的授权范围内:
39
+
40
+ ## 4. 边界:修改产物 B′ 怎么分发
41
+
42
+ 先把 AFL-3.0 **§1(c)** 的原文摆出来(这是关键,别只看我们的总结):
43
+
44
+ > to distribute or communicate copies of the Original Work and Derivative Works to the public,
45
+ > **under any license of your choice that does not contradict the terms and conditions**,
46
+ > including Licensor's reserved rights and remedies, in this Academic Free License
47
+
48
+ 也就是说:**AFL-3.0 本身就允许你换许可证分发衍生作品**,
49
+ 条件只有一个——**你选的那个许可证不能与本许可的条款冲突**。
50
+
51
+ | 情形 | 是否允许 | 说明 |
52
+ | --- | --- | --- |
53
+ | **B′ 只在本地使用、不对外分发** | ✅ | 分发义务不触发,无附加要求 |
54
+ | **B′ 对外分发(多长的条款都行)** | ✅ | 必须保留原版权声明、并声明“已被修改”(§5) |
55
+ | **把 B′ 换成 MIT / Apache-2.0 / BSD / 闭源商业许可** | ✅ **允许** | 由 §1(c) 直接授权:这些许可与 AFL 不冲突(同样宽松、同样不强制开源),照做即可 |
56
+ | **把 B′ 换成 GPL-2.0/3.0、AGPL-3.0** | ❌ **不允许** | GPL 的 copyleft 条款与 AFL 的条款**直接冲突**(GPL 要求整件作品 GPL 兼容、且不得附加额外限制)⇒ 落进 §1(c) 的“contradict”里,被排除 |
57
+
58
+ **所以准确的表述是**:“B′ 可以换许可证,但**不能换成与 AFL 冲突的那些**(GPL/AGPL 就在这个名单里)”。
59
+
60
+ > 补充:第 3 条的额外许可只解决「修改行为本身合规」;
61
+ > **允许换证的依据是 AFL §1(c) 本身**,不需要我们额外授权。
62
+ > 我们这份说明只是把 §1(c) 的含义讲清楚,并明确 GPL/AGPL 属于“冲突”的那一类。
63
+
64
+ ## 5. 对插件作者的提醒(重要)
65
+
66
+ > **本文件给你的便利,不替代你在自己许可证下的义务。**
67
+
68
+ - 若你的插件是 **GPL/AGPL**:你与 B **在同一进程里结合运行**时,
69
+ GPL 侧仍可能认为构成「结合作品」,需要你自己处理兼容性
70
+ (常见做法:为你的插件增加**链接例外 / 组合例外**,或把插件写成独立进程)。
71
+ - 若你只是把插件放在 `.qqbot-extensions/` 里、由 B 动态加载,
72
+ 按本文件第 1 条它**不是衍生作品**;但这是本项目的立场,
73
+ **不能替 GPL 那边下结论** —— 请以你自己许可证的要求为准。
74
+ - 若你要分发 **B′ 与你的 GPL 插件组成的整体**,请自行确认合法性;
75
+ 本项目不为你的分发行为承担保证。
76
+
77
+ ## 6. 历史版本
78
+
79
+ - 本项目在 **v1.12.12 及更早**的版本以 **MIT** 发布,该授权**永久有效、不可撤回**。
80
+ 已经取得那些版本的人,仍可按 MIT 使用、修改与再分发(包括并入 GPL 项目)。
81
+ - 本文件所载的 AFL-3.0 与额外许可,**自 v1.12.13 起**适用于新版本。
82
+ - 上游第三方代码的许可见 `NOTICE`,不受本文件影响。
package/NOTICE ADDED
@@ -0,0 +1,47 @@
1
+ # NOTICE
2
+
3
+ 本项目(`@zaofan/dsh-qqbot`)自 **v1.12.13** 起以 **Academic Free License 3.0(AFL-3.0)** 发布,
4
+ 并附带 [`LICENSE-ADDENDUM.md`](./LICENSE-ADDENDUM.md) 中的额外权限说明。
5
+
6
+ ```
7
+ Copyright (c) 2026 zaofan-make
8
+ Licensed under the Academic Free License version 3.0
9
+ ```
10
+
11
+ ## 上游第三方代码(保留其原始许可证)
12
+
13
+ 本项目包含或链接了以下第三方作品。它们**不受**本项目 AFL-3.0 的授权,
14
+ 仍按其各自的原始许可证使用:
15
+
16
+ | 组件 | 版权 | 许可证 |
17
+ | --- | --- | --- |
18
+ | `@tencent-connect/qqbot-nodejs` | Copyright (c) Tencent | MIT |
19
+ | `@tencent-connect/qqbot-connector` | Copyright (c) Tencent | 见其包内声明 |
20
+ | 设计思路与部分实现参考自 `tencent-connect/dsh-qqbot` 等上游项目 | 各原作者 | MIT |
21
+
22
+ ## 运行时依赖(各自适用其许可证)
23
+
24
+ 主要依赖:`jimp`(MIT)、`js-yaml`(MIT)、`silk-wasm`(MIT)、`@deepseek-ai/schemastery`(MIT)、
25
+ `@deepseek-ai/dsh-client-ui-slots`(MIT)、`@deepseek-ai/dsh-client-ui-settings`(MIT)。
26
+
27
+ 其中包含 **LGPL-3.0** 组件:
28
+
29
+ | 组件 | 许可证 | 说明 |
30
+ | --- | --- | --- |
31
+ | `lamejs-fixed` | LGPL-3.0 | 语音转 mp3;作为**独立 npm 依赖**加载,可替换 |
32
+ | `@img/sharp-win32-x64` | Apache-2.0 AND LGPL-3.0-or-later | sharp 的 Windows 预编译二进制,动态加载 |
33
+
34
+ > 本项目**不把上述 LGPL 组件内联进构建产物**(`dist/` 通过 `require` 引用外部包),
35
+ > 以保证其可替换性符合 LGPL 要求。若你打算把本项目打包成单文件,请自行评估 LGPL 义务。
36
+
37
+ ## 历史
38
+
39
+ v1.12.12 及更早版本以 **MIT** 发布,该授权永久有效、不可撤回;本 NOTICE 不影响那些版本的使用者。
40
+
41
+ ## 贡献
42
+
43
+ 感谢本项目接收过的社区贡献(排名不分先后):
44
+ `kinokn`(#43 / #44 / #45)、`Chaos-Paradox`(#41)、`Cypas`(#23 / #27 / #31 相关讨论与修复)等。
45
+
46
+ 这些贡献在提交时按当时的 MIT 许可纳入;若其中任何作者对本次许可证变更(MIT → AFL-3.0)
47
+ 有异议,请开 issue 联系,我们会为该部分保留 MIT 声明或作相应处理。
package/README.md CHANGED
@@ -1,11 +1,28 @@
1
1
  # @zaofan/dsh-qqbot
2
2
 
3
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE) ![Platform](https://img.shields.io/badge/platform-QQ%20Bot%20(dsh)-blue)
3
+ [![License: AFL-3.0](https://img.shields.io/badge/License-AFL--3.0-blue.svg)](./LICENSE) ![Platform](https://img.shields.io/badge/platform-QQ%20Bot%20(dsh)-blue)
4
4
 
5
5
  基于 [deepseek-harness](https://github.com/deepseek-ai/deepseek-harness) (dsh) 的 QQ Bot IM 插件**增强 fork**:将 QQ 消息平台作为 dsh agent 的前端协议驱动,并加入表情包图库、富媒体收发、定时任务、多实例人格、好感度系统、可视化设置面板等能力。
6
6
 
7
7
  📦 仓库: [zaofan-make/dsh-qqbot](https://github.com/zaofan-make/dsh-qqbot)(fork 自 [tencent-connect/dsh-qqbot](https://github.com/tencent-connect/dsh-qqbot);改动都在这一侧,升级/重装上游会被冲掉)
8
8
 
9
+ ## 📄 许可证
10
+
11
+ 本项目自 **v1.12.13** 起采用 **[Academic Free License 3.0](./LICENSE)(AFL-3.0)** —— 宽松、允许闭源商用,
12
+ 但**与 GPL 不兼容**(GPL 项目无法把它整体并入并换证分发)。
13
+
14
+ **几句话看懂能干什么:**
15
+
16
+ - ✅ **插件不算衍生作品**:通过 `.qqbot-extensions/` 等公开扩展接口接入、没有改动本体的插件,
17
+ 可以**自选任何许可证**,包括 GPL / AGPL。→ 详见 [`LICENSE-ADDENDUM.md`](./LICENSE-ADDENDUM.md)
18
+ - ✅ **随便抄、随便改、可闭源商用**,条件只有:保留版权声明、注明“已修改”
19
+ - ✅ **启动前修改本体的工具(M)**:修改行为本身额外许可,不违反 AFL-3.0
20
+ - ❌ **不能把(修改后的)本体换成 GPL/AGPL 分发** —— AFL 与它们条款冲突;但**可以换成 MIT/Apache/闭源**(AFL §1(c) 明确允许,只要新许可不与 AFL 冲突)
21
+ - ⚠️ 你自己的 GPL 插件与本插件**结合运行时**的兼容性,仍需你自行处理(例如加链接例外)
22
+ - 📌 v1.12.12 及更早的 **MIT 版本永久有效**,已拿到的人仍可按 MIT 使用、包括并入 GPL
23
+
24
+ 上游第三方代码的许可证见 [`NOTICE`](./NOTICE)。
25
+
9
26
  > ⭐ **用得顺手的话,麻烦点一下右上角的 Star** —— 它是这个项目"有人在用"的唯一可见信号,也是继续更新的动力。
10
27
 
11
28
  中文 | [English](./README_EN.md) | 📖 **[用户手册](./docs/USER-GUIDE.md)**(配置项 / 内置命令 / 自定义扩展 / 群管理 / 智能回复 / 架构…)
package/README_EN.md CHANGED
@@ -637,4 +637,13 @@ If this plugin saved you some tokens — or made your QQ bot feel alive — a **
637
637
 
638
638
  ## License
639
639
 
640
- [MIT](./LICENSE)
640
+ Since **v1.12.13** this project is licensed under the **[Academic Free License 3.0](./LICENSE) (AFL-3.0)** —
641
+ permissive (proprietary use allowed) but **GPL-incompatible**.
642
+
643
+ - ✅ Extensions that only use the public `.qqbot-extensions/` interfaces (without modifying this project)
644
+ are **not derivative works** and may pick any license, including GPL/AGPL — see [`LICENSE-ADDENDUM.md`](./LICENSE-ADDENDUM.md).
645
+ - ✅ Copy, modify, use commercially; just keep the copyright notice and state that you changed it.
646
+ - ❌ You may **not** redistribute this project (or a modified copy of it) as a whole under GPL/AGPL.
647
+ - 📌 Versions up to **v1.12.12** remain **MIT** forever; those copies may still be used under MIT.
648
+
649
+ Third-party components keep their own licenses — see [`NOTICE`](./NOTICE).
@@ -272,6 +272,29 @@ handler 返回 `{ok:false,...}` 会原样透传,其它值包成 `{ok:true, dat
272
272
  | 宿主自重启 | `await env.restart()` | 复用内置 `/bot-restart`(自动识别启动命令、强补 `--no-open`)。默认**仅主人**可触发;要放开写 `env.restart({ requireOwner: false })` |
273
273
  | 回调按钮卡 | `env.registerInteractionCard({cardId, buttonIds, expireAt})` | 发**带回调按钮**的卡片必须先登记,否则点了没人认 |
274
274
 
275
+ ### `env.manager` —— 会话管理器(2026-11-08 补登)
276
+
277
+ 扩展拿到的 `env.manager` 就是插件内部的 **SessionManager 实例**,可以直接操作 QQ 会话。
278
+ 以下方法是**受支持的稳定接口**(其余同名内部方法可能随版本变动,别依赖):
279
+
280
+ | 需求 | 用法 |
281
+ |---|---|
282
+ | 按 DSH 会话 id 反查 QQ 会话 | `env.manager.findBySessionId(sessionId)` → `record \| undefined` |
283
+ | 按 agent 反查 | `env.manager.findByAgent(agent)` |
284
+ | 按 QQ peer 反查 | `env.manager.findByPeer(scope, peerId)` |
285
+ | 取会话记录 | `env.manager.getSessionRecord(scope, peerId)` |
286
+ | 当前用的模型 | `env.manager.getEffectiveModel(scope, peerId)` → `{provider, model, effort?}` |
287
+ | 切模型/强度 | `await env.manager.setModelOverride(scope, peerId, {provider, model, effort?})` |
288
+ | 可用模型列表 | `await env.manager.listAvailableModels()` |
289
+ | 思考强度档位 | `await env.manager.listReasoningEfforts()` |
290
+ | 列会话 | `env.manager.listSessions()` |
291
+ | 往某会话静默注入 | `await env.manager.injectToPeer(scope, peerId, text)` |
292
+
293
+ > ⚠️ **不要 `import` 插件的 `dist/`**(例如 `dist/features/session-registry.js`)。
294
+ > 那些是**内部模块**,重构时不保证形状;一改就静默坏掉(`import` 抛错常被 try 吞了)。
295
+ > 上面这张表 + `env.kernel.get('宿主服务名')` 已经覆盖绝大多数需求;
296
+ > 缺什么请提 issue,我们会补成正式接口,而不是让你去摸内部文件。
297
+
275
298
  ### 扩展设置页的字段类型(schema)
276
299
 
277
300
  扩展文件里 `export const qqbotSettingsPage = { title, desc, schema: [...] }`,面板就会给它生成设置页。
package/package.json CHANGED
@@ -1,145 +1,147 @@
1
- {
2
- "name": "@zaofan/dsh-qqbot",
3
- "version": "1.12.12",
4
- "description": "QQ Bot IM channel plugin for deepseek-harness (dsh)",
5
- "type": "module",
6
- "main": "./entry.js",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./entry.js"
12
- },
13
- "./channel-tools": {
14
- "types": "./dist/channel-tools.d.ts",
15
- "import": "./dist/channel-tools.js"
16
- },
17
- "./sticker-store": {
18
- "types": "./dist/features/sticker-store.d.ts",
19
- "import": "./dist/features/sticker-store.js"
20
- },
21
- "./schedule-store": {
22
- "types": "./dist/features/schedule-store.d.ts",
23
- "import": "./dist/features/schedule-store.js"
24
- },
25
- "./client": "./client/qqbot-settings.js",
26
- "./session-registry": "./dist/features/session-registry.js"
27
- },
28
- "scripts": {
29
- "build": "tsc",
30
- "dev": "tsc --watch",
31
- "prepublishOnly": "npm run build && node scripts/check-package.mjs",
32
- "check:package": "node scripts/check-package.mjs",
33
- "lint": "eslint src/",
34
- "test": "vitest run",
35
- "clean": "rm -rf dist",
36
- "ci:prepare-test-pkg": "node scripts/prepare-test-pkg.js"
37
- },
38
- "repository": {
39
- "type": "git",
40
- "url": "git+https://github.com/zaofan-make/dsh-qqbot.git"
41
- },
42
- "homepage": "https://github.com/zaofan-make/dsh-qqbot#readme",
43
- "bugs": {
44
- "url": "https://github.com/zaofan-make/dsh-qqbot/issues"
45
- },
46
- "keywords": [
47
- "deepseek-harness",
48
- "dsh",
49
- "dsh-plugin",
50
- "qqbot",
51
- "qq-bot",
52
- "chatbot",
53
- "ai-agent",
54
- "cordis",
55
- "plugin",
56
- "llm"
57
- ],
58
- "license": "MIT",
59
- "files": [
60
- "dist",
61
- "docs/extension-contract.md",
62
- "docs/USER-GUIDE.md",
63
- "docs/botplay-contract.md",
64
- "docs/host-services.md",
65
- "examples",
66
- "client",
67
- "cordis.patch.yml",
68
- "settings-host.js",
69
- "README.md",
70
- "README_EN.md",
71
- "LICENSE",
72
- "voice-convert.mjs",
73
- "scripts/download-model.mjs",
74
- "scripts/fix-dsh-016-presets.ps1",
75
- "entry.js"
76
- ],
77
- "dsh": {
78
- "bundle": {
79
- "patch": "./cordis.patch.yml"
80
- },
81
- "client": {
82
- "platform": "web",
83
- "inject": [
84
- "@deepseek-ai/dsh-client-ui-settings",
85
- "@deepseek-ai/dsh-client-ui-slots"
86
- ],
87
- "immediately": true
88
- },
89
- "engines": {
90
- "dsh": ">=0.1.5-rc.2"
91
- },
92
- "manifestVersion": 1
93
- },
94
- "dependencies": {
95
- "@deepseek-ai/dsh-client-ui-slots": "0.1.7-rc.1",
96
- "@deepseek-ai/schemastery": "3.18.4",
97
- "@tencent-connect/qqbot-connector": "1.2.0",
98
- "@tencent-connect/qqbot-nodejs": "^1.0.4",
99
- "jimp": "^1.6.1",
100
- "js-yaml": "^4.1.0",
101
- "lamejs-fixed": "^1.2.2",
102
- "silk-wasm": "^3.7.1"
103
- },
104
- "optionalDependencies": {
105
- "@huggingface/transformers": "^4.3.0"
106
- },
107
- "peerDependencies": {
108
- "@deepseek-ai/cordis": ">=4.0.1",
109
- "@deepseek-ai/dsh-agent": ">=0.1.0-rc.6",
110
- "@deepseek-ai/dsh-llm": ">=0.1.0-rc.6",
111
- "@deepseek-ai/dsh-session": ">=0.1.0-rc.6",
112
- "@deepseek-ai/dsh-settings": "*",
113
- "@deepseek-ai/dsh-tools": ">=0.1.1-rc.2",
114
- "@tencent-connect/qqbot-connector": "1.2.0"
115
- },
116
- "peerDependenciesMeta": {
117
- "@deepseek-ai/cordis": {
118
- "optional": true
119
- },
120
- "@deepseek-ai/schemastery": {
121
- "optional": true
122
- },
123
- "@deepseek-ai/dsh-agent": {
124
- "optional": true
125
- },
126
- "@deepseek-ai/dsh-session": {
127
- "optional": true
128
- },
129
- "@deepseek-ai/dsh-llm": {
130
- "optional": true
131
- }
132
- },
133
- "devDependencies": {
134
- "@deepseek-ai/cordis": "4.0.1",
135
- "@deepseek-ai/dsh-agent": "0.1.0-rc.6",
136
- "@deepseek-ai/dsh-llm": "0.1.0-rc.6",
137
- "@deepseek-ai/dsh-session": "0.1.0-rc.6",
138
- "@deepseek-ai/dsh-tools": ">=0.1.1-rc.2",
139
- "@deepseek-ai/schemastery": "3.18.1",
140
- "@types/js-yaml": "^4.0.9",
141
- "@types/node": "^26.2.0",
142
- "typescript": "^5.5.0",
143
- "vitest": "^4.1.8"
144
- }
145
- }
1
+ {
2
+ "name": "@zaofan/dsh-qqbot",
3
+ "version": "1.12.14",
4
+ "description": "QQ Bot IM channel plugin for deepseek-harness (dsh)",
5
+ "type": "module",
6
+ "main": "./entry.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./entry.js"
12
+ },
13
+ "./channel-tools": {
14
+ "types": "./dist/channel-tools.d.ts",
15
+ "import": "./dist/channel-tools.js"
16
+ },
17
+ "./sticker-store": {
18
+ "types": "./dist/features/sticker-store.d.ts",
19
+ "import": "./dist/features/sticker-store.js"
20
+ },
21
+ "./schedule-store": {
22
+ "types": "./dist/features/schedule-store.d.ts",
23
+ "import": "./dist/features/schedule-store.js"
24
+ },
25
+ "./client": "./client/qqbot-settings.js",
26
+ "./session-registry": "./dist/features/session-registry.js"
27
+ },
28
+ "scripts": {
29
+ "build": "tsc",
30
+ "dev": "tsc --watch",
31
+ "prepublishOnly": "npm run build && node scripts/check-package.mjs",
32
+ "check:package": "node scripts/check-package.mjs",
33
+ "lint": "eslint src/",
34
+ "test": "vitest run",
35
+ "clean": "rm -rf dist",
36
+ "ci:prepare-test-pkg": "node scripts/prepare-test-pkg.js"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/zaofan-make/dsh-qqbot.git"
41
+ },
42
+ "homepage": "https://github.com/zaofan-make/dsh-qqbot#readme",
43
+ "bugs": {
44
+ "url": "https://github.com/zaofan-make/dsh-qqbot/issues"
45
+ },
46
+ "keywords": [
47
+ "deepseek-harness",
48
+ "dsh",
49
+ "dsh-plugin",
50
+ "qqbot",
51
+ "qq-bot",
52
+ "chatbot",
53
+ "ai-agent",
54
+ "cordis",
55
+ "plugin",
56
+ "llm"
57
+ ],
58
+ "license": "AFL-3.0",
59
+ "files": [
60
+ "dist",
61
+ "docs/extension-contract.md",
62
+ "docs/USER-GUIDE.md",
63
+ "docs/botplay-contract.md",
64
+ "docs/host-services.md",
65
+ "examples",
66
+ "client",
67
+ "cordis.patch.yml",
68
+ "settings-host.js",
69
+ "README.md",
70
+ "README_EN.md",
71
+ "LICENSE",
72
+ "voice-convert.mjs",
73
+ "scripts/download-model.mjs",
74
+ "scripts/fix-dsh-016-presets.ps1",
75
+ "entry.js",
76
+ "NOTICE",
77
+ "LICENSE-ADDENDUM.md"
78
+ ],
79
+ "dsh": {
80
+ "bundle": {
81
+ "patch": "./cordis.patch.yml"
82
+ },
83
+ "client": {
84
+ "platform": "web",
85
+ "inject": [
86
+ "@deepseek-ai/dsh-client-ui-settings",
87
+ "@deepseek-ai/dsh-client-ui-slots"
88
+ ],
89
+ "immediately": true
90
+ },
91
+ "engines": {
92
+ "dsh": ">=0.1.5-rc.2"
93
+ },
94
+ "manifestVersion": 1
95
+ },
96
+ "dependencies": {
97
+ "@deepseek-ai/dsh-client-ui-slots": "0.1.7-rc.1",
98
+ "@deepseek-ai/schemastery": "3.18.4",
99
+ "@tencent-connect/qqbot-connector": "1.2.0",
100
+ "@tencent-connect/qqbot-nodejs": "^1.0.4",
101
+ "jimp": "^1.6.1",
102
+ "js-yaml": "^4.1.0",
103
+ "lamejs-fixed": "^1.2.2",
104
+ "silk-wasm": "^3.7.1"
105
+ },
106
+ "optionalDependencies": {
107
+ "@huggingface/transformers": "^4.3.0"
108
+ },
109
+ "peerDependencies": {
110
+ "@deepseek-ai/cordis": ">=4.0.1",
111
+ "@deepseek-ai/dsh-agent": ">=0.1.0-rc.6",
112
+ "@deepseek-ai/dsh-llm": ">=0.1.0-rc.6",
113
+ "@deepseek-ai/dsh-session": ">=0.1.0-rc.6",
114
+ "@deepseek-ai/dsh-settings": "*",
115
+ "@deepseek-ai/dsh-tools": ">=0.1.1-rc.2",
116
+ "@tencent-connect/qqbot-connector": "1.2.0"
117
+ },
118
+ "peerDependenciesMeta": {
119
+ "@deepseek-ai/cordis": {
120
+ "optional": true
121
+ },
122
+ "@deepseek-ai/schemastery": {
123
+ "optional": true
124
+ },
125
+ "@deepseek-ai/dsh-agent": {
126
+ "optional": true
127
+ },
128
+ "@deepseek-ai/dsh-session": {
129
+ "optional": true
130
+ },
131
+ "@deepseek-ai/dsh-llm": {
132
+ "optional": true
133
+ }
134
+ },
135
+ "devDependencies": {
136
+ "@deepseek-ai/cordis": "4.0.1",
137
+ "@deepseek-ai/dsh-agent": "0.1.0-rc.6",
138
+ "@deepseek-ai/dsh-llm": "0.1.0-rc.6",
139
+ "@deepseek-ai/dsh-session": "0.1.0-rc.6",
140
+ "@deepseek-ai/dsh-tools": ">=0.1.1-rc.2",
141
+ "@deepseek-ai/schemastery": "3.18.1",
142
+ "@types/js-yaml": "^4.0.9",
143
+ "@types/node": "^26.2.0",
144
+ "typescript": "^5.5.0",
145
+ "vitest": "^4.1.8"
146
+ }
147
+ }
package/settings-host.js CHANGED
@@ -1122,13 +1122,49 @@ export function apply(ctx) {
1122
1122
 
1123
1123
  /** YAML 单引号标量(含 ' 转义为 '') */
1124
1124
  function yq(v) { return `'${String(v ?? '').replace(/'/g, "''")}'` }
1125
+
1126
+ /**
1127
+ * 「需要引号才引」的标量写法(2026-11-08)。
1128
+ *
1129
+ * 为什么不是无脑 yq():我们的 `- id:` 行**自己也会被解析回来**(isBotHead / botIdOf / insert 扫描),
1130
+ * 如果一律加引号,读回来的就是 `'im-qqbot-2'`(带引号)→ `/^im-qqbot/` 判不出来 → 实例直接消失。
1131
+ * 所以:**像标识符的原样写**(im-qqbot、im-qqbot-2),**其余一律加引号**(数字 1、true、含空格/冒号/中文…)。
1132
+ */
1133
+ function yqLoose(v) {
1134
+ const t = String(v ?? '');
1135
+ return /^[A-Za-z_][A-Za-z0-9_.-]*$/.test(t) ? t : yq(t);
1136
+ }
1137
+
1138
+ /** 去掉 YAML 标量外层的一对单引号('' → ' 还原);没引号则原样返回 */
1139
+ function unq(v) {
1140
+ const t = String(v ?? '');
1141
+ const m = /^'(.*)'$/.exec(t);
1142
+ return m ? m[1].replace(/''/g, "'") : t;
1143
+ }
1144
+
1145
+ /**
1146
+ * **自愈历史遗留的裸数字 id**(2026-11-08,dsh-market issue #1071)。
1147
+ *
1148
+ * 用户完全可能把实例 id 填成 `1`、`2` 这种纯数字 —— 这是合法输入,不该拒绝。
1149
+ * 但裸写进 YAML 会被解析成 **number**:DSH loader 只判 falsy 所以照样收下,
1150
+ * 下游(插件市场等)对 id 调 `.split()` 就抛 TypeError,现象是"已安装列表空白 + 400 空 body + 零日志"。
1151
+ *
1152
+ * 所以:**允许用户填数字,但落盘一律转成字符串**(加引号),并且在每次写 patch 前
1153
+ * 把历史文件里已经裸写出来的数字 id 顺手补上引号(幂等)。
1154
+ */
1155
+ function quoteNumericIds(text) {
1156
+ try {
1157
+ return String(text ?? '').replace(/^(\s*-\s*id:\s*)([0-9]+)(\s*)$/gm, (_m, a, b, c) => `${a}'${b}'${c}`);
1158
+ } catch { return text; }
1159
+ }
1125
1160
  /** appSecret 裸写规则: 纯安全字符直接裸, 否则单引号 */
1126
1161
  function ysec(v) { const s = String(v ?? ''); return /^[A-Za-z0-9+/=_\-]+$/.test(s) ? s : yq(s) }
1127
1162
  /** 顶层块行判断(0 缩进以 "- " 开头) */
1128
1163
  function isTopLine(l) { return /^-\s/.test(l) }
1129
1164
  /** 块头是 im-qqbot 实例? */
1130
- function isBotHead(l) { const m = /^-\s*id:\s*(\S+)\s*$/.exec(l.trim()); return m ? /^im-qqbot(-|$)/.test(m[1]) : false }
1131
- function botIdOf(headLine) { const m = /^-\s*id:\s*(\S+)\s*$/.exec(headLine.trim()); return m ? m[1] : '' }
1165
+ // ⚠️ 取值后必须 unq():文件里可能是 `- id: '1'`(自动加过引号),带引号会让 /^im-qqbot/ 判不出来
1166
+ function isBotHead(l) { const m = /^-\s*id:\s*(\S+)\s*$/.exec(l.trim()); return m ? /^im-qqbot(-|$)/.test(unq(m[1])) : false }
1167
+ function botIdOf(headLine) { const m = /^-\s*id:\s*(\S+)\s*$/.exec(headLine.trim()); return m ? unq(m[1]) : '' }
1132
1168
 
1133
1169
  /** 解析 patch: 返回 {raw, bots:[{id,start,end,ins,cfg:{appId,appSecret,preset,cwd},disabled}], hasFile}
1134
1170
  * patch 语义(宿主 dsh-app-boot applyEntryPatches): 顶层 `- id: X` 只能覆盖已存在 id(bundle insert 建的);
@@ -1171,7 +1207,7 @@ export function apply(ctx) {
1171
1207
  // 在 insert 列表内(行以空白开头或为列表项), 找 4 空格 "- id:"
1172
1208
  const c = lines[k];
1173
1209
  const m4 = /^\s{4}-\s*id:\s*(\S+)\s*$/.exec(c);
1174
- if (m4 && /^im-qqbot(-|$)/.test(m4[1])) { found = { line: k, id: m4[1] }; break; }
1210
+ if (m4 && /^im-qqbot(-|$)/.test(unq(m4[1]))) { found = { line: k, id: unq(m4[1]) }; break; }
1175
1211
  if (/^-\s/.test(c) && !/^\s/.test(c)) break; // 下一个顶层条目
1176
1212
  if (c.trim() !== '' && !/^\s/.test(c) && !/^-\s/.test(c)) break;
1177
1213
  k += 1;
@@ -1234,7 +1270,11 @@ export function apply(ctx) {
1234
1270
  const pad4 = ' '.repeat(L0 + 4);
1235
1271
  const out = [];
1236
1272
  if (!isMain) out.push('- insert:');
1237
- out.push(`${pad0}- id: ${id}`);
1273
+ // ★ 2026-11-08(dsh-market issue #1071 指出):**必须加引号**。
1274
+ // 实例 id 是用户填的,填「1」就会写出 `- id: 1` —— js-yaml 解析成 **number**,
1275
+ // 而 DSH loader 只判 falsy(数字 1 是 truthy,照收),下游市场插件对 id 调 `.split()`
1276
+ // 就抛 TypeError,表现成"已安装列表空白 + 400 空 body + 零日志",极难排查。
1277
+ out.push(`${pad0}- id: ${yqLoose(id)}`);
1238
1278
  if (!isMain) out.push(`${pad2}name: '@zaofan/dsh-qqbot'`);
1239
1279
  if (inst.disabled) out.push(`${pad2}disabled: true`);
1240
1280
  out.push(`${pad2}config:`);
@@ -1439,7 +1479,7 @@ export function apply(ctx) {
1439
1479
  writeOwnSettings(nsKey, cur);
1440
1480
  }
1441
1481
  } catch { /* 自有存储失败不阻塞 patch 写入 */ }
1442
- writeFileSync(PATCH_FILE, out, 'utf8');
1482
+ writeFileSync(PATCH_FILE, quoteNumericIds(out), 'utf8');
1443
1483
  return { ok: true, file: PATCH_FILE, needRestart: true };
1444
1484
  }
1445
1485
 
@@ -2006,7 +2046,7 @@ export function apply(ctx) {
2006
2046
  text += add;
2007
2047
  const bak = PATCH_FILE + '.bak-copy-' + Date.now();
2008
2048
  try { writeFileSync(bak, raw, 'utf8'); } catch { /* 备份失败不阻塞 */ }
2009
- writeFileSync(PATCH_FILE, text, 'utf8');
2049
+ writeFileSync(PATCH_FILE, quoteNumericIds(text), 'utf8');
2010
2050
  return { ok: true, backup: bak, newId };
2011
2051
  } catch (e) { return { ok: false, error: String((e && e.message) || e) }; }
2012
2052
  }
@@ -2164,7 +2204,7 @@ export function apply(ctx) {
2164
2204
  }
2165
2205
  const bak = PATCH_FILE + '.bak-cfg-' + Date.now();
2166
2206
  try { writeFileSync(bak, raw, 'utf8'); } catch { /* 备份失败不阻塞 */ }
2167
- writeFileSync(PATCH_FILE, out, 'utf8');
2207
+ writeFileSync(PATCH_FILE, quoteNumericIds(out), 'utf8');
2168
2208
  return { ok: true, backup: bak, missing };
2169
2209
  } catch (e) { return { ok: false, error: String((e && e.message) || e) }; }
2170
2210
  }
@@ -2215,7 +2255,7 @@ export function apply(ctx) {
2215
2255
  }
2216
2256
  const bak = PATCH_FILE + '.bak-persona-' + Date.now();
2217
2257
  try { writeFileSync(bak, raw, 'utf8'); } catch { /* 备份失败不阻塞 */ }
2218
- writeFileSync(PATCH_FILE, out, 'utf8');
2258
+ writeFileSync(PATCH_FILE, quoteNumericIds(text), 'utf8');
2219
2259
  return { ok: true, backup: bak };
2220
2260
  } catch (e) { return { ok: false, error: String((e && e.message) || e) }; }
2221
2261
  }