mioku-plugin-chat 2.6.0 → 2.7.0

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.
@@ -119,7 +119,7 @@ export const PERSONALIZATION_CONFIG: {
119
119
  emoji: {
120
120
  enabled: true,
121
121
  characters: [],
122
- useAISelection: true,
122
+ stickers: [],
123
123
  },
124
124
 
125
125
  expression: {
package/context.ts CHANGED
@@ -11,6 +11,7 @@ import type { GroupStructuredHistoryManager } from "./manage/group-structured-hi
11
11
  import type { CooldownManager } from "./manage/cooldown";
12
12
  import type { IdleCheckManager } from "./manage/idle-check";
13
13
  import type { QueueProcessor } from "./manage/queue-processor";
14
+ import type { SessionTurnScheduler } from "./manage/session-turn-scheduler";
14
15
  import type {
15
16
  RunRateLimitGuard,
16
17
  GetGroupHistoryMessages,
@@ -58,6 +59,7 @@ export interface ChatPluginContext {
58
59
  cooldownManager: CooldownManager;
59
60
  idleCheckManager: IdleCheckManager;
60
61
  queueProcessor: QueueProcessor;
62
+ sessionTurnScheduler: SessionTurnScheduler;
61
63
 
62
64
  // Utility
63
65
  runWithRateLimitGuard: RunRateLimitGuard;
package/core/base.ts CHANGED
@@ -518,7 +518,7 @@ function expandOutgoingLines(text: string): string[] {
518
518
 
519
519
  function normalizeActionLineBreaks(text: string): string {
520
520
  return String(text || "").replace(
521
- /\\\s*(?=(?:\[meme:[^\]]+\]|\[emotion:[^\]]+\]|\[audio:[^\]]+\]|\[reply:-?\d+\]))/gi,
521
+ /\\\s*(?=(?:\[\]|\[emotion:[^\]]+\]|\[audio:[^\]]+\]|\[reply:-?\d+\]))/gi,
522
522
  "\n",
523
523
  );
524
524
  }
@@ -180,8 +180,7 @@ export async function runChat(
180
180
  segment: string,
181
181
  unitIndex: number,
182
182
  ): Promise<void> => {
183
- const text = cleanMarkers(segment)
184
- .replace(/\[meme:[^\]]+\]/gi, "")
183
+ const text = removeStickerIntentLines(cleanMarkers(segment))
185
184
  .replace(/\[emotion:[^\]]+\]/gi, "")
186
185
  .replace(/\r/g, "")
187
186
  .trim();
@@ -348,13 +347,18 @@ export async function runChat(
348
347
  let emojiPath: string | null = null;
349
348
  let finalText = cleanedText;
350
349
  if (cleanedText.trim()) {
351
- const memeResult = await humanize.emojiAgent.processMemeResponse(
350
+ const stickerResult = await humanize.emojiAgent.processStickerResponse(
352
351
  cleanedText,
353
- toolCtx.sessionId,
352
+ {
353
+ sessionId: toolCtx.sessionId,
354
+ botNickname: promptCtx.botNickname,
355
+ chatHistory: history,
356
+ targetMessage,
357
+ },
354
358
  );
355
- if (memeResult.success && memeResult.emojiPath) {
356
- emojiPath = memeResult.emojiPath;
357
- finalText = memeResult.cleanedText || cleanedText;
359
+ finalText = stickerResult.cleanedText;
360
+ if (stickerResult.success && stickerResult.emojiPath) {
361
+ emojiPath = stickerResult.emojiPath;
358
362
  }
359
363
  }
360
364
 
@@ -723,6 +727,13 @@ function cleanMarkers(text: string): string {
723
727
  return cleaned;
724
728
  }
725
729
 
730
+ function removeStickerIntentLines(text: string): string {
731
+ return String(text || "")
732
+ .split(/\r?\n/)
733
+ .filter((line) => !/^\s*\[\]\s*$/.test(line))
734
+ .join("\n");
735
+ }
736
+
726
737
  function stripThinkBlocks(text: string): string {
727
738
  let source = String(text || "");
728
739
  let output = "";
package/core/chat-turn.ts CHANGED
@@ -124,7 +124,7 @@ function resolveRuntimeContext(
124
124
  }
125
125
 
126
126
  // Shared send/save/cooldown tail for both live and runtime turns.
127
- async function finalizeTurn(
127
+ export async function finalizeChatTurn(
128
128
  pluginCtx: ChatPluginContext,
129
129
  args: {
130
130
  event: any;
@@ -358,7 +358,7 @@ export async function processChat(
358
358
  return;
359
359
  }
360
360
 
361
- await finalizeTurn(pluginCtx, {
361
+ await finalizeChatTurn(pluginCtx, {
362
362
  event: e,
363
363
  cfg,
364
364
  result,
@@ -376,15 +376,32 @@ export async function processChat(
376
376
  }
377
377
  }
378
378
 
379
- // Runtime turn — triggered by ChatRuntime.generateNotice / requestInformation.
380
- export async function executeChatRuntimeRequest(
381
- options: ExecuteChatRuntimeRequestOptions,
382
- pluginCtx: ChatPluginContext,
383
- ): Promise<{
379
+ type ChatRuntimeExecutionResult = {
384
380
  messages: string[];
385
381
  toolCalls: Array<{ name: string; arguments: any; result: any }>;
386
382
  collectedInfo: null;
387
- }> {
383
+ };
384
+
385
+ export async function executeChatRuntimeRequest(
386
+ options: ExecuteChatRuntimeRequestOptions,
387
+ pluginCtx: ChatPluginContext,
388
+ ): Promise<ChatRuntimeExecutionResult> {
389
+ const runtimeCtx = resolveRuntimeContext(pluginCtx.ctx, options);
390
+ if (!runtimeCtx.isGroup) {
391
+ return executeChatRuntimeRequestNow(options, pluginCtx);
392
+ }
393
+ return pluginCtx.sessionTurnScheduler.run(
394
+ runtimeCtx.sessionId,
395
+ "chat-runtime",
396
+ () => executeChatRuntimeRequestNow(options, pluginCtx),
397
+ );
398
+ }
399
+
400
+ // Runtime turn — triggered by ChatRuntime.generateNotice / requestInformation.
401
+ async function executeChatRuntimeRequestNow(
402
+ options: ExecuteChatRuntimeRequestOptions,
403
+ pluginCtx: ChatPluginContext,
404
+ ): Promise<ChatRuntimeExecutionResult> {
388
405
  const cfg = options.config;
389
406
  const runtimeCtx = resolveRuntimeContext(pluginCtx.ctx, options);
390
407
  const {
@@ -516,7 +533,7 @@ export async function executeChatRuntimeRequest(
516
533
  { extraTools: options.extraTools },
517
534
  );
518
535
 
519
- await finalizeTurn(pluginCtx, {
536
+ await finalizeChatTurn(pluginCtx, {
520
537
  event,
521
538
  cfg,
522
539
  result,