refactor: share tts auto mode normalization

This commit is contained in:
Peter Steinberger
2026-03-26 22:27:36 +00:00
parent 138a92373b
commit 5445bc68b9

View File

@@ -38,6 +38,7 @@ import type {
TtsDirectiveOverrides,
TtsDirectiveParseResult,
} from "./provider-types.js";
import { normalizeTtsAutoMode } from "./tts-auto-mode.js";
import { scheduleCleanup, summarizeText } from "./tts-core.js";
export type { TtsDirectiveOverrides, TtsDirectiveParseResult } from "./provider-types.js";
@@ -63,8 +64,6 @@ const DEFAULT_OUTPUT = {
voiceCompatible: false,
};
const TTS_AUTO_MODES = new Set<TtsAutoMode>(["off", "always", "inbound", "tagged"]);
export type ResolvedTtsConfig = {
auto: TtsAutoMode;
mode: TtsMode;
@@ -133,17 +132,6 @@ type TtsStatusEntry = {
let lastTtsAttempt: TtsStatusEntry | undefined;
export function normalizeTtsAutoMode(value: unknown): TtsAutoMode | undefined {
if (typeof value !== "string") {
return undefined;
}
const normalized = value.trim().toLowerCase();
if (TTS_AUTO_MODES.has(normalized as TtsAutoMode)) {
return normalized as TtsAutoMode;
}
return undefined;
}
function resolveModelOverridePolicy(
overrides: TtsModelOverrideConfig | undefined,
): ResolvedTtsModelOverrides {