@dornick/capabilities
v0.1.0
Published
Browser capability detection for Dornick — typed flags, async probes, reactive subscriptions, system-prompt summary.
Downloads
37
Readme
@dornick/capabilities
Browser capability detection for Dornick — typed flags, async probes, reactive subscriptions, system-prompt summary.
A small (~2 KB gz), no-deps package that probes the browser at startup and tells you what's actually reachable. Dornick uses it to gate parsers, mounts, and skills so the agent never sees an affordance that won't work on this user's browser.
Install
npm i @dornick/capabilitiesUse
import { CapabilityRegistry } from "@dornick/capabilities";
const caps = await CapabilityRegistry.detect();
caps.has("webgpu"); // boolean
caps.has("apis.fileSystemAccess"); // boolean
caps.has("apis.webSpeech.recognition"); // boolean
caps.toPromptSummary();
// "browser capabilities — platform: mobile, touch, languages=en-GB;
// compute: wasm+simd, webgpu; storage: indexedDB, opfs, quota=2048MB;
// apis: clipboard, geo, fs-access, camera, mic, speech-out."
caps.toJSON(); // full BrowserCapabilities object — pass to /host/browser/capabilities.json
caps.onChange((next) => {
// fires on online/offline + permission changes
});What it detects
| Group | Examples |
|---|---|
| Compute | WebAssembly + SIMD + threads, WebGPU adapter info, WebGL v1/v2, crossOriginIsolated |
| Storage | IndexedDB, OPFS, quota estimate in MB |
| APIs | Clipboard, Geolocation, Notifications, ServiceWorker, BackgroundSync, Web Speech (in/out), File System Access, BarcodeDetector, Web NFC, WebAuthn, Bluetooth, USB, Serial, camera, mic, share / share-target, WakeLock, IdleDetection, ContactsPicker, PaymentRequest, WebHID, WebXR |
| Permissions | granted / denied / prompt for geolocation, notifications, camera, microphone, clipboard, persistent-storage, push, screen-wake-lock |
| Platform | userAgent, mobile, touch, online, languages, timezone, devicePixelRatio |
Three detection phases
| Phase | Latency | Examples |
|---|---|---|
| Static (synchronous) | < 1 ms | class-existence ('BarcodeDetector' in window), WebGL canvas probe, crossOriginIsolated |
| Probe (async) | 50–200 ms | WASM SIMD/threads validation, WebGPU adapter request, storage quota estimate, permissions snapshot |
| Reactive | live | online/offline events; permission changes (planned) |
Use detectSync() for a synchronous-only snapshot when you need to make a decision at boot before the async probes resolve.
How parsers and mounts use it
Each @dornick/parsers-* package and each @dornick/mounts-* package declares the capabilities it requires. Dornick's parser registry and mount registration filter them automatically:
// in @dornick/parsers-audio
export const whisperParser: FileParser = {
name: "whisper-audio",
requires: ["webgpu", "crossOriginIsolated"],
matches: (file, caps) => file.mimeType.startsWith("audio/"),
// ...
};// in @dornick/mounts-browser
export class FileSystemMount implements VfsMountHandler {
static available(caps: BrowserCapabilities): boolean {
return caps.apis.fileSystemAccess;
}
// ...
}If the gate fails, the parser / mount becomes a no-op — never appears in tree /, never gets called by the model.
Links
License
MIT — © Dipankar Sarkar
