omniwire 2.0.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/LICENSE +21 -0
- package/README.md +316 -0
- package/dist/claude/integration.d.ts +12 -0
- package/dist/claude/integration.js +157 -0
- package/dist/claude/integration.js.map +1 -0
- package/dist/commands/browser.d.ts +2 -0
- package/dist/commands/browser.js +23 -0
- package/dist/commands/browser.js.map +1 -0
- package/dist/commands/builtins.d.ts +4 -0
- package/dist/commands/builtins.js +309 -0
- package/dist/commands/builtins.js.map +1 -0
- package/dist/commands/router.d.ts +2 -0
- package/dist/commands/router.js +174 -0
- package/dist/commands/router.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +198 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +71 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/rest.d.ts +3 -0
- package/dist/mcp/rest.js +98 -0
- package/dist/mcp/rest.js.map +1 -0
- package/dist/mcp/server.d.ts +4 -0
- package/dist/mcp/server.js +419 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/sse.d.ts +2 -0
- package/dist/mcp/sse.js +43 -0
- package/dist/mcp/sse.js.map +1 -0
- package/dist/mcp/sync-tools.d.ts +5 -0
- package/dist/mcp/sync-tools.js +124 -0
- package/dist/mcp/sync-tools.js.map +1 -0
- package/dist/nodes/manager.d.ts +28 -0
- package/dist/nodes/manager.js +341 -0
- package/dist/nodes/manager.js.map +1 -0
- package/dist/nodes/realtime.d.ts +13 -0
- package/dist/nodes/realtime.js +46 -0
- package/dist/nodes/realtime.js.map +1 -0
- package/dist/nodes/shell.d.ts +17 -0
- package/dist/nodes/shell.js +137 -0
- package/dist/nodes/shell.js.map +1 -0
- package/dist/nodes/transfer.d.ts +22 -0
- package/dist/nodes/transfer.js +244 -0
- package/dist/nodes/transfer.js.map +1 -0
- package/dist/nodes/tunnel.d.ts +12 -0
- package/dist/nodes/tunnel.js +49 -0
- package/dist/nodes/tunnel.js.map +1 -0
- package/dist/protocol/config.d.ts +9 -0
- package/dist/protocol/config.js +133 -0
- package/dist/protocol/config.js.map +1 -0
- package/dist/protocol/paths.d.ts +3 -0
- package/dist/protocol/paths.js +19 -0
- package/dist/protocol/paths.js.map +1 -0
- package/dist/protocol/types.d.ts +106 -0
- package/dist/protocol/types.js +3 -0
- package/dist/protocol/types.js.map +1 -0
- package/dist/sync/db.d.ts +53 -0
- package/dist/sync/db.js +212 -0
- package/dist/sync/db.js.map +1 -0
- package/dist/sync/engine.d.ts +23 -0
- package/dist/sync/engine.js +251 -0
- package/dist/sync/engine.js.map +1 -0
- package/dist/sync/hasher.d.ts +2 -0
- package/dist/sync/hasher.js +25 -0
- package/dist/sync/hasher.js.map +1 -0
- package/dist/sync/index.d.ts +6 -0
- package/dist/sync/index.js +155 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/manifest.d.ts +4 -0
- package/dist/sync/manifest.js +105 -0
- package/dist/sync/manifest.js.map +1 -0
- package/dist/sync/memory-bridge.d.ts +7 -0
- package/dist/sync/memory-bridge.js +84 -0
- package/dist/sync/memory-bridge.js.map +1 -0
- package/dist/sync/paths.d.ts +6 -0
- package/dist/sync/paths.js +53 -0
- package/dist/sync/paths.js.map +1 -0
- package/dist/sync/schema.d.ts +2 -0
- package/dist/sync/schema.js +72 -0
- package/dist/sync/schema.js.map +1 -0
- package/dist/sync/types.d.ts +83 -0
- package/dist/sync/types.js +11 -0
- package/dist/sync/types.js.map +1 -0
- package/dist/sync/watcher.d.ts +21 -0
- package/dist/sync/watcher.js +87 -0
- package/dist/sync/watcher.js.map +1 -0
- package/dist/ui/format.d.ts +24 -0
- package/dist/ui/format.js +108 -0
- package/dist/ui/format.js.map +1 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 VoidChecksum
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://img.shields.io/npm/v/omniwire?style=flat-square&color=0A0E14&labelColor=0A0E14&label=npm" alt="npm version" />
|
|
3
|
+
<img src="https://img.shields.io/badge/MCP-30_tools-59C2FF?style=flat-square&labelColor=0A0E14" alt="MCP tools" />
|
|
4
|
+
<img src="https://img.shields.io/badge/transport-stdio_%7C_SSE_%7C_REST-91B362?style=flat-square&labelColor=0A0E14" alt="transports" />
|
|
5
|
+
<img src="https://img.shields.io/badge/license-MIT-E6B450?style=flat-square&labelColor=0A0E14" alt="license" />
|
|
6
|
+
<img src="https://img.shields.io/badge/node-%3E%3D20-CC93E6?style=flat-square&labelColor=0A0E14" alt="node" />
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<h1 align="center">OmniWire</h1>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<strong>Unified mesh control layer for distributed infrastructure</strong><br/>
|
|
13
|
+
<sub>30-tool MCP server • SSH2 connection pooling • adaptive file transfers • cross-node config sync</sub>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
OmniWire connects all your machines into a single control plane. It exposes **30 MCP tools** that any AI agent (Claude Code, OpenCode, Cursor, etc.) can use to execute commands, transfer files, manage Docker containers, and sync configurations across your entire infrastructure — through one unified interface.
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
22
|
+
│ AI Agent (MCP Client) │
|
|
23
|
+
│ Claude Code / OpenCode / Cursor │
|
|
24
|
+
└──────────────────────┬───────────────────────────────────────┘
|
|
25
|
+
│ MCP Protocol (stdio / SSE / REST)
|
|
26
|
+
▼
|
|
27
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
28
|
+
│ OmniWire MCP Server │
|
|
29
|
+
│ 22 Core Tools │ 8 CyberSync Tools │ 3 Transports │
|
|
30
|
+
└──────┬──────────┴──────────┬──────────┴──────────────────────┘
|
|
31
|
+
│ SSH2 (compressed, pooled) │ PostgreSQL
|
|
32
|
+
▼ ▼
|
|
33
|
+
┌─────────┐ ┌─────────┐ ┌─────────┐ ┌────────────┐
|
|
34
|
+
│ Node A │ │ Node B │ │ Node C │ │ CyberSync │
|
|
35
|
+
│ storage │ │ compute │ │ GPU │ │ Database │
|
|
36
|
+
└─────────┘ └─────────┘ └─────────┘ └────────────┘
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
### MCP Server — 30 Tools
|
|
42
|
+
|
|
43
|
+
| Category | Tools | Description |
|
|
44
|
+
|----------|-------|-------------|
|
|
45
|
+
| **Execution** | `omniwire_exec`, `omniwire_broadcast` | Run commands on one or all nodes |
|
|
46
|
+
| **Monitoring** | `omniwire_mesh_status`, `omniwire_node_info`, `omniwire_live_monitor` | Health, latency, CPU/mem/disk |
|
|
47
|
+
| **Files** | `omniwire_read_file`, `omniwire_write_file`, `omniwire_list_files`, `omniwire_find_files` | Full remote filesystem access |
|
|
48
|
+
| **Transfer** | `omniwire_transfer_file`, `omniwire_deploy` | 3-mode adaptive transfer engine |
|
|
49
|
+
| **System** | `omniwire_process_list`, `omniwire_disk_usage`, `omniwire_tail_log`, `omniwire_install_package` | System administration |
|
|
50
|
+
| **Services** | `omniwire_service_control`, `omniwire_docker` | systemd + Docker management |
|
|
51
|
+
| **Network** | `omniwire_port_forward`, `omniwire_open_browser` | SSH tunnels, remote browsers |
|
|
52
|
+
| **Advanced** | `omniwire_kernel`, `omniwire_shell`, `omniwire_stream` | Kernel ops, persistent PTY, streaming |
|
|
53
|
+
| **CyberSync** | `cybersync_status`, `cybersync_sync_now`, `cybersync_diff`, `cybersync_history`, `cybersync_search_knowledge`, `cybersync_get_memory`, `cybersync_manifest`, `cybersync_force_push` | Cross-node config synchronization |
|
|
54
|
+
|
|
55
|
+
### SSH2 Connection Layer
|
|
56
|
+
|
|
57
|
+
- **Persistent connection pooling** — one SSH2 connection per node, reused for all operations
|
|
58
|
+
- **Zlib compression** — ~60% less data over the wire for text-heavy outputs
|
|
59
|
+
- **Exponential backoff reconnect** — 1s → 2s → 4s → ... → 30s cap with jitter
|
|
60
|
+
- **Circuit breaker** — 3 consecutive failures → 60s cooldown, auto-recovers
|
|
61
|
+
- **2MB output guard** — prevents memory exhaustion from runaway commands
|
|
62
|
+
- **Health pings** — 30s interval, detects degraded connections (>3s response)
|
|
63
|
+
- **Status caching** — 5s TTL eliminates redundant probes
|
|
64
|
+
|
|
65
|
+
### Adaptive File Transfer Engine
|
|
66
|
+
|
|
67
|
+
OmniWire automatically selects the fastest transfer mode based on file size:
|
|
68
|
+
|
|
69
|
+
| Mode | Size Range | Method | Speed |
|
|
70
|
+
|------|-----------|--------|-------|
|
|
71
|
+
| **SFTP** | < 10 MB | SSH2 native SFTP subsystem | Zero overhead, binary-safe |
|
|
72
|
+
| **netcat+tar+gzip** | 10 MB – 1 GB | Compressed TCP stream | ~70% smaller for text |
|
|
73
|
+
| **aria2c** | > 1 GB | 16-connection parallel HTTP download | Saturates bandwidth |
|
|
74
|
+
|
|
75
|
+
### CyberSync — Config Synchronization
|
|
76
|
+
|
|
77
|
+
Keeps AI tool configurations (Claude Code, OpenCode, Codex, etc.) synchronized across all your machines:
|
|
78
|
+
|
|
79
|
+
- **6 tools tracked** — claude-code, opencode, openclaw, codex, gemini, paperclip
|
|
80
|
+
- **File watching** — single chokidar instance with batch debounce
|
|
81
|
+
- **Parallel sync** — pushes to all nodes simultaneously via `Promise.allSettled`
|
|
82
|
+
- **Parallel hashing** — SHA-256 in 50-file batches with streaming for large files
|
|
83
|
+
- **Conflict resolution** — node-ownership model with detailed conflict logging
|
|
84
|
+
- **Memory bridge** — ingests Claude's `memory.db` (SQLite → PostgreSQL)
|
|
85
|
+
- **Auto-reconciliation** — every 5 minutes, with event log pruning
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Quick Start
|
|
90
|
+
|
|
91
|
+
### 1. Install
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npm install -g omniwire
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 2. Configure Your Mesh
|
|
98
|
+
|
|
99
|
+
Create `~/.omniwire/mesh.json`:
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"nodes": [
|
|
104
|
+
{
|
|
105
|
+
"id": "server1",
|
|
106
|
+
"host": "10.0.0.1",
|
|
107
|
+
"user": "root",
|
|
108
|
+
"identityFile": "id_ed25519",
|
|
109
|
+
"role": "storage",
|
|
110
|
+
"tags": ["vps", "docker"]
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"id": "server2",
|
|
114
|
+
"host": "10.0.0.2",
|
|
115
|
+
"user": "root",
|
|
116
|
+
"identityFile": "id_ed25519",
|
|
117
|
+
"role": "compute"
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
"meshSubnet": "10.0.0.0/24"
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
SSH identity files are resolved relative to `~/.ssh/`. Full paths also work.
|
|
125
|
+
|
|
126
|
+
### 3. Use as MCP Server
|
|
127
|
+
|
|
128
|
+
Add to your AI tool's MCP config (`.mcp.json`, Claude Code settings, etc.):
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"mcpServers": {
|
|
133
|
+
"omniwire": {
|
|
134
|
+
"command": "node",
|
|
135
|
+
"args": ["/path/to/omniwire/dist/mcp/index.js", "--stdio"]
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Or if installed globally:
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"mcpServers": {
|
|
146
|
+
"omniwire": {
|
|
147
|
+
"command": "omniwire",
|
|
148
|
+
"args": ["--stdio"]
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 4. Use as Interactive Terminal
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
omniwire
|
|
158
|
+
# or
|
|
159
|
+
ow
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Transport Modes
|
|
165
|
+
|
|
166
|
+
| Mode | Port | Use Case |
|
|
167
|
+
|------|------|----------|
|
|
168
|
+
| **stdio** | — | Claude Code, Cursor, any MCP subprocess client |
|
|
169
|
+
| **SSE** | 3200 | OpenCode, remote HTTP-based MCP clients |
|
|
170
|
+
| **REST** | 3201 | Non-MCP integrations, scripts, dashboards |
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# stdio (default for MCP)
|
|
174
|
+
omniwire --stdio
|
|
175
|
+
|
|
176
|
+
# SSE + REST (for remote/HTTP clients)
|
|
177
|
+
omniwire --sse-port=3200 --rest-port=3201
|
|
178
|
+
|
|
179
|
+
# Disable CyberSync (MCP-only, no PostgreSQL needed)
|
|
180
|
+
omniwire --stdio --no-sync
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## CyberSync Setup
|
|
186
|
+
|
|
187
|
+
CyberSync requires PostgreSQL for the sync database. Set via environment variables:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
export CYBERSYNC_PG_HOST=10.0.0.1
|
|
191
|
+
export CYBERSYNC_PG_PORT=5432
|
|
192
|
+
export CYBERSYNC_PG_DATABASE=cybersync
|
|
193
|
+
export CYBERSYNC_PG_USER=cybersync
|
|
194
|
+
export CYBERSYNC_PG_PASSWORD=your_password
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Run the sync daemon:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# Continuous daemon (watch + reconcile every 5 min)
|
|
201
|
+
omniwire sync
|
|
202
|
+
|
|
203
|
+
# Single reconciliation pass
|
|
204
|
+
omniwire sync:once
|
|
205
|
+
|
|
206
|
+
# Ingest Claude memory.db only
|
|
207
|
+
omniwire sync:ingest
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
If you don't need CyberSync, pass `--no-sync` to the MCP server — it works fine without PostgreSQL.
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Configuration Reference
|
|
215
|
+
|
|
216
|
+
### Mesh Config (`~/.omniwire/mesh.json`)
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
interface MeshConfig {
|
|
220
|
+
nodes: Array<{
|
|
221
|
+
id: string; // Unique node identifier
|
|
222
|
+
alias?: string; // Short alias (e.g., "s1")
|
|
223
|
+
host: string; // IP or hostname
|
|
224
|
+
port?: number; // SSH port (default: 22)
|
|
225
|
+
user?: string; // SSH user (default: "root")
|
|
226
|
+
identityFile?: string; // SSH key filename or full path
|
|
227
|
+
os?: "windows" | "linux"; // OS type (default: "linux")
|
|
228
|
+
role?: "controller" | "storage" | "compute" | "gpu+browser";
|
|
229
|
+
tags?: string[]; // Custom tags for filtering
|
|
230
|
+
}>;
|
|
231
|
+
meshSubnet?: string; // Subnet notation (informational)
|
|
232
|
+
defaultNode?: string; // Default target node
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Environment Variables
|
|
237
|
+
|
|
238
|
+
| Variable | Description | Default |
|
|
239
|
+
|----------|-------------|---------|
|
|
240
|
+
| `OMNIWIRE_CONFIG` | JSON mesh config (alternative to file) | — |
|
|
241
|
+
| `OMNIWIRE_NODE_ID` | Override local node ID detection | auto-detected |
|
|
242
|
+
| `OMNIWIRE_LINUX_HOME` | Linux home directory for path mapping | `/root` |
|
|
243
|
+
| `CYBERSYNC_PG_HOST` | PostgreSQL host | `localhost` |
|
|
244
|
+
| `CYBERSYNC_PG_PORT` | PostgreSQL port | `5432` |
|
|
245
|
+
| `CYBERSYNC_PG_DATABASE` | Database name | `cybersync` |
|
|
246
|
+
| `CYBERSYNC_PG_USER` | Database user | `cybersync` |
|
|
247
|
+
| `CYBERSYNC_PG_PASSWORD` | Database password | — |
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Architecture
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
omniwire/
|
|
255
|
+
├── src/
|
|
256
|
+
│ ├── mcp/
|
|
257
|
+
│ │ ├── index.ts # Entrypoint — dual transport (stdio + SSE)
|
|
258
|
+
│ │ ├── server.ts # 22 core MCP tools
|
|
259
|
+
│ │ ├── sync-tools.ts # 8 CyberSync MCP tools
|
|
260
|
+
│ │ ├── sse.ts # SSE transport
|
|
261
|
+
│ │ └── rest.ts # REST API
|
|
262
|
+
│ ├── nodes/
|
|
263
|
+
│ │ ├── manager.ts # SSH2 connection pooling + circuit breaker
|
|
264
|
+
│ │ ├── transfer.ts # 3-mode adaptive file transfer
|
|
265
|
+
│ │ ├── shell.ts # Persistent PTY sessions
|
|
266
|
+
│ │ ├── tunnel.ts # SSH port forwarding
|
|
267
|
+
│ │ └── realtime.ts # Streaming command dispatch
|
|
268
|
+
│ ├── sync/
|
|
269
|
+
│ │ ├── engine.ts # Push/pull/reconcile with parallel ops
|
|
270
|
+
│ │ ├── db.ts # PostgreSQL pool (8 connections, FTS)
|
|
271
|
+
│ │ ├── watcher.ts # Single chokidar, batch debounce
|
|
272
|
+
│ │ ├── hasher.ts # SHA-256 (streaming for large files)
|
|
273
|
+
│ │ ├── manifest.ts # Tool sync definitions
|
|
274
|
+
│ │ ├── memory-bridge.ts # SQLite → PostgreSQL ingestion
|
|
275
|
+
│ │ └── paths.ts # Windows/Linux path adaptation
|
|
276
|
+
│ ├── protocol/
|
|
277
|
+
│ │ ├── config.ts # Mesh topology loader
|
|
278
|
+
│ │ ├── types.ts # Shared type definitions
|
|
279
|
+
│ │ └── paths.ts # node:/path format parser
|
|
280
|
+
│ ├── commands/ # Interactive REPL commands
|
|
281
|
+
│ ├── claude/ # Claude Code AI integration
|
|
282
|
+
│ └── ui/ # Terminal formatting
|
|
283
|
+
├── mesh.example.json # Example mesh configuration
|
|
284
|
+
├── package.json
|
|
285
|
+
└── tsconfig.json
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Performance
|
|
291
|
+
|
|
292
|
+
Benchmarked on a 3-node WireGuard mesh (EU region):
|
|
293
|
+
|
|
294
|
+
| Operation | Latency | Notes |
|
|
295
|
+
|-----------|---------|-------|
|
|
296
|
+
| Single command exec | ~120ms | SSH2 + command + return |
|
|
297
|
+
| Mesh status (all nodes) | ~150ms | Parallel probes, 5s cache |
|
|
298
|
+
| File read (< 1MB) | ~80ms | SFTP, no encoding overhead |
|
|
299
|
+
| File transfer (10MB) | ~200ms | gzip netcat over WireGuard |
|
|
300
|
+
| Config sync (push) | ~200ms | Parallel to all nodes |
|
|
301
|
+
| Reconcile (500 files) | ~2s | 50-file parallel hash batches |
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Requirements
|
|
306
|
+
|
|
307
|
+
- **Node.js** >= 20
|
|
308
|
+
- **SSH access** to remote nodes (key-based auth)
|
|
309
|
+
- **PostgreSQL** (only if using CyberSync)
|
|
310
|
+
- **WireGuard / VPN** recommended for mesh connectivity
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## License
|
|
315
|
+
|
|
316
|
+
MIT
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NodeManager } from '../nodes/manager.js';
|
|
2
|
+
export declare class ClaudeIntegration {
|
|
3
|
+
private manager;
|
|
4
|
+
private sessionId;
|
|
5
|
+
constructor(manager: NodeManager);
|
|
6
|
+
handlePrompt(userPrompt: string): Promise<string>;
|
|
7
|
+
handleSession(userPrompt: string): Promise<string>;
|
|
8
|
+
private buildMeshContext;
|
|
9
|
+
private buildClaudePrompt;
|
|
10
|
+
private runClaude;
|
|
11
|
+
runSuggestedCommands(response: string): Promise<string[]>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// OmniWire Claude Integration — AI-powered mesh orchestration
|
|
2
|
+
// v2: streaming output, multi-turn sessions, MCP tool awareness
|
|
3
|
+
// SECURITY: Uses spawn() with explicit argv — prompt goes as argument, not through shell.
|
|
4
|
+
// The manager.execAll() calls below use SSH2 client channels, not child_process.
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
6
|
+
import { allNodes, NODE_ROLES } from '../protocol/config.js';
|
|
7
|
+
import { cyan, dim, green, red, Spinner } from '../ui/format.js';
|
|
8
|
+
export class ClaudeIntegration {
|
|
9
|
+
manager;
|
|
10
|
+
sessionId = null;
|
|
11
|
+
constructor(manager) {
|
|
12
|
+
this.manager = manager;
|
|
13
|
+
}
|
|
14
|
+
async handlePrompt(userPrompt) {
|
|
15
|
+
const meshContext = this.buildMeshContext();
|
|
16
|
+
const fullPrompt = this.buildClaudePrompt(userPrompt, meshContext);
|
|
17
|
+
try {
|
|
18
|
+
return await this.runClaude(fullPrompt);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return red('Claude CLI not available. Install: npm i -g @anthropic-ai/claude-code');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async handleSession(userPrompt) {
|
|
25
|
+
const meshContext = this.buildMeshContext();
|
|
26
|
+
const fullPrompt = this.buildClaudePrompt(userPrompt, meshContext);
|
|
27
|
+
try {
|
|
28
|
+
return await this.runClaude(fullPrompt, true);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return red('Claude CLI not available.');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
buildMeshContext() {
|
|
35
|
+
const online = this.manager.getOnlineNodes();
|
|
36
|
+
const nodes = allNodes();
|
|
37
|
+
const nodeList = nodes
|
|
38
|
+
.map((n) => {
|
|
39
|
+
const status = online.includes(n.id) ? 'ONLINE' : 'OFFLINE';
|
|
40
|
+
const role = NODE_ROLES[n.id] ?? 'unknown';
|
|
41
|
+
return ` - ${n.id} (${n.alias}): ${n.host} [${n.os}] [${status}] role=${role} tags: ${n.tags.join(', ')}`;
|
|
42
|
+
})
|
|
43
|
+
.join('\n');
|
|
44
|
+
const roleLines = Object.entries(NODE_ROLES)
|
|
45
|
+
.map(([id, role]) => `- ${id} (${role})`)
|
|
46
|
+
.join('\n');
|
|
47
|
+
const storageNode = Object.entries(NODE_ROLES).find(([, r]) => r === 'storage')?.[0] ?? 'storage node';
|
|
48
|
+
const browserNode = Object.entries(NODE_ROLES).find(([, r]) => r === 'gpu+browser')?.[0] ?? 'gpu+browser node';
|
|
49
|
+
const computeNode = Object.entries(NODE_ROLES).find(([, r]) => r === 'compute')?.[0] ?? storageNode;
|
|
50
|
+
const controllerNode = Object.entries(NODE_ROLES).find(([, r]) => r === 'controller')?.[0] ?? 'local';
|
|
51
|
+
return `OMNIWIRE MESH STATUS:
|
|
52
|
+
Nodes:
|
|
53
|
+
${nodeList}
|
|
54
|
+
|
|
55
|
+
NODE ROLES:
|
|
56
|
+
${roleLines}
|
|
57
|
+
|
|
58
|
+
ROUTING DEFAULTS:
|
|
59
|
+
- File storage/retrieval → ${storageNode}
|
|
60
|
+
- Browser/GUI ops → ${browserNode}
|
|
61
|
+
- Heavy compute → ${computeNode}
|
|
62
|
+
- Local dev → ${controllerNode}
|
|
63
|
+
|
|
64
|
+
MCP TOOLS AVAILABLE:
|
|
65
|
+
You have 22 omniwire_* tools for direct mesh access via MCP.
|
|
66
|
+
Tools: omniwire_exec, omniwire_broadcast, omniwire_read_file, omniwire_write_file,
|
|
67
|
+
omniwire_transfer_file, omniwire_docker, omniwire_service_control, omniwire_kernel, etc.
|
|
68
|
+
|
|
69
|
+
LEGACY COMMANDS (still work):
|
|
70
|
+
- @<node> <command>, @all <command>, @sync <file> <src> <dst>
|
|
71
|
+
- Online nodes: ${online.join(', ')}`;
|
|
72
|
+
}
|
|
73
|
+
buildClaudePrompt(userPrompt, meshContext) {
|
|
74
|
+
return `You are the AI brain of OmniWire Terminal, a unified terminal for a WireGuard mesh network.
|
|
75
|
+
The user treats all nodes as one machine. Help them accomplish their task across the mesh.
|
|
76
|
+
|
|
77
|
+
${meshContext}
|
|
78
|
+
|
|
79
|
+
IMPORTANT: If you have omniwire MCP tools available, use them directly.
|
|
80
|
+
Otherwise, output OmniWire commands (prefixed with @node or @all) that I can run.
|
|
81
|
+
Format each command on its own line starting with @.
|
|
82
|
+
After the commands, briefly explain what they do.
|
|
83
|
+
|
|
84
|
+
USER REQUEST: ${userPrompt}`;
|
|
85
|
+
}
|
|
86
|
+
// spawn with explicit argv — prompt goes as argument, not through shell
|
|
87
|
+
runClaude(prompt, useSession = false) {
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
const spinner = new Spinner('Claude is thinking...');
|
|
90
|
+
spinner.start();
|
|
91
|
+
let stdout = '';
|
|
92
|
+
let stderr = '';
|
|
93
|
+
const args = ['-p', prompt, '--no-input', '--output-format', 'text'];
|
|
94
|
+
if (useSession && this.sessionId) {
|
|
95
|
+
args.push('--resume', this.sessionId);
|
|
96
|
+
}
|
|
97
|
+
const proc = spawn('claude', args, {
|
|
98
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
99
|
+
timeout: 120000,
|
|
100
|
+
});
|
|
101
|
+
proc.stdout?.on('data', (data) => {
|
|
102
|
+
const chunk = data.toString();
|
|
103
|
+
stdout += chunk;
|
|
104
|
+
spinner.stop();
|
|
105
|
+
process.stdout.write(dim('│ ') + chunk);
|
|
106
|
+
});
|
|
107
|
+
proc.stderr?.on('data', (data) => {
|
|
108
|
+
stderr += data.toString();
|
|
109
|
+
});
|
|
110
|
+
proc.on('close', (code) => {
|
|
111
|
+
spinner.stop();
|
|
112
|
+
if (code === 0 && stdout.trim()) {
|
|
113
|
+
const sessionMatch = stderr.match(/session[:\s]+([a-f0-9-]+)/i);
|
|
114
|
+
if (sessionMatch) {
|
|
115
|
+
this.sessionId = sessionMatch[1];
|
|
116
|
+
}
|
|
117
|
+
resolve(formatClaudeResponse(stdout.trim()));
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
reject(new Error(stderr || `Claude exited with code ${code}`));
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
proc.on('error', (err) => {
|
|
124
|
+
spinner.stop();
|
|
125
|
+
reject(err);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
// Run Claude's suggested @ commands and return results (SSH2 channels)
|
|
130
|
+
async runSuggestedCommands(response) {
|
|
131
|
+
const lines = response.split('\n');
|
|
132
|
+
const commands = lines.filter((l) => l.trim().startsWith('@'));
|
|
133
|
+
const results = [];
|
|
134
|
+
for (const cmd of commands) {
|
|
135
|
+
const trimmed = cmd.trim();
|
|
136
|
+
const match = trimmed.match(/^@(\w+)\s+(.+)$/);
|
|
137
|
+
if (match) {
|
|
138
|
+
const [, target, command] = match;
|
|
139
|
+
if (target === 'all') {
|
|
140
|
+
const r = await this.manager.execAll(command);
|
|
141
|
+
for (const res of r) {
|
|
142
|
+
results.push(`${green(`[${res.nodeId}]`)} ${res.stdout}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const result = await this.manager.exec(target, command);
|
|
147
|
+
results.push(`${green(`[${result.nodeId}]`)} ${result.stdout}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return results;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function formatClaudeResponse(response) {
|
|
155
|
+
return `${cyan('┌─ Claude')}\n${dim('│')} ${response.split('\n').join(`\n${dim('│')} `)}\n${cyan('└─')}`;
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=integration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.js","sourceRoot":"","sources":["../../src/claude/integration.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,gEAAgE;AAChE,0FAA0F;AAC1F,iFAAiF;AAEjF,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAEjE,MAAM,OAAO,iBAAiB;IACpB,OAAO,CAAc;IACrB,SAAS,GAAkB,IAAI,CAAC;IAExC,YAAY,OAAoB;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,UAAkB;QACnC,MAA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3
|
+
// NOTE: Uses manager.exec() which is SSH2 client channel, not child_process
|
|
4
|
+
import { getDefaultNodeForTask, findNode } from '../protocol/config.js';
|
|
5
|
+
export async function openBrowser(manager, url, nodeId) {
|
|
6
|
+
const target = nodeId ?? getDefaultNodeForTask('browser');
|
|
7
|
+
const node = findNode(target);
|
|
8
|
+
if (!node)
|
|
9
|
+
return `Unknown node: ${target}`;
|
|
10
|
+
if (!manager.isConnected(node.id)) {
|
|
11
|
+
return `Node ${node.id} is offline`;
|
|
12
|
+
}
|
|
13
|
+
// Build open command based on OS — runs on remote node via SSH
|
|
14
|
+
const openCmd = node.os === 'windows'
|
|
15
|
+
? `cmd.exe /c start "" "${url}"`
|
|
16
|
+
: `xdg-open "${url}" 2>/dev/null || sensible-browser "${url}" 2>/dev/null || firefox "${url}" 2>/dev/null || chromium-browser "${url}" 2>/dev/null &`;
|
|
17
|
+
const result = await manager.exec(node.id, openCmd);
|
|
18
|
+
if (result.code !== 0 && result.stderr) {
|
|
19
|
+
return `Failed to open browser on ${node.id}: ${result.stderr}`;
|
|
20
|
+
}
|
|
21
|
+
return `Opened ${url} on ${node.id}`;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/commands/browser.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,0EAA0E;AAC1E,4EAA4E;AAG5E,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAExE,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAoB,EACpB,GAAW,EACX,MAAe;IAEf,MAAM,MAAM,GAAG,MAAM,IAAI,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9B,IAAI,CAAC,IAAI;QAAE,OAAO,iBAAiB,MAAM,EAAE,CAAC;IAE5C,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QAClC,OAAO,QAAQ,IAAI,CAAC,EAAE,aAAa,CAAC;IACtC,CAAC;IAED,+DAA+D;IAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,KAAK,SAAS;QACnC,CAAC,CAAC,wBAAwB,GAAG,GAAG;QAChC,CAAC,CAAC,aAAa,GAAG,sCAAsC,GAAG,6BAA6B,GAAG,sCAAsC,GAAG,iBAAiB,CAAC;IAExJ,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACpD,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QACvC,OAAO,6BAA6B,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;IAClE,CAAC;IACD,OAAO,UAAU,GAAG,OAAO,IAAI,CAAC,EAAE,EAAE,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NodeManager } from '../nodes/manager.js';
|
|
2
|
+
import type { TransferEngine } from '../nodes/transfer.js';
|
|
3
|
+
export declare function setTransferEngine(engine: TransferEngine): void;
|
|
4
|
+
export declare function handleBuiltin(name: string, args: string[], raw: string, manager: NodeManager): Promise<string>;
|