@tryhamster/gerbil 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +99 -34
- package/dist/browser/index.d.ts +12 -2
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +12 -5
- package/dist/browser/index.js.map +1 -1
- package/dist/cli.mjs +7 -7
- package/dist/cli.mjs.map +1 -1
- package/dist/frameworks/express.d.mts +1 -1
- package/dist/frameworks/express.mjs +1 -1
- package/dist/frameworks/fastify.d.mts +1 -1
- package/dist/frameworks/fastify.mjs +1 -1
- package/dist/frameworks/hono.d.mts +1 -1
- package/dist/frameworks/hono.mjs +1 -1
- package/dist/frameworks/next.d.mts +3 -3
- package/dist/frameworks/next.mjs +1 -1
- package/dist/frameworks/react.d.mts +1 -1
- package/dist/frameworks/trpc.d.mts +1 -1
- package/dist/frameworks/trpc.mjs +1 -1
- package/dist/gerbil-B-jMOrnE.mjs +4 -0
- package/dist/{gerbil-BT9fCydo.d.mts → gerbil-BetB5xb0.d.mts} +3 -3
- package/dist/{gerbil-BT9fCydo.d.mts.map → gerbil-BetB5xb0.d.mts.map} +1 -1
- package/dist/{gerbil-BHrJJIa4.mjs → gerbil-CV4VpF4_.mjs} +2 -2
- package/dist/{gerbil-BHrJJIa4.mjs.map → gerbil-CV4VpF4_.mjs.map} +1 -1
- package/dist/gpu/hooks.d.mts +166 -1
- package/dist/gpu/hooks.d.mts.map +1 -1
- package/dist/gpu/hooks.mjs +214 -6
- package/dist/gpu/hooks.mjs.map +1 -1
- package/dist/gpu/index.d.mts +2 -2
- package/dist/gpu/index.mjs +2 -2
- package/dist/{gpu-33qCAtHW.mjs → gpu-836grvrv.mjs} +178 -3
- package/dist/gpu-836grvrv.mjs.map +1 -0
- package/dist/index-Dgmb2kE3.d.mts.map +1 -1
- package/dist/{index-jEAL2s-A.d.mts → index-DukkJRMj.d.mts} +104 -12
- package/dist/index-DukkJRMj.d.mts.map +1 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +4 -4
- package/dist/integrations/ai-sdk.d.mts +1 -1
- package/dist/integrations/ai-sdk.mjs +1 -1
- package/dist/integrations/langchain.d.mts +1 -1
- package/dist/integrations/langchain.mjs +1 -1
- package/dist/integrations/llamaindex.d.mts +1 -1
- package/dist/integrations/llamaindex.mjs +1 -1
- package/dist/integrations/mcp.d.mts +3 -3
- package/dist/integrations/mcp.mjs +4 -4
- package/dist/{mcp-1DaMsaBc.mjs → mcp-BVHI5vzD.mjs} +3 -3
- package/dist/{mcp-1DaMsaBc.mjs.map → mcp-BVHI5vzD.mjs.map} +1 -1
- package/dist/{moonshine-stt-v_P_Ci_m.mjs → moonshine-stt-BzQRl-BO.mjs} +51 -19
- package/dist/{moonshine-stt-v_P_Ci_m.mjs.map → moonshine-stt-BzQRl-BO.mjs.map} +1 -1
- package/dist/moonshine-stt-CIolM_SX.mjs +4 -0
- package/dist/{one-liner-DnQn7HJK.mjs → one-liner-Cn7IEg1G.mjs} +2 -2
- package/dist/{one-liner-DnQn7HJK.mjs.map → one-liner-Cn7IEg1G.mjs.map} +1 -1
- package/dist/{repl-jV5gcJFA.mjs → repl-CKAf2M7H.mjs} +3 -3
- package/dist/skills/index.d.mts +5 -5
- package/dist/skills/index.mjs +3 -3
- package/dist/{skills-DX8D59UH.mjs → skills-uuU5GONV.mjs} +2 -2
- package/dist/{skills-DX8D59UH.mjs.map → skills-uuU5GONV.mjs.map} +1 -1
- package/dist/{types-D6FiR_oh.d.mts → types-LlyYILII.d.mts} +7 -3
- package/dist/types-LlyYILII.d.mts.map +1 -0
- package/package.json +1 -1
- package/dist/gerbil-DomNfIr1.mjs +0 -4
- package/dist/gpu-33qCAtHW.mjs.map +0 -1
- package/dist/index-jEAL2s-A.d.mts.map +0 -1
- package/dist/moonshine-stt-BLyVoRpB.mjs +0 -4
- package/dist/types-D6FiR_oh.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -9,14 +9,15 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
+
<a href="https://gerbilsdk.com"><strong>gerbilsdk.com</strong></a> •
|
|
12
13
|
<a href="#install">Install</a> •
|
|
13
14
|
<a href="#native-webgpu-engine">Engine</a> •
|
|
14
15
|
<a href="#react-quickstart">React</a> •
|
|
15
16
|
<a href="#embeddings">Embeddings</a> •
|
|
16
17
|
<a href="#vision">Vision</a> •
|
|
17
18
|
<a href="#speech">Speech</a> •
|
|
18
|
-
<a href="
|
|
19
|
-
<a href="
|
|
19
|
+
<a href="https://gerbilsdk.com/docs/frameworks/ai-sdk">AI SDK</a> •
|
|
20
|
+
<a href="https://gerbilsdk.com/docs/cli">CLI</a>
|
|
20
21
|
</p>
|
|
21
22
|
|
|
22
23
|
<p align="center">
|
|
@@ -43,13 +44,14 @@ const engine = await WebGPUEngine.create({ repo: "mlx-community/Qwen3.5-0.8B-4bi
|
|
|
43
44
|
const { text } = await engine.generate("Explain recursion in one sentence");
|
|
44
45
|
```
|
|
45
46
|
|
|
46
|
-
> **
|
|
47
|
-
> native engine surface below is the path going forward; APIs may still shift before 1.0.
|
|
47
|
+
> **📚 Full docs → [gerbilsdk.com/docs](https://gerbilsdk.com/docs)** · live playground & demos at **[gerbilsdk.com](https://gerbilsdk.com)**
|
|
48
48
|
|
|
49
49
|
## Why Gerbil?
|
|
50
50
|
|
|
51
51
|
- **One native engine** — a from-scratch WebGPU/WGSL engine, pure compute shaders, nothing
|
|
52
52
|
extra to ship.
|
|
53
|
+
- **~90 KB gzipped** — the _entire_ multimodal engine. No heavyweight ML runtime; model
|
|
54
|
+
weights stream from the HuggingFace Hub at run time.
|
|
53
55
|
- **Multimodal, all native** — text, vision (image→text), embeddings, and speech run on the
|
|
54
56
|
same engine, loading safetensors directly from the HuggingFace Hub.
|
|
55
57
|
- **Browser & Node** — Chrome 113+, Safari 26+ (iOS 26+), Firefox 141+, and Node via Dawn
|
|
@@ -137,6 +139,20 @@ function Chat() {
|
|
|
137
139
|
The same hook exposes `describeImage` (vision), `embed`/`similarity` (embeddings), `stop`,
|
|
138
140
|
and `dispose`. Pass `enableVision: true` or `embedding: true` to load those modalities.
|
|
139
141
|
|
|
142
|
+
**Gate your app behind the download.** Wrap your app in `<GerbilGate>` to show a splash
|
|
143
|
+
until the engine is ready — and keep it warm across navigation (no GPU re-upload):
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
import { GerbilGate } from "@tryhamster/gerbil/gpu/hooks";
|
|
147
|
+
|
|
148
|
+
<GerbilGate
|
|
149
|
+
model="mlx-community/Qwen3.5-0.8B-4bit"
|
|
150
|
+
fallback={({ progress }) => <Splash percent={progress} />}
|
|
151
|
+
>
|
|
152
|
+
<App />
|
|
153
|
+
</GerbilGate>;
|
|
154
|
+
```
|
|
155
|
+
|
|
140
156
|
## Structured Output
|
|
141
157
|
|
|
142
158
|
`generateObject` makes the model return a JSON object: it generates, extracts the JSON,
|
|
@@ -209,7 +225,7 @@ const doc = await engine.embed("Paris is the capital of France", { taskType: "do
|
|
|
209
225
|
const sim = query.reduce((s, v, i) => s + v * doc[i], 0);
|
|
210
226
|
```
|
|
211
227
|
|
|
212
|
-
📖 **[Full Embeddings Documentation →](
|
|
228
|
+
📖 **[Full Embeddings Documentation →](https://gerbilsdk.com/docs)**
|
|
213
229
|
|
|
214
230
|
## Vision
|
|
215
231
|
|
|
@@ -230,7 +246,7 @@ const { text } = await engine.describeImage(
|
|
|
230
246
|
);
|
|
231
247
|
```
|
|
232
248
|
|
|
233
|
-
📖 **[Full Vision Documentation →](
|
|
249
|
+
📖 **[Full Vision Documentation →](https://gerbilsdk.com/docs/vision)**
|
|
234
250
|
|
|
235
251
|
## Speech
|
|
236
252
|
|
|
@@ -249,10 +265,13 @@ via the dedicated `MoonshineSTT` class.
|
|
|
249
265
|
import { MoonshineSTT } from "@tryhamster/gerbil/gpu";
|
|
250
266
|
|
|
251
267
|
const stt = await MoonshineSTT.create({ repo: "UsefulSensors/moonshine-base" });
|
|
252
|
-
const { text } = await stt.transcribe(pcm16kMono); //
|
|
268
|
+
const { text, noSpeech } = await stt.transcribe(pcm16kMono); // noSpeech flags silence
|
|
253
269
|
```
|
|
254
270
|
|
|
255
|
-
|
|
271
|
+
`transcribe` returns `noSpeech` (RMS VAD + min-duration + marker denylist) so you can skip
|
|
272
|
+
silent/empty clips; `useSTT` surfaces it too, with an `onNoSpeech` callback.
|
|
273
|
+
|
|
274
|
+
📖 **[Full TTS Documentation →](https://gerbilsdk.com/docs/tts)** · **[Full STT Documentation →](https://gerbilsdk.com/docs/stt)**
|
|
256
275
|
|
|
257
276
|
## Skills
|
|
258
277
|
|
|
@@ -286,7 +305,7 @@ await loadSkills("./skills"); // loads *.skill.ts
|
|
|
286
305
|
const skill = useSkill("my-skill");
|
|
287
306
|
```
|
|
288
307
|
|
|
289
|
-
📖 **[Full Skills Documentation →](
|
|
308
|
+
📖 **[Full Skills Documentation →](https://gerbilsdk.com/docs/skills)**
|
|
290
309
|
|
|
291
310
|
## Tools & Agents
|
|
292
311
|
|
|
@@ -303,6 +322,27 @@ const weatherTool = defineTool({
|
|
|
303
322
|
});
|
|
304
323
|
```
|
|
305
324
|
|
|
325
|
+
**Agentic loop, on-device.** `engine.generateWithTools` (and the `useAgent` React hook)
|
|
326
|
+
run the whole loop — generate → call a tool → feed the result back → repeat — and return a
|
|
327
|
+
step trace for UIs:
|
|
328
|
+
|
|
329
|
+
```tsx
|
|
330
|
+
import { useAgent } from "@tryhamster/gerbil/gpu/hooks";
|
|
331
|
+
|
|
332
|
+
const { run, steps, answer, isRunning } = useAgent({
|
|
333
|
+
model: "mlx-community/Qwen3.5-0.8B-4bit",
|
|
334
|
+
tools: [
|
|
335
|
+
{
|
|
336
|
+
name: "get_weather",
|
|
337
|
+
description: "Get the weather for a city",
|
|
338
|
+
parameters: { city: "string" },
|
|
339
|
+
execute: ({ city }) => `Weather in ${city}: 72°F, sunny`,
|
|
340
|
+
},
|
|
341
|
+
],
|
|
342
|
+
});
|
|
343
|
+
await run("What's the weather in Paris?"); // steps[]: tool_call → tool_result → answer
|
|
344
|
+
```
|
|
345
|
+
|
|
306
346
|
**Built-in tools:**
|
|
307
347
|
- `gerbil_docs` — Search Gerbil documentation
|
|
308
348
|
- `run_skill` — Execute any Gerbil skill
|
|
@@ -316,7 +356,28 @@ npx @tryhamster/gerbil repl
|
|
|
316
356
|
# Gerbil will call the docs tool and synthesize an answer
|
|
317
357
|
```
|
|
318
358
|
|
|
319
|
-
📖 **[Full Tools Documentation →](
|
|
359
|
+
📖 **[Full Tools Documentation →](https://gerbilsdk.com/docs/tools)**
|
|
360
|
+
|
|
361
|
+
## Autocomplete & Rewrite
|
|
362
|
+
|
|
363
|
+
Inline autocomplete — `engine.autocomplete(prefix)` and the debounced `useAutocomplete`
|
|
364
|
+
hook return a brief single-line continuation (low-latency defaults + cleanup):
|
|
365
|
+
|
|
366
|
+
```tsx
|
|
367
|
+
import { useAutocomplete } from "@tryhamster/gerbil/gpu/hooks";
|
|
368
|
+
|
|
369
|
+
const { suggestion, onInput, accept, dismiss } = useAutocomplete({
|
|
370
|
+
model: "mlx-community/Qwen3.5-0.8B-4bit",
|
|
371
|
+
});
|
|
372
|
+
// <input onChange={(e) => onInput(e.target.value)} /> — render `suggestion` as ghost text;
|
|
373
|
+
// Tab → accept(), Esc → dismiss()
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Tone rewrite — `engine.rewrite(text, { tone })` (and `useEngine().rewrite`) re-generates
|
|
377
|
+
text in a target tone (`"professional"`, `"friendly"`, `"concise"`, `"playful"`,
|
|
378
|
+
`"pirate"`) or with free-form `instructions`.
|
|
379
|
+
|
|
380
|
+
📖 **[Full Autocomplete Documentation →](https://gerbilsdk.com/docs/autocomplete)**
|
|
320
381
|
|
|
321
382
|
## CLI
|
|
322
383
|
|
|
@@ -339,7 +400,7 @@ gerbil update # Update to latest version
|
|
|
339
400
|
|
|
340
401
|
> **Updates**: Gerbil checks for updates but never installs without permission. Press `u` in REPL or run `gerbil update`.
|
|
341
402
|
|
|
342
|
-
📖 **[Full CLI Documentation →](
|
|
403
|
+
📖 **[Full CLI Documentation →](https://gerbilsdk.com/docs/cli)**
|
|
343
404
|
|
|
344
405
|
## Browser Usage
|
|
345
406
|
|
|
@@ -363,22 +424,22 @@ function Chat() {
|
|
|
363
424
|
}
|
|
364
425
|
```
|
|
365
426
|
|
|
366
|
-
`@tryhamster/gerbil/browser`
|
|
427
|
+
`@tryhamster/gerbil/browser` exports the device & storage utilities
|
|
367
428
|
(`isModelSafeForDevice`, `detectMemoryCrash`, `downloadModelChunked`,
|
|
368
|
-
`
|
|
429
|
+
`getRecommendedModels`, `requestPersistentStorage`, …).
|
|
369
430
|
|
|
370
|
-
📖 **[Full Browser Documentation →](
|
|
431
|
+
📖 **[Full Browser Documentation →](https://gerbilsdk.com/docs/browser)**
|
|
371
432
|
|
|
372
433
|
## Integrations
|
|
373
434
|
|
|
374
435
|
| Integration | Import | Docs |
|
|
375
436
|
|-------------|--------|------|
|
|
376
|
-
| **Browser** | `@tryhamster/gerbil/browser` | [📖 Browser](
|
|
377
|
-
| **AI SDK v5** | `@tryhamster/gerbil/ai` | [📖 AI SDK](
|
|
378
|
-
| **Next.js** | `@tryhamster/gerbil/next` | [📖
|
|
379
|
-
| **Express** | `@tryhamster/gerbil/express` | [📖
|
|
380
|
-
| **LangChain** | `@tryhamster/gerbil/langchain` | [📖
|
|
381
|
-
| **MCP Server** | `npx @tryhamster/gerbil serve --mcp` | [📖 MCP](
|
|
437
|
+
| **Browser** | `@tryhamster/gerbil/browser` | [📖 Browser](https://gerbilsdk.com/docs/browser) |
|
|
438
|
+
| **AI SDK v5** | `@tryhamster/gerbil/ai` | [📖 AI SDK](https://gerbilsdk.com/docs/frameworks/ai-sdk) |
|
|
439
|
+
| **Next.js** | `@tryhamster/gerbil/next` | [📖 Next.js](https://gerbilsdk.com/docs/frameworks/nextjs) |
|
|
440
|
+
| **Express** | `@tryhamster/gerbil/express` | [📖 Express](https://gerbilsdk.com/docs/frameworks/express) |
|
|
441
|
+
| **LangChain** | `@tryhamster/gerbil/langchain` | [📖 LangChain](https://gerbilsdk.com/docs/frameworks/langchain) |
|
|
442
|
+
| **MCP Server** | `npx @tryhamster/gerbil serve --mcp` | [📖 MCP](https://gerbilsdk.com/docs/mcp) |
|
|
382
443
|
|
|
383
444
|
**Native engine:** `import { WebGPUEngine } from "@tryhamster/gerbil/gpu"` (or `useEngine` from `@tryhamster/gerbil/gpu/hooks` for React) is the primary surface for text, vision, embeddings, and speech.
|
|
384
445
|
|
|
@@ -444,22 +505,26 @@ HiFi-GAN (NanoCodec decoder), and more.
|
|
|
444
505
|
|
|
445
506
|
## Documentation
|
|
446
507
|
|
|
508
|
+
Full documentation, guides, and a live playground live at **[gerbilsdk.com/docs](https://gerbilsdk.com/docs)**.
|
|
509
|
+
|
|
447
510
|
| Guide | Description |
|
|
448
511
|
|-------|-------------|
|
|
449
|
-
| [📖
|
|
450
|
-
| [📖
|
|
451
|
-
| [📖
|
|
452
|
-
| [📖
|
|
453
|
-
| [📖
|
|
454
|
-
| [📖
|
|
455
|
-
| [📖
|
|
456
|
-
| [📖
|
|
457
|
-
| [📖
|
|
458
|
-
| [📖
|
|
459
|
-
| [📖
|
|
460
|
-
| [📖
|
|
461
|
-
| [📖
|
|
462
|
-
| [📖
|
|
512
|
+
| [📖 Getting Started](https://gerbilsdk.com/docs/getting-started) | Install, load a model, core concepts |
|
|
513
|
+
| [📖 Structured Output](https://gerbilsdk.com/docs) | `generateObject` / `useObject` — validated JSON with retries |
|
|
514
|
+
| [📖 Embeddings](https://gerbilsdk.com/docs) | EmbeddingGemma semantic search, similarity, RAG |
|
|
515
|
+
| [📖 Vision](https://gerbilsdk.com/docs/vision) | Image → text with Qwen3.5 ViT & Gemma 4 ViT |
|
|
516
|
+
| [📖 Text-to-Speech](https://gerbilsdk.com/docs/tts) | Native Kani-TTS-2 (`engine.speak()`) |
|
|
517
|
+
| [📖 Speech-to-Text](https://gerbilsdk.com/docs/stt) | Native Moonshine (`MoonshineSTT`) |
|
|
518
|
+
| [📖 Browser](https://gerbilsdk.com/docs/browser) | WebGPU inference, React hooks |
|
|
519
|
+
| [📖 Hooks](https://gerbilsdk.com/docs/hooks) | `useEngine` / `useObject` / `useTTS` / `useSTT` |
|
|
520
|
+
| [📖 Skills](https://gerbilsdk.com/docs/skills) | Built-in skills, custom skill development |
|
|
521
|
+
| [📖 Tools](https://gerbilsdk.com/docs/tools) | Tool calling, agentic workflows |
|
|
522
|
+
| [📖 REPL](https://gerbilsdk.com/docs/repl) | Interactive terminal dashboard |
|
|
523
|
+
| [📖 AI SDK](https://gerbilsdk.com/docs/frameworks/ai-sdk) | Vercel AI SDK v5 (LLM, TTS, STT, Embeddings) |
|
|
524
|
+
| [📖 Frameworks](https://gerbilsdk.com/docs/frameworks) | Next.js, Express, React, LangChain |
|
|
525
|
+
| [📖 CLI](https://gerbilsdk.com/docs/cli) | All CLI commands and options |
|
|
526
|
+
| [📖 Mobile](https://gerbilsdk.com/docs/mobile) | iOS / iPadOS guidance & memory guards |
|
|
527
|
+
| [📖 MCP](https://gerbilsdk.com/docs/mcp) | MCP server for Claude Desktop & Cursor |
|
|
463
528
|
|
|
464
529
|
## Requirements
|
|
465
530
|
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -41,8 +41,12 @@ type GenerateOptions = {
|
|
|
41
41
|
system?: string;
|
|
42
42
|
/** Enable thinking/reasoning mode (Qwen3) */
|
|
43
43
|
thinking?: boolean;
|
|
44
|
-
/** Callback for each token (streaming) */
|
|
45
|
-
onToken?: (token: string
|
|
44
|
+
/** Callback for each token (streaming); `meta` carries live decode-only tok/s */
|
|
45
|
+
onToken?: (token: string, meta?: {
|
|
46
|
+
tokenIndex: number;
|
|
47
|
+
tps: number;
|
|
48
|
+
elapsedMs: number;
|
|
49
|
+
}) => void;
|
|
46
50
|
/** Images to include (only used if model supports vision) */
|
|
47
51
|
images?: ImageInput[];
|
|
48
52
|
/** Enable response caching (default: false) */
|
|
@@ -581,6 +585,12 @@ declare const MODEL_SIZES: Record<string, number>;
|
|
|
581
585
|
*/
|
|
582
586
|
declare function isModelSafeForDevice(modelId: string): {
|
|
583
587
|
safe: boolean;
|
|
588
|
+
/**
|
|
589
|
+
* Borderline: may run on the newest hardware but is prone to OOM. Reported
|
|
590
|
+
* unsafe (`safe: false`) so callers block by default; a UI can use `risky` to
|
|
591
|
+
* offer an explicit "load anyway" on capable devices.
|
|
592
|
+
*/
|
|
593
|
+
risky: boolean;
|
|
584
594
|
reason: string;
|
|
585
595
|
recommendation?: string;
|
|
586
596
|
maxSafeModel?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/core/types.ts","../../src/core/models.ts","../../src/browser/pwa.ts","../../src/browser/audio.ts","../../src/browser/device-guards.ts","../../src/browser/download.ts"],"sourcesContent":[],"mappings":";;;;AAyBY,KAfA,WAAA,GAeW;EASX,EAAA,EAAA,MAAA;EAWA,IAAA,EAAA,MAAA;EAmCA,WAAA,EAAA,MAAc;EA8Bd,IAAA,EAAA,MAAA;EAkBA,aAAA,EAAY,MAAA;EAQZ,gBAAW,EAAA,OAAA;EAWX,YAAA,EAAA,OAAY;EAWZ;EAkBA,cAAW,CAAA,EAAA,OAAA;EAqBX;EAOA,iBAAY,CAAA,EAAA,MAAA;EAYZ,MAAA,EAAA,MAAA,GAAY,QAAA,GAAA,KAAA,GAAA,SAAA,GAAA,OAAA,GAAA,OAAA;CAWd;AAGG,KA7MD,WAAA,GA6MC;EAGC,IAAA,EAAA,SAAA,GAAA,aAAA,GAAA,OAAA;EAGE,IAAA,EAAA,MAAA;CAAiB;AAGrB,KA7MA,UAAA,GA6MW;EAiBX;EAqBA,MAAA,EAAA,MAAA;EAUA;EAOA,GAAA,CAAA,EAAA,MAAA;AAyBZ,CAAA;AAWY,KA7RA,eAAA,GA6RsB;EAYtB;EAeA,SAAA,CAAA,EAAA,MAAc;EAmBd;EAWA,WAAA,CAAA,EAAU,MAAA;EAWV;EAaA,IAAA,CAAA,EAAA,MAAA;EAWA;EAiBA,IAAA,CAAA,EAAA,MAAA;EASA;EASA,aAAA,CAAA,EAAA,MAAgB,EAAA;EAahB;EAWA,MAAA,CAAA,EAAA,MAAA;EAeA;EAES,QAAA,CAAA,EAAA,OAAA;EAEN;EAID,OAAA,CAAA,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GAAA,IAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/core/types.ts","../../src/core/models.ts","../../src/browser/pwa.ts","../../src/browser/audio.ts","../../src/browser/device-guards.ts","../../src/browser/download.ts"],"sourcesContent":[],"mappings":";;;;AAyBY,KAfA,WAAA,GAeW;EASX,EAAA,EAAA,MAAA;EAWA,IAAA,EAAA,MAAA;EAmCA,WAAA,EAAA,MAAc;EA8Bd,IAAA,EAAA,MAAA;EAkBA,aAAA,EAAY,MAAA;EAQZ,gBAAW,EAAA,OAAA;EAWX,YAAA,EAAA,OAAY;EAWZ;EAkBA,cAAW,CAAA,EAAA,OAAA;EAqBX;EAOA,iBAAY,CAAA,EAAA,MAAA;EAYZ,MAAA,EAAA,MAAA,GAAY,QAAA,GAAA,KAAA,GAAA,SAAA,GAAA,OAAA,GAAA,OAAA;CAWd;AAGG,KA7MD,WAAA,GA6MC;EAGC,IAAA,EAAA,SAAA,GAAA,aAAA,GAAA,OAAA;EAGE,IAAA,EAAA,MAAA;CAAiB;AAGrB,KA7MA,UAAA,GA6MW;EAiBX;EAqBA,MAAA,EAAA,MAAA;EAUA;EAOA,GAAA,CAAA,EAAA,MAAA;AAyBZ,CAAA;AAWY,KA7RA,eAAA,GA6RsB;EAYtB;EAeA,SAAA,CAAA,EAAA,MAAc;EAmBd;EAWA,WAAA,CAAA,EAAU,MAAA;EAWV;EAaA,IAAA,CAAA,EAAA,MAAA;EAWA;EAiBA,IAAA,CAAA,EAAA,MAAA;EASA;EASA,aAAA,CAAA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Id(modelId) {
|
|
|
280
280
|
* - blocked: too large for the WKWebView memory ceiling on iPhone — will crash.
|
|
281
281
|
* gemma-4-e2b (~3.6GB) plus any vision checkpoint (the vision encoder pushes
|
|
282
282
|
* the working set well past what an iPhone can hold).
|
|
283
|
-
* - risky:
|
|
284
|
-
*
|
|
283
|
+
* - risky: Qwen3.5-2B (~1.7GB) OOM-crashes iPhone WKWebView in practice — now
|
|
284
|
+
* treated as unsafe to auto-load (flagged `risky` so a UI can offer to force it).
|
|
285
285
|
* - everything else (Qwen3.5-0.8B ~0.65GB, LFM2.5-350M) is allowed everywhere.
|
|
286
286
|
*/
|
|
287
287
|
const IOS_MODEL_LIMITS = {
|
|
@@ -314,41 +314,48 @@ function isModelSafeForDevice(modelId) {
|
|
|
314
314
|
if (isIPhone) {
|
|
315
315
|
if (isBlocked) return {
|
|
316
316
|
safe: false,
|
|
317
|
+
risky: false,
|
|
317
318
|
reason: `Model ${modelId} will crash on iPhone${isIOSChrome ? " (iOS Chrome uses WKWebView, same limits as Safari)" : ""}. ${isVision ? "Vision checkpoints need a separate image encoder in memory" : "It is too large (~3.6GB)"}, which exceeds the WKWebView memory ceiling.`,
|
|
318
319
|
recommendation: `Use ${SAFE_MOBILE_CHAT} (Qwen3.5-0.8B) on iPhone, or run larger models on desktop.`,
|
|
319
320
|
maxSafeModel: SAFE_MOBILE_CHAT
|
|
320
321
|
};
|
|
321
322
|
if (isRisky) return {
|
|
322
|
-
safe:
|
|
323
|
-
|
|
324
|
-
|
|
323
|
+
safe: false,
|
|
324
|
+
risky: true,
|
|
325
|
+
reason: `Model ${modelId} (~1.7GB) exceeds the iPhone WKWebView memory budget and is likely to crash.`,
|
|
326
|
+
recommendation: `Use ${SAFE_MOBILE_CHAT} (Qwen3.5-0.8B) on iPhone; run Qwen3.5-2B on iPad or desktop.`,
|
|
325
327
|
maxSafeModel: SAFE_MOBILE_CHAT
|
|
326
328
|
};
|
|
327
329
|
return {
|
|
328
330
|
safe: true,
|
|
331
|
+
risky: false,
|
|
329
332
|
reason: "Model is within iPhone memory limits."
|
|
330
333
|
};
|
|
331
334
|
}
|
|
332
335
|
if (isIPad) {
|
|
333
336
|
if (isBlocked) return {
|
|
334
337
|
safe: false,
|
|
338
|
+
risky: false,
|
|
335
339
|
reason: `Model ${modelId} may crash on iPad. ${isVision ? "Vision checkpoints need a separate image encoder in memory" : "It is too large (~3.6GB)"}, which can exceed the WKWebView memory ceiling.`,
|
|
336
340
|
recommendation: `Use ${SAFE_MOBILE_CHAT} (Qwen3.5-0.8B) or Qwen3.5-2B on iPad.`,
|
|
337
341
|
maxSafeModel: "mlx-community/Qwen3.5-2B-4bit"
|
|
338
342
|
};
|
|
339
343
|
return {
|
|
340
344
|
safe: true,
|
|
345
|
+
risky: false,
|
|
341
346
|
reason: "Model is within iPad memory limits."
|
|
342
347
|
};
|
|
343
348
|
}
|
|
344
349
|
if (/Android/.test(ua) && isBlocked) return {
|
|
345
350
|
safe: false,
|
|
351
|
+
risky: false,
|
|
346
352
|
reason: `Model ${modelId} is very large and may crash on Android devices.`,
|
|
347
353
|
recommendation: `Use ${SAFE_MOBILE_CHAT} (Qwen3.5-0.8B) or Qwen3.5-2B on Android.`,
|
|
348
354
|
maxSafeModel: "mlx-community/Qwen3.5-2B-4bit"
|
|
349
355
|
};
|
|
350
356
|
return {
|
|
351
357
|
safe: true,
|
|
358
|
+
risky: false,
|
|
352
359
|
reason: "Desktop browser has sufficient memory."
|
|
353
360
|
};
|
|
354
361
|
}
|