opc-agent 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,365 +1,545 @@
1
- <div align="center">
2
-
3
- # 🤖 OPC Agent
4
-
5
- **Agent OS AI Agent 全生命周期操作系统**
6
-
7
- [![npm](https://img.shields.io/npm/v/opc-agent)](https://www.npmjs.com/package/opc-agent)
8
- [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
9
- [![Tests](https://img.shields.io/badge/Tests-204_passing-green)]()
10
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue)](https://www.typescriptlang.org/)
11
- [![Version](https://img.shields.io/badge/version-2.0.0-brightgreen)]()
12
-
13
- [快速开始](#快速开始) · [CLI 命令](#cli-命令) · [渠道](#11-个渠道) · [English](#english)
14
-
15
- </div>
16
-
17
- ---
18
-
19
- ## 💡 一句话介绍
20
-
21
- > **不只是 Harness,是比 Harness 高一维的 Agent OS。**
22
- > 从创建到运行到监控,一个工具搞定 Agent 全生命周期。
23
-
24
- ## 🎯 和竞品的区别
25
-
26
- | | LangChain | CrewAI | AutoGen | Hermes Agent | **OPC Agent** |
27
- |---|---|---|---|---|---|
28
- | 创建 | 写代码 | 写代码 | 写代码 | CLI | **`opc init` 一键** |
29
- | 配置 | Python/代码 | Python | Python | YAML | **YAML 声明式** |
30
- | 测试 | 自己搭 | 无 | 无 | 基础 | **内置测试框架** |
31
- | 渠道 | 自己接 | 无 | 无 | 有限 | **11 渠道开箱即用** |
32
- | 监控 | 自己搭 | 无 | 无 | 基础 | **Traces + Score** |
33
- | 记忆 | 自己管 | 简单 | 简单 | 无 | **DeepBrain 集成** |
34
- | 守护进程 | 无 | 无 | 无 | 无 | **`opc start/stop/status`** |
35
- | 定时任务 | 无 | 无 | 无 | 无 | **内置 Cron 调度** |
36
- | 技能学习 | | 无 | 无 | 无 | **自主技能习得** |
37
- | 子 Agent | 无 | 有 | 有 | 无 | **并行子 Agent 系统** |
38
- | MCP | 无 | 无 | 无 | 无 | **MCP Client 集成** |
39
-
40
- **框架管"怎么跑",Agent OS 管"全过程"。**
41
-
42
- ## 快速开始
43
-
44
- ```bash
45
- # 最快方式(无需全局安装)
46
- npx opc-agent init my-agent
47
- cd my-agent
48
- npm install
49
- opc chat
50
-
51
- # 或全局安装
52
- npm install -g opc-agent
53
- opc init my-agent
54
- cd my-agent
55
- opc dev
56
- ```
57
-
58
- ## 🆕 v2.0.0 新特性
59
-
60
- ### 🖥️ 交互式 CLI (`opc chat`)
61
- 全功能 TUI:流式输出、斜杠命令、历史记录,直接在终端和 Agent 对话。
62
-
63
- ### 🔄 守护进程模式
64
- ```bash
65
- opc start # 后台启动 Agent
66
- opc status # 查看运行状态
67
- opc stop # 停止 Agent
68
- ```
69
-
70
- ### ⏰ Cron 调度器
71
- OAD 配置中声明定时任务,Agent 自动按计划执行:
72
- ```yaml
73
- scheduler:
74
- jobs:
75
- - cron: "0 9 * * *"
76
- task: daily-report
77
- ```
78
-
79
- ### 🧠 自主技能学习
80
- Agent 从经验中自动创建和改进技能,越用越强。
81
-
82
- ### 🤖 子 Agent 系统
83
- 并行派生子 Agent 处理复杂任务,支持任务委派和结果汇总。
84
-
85
- ### 🔧 内置工具
86
- 文件操作、Web 抓取、Shell 执行、日期时间 — 开箱即用,无需额外配置。
87
-
88
- ### 🔌 MCP Client
89
- 通过 JSON-RPC 连接外部 MCP 服务器,扩展 Agent 能力边界。
90
-
91
- ### 📄 SOUL.md + CONTEXT.md
92
- Markdown 定义 Agent 人格和项目上下文,人性化配置。
93
-
94
- ## OAD 声明式配置
95
-
96
- 不用写代码,用 YAML 定义 Agent:
97
-
98
- ```yaml
99
- id: customer-service
100
- name: 客服专员
101
- version: "1.0.0"
102
-
103
- model: deepseek-chat
104
- systemPrompt: |
105
- 你是一个专业的客服...
106
-
107
- skills:
108
- - ticket-management
109
- - knowledge-base-search
110
-
111
- channels:
112
- - type: web
113
- priority: primary
114
- - type: telegram
115
- priority: secondary
116
- - type: wechat
117
- priority: secondary
118
-
119
- memory:
120
- shortTerm: true
121
- longTerm:
122
- provider: deepbrain
123
- ```
124
-
125
- ## CLI 命令
126
-
127
- ```bash
128
- opc init <name> # 创建新 Agent
129
- opc chat # 交互式对话(TUI)
130
- opc dev # 开发模式(热重载)
131
- opc run # 生产运行
132
- opc start # 守护进程启动
133
- opc stop # 停止守护进程
134
- opc status # 查看运行状态
135
- opc jobs # 查看定时任务
136
- opc skills # 查看已学技能
137
- opc info # Agent 信息
138
- opc build # 构建
139
- opc test # 运行测试
140
- opc analytics # 数据分析
141
- opc brain [--url ...] # 查看记忆状态
142
- opc logs [-f] # 查看 Traces 日志
143
- opc score # 查看性能评分
144
- opc search <query> # 搜索
145
- opc deploy # 部署
146
- opc publish # 发布
147
- opc install <skill> # 安装技能
148
- opc plugin <name> # 管理插件
149
- opc tool <name> # 管理工具
150
- opc workflow <name> # 工作流
151
- opc migrate # 迁移
152
- ```
153
-
154
- ## 11 个渠道
155
-
156
- 一套代码,部署到任意渠道:
157
-
158
- | 渠道 | 状态 | 说明 |
159
- |------|------|------|
160
- | 🌐 Web | ✅ | 网页聊天 |
161
- | 📱 Telegram | | Bot API |
162
- | 💬 Slack | ✅ | Slack App |
163
- | 🎮 Discord | ✅ | Discord Bot |
164
- | 📧 Email | | IMAP/SMTP |
165
- | 💚 微信 | ✅ | 企业微信/个人微信 |
166
- | 🔵 飞书 | ✅ | 飞书机器人 |
167
- | 🎤 Voice | ✅ | 语音通话 |
168
- | 🔌 WebSocket | ✅ | 实时双向 |
169
- | 🪝 Webhook | ✅ | HTTP 回调 |
170
- | 📡 API | ✅ | REST API |
171
-
172
- ## 核心特性
173
-
174
- | 类别 | 特性 |
175
- |------|------|
176
- | 📋 **配置** | OAD 声明式定义、YAML 配置 |
177
- | 📡 **渠道** | 11 个渠道统一接入 |
178
- | 🧪 **测试** | 内置测试框架、163 tests |
179
- | 🔌 **插件** | 可扩展技能和工具系统 |
180
- | 📊 **监控** | Traces 行为采集、Score 评分 |
181
- | 🧠 **记忆** | DeepBrain 集成、自动学习 |
182
- | 🌍 **国际化** | 内置 i18n 支持 |
183
- | 🚀 **部署** | OpenClaw 等平台一键部署 |
184
- | 📈 **分析** | Analytics 数据分析 |
185
- | 🔄 **流式** | Streaming 实时响应 |
186
-
187
- ## 架构
188
-
189
- ```
190
- ┌─────────────────────────────────────────┐
191
- │ OPC Agent OS │
192
- ├──────────┬──────────┬───────────────────┤
193
- │ 创建 │ 运行 │ 监控 │
194
- opc init 11 渠道 │ Traces │
195
- OAD 配置 │ 插件系统 │ Score │
196
- 测试框架 │ 流式响应 │ Analytics │
197
- ├──────────┴──────────┴───────────────────┤
198
- │ DeepBrain 记忆 │
199
- │ learn Traces recall │
200
- └─────────────────────────────────────────┘
201
- ```
202
-
203
- ## 🔗 生态
204
-
205
- | 项目 | 定位 | 关系 |
206
- |------|------|------|
207
- | [deepbrain](https://github.com/Deepleaper/deepbrain) | Agent 记忆引擎 | Traces → learn() |
208
- | **opc-agent** | Agent OS | ← 你在这里 |
209
- | [agentkits](https://github.com/Deepleaper/agentkits) | 带记忆的 OpenRouter | 模型调用层 |
210
- | [agent-workstation](https://github.com/Deepleaper/agent-workstation) | 虚拟工位模板 | `opc init --template` |
211
-
212
- ## License
213
-
214
- Apache-2.0
215
-
216
- ---
217
-
218
- <a name="english"></a>
219
-
220
- ## English
221
-
222
- ## 💡 What Is OPC Agent?
223
-
224
- > **Not just a Harness — it's an Agent OS, one dimension above Harness frameworks.**
225
- > From creation to runtime to monitoring, one tool for the entire Agent lifecycle.
226
-
227
- ## 🎯 How It Differs from Harness Frameworks
228
-
229
- | | LangChain | CrewAI | AutoGen | **OPC Agent** |
230
- |---|---|---|---|---|
231
- | Creation | Write code | Write code | Write code | **`opc init` one command** |
232
- | Configuration | Python/code | Python | Python | **YAML declarative** |
233
- | Testing | DIY | None | None | **Built-in test framework** |
234
- | Channels | DIY | None | None | **11 channels out-of-the-box** |
235
- | Monitoring | DIY | None | None | **Traces + Score** |
236
- | Memory | DIY | Basic | Basic | **DeepBrain integration** |
237
-
238
- **Frameworks manage "how to run." Agent OS manages "the entire process."**
239
-
240
- ## Quick Start
241
-
242
- ```bash
243
- # Fastest way (no global install)
244
- npx opc-agent init my-agent
245
- cd my-agent
246
- npm install
247
- opc chat
248
-
249
- # Or install globally
250
- npm install -g opc-agent
251
- opc init my-agent
252
- cd my-agent
253
- opc dev
254
- ```
255
-
256
- ## OAD Declarative Configuration
257
-
258
- Define your Agent with YAML — no code required:
259
-
260
- ```yaml
261
- id: customer-service
262
- name: Customer Service Rep
263
- version: "1.0.0"
264
-
265
- model: deepseek-chat
266
- systemPrompt: |
267
- You are a professional customer service agent...
268
-
269
- skills:
270
- - ticket-management
271
- - knowledge-base-search
272
-
273
- channels:
274
- - type: web
275
- priority: primary
276
- - type: telegram
277
- priority: secondary
278
- - type: wechat
279
- priority: secondary
280
-
281
- memory:
282
- shortTerm: true
283
- longTerm:
284
- provider: deepbrain
285
- ```
286
-
287
- ## CLI Commands
288
-
289
- ```bash
290
- opc init <name> # Create a new Agent
291
- opc dev # Development mode (hot reload)
292
- opc test # Run tests
293
- opc run # Production run
294
- opc logs [-f] # View Traces logs
295
- opc brain [--url ...] # View memory status
296
- opc score # View performance score
297
- ```
298
-
299
- ## 11 Channels
300
-
301
- One codebase, deploy to any channel:
302
-
303
- | Channel | Status | Description |
304
- |---------|--------|-------------|
305
- | 🌐 Web | ✅ | Web chat |
306
- | 📱 Telegram | ✅ | Bot API |
307
- | 💬 Slack | ✅ | Slack App |
308
- | 🎮 Discord | ✅ | Discord Bot |
309
- | 📧 Email | ✅ | IMAP/SMTP |
310
- | 💚 WeChat | ✅ | Enterprise/Personal WeChat |
311
- | 🔵 Feishu | | Feishu (Lark) Bot |
312
- | 🎤 Voice | | Voice call |
313
- | 🔌 WebSocket | ✅ | Real-time bidirectional |
314
- | 🪝 Webhook | | HTTP callback |
315
- | 📡 API | | REST API |
316
-
317
- ## Full Feature Set
318
-
319
- | Category | Features |
320
- |----------|----------|
321
- | 📋 **Configuration** | OAD declarative definition, YAML config |
322
- | 📡 **Channels** | 11 channels, unified access |
323
- | 🧪 **Testing** | Built-in test framework, 204 tests |
324
- | 🔌 **Plugins** | Extensible skills and tools system |
325
- | 📊 **Monitoring** | Traces behavior collection, Score rating |
326
- | 🧠 **Memory** | DeepBrain integration, auto-learning |
327
- | 🌍 **i18n** | Built-in internationalization support |
328
- | 🚀 **Deployment** | One-click deploy on OpenClaw and other platforms |
329
- | 📈 **Analytics** | Data analytics |
330
- | 🔄 **Streaming** | Real-time streaming responses |
331
-
332
- ## Architecture
333
-
334
- ```
335
- ┌─────────────────────────────────────────┐
336
- │ OPC Agent OS │
337
- ├──────────┬──────────┬───────────────────┤
338
- │ Create │ Run │ Monitor │
339
- │ opc init │ 11 Chan. │ Traces │
340
- │ OAD Config│ Plugins │ Score │
341
- │ Test Fwk │ Streaming │ Analytics │
342
- ├──────────┴──────────┴───────────────────┤
343
- │ DeepBrain Memory │
344
- │ learn ← Traces → recall │
345
- └─────────────────────────────────────────┘
346
- ```
347
-
348
- ## 🔗 Ecosystem
349
-
350
- | Project | Role | Relationship |
351
- |---------|------|-------------|
352
- | [deepbrain](https://github.com/Deepleaper/deepbrain) | Agent Memory Engine | Traces → learn() |
353
- | **opc-agent** | Agent OS | ← You are here |
354
- | [agentkits](https://github.com/Deepleaper/agentkits) | OpenRouter with Memory | Model call layer |
355
- | [agent-workstation](https://github.com/Deepleaper/agent-workstation) | Virtual Role Templates | `opc init --template` |
356
-
357
- ## License
358
-
359
- Apache-2.0
360
- thub.com/Deepleaper/agentkits) | OpenRouter with Memory | Model call layer |
361
- | [agent-workstation](https://github.com/Deepleaper/agent-workstation) | Virtual Role Templates | `opc init --template` |
362
-
363
- ## License
364
-
365
- Apache-2.0
1
+ <div align="center">
2
+
3
+ # OPC Agent
4
+
5
+ ### 全球首个内置记忆进化的 TypeScript Agent 框架
6
+
7
+ [![npm version](https://img.shields.io/npm/v/opc-agent)](https://www.npmjs.com/package/opc-agent)
8
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/Deepleaper/opc-agent/blob/main/LICENSE)
9
+ [![Tests](https://img.shields.io/badge/tests-204_passing-brightgreen)]()
10
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
11
+ [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D18-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
12
+
13
+ **你的 Agent 不该只是"能跑"——它应该能记住、能进化、能跨 11 个渠道触达用户。**
14
+
15
+ OPC Agent 是一个全生命周期 Agent 框架:从 `opc init` 创建,到 `opc chat` 对话,到 `opc studio` 可视化管理,<br>内置记忆进化引擎让 Agent **越用越聪明**,而不是每次从零开始。
16
+
17
+ [快速开始](#-快速开始) · [核心特性](#-核心特性) · [代码示例](#-代码示例) · [CLI 参考](#-cli-参考) · [English](#-english-version)
18
+
19
+ </div>
20
+
21
+ ---
22
+
23
+ ## 🚀 快速开始
24
+
25
+ ```bash
26
+ npm install -g opc-agent
27
+ opc init my-agent --role customer-service
28
+ cd my-agent && npm install
29
+ opc chat
30
+ ```
31
+
32
+ ```
33
+ 🤖 客服专员已就绪
34
+
35
+ You: 我的订单 #12345 什么时候发货?
36
+ Agent: 您好!订单 #12345 已于今天上午发出,预计 3 天内送达。需要我帮您查看物流详情吗?
37
+
38
+ You: 上次你帮我查的那个订单呢?
39
+ Agent: 您上次查询的订单 #12300 已签收,签收时间是 4 月 15 日下午 2 点。
40
+ 记忆自动召回,无需重复说明
41
+ ```
42
+
43
+ > Agent 自动记住每次对话、沉淀专业知识、进化应答策略。这不是 demo,这是默认行为。
44
+
45
+ ---
46
+
47
+ ## ✨ 核心特性
48
+
49
+ | | 特性 | 说明 |
50
+ |---|---|---|
51
+ | 🧠 | **记忆进化** | learn → recall → evolve,全球唯一内置知识自动沉淀 |
52
+ | 🔧 | **20+ CLI 命令** | init / chat / run / start / studio / doctor / eval / traces / publish |
53
+ | 📡 | **11 种 Channel** | Telegram / Discord / Slack / WeChat / Feishu / Email / Web / WebSocket / Voice / Webhook / API |
54
+ | 🔌 | **三大协议** | Google A2A + AG-UI + MCP(Server & Client) |
55
+ | 🎨 | **OPC Studio** | 可视化管理后台,一条命令 `opc studio` 启动 |
56
+ | 📊 | **OpenTelemetry** | 全链路追踪 + p50 / p95 / p99 延迟指标 |
57
+ | 🧪 | **内置评估** | `opc eval` 运行 24 个评估用例,量化 Agent 质量 |
58
+ | 🔍 | **RAG Pipeline** | 5 种分块策略 + 4 种重排序(通过 DeepBrain) |
59
+ | 📦 | **打包分发** | `opc publish` 一键发布到 npm |
60
+ | 🏭 | **工位模板** | 20+ 专业角色,`opc init --role` 秒级创建 |
61
+ | 🔒 | **安全沙箱** | 命令审批 + API Key 加密 + 文件/网络限制 |
62
+ | 🤖 | **子 Agent** | spawn / parallel / kill 多 Agent 协作 |
63
+
64
+ ---
65
+
66
+ ## 🏗️ 架构
67
+
68
+ ```
69
+ ┌──────────────────────────────────────────────────┐
70
+ │ OPC Studio (:4000) │
71
+ │ 可视化管理 · Agent 监控 · 对话调试 │
72
+ ├────────────┬────────────┬────────────┬───────────┤
73
+ │ DeepBrain │ AgentKits │Workstation │ OPC Core │
74
+ │ 🧠 记忆进化 │ 📊 统一模型 │ 👤 角色模板 │ ⚡ 运行引擎 │
75
+ │ │ │ │ │
76
+ learn() │ OpenAI │ 20+ 角色 │ 11 渠道 │
77
+ │ recall() │ Anthropic │ YAML 定义 │ 3 大协议 │
78
+ │ evolve() │ Ollama │ 技能系统 │ Cron 调度 │
79
+ RAG │ DeepSeek │ 一键创建 │ 子 Agent │
80
+ ├────────────┴────────────┴────────────┴───────────┤
81
+ │ OpenTelemetry 全链路追踪 · Eval 评估 · Traces │
82
+ └──────────────────────────────────────────────────┘
83
+ ```
84
+
85
+ ---
86
+
87
+ ## 💻 代码示例
88
+
89
+ ### 1. 最简 Agent(10 行)
90
+
91
+ ```typescript
92
+ import { BaseAgent, InMemoryStore } from 'opc-agent';
93
+
94
+ const agent = new BaseAgent({
95
+ name: 'my-agent',
96
+ systemPrompt: 'You are a helpful assistant.',
97
+ provider: 'ollama',
98
+ model: 'qwen2.5',
99
+ memory: new InMemoryStore(),
100
+ });
101
+
102
+ await agent.init();
103
+ const response = await agent.handleMessage({
104
+ id: '1', content: 'Hello!', sender: 'user',
105
+ channel: 'web', sessionId: 's1', timestamp: new Date(),
106
+ });
107
+ console.log(response.content);
108
+ ```
109
+
110
+ ### 2. 带记忆进化的 Agent
111
+
112
+ ```typescript
113
+ import { AgentRuntime } from 'opc-agent';
114
+
115
+ const runtime = new AgentRuntime('./agent.yaml');
116
+ await runtime.start();
117
+ // 自动: recall(历史记忆) → respond(生成回答) → learn(沉淀知识) → evolve(进化策略)
118
+ ```
119
+
120
+ ### 3. 多协议 Agent(agent.yaml)
121
+
122
+ ```yaml
123
+ id: smart-assistant
124
+ name: 智能助手
125
+ version: "1.0.0"
126
+ model: deepseek-chat
127
+
128
+ channels:
129
+ - type: web
130
+ port: 3000
131
+ - type: telegram
132
+ token: ${TELEGRAM_BOT_TOKEN}
133
+
134
+ protocols:
135
+ a2a:
136
+ enabled: true
137
+ port: 4001
138
+ ag-ui:
139
+ enabled: true
140
+ port: 4002
141
+ mcp:
142
+ role: both # server + client
143
+ port: 4003
144
+ servers:
145
+ - name: file-tools
146
+ command: npx @modelcontextprotocol/server-filesystem
147
+
148
+ memory:
149
+ shortTerm: true
150
+ longTerm:
151
+ provider: deepbrain
152
+ autoEvolve: true
153
+ ```
154
+
155
+ ---
156
+
157
+ ## 📊 对比
158
+
159
+ | 特性 | OPC Agent | Mastra | CrewAI | LangGraph |
160
+ |------|:---------:|:------:|:------:|:---------:|
161
+ | 语言 | TypeScript | TypeScript | Python | Python |
162
+ | 记忆进化 | ✅ 内置 | | | ❌ |
163
+ | CLI 全生命周期 | ✅ 20+ 命令 | ⚠️ 部分 | ❌ | ❌ |
164
+ | 渠道数量 | 11 | 自己接 | 自己接 | 自己接 |
165
+ | A2A 协议 | ✅ | ⚠️ | ❌ | ❌ |
166
+ | AG-UI 协议 | ✅ | | ❌ | ❌ |
167
+ | MCP (Server+Client) | ✅ | ⚠️ Client | ❌ | ⚠️ Client |
168
+ | 可视化 Studio | ✅ | ⚠️ | ❌ | ⚠️ |
169
+ | 内置评估 | ✅ `opc eval` | | | ❌ |
170
+ | OpenTelemetry | ✅ | | | ⚠️ |
171
+ | 子 Agent | ✅ spawn/parallel | ❌ | ✅ | ✅ |
172
+ | 打包发布 | ✅ `opc publish` | ❌ | ❌ | ❌ |
173
+ | YAML 声明式 | ✅ | ⚠️ | ❌ | ❌ |
174
+
175
+ > 其他框架各有所长——OPC 的差异化在于**记忆进化 + 全生命周期 CLI + 11 渠道开箱即用**的完整闭环。
176
+
177
+ ---
178
+
179
+ ## 📦 四件套生态
180
+
181
+ | | 功能 | 安装 |
182
+ |---|---|---|
183
+ | **[opc-agent](https://www.npmjs.com/package/opc-agent)** | Agent OS — 创建、运行、管理 | `npm i opc-agent` |
184
+ | **[deepbrain](https://www.npmjs.com/package/deepbrain)** | 组织大脑 — 记忆存储与进化 | `npm i deepbrain` |
185
+ | **[agentkits](https://www.npmjs.com/package/agentkits)** | 模型层 — 统一 API + 推荐 | `npm i agentkits` |
186
+ | **[agent-workstation](https://www.npmjs.com/package/agent-workstation)** | 工位模板 — 20+ 专业角色 | `npm i agent-workstation` |
187
+
188
+ ---
189
+
190
+ ## 🔧 CLI 参考
191
+
192
+ | 命令 | 说明 |
193
+ |------|------|
194
+ | `opc init <name>` | 创建新 Agent(支持 `--role` 指定角色模板) |
195
+ | `opc chat` | 交互式 TUI 对话 |
196
+ | `opc dev` | 开发模式(热重载) |
197
+ | `opc run` | 生产模式运行 |
198
+ | `opc start` | 守护进程后台启动 |
199
+ | `opc stop` | 停止守护进程 |
200
+ | `opc status` | 查看运行状态 |
201
+ | `opc studio` | 启动可视化管理后台 |
202
+ | `opc doctor` | 环境检查与诊断 |
203
+ | `opc eval` | 运行评估测试 |
204
+ | `opc test` | 运行单元测试 |
205
+ | `opc build` | 构建 Agent |
206
+ | `opc publish` | 发布到 npm |
207
+ | `opc deploy` | 部署到云端 |
208
+ | `opc logs [-f]` | 查看 Traces 日志 |
209
+ | `opc traces` | 查看全链路追踪 |
210
+ | `opc score` | 查看性能评分 |
211
+ | `opc analytics` | 数据分析面板 |
212
+ | `opc brain` | 查看记忆状态 |
213
+ | `opc jobs` | 查看定时任务 |
214
+ | `opc skills` | 查看已学技能 |
215
+ | `opc search <query>` | 搜索 |
216
+ | `opc info` | Agent 信息 |
217
+ | `opc install <skill>` | 安装技能 |
218
+ | `opc plugin <name>` | 管理插件 |
219
+ | `opc tool <name>` | 管理工具 |
220
+ | `opc workflow <name>` | 工作流 |
221
+ | `opc migrate` | 迁移 |
222
+
223
+ ---
224
+
225
+ ## 🔌 协议支持
226
+
227
+ | 协议 | 角色 | 说明 |
228
+ |------|------|------|
229
+ | **[Google A2A](https://google.github.io/A2A/)** | Server + Client | Agent-to-Agent 互操作,发现/调用其他 Agent |
230
+ | **[AG-UI](https://ag-ui.com/)** | Server | Agent-to-UI 流式协议,前端实时渲染 Agent 状态 |
231
+ | **[MCP](https://modelcontextprotocol.io/)** | Server + Client | 连接外部工具服务器,也可作为工具提供方 |
232
+
233
+ ---
234
+
235
+ ## 📡 11 Channel
236
+
237
+ | 渠道 | 状态 | 说明 |
238
+ |------|:----:|------|
239
+ | 🌐 Web | ✅ | 网页聊天组件 |
240
+ | 📱 Telegram | ✅ | Bot API |
241
+ | 💬 Slack | ✅ | Slack App |
242
+ | 🎮 Discord | ✅ | Discord Bot |
243
+ | 📧 Email | | IMAP / SMTP |
244
+ | 💚 WeChat | ✅ | 企业微信 / 个人微信 |
245
+ | 🔵 Feishu | ✅ | 飞书机器人 |
246
+ | 🎤 Voice | ✅ | 语音通话 |
247
+ | 🔌 WebSocket | ✅ | 实时双向通信 |
248
+ | 🪝 Webhook | ✅ | HTTP 回调 |
249
+ | 📡 REST API | ✅ | HTTP API |
250
+
251
+ ---
252
+
253
+ ## 🤝 贡献
254
+
255
+ 欢迎贡献!请查看 [Contributing Guide](CONTRIBUTING.md)。
256
+
257
+ ```bash
258
+ git clone https://github.com/Deepleaper/opc-agent.git
259
+ cd opc-agent
260
+ npm install
261
+ npm run build
262
+ npm test
263
+ ```
264
+
265
+ ---
266
+
267
+ ## 📄 License
268
+
269
+ [Apache-2.0](LICENSE) © [Deepleaper](https://github.com/Deepleaper)
270
+
271
+ ---
272
+
273
+ ---
274
+
275
+ <a name="english-version"></a>
276
+
277
+ <div align="center">
278
+
279
+ # ⚡ OPC Agent
280
+
281
+ ### The World's First TypeScript Agent Framework with Built-in Memory Evolution
282
+
283
+ [![npm version](https://img.shields.io/npm/v/opc-agent)](https://www.npmjs.com/package/opc-agent)
284
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/Deepleaper/opc-agent/blob/main/LICENSE)
285
+ [![Tests](https://img.shields.io/badge/tests-204_passing-brightgreen)]()
286
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
287
+ [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D18-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
288
+
289
+ **Your Agent shouldn't just "run" — it should remember, evolve, and reach users across 11 channels.**
290
+
291
+ OPC Agent is a full-lifecycle Agent framework: from `opc init` to create, `opc chat` to converse, `opc studio` to manage visually.<br>The built-in memory evolution engine makes your Agent **smarter over time**, instead of starting from scratch every session.
292
+
293
+ [Quick Start](#-quick-start) · [Features](#-features) · [Code Examples](#-code-examples-1) · [CLI Reference](#-cli-reference-1)
294
+
295
+ </div>
296
+
297
+ ---
298
+
299
+ ## 🚀 Quick Start
300
+
301
+ ```bash
302
+ npm install -g opc-agent
303
+ opc init my-agent --role customer-service
304
+ cd my-agent && npm install
305
+ opc chat
306
+ ```
307
+
308
+ ```
309
+ 🤖 Customer Service Agent ready
310
+
311
+ You: When will my order #12345 ship?
312
+ Agent: Hi! Order #12345 shipped this morning and should arrive within 3 days. Want me to check the tracking details?
313
+
314
+ You: What about the order you looked up last time?
315
+ Agent: Your previous order #12300 was delivered on April 15th at 2 PM.
316
+ ↑ Memory auto-recalled — no need to repeat context
317
+ ```
318
+
319
+ > The Agent automatically remembers every conversation, distills domain knowledge, and evolves its response strategy. This isn't a demo — it's the default behavior.
320
+
321
+ ---
322
+
323
+ ## Features
324
+
325
+ | | Feature | Description |
326
+ |---|---|---|
327
+ | 🧠 | **Memory Evolution** | learn → recall → evolve — the only framework with built-in automatic knowledge distillation |
328
+ | 🔧 | **20+ CLI Commands** | init / chat / run / start / studio / doctor / eval / traces / publish |
329
+ | 📡 | **11 Channels** | Telegram / Discord / Slack / WeChat / Feishu / Email / Web / WebSocket / Voice / Webhook / API |
330
+ | 🔌 | **3 Protocols** | Google A2A + AG-UI + MCP (Server & Client) |
331
+ | 🎨 | **OPC Studio** | Visual management dashboard — one command `opc studio` |
332
+ | 📊 | **OpenTelemetry** | Full distributed tracing + p50 / p95 / p99 latency metrics |
333
+ | 🧪 | **Built-in Eval** | `opc eval` with 24 evaluation test cases for quantifying Agent quality |
334
+ | 🔍 | **RAG Pipeline** | 5 chunking strategies + 4 rerankers (via DeepBrain) |
335
+ | 📦 | **Package & Publish** | `opc publish` — one command to publish to npm |
336
+ | 🏭 | **Role Templates** | 20+ professional roles, `opc init --role` for instant creation |
337
+ | 🔒 | **Security Sandbox** | Command approval + API Key encryption + file/network restrictions |
338
+ | 🤖 | **Sub-Agents** | spawn / parallel / kill for multi-Agent collaboration |
339
+
340
+ ---
341
+
342
+ ## 🏗️ Architecture
343
+
344
+ ```
345
+ ┌──────────────────────────────────────────────────┐
346
+ │ OPC Studio (:4000) │
347
+ │ Visual Management · Monitoring · Debug │
348
+ ├────────────┬────────────┬────────────┬───────────┤
349
+ │ DeepBrain │ AgentKits │Workstation │ OPC Core │
350
+ 🧠 Memory │ 📊 Models │ 👤 Roles │ ⚡ Engine │
351
+ │ │ │ │ │
352
+ learn() OpenAI │ 20+ roles │ 11 chan. │
353
+ recall() │ Anthropic │ YAML def. │ 3 proto. │
354
+ evolve() Ollama │ Skill sys. Cron sched│
355
+ RAG │ DeepSeek │ One-click │ Sub-Agent
356
+ ├────────────┴────────────┴────────────┴───────────┤
357
+ │ OpenTelemetry Tracing · Eval · Traces │
358
+ └──────────────────────────────────────────────────┘
359
+ ```
360
+
361
+ ---
362
+
363
+ ## 💻 Code Examples
364
+
365
+ ### 1. Minimal Agent (10 lines)
366
+
367
+ ```typescript
368
+ import { BaseAgent, InMemoryStore } from 'opc-agent';
369
+
370
+ const agent = new BaseAgent({
371
+ name: 'my-agent',
372
+ systemPrompt: 'You are a helpful assistant.',
373
+ provider: 'ollama',
374
+ model: 'qwen2.5',
375
+ memory: new InMemoryStore(),
376
+ });
377
+
378
+ await agent.init();
379
+ const response = await agent.handleMessage({
380
+ id: '1', content: 'Hello!', sender: 'user',
381
+ channel: 'web', sessionId: 's1', timestamp: new Date(),
382
+ });
383
+ console.log(response.content);
384
+ ```
385
+
386
+ ### 2. Agent with Memory Evolution
387
+
388
+ ```typescript
389
+ import { AgentRuntime } from 'opc-agent';
390
+
391
+ const runtime = new AgentRuntime('./agent.yaml');
392
+ await runtime.start();
393
+ // Auto: recall(history) → respond(generate) → learn(distill) → evolve(improve)
394
+ ```
395
+
396
+ ### 3. Multi-Protocol Agent (agent.yaml)
397
+
398
+ ```yaml
399
+ id: smart-assistant
400
+ name: Smart Assistant
401
+ version: "1.0.0"
402
+ model: deepseek-chat
403
+
404
+ channels:
405
+ - type: web
406
+ port: 3000
407
+ - type: telegram
408
+ token: ${TELEGRAM_BOT_TOKEN}
409
+
410
+ protocols:
411
+ a2a:
412
+ enabled: true
413
+ port: 4001
414
+ ag-ui:
415
+ enabled: true
416
+ port: 4002
417
+ mcp:
418
+ role: both # server + client
419
+ port: 4003
420
+ servers:
421
+ - name: file-tools
422
+ command: npx @modelcontextprotocol/server-filesystem
423
+
424
+ memory:
425
+ shortTerm: true
426
+ longTerm:
427
+ provider: deepbrain
428
+ autoEvolve: true
429
+ ```
430
+
431
+ ---
432
+
433
+ ## 📊 Comparison
434
+
435
+ | Feature | OPC Agent | Mastra | CrewAI | LangGraph |
436
+ |---------|:---------:|:------:|:------:|:---------:|
437
+ | Language | TypeScript | TypeScript | Python | Python |
438
+ | Memory Evolution | ✅ Built-in | ❌ | ❌ | ❌ |
439
+ | Full-lifecycle CLI | ✅ 20+ cmds | ⚠️ Partial | ❌ | ❌ |
440
+ | Channels | 11 | DIY | DIY | DIY |
441
+ | A2A Protocol | ✅ | ⚠️ | ❌ | ❌ |
442
+ | AG-UI Protocol | ✅ | ❌ | ❌ | ❌ |
443
+ | MCP (Server+Client) | ✅ | ⚠️ Client | ❌ | ⚠️ Client |
444
+ | Visual Studio | ✅ | ⚠️ | ❌ | ⚠️ |
445
+ | Built-in Eval | ✅ `opc eval` | ❌ | ❌ | ❌ |
446
+ | OpenTelemetry | ✅ | ❌ | ❌ | ⚠️ |
447
+ | Sub-Agents | ✅ spawn/parallel | ❌ | ✅ | ✅ |
448
+ | Publish to npm | ✅ `opc publish` | ❌ | ❌ | ❌ |
449
+ | YAML Declarative | ✅ | ⚠️ | ❌ | ❌ |
450
+
451
+ > Each framework has its strengths — OPC's differentiation is the **Memory Evolution + Full-lifecycle CLI + 11 Channels** complete loop.
452
+
453
+ ---
454
+
455
+ ## 📦 Ecosystem
456
+
457
+ | Package | Purpose | Install |
458
+ |---|---|---|
459
+ | **[opc-agent](https://www.npmjs.com/package/opc-agent)** | Agent OS — create, run, manage | `npm i opc-agent` |
460
+ | **[deepbrain](https://www.npmjs.com/package/deepbrain)** | Org Brain — memory storage & evolution | `npm i deepbrain` |
461
+ | **[agentkits](https://www.npmjs.com/package/agentkits)** | Model Layer — unified API + routing | `npm i agentkits` |
462
+ | **[agent-workstation](https://www.npmjs.com/package/agent-workstation)** | Role Templates — 20+ professional roles | `npm i agent-workstation` |
463
+
464
+ ---
465
+
466
+ ## 🔧 CLI Reference
467
+
468
+ | Command | Description |
469
+ |---------|-------------|
470
+ | `opc init <name>` | Create a new Agent (supports `--role` for role templates) |
471
+ | `opc chat` | Interactive TUI conversation |
472
+ | `opc dev` | Development mode (hot reload) |
473
+ | `opc run` | Production run |
474
+ | `opc start` | Daemon mode (background) |
475
+ | `opc stop` | Stop daemon |
476
+ | `opc status` | View running status |
477
+ | `opc studio` | Launch visual management dashboard |
478
+ | `opc doctor` | Environment check & diagnostics |
479
+ | `opc eval` | Run evaluation tests |
480
+ | `opc test` | Run unit tests |
481
+ | `opc build` | Build Agent |
482
+ | `opc publish` | Publish to npm |
483
+ | `opc deploy` | Deploy to cloud |
484
+ | `opc logs [-f]` | View Traces logs |
485
+ | `opc traces` | View distributed traces |
486
+ | `opc score` | View performance score |
487
+ | `opc analytics` | Analytics dashboard |
488
+ | `opc brain` | View memory status |
489
+ | `opc jobs` | View scheduled tasks |
490
+ | `opc skills` | View learned skills |
491
+ | `opc search <query>` | Search |
492
+ | `opc info` | Agent info |
493
+ | `opc install <skill>` | Install a skill |
494
+ | `opc plugin <name>` | Manage plugins |
495
+ | `opc tool <name>` | Manage tools |
496
+ | `opc workflow <name>` | Workflows |
497
+ | `opc migrate` | Migration |
498
+
499
+ ---
500
+
501
+ ## 🔌 Protocol Support
502
+
503
+ | Protocol | Role | Description |
504
+ |----------|------|-------------|
505
+ | **[Google A2A](https://google.github.io/A2A/)** | Server + Client | Agent-to-Agent interop — discover and invoke other Agents |
506
+ | **[AG-UI](https://ag-ui.com/)** | Server | Agent-to-UI streaming protocol — real-time frontend rendering |
507
+ | **[MCP](https://modelcontextprotocol.io/)** | Server + Client | Connect to external tool servers or serve as a tool provider |
508
+
509
+ ---
510
+
511
+ ## 📡 11 Channels
512
+
513
+ | Channel | Status | Description |
514
+ |---------|:------:|-------------|
515
+ | 🌐 Web | ✅ | Web chat widget |
516
+ | 📱 Telegram | ✅ | Bot API |
517
+ | 💬 Slack | ✅ | Slack App |
518
+ | 🎮 Discord | ✅ | Discord Bot |
519
+ | 📧 Email | ✅ | IMAP / SMTP |
520
+ | 💚 WeChat | ✅ | Enterprise / Personal WeChat |
521
+ | 🔵 Feishu | ✅ | Feishu (Lark) Bot |
522
+ | 🎤 Voice | ✅ | Voice call |
523
+ | 🔌 WebSocket | ✅ | Real-time bidirectional |
524
+ | 🪝 Webhook | ✅ | HTTP callback |
525
+ | 📡 REST API | ✅ | HTTP API |
526
+
527
+ ---
528
+
529
+ ## 🤝 Contributing
530
+
531
+ Contributions welcome! See [Contributing Guide](CONTRIBUTING.md).
532
+
533
+ ```bash
534
+ git clone https://github.com/Deepleaper/opc-agent.git
535
+ cd opc-agent
536
+ npm install
537
+ npm run build
538
+ npm test
539
+ ```
540
+
541
+ ---
542
+
543
+ ## 📄 License
544
+
545
+ [Apache-2.0](LICENSE) © [Deepleaper](https://github.com/Deepleaper)