feat(audio): add native audio support to type system and model clients

- Add AudioSource interface and 'audio' variant to MessageContentPart union
- Update buildUserMessage() to create audio content parts from attachments
- Add attachmentToAudioSource(), hasAudio(), stripAudioParts() helpers
- Gemini: native audio via inlineData (same format as images)
- OpenAI/GitHub: native audio via input_audio content parts
- Anthropic/Bedrock: graceful fallback to transcript text
- Update getMessageTextWithTools() to handle audio blocks for local models
This commit is contained in:
William Valentin
2026-02-11 18:17:33 -08:00
parent a875bcc4ae
commit 32e1a2724a
8 changed files with 169 additions and 22 deletions
+7
View File
@@ -41,6 +41,13 @@ function toAnthropicContent(content: string | MessageContentPart[]): string | un
},
};
}
// Audio — Anthropic doesn't support native audio input; use transcript fallback
if (part.type === 'audio') {
if (part.source.transcript) {
return { type: 'text', text: `[Voice message]: ${part.source.transcript}` };
}
return { type: 'text', text: '[Audio message received but no transcript available]' };
}
return part;
});
}