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

cogentlm

v0.0.12

Published

Run powerful AI models locally with high-performance text and vision inference directly in the browser

Readme

cogentlm

A high-performance, WebGPU-accelerated inference and vision runtime for executing Large Language Models (LLMs) and computer vision locally in the browser.

import { CogentEngine } from 'cogentlm';

const engine = await CogentEngine.create();

await engine.models.load('https://example.com/model.gguf');
const answer = await engine.chat([
  { role: 'user', content: 'Explain browser-hosted inference in one paragraph.' },
]);

console.log(answer);
await engine.close();

Observability

Observability is opt-in. Use "runtime" for request/runtime metrics or "profile" when backend profiling is needed:

await engine.models.load('https://example.com/model.gguf', {
  observability: 'profile',
  runtime: { nCtx: 4096 },
});

const unsubscribe = engine.observability.subscribe(({ type, snapshot }) => {
  if (type === 'query-complete') {
    console.log(`TPS: ${snapshot.runtime?.tokensPerSecond}, TTFT: ${snapshot.runtime?.ttftMs}ms`);
  }
});

await engine.chat([{ role: 'user', content: 'Measure this request.' }]);
unsubscribe();

chat() and query() still return only a string. Metrics are read from engine.observability.current() and lifecycle events are emitted only at load, query, error, and close boundaries.

Model Lifecycle

Use engine.models for model management:

const loaded = await engine.models.load({
  model: 'https://example.com/vision-model.gguf',
  projector: 'https://example.com/mmproj.gguf',
});

await engine.models.load(loaded.id);

console.log(engine.models.current());
console.log(await engine.models.list());

await engine.models.remove(loaded.id);

engine.models.load(...) handles first load, reload, model switching, local imports, remote downloads, shard arrays, and explicit model/projector assembly.

ModelInfo.id is the installed model id for the persisted base-model entry. If a model has already been validated with a projector, later engine.models.load(id) reuses that stored pairing automatically. Installed entries and pairings live in OPFS, so they survive tab refresh and browser restart for the same origin.

Managed storage requires OPFS. If OPFS is unavailable, loading fails clearly instead of silently falling back to transient memory.

Worker Mode

When worker execution is selected, the worker hosts the same high-level model service used by main-thread mode. The main thread talks to a worker model-service client, while low-level WASM, scheduling, cache, and runtime details stay internal.

Query

Use engine.chat(...) for normal assistant-style interaction. Cogent reads the loaded GGUF model's native chat template and renders your messages into the model-specific prompt format before inference:

const reply = await engine.chat([
  { role: 'system', content: 'Be concise.' },
  { role: 'user', content: 'Summarize the current model.' },
]);

Use engine.query(...) only when you already have a complete raw prompt string. Cogent does not apply a chat template in query(), so the prompt must already include whatever control tokens, role markers, or assistant prefix your model expects:

const text = await engine.query(
  '<|im_start|>user\nSummarize the current model.<|im_end|>\n<|im_start|>assistant\n'
);

const vision = await engine.chat({
  messages: [{ role: 'user', content: 'What is in this image?' }],
  media: [imageBytes],
});

Streaming is available through onToken:

const output = await engine.chat([{ role: 'user', content: 'Write a haiku.' }], {
  onToken: (tokens) => {
    console.log(tokens.join(''));
  },
});

Public Exports

  • CogentEngine
  • CogentEngineOptions
  • ModelSource
  • ModelLoadOptions
  • ModelInfo
  • ObservabilityMode
  • EngineObservability
  • ObservabilityEvent
  • ObservabilityEventType
  • ObservabilitySnapshot
  • QueryObservation
  • RuntimeObservation
  • BackendProfileObservation
  • ChatInput
  • ChatMessage
  • ChatOptions
  • QueryInput
  • QueryOptions
  • QueryError

Custom-hosted runtime assets can be supplied with CogentEngine.create({ moduleUrl, wasmUrl }).