Skip to main content
Glama
README.md
<div align="center">

# πŸ€– LaptopAI-Agent

### Personal Agentic AI for Laptop Management β€” Private, Secure, Offline-First

[![Python](https://img.shields.io/badge/Python-3.10+-3776AB?style=for-the-badge&logo=python&logoColor=white)](https://www.python.org/)
[![LangGraph](https://img.shields.io/badge/LangGraph-0.2+-FF6B35?style=for-the-badge&logo=langchain&logoColor=white)](https://github.com/langchain-ai/langgraph)
[![ChromaDB](https://img.shields.io/badge/ChromaDB-0.5+-FF4785?style=for-the-badge)](https://www.trychroma.com/)
[![Ollama](https://img.shields.io/badge/Ollama-Local_LLM-000000?style=for-the-badge)](https://ollama.ai/)
[![MCP](https://img.shields.io/badge/MCP-1.0+-6366F1?style=for-the-badge)](https://modelcontextprotocol.io/)
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-green?style=for-the-badge)](LICENSE)
[![sunilgentyala/LaptopAI-Agent MCP server](https://glama.ai/mcp/servers/sunilgentyala/LaptopAI-Agent/badges/score.svg)](https://glama.ai/mcp/servers/sunilgentyala/LaptopAI-Agent)

**Zero API keys. Zero cloud calls. Full system control β€” with a cryptographic audit trail.**

*Built by [Sunil Gentyala](https://github.com/sunilgentyala) Β· IEEE Senior Member Β· HCL America Inc.*

</div>

---

## 🧠 What Is This?

LaptopAI-Agent is a **fully local, privacy-first autonomous AI agent** that manages and reasons about your laptop. It combines:

- A **LangGraph reasoning loop** β€” multi-step planning with tool use, up to 10 agentic iterations per query
- A **local LLM via Ollama** β€” default `qwen2.5-coder:7b` for high tool-calling accuracy, no internet required
- A **ChromaDB RAG layer** β€” ingest your git repos, configs, logs, and docs; retrieve relevant context at inference time
- An **MCP server** β€” expose all tools to Claude Desktop / Claude Code over stdio
- A **SHA-256 chained audit log** β€” append-only, tamper-evident JSONL record of every agent action

Ask it: *"Which of my repos have uncommitted changes?"* or *"My disk is 87% full β€” what's taking space in C:\Gitrepos?"* and it will reason, call tools, and respond β€” entirely on your machine.

---

## ⚑ Quick Start

```bash
# 1. Pull the recommended local model
ollama pull qwen2.5-coder:7b

# 2. Install Python dependencies
pip install -r requirements.txt

# 3. Start chatting
python main.py chat

# 4. Check system health dashboard
python main.py status

# 5. List all git repos + remote URLs + branch
python main.py repos

# 6. Ingest documents into local RAG
python main.py ingest C:\Gitrepos\LaptopAI-Agent\docs

# 7. Start MCP server (for Claude Desktop / Claude Code)
python main.py mcp

# 8. Verify audit log chain integrity
python main.py verify-audit

# 9. Back up + clear browser history (Chrome/Edge/Brave/Firefox), also runs on a 15-day schedule
python main.py clean-browser-history --dry-run
```

---

## πŸ—οΈ Architecture

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        User / MCP Client                            β”‚
β”‚                    (CLI chat or Claude Desktop)                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚ query
                                β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    LangGraph Agent Loop                             β”‚
β”‚                                                                     β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   tool_calls?   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                    β”‚
β”‚   β”‚  agent   β”‚ ──────────────► β”‚  ToolNode    β”‚                    β”‚
β”‚   β”‚  (LLM)   β”‚ ◄────────────── β”‚ (LangChain)  β”‚                    β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   tool results  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β”‚
β”‚        β”‚                              β”‚                             β”‚
β”‚   max 10 iterations            Permission Guard                     β”‚
β”‚        β”‚                       + Audit Log                          β”‚
β”‚        β–Ό                                                            β”‚
β”‚   Final response                                                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β–Ό                     β–Ό                        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Ollama (LLM)   β”‚  β”‚  ChromaDB (RAG)     β”‚  β”‚  System Tools      β”‚
β”‚                  β”‚  β”‚                     β”‚  β”‚                    β”‚
β”‚ qwen2.5-coder:7b β”‚  β”‚ all-MiniLM-L6-v2   β”‚  β”‚ psutil, git,       β”‚
β”‚ localhost:11434  β”‚  β”‚ cosine similarity   β”‚  β”‚ pathlib, subprocessβ”‚
β”‚ temperature=0.1  β”‚  β”‚ 512-token chunks    β”‚  β”‚                    β”‚
β”‚ NO API KEY       β”‚  β”‚ 64-token overlap    β”‚  β”‚ Permission Guard   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

---

## πŸ› οΈ Available Tools

Every tool call is intercepted by the **Permission Guard** and written to the **chained audit log**.

| Tool | Description | Permission |
|---|---|---|
| `get_system_status` | CPU %, memory %, disk free GB, battery %, boot time, platform | Read |
| `list_gitrepos` | All repos under `C:\Gitrepos` with remote URL and current branch | Read |
| `run_git_status` | `git status --short` for a named repo | Read (path check) |
| `list_running_processes` | Top N processes ranked by CPU usage via psutil | Read |
| `read_file` | Read any text file ≀ 2 MB from an allowed path | Read (allowlist) |
| `write_file` | Write content to a file in an allowed path | Write (allowlist) |
| `query_knowledge_base` | Semantic search over ingested documents (top-k cosine hits) | Read |

### MCP Tools (exposed to Claude Desktop / Claude Code)

| MCP Tool | Description |
|---|---|
| `system_status` | CPU, memory, disk, battery snapshot |
| `list_gitrepos` | All repos with remote URLs |
| `git_status` | Status for a named repo |
| `top_processes` | Top 10 processes by CPU |
| `rag_query` | Semantic search over ingested knowledge base |
| `aegis_analyze_paper` | Full AEGIS plagiarism/AI-detection/citation scan of a paper file |
| `aegis_check_citations` | Fast citation-integrity-only scan (hallucinated DOIs, predatory journals) |
| `aegis_compare_papers` | Compare two paper files for self-plagiarism/similarity |
| `signaltrim_run` | Run a build/test/install command through [SignalTrim](https://github.com/sunilgentyala/signaltrim), stripping noise from the output while guaranteeing error-shaped lines survive |
| `signaltrim_report` | View SignalTrim's run history and token-savings stats |
| `browser_history_status` | Discover every browser profile with a history DB and whether it's currently running (read-only) |
| `browser_history_cleanup` | Back up then clear history for every **closed** browser profile (Chrome/Edge/Brave/Firefox); running browsers are skipped, never force-closed; requires `confirm=true` to actually change anything |

---

## πŸ•ΆοΈ Browser History Hygiene

`src/privacy/history_cleaner.py` backs up then clears browsing history for
every locally installed browser profile (Chrome, Edge, Brave, Firefox),
and is registered as a Windows Scheduled Task (**"LaptopAI Browser History
Cleanup"**) that fires every 15 days.

- **Backup before delete, always.** Each closed profile's history DB is
  snapshotted via SQLite's own backup API into a timestamped folder under
  `Documents\BrowserHistoryBackups` before any row is touched. Old backup
  runs are pruned after `retention_days` (default 180).
- **Never touches a running browser.** Chromium browsers hold their History
  file under an exclusive SQLite lock the entire time they're open, so any
  external read attempt fails outright β€” and a raw file copy could capture a
  torn mid-write snapshot. Rather than risk that (or force-close your
  browser), a profile that's currently running is skipped entirely for that
  cycle and reported as `browser_running`; it gets swept up on the next run.
- **Firefox keeps its bookmarks.** `places.sqlite` holds history *and*
  bookmarks in the same tables, so the Firefox path deletes visit rows and
  un-bookmarked places while preserving bookmarked entries (resetting only
  their visit stats) β€” the same scope as Firefox's own "Clear Browsing &
  Download History".

```bash
python main.py clean-browser-history --dry-run   # preview only
python main.py clean-browser-history             # back up + clear now
```

Manage the schedule with `scripts/register_browser_history_cleanup_task.ps1`
(re-run to update it) or `schtasks /Delete /TN "LaptopAI Browser History Cleanup" /F`
to remove it.

---

## πŸ” Security Model

LaptopAI-Agent is built on the assumption that a local agent with file-write access is a high-privilege process. Three controls enforce safe operation:

### 1. πŸ›‘οΈ Permission Guard

Every tool call passes through `PermissionGuard` before execution:

```
Allowed write paths:   C:\Gitrepos, C:\Users\Sunil\Documents, C:\Users\Sunil\Desktop
Blocked paths:         C:\Windows\System32, C:\Program Files
Allowed commands:      git, python, pip, npm, node, powershell, Get-ChildItem, ...
Manual approval for:   rm, Remove-Item, Format-*, reg delete
Max file write:        100 MB
Max execution time:    30 seconds
```

Any violation raises `PermissionError` and the tool call is blocked β€” the LLM never sees the result.

### 2. πŸ”— SHA-256 Chained Audit Log

Every agent action writes to `logs/audit.jsonl` as a **hash chain** β€” each entry commits the hash of the previous entry, making any historical modification detectable:

```jsonc
{
  "timestamp": "2026-06-05T00:00:00+00:00",
  "event_type": "TOOL_CALL",
  "actor": "LaptopAI-Agent",
  "action": "read_file",
  "target": "C:\\Gitrepos\\ZKP-RA\\paper.tex",
  "result": "32650 chars",
  "prev_hash": "a3f1cc...",
  "hash": "9d2c44..."   // SHA-256(this entry + prev_hash)
}
```

Verify the full chain integrity at any time:

```bash
python main.py verify-audit
# Chain valid (847 entries)
```

### 3. πŸ”’ Zero External Calls

| Component | Runs Where |
|---|---|
| LLM inference | Locally via Ollama (`localhost:11434`) |
| Embeddings | Locally via `sentence-transformers` |
| Vector store | Locally via ChromaDB (`./data/chroma_db/`) |
| Audit log | Locally (`./logs/audit.jsonl`) |

No tokens, queries, files, or embeddings ever leave your machine.

---

## 🧩 Claude Desktop / Claude Code Integration

Add to `claude_desktop_config.json`:
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
- **Mac:** `~/Library/Application Support/Claude/claude_desktop_config.json`

```json
{
  "mcpServers": {
    "laptop-ai": {
      "command": "python",
      "args": ["C:\\Gitrepos\\LaptopAI-Agent\\main.py", "mcp"],
      "cwd": "C:\\Gitrepos\\LaptopAI-Agent"
    }
  }
}
```

Once connected, Claude can call `system_status`, `list_gitrepos`, `git_status`, `top_processes`, and `rag_query` directly from any conversation β€” with every call logged to the audit trail.

---

## πŸ“š RAG Knowledge Base

The RAG layer ingests `.txt`, `.md`, `.log`, `.py`, `.yaml`, and `.json` files using a sliding-window chunker with upsert deduplication:

| Parameter | Value |
|---|---|
| Vector DB | ChromaDB (persistent local) |
| Embedding model | `all-MiniLM-L6-v2` (sentence-transformers, runs locally) |
| Similarity metric | Cosine |
| Chunk size | 512 tokens |
| Chunk overlap | 64 tokens |
| Deduplication | MD5 hash per `(file_path, chunk_index)` β€” upsert-safe re-ingestion |
| Default top-k | 5 results |

```bash
# Ingest an entire directory recursively
python main.py ingest C:\Gitrepos

# Ask the agent a RAG-grounded question
python main.py chat
> What does the ZKP-RA circuit enforce at the policy layer?
```

---

## βš™οΈ Configuration

All behaviour is controlled by `config.yaml` β€” no code changes needed:

```yaml
llm:
  model: "qwen2.5-coder:7b"   # swap to llama3.2, mistral, deepseek-r1, etc.
  temperature: 0.1             # low = more deterministic tool calls

rag:
  chunk_size: 512
  chunk_overlap: 64
  top_k: 5

security:
  max_file_size_mb: 100
  allowed_paths:
    - "C:\\Gitrepos"
    - "C:\\Users\\Sunil\\Documents"
  blocked_paths:
    - "C:\\Windows\\System32"
  require_approval_for:
    - "rm"
    - "Remove-Item"

monitoring:
  alert_cpu_percent: 90
  alert_memory_percent: 85
  alert_disk_percent: 80
```

---

## πŸ“ Project Structure

```
LaptopAI-Agent/
β”œβ”€β”€ main.py                        # CLI entry point
β”œβ”€β”€ config.yaml                    # All runtime configuration
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ agent/
β”‚   β”‚   β”œβ”€β”€ graph.py               # LangGraph StateGraph β€” agent ↔ ToolNode loop (max 10 iters)
β”‚   β”‚   └── tools.py               # LangChain @tool definitions + PermissionGuard hooks
β”‚   β”œβ”€β”€ mcp/
β”‚   β”‚   └── server.py              # MCP stdio server β€” 12 tools exposed to Claude
β”‚   β”œβ”€β”€ rag/
β”‚   β”‚   └── knowledge_base.py      # ChromaDB ingestion + cosine semantic query
β”‚   └── security/
β”‚       β”œβ”€β”€ audit.py               # SHA-256 chained append-only audit logger
β”‚       └── permissions.py         # PermissionGuard β€” path, command, size enforcement
β”œβ”€β”€ data/
β”‚   └── chroma_db/                 # Local vector store (gitignored)
└── logs/
    └── audit.jsonl                # Tamper-evident audit trail (gitignored)
```

---

## πŸ”¬ Recommended Local Models

| Model | Size | Strength |
|---|---|---|
| `qwen2.5-coder:7b` ⭐ | ~4.7 GB | Tool calling, code reasoning β€” **default** |
| `llama3.2:3b` | ~2.0 GB | Lightweight, fast responses |
| `mistral:7b` | ~4.1 GB | General reasoning, instruction following |
| `deepseek-r1:7b` | ~4.7 GB | Multi-step planning, math |

```bash
ollama pull qwen2.5-coder:7b   # recommended
ollama pull llama3.2:3b        # lightweight alternative
```

---

## πŸ“¦ Key Dependencies

| Package | Version | Purpose |
|---|---|---|
| `langgraph` | β‰₯0.2 | Agentic state machine (agent ↔ tools loop) |
| `langchain-ollama` | β‰₯0.2 | Ollama LLM binding with native tool-calling |
| `mcp` | β‰₯1.0 | Model Context Protocol server (stdio transport) |
| `chromadb` | β‰₯0.5 | Local persistent vector database |
| `sentence-transformers` | β‰₯3.0 | Local embeddings (`all-MiniLM-L6-v2`) |
| `psutil` | β‰₯6.0 | CPU, memory, disk, battery, process inspection |
| `rich` | β‰₯13.0 | Terminal output formatting |
| `typer` | β‰₯0.12 | CLI command routing |

---

## πŸ“– Research & References

| Project | Link |
|---|---|
| LangGraph | [github.com/langchain-ai/langgraph](https://github.com/langchain-ai/langgraph) |
| Model Context Protocol | [modelcontextprotocol.io](https://modelcontextprotocol.io) |
| RAGFlow | [github.com/infiniflow/ragflow](https://github.com/infiniflow/ragflow) |
| Agent-S | [github.com/simular-ai/Agent-S](https://github.com/simular-ai/Agent-S) |
| AIOS | [github.com/agiresearch/AIOS](https://github.com/agiresearch/AIOS) |
| SoK: AI Agents for Blockchain | [arXiv:2509.07131](https://arxiv.org/abs/2509.07131) |

---

## πŸ‘€ Author

**Sunil Gentyala**
Lead Cybersecurity and AI Security Consultant β€” HCL America Inc., Dallas TX
IEEE Senior Member No. 101760715 Β· CISM No. 263076408 Β· MBCS Β· ACM Professional Member Β· CIISec Affiliate

[![GitHub](https://img.shields.io/badge/GitHub-sunilgentyala-181717?style=flat-square&logo=github)](https://github.com/sunilgentyala)
[![LinkedIn](https://img.shields.io/badge/LinkedIn-sunilgentyala-0A66C2?style=flat-square&logo=linkedin)](https://www.linkedin.com/in/sunil-gentyala/)
[![Portfolio](https://img.shields.io/badge/Portfolio-sunilgentyala.github.io-FF6B35?style=flat-square)](https://sunilgentyala.github.io)
[![IEEE Email](https://img.shields.io/badge/IEEE-sunil.gentyala%40ieee.org-00629B?style=flat-square&logo=ieee)](mailto:sunil.gentyala@ieee.org)

---

## How to Cite

If you use LaptopAI-Agent in your research, please cite the software:

```bibtex
@software{gentyala2026laptopai,
  author    = {Gentyala, Sunil},
  title     = {LaptopAI-Agent},
  year      = {2026},
  version   = {1.3.0},
  url       = {https://github.com/sunilgentyala/LaptopAI-Agent}
}
```

Machine-readable metadata is in [`CITATION.cff`](CITATION.cff); GitHub shows it under "Cite this repository".

---

## πŸ“„ License

Apache 2.0 β€” See [LICENSE](LICENSE) for details.

---

<div align="center">
<sub>Built for privacy, security, and full local control. No API keys. No cloud. Just your machine.</sub>
</div>

TDQS

B3.1/5.0

Scored across 12 tools

Disambiguation4/5

Most tools are clearly distinct by resource and action (system_status vs top_processes vs git_status vs rag_query), and the aegis_* trio separates full analysis, citation-only checks, and paper comparison. The one soft overlap is aegis_check_citations being a fast subset of aegis_analyze_paper and browser_history_cleanup behaving like status when confirm=false, but descriptions explicitly disambiguate both.

Naming Consistency3/5

There is a recognizable namespace-prefix pattern (aegis_*, signaltrim_*, browser_history_*), but the base conventions are mixed: verb-first (list_gitrepos, top_processes), noun-first (system_status, git_status, rag_query), and inconsistent capitalization in 'gitrepos'. Readable, but no single predictable verb_noun scheme throughout.

Tool Count4/5

12 tools is a comfortable, well-scoped count for a personal agent covering system, git, RAG, paper-integrity, command-output, and browser-history domains. Each tool maps to a real operation; the set is a multi-feature grab-bag rather than one coherent domain, but no tool feels redundant.

Completeness3/5

The aegis and browser clusters are lifecycle-complete (analyze/check/compare; status/cleanup), and signaltrim pairs run with a reporting tool. However, git is read-only (no commit/log/diff) and rag_query has no ingest/add counterpart, leaving notable gaps that will cause dead ends for common workflows.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues