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

@elgap/ai-composer

v2.0.0

Published

An open-source, minimalist AI Composer for orchestrating ideas. Powered by @elgap/ai-connect.

Downloads

3

Readme

@elgap/ai-composer

npm version License: Apache 2.0

An opinionated, minimalist engine for creating safe, constitution-based AI agents.

Philosophy

@elgap/ai-composer is built on a simple but powerful idea: every great agent, like every great society, needs a constitution. The system prompt is not just a suggestion; it is the fundamental, unchangeable law that governs all of the agent's behavior.

This "constitution-first" approach ensures that your agent remains focused, predictable, and safe, embodying the ElGap principle: Substance First. Then Precision.

Note on ElGap Ecosystem

Built on top of @elgap/ai-connect for seamless integration (currently supports only Ollama).

Both, @elgap/ai-connect and @elgap/ai-composer are under continuous development. At the moment they support only /api/generate Ollama endpoint (single response object or stream of objects).

A Note on Co-Creation

This package was co-created in a deep, multi-month symbiotic dialogue between a human artisan Ivan Pavković and AI (Google's Gemini). The process served as both a real-world case study in Human-AI partnership and as a practical journey for Ivan to learn TypeScript, npm package creation and dive into world of LLM's and prompt engineering. The code you see is a direct result of this iterative, "sparring" process.

Features

  • Built-in default system prompt
  • Enforces a strict separation between the agent's "constitution" (system prompt), Agent purpose and scope (agentExpertise) and user input.
  • Required Agent expertise for defining Agent purpose and scope.
  • Support for chat history.
  • Support for token usage.
  • Simple, declarative API for creating and interacting with LLMs.

Installation

npm install @elgap/ai-composer @elgap/ai-connect

Quick Start

import { LLMResponse, OllamaProvider, OllamaProviderOptionsInput } from '@elgap/ai-connect';
import { Composer } from '@elgap/ai-composer';

/**
 * Configuration
 */
const model: string = 'llama3.1:latest'; //Set model to math your locally running agent
const baseUrl: string = 'http://localhost:11434'; //Default for Ollama, adjust if it's elsewhere
const temperature: number = 0.7; // 0 for precision, 1.0 for creativity

const options: OllamaProviderOptionsInput = {
    model,
    baseUrl,
    temperature
}
//Create provider
const provider = new OllamaProvider(options);

//Define Agent expertise and scope
const agentExpertise = "You can talk only about the sky and it's colors";

//Create Agent
const agent:Composer = Composer.create(provider, agentExpertise);

//Function to get Agent response
async function getAgentResponse(userInput:string):Promise<LLMResponse>
{
    return await agent.compose(userInput);
}

//Define user input
let userInput:string = 'Why the sky is blue';

getAgentResponse(userInput).then(function(response:LLMResponse):void {
    console.log("User: ", userInput);
    console.log("Agent response: ", response.content);
    console.log("Token Usage: ", response.usage);
});

Examples

You can find a collection of ready-to-run examples in the /examples directory. We encourage you to clone the repository and experiment.

npm run example:ollama
npm run example:ollamaStreaming
npm run example:ollamaChat

API Reference

Composer.create(provider, agentExpertise)
  • provider: An instance of an AI provider (e.g., OllamaProvider from @elgap/ai-connect).
  • agentExpertise: string - Agent expertise and scope.
  • Returns: An instance of Composer
agent.compose(prompt, Chathistory)
  • prompt: string - The user's message.
  • chatHistory?: string[] - An optional array of previous conversation turns.
  • Returns: Promise - The agent's final response.

License

This project is licensed under the Apache 2.0 License.