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

lemura

v1.5.3

Published

Provider-agnostic agentic AI runtime

Readme

lemura

A provider-agnostic, premium agentic AI runtime for the modern web.

npm version license docs build coverage


lemura is a robust, provider-agnostic npm package designed to encapsulate a full agentic AI runtime. It simplifies the complex orchestration of LLMs, tools, and context management into a single, cohesive interface.

❓ Why lemura?

  • Zero Lock-in: Switch between OpenAI, Anthropic, Groq, or local Ollama instances by changing one line of code.
  • Production Ready: Built-in context compression, tool retry logic, and execution budget enforcement.
  • Developer First: Premium logging, native TypeScript types, and Model Context Protocol (MCP) support.

✨ Key Features

  • 🧠 Dynamic Skill Market: Switch skills on/off at runtime via tags, names, or tool dependencies.
  • 🔌 Native MCP Support: Connect to any Model Context Protocol server with custom header support (Auth).
  • 🛡️ Tool Firewall: Fully integrated ask/accept/deny policy layer for secure tool execution.
  • 🎯 Goal Maintenance: LLM-powered sub-goal decomposition and status tracking across turns.
  • 🧹 Summary Injection: Automatically compresses history while ensuring the model never "forgets" the context.
  • 🌊 Native Streaming: Token-by-token completion for smooth, responsive user experiences.
  • 📊 Observability: Detailed tracing, token tracking, and structured logging with actionable hints.

🚀 Install

pnpm add lemura
# or
npm install lemura

⚙️ Environment Variables

The built-in OpenAICompatibleAdapter can be configured using environment variables. To load them from a .env file in Node.js, you'll typically need a library like dotenv:

npm install dotenv

Then at the very top of your entry point:

import 'dotenv/config';

Create a .env file in your project root:

# Provider Configuration (OpenAI, Groq, Together, Ollama, etc.)
LEMURA_API_KEY=your_api_key_here
LEMURA_BASE_URL=https://api.openai.com/v1
LEMURA_MODEL=gpt-4o-mini

# Fallbacks (Lemura also checks standard OpenAI variables)
OPENAI_API_KEY=your_api_key_here
OPENAI_BASE_URL=https://api.openai.com/v1
OPENAI_MODEL=gpt-4o-mini

⚡ Quick Start

import { SessionManager, OpenAICompatibleAdapter } from 'lemura';

async function main() {
  const adapter = new OpenAICompatibleAdapter({
    baseUrl: 'https://api.openai.com/v1',
    apiKey: process.env.OPENAI_API_KEY || '',
    defaultModel: 'gpt-4o-mini'
  });

  const session = new SessionManager({
    adapter,
    model: 'gpt-4o-mini',
    maxTokens: 100000,
  });

  const response = await session.run('What is lemura?');
  console.log(response);

  // Or stream the final response token-by-token
  for await (const token of session.stream('What is lemura?')) {
    process.stdout.write(token);
  }
}

main();

🛠️ Quick Start: Creating a Tool

Adding tools to your agent is straightforward using the standard IToolDefinition interface.

import { IToolDefinition } from 'lemura';

const getWeather: IToolDefinition = {
  name: 'get_weather',
  description: 'Get the current weather for a specific city',
  parameters: {
    type: 'object',
    properties: {
      city: { type: 'string', description: 'The name of the city' }
    },
    required: ['city']
  },
  execute: async ({ city }) => {
    // Call your weather API here
    return `The weather in ${city} is sunny, 22°C.`;
  }
};

// Register it when creating the session
const session = new SessionManager({
  adapter,
  model: 'gpt-4o-mini',
  tools: [getWeather]
});

🧠 Core Concepts

Explore the architecture and advanced capabilities of lemura at lemura.makix.fr or browse the local guides:

📦 API Overview

| Export | Description | |---|---| | SessionManager | The main entry point orchestrating the ReAct loop and tools. | | ContextManager | Manages the conversation history using compression strategies. | | OpenAICompatibleAdapter | Reference adapter for OpenAI, Groq, Together, etc. | | ToolRegistry | Registers and executes tools for the agent. | | SkillInjector | Loads and formats YAML/Markdown skills into system prompts. | | DefaultLogger | Colorized logger with Problem/Hints metadata support. |

🪵 Logging and Tracing

lemura features a premium, structured logging system designed for developer experience. It provides colorized output and actionable hints for errors.

import { SessionManager, DefaultLogger, LogLevel } from 'lemura';

const logger = new DefaultLogger();
logger.setLevel(LogLevel.DEBUG); // Set to show trace-level information

const session = new SessionManager({
  adapter,
  model: 'gpt-4o-mini',
  maxTokens: 100000,
  logger: logger // Inject the logger
});

When an error occurs (like an invalid API key), lemura provides beautiful, structured feedback:

2026-03-07T13:05:49.686Z [FATAL] Provider call failed: HTTP 401: Unauthorized
  PROBLEM: Authentication failed. The API key is invalid or missing.
  HINTS:
    - Ensure your API key is correctly configured in the adapter or environment variables.
    - Check if the API key has expired or been revoked.

🔌 Provider Adapters

lemura interacts with LLMs exclusively through the IProviderAdapter interface, ensuring zero lock-in.

| Adapter | Status | Description | |---|---|---| | OpenAICompatibleAdapter | ✅ Built-in | Wrapper for OpenAI and API-compatible endpoints. |

[!TIP] To write a custom adapter for another provider, see the Custom Adapter Recipe.

🤝 Contributing

We welcome contributions! Please read our Internal Rules and Documentation Guidelines before submitting a PR.

📄 License

Distributed under the MIT License. See LICENSE for more information.