iblai-vibe-local-llm
Skill15 starsChanged 2 months agoMITView on GitHub
Use when adding on-device LLM inference (Ollama backend) to a vibe Next.js + Tauri app. Documents the contract a vibe app must implement so the SDK can route chat through a local model via `localLLMProps` — the Tauri command names, event names, and the React hook shape. Mention before wiring "offline AI", "local model", "on-device LLM", or "Ollama" support into a desktop build.
- Pipes a download into a shell
In this repository158 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- iblai-vibe-pr-reviewSkill
- iblai-api-agent-accessSkill
- iblai-api-agent-auditSkill
- iblai-api-agent-chatSkill
- iblai-api-agent-createSkill
- iblai-api-agent-datasetSkill
- iblai-api-agent-disclaimerSkill
- iblai-api-agent-embedSkill
- iblai-api-agent-evalSkill
- iblai-api-agent-historySkill
- iblai-api-agent-llmSkill
- iblai-api-agent-mcpSkill
- iblai-api-agent-memorySkill
- iblai-api-agent-privacySkill
- iblai-api-agent-promptSkill
- iblai-api-agent-safetySkill
- iblai-api-agent-sandboxSkill
- iblai-api-agent-sessionSkill
- iblai-api-agent-settingSkill
- iblai-api-agent-skillSkill
- iblai-api-agent-supportSkill
- iblai-api-agent-toolSkill
- iblai-api-inferenceSkill
- iblai-api-searchSkill
- iblai-vibe-agent-accessSkill
- iblai-vibe-agent-apiSkill
- iblai-vibe-agent-auditSkill
- iblai-vibe-agent-billingSkill
- iblai-vibe-agent-chat-sidebarSkill
- iblai-vibe-agent-chatSkill
- iblai-vibe-agent-createSkill
- iblai-vibe-agent-datasetSkill
- iblai-vibe-agent-disclaimerSkill
- iblai-vibe-agent-embedSkill
- iblai-vibe-agent-evalsSkill
- iblai-vibe-agent-graderSkill
- iblai-vibe-agent-historySkill
- iblai-vibe-agent-llmSkill
- iblai-vibe-agent-ltiSkill
- iblai-vibe-agent-mcpSkill
- iblai-vibe-agent-memorySkill
- iblai-vibe-agent-privacySkill
- iblai-vibe-agent-promptSkill
- iblai-vibe-agent-safetySkill
- iblai-vibe-agent-sandboxSkill
- iblai-vibe-agent-searchSkill
- iblai-vibe-agent-settingSkill
- iblai-vibe-agentSkill
- iblai-vibe-agent-skillsSkill
- iblai-vibe-agent-supportSkill
- iblai-vibe-agent-taskSkill
- iblai-vibe-agent-toolSkill
- iblai-vibe-agent-virtual-machineSkill
- iblai-vibe-agent-voiceSkill
- iblai-vibe-os-agent-code-modeSkill
- iblai-vibe-projectSkill
- iblai-vibe-workflowSkill
- iblai-api-analyticsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 148
If you do hand-roll the hook, it must:
- Very specific: line 185
When isAvailable is false (a normal browser tab), the props degrade to no-ops and the SDK uses the hosted backend.
- Very specific: line 210
Warn before downloading a model too big for the machine: Call get_system_memory → { ram_total, vram_total } (bytes) and size the model …
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
/iblai-vibe-local-llm
A vibe Next.js + Tauri app can serve chat from a model running on the
user's machine instead of the hosted backend. The SDK turns this on
automatically when you pass a localLLMProps object whose
isAvailable is true and whose ollamaStatus.model_installed (or
foundryStatus.has_models) reports a ready model.
This skill defines the contract your app must implement to feed that prop:
- the Tauri
#[command]names the React layer calls, - the Tauri event names the React layer listens on,
- the shape the React hook must return,
and points to references describing the install-flow, the on-disk layout, and the failure modes you'll hit.
It does not ship a reference implementation — local-LLM support is closed-source in the apps that have it today.
Do NOT add custom styles / colors to ibl.ai SDK components. They ship with their own styling. See BRAND.md for the brand palette.
Common setup (env, conventions, verification): see docs/skill-setup.md.
Prerequisites
- Tauri shell wired up via
/iblai-vibe-ops-build(addssrc-tauri/+pnpm install). The skill assumessrc-tauri/already exists. Heads-up: on an app that already has a non-trivialnext.config.mjs, adding the Tauri shell can mis-merge itsoutput: 'export'/images/allowedDevOriginsinjection (it has landed those inside the wrong object, e.g. an SSR polyfill, leaving them as dead code).git diff next.config.mjsright after running it. - Rust toolchain via rustup, plus the Tauri
system libraries for your OS (Linux:
libwebkit2gtk-4.1-dev,libdbus-1-dev,libsoup-3.0-dev, …). These build before your crate, so a missing one (e.g.libdbus-syspanicking) masks your own compile errors entirely. - ibl.ai providers in place (
/iblai-vibe-auth) — the SDK looks forlocalLLMPropson its account/profile dropdown surfaces (UserProfileDropdown/UserProfileModal), not onAccount/Chat.
The contract
1 — Tauri command + event names
Drop assets/nextjs/types/tauri.ts into
your project at types/tauri.ts. It exports:
TAURI_COMMANDS— every#[tauri::command]name your Rust side must register (install_ollama,get_system_memory,download_model,ollama_chat_stream, …)TAURI_EVENTS— everyapp.emit(...)name your Rust side must use (model:download-progress,model:installation-log, …)OllamaStatus,DownloadProgress,InstallationLog,DiskSpaceError,FoundryStatus— the payload types each command / event must conform toisTauriApp()— synchronous check for__TAURI_INTERNALS__onwindow
These are the only assets the skill ships — they're public-API constants and TypeScript interfaces, not implementation.
2 — Rust commands to implement
Your src-tauri/src/ needs #[tauri::command] async functions
matching the names in TAURI_COMMANDS and the signatures in
references/tauri-commands.md. At
minimum (Ollama path):
install_ollama -> Result<String, String>
stop_ollama -> Result<(), String> (onStopManager / toggle off)
check_ollama_status -> Result<OllamaStatus, String>
check_disk_space_for_model -> Result<bool, String> (emits disk-space-error)
get_system_memory -> SystemMemory (sync; RAM via sysinfo, VRAM via nvidia-smi)
download_model(model_id) -> Result<(), String> (emits download-progress)
cancel_model_download -> Result<(), String>
check_network_status -> Result<bool, String>
get_os_type -> String
ollama_chat -> Result<String, String>
ollama_chat_stream -> Result<(), String> (emits ollama:chunk/done/error)download_model takes the Ollama tag as an argument (the SDK's Local-LLM
tab owns the catalog and passes the chosen id) — it is not the old
hardcoded download_phi3_model. get_system_memory is a synchronous
probe used to warn before pulling a model too big for the host.
Wire them into .invoke_handler(tauri::generate_handler![...]). Add
the Cargo deps listed in
references/cargo-deps.toml.
3 — React hook shape
localLLMProps is read by the SDK's account/profile dropdown
surfaces (see "Use it"). Grep your installed @iblai/web-containers
.d.ts for localLLMProps and match its exact shape — it is the
ground truth, and it differs from earlier drafts of this skill. As of
@iblai/web-containers 1.8.x the shape is:
{
isAvailable: boolean // isTauriApp() && commands registered
state: ModelDownloadState // status/progress/message/logs/lastUpdated
ollamaStatus: OllamaStatus | null
systemMemory?: SystemMemory | null // { ram_total, vram_total } from get_system_memory
isUsingFoundry?: boolean // Windows NPU path
foundryStatus?: FoundryStatus | null
foundryModels?: FoundryModel[]
selectedFoundryModel?: string | null
onStartDownload: (modelId?: string) => void // install (if needed) + pull that tag
onCancelDownload: () => void
onInstallOllama: () => void
onStopManager?: () => void // stop_ollama — fired when the toggle goes off
onInstallFoundry?: () => void
onCheckStatus: () => void
onResetState: () => void
onSelectFoundryModel?: (modelId: string) => void
}Note the callbacks are on*-prefixed and return void (they fire
the invoke internally — don't return the promise). onStartDownload
now takes an optional modelId — the tab passes the catalog entry the
user picked, and the SDK forwards it to download_model.
The SDK ships the hook. @iblai/web-containers exports
useModelDownload(), which already does the work below and returns
{ isAvailable, state, ollamaStatus, systemMemory, startDownload(modelId?),
cancelDownload, installOllama, stopManager, checkStatus, resetState, … }.
Wire its output into localLLMProps (renaming to the on* callbacks)
rather than re-implementing — that's how the shipped desktop app does it.
If you do hand-roll the hook, it must:
invoke(TAURI_COMMANDS.CHECK_OLLAMA_STATUS)on mount, after an opportunisticCHECK_FOUNDRY_STATUSthat silently falls back when the Foundry commands aren't registered (theinvokejust rejects),invoke(TAURI_COMMANDS.GET_SYSTEM_MEMORY)once on mount and keepsystemMemoryso a Download click can be pre-flighted against host capacity (see "Field notes"),listenon everymodel:*event to drivestate,- persist
statetolocalStorage.model_download_stateso progress survives reload — hydrate it in an effect, not the initialuseState, or you'll get an SSR hydration mismatch.
onStartDownload(modelId) calls install_ollama (if not installed) then
download_model(modelId); onCancelDownload calls
cancel_model_download; onStopManager calls stop_ollama.
Use it
Pass the hook output to whichever surface accepts localLLMProps in
your installed SDK. As of @iblai/web-containers 1.7.x that is
UserProfileDropdown / UserProfileModal (the "Local LLM" account tab)
— not Account or Chat. Confirm with
grep -rn localLLMProps node_modules/@iblai/web-containers/dist/**/*.d.ts
before wiring; the earlier <Account localLLMProps> example was wrong
for shipped SDKs.
"use client";
import { useLocalLLM } from "@/hooks/use-local-llm";
import { UserProfileDropdown } from "@iblai/iblai-js/web-containers/next";
export function AccountMenu(props) {
const localLLMProps = useLocalLLM();
return <UserProfileDropdown {...props} localLLMProps={localLLMProps} />;
}When isAvailable is false (a normal browser tab), the props degrade
to no-ops and the SDK uses the hosted backend.
Chat routing is automatic — <Chat> does not take localLLMProps.
Once isAvailable && (ollamaStatus.model_installed ||
foundryStatus.has_models), the SDK invokes the registered
ollama_chat_stream command and listens on ollama:chunk /
ollama:done / ollama:error on its own. Your only job for chat is to
register the Tauri commands with the exact names/events from
types/tauri.ts — no per-surface wiring.
Backend choice
| Backend | Recommended for | Default model |
| Ollama | Cross-platform default — macOS, Linux, Windows x64 | Phi-3 Mini (~2 GB) |
| Foundry Local | Windows ARM / Copilot+ PCs with NPU | qwen2.5-0.5b (~1 GB) |
The hook should call check_foundry_status first and fall back to
Ollama when it rejects or returns is_supported: false. See
references/foundry-status.md for
the Foundry-specific command names and lifecycle.
Field notes (from a production integration)
Warn before downloading a model too big for the machine. Call
get_system_memory→{ ram_total, vram_total }(bytes) and size the model againstusable = max(ram_total, vram_total).vram_totalcomes fromnvidia-smiand is0on integrated graphics, Apple unified memory, and AMD/Intel GPUs — so thresholding on VRAM alone wrongly flags every Mac; always fall back to RAM via themax. Parse the catalog's human size ("2.2 GB"→ bytes) and, when it exceedsusable * FRACTION, show a confirm dialog instead of pulling:const usableMemoryBytes = (m?: SystemMemory | null) => m ? Math.max(m.ram_total, m.vram_total) : 0; // VRAM 0 ⇒ use RAM const modelExceedsCapacity = (model, m) => { const bytes = parseModelSizeBytes(model.size); // "2.2 GB" → number if (bytes == null) return false; // unknown size ⇒ don't warn return bytes > usableMemoryBytes(m) * MODEL_SIZE_WARN_FRACTION; };MODEL_SIZE_WARN_FRACTIONis the share of usable memory a model may occupy before the warning trips (a realistic ceiling is ~0.5–0.8; the shipped tab ships a deliberately tiny test value so the dialog is easy to trigger — set it sanely before release). Gotcha: read memory before any catalog-lookup / early-return guard, or theinvokesilently never fires — see troubleshooting "A command never runs".- Server-rendered apps can't use the default static export. The
Tauri shell defaults to
frontendDist: "../out"(anext buildstatic export). An app with runtime-dynamic routes (e.g./x/[id]/[[...slug]]) and nogenerateStaticParamscannot be exported —output: 'export'hard-errors with "missing generateStaticParams()". Keepoutput: 'standalone'and point Tauri dev at the live Next server instead, intauri.conf.json:"build": { "beforeDevCommand": "pnpm dev", "devUrl": "http://localhost:3000", "beforeBuildCommand": "pnpm build", "frontendDist": "../out" }tauri devthen loadslocalhost:3000; noout/needed. (Production bundles for such apps pointfrontendDist/devUrlat a hosted URL rather than shipping a static export.) - Download via the daemon HTTP API, not the CLI. Implementing
download_model(modelId)asPOST 127.0.0.1:11434/api/pull {"model": modelId, "stream":true}and reading the NDJSON stream ({status,completed,total,digest}) is cleaner than scrapingollama pullstdout — it maps straight onto theDownloadProgressfields and cancels by breaking the stream loop on a sharedAtomicBool(no child-process to kill). Same pattern for chat: streamPOST /api/chat. install_ollamaneeds root on Linux. The officialinstall.shwrites/usr/local/bin/ollamaand creates anollamasystemd service + user viasudo. A non-root Tauri app spawningcurl … | shnon-interactively can't elevate, so the install fails silently. Prefer a rootless install (drop the staticollamabinary in~/.local/bin, runollama serve) or detect-and-guide instead of auto-installing.- Minimal Cargo deps for the HTTP-API approach:
reqwest { json, stream, rustls-tls },tokio { full },futures-util,sysinfo,chrono.blocking/sha2/hex/httpare only needed if you verify installer checksums.sysinfoalso backsget_system_memory's RAM figure (System::total_memory()); VRAM is read by shelling out tonvidia-smi, so it needs no extra crate — and contributes0wherever that binary is absent.
References
references/architecture.md— layer diagram, lifecycle, on-disk model paths.references/tauri-commands.md— full signatures + event payloads for every command in the contract.references/foundry-status.md— Windows NPU path command surface.references/cargo-deps.toml— Cargo[dependencies]your Rust side needs.references/troubleshooting.md— common install / runtime failures with root causes.
Related skills
/iblai-vibe-ops-build— adds the Tauri shell this skill depends on./iblai-vibe-account— Account / settings surface that consumeslocalLLMProps./iblai-vibe-agent-chat— chat surface that routes through the local model./iblai-vibe-agent-llm— the per-agent LLM-provider Settings tab.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

