<div align="center">

# ⚡ OPC Agent

**Your own AI employee — local, private, gets smarter over time.**

[![npm](https://img.shields.io/npm/v/opc-agent/alpha?label=opc-agent%40alpha)](https://www.npmjs.com/package/opc-agent)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
[![Node](https://img.shields.io/badge/Node.js-%3E%3D18-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
[![Tests](https://img.shields.io/badge/tests-1226%2B-brightgreen)](tests/)

[中文文档](README.zh-CN.md)

</div>

---

## Why OPC Agent?

AI Agents are powerful, but hard to use for most people:

- **Expensive** — Cloud agents charge per token. Costs add up fast.
- **No memory** — Every conversation starts from scratch.
- **Data privacy** — Your chats and documents live on someone else's servers.
- **Can only chat** — Can't read files, search the web, or run code.

**OPC Agent fixes all of this:**

✅ Runs locally, zero cost (powered by Ollama)<br>
✅ Gets smarter over time (automatic learning & evolution)<br>
✅ Your data stays on your machine<br>
✅ Can read/write files, search the web, execute code, use tools

---

## 🚀 Install

Pick your OS, copy one line:

### macOS / Linux

```bash
curl -fsSL https://raw.githubusercontent.com/Deepleaper/opc-agent/main/install.sh | bash
```

### Windows

```powershell
irm https://raw.githubusercontent.com/Deepleaper/opc-agent/main/install.ps1 | iex
```

> The installer automatically sets up Node.js, OPC Agent, Ollama, and the best AI model for your hardware. No manual steps.

### Manual install

```bash
npm install -g opc-agent@alpha
```

---

## ⚡ Get started in 30 seconds

### Step 1: Create your AI employee

```bash
opc init my-agent
cd my-agent
```

### Step 2: Start chatting

```bash
opc chat
```

That's it. Your AI employee is ready.

### More

```bash
opc studio        # Web dashboard at localhost:4000
opc run           # Start everything: chat + Telegram + web + dashboard
```

---

## What can it do?

OPC Agent isn't just a chatbot. It's an **AI employee that gets work done**:

| Capability | Details |
|-----------|---------|
| 💬 **Chat** | Terminal or web interface |
| 📁 **Read & write files** | Read your docs, write reports, organize notes |
| 🔍 **Web search** | Real-time search for up-to-date information |
| 🌐 **Read web pages** | Fetch and summarize any URL |
| 💻 **Execute code** | Run JavaScript, TypeScript, Python |
| 🧠 **Memory** | Remembers past conversations, gets smarter over time |
| 🔧 **MCP tool extensions** | Connect GitHub, databases, Slack, and more |
| 📱 **Telegram bot** | Add a bot token and chat via Telegram |
| 🎙 **Voice synthesis** | Text-to-speech via edge-tts |
| 👥 **Sub-agents** | Spawn parallel workers for complex tasks |
| 🔄 **Provider failover** | Circuit breaker, automatic retry with fallback |
| 📋 **20 workstation roles** | Pre-built templates: customer service, engineer, analyst, executive... |
| ⏰ **Scheduled tasks** | Cron jobs auto-registered from templates |

---

## 🧠 Gets smarter over time

This is what makes OPC Agent different: **it evolves.**

```
You chat with your AI
    ↓
AI extracts knowledge from the conversation     ← automatic
    ↓
Knowledge is saved to a local database           ← on your machine
    ↓
Next conversation references that knowledge      ← it remembers
    ↓
Knowledge gradually refines and improves         ← gets better over time
```

All learning runs on local Ollama models. **Zero cost.**

Knowledge is organized in three layers: **industry → job → workstation** — precise context for every role.

---

## 🎨 Studio Dashboard

```bash
opc studio
```

Open `localhost:4000` in your browser to:

- **Models** — Switch AI models (local or cloud)
- **Channels** — Configure Telegram bot
- **Knowledge** — See what your agent has learned
- **Settings** — Customize personality, skills, behavior

---

## 📖 Model support

### Local (zero cost)

Auto-recommended based on your RAM:

| RAM | Model | Download |
|-----|-------|----------|
| ≤3 GB | qwen2.5:0.5b | 400MB |
| ≤7 GB | qwen2.5:1.5b | 1.0GB |
| ≤15 GB | qwen2.5:7b | 4.7GB |
| ≤31 GB | qwen2.5:14b | 9.0GB |
| 32+ GB | qwen2.5:32b | 19GB |

### Cloud (optional)

Add API keys in Studio: OpenAI, DeepSeek, Anthropic, Qwen, Google Gemini

Automatic failover with circuit breaker — if one provider goes down, the next one takes over instantly.

---

## 📋 Commands

| Command | What it does |
|---------|-------------|
| `opc init [name]` | Create an AI employee |
| `opc chat` | Chat in terminal |
| `opc studio` | Open web dashboard |
| `opc run` | Start all services |
| `opc brain stats` | Knowledge base status |
| `opc brain recall "query"` | Search knowledge |
| `opc brain learn file.md` | Import a document |
| `opc voice test "hello"` | Test voice synthesis |
| `opc mcp list` | List connected tools |
| `opc doctor` | Diagnose issues |
| `opc init --role <name>` | Create from workstation template |
| `opc init --list-roles` | See available roles |
| `opc template check <path>` | Validate template quality |
| `opc template test <path>` | Run template tests |

---

## 🔒 Privacy

- All data stored locally on your machine
- No telemetry
- Local Ollama models never touch the cloud
- Your knowledge, conversations, and files stay private

---

## 🤝 Contributing

```bash
git clone https://github.com/Deepleaper/opc-agent.git
cd opc-agent
npm install
npx tsc                    # Build
npx vitest run             # Test
```

---

## 📄 License

Apache-2.0 © [Deepleaper](https://github.com/Deepleaper)

---

<div align="center">

**Built by [Deepleaper](https://www.deepleaper.com)**

⭐ Star this repo if it helps you!

</div>
