feat(hooks): add empty-message-sanitizer to prevent API errors from empty chat messages

Add new hook that uses the `experimental.chat.messages.transform` hook to prevent 'non-empty content' API errors by injecting placeholder text into empty messages BEFORE they're sent to the API.

This is a preventive fix - unlike session-recovery which fixes errors after they occur, this hook prevents the error from happening by sanitizing messages before API transmission.

Files:
- src/hooks/empty-message-sanitizer/index.ts (new hook implementation)
- src/hooks/index.ts (export hook function)
- src/config/schema.ts (add hook to HookName type)
- src/index.ts (wire up hook to plugin)

🤖 Generated with assistance of OhMyOpenCode (https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
YeonGyu-Kim
2025-12-16 21:02:38 +09:00
parent 3761d45712
commit 7293b8845d
4 changed files with 105 additions and 0 deletions

View File

@@ -62,6 +62,7 @@ export const HookNameSchema = z.enum([
"agent-usage-reminder",
"non-interactive-env",
"interactive-bash-session",
"empty-message-sanitizer",
])
export const AgentOverrideConfigSchema = z.object({