@mmmbuto/nexuscli 0.8.9 → 0.9.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 +9 -8
- package/frontend/dist/assets/{index-Dl9FJBOB.css → index-Ci39i_2l.css} +1 -1
- package/frontend/dist/assets/{index-DFYYfeuX.js → index-x6Jl2qtq.js} +1697 -1697
- package/frontend/dist/index.html +2 -2
- package/frontend/dist/sw.js +1 -1
- package/frontend/package.json +1 -1
- package/lib/cli/api.js +6 -0
- package/lib/cli/status.js +1 -19
- package/lib/config/models.js +15 -0
- package/lib/server/.env.example +1 -1
- package/lib/server/lib/pty-adapter.js +2 -0
- package/lib/server/routes/models.js +1 -1
- package/lib/server/server.js +0 -2
- package/lib/server/services/claude-wrapper.js +115 -16
- package/lib/server/services/output-parser.js +11 -2
- package/package.json +1 -2
- package/lib/server/db.js.old +0 -225
- package/lib/server/docs/API_WRAPPER_CONTRACT.md +0 -682
- package/lib/server/docs/ARCHITECTURE.md +0 -441
- package/lib/server/docs/DATABASE_SCHEMA.md +0 -783
- package/lib/server/docs/DESIGN_PRINCIPLES.md +0 -598
- package/lib/server/docs/NEXUSCHAT_ANALYSIS.md +0 -488
- package/lib/server/docs/PIPELINE_INTEGRATION.md +0 -636
- package/lib/server/docs/README.md +0 -272
- package/lib/server/docs/UI_DESIGN.md +0 -916
- package/lib/server/routes/system.js +0 -29
- package/lib/server/services/version-manager.js +0 -170
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
# NexusCLI Backend Documentation
|
|
2
|
-
|
|
3
|
-
**Version**: 0.1.0
|
|
4
|
-
**Created**: 2025-11-17
|
|
5
|
-
**Status**: Design Phase
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## 📚 Documentation Index
|
|
10
|
-
|
|
11
|
-
This directory contains the **official design documentation** for NexusCLI backend, based on analysis of the NexusChat wrapper architecture.
|
|
12
|
-
|
|
13
|
-
### Core Documents
|
|
14
|
-
|
|
15
|
-
| Document | Purpose | Audience |
|
|
16
|
-
|----------|---------|----------|
|
|
17
|
-
| **⭐ [Design Principles](./DESIGN_PRINCIPLES.md)** | **Three Pillars**: Lightweight, Portable, ChatGPT UI | **Everyone - Start here!** |
|
|
18
|
-
| **[Database Schema](./DATABASE_SCHEMA.md)** | SQLite schema for chat/sessions (Linux + Termux friendly) | Backend developers, DB admins |
|
|
19
|
-
| **[API & Wrapper Contract](./API_WRAPPER_CONTRACT.md)** | Complete API specification for Control Plane and node wrappers | Backend developers, API consumers |
|
|
20
|
-
| **[Architecture Overview](./ARCHITECTURE.md)** | High-level system architecture and component design | System architects, DevOps |
|
|
21
|
-
| **[Pipeline Integration](./PIPELINE_INTEGRATION.md)** | How the 5-phase pipeline works (Analysis → Deploy) | Product managers, full-stack developers |
|
|
22
|
-
| **[NexusChat Analysis](./NEXUSCHAT_ANALYSIS.md)** | Detailed analysis of reference implementation | Backend developers, researchers |
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## 🎯 Quick Start
|
|
27
|
-
|
|
28
|
-
### For Everyone
|
|
29
|
-
|
|
30
|
-
**Start with**: [Design Principles](./DESIGN_PRINCIPLES.md) - Understand the three pillars (Lightweight, Portable, ChatGPT UI)
|
|
31
|
-
|
|
32
|
-
### For Backend Developers
|
|
33
|
-
|
|
34
|
-
1. Read [Architecture Overview](./ARCHITECTURE.md) to understand the system design
|
|
35
|
-
2. Review [API Contract](./API_WRAPPER_CONTRACT.md) for endpoint specifications
|
|
36
|
-
3. Study [Pipeline Integration](./PIPELINE_INTEGRATION.md) for workflow logic
|
|
37
|
-
4. Check [NexusChat Analysis](./NEXUSCHAT_ANALYSIS.md) for reference implementation details
|
|
38
|
-
|
|
39
|
-
### For Frontend Developers
|
|
40
|
-
|
|
41
|
-
1. Focus on **API Contract** sections:
|
|
42
|
-
- Control Plane API endpoints
|
|
43
|
-
- SSE event streaming format
|
|
44
|
-
- Data structures (Node, Job, Event)
|
|
45
|
-
|
|
46
|
-
### For DevOps Engineers
|
|
47
|
-
|
|
48
|
-
1. Read **Architecture** for deployment strategy
|
|
49
|
-
2. Check **Pipeline Integration** for monitoring metrics
|
|
50
|
-
3. See **API Contract** for health check endpoints
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
## 🏗️ Architecture Summary
|
|
55
|
-
|
|
56
|
-
**NexusCLI** = Distributed control plane for CLI orchestration
|
|
57
|
-
|
|
58
|
-
```
|
|
59
|
-
┌───────────────┐
|
|
60
|
-
│ Frontend │ ← React dashboard
|
|
61
|
-
└───────┬───────┘
|
|
62
|
-
│ REST API + SSE
|
|
63
|
-
↓
|
|
64
|
-
┌───────────────┐
|
|
65
|
-
│ Control Plane │ ← Express.js (this codebase)
|
|
66
|
-
└───────┬───────┘
|
|
67
|
-
│ HTTP
|
|
68
|
-
↓
|
|
69
|
-
┌───────────────┐
|
|
70
|
-
│ nexus-wrapper │ ← Node agent (separate repo)
|
|
71
|
-
└───────┬───────┘
|
|
72
|
-
│ PTY
|
|
73
|
-
↓
|
|
74
|
-
┌───────────────┐
|
|
75
|
-
│ CLI Tools │ ← bash, git, docker, etc.
|
|
76
|
-
└───────────────┘
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
**Inspired by**: NexusChat's claude-code-server wrapper architecture
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
## 🔄 5-Phase Pipeline
|
|
84
|
-
|
|
85
|
-
```
|
|
86
|
-
Analysis → Coordination → Execution → Test → Deploy
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
Each job follows this pipeline:
|
|
90
|
-
|
|
91
|
-
1. **Analysis**: Validate command, check feasibility
|
|
92
|
-
2. **Coordination**: Select node, queue job
|
|
93
|
-
3. **Execution**: Run command, stream output
|
|
94
|
-
4. **Test**: Verify results, assert expectations
|
|
95
|
-
5. **Deploy**: Apply changes, trigger follow-ups
|
|
96
|
-
|
|
97
|
-
See [Pipeline Integration](./PIPELINE_INTEGRATION.md) for details.
|
|
98
|
-
|
|
99
|
-
---
|
|
100
|
-
|
|
101
|
-
## 📊 Data Structures
|
|
102
|
-
|
|
103
|
-
### Node
|
|
104
|
-
```json
|
|
105
|
-
{
|
|
106
|
-
"nodeId": "node-001",
|
|
107
|
-
"hostname": "server-prod-1",
|
|
108
|
-
"status": "online",
|
|
109
|
-
"capabilities": {
|
|
110
|
-
"tools": ["bash", "git", "docker"]
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Job
|
|
116
|
-
```json
|
|
117
|
-
{
|
|
118
|
-
"jobId": "job-123",
|
|
119
|
-
"nodeId": "node-001",
|
|
120
|
-
"status": "completed",
|
|
121
|
-
"tool": "bash",
|
|
122
|
-
"command": "ls -la",
|
|
123
|
-
"result": {
|
|
124
|
-
"exitCode": 0,
|
|
125
|
-
"stdout": "...",
|
|
126
|
-
"duration": 123
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### Event (SSE)
|
|
132
|
-
```json
|
|
133
|
-
{
|
|
134
|
-
"type": "status",
|
|
135
|
-
"category": "tool",
|
|
136
|
-
"message": "Bash: ls -la",
|
|
137
|
-
"icon": "🔧"
|
|
138
|
-
}
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
---
|
|
142
|
-
|
|
143
|
-
## 🔗 Key APIs
|
|
144
|
-
|
|
145
|
-
### Control Plane
|
|
146
|
-
|
|
147
|
-
```
|
|
148
|
-
POST /api/v1/nodes/register # Register node
|
|
149
|
-
GET /api/v1/nodes # List nodes
|
|
150
|
-
POST /api/v1/jobs # Create job
|
|
151
|
-
GET /api/v1/jobs/:id/stream # SSE stream
|
|
152
|
-
GET /api/v1/jobs/:id # Get result
|
|
153
|
-
DELETE /api/v1/jobs/:id # Cancel job
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### Node Wrapper
|
|
157
|
-
|
|
158
|
-
```
|
|
159
|
-
GET /api/v1/health # Health check
|
|
160
|
-
GET /api/v1/capabilities # List tools
|
|
161
|
-
POST /api/v1/jobs # Execute job
|
|
162
|
-
GET /api/v1/jobs/:id/stream # SSE stream
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
## 🧪 Implementation Status
|
|
168
|
-
|
|
169
|
-
| Component | Status | Priority |
|
|
170
|
-
|-----------|--------|----------|
|
|
171
|
-
| Control Plane API | 📝 Designed | High |
|
|
172
|
-
| Node Registry | 📝 Designed | High |
|
|
173
|
-
| Job Manager | 📝 Designed | High |
|
|
174
|
-
| SSE Streaming | 📝 Designed | High |
|
|
175
|
-
| nexus-wrapper | 📝 Designed | Medium |
|
|
176
|
-
| Output Parser | 📝 Designed | Medium |
|
|
177
|
-
| Frontend Dashboard | ✅ Bootstrap | Medium |
|
|
178
|
-
| Pipeline Templates | 📝 Designed | Low |
|
|
179
|
-
| WellaNet Integration | 🔮 Future | Low |
|
|
180
|
-
|
|
181
|
-
**Legend**: ✅ Done | 🔄 In Progress | 📝 Designed | 🔮 Future
|
|
182
|
-
|
|
183
|
-
---
|
|
184
|
-
|
|
185
|
-
## 📖 Design Philosophy
|
|
186
|
-
|
|
187
|
-
### Learned from NexusChat
|
|
188
|
-
|
|
189
|
-
1. **PTY over Subprocess**: Use `node-pty` for real TTY simulation
|
|
190
|
-
2. **2-Layer Persistence**: RAM cache + disk storage for crash recovery
|
|
191
|
-
3. **SSE for Streaming**: Server-Sent Events for real-time updates
|
|
192
|
-
4. **Output Parser State Machine**: Regex-based parsing with state tracking
|
|
193
|
-
5. **Graceful Shutdown**: Handle SIGTERM, save in-flight jobs
|
|
194
|
-
|
|
195
|
-
### Generalized for NexusCLI
|
|
196
|
-
|
|
197
|
-
- **Wrapper abstraction**: Generic interface for any CLI tool
|
|
198
|
-
- **Multi-node orchestration**: Control plane coordinates multiple wrappers
|
|
199
|
-
- **Pipeline thinking**: Every job follows Analysis → Deploy workflow
|
|
200
|
-
- **Event-driven**: All updates flow through SSE event streams
|
|
201
|
-
|
|
202
|
-
---
|
|
203
|
-
|
|
204
|
-
## 🔐 Security Considerations
|
|
205
|
-
|
|
206
|
-
### Authentication
|
|
207
|
-
- JWT tokens for API clients
|
|
208
|
-
- Bearer tokens for node wrappers
|
|
209
|
-
- Rate limiting per user/node
|
|
210
|
-
|
|
211
|
-
### Authorization
|
|
212
|
-
- RBAC for job execution
|
|
213
|
-
- Tool restrictions per node
|
|
214
|
-
- Command whitelisting/blacklisting
|
|
215
|
-
|
|
216
|
-
### Isolation
|
|
217
|
-
- Isolated working directories
|
|
218
|
-
- Resource limits (CPU, memory, timeout)
|
|
219
|
-
- No access to wrapper process environment
|
|
220
|
-
|
|
221
|
-
---
|
|
222
|
-
|
|
223
|
-
## 📈 Performance Targets
|
|
224
|
-
|
|
225
|
-
| Metric | Target |
|
|
226
|
-
|--------|--------|
|
|
227
|
-
| Job submission latency | < 100ms |
|
|
228
|
-
| SSE event latency | < 50ms |
|
|
229
|
-
| Concurrent jobs (per node) | 5-10 |
|
|
230
|
-
| Control plane throughput | 100 jobs/sec |
|
|
231
|
-
| Node wrapper memory | < 100MB |
|
|
232
|
-
|
|
233
|
-
---
|
|
234
|
-
|
|
235
|
-
## 🚀 Next Steps
|
|
236
|
-
|
|
237
|
-
### Immediate (Phase 1)
|
|
238
|
-
|
|
239
|
-
1. Implement Control Plane API endpoints
|
|
240
|
-
2. Create nexus-wrapper reference implementation
|
|
241
|
-
3. Adapt OutputParser for generic CLI tools
|
|
242
|
-
4. Set up systemd services
|
|
243
|
-
|
|
244
|
-
### Short-term (Phase 2)
|
|
245
|
-
|
|
246
|
-
1. Add WebSocket support (alternative to SSE)
|
|
247
|
-
2. Implement job scheduling (cron-like)
|
|
248
|
-
3. Create pipeline templates
|
|
249
|
-
4. Add approval workflows
|
|
250
|
-
|
|
251
|
-
### Long-term (Phase 3)
|
|
252
|
-
|
|
253
|
-
1. WellaNet integration (compute marketplace)
|
|
254
|
-
2. AI-assisted command validation
|
|
255
|
-
3. Blockchain-based node registry
|
|
256
|
-
4. Multi-cloud orchestration
|
|
257
|
-
|
|
258
|
-
---
|
|
259
|
-
|
|
260
|
-
## 📞 Contact & Contribution
|
|
261
|
-
|
|
262
|
-
**Project Lead**: Davide A. Guglielmi
|
|
263
|
-
**Email**: dev@mmmbuto.com
|
|
264
|
-
**Repository**: `/var/www/cli.wellanet.dev/`
|
|
265
|
-
|
|
266
|
-
**Based on**:
|
|
267
|
-
- NexusChat wrapper architecture (`/var/www/chat.mmmbuto.com/servers/claude-code-server/`)
|
|
268
|
-
- Production experience with 100+ daily requests
|
|
269
|
-
|
|
270
|
-
---
|
|
271
|
-
|
|
272
|
-
_All documentation generated with [Claude Code](https://claude.com/claude-code) (Sonnet 4.5)_
|