resources

This commit is contained in:
2026-02-24 16:44:22 +00:00
parent d6ffe43a11
commit 05f0d0e8f7
39 changed files with 1385 additions and 1057 deletions
+14 -2
View File
@@ -1,5 +1,6 @@
import { createRouter } from '../../create-router';
import { settingsPath } from './server-settings';
import { readResourceConfig } from './resources';
type TtsConfig = {
provider: 'openai' | 'elevenlabs';
@@ -15,8 +16,19 @@ function maskSecret(value: string | undefined): string | undefined {
}
export async function readTtsConfig(): Promise<TtsConfig | undefined> {
const settings = await Bun.file(settingsPath).json().catch(() => ({}));
return settings.tts as TtsConfig | undefined;
const config = await readResourceConfig('text-to-speech');
if (!config.url && !config.provider) {
// Fallback to legacy settings.json
const settings = await Bun.file(settingsPath).json().catch(() => ({}));
return settings.tts as TtsConfig | undefined;
}
return {
provider: (config.provider || 'openai') as 'openai' | 'elevenlabs',
url: config.url ?? '',
apiKey: config.api_key || undefined,
model: config.model ?? '',
voice: config.voice ?? '',
};
}
export const ttsRouter = createRouter();