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

agl-ai

v0.1.7

Published

Minimalist Pydantic AI clone in Bun JavaScript.

Readme

Another Generative Language (AnGeL) 👼

A minimalist Pydantic AI clone in Bun JavaScript.

Lightweight AI agent framework with tool calling -- zero dependencies.

Requirements

Install

npm install agl-ai

Usage

Below is a simplistic example from the unit tests:

Omit model (or pass null / '') to use the user default from ~/.config/agl/config.yaml:

default_model: llama-server:gemma-4-12b-qat

context_windows:
  llama-server:
    default: 1048576
    gemma-4-12b-qat: 1048576
  xai:
    default: 131072
    grok-4.6: 500000

That file is re-read on every inference when the caller omitted a model, and on every resolveContextWindow / listModels call, so a disk edit switches every AGL-dependent app without a restart and without probing providers. Override the path with AGL_CONFIG_PATH. If the file is missing, AGL falls back to llama-server:gemma-4-12b-qat and a 32_768 token window.

import Agent from 'agl-ai';

// Uses ~/.config/agl/config.yaml default_model
const agent = await Agent.factory({
  system_prompt: 'You are a helpful assistant.',
});

// Simple completion with an explicit model
const grok = await Agent.factory({
  model: 'xai:grok-4-1-fast-reasoning',
  system_prompt: 'You are a helpful assistant. The date is {{date}}.',
  locals: { date: new Date().toLocaleString() }, // optional Handlebars-like substitution
  reasoning_effort: 'high', // optional; omitted/blank → provider default
});
const result = await agent.run({ prompt: 'What is 2+2?' });

// mycloud / llama-server — pass this instance's URL + API key (do not rely on
// process-wide MYCLOUD_BASE_URL, which may still point at a previous VM)
const llama = await Agent.factory({
  model: 'mycloud:qwen-3.8-27b',
  base_url: 'https://HOST:1234',
  api_key: instanceApiKey,
  ca_file: process.env.MYCLOUD_CA_FILE, // optional; default ~/.mycloud/cert.pem
});
await llama.run({ prompt: '2+2?' });

// dad-proxy (or any OpenAI-compat gateway): every provider:model is POSTed
// there as-is. `host:port` becomes https://host:port.
const viaProxy = await Agent.factory({
  model: 'xai:grok-4.6',
  proxy: 'host.containers.internal:1234',
  api_key: process.env.DAD_PROXY_API_KEY,
  ca_file: '/opt/certs/ca.pem',
});
await viaProxy.run({ prompt: '2+2?' });

// Tool calling
const agent = await Agent.factory({
  model: 'xai:grok-4-1-fast-reasoning',
  system_prompt: 'Use the roulette_wheel function to check if the customer won.',
  output_tool: { type: 'boolean' },
  parallel_tools: true, // execute multiple tool calls concurrently (default: false)
  max_turns: 5, // cap provider rounds when output_tool is required (default 5; stops nudge loops)
});

agent.Tool('roulette_wheel', 'check if the square is a winner', {
  v1: { type: 'integer' },
}, ['v1'], async (ctx, { v1 }) => {
  return ctx.magic_num == v1 ? 'winner' : 'loser';
});

// Or pass a named function that carries its own schema:
//   fn.description / fn.parameters / fn.required  (name = fn.name)
//   agent.Tool(desk_light)

const magic_num = 18;
const result1 = await agent.run({ prompt: 'Put my money on square eighteen', magic_num });
log('', { result1 }); // => true

const result2 = await agent.run({ prompt: 'I bet five is the winner', magic_num });
log('', { result2 }); // => false

locals is optional. When it is a plain object, system_prompt is compiled as a Handlebars-like template ({{name}}, {{#if}} / {{#unless}} / {{#each}} / {{#with}}, whitespace ~, \{{escape}}) against those values, once at factory time. Omit locals and the prompt is unchanged — including any literal {{...}}. Implementation: src/lib/mini-handlebars.mjs (no extra dependency).

AI Providers

These are supported.

| Provider | Model format | Auth | |----------|-------------|------| | xAI | xai:<model> | XAI_API_KEY env var | | Copilot | copilot:<model> | Tokenman-injected Copilot session | | Ollama | ollama:<model> | None (localhost) | | LM Studio | lm-studio:<model> | None (localhost LM Studio; native /api/v0 plus OpenAI /v1) | | RunPod | runpod:<model> | RUNPOD_BASE_URL (OpenAI-compatible pod proxy/tunnel) | | llama-server | llama-server:<model> | Local llama.cpp (default http://127.0.0.1:1234). Optional LLAMA_SERVER_BASE_URL / LLAMA_SERVER_API_KEY. Does not use MYCLOUD_BASE_URL. | | mycloud | mycloud:<model> | MYCLOUD_BASE_URL + MYCLOUD_API_KEY (HTTPS llama.cpp, e.g. GCE :1234). Optional MYCLOUD_CA_FILE for a self-signed cert (default ~/.mycloud/cert.pem). Override per agent with Agent.factory({ base_url, api_key, ca_file }). | | gateway / dad-proxy | any provider:model | Agent.factory({ proxy: 'host:port', api_key, ca_file }). Skips native provider clients; POSTs OpenAI chat completions to the proxy with the full model id. | | Meta | meta:<model> (alias muse:<model>) | META_API_KEY or legacy MUSE_API_KEY |

Credentials are supplied through the process environment. With Tokenman:

op run --env-file=<(tokenman script agl-xai) -- bun src/agents/home.mjs 'hello'
op run --env-file=<(tokenman script agl-copilot) -- bun src/agents/home.mjs 'hello'

Tokenman owns provider refresh and any required interactive login; AGL does not read .env or persist provider tokens.

Running

bun src/agents/home.mjs turn on my desk light     # run an agent
DEBUG=1 bun src/agents/home.mjs set lights red    # with debug logging

bun test                                          # unit tests (test/unit/)

Related