chatluna-plugin-onebot-toolbox 0.0.0-stage → 0.0.2

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sor85
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.
package/README.md CHANGED
@@ -1,3 +1,51 @@
1
- # Temporary Holding Version
1
+ # chatluna-plugin-onebot-toolbox
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ChatLuna v2 插件:为 ChatLuna 提供 OneBot(QQ)原生工具与群聊信息变量,仅支持 OneBot 平台(NapCat、LLBot、SnowLuma)。
4
+
5
+ ## 功能
6
+
7
+ ### 原生工具
8
+
9
+ 注册给模型调用的工具,只在 OneBot 会话中提供。插件启用后全部注册,开关与可用范围在 ChatLuna 的工具管理中设置:
10
+
11
+ | 工具 | 默认名称 | OneBot action |
12
+ | --- | --- | --- |
13
+ | 修改自身账户信息(昵称、签名、性别) | `set_self_profile` | `set_qq_profile` |
14
+ | 修改 QQ 头像 | `set_qq_avatar` | `set_qq_avatar` |
15
+ | 修改群成员昵称 | `set_group_card` | `set_group_card` |
16
+ | 搜索群成员(按 qqid、群昵称或 QQ 昵称) | `search_group_member` | `get_group_member_list` |
17
+ | 退群 | `set_group_leave` | `set_group_leave` |
18
+ | 处理好友与群申请 | `handle_request` | `set_friend_add_request` / `set_group_add_request` |
19
+ | 踢出群成员 | `set_group_kick` | `set_group_kick` |
20
+ | 修改群成员专属头衔 | `set_group_special_title` | `set_group_special_title` |
21
+ | 撤回消息 | `delete_msg` | `delete_msg` |
22
+
23
+ - QQ 头像工具接受会话里的图片(聊天中发送的图片可直接设为头像)、HTTP/HTTPS 链接或 OneBot 端可读的本地路径;会话图片与 HTTP/HTTPS 图片先读成 OneBot `base64://` 文件再提交,避免 OneBot 端访问不到临时图片地址。会话图片从 ChatLuna 的文件存储读取,存储中的临时文件过期后需重新发送。
24
+ - SnowLuma 同意好友申请时不读取备注,插件在同意后另用 `set_friend_remark` 设置;它的消息 ID 常为负数,撤回消息工具按原样提交。
25
+ - 收到好友申请、加群申请或群邀请时插件会唤醒对应会话,把申请 flag 告诉模型,由 `handle_request` 处理:好友申请与群邀请发往申请人的私聊,加群申请发往所申请的群。在 ChatLuna 工具管理中禁用 `handle_request` 后不再唤醒;也可在设置中单独关闭「申请通知」。
26
+ - 工具默认对所有用户开放;如需收紧,在 ChatLuna 的权限页按 `tool:<工具名>` 设置。
27
+
28
+ ### 变量
29
+
30
+ 在预设中引用,渲染时向 OneBot 查询:
31
+
32
+ - `{userInfo}`:当前用户的群昵称、身份、等级、头衔、性别、年龄、地区、入群与最后发言时间
33
+ - `{botInfo}`:机器人在当前群的同类信息
34
+ - `{groupInfo}`:群名、群号、成员数量、创建时间、群主与管理员名单
35
+ - `{groupShutList}`:当前群被禁言的成员与解除时间(缓存 15 秒)
36
+
37
+ 这些变量随群聊状态变化,只能写在预设的上下文或输入区,不能写在 system 区。
38
+
39
+ ## 安装
40
+
41
+ 在 ChatLuna v2 的插件市场搜索 `onebot-toolbox` 安装,或在项目目录执行:
42
+
43
+ ```sh
44
+ yarn add chatluna-plugin-onebot-toolbox
45
+ ```
46
+
47
+ 启用插件后,在 WebUI「插件设置」页选中本插件编辑配置。
48
+
49
+ ## License
50
+
51
+ MIT
@@ -0,0 +1,40 @@
1
+ import { Schema } from '@chatluna/schema';
2
+ export type OneBotProtocol = 'napcat' | 'llbot' | 'snowluma';
3
+ export type NativeToolKey = 'setSelfProfile' | 'setQQAvatar' | 'setGroupCard' | 'searchGroupMember' | 'leaveGroup' | 'handleRequest' | 'setGroupKick' | 'setGroupSpecialTitle' | 'deleteMessage';
4
+ export interface NativeToolInfo {
5
+ toolName: string;
6
+ description: string;
7
+ }
8
+ export type MemberInfoItem = 'userId' | 'nickname' | 'role' | 'level' | 'title' | 'gender' | 'age' | 'area' | 'joinTime' | 'lastSentTime';
9
+ export type GroupInfoItem = 'groupName' | 'groupId' | 'memberCount' | 'createTime' | 'ownerList' | 'adminList';
10
+ export interface Config {
11
+ oneBotProtocol: OneBotProtocol;
12
+ requestNotice: boolean;
13
+ userInfo: {
14
+ variableName: string;
15
+ items: MemberInfoItem[];
16
+ };
17
+ botInfo: {
18
+ variableName: string;
19
+ items: MemberInfoItem[];
20
+ };
21
+ groupInfo: {
22
+ variableName: string;
23
+ items: GroupInfoItem[];
24
+ };
25
+ groupShutList: {
26
+ variableName: string;
27
+ };
28
+ debugLogging: boolean;
29
+ }
30
+ /** 原生工具的名称与描述固定,全部注册;启用范围交给 v2 的工具管理。 */
31
+ export declare const NATIVE_TOOLS: Record<NativeToolKey, NativeToolInfo>;
32
+ export declare const NATIVE_TOOL_KEYS: NativeToolKey[];
33
+ export declare const DEFAULT_MEMBER_INFO_ITEMS: MemberInfoItem[];
34
+ export declare const DEFAULT_GROUP_INFO_ITEMS: GroupInfoItem[];
35
+ /**
36
+ * 插件配置,直接在 v2 的插件设置页编辑。顶层是分组的 intersect,SchemaForm 把每组的 description 渲染成小节标题;
37
+ * 每个字段都写 `extra('label')`,缺 label 时 SchemaForm 会把配置键当标题显示。
38
+ */
39
+ export declare const Config: Schema<Config>;
40
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAA;AAE5D,MAAM,MAAM,aAAa,GACrB,gBAAgB,GAChB,aAAa,GACb,cAAc,GACd,mBAAmB,GACnB,YAAY,GACZ,eAAe,GACf,cAAc,GACd,sBAAsB,GACtB,eAAe,CAAA;AAEnB,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,MAAM,cAAc,GACtB,QAAQ,GACR,UAAU,GACV,MAAM,GACN,OAAO,GACP,OAAO,GACP,QAAQ,GACR,KAAK,GACL,MAAM,GACN,UAAU,GACV,cAAc,CAAA;AAElB,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,SAAS,GAAG,aAAa,GAAG,YAAY,GAAG,WAAW,GAAG,WAAW,CAAA;AAE9G,MAAM,WAAW,MAAM;IACrB,cAAc,EAAE,cAAc,CAAA;IAC9B,aAAa,EAAE,OAAO,CAAA;IACtB,QAAQ,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,cAAc,EAAE,CAAA;KAAE,CAAA;IAC3D,OAAO,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,cAAc,EAAE,CAAA;KAAE,CAAA;IAC1D,SAAS,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,aAAa,EAAE,CAAA;KAAE,CAAA;IAC3D,aAAa,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,CAAA;IACvC,YAAY,EAAE,OAAO,CAAA;CACtB;AAED,yCAAyC;AACzC,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,aAAa,EAAE,cAAc,CAqC9D,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAgC,aAAa,EAAE,CAAA;AAE5E,eAAO,MAAM,yBAAyB,EAAE,cAAc,EAErD,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,aAAa,EAAsE,CAAA;AA+D1H;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,CAIhC,CAAA"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { Context } from 'cordis';
2
+ import type { Config } from './config';
3
+ export * from './config';
4
+ export declare const name = "chatluna-onebot-toolbox";
5
+ /** 过滤工具用的 agents、唤醒用的 chat 与读取会话图片用的 chatluna_storage 是可选服务。 */
6
+ export declare const inject: string[];
7
+ export declare function apply(ctx: Context, config: Config): void;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAMtC,cAAc,UAAU,CAAA;AAExB,eAAO,MAAM,IAAI,4BAA4B,CAAA;AAE7C,gEAAgE;AAChE,eAAO,MAAM,MAAM,UAAgC,CAAA;AAEnD,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAKjD"}