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 🙏

© 2025 – Pkg Stats / Ryan Hefner

agentary-js

v3.0.0

Published

JS SDK for running quantized small language models in the browser

Readme

Agentary JS

A lightweight JavaScript SDK for building agentic workflows with tool calling, memory, and multi-step reasoning.

npm version
License: MIT


🚀 Features

🤖 Agentic Workflows (Core Value)

Multi-step agents with reasoning, tool execution, memory, and decision logic.

🔧 Tool Calling

Typed function calling with automatic execution, supported on cloud and device.

🧠 Smart Memory

Sliding window, LLM summarization, or checkpoint-based memory for long-running agents.

☁️ Cloud + 🖥️ Device Runtime (Flexible Execution)

Use Claude/OpenAI for advanced reasoning, or run models locally using Transformers.js.

📡 Unified API

Same function calls for device and cloud models. No vendor lock-in, no rewriting code.

📊 Observable Runtime

Lifecycle events for streaming tokens, workflow steps, tool calls, and model routing.

Lightweight & Type-Safe

Tree-shakeable, minimal abstraction, full TypeScript IntelliSense.


📦 Installation

For Cloud-Only Usage

npm install agentary-js

For Device (Local) Inference

If you plan to run models locally using Transformers.js, install the peer dependency:

npm install agentary-js @huggingface/transformers

Note: @huggingface/transformers is only required for on-device inference. Cloud-only users can skip this dependency.


🎯 Quick Start

Below are the three primary ways developers use Agentary.


1. Agentic Workflow (Recommended)

import { createAgentSession } from 'agentary-js';

const agent = await createAgentSession({
  models: [{
    runtime: 'anthropic',
    model: 'claude-sonnet-4-5',
    proxyUrl: '/api/anthropic',
    modelProvider: 'anthropic'
  }]
});

const workflow = {
  id: 'research',
  name: 'Research Assistant',
  maxIterations: 5,
  steps: [
    { id: 'understand', prompt: 'Break the topic down.' },
    { 
      id: 'research', 
      prompt: 'Search for relevant information.',
      toolChoice: ['web_search'] 
    },
    { id: 'synthesize', prompt: 'Summarize your findings clearly.' }
  ],
  tools: [
    {
      definition: {
        name: 'web_search',
        description: 'Search the web for information',
        parameters: {
          type: 'object',
          properties: { query: { type: 'string' } },
          required: ['query']
        }
      },
      implementation: async ({ query }) =>
        `Search results for: ${query}`
    }
  ]
};

for await (const step of agent.runWorkflow(
  'Explain the benefits of renewable energy.',
  workflow,
  { strategy: 'sliding-window', maxMessages: 10 }
)) {
  console.log(`[${step.stepId}]`, step.content);
}

2. Cloud Provider Inference (OpenAI / Anthropic)

import { createSession } from 'agentary-js';

const session = await createSession({
  models: [{
    runtime: 'anthropic',
    model: 'claude-sonnet-4-5',
    proxyUrl: '/api/anthropic',
    modelProvider: 'anthropic'
  }]
});

const res = await session.createResponse('claude-sonnet-4-5', {
  messages: [{ role: 'user', content: 'Explain quantum computing.' }],
  max_tokens: 300
});

console.log(res.type === 'complete' ? res.content : '');
await session.dispose();

3. On-Device Inference (Transformers.js Runtime)

import { createSession } from 'agentary-js';

const session = await createSession({
  models: [{
    runtime: 'transformers-js',
    model: 'onnx-community/Qwen3-0.6B-ONNX',
    quantization: 'q4',
    engine: 'webgpu'
  }]
});

const out = await session.createResponse('onnx-community/Qwen3-0.6B-ONNX', {
  messages: [{ role: 'user', content: 'Hello!' }]
});

if (out.type === 'streaming') {
  for await (const chunk of out.stream) {
    process.stdout.write(chunk.token);
  }
}

await session.dispose();

🔧 Tool Calling

const tools = [
  {
    name: 'get_weather',
    description: 'Get weather for a city',
    parameters: {
      type: 'object',
      properties: {
        location: { type: 'string' }
      },
      required: ['location']
    },
    implementation: async ({ location }) =>
      `Weather in ${location}: 72°F, Sunny`
  }
];

Agentary handles:

  • parsing model tool calls
  • resolving arguments
  • executing tools
  • inserting results back into context

🧠 Why Agentary?

When to Use Agentary

| Use Case | Recommendation | |----------|----------------| | Build multi-step agents with tools, memory, decision logic | Agentary | | Unified cloud + device execution | Agentary | | Easiest workflow engine in JS | Agentary | | Only need raw on-device inference | Use Transformers.js directly | | Only calling OpenAI/Anthropic APIs | Agentary or Vercel AI SDK | | Large enterprise-style orchestration | Agentary or LangChain.js |


📚 Documentation

📖 https://docs.agentary.ai

  • Getting Started
  • Tool Calling
  • Cloud Providers
  • Agentic Workflows
  • Memory Management
  • Supported Models
  • API Reference

🌐 Runtime Support

On-Device (Transformers.js)

  • WebGPU: Chrome 113+, Edge 113+, Safari 26+, Firefox (flag)
  • WASM fallback
  • 4GB RAM recommended for small models

Cloud Providers

Works in:

  • Browsers
  • Node.js
  • Serverless / Edge functions

Requires a secure backend proxy for API keys.


🔧 Development

git clone https://github.com/agentary-ai/agentary-js.git
cd agentary-js
npm install
npm run build
npm run dev
npm test

📄 License

MIT License.


🙋‍♀️ Support

  • Documentation
  • GitHub Issues
  • Discussions

🤝 Contributing

See .github/CONTRIBUTING.md.