koishi-plugin-chatluna-affinity 0.2.3-alpha.4 → 0.2.3
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.d.ts +1 -1
- package/lib/index.js +112 -41
- package/lib/integrations/onebot/api.d.ts +1 -0
- package/lib/integrations/onebot/tools/poke.d.ts +3 -0
- package/lib/integrations/onebot/tools/profile.d.ts +2 -0
- package/lib/integrations/onebot/tools/send-fake-msg.d.ts +2 -0
- package/lib/integrations/onebot/tools/send-forward-msg.d.ts +2 -0
- package/lib/integrations/onebot/tools/set-msg-emoji.d.ts +3 -0
- package/lib/schema/index.d.ts +4 -0
- package/lib/schema/tools.d.ts +4 -0
- package/lib/types/config.d.ts +2 -0
- package/package.json +1 -1
- package/readme.md +3 -0
package/lib/index.d.ts
CHANGED
|
@@ -14,4 +14,4 @@ export * from './renders';
|
|
|
14
14
|
export * from './commands';
|
|
15
15
|
export * from './integrations';
|
|
16
16
|
export { ConfigSchema, AffinitySchema, BlacklistSchema, RelationshipSchema, ScheduleSchema, OtherVariablesSchema, NativeToolsSchema, XmlToolsSchema, OtherCommandsSchema, OtherSettingsSchema } from './schema';
|
|
17
|
-
export declare const usage = "\n## \u66F4\u65B0\u65E5\u5FD7\n\n0.2.3-alpha.4\n- \u4FEE\u590D\u65E5\u7A0B\u751F\u6210\u63D0\u793A\u8BCD\u4EBA\u8BBE\u6CE8\u5165\u53D8\u91CF {persona} \u5931\u6548\u7684\u95EE\u9898\uFF0C\u65B0\u589E\u6A21\u578B\u9009\u62E9\u4E0E\u4EBA\u8BBE\u6CE8\u5165\u9009\u9879\n- \u5929\u6C14\u670D\u52A1\u5207\u6362\u4E3A open-meteo\uFF0C\u4E0D\u518D\u9700\u8981\u63D0\u4F9B token\n\n0.2.3-alpha.3\n- \u4FEE\u590D\u65E0\u6CD5\u9009\u62E9\u65E5\u7A0B\u6A21\u578B\u7684\u95EE\u9898\n
|
|
17
|
+
export declare const usage = "\n## \u66F4\u65B0\u65E5\u5FD7\n\n0.2.3\n- OneBot \u534F\u8BAE\u65B0\u589E NapCat/LLBot \u72EC\u7ACB\u9009\u9879\uFF0C\u6309\u914D\u7F6E\u9009\u62E9\u534F\u8BAE\n\n0.2.3-alpha.4\n- \u4FEE\u590D\u65E5\u7A0B\u751F\u6210\u63D0\u793A\u8BCD\u4EBA\u8BBE\u6CE8\u5165\u53D8\u91CF {persona} \u5931\u6548\u7684\u95EE\u9898\uFF0C\u65B0\u589E\u6A21\u578B\u9009\u62E9\u4E0E\u4EBA\u8BBE\u6CE8\u5165\u9009\u9879\n- \u5929\u6C14\u670D\u52A1\u5207\u6362\u4E3A open-meteo\uFF0C\u4E0D\u518D\u9700\u8981\u63D0\u4F9B token\n\n0.2.3-alpha.3\n- \u4FEE\u590D\u65E0\u6CD5\u9009\u62E9\u65E5\u7A0B\u6A21\u578B\u7684\u95EE\u9898\n";
|
package/lib/index.js
CHANGED
|
@@ -539,7 +539,7 @@ var import_koishi4 = require("koishi");
|
|
|
539
539
|
var ScheduleSchema = import_koishi4.Schema.object({
|
|
540
540
|
schedule: import_koishi4.Schema.object({
|
|
541
541
|
enabled: import_koishi4.Schema.boolean().default(true).description("\u662F\u5426\u542F\u7528\u65E5\u7A0B\u529F\u80FD"),
|
|
542
|
-
model: import_koishi4.Schema.dynamic("model").default("").description("\u65E5\u7A0B\u751F\u6210\u4F7F\u7528\u7684\u6A21\u578B
|
|
542
|
+
model: import_koishi4.Schema.dynamic("model").default("").description("\u65E5\u7A0B\u751F\u6210\u4F7F\u7528\u7684\u6A21\u578B"),
|
|
543
543
|
personaSource: import_koishi4.Schema.union([
|
|
544
544
|
import_koishi4.Schema.const("none").description("\u4E0D\u6CE8\u5165\u4EBA\u8BBE"),
|
|
545
545
|
import_koishi4.Schema.const("chatluna").description("\u4F7F\u7528 ChatLuna \u4E3B\u63D2\u4EF6\u4EBA\u8BBE"),
|
|
@@ -659,6 +659,8 @@ var OtherVariablesSchema = import_koishi6.Schema.object({
|
|
|
659
659
|
// src/schema/tools.ts
|
|
660
660
|
var import_koishi7 = require("koishi");
|
|
661
661
|
var NativeToolsSchema = import_koishi7.Schema.object({
|
|
662
|
+
enableNapCatProtocol: import_koishi7.Schema.boolean().default(true).description("\u542F\u7528 NapCat OneBot \u534F\u8BAE\uFF08\u4E0E LLBot \u4E8C\u9009\u4E00\uFF09"),
|
|
663
|
+
enableLlbotProtocol: import_koishi7.Schema.boolean().default(false).description("\u542F\u7528 LLBot OneBot \u534F\u8BAE\uFF08\u4E0E NapCat \u4E8C\u9009\u4E00\uFF09"),
|
|
662
664
|
enablePokeTool: import_koishi7.Schema.boolean().default(false).description("\u6CE8\u518C ChatLuna \u5DE5\u5177\uFF1A\u6233\u4E00\u6233"),
|
|
663
665
|
pokeToolName: import_koishi7.Schema.string().default("poke_user").description("ChatLuna \u5DE5\u5177\u540D\u79F0\uFF1A\u6233\u4E00\u6233"),
|
|
664
666
|
enableSetSelfProfileTool: import_koishi7.Schema.boolean().default(false).description("\u6CE8\u518C ChatLuna \u5DE5\u5177\uFF1A\u4FEE\u6539\u81EA\u8EAB\u8D26\u6237\u4FE1\u606F"),
|
|
@@ -7491,13 +7493,22 @@ async function callOneBotAPI(internal, action, params, fallbacks = []) {
|
|
|
7491
7493
|
// src/integrations/onebot/tools/poke.ts
|
|
7492
7494
|
async function sendPoke(params) {
|
|
7493
7495
|
try {
|
|
7494
|
-
const { session, userId, groupId, log } = params;
|
|
7496
|
+
const { session, userId, groupId, log, protocol } = params;
|
|
7495
7497
|
const { error, internal, session: validatedSession } = ensureOneBotSession(session);
|
|
7496
7498
|
if (error) return error;
|
|
7497
7499
|
const resolvedGroupId = groupId?.trim() || validatedSession?.guildId || validatedSession?.channelId || validatedSession?.roomId;
|
|
7498
7500
|
const payload = { user_id: userId };
|
|
7499
7501
|
if (resolvedGroupId) payload.group_id = resolvedGroupId;
|
|
7500
|
-
if (
|
|
7502
|
+
if (protocol === "llbot") {
|
|
7503
|
+
const action = payload.group_id ? "group_poke" : "friend_poke";
|
|
7504
|
+
if (typeof internal._request === "function") {
|
|
7505
|
+
await internal._request(action, payload);
|
|
7506
|
+
} else if (typeof internal[action] === "function") {
|
|
7507
|
+
await internal[action](payload);
|
|
7508
|
+
} else {
|
|
7509
|
+
throw new Error(`\u5F53\u524D\u9002\u914D\u5668\u672A\u5B9E\u73B0 ${action} API\u3002`);
|
|
7510
|
+
}
|
|
7511
|
+
} else if (typeof internal._request === "function") {
|
|
7501
7512
|
await internal._request("send_poke", payload);
|
|
7502
7513
|
} else if (typeof internal.sendPoke === "function") {
|
|
7503
7514
|
await internal.sendPoke(
|
|
@@ -7519,7 +7530,7 @@ async function sendPoke(params) {
|
|
|
7519
7530
|
}
|
|
7520
7531
|
}
|
|
7521
7532
|
function createPokeTool(deps) {
|
|
7522
|
-
const { toolName, log } = deps;
|
|
7533
|
+
const { toolName, log, protocol } = deps;
|
|
7523
7534
|
return new class extends import_tools8.StructuredTool {
|
|
7524
7535
|
name = toolName || "poke_user";
|
|
7525
7536
|
description = "Poke (nudge) a specified user in a group or private conversation.";
|
|
@@ -7531,7 +7542,7 @@ function createPokeTool(deps) {
|
|
|
7531
7542
|
});
|
|
7532
7543
|
async _call(input, _manager, runnable) {
|
|
7533
7544
|
const session = getSession(runnable);
|
|
7534
|
-
return sendPoke({ session, userId: input.userId, groupId: input.groupId, log });
|
|
7545
|
+
return sendPoke({ session, userId: input.userId, groupId: input.groupId, log, protocol });
|
|
7535
7546
|
}
|
|
7536
7547
|
}();
|
|
7537
7548
|
}
|
|
@@ -7541,7 +7552,7 @@ var import_zod8 = require("zod");
|
|
|
7541
7552
|
var import_tools9 = require("@langchain/core/tools");
|
|
7542
7553
|
var genders = { unknown: "0", male: "1", female: "2" };
|
|
7543
7554
|
function createSetProfileTool(deps) {
|
|
7544
|
-
const { toolName, log } = deps;
|
|
7555
|
+
const { toolName, log, protocol } = deps;
|
|
7545
7556
|
return new class extends import_tools9.StructuredTool {
|
|
7546
7557
|
name = toolName || "set_self_profile";
|
|
7547
7558
|
description = "Update the bot's own QQ profile (nickname, signature, gender).";
|
|
@@ -7557,7 +7568,7 @@ function createSetProfileTool(deps) {
|
|
|
7557
7568
|
if (error) return error;
|
|
7558
7569
|
const payload = { nickname: input.nickname };
|
|
7559
7570
|
if (input.signature) payload.personal_note = input.signature;
|
|
7560
|
-
if (input.gender) payload.sex = genders[input.gender];
|
|
7571
|
+
if (input.gender && protocol !== "llbot") payload.sex = genders[input.gender];
|
|
7561
7572
|
await callOneBotAPI(internal, "set_qq_profile", payload, ["setQQProfile"]);
|
|
7562
7573
|
const message = "\u673A\u5668\u4EBA\u8D44\u6599\u5DF2\u66F4\u65B0\u3002";
|
|
7563
7574
|
log?.("info", message);
|
|
@@ -7617,9 +7628,12 @@ var import_zod10 = require("zod");
|
|
|
7617
7628
|
var import_tools11 = require("@langchain/core/tools");
|
|
7618
7629
|
async function sendMsgEmoji(params) {
|
|
7619
7630
|
try {
|
|
7620
|
-
const { session, messageId, emojiId, log } = params;
|
|
7631
|
+
const { session, messageId, emojiId, log, protocol } = params;
|
|
7621
7632
|
if (!session) return "No session context available.";
|
|
7622
7633
|
if (session.platform !== "onebot") return "This tool only supports OneBot platform.";
|
|
7634
|
+
if (protocol === "llbot" && !session.guildId && !session.channelId) {
|
|
7635
|
+
return "\u5F53\u524D\u4F1A\u8BDD\u4E0D\u662F\u7FA4\u804A\uFF0CLLBot \u4E0D\u652F\u6301\u79C1\u804A\u8868\u60C5\u56DE\u5E94\u3002";
|
|
7636
|
+
}
|
|
7623
7637
|
const messageIdRaw = messageId.trim();
|
|
7624
7638
|
const emojiIdRaw = emojiId.trim();
|
|
7625
7639
|
if (!messageIdRaw) return "message_id is required.";
|
|
@@ -7642,7 +7656,7 @@ async function sendMsgEmoji(params) {
|
|
|
7642
7656
|
}
|
|
7643
7657
|
}
|
|
7644
7658
|
function createSetMsgEmojiTool(deps) {
|
|
7645
|
-
const { toolName, log } = deps;
|
|
7659
|
+
const { toolName, log, protocol } = deps;
|
|
7646
7660
|
return new class extends import_tools11.StructuredTool {
|
|
7647
7661
|
name = toolName || "set_msg_emoji";
|
|
7648
7662
|
description = "React to a message with an emoji by messageId. Required: message_id and emoji_id (emoji ID).";
|
|
@@ -7652,7 +7666,7 @@ function createSetMsgEmojiTool(deps) {
|
|
|
7652
7666
|
});
|
|
7653
7667
|
async _call(input, _manager, runnable) {
|
|
7654
7668
|
const session = getSession(runnable);
|
|
7655
|
-
return sendMsgEmoji({ session, messageId: input.messageId, emojiId: input.emojiId, log });
|
|
7669
|
+
return sendMsgEmoji({ session, messageId: input.messageId, emojiId: input.emojiId, log, protocol });
|
|
7656
7670
|
}
|
|
7657
7671
|
}();
|
|
7658
7672
|
}
|
|
@@ -7661,7 +7675,7 @@ function createSetMsgEmojiTool(deps) {
|
|
|
7661
7675
|
var import_zod11 = require("zod");
|
|
7662
7676
|
var import_tools12 = require("@langchain/core/tools");
|
|
7663
7677
|
function createFakeMessageTool(deps) {
|
|
7664
|
-
const { toolName, log } = deps;
|
|
7678
|
+
const { toolName, log, protocol } = deps;
|
|
7665
7679
|
return new class extends import_tools12.StructuredTool {
|
|
7666
7680
|
name = toolName || "send_fake_msg";
|
|
7667
7681
|
description = "Forge messages for one or more users and send as a merged forward. Accepts messages array or senderId + texts. Requires OneBot and send_forward_msg support.";
|
|
@@ -7704,6 +7718,18 @@ function createFakeMessageTool(deps) {
|
|
|
7704
7718
|
if (!targetGroupId) {
|
|
7705
7719
|
return "Missing targetGroupId. Provide targetGroupId or run inside a group session.";
|
|
7706
7720
|
}
|
|
7721
|
+
const buildForwardContent = (content) => [{
|
|
7722
|
+
type: "text",
|
|
7723
|
+
data: { text: content }
|
|
7724
|
+
}];
|
|
7725
|
+
const buildLegacyNodes = (targets) => targets.map((node) => ({
|
|
7726
|
+
type: "node",
|
|
7727
|
+
data: {
|
|
7728
|
+
name: node.data.name,
|
|
7729
|
+
uin: node.data.uin,
|
|
7730
|
+
content: node.data.content.map((segment) => segment.data.text || "").filter(Boolean).join("")
|
|
7731
|
+
}
|
|
7732
|
+
}));
|
|
7707
7733
|
const nodes = (() => {
|
|
7708
7734
|
const buildNodesFromMessages = (messages) => {
|
|
7709
7735
|
return messages.map((item) => {
|
|
@@ -7718,7 +7744,7 @@ function createFakeMessageTool(deps) {
|
|
|
7718
7744
|
data: {
|
|
7719
7745
|
name: displayName2 || uin,
|
|
7720
7746
|
uin,
|
|
7721
|
-
content: text
|
|
7747
|
+
content: buildForwardContent(text)
|
|
7722
7748
|
}
|
|
7723
7749
|
};
|
|
7724
7750
|
}).filter((v) => Boolean(v));
|
|
@@ -7750,7 +7776,7 @@ function createFakeMessageTool(deps) {
|
|
|
7750
7776
|
data: {
|
|
7751
7777
|
name: displayName,
|
|
7752
7778
|
uin: senderId,
|
|
7753
|
-
content
|
|
7779
|
+
content: buildForwardContent(content)
|
|
7754
7780
|
}
|
|
7755
7781
|
}));
|
|
7756
7782
|
})();
|
|
@@ -7770,12 +7796,22 @@ function createFakeMessageTool(deps) {
|
|
|
7770
7796
|
);
|
|
7771
7797
|
const { error, internal } = ensureOneBotSession(session);
|
|
7772
7798
|
if (error) return error;
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7799
|
+
if (protocol === "llbot") {
|
|
7800
|
+
await callOneBotAPI(
|
|
7801
|
+
internal,
|
|
7802
|
+
"send_group_forward_msg",
|
|
7803
|
+
{ group_id: targetGroupId, messages: nodes },
|
|
7804
|
+
["sendGroupForwardMsg"]
|
|
7805
|
+
);
|
|
7806
|
+
} else {
|
|
7807
|
+
const legacyNodes = buildLegacyNodes(nodes);
|
|
7808
|
+
await callOneBotAPI(
|
|
7809
|
+
internal,
|
|
7810
|
+
"send_forward_msg",
|
|
7811
|
+
{ group_id: targetGroupId, messages: legacyNodes },
|
|
7812
|
+
["sendForwardMsg"]
|
|
7813
|
+
);
|
|
7814
|
+
}
|
|
7779
7815
|
const senderSet = Array.from(new Set(nodes.map((n) => n.data.uin || n.data.name).filter(Boolean)));
|
|
7780
7816
|
const senderLabel = senderSet.length ? senderSet.join(",") : "unknown";
|
|
7781
7817
|
const success = `Forged ${nodes.length} messages from ${senderLabel} and forwarded to group ${targetGroupId}.`;
|
|
@@ -7793,7 +7829,7 @@ function createFakeMessageTool(deps) {
|
|
|
7793
7829
|
var import_zod12 = require("zod");
|
|
7794
7830
|
var import_tools13 = require("@langchain/core/tools");
|
|
7795
7831
|
function createForwardMessageTool(deps) {
|
|
7796
|
-
const { toolName, messageStore, log } = deps;
|
|
7832
|
+
const { toolName, messageStore, log, protocol } = deps;
|
|
7797
7833
|
return new class extends import_tools13.StructuredTool {
|
|
7798
7834
|
name = toolName || "send_forward_msg";
|
|
7799
7835
|
description = "Forward messages as a merged forward to a group. messageIds is required to specify messages to forward. Requires message_id exposure via chatluna-character enableMessageId.";
|
|
@@ -7811,11 +7847,11 @@ function createForwardMessageTool(deps) {
|
|
|
7811
7847
|
return "Missing targetGroupId. Provide targetGroupId or run inside a group session.";
|
|
7812
7848
|
}
|
|
7813
7849
|
const explicitIds = Array.isArray(input.messageIds) && input.messageIds.length ? input.messageIds.map((id) => id.trim()).filter(Boolean) : [];
|
|
7814
|
-
let
|
|
7850
|
+
let legacyNodes;
|
|
7815
7851
|
if (explicitIds.length > 0) {
|
|
7816
7852
|
const found = messageStore.findByIds(session, explicitIds);
|
|
7817
7853
|
const map = new Map(found.map((msg) => [msg.messageId, msg]));
|
|
7818
|
-
|
|
7854
|
+
legacyNodes = explicitIds.map((id) => {
|
|
7819
7855
|
const hit = map.get(id);
|
|
7820
7856
|
if (!hit) return null;
|
|
7821
7857
|
return {
|
|
@@ -7823,11 +7859,11 @@ function createForwardMessageTool(deps) {
|
|
|
7823
7859
|
data: {
|
|
7824
7860
|
name: hit.username || hit.userId || "\u672A\u77E5\u7528\u6237",
|
|
7825
7861
|
uin: hit.userId || session.userId || "",
|
|
7826
|
-
content: hit.content
|
|
7862
|
+
content: String(hit.content || "")
|
|
7827
7863
|
}
|
|
7828
7864
|
};
|
|
7829
7865
|
}).filter((item) => item !== null);
|
|
7830
|
-
if (!
|
|
7866
|
+
if (!legacyNodes.length) {
|
|
7831
7867
|
return "No messages found for provided messageIds.";
|
|
7832
7868
|
}
|
|
7833
7869
|
} else {
|
|
@@ -7835,13 +7871,30 @@ function createForwardMessageTool(deps) {
|
|
|
7835
7871
|
}
|
|
7836
7872
|
const { error, internal } = ensureOneBotSession(session);
|
|
7837
7873
|
if (error) return error;
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7874
|
+
if (protocol === "llbot") {
|
|
7875
|
+
const llbotNodes = legacyNodes.map((node) => ({
|
|
7876
|
+
type: "node",
|
|
7877
|
+
data: {
|
|
7878
|
+
name: node.data.name,
|
|
7879
|
+
uin: node.data.uin,
|
|
7880
|
+
content: [{ type: "text", data: { text: node.data.content } }]
|
|
7881
|
+
}
|
|
7882
|
+
}));
|
|
7883
|
+
await callOneBotAPI(
|
|
7884
|
+
internal,
|
|
7885
|
+
"send_group_forward_msg",
|
|
7886
|
+
{ group_id: targetGroupId, messages: llbotNodes },
|
|
7887
|
+
["sendGroupForwardMsg"]
|
|
7888
|
+
);
|
|
7889
|
+
} else {
|
|
7890
|
+
await callOneBotAPI(
|
|
7891
|
+
internal,
|
|
7892
|
+
"send_forward_msg",
|
|
7893
|
+
{ group_id: targetGroupId, messages: legacyNodes },
|
|
7894
|
+
["sendForwardMsg"]
|
|
7895
|
+
);
|
|
7896
|
+
}
|
|
7897
|
+
const success = `Forwarded ${legacyNodes.length} messages to group ${targetGroupId}.`;
|
|
7845
7898
|
log?.("info", success);
|
|
7846
7899
|
return success;
|
|
7847
7900
|
} catch (error) {
|
|
@@ -8643,6 +8696,17 @@ function apply(ctx, config) {
|
|
|
8643
8696
|
});
|
|
8644
8697
|
});
|
|
8645
8698
|
const log = createLogger2(ctx, config);
|
|
8699
|
+
const resolveOneBotProtocol = () => {
|
|
8700
|
+
if (config.enableNapCatProtocol && config.enableLlbotProtocol) {
|
|
8701
|
+
log("warn", "NapCat \u4E0E LLBot \u534F\u8BAE\u540C\u65F6\u542F\u7528\uFF0C\u5C06\u4F18\u5148\u4F7F\u7528 LLBot\u3002");
|
|
8702
|
+
return "llbot";
|
|
8703
|
+
}
|
|
8704
|
+
if (config.enableLlbotProtocol) return "llbot";
|
|
8705
|
+
if (config.enableNapCatProtocol) return "napcat";
|
|
8706
|
+
log("warn", "\u672A\u542F\u7528 OneBot \u534F\u8BAE\u9009\u9879\uFF0C\u9ED8\u8BA4\u4F7F\u7528 NapCat\u3002");
|
|
8707
|
+
return "napcat";
|
|
8708
|
+
};
|
|
8709
|
+
const onebotProtocol = resolveOneBotProtocol();
|
|
8646
8710
|
log("warn", "\u26A0\uFE0F \u5347\u7EA7\u63D0\u793A\uFF1A0.2.1-alpha.10 \u7248\u672C\u540E\u6570\u636E\u5E93\u7ED3\u6784\u5DF2\u91CD\u6784\uFF0C\u82E5\u51FA\u73B0\u6570\u636E\u5E93\u76F8\u5173\u9519\u8BEF\uFF0C\u8BF7\u6267\u884C affinity.clearall \u547D\u4EE4\u6E05\u9664\u6570\u636E\u540E\u91CD\u8BD5\u3002\u597D\u611F\u5EA6\u5206\u6790\u63D0\u793A\u8BCD\u4E0E\u65E5\u7A0B\u751F\u6210\u63D0\u793A\u8BCD\u5DF2\u66F4\u65B0\uFF0C\u82E5\u60A8\u81EA\u5B9A\u4E49\u8FC7\u63D0\u793A\u8BCD\uFF0C\u8BF7\u5C06\u5176\u6062\u590D\u9ED8\u8BA4\u4EE5\u5E94\u7528\u6700\u65B0\u7248\u672C\u3002");
|
|
8647
8711
|
const cache = createAffinityCache();
|
|
8648
8712
|
const store = createAffinityStore({ ctx, config, log });
|
|
@@ -8821,7 +8885,7 @@ function apply(ctx, config) {
|
|
|
8821
8885
|
const session = rawModelResponseSessionMap.get(rawModelResponseGuildId) || null;
|
|
8822
8886
|
if (session && targetIds.length) {
|
|
8823
8887
|
for (const userId of targetIds) {
|
|
8824
|
-
void sendPoke({ session, userId, log });
|
|
8888
|
+
void sendPoke({ session, userId, log, protocol: onebotProtocol });
|
|
8825
8889
|
}
|
|
8826
8890
|
} else if (targetIds.length) {
|
|
8827
8891
|
log("warn", "\u68C0\u6D4B\u5230\u6233\u4E00\u6233\u6807\u8BB0\u4F46\u7F3A\u5C11\u4F1A\u8BDD\u4E0A\u4E0B\u6587", {
|
|
@@ -8843,7 +8907,13 @@ function apply(ctx, config) {
|
|
|
8843
8907
|
const messageId = String(match[1] || "").trim();
|
|
8844
8908
|
const emojiId = String(match[2] || "").trim();
|
|
8845
8909
|
if (messageId && emojiId) {
|
|
8846
|
-
void sendMsgEmoji({
|
|
8910
|
+
void sendMsgEmoji({
|
|
8911
|
+
session,
|
|
8912
|
+
messageId,
|
|
8913
|
+
emojiId,
|
|
8914
|
+
log,
|
|
8915
|
+
protocol: onebotProtocol
|
|
8916
|
+
});
|
|
8847
8917
|
}
|
|
8848
8918
|
}
|
|
8849
8919
|
} else {
|
|
@@ -9082,7 +9152,7 @@ function apply(ctx, config) {
|
|
|
9082
9152
|
plugin.registerTool(toolName, {
|
|
9083
9153
|
selector: () => true,
|
|
9084
9154
|
authorization: (session) => session?.platform === "onebot",
|
|
9085
|
-
createTool: () => createPokeTool({ ctx, toolName, log })
|
|
9155
|
+
createTool: () => createPokeTool({ ctx, toolName, log, protocol: onebotProtocol })
|
|
9086
9156
|
});
|
|
9087
9157
|
log("info", `\u6233\u4E00\u6233\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
9088
9158
|
}
|
|
@@ -9099,7 +9169,7 @@ function apply(ctx, config) {
|
|
|
9099
9169
|
plugin.registerTool(toolName, {
|
|
9100
9170
|
selector: () => true,
|
|
9101
9171
|
authorization: (session) => session?.platform === "onebot",
|
|
9102
|
-
createTool: () => createSetProfileTool({ ctx, toolName, log })
|
|
9172
|
+
createTool: () => createSetProfileTool({ ctx, toolName, log, protocol: onebotProtocol })
|
|
9103
9173
|
});
|
|
9104
9174
|
log("info", `\u8BBE\u7F6E\u8D44\u6599\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
9105
9175
|
}
|
|
@@ -9117,7 +9187,7 @@ function apply(ctx, config) {
|
|
|
9117
9187
|
plugin.registerTool(toolName, {
|
|
9118
9188
|
selector: () => true,
|
|
9119
9189
|
authorization: (session) => session?.platform === "onebot",
|
|
9120
|
-
createTool: () => createSetMsgEmojiTool({ toolName, log })
|
|
9190
|
+
createTool: () => createSetMsgEmojiTool({ toolName, log, protocol: onebotProtocol })
|
|
9121
9191
|
});
|
|
9122
9192
|
log("info", `\u6D88\u606F\u8868\u60C5\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
9123
9193
|
}
|
|
@@ -9129,7 +9199,8 @@ function apply(ctx, config) {
|
|
|
9129
9199
|
createTool: () => createForwardMessageTool({
|
|
9130
9200
|
toolName,
|
|
9131
9201
|
messageStore,
|
|
9132
|
-
log
|
|
9202
|
+
log,
|
|
9203
|
+
protocol: onebotProtocol
|
|
9133
9204
|
})
|
|
9134
9205
|
});
|
|
9135
9206
|
log("info", `\u5408\u5E76\u8F6C\u53D1\u6D88\u606F\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
@@ -9139,7 +9210,7 @@ function apply(ctx, config) {
|
|
|
9139
9210
|
plugin.registerTool(toolName, {
|
|
9140
9211
|
selector: () => true,
|
|
9141
9212
|
authorization: (session) => session?.platform === "onebot",
|
|
9142
|
-
createTool: () => createFakeMessageTool({ toolName, log })
|
|
9213
|
+
createTool: () => createFakeMessageTool({ toolName, log, protocol: onebotProtocol })
|
|
9143
9214
|
});
|
|
9144
9215
|
log("info", `\u4F2A\u9020\u6D88\u606F\u5DE5\u5177\u5DF2\u6CE8\u518C: ${toolName}`);
|
|
9145
9216
|
}
|
|
@@ -9172,15 +9243,15 @@ function apply(ctx, config) {
|
|
|
9172
9243
|
var usage = `
|
|
9173
9244
|
## \u66F4\u65B0\u65E5\u5FD7
|
|
9174
9245
|
|
|
9246
|
+
0.2.3
|
|
9247
|
+
- OneBot \u534F\u8BAE\u65B0\u589E NapCat/LLBot \u72EC\u7ACB\u9009\u9879\uFF0C\u6309\u914D\u7F6E\u9009\u62E9\u534F\u8BAE
|
|
9248
|
+
|
|
9175
9249
|
0.2.3-alpha.4
|
|
9176
9250
|
- \u4FEE\u590D\u65E5\u7A0B\u751F\u6210\u63D0\u793A\u8BCD\u4EBA\u8BBE\u6CE8\u5165\u53D8\u91CF {persona} \u5931\u6548\u7684\u95EE\u9898\uFF0C\u65B0\u589E\u6A21\u578B\u9009\u62E9\u4E0E\u4EBA\u8BBE\u6CE8\u5165\u9009\u9879
|
|
9177
9251
|
- \u5929\u6C14\u670D\u52A1\u5207\u6362\u4E3A open-meteo\uFF0C\u4E0D\u518D\u9700\u8981\u63D0\u4F9B token
|
|
9178
9252
|
|
|
9179
9253
|
0.2.3-alpha.3
|
|
9180
9254
|
- \u4FEE\u590D\u65E0\u6CD5\u9009\u62E9\u65E5\u7A0B\u6A21\u578B\u7684\u95EE\u9898
|
|
9181
|
-
|
|
9182
|
-
0.2.3-alpha.2
|
|
9183
|
-
- \u4FEE\u590D\u597D\u611F\u5EA6\u66F4\u65B0\u65F6\u672A\u66F4\u65B0 chatCount \u7684\u95EE\u9898
|
|
9184
9255
|
`;
|
|
9185
9256
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9186
9257
|
0 && (module.exports = {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* 提供 OneBot 平台 API 调用的辅助函数
|
|
4
4
|
*/
|
|
5
5
|
import type { Session } from 'koishi';
|
|
6
|
+
export type OneBotProtocol = 'napcat' | 'llbot';
|
|
6
7
|
export interface OneBotInternal {
|
|
7
8
|
_request?: (action: string, params: Record<string, unknown>) => Promise<unknown>;
|
|
8
9
|
[key: string]: unknown;
|
|
@@ -5,15 +5,18 @@
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import type { Context, Session } from 'koishi';
|
|
7
7
|
import type { LogFn } from '../../../types';
|
|
8
|
+
import { type OneBotProtocol } from '../api';
|
|
8
9
|
export interface PokeToolDeps {
|
|
9
10
|
ctx: Context;
|
|
10
11
|
toolName: string;
|
|
12
|
+
protocol: OneBotProtocol;
|
|
11
13
|
log?: LogFn;
|
|
12
14
|
}
|
|
13
15
|
export interface SendPokeParams {
|
|
14
16
|
session: Session | null;
|
|
15
17
|
userId: string;
|
|
16
18
|
groupId?: string;
|
|
19
|
+
protocol: OneBotProtocol;
|
|
17
20
|
log?: LogFn;
|
|
18
21
|
}
|
|
19
22
|
export declare function sendPoke(params: SendPokeParams): Promise<string>;
|
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import type { Context } from 'koishi';
|
|
7
7
|
import type { LogFn } from '../../../types';
|
|
8
|
+
import { type OneBotProtocol } from '../api';
|
|
8
9
|
export interface ProfileToolDeps {
|
|
9
10
|
ctx: Context;
|
|
10
11
|
toolName: string;
|
|
12
|
+
protocol: OneBotProtocol;
|
|
11
13
|
log?: LogFn;
|
|
12
14
|
}
|
|
13
15
|
export declare function createSetProfileTool(deps: ProfileToolDeps): {
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import type { LogFn } from '../../../types';
|
|
7
|
+
import { type OneBotProtocol } from '../api';
|
|
7
8
|
export interface FakeMessageToolDeps {
|
|
8
9
|
toolName: string;
|
|
10
|
+
protocol: OneBotProtocol;
|
|
9
11
|
log?: LogFn;
|
|
10
12
|
}
|
|
11
13
|
export declare function createFakeMessageTool(deps: FakeMessageToolDeps): {
|
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import type { LogFn } from '../../../types';
|
|
7
7
|
import type { MessageStore } from '../../../services/message/store';
|
|
8
|
+
import { type OneBotProtocol } from '../api';
|
|
8
9
|
export interface ForwardMessageToolDeps {
|
|
9
10
|
toolName: string;
|
|
10
11
|
messageStore: MessageStore;
|
|
12
|
+
protocol: OneBotProtocol;
|
|
11
13
|
log?: LogFn;
|
|
12
14
|
}
|
|
13
15
|
export declare function createForwardMessageTool(deps: ForwardMessageToolDeps): {
|
|
@@ -5,14 +5,17 @@
|
|
|
5
5
|
import { StructuredTool } from '@langchain/core/tools';
|
|
6
6
|
import type { LogFn } from '../../../types';
|
|
7
7
|
import type { Session } from 'koishi';
|
|
8
|
+
import { type OneBotProtocol } from '../api';
|
|
8
9
|
export interface SetMsgEmojiToolDeps {
|
|
9
10
|
toolName: string;
|
|
11
|
+
protocol: OneBotProtocol;
|
|
10
12
|
log?: LogFn;
|
|
11
13
|
}
|
|
12
14
|
export interface SendMsgEmojiParams {
|
|
13
15
|
session: Session | null;
|
|
14
16
|
messageId: string;
|
|
15
17
|
emojiId: string;
|
|
18
|
+
protocol: OneBotProtocol;
|
|
16
19
|
log?: LogFn;
|
|
17
20
|
}
|
|
18
21
|
export declare function sendMsgEmoji(params: SendMsgEmojiParams): Promise<string>;
|
package/lib/schema/index.d.ts
CHANGED
|
@@ -155,6 +155,8 @@ export declare const ConfigSchema: Schema<{
|
|
|
155
155
|
max?: number | null | undefined;
|
|
156
156
|
} & import("cosmokit").Dict) | null | undefined;
|
|
157
157
|
} & {
|
|
158
|
+
enableNapCatProtocol?: boolean | null | undefined;
|
|
159
|
+
enableLlbotProtocol?: boolean | null | undefined;
|
|
158
160
|
enablePokeTool?: boolean | null | undefined;
|
|
159
161
|
pokeToolName?: string | null | undefined;
|
|
160
162
|
enableSetSelfProfileTool?: boolean | null | undefined;
|
|
@@ -351,6 +353,8 @@ export declare const ConfigSchema: Schema<{
|
|
|
351
353
|
max: Schema<number, number>;
|
|
352
354
|
}>;
|
|
353
355
|
} & {
|
|
356
|
+
enableNapCatProtocol: boolean;
|
|
357
|
+
enableLlbotProtocol: boolean;
|
|
354
358
|
enablePokeTool: boolean;
|
|
355
359
|
pokeToolName: string;
|
|
356
360
|
enableSetSelfProfileTool: boolean;
|
package/lib/schema/tools.d.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { Schema } from 'koishi';
|
|
6
6
|
export declare const NativeToolsSchema: Schema<Schemastery.ObjectS<{
|
|
7
|
+
enableNapCatProtocol: Schema<boolean, boolean>;
|
|
8
|
+
enableLlbotProtocol: Schema<boolean, boolean>;
|
|
7
9
|
enablePokeTool: Schema<boolean, boolean>;
|
|
8
10
|
pokeToolName: Schema<string, string>;
|
|
9
11
|
enableSetSelfProfileTool: Schema<boolean, boolean>;
|
|
@@ -38,6 +40,8 @@ export declare const NativeToolsSchema: Schema<Schemastery.ObjectS<{
|
|
|
38
40
|
panSouMaxResults: Schema<number, number>;
|
|
39
41
|
}>>;
|
|
40
42
|
}>, Schemastery.ObjectT<{
|
|
43
|
+
enableNapCatProtocol: Schema<boolean, boolean>;
|
|
44
|
+
enableLlbotProtocol: Schema<boolean, boolean>;
|
|
41
45
|
enablePokeTool: Schema<boolean, boolean>;
|
|
42
46
|
pokeToolName: Schema<string, string>;
|
|
43
47
|
enableSetSelfProfileTool: Schema<boolean, boolean>;
|
package/lib/types/config.d.ts
CHANGED
|
@@ -119,6 +119,8 @@ export interface Config {
|
|
|
119
119
|
userInfo: UserInfoConfig;
|
|
120
120
|
botInfo: BotInfoConfig;
|
|
121
121
|
groupInfo: GroupInfoConfig;
|
|
122
|
+
enableNapCatProtocol: boolean;
|
|
123
|
+
enableLlbotProtocol: boolean;
|
|
122
124
|
enablePokeTool: boolean;
|
|
123
125
|
pokeToolName: string;
|
|
124
126
|
enablePokeXmlTool: boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-chatluna-affinity",
|
|
3
3
|
"description": "为 ChatLuna Character 提供更多变量及工具,例如 {好感度}、{关系}、{日程}、{天气}、{用户信息}、{机器人信息}、{群信息}等变量并提供对应的工具调用和低好感自动拉黑功能。",
|
|
4
|
-
"version": "0.2.3
|
|
4
|
+
"version": "0.2.3",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
package/readme.md
CHANGED