How letsgettoworkbro/dreamlayer works
Purpose and runtime topology
DreamLayer is a privacy-first ambient-memory stack for Halo smart glasses. It spans four primary runtimes: Lua on glasses, Python for the phone hub/Mac-or-Windows Brain, React Native on phone, and Rust for portable figment interpretation. The default processing path stays local; LAN Brain and cloud model use are optional.
Entry points and user surfaces
Primary executable paths are the Python package/CLI and Brain server: host-python/src/dreamlayer/__main__.py, host-python/src/dreamlayer/main.py, and host-python/src/dreamlayer/ai_brain/server/__main__.py. The simulator is separately runnable through host-python/src/dreamlayer/simulator/__main__.py. Mobile starts in Expo Router at phone-app/app/_layout.tsx; the on-glasses entry is halo-lua/main.lua. Browser-facing product surfaces are static landing/index.html and Vite web/src/main.ts.
Device, bridge, and HUD boundary
The glasses are a constrained display/sensor client: Lua maintains session/state, BLE protocol, capture hooks, and card rendering. Python bridges either real hardware, emulator, or Lua raster execution, isolating device transport from product logic.
• halo-lua/app/state_machine.lua
• halo-lua/ble/protocol.lua
• halo-lua/display/renderer.lua
• host-python/src/dreamlayer/bridge/real_bridge.py
• host-python/src/dreamlayer/bridge/emulator_bridge.py
Orchestration, perception, and response loop
The orchestrator coordinates capture, attention, voice, commands, confidence, budgets, provenance, and output cards. Pipelines provide camera/audio ingestion, speech, vision, and LLM adaptation. Inputs are veil-gated, interpreted into lens actions or queries, enriched with recall/context, then emitted to HUD/phone/Brain surfaces.
• host-python/src/dreamlayer/orchestrator/orchestrator.py
• host-python/src/dreamlayer/orchestrator/capture.py
• host-python/src/dreamlayer/orchestrator/voice.py
• host-python/src/dreamlayer/pipelines/ingest.py
• host-python/src/dreamlayer/pipelines/vision.py
Local memory and privacy spine
Memory persists structured, recallable meaning rather than raw recordings. The subsystem combines relational storage, embeddings/vector backends, retrieval, retention, PII handling, and proactive recall. Privacy/provenance controls are cross-cutting boundaries for capture, egress, plugins, and erase flows.
• host-python/src/dreamlayer/memory/db.py
• host-python/src/dreamlayer/memory/vector_store.py
• host-python/src/dreamlayer/memory/retrieval.py
• host-python/src/dreamlayer/memory/privacy.py
• host-python/src/dreamlayer/orchestrator/provenance.py
Brain service and intelligence tiers
The AI Brain is a local control-panel/API service with selectable local, LAN, and opt-in cloud backends. It integrates indexed desktop sources and model providers while server code owns authentication, TLS, state, and live endpoints. Cloud is an external boundary; model providers include local MLX/Gemma/Ollama-style routes and LiteLLM-backed remote providers.
• host-python/src/dreamlayer/ai_brain/server/server.py
• host-python/src/dreamlayer/ai_brain/server_fastapi.py
• host-python/src/dreamlayer/ai_brain/router.py
• host-python/src/dreamlayer/ai_brain/cloud.py
• host-python/src/dreamlayer/ai_brain/perception.py
Extensibility: plugins and Reality Compiler
Third-party Python plugins pass validation, signing/trust, egress controls, and isolation through subprocess/OS/WASM hosts. Separately, the Reality Compiler converts intent into signed declarative “figments,” constrained by capabilities and safety contracts, then deploys them to fixed interpreters. Interpreter parity spans Python, Lua, browser JS, and Rust/WASM.
• host-python/src/dreamlayer/plugins/isolation.py
• host-python/src/dreamlayer/plugins/wasm_component_host.py
• host-python/src/dreamlayer/reality_compiler/v2/compiler.py
• host-python/src/dreamlayer/reality_compiler/v2/safety.py
• reality-core/src/lib.rs
Distribution, coordination, and external infrastructure
The phone app is the pairing/control hub, using BLE and local state stores to control glasses and Brain. The plugin registry is git-backed metadata; a Cloudflare Worker provides catalog search, ratings, and Figment Golf-like community APIs without shipping code. Releases build macOS and Windows desktop packages; phone builds target iOS/Android.
• phone-app/src/ble/bridge.ts
• phone-app/src/services/pairing.ts
• phone-app/src/state/useConnectionStore.ts
• registry-api/worker.js
• host-python/packaging/setup_app.py
Main entry points: orchestrator.py Orchestrator · ingest.py Capture ingestion · retrieval.py Recall retrieval · main.lua Halo Lua app
Components 22
Glasses Runtime
Lua device client and HUD.
- Halo Lua app · Runs the glasses session, capture hooks, and HUD.
halo-lua/main.lua - Session state machine
halo-lua/app/state_machine.lua - BLE protocol
halo-lua/ble/protocol.lua - HUD renderer
halo-lua/display/renderer.lua
Host Runtime
Python hub, orchestration, and perception.
- Host CLI · Starts the local hub runtime.
host-python/src/dreamlayer/main.py - Device bridge · Isolates real hardware and emulator transports.
host-python/src/dreamlayer/bridge/real_bridge.py - Orchestrator · Coordinates capture, attention, budgets, actions, and output cards.
host-python/src/dreamlayer/orchestrator/orchestrator.py - Capture ingestion · Ingests camera and audio inputs.
host-python/src/dreamlayer/pipelines/ingest.py - Vision pipeline
host-python/src/dreamlayer/pipelines/vision.py
Memory & Privacy
Local durable meaning and policy controls.
- Memory store · Persists structured recallable meaning rather than raw recordings.
host-python/src/dreamlayer/memory/db.py - Vector store
host-python/src/dreamlayer/memory/vector_store.py - Recall retrieval · Enriches actions and queries with local context.
host-python/src/dreamlayer/memory/retrieval.py - Privacy & provenance · Gates capture, egress, retention, and erase flows.
host-python/src/dreamlayer/memory/privacy.py
AI Brain
Local API and selectable intelligence backends.
- Brain API server · Control panel and authenticated live API.
host-python/src/dreamlayer/ai_brain/server/server.py - Model router · Selects local, LAN, or opt-in cloud providers.
host-python/src/dreamlayer/ai_brain/router.py - Cloud model providers · Optional remote models via LiteLLM-backed providers.
Figments & Plugins
Safe extensibility across interpreters.
- Plugin isolation · Validates and isolates third-party plugin execution.
host-python/src/dreamlayer/plugins/isolation.py - Reality Compiler · Compiles intent into signed declarative figments.
host-python/src/dreamlayer/reality_compiler/v2/compiler.py - Figment safety · Enforces capabilities and safety contracts.
host-python/src/dreamlayer/reality_compiler/v2/safety.py - Portable figment runtime · Provides portable interpreter parity.
reality-core/src/lib.rs
Phone & Web
Pairing hub and browser-facing surfaces.
- Phone pairing hub · Controls glasses and Brain through BLE and local state.
phone-app/app/_layout.tsx - Plugin registry API · Serves catalog, ratings, and community APIs without shipping code.
registry-api/worker.js
Connections 27
- Halo Lua app → Session state machine: maintains session
- Halo Lua app → BLE protocol: communicates over
- Session state machine → HUD renderer: drives cards
- BLE protocol → Device bridge: BLE transport
- Host CLI → Orchestrator: starts
- Device bridge → Orchestrator: device events
- Orchestrator → Capture ingestion: requests capture
- Capture ingestion → Vision pipeline: image inputs
- Capture ingestion → Privacy & provenance: veil-gated by
- Vision pipeline → Orchestrator: perception results
- Orchestrator → Recall retrieval: recalls context
- Recall retrieval → Memory store: reads meaning
- Recall retrieval → Vector store: semantic search
- Orchestrator → Memory store: persists events
- Privacy & provenance → Memory store: retention policy
- Orchestrator → Brain API server: queries intelligence
- Brain API server → Model router: routes requests
- Model router → Cloud model providers: opt-in egress
- Orchestrator → Device bridge: HUD output
- Phone pairing hub → BLE protocol: pairs and controls
- Phone pairing hub → Brain API server: local control
- Orchestrator → Plugin isolation: runs extensions
- Plugin isolation → Privacy & provenance: egress controls
- Reality Compiler → Figment safety: checks contracts
- Figment safety → Portable figment runtime: deploys approved figments
- Portable figment runtime → Halo Lua app: portable interpretation
- Plugin registry API → Plugin isolation: catalog metadata