Skip to content

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

feat(cos): bundle two animated CC0 mini-character avatars

Adam Eivy413c868f198a
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 97db35eeb4..5352cc5b66 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -2,6 +2,8 @@
## Added
+- **Animated 3D mini-character CoS avatars (bundled, CC0)** — two new Chief-of-Staff avatar styles, **Mini Character — Male (3D)** and **Mini Character — Female (3D)**, ship as rigged, animated GLB models out of the box (no user setup, no download). Unlike the `muse` style (which needs you to drop your own `data/avatar/model.glb`), these render immediately and play real skeletal animations mapped to the CoS agent state — `idle` while thinking, `walk` while coding, `sit` while sleeping, `sprint` while ideating, `emote-yes` while reviewing — plus a slow turntable rotation and a speaking head-bob, with clips crossfading on state change. The models are Kenney's [Mini Characters](https://kenney.nl/assets/mini-characters) (Creative Commons Zero), re-exported with the texture embedded and Draco compression disabled so they render offline / over Tailscale without fetching an external decoder from a CDN. Each is ~210 KB and ships in `data.reference/avatar/` (seeded into `data/avatar/` by `npm run setup:data`). The avatar route gained a safe `?variant=<name>` selector (strict `[a-z0-9-]` validation, no path traversal) so multiple bundled characters share one endpoint. Drop any rigged GLB at `data/avatar/<name>.glb` to add your own.
+
- **[issue-1092] Vocal takes remember their pitch analysis** — when you record a take against a song's notated melody, the take now keeps its color-match grading (percent-in-tune and per-note accuracy) and the tuner trace. Each saved take shows its score in the takes list, and a Review button replays that grading on the staff without re-singing.
- **Public API surface with per-API auth gating (Voice/TTS + sdapi):** PortOS can now serve individual services as HTTP APIs on your tailnet. A new **Settings → API Access** tab exposes per-API toggles — *Expose on the network* (off by default) and *Require auth* (off = passwordless) — so you can keep the whole app behind your PortOS password while leaving the **Voice/TTS** and **Image Gen (sdapi)** APIs open for other machines to call. A deliberately-minimal `POST /api/voice/public/synthesize` (plus `/voices` and `/engines`) turns text into WAV audio with any engine/voice/rate; config and process-control endpoints always stay gated. A single in-tree registry (`server/lib/apiRegistry.js`) drives the auth-gate exemptions, the settings UI, and a native **OpenAPI 3.1 spec** at `GET /api/api-docs/openapi.json` (no swagger dependency — request bodies are generated from the same Zod schemas the routes validate against). The API Access tab shows each API's public base URL and a copy-paste `curl` example, and the Voice settings tab links to it. Defaults are safe: both APIs ship not-exposed and passwordless-once-exposed, with a migration seeding the key for existing installs.
diff --git a/client/src/components/cos/MiniCharFemaleD.jsx b/client/src/components/cos/MiniCharFemaleD.jsx
new file mode 100644
index 0000000000..945c70d1cc
--- /dev/null
+++ b/client/src/components/cos/MiniCharFemaleD.jsx
@@ -0,0 +1,5 @@
+import MiniCharacterCoSAvatar from './MiniCharacterCoSAvatar';
+// Bundled CC0 Kenney Mini Character (Female D). See data.reference/avatar/README.md.
+export default function MiniCharFemaleD(props) {
+ return <MiniCharacterCoSAvatar {...props} variant="mini-female-d" />;
+}
diff --git a/client/src/components/cos/MiniCharMaleC.jsx b/client/src/components/cos/MiniCharMaleC.jsx
new file mode 100644
index 0000000000..c1986822f2
--- /dev/null
+++ b/client/src/components/cos/MiniCharMaleC.jsx
@@ -0,0 +1,5 @@
+import MiniCharacterCoSAvatar from './MiniCharacterCoSAvatar';
+// Bundled CC0 Kenney Mini Character (Male C). See data.reference/avatar/README.md.
+export default function MiniCharMaleC(props) {
+ return <MiniCharacterCoSAvatar {...props} variant="mini-male-c" />;
+}
diff --git a/client/src/components/cos/MiniCharacterCoSAvatar.jsx b/client/src/components/cos/MiniCharacterCoSAvatar.jsx
new file mode 100644
index 0000000000..bc3a033656
--- /dev/null
+++ b/client/src/components/cos/MiniCharacterCoSAvatar.jsx
@@ -0,0 +1,181 @@
+import { useRef, useMemo, useEffect, useState, Suspense } from 'react';
+import { Canvas, useFrame } from '@react-three/fiber';
+import { useGLTF, useAnimations } from '@react-three/drei';
+import * as THREE from 'three';
+import { SkeletonUtils } from 'three-stdlib';
+import { AGENT_STATES } from './constants';
+import CoSAvatarOrbitControls from './CoSAvatarOrbitControls';
+import CoSAvatarFrame from './CoSAvatarFrame';
+import CoSBackgroundCamera from './CoSBackgroundCamera';
+
+// Kenney Mini Characters (CC0) ship 32 named clips. We map the CoS agent
+// states onto the most evocative ones. Each entry has a clip name plus a
+// per-state turntable rotation speed so the body language reads at a glance.
+const STATE_CLIP_MAP = {
+ sleeping: { clip: 'sit', rot: 0.05, timeScale: 0.6 },
+ thinking: { clip: 'idle', rot: 0.15, timeScale: 0.8 },
+ coding: { clip: 'walk', rot: 0.0, timeScale: 1.4 },
+ investigating: { clip: 'interact-right', rot: 0.0, timeScale: 1.0 },
+ reviewing: { clip: 'emote-yes', rot: 0.0, timeScale: 0.9 },
+ planning: { clip: 'idle', rot: 0.4, timeScale: 1.0 },
+ ideating: { clip: 'sprint', rot: 0.0, timeScale: 1.2 },
+};
+const FALLBACK = { clip: 'idle', rot: 0.2, timeScale: 1.0 };
+
+// Shared ground-plane Y. The character's feet rest here AND the shadow/glow
+// disc sits here, so they can never drift apart. Lowering this value pushes
+// the whole avatar down in frame (~210px per world unit at this camera).
+const GROUND_Y = -1.4;
+
+function buildModelUrl(variant) {
+ return variant ? `/api/avatar/model.glb?variant=${encodeURIComponent(variant)}` : '/api/avatar/model.glb';
+}
+
+function MiniCharacter({ state, speaking, variant }) {
+ const url = useMemo(() => buildModelUrl(variant), [variant]);
+ const gltf = useGLTF(url);
+ const group = useRef();
+
+ // Clone via SkeletonUtils — a plain Object3D.clone() does NOT rebind the
+ // SkinnedMesh to the cloned skeleton, so AnimationMixer would drive bones
+ // the visible mesh no longer references and nothing moves. SkeletonUtils
+ // rebuilds the bone bindings on the clone so animations actually deform it.
+ const scene = useMemo(() => SkeletonUtils.clone(gltf.scene), [gltf.scene]);
+ const { actions, names } = useAnimations(gltf.animations, scene);
+
+ // Fit the character into a consistent height regardless of source scale.
+ // Kenney mini-characters are authored ~1.7 units tall already, but we
+ // normalize so any dropped-in model fills the frame the same way.
+ useEffect(() => {
+ const box = new THREE.Box3().setFromObject(scene);
+ const size = box.getSize(new THREE.Vector3());
+ const center = box.getCenter(new THREE.Vector3());
+ const targetHeight = 2.6;
+ const scale = targetHeight / Math.max(size.y, 1e-3);
+ scene.scale.setScalar(scale);
+ // Recenter horizontally; rest the feet on the shared ground plane
+ // (GROUND_Y) rather than centering vertically so the character stands
+ // in frame with its feet on the shadow disc.
+ scene.position.set(
+ -center.x * scale,
+ -box.min.y * scale + GROUND_Y,
+ -center.z * scale,
+ );
+ }, [scene]);
+
+ // Resolve the active clip for this state, falling back gracefully.
+ const cfg = STATE_CLIP_MAP[state] || FALLBACK;
+ const clipName = useMemo(() => {
+ if (names.includes(cfg.clip)) return cfg.clip;
+ if (names.includes('idle')) return 'idle';
+ return names[0];
+ }, [names, cfg.clip]);
+
+ // Crossfade between clips on state change.
+ const prevClip = useRef(null);
+ useEffect(() => {
+ const next = actions[clipName];
+ if (!next) return;
+ next.reset().setEffectiveTimeScale(cfg.timeScale || 1).fadeIn(0.3).play();
+ if (prevClip.current && prevClip.current !== next) {
+ prevClip.current.fadeOut(0.3);
+ }
+ prevClip.current = next;
+ return () => {
+ next.fadeOut(0.3);
+ };
+ }, [actions, clipName, cfg.timeScale]);
+
+ // Turntable rotation + speaking head-bob.
+ useFrame((_, delta) => {
+ if (!group.current) return;
+ group.current.rotation.y += (cfg.rot || 0) * delta;
+ const bob = speaking ? Math.sin(performance.now() * 0.012) * 0.03 : 0;
+ group.current.position.y = bob;
+ });
+
+ return (
+ <group ref={group}>
+ <primitive object={scene} />
+ </group>
+ );
+}
+
+function StageLighting({ color }) {
+ return (
+ <>
+ <ambientLight intensity={0.6} />
+ <directionalLight position={[3, 5, 4]} intensity={1.2} />
+ <pointLight position={[-3, 2, 3]} intensity={0.5} color={color} />
+ {/* soft ground glow tinted by state — sits on the shared ground plane
+ so it stays under the character's feet (slight +0.01 lift avoids
+ z-fighting with the lowest foot geometry). */}
+ <mesh rotation={[-Math.PI / 2, 0, 0]} position={[0, GROUND_Y + 0.01, 0]}>
+ <circleGeometry args={[1.1, 48]} />
+ <meshStandardMaterial color={color} emissive={color} emissiveIntensity={0.25} transparent opacity={0.15} />
+ </mesh>
+ </>
+ );
+}
+
+function Scene({ state, speaking, background, variant }) {
+ const stateConfig = AGENT_STATES[state] || AGENT_STATES.sleeping;
+ const color = stateConfig.color;
+ return (
+ <>
+ <CoSBackgroundCamera enabled={background} z={3.6} />
+ <StageLighting color={color} />
+ <MiniCharacter state={state} speaking={speaking} variant={variant} />
+ <CoSAvatarOrbitControls />
+ </>
+ );
+}
+
+function MissingModelHint({ background = false }) {
+ return (
+ <div className={`${background ? 'relative w-full h-full min-h-full' : '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 mini-character model</div>
+ <code className="text-[9px] text-port-accent break-all leading-tight">data/avatar/&lt;variant&gt;.glb</code>
+ </div>
+ );
+}
+
+function LoadingPlaceholder({ background = false }) {
+ return (
+ <div className={`${background ? 'relative w-full h-full min-h-full' : '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>
+ );
+}
+
+// `variant` is wired by the per-character style wrappers (MiniCharMaleC, etc.).
+export default function MiniCharacterCoSAvatar({ state, speaking, background = false, variant = 'mini-male-c' }) {
+ const [modelPresent, setModelPresent] = useState(null);
+ const url = useMemo(() => buildModelUrl(variant), [variant]);
+
+ useEffect(() => {
+ let cancelled = false;
+ fetch(url, { method: 'HEAD' })
+ .then((r) => { if (!cancelled) setModelPresent(r.ok); })
+ .catch(() => { if (!cancelled) setModelPresent(false); });
+ return () => { cancelled = true; };
+ }, [url]);
+
+ if (modelPresent === null) return <LoadingPlaceholder background={background} />;
+ if (!modelPresent) return <MissingModelHint background={background} />;
+
+ return (
+ <CoSAvatarFrame label="Mini-character avatar. Drag to rotate." background={background}>
+ <Canvas
+ camera={{ position: [0, 0.2, 3.0], fov: 40 }}
+ style={{ width: '100%', height: '100%', background: 'transparent' }}
+ gl={{ alpha: true, antialias: true }}
+ >
+ <Suspense fallback={null}>
+ <Scene state={state} speaking={speaking} background={background} variant={variant} />
+ </Suspense>
+ </Canvas>
+ </CoSAvatarFrame>
+ );
+}
diff --git a/client/src/components/cos/constants.js b/client/src/components/cos/constants.js
index 24f58f3c71..5a24699400 100644
--- a/client/src/components/cos/constants.js
+++ b/client/src/components/cos/constants.js
@@ -332,6 +332,9 @@ export const AVATAR_STYLE_LABELS = {
esoteric: 'Esoteric (3D)',
nexus: 'Neural Nexus (3D)',
muse: 'Cyber Muse (3D)',
+ // Bundled CC0 Kenney Mini Characters — animated rigged GLB avatars.
+ miniMaleC: 'Mini Character — Male (3D)',
+ miniFemaleD: 'Mini Character — Female (3D)',
ascii: 'Minimalist (ASCII)'
};
diff --git a/client/src/pages/ChiefOfStaff.jsx b/client/src/pages/ChiefOfStaff.jsx
index cc195a59e4..cdcf8beefb 100644
--- a/client/src/pages/ChiefOfStaff.jsx
+++ b/client/src/pages/ChiefOfStaff.jsx
@@ -47,9 +47,15 @@ const LAZY_AVATARS = {
esoteric: lazy(() => import('../components/cos/EsotericCoSAvatar')),
nexus: lazy(() => import('../components/cos/NexusCoSAvatar')),
muse: lazy(() => import('../components/cos/MuseCoSAvatar')),
+ // Bundled CC0 Kenney Mini Characters — animated rigged GLB avatars.
+ miniMaleC: lazy(() => import('../components/cos/MiniCharMaleC')),
+ miniFemaleD: lazy(() => import('../components/cos/MiniCharFemaleD')),
};
-const CANVAS_AVATAR_STYLES = new Set(['cyber', 'sigil', 'esoteric', 'nexus', 'muse']);
+const CANVAS_AVATAR_STYLES = new Set([
+ 'cyber', 'sigil', 'esoteric', 'nexus', 'muse',
+ 'miniMaleC', 'miniFemaleD',
+]);
export default function ChiefOfStaff() {
const { tab } = useParams();
diff --git a/data.reference/avatar/README.md b/data.reference/avatar/README.md
new file mode 100644
index 0000000000..d39c73e240
--- /dev/null
+++ b/data.reference/avatar/README.md
@@ -0,0 +1,29 @@
+# Bundled CoS Avatar Models
+
+These GLB models are shipped as selectable Chief-of-Staff avatar styles.
+
+## Source & License
+
+**Kenney Mini Characters** — https://kenney.nl/assets/mini-characters
+License: **Creative Commons Zero (CC0)** — public domain, free for personal,
+educational, and commercial use. Attribution appreciated but not required.
+
+The models were re-exported from Kenney's source GLBs with the embedded
+texture packed in and Draco compression intentionally disabled (PortOS must
+render them offline / over Tailscale without fetching an external Draco
+decoder from a CDN).
+
+| File | Character |
+|------|-----------|
+| `mini-male-c.glb` | Mini Character — Male C (uniformed) |
+| `mini-female-d.glb` | Mini Character — Female D (jacket, bun) |
+
+Each ships 32 named animation clips (`idle`, `walk`, `sprint`, `sit`,
+`emote-yes`, `interact-right`, etc.) that the avatar maps onto CoS agent states.
+
+## Adding more
+
+Drop any rigged GLB at `data/avatar/<name>.glb` and reference it via
+`/api/avatar/model.glb?variant=<name>`. Clip names that match the
+`STATE_CLIP_MAP` in `client/src/components/cos/MiniCharacterCoSAvatar.jsx`
+will animate per-state; others fall back to `idle`.
diff --git a/data.reference/avatar/mini-female-d.glb b/data.reference/avatar/mini-female-d.glb
new file mode 100644
index 0000000000..24525e5bbc
Binary files /dev/null and b/data.reference/avatar/mini-female-d.glb differ
diff --git a/data.reference/avatar/mini-male-c.glb b/data.reference/avatar/mini-male-c.glb
new file mode 100644
index 0000000000..28bbcfa898
Binary files /dev/null and b/data.reference/avatar/mini-male-c.glb differ
diff --git a/docs/superpowers/specs/2026-04-20-rigged-3d-avatar-stage-design.md b/docs/superpowers/specs/2026-04-20-rigged-3d-avatar-stage-design.md
index 51e4b872ac..7d1d01259d 100644
--- a/docs/superpowers/specs/2026-04-20-rigged-3d-avatar-stage-design.md
+++ b/docs/superpowers/specs/2026-04-20-rigged-3d-avatar-stage-design.md
@@ -15,7 +15,7 @@ The character's body animation, facial expression, and speaking behavior react t
## Non-goals
-- Shipping a bundled 3D model in the repo. The single source of the character is a user-supplied GLB at `./data/avatar/model.glb`. No binary is committed.
+- ~~Shipping a bundled 3D model in the repo.~~ **(Superseded 2026-06-10.)** PortOS now bundles two CC0 Kenney Mini Character GLBs as ready-to-use animated avatar styles (`miniMaleC`, `miniFemaleD`), seeded from `data.reference/avatar/` into `data/avatar/` by `setup-data.js`. The `muse` style still loads a user-supplied `./data/avatar/model.glb`; the bundled mini-characters are served from the same route via a `?variant=<name>` selector. See `client/src/components/cos/MiniCharacterCoSAvatar.jsx` and `data.reference/avatar/README.md`.
- Teaching users to rig characters. `docs/avatar-pipeline.md` links to external tools (AccuRIG 2, Mesh2Motion, Rigify) for the rigging step.
- Per-agent personas, skins, or multiple simultaneous avatars.
- Phoneme-timed TTS lip-sync. Speaking is driven by audio amplitude or a sine fallback, not phoneme sequences. A viseme-per-phoneme engine is a later upgrade if desired.
diff --git a/server/routes/avatar.js b/server/routes/avatar.js
index 360057d923..db58605578 100644
--- a/server/routes/avatar.js
+++ b/server/routes/avatar.js
@@ -5,7 +5,18 @@ import { PATHS } from '../lib/fileUtils.js';
import { ServerError } from '../lib/errorHandler.js';
const router = Router();
-const AVATAR_PATH = join(PATHS.data, 'avatar', 'model.glb');
+const AVATAR_DIR = join(PATHS.data, 'avatar');
+const AVATAR_PATH = join(AVATAR_DIR, 'model.glb');
+
+// Resolve a requested variant filename to an absolute path inside AVATAR_DIR.
+// Only [a-z0-9-] basenames are allowed (no slashes, no dots, no traversal),
+// and the .glb extension is appended server-side — so a malicious `?variant`
+// can never escape the avatar directory.
+function resolveVariant(variant) {
+ if (!variant || typeof variant !== 'string') return AVATAR_PATH;
+ if (!/^[a-z0-9-]+$/.test(variant)) return null;
+ return join(AVATAR_DIR, `${variant}.glb`);
+}
// Non-throwing stat wrapper used by the HEAD handler — file may be removed between
// existsSync() and statSync() (TOCTOU), which would otherwise crash the process.
@@ -18,10 +29,11 @@ function safeStat(p) {
}
router.head('/model.glb', (req, res) => {
- if (!existsSync(AVATAR_PATH)) {
+ const path = resolveVariant(req.query.variant);
+ if (!path || !existsSync(path)) {
return res.status(404).end();
}
- const s = safeStat(AVATAR_PATH);
+ const s = safeStat(path);
if (!s) return res.status(404).end();
res.set('Content-Type', 'model/gltf-binary');
res.set('Content-Length', String(s.size));
@@ -30,14 +42,15 @@ router.head('/model.glb', (req, res) => {
});
router.get('/model.glb', (req, res) => {
- if (!existsSync(AVATAR_PATH)) {
+ const path = resolveVariant(req.query.variant);
+ if (!path || !existsSync(path)) {
throw new ServerError('No avatar model configured. Drop a GLB at data/avatar/model.glb', { status: 404 });
}
res.set('Content-Type', 'model/gltf-binary');
res.set('Cache-Control', 'public, max-age=60');
// Guard against TOCTOU: if the file is removed between existsSync() and
// createReadStream(), the stream emits 'error' — handle it instead of crashing.
- const stream = createReadStream(AVATAR_PATH);
+ const stream = createReadStream(path);
stream.on('error', (err) => {
console.warn(`⚠️ Avatar stream error: ${err.code || err.message}`);
if (!res.headersSent) {
diff --git a/server/routes/avatar.test.js b/server/routes/avatar.test.js
index 2976342947..652dd5fe1b 100644
--- a/server/routes/avatar.test.js
+++ b/server/routes/avatar.test.js
@@ -87,4 +87,29 @@ describe('avatar routes', () => {
expect(res.status).toBe(500);
});
});
+
+ describe('variant resolution', () => {
+ it('serves a named variant from the avatar dir', async () => {
+ existsSync.mockReturnValue(true);
+ createReadStream.mockReturnValue(Readable.from([Buffer.from('VARIANT-GLB')]));
+ const res = await request(buildApp()).get('/api/avatar/model.glb?variant=mini-male-c');
+ expect(res.status).toBe(200);
+ expect(res.text).toBe('VARIANT-GLB');
+ // The resolved path must stay inside the avatar dir with .glb appended.
+ expect(createReadStream).toHaveBeenCalledWith('/mock/data/avatar/mini-male-c.glb');
+ });
+
+ it('rejects path-traversal / illegal variant names with 404', async () => {
+ existsSync.mockReturnValue(true);
+ for (const bad of ['../secret', 'a/b', 'foo.glb', 'UP', '']) {
+ const res = await request(buildApp()).get(`/api/avatar/model.glb?variant=${encodeURIComponent(bad)}`);
+ // Empty string falls back to default model.glb (200); the rest are 404.
+ if (bad === '') {
+ expect(res.status).toBe(200);
+ } else {
+ expect(res.status).toBe(404);
+ }
+ }
+ });
+ });
});
diff --git a/server/routes/cosStatusRoutes.js b/server/routes/cosStatusRoutes.js
index 64dc507a98..442cefda17 100644
--- a/server/routes/cosStatusRoutes.js
+++ b/server/routes/cosStatusRoutes.js
@@ -34,7 +34,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', 'muse']).optional(),
+ avatarStyle: z.enum(['svg', 'ascii', 'cyber', 'sigil', 'esoteric', 'nexus', 'muse', 'miniMaleC', 'miniFemaleD']).optional(),
dynamicAvatar: z.boolean().optional(),
alwaysOn: z.boolean().optional(),
appReviewCooldownMs: z.number().int().min(0).optional(),