opc-agent 1.1.0 → 1.1.1
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 +232 -88
- package/README.zh-CN.md +334 -56
- package/dist/cli.js +1 -32
- package/dist/i18n/index.js +60 -9
- package/docs/.vitepress/config.ts +13 -2
- package/docs/zh/api/cli.md +54 -0
- package/docs/zh/api/oad-schema.md +86 -2
- package/docs/zh/api/sdk.md +102 -0
- package/docs/zh/guide/concepts.md +90 -14
- package/docs/zh/guide/configuration.md +109 -13
- package/docs/zh/guide/deployment.md +79 -1
- package/docs/zh/guide/getting-started.md +41 -17
- package/docs/zh/guide/templates.md +79 -17
- package/docs/zh/guide/testing.md +75 -5
- package/docs/zh/index.md +13 -13
- package/package.json +1 -1
- package/src/cli.ts +1 -35
- package/src/i18n/index.ts +60 -9
- package/tests/i18n.test.ts +1 -1
package/README.zh-CN.md
CHANGED
|
@@ -1,88 +1,366 @@
|
|
|
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="开源协议"></a>
|
|
7
|
+
<a href="https://github.com/Deepleaper/opc-agent/actions"><img src="https://img.shields.io/badge/tests-passing-brightgreen" alt="测试状态"></a>
|
|
8
|
+
<a href="https://www.npmjs.com/package/opc-agent"><img src="https://img.shields.io/npm/dm/opc-agent?color=orange" alt="下载量"></a>
|
|
9
|
+
</p>
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="./README.md">English</a> · <strong>中文</strong>
|
|
12
|
+
</p>
|
|
13
|
+
</p>
|
|
2
14
|
|
|
3
|
-
|
|
15
|
+
---
|
|
4
16
|
|
|
5
|
-
|
|
6
|
-
[](LICENSE)
|
|
17
|
+
## 💡 这是什么?
|
|
7
18
|
|
|
8
|
-
|
|
19
|
+
OPC Agent 是一个 **TypeScript 优先的开放智能体框架**,由 [跃盟科技 (Deepleaper)](https://www.deepleaper.com) 开发维护。
|
|
9
20
|
|
|
10
|
-
|
|
11
|
-
- 📋 **OAD Schema** — 声明式 Agent 定义(YAML/JSON),内置校验
|
|
12
|
-
- 🧠 **记忆系统** — 短期 + 长期记忆,支持 DeepBrain 集成
|
|
13
|
-
- 🔌 **多通道** — Web、WebSocket、Telegram 通道
|
|
14
|
-
- 🛡️ **DTV 框架** — 数据、信任、价值追踪
|
|
15
|
-
- 🎯 **技能系统** — 可插拔技能 + 注册表 + 优先级执行
|
|
16
|
-
- 📦 **模板** — 客服、销售助手、知识库、代码审查
|
|
17
|
-
- 🚀 **CLI** — 交互式创建、开发模式、构建、测试、运行
|
|
21
|
+
一句话概括:**用一个 YAML 文件定义智能体,接入任意大语言模型,一键部署到多个渠道。**
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
不需要写一堆胶水代码,不需要自己搞 Prompt 管理,也不需要操心渠道对接。定义好 OAD 文件,`opc run` 就完事了。
|
|
24
|
+
|
|
25
|
+
## ⚡ 快速开始(30 秒上手)
|
|
20
26
|
|
|
21
27
|
```bash
|
|
22
|
-
#
|
|
28
|
+
# 1. 安装 CLI
|
|
23
29
|
npm install -g opc-agent
|
|
24
30
|
|
|
25
|
-
#
|
|
31
|
+
# 2. 创建项目(交互式,会让你选模板)
|
|
26
32
|
opc init my-agent
|
|
27
33
|
|
|
28
|
-
#
|
|
29
|
-
opc init my-bot --template sales-assistant
|
|
30
|
-
|
|
31
|
-
# 运行 Agent
|
|
34
|
+
# 3. 进入项目目录
|
|
32
35
|
cd my-agent
|
|
36
|
+
|
|
37
|
+
# 4. 跑起来
|
|
33
38
|
opc run
|
|
34
39
|
```
|
|
35
40
|
|
|
36
|
-
|
|
41
|
+
打开浏览器访问 `http://localhost:3000`,你的智能体已经在线了,自带一个好看的对话界面。
|
|
37
42
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
### 用模板快速创建
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# 客服智能体
|
|
47
|
+
opc init my-service --template customer-service
|
|
48
|
+
|
|
49
|
+
# 销售助手
|
|
50
|
+
opc init my-sales --template sales-assistant
|
|
51
|
+
|
|
52
|
+
# 知识库问答
|
|
53
|
+
opc init my-kb --template knowledge-base
|
|
54
|
+
|
|
55
|
+
# 代码审查
|
|
56
|
+
opc init my-reviewer --template code-reviewer
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## ✨ 核心特性
|
|
60
|
+
|
|
61
|
+
### 🔌 多模型供应商 — 不绑定任何一家
|
|
62
|
+
|
|
63
|
+
```yaml
|
|
64
|
+
spec:
|
|
65
|
+
provider:
|
|
66
|
+
default: deepseek # 默认用 DeepSeek
|
|
67
|
+
allowed: [openai, deepseek, qwen, anthropic, ollama]
|
|
68
|
+
model: deepseek-chat
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
支持的供应商:
|
|
72
|
+
- **DeepSeek** — 性价比之王,国产首选
|
|
73
|
+
- **通义千问 (Qwen)** — 阿里出品,中文能力强
|
|
74
|
+
- **OpenAI** — GPT-4o、GPT-4o-mini
|
|
75
|
+
- **Anthropic** — Claude 系列
|
|
76
|
+
- **Ollama** — 本地部署,数据不出门
|
|
77
|
+
- 任何兼容 OpenAI 接口的服务
|
|
78
|
+
|
|
79
|
+
### 📡 多渠道部署 — 一套代码,到处运行
|
|
80
|
+
|
|
81
|
+
```yaml
|
|
82
|
+
spec:
|
|
83
|
+
channels:
|
|
84
|
+
- type: web # 🌐 Web 对话界面
|
|
85
|
+
port: 3000
|
|
86
|
+
- type: telegram # ✈️ Telegram 机器人
|
|
87
|
+
- type: websocket # 🔗 实时 WebSocket
|
|
88
|
+
- type: slack # 💬 Slack 集成
|
|
89
|
+
- type: email # 📧 邮件渠道
|
|
90
|
+
- type: wechat # 💚 微信公众号
|
|
91
|
+
- type: feishu # 🔵 飞书
|
|
92
|
+
- type: voice # 🎙️ 语音(STT/TTS)
|
|
93
|
+
- type: webhook # 🔔 Webhook 回调
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 🧠 知识库(RAG)— 让智能体拥有你的专业知识
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { KnowledgeBase } from 'opc-agent';
|
|
100
|
+
|
|
101
|
+
const kb = new KnowledgeBase('./docs');
|
|
102
|
+
await kb.addFile('产品手册.pdf');
|
|
103
|
+
await kb.addFile('常见问题.md');
|
|
104
|
+
// 智能体回答时自动检索知识库,生成更准确的回答
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 🎭 多智能体编排 — 分工协作,按需路由
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import { Orchestrator } from 'opc-agent';
|
|
111
|
+
|
|
112
|
+
const orchestrator = new Orchestrator({
|
|
113
|
+
agents: [分诊智能体, 销售智能体, 客服智能体],
|
|
114
|
+
strategy: 'route-by-intent', // 按用户意图自动路由
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 🧪 内置测试 — 发布前验证智能体行为
|
|
119
|
+
|
|
120
|
+
```yaml
|
|
121
|
+
spec:
|
|
122
|
+
testing:
|
|
123
|
+
cases:
|
|
124
|
+
- name: 问候测试
|
|
125
|
+
input: "你好"
|
|
126
|
+
expect:
|
|
127
|
+
contains: ["你好", "帮"]
|
|
128
|
+
maxLatencyMs: 5000
|
|
129
|
+
|
|
130
|
+
- name: 产品咨询
|
|
131
|
+
input: "你们的产品怎么收费?"
|
|
132
|
+
expect:
|
|
133
|
+
contains: ["价格", "套餐"]
|
|
134
|
+
notContains: ["error"]
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
opc test # 运行测试
|
|
139
|
+
opc test --watch # 监听模式,改了代码自动测
|
|
140
|
+
opc test --json # JSON 格式输出
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### 🔧 插件系统 — 按需扩展
|
|
144
|
+
|
|
145
|
+
```yaml
|
|
146
|
+
spec:
|
|
147
|
+
plugins:
|
|
148
|
+
- name: logging # 日志记录
|
|
149
|
+
- name: analytics # 使用分析
|
|
150
|
+
- name: rate-limit # 限流保护
|
|
151
|
+
config: { maxPerMinute: 60 }
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
支持自定义插件,提供完整的生命周期钩子:`onInit`、`onMessage`、`onResponse`、`onError`、`onShutdown`。
|
|
155
|
+
|
|
156
|
+
### 🔒 安全特性
|
|
157
|
+
|
|
158
|
+
- 输入消毒(防 XSS、注入攻击)
|
|
159
|
+
- API Key 轮换管理
|
|
160
|
+
- CORS 跨域配置
|
|
161
|
+
- 安全响应头(Helmet 风格)
|
|
162
|
+
- Content Security Policy
|
|
163
|
+
- 会话隔离的认证中间件
|
|
164
|
+
|
|
165
|
+
### 📊 监控与分析
|
|
44
166
|
|
|
45
|
-
|
|
167
|
+
- `/api/health` — 健康检查接口
|
|
168
|
+
- `/api/metrics` — Prometheus 兼容指标
|
|
169
|
+
- `/api/dashboard` — 实时仪表盘 UI
|
|
170
|
+
- 对话记录导出(JSON / Markdown / CSV)
|
|
46
171
|
|
|
47
|
-
|
|
172
|
+
## 🏗️ 架构设计
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
┌─────────────────────────────────────────────────┐
|
|
176
|
+
│ OAD (YAML 定义文件) │
|
|
177
|
+
│ 智能体的一切配置都在这里 │
|
|
178
|
+
├─────────────────────────────────────────────────┤
|
|
179
|
+
│ │
|
|
180
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
|
|
181
|
+
│ │ 渠道层 │ │ 插件层 │ │ 安全层 │ │
|
|
182
|
+
│ │ Web, TG, │ │ 日志, │ │ 消毒, CORS, │ │
|
|
183
|
+
│ │ WS, 微信 │ │ 分析 │ │ 认证 │ │
|
|
184
|
+
│ └────┬─────┘ └────┬─────┘ └──────┬───────┘ │
|
|
185
|
+
│ │ │ │ │
|
|
186
|
+
│ ┌────▼──────────────▼───────────────▼────────┐ │
|
|
187
|
+
│ │ 智能体运行时 (Agent Runtime) │ │
|
|
188
|
+
│ │ │ │
|
|
189
|
+
│ │ ┌─────────┐ ┌────────┐ ┌─────────────┐ │ │
|
|
190
|
+
│ │ │ 记忆 │ │ 技能 │ │ 知识库 │ │ │
|
|
191
|
+
│ │ │ 短期+ │ │ FAQ, │ │ RAG 检索 │ │ │
|
|
192
|
+
│ │ │ 长期 │ │ 转接 │ │ │ │ │
|
|
193
|
+
│ │ └─────────┘ └────────┘ └─────────────┘ │ │
|
|
194
|
+
│ └────────────────────┬───────────────────────┘ │
|
|
195
|
+
│ │ │
|
|
196
|
+
│ ┌────────────────────▼───────────────────────┐ │
|
|
197
|
+
│ │ 大语言模型供应商 │ │
|
|
198
|
+
│ │ DeepSeek · 通义千问 · OpenAI · Ollama │ │
|
|
199
|
+
│ └─────────────────────────────────────────────┘│
|
|
200
|
+
└─────────────────────────────────────────────────┘
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## 📋 全部模板(12 个)
|
|
204
|
+
|
|
205
|
+
| 模板 | 说明 | 典型场景 |
|
|
206
|
+
|------|------|---------|
|
|
207
|
+
| `customer-service` | 客服智能体 | FAQ 自动回答 + 转人工 |
|
|
208
|
+
| `sales-assistant` | 销售助手 | 产品问答 + 线索捕获 + 预约 |
|
|
209
|
+
| `knowledge-base` | 知识库问答 | 基于文档的 RAG 语义检索 |
|
|
210
|
+
| `code-reviewer` | 代码审查 | Bug 检测 + 代码风格检查 |
|
|
211
|
+
| `hr-recruiter` | HR 招聘助手 | 简历筛选 + 面试安排 |
|
|
212
|
+
| `project-manager` | 项目管理 | 任务跟踪 + 会议纪要 |
|
|
213
|
+
| `content-writer` | 内容创作 | 博客写作 + 社媒运营 + SEO |
|
|
214
|
+
| `legal-assistant` | 法务助手 | 合同审查 + 合规检查 |
|
|
215
|
+
| `financial-advisor` | 财务顾问 | 预算管理 + 支出分析 |
|
|
216
|
+
| `executive-assistant` | 行政助理 | 日程管理 + 邮件处理 |
|
|
217
|
+
| `data-analyst` | 数据分析师 | SQL 查询 + 数据可视化 |
|
|
218
|
+
| `teacher` | 教学助手 | 课程设计 + 出题 + 互动 |
|
|
219
|
+
|
|
220
|
+
## 🚀 部署指南
|
|
221
|
+
|
|
222
|
+
### 本地开发
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
opc dev # 热重载开发模式
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Docker 部署
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
# 每个 opc init 项目都自带 Dockerfile 和 docker-compose.yml
|
|
232
|
+
docker compose up -d
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### 部署到 OpenClaw
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
opc deploy --target openclaw
|
|
239
|
+
opc deploy --target openclaw --install # 同时注册到配置
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### 部署到 Hermes 云
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
opc deploy --target hermes
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### 环境变量
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
# .env
|
|
252
|
+
OPC_LLM_API_KEY=your-api-key
|
|
253
|
+
OPC_LLM_BASE_URL=https://api.deepseek.com/v1 # DeepSeek
|
|
254
|
+
OPC_LLM_MODEL=deepseek-chat
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## 📖 CLI 命令参考
|
|
258
|
+
|
|
259
|
+
| 命令 | 说明 |
|
|
48
260
|
|------|------|
|
|
49
|
-
| `opc init [name]` |
|
|
50
|
-
| `opc create <name>` |
|
|
51
|
-
| `opc
|
|
52
|
-
| `opc
|
|
53
|
-
| `opc
|
|
54
|
-
| `opc
|
|
55
|
-
| `opc
|
|
56
|
-
| `opc
|
|
57
|
-
| `opc
|
|
261
|
+
| `opc init [name]` | 创建新智能体项目(交互式) |
|
|
262
|
+
| `opc create <name>` | 从模板快速创建 |
|
|
263
|
+
| `opc run` | 启动智能体服务 |
|
|
264
|
+
| `opc dev` | 开发模式(热重载) |
|
|
265
|
+
| `opc chat` | 命令行交互对话 |
|
|
266
|
+
| `opc test` | 运行测试用例 |
|
|
267
|
+
| `opc build` | 校验 OAD 配置 |
|
|
268
|
+
| `opc info` | 查看智能体信息 |
|
|
269
|
+
| `opc analytics` | 查看使用分析 |
|
|
270
|
+
| `opc deploy` | 部署智能体 |
|
|
271
|
+
| `opc publish` | 发布到市场 |
|
|
272
|
+
| `opc kb add <file>` | 添加知识库文件 |
|
|
273
|
+
| `opc kb search <query>` | 搜索知识库 |
|
|
274
|
+
| `opc stats` | 查看运行时统计 |
|
|
58
275
|
|
|
59
|
-
##
|
|
276
|
+
## 🔗 SDK 参考
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
import { AgentRuntime, KnowledgeBase, Orchestrator } from 'opc-agent';
|
|
280
|
+
|
|
281
|
+
// 创建并启动智能体
|
|
282
|
+
const runtime = new AgentRuntime();
|
|
283
|
+
await runtime.loadConfig('oad.yaml');
|
|
284
|
+
const agent = await runtime.initialize();
|
|
285
|
+
await runtime.start();
|
|
286
|
+
|
|
287
|
+
// 使用知识库
|
|
288
|
+
const kb = new KnowledgeBase('./docs');
|
|
289
|
+
await kb.addFile('handbook.pdf');
|
|
290
|
+
|
|
291
|
+
// 多智能体编排
|
|
292
|
+
const orch = new Orchestrator({
|
|
293
|
+
agents: [agentA, agentB],
|
|
294
|
+
strategy: 'route-by-intent',
|
|
295
|
+
});
|
|
296
|
+
```
|
|
60
297
|
|
|
61
|
-
|
|
62
|
-
简单键值存储,重启后数据丢失。
|
|
298
|
+
## 🔑 OAD 配置文件说明
|
|
63
299
|
|
|
64
|
-
|
|
65
|
-
语义搜索历史对话和知识。安装 `deepbrain` 包后配置:
|
|
300
|
+
OAD(Open Agent Definition)是智能体的声明式定义格式:
|
|
66
301
|
|
|
67
302
|
```yaml
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
303
|
+
apiVersion: opc/v1 # API 版本
|
|
304
|
+
kind: Agent # 资源类型
|
|
305
|
+
|
|
306
|
+
metadata:
|
|
307
|
+
name: my-agent # 智能体名称
|
|
308
|
+
version: 1.0.0 # 版本号
|
|
309
|
+
description: 我的智能体 # 描述
|
|
310
|
+
|
|
311
|
+
spec:
|
|
312
|
+
provider:
|
|
313
|
+
default: deepseek # 默认供应商
|
|
314
|
+
allowed: [deepseek, openai, qwen]
|
|
315
|
+
model: deepseek-chat # 模型
|
|
316
|
+
systemPrompt: | # 系统提示词
|
|
317
|
+
你是一个专业的客服助手...
|
|
318
|
+
|
|
319
|
+
skills: [] # 技能列表
|
|
320
|
+
channels: # 渠道配置
|
|
321
|
+
- type: web
|
|
322
|
+
port: 3000
|
|
323
|
+
|
|
324
|
+
memory:
|
|
325
|
+
shortTerm: true # 短期记忆(对话上下文)
|
|
326
|
+
longTerm: false # 长期记忆(跨会话)
|
|
327
|
+
|
|
328
|
+
rateLimits: # 限流
|
|
329
|
+
perUser:
|
|
330
|
+
maxRequests: 60
|
|
331
|
+
windowMs: 60000
|
|
332
|
+
|
|
333
|
+
cache: # 缓存(降低 API 开销)
|
|
334
|
+
enabled: true
|
|
335
|
+
ttlMs: 3600000
|
|
72
336
|
```
|
|
73
337
|
|
|
74
|
-
|
|
338
|
+
## 🤝 贡献指南
|
|
339
|
+
|
|
340
|
+
我们欢迎所有形式的贡献!
|
|
341
|
+
|
|
342
|
+
1. Fork 本仓库
|
|
343
|
+
2. 创建功能分支:`git checkout -b feat/awesome-feature`
|
|
344
|
+
3. 编写代码和测试
|
|
345
|
+
4. 确保测试通过:`npm test`
|
|
346
|
+
5. 提交 Pull Request
|
|
75
347
|
|
|
76
|
-
|
|
348
|
+
### 本地开发环境
|
|
77
349
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
-
|
|
350
|
+
```bash
|
|
351
|
+
git clone https://github.com/Deepleaper/opc-agent.git
|
|
352
|
+
cd opc-agent
|
|
353
|
+
npm install
|
|
354
|
+
npm run build
|
|
355
|
+
npm test
|
|
356
|
+
```
|
|
81
357
|
|
|
82
|
-
##
|
|
358
|
+
## 📄 开源协议
|
|
83
359
|
|
|
84
|
-
|
|
360
|
+
[Apache License 2.0](LICENSE) — 商用和开源项目均可自由使用。
|
|
85
361
|
|
|
86
|
-
|
|
362
|
+
---
|
|
87
363
|
|
|
88
|
-
|
|
364
|
+
<p align="center">
|
|
365
|
+
由 <a href="https://www.deepleaper.com">跃盟科技 (Deepleaper)</a> 用 ❤️ 打造
|
|
366
|
+
</p>
|
package/dist/cli.js
CHANGED
|
@@ -486,38 +486,7 @@ program
|
|
|
486
486
|
process.exit(0);
|
|
487
487
|
});
|
|
488
488
|
});
|
|
489
|
-
//
|
|
490
|
-
program
|
|
491
|
-
.command('publish')
|
|
492
|
-
.description('Validate and package for OPC Registry')
|
|
493
|
-
.option('-f, --file <file>', 'OAD file', 'oad.yaml')
|
|
494
|
-
.action(async (opts) => {
|
|
495
|
-
try {
|
|
496
|
-
const runtime = new runtime_1.AgentRuntime();
|
|
497
|
-
const config = await runtime.loadConfig(opts.file);
|
|
498
|
-
const trust = config.spec.dtv?.trust?.level ?? 'sandbox';
|
|
499
|
-
console.log(`\n${icon.package} Publishing: ${color.bold(config.metadata.name)} v${config.metadata.version}`);
|
|
500
|
-
console.log(` ${icon.success} OAD validation passed`);
|
|
501
|
-
const manifest = {
|
|
502
|
-
name: config.metadata.name,
|
|
503
|
-
version: config.metadata.version,
|
|
504
|
-
description: config.metadata.description,
|
|
505
|
-
author: config.metadata.author,
|
|
506
|
-
license: config.metadata.license,
|
|
507
|
-
trust,
|
|
508
|
-
channels: config.spec.channels.map((c) => c.type),
|
|
509
|
-
skills: config.spec.skills.map((s) => s.name),
|
|
510
|
-
publishedAt: new Date().toISOString(),
|
|
511
|
-
};
|
|
512
|
-
fs.writeFileSync('opc-manifest.json', JSON.stringify(manifest, null, 2));
|
|
513
|
-
console.log(` ${icon.file} Generated opc-manifest.json`);
|
|
514
|
-
console.log(`\n🚧 OPC Registry is coming soon. Manifest saved locally.\n`);
|
|
515
|
-
}
|
|
516
|
-
catch (err) {
|
|
517
|
-
console.error(`${icon.error} Publish failed:`, err instanceof Error ? err.message : err);
|
|
518
|
-
process.exit(1);
|
|
519
|
-
}
|
|
520
|
-
});
|
|
489
|
+
// (publish command moved to marketplace section below)
|
|
521
490
|
// ── Deploy command ───────────────────────────────────────────
|
|
522
491
|
program
|
|
523
492
|
.command('deploy')
|
package/dist/i18n/index.js
CHANGED
|
@@ -16,16 +16,33 @@ const messages = {
|
|
|
16
16
|
'agent.notUnderstood': 'I\'m not sure I understand. Could you rephrase?',
|
|
17
17
|
'agent.handoff': 'Let me connect you with a human agent.',
|
|
18
18
|
'cli.init.success': 'Created agent project: {name}',
|
|
19
|
+
'cli.init.prompt.name': 'Agent name:',
|
|
20
|
+
'cli.init.prompt.template': 'Choose a template:',
|
|
21
|
+
'cli.init.prompt.provider': 'Choose an LLM provider:',
|
|
19
22
|
'cli.build.success': 'Build successful: {name} v{version}',
|
|
20
23
|
'cli.test.pass': 'All tests passed',
|
|
21
24
|
'cli.test.fail': '{count} test(s) failed',
|
|
25
|
+
'cli.run.starting': 'Starting agent "{name}"...',
|
|
26
|
+
'cli.run.listening': 'Agent "{name}" is running at http://localhost:{port}',
|
|
27
|
+
'cli.deploy.success': 'Deployed "{name}" to {target}',
|
|
28
|
+
'cli.deploy.error': 'Deploy failed: {error}',
|
|
29
|
+
'cli.validate.success': 'OAD validation passed',
|
|
30
|
+
'cli.validate.error': 'OAD validation failed: {error}',
|
|
31
|
+
'cli.analytics.title': 'Agent Analytics',
|
|
32
|
+
'cli.analytics.noData': 'No analytics data yet',
|
|
22
33
|
'cli.stats.title': 'Agent Analytics',
|
|
23
34
|
'cli.stats.messages': 'Messages Processed',
|
|
24
35
|
'cli.stats.avgTime': 'Avg Response Time',
|
|
25
36
|
'cli.stats.errors': 'Errors',
|
|
26
37
|
'cli.stats.uptime': 'Uptime',
|
|
38
|
+
'cli.chat.welcome': 'Chat with your agent. Type "exit" to quit.',
|
|
39
|
+
'cli.dev.watching': 'Watching for changes...',
|
|
40
|
+
'cli.publish.success': 'Published "{name}" v{version}',
|
|
27
41
|
'plugin.loaded': 'Plugin "{name}" loaded',
|
|
28
42
|
'plugin.error': 'Plugin "{name}" failed: {error}',
|
|
43
|
+
'kb.added': 'Added "{file}" to knowledge base',
|
|
44
|
+
'kb.searchResults': '{count} results found',
|
|
45
|
+
'kb.noResults': 'No results found',
|
|
29
46
|
'web.title': 'OPC Agent',
|
|
30
47
|
'web.chat.placeholder': 'Type a message...',
|
|
31
48
|
'web.chat.send': 'Send',
|
|
@@ -48,22 +65,39 @@ const messages = {
|
|
|
48
65
|
'zh-CN': {
|
|
49
66
|
'agent.started': '智能体 "{name}" 启动成功',
|
|
50
67
|
'agent.stopped': '智能体 "{name}" 已停止',
|
|
51
|
-
'agent.error': '
|
|
52
|
-
'agent.greeting': '
|
|
53
|
-
'agent.farewell': '
|
|
54
|
-
'agent.notUnderstood': '
|
|
55
|
-
'agent.handoff': '
|
|
56
|
-
'cli.init.success': '
|
|
57
|
-
'cli.
|
|
68
|
+
'agent.error': '发生错误:{error}',
|
|
69
|
+
'agent.greeting': '你好!有什么可以帮你的?',
|
|
70
|
+
'agent.farewell': '再见!祝你愉快。',
|
|
71
|
+
'agent.notUnderstood': '抱歉,我没太理解你的意思。能换个方式描述一下吗?',
|
|
72
|
+
'agent.handoff': '我来帮你转接人工客服。',
|
|
73
|
+
'cli.init.success': '已创建智能体项目:{name}',
|
|
74
|
+
'cli.init.prompt.name': '智能体名称:',
|
|
75
|
+
'cli.init.prompt.template': '选择一个模板:',
|
|
76
|
+
'cli.init.prompt.provider': '选择大语言模型供应商:',
|
|
77
|
+
'cli.build.success': '构建成功:{name} v{version}',
|
|
58
78
|
'cli.test.pass': '所有测试通过',
|
|
59
79
|
'cli.test.fail': '{count} 个测试失败',
|
|
60
|
-
'cli.
|
|
80
|
+
'cli.run.starting': '正在启动智能体 "{name}"...',
|
|
81
|
+
'cli.run.listening': '智能体 "{name}" 已在 http://localhost:{port} 上运行',
|
|
82
|
+
'cli.deploy.success': '已将 "{name}" 部署到 {target}',
|
|
83
|
+
'cli.deploy.error': '部署失败:{error}',
|
|
84
|
+
'cli.validate.success': 'OAD 配置校验通过',
|
|
85
|
+
'cli.validate.error': 'OAD 配置校验失败:{error}',
|
|
86
|
+
'cli.analytics.title': '智能体数据分析',
|
|
87
|
+
'cli.analytics.noData': '暂无分析数据',
|
|
88
|
+
'cli.stats.title': '智能体数据分析',
|
|
61
89
|
'cli.stats.messages': '已处理消息',
|
|
62
90
|
'cli.stats.avgTime': '平均响应时间',
|
|
63
91
|
'cli.stats.errors': '错误数',
|
|
64
92
|
'cli.stats.uptime': '运行时间',
|
|
93
|
+
'cli.chat.welcome': '开始和智能体对话吧。输入 "exit" 退出。',
|
|
94
|
+
'cli.dev.watching': '正在监听文件变更...',
|
|
95
|
+
'cli.publish.success': '已发布 "{name}" v{version}',
|
|
65
96
|
'plugin.loaded': '插件 "{name}" 已加载',
|
|
66
|
-
'plugin.error': '插件 "{name}"
|
|
97
|
+
'plugin.error': '插件 "{name}" 出错:{error}',
|
|
98
|
+
'kb.added': '已将 "{file}" 添加到知识库',
|
|
99
|
+
'kb.searchResults': '找到 {count} 条结果',
|
|
100
|
+
'kb.noResults': '未找到相关结果',
|
|
67
101
|
'web.title': 'OPC 智能体',
|
|
68
102
|
'web.chat.placeholder': '输入消息...',
|
|
69
103
|
'web.chat.send': '发送',
|
|
@@ -92,16 +126,33 @@ const messages = {
|
|
|
92
126
|
'agent.notUnderstood': '申し訳ございません、理解できませんでした。別の言い方でお願いできますか?',
|
|
93
127
|
'agent.handoff': 'オペレーターにおつなぎします。',
|
|
94
128
|
'cli.init.success': 'エージェントプロジェクトを作成しました: {name}',
|
|
129
|
+
'cli.init.prompt.name': 'エージェント名:',
|
|
130
|
+
'cli.init.prompt.template': 'テンプレートを選択:',
|
|
131
|
+
'cli.init.prompt.provider': 'LLMプロバイダーを選択:',
|
|
95
132
|
'cli.build.success': 'ビルド成功: {name} v{version}',
|
|
96
133
|
'cli.test.pass': '全テスト合格',
|
|
97
134
|
'cli.test.fail': '{count} 件のテストが失敗しました',
|
|
135
|
+
'cli.run.starting': 'エージェント「{name}」を起動中...',
|
|
136
|
+
'cli.run.listening': 'エージェント「{name}」が http://localhost:{port} で稼働中',
|
|
137
|
+
'cli.deploy.success': '「{name}」を {target} にデプロイしました',
|
|
138
|
+
'cli.deploy.error': 'デプロイ失敗: {error}',
|
|
139
|
+
'cli.validate.success': 'OADバリデーション成功',
|
|
140
|
+
'cli.validate.error': 'OADバリデーション失敗: {error}',
|
|
141
|
+
'cli.analytics.title': 'エージェント分析',
|
|
142
|
+
'cli.analytics.noData': '分析データがありません',
|
|
98
143
|
'cli.stats.title': 'エージェント分析',
|
|
99
144
|
'cli.stats.messages': '処理済みメッセージ',
|
|
100
145
|
'cli.stats.avgTime': '平均応答時間',
|
|
101
146
|
'cli.stats.errors': 'エラー数',
|
|
102
147
|
'cli.stats.uptime': '稼働時間',
|
|
148
|
+
'cli.chat.welcome': 'エージェントとチャットしましょう。"exit"で終了。',
|
|
149
|
+
'cli.dev.watching': 'ファイル変更を監視中...',
|
|
150
|
+
'cli.publish.success': '「{name}」v{version} を公開しました',
|
|
103
151
|
'plugin.loaded': 'プラグイン「{name}」を読み込みました',
|
|
104
152
|
'plugin.error': 'プラグイン「{name}」でエラー: {error}',
|
|
153
|
+
'kb.added': '「{file}」をナレッジベースに追加しました',
|
|
154
|
+
'kb.searchResults': '{count} 件の結果が見つかりました',
|
|
155
|
+
'kb.noResults': '結果が見つかりませんでした',
|
|
105
156
|
'web.title': 'OPC エージェント',
|
|
106
157
|
'web.chat.placeholder': 'メッセージを入力...',
|
|
107
158
|
'web.chat.send': '送信',
|
|
@@ -49,6 +49,7 @@ export default defineConfig({
|
|
|
49
49
|
zh: {
|
|
50
50
|
label: '中文',
|
|
51
51
|
lang: 'zh-CN',
|
|
52
|
+
description: '开放智能体框架 — 构建、测试、运行企业级 AI 智能体',
|
|
52
53
|
themeConfig: {
|
|
53
54
|
nav: [
|
|
54
55
|
{ text: '指南', link: '/zh/guide/getting-started' },
|
|
@@ -58,7 +59,7 @@ export default defineConfig({
|
|
|
58
59
|
sidebar: {
|
|
59
60
|
'/zh/guide/': [
|
|
60
61
|
{
|
|
61
|
-
text: '
|
|
62
|
+
text: '入门',
|
|
62
63
|
items: [
|
|
63
64
|
{ text: '快速开始', link: '/zh/guide/getting-started' },
|
|
64
65
|
{ text: '核心概念', link: '/zh/guide/concepts' },
|
|
@@ -74,6 +75,16 @@ export default defineConfig({
|
|
|
74
75
|
],
|
|
75
76
|
},
|
|
76
77
|
],
|
|
78
|
+
'/zh/api/': [
|
|
79
|
+
{
|
|
80
|
+
text: '参考',
|
|
81
|
+
items: [
|
|
82
|
+
{ text: 'OAD Schema', link: '/zh/api/oad-schema' },
|
|
83
|
+
{ text: 'CLI 命令', link: '/zh/api/cli' },
|
|
84
|
+
{ text: 'SDK', link: '/zh/api/sdk' },
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
],
|
|
77
88
|
},
|
|
78
89
|
},
|
|
79
90
|
},
|
|
@@ -86,7 +97,7 @@ export default defineConfig({
|
|
|
86
97
|
],
|
|
87
98
|
footer: {
|
|
88
99
|
message: 'Released under the Apache-2.0 License.',
|
|
89
|
-
copyright: 'Copyright © 2025 Deepleaper',
|
|
100
|
+
copyright: 'Copyright © 2025 Deepleaper 跃盟科技',
|
|
90
101
|
},
|
|
91
102
|
},
|
|
92
103
|
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# CLI 命令参考
|
|
2
|
+
|
|
3
|
+
## 完整命令列表
|
|
4
|
+
|
|
5
|
+
| 命令 | 说明 |
|
|
6
|
+
|------|------|
|
|
7
|
+
| `opc init [name]` | 创建新智能体项目(交互式) |
|
|
8
|
+
| `opc create <name>` | 从模板快速创建 |
|
|
9
|
+
| `opc run` | 启动智能体(Web 服务) |
|
|
10
|
+
| `opc chat` | 命令行交互对话 |
|
|
11
|
+
| `opc test` | 运行测试用例 |
|
|
12
|
+
| `opc analytics` | 查看使用分析 |
|
|
13
|
+
| `opc info` | 查看智能体信息 |
|
|
14
|
+
| `opc build` | 校验 OAD 配置 |
|
|
15
|
+
| `opc dev` | 热重载开发模式 |
|
|
16
|
+
| `opc deploy` | 部署智能体 |
|
|
17
|
+
| `opc publish` | 发布到市场 |
|
|
18
|
+
| `opc install <source>` | 从包安装智能体 |
|
|
19
|
+
| `opc search <query>` | 搜索 OPC 市场 |
|
|
20
|
+
| `opc stats` | 查看运行时统计 |
|
|
21
|
+
| `opc kb add <file>` | 添加知识库文件 |
|
|
22
|
+
| `opc kb search <query>` | 搜索知识库 |
|
|
23
|
+
| `opc tool list` | 列出 MCP 工具 |
|
|
24
|
+
| `opc workflow run <name>` | 运行工作流 |
|
|
25
|
+
| `opc version-mgmt list` | 列出保存的版本 |
|
|
26
|
+
|
|
27
|
+
## 通用选项
|
|
28
|
+
|
|
29
|
+
- `-f, --file <file>` — OAD 文件路径(默认:`oad.yaml`)
|
|
30
|
+
- `-t, --template <name>` — 模板名称
|
|
31
|
+
- `-p, --port <port>` — 端口覆盖
|
|
32
|
+
- `--json` — JSON 格式输出(用于 test/analytics)
|
|
33
|
+
|
|
34
|
+
## 常用示例
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# 用模板创建项目
|
|
38
|
+
opc init my-bot -t teacher
|
|
39
|
+
|
|
40
|
+
# 运行测试,输出 JSON
|
|
41
|
+
opc test --json
|
|
42
|
+
|
|
43
|
+
# 查看分析数据
|
|
44
|
+
opc analytics
|
|
45
|
+
|
|
46
|
+
# 部署到 OpenClaw
|
|
47
|
+
opc deploy --target openclaw --install
|
|
48
|
+
|
|
49
|
+
# 添加文件到知识库
|
|
50
|
+
opc kb add ./docs/product-manual.pdf
|
|
51
|
+
|
|
52
|
+
# 搜索知识库
|
|
53
|
+
opc kb search "退货政策"
|
|
54
|
+
```
|