v1.2.2 — MIT LICENSE — OPEN SOURCE

ASK YOUR
DATA
ANYTHING.

Natural language queries. Charts. Stats. Rankings.
Zero server. Zero API keys. Zero latency.
Qwen2.5-Coder runs entirely on your GPU.

/** * @package @dhruvil0210/local-ghost * @type React AI components · WebGPU · no API keys · no server * * Open-source React npm package. Add AI to any web app with zero API keys, * no backend, and no per-query cost. Drop in SmartDataGrid, * SmartForm, or SmartAnalytics — Qwen2.5 runs on the * user's GPU via WebGPU, with automatic WASM fallback. * * For React developers who want AI-powered data filtering, form auto-fill, * and chart generation without OpenAI, Anthropic, or any cloud dependency. */
local-ghost — v1.2.2STAT
0ms
Server Latency
$0
Infra Cost / Mo
100%
On-Device
4
Action Types

// LIVE PROJECT STATS

LIVE PROJECT STATS
···
GH STARS
···
FORKS
···
OPEN ISSUES
···
LAST COMMIT
···
NPM / WEEK
···
NPM / MONTH
STAR ON GITHUB

// WHAT'S NEW IN v1.2.2

NEW

DEVICE-LOST HOT SWAP

When the OS reclaims GPU memory — sleep cycle, VRAM spike, driver crash, tab freeze — the worker detects the context loss via GPUDevice.lost and seamlessly reinitialises on WASM. No UI errors. No user action required.

NEW

isProcessing LOCK

AIState now exports isProcessing: boolean — true while any worker request is in-flight. All three dispatchers set and clear it atomically, including every error, timeout, and hotswap path. Race conditions eliminated.

NEW

CONCURRENCY DROP

Rapid-fire queries no longer destabilise the tensor pipeline. If a ref slot is already occupied, the new request is rejected immediately with a clear message — no stale promises left dangling.

HARDENED

HOTSWAP UI FLOW

On device loss the context transitions to loading, logs [LG_HARDENING] WebGPU context lost. Hot-swapping to WASM..., and resolves back to AI Ready — WASM once the fallback pipeline is live.

VERIFIED

BUILD INVARIANTS

turbo run build --force: 3/3 tasks clean. Zero console.log or debugger in production bundle. All 7 .d.ts files present. Sourcemaps confirmed. The one eval() grep hit is the literal string inside the security blacklist.

FIXED

RUNTIME MODE REPORT

After a hot-swap the READY message carries device: "wasm" and the context reads it correctly — mode no longer incorrectly reports "webgpu" after a WASM fallback reinitialisation.

// WHAT'S NEW IN v1.1.0

NEW

analyzeData()

Ask any question in plain English. AI decides whether to return a stat, ranked table, chart, or filtered rows — then the engine executes it deterministically on your data.

NEW

RULE-BASED FALLBACK

15+ regex patterns handle common queries ("who earns most", "top 5", "average X by Y") without LLM inference — instant results even if the model is loading.

NEW

SCATTER CHARTS

Plot any two numeric fields against each other. "scatter age vs salary" — AI picks the axes, frontend renders a live XY scatter with labelled axes.

NEW

VRAM MANAGER

Idle for 5 minutes? The model disposes its GPU bindings automatically. Re-enable with one click. Your battery and memory thank you.

FIX

QUERY ERRORS

Inference failures no longer permanently kill AI status. QUERY_ERROR, JSON_ERROR, and ANALYSIS_ERROR keep the model ready — only the failed request is rejected.

FIX

SANDBOX HARDENED

Generated code now runs inside a closure that null-shadows window, document, fetch, localStorage, sessionStorage, XMLHttpRequest, and WebSocket.

// COMPONENTS

01

SMART DATA GRID

Natural language filter and sort for any array of objects. "show only engineers sorted by salary desc" — AI generates a sandboxed JS filter, frontend executes it.

natural language → filtered table
02

SMART FORM

Paste any unstructured text — email, bio, notes — and the AI extracts structured JSON to fill your form fields. Confidence badges show extraction quality per field.

unstructured text → filled form
03

SMART ANALYTICS

Ask anything. AI classifies your query into chart / stat / table / filter and the engine computes results deterministically. Bar, line, pie, scatter all supported.

any question → chart, stat, or table

// ANALYTICS ACTION TYPES

STAT
  • who earns the most?
  • average salary
  • total payroll
  • how many employees?
  • youngest person
{ kind: "stat", value: 210000, record: { name: "Grace Kim", ... } }
TABLE
  • top 5 earners
  • rank by salary
  • sort by age desc
  • bottom 3 salaries
{ kind: "table", rows: [ ...ranked rows... ] }
CHART
  • average salary by role
  • count by city
  • scatter age vs salary
  • salary pie by role
{ kind: "chart", chartData: [...], yKey: "avg_salary" }
FILTER
  • show engineers
  • salary over 100k
  • employees in New York
  • age > 35
{ kind: "filter", rows: [ ...matched rows... ] }

// INSTALL

NPM
$ npm install @dhruvil0210/local-ghost
# peer deps: react ^18, recharts ^2
QUICK START
import { WebGPUAIProvider, SmartDataGrid,
         SmartForm, SmartAnalytics }
  from '@dhruvil0210/local-ghost';

export default function App() {
  return (
    <WebGPUAIProvider>
      /* natural language → filtered table */
      <SmartDataGrid data={myData} />

      /* paste text → auto-filled form */
      <SmartForm fields={fields} onSubmit={save} />

      /* ask anything → chart, stat, table, filter */
      <SmartAnalytics data={myData} />
    </WebGPUAIProvider>
  );
}
analyzeData() — DIRECT API
import { useWebGPUAI } from '@dhruvil0210/local-ghost';

function MyComponent() {
  const { analyzeData, status } = useWebGPUAI();

  const result = await analyzeData(
    'id, name, age, role, salary',
    'who earns the most?'
  );

  // result.action → "stat"
  // result.metric → "max"
  // result.field  → "salary"
}

// ARCHITECTURE

01

WEBGPU ACCELERATION

Qwen2.5-Coder-0.5B runs directly on device GPU via WebGPU API. Automatic WASM fallback for unsupported browsers. 0ms server round-trip.

10× faster than CPU inference
02

DEVICE-LOST RECOVERY

A separate GPUDevice handle monitors the OS-level context. On sleep, VRAM spike, or driver crash — GPUDevice.lost fires, the old pipeline is disposed, and WASM reinitialises automatically.

zero-downtime GPU → WASM hotswap
03

SECURITY SANDBOX

Generated JS runs in a closure that null-shadows window, document, fetch, localStorage, sessionStorage, XMLHttpRequest, and WebSocket. Token blacklist blocks eval, prototype, and constructor.

injection-proof execution
04

CONCURRENCY LATCHES

isProcessing lock on AIState prevents race conditions from rapid-fire input. Every resolve, reject, error, hotswap, and dispose path resets the lock — it can never get permanently stuck.

zero race conditions
05

VRAM MANAGEMENT

After 5 minutes of inactivity the model disposes its GPU bindings automatically. Re-enables on demand with a single click. Battery and memory preserved.

5-min idle → full VRAM purge
06

WEB WORKER ISOLATION

All model inference runs in a dedicated Web Worker thread. The main thread stays at 60fps while the AI processes your query. LOG messages stream progress in real time.

0ms UI thread blocking