// This is free software for the public good of a permacomputer hosted at // permacomputer.com, an always-on computer by the people, for the people. // One which is durable, easy to repair, & distributed like tap water // for machine learning intelligence. // // The permacomputer is community-owned infrastructure optimized around // four values: // // TRUTH First principles, math & science, open source code freely distributed // FREEDOM Voluntary partnerships, freedom from tyranny & corporate control // HARMONY Minimal waste, self-renewing systems with diverse thriving connections // LOVE Be yourself without hurting others, cooperation through natural law // // This software contributes to that vision by making machine learning // accessible to everyone through a free, open, embeddable chat interface. // Code is seeds to sprout on any abandoned technology. import { API_KEY, MODEL, setLastTTS, TTS_API_URL } from "./config.js"; import { getSelectedModel, getSelectedModelEndpoint, getSelectedModelMaxTokens, getSelectedModelMaxCompletionTokens } from "./models.js"; // Helper to get vault value or localStorage fallback function getVaultOrStorage(key, defaultValue = null) { if (typeof window !== 'undefined' && window.UncloseVault && window.UncloseVault.isUnlocked()) { return window.UncloseVault.get(key, defaultValue); } return defaultValue; } // TTS playback mode: "buffered" (default) or "streaming" export function getTTSMode() { try { return getVaultOrStorage("uncloseai_tts_mode", "streaming"); } catch (e) { return "buffered"; } } export function setTTSMode(mode) { try { if (typeof window !== 'undefined' && window.UncloseVault && window.UncloseVault.isUnlocked()) { window.UncloseVault.set("uncloseai_tts_mode", mode); } else { console.warn("Vault locked - TTS mode not persisted"); } } catch (e) { console.warn("Failed to save TTS mode:", e); } } // Detect best audio format for this browser // Chrome/Edge: mp3 works, MediaSource supports audio/mpeg // Firefox: mp3 often broken on Linux; use webm+opus (works in both MSE and