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

@mlhkinfotech/ai-agent

v1.0.3

Published

Enterprise-ready AI Agent Engine with multi-provider LLM, memory & tool-calling

Readme

@mlhkinfotech/ai-agent

npm version License: MIT

Enterprise AI Brain Engine for conversational WhatsApp bots with multi-provider LLM support (Google Gemini & OpenRouter), sliding conversation memory, intent recognition, and dynamic tool-calling.


🚀 Features

  • Multi-Provider LLM:
    • Google Gemini: Direct integration with gemini-1.5-flash, gemini-1.5-pro, gemini-2.0-flash.
    • OpenRouter: Access to 100+ models (Claude 3.5 Sonnet, DeepSeek R1, GPT-4o, Llama 3.3).
  • Conversation Memory Manager: Per-contact sliding conversation buffer with TTL and max message history.
  • Dynamic Tool Calling: Register custom tools and functions that the AI can call seamlessly to fetch data or trigger actions.
  • Intent Recognition Engine: Fast heuristic intent classification (greetings, product search, order placement, human handoff, FAQs).
  • System Prompt Templating: Easily tailor persona, business rules, tone, and policies.

📦 Installation

npm install @mlhkinfotech/ai-agent

💻 Quick Start

Basic Gemini Agent

import { AIAgent } from '@mlhkinfotech/ai-agent';

const agent = new AIAgent({
  provider: 'gemini',
  apiKey: process.env.GEMINI_API_KEY!,
  model: 'gemini-1.5-flash',
  systemPrompt: `You are the friendly AI assistant for "Apex Electronics".
Answer questions concisely and politely in WhatsApp style.`
});

// Process an incoming customer message
const response = await agent.process({
  contactId: '[email protected]',
  contactName: 'Rahul Sharma',
  message: 'Do you have iPhone 15 Pro Max in stock?'
});

console.log('AI Reply:', response.reply);

OpenRouter Multi-Model Agent (e.g., DeepSeek / Claude)

import { AIAgent } from '@mlhkinfotech/ai-agent';

const agent = new AIAgent({
  provider: 'openrouter',
  apiKey: process.env.OPENROUTER_API_KEY!,
  model: 'deepseek/deepseek-chat', // or 'anthropic/claude-3.5-sonnet'
  systemPrompt: 'You are an intelligent sales consultant.'
});

Adding Custom Tools (Function Calling)

import { AIAgent, ToolRegistry } from '@mlhkinfotech/ai-agent';

const agent = new AIAgent({
  provider: 'gemini',
  apiKey: process.env.GEMINI_API_KEY!
});

// Register a real-time order tracking tool
agent.registerTool({
  name: 'track_order',
  description: 'Lookup current delivery status of an order by Order ID',
  parameters: {
    type: 'object',
    properties: {
      orderId: { type: 'string', description: 'The numeric or alphanumeric order ID' }
    },
    required: ['orderId']
  },
  handler: async ({ orderId }) => {
    // Database or API lookup
    return {
      orderId,
      status: 'Out for delivery',
      courier: 'BlueDart',
      estimatedArrival: 'Today by 5:00 PM'
    };
  }
});

// AI will automatically invoke the tool when customer asks: "Where is my order #12345?"
const result = await agent.process({
  contactId: 'customer_1',
  message: 'Please check where my order #12345 has reached.'
});

console.log(result.reply);

Conversation Memory Buffer

import { MemoryManager } from '@mlhkinfotech/ai-agent';

const memory = new MemoryManager({
  maxMessagesPerUser: 20, // Keep last 20 messages per contact
  ttlMs: 24 * 60 * 60 * 1000 // Expire inactive chat history after 24 hours
});

// Add message
memory.addMessage('user-1', { role: 'user', content: 'My name is Amit' });
memory.addMessage('user-1', { role: 'assistant', content: 'Nice to meet you, Amit!' });

// Get chat history for AI context
const history = memory.getHistory('user-1');

📄 License

MIT © MLHK Infotech