opc-agent 2.1.0 → 3.0.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 +603 -545
- package/dist/channels/voice.d.ts +59 -0
- package/dist/channels/voice.js +351 -1
- package/dist/cli.js +172 -1
- package/dist/core/agent.d.ts +4 -0
- package/dist/core/agent.js +35 -0
- package/dist/core/collaboration.d.ts +89 -0
- package/dist/core/collaboration.js +201 -0
- package/dist/deploy/index.d.ts +40 -0
- package/dist/deploy/index.js +261 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +47 -3
- package/dist/mcp/servers/calculator-mcp.d.ts +3 -0
- package/dist/mcp/servers/calculator-mcp.js +65 -0
- package/dist/mcp/servers/crypto-mcp.d.ts +3 -0
- package/dist/mcp/servers/crypto-mcp.js +108 -0
- package/dist/mcp/servers/database-mcp.d.ts +3 -0
- package/dist/mcp/servers/database-mcp.js +73 -0
- package/dist/mcp/servers/datetime-mcp.d.ts +3 -0
- package/dist/mcp/servers/datetime-mcp.js +71 -0
- package/dist/mcp/servers/filesystem.d.ts +3 -0
- package/dist/mcp/servers/filesystem.js +101 -0
- package/dist/mcp/servers/github-mcp.d.ts +3 -0
- package/dist/mcp/servers/github-mcp.js +60 -0
- package/dist/mcp/servers/index.d.ts +21 -0
- package/dist/mcp/servers/index.js +50 -0
- package/dist/mcp/servers/json-mcp.d.ts +3 -0
- package/dist/mcp/servers/json-mcp.js +126 -0
- package/dist/mcp/servers/memory-mcp.d.ts +3 -0
- package/dist/mcp/servers/memory-mcp.js +60 -0
- package/dist/mcp/servers/regex-mcp.d.ts +3 -0
- package/dist/mcp/servers/regex-mcp.js +56 -0
- package/dist/mcp/servers/web-mcp.d.ts +3 -0
- package/dist/mcp/servers/web-mcp.js +51 -0
- package/dist/schema/oad.d.ts +292 -12
- package/dist/schema/oad.js +12 -1
- package/dist/security/guardrails.d.ts +50 -0
- package/dist/security/guardrails.js +197 -0
- package/dist/studio/server.d.ts +31 -1
- package/dist/studio/server.js +154 -3
- package/dist/studio-ui/index.html +1278 -662
- package/dist/tools/integrations/calendar.d.ts +3 -0
- package/dist/tools/integrations/calendar.js +73 -0
- package/dist/tools/integrations/code-exec.d.ts +3 -0
- package/dist/tools/integrations/code-exec.js +42 -0
- package/dist/tools/integrations/csv-analyzer.d.ts +3 -0
- package/dist/tools/integrations/csv-analyzer.js +142 -0
- package/dist/tools/integrations/database.d.ts +3 -0
- package/dist/tools/integrations/database.js +44 -0
- package/dist/tools/integrations/email-send.d.ts +3 -0
- package/dist/tools/integrations/email-send.js +104 -0
- package/dist/tools/integrations/git-tool.d.ts +3 -0
- package/dist/tools/integrations/git-tool.js +49 -0
- package/dist/tools/integrations/github-tool.d.ts +3 -0
- package/dist/tools/integrations/github-tool.js +77 -0
- package/dist/tools/integrations/image-gen.d.ts +3 -0
- package/dist/tools/integrations/image-gen.js +58 -0
- package/dist/tools/integrations/index.d.ts +30 -0
- package/dist/tools/integrations/index.js +107 -0
- package/dist/tools/integrations/jira.d.ts +3 -0
- package/dist/tools/integrations/jira.js +85 -0
- package/dist/tools/integrations/notion.d.ts +3 -0
- package/dist/tools/integrations/notion.js +71 -0
- package/dist/tools/integrations/npm-tool.d.ts +3 -0
- package/dist/tools/integrations/npm-tool.js +49 -0
- package/dist/tools/integrations/pdf-reader.d.ts +3 -0
- package/dist/tools/integrations/pdf-reader.js +91 -0
- package/dist/tools/integrations/slack.d.ts +3 -0
- package/dist/tools/integrations/slack.js +67 -0
- package/dist/tools/integrations/summarizer.d.ts +3 -0
- package/dist/tools/integrations/summarizer.js +49 -0
- package/dist/tools/integrations/translator.d.ts +3 -0
- package/dist/tools/integrations/translator.js +48 -0
- package/dist/tools/integrations/trello.d.ts +3 -0
- package/dist/tools/integrations/trello.js +60 -0
- package/dist/tools/integrations/vector-search.d.ts +3 -0
- package/dist/tools/integrations/vector-search.js +44 -0
- package/dist/tools/integrations/web-scraper.d.ts +3 -0
- package/dist/tools/integrations/web-scraper.js +48 -0
- package/dist/tools/integrations/web-search.d.ts +3 -0
- package/dist/tools/integrations/web-search.js +60 -0
- package/dist/tools/integrations/webhook.d.ts +3 -0
- package/dist/tools/integrations/webhook.js +39 -0
- package/dist/ui/components.d.ts +10 -0
- package/dist/ui/components.js +123 -0
- package/package.json +1 -1
- package/src/channels/voice.ts +365 -0
- package/src/cli.ts +176 -2
- package/src/core/agent.ts +38 -0
- package/src/core/collaboration.ts +275 -0
- package/src/deploy/index.ts +255 -0
- package/src/index.ts +21 -1
- package/src/mcp/servers/calculator-mcp.ts +65 -0
- package/src/mcp/servers/crypto-mcp.ts +73 -0
- package/src/mcp/servers/database-mcp.ts +72 -0
- package/src/mcp/servers/datetime-mcp.ts +69 -0
- package/src/mcp/servers/filesystem.ts +66 -0
- package/src/mcp/servers/github-mcp.ts +58 -0
- package/src/mcp/servers/index.ts +63 -0
- package/src/mcp/servers/json-mcp.ts +102 -0
- package/src/mcp/servers/memory-mcp.ts +56 -0
- package/src/mcp/servers/regex-mcp.ts +53 -0
- package/src/mcp/servers/web-mcp.ts +49 -0
- package/src/schema/oad.ts +13 -0
- package/src/security/guardrails.ts +248 -0
- package/src/studio/server.ts +166 -4
- package/src/studio-ui/index.html +1278 -662
- package/src/tools/integrations/calendar.ts +73 -0
- package/src/tools/integrations/code-exec.ts +39 -0
- package/src/tools/integrations/csv-analyzer.ts +92 -0
- package/src/tools/integrations/database.ts +44 -0
- package/src/tools/integrations/email-send.ts +76 -0
- package/src/tools/integrations/git-tool.ts +42 -0
- package/src/tools/integrations/github-tool.ts +76 -0
- package/src/tools/integrations/image-gen.ts +56 -0
- package/src/tools/integrations/index.ts +92 -0
- package/src/tools/integrations/jira.ts +83 -0
- package/src/tools/integrations/notion.ts +71 -0
- package/src/tools/integrations/npm-tool.ts +48 -0
- package/src/tools/integrations/pdf-reader.ts +58 -0
- package/src/tools/integrations/slack.ts +65 -0
- package/src/tools/integrations/summarizer.ts +49 -0
- package/src/tools/integrations/translator.ts +48 -0
- package/src/tools/integrations/trello.ts +60 -0
- package/src/tools/integrations/vector-search.ts +42 -0
- package/src/tools/integrations/web-scraper.ts +47 -0
- package/src/tools/integrations/web-search.ts +58 -0
- package/src/tools/integrations/webhook.ts +38 -0
- package/src/ui/components.ts +127 -0
- package/tests/brain-seed-extended.test.ts +490 -0
- package/tests/collaboration.test.ts +319 -0
- package/tests/deploy-and-dag.test.ts +196 -0
- package/tests/guardrails.test.ts +177 -0
- package/tests/integrations.test.ts +249 -0
- package/tests/mcp-servers.test.ts +260 -0
- package/tests/voice-enhanced.test.ts +169 -0
- package/dist/dtv/data.d.ts +0 -18
- package/dist/dtv/data.js +0 -25
- package/dist/dtv/trust.d.ts +0 -19
- package/dist/dtv/trust.js +0 -40
- package/dist/dtv/value.d.ts +0 -23
- package/dist/dtv/value.js +0 -38
- package/dist/marketplace/index.d.ts +0 -34
- package/dist/marketplace/index.js +0 -202
package/README.md
CHANGED
|
@@ -1,545 +1,603 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
# ⚡ OPC Agent
|
|
4
|
-
|
|
5
|
-
### 全球首个内置记忆进化的 TypeScript Agent 框架
|
|
6
|
-
|
|
7
|
-
[](https://github.com/Deepleaper/opc-agent/blob/main/LICENSE)
|
|
9
|
-
[]()
|
|
10
|
-
[](https://www.typescriptlang.org/)
|
|
11
|
-
[](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
|
-
| 🏭 | **工位模板** |
|
|
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 │
|
|
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
|
193
|
-
|
|
194
|
-
|
|
|
195
|
-
| `opc
|
|
196
|
-
|
|
|
197
|
-
|
|
|
198
|
-
| `opc
|
|
199
|
-
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
|
208
|
-
|
|
209
|
-
|
|
|
210
|
-
|
|
|
211
|
-
|
|
|
212
|
-
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
|
219
|
-
|
|
220
|
-
| `opc
|
|
221
|
-
| `opc
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
|
228
|
-
|
|
229
|
-
|
|
|
230
|
-
|
|
|
231
|
-
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
|
238
|
-
|
|
239
|
-
|
|
|
240
|
-
|
|
|
241
|
-
|
|
|
242
|
-
|
|
|
243
|
-
|
|
|
244
|
-
|
|
|
245
|
-
|
|
|
246
|
-
|
|
|
247
|
-
|
|
|
248
|
-
|
|
|
249
|
-
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
[
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
name:
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
|
491
|
-
|
|
492
|
-
|
|
|
493
|
-
|
|
|
494
|
-
|
|
|
495
|
-
|
|
|
496
|
-
|
|
|
497
|
-
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
|
516
|
-
|
|
|
517
|
-
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
|
524
|
-
|
|
525
|
-
|
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
npm
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# ⚡ OPC Agent
|
|
4
|
+
|
|
5
|
+
### 全球首个内置记忆进化的 TypeScript Agent 框架
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/opc-agent)
|
|
8
|
+
[](https://github.com/Deepleaper/opc-agent/blob/main/LICENSE)
|
|
9
|
+
[]()
|
|
10
|
+
[](https://www.typescriptlang.org/)
|
|
11
|
+
[](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
|
+
| 🏭 | **工位模板** | 100+ 专业角色,`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 │ 100+ 角色 │ 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
|
+
## 🌱 Brain Seed 自动加载
|
|
158
|
+
|
|
159
|
+
v2.1.0 起,OPC Agent 支持三层知识种子自动加载。当 `brain-seeds/` 目录存在时,Agent 首次启动自动导入行业→岗位→工位知识:
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
const agent = new BaseAgent({
|
|
163
|
+
name: 'my-agent',
|
|
164
|
+
systemPrompt: 'You are a helpful assistant.',
|
|
165
|
+
provider: 'deepseek',
|
|
166
|
+
model: 'deepseek-chat',
|
|
167
|
+
});
|
|
168
|
+
agent.setLongTermMemory(brain);
|
|
169
|
+
// Auto-seeds on first run if brain-seeds/ directory exists
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
通过 CLI 管理知识种子:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
opc brain seed # 查看当前 brain seed 状态
|
|
176
|
+
opc brain seed --load # 手动加载/重新加载种子
|
|
177
|
+
opc brain evolve # 触发知识进化(工位→岗位→行业)
|
|
178
|
+
opc brain status # 查看 brain 统计信息
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## 📊 对比
|
|
184
|
+
|
|
185
|
+
| 特性 | OPC Agent | Mastra | CrewAI | LangGraph |
|
|
186
|
+
|------|:---------:|:------:|:------:|:---------:|
|
|
187
|
+
| 语言 | TypeScript | TypeScript | Python | Python |
|
|
188
|
+
| 记忆进化 | ✅ 内置 | ❌ | ❌ | ❌ |
|
|
189
|
+
| CLI 全生命周期 | ✅ 20+ 命令 | ⚠️ 部分 | ❌ | ❌ |
|
|
190
|
+
| 渠道数量 | 11 | 自己接 | 自己接 | 自己接 |
|
|
191
|
+
| A2A 协议 | ✅ | ⚠️ | ❌ | ❌ |
|
|
192
|
+
| AG-UI 协议 | ✅ | ❌ | ❌ | ❌ |
|
|
193
|
+
| MCP (Server+Client) | ✅ | ⚠️ Client | ❌ | ⚠️ Client |
|
|
194
|
+
| 可视化 Studio | ✅ | ⚠️ | ❌ | ⚠️ |
|
|
195
|
+
| 内置评估 | ✅ `opc eval` | ❌ | ❌ | ❌ |
|
|
196
|
+
| OpenTelemetry | ✅ | ❌ | ❌ | ⚠️ |
|
|
197
|
+
| 子 Agent | ✅ spawn/parallel | ❌ | ✅ | ✅ |
|
|
198
|
+
| 打包发布 | ✅ `opc publish` | ❌ | ❌ | ❌ |
|
|
199
|
+
| YAML 声明式 | ✅ | ⚠️ | ❌ | ❌ |
|
|
200
|
+
|
|
201
|
+
> 其他框架各有所长——OPC 的差异化在于**记忆进化 + 全生命周期 CLI + 11 渠道开箱即用**的完整闭环。
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## 📦 四件套生态
|
|
206
|
+
|
|
207
|
+
| 包 | 功能 | 安装 |
|
|
208
|
+
|---|---|---|
|
|
209
|
+
| **[opc-agent](https://www.npmjs.com/package/opc-agent)** | Agent OS — 创建、运行、管理 | `npm i opc-agent` |
|
|
210
|
+
| **[deepbrain](https://www.npmjs.com/package/deepbrain)** | 组织大脑 — 记忆存储与进化 | `npm i deepbrain` |
|
|
211
|
+
| **[agentkits](https://www.npmjs.com/package/agentkits)** | 模型层 — 统一 API + 推荐 | `npm i agentkits` |
|
|
212
|
+
| **[agent-workstation](https://www.npmjs.com/package/agent-workstation)** | 工位模板 — 100+ 专业角色 | `npm i agent-workstation` |
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## 🔧 CLI 参考
|
|
217
|
+
|
|
218
|
+
| 命令 | 说明 |
|
|
219
|
+
|------|------|
|
|
220
|
+
| `opc init <name>` | 创建新 Agent(支持 `--role` 指定角色模板) |
|
|
221
|
+
| `opc chat` | 交互式 TUI 对话 |
|
|
222
|
+
| `opc dev` | 开发模式(热重载) |
|
|
223
|
+
| `opc run` | 生产模式运行 |
|
|
224
|
+
| `opc start` | 守护进程后台启动 |
|
|
225
|
+
| `opc stop` | 停止守护进程 |
|
|
226
|
+
| `opc status` | 查看运行状态 |
|
|
227
|
+
| `opc studio` | 启动可视化管理后台 |
|
|
228
|
+
| `opc doctor` | 环境检查与诊断 |
|
|
229
|
+
| `opc eval` | 运行评估测试 |
|
|
230
|
+
| `opc test` | 运行单元测试 |
|
|
231
|
+
| `opc build` | 构建 Agent |
|
|
232
|
+
| `opc publish` | 发布到 npm |
|
|
233
|
+
| `opc deploy` | 部署到云端 |
|
|
234
|
+
| `opc logs [-f]` | 查看 Traces 日志 |
|
|
235
|
+
| `opc traces` | 查看全链路追踪 |
|
|
236
|
+
| `opc score` | 查看性能评分 |
|
|
237
|
+
| `opc analytics` | 数据分析面板 |
|
|
238
|
+
| `opc brain` | 查看记忆状态 |
|
|
239
|
+
| `opc brain seed` | 查看/加载三层知识种子 |
|
|
240
|
+
| `opc brain evolve` | 触发知识进化(工位→岗位→行业) |
|
|
241
|
+
| `opc brain status` | 查看 brain 详细统计 |
|
|
242
|
+
| `opc jobs` | 查看定时任务 |
|
|
243
|
+
| `opc skills` | 查看已学技能 |
|
|
244
|
+
| `opc search <query>` | 搜索 |
|
|
245
|
+
| `opc info` | Agent 信息 |
|
|
246
|
+
| `opc install <skill>` | 安装技能 |
|
|
247
|
+
| `opc plugin <name>` | 管理插件 |
|
|
248
|
+
| `opc tool <name>` | 管理工具 |
|
|
249
|
+
| `opc workflow <name>` | 工作流 |
|
|
250
|
+
| `opc migrate` | 迁移 |
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## 🔌 协议支持
|
|
255
|
+
|
|
256
|
+
| 协议 | 角色 | 说明 |
|
|
257
|
+
|------|------|------|
|
|
258
|
+
| **[Google A2A](https://google.github.io/A2A/)** | Server + Client | Agent-to-Agent 互操作,发现/调用其他 Agent |
|
|
259
|
+
| **[AG-UI](https://ag-ui.com/)** | Server | Agent-to-UI 流式协议,前端实时渲染 Agent 状态 |
|
|
260
|
+
| **[MCP](https://modelcontextprotocol.io/)** | Server + Client | 连接外部工具服务器,也可作为工具提供方 |
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## 📡 11 种 Channel
|
|
265
|
+
|
|
266
|
+
| 渠道 | 状态 | 说明 |
|
|
267
|
+
|------|:----:|------|
|
|
268
|
+
| 🌐 Web | ✅ | 网页聊天组件 |
|
|
269
|
+
| 📱 Telegram | ✅ | Bot API |
|
|
270
|
+
| 💬 Slack | ✅ | Slack App |
|
|
271
|
+
| 🎮 Discord | ✅ | Discord Bot |
|
|
272
|
+
| 📧 Email | ✅ | IMAP / SMTP |
|
|
273
|
+
| 💚 WeChat | ✅ | 企业微信 / 个人微信 |
|
|
274
|
+
| 🔵 Feishu | ✅ | 飞书机器人 |
|
|
275
|
+
| 🎤 Voice | ✅ | 语音通话 |
|
|
276
|
+
| 🔌 WebSocket | ✅ | 实时双向通信 |
|
|
277
|
+
| 🪝 Webhook | ✅ | HTTP 回调 |
|
|
278
|
+
| 📡 REST API | ✅ | HTTP API |
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## 🤝 贡献
|
|
283
|
+
|
|
284
|
+
欢迎贡献!请查看 [Contributing Guide](CONTRIBUTING.md)。
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
git clone https://github.com/Deepleaper/opc-agent.git
|
|
288
|
+
cd opc-agent
|
|
289
|
+
npm install
|
|
290
|
+
npm run build
|
|
291
|
+
npm test
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## 📄 License
|
|
297
|
+
|
|
298
|
+
[Apache-2.0](LICENSE) © [Deepleaper](https://github.com/Deepleaper)
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
<a name="english-version"></a>
|
|
305
|
+
|
|
306
|
+
<div align="center">
|
|
307
|
+
|
|
308
|
+
# ⚡ OPC Agent
|
|
309
|
+
|
|
310
|
+
### The World's First TypeScript Agent Framework with Built-in Memory Evolution
|
|
311
|
+
|
|
312
|
+
[](https://www.npmjs.com/package/opc-agent)
|
|
313
|
+
[](https://github.com/Deepleaper/opc-agent/blob/main/LICENSE)
|
|
314
|
+
[]()
|
|
315
|
+
[](https://www.typescriptlang.org/)
|
|
316
|
+
[](https://nodejs.org/)
|
|
317
|
+
|
|
318
|
+
**Your Agent shouldn't just "run" — it should remember, evolve, and reach users across 11 channels.**
|
|
319
|
+
|
|
320
|
+
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.
|
|
321
|
+
|
|
322
|
+
[Quick Start](#-quick-start) · [Features](#-features) · [Code Examples](#-code-examples-1) · [CLI Reference](#-cli-reference-1)
|
|
323
|
+
|
|
324
|
+
</div>
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## 🚀 Quick Start
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
npm install -g opc-agent
|
|
332
|
+
opc init my-agent --role customer-service
|
|
333
|
+
cd my-agent && npm install
|
|
334
|
+
opc chat
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
```
|
|
338
|
+
🤖 Customer Service Agent ready
|
|
339
|
+
|
|
340
|
+
You: When will my order #12345 ship?
|
|
341
|
+
Agent: Hi! Order #12345 shipped this morning and should arrive within 3 days. Want me to check the tracking details?
|
|
342
|
+
|
|
343
|
+
You: What about the order you looked up last time?
|
|
344
|
+
Agent: Your previous order #12300 was delivered on April 15th at 2 PM.
|
|
345
|
+
↑ Memory auto-recalled — no need to repeat context
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
> The Agent automatically remembers every conversation, distills domain knowledge, and evolves its response strategy. This isn't a demo — it's the default behavior.
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
## ✨ Features
|
|
353
|
+
|
|
354
|
+
| | Feature | Description |
|
|
355
|
+
|---|---|---|
|
|
356
|
+
| 🧠 | **Memory Evolution** | learn → recall → evolve — the only framework with built-in automatic knowledge distillation |
|
|
357
|
+
| 🔧 | **20+ CLI Commands** | init / chat / run / start / studio / doctor / eval / traces / publish |
|
|
358
|
+
| 📡 | **11 Channels** | Telegram / Discord / Slack / WeChat / Feishu / Email / Web / WebSocket / Voice / Webhook / API |
|
|
359
|
+
| 🔌 | **3 Protocols** | Google A2A + AG-UI + MCP (Server & Client) |
|
|
360
|
+
| 🎨 | **OPC Studio** | Visual management dashboard — one command `opc studio` |
|
|
361
|
+
| 📊 | **OpenTelemetry** | Full distributed tracing + p50 / p95 / p99 latency metrics |
|
|
362
|
+
| 🧪 | **Built-in Eval** | `opc eval` with 24 evaluation test cases for quantifying Agent quality |
|
|
363
|
+
| 🔍 | **RAG Pipeline** | 5 chunking strategies + 4 rerankers (via DeepBrain) |
|
|
364
|
+
| 📦 | **Package & Publish** | `opc publish` — one command to publish to npm |
|
|
365
|
+
| 🏭 | **Role Templates** | 100+ professional roles, `opc init --role` for instant creation |
|
|
366
|
+
| 🔒 | **Security Sandbox** | Command approval + API Key encryption + file/network restrictions |
|
|
367
|
+
| 🤖 | **Sub-Agents** | spawn / parallel / kill for multi-Agent collaboration |
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## 🏗️ Architecture
|
|
372
|
+
|
|
373
|
+
```
|
|
374
|
+
┌──────────────────────────────────────────────────┐
|
|
375
|
+
│ OPC Studio (:4000) │
|
|
376
|
+
│ Visual Management · Monitoring · Debug │
|
|
377
|
+
├────────────┬────────────┬────────────┬───────────┤
|
|
378
|
+
│ DeepBrain │ AgentKits │Workstation │ OPC Core │
|
|
379
|
+
│ 🧠 Memory │ 📊 Models │ 👤 Roles │ ⚡ Engine │
|
|
380
|
+
│ │ │ │ │
|
|
381
|
+
│ learn() │ OpenAI │ 100+ roles │ 11 chan. │
|
|
382
|
+
│ recall() │ Anthropic │ YAML def. │ 3 proto. │
|
|
383
|
+
│ evolve() │ Ollama │ Skill sys. │ Cron sched│
|
|
384
|
+
│ RAG │ DeepSeek │ One-click │ Sub-Agent │
|
|
385
|
+
├────────────┴────────────┴────────────┴───────────┤
|
|
386
|
+
│ OpenTelemetry Tracing · Eval · Traces │
|
|
387
|
+
└──────────────────────────────────────────────────┘
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## 💻 Code Examples
|
|
393
|
+
|
|
394
|
+
### 1. Minimal Agent (10 lines)
|
|
395
|
+
|
|
396
|
+
```typescript
|
|
397
|
+
import { BaseAgent, InMemoryStore } from 'opc-agent';
|
|
398
|
+
|
|
399
|
+
const agent = new BaseAgent({
|
|
400
|
+
name: 'my-agent',
|
|
401
|
+
systemPrompt: 'You are a helpful assistant.',
|
|
402
|
+
provider: 'ollama',
|
|
403
|
+
model: 'qwen2.5',
|
|
404
|
+
memory: new InMemoryStore(),
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
await agent.init();
|
|
408
|
+
const response = await agent.handleMessage({
|
|
409
|
+
id: '1', content: 'Hello!', sender: 'user',
|
|
410
|
+
channel: 'web', sessionId: 's1', timestamp: new Date(),
|
|
411
|
+
});
|
|
412
|
+
console.log(response.content);
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
### 2. Agent with Memory Evolution
|
|
416
|
+
|
|
417
|
+
```typescript
|
|
418
|
+
import { AgentRuntime } from 'opc-agent';
|
|
419
|
+
|
|
420
|
+
const runtime = new AgentRuntime('./agent.yaml');
|
|
421
|
+
await runtime.start();
|
|
422
|
+
// Auto: recall(history) → respond(generate) → learn(distill) → evolve(improve)
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
### 3. Multi-Protocol Agent (agent.yaml)
|
|
426
|
+
|
|
427
|
+
```yaml
|
|
428
|
+
id: smart-assistant
|
|
429
|
+
name: Smart Assistant
|
|
430
|
+
version: "1.0.0"
|
|
431
|
+
model: deepseek-chat
|
|
432
|
+
|
|
433
|
+
channels:
|
|
434
|
+
- type: web
|
|
435
|
+
port: 3000
|
|
436
|
+
- type: telegram
|
|
437
|
+
token: ${TELEGRAM_BOT_TOKEN}
|
|
438
|
+
|
|
439
|
+
protocols:
|
|
440
|
+
a2a:
|
|
441
|
+
enabled: true
|
|
442
|
+
port: 4001
|
|
443
|
+
ag-ui:
|
|
444
|
+
enabled: true
|
|
445
|
+
port: 4002
|
|
446
|
+
mcp:
|
|
447
|
+
role: both # server + client
|
|
448
|
+
port: 4003
|
|
449
|
+
servers:
|
|
450
|
+
- name: file-tools
|
|
451
|
+
command: npx @modelcontextprotocol/server-filesystem
|
|
452
|
+
|
|
453
|
+
memory:
|
|
454
|
+
shortTerm: true
|
|
455
|
+
longTerm:
|
|
456
|
+
provider: deepbrain
|
|
457
|
+
autoEvolve: true
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
---
|
|
461
|
+
|
|
462
|
+
## 🌱 Brain Seed Auto-Loading
|
|
463
|
+
|
|
464
|
+
Since v2.1.0, OPC Agent supports automatic 3-tier knowledge seed loading. When a `brain-seeds/` directory exists, the Agent auto-imports industry → job → workstation knowledge on first run:
|
|
465
|
+
|
|
466
|
+
```typescript
|
|
467
|
+
const agent = new BaseAgent({
|
|
468
|
+
name: 'my-agent',
|
|
469
|
+
systemPrompt: 'You are a helpful assistant.',
|
|
470
|
+
provider: 'deepseek',
|
|
471
|
+
model: 'deepseek-chat',
|
|
472
|
+
});
|
|
473
|
+
agent.setLongTermMemory(brain);
|
|
474
|
+
// Auto-seeds on first run if brain-seeds/ directory exists
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
Manage brain seeds via CLI:
|
|
478
|
+
|
|
479
|
+
```bash
|
|
480
|
+
opc brain seed # View current brain seed status
|
|
481
|
+
opc brain seed --load # Manually load/reload seeds
|
|
482
|
+
opc brain evolve # Trigger knowledge evolution (workstation → job → industry)
|
|
483
|
+
opc brain status # View brain statistics
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
---
|
|
487
|
+
|
|
488
|
+
## 📊 Comparison
|
|
489
|
+
|
|
490
|
+
| Feature | OPC Agent | Mastra | CrewAI | LangGraph |
|
|
491
|
+
|---------|:---------:|:------:|:------:|:---------:|
|
|
492
|
+
| Language | TypeScript | TypeScript | Python | Python |
|
|
493
|
+
| Memory Evolution | ✅ Built-in | ❌ | ❌ | ❌ |
|
|
494
|
+
| Full-lifecycle CLI | ✅ 20+ cmds | ⚠️ Partial | ❌ | ❌ |
|
|
495
|
+
| Channels | 11 | DIY | DIY | DIY |
|
|
496
|
+
| A2A Protocol | ✅ | ⚠️ | ❌ | ❌ |
|
|
497
|
+
| AG-UI Protocol | ✅ | ❌ | ❌ | ❌ |
|
|
498
|
+
| MCP (Server+Client) | ✅ | ⚠️ Client | ❌ | ⚠️ Client |
|
|
499
|
+
| Visual Studio | ✅ | ⚠️ | ❌ | ⚠️ |
|
|
500
|
+
| Built-in Eval | ✅ `opc eval` | ❌ | ❌ | ❌ |
|
|
501
|
+
| OpenTelemetry | ✅ | ❌ | ❌ | ⚠️ |
|
|
502
|
+
| Sub-Agents | ✅ spawn/parallel | ❌ | ✅ | ✅ |
|
|
503
|
+
| Publish to npm | ✅ `opc publish` | ❌ | ❌ | ❌ |
|
|
504
|
+
| YAML Declarative | ✅ | ⚠️ | ❌ | ❌ |
|
|
505
|
+
|
|
506
|
+
> Each framework has its strengths — OPC's differentiation is the **Memory Evolution + Full-lifecycle CLI + 11 Channels** complete loop.
|
|
507
|
+
|
|
508
|
+
---
|
|
509
|
+
|
|
510
|
+
## 📦 Ecosystem
|
|
511
|
+
|
|
512
|
+
| Package | Purpose | Install |
|
|
513
|
+
|---|---|---|
|
|
514
|
+
| **[opc-agent](https://www.npmjs.com/package/opc-agent)** | Agent OS — create, run, manage | `npm i opc-agent` |
|
|
515
|
+
| **[deepbrain](https://www.npmjs.com/package/deepbrain)** | Org Brain — memory storage & evolution | `npm i deepbrain` |
|
|
516
|
+
| **[agentkits](https://www.npmjs.com/package/agentkits)** | Model Layer — unified API + routing | `npm i agentkits` |
|
|
517
|
+
| **[agent-workstation](https://www.npmjs.com/package/agent-workstation)** | Role Templates — 100+ professional roles | `npm i agent-workstation` |
|
|
518
|
+
|
|
519
|
+
---
|
|
520
|
+
|
|
521
|
+
## 🔧 CLI Reference
|
|
522
|
+
|
|
523
|
+
| Command | Description |
|
|
524
|
+
|---------|-------------|
|
|
525
|
+
| `opc init <name>` | Create a new Agent (supports `--role` for role templates) |
|
|
526
|
+
| `opc chat` | Interactive TUI conversation |
|
|
527
|
+
| `opc dev` | Development mode (hot reload) |
|
|
528
|
+
| `opc run` | Production run |
|
|
529
|
+
| `opc start` | Daemon mode (background) |
|
|
530
|
+
| `opc stop` | Stop daemon |
|
|
531
|
+
| `opc status` | View running status |
|
|
532
|
+
| `opc studio` | Launch visual management dashboard |
|
|
533
|
+
| `opc doctor` | Environment check & diagnostics |
|
|
534
|
+
| `opc eval` | Run evaluation tests |
|
|
535
|
+
| `opc test` | Run unit tests |
|
|
536
|
+
| `opc build` | Build Agent |
|
|
537
|
+
| `opc publish` | Publish to npm |
|
|
538
|
+
| `opc deploy` | Deploy to cloud |
|
|
539
|
+
| `opc logs [-f]` | View Traces logs |
|
|
540
|
+
| `opc traces` | View distributed traces |
|
|
541
|
+
| `opc score` | View performance score |
|
|
542
|
+
| `opc analytics` | Analytics dashboard |
|
|
543
|
+
| `opc brain` | View memory status |
|
|
544
|
+
| `opc brain seed` | View/load 3-tier knowledge seeds |
|
|
545
|
+
| `opc brain evolve` | Trigger knowledge evolution (workstation → job → industry) |
|
|
546
|
+
| `opc brain status` | View brain detailed statistics |
|
|
547
|
+
| `opc jobs` | View scheduled tasks |
|
|
548
|
+
| `opc skills` | View learned skills |
|
|
549
|
+
| `opc search <query>` | Search |
|
|
550
|
+
| `opc info` | Agent info |
|
|
551
|
+
| `opc install <skill>` | Install a skill |
|
|
552
|
+
| `opc plugin <name>` | Manage plugins |
|
|
553
|
+
| `opc tool <name>` | Manage tools |
|
|
554
|
+
| `opc workflow <name>` | Workflows |
|
|
555
|
+
| `opc migrate` | Migration |
|
|
556
|
+
|
|
557
|
+
---
|
|
558
|
+
|
|
559
|
+
## 🔌 Protocol Support
|
|
560
|
+
|
|
561
|
+
| Protocol | Role | Description |
|
|
562
|
+
|----------|------|-------------|
|
|
563
|
+
| **[Google A2A](https://google.github.io/A2A/)** | Server + Client | Agent-to-Agent interop — discover and invoke other Agents |
|
|
564
|
+
| **[AG-UI](https://ag-ui.com/)** | Server | Agent-to-UI streaming protocol — real-time frontend rendering |
|
|
565
|
+
| **[MCP](https://modelcontextprotocol.io/)** | Server + Client | Connect to external tool servers or serve as a tool provider |
|
|
566
|
+
|
|
567
|
+
---
|
|
568
|
+
|
|
569
|
+
## 📡 11 Channels
|
|
570
|
+
|
|
571
|
+
| Channel | Status | Description |
|
|
572
|
+
|---------|:------:|-------------|
|
|
573
|
+
| 🌐 Web | ✅ | Web chat widget |
|
|
574
|
+
| 📱 Telegram | ✅ | Bot API |
|
|
575
|
+
| 💬 Slack | ✅ | Slack App |
|
|
576
|
+
| 🎮 Discord | ✅ | Discord Bot |
|
|
577
|
+
| 📧 Email | ✅ | IMAP / SMTP |
|
|
578
|
+
| 💚 WeChat | ✅ | Enterprise / Personal WeChat |
|
|
579
|
+
| 🔵 Feishu | ✅ | Feishu (Lark) Bot |
|
|
580
|
+
| 🎤 Voice | ✅ | Voice call |
|
|
581
|
+
| 🔌 WebSocket | ✅ | Real-time bidirectional |
|
|
582
|
+
| 🪝 Webhook | ✅ | HTTP callback |
|
|
583
|
+
| 📡 REST API | ✅ | HTTP API |
|
|
584
|
+
|
|
585
|
+
---
|
|
586
|
+
|
|
587
|
+
## 🤝 Contributing
|
|
588
|
+
|
|
589
|
+
Contributions welcome! See [Contributing Guide](CONTRIBUTING.md).
|
|
590
|
+
|
|
591
|
+
```bash
|
|
592
|
+
git clone https://github.com/Deepleaper/opc-agent.git
|
|
593
|
+
cd opc-agent
|
|
594
|
+
npm install
|
|
595
|
+
npm run build
|
|
596
|
+
npm test
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
---
|
|
600
|
+
|
|
601
|
+
## 📄 License
|
|
602
|
+
|
|
603
|
+
[Apache-2.0](LICENSE) © [Deepleaper](https://github.com/Deepleaper)
|