mioku-plugin-chat 3.0.4 → 3.0.5

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.
@@ -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
  })),
@@ -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.5",
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";
@@ -339,7 +338,7 @@ export interface ChatResult {
339
338
  pendingQuote?: string;
340
339
  toolCalls: { name: string; args: any; result: any }[];
341
340
  emojiPath?: string | null;
342
- protocolMessages?: ChatCompletionMessageParam[];
341
+ protocolMessages?: unknown[];
343
342
  }
344
343
 
345
344
  /**