feat(audio): add tests, token estimation, and config override for native audio

- Add capabilities.test.ts (18 tests) for supportsAudioInput()
- Add 15 audio tests to media.test.ts (hasAudio, stripAudioParts, attachmentToAudioSource)
- Add estimateAudioTokens() to tokens.ts (base64→bytes→duration→tokens)
- Update estimateMessageTokens() to include audio content parts
- Add 5 audio token tests to tokens.test.ts
- Add supports_audio config override to model schema
- Wire supports_audio from tier config through routing to capability check

Total tests: 1369 (was 1331, +38 audio-related)
This commit is contained in:
William Valentin
2026-02-11 18:27:19 -08:00
parent 32ac4df20a
commit 148219153e
7 changed files with 357 additions and 8 deletions
+2 -1
View File
@@ -232,7 +232,8 @@ export function createMessageRouter(deps: {
const tierConfig = modelsConfig[effectiveTier] ?? deps.config.models.default;
const modelProvider = tierConfig?.provider ?? deps.config.models.default.provider;
const modelName = tierConfig?.model ?? deps.config.models.default.model;
const nativeAudioSupported = supportsAudioInput(modelProvider, modelName);
const supportsAudioOverride = (tierConfig as Record<string, unknown> | undefined)?.supports_audio as boolean | undefined;
const nativeAudioSupported = supportsAudioInput(modelProvider, modelName, supportsAudioOverride);
let messageText = msg.text;
let attachments = msg.attachments;