Skip to content

refactor: プラグイン間のイベント発火パターンを統一#121

Open
oboroge0 wants to merge 2 commits intomainfrom
refactor/unify-event-patterns
Open

refactor: プラグイン間のイベント発火パターンを統一#121
oboroge0 wants to merge 2 commits intomainfrom
refactor/unify-event-patterns

Conversation

@oboroge0
Copy link
Copy Markdown
Owner

@oboroge0 oboroge0 commented Feb 26, 2026

概要

同じカテゴリのプラグイン間でイベント発火パターンが不統一だった問題を修正します。

TTSプラグイン

  • COEIROINK: audio.generated イベントのペイロードに audio(ファイルパス)と audioUrl(APIパス)を追加し、VOICEVOXと統一
  • Style-Bert-VITS2: 同上、audioaudioUrl をペイロードに追加
  • 両プラグインの execute() 戻り値にも audioUrl を追加

LLMプラグイン

  • Anthropic (Claude): response.generated イベント({text, model} ペイロード)を追加
  • Google (Gemini): 同上
  • Ollama: 同上
  • 各プラグインの manifest.jsonevents.emits にも response.generated を追加

リファレンス実装

  • TTS: plugins/voicevox-tts/node.ts のイベントペイロード形式に統一
  • LLM: plugins/openai-llm/node.ts のイベント発火パターンに統一

テスト計画

  • 既存テスト(95件)が全てパスすることを確認済み
  • COEIROINK TTS ノードで音声生成時に audio.generated イベントが正しいペイロードで発火されること
  • Style-Bert-VITS2 TTS ノードで同上
  • Anthropic LLM ノードで応答生成時に response.generated イベントが発火されること
  • Google LLM ノードで同上
  • Ollama LLM ノードで同上

closes #105

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • LLM plugins (Anthropic, Google, Ollama) now emit a "response.generated" event, enabling downstream listeners to react to generated responses with text and model information.
    • TTS plugins (Coeiroink, SBV2) enhanced to include audio URL and text in event payloads, providing more complete information for integrations.

TTSプラグイン(COEIROINK, Style-Bert-VITS2)の audio.generated イベントペイロードを
VOICEVOX と統一し、audio/audioUrl フィールドを追加。
LLMプラグイン(Anthropic, Google, Ollama)に response.generated イベントを追加し、
OpenAI と同じイベントパターンに統一。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 26, 2026

Warning

Rate limit exceeded

@oboroge0 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 14 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between ef922f9 and f388d87.

📒 Files selected for processing (2)
  • plugins/coeiroink-tts/node.ts
  • plugins/sbv2-tts/node.ts
📝 Walkthrough

Walkthrough

LLM plugins (Anthropic, Google, Ollama) now emit "response.generated" events after producing responses, with manifest updates declaring the new event type. TTS plugins (COEIROINK, SBV2) extend audio event payloads to include audioUrl and enhanced metadata, improving downstream accessibility to generated content.

Changes

Cohort / File(s) Summary
LLM Event Declarations
plugins/anthropic-llm/manifest.json, plugins/google-llm/manifest.json, plugins/ollama-llm/manifest.json
Updated node.events.emits from empty array to ["response.generated"], declaring new event type across all LLM plugins.
LLM Event Emission
plugins/anthropic-llm/node.ts, plugins/google-llm/node.ts, plugins/ollama-llm/node.ts
Added createEvent import and event emission logic after response generation, emitting "response.generated" with response text and model information.
TTS Event Enrichment
plugins/coeiroink-tts/node.ts, plugins/sbv2-tts/node.ts
Extended audio event payloads with audioUrl field and additional metadata (text field in some cases), updated logging from filename to duration.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Whiskers twitching with delight,
Events now fire left and right,
LLMs speak with "response" clear,
Audio blooms with URLs dear,
Patterns unified, plugins aligned—
Harmony in code, perfectly designed! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: unifying event emission patterns across plugins.
Linked Issues check ✅ Passed The PR implements all coding requirements from issue #105: adds response.generated events to LLM plugins and audio/audioUrl fields to TTS event payloads.
Out of Scope Changes check ✅ Passed All changes directly address issue #105 objectives: unifying event patterns in LLM and TTS plugins with appropriate payload fields.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/unify-event-patterns

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
plugins/coeiroink-tts/node.ts (1)

99-112: ⚠️ Potential issue | 🟠 Major

Unify execute() return shape across all branches.

Line 188 returns { audioUrl, ... }, but guard/error paths (Line 99, Line 106, Line 111, Line 134, Line 160, Line 191) still omit audioUrl. This makes outputs structurally inconsistent for downstream consumers.

Proposed fix
   async execute(
     inputs: Record<string, any>,
     context: NodeContext,
   ): Promise<Record<string, any>> {
+    const emptyResult = { audio: "", audioUrl: "", filename: "", duration: 0 };
     const text = (inputs.text as string) ?? "";

     if (!text) {
       await context.log("No text provided", "warning");
-      return { audio: "", filename: "", duration: 0 };
+      return emptyResult;
     }

     // Demo mode: skip TTS if connection is unavailable
     if (this.demoMode && !this.connectionAvailable) {
       const preview = text.length > 30 ? text.slice(0, 30) + "..." : text;
       await context.log(`[デモモード] TTS スキップ: ${preview}`, "info");
-      return { audio: "", filename: "", duration: 0 };
+      return emptyResult;
     }

     if (!this.speakerUuid) {
       await context.log("Speaker UUID not configured", "error");
-      return { audio: "", filename: "", duration: 0 };
+      return emptyResult;
     }
@@
       if (!prosodyResponse.ok) {
         const error = await prosodyResponse.text();
         await context.log(`Prosody estimation failed: ${error}`, "error");
-        return { audio: "" };
+        return emptyResult;
       }
@@
       if (!synthResponse.ok) {
         const error = await synthResponse.text();
         await context.log(`Synthesis failed: ${error}`, "error");
-        return { audio: "" };
+        return emptyResult;
       }
@@
     } catch (e) {
       await context.log(`COEIROINK error: ${String(e)}`, "error");
-      return { audio: "" };
+      return emptyResult;
     }
   }

As per coding guidelines, "Use TypeScript type safety - match manifest types with TypeScript implementations for config, inputs, and outputs".

Also applies to: 134-135, 160-161, 188-191

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/coeiroink-tts/node.ts` around lines 99 - 112, The execute() method
currently returns different object shapes across early-return/guard branches
(e.g., when this.demoMode && !this.connectionAvailable, when !this.speakerUuid,
and other error guards) while the success path returns { audioUrl, ... }; update
every guard/error return in execute() to include the audioUrl property (use an
empty string or null per your manifest type) so all returns match the declared
output shape; locate returns inside execute(), especially around checks for
this.demoMode, this.connectionAvailable, this.speakerUuid and any other
early-return branches, and add audioUrl plus the existing audio, filename,
duration fields to each returned object.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@plugins/coeiroink-tts/node.ts`:
- Around line 99-112: The execute() method currently returns different object
shapes across early-return/guard branches (e.g., when this.demoMode &&
!this.connectionAvailable, when !this.speakerUuid, and other error guards) while
the success path returns { audioUrl, ... }; update every guard/error return in
execute() to include the audioUrl property (use an empty string or null per your
manifest type) so all returns match the declared output shape; locate returns
inside execute(), especially around checks for this.demoMode,
this.connectionAvailable, this.speakerUuid and any other early-return branches,
and add audioUrl plus the existing audio, filename, duration fields to each
returned object.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4920ffd and ef922f9.

📒 Files selected for processing (8)
  • plugins/anthropic-llm/manifest.json
  • plugins/anthropic-llm/node.ts
  • plugins/coeiroink-tts/node.ts
  • plugins/google-llm/manifest.json
  • plugins/google-llm/node.ts
  • plugins/ollama-llm/manifest.json
  • plugins/ollama-llm/node.ts
  • plugins/sbv2-tts/node.ts

COEIROINK と Style-Bert-VITS2 の execute() メソッドで、
ガード節やエラー時の返却オブジェクトに audioUrl が欠けていた問題を修正。
emptyResult パターンを導入し、全ての分岐で同じプロパティを返すように統一。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: プラグイン間のイベント発火パターンの統一

1 participant