@sleep2agi/agent-network 0.0.28 → 0.0.29
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 +110 -118
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,177 +1,153 @@
|
|
|
1
1
|
# @sleep2agi/agent-network
|
|
2
2
|
|
|
3
|
-
AI Agent 通信网络 —
|
|
3
|
+
AI Agent 通信网络 — Server + Agent + CLI,一个包搞定。
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- **claude-code** — Claude Code CLI(交互式开发)
|
|
7
|
-
- **agent-sdk** — Claude Agent SDK + 任意模型(MiniMax/Claude,自动化)
|
|
5
|
+
支持 MiniMax / 书生 Intern-S1 / Claude 等任意 Anthropic API 兼容模型。
|
|
8
6
|
|
|
9
7
|
## 安装
|
|
10
8
|
|
|
11
9
|
```bash
|
|
12
|
-
# 必装:anet CLI + CommHub SDK
|
|
13
10
|
npm install -g @sleep2agi/agent-network
|
|
14
|
-
|
|
15
|
-
# 按需装:
|
|
16
|
-
npm install -g @anthropic-ai/claude-code # claude-code runtime
|
|
17
|
-
npm install -g @sleep2agi/agent-node # agent-sdk runtime
|
|
18
11
|
```
|
|
19
12
|
|
|
20
|
-
##
|
|
13
|
+
## 一分钟上手
|
|
21
14
|
|
|
22
|
-
###
|
|
15
|
+
### 1. 启动 Server
|
|
23
16
|
|
|
17
|
+
```bash
|
|
18
|
+
anet server start --port 9200
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### 2. 启动 Agent
|
|
22
|
+
|
|
23
|
+
**Claude Code(交互式):**
|
|
24
24
|
```bash
|
|
25
25
|
anet init --hub http://YOUR_IP:9200
|
|
26
26
|
anet init project
|
|
27
|
-
anet init profile 指挥室 --alias 指挥室 --channel server:commhub
|
|
28
27
|
anet start 指挥室
|
|
29
28
|
```
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
**MiniMax(低成本自动化):**
|
|
33
31
|
```bash
|
|
34
32
|
anet init --hub http://YOUR_IP:9200
|
|
35
|
-
anet init profile 小明
|
|
36
|
-
--
|
|
37
|
-
--
|
|
38
|
-
|
|
39
|
-
--tools "Read,Bash,Grep" \
|
|
40
|
-
--env "ANTHROPIC_BASE_URL=https://api.minimax.chat/anthropic" \
|
|
41
|
-
--env "ANTHROPIC_AUTH_TOKEN=your-minimax-key"
|
|
42
|
-
anet start 小明1号
|
|
33
|
+
anet init profile 小明 --runtime agent-sdk --alias 小明 --model MiniMax-M2.7 --tools all \
|
|
34
|
+
--env "ANTHROPIC_BASE_URL=https://api.minimaxi.com/anthropic" \
|
|
35
|
+
--env "ANTHROPIC_AUTH_TOKEN=your-key"
|
|
36
|
+
anet start 小明
|
|
43
37
|
```
|
|
44
38
|
|
|
45
|
-
|
|
39
|
+
**书生 Intern-S1-Pro:**
|
|
40
|
+
```bash
|
|
41
|
+
anet init profile 书生 --runtime agent-sdk --alias 书生 --model intern-s1-pro --tools all \
|
|
42
|
+
--env "ANTHROPIC_BASE_URL=https://chat.intern-ai.org.cn" \
|
|
43
|
+
--env "ANTHROPIC_AUTH_TOKEN=your-key"
|
|
44
|
+
anet start 书生
|
|
45
|
+
```
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
### 3. 查看状态
|
|
48
48
|
|
|
49
|
+
```bash
|
|
50
|
+
anet ls
|
|
49
51
|
```
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
|
|
53
|
+
## CLI 命令
|
|
54
|
+
|
|
55
|
+
### Server
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
anet server start # 启动 CommHub Server(自动拉 @sleep2agi/commhub-server)
|
|
59
|
+
anet server start --port 9200 # 指定端口
|
|
60
|
+
anet server start --token my-secret # 加认证
|
|
52
61
|
```
|
|
53
62
|
|
|
54
|
-
|
|
63
|
+
需要 Bun 运行时(`curl -fsSL https://bun.sh/install | bash`)。
|
|
55
64
|
|
|
56
|
-
|
|
65
|
+
### Agent 初始化
|
|
57
66
|
|
|
67
|
+
```bash
|
|
68
|
+
anet init # 配 hub URL(全局,一次性)
|
|
69
|
+
anet init project # 配项目(claude-code 用:channel 插件 + .mcp.json + CLAUDE.md)
|
|
70
|
+
anet init profile <id> [options] # 创建启动 profile
|
|
58
71
|
```
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
anet
|
|
64
|
-
anet
|
|
72
|
+
|
|
73
|
+
### Agent 启动
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
anet start <id> # 新建 session
|
|
77
|
+
anet resume <id> # 恢复上次 session
|
|
78
|
+
anet start # 列出所有 profile
|
|
79
|
+
anet <id> # 快捷启动
|
|
65
80
|
```
|
|
66
81
|
|
|
67
|
-
|
|
82
|
+
profile 不存在时自动进入交互式创建。
|
|
83
|
+
|
|
84
|
+
`anet start` 根据 profile 的 `runtime` 自动选择:
|
|
85
|
+
- `claude-code` → spawn claude CLI
|
|
86
|
+
- `agent-sdk` → spawn @sleep2agi/agent-node
|
|
87
|
+
|
|
88
|
+
### 状态查看
|
|
68
89
|
|
|
69
90
|
```bash
|
|
70
|
-
anet
|
|
91
|
+
anet ls # profiles + sessions + 网络状态
|
|
71
92
|
```
|
|
72
93
|
|
|
73
|
-
|
|
94
|
+
## anet init profile 参数
|
|
95
|
+
|
|
96
|
+
**共用:**
|
|
74
97
|
|
|
75
98
|
| 参数 | 说明 |
|
|
76
99
|
|------|------|
|
|
77
|
-
| `--alias` |
|
|
100
|
+
| `--alias` | Agent 名称 |
|
|
78
101
|
| `--runtime` | `claude-code`(默认)或 `agent-sdk` |
|
|
79
102
|
| `--env` | 环境变量 K=V(可重复) |
|
|
80
103
|
|
|
81
|
-
**claude-code
|
|
104
|
+
**claude-code:**
|
|
82
105
|
|
|
83
106
|
| 参数 | 说明 |
|
|
84
107
|
|------|------|
|
|
85
108
|
| `--channel` | Channel(可重复,默认 server:commhub) |
|
|
86
109
|
| `--teammate-mode` | 默认 in-process |
|
|
87
|
-
| `--resume-alias` | 恢复搜索名 |
|
|
88
110
|
|
|
89
|
-
**agent-sdk
|
|
111
|
+
**agent-sdk:**
|
|
90
112
|
|
|
91
113
|
| 参数 | 说明 |
|
|
92
114
|
|------|------|
|
|
93
|
-
| `--model` |
|
|
94
|
-
| `--tools` |
|
|
115
|
+
| `--model` | 模型名 |
|
|
116
|
+
| `--tools` | `all` 或逗号分隔(Read,Write,Edit,Bash,Glob,Grep,WebSearch,WebFetch) |
|
|
95
117
|
| `--max-turns` | 每任务最大轮次 |
|
|
96
|
-
|
|
97
|
-
### anet start / resume
|
|
98
|
-
|
|
99
|
-
```bash
|
|
100
|
-
anet start 指挥室 # 新建 session
|
|
101
|
-
anet resume 指挥室 # 恢复上次 session
|
|
102
|
-
anet start # 列出所有 profile
|
|
103
|
-
anet 指挥室 # 快捷方式
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
交互式创建:profile 不存在时自动引导创建(选 runtime、填 alias、model 等)。
|
|
107
|
-
|
|
108
|
-
### anet init project
|
|
109
|
-
|
|
110
|
-
仅 claude-code runtime 需要:
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
anet init project
|
|
114
|
-
# ✅ .anet/node-server.ts(Channel 插件)
|
|
115
|
-
# ✅ Dependencies installed
|
|
116
|
-
# ✅ .mcp.json
|
|
117
|
-
# ✅ CLAUDE.md
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
agent-sdk runtime 不需要 init project。
|
|
121
|
-
|
|
122
|
-
### anet ls
|
|
123
|
-
|
|
124
|
-
```
|
|
125
|
-
Profiles:
|
|
126
|
-
指挥室 → 指挥室 [server:commhub, plugin:telegram]
|
|
127
|
-
小明1号 → 小明1号 []
|
|
128
|
-
|
|
129
|
-
Sessions (/home/vansin/project):
|
|
130
|
-
SESSION PID NETWORK
|
|
131
|
-
──────────────────── ─────── ─────────────────────
|
|
132
|
-
fef0eb55-b39c-4abc 64269 通信龙 offline ●
|
|
133
|
-
```
|
|
118
|
+
| `--max-budget` | 每任务预算(美元) |
|
|
134
119
|
|
|
135
120
|
## Profile 格式
|
|
136
121
|
|
|
137
|
-
路径:`.anet/profiles/<id>.json
|
|
138
|
-
|
|
139
|
-
anet 和 agent-node 共用同一套配置。
|
|
140
|
-
|
|
141
|
-
### claude-code 示例
|
|
142
|
-
|
|
143
|
-
```json
|
|
144
|
-
{
|
|
145
|
-
"runtime": "claude-code",
|
|
146
|
-
"alias": "指挥室",
|
|
147
|
-
"hub": "http://YOUR_IP:9200",
|
|
148
|
-
"channels": ["server:commhub", "plugin:telegram@claude-plugins-official"],
|
|
149
|
-
"env": { "TELEGRAM_STATE_DIR": "~/.claude/channels/telegram-vincent" },
|
|
150
|
-
"flags": { "dangerouslySkipPermissions": true, "teammateMode": "in-process" }
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### agent-sdk 示例(MiniMax)
|
|
122
|
+
路径:`.anet/profiles/<id>.json`,anet 和 agent-node 共用。
|
|
155
123
|
|
|
156
124
|
```json
|
|
157
125
|
{
|
|
158
126
|
"runtime": "agent-sdk",
|
|
159
|
-
"alias": "小明
|
|
127
|
+
"alias": "小明",
|
|
160
128
|
"hub": "http://YOUR_IP:9200",
|
|
161
129
|
"model": "MiniMax-M2.7",
|
|
162
|
-
"tools": ["Read", "Bash", "Grep"],
|
|
130
|
+
"tools": ["Read", "Write", "Edit", "Bash", "Glob", "Grep", "WebSearch", "WebFetch"],
|
|
163
131
|
"env": {
|
|
164
|
-
"ANTHROPIC_BASE_URL": "https://api.
|
|
132
|
+
"ANTHROPIC_BASE_URL": "https://api.minimaxi.com/anthropic",
|
|
165
133
|
"ANTHROPIC_AUTH_TOKEN": "your-key"
|
|
166
134
|
}
|
|
167
135
|
}
|
|
168
136
|
```
|
|
169
137
|
|
|
170
|
-
|
|
138
|
+
配置优先级:`CLI 参数 > profile env > 系统环境变量 > ~/.anet/config.json > 默认值`
|
|
171
139
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
140
|
+
## 支持的模型
|
|
141
|
+
|
|
142
|
+
| 模型 | ANTHROPIC_BASE_URL | 已验证 |
|
|
143
|
+
|------|-------------------|--------|
|
|
144
|
+
| MiniMax M2.7(国际) | `https://api.minimaxi.com/anthropic` | ✅ 对话 + tool_use |
|
|
145
|
+
| MiniMax M2.7(国内) | `https://api.minimax.chat/anthropic` | ✅ |
|
|
146
|
+
| 书生 Intern-S1-Pro | `https://chat.intern-ai.org.cn` | ✅ |
|
|
147
|
+
| Claude(默认) | 不设 | ✅ |
|
|
148
|
+
| 任意 Anthropic 兼容 | 对应端点 | — |
|
|
149
|
+
|
|
150
|
+
两个环境变量切模型,零代码修改。
|
|
175
151
|
|
|
176
152
|
## SDK 代码引用
|
|
177
153
|
|
|
@@ -188,25 +164,41 @@ hub.on('task', async (msg) => {
|
|
|
188
164
|
|------|------|
|
|
189
165
|
| `hub.send(alias, content)` | 发任务 |
|
|
190
166
|
| `hub.message(alias, content)` | 发消息 |
|
|
167
|
+
| `hub.reply(taskId, text, status?)` | 回复任务 |
|
|
191
168
|
| `hub.status(state, extra?)` | 更新状态 |
|
|
169
|
+
| `hub.broadcast(content)` | 广播 |
|
|
170
|
+
| `hub.getAllStatus()` | 查看所有 session |
|
|
192
171
|
| `hub.disconnect()` | 断开 |
|
|
193
172
|
|
|
173
|
+
| 事件 | 说明 |
|
|
174
|
+
|------|------|
|
|
175
|
+
| `task` | 收到任务(已自动 ACK) |
|
|
176
|
+
| `connected` | SSE 连接成功 |
|
|
177
|
+
| `disconnected` | SSE 断开(自动重连) |
|
|
178
|
+
|
|
194
179
|
## 依赖
|
|
195
180
|
|
|
196
|
-
|
|
|
197
|
-
|
|
198
|
-
| @sleep2agi/agent-network |
|
|
199
|
-
| @anthropic-ai/claude-code |
|
|
200
|
-
| @sleep2agi/agent-node |
|
|
201
|
-
|
|
|
181
|
+
| 组件 | 什么时候需要 | 安装 |
|
|
182
|
+
|------|------------|------|
|
|
183
|
+
| @sleep2agi/agent-network | 所有人 | `npm i -g @sleep2agi/agent-network` |
|
|
184
|
+
| @anthropic-ai/claude-code | Claude Code Agent | `npm i -g @anthropic-ai/claude-code` |
|
|
185
|
+
| @sleep2agi/agent-node | agent-sdk Agent | `npm i -g @sleep2agi/agent-node` |
|
|
186
|
+
| @anthropic-ai/claude-agent-sdk | agent-sdk Agent(运行时依赖) | `npm i @anthropic-ai/claude-agent-sdk` |
|
|
187
|
+
| Bun | 启动 CommHub Server | `curl -fsSL https://bun.sh/install \| bash` |
|
|
188
|
+
|
|
189
|
+
## npm 包
|
|
190
|
+
|
|
191
|
+
| 包 | 说明 | 大小 |
|
|
192
|
+
|---|------|------|
|
|
193
|
+
| [@sleep2agi/agent-network](https://www.npmjs.com/package/@sleep2agi/agent-network) | anet CLI + CommHub SDK | ~15KB |
|
|
194
|
+
| [@sleep2agi/agent-node](https://www.npmjs.com/package/@sleep2agi/agent-node) | Agent 运行时 | ~5KB |
|
|
195
|
+
| [@sleep2agi/commhub-server](https://www.npmjs.com/package/@sleep2agi/commhub-server) | CommHub Server | ~10KB |
|
|
202
196
|
|
|
203
|
-
##
|
|
197
|
+
## 文档
|
|
204
198
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
| [@sleep2agi/agent-node](https://www.npmjs.com/package/@sleep2agi/agent-node) | Agent 运行时 |
|
|
209
|
-
| [@sleep2agi/commhub-server](https://www.npmjs.com/package/@sleep2agi/commhub-server) | CommHub Server |
|
|
199
|
+
- [CLI 设计](docs/cli-design.md) — 命令 + Profile 规范
|
|
200
|
+
- [架构设计](docs/architecture.md) — 系统架构
|
|
201
|
+
- [操作手册](https://github.com/sleep2agi/agent-ops)(private) — 服务器/启动命令/Key
|
|
210
202
|
|
|
211
203
|
## License
|
|
212
204
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sleep2agi/agent-network",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.29",
|
|
4
4
|
"description": "AI Agent Network — Server + Client + Setup in one package. SSE real-time communication for multi-agent orchestration.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/client.js",
|