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
feat: add Cyber Muse CoS avatar backed by user-supplied GLB
Adam Eivyc3f0100264b6
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex ab04af7ed3..f1892b78ad 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -1,5 +1,6 @@## Added+- **Cyber Muse CoS avatar — GLB-backed holographic head** — new `muse` option in Settings → CoS → Appearance. Rather than assembling sphere primitives into a face (uncanny) or displacing a sphere point cloud (unreadable silhouette), the avatar loads a user-supplied `data/avatar/model.glb` through a new `/api/avatar/model.glb` route (`server/routes/avatar.js`, HEAD + GET, 404 when missing, `model/gltf-binary` when present) and renders it with a holographic material treatment: dark base + state-colored emissive glow that pulses per CoS state (sleeping/thinking/coding/investigating/ideating) and sync-bobs when the CoS is speaking. Bounding-box auto-fit means any model scale/origin works — drop in a ~4MB Ready Player Me export, a Sketchfab head bust, or a Mixamo-rigged character and it centers + sizes itself. When no GLB is present, renders a clean empty-state card pointing at the target path. Piggybacks on `useGLTF` (drei) and reuses the existing Sparkles/halo/ground-glow chrome. Zod enum for `avatarStyle` gained `'muse'` in `server/routes/cosStatusRoutes.js`.- **Loopback HTTP mirror on port 5553 when HTTPS is active** — Tailscale's Let's Encrypt cert only covers `<machine>.<tailnet>.ts.net`, so `https://localhost:5555` always tripped a cert warning. When HTTPS is active the server now also spins up a plain HTTP listener bound to `127.0.0.1:5553` that attaches to the same Express app and Socket.IO instance — `http://localhost:5553` works without cert warnings and Chrome still treats it as a secure context (so getUserMedia / mic access continues to work). Override the port via `PORTOS_HTTP_PORT`. Documented in `docs/PORTS.md`.- **Voice agent — universal accessibility-mode DOM driving** — the voice Chief-of-Staff can now navigate to any page and operate any control by voice. New `ui_navigate` tool with a 100+ entry named-page enum ("take me to tasks" / "chief of staff agents" / "calendar" all route correctly instead of defaulting to Daily Log). New accessibility layer: a client-side DOM indexer (`client/src/services/domIndex.js`) walks `<main>` for interactable elements (tabs, buttons, links, inputs, selects, textareas, checkboxes, radios), resolves labels via the standard aria → `<label for>` → wrapping label → text → placeholder → title chain, stamps stable `data-voice-ref` refs, and caps at 200 elements. `useVoiceUiSync` hook (debounced MutationObserver scoped to `<main>`, change-detection via content signature) pushes the index to the server whenever it actually changes. Server stores the index on per-socket state and — for UI-driving user turns (verb-gated by regex to keep the 80% of turns that don't need it cheap) — injects a compact page summary into the LLM's system prompt. New tools: `ui_click` (tab/button/link by label with optional kind hint), `ui_fill` (text inputs + textareas, uses React-safe native value setter so `onChange` fires), `ui_select` (dropdowns with fuzzy option matching), `ui_check` (checkboxes + radios), `ui_list_interactables` (deep-dive fallback). Misses return a helpful `available` list to the LLM so it can self-correct instead of silently failing. **In-turn chained flows**: after a ui_* action fires, the server pauses briefly for the client to push the post-action DOM index, then attaches the fresh summary to the tool result — so multi-step flows like "create a task named Foo with description Bar" can complete in a single turn (ui_click New Task → see the modal → ui_fill Name → ui_fill Description → ui_click Save).- **Per-peer DNS override on the Instances page** — peer cards now expose an "edit host" control that lets you swap the raw Tailscale IP (`http://100.83.147.46:5555`) for a trusted HTTPS DNS name (`https://void.taile8179.ts.net:5555`). Once set, the server's probe, socket relay, sync orchestrator, and query proxy all route through `https://<host>` instead of `http://<ip>` — so app links in `PeerAppsList` also upgrade to HTTPS automatically. New `GET /api/instances/tailnet-suffix` endpoint shells out to the local `tailscale status --json` and returns the MagicDNS suffix + the full peer map, which the Instances UI uses to auto-suggest DNS names: match by Tailscale IP first (authoritative), fall back to `<peer.hostname>.<suffix>` composition. The UI's "use `<suggested>`" button applies the suggestion in one click. `updatePeer` now accepts an optional `host` field (validated as a DNS name; empty string clears); invalid hosts return 400 instead of silent no-ops. `addPeer` also accepts `host` for direct-DNS registration. Vite dev proxy auto-detects `data/certs/cert.pem` and flips its target to `https://localhost:5555` with `secure: false` when HTTPS is active, fixing "socket hang up" errors in dev mode. 44 tests (3 new) cover valid/invalid/cleared host handling.diff --git a/client/src/components/cos/MuseCoSAvatar.jsx b/client/src/components/cos/MuseCoSAvatar.jsxnew file mode 100644index 0000000000..66f4c0e968--- /dev/null+++ b/client/src/components/cos/MuseCoSAvatar.jsx@@ -0,0 +1,199 @@+import { useRef, useMemo, useEffect, useState, Suspense } from 'react';+import { Canvas, useFrame } from '@react-three/fiber';+import { useGLTF, Sparkles } from '@react-three/drei';+import * as THREE from 'three';+import { AGENT_STATES } from './constants';++const MODEL_URL = '/api/avatar/model.glb';++// Loaded head wrapped in a holographic material treatment.+// Works with any rigged or static GLB — we auto-fit the bounding box+// so the head fills the viewport regardless of original scale/origin.+function GLBHead({ color, state, speaking }) {+ const gltf = useGLTF(MODEL_URL);+ const ref = useRef();++ // Clone so the cache copy isn't mutated.+ const scene = useMemo(() => gltf.scene.clone(true), [gltf.scene]);++ // Auto-fit to viewport + apply holographic material.+ useEffect(() => {+ // Replace all mesh materials with a dark base + emissive glow that+ // picks up the current state color. This avoids skin-tone uncanny+ // valley and keeps the silhouette consistent with other avatars.+ scene.traverse((obj) => {+ if (!obj.isMesh) return;+ obj.castShadow = false;+ obj.receiveShadow = false;+ obj.material = new THREE.MeshStandardMaterial({+ color: '#120820',+ emissive: color,+ emissiveIntensity: 0.55,+ metalness: 0.55,+ roughness: 0.35,+ transparent: true,+ opacity: 0.94,+ side: THREE.FrontSide,+ });+ });++ // Fit bounding box into a fixed height so different models render consistently.+ const box = new THREE.Box3().setFromObject(scene);+ const size = box.getSize(new THREE.Vector3());+ const center = box.getCenter(new THREE.Vector3());+ const targetHeight = 1.9;+ const scale = targetHeight / Math.max(size.y, 1e-3);+ scene.scale.setScalar(scale);+ scene.position.set(+ -center.x * scale,+ -center.y * scale + 0.05,+ -center.z * scale+ );+ }, [scene, color]);++ useFrame(({ clock }) => {+ const t = clock.getElapsedTime();+ if (!ref.current) return;++ const rotSpeed =+ state === 'sleeping' ? 0.15 :+ state === 'coding' ? 0.55 :+ state === 'investigating' ? 0.4 :+ state === 'thinking' ? 0.25 : 0.3;+ ref.current.rotation.y = Math.sin(t * rotSpeed) * 0.25;+ ref.current.rotation.x = speaking+ ? Math.sin(t * 10) * 0.04+ : Math.sin(t * 0.3) * 0.025;++ const intensity =+ state === 'sleeping' ? 0.2 :+ state === 'thinking' ? 0.6 + Math.sin(t * 3) * 0.3 :+ state === 'coding' ? 0.75 + Math.sin(t * 8) * 0.3 :+ state === 'investigating' ? 0.7 + Math.sin(t * 5) * 0.25 :+ state === 'ideating' ? 0.8 + Math.sin(t * 4) * 0.4 :+ 0.55;++ scene.traverse((obj) => {+ if (obj.isMesh && obj.material) {+ obj.material.emissiveIntensity = intensity;+ }+ });+ });++ return <primitive ref={ref} object={scene} />;+}++function Halo({ color, state }) {+ const ref = useRef();+ useFrame(({ clock }) => {+ const t = clock.getElapsedTime();+ if (!ref.current) return;+ const speed = state === 'sleeping' ? 0.1 : 0.3;+ ref.current.rotation.z = t * speed;+ ref.current.material.opacity = state === 'sleeping' ? 0.12 : 0.28 + Math.sin(t * 2) * 0.08;+ });+ return (+ <mesh ref={ref} position={[0, 0.15, -0.55]}>+ <ringGeometry args={[0.85, 1.05, 64]} />+ <meshBasicMaterial color={color} transparent opacity={0.28} side={THREE.DoubleSide} />+ </mesh>+ );+}++function GroundGlow({ color }) {+ return (+ <mesh rotation={[-Math.PI / 2, 0, 0]} position={[0, -1.25, 0]}>+ <circleGeometry args={[1.2, 32]} />+ <meshStandardMaterial+ color={color}+ emissive={color}+ emissiveIntensity={0.3}+ transparent+ opacity={0.12}+ />+ </mesh>+ );+}++function StateEffects({ color, state }) {+ if (state === 'ideating') return <Sparkles count={40} scale={2.5} size={4} speed={1} color={color} />;+ if (state === 'thinking') return <Sparkles count={30} scale={2.5} size={3} speed={0.6} color={color} />;+ if (state === 'coding') return <Sparkles count={55} scale={3} size={2} speed={2} color={color} />;+ if (state === 'investigating') return <Sparkles count={40} scale={3} size={3.5} speed={1.4} color={color} />;+ return <Sparkles count={15} scale={3} size={1.5} speed={0.3} color={color} />;+}++function Scene({ state, speaking }) {+ const stateConfig = AGENT_STATES[state] || AGENT_STATES.sleeping;+ const color = stateConfig.color;++ return (+ <>+ <ambientLight intensity={0.25} />+ <pointLight position={[2, 3, 4]} intensity={0.6} color={color} />+ <pointLight position={[-2, 1, 3]} intensity={0.3} color="#f472b6" />+ <Halo color={color} state={state} />+ <GLBHead color={color} state={state} speaking={speaking} />+ <StateEffects color={color} state={state} />+ <GroundGlow color={color} />+ </>+ );+}++function MissingModelHint() {+ return (+ <div className="relative w-full max-w-[8rem] lg:max-w-[12rem] aspect-[5/6] flex flex-col items-center justify-center rounded-lg border border-port-border bg-port-card/60 text-center p-3">+ <div className="text-3xl mb-2">🎭</div>+ <div className="text-xs font-semibold text-slate-200 mb-1">No avatar model</div>+ <div className="text-[10px] text-slate-400 mb-1.5">Drop a GLB at</div>+ <code className="text-[9px] text-port-accent break-all leading-tight">+ data/avatar/model.glb+ </code>+ </div>+ );+}++function LoadingPlaceholder() {+ return (+ <div className="relative w-full max-w-[8rem] lg:max-w-[12rem] aspect-[5/6] flex items-center justify-center">+ <div className="text-xs text-slate-500 animate-pulse">loading…</div>+ </div>+ );+}++export default function MuseCoSAvatar({ state, speaking }) {+ // null = checking, true = GLB present, false = missing+ const [modelPresent, setModelPresent] = useState(null);++ useEffect(() => {+ let cancelled = false;+ fetch(MODEL_URL, { method: 'HEAD' })+ .then((r) => {+ if (!cancelled) setModelPresent(r.ok);+ })+ .catch(() => {+ if (!cancelled) setModelPresent(false);+ });+ return () => { cancelled = true; };+ }, []);++ if (modelPresent === null) return <LoadingPlaceholder />;+ if (!modelPresent) return <MissingModelHint />;++ return (+ <div className="relative w-full max-w-[8rem] lg:max-w-[12rem] aspect-[5/6]">+ <Canvas+ camera={{ position: [0, 0, 3.3], fov: 45 }}+ style={{ background: 'transparent' }}+ gl={{ alpha: true, antialias: true }}+ >+ <Suspense fallback={null}>+ <Scene state={state} speaking={speaking} />+ </Suspense>+ </Canvas>+ </div>+ );+}++// Preload cache once URL is known to exist.+useGLTF.preload(MODEL_URL);diff --git a/client/src/components/cos/constants.js b/client/src/components/cos/constants.jsindex e5e2c3d644..ba07174325 100644--- a/client/src/components/cos/constants.js+++ b/client/src/components/cos/constants.js@@ -214,6 +214,7 @@ export const AVATAR_STYLE_LABELS = {sigil: 'Arcane Sigil (3D)',esoteric: 'Esoteric (3D)',nexus: 'Neural Nexus (3D)',+ muse: 'Cyber Muse (3D)',ascii: 'Minimalist (ASCII)'};diff --git a/client/src/components/cos/index.js b/client/src/components/cos/index.jsindex b8136ce1f0..438c85d0c0 100644--- a/client/src/components/cos/index.js+++ b/client/src/components/cos/index.js@@ -10,6 +10,7 @@ export { default as CyberCoSAvatar } from './CyberCoSAvatar';export { default as SigilCoSAvatar } from './SigilCoSAvatar';export { default as EsotericCoSAvatar } from './EsotericCoSAvatar';export { default as NexusCoSAvatar } from './NexusCoSAvatar';+export { default as MuseCoSAvatar } from './MuseCoSAvatar';export { default as StateLabel } from './StateLabel';export { default as TerminalCoSPanel } from './TerminalCoSPanel';diff --git a/client/src/pages/ChiefOfStaff.jsx b/client/src/pages/ChiefOfStaff.jsxindex ea7f8742b0..f2cc43112c 100644--- a/client/src/pages/ChiefOfStaff.jsx+++ b/client/src/pages/ChiefOfStaff.jsx@@ -16,6 +16,7 @@ import {SigilCoSAvatar,EsotericCoSAvatar,NexusCoSAvatar,+ MuseCoSAvatar,StateLabel,TerminalCoSPanel,StatusIndicator,@@ -602,6 +603,8 @@ export default function ChiefOfStaff() {? <EsotericCoSAvatar state={agentState} speaking={speaking} />: avatarStyle === 'nexus'? <NexusCoSAvatar state={agentState} speaking={speaking} />+ : avatarStyle === 'muse'+ ? <MuseCoSAvatar state={agentState} speaking={speaking} />: <CoSCharacter state={agentState} speaking={speaking} />}<div className="hidden lg:block">diff --git a/server/index.js b/server/index.jsindex 2448c9fc21..feae6fb5c5 100644--- a/server/index.js+++ b/server/index.js@@ -10,6 +10,7 @@ import { readFile, unlink } from 'fs/promises';import alertsRoutes from './routes/alerts.js';import appleHealthRoutes from './routes/appleHealth.js';+import avatarRoutes from './routes/avatar.js';import systemHealthRoutes from './routes/systemHealth.js';import appsRoutes from './routes/apps.js';import portsRoutes from './routes/ports.js';@@ -229,6 +230,7 @@ app.set('io', io);// API Routesapp.use('/api/alerts', alertsRoutes);+app.use('/api/avatar', avatarRoutes);app.use('/api/system', systemHealthRoutes);app.use('/api/apps', appsRoutes);app.use('/api/ports', portsRoutes);diff --git a/server/routes/avatar.js b/server/routes/avatar.jsnew file mode 100644index 0000000000..5960ab0de1--- /dev/null+++ b/server/routes/avatar.js@@ -0,0 +1,29 @@+import { Router } from 'express';+import { existsSync, statSync, createReadStream } from 'fs';+import { join } from 'path';+import { PATHS } from '../lib/fileUtils.js';++const router = Router();+const AVATAR_PATH = join(PATHS.data, 'avatar', 'model.glb');++router.head('/model.glb', (req, res) => {+ if (!existsSync(AVATAR_PATH)) {+ return res.status(404).end();+ }+ const s = statSync(AVATAR_PATH);+ res.set('Content-Type', 'model/gltf-binary');+ res.set('Content-Length', String(s.size));+ res.set('Cache-Control', 'public, max-age=60');+ return res.status(200).end();+});++router.get('/model.glb', (req, res) => {+ if (!existsSync(AVATAR_PATH)) {+ return res.status(404).json({ error: 'No avatar model configured. Drop a GLB at data/avatar/model.glb' });+ }+ res.set('Content-Type', 'model/gltf-binary');+ res.set('Cache-Control', 'public, max-age=60');+ createReadStream(AVATAR_PATH).pipe(res);+});++export default router;diff --git a/server/routes/cosStatusRoutes.js b/server/routes/cosStatusRoutes.jsindex 2b2e098d66..6ab105f87d 100644--- a/server/routes/cosStatusRoutes.js+++ b/server/routes/cosStatusRoutes.js@@ -31,7 +31,7 @@ export const cosConfigSchema = z.object({selfImprovementEnabled: z.boolean().optional(),appImprovementEnabled: z.boolean().optional(),improvementEnabled: z.boolean().optional(),- avatarStyle: z.enum(['svg', 'ascii', 'cyber', 'sigil', 'esoteric', 'nexus']).optional(),+ avatarStyle: z.enum(['svg', 'ascii', 'cyber', 'sigil', 'esoteric', 'nexus', 'muse']).optional(),dynamicAvatar: z.boolean().optional(),alwaysOn: z.boolean().optional(),appReviewCooldownMs: z.number().int().min(0).optional(),