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
address review (copilot): gate provider-enable log on success, validate modelId against flag/control injection, 64MB maxBuffer for lms get
Adam Eivy09b7fe1b0e13
diff --git a/server/lib/validation.js b/server/lib/validation.jsindex 8bb4aa76c5..5bfc185d7b 100644--- a/server/lib/validation.js+++ b/server/lib/validation.js@@ -1043,9 +1043,14 @@ export const stageConfigUpdateSchema = z.object({// === Local LLM backends (Ollama / LM Studio) ===export const localLlmBackendSchema = z.enum(['ollama', 'lmstudio']);+// modelId is passed positionally to the `lms` CLI (execFile, no shell) — reject+// a leading dash (would be parsed as a flag) and control chars (NUL / newline).+export const localLlmModelIdSchema = z.string().min(1).max(256)+ .refine((v) => !v.startsWith('-'), { message: 'modelId may not start with "-"' })+ .refine((v) => !/[ \r\n]/.test(v), { message: 'modelId may not contain control characters' });export const localLlmInstallSchema = z.object({backend: localLlmBackendSchema,- modelId: z.string().min(1).max(256),+ modelId: localLlmModelIdSchema,});export const localLlmDeleteSchema = localLlmInstallSchema;export const localLlmSwitchSchema = z.object({ to: localLlmBackendSchema });diff --git a/server/services/localLlm.js b/server/services/localLlm.jsindex fcd3a7d944..b99fa2e440 100644--- a/server/services/localLlm.js+++ b/server/services/localLlm.js@@ -77,9 +77,13 @@ export async function ensureBackendProvider(backend) {if (!id) returnconst provider = await getProviderById(id).catch(() => null)if (provider && !provider.enabled) {- await updateProvider(id, { enabled: true }).catch((err) =>- console.error(`⚠️ Failed to enable ${id} provider: ${err.message}`))- console.log(`🔌 Enabled ${id} provider for active local LLM backend`)+ const enabled = await updateProvider(id, { enabled: true })+ .then(() => true)+ .catch((err) => {+ console.error(`⚠️ Failed to enable ${id} provider: ${err.message}`)+ return false+ })+ if (enabled) console.log(`🔌 Enabled ${id} provider for active local LLM backend`)}}@@ -160,7 +164,10 @@ export async function installModel(backend, modelId, onProgress) {}// LM Studio: prefer the `lms` CLI (real download), fall back to the REST hook.if (await commandExists('lms', ['version'])) {- const r = await execFileAsync('lms', ['get', '-y', modelId], { timeout: 0 })+ // `lms get` streams substantial progress to stdout; the default 1MB+ // maxBuffer overflows and surfaces as a false install failure (see+ // voice/bootstrap.js which uses the same 64MB ceiling for `lms get`).+ const r = await execFileAsync('lms', ['get', '-y', modelId], { timeout: 0, maxBuffer: 64 * 1024 * 1024 }).then(() => ({ ok: true })).catch((err) => ({ _err: err.stderr || err.message }))if (r._err) return { success: false, error: r._err, modelId }lmStudioManager.resetCache()