Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
refactor: reuse trimTo and keep route helpers module-private (#9545)
[._.]/ Adam Eivyfb94754f454e
diff --git a/server/lib/README.md b/server/lib/README.mdindex fba0fa3766..0d9893d79e 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -800,7 +800,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `musicVideoCreativeContext.js` | `musicVideoDirectionContext(direction)` bounds the authoritative Cast & Sets bible; `musicVideoCreativeContext(concept)` composes the selected universe style and authored cast/place/object bible for planning and generation. || `moodBoardStyleContext.js` | `collectBoardStyleContext(board)` bounds a board's notes, captions, analyzed prompts, and composite style for creative prompts. `moodBoardImageCandidates(board, resolveItem)` lists the poster first, then pinned local images. || `musicVideoAutonomous.js` | Fully-autonomous Music Video vocabulary: `AUTONOMOUS_STAGES` (brief → lyrics → style → song → analyze → produce), optional `AUTONOMOUS_CHECKPOINT_IDS`, `normalizeAutonomousSettings` / `normalizeAutonomousBrief` / `normalizeAutopilotParams` (the shared run settings, a run's stored brief, and the scheduled task's params), `autonomousMedium` / `autonomousPool` (tool picks → footage vs code, production route pool), `sunoSongFields` + Suno limits/URL helpers, and `pickBrainIdea` / `ideaToPrompt` for the scheduled task. Pure; the client drawer and the run service import it. |-| `musicVideoAutomation.js` | Music Video automation brief: `MUSIC_VIDEO_AUTOMATION_TOOLS` (image/video backends derived from `generationModes.js` plus `code:render`, each flagged `metered`), `MUSIC_VIDEO_AUTOMATION_TOOL_IDS`, and `normalizeMusicVideoAutomation(patch, current)` (per-sub-field merge, catalog-ordered tools, `budgetUsd: null` = no cap, `llm: null` clears the direction-LLM pin, server-written `routes` survive but are never patch-settable). Also `normalizeMusicVideoLlm` / `normalizeMusicVideoLlmRoute` / `normalizeMusicVideoEffort` / `musicVideoLlmRouteLabel` for that pin and the effective route a stage ran on (#9545). Dependency-light; the client create drawer imports it. |+| `musicVideoAutomation.js` | Music Video automation brief: `MUSIC_VIDEO_AUTOMATION_TOOLS` (image/video backends derived from `generationModes.js` plus `code:render`, each flagged `metered`), `MUSIC_VIDEO_AUTOMATION_TOOL_IDS`, and `normalizeMusicVideoAutomation(patch, current)` (per-sub-field merge, catalog-ordered tools, `budgetUsd: null` = no cap, `llm: null` clears the direction-LLM pin, server-written `routes` survive but are never patch-settable). Also `normalizeMusicVideoLlm` / `normalizeMusicVideoEffort` / `musicVideoLlmRouteLabel` for that pin and the effective route a stage ran on (#9545). Dependency-light; the client create drawer imports it. || `albumLimits.js` | Album record length/count caps shared by the albums sanitizer and client editors. || `artistLimits.js` | Artist record length caps shared by the artists sanitizer and client editors. || `authorLimits.js` | Author record length caps shared by the authors sanitizer and client editors. |diff --git a/server/lib/musicVideoAutomation.js b/server/lib/musicVideoAutomation.jsindex 69f924cafd..a770d643e0 100644--- a/server/lib/musicVideoAutomation.js+++ b/server/lib/musicVideoAutomation.js@@ -12,6 +12,7 @@*/import { EFFORT_LEVELS } from './providerModels.js';+import { trimTo } from './textUtils.js';import {CLOUD_IMAGE_GEN_MODES, CLOUD_VIDEO_GEN_MODES, IMAGE_GEN_MODE, IMAGE_GEN_MODES, VIDEO_GEN_MODE, VIDEO_GEN_MODES,} from './generationModes.js';@@ -70,22 +71,21 @@ export const normalizeMusicVideoEffort = (value) => (EFFORT_LEVELS.includes(valu*/export function normalizeMusicVideoLlm(raw) {if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;- const text = (v, max) => (typeof v === 'string' ? v.trim().slice(0, max) : '');- const providerId = text(raw.providerId, 200);+ const providerId = trimTo(raw.providerId, 200);if (!providerId) return null;return {providerId,- model: text(raw.model, 200) || null,+ model: trimTo(raw.model, 200) || null,effort: normalizeMusicVideoEffort(raw.effort),};}/** The effective LLM route a stage last ran on, as stored for the project summary. */-export function normalizeMusicVideoLlmRoute(raw) {+function normalizeMusicVideoLlmRoute(raw) {if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;- const providerId = typeof raw.providerId === 'string' ? raw.providerId.trim().slice(0, 200) : '';+ const providerId = trimTo(raw.providerId, 200);if (!providerId) return null;- const text = (v, max) => (typeof v === 'string' && v.trim() ? v.trim().slice(0, max) : null);+ const text = (v, max) => trimTo(v, max) || null;return {providerId,model: text(raw.model, 200),diff --git a/server/services/musicVideo/llmRoute.js b/server/services/musicVideo/llmRoute.jsindex 3f315eff9d..726ef6a58e 100644--- a/server/services/musicVideo/llmRoute.js+++ b/server/services/musicVideo/llmRoute.js@@ -40,7 +40,7 @@ async function launchable(provider) {* The TUI provider an unpinned text stage should use, or null. Never throws: a* registry read failure just means "no preference".*/-export async function preferredTuiProvider() {+async function preferredTuiProvider() {// Lazy: the provider registry (and its toolkit) is only needed when nothing is pinned.const { getActiveProvider, listProviders } = await import('../providers.js');const providers = await listProviders().catch(() => []);