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
Add RobotExpressive default Muse avatar with CoS-state animation triggers
Adam Eivyd5cc8fe1e655
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 4010f5a0fa..70f6e2e41c 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -11,6 +11,7 @@- **Scheduled tasks and the new-task form can pin a thinking-effort level.** Alongside the existing provider/model overrides, a "Thinking Effort" select appears when the pinned provider is Claude Code or Codex (Claude: low→max; Codex: minimal→ultra). The spawned agent gets `--effort <level>` (claude) or `-c model_reasoning_effort=<level>` (codex) across all three execution modes — direct CLI, runner, and TUI. Codex-only values clamp to the nearest Claude equivalent if the task later runs on a Claude provider, a user-baked `--effort` in provider args wins over the injected one, and task templates save/re-apply the effort choice.- **[issue-2502] Thinking-effort pins now extend to pipeline stages and autonomous jobs.** The two remaining surfaces that carried provider/model overrides gain the same "Thinking Effort" select: each pipeline stage (code-reviewer's Review/Implement, pr-reviewer's Security/Review, etc.) can pin its own effort in its stage card, and each autonomous job can pin one in the job form. The select only renders for effort-capable providers (Claude Code / Codex) and resets when the stage/job provider changes. Stage 0's effort rides into the first agent and each subsequent stage re-applies its own on hand-off; a job's effort flows into every task it generates — spawning with `--effort`/`-c model_reasoning_effort=` and a no-op for non-effort providers.+- **The Cyber Muse (3D) CoS avatar ships a default animated model and reacts to agent state.** A bundled RobotExpressive model (three.js example, CC0) is now seeded at `data/avatar/model.glb`, so the Muse avatar renders out of the box instead of showing a "drop a GLB" hint. Its skeletal clips are now driven by an `AnimationMixer` (via drei `useAnimations`) keyed off the CoS runtime: each agent state crossfades to its own in-place clip — sleeping→sit, thinking→idle, coding→punch, investigating→scan, reviewing→nod, planning→thumbs-up, ideating→dance — and the `speaking` flag fires a one-shot wave that returns to the base loop. Root-motion clips (walk/run) are intentionally left unmapped so the fixed-frame avatar can't drift out of view, the holographic emissive treatment is preserved, and a GLB with no clips falls back to the original procedural rotation/glow so other variants and static models still render.## Changeddiff --git a/client/src/components/cos/MuseCoSAvatar.jsx b/client/src/components/cos/MuseCoSAvatar.jsxindex dff3fc2573..2074e299ab 100644--- a/client/src/components/cos/MuseCoSAvatar.jsx+++ b/client/src/components/cos/MuseCoSAvatar.jsx@@ -1,34 +1,54 @@-import { useRef, useMemo, useEffect, useState, Suspense } from 'react';+import { useRef, useMemo, useEffect, useState, useCallback, Suspense, Component } from 'react';import { Canvas, useFrame } from '@react-three/fiber';-import { useGLTF, Sparkles } from '@react-three/drei';+import { useGLTF, useAnimations, Sparkles } from '@react-three/drei';import * as THREE from 'three';-import { AGENT_STATES } from './constants';+import { SkeletonUtils } from 'three-stdlib';+import {+ AGENT_STATES,+ MUSE_STATE_ANIMATIONS,+ MUSE_ANIMATION_FALLBACK,+ MUSE_SPEAKING_GESTURE,+} from './constants';import CoSAvatarOrbitControls from './CoSAvatarOrbitControls';import CoSAvatarFrame from './CoSAvatarFrame';import CoSBackgroundCamera from './CoSBackgroundCamera';const MODEL_URL = '/api/avatar/model.glb';+const FADE = 0.35; // crossfade seconds between state loops-// 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 }) {+// Loaded avatar wrapped in a holographic material treatment. When the GLB+// ships animation clips (the bundled RobotExpressive default does), an+// AnimationMixer drives the skeleton per CoS state and `speaking`; otherwise it+// falls back to the fully-procedural rotation/glow so static GLBs still render.+function GLBAvatar({ 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]);+ // SkeletonUtils.clone rebinds SkinnedMeshes to the cloned skeleton so the+ // AnimationMixer actually deforms the visible mesh. A plain scene.clone(true)+ // leaves the mixer driving bones the rendered mesh no longer references, so+ // nothing would move — the reason clips were previously ignored.+ const scene = useMemo(() => SkeletonUtils.clone(gltf.scene), [gltf.scene]);+ const { actions, names, mixer } = useAnimations(gltf.animations, scene);+ const hasClips = names.length > 0;- // Auto-fit to viewport + apply holographic material.+ // Materials to pulse each frame (collected once so we don't traverse the+ // whole scene graph on every frame).+ const matsRef = useRef([]);++ // Auto-fit to viewport + apply holographic material. Replacing the material+ // does NOT affect skinning — the skeleton drives deformation regardless of+ // the material bound to the SkinnedMesh, so clips still animate the body.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.+ const mats = [];scene.traverse((obj) => {if (!obj.isMesh) return;obj.castShadow = false;obj.receiveShadow = false;- obj.material = new THREE.MeshStandardMaterial({+ // Animated poses (arms out, jump) can exceed the bind-pose bounding box;+ // disable frustum culling so the avatar never blinks out mid-clip.+ obj.frustumCulled = false;+ const material = new THREE.MeshStandardMaterial({color: '#120820',emissive: color,emissiveIntensity: 0.55,@@ -38,7 +58,10 @@ function GLBHead({ color, state, speaking }) {opacity: 0.94,side: THREE.FrontSide,});+ obj.material = material;+ mats.push(material);});+ matsRef.current = mats;// Fit bounding box into a fixed height so different models render consistently.const box = new THREE.Box3().setFromObject(scene);@@ -54,19 +77,103 @@ function GLBHead({ color, state, speaking }) {);}, [scene, color]);+ // --- Animation driving -------------------------------------------------+ // The base loop we should return to when idle (updated by the state effect),+ // plus a flag so a state change mid-gesture defers the crossfade to the+ // gesture's finish handler instead of fighting it.+ const activeRef = useRef(null); // currently-playing action+ const desiredBaseRef = useRef(null); // { name, timeScale, once } to rest on+ const gestureActiveRef = useRef(false);+ const speakingRef = useRef(false);++ // Crossfade the currently-active action to `clipName`.+ const fadeTo = useCallback((clipName, opts = {}) => {+ const next = actions[clipName];+ if (!next) return;+ const dur = opts.duration ?? FADE;+ next.reset();+ next.enabled = true;+ next.setEffectiveTimeScale(opts.timeScale ?? 1);+ next.setEffectiveWeight(1);+ next.setLoop(opts.once ? THREE.LoopOnce : THREE.LoopRepeat, opts.once ? 1 : Infinity);+ next.clampWhenFinished = !!opts.once;+ next.fadeIn(dur).play();+ const prev = activeRef.current;+ if (prev && prev !== next) prev.fadeOut(dur);+ activeRef.current = next;+ }, [actions]);++ // Resolve the base loop clip for the current state (guarded against a GLB+ // that lacks the mapped clip).+ const baseCfg = MUSE_STATE_ANIMATIONS[state] || {};+ const baseClip = useMemo(() => {+ if (!hasClips) return null;+ if (baseCfg.clip && names.includes(baseCfg.clip)) return baseCfg.clip;+ if (names.includes(MUSE_ANIMATION_FALLBACK)) return MUSE_ANIMATION_FALLBACK;+ return names[0];+ }, [hasClips, names, baseCfg.clip]);++ // Play / crossfade the base state loop.+ useEffect(() => {+ if (!baseClip) return;+ desiredBaseRef.current = { name: baseClip, timeScale: baseCfg.timeScale, once: baseCfg.once };+ // Mid-gesture: don't crossfade now — the gesture's finish handler restores+ // to whatever desiredBaseRef points at, so the latest state still wins.+ if (gestureActiveRef.current) return;+ fadeTo(baseClip, { timeScale: baseCfg.timeScale, once: baseCfg.once });+ }, [fadeTo, baseClip, baseCfg.timeScale, baseCfg.once]);++ // Persistent listener: when the one-shot speaking gesture finishes, hand+ // control back to whatever base loop the current state wants (read live from+ // desiredBaseRef, so a state change mid-gesture still lands correctly). Kept+ // separate from the trigger effect below so that `speaking` flipping back to+ // false mid-gesture can't tear down the restore path — the gesture always+ // returns to a base loop instead of freezing on its end pose.+ useEffect(() => {+ if (!hasClips) return;+ const gesture = actions[MUSE_SPEAKING_GESTURE];+ const onFinished = (e) => {+ if (!gestureActiveRef.current) return;+ if (gesture && e.action !== gesture) return; // ignore base clips finishing+ gestureActiveRef.current = false;+ const rest = desiredBaseRef.current;+ if (rest?.name) fadeTo(rest.name, { timeScale: rest.timeScale, once: rest.once, duration: 0.25 });+ };+ mixer.addEventListener('finished', onFinished);+ return () => mixer.removeEventListener('finished', onFinished);+ }, [fadeTo, hasClips, actions, mixer]);++ // Speaking overlay: on the false→true edge, crossfade to the gesture once.+ // The persistent listener above returns to the base loop when it finishes.+ useEffect(() => {+ if (!hasClips) return;+ const was = speakingRef.current;+ speakingRef.current = speaking;+ if (!speaking || was) return; // only fire on the rising edge++ const gesture = actions[MUSE_SPEAKING_GESTURE];+ const base = desiredBaseRef.current;+ if (!gesture || (base && gesture === actions[base.name])) return;++ gestureActiveRef.current = true;+ fadeTo(MUSE_SPEAKING_GESTURE, { once: true, duration: 0.2 });+ }, [fadeTo, speaking, hasClips, actions]);++ // Subtle container sway + holographic emissive pulse. The clip drives the+ // body; this only adds the gentle float/glow that reads as "holographic".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;+ if (ref.current) {+ 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.2;+ ref.current.rotation.x = speaking+ ? Math.sin(t * 10) * 0.03+ : Math.sin(t * 0.3) * 0.02;+ }const intensity =state === 'sleeping' ? 0.2 :@@ -75,15 +182,15 @@ function GLBHead({ color, state, speaking }) {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;- }- });+ const mats = matsRef.current;+ for (let i = 0; i < mats.length; i++) mats[i].emissiveIntensity = intensity;});- return <primitive ref={ref} object={scene} />;+ return (+ <group ref={ref}>+ <primitive object={scene} />+ </group>+ );}function Halo({ color, state }) {@@ -138,7 +245,7 @@ function Scene({ state, speaking, background }) {<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} />+ <GLBAvatar color={color} state={state} speaking={speaking} /><StateEffects color={color} state={state} /><GroundGlow color={color} />@@ -152,7 +259,7 @@ function MissingModelHint({ background = false }) {<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-gray-200 mb-1">No avatar model</div>- <div className="text-[10px] text-gray-400 mb-1.5">Drop a GLB at</div>+ <div className="text-[10px] text-gray-400 mb-1.5">Run <code className="text-port-accent">npm run setup:data</code> or drop a GLB at</div><code className="text-[9px] text-port-accent break-all leading-tight">data/avatar/model.glb</code>@@ -160,6 +267,25 @@ function MissingModelHint({ background = false }) {);}+// Error boundary so a corrupt/non-GLTF body (the HEAD probe only confirms+// r.ok, not valid GLTF) degrades to the missing-model hint instead of+// white-screening the whole CoS page.+class AvatarErrorBoundary extends Component {+ constructor(props) {+ super(props);+ this.state = { failed: false };+ }+ static getDerivedStateFromError() {+ return { failed: true };+ }+ componentDidCatch(err) {+ console.warn(`⚠️ Muse avatar failed to load: ${err?.message || err}`);+ }+ render() {+ return this.state.failed ? this.props.fallback : this.props.children;+ }+}+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`}>@@ -189,15 +315,17 @@ export default function MuseCoSAvatar({ state, speaking, background = false }) {return (<CoSAvatarFrame label="Muse 3D avatar. Drag to rotate." background={background}>- <Canvas- camera={{ position: [0, 0, 3.3], fov: 45 }}- style={{ width: '100%', height: '100%', background: 'transparent' }}- gl={{ alpha: true, antialias: true }}- >- <Suspense fallback={null}>- <Scene state={state} speaking={speaking} background={background} />- </Suspense>- </Canvas>+ <AvatarErrorBoundary fallback={<MissingModelHint background={background} />}>+ <Canvas+ camera={{ position: [0, 0, 3.3], fov: 45 }}+ style={{ width: '100%', height: '100%', background: 'transparent' }}+ gl={{ alpha: true, antialias: true }}+ >+ <Suspense fallback={null}>+ <Scene state={state} speaking={speaking} background={background} />+ </Suspense>+ </Canvas>+ </AvatarErrorBoundary></CoSAvatarFrame>);}diff --git a/client/src/components/cos/constants.js b/client/src/components/cos/constants.jsindex 53190667ee..39d044d8c4 100644--- a/client/src/components/cos/constants.js+++ b/client/src/components/cos/constants.js@@ -61,6 +61,48 @@ export const AGENT_STATES = {ideating: { label: 'Ideating', color: '#f97316', icon: '💡' },};+// Cyber Muse (3D) avatar animation triggers. The bundled default model+// (data.reference/avatar/model.glb) is three.js's RobotExpressive (CC0), which+// ships 14 clips: Idle, Walking, Running, Dance, Death, Sitting, Standing,+// Jump, Yes, No, Wave, Punch, ThumbsUp, WalkJump.+//+// Each of the 7 AGENT_STATES maps to an IN-PLACE base loop. Walking / Running /+// WalkJump carry root translation (they move the model forward) and are+// intentionally excluded so a fixed-frame avatar can't drift out of view. The+// `speaking` boolean fires a one-shot gesture overlay (MUSE_SPEAKING_GESTURE)+// that hands control back to the base loop when it finishes.+//+// Consumed by MuseCoSAvatar's AnimationMixer (via drei useAnimations). Clip+// names are matched case-sensitively against the loaded GLB and guarded: a GLB+// missing a mapped clip falls back to MUSE_ANIMATION_FALLBACK, and a GLB with+// NO clips at all falls back to the fully-procedural rotation/glow behavior so+// static models and other variants keep working. `once: true` clamps a+// pose/transition clip (Sitting) on its final frame instead of looping it.+// The emote clips (Yes/No/Wave/Punch/ThumbsUp) start and end near a neutral+// pose, so looping them reads as a repeated, deliberate gesture (nodding,+// scanning, jabbing) rather than snapping — that's what lets us give each+// state its own body language instead of collapsing everything onto Idle. The+// read for each: sleeping = seated rest; thinking = calm contemplation (Idle);+// coding = jabbing away at the work (Punch); investigating = slow side-to-side+// scan (No); reviewing = approving nod (Yes); planning = confident "locked in"+// thumbs-up (ThumbsUp); ideating = creative celebration (Dance).+export const MUSE_STATE_ANIMATIONS = {+ sleeping: { clip: 'Sitting', timeScale: 0.8, once: true },+ thinking: { clip: 'Idle', timeScale: 0.85 },+ coding: { clip: 'Punch', timeScale: 1.1 },+ investigating: { clip: 'No', timeScale: 0.7 },+ reviewing: { clip: 'Yes', timeScale: 0.8 },+ planning: { clip: 'ThumbsUp', timeScale: 0.85 },+ ideating: { clip: 'Dance', timeScale: 1.0 },+};++// Clip used when a mapped state clip is absent from the loaded GLB.+export const MUSE_ANIMATION_FALLBACK = 'Idle';++// One-shot gesture played on the rising edge of `speaking`, then the avatar+// returns to its base state loop.+export const MUSE_SPEAKING_GESTURE = 'Wave';+// Default messages shown when no specific event message is availableexport const STATE_MESSAGES = {sleeping: "Idle - waiting for tasks...",diff --git a/data.reference/avatar/README.md b/data.reference/avatar/README.mdindex d39c73e240..ec3af938e8 100644--- a/data.reference/avatar/README.md+++ b/data.reference/avatar/README.md@@ -1,8 +1,43 @@# Bundled CoS Avatar Models-These GLB models are shipped as selectable Chief-of-Staff avatar styles.+These GLB models are shipped as selectable Chief-of-Staff avatar styles and+seeded into `data/avatar/` by `scripts/setup-data.js` (`npm run setup:data`).-## Source & License+## Default model — `model.glb`++`model.glb` is the default served at `/api/avatar/model.glb` and rendered by the+**Cyber Muse (3D)** avatar style (`client/src/components/cos/MuseCoSAvatar.jsx`).++**three.js — RobotExpressive** — https://github.com/mrdoob/three.js (`examples/models/gltf/RobotExpressive/`)+License: **Creative Commons Zero (CC0)** — public domain, free for personal,+educational, and commercial use.++It ships 14 animation clips — `Idle`, `Walking`, `Running`, `Dance`, `Death`,+`Sitting`, `Standing`, `Jump`, `Yes`, `No`, `Wave`, `Punch`, `ThumbsUp`,+`WalkJump` — plus 3 face morph targets (`Angry`, `Surprised`, `Sad`).++MuseCoSAvatar drives these clips from the CoS runtime via an `AnimationMixer`,+mapping each agent state to an **in-place** clip (see `MUSE_STATE_ANIMATIONS` in+`client/src/components/cos/constants.js`). `Walking` / `Running` / `WalkJump`+carry root translation and are intentionally left unmapped so the fixed-frame+avatar can't drift out of view. The `speaking` flag fires a one-shot `Wave`+overlay that returns to the base state loop.++| CoS state | Clip | Read |+|-----------|------|------|+| sleeping | `Sitting` | seated rest (clamped on final frame) |+| thinking | `Idle` | calm contemplation |+| coding | `Punch` | jabbing away at the work |+| investigating | `No` | slow side-to-side scan |+| reviewing | `Yes` | approving nod |+| planning | `ThumbsUp` | confident "locked in" |+| ideating | `Dance` | creative celebration |+| _speaking_ | `Wave` | one-shot gesture, then back to base loop |++A GLB with none of these clips (or no clips at all) falls back to the+procedural rotation/glow treatment, so static models still render.++## Selectable variants**Kenney Mini Characters** — https://kenney.nl/assets/mini-charactersLicense: **Creative Commons Zero (CC0)** — public domain, free for personal,diff --git a/data.reference/avatar/model.glb b/data.reference/avatar/model.glbnew file mode 100644index 0000000000..6fec9cfb4bBinary files /dev/null and b/data.reference/avatar/model.glb differ