opc-agent 1.3.0 → 1.3.2
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/CHANGELOG.md +6 -0
- package/CONTRIBUTING.md +75 -75
- package/README.md +358 -235
- package/README.zh-CN.md +415 -415
- package/dist/core/dashboard.d.ts +35 -0
- package/dist/core/dashboard.js +157 -0
- package/dist/core/priority.d.ts +52 -0
- package/dist/core/priority.js +102 -0
- package/dist/core/streaming.d.ts +56 -0
- package/dist/core/streaming.js +160 -0
- package/dist/deploy/hermes.js +22 -22
- package/dist/deploy/openclaw.js +31 -31
- package/dist/index.d.ts +8 -0
- package/dist/index.js +12 -1
- package/dist/templates/code-reviewer.js +5 -5
- package/dist/templates/customer-service.js +2 -2
- package/dist/templates/data-analyst.js +5 -5
- package/dist/templates/knowledge-base.js +2 -2
- package/dist/templates/sales-assistant.js +4 -4
- package/dist/templates/teacher.js +6 -6
- package/dist/tools/gateway.d.ts +28 -0
- package/dist/tools/gateway.js +177 -0
- package/docs/.vitepress/config.ts +103 -103
- package/docs/api/cli.md +48 -48
- package/docs/api/oad-schema.md +64 -64
- package/docs/api/sdk.md +80 -80
- package/docs/guide/concepts.md +51 -51
- package/docs/guide/configuration.md +79 -79
- package/docs/guide/deployment.md +42 -42
- package/docs/guide/getting-started.md +44 -44
- package/docs/guide/templates.md +28 -28
- package/docs/guide/testing.md +84 -84
- package/docs/index.md +27 -27
- package/docs/zh/api/cli.md +54 -54
- package/docs/zh/api/oad-schema.md +87 -87
- package/docs/zh/api/sdk.md +102 -102
- package/docs/zh/guide/concepts.md +104 -104
- package/docs/zh/guide/configuration.md +135 -135
- package/docs/zh/guide/deployment.md +81 -81
- package/docs/zh/guide/getting-started.md +82 -82
- package/docs/zh/guide/templates.md +84 -84
- package/docs/zh/guide/testing.md +88 -88
- package/docs/zh/index.md +27 -27
- package/examples/customer-service-demo/README.md +90 -90
- package/examples/customer-service-demo/oad.yaml +107 -107
- package/package.json +50 -50
- package/src/analytics/index.ts +66 -66
- package/src/channels/discord.ts +192 -192
- package/src/channels/email.ts +177 -177
- package/src/channels/feishu.ts +236 -236
- package/src/channels/index.ts +15 -15
- package/src/channels/slack.ts +160 -160
- package/src/channels/telegram.ts +90 -90
- package/src/channels/voice.ts +106 -106
- package/src/channels/webhook.ts +199 -199
- package/src/channels/websocket.ts +87 -87
- package/src/channels/wechat.ts +149 -149
- package/src/cli.ts +1 -119
- package/src/core/a2a.ts +143 -143
- package/src/core/agent.ts +152 -152
- package/src/core/analytics-engine.ts +186 -186
- package/src/core/auth.ts +57 -57
- package/src/core/cache.ts +141 -141
- package/src/core/compose.ts +77 -77
- package/src/core/config.ts +14 -14
- package/src/core/dashboard.ts +219 -0
- package/src/core/errors.ts +148 -148
- package/src/core/hitl.ts +138 -138
- package/src/core/logger.ts +57 -57
- package/src/core/orchestrator.ts +215 -215
- package/src/core/performance.ts +187 -187
- package/src/core/priority.ts +140 -0
- package/src/core/rate-limiter.ts +128 -128
- package/src/core/room.ts +109 -109
- package/src/core/runtime.ts +152 -152
- package/src/core/sandbox.ts +101 -101
- package/src/core/security.ts +171 -171
- package/src/core/types.ts +68 -68
- package/src/core/versioning.ts +106 -106
- package/src/core/watch.ts +178 -178
- package/src/core/workflow.ts +235 -235
- package/src/deploy/hermes.ts +156 -156
- package/src/deploy/openclaw.ts +200 -200
- package/src/dtv/data.ts +29 -0
- package/src/dtv/trust.ts +43 -0
- package/src/dtv/value.ts +47 -0
- package/src/i18n/index.ts +216 -216
- package/src/index.ts +6 -4
- package/src/marketplace/index.ts +223 -0
- package/src/memory/deepbrain.ts +108 -108
- package/src/memory/index.ts +34 -34
- package/src/plugins/index.ts +208 -208
- package/src/schema/oad.ts +155 -154
- package/src/skills/base.ts +16 -16
- package/src/skills/document.ts +100 -100
- package/src/skills/http.ts +35 -35
- package/src/skills/index.ts +27 -27
- package/src/skills/scheduler.ts +80 -80
- package/src/skills/webhook-trigger.ts +59 -59
- package/src/templates/code-reviewer.ts +34 -30
- package/src/templates/customer-service.ts +80 -76
- package/src/templates/data-analyst.ts +70 -66
- package/src/templates/executive-assistant.ts +71 -71
- package/src/templates/financial-advisor.ts +60 -60
- package/src/templates/knowledge-base.ts +31 -27
- package/src/templates/legal-assistant.ts +71 -71
- package/src/templates/sales-assistant.ts +79 -75
- package/src/templates/teacher.ts +79 -75
- package/src/testing/index.ts +181 -181
- package/src/tools/calculator.ts +73 -73
- package/src/tools/datetime.ts +149 -149
- package/src/tools/json-transform.ts +187 -187
- package/src/tools/mcp.ts +76 -76
- package/src/tools/text-analysis.ts +116 -116
- package/templates/Dockerfile +15 -15
- package/templates/code-reviewer/README.md +27 -27
- package/templates/code-reviewer/oad.yaml +41 -41
- package/templates/customer-service/README.md +22 -22
- package/templates/customer-service/oad.yaml +36 -36
- package/templates/docker-compose.yml +21 -21
- package/templates/ecommerce-assistant/README.md +45 -45
- package/templates/ecommerce-assistant/oad.yaml +47 -47
- package/templates/knowledge-base/README.md +28 -28
- package/templates/knowledge-base/oad.yaml +38 -38
- package/templates/sales-assistant/README.md +26 -26
- package/templates/sales-assistant/oad.yaml +43 -43
- package/templates/tech-support/README.md +43 -43
- package/templates/tech-support/oad.yaml +45 -45
- package/tests/a2a.test.ts +66 -66
- package/tests/agent.test.ts +72 -72
- package/tests/analytics.test.ts +50 -50
- package/tests/channel.test.ts +39 -39
- package/tests/e2e.test.ts +134 -134
- package/tests/errors.test.ts +83 -83
- package/tests/hitl.test.ts +71 -71
- package/tests/i18n.test.ts +41 -41
- package/tests/mcp.test.ts +54 -54
- package/tests/oad.test.ts +68 -68
- package/tests/performance.test.ts +115 -115
- package/tests/plugin.test.ts +74 -74
- package/tests/room.test.ts +106 -106
- package/tests/runtime.test.ts +42 -42
- package/tests/sandbox.test.ts +46 -46
- package/tests/security.test.ts +60 -60
- package/tests/templates.test.ts +77 -77
- package/tests/v070.test.ts +76 -76
- package/tests/versioning.test.ts +75 -75
- package/tests/voice.test.ts +61 -61
- package/tests/webhook.test.ts +29 -29
- package/tests/workflow.test.ts +143 -143
- package/tsconfig.json +19 -19
- package/vitest.config.ts +9 -9
- package/src/traces/index.ts +0 -132
package/README.md
CHANGED
|
@@ -1,306 +1,429 @@
|
|
|
1
|
-
<
|
|
1
|
+
<p align="center">
|
|
2
|
+
<h1 align="center">🤖 OPC Agent</h1>
|
|
3
|
+
<p align="center"><strong>开放智能体框架 — 构建、测试、运行企业级 AI 智能体</strong></p>
|
|
4
|
+
<p align="center">
|
|
5
|
+
<a href="https://www.npmjs.com/package/opc-agent"><img src="https://img.shields.io/npm/v/opc-agent?color=blue" alt="npm"></a>
|
|
6
|
+
<a href="https://github.com/Deepleaper/opc-agent/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-green" alt="license"></a>
|
|
7
|
+
<img src="https://img.shields.io/badge/tests-146%20passed-brightgreen" alt="146 tests passing">
|
|
8
|
+
<a href="https://www.npmjs.com/package/opc-agent"><img src="https://img.shields.io/npm/dm/opc-agent?color=orange" alt="downloads"></a>
|
|
9
|
+
</p>
|
|
10
|
+
<p align="center">
|
|
11
|
+
<strong>🇨🇳 中文</strong> · <a href="#english">🇺🇸 English</a>
|
|
12
|
+
</p>
|
|
13
|
+
</p>
|
|
2
14
|
|
|
3
|
-
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
OPC Agent 是一个 **TypeScript 优先的开放智能体框架**,由 [跃盟科技 (Deepleaper)](https://www.deepleaper.com) 开发。用一个 YAML 文件(OAD)定义智能体,接入任意大语言模型,一键部署到多个渠道。
|
|
4
18
|
|
|
5
|
-
|
|
19
|
+
## ⚡ 快速开始(30 秒)
|
|
6
20
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
21
|
+
```bash
|
|
22
|
+
npm install -g opc-agent
|
|
23
|
+
opc init my-agent
|
|
24
|
+
cd my-agent
|
|
25
|
+
opc run
|
|
26
|
+
```
|
|
11
27
|
|
|
12
|
-
|
|
28
|
+
访问 `http://localhost:3000`,内置 Web 对话界面即刻可用。
|
|
13
29
|
|
|
14
|
-
|
|
30
|
+
## ✨ 功能特性
|
|
15
31
|
|
|
16
|
-
|
|
32
|
+
### 🔌 多模型供应商
|
|
17
33
|
|
|
18
|
-
|
|
34
|
+
```yaml
|
|
35
|
+
spec:
|
|
36
|
+
provider:
|
|
37
|
+
default: deepseek
|
|
38
|
+
allowed: [openai, deepseek, qwen, anthropic, ollama]
|
|
39
|
+
model: deepseek-chat
|
|
40
|
+
```
|
|
19
41
|
|
|
20
|
-
|
|
21
|
-
> 从创建到运行到监控,一个工具搞定 Agent 全生命周期。
|
|
42
|
+
支持 **DeepSeek**、**通义千问 (Qwen)**、**OpenAI**、**Anthropic**、**Ollama**(本地),以及任何兼容 OpenAI 接口的服务。
|
|
22
43
|
|
|
23
|
-
|
|
44
|
+
### 📡 11 个渠道,一套代码
|
|
24
45
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
46
|
+
```yaml
|
|
47
|
+
spec:
|
|
48
|
+
channels:
|
|
49
|
+
- type: web # Web 对话界面(内置 UI)
|
|
50
|
+
port: 3000
|
|
51
|
+
- type: telegram # Telegram 机器人
|
|
52
|
+
- type: websocket # 实时 WebSocket
|
|
53
|
+
- type: slack # Slack Bot(Socket Mode / Events API)
|
|
54
|
+
- type: email # IMAP 收信 + SMTP 回信
|
|
55
|
+
- type: wechat # 微信公众号
|
|
56
|
+
- type: feishu # 飞书 / Lark 消息卡片
|
|
57
|
+
- type: voice # 语音(STT/TTS,可配置供应商)
|
|
58
|
+
- type: webhook # Webhook 接收 + HTTP 回调
|
|
59
|
+
- type: discord # Discord Bot(斜杠命令 + 线程 + Embed)
|
|
60
|
+
```
|
|
33
61
|
|
|
34
|
-
|
|
62
|
+
### 🧠 知识库(RAG)
|
|
35
63
|
|
|
36
|
-
|
|
64
|
+
```typescript
|
|
65
|
+
import { KnowledgeBase } from 'opc-agent';
|
|
37
66
|
|
|
38
|
-
|
|
39
|
-
|
|
67
|
+
const kb = new KnowledgeBase('./docs');
|
|
68
|
+
await kb.addFile('产品手册.pdf');
|
|
69
|
+
// 智能体自动检索知识库,无需额外配置
|
|
70
|
+
```
|
|
40
71
|
|
|
41
|
-
|
|
42
|
-
opc init my-agent
|
|
43
|
-
cd my-agent
|
|
72
|
+
内置 TF-IDF 向量化 + 余弦相似度检索,数据持久化到 `.opc-knowledge.json`,无需外部向量数据库。
|
|
44
73
|
|
|
45
|
-
|
|
46
|
-
opc dev
|
|
74
|
+
### 🎭 多智能体编排
|
|
47
75
|
|
|
48
|
-
|
|
49
|
-
opc
|
|
76
|
+
```typescript
|
|
77
|
+
import { Orchestrator } from 'opc-agent';
|
|
50
78
|
|
|
51
|
-
|
|
52
|
-
|
|
79
|
+
const orchestrator = new Orchestrator({
|
|
80
|
+
agents: [分诊智能体, 销售智能体, 客服智能体],
|
|
81
|
+
strategy: 'route-by-intent',
|
|
82
|
+
});
|
|
53
83
|
```
|
|
54
84
|
|
|
55
|
-
|
|
85
|
+
支持顺序执行、并行执行、条件路由、智能体移交(handoff)。
|
|
56
86
|
|
|
57
|
-
|
|
87
|
+
### 🧪 内置测试框架
|
|
58
88
|
|
|
59
89
|
```yaml
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
skills:
|
|
69
|
-
- ticket-management
|
|
70
|
-
- knowledge-base-search
|
|
71
|
-
|
|
72
|
-
channels:
|
|
73
|
-
- type: web
|
|
74
|
-
priority: primary
|
|
75
|
-
- type: telegram
|
|
76
|
-
priority: secondary
|
|
77
|
-
- type: wechat
|
|
78
|
-
priority: secondary
|
|
79
|
-
|
|
80
|
-
memory:
|
|
81
|
-
shortTerm: true
|
|
82
|
-
longTerm:
|
|
83
|
-
provider: deepbrain
|
|
90
|
+
spec:
|
|
91
|
+
testing:
|
|
92
|
+
cases:
|
|
93
|
+
- name: 问候测试
|
|
94
|
+
input: "你好"
|
|
95
|
+
expect:
|
|
96
|
+
contains: ["你好", "帮"]
|
|
97
|
+
maxLatencyMs: 5000
|
|
84
98
|
```
|
|
85
99
|
|
|
86
|
-
## CLI 命令
|
|
87
|
-
|
|
88
100
|
```bash
|
|
89
|
-
opc
|
|
90
|
-
opc
|
|
91
|
-
opc test
|
|
92
|
-
opc run # 生产运行
|
|
93
|
-
opc logs [-f] # 查看 Traces 日志
|
|
94
|
-
opc brain [--url ...] # 查看记忆状态
|
|
95
|
-
opc score # 查看性能评分
|
|
101
|
+
opc test # 运行测试用例
|
|
102
|
+
opc test --watch # 监听模式
|
|
103
|
+
opc test --json # JSON 格式输出
|
|
96
104
|
```
|
|
97
105
|
|
|
98
|
-
|
|
106
|
+
### 🔧 插件系统
|
|
99
107
|
|
|
100
|
-
|
|
108
|
+
```yaml
|
|
109
|
+
spec:
|
|
110
|
+
plugins:
|
|
111
|
+
- name: logging
|
|
112
|
+
- name: analytics
|
|
113
|
+
- name: rate-limit
|
|
114
|
+
config: { maxPerMinute: 60 }
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
完整生命周期钩子:`onInit`、`onMessage`、`onResponse`、`onError`、`onShutdown`。
|
|
118
|
+
|
|
119
|
+
### 🔒 安全特性
|
|
120
|
+
|
|
121
|
+
- 输入消毒(防 XSS、注入攻击)
|
|
122
|
+
- API Key 轮换管理
|
|
123
|
+
- CORS 配置
|
|
124
|
+
- 安全响应头
|
|
125
|
+
- 会话隔离认证中间件
|
|
101
126
|
|
|
102
|
-
|
|
103
|
-
|------|------|------|
|
|
104
|
-
| 🌐 Web | ✅ | 网页聊天 |
|
|
105
|
-
| 📱 Telegram | ✅ | Bot API |
|
|
106
|
-
| 💬 Slack | ✅ | Slack App |
|
|
107
|
-
| 🎮 Discord | ✅ | Discord Bot |
|
|
108
|
-
| 📧 Email | ✅ | IMAP/SMTP |
|
|
109
|
-
| 💚 微信 | ✅ | 企业微信/个人微信 |
|
|
110
|
-
| 🔵 飞书 | ✅ | 飞书机器人 |
|
|
111
|
-
| 🎤 Voice | ✅ | 语音通话 |
|
|
112
|
-
| 🔌 WebSocket | ✅ | 实时双向 |
|
|
113
|
-
| 🪝 Webhook | ✅ | HTTP 回调 |
|
|
114
|
-
| 📡 API | ✅ | REST API |
|
|
127
|
+
### 📊 监控与分析
|
|
115
128
|
|
|
116
|
-
|
|
129
|
+
Web 渠道内置以下端点:
|
|
117
130
|
|
|
118
|
-
|
|
|
131
|
+
| 端点 | 说明 |
|
|
119
132
|
|------|------|
|
|
120
|
-
|
|
|
121
|
-
|
|
|
122
|
-
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
| 🚀 **部署** | OpenClaw 等平台一键部署 |
|
|
128
|
-
| 📈 **分析** | Analytics 数据分析 |
|
|
129
|
-
| 🔄 **流式** | Streaming 实时响应 |
|
|
130
|
-
|
|
131
|
-
## 架构
|
|
133
|
+
| `GET /api/health` | 健康检查 |
|
|
134
|
+
| `GET /api/metrics` | Prometheus 文本格式指标(uptime、请求数、错误数、LLM 延迟、Token 用量等) |
|
|
135
|
+
| `GET /api/dashboard` | 实时仪表盘 |
|
|
136
|
+
|
|
137
|
+
`opc analytics` 和 `opc stats` 命令可查看离线分析快照。
|
|
138
|
+
|
|
139
|
+
## 🏗️ 架构
|
|
132
140
|
|
|
133
141
|
```
|
|
134
|
-
|
|
135
|
-
│
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
│
|
|
139
|
-
│
|
|
140
|
-
│
|
|
141
|
-
|
|
142
|
-
│
|
|
143
|
-
│
|
|
144
|
-
|
|
142
|
+
┌─────────────────────────────────────────────────┐
|
|
143
|
+
│ OAD (YAML 定义文件) │
|
|
144
|
+
│ 智能体的一切配置都在这里 │
|
|
145
|
+
├─────────────────────────────────────────────────┤
|
|
146
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
|
|
147
|
+
│ │ 渠道层 │ │ 插件层 │ │ 安全层 │ │
|
|
148
|
+
│ │10 个渠道 │ │ 日志/分析│ │ 消毒/CORS/认证│ │
|
|
149
|
+
│ └────┬─────┘ └────┬─────┘ └──────┬───────┘ │
|
|
150
|
+
│ ┌────▼──────────────▼───────────────▼────────┐ │
|
|
151
|
+
│ │ 智能体运行时 (Agent Runtime) │ │
|
|
152
|
+
│ │ ┌─────────┐ ┌────────┐ ┌─────────────┐ │ │
|
|
153
|
+
│ │ │ 记忆 │ │ 技能 │ │ 知识库 │ │ │
|
|
154
|
+
│ │ └─────────┘ └────────┘ └─────────────┘ │ │
|
|
155
|
+
│ └────────────────────┬───────────────────────┘ │
|
|
156
|
+
│ ┌────────────────────▼───────────────────────┐ │
|
|
157
|
+
│ │ 大语言模型供应商 │ │
|
|
158
|
+
│ │ DeepSeek · 通义千问 · OpenAI · Ollama │ │
|
|
159
|
+
│ └─────────────────────────────────────────────┘│
|
|
160
|
+
└─────────────────────────────────────────────────┘
|
|
145
161
|
```
|
|
146
162
|
|
|
147
|
-
##
|
|
163
|
+
## 📋 12 个开箱即用模板
|
|
148
164
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
| **opc-agent** | Agent OS | ← 你在这里 |
|
|
153
|
-
| [agentkits](https://github.com/Deepleaper/agentkits) | 带记忆的 OpenRouter | 模型调用层 |
|
|
154
|
-
| [agent-workstation](https://github.com/Deepleaper/agent-workstation) | 虚拟工位模板 | `opc init --template` |
|
|
165
|
+
```bash
|
|
166
|
+
opc init my-agent --template <模板名>
|
|
167
|
+
```
|
|
155
168
|
|
|
156
|
-
|
|
169
|
+
| 模板 | 说明 | 典型场景 |
|
|
170
|
+
|------|------|---------|
|
|
171
|
+
| `customer-service` | 客服智能体 | FAQ 自动回答 + 转人工 |
|
|
172
|
+
| `sales-assistant` | 销售助手 | 产品问答 + 线索捕获 |
|
|
173
|
+
| `knowledge-base` | 知识库问答 | 文档 RAG 语义检索 |
|
|
174
|
+
| `code-reviewer` | 代码审查 | Bug 检测 + 风格检查 |
|
|
175
|
+
| `hr-recruiter` | HR 招聘助手 | 简历筛选 + 面试安排 |
|
|
176
|
+
| `project-manager` | 项目管理 | 任务跟踪 + 会议纪要 |
|
|
177
|
+
| `content-writer` | 内容创作 | 博客 + 社媒 + SEO |
|
|
178
|
+
| `legal-assistant` | 法务助手 | 合同审查 + 合规检查 |
|
|
179
|
+
| `financial-advisor` | 财务顾问 | 预算管理 + 支出追踪 |
|
|
180
|
+
| `executive-assistant` | 行政助理 | 日程 + 邮件 + 会议 |
|
|
181
|
+
| `data-analyst` | 数据分析师 | 数据查询 + 可视化 |
|
|
182
|
+
| `teacher` | 教学助手 | 课程设计 + 出题 |
|
|
157
183
|
|
|
158
|
-
|
|
184
|
+
## 🚀 部署
|
|
159
185
|
|
|
160
|
-
|
|
186
|
+
### Docker 部署
|
|
161
187
|
|
|
162
|
-
|
|
188
|
+
`opc init` 创建的每个项目都自带 `Dockerfile` 和 `docker-compose.yml`:
|
|
163
189
|
|
|
164
|
-
|
|
190
|
+
```bash
|
|
191
|
+
docker compose up -d
|
|
192
|
+
```
|
|
165
193
|
|
|
166
|
-
|
|
194
|
+
### 部署到 OpenClaw
|
|
167
195
|
|
|
168
|
-
|
|
169
|
-
|
|
196
|
+
```bash
|
|
197
|
+
opc deploy --target openclaw
|
|
198
|
+
opc deploy --target openclaw --install # 同时写入本地配置
|
|
199
|
+
```
|
|
170
200
|
|
|
171
|
-
|
|
201
|
+
生成 `IDENTITY.md`、`SOUL.md`、`AGENTS.md` 到 `~/.openclaw/agents/{id}/workspace/`。
|
|
172
202
|
|
|
173
|
-
|
|
174
|
-
|---|---|---|---|---|
|
|
175
|
-
| Creation | Write code | Write code | Write code | **`opc init` one command** |
|
|
176
|
-
| Configuration | Python/code | Python | Python | **YAML declarative** |
|
|
177
|
-
| Testing | DIY | None | None | **Built-in test framework** |
|
|
178
|
-
| Channels | DIY | None | None | **11 channels out-of-the-box** |
|
|
179
|
-
| Monitoring | DIY | None | None | **Traces + Score** |
|
|
180
|
-
| Memory | DIY | Basic | Basic | **DeepBrain integration** |
|
|
203
|
+
### 部署到 Hermes
|
|
181
204
|
|
|
182
|
-
|
|
205
|
+
```bash
|
|
206
|
+
opc deploy --target hermes
|
|
207
|
+
```
|
|
183
208
|
|
|
184
|
-
|
|
209
|
+
将 OAD 转换为 Hermes Character 格式(包含 personality、bio、lore、message examples 等字段)。
|
|
185
210
|
|
|
186
|
-
|
|
187
|
-
npm install -g opc-agent
|
|
211
|
+
## 📖 CLI 命令参考
|
|
188
212
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
213
|
+
| 命令 | 说明 |
|
|
214
|
+
|------|------|
|
|
215
|
+
| `opc init [name]` | 创建新智能体项目(交互式,可选模板) |
|
|
216
|
+
| `opc create <name>` | 从模板快速创建 |
|
|
217
|
+
| `opc run` | 启动智能体 |
|
|
218
|
+
| `opc dev` | 开发模式(文件监听热重载) |
|
|
219
|
+
| `opc chat` | 命令行交互对话(readline 界面) |
|
|
220
|
+
| `opc test` | 运行 OAD 中定义的测试用例 |
|
|
221
|
+
| `opc build` | 校验 OAD 配置合法性 |
|
|
222
|
+
| `opc info` | 查看智能体信息 |
|
|
223
|
+
| `opc analytics` | 查看使用分析 |
|
|
224
|
+
| `opc stats` | 查看运行时统计快照 |
|
|
225
|
+
| `opc deploy` | 部署智能体(--target openclaw\|hermes) |
|
|
226
|
+
| `opc kb add <file>` | 向知识库添加文件 |
|
|
227
|
+
| `opc kb search <query>` | 搜索知识库 |
|
|
228
|
+
| `opc kb stats` | 知识库统计 |
|
|
229
|
+
| `opc kb clear` | 清空知识库 |
|
|
230
|
+
| `opc search` | 搜索 OPC Registry |
|
|
231
|
+
| `opc tool` | MCP 工具管理 |
|
|
232
|
+
| `opc workflow run` | 运行工作流 |
|
|
233
|
+
| `opc workflow list` | 列出工作流 |
|
|
234
|
+
| `opc version-mgmt list` | 列出历史版本 |
|
|
235
|
+
| `opc version-mgmt rollback` | 回滚版本 |
|
|
236
|
+
| `opc publish` | 打包发布智能体 |
|
|
237
|
+
| `opc install <pkg>` | 安装智能体包 |
|
|
238
|
+
| `opc plugin list` | 列出已安装插件 |
|
|
239
|
+
| `opc plugin add <name>` | 添加插件 |
|
|
240
|
+
| `opc migrate` | OAD Schema 迁移 |
|
|
241
|
+
|
|
242
|
+
## 🔗 SDK 参考
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
import { AgentRuntime, KnowledgeBase, Orchestrator } from 'opc-agent';
|
|
246
|
+
|
|
247
|
+
// 启动智能体
|
|
248
|
+
const runtime = new AgentRuntime();
|
|
249
|
+
await runtime.loadConfig('oad.yaml');
|
|
250
|
+
await runtime.initialize();
|
|
251
|
+
await runtime.start();
|
|
252
|
+
|
|
253
|
+
// 知识库
|
|
254
|
+
const kb = new KnowledgeBase('./docs');
|
|
255
|
+
await kb.addFile('handbook.pdf');
|
|
256
|
+
const results = await kb.search('退款政策');
|
|
257
|
+
|
|
258
|
+
// 多智能体编排
|
|
259
|
+
const orch = new Orchestrator({
|
|
260
|
+
agents: [agentA, agentB],
|
|
261
|
+
strategy: 'route-by-intent',
|
|
262
|
+
});
|
|
263
|
+
```
|
|
192
264
|
|
|
193
|
-
|
|
194
|
-
opc dev
|
|
265
|
+
## 🔑 OAD 配置文件速览
|
|
195
266
|
|
|
196
|
-
|
|
197
|
-
opc
|
|
267
|
+
```yaml
|
|
268
|
+
apiVersion: opc/v1
|
|
269
|
+
kind: Agent
|
|
270
|
+
|
|
271
|
+
metadata:
|
|
272
|
+
name: my-agent
|
|
273
|
+
version: 1.0.0
|
|
274
|
+
|
|
275
|
+
spec:
|
|
276
|
+
provider:
|
|
277
|
+
default: deepseek
|
|
278
|
+
allowed: [deepseek, openai, qwen, anthropic, ollama]
|
|
279
|
+
model: deepseek-chat
|
|
280
|
+
systemPrompt: |
|
|
281
|
+
你是一个专业的客服助手...
|
|
282
|
+
|
|
283
|
+
channels:
|
|
284
|
+
- type: web
|
|
285
|
+
port: 3000
|
|
286
|
+
|
|
287
|
+
memory:
|
|
288
|
+
shortTerm: true
|
|
289
|
+
longTerm: false
|
|
290
|
+
|
|
291
|
+
rateLimits:
|
|
292
|
+
perUser:
|
|
293
|
+
maxRequests: 60
|
|
294
|
+
windowMs: 60000
|
|
295
|
+
|
|
296
|
+
plugins:
|
|
297
|
+
- name: logging
|
|
298
|
+
- name: analytics
|
|
299
|
+
|
|
300
|
+
testing:
|
|
301
|
+
cases:
|
|
302
|
+
- name: 基本问候
|
|
303
|
+
input: "你好"
|
|
304
|
+
expect:
|
|
305
|
+
contains: ["你好"]
|
|
306
|
+
maxLatencyMs: 5000
|
|
307
|
+
```
|
|
198
308
|
|
|
199
|
-
|
|
200
|
-
|
|
309
|
+
## 🤝 贡献指南
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
git clone https://github.com/Deepleaper/opc-agent.git
|
|
313
|
+
cd opc-agent
|
|
314
|
+
npm install
|
|
315
|
+
npm run build # TypeScript 编译
|
|
316
|
+
npm test # 运行 146 个测试
|
|
201
317
|
```
|
|
202
318
|
|
|
203
|
-
|
|
319
|
+
欢迎提交 Issue 和 Pull Request。
|
|
204
320
|
|
|
205
|
-
|
|
321
|
+
## 📄 开源协议
|
|
206
322
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
- type: wechat
|
|
226
|
-
priority: secondary
|
|
227
|
-
|
|
228
|
-
memory:
|
|
229
|
-
shortTerm: true
|
|
230
|
-
longTerm:
|
|
231
|
-
provider: deepbrain
|
|
323
|
+
[Apache License 2.0](LICENSE) — 商用和开源项目均可自由使用。
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
<details>
|
|
328
|
+
<summary id="english">🇺🇸 English</summary>
|
|
329
|
+
|
|
330
|
+
## OPC Agent
|
|
331
|
+
|
|
332
|
+
A **TypeScript-first open agent framework** by [Deepleaper](https://www.deepleaper.com). Define your agent in a single YAML file (OAD — Open Agent Definition), connect any LLM provider, deploy to any channel.
|
|
333
|
+
|
|
334
|
+
## Quick Start
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
npm install -g opc-agent
|
|
338
|
+
opc init my-agent
|
|
339
|
+
cd my-agent
|
|
340
|
+
opc run
|
|
232
341
|
```
|
|
233
342
|
|
|
234
|
-
|
|
343
|
+
Agent is live at `http://localhost:3000` with a built-in web chat UI.
|
|
344
|
+
|
|
345
|
+
## Features
|
|
346
|
+
|
|
347
|
+
- **Multi-Provider LLM** — DeepSeek, Qwen, OpenAI, Anthropic, Ollama, any OpenAI-compatible API
|
|
348
|
+
- **10 Channels** — Web, Telegram, Slack, WebSocket, Email, WeChat, Feishu, Voice (STT/TTS), Webhook, Discord
|
|
349
|
+
- **Knowledge Base (RAG)** — TF-IDF + cosine similarity, no external vector DB required
|
|
350
|
+
- **Multi-Agent Orchestration** — Intent routing, sequential/parallel execution, agent handoff
|
|
351
|
+
- **Built-in Testing** — YAML-defined test cases with content and latency assertions
|
|
352
|
+
- **Plugin System** — Logging, analytics, rate limiting; full lifecycle hooks
|
|
353
|
+
- **Security** — Input sanitization, CORS, auth middleware, session isolation
|
|
354
|
+
- **Monitoring** — `/api/health`, `/api/metrics` (Prometheus format), `/api/dashboard`
|
|
355
|
+
- **12 Templates** — Customer service, sales, knowledge base, code review, HR, and more
|
|
356
|
+
- **146 Tests** — 22 test files covering all major features
|
|
357
|
+
|
|
358
|
+
## CLI Reference
|
|
359
|
+
|
|
360
|
+
| Command | Description |
|
|
361
|
+
|---------|-------------|
|
|
362
|
+
| `opc init [name]` | Create new agent project (interactive, template selection) |
|
|
363
|
+
| `opc run` | Start agent |
|
|
364
|
+
| `opc dev` | Development mode (hot-reload) |
|
|
365
|
+
| `opc test` | Run OAD test cases |
|
|
366
|
+
| `opc chat` | Interactive CLI chat |
|
|
367
|
+
| `opc build` | Validate OAD configuration |
|
|
368
|
+
| `opc deploy` | Deploy (`--target openclaw\|hermes`) |
|
|
369
|
+
| `opc analytics` | View analytics |
|
|
370
|
+
| `opc stats` | Runtime statistics snapshot |
|
|
371
|
+
| `opc kb add <file>` | Add file to knowledge base |
|
|
372
|
+
| `opc kb search <query>` | Search knowledge base |
|
|
373
|
+
| `opc workflow run` | Run a workflow |
|
|
374
|
+
| `opc version-mgmt rollback` | Rollback to a previous version |
|
|
375
|
+
| `opc publish` | Package agent for distribution |
|
|
376
|
+
| `opc install <pkg>` | Install agent package |
|
|
377
|
+
| `opc plugin add <name>` | Add plugin |
|
|
378
|
+
| `opc migrate` | Migrate OAD schema |
|
|
379
|
+
|
|
380
|
+
## Deploy
|
|
381
|
+
|
|
382
|
+
### Docker
|
|
383
|
+
|
|
384
|
+
Every project created with `opc init` includes a `Dockerfile` and `docker-compose.yml`:
|
|
235
385
|
|
|
236
386
|
```bash
|
|
237
|
-
|
|
238
|
-
opc dev # Development mode (hot reload)
|
|
239
|
-
opc test # Run tests
|
|
240
|
-
opc run # Production run
|
|
241
|
-
opc logs [-f] # View Traces logs
|
|
242
|
-
opc brain [--url ...] # View memory status
|
|
243
|
-
opc score # View performance score
|
|
387
|
+
docker compose up -d
|
|
244
388
|
```
|
|
245
389
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
One codebase, deploy to any channel:
|
|
249
|
-
|
|
250
|
-
| Channel | Status | Description |
|
|
251
|
-
|---------|--------|-------------|
|
|
252
|
-
| 🌐 Web | ✅ | Web chat |
|
|
253
|
-
| 📱 Telegram | ✅ | Bot API |
|
|
254
|
-
| 💬 Slack | ✅ | Slack App |
|
|
255
|
-
| 🎮 Discord | ✅ | Discord Bot |
|
|
256
|
-
| 📧 Email | ✅ | IMAP/SMTP |
|
|
257
|
-
| 💚 WeChat | ✅ | Enterprise/Personal WeChat |
|
|
258
|
-
| 🔵 Feishu | ✅ | Feishu (Lark) Bot |
|
|
259
|
-
| 🎤 Voice | ✅ | Voice call |
|
|
260
|
-
| 🔌 WebSocket | ✅ | Real-time bidirectional |
|
|
261
|
-
| 🪝 Webhook | ✅ | HTTP callback |
|
|
262
|
-
| 📡 API | ✅ | REST API |
|
|
263
|
-
|
|
264
|
-
## Full Feature Set
|
|
265
|
-
|
|
266
|
-
| Category | Features |
|
|
267
|
-
|----------|----------|
|
|
268
|
-
| 📋 **Configuration** | OAD declarative definition, YAML config |
|
|
269
|
-
| 📡 **Channels** | 11 channels, unified access |
|
|
270
|
-
| 🧪 **Testing** | Built-in test framework, 163 tests |
|
|
271
|
-
| 🔌 **Plugins** | Extensible skills and tools system |
|
|
272
|
-
| 📊 **Monitoring** | Traces behavior collection, Score rating |
|
|
273
|
-
| 🧠 **Memory** | DeepBrain integration, auto-learning |
|
|
274
|
-
| 🌍 **i18n** | Built-in internationalization support |
|
|
275
|
-
| 🚀 **Deployment** | One-click deploy on OpenClaw and other platforms |
|
|
276
|
-
| 📈 **Analytics** | Data analytics |
|
|
277
|
-
| 🔄 **Streaming** | Real-time streaming responses |
|
|
278
|
-
|
|
279
|
-
## Architecture
|
|
390
|
+
### OpenClaw
|
|
280
391
|
|
|
392
|
+
```bash
|
|
393
|
+
opc deploy --target openclaw
|
|
281
394
|
```
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
├──────────┴──────────┴───────────────────┤
|
|
290
|
-
│ DeepBrain Memory │
|
|
291
|
-
│ learn ← Traces → recall │
|
|
292
|
-
└─────────────────────────────────────────┘
|
|
395
|
+
|
|
396
|
+
Generates `IDENTITY.md`, `SOUL.md`, `AGENTS.md` into `~/.openclaw/agents/{id}/workspace/`.
|
|
397
|
+
|
|
398
|
+
### Hermes
|
|
399
|
+
|
|
400
|
+
```bash
|
|
401
|
+
opc deploy --target hermes
|
|
293
402
|
```
|
|
294
403
|
|
|
295
|
-
|
|
404
|
+
Converts OAD to Hermes Character format (personality, bio, lore, message examples, style guides).
|
|
405
|
+
|
|
406
|
+
## SDK
|
|
296
407
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
408
|
+
```typescript
|
|
409
|
+
import { AgentRuntime, KnowledgeBase, Orchestrator } from 'opc-agent';
|
|
410
|
+
|
|
411
|
+
const runtime = new AgentRuntime();
|
|
412
|
+
await runtime.loadConfig('oad.yaml');
|
|
413
|
+
await runtime.initialize();
|
|
414
|
+
await runtime.start();
|
|
415
|
+
```
|
|
303
416
|
|
|
304
417
|
## License
|
|
305
418
|
|
|
306
|
-
Apache
|
|
419
|
+
[Apache License 2.0](LICENSE)
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
|
|
423
|
+
Built with ❤️ by [Deepleaper](https://www.deepleaper.com)
|
|
424
|
+
|
|
425
|
+
</details>
|
|
426
|
+
|
|
427
|
+
---
|
|
428
|
+
|
|
429
|
+
<p align="center">由 <a href="https://www.deepleaper.com">跃盟科技 (Deepleaper)</a> 用 ❤️ 打造</p>
|