koishi-plugin-chatluna-toolbox 0.0.6 → 0.0.7
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/lib/index.js +194 -100
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
BasicSettingsSchema: () => BasicSettingsSchema,
|
|
23
24
|
Config: () => ConfigSchema,
|
|
24
25
|
ConfigSchema: () => ConfigSchema,
|
|
25
26
|
DEFAULT_GROUP_INFO_ITEMS: () => DEFAULT_GROUP_INFO_ITEMS,
|
|
@@ -58,27 +59,86 @@ __export(index_exports, {
|
|
|
58
59
|
module.exports = __toCommonJS(index_exports);
|
|
59
60
|
|
|
60
61
|
// src/schema/index.ts
|
|
61
|
-
var
|
|
62
|
+
var import_koishi5 = require("koishi");
|
|
62
63
|
|
|
63
|
-
// src/schema/
|
|
64
|
+
// src/schema/basic-settings.ts
|
|
64
65
|
var import_koishi = require("koishi");
|
|
65
|
-
var
|
|
66
|
+
var BasicSettingsSchema = import_koishi.Schema.object({
|
|
66
67
|
enableNapCatProtocol: import_koishi.Schema.boolean().default(true).description("\u542F\u7528 NapCat OneBot \u534F\u8BAE\uFF08\u4E0E LLBot \u4E8C\u9009\u4E00\uFF09"),
|
|
67
|
-
enableLlbotProtocol: import_koishi.Schema.boolean().default(false).description("\u542F\u7528 LLBot OneBot \u534F\u8BAE\uFF08\u4E0E NapCat \u4E8C\u9009\u4E00\uFF09")
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
enableLlbotProtocol: import_koishi.Schema.boolean().default(false).description("\u542F\u7528 LLBot OneBot \u534F\u8BAE\uFF08\u4E0E NapCat \u4E8C\u9009\u4E00\uFF09")
|
|
69
|
+
}).description("\u57FA\u7840\u8BBE\u7F6E");
|
|
70
|
+
|
|
71
|
+
// src/schema/native-tools.ts
|
|
72
|
+
var import_koishi2 = require("koishi");
|
|
73
|
+
|
|
74
|
+
// src/features/native-tools/defaults.ts
|
|
75
|
+
var DEFAULT_POKE_TOOL_DESCRIPTION = "\u5BF9\u6307\u5B9A\u7528\u6237\u6267\u884C\u6233\u4E00\u6233\u3002";
|
|
76
|
+
var DEFAULT_SET_SELF_PROFILE_TOOL_DESCRIPTION = "\u4FEE\u6539\u81EA\u5DF1\u7684 QQ \u8D44\u6599\uFF0C\u53EF\u8BBE\u7F6E\u6635\u79F0\u3001\u7B7E\u540D\u548C\u6027\u522B\u3002";
|
|
77
|
+
var DEFAULT_SET_GROUP_CARD_TOOL_DESCRIPTION = "\u4FEE\u6539\u7FA4\u6210\u5458\u7684\u7FA4\u6635\u79F0\u3002";
|
|
78
|
+
var DEFAULT_SET_MSG_EMOJI_TOOL_DESCRIPTION = "\u5BF9\u6307\u5B9A\u6D88\u606F\u6DFB\u52A0\u8868\u60C5\u56DE\u5E94\u3002";
|
|
79
|
+
var DEFAULT_DELETE_MESSAGE_TOOL_DESCRIPTION = "\u6839\u636E\u6D88\u606F ID \u64A4\u56DE\u6307\u5B9A\u6D88\u606F\u3002";
|
|
80
|
+
|
|
81
|
+
// src/schema/native-tools.ts
|
|
82
|
+
var NativeToolsSchema = import_koishi2.Schema.object({
|
|
83
|
+
poke: import_koishi2.Schema.object({
|
|
84
|
+
enabled: import_koishi2.Schema.boolean().default(false).description("\u6CE8\u518C ChatLuna \u5DE5\u5177\uFF1A\u6233\u4E00\u6233\uFF08\u4E0E XML\u5DE5\u5177 \u4E8C\u9009\u4E00\uFF09"),
|
|
85
|
+
toolName: import_koishi2.Schema.string().default("poke_user").description("\u5DE5\u5177\u540D\u79F0"),
|
|
86
|
+
description: import_koishi2.Schema.string().default(DEFAULT_POKE_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
87
|
+
}).description("\u6233\u4E00\u6233\u5DE5\u5177").collapse(),
|
|
88
|
+
setSelfProfile: import_koishi2.Schema.object({
|
|
89
|
+
enabled: import_koishi2.Schema.boolean().default(false).description("\u6CE8\u518C ChatLuna \u5DE5\u5177\uFF1A\u4FEE\u6539\u81EA\u8EAB\u8D26\u6237\u4FE1\u606F\uFF08\u652F\u6301\u6635\u79F0/\u7B7E\u540D/\u6027\u522B\uFF09"),
|
|
90
|
+
toolName: import_koishi2.Schema.string().default("set_self_profile").description("\u5DE5\u5177\u540D\u79F0"),
|
|
91
|
+
description: import_koishi2.Schema.string().default(DEFAULT_SET_SELF_PROFILE_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
92
|
+
}).description("\u4FEE\u6539\u81EA\u8EAB\u8D26\u6237\u4FE1\u606F\u5DE5\u5177").collapse(),
|
|
93
|
+
setGroupCard: import_koishi2.Schema.object({
|
|
94
|
+
enabled: import_koishi2.Schema.boolean().default(false).description("\u6CE8\u518C ChatLuna \u5DE5\u5177\uFF1A\u4FEE\u6539\u7FA4\u6210\u5458\u6635\u79F0"),
|
|
95
|
+
toolName: import_koishi2.Schema.string().default("set_group_card").description("\u5DE5\u5177\u540D\u79F0"),
|
|
96
|
+
description: import_koishi2.Schema.string().default(DEFAULT_SET_GROUP_CARD_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
97
|
+
}).description("\u4FEE\u6539\u7FA4\u6210\u5458\u6635\u79F0\u5DE5\u5177").collapse(),
|
|
98
|
+
setMsgEmoji: import_koishi2.Schema.object({
|
|
99
|
+
enabled: import_koishi2.Schema.boolean().default(false).description(
|
|
100
|
+
"\u6CE8\u518C ChatLuna \u5DE5\u5177\uFF1A\u7ED9\u6D88\u606F\u6DFB\u52A0\u8868\u60C5\uFF08\u9700 chatluna-character \u5F00\u542F enableMessageId\uFF0C\u4E0E XML\u5DE5\u5177 \u4E8C\u9009\u4E00\uFF0C\u8868\u60C5\u5BF9\u7167\u8868\uFF1Ahttps://bot.q.qq.com/wiki/develop/pythonsdk/model/emoji.html \uFF09"
|
|
101
|
+
),
|
|
102
|
+
toolName: import_koishi2.Schema.string().default("set_msg_emoji").description("\u5DE5\u5177\u540D\u79F0"),
|
|
103
|
+
description: import_koishi2.Schema.string().default(DEFAULT_SET_MSG_EMOJI_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
104
|
+
}).description("\u6D88\u606F\u8868\u60C5\u5DE5\u5177").collapse(),
|
|
105
|
+
deleteMessage: import_koishi2.Schema.object({
|
|
106
|
+
enabled: import_koishi2.Schema.boolean().default(false).description(
|
|
107
|
+
"\u6CE8\u518C ChatLuna \u5DE5\u5177\uFF1A\u64A4\u56DE\u6D88\u606F\uFF08\u9700 chatluna-character \u5F00\u542F enableMessageId\uFF0C\u4E0E XML\u5DE5\u5177 \u4E8C\u9009\u4E00\uFF09"
|
|
108
|
+
),
|
|
109
|
+
toolName: import_koishi2.Schema.string().default("delete_msg").description("\u5DE5\u5177\u540D\u79F0"),
|
|
110
|
+
description: import_koishi2.Schema.string().default(DEFAULT_DELETE_MESSAGE_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
|
|
111
|
+
}).description("\u64A4\u56DE\u6D88\u606F\u5DE5\u5177").collapse()
|
|
112
|
+
}).default({
|
|
113
|
+
poke: {
|
|
114
|
+
enabled: false,
|
|
115
|
+
toolName: "poke_user",
|
|
116
|
+
description: DEFAULT_POKE_TOOL_DESCRIPTION
|
|
117
|
+
},
|
|
118
|
+
setSelfProfile: {
|
|
119
|
+
enabled: false,
|
|
120
|
+
toolName: "set_self_profile",
|
|
121
|
+
description: DEFAULT_SET_SELF_PROFILE_TOOL_DESCRIPTION
|
|
122
|
+
},
|
|
123
|
+
setGroupCard: {
|
|
124
|
+
enabled: false,
|
|
125
|
+
toolName: "set_group_card",
|
|
126
|
+
description: DEFAULT_SET_GROUP_CARD_TOOL_DESCRIPTION
|
|
127
|
+
},
|
|
128
|
+
setMsgEmoji: {
|
|
129
|
+
enabled: false,
|
|
130
|
+
toolName: "set_msg_emoji",
|
|
131
|
+
description: DEFAULT_SET_MSG_EMOJI_TOOL_DESCRIPTION
|
|
132
|
+
},
|
|
133
|
+
deleteMessage: {
|
|
134
|
+
enabled: false,
|
|
135
|
+
toolName: "delete_msg",
|
|
136
|
+
description: DEFAULT_DELETE_MESSAGE_TOOL_DESCRIPTION
|
|
137
|
+
}
|
|
78
138
|
}).description("\u539F\u751F\u5DE5\u5177");
|
|
79
139
|
|
|
80
140
|
// src/schema/xml-tools.ts
|
|
81
|
-
var
|
|
141
|
+
var import_koishi3 = require("koishi");
|
|
82
142
|
var DEFAULT_XML_REFERENCE_PROMPT = `## \u52A8\u4F5C\u6307\u4EE4
|
|
83
143
|
\u4F60\u53EF\u4EE5\u6839\u636E\u9700\u8981\u5728\u6A21\u578B\u56DE\u590D\u4E2D\u8F93\u51FA\u4E00\u4E2A\u72EC\u7ACB\u7684 <actions> \u5143\u7D20\u3002\u5B83\u7528\u4E8E\u6267\u884C\u975E\u8BED\u8A00\u7684\u7CFB\u7EDF\u6307\u4EE4\u3002\u5982\u679C\u4E0D\u9700\u8981\u6267\u884C\u4EFB\u4F55\u52A8\u4F5C\uFF0C\u8BF7\u7701\u7565\u6B64\u5143\u7D20\u3002
|
|
84
144
|
1. \u6233\u4E00\u6233: <poke id=""/>
|
|
@@ -111,17 +171,17 @@ var DEFAULT_XML_REFERENCE_PROMPT = `## \u52A8\u4F5C\u6307\u4EE4
|
|
|
111
171
|
<delete message_id="435663"/>
|
|
112
172
|
</actions>
|
|
113
173
|
\`\`\``;
|
|
114
|
-
var XmlToolsSchema =
|
|
115
|
-
enablePokeXmlTool:
|
|
116
|
-
enableEmojiXmlTool:
|
|
174
|
+
var XmlToolsSchema = import_koishi3.Schema.object({
|
|
175
|
+
enablePokeXmlTool: import_koishi3.Schema.boolean().default(false).description("\u542F\u7528 XML \u5F62\u5F0F\u7684\u6233\u4E00\u6233\u8C03\u7528\uFF08\u4E0E \u539F\u751F\u5DE5\u5177 \u4E8C\u9009\u4E00\uFF09"),
|
|
176
|
+
enableEmojiXmlTool: import_koishi3.Schema.boolean().default(false).description(
|
|
117
177
|
"\u542F\u7528 XML \u5F62\u5F0F\u7684\u6D88\u606F\u8868\u60C5\u8C03\u7528\uFF0C\uFF08\u9700 chatluna-character \u5F00\u542F enableMessageId\uFF0C\u4E0E \u539F\u751F\u5DE5\u5177 \u4E8C\u9009\u4E00\uFF0Cemoji_id \u5BF9\u7167\u8868\uFF1Ahttps://bot.q.qq.com/wiki/develop/pythonsdk/model/emoji.html \uFF09"
|
|
118
178
|
),
|
|
119
|
-
enableDeleteXmlTool:
|
|
120
|
-
referencePrompt:
|
|
179
|
+
enableDeleteXmlTool: import_koishi3.Schema.boolean().default(false).description("\u542F\u7528 XML \u5F62\u5F0F\u7684\u6D88\u606F\u64A4\u56DE\u8C03\u7528\uFF08\u9700 chatluna-character \u5F00\u542F enableMessageId\uFF0C\u4E0E \u539F\u751F\u5DE5\u5177 \u4E8C\u9009\u4E00\uFF09"),
|
|
180
|
+
referencePrompt: import_koishi3.Schema.string().role("textarea").default(DEFAULT_XML_REFERENCE_PROMPT).description("\u6A21\u578B\u56DE\u590D XML \u53C2\u8003\u63D0\u793A\u8BCD\uFF0C\u81EA\u884C\u5199\u5165\u63D0\u793A\u8BCD\u4E2D\uFF0C\u4E0D\u4F1A\u81EA\u52A8\u6CE8\u5165")
|
|
121
181
|
}).description("XML \u5DE5\u5177");
|
|
122
182
|
|
|
123
183
|
// src/schema/variables.ts
|
|
124
|
-
var
|
|
184
|
+
var import_koishi4 = require("koishi");
|
|
125
185
|
|
|
126
186
|
// src/constants/defaults.ts
|
|
127
187
|
var DEFAULT_MEMBER_INFO_ITEMS = [
|
|
@@ -146,58 +206,58 @@ var DEFAULT_GROUP_INFO_ITEMS = [
|
|
|
146
206
|
var RAW_INTERCEPTOR_TAG = "__chatlunaToolboxRawInterceptor";
|
|
147
207
|
|
|
148
208
|
// src/schema/variables.ts
|
|
149
|
-
var VariablesSchema =
|
|
150
|
-
userInfo:
|
|
151
|
-
variableName:
|
|
152
|
-
items:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
209
|
+
var VariablesSchema = import_koishi4.Schema.object({
|
|
210
|
+
userInfo: import_koishi4.Schema.object({
|
|
211
|
+
variableName: import_koishi4.Schema.string().default("userInfo").description("\u53D8\u91CF\u540D\u79F0"),
|
|
212
|
+
items: import_koishi4.Schema.array(
|
|
213
|
+
import_koishi4.Schema.union([
|
|
214
|
+
import_koishi4.Schema.const("userId").description("\u7528\u6237 ID"),
|
|
215
|
+
import_koishi4.Schema.const("nickname").description("\u7FA4\u6635\u79F0"),
|
|
216
|
+
import_koishi4.Schema.const("role").description("\u7FA4\u5185\u8EAB\u4EFD"),
|
|
217
|
+
import_koishi4.Schema.const("level").description("\u7FA4\u7B49\u7EA7"),
|
|
218
|
+
import_koishi4.Schema.const("title").description("\u7FA4\u5934\u8854"),
|
|
219
|
+
import_koishi4.Schema.const("gender").description("\u6027\u522B"),
|
|
220
|
+
import_koishi4.Schema.const("age").description("\u5E74\u9F84"),
|
|
221
|
+
import_koishi4.Schema.const("area").description("\u5730\u533A"),
|
|
222
|
+
import_koishi4.Schema.const("joinTime").description("\u5165\u7FA4\u65F6\u95F4"),
|
|
223
|
+
import_koishi4.Schema.const("lastSentTime").description("\u6700\u540E\u53D1\u8A00\u65F6\u95F4")
|
|
164
224
|
])
|
|
165
225
|
).role("checkbox").default([...DEFAULT_MEMBER_INFO_ITEMS]).description("\u663E\u793A\u7684\u8BE6\u7EC6\u4FE1\u606F\u9879")
|
|
166
226
|
}).description("\u7528\u6237\u4FE1\u606F\u53D8\u91CF").collapse(),
|
|
167
|
-
botInfo:
|
|
168
|
-
variableName:
|
|
169
|
-
items:
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
227
|
+
botInfo: import_koishi4.Schema.object({
|
|
228
|
+
variableName: import_koishi4.Schema.string().default("botInfo").description("\u53D8\u91CF\u540D\u79F0"),
|
|
229
|
+
items: import_koishi4.Schema.array(
|
|
230
|
+
import_koishi4.Schema.union([
|
|
231
|
+
import_koishi4.Schema.const("userId").description("\u673A\u5668\u4EBA ID"),
|
|
232
|
+
import_koishi4.Schema.const("nickname").description("\u7FA4\u6635\u79F0"),
|
|
233
|
+
import_koishi4.Schema.const("role").description("\u7FA4\u5185\u8EAB\u4EFD"),
|
|
234
|
+
import_koishi4.Schema.const("level").description("\u7FA4\u7B49\u7EA7"),
|
|
235
|
+
import_koishi4.Schema.const("title").description("\u7FA4\u5934\u8854"),
|
|
236
|
+
import_koishi4.Schema.const("gender").description("\u6027\u522B"),
|
|
237
|
+
import_koishi4.Schema.const("age").description("\u5E74\u9F84"),
|
|
238
|
+
import_koishi4.Schema.const("area").description("\u5730\u533A"),
|
|
239
|
+
import_koishi4.Schema.const("joinTime").description("\u5165\u7FA4\u65F6\u95F4"),
|
|
240
|
+
import_koishi4.Schema.const("lastSentTime").description("\u6700\u540E\u53D1\u8A00\u65F6\u95F4")
|
|
181
241
|
])
|
|
182
242
|
).role("checkbox").default([...DEFAULT_MEMBER_INFO_ITEMS]).description("\u663E\u793A\u7684\u673A\u5668\u4EBA\u8BE6\u7EC6\u4FE1\u606F\u9879")
|
|
183
243
|
}).description("\u673A\u5668\u4EBA\u4FE1\u606F\u53D8\u91CF").collapse(),
|
|
184
|
-
groupInfo:
|
|
185
|
-
variableName:
|
|
186
|
-
items:
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
244
|
+
groupInfo: import_koishi4.Schema.object({
|
|
245
|
+
variableName: import_koishi4.Schema.string().default("groupInfo").description("\u53D8\u91CF\u540D\u79F0"),
|
|
246
|
+
items: import_koishi4.Schema.array(
|
|
247
|
+
import_koishi4.Schema.union([
|
|
248
|
+
import_koishi4.Schema.const("groupName").description("\u7FA4\u540D\u79F0"),
|
|
249
|
+
import_koishi4.Schema.const("groupId").description("\u7FA4\u53F7"),
|
|
250
|
+
import_koishi4.Schema.const("memberCount").description("\u6210\u5458\u6570\u91CF"),
|
|
251
|
+
import_koishi4.Schema.const("createTime").description("\u521B\u5EFA\u65F6\u95F4\uFF08\u4EC5\u90E8\u5206\u5B9E\u73B0\u652F\u6301\uFF09"),
|
|
252
|
+
import_koishi4.Schema.const("ownerList").description("\u7FA4\u4E3B\u540D\u5355"),
|
|
253
|
+
import_koishi4.Schema.const("adminList").description("\u7BA1\u7406\u5458\u540D\u5355")
|
|
194
254
|
])
|
|
195
255
|
).role("checkbox").default([...DEFAULT_GROUP_INFO_ITEMS]).description("\u663E\u793A\u7684\u7FA4\u4FE1\u606F\u9879")
|
|
196
256
|
}).description("\u7FA4\u4FE1\u606F\u53D8\u91CF").collapse(),
|
|
197
|
-
random:
|
|
198
|
-
variableName:
|
|
199
|
-
min:
|
|
200
|
-
max:
|
|
257
|
+
random: import_koishi4.Schema.object({
|
|
258
|
+
variableName: import_koishi4.Schema.string().default("random").description("\u53D8\u91CF\u540D\u79F0"),
|
|
259
|
+
min: import_koishi4.Schema.number().default(0).description("\u9ED8\u8BA4\u968F\u673A\u6570\u4E0B\u9650"),
|
|
260
|
+
max: import_koishi4.Schema.number().default(100).description("\u9ED8\u8BA4\u968F\u673A\u6570\u4E0A\u9650")
|
|
201
261
|
}).description("\u968F\u673A\u6570\u53D8\u91CF").collapse()
|
|
202
262
|
}).default({
|
|
203
263
|
userInfo: {
|
|
@@ -213,15 +273,16 @@ var VariablesSchema = import_koishi3.Schema.object({
|
|
|
213
273
|
}).description("\u5176\u4ED6\u53D8\u91CF");
|
|
214
274
|
|
|
215
275
|
// src/schema/index.ts
|
|
216
|
-
var OtherSettingsSchema =
|
|
217
|
-
debugLogging:
|
|
276
|
+
var OtherSettingsSchema = import_koishi5.Schema.object({
|
|
277
|
+
debugLogging: import_koishi5.Schema.boolean().default(false).description("\u8F93\u51FA\u8C03\u8BD5\u65E5\u5FD7")
|
|
218
278
|
}).description("\u5176\u4ED6\u8BBE\u7F6E");
|
|
219
279
|
var name = "chatluna-toolbox";
|
|
220
280
|
var inject = {
|
|
221
281
|
required: ["chatluna"],
|
|
222
282
|
optional: ["chatluna_character"]
|
|
223
283
|
};
|
|
224
|
-
var ConfigSchema =
|
|
284
|
+
var ConfigSchema = import_koishi5.Schema.intersect([
|
|
285
|
+
BasicSettingsSchema,
|
|
225
286
|
NativeToolsSchema,
|
|
226
287
|
XmlToolsSchema,
|
|
227
288
|
VariablesSchema,
|
|
@@ -305,10 +366,10 @@ async function sendDeleteMessage(params) {
|
|
|
305
366
|
}
|
|
306
367
|
}
|
|
307
368
|
function createDeleteMessageTool(deps) {
|
|
308
|
-
const { toolName, log } = deps;
|
|
369
|
+
const { toolName, description, log } = deps;
|
|
309
370
|
const tool = {
|
|
310
371
|
name: toolName || "delete_msg",
|
|
311
|
-
description:
|
|
372
|
+
description: description || DEFAULT_DELETE_MESSAGE_TOOL_DESCRIPTION,
|
|
312
373
|
schema: import_zod.z.object({
|
|
313
374
|
messageId: import_zod.z.string().min(1, "messageId is required").describe("Specific message ID to delete.")
|
|
314
375
|
}),
|
|
@@ -375,10 +436,10 @@ async function sendPoke(params) {
|
|
|
375
436
|
}
|
|
376
437
|
}
|
|
377
438
|
function createPokeTool(deps) {
|
|
378
|
-
const { toolName, log, protocol } = deps;
|
|
439
|
+
const { toolName, description, log, protocol } = deps;
|
|
379
440
|
return new class extends import_tools.StructuredTool {
|
|
380
441
|
name = toolName || "poke_user";
|
|
381
|
-
description =
|
|
442
|
+
description = description || DEFAULT_POKE_TOOL_DESCRIPTION;
|
|
382
443
|
schema = import_zod2.z.object({
|
|
383
444
|
userId: import_zod2.z.string().min(1, "userId is required").describe("The user ID to poke."),
|
|
384
445
|
groupId: import_zod2.z.string().optional().describe("Optional: specify a different group ID.")
|
|
@@ -400,10 +461,10 @@ function createPokeTool(deps) {
|
|
|
400
461
|
var import_zod3 = require("zod");
|
|
401
462
|
var import_tools2 = require("@langchain/core/tools");
|
|
402
463
|
function createSetGroupCardTool(deps) {
|
|
403
|
-
const { toolName, log } = deps;
|
|
464
|
+
const { toolName, description, log } = deps;
|
|
404
465
|
return new class extends import_tools2.StructuredTool {
|
|
405
466
|
name = toolName || "set_group_card";
|
|
406
|
-
description =
|
|
467
|
+
description = description || DEFAULT_SET_GROUP_CARD_TOOL_DESCRIPTION;
|
|
407
468
|
schema = import_zod3.z.object({
|
|
408
469
|
groupId: import_zod3.z.string().optional().describe("Target group ID. Defaults to current session group."),
|
|
409
470
|
userId: import_zod3.z.string().min(1, "userId is required").describe("Target member user ID."),
|
|
@@ -473,10 +534,10 @@ async function sendMsgEmoji(params) {
|
|
|
473
534
|
}
|
|
474
535
|
}
|
|
475
536
|
function createSetMsgEmojiTool(deps) {
|
|
476
|
-
const { toolName, log, protocol } = deps;
|
|
537
|
+
const { toolName, description, log, protocol } = deps;
|
|
477
538
|
return new class extends import_tools3.StructuredTool {
|
|
478
539
|
name = toolName || "set_msg_emoji";
|
|
479
|
-
description =
|
|
540
|
+
description = description || DEFAULT_SET_MSG_EMOJI_TOOL_DESCRIPTION;
|
|
480
541
|
schema = import_zod4.z.object({
|
|
481
542
|
messageId: import_zod4.z.string().min(1, "message_id is required").describe("Target message ID."),
|
|
482
543
|
emojiId: import_zod4.z.string().min(1, "emoji_id is required").describe("Emoji ID to send.")
|
|
@@ -503,10 +564,10 @@ var genders = {
|
|
|
503
564
|
female: "2"
|
|
504
565
|
};
|
|
505
566
|
function createSetProfileTool(deps) {
|
|
506
|
-
const { toolName, log, protocol } = deps;
|
|
567
|
+
const { toolName, description, log, protocol } = deps;
|
|
507
568
|
return new class extends import_tools4.StructuredTool {
|
|
508
569
|
name = toolName || "set_self_profile";
|
|
509
|
-
description =
|
|
570
|
+
description = description || DEFAULT_SET_SELF_PROFILE_TOOL_DESCRIPTION;
|
|
510
571
|
schema = import_zod5.z.object({
|
|
511
572
|
nickname: import_zod5.z.string().min(1, "nickname is required").describe("The new nickname for the bot."),
|
|
512
573
|
signature: import_zod5.z.string().optional().describe("Optional: the new personal signature."),
|
|
@@ -536,6 +597,14 @@ function createSetProfileTool(deps) {
|
|
|
536
597
|
}
|
|
537
598
|
|
|
538
599
|
// src/features/native-tools/register.ts
|
|
600
|
+
function resolveToolName(value, fallback) {
|
|
601
|
+
const trimmedValue = value.trim();
|
|
602
|
+
return trimmedValue || fallback;
|
|
603
|
+
}
|
|
604
|
+
function resolveToolDescription(value, fallback) {
|
|
605
|
+
const trimmedValue = value.trim();
|
|
606
|
+
return trimmedValue || fallback;
|
|
607
|
+
}
|
|
539
608
|
function resolveOneBotProtocol(config, log) {
|
|
540
609
|
if (config.enableNapCatProtocol && config.enableLlbotProtocol) {
|
|
541
610
|
log?.("warn", "NapCat \u4E0E LLBot \u534F\u8BAE\u540C\u65F6\u542F\u7528\uFF0C\u5C06\u4F18\u5148\u4F7F\u7528 LLBot\u3002");
|
|
@@ -548,56 +617,80 @@ function resolveOneBotProtocol(config, log) {
|
|
|
548
617
|
}
|
|
549
618
|
function registerNativeTools(deps) {
|
|
550
619
|
const { ctx, config, plugin, protocol, log } = deps;
|
|
551
|
-
if (config.
|
|
552
|
-
const toolName =
|
|
620
|
+
if (config.poke.enabled) {
|
|
621
|
+
const toolName = resolveToolName(config.poke.toolName, "poke_user");
|
|
622
|
+
const description = resolveToolDescription(
|
|
623
|
+
config.poke.description,
|
|
624
|
+
DEFAULT_POKE_TOOL_DESCRIPTION
|
|
625
|
+
);
|
|
553
626
|
plugin.registerTool(toolName, {
|
|
554
627
|
selector: () => true,
|
|
555
628
|
authorization: (session) => session?.platform === "onebot",
|
|
556
|
-
createTool: () => createPokeTool({ ctx, toolName, log, protocol })
|
|
629
|
+
createTool: () => createPokeTool({ ctx, toolName, description, log, protocol })
|
|
557
630
|
});
|
|
558
631
|
log?.("info", `\u6233\u4E00\u6233\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
559
632
|
}
|
|
560
|
-
if (config.
|
|
561
|
-
const toolName =
|
|
562
|
-
config.
|
|
563
|
-
|
|
633
|
+
if (config.setSelfProfile.enabled) {
|
|
634
|
+
const toolName = resolveToolName(
|
|
635
|
+
config.setSelfProfile.toolName,
|
|
636
|
+
"set_self_profile"
|
|
637
|
+
);
|
|
638
|
+
const description = resolveToolDescription(
|
|
639
|
+
config.setSelfProfile.description,
|
|
640
|
+
DEFAULT_SET_SELF_PROFILE_TOOL_DESCRIPTION
|
|
641
|
+
);
|
|
564
642
|
plugin.registerTool(toolName, {
|
|
565
643
|
selector: () => true,
|
|
566
644
|
authorization: (session) => session?.platform === "onebot",
|
|
567
|
-
createTool: () => createSetProfileTool({ ctx, toolName, log, protocol })
|
|
645
|
+
createTool: () => createSetProfileTool({ ctx, toolName, description, log, protocol })
|
|
568
646
|
});
|
|
569
647
|
log?.("info", `\u8BBE\u7F6E\u8D44\u6599\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
570
648
|
}
|
|
571
|
-
if (config.
|
|
572
|
-
const toolName =
|
|
573
|
-
config.
|
|
574
|
-
|
|
649
|
+
if (config.setGroupCard.enabled) {
|
|
650
|
+
const toolName = resolveToolName(
|
|
651
|
+
config.setGroupCard.toolName,
|
|
652
|
+
"set_group_card"
|
|
653
|
+
);
|
|
654
|
+
const description = resolveToolDescription(
|
|
655
|
+
config.setGroupCard.description,
|
|
656
|
+
DEFAULT_SET_GROUP_CARD_TOOL_DESCRIPTION
|
|
657
|
+
);
|
|
575
658
|
plugin.registerTool(toolName, {
|
|
576
659
|
selector: () => true,
|
|
577
660
|
authorization: (session) => session?.platform === "onebot",
|
|
578
|
-
createTool: () => createSetGroupCardTool({ ctx, toolName, log })
|
|
661
|
+
createTool: () => createSetGroupCardTool({ ctx, toolName, description, log })
|
|
579
662
|
});
|
|
580
663
|
log?.("info", `\u7FA4\u6635\u79F0\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
581
664
|
}
|
|
582
|
-
if (config.
|
|
583
|
-
const toolName =
|
|
584
|
-
config.
|
|
585
|
-
|
|
665
|
+
if (config.setMsgEmoji.enabled) {
|
|
666
|
+
const toolName = resolveToolName(
|
|
667
|
+
config.setMsgEmoji.toolName,
|
|
668
|
+
"set_msg_emoji"
|
|
669
|
+
);
|
|
670
|
+
const description = resolveToolDescription(
|
|
671
|
+
config.setMsgEmoji.description,
|
|
672
|
+
DEFAULT_SET_MSG_EMOJI_TOOL_DESCRIPTION
|
|
673
|
+
);
|
|
586
674
|
plugin.registerTool(toolName, {
|
|
587
675
|
selector: () => true,
|
|
588
676
|
authorization: (session) => session?.platform === "onebot",
|
|
589
|
-
createTool: () => createSetMsgEmojiTool({ toolName, log, protocol })
|
|
677
|
+
createTool: () => createSetMsgEmojiTool({ toolName, description, log, protocol })
|
|
590
678
|
});
|
|
591
679
|
log?.("info", `\u6D88\u606F\u8868\u60C5\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
592
680
|
}
|
|
593
|
-
if (config.
|
|
594
|
-
const toolName =
|
|
595
|
-
config.
|
|
596
|
-
|
|
681
|
+
if (config.deleteMessage.enabled) {
|
|
682
|
+
const toolName = resolveToolName(
|
|
683
|
+
config.deleteMessage.toolName,
|
|
684
|
+
"delete_msg"
|
|
685
|
+
);
|
|
686
|
+
const description = resolveToolDescription(
|
|
687
|
+
config.deleteMessage.description,
|
|
688
|
+
DEFAULT_DELETE_MESSAGE_TOOL_DESCRIPTION
|
|
689
|
+
);
|
|
597
690
|
plugin.registerTool(toolName, {
|
|
598
691
|
selector: () => true,
|
|
599
692
|
authorization: (session) => session?.platform === "onebot",
|
|
600
|
-
createTool: () => createDeleteMessageTool({ toolName, log })
|
|
693
|
+
createTool: () => createDeleteMessageTool({ toolName, description, log })
|
|
601
694
|
});
|
|
602
695
|
log?.("info", `\u5220\u9664\u6D88\u606F\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
603
696
|
}
|
|
@@ -1556,6 +1649,7 @@ function apply(ctx, config) {
|
|
|
1556
1649
|
}
|
|
1557
1650
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1558
1651
|
0 && (module.exports = {
|
|
1652
|
+
BasicSettingsSchema,
|
|
1559
1653
|
Config,
|
|
1560
1654
|
ConfigSchema,
|
|
1561
1655
|
DEFAULT_GROUP_INFO_ITEMS,
|