A production-grade AI agent framework with 21 integrated tool classes and a four-role autonomous LLM pipeline โ built on the NPMAI ECOSYSTEM.
Project description
โฆ What is npmai_agents?
npmai_agentsis a monolithic, production-grade desktop AI agent framework โ a single Python package containing 21 integrated tool classes and a 4-role autonomous LLM pipeline (Planner โ Coder โ Auditor โ Verifier) that can execute any plain-English task on your computer.
No GPT-4. No Gemini. No monthly bills.
Everything runs free on 45+ open-source LLMs served by the NPMAI ECOSYSTEM load balancer.
pip install npmai_agents
from npmai_agents import AgentBrain
brain = AgentBrain()
brain.run_task("Organise my Downloads folder and email me a summary")
# โ That's it. The agent plans, codes, audits, executes, verifies โ by itself.
๐๏ธ Built by NPMAI ECOSYSTEM
npmai_agents is an official product of the NPMAI ECOSYSTEM โ a free, open-source AI research and development platform serving developers and researchers worldwide.
|
๐ค Founder |
๐ Ecosystem Stats |
โก Why npmai_agents?
| ๐ด The Problem | ๐ข npmai_agents Solution |
|---|---|
| Paid LLM APIs (GPT-4, Claude, Gemini) | 45+ free LLMs via NPMAI load balancer |
| Single-model, single-purpose agents | 4 specialized LLM roles in one pipeline |
| Scattered automation libraries | 21 tool classes in one package |
| Plain-text credential storage | Fernet-encrypted CredStore (machine key) |
| No memory between sessions | Persistent Memory via npmai.Memory |
| Manual document Q&A setup | LARA RAG pipeline built-in |
| Complex dependency management | Auto-installs everything on first run |
| Fragile single-attempt execution | Up to 12 auto-retries per step with error feedback |
๐ Features
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ npmai_agents v0.0.1 โ
โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โ โ 21 TOOLS โ โ 4-LLM PIPE โ โ FERNET ENC โ โ
โ โ one package โ โ autonomous โ โ credentials โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โ โ LARA RAG โ โ 12x RETRY โ โ KILL SWITCH โ โ
โ โ built-in โ โ per step โ โ mid-task โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โ โ WORKSPACE โ โ PERSISTENT โ โ SECURITY โ โ
โ โ scanner โ โ memory โ โ auditor โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- ๐ง 21 integrated tool classes โ email, files, PDF, web, spreadsheets, GitHub, Slack, Discord, WhatsApp, Notion, Twitter, system, images, scheduler, Jira, Telegram, QR, voice, watcher, RAG, SSH
- ๐ง Four-role LLM pipeline โ each role runs a different model optimised for its purpose
- ๐ Built-in security auditor โ every generated code block is scanned before execution
- ๐ Fernet-encrypted CredStore โ machine-specific AES key, never plain text
- ๐ LARA RAG integration โ query and summarise any document
- ๐พ Persistent memory โ separate contexts for planning, coding, chat, task history
- โป๏ธ Auto-dependency installer โ missing packages pip-installed on first run
- ๐ฏ 12 auto-retries per step โ error output fed back to the coder LLM
- ๐ฅ๏ธ Workspace scanner โ agent builds a live file-system profile before planning
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโ
Plain English โ โ
Task Input โโโถ โ AgentBrain โ
โ โ
โ โโโโโโโโโโโโโโโโโโโ โ
โ โ 1. WORKSPACE โ โ โโโ scans Desktop, Downloads,
โ โ SCANNER โ โ Documents, Pictures, etc.
โ โโโโโโโโโโฌโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโผโโโโโโโโโ โ
โ โ 2. PLANNER โ โ โโโ llama3.2:3b / mistral:7b
โ โ LLM โ โ breaks task โ 2โ5 steps
โ โโโโโโโโโโฌโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโผโโโโโโโ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ per step: โ โ โ repeats up to 12 times โ
โ โ โ โ โ on failure, feeding โ
โ โ 3. CODER โโโโโโโโโโโ error output back to โ
โ โ LLM โ โ โ the Coder LLM โ
โ โ 4. AUDITOR โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ LLM โ โ
โ โ 5. EXECUTE โ โ
โ โ 6. VERIFY โ โ
โ โโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
Task Complete โ
| Role | Default Model | Fallback | Job |
|---|---|---|---|
| ๐บ๏ธ Planner | llama3.2:3b |
mistral:7b |
Breaks task into 2โ5 atomic steps |
| ๐ป Coder | codellama:7b-instruct |
deepseek-coder:6.7b |
Generates executable Python code |
| ๐ก๏ธ Auditor | qwen2.5-coder:7b |
falcon:7b-instruct |
Security scan before execution |
| โ Verifier | llama3.2:3b |
mistral:7b |
Confirms step completed successfully |
| ๐ฌ Chatter | granite3.3:2b |
llama3.2:1b |
General Q&A / conversational mode |
All models served free via NPMAI ECOSYSTEM load balancer with change=True auto-fallback.
๐ฆ Installation
pip install npmai_agents
Auto-installs all dependencies on first run. Or pre-install everything:
pip install npmai_agents[full]
Import styles:
# Import specific classes
from npmai_agents import AgentBrain, CredStore, EmailTool, FileTool
# Import the whole module
import npmai_agents
๐ Documentation
๐ CredStore โ Encrypted Credential Vault
Configure once. All 21 tools read from here. Stored at
~/.npmai_agent/creds.jsonwith a machine-specific Fernet key.
from npmai_agents import CredStore
# โโ Save credentials โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
CredStore.save("gmail", {
"email": "you@gmail.com",
"password": "your-app-password", # Gmail App Password, not login password
"smtp_host": "smtp.gmail.com",
"smtp_port": 587,
"imap_host": "imap.gmail.com"
})
CredStore.save("github", {"token": "ghp_xxxxxxxxxxxxxxxxxxxx"})
CredStore.save("slack", {"bot_token": "xoxb-xxxxxxxxxxxx"})
CredStore.save("notion", {"token": "secret_xxxxxxxxxxxx"})
CredStore.save("telegram", {"bot_token": "1234567890:AAxxxxxxxxxxxxxx"})
CredStore.save("twitter", {
"api_key": "...", "api_secret": "...",
"access_token": "...", "access_token_secret": "..."
})
CredStore.save("jira", {
"server": "https://yourworkspace.atlassian.net",
"email": "you@company.com",
"api_token": "your-jira-api-token"
})
CredStore.save("ssh", {"user": "ubuntu", "password": "secret"})
# or with SSH key: CredStore.save("ssh", {"user": "ubuntu", "key_path": "~/.ssh/id_rsa"})
# โโ Load & inspect โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
creds = CredStore.load("gmail")
print(creds["email"])
print(CredStore.all_keys())
# ['gmail', 'github', 'slack', 'notion', 'telegram', 'jira', 'ssh']
Credential reference by tool:
| Tool | cred_key |
Required fields |
|---|---|---|
EmailTool |
"gmail" |
email, password, smtp_host, smtp_port, imap_host |
GitHubTool |
"github" |
token |
SlackTool |
"slack" |
bot_token |
SpreadsheetTool |
"google" |
Full service account JSON as dict |
NotionTool |
"notion" |
token |
TwitterTool |
"twitter" |
api_key, api_secret, access_token, access_token_secret |
JiraTool |
"jira" |
server, email, api_token |
TelegramTool |
"telegram" |
bot_token |
SSHTool |
"ssh" |
user, password or key_path |
๐ฅ๏ธ Workspace โ File System Context
from npmai_agents import Workspace
ws = Workspace()
profile = ws.scan() # scans Desktop, Downloads, Documents, etc.
print(profile["os"]) # 'Windows' / 'Darwin' / 'Linux'
print(profile["home"]) # '/home/sonu'
print(profile["paths"]) # { 'desktop': { path, files }, ... }
ws.update_profile("user_name", "Sonu Kumar")
print(ws.context_summary()) # short text fed to the Planner LLM
๐ง EmailTool
from npmai_agents import EmailTool
# Send a single email
result = EmailTool.send(
to="friend@example.com",
subject="Hello from npmai_agents",
body="<h1>Sent by an AI agent!</h1>"
)
print(result) # โ Email sent to friend@example.com
# With attachments
result = EmailTool.send(
to="boss@company.com",
subject="Monthly Report",
body="Report attached.",
attachments=["/home/sonu/report.pdf"]
)
# Read inbox
result = EmailTool.read_inbox(count=10)
for msg in result.data:
print(msg["from"], "|", msg["subject"])
# Bulk email from CSV (must have 'name' + 'email' columns)
result = EmailTool.send_bulk(
csv_path="contacts.csv",
subject="NPMAI Launch Invite",
body_template="<p>Hello {name}, you're invited!</p>"
)
print(result) # โ Sent 42 emails, 0 failed
๐ FileTool
from npmai_agents import FileTool
# Bulk rename
FileTool.bulk_rename("/home/sonu/Docs", pattern="*.txt", prefix="NPMAI_", add_date=True)
# Zip / unzip
FileTool.zip_folder("/home/sonu/project", dest="/home/sonu/project.zip")
FileTool.unzip("/home/sonu/archive.zip", dest="/home/sonu/extracted")
# Find files
result = FileTool.find_files("/home/sonu", pattern="*.py", recursive=True)
print(result.data) # ['/home/sonu/agent.py', ...]
# Organize by type โ creates Images/ Videos/ Docs/ Code/ etc.
FileTool.organize_by_type("/home/sonu/Downloads")
# Read / write
content = FileTool.read_file("/home/sonu/notes.txt").data
FileTool.write_file("/home/sonu/out.txt", "Generated by npmai_agents.")
# Copy tree
FileTool.duplicate_tree("/home/sonu/project", "/home/sonu/project_backup")
๐ PDFTool
from npmai_agents import PDFTool
# Extract text
text = PDFTool.extract_text("/home/sonu/paper.pdf").data
# Merge PDFs
PDFTool.merge(["/home/sonu/ch1.pdf", "/home/sonu/ch2.pdf"], out="/home/sonu/book.pdf")
# Split into pages
PDFTool.split("/home/sonu/doc.pdf", out_dir="/home/sonu/pages")
๐ WebTool
from npmai_agents import WebTool
# Scrape page text
result = WebTool.scrape("https://npmai.netlify.app")
# Scrape with CSS selector
result = WebTool.scrape("https://example.com", selector="h2")
print(result.data) # ['Title 1', 'Title 2', ...]
# Download a file
WebTool.download_file("https://example.com/file.pdf", dest="/home/sonu/file.pdf")
# Full-page screenshot
WebTool.screenshot_url("https://npmai.netlify.app", out="screenshot.png")
# Browser automation (Playwright)
WebTool.browser_action("https://example.com/login", actions=[
{"type": "fill", "selector": "#username", "value": "sonu"},
{"type": "fill", "selector": "#password", "value": "secret"},
{"type": "click", "selector": "#login-btn"},
{"type": "wait", "ms": 2000},
{"type": "screenshot", "path": "after_login.png"}
])
# Raw API call
result = WebTool.api_call(
url="https://api.example.com/data",
method="POST",
headers={"Authorization": "Bearer token"},
payload={"query": "test"}
)
print(result.data) # parsed JSON
๐ SpreadsheetTool
from npmai_agents import SpreadsheetTool
# Read CSV โ pandas DataFrame
df = SpreadsheetTool.read_csv("/home/sonu/data.csv").data
# Write to Excel
SpreadsheetTool.write_excel(
data=[{"name": "Sonu", "age": 15}],
path="/home/sonu/out.xlsx",
sheet="Founders"
)
# Google Sheets (needs 'google' cred with service account JSON)
result = SpreadsheetTool.google_sheets_read(sheet_id="1Bxi...", range_="Sheet1")
print(result.data) # list of row dicts
๐ GitHubTool
from npmai_agents import GitHubTool
# Create issue
GitHubTool.create_issue(
repo="sonuramashishnpm/npmai",
title="Add voice input support",
body="Feature request...",
labels=["enhancement"]
)
# Push file (creates or updates)
GitHubTool.push_file(
repo="sonuramashishnpm/npmai",
path="docs/agent.md",
content="# npmai_agents docs\n...",
message="docs: add agent docs"
)
# List issues
for issue in GitHubTool.list_issues("sonuramashishnpm/npmai").data:
print(issue["#"], issue["title"])
# Get README
print(GitHubTool.get_readme("sonuramashishnpm/npmai").data[:300])
# Clone & commit-push
GitHubTool.clone_repo("https://github.com/sonuramashishnpm/npmai.git", "/home/sonu/npmai")
GitHubTool.git_commit_push("/home/sonu/npmai", "feat: new endpoints")
๐ฌ SlackTool
from npmai_agents import SlackTool
SlackTool.send_message("#general", "npmai_agents task done โ")
for msg in SlackTool.read_channel("#dev-logs", limit=20).data:
print(msg["user"], ":", msg["text"])
SlackTool.upload_file("#reports", "/home/sonu/report.pdf", comment="Weekly AI report")
๐ฎ DiscordTool
from npmai_agents import DiscordTool
WEBHOOK = "https://discord.com/api/webhooks/xxxx/yyyy"
DiscordTool.send_webhook(WEBHOOK, "๐ Deployment complete!")
DiscordTool.send_webhook(WEBHOOK, "Update:", embeds=[{
"title": "Step 3 Done",
"description": "All files organized.",
"color": 3066993
}])
๐ฑ WhatsAppTool
from npmai_agents import WhatsAppTool
# Requires WhatsApp Web open in browser
WhatsAppTool.send(phone="+919876543210", message="Hello from npmai_agents!", wait=15)
๐ NotionTool
from npmai_agents import NotionTool
NotionTool.create_page(
parent_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
title="NPMAI Research Notes",
content="Auto-created by npmai_agents."
)
NotionTool.add_db_entry(
db_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
props={
"Name": {"title": [{"text": {"content": "Task Done"}}]},
"Status": {"select": {"name": "Done"}}
}
)
๐ฆ TwitterTool
from npmai_agents import TwitterTool
TwitterTool.tweet("Just automated my workflow with npmai_agents ๐ค #OpenSource #AI")
โ๏ธ SystemTool
from npmai_agents import SystemTool
# Shell command
print(SystemTool.run_command("ls -la /home/sonu", timeout=30).output)
# Clipboard
SystemTool.set_clipboard("Copied by npmai_agents")
print(SystemTool.get_clipboard().data)
# Screenshot
SystemTool.screenshot(out="/home/sonu/screen.png")
# Processes
for p in SystemTool.get_processes().data[:5]:
print(p["name"], p["cpu"], "%")
# Desktop notification
SystemTool.notify("npmai_agents", "Task complete!")
๐ผ๏ธ ImageTool
from npmai_agents import ImageTool
ImageTool.resize("/home/sonu/photo.jpg", width=800, height=600, out="resized.jpg")
ImageTool.convert("/home/sonu/photo.jpg", format="PNG", out="photo.png")
# OCR
text = ImageTool.ocr("/home/sonu/scanned.png").data
print(text)
# Bulk compress
ImageTool.bulk_compress("/home/sonu/Pictures", quality=75)
โฑ๏ธ SchedulerTool
from npmai_agents import SchedulerTool
def daily_job():
print("Running daily task!")
SchedulerTool.schedule_task("heartbeat", "every 5 minutes", daily_job)
SchedulerTool.schedule_task("daily_report", "every day at 09:00", daily_job)
SchedulerTool.schedule_task("weekly_sync", "every monday at 08:00", daily_job)
SchedulerTool.cancel_task("heartbeat")
๐ JiraTool
from npmai_agents import JiraTool
JiraTool.create_issue(
project="NPMAI",
summary="Integrate agent v0.0.1 with desktop UI",
description="Wire agent core to PySide6 app.",
issue_type="Task"
)
# โ Jira issue NPMAI-17 created
โ๏ธ TelegramTool
from npmai_agents import TelegramTool
TelegramTool.send(chat_id="123456789", text="โ
Task complete: organised 87 files.")
๐ท QRTool
from npmai_agents import QRTool
QRTool.generate(data="https://npmai.netlify.app", out="npmai_qr.png", size=10)
๐ค VoiceTool
from npmai_agents import VoiceTool
VoiceTool.speak("Task completed. npmai_agents is ready.")
result = VoiceTool.listen(seconds=5)
if result.success:
print(result.data) # recognised speech text
๐๏ธ WatcherTool
from npmai_agents import WatcherTool
def on_change(file_path):
print(f"Changed: {file_path}")
WatcherTool.watch("/home/sonu/incoming", callback=on_change)
# Runs in background thread โ โ Watching /home/sonu/incoming
๐ง RAGTool
from npmai_agents import RAGTool
# Query any document with a natural language question
result = RAGTool.query_document(
doc_path="/home/sonu/paper.pdf",
question="What is the main contribution of this paper?",
chunk_size=500
)
print(result.data)
# Summarise a large file (up to 10 ร 3000-char chunks)
summary = RAGTool.summarize_large_file("/home/sonu/thesis.pdf", model="mistral:7b").data
print(summary)
๐ SSHTool
from npmai_agents import SSHTool
# Remote command
print(SSHTool.run("192.168.1.100", "df -h && uptime").data)
# SFTP upload
SSHTool.upload("192.168.1.100", local="/home/sonu/deploy.sh", remote="/home/ubuntu/deploy.sh")
๐ค AgentBrain โ The Autonomous Core
This is the main event. Configure your credentials with
CredStore, then handAgentBrainany task in plain English. It uses all 21 tool classes automatically โ you never call them yourself.
from npmai_agents import AgentBrain
brain = AgentBrain(
log_cb=print, # receives HTML-formatted log lines
progress_cb=lambda pct: None, # 0โ100 progress value
status_cb=lambda s: None # status string
)
Running Tasks
# The agent plans, codes, audits, executes, verifies โ all by itself
brain.run_task("Organise my Downloads folder by file type")
brain.run_task("Email team@company.com that the build passed")
brain.run_task("Scrape article titles from https://example.com/blog and save to CSV")
brain.run_task("Create a GitHub issue in sonuramashishnpm/npmai: Add voice input")
brain.run_task("Read my last 5 emails and give me a summary")
brain.run_task("Generate a QR code for https://npmai.netlify.app and save it to my Desktop")
brain.run_task("Take a screenshot and upload it to the #dev-logs Slack channel")
Chat Mode
response = brain.chat("What is the LARA RAG architecture?")
print(response)
Kill Switch
import threading
killed = [False]
def run():
brain.run_task("Process 500 PDFs on the server", killed_flag=killed)
t = threading.Thread(target=run)
t.start()
killed[0] = True # cancel at any time
Task History
from npmai_agents import AgentBrain
for entry in AgentBrain.load_task_history():
icon = "โ" if entry["success"] else "โ"
print(f"{icon} [{entry['time']}] {entry['task']}")
How AgentBrain accesses all 21 tools
The Coder LLM is given this import context for every code generation call:
from npmai_agents import EmailTool, FileTool, WebTool, SpreadsheetTool
from npmai_agents import GitHubTool, SlackTool, PDFTool, ImageTool
from npmai_agents import SystemTool, TelegramTool, QRTool, RAGTool, SSHTool
from npmai_agents import DiscordTool, WhatsAppTool, NotionTool, TwitterTool
from npmai_agents import SchedulerTool, JiraTool, VoiceTool, WatcherTool
from npmai_agents import CredStore, Workspace
๐ ๏ธ Executor (Standalone)
from npmai_agents import Executor
executor = Executor(log_cb=print, timeout=120)
success, output = executor.run("""
import time
for i in range(5):
print(f"Step {i+1}")
time.sleep(0.5)
""")
print(success, output)
executor.kill() # kill mid-run if needed
๐ Version
| Version | Status | Notes |
|---|---|---|
0.0.1 |
๐ก Alpha | Initial public release โ all 21 tools stable |
๐ License
MIT License โ free to use, modify, and distribute.
Built with โค๏ธ by Sonu Kumar ยท npmai.netlify.app
"Promoting AI tools to every nation's village โ free and open forever."
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file npmai_agents-0.0.1.tar.gz.
File metadata
- Download URL: npmai_agents-0.0.1.tar.gz
- Upload date:
- Size: 36.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f5439979286112ec3ec050b53070d624937b4d7c83640a4bbcf8abd7e2da5b3
|
|
| MD5 |
8b504e30a3fc78838c8737faf4027c62
|
|
| BLAKE2b-256 |
9454026e49591210a7e6cd297ed3ed8c96f813377721a81c08d58ae9d2f4a0ba
|
File details
Details for the file npmai_agents-0.0.1-py3-none-any.whl.
File metadata
- Download URL: npmai_agents-0.0.1-py3-none-any.whl
- Upload date:
- Size: 26.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d36a1996f53123e891b3378dd685a6071303f1a43fcdfbb43d33bad1e02366ee
|
|
| MD5 |
397c7818e3184e421025ffb3388b7744
|
|
| BLAKE2b-256 |
6dfb617f37c29c8d784ad99382d8344b0e72304a3c603a737dcb1776b210beb4
|