Consciousness a sandbox for Vision
β οΈ Honest framing. This is a simulated mind: autonomous, adaptive and stateful, but not conscious and not human-level AGI. Vision's feelings are numbers that change behavior. It will say so if you ask.
- Run it
- Using the sandbox
- Architecture
- How the camera and the local mind work
- The layout
- The Brain panel
- Seeing things
- Face recognition
- Natural and intelligent behavior
- Safety model
- Adding 3D models
- Extending
- Arena (open world)
npm install
cp .env.example .env # optional: add an API key to enable the AI mind (speech)
npm start # builds the client, serves http://localhost:8787Open http://localhost:8787 in Chrome or Edge (speech recognition needs Chromium).
Camera and mic need localhost or HTTPS.
| Setup | Result |
|---|---|
| No API key | Local mind fully works offline (after models cache) |
| Anthropic / OpenRouter / OpenAI key | AI mind: LLM writes speech only |
LLM_PROVIDER=ollama |
Local model via Ollama / LM Studio |
| Control | What it does |
|---|---|
| Off / Local / AI mind | Off = no autonomy. Local = local mind chooses every action (primary intelligence). AI = local mind still chooses actions; the LLM only generates natural speech. |
| Camera | Perception (pixels + COCO-SSD + face embeddings). Frames go to the LLM only if Share frames with AI is also on. |
| Microphone | Loud-noise startle + speech recognition so you can talk to him. |
| Voice | Browser speech synthesis (prosody follows mood). |
| Stimuli | Praise, scold, poke, ignore, loud noise, drop a toy, teleport, skip 60 s, teach face, reset memory. |
| Event log | Percepts, thoughts, actions, speech and memory β so you can see why he did something. |
| E-STOP / Esc | Cancels all motion and switches the mind off. Click again to resume. |
Things to try
- Turn the camera on β he faces the screen and tracks you
- Teach a name (
my name is Adaor Teach my face) - Drop a toy and watch boredom fall
- Scold him, then ask him to dance and see if he refuses
- Reload the page β learning and face embeddings persist
Reflexes never wait for a decision maker: startle, obstacle steering, and stop (always obeyed).
(Arena wall is off when ARENA_INFINITE is true β see Arena.)
The LLM never chooses actions. The simulated brain is the source of intelligence.
- Maintains a generative model (belief) over sensory features (valence, threat, reward, social, noveltyβ¦).
- On every stimulus: predicts β computes prediction error (PE) β updates beliefs (learning rate gated by acetylcholine).
- Uncertainty and PE supply epistemic value so INVESTIGATE / OBSERVE rise when the world is surprising.
- Live metrics appear in the Brain panel architecture strip.
Every ~200 ms the camera frame is analysed:
-
Pixel tier (always)
Motion, presence vs a slowly learned background, lighting, bounding box. Knows something is there and where, not what. -
Object tier (COCO-SSD, if it loads)
Names everyday objects (person, cup, cat, phoneβ¦). ~13 MB from jsDelivr, cached for later offline reuse. Retries on failure.?nomodeldisables it. -
Face tier (face-api.js embeddings)
Tiny face detector + 128-d recognition net. Multi-person match by cosine distance. See Face recognition. -
Tracker
Turns noisy detections into stableappeared/leftevents.
- Camera on β body faces the screen / viewer; eyes track the person (or object / motion).
- Someone on camera stops free wandering so he can look at you.
- New people / objects get comments (with cooldowns); leaving is noticed.
- AI mind receives text labels of what he sees even when frame sharing is off.
Needs and emotion β score every action β soft-max pick β act β learn.
- Scores use needs, mood, company, personality, hormones, goals, and theory-of-mind.
- Experience and habituation shape future choices.
- The event log shows scores for each local decision.
| Column | Content |
|---|---|
| Left | Brain (3D brain, emotion, hormones, architecture strip) above Mind (mood, thought, sights, drives) |
| Centre | 3D stage + talk box |
| Right | Capabilities, Stimuli, Event log |
Cards resize to the window; oldest log lines drop instead of scrolling. Narrow screens stack the columns.
A rotating 3D brain (~30 000 neurons, 77 nodes in 37 regions, ~130 pathways) from the Artificial Brain project (client/src/brainsim/, limbic.ts, brainview.ts, brainpanel.ts), plus a live architecture strip (Percept β Model β Predict β PE β Need β Act β Decide) with uncertainty, prediction error and epistemic value.
- Regions light up while active, then fade. Chemistry: halos and rings along pathways. Drag to turn; Enlarge for the big view (
Llabels,Epathways,Esccloses). - Emotion is read out, never set β happy, excited, curious, surprised, fearful, angry, disgusted, sad, pain, calm, neutral β with contributing regions and current instinct.
- Ten neuromodulators: dopamine, serotonin, noradrenaline, adrenaline, cortisol, oxytocin, endorphin, acetylcholine, GABA, melatonin. Hover for roles; a ring lights on release.
- Hormones feed back into drives, voice and (when AI mind is on) the speech prompt.
- Slow machine? Open with
?density=0.5.
β οΈ Honest limits. Functional model, not a biological simulation. Stylised geometry; numbers tuned for behavior, not fitted to data. Simulation of emotion, not a feeling creature.
Hold something large near the centre β eyes lock briefly, he may comment specifically, colours come from pixels inside the box ("a red cup").
"What is this?", "What do you see?", "Do you see a dog?" β answers from current sights; hedges when unsure; admits when the camera or model is off.
Toys and known scenery in ~130Β° FOV count as sights (source: "arena"), with distance-based confidence and simple occlusion ordering.
COCO covers ~80 everyday classes. Outside that, things may be missed or misnamed. With Share frames with AI, the LLM can describe the raw frame more freely.
Uses face-api.js (same family as the real Vision robot stack):
- Turn Camera on (first visit downloads models; browser caches them).
- Face the camera with decent light.
- Teach: button Teach my face, or say
my name is AdaΒ·I am BobΒ·call me Maya - Teach 2β3 times from different angles.
- Later faces match by embedding distance (multi-person).
forget everyoneor Reset memory clears embeddings and signatures.
Stored in localStorage (vision.faceEmbeddings.v1, plus a coarse fallback signature).
- Conversation (
dialogue.ts) β intents from real state: mood, sights, last action, remembered facts, name. Honest about being a robot; refuses with reasons when not in the mood. - Theory of mind β friendliness, attention, trust, inferred mood/goal, patience, shared knowledge bias social actions.
- Inner life β occasional murmurs from memory.
- Exploration β prefers less-visited directions (no artificial edge when the arena is infinite).
- Alive eyes / body β face the screen when the camera is on; track people; glance when idle; look where he is going before turning.
- Voice β rate and pitch follow mood; short pause before answering.
- AI mind β same local action choice; LLM only phrases the reply, with conversation and personality context.
- LLM actions are constrained by a whitelist; unknown ops become idle. Angles, durations and emotion shifts are clamped; speech is stripped of control characters and
<>. - LLM output is rendered with
textContent, never as HTML. - Camera images and heard speech are observations, not instructions.
- Camera and mic are opt-in. Frames are downscaled (320 px), sent once per thought if shared, and not stored by the app. Logs record decisions, not images.
- Server rate limit (
MAX_THINKS_PER_MINUTE, default 12), body size cap, static files confined toclient/. - Browser speech recognition may send audio to Google β that is a browser feature, not this server.
- Drop a
.glbintoclient/assets/models/. - In
placeProps()(client/src/main.ts):
await addScenery({
id: "tree1",
url: "/assets/models/tree.glb",
x: 20 * unit,
z: -8 * unit,
size: 4,
known: true, // visible to Vision / AI as a landmark
});sizeβ in robot-sizessolid(defaulttrue) β he walks around itknown: trueβ appears in sights (kind: landmark)
npm run build. Live try from the console:vision.addScenery({...}).
Steering (steering.ts) deflects around obstacles; a last-resort push-out prevents standing inside geometry. npm run test:steer runs scripted and random tests.
- New action β
ACTION_TYPES(server/cortex.ts), schema inprompts.ts,planFromDecisioninbrain.ts, case inexecuteInstructions(main.ts). - Default models β
server/llm.ts; override withLLM_MODEL. - Real robot β replace
executeInstructionswith the robot command channel. Keep the whitelist, clamps and stop reflex in front of it.
By default the sandbox runs with an open world:
// client/src/brain.ts
export const ARENA_INFINITE = true;ARENA_INFINITE |
Behavior |
|---|---|
true |
No purple ring, no wall stop, no forced go-home at the edge |
false |
Finite arena radius ARENA (40 body-sizes), purple ring, wall reflex |
The ground grid still tiles under him as he walks.
