Skip to main content

Dan-EL

Research, not an audit
These pages are research and development and may not match the live app. Do not treat this as an audit. Shared for testing and demo only. Please use responsibly.

Glitr can run a small language model and text-to-image models on the device. After the weights are downloaded, chat turns and image prompts stay in-process — they are not sent to a remote LLM API. Dan-EL is not part of the git mailbox, the recipient crypto cascade, or the live WebRTC path.

Beyond free-form chat, the product hosts an in-app agent: it retrieves Glitr docs (BM25 over a published index), proposes allowlisted UI actions for confirmation, and can run guided journeys (pair with a peer, attach a remote, load a model, and similar). The user how-to is In-app Dan-EL assistant. Chrome details are on UI/UX.

This page is the ai sibling library and how whatsup hosts it. Session, poll, and send stay on Network. How the shell sits on the rest of the stack is the Architecture product map.

The product path is closed-source. The ai gallery is the public surface you can press: positive-intentions.github.io/ai.

Product wiring​

whatsup links the engines as path Cargo crates from the sibling ai repo:

TargetCrateWhen
Browser (wasm)ai-webAlways for wasm32
Desktop GUIai-coreCargo feature desktop

whatsup-ui has no dependency on ai. It owns the Dan-EL chrome and domain scaffolding (ChatKind::LocalAi, synthetic contact ids, load/manage dialogs, markdown assistant bubbles, floating assistant popover, guide/nudge cards). whatsup is the host that calls into ai-web or ai-core, runs the agent/guide loop, and pushes tokens or image data URLs into AppState.

Host moduleRole
ai_gui.rsBrowser: WebLLM chat + ORT image over WebGPU; assistant popover; agent turns
ai_native.rsDesktop: Candle GGUF chat + Candle Stable Diffusion; assistant popover; agent turns
agent_host.rsSnapshot, BM25 retrieve, parse reply, execute confirmed actions
guide_host.rsGuideFacts, GuideRunner, journey auto-ops, nudge prefs
gui.rsprovide_ai_ctx(), GuideCtx, route /ai, speed dial, overlays

The Dan-EL thread uses fixed ids (AI_CHAT_ID, AI_CONTACT_ID). It is shared by the full-bleed /ai route and the top-right floating assistant. It is hidden from the main chat list, excluded from mailbox snapshots, and skipped on the TUI live-send path. Image prompts are detected with parse_image_intent (/image …, “draw me …”, and similar phrases); the host unloads chat VRAM when needed, runs the image session, and attaches a PNG data URL in the thread.

Platform availability: desktop and browser GUI builds (including the agent and guided journeys). Mobile-without-desktop and TUI show a stub (“available in desktop and browser builds”). UI details: UI/UX.

Inference after load is local. First-time model download still uses the network (Hugging Face, MLC, CDNs). Refreshing the docs index uses https://glitr.io/ai-index.json. That is not the same as a cloud assistant.

In-app agent​

Each user turn in the Dan-EL thread is an agent turn, not a bare completion against an empty system prompt.

  1. Snapshot — AppContextSnapshot from live app state (route, platform, connection/Tor status, loaded model, contacts/chats summaries, recent messages from an open thread). The host decides how much to include; the product path includes message text for guidance.
  2. Retrieve — BM25 over the resolved docs index (fetched ai-index.json merged with a built-in app map). Prefer user-audience chunks for ordinary questions.
  3. Budget — TurnBudget / build_turn (or build_turn_with_guide when a journey is active) packs base system prompt, action protocol, optional active-guide block, context, docs snippets, and trimmed history into the model window.
  4. Generate — WebLLM or Candle streams the assistant reply into AI_CHAT_ID.
  5. Parse — strip <action>{json}</action> tags; resolve [n] citations against this turn’s hits; attach PendingAction cards that require Confirm before the host runs anything.
  6. Keyword fallback — if the model emits no action, suggest_journey may still offer a start_journey confirm from the user’s wording.

Allowlisted action types include navigate, open_doc, set_theme, clear_ai_chat, open_model_picker, check_for_updates, start_journey, stop_journey, and open_chat. Unknown types are ignored.

Docs index (BM25)​

The public site builds ai-index.json (and llms.txt) in a Docusaurus postBuild plugin under glitr-website/plugins/ai-index. It walks docs/ and blog/, strips MDX chrome, and chunks at ## / ### headings. Audience is user, technical, or blog from the path.

ConcernBehavior
URLhttps://glitr.io/ai-index.json (CORS headers from the site CDN stack)
Browser cacheCache Storage via ai-web index store
Native cacheDisk cache via ai-core DiskIndexStore
OfflineIf fetch fails, fall back to the built-in app map only
App mapHand-written route/settings chunks in ai-core agent/app_map.rs (always merged when an index loads)

Deterministic guided steps do not need BM25 (next_step reads GuideFacts). BM25 matters for free-text Q&A and for citing docs while a journey is active.

Guided journeys​

Journeys are a hybrid design: a pure state machine in ai-core (agent/guide.rs) picks the next step from live facts; the LLM explains the step and may propose start_journey. After one confirmation (action card or nudge “Guide me”), the host runs auto_ops until the journey is done or the user stops. Typing codes, credentials, and sending messages stay with the user (awaiting_user); the assistant popover opens when the user must act.

IdTitlePrimary docRough machine
pair_livePair with a peerTalk nowNavigate/open Add contact (Pair) → mint invite → share/paste (awaiting_user) → connecting → live
git_contactAdd a git contactAdd a contactOpen Add contact (Git) → fill URL (awaiting_user) → done when a peer contact exists
connect_remoteConnect a mailbox remoteConnect repositoryNavigate Settings → Sync → attach remote (awaiting_user)
first_messageSend your first messageFirst conversationNeed a peer → open their chat → compose/send (awaiting_user)
pair_devicePair another deviceAnother deviceNavigate Devices → show/scan code (awaiting_user)
troubleshootTroubleshoot connectionTroubleshootingDecision tree: no mailbox → Tor fail → pair failed → pending peer → delivery fail → stall
ai_setupSet up Dan-ELInstallOpen Dan-EL / model picker → wait until a model is loaded

Proactive nudges (first run, pairing stalled/failed, peer offline, failed delivery, AI open with no model) show as badge/cards on the floating assistant. Dismissed nudge ids and onboarding_done persist under glitr:guide.

GuideOp values the host can auto-run: Navigate, OpenAddContact, StartPairInvite, OpenChat, OpenDevicePair, OpenAttachRemote, OpenModelPicker, Highlight (coach mark / data-guide anchor), OpenDoc.

Module map​

AreaFiles
ai-core agentagent/{mod,guide,actions,turn,bm25,index,store,app_map,prompt,context,disk_index}.rs
whatsup hostagent_host.rs, guide_host.rs, ai_gui.rs, ai_native.rs, gui.rs (GuideCtx, ClientCtx)
whatsup-ui chromeAssistantButton, AssistantPopover, GuideStepCard, JourneyStartChips, NudgeCard, CoachMark, ActionConfirmCard, DocCitationChip; AppState.assistant
glitr-websiteplugins/ai-index → ai-index.json / llms.txt

ai-core​

ai-core is the shared Rust core: curated catalogs, SHA-256-pinned fetch, chat templates, streaming AiSession, parallel ImageSession, and pluggable engines.

ConcernBehavior
CatalogStatic ModelSpec list; list, get, list_for(Platform), default_web
FetchHttpFetcher pulls Hub resolve/main URLs; progress callbacks
IntegritySHA-256 verify before cache write; mismatch → remove + error
CacheDiskCache::user_cache() under the OS project dir for com.positive-intentions.ai (for example ~/.cache/positive-intentions/ai)
Chatpull / load / generate_user / next_token / cancel_generation / history reset
ImageImageSession + parse_image_intent; engines produce PNG bytes
EnginesCandleEngine / CandleImageEngine (feature candle); MockEngine / MockImageEngine for tests and --no-default-features

Candle is not llama.cpp. Only curated GGUF arches ship in the catalog; arbitrary Hub GGUF files are unsupported. Optional native GPU features (cuda, metal) exist; CI stays on CPU/mock.

ai-web​

ai-web is the browser product path. It does not run Candle in WASM for production chat.

SurfaceStack
ChatWebLLM (@mlc-ai/web-llm@0.2.79 vendored same-origin under assets/vendor/web-llm/), preferably a Worker engine; MLC prebuilt catalog (separate ids from native GGUF)
ImageORT-Web WebGPU pipelines (sd_pipeline.js) for SD 1.5 / SDXL-Lightning ONNX packs
PromptEngine-side Glitr system prompt (system_prompt_for); not shown in the UI
CacheBrowser Cache Storage for weights; last model id in localStorage

WebGPU is required for load. Browser image generation also requires shader-f16. Without an adapter or f16 support, load fails fast instead of hanging. Ubuntu + NVIDIA often needs Chrome launched with Vulkan ANGLE flags so requestAdapter() succeeds; the ai README documents npm run chrome:webgpu.

The host unloads WebLLM before starting an ORT image session so the two do not fight over the same GPU.

Catalogs​

Hosts must pick the catalog that matches the surface. Native Candle uses GGUF ids. Browser WebLLM uses MLC ids. Image ids are shared by name across native and browser, with different backends underneath.

Native chat (Candle GGUF)​

IdApprox. sizeNotes
tinyllama-stories-15m~19 MBTiny; web-default helper for mock/CLI
smollm2-135m~105 MBInstruct
qwen3-0.6b-q4~380 MBQwen3
smollm2-1.7b~1.06 GBNative
qwen25-1.5b-q4~1.12 GBNative
qwen25-3b-q4~2.1 GBNative
smollm3-3b-q4~1.92 GBNative; not in WebLLM

Browser chat (WebLLM / MLC)​

IdNotes
SmolLM2-135M-Instruct-q0f32-MLCWeb default (f32; no shader-f16 required for this entry)
Qwen2.5-0.5B-Instruct-q4f32_1-MLCLarger
Llama-3.2-1B-Instruct-q4f32_1-MLC~900 MB
Qwen2.5-1.5B-Instruct-q4f32_1-MLC~1.1 GB; desktop GPU
SmolLM2-1.7B-Instruct-q4f32_1-MLC~1.3 GB; high VRAM
Qwen2.5-3B-Instruct-q4f32_1-MLC~1.9 GB; high VRAM

Image (OpenRAIL-oriented catalog)​

| Id | License | Approx. download | Notes | | --- | --- | --- | | sd15 | OpenRAIL-M | ~2 GB | Default. Native: Candle SD 1.5. Browser: Microsoft ONNX via ORT-Web | | sdxl-lightning | OpenRAIL++-M | ~7 GB native / multi-GB ONNX | High VRAM. Browser: 4-step ONNX. Native uses SDXL-base weights with Lightning-oriented defaults |

Turbo / FLUX [dev] / revenue-capped community packs are excluded on purpose so the closed product path stays on commercial-safer OpenRAIL entries. Hub and MLC model licenses are separate from the library license; they are not part of the AGPL grant on the ai code.

PieceRole
ai-climodels, pull, chat, complete, image over Candle or mock
ai-wasm (root crate)wasm-bindgen + AiWasmClient JS helper; mock engine only — caller supplies GGUF bytes; not the production browser chat path
ai-gallerySeparate Dioxus workspace using whatsup-ui chrome: Local chat, Local image, Benchmark (GUI + TUI)

Open the Dan-EL gallery

Gallery e2e (Playwright) builds with the mock engine so CI never downloads Hub or MLC weights. The Pages build uses WebLLM; models download in the browser on first use.

The office gallery can also dock these engines beside document stories (skills + office::tools). That is a gallery host path, separate from the product Dan-EL route at /ai. See Office (editors) and Drive.

Privacy and network​

ClaimMeaning
On-device inferenceAfter weights load, generation runs in the browser or desktop process — not a remote LLM API
App context for the agentEach agent turn may include route, contacts/chats summaries, and recent message text from an open thread so the assistant can guide you. That data stays in-process; it is not uploaded to an LLM provider
Not mailbox cryptoPrompts are not cascaded to a peer; the AI thread is not a contact you sync with
Not syncedMailbox snapshots omit the Dan-EL thread; it is reattached in-session only
Network still usedFirst download of weights/engine from Hub, MLC, or CDNs; docs index refresh from glitr.io; “local” ≠ offline-by-default
ResidualLarge Cache Storage / disk caches (weights + optional ai-index.json) stay on the device; clearing models is a product UI action; guide prefs use glitr:guide

The system prompt still forbids inventing APIs or claiming cloud storage of chats. It no longer claims the model can only see the Dan-EL thread: the host injects a Context block each turn. That is product framing for the model, not a sandbox proof against a compromised device. Device-store notes: Devices and storage.

Runtime and limits​

  • Browser: Chromium-class browser with a WebGPU adapter; image path needs shader-f16.
  • Desktop: RAM/VRAM for chosen GGUF or SD weights; GPU strongly preferred for image.
  • Dual catalogs: do not assume a GGUF id works in WebLLM or the reverse.
  • Root WASM: mock-only; production browser chat is ai-web + WebLLM.
  • License: ai code is AGPL-3.0-only; third-party crates and downloaded models keep their own licenses. A commercial license for proprietary use of the code is offered separately and does not change the public AGPL grant.

Tests​

LayerWhat
ai-coreUnit tests; CI gates 100% line coverage with and without Candle
ai-cliassert_cmd integration on the mock engine
ai-wasmwasm-pack test --node on the mock façade
ai-webCatalog / system-prompt / image-catalog unit tests
e2ePlaywright against the mock gallery build (UI smoke; no real model download)

User how-to: In-app Dan-EL assistant. How the shell mounts Dan-EL chrome is on UI/UX. Next: Data structures for mailbox record shapes.