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
fix: zod-validate remaining route inputs, URL-param tabs, surface swallowed client errors
[._.]/ Adam Eivya37305dfa757
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 25229c1c13..2a0a462259 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -19,6 +19,7 @@## Fixed- **Workspace-root validation on git/scaffold routes** — git operations and app scaffolding refuse paths outside allowed workspace roots; file staging uses literal pathspecs (no git glob expansion); `env` removed from the shell command allowlist so process secrets can't land in persisted job output.+- **Route validation + linkable tabs** — jira, loops, CoS, digital-twin, automation-schedule, and history inputs are now Zod-validated; Prompt Manager and Messages triage tabs live in the URL (deep-linkable); previously-swallowed client errors are logged.- **A watched TUI run no longer false-times-out after finishing its work** — companion fix to *Live TUI runs are now viewable AND drivable in the Shell page* (above). One-shot AI runs that drive a terminal UI (Claude Code, Codex, etc.) write their completed answer to a response file and then return to an interactive prompt **without exiting**. The runner only auto-completed such a run via output-idle — which is paused while you watch it in the Shell page (so it isn't snapped shut mid-read). With the process never exiting and idle paused, a watched run had no terminus but the 10-minute hard timeout — at which point it was marked **failed**, its already-written result was **discarded**, and a useless fallback retry ran in its place. The runner now watches for the response file as the model's authoritative "done" signal and completes the run the moment it's written — even while you're watching — since once the file exists the task is genuinely finished. A second safety net salvages the file on hard timeout: if the result was written but completion stalled for any other reason, the run finishes as **success** with that result instead of throwing it away and falling back. So a long editorial pass you keep open in the Shell tab now lands its findings when the model finishes, instead of silently dying at 10 minutes. (`server/lib/tuiPromptRunner.js`)diff --git a/client/src/components/meatspace/post/MemoryPractice.jsx b/client/src/components/meatspace/post/MemoryPractice.jsxindex 376babeed1..31b7d43488 100644--- a/client/src/components/meatspace/post/MemoryPractice.jsx+++ b/client/src/components/meatspace/post/MemoryPractice.jsx@@ -621,7 +621,7 @@ export default function MemoryPractice({ item, onBack }) {answered: r.answered,})),totalMs: Date.now() - startTime,- }).catch(() => {});+ }).catch(err => console.warn(`⚠️ Failed to save sequence practice: ${err.message}`));}if (spacedChunkIdx + 1 < chunkMastery.length) {@@ -648,7 +648,7 @@ export default function MemoryPractice({ item, onBack }) {answered: r.answered,})),totalMs: Date.now() - startTime,- }).catch(() => {});+ }).catch(err => console.warn(`⚠️ Failed to save practice results: ${err.message}`));}}diff --git a/client/src/components/messages/ConfigTab.jsx b/client/src/components/messages/ConfigTab.jsxindex fdbdfc6f92..cdee80c237 100644--- a/client/src/components/messages/ConfigTab.jsx+++ b/client/src/components/messages/ConfigTab.jsx@@ -95,7 +95,7 @@ export default function ConfigTab({ accounts, setAccounts }) {const hasGmailAccount = accounts.some(a => a.type === 'gmail');useEffect(() => {if (hasGmailAccount) {- api.getGoogleAuthStatus().then(setGoogleAuth).catch(() => {});+ api.getGoogleAuthStatus().then(setGoogleAuth).catch(err => console.warn(`⚠️ Failed to load Google auth status: ${err.message}`));}}, [hasGmailAccount]);diff --git a/client/src/components/messages/InboxTab.jsx b/client/src/components/messages/InboxTab.jsxindex 7f80c51a1a..0b3810df6f 100644--- a/client/src/components/messages/InboxTab.jsx+++ b/client/src/components/messages/InboxTab.jsx@@ -1,6 +1,6 @@import { useState, useEffect, useCallback, useRef } from 'react';import { Mail, Search, RefreshCw, ChevronRight, Sparkles, Archive, Trash2, Reply, Eye, Flag, Pin, Loader2 } from 'lucide-react';-import { useNavigate } from 'react-router-dom';+import { useNavigate, useSearchParams } from 'react-router-dom';import toast from '../ui/Toast';import * as api from '../../services/api';import socket from '../../services/socket';@@ -44,9 +44,18 @@ export default function InboxTab({ accounts }) {const [syncing, setSyncing] = useState(false);const [fetchingFull, setFetchingFull] = useState(false);const [actionInProgress, setActionInProgress] = useState(null);- const [activeTab, setActiveTab] = useState('all');const debounceRef = useRef(null);const navigate = useNavigate();+ const [searchParams, setSearchParams] = useSearchParams();+ const rawTriage = searchParams.get('triage');+ const VALID_TRIAGE_KEYS = TRIAGE_TABS.map(t => t.key);+ const activeTab = VALID_TRIAGE_KEYS.includes(rawTriage) ? rawTriage : 'all';+ const setActiveTab = (key) => {+ const p = new URLSearchParams(searchParams);+ if (key === 'all') p.delete('triage');+ else p.set('triage', key);+ setSearchParams(p, { replace: true });+ };useEffect(() => {clearTimeout(debounceRef.current);diff --git a/client/src/components/messages/MessageDetail.jsx b/client/src/components/messages/MessageDetail.jsxindex bed4436a84..22a1cea29c 100644--- a/client/src/components/messages/MessageDetail.jsx+++ b/client/src/components/messages/MessageDetail.jsx@@ -89,7 +89,7 @@ export default function MessageDetail({ message, accounts, onBack }) {useEffect(() => {api.getSettings().then(s => setUseVoice(s?.messages?.voiceMode ?? false))- .catch(() => {});+ .catch(err => console.warn(`⚠️ Failed to load voice mode setting: ${err.message}`));}, []);const account = accounts.find(a => a.id === displayedMessage.accountId) || accounts[0];diff --git a/client/src/pages/PromptManager.jsx b/client/src/pages/PromptManager.jsxindex 1d53860f30..9ce4f71d37 100644--- a/client/src/pages/PromptManager.jsx+++ b/client/src/pages/PromptManager.jsx@@ -1,4 +1,5 @@import { useState, useEffect } from 'react';+import { useSearchParams } from 'react-router-dom';import { FileText, Variable, RefreshCw, Save, Plus, Trash2, Eye, Briefcase } from 'lucide-react';import toast from '../components/ui/Toast';import BrailleSpinner from '../components/BrailleSpinner';@@ -14,8 +15,18 @@ import {import useFieldDraft from '../hooks/useFieldDraft';import SettingsTabsHeader from '../components/settings/SettingsTabsHeader';+const VALID_PROMPT_TABS = ['stages', 'variables', 'job-skills'];+export default function PromptManager() {- const [tab, setTab] = useState('stages');+ const [searchParams, setSearchParams] = useSearchParams();+ const rawTab = searchParams.get('tab');+ const tab = VALID_PROMPT_TABS.includes(rawTab) ? rawTab : 'stages';+ const setTab = (next) => {+ const p = new URLSearchParams(searchParams);+ if (next === 'stages') p.delete('tab');+ else p.set('tab', next);+ setSearchParams(p, { replace: true });+ };const [stages, setStages] = useState({});const [variables, setVariables] = useState({});const [loading, setLoading] = useState(true);diff --git a/server/routes/automationSchedules.js b/server/routes/automationSchedules.jsindex 8dc1a21d69..051bbc41da 100644--- a/server/routes/automationSchedules.js+++ b/server/routes/automationSchedules.js@@ -5,6 +5,7 @@*/import { Router } from 'express';+import { z } from 'zod';import { asyncHandler, ServerError } from '../lib/errorHandler.js';import { validateRequest, automationScheduleSchema, automationScheduleUpdateSchema } from '../lib/validation.js';import * as automationScheduler from '../services/automationScheduler.js';@@ -12,6 +13,10 @@ import * as platformAccounts from '../services/platformAccounts.js';import * as agentPersonalities from '../services/agentPersonalities.js';import { logAction } from '../services/history.js';+const toggleScheduleSchema = z.object({+ enabled: z.boolean(),+});+const router = Router();// GET / - Get all schedules@@ -120,7 +125,7 @@ router.delete('/:id', asyncHandler(async (req, res) => {// POST /:id/toggle - Toggle schedule enabled statusrouter.post('/:id/toggle', asyncHandler(async (req, res) => {const { id } = req.params;- const { enabled } = req.body;+ const { enabled } = validateRequest(toggleScheduleSchema, req.body);console.log(`📅 POST /api/agents/schedules/${id}/toggle enabled=${enabled}`);const schedule = await automationScheduler.toggleSchedule(id, enabled);diff --git a/server/routes/cosReportRoutes.js b/server/routes/cosReportRoutes.jsindex 6b4b140967..4b90459e26 100644--- a/server/routes/cosReportRoutes.js+++ b/server/routes/cosReportRoutes.js@@ -13,6 +13,10 @@ import { validateRequest } from '../lib/validation.js';const router = Router();+const generateReportSchema = z.object({+ date: z.string().optional(),+});+// `since` is the client's last-visit marker (ISO-8601). Optional and tolerant:// `getWhileAwayActivity` already clamps an absent/garbage/future marker to a// 24h fallback, so a malformed value preprocesses to `undefined` (let the@@ -48,7 +52,7 @@ router.get('/reports/:date', asyncHandler(async (req, res) => {// POST /api/cos/reports/generate - Generate report for daterouter.post('/reports/generate', asyncHandler(async (req, res) => {- const { date } = req.body;+ const { date } = validateRequest(generateReportSchema, req.body);const report = await cos.generateReport(date);res.json(report);}));diff --git a/server/routes/cosScheduleRoutes.js b/server/routes/cosScheduleRoutes.jsindex 7ad7591f44..a52a633027 100644--- a/server/routes/cosScheduleRoutes.js+++ b/server/routes/cosScheduleRoutes.js@@ -3,9 +3,19 @@*/import { Router } from 'express';+import { z } from 'zod';import * as taskSchedule from '../services/taskSchedule.js';import { asyncHandler, ServerError } from '../lib/errorHandler.js';-import { sanitizeTaskMetadata } from '../lib/validation.js';+import { sanitizeTaskMetadata, validateRequest } from '../lib/validation.js';++const templateTaskSchema = z.object({+ name: z.string().min(1),+ description: z.string().min(1),+ category: z.string().optional(),+ taskType: z.string().optional(),+ priority: z.string().optional(),+ metadata: z.record(z.unknown()).optional(),+});const router = Router();@@ -150,11 +160,7 @@ router.get('/schedule/templates', asyncHandler(async (req, res) => {// POST /api/cos/schedule/templates - Add a template taskrouter.post('/schedule/templates', asyncHandler(async (req, res) => {- const { name, description, category, taskType, priority, metadata } = req.body;-- if (!name || !description) {- throw new ServerError('name and description are required', { status: 400, code: 'VALIDATION_ERROR' });- }+ const { name, description, category, taskType, priority, metadata } = validateRequest(templateTaskSchema, req.body);const template = await taskSchedule.addTemplateTask({name,diff --git a/server/routes/cosScheduleRoutes.test.js b/server/routes/cosScheduleRoutes.test.jsindex 6dfb1b680b..f9105b2324 100644--- a/server/routes/cosScheduleRoutes.test.js+++ b/server/routes/cosScheduleRoutes.test.js@@ -21,7 +21,15 @@ vi.mock('../services/taskSchedule.js', () => ({}));vi.mock('../lib/validation.js', () => ({- sanitizeTaskMetadata: vi.fn((meta) => meta)+ sanitizeTaskMetadata: vi.fn((meta) => meta),+ validateRequest: vi.fn((schema, data) => {+ const result = schema.safeParse(data);+ if (!result.success) {+ const { ServerError } = require('../lib/errorHandler.js');+ throw new ServerError('Validation failed', { status: 400, code: 'VALIDATION_ERROR' });+ }+ return result.data;+ }),}));import * as taskSchedule from '../services/taskSchedule.js';diff --git a/server/routes/cosStatusRoutes.js b/server/routes/cosStatusRoutes.jsindex 442cefda17..fc1a6080d2 100644--- a/server/routes/cosStatusRoutes.js+++ b/server/routes/cosStatusRoutes.js@@ -15,6 +15,10 @@ import { BUDGET_LIMIT_FIELDS } from '../lib/domainBudgets.js';const router = Router();+const pauseSchema = z.object({+ reason: z.string().optional(),+});+export const cosConfigSchema = z.object({userTasksFile: z.string().optional(),cosTasksFile: z.string().optional(),@@ -93,7 +97,7 @@ router.post('/stop', asyncHandler(async (req, res) => {// POST /api/cos/pause - Pause CoS daemon (stays running but skips evaluations)router.post('/pause', asyncHandler(async (req, res) => {- const { reason } = req.body;+ const { reason } = validateRequest(pauseSchema, req.body);const result = await cos.pause(reason);res.json(result);}));diff --git a/server/routes/cosTaskRoutes.js b/server/routes/cosTaskRoutes.jsindex 46e2679ce1..fdad3cba20 100644--- a/server/routes/cosTaskRoutes.js+++ b/server/routes/cosTaskRoutes.js@@ -3,12 +3,18 @@*/import { Router } from 'express';+import { z } from 'zod';import * as cos from '../services/cos.js';import * as taskWatcher from '../services/taskWatcher.js';import { enhanceTaskPrompt } from '../services/taskEnhancer.js';import { loadSlashdoCommand } from '../services/subAgentSpawner.js';import { asyncHandler, ServerError, failValidation } from '../lib/errorHandler.js';-import { createCosTaskSchema, updateCosTaskSchema } from '../lib/validation.js';+import { createCosTaskSchema, updateCosTaskSchema, validateRequest } from '../lib/validation.js';++const enhanceTaskSchema = z.object({+ description: z.string().min(1),+ context: z.string().optional(),+});const SLASHDO_COMMANDS = {push: { label: 'Push', description: 'Commit and push all work with changelog' },@@ -59,12 +65,7 @@ router.post('/tasks/reorder', asyncHandler(async (req, res) => {// POST /api/cos/tasks/enhance - Enhance a task prompt with AIrouter.post('/tasks/enhance', asyncHandler(async (req, res) => {- const { description, context } = req.body;-- if (!description) {- throw new ServerError('Description is required', { status: 400, code: 'VALIDATION_ERROR' });- }-+ const { description, context } = validateRequest(enhanceTaskSchema, req.body);const result = await enhanceTaskPrompt(description, context);res.json(result);}));diff --git a/server/routes/digital-twin.js b/server/routes/digital-twin.jsindex 9ad806ccb9..b1c6f9515b 100644--- a/server/routes/digital-twin.js+++ b/server/routes/digital-twin.js@@ -52,6 +52,17 @@ import {} from '../lib/digitalTwinValidation.js';import * as timeCapsuleService from '../services/timeCapsule.js';import { UUID_RE } from '../lib/fileUtils.js';+import { z } from 'zod';++const importSaveSchema = z.object({+ source: z.string().min(1),+ suggestedDoc: z.object({+ filename: z.string().min(1),+ content: z.string().min(1),+ title: z.string().optional(),+ category: z.string().optional(),+ }),+});const router = Router();@@ -701,15 +712,7 @@ router.post('/import/analyze', asyncHandler(async (req, res) => {* Save import analysis as a document*/router.post('/import/save', asyncHandler(async (req, res) => {- const { source, suggestedDoc } = req.body;-- if (!source || !suggestedDoc || !suggestedDoc.filename || !suggestedDoc.content) {- throw new ServerError('Missing required fields: source and suggestedDoc', {- status: 400,- code: 'VALIDATION_ERROR'- });- }-+ const { source, suggestedDoc } = validateRequest(importSaveSchema, req.body);const document = await digitalTwinService.saveImportAsDocument(source, suggestedDoc);res.json({ document, message: 'Document saved successfully' });}));diff --git a/server/routes/history.js b/server/routes/history.jsindex 8bd7967e1b..81900a8170 100644--- a/server/routes/history.js+++ b/server/routes/history.js@@ -1,17 +1,28 @@import { Router } from 'express';+import { z } from 'zod';import { asyncHandler, ServerError } from '../lib/errorHandler.js';+import { validateRequest } from '../lib/validation.js';import * as history from '../services/history.js';+const historyQuerySchema = z.object({+ limit: z.preprocess(v => (v !== undefined ? Number(v) : undefined), z.number().int().min(1).max(1000).optional()),+ offset: z.preprocess(v => (v !== undefined ? Number(v) : undefined), z.number().int().min(0).optional()),+ action: z.string().optional(),+ target: z.string().optional(),+ success: z.preprocess(v => (v === 'true' ? true : v === 'false' ? false : undefined), z.boolean().optional()),+});+const router = Router();// GET /api/history - Get history entriesrouter.get('/', asyncHandler(async (req, res) => {+ const parsed = validateRequest(historyQuerySchema, req.query);const options = {- limit: parseInt(req.query.limit, 10) || 100,- offset: parseInt(req.query.offset, 10) || 0,- action: req.query.action || undefined,- target: req.query.target || undefined,- success: req.query.success !== undefined ? req.query.success === 'true' : undefined+ limit: parsed.limit ?? 100,+ offset: parsed.offset ?? 0,+ action: parsed.action,+ target: parsed.target,+ success: parsed.success,};res.json(await history.getHistory(options));diff --git a/server/routes/jira.js b/server/routes/jira.jsindex abc8318007..c7f334206c 100644--- a/server/routes/jira.js+++ b/server/routes/jira.js@@ -3,10 +3,37 @@*/import express from 'express';+import { z } from 'zod';import * as jiraService from '../services/jira.js';import * as jiraReports from '../services/jiraReports.js';import { getAppById } from '../services/apps.js';import { asyncHandler, ServerError } from '../lib/errorHandler.js';+import { validateRequest } from '../lib/validation.js';++const jiraInstanceSchema = z.object({+ id: z.string().min(1),+ name: z.string().min(1),+ baseUrl: z.string().url(),+ email: z.string().email(),+ apiToken: z.string().min(1),+});++const jiraTicketCreateSchema = z.object({+ projectKey: z.string().min(1),+ summary: z.string().min(1),+ description: z.string().optional(),+ issueType: z.string().optional(),+ priority: z.string().optional(),+ labels: z.array(z.string()).optional(),+ epicKey: z.string().optional(),+ sprintId: z.union([z.string(), z.number()]).optional(),+ storyPoints: z.number().optional(),+ assignee: z.string().optional(),+ components: z.array(z.string()).optional(),+ customFields: z.record(z.unknown()).optional(),+}).passthrough();++const jiraTicketUpdateSchema = jiraTicketCreateSchema.partial();const router = express.Router();@@ -44,14 +71,7 @@ router.get('/instances', asyncHandler(async (req, res) => {* Create or update JIRA instance*/router.post('/instances', asyncHandler(async (req, res) => {- const { id, name, baseUrl, email, apiToken } = req.body;-- if (!id || !name || !baseUrl || !email || !apiToken) {- throw new ServerError('Missing required fields', {- status: 400,- code: 'INVALID_INPUT'- });- }+ const { id, name, baseUrl, email, apiToken } = validateRequest(jiraInstanceSchema, req.body);const instance = await jiraService.upsertInstance(id, {name,@@ -107,7 +127,8 @@ router.get('/instances/:id/projects', asyncHandler(async (req, res) => {* Create JIRA ticket*/router.post('/instances/:id/tickets', asyncHandler(async (req, res) => {- const result = await jiraService.createTicket(req.params.id, req.body);+ const ticketData = validateRequest(jiraTicketCreateSchema, req.body);+ const result = await jiraService.createTicket(req.params.id, ticketData);res.json(result);}));@@ -116,10 +137,11 @@ router.post('/instances/:id/tickets', asyncHandler(async (req, res) => {* Update JIRA ticket*/router.put('/instances/:instanceId/tickets/:ticketId', asyncHandler(async (req, res) => {+ const updates = validateRequest(jiraTicketUpdateSchema, req.body);const result = await jiraService.updateTicket(req.params.instanceId,req.params.ticketId,- req.body+ updates);res.json(result);}));diff --git a/server/routes/loops.js b/server/routes/loops.jsindex 0075dba478..235659d4cf 100644--- a/server/routes/loops.js+++ b/server/routes/loops.js@@ -3,6 +3,16 @@ import { asyncHandler, ServerError, failValidation } from '../lib/errorHandler.jimport * as loopsService from '../services/loops.js';import { createLoopSchema } from '../lib/validation.js';+// updateLoop accepts a subset of createLoopSchema fields (name/prompt/interval/cwd/providerId/timeout)+const updateLoopSchema = createLoopSchema.pick({+ name: true,+ prompt: true,+ interval: true,+ cwd: true,+ providerId: true,+ timeout: true,+}).partial();+const router = Router();// GET /api/loops@@ -38,7 +48,9 @@ router.post('/', asyncHandler(async (req, res) => {// PUT /api/loops/:idrouter.put('/:id', asyncHandler(async (req, res) => {- const loop = await loopsService.updateLoop(req.params.id, req.body);+ const parsed = updateLoopSchema.safeParse(req.body);+ if (!parsed.success) failValidation(parsed);+ const loop = await loopsService.updateLoop(req.params.id, parsed.data);res.json(loop);}));