mioku-plugin-chat 3.0.4 → 3.0.6

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/configs/base.ts CHANGED
@@ -4,4 +4,5 @@ export const BASE_CONFIG = {
4
4
  historyCount: 100,
5
5
  maxIterations: 20,
6
6
  enableMediaRecognition: true,
7
+ ignorePrivateChat: true,
7
8
  };
@@ -580,8 +580,8 @@ function prependDynamicContextToFirstUserMessage(
580
580
 
581
581
  const RATE_LIMITED_TOOL_NAMES = new Set(["web_search", "web_read_page"]);
582
582
  const RATE_LIMITED_BUILTIN_NAMES = new Set([
583
- "web_search.web_search",
584
- "web_search.web_read_page",
583
+ "web_search-web_search",
584
+ "web_search-web_read_page",
585
585
  ]);
586
586
 
587
587
  function buildSessionTools(
@@ -634,7 +634,7 @@ function buildSessionTools(
634
634
  }
635
635
 
636
636
  for (const [name, tool] of skillTools) {
637
- const skillName = name.split(".")[0] || "";
637
+ const skillName = name.split("-")[0] || "";
638
638
  const skill = toolCtx.aiService.getSkill(skillName);
639
639
  if (
640
640
  !toolCtx.config.enableExternalSkills ||
package/core/chat-turn.ts CHANGED
@@ -609,6 +609,15 @@ async function executeChatRuntimeRequestNow(
609
609
  { extraTools: options.extraTools },
610
610
  );
611
611
 
612
+ if (!result) {
613
+ pluginCtx.sessionManager.touch(sessionId);
614
+ return {
615
+ messages: [],
616
+ toolCalls: [],
617
+ collectedInfo: null,
618
+ };
619
+ }
620
+
612
621
  await finalizeChatTurn(pluginCtx, {
613
622
  event,
614
623
  cfg,
@@ -57,7 +57,7 @@ export async function extractGifFrames(
57
57
  })
58
58
  .png()
59
59
  .toBuffer();
60
- frames.push(`data:image/png);base64,${firstFrame.toString("base64")}`);
60
+ frames.push(`data:image/png;base64,${firstFrame.toString("base64")}`);
61
61
 
62
62
  // 提取中间帧
63
63
  if (middleIndex !== firstIndex && middleIndex !== lastIndex) {
@@ -67,7 +67,7 @@ export async function extractGifFrames(
67
67
  })
68
68
  .png()
69
69
  .toBuffer();
70
- frames.push(`data:image/png);base64,${middleFrame.toString("base64")}`);
70
+ frames.push(`data:image/png;base64,${middleFrame.toString("base64")}`);
71
71
  }
72
72
 
73
73
  // 提取末尾帧
@@ -78,7 +78,7 @@ export async function extractGifFrames(
78
78
  })
79
79
  .png()
80
80
  .toBuffer();
81
- frames.push(`data:image/png);base64,${lastFrame.toString("base64")}`);
81
+ frames.push(`data:image/png;base64,${lastFrame.toString("base64")}`);
82
82
  }
83
83
 
84
84
  logger.info(
@@ -97,7 +97,7 @@ export function createLoadSkillTool(
97
97
  feature: true,
98
98
  expires_in: "1 hour",
99
99
  tools: featureTools.map((t) => ({
100
- name: `${skillName}.${t.name}`,
100
+ name: `${skillName}-${t.name}`,
101
101
  description: t.description,
102
102
  parameters: t.parameters,
103
103
  })),
@@ -139,7 +139,7 @@ export function createLoadSkillTool(
139
139
  skill_name: skill.name,
140
140
  expires_in: "1 hour",
141
141
  tools: skill.tools.map((t) => ({
142
- name: `${skill.name}.${t.name}`,
142
+ name: `${skill.name}-${t.name}`,
143
143
  description: t.description,
144
144
  parameters: t.parameters,
145
145
  })),
@@ -39,6 +39,7 @@ export function createMessageHandler(
39
39
  ? Number(e.group_id)
40
40
  : undefined;
41
41
  const cfg = await getConfig(groupId);
42
+ if (!isGroup && cfg.ignorePrivateChat) return;
42
43
  if (!cfg.model && !cfg.apiKey) return;
43
44
  if (!e?.message || !Array.isArray(e.message)) return;
44
45
 
@@ -43,7 +43,7 @@ export class SkillSessionManager {
43
43
  const now = Date.now();
44
44
  const toolMap = new Map<string, AITool>();
45
45
  for (const tool of tools) {
46
- toolMap.set(`${skillName}.${tool.name}`, tool);
46
+ toolMap.set(`${skillName}-${tool.name}`, tool);
47
47
  }
48
48
 
49
49
  const session: SkillSession = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mioku-plugin-chat",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
4
  "description": "AI 智能聊天插件",
5
5
  "main": "index.ts",
6
6
  "type": "module",
@@ -15,9 +15,11 @@ function resolveRuntimeGroupId(
15
15
  ): number | undefined {
16
16
  if ("event" in options) {
17
17
  const event = options.event;
18
- return event?.message_type === "group" && typeof event.group_id === "number"
19
- ? event.group_id
20
- : undefined;
18
+ if (event?.kind !== "message" || event.message_type !== "group") {
19
+ return undefined;
20
+ }
21
+ const groupId: unknown = event.group_id;
22
+ return typeof groupId === "number" ? groupId : undefined;
21
23
  }
22
24
  return "groupId" in options ? options.groupId : undefined;
23
25
  }
package/types.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { ChatCompletionMessageParam } from "openai/resources/chat/completions";
2
1
  import type { MiokuContext } from "mioku";
3
2
  import type { AITool, AIService, SkillPermissionRole } from "mioku";
4
3
  import type { ChatDatabase } from "./db";
@@ -175,6 +174,7 @@ export interface ChatConfig {
175
174
  multimodalWorkingModel: string;
176
175
  isMultimodal: boolean;
177
176
  enableMediaRecognition: boolean;
177
+ ignorePrivateChat: boolean;
178
178
  nicknames: string[];
179
179
  persona: string;
180
180
  maxContextTokens: number;
@@ -339,7 +339,7 @@ export interface ChatResult {
339
339
  pendingQuote?: string;
340
340
  toolCalls: { name: string; args: any; result: any }[];
341
341
  emojiPath?: string | null;
342
- protocolMessages?: ChatCompletionMessageParam[];
342
+ protocolMessages?: unknown[];
343
343
  }
344
344
 
345
345
  /**