@sleep2agi/agent-node 0.1.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 ADDED
@@ -0,0 +1,109 @@
1
+ # @sleep2agi/agent-node
2
+
3
+ One-command AI Agent node for CommHub networks.
4
+
5
+ ```bash
6
+ npx @sleep2agi/agent-node --alias "我的Agent" --model MiniMax-M2.7 --hub http://YOUR_HUB:9200
7
+ ```
8
+
9
+ ## Features
10
+
11
+ - SSE real-time messaging with auto-reconnect
12
+ - Heartbeat keepalive (3 min interval)
13
+ - Session resume for context continuity
14
+ - Works with Claude, MiniMax, or any Anthropic-compatible API
15
+ - Config file support (`.agent-node.json`)
16
+ - Graceful shutdown (SIGINT/SIGTERM)
17
+
18
+ ## Quick Start
19
+
20
+ ### With MiniMax
21
+
22
+ ```bash
23
+ ANTHROPIC_BASE_URL=https://api.minimaxi.com/anthropic \
24
+ ANTHROPIC_AUTH_TOKEN=your-token \
25
+ npx @sleep2agi/agent-node --alias "MiniMax马" --model MiniMax-M2.7
26
+ ```
27
+
28
+ ### With Claude
29
+
30
+ ```bash
31
+ ANTHROPIC_API_KEY=your-key \
32
+ npx @sleep2agi/agent-node --alias "Claude马" --model claude-sonnet-4-6
33
+ ```
34
+
35
+ ### With Config File
36
+
37
+ Create `.agent-node.json`:
38
+
39
+ ```json
40
+ {
41
+ "alias": "我的Agent",
42
+ "hub": "http://YOUR_HUB:9200",
43
+ "model": "MiniMax-M2.7",
44
+ "tools": [],
45
+ "maxTurns": 5,
46
+ "systemPrompt": "你是一个有用的助手"
47
+ }
48
+ ```
49
+
50
+ Then:
51
+
52
+ ```bash
53
+ ANTHROPIC_BASE_URL=https://api.minimaxi.com/anthropic \
54
+ ANTHROPIC_AUTH_TOKEN=your-token \
55
+ npx @sleep2agi/agent-node
56
+ ```
57
+
58
+ ## Programmatic Usage
59
+
60
+ ```typescript
61
+ import { AgentNode } from "@sleep2agi/agent-node";
62
+
63
+ const agent = new AgentNode({
64
+ alias: "我的Agent",
65
+ hub: "http://YOUR_HUB:9200",
66
+ model: "MiniMax-M2.7",
67
+ tools: ["Read", "Grep"],
68
+ maxTurns: 5,
69
+ onTask: async (msg) => {
70
+ console.log("收到任务:", msg.content);
71
+ // Return string to override AI processing
72
+ // Return void to use default AI processing
73
+ },
74
+ onResult: async (msg, result) => {
75
+ console.log("完成:", result);
76
+ },
77
+ });
78
+
79
+ await agent.start();
80
+ ```
81
+
82
+ ## CLI Options
83
+
84
+ | Option | Env Var | Description |
85
+ |--------|---------|-------------|
86
+ | `--alias` | `ALIAS` | Agent name (required) |
87
+ | `--hub` | `COMMHUB_URL` | CommHub URL (default: `http://127.0.0.1:9200`) |
88
+ | `--model` | `MODEL` | AI model (default: `claude-sonnet-4-6`) |
89
+ | `--tools` | - | Comma-separated tool list |
90
+ | `--max-turns` | - | Max turns per task (default: 5) |
91
+ | `--prompt` | - | Custom system prompt |
92
+ | `--token` | `COMMHUB_TOKEN` | Auth token |
93
+ | `--config` | - | Config file path (default: `.agent-node.json`) |
94
+
95
+ ## Architecture
96
+
97
+ ```
98
+ CommHub Server (SSE)
99
+
100
+ agent-node (this package)
101
+ ├─ SSE listener → receive tasks
102
+ ├─ CommHub MCP client → register/ack/reply
103
+ └─ Claude Agent SDK → AI processing
104
+ └─ Anthropic API / MiniMax / compatible
105
+ ```
106
+
107
+ ## License
108
+
109
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @sleep2agi/agent-node CLI
4
+ *
5
+ * npx @sleep2agi/agent-node --alias "我的Agent" --model MiniMax-M2.7 --hub http://127.0.0.1:9200
6
+ */
7
+ export {};