@sleep2agi/agent-node 2.5.0-preview.26 → 2.5.0-preview.28

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.
Files changed (3) hide show
  1. package/README.md +46 -166
  2. package/dist/cli.js +73 -73
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,199 +1,79 @@
1
- # @sleep2agi/agent-node
1
+ # `@sleep2agi/agent-node`
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@sleep2agi/agent-node.svg)](https://www.npmjs.com/package/@sleep2agi/agent-node)
4
4
  [![npm downloads](https://img.shields.io/npm/dm/@sleep2agi/agent-node.svg)](https://www.npmjs.com/package/@sleep2agi/agent-node)
5
5
  [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/sleep2agi/agent-network/blob/main/LICENSE)
6
6
  [![Docs](https://img.shields.io/badge/docs-anet.sh-009e7e.svg)](https://anet.sh)
7
7
 
8
- Agent runtime for Agent Network. Connects to a CommHub server, registers under an alias, and processes incoming tasks with Claude, Codex, Codex app-server, Grok Build, or OpenCode ACP runtimes.
8
+ Agent Node is the worker process between CommHub and a model runtime. It receives tasks over SSE, invokes the configured runtime, returns results, and reports node status.
9
9
 
10
- The supported entry point is the `anet` CLI from `@sleep2agi/agent-network`, which writes the right `config.json`, network token, and environment variables for you.
10
+ Most users should manage it through the `anet` CLI. `anet node create` writes the network-bound identity and runtime configuration; `anet node start` launches the matching Agent Node.
11
11
 
12
- ## Install
13
-
14
- You usually don't install this package directly — `anet node create` and `anet node start` use it via `npx`. To pin it:
12
+ ## Install and run
15
13
 
16
14
  ```bash
17
- npm install -g @sleep2agi/agent-node
18
- ```
19
-
20
- For the canonical OpenCode preview, install the entire vetted pair exactly. The OpenCode path does not execute an ambient package or automatic `npx` fallback:
15
+ npm install -g bun @sleep2agi/agent-network @sleep2agi/agent-node
21
16
 
22
- ```bash
23
- npm install -g @sleep2agi/agent-network@2.3.0-preview.34 \
24
- @sleep2agi/agent-node@2.5.0-preview.26 \
25
- opencode-ai@1.18.1
17
+ anet hub start
18
+ anet hub dashboard
19
+ anet login --hub http://127.0.0.1:9200 --username admin
20
+ anet node create my-bot
21
+ anet node start my-bot
26
22
  ```
27
23
 
28
- ## Verified flow
29
-
30
- ```bash
31
- npm install -g @sleep2agi/agent-network
32
- anet hub start # local hub (terminal 1)
33
- anet hub dashboard # web UI (terminal 2)
34
- anet login --hub http://127.0.0.1:9200 --username admin --password anethub
35
- anet node create my-bot # two-step picker: runtime, then provider
36
- anet node start my-bot # → SSE connected
37
- ```
38
-
39
- The picker writes `.anet/nodes/<name>/config.json`. `anet node start` reads it and runs this package under the hood.
40
-
41
- ## Direct invocation
24
+ The node is ready after `SSE connected` appears in its log.
42
25
 
43
- For scripts and CI:
26
+ For an existing profile, direct invocation is possible but normally unnecessary:
44
27
 
45
28
  ```bash
46
- npx @sleep2agi/agent-node --alias my-bot --hub http://127.0.0.1:9200 --tools all
29
+ npx @sleep2agi/agent-node \
30
+ --config .anet/nodes/<name>/config.json \
31
+ --alias <name>
47
32
  ```
48
33
 
49
- CLI flags:
50
-
51
- | Flag | Default | Notes |
52
- |---|---|---|
53
- | `--alias` | required | unique name in the hub |
54
- | `--hub` | `http://127.0.0.1:9200` | CommHub URL |
55
- | `--runtime` | `claude-agent-sdk` | `claude-agent-sdk` / `claude-code-cli` / `codex-sdk` / `codex-app-server` / `grok-build-acp` / `opencode-cli` |
56
- | `--model` | runtime default | passed through to the SDK |
57
- | `--tools` | (none) | `all` or comma-separated list |
58
- | `--max-turns` | `50` | upper bound per task |
59
- | `--session` | (none) | resume a prior session / thread |
34
+ The config must contain a valid node token, or authentication must resolve through the documented legacy fallback. Do not pass a user token as node identity.
60
35
 
61
36
  ## Runtimes
62
37
 
63
- | Runtime | Backend | Status | Notes |
64
- |---|---|---|---|
65
- | `claude-agent-sdk` | [@anthropic-ai/claude-agent-sdk](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk) | verified | Anthropic-compatible API; works with MiniMax, DeepSeek, GLM, Kimi, Anthropic, OpenRouter, or custom endpoints |
66
- | `codex-sdk` | [@openai/codex-sdk](https://www.npmjs.com/package/@openai/codex-sdk) | unverified end-to-end | unit tests pass, no full E2E with real codex auth |
67
- | `claude-code-cli` | local `claude` CLI | unverified end-to-end | runs locally for Claude Pro subscribers (v0.8.2 fixed the session-resume default-loss bug; see [changelog](https://anet.sh/en/changelog)) |
68
- | `codex-app-server` | local `codex app-server` WebSocket | preview, Windows-verified | shares a Codex TUI thread with dispatched network tasks |
69
- | `grok-build-acp` | local `grok agent stdio` | stable runtime, native MCP injection boundary remains preview | requires Grok Build CLI login; stable for receive/reply, session persistence, and explicit CommHub delegation handled by agent-node |
70
- | `opencode-cli` | exact `opencode-ai@1.18.1` ACP child | canonical preview, release-gated | defaults to a launch-scoped external workspace with tools disabled; Anthropic/OpenAI presets |
71
-
72
- The canonical preview picker exposes exactly these 6 runtimes. They are loaded lazily; picking one does not pull the others' SDK dependencies. `claude-code-cli` adds zero extra SDK weight.
73
-
74
- ## Grok Build ACP
75
-
76
- `grok-build-acp` runs the local Grok Build CLI over Agent Client Protocol:
77
-
78
- ```bash
79
- curl -fsSL https://x.ai/cli/install.sh | bash
80
- grok
81
- anet node create grok-demo --runtime grok-build-acp
82
- anet node start grok-demo
83
- ```
84
-
85
- The runtime starts `grok agent stdio`, authenticates with the cached Grok login, opens or loads a Grok session, sends the task prompt, collects streamed ACP notifications, and writes `grokSession` back to the node config.
38
+ Runtime availability follows the installed npm channel; do not infer it from a fixed version table in a README. Use the [runtime guide](https://anet.sh/guide/runtimes) as the current compatibility matrix.
86
39
 
87
- Stable behavior:
88
-
89
- - CommHub task delivery and replies are handled by `agent-node`, not by Grok itself.
90
- - Plain text tasks should be answered directly by Grok.
91
- - Explicit delegation tasks are intercepted before Grok when they use a clear pattern such as `给 <alias> 发任务: <task>`.
92
- - Intercepted delegation calls CommHub directly, passes `parent_task_id`, polls `get_task`, and returns the child result.
93
-
94
- Known boundary:
95
-
96
- - Native Grok MCP tool injection is still experimental. Do not rely on Grok itself seeing `commhub_get_all_status` or `commhub_send_task`.
97
- - Image attachments are currently text-only because the captured Grok ACP capability reports `promptCapabilities.image=false`.
98
- - `grok ACP error -32603` is treated as retryable once with a fresh session; the runtime now logs JSON-RPC `error.data` when Grok provides it.
99
- - Grok tool-state boilerplate such as "Do not attempt to use tools from these servers yet" is stripped from final CommHub replies so users see the actual task answer.
100
-
101
- ## Provider presets (claude-agent-sdk)
102
-
103
- `anet node create` step 2 picks one of these and writes `ANTHROPIC_BASE_URL` + a default model. All Anthropic-compatible HTTP API; `--model` is passed through verbatim.
104
-
105
- | Provider | Base URL | Default model | Status |
106
- |---|---|---|---|
107
- | Anthropic | `https://api.anthropic.com` | configured by `--model` | verified |
108
- | MiniMax (国际) | `https://api.minimax.io/anthropic` | `MiniMax-M2.7` | verified |
109
- | MiniMax (国内) | `https://api.minimaxi.com/anthropic` | `MiniMax-M2.7` | verified |
110
- | DeepSeek | `https://api.deepseek.com/anthropic` | `deepseek-chat` | verified |
111
- | GLM (智谱) | `https://open.bigmodel.cn/api/anthropic` | `glm-4-plus` | verified |
112
- | Kimi (Moonshot) | `https://api.moonshot.cn/anthropic` | `moonshot-v1-32k` | verified |
113
- | OpenRouter | `https://openrouter.ai/api/v1` | (user-chosen) | unverified end-to-end |
114
- | Custom | user-supplied | user-supplied | unverified end-to-end |
115
-
116
- ## Manual env-var examples
117
-
118
- ```bash
119
- # DeepSeek
120
- ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic \
121
- ANTHROPIC_AUTH_TOKEN=sk-... \
122
- npx @sleep2agi/agent-node --alias deep --hub http://127.0.0.1:9200 --tools all
123
-
124
- # MiniMax
125
- ANTHROPIC_BASE_URL=https://api.minimax.io/anthropic \
126
- ANTHROPIC_AUTH_TOKEN=your-key \
127
- npx @sleep2agi/agent-node --alias mini --model <minimax-model-id> --hub http://127.0.0.1:9200 --tools all
128
- ```
129
-
130
- ## Configuration file
131
-
132
- Typical output of `anet node create` at `.anet/nodes/<name>/config.json`:
133
-
134
- ```json
135
- {
136
- "node_id": "n_a1b2c3d4",
137
- "node_name": "my-bot",
138
- "hub": "http://127.0.0.1:9200",
139
- "token": "ntok_...",
140
- "runtime": "claude-agent-sdk",
141
- "model": "<minimax-model-id>",
142
- "channels": ["server:commhub"],
143
- "tools": ["Read", "Write", "Edit", "Bash", "Glob", "Grep"],
144
- "env": {
145
- "ANTHROPIC_BASE_URL": "https://api.minimax.io/anthropic",
146
- "ANTHROPIC_AUTH_TOKEN": "sk-..."
147
- },
148
- "flags": {
149
- "dangerouslySkipPermissions": true,
150
- "teammateMode": "in-process",
151
- "maxTurns": 50
152
- }
153
- }
154
- ```
155
-
156
- Per-node config wins over `~/.anet/config.json`; missing fields fall back to global, then defaults.
157
-
158
- ## Main loop
159
-
160
- Same shape across runtimes:
40
+ | Runtime | Purpose | Availability boundary |
41
+ |---|---|---|
42
+ | `claude-code-cli` | Reuse a local Claude Code login/session | Published task runtime |
43
+ | `claude-agent-sdk` | Call Anthropic-compatible APIs | Published task runtime |
44
+ | `codex-sdk` | Run Codex-backed tasks | Published task runtime |
45
+ | `grok-build-acp` | Run Grok Build through ACP | Published task runtime; no human attach |
46
+ | `codex-app-server` | Share a Codex thread with a human TUI | Preview-only; use `anet node start <name> --copresence` |
47
+ | `opencode-cli` | Run the vetted OpenCode ACP path | Preview-only |
161
48
 
162
- ```
163
- start
164
- → report_status: idle
165
- → SSE long-poll /events/:alias
166
- → on new_task: get_inbox → ack_inbox
167
- → report_status: working
168
- → run the LLM (with commhub MCP tools injected)
169
- → send_reply
170
- → report_status: idle
171
- ```
49
+ Neither npm `latest` nor `preview` includes a shared Grok TUI. Development branches may contain source-only experiments, but they are not an installable product path until published and listed in the [Grok TUI status page](https://anet.sh/guide/grok-copresence).
172
50
 
173
- ## Peer coordination (verified)
51
+ ## Configuration and security
174
52
 
175
- When the agent runs, the commhub MCP tools are auto-injected. The model can call:
53
+ Project-local profiles live under `.anet/nodes/<alias>/`. A profile includes the Hub URL, runtime, `node_id`, network-bound `ntok_`, model settings, and runtime flags. Treat it as a secret:
176
54
 
177
- - `commhub_get_all_status()` see who else is online
178
- - `commhub_send_task(alias, task)` dispatch a sub-task to a peer
179
- - `commhub_get_task(task_id)` poll for the peer's reply
180
- - `commhub_send_message(alias, message)` chat without a task lifecycle
181
- - `commhub_report_status(status, task)` push status update
55
+ - Do not commit `.anet`, profile files, `.env`, or tokens.
56
+ - Do not copy one node profile to another machine or alias.
57
+ - Create a separate node identity on each machine.
58
+ - Start from the intended project directory; runtime file tools inherit that workspace.
59
+ - Runtime permission defaults differ. Read the CLI disclosure and [security guide](https://anet.sh/concepts/security) before allowing shell, file-write, or network access.
182
60
 
183
- This is what powers the multi-agent flow demonstrated in `anet hub dashboard` (e.g. ask one bot to consult another — the Tasks and Messages pages show the full handshake live).
61
+ Agent Node does not read environment variables literally named `TOOLS` or `SYSTEM_PROMPT`. Use `--tools` / config `tools` and `--prompt` / config `systemPrompt`.
184
62
 
185
- ## Isolation
63
+ ## Task behavior
186
64
 
187
- When the runtime is `claude-code-cli`, the spawned subprocess gets `settingSources: []` so it doesn't read the host's `~/.claude.json` and accidentally cross networks.
65
+ - `send_task` creates executable work and can invoke the target runtime.
66
+ - `send_reply` completes a task without invoking another model.
67
+ - `send_message` is ordinary chat and does not invoke another model.
188
68
 
189
- ## Companion packages
69
+ This distinction prevents reply loops. See the [task lifecycle](https://anet.sh/concepts/task-lifecycle) for state, retry, timeout, and parent-child semantics.
190
70
 
191
- | Package | Version |
192
- |---|---|
193
- | [@sleep2agi/agent-network](https://www.npmjs.com/package/@sleep2agi/agent-network) | 2.2.10 |
194
- | [@sleep2agi/commhub-server](https://www.npmjs.com/package/@sleep2agi/commhub-server) | 0.8.4 |
195
- | [@sleep2agi/agent-network-dashboard](https://www.npmjs.com/package/@sleep2agi/agent-network-dashboard) | 0.5.6 |
71
+ ## Documentation
196
72
 
197
- ## License
73
+ - [Agent Node guide](https://anet.sh/guide/agent-node)
74
+ - [Runtime guide](https://anet.sh/guide/runtimes)
75
+ - [CLI reference](https://anet.sh/guide/cli)
76
+ - [Troubleshooting](https://anet.sh/troubleshooting)
77
+ - [Source repository](https://github.com/sleep2agi/agent-network)
198
78
 
199
- Apache-2.0
79
+ Apache-2.0.