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

laigents

v1.2.15

Published

A simple set of abstractions for building AI agents and workflows

Readme

Laigents

For those of us who want to be lazy and build agents.

A simple to use set of abstractions for building AI agents and workflows. This system allows developers to instantiate agents and instruct workflows to complete tasks, with built-in support for memory and file operations.

Features

  • 🤖 Simple agent creation and management
  • 💾 Built-in memory management with Pinecone
  • 📝 File operations support
  • 🔄 Workflow automation
  • 🎯 Task-focused design
  • 🔌 Extensible adapter system

Installation

# Using npm
npm install laigents

# Using yarn
yarn add laigents

# Using pnpm
pnpm add laigents

Environment Setup

Create a .env file in your project root:

# OpenAI Configuration
OPENAI_API_KEY=your_openai_api_key
OPENAI_EMBEDDING_MODEL=text-embedding-ada-002  # Optional

# Pinecone Configuration
PINECONE_API_KEY=your_pinecone_api_key
PINECONE_ENVIRONMENT=your_pinecone_environment
PINECONE_INDEX=your_pinecone_index

Basic Usage

import { Laigent, AgentConfig, SystemConfig } from 'laigents';
import dotenv from 'dotenv';

dotenv.config();

// Configure your agents
const agents: AgentConfig[] = [
  {
    name: 'smith',
    systemPrompt: 'You are a helpful assistant.',
    purpose: 'answering',
    response: {
      type: 'code',
      language: 'typescript',
      maxTokens: 300,
    },
  },
];

// Configure the system
const config: SystemConfig = {
  openaiApiKey: process.env.OPENAI_API_KEY!,
  pineconeApiKey: process.env.PINECONE_API_KEY!,
  pineconeEnvironment: process.env.PINECONE_ENVIRONMENT!,
  pineconeIndexName: process.env.PINECONE_INDEX!,
  embeddingModel: process.env.OPENAI_EMBEDDING_MODEL,
};

// Create and initialize the Laigent instance
const ai = new Laigent(agents, config);

async function main() {
  await ai.initialize();
  const agent = ai.getAgent('smith');

  // Prompt the agent
  const response = await agent.prompt('I need a function that returns the sum of two numbers.');

  // Write the response to a file
  await agent.writeFile('sum.ts', response);

  // Read the file
  const readFileResult = await agent.readFile('sum.ts');
  console.log(readFileResult);

  // Save something to memory
  await agent.saveInMemory(readFileResult, 'text');

  // Search memory
  const memory = await agent.searchMemory('sum');
  console.log(memory);
}

main();

Advanced Usage

Multi-Agent Workflows

import { Laigent, AgentConfig, SystemConfig } from 'laigents';
import dotenv from 'dotenv';

dotenv.config();

// Configure multiple agents for different tasks
const agents: AgentConfig[] = [
  {
    name: 'function_creator',
    systemPrompt:
      'You are a TypeScript function creator. You create well-documented, efficient functions.',
    purpose: 'coding',
    response: {
      type: 'code',
      language: 'typescript',
      maxTokens: 300,
    },
  },
  {
    name: 'documenter',
    systemPrompt: 'You are a documentation expert. You create clear, comprehensive documentation.',
    purpose: 'reasoning',
    response: {
      type: 'markdown',
      maxTokens: 300,
    },
  },
];

// Configure the system
const config: SystemConfig = {
  openaiApiKey: process.env.OPENAI_API_KEY!,
  pineconeApiKey: process.env.PINECONE_API_KEY!,
  pineconeEnvironment: process.env.PINECONE_ENVIRONMENT!,
  pineconeIndexName: process.env.PINECONE_INDEX!,
  embeddingModel: process.env.OPENAI_EMBEDDING_MODEL,
};

// Create and initialize the Laigent instance
const ai = new Laigent(agents, config);

async function main() {
  await ai.initialize();

  // Get both agents
  const functionCreator = ai.getAgent('function_creator');
  const documenter = ai.getAgent('documenter');

  // Create a function
  const functionCode = await functionCreator.prompt(
    'Create a function that calculates the factorial of a number.'
  );

  // Write the function to a file
  await functionCreator.writeFile('factorial.ts', functionCode);

  // Get documentation for the function
  const functionDoc = await documenter.prompt(
    'Create documentation for this factorial function: ' + functionCode
  );

  // Write the documentation
  await documenter.writeFile('factorial.md', functionDoc);

  // Read both files
  const code = await functionCreator.readFile('factorial.ts');
  const docs = await documenter.readFile('factorial.md');

  console.log('Function Code:\n', code);
  console.log('Function Documentation:\n', docs);
}

main();

API Documentation

Laigent Class

The main class for managing agents and their configurations.

new Laigent(
  agents: AgentConfig[],
  config: SystemConfig
)

Methods

  • initialize(): Promise<void> - Initialize the instance and all agents
  • getAgent(name: string): Agent - Get an agent by name
  • getAllAgents(): Agent[] - Get all initialized agents
  • getAgentNames(): string[] - Get names of all agents

Agent Class

The class representing individual agents.

Methods

  • prompt(prompt: string): Promise<string> - Send a prompt to the agent
  • saveInMemory(content: string, contentType: ContentType): Promise<string[]> - Save content to agent's memory
  • searchMemory(query: string, limit?: number, filter?: MemorySearchFilter): Promise<Memory[]> - Search agent's memory
  • readFile(path: string): Promise<string> - Read a file
  • writeFile(path: string, content: string | object): Promise<void> - Write to a file
  • appendFile(path: string, content: string): Promise<void> - Append to a file
  • fileExists(path: string): Promise<boolean> - Check if a file exists
  • createDirectory(path: string): Promise<void> - Create a directory
  • executeCommand(command: string): Promise<string> - Execute a shell command

For more detailed documentation and examples, visit our GitHub repository.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT