npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@edgellm/core

v0.1.0

Published

Core runtime for edge-first LLM tool calling

Readme

@edgellm/core

The intelligent runtime manager for hybrid AI inference in the browser.

This package handles the complex logic of orchestrating LLMs: choosing the best available runtime (WebGPU vs WASM vs API), managing downloads, executing tool calls, and enabling seamless hot-mapping.

Features

  • 🧠 Hybrid Inference Engine: Starts instantly with a cloud API, then silently hot-swaps to a local model (WebLLM/Transformers.js) once downloaded.
  • 🛠 Universal Tool Calling: Write tools once using standard schemas, and run them on any backend. Handles JSON/XML format differences automatically.
  • 🔄 Smart Fallback:
    • Tier 1: WebLLM (WebGPU) - Fastest, local.
    • Tier 2: Transformers.js (WASM) - CPU fallback, local.
    • Tier 3: API (OpenAI/Ollama) - Universal fallback, immediate start.
  • ⚡ Hot-Swap Ready: Applications remain interactive during the 1-2GB model download. The switching happens in the background without user interruption.

Installation

npm install @edgellm/core

Basic Usage

import { LLMClient } from "@edgellm/core";

// 1. Initialize the client
const client = new LLMClient();

await client.initialize({
  // "auto" prioritizes: API (for speed) -> WebGPU -> WASM
  preferredRuntime: "auto", 
  
  // Optional: API fallback (e.g., local Ollama bridge)
  apiUrl: "http://localhost:3001/v1/chat/completions",
  
  models: {
    // Local models to download in background
    webllm: "Llama-3-8B-Instruct-q4f16_1-MLC",
    transformers: "onnx-community/functiongemma-270m-it-ONNX",
  }
});

// 2. Chat with tools
const response = await client.chat([
  { role: "user", content: "Calculate 5 * 12" }
], [
  {
    name: "calculate",
    description: "Evaluate a math expression",
    parameters: { type: "object", properties: { expression: { type: "string" } } },
    handler: async ({ expression }) => eval(expression)
  }
]);

Hybrid Inference & Hot-Swapping

The core philosophy of @edgellm/core is "Reliability First".

  1. Instant Start: If an apiUrl is provided, the client is "Ready" immediately. It routes initial requests to the API.
  2. Background Download: If a local runtime (WebLLM/Transformers.js) is configured, it begins downloading model weights in the background.
  3. Seamless Switch: Once the local model is fully loaded and compiled, the client automatically "hot-swaps" the active backend. Subsequent requests run locally on-device.

Configuration

type RuntimeConfig = {
  // Strategy
  preferredRuntime?: "webllm" | "transformers" | "api" | "auto";
  fallbackStrategy?: "quality" | "speed" | "cost";

  // API Config (for API Runtime)
  apiUrl?: string;
  apiKey?: string;
  
  // Model Config
  models?: {
    webllm?: string;       // e.g. "Llama-3-8B-Instruct-q4f16_1-MLC"
    transformers?: string; // e.g. "onnx-community/functiongemma-270m-it-ONNX"
    api?: string;          // e.g. "llama3" (for Ollama) or "gpt-4o"
  };

  // Tool Format Override
  // "json" (standard) or "xml" (FunctionGemma)
  toolCallFormat?: "json" | "xml";
}