@serkanalgur/opencode-nexus 1.0.5 → 1.2.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 +296 -248
- package/dist/index.js +2294 -432
- package/dist/tui.js +328 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
**Adaptive Multi-Agent Orchestration with Cost Intelligence**
|
|
11
11
|
|
|
12
|
-
[Installation](#installation) • [Quick Start](#quick-start) • [Features](#features) • [
|
|
12
|
+
[Installation](#installation) • [Quick Start](#quick-start) • [Features](#features) • [TUI Commands](#tui-commands) • [Tools](#tools) • [Configuration](#configuration) • [Development](#development) • [Contributing](#contributing)
|
|
13
13
|
|
|
14
14
|
</div>
|
|
15
15
|
|
|
@@ -17,18 +17,23 @@
|
|
|
17
17
|
|
|
18
18
|
## What is OpenCode Nexus?
|
|
19
19
|
|
|
20
|
-
OpenCode Nexus is
|
|
20
|
+
OpenCode Nexus is an agent orchestration plugin for [OpenCode V2](https://opencode.ai) that spawns **real sub-agent sessions** with **cost-aware routing**, **DAG-based task execution**, **self-healing**, and a **TUI dashboard**.
|
|
21
21
|
|
|
22
|
-
###
|
|
22
|
+
### Key Capabilities
|
|
23
23
|
|
|
24
|
-
|
|
|
25
|
-
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
24
|
+
| Capability | Description |
|
|
25
|
+
|------------|-------------|
|
|
26
|
+
| **Real Sessions** | Each agent runs in its own OpenCode session via `ctx.session.create()` |
|
|
27
|
+
| **Role-Based Agents** | Architect, Coder, Reviewer, Tester, Explorer, Documenter — each with specialized prompts |
|
|
28
|
+
| **DAG Execution** | Tasks are parallelized based on dependency graphs with priority queuing |
|
|
29
|
+
| **Cost-Aware Routing** | Scores models by quality/cost/speed, selects optimal per task complexity |
|
|
30
|
+
| **Self-Healing** | Retries with exponential backoff, context transfer, escalation policies |
|
|
31
|
+
| **Web Dashboard** | Real-time monitoring via HTTP + WebSocket server on port 4747 |
|
|
32
|
+
| **TUI Dashboard** | Monitor agents, budget, and config from the terminal |
|
|
33
|
+
| **Persistent Memory** | SQLite-backed memory store with TTL and search |
|
|
34
|
+
| **Learning Module** | Pattern recognition from failures, confidence scoring |
|
|
35
|
+
| **JSONC Config** | Read/write project and global config files with comments |
|
|
36
|
+
| **Slash Commands** | `/nexus`, `/nexus-dashboard`, `/nexus-model`, and more |
|
|
32
37
|
|
|
33
38
|
---
|
|
34
39
|
|
|
@@ -57,7 +62,33 @@ Or manually add to `~/.config/opencode/opencode.json`:
|
|
|
57
62
|
|
|
58
63
|
## Quick Start
|
|
59
64
|
|
|
60
|
-
### 1.
|
|
65
|
+
### 1. Configure Agent Models
|
|
66
|
+
|
|
67
|
+
Press **Ctrl+N** or type `/nexus` to open the configuration dialog and select models for each agent role.
|
|
68
|
+
|
|
69
|
+
### 2. Use Slash Commands
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
/nexus # Open full configuration
|
|
73
|
+
/nexus config # Configure models & budget
|
|
74
|
+
/nexus status # Show config summary
|
|
75
|
+
/nexus dashboard # Show dashboard
|
|
76
|
+
/nexus model # Select model for a role
|
|
77
|
+
/nexus reset # Reset to defaults
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 3. Spawn Agents via Tools
|
|
81
|
+
|
|
82
|
+
From any agent prompt, use the nexus tools:
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
Use the nexus.spawn tool to create a coder agent for implementing JWT auth
|
|
86
|
+
Use the nexus.status tool to check orchestrator state
|
|
87
|
+
Use the nexus.agents tool to list all spawned agents
|
|
88
|
+
Use the nexus.costs tool to see cost breakdown
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 4. Programmatic Usage
|
|
61
92
|
|
|
62
93
|
```typescript
|
|
63
94
|
import { NexusOrchestrator } from '@serkanalgur/opencode-nexus'
|
|
@@ -66,7 +97,13 @@ const orchestrator = new NexusOrchestrator({
|
|
|
66
97
|
budget: { maxTotalCost: 10.00 }
|
|
67
98
|
})
|
|
68
99
|
|
|
69
|
-
//
|
|
100
|
+
// Initialize with OpenCode context (done automatically by plugin)
|
|
101
|
+
orchestrator.initialize(ctx)
|
|
102
|
+
|
|
103
|
+
// Spawn a real agent session
|
|
104
|
+
const agent = await orchestrator.spawnAgent({ role: 'coder' })
|
|
105
|
+
|
|
106
|
+
// Execute tasks in DAG
|
|
70
107
|
const result = await orchestrator.execute({
|
|
71
108
|
tasks: [
|
|
72
109
|
{
|
|
@@ -79,17 +116,6 @@ const result = await orchestrator.execute({
|
|
|
79
116
|
files: { include: ['src/auth/**'] },
|
|
80
117
|
priority: 'high',
|
|
81
118
|
status: 'pending'
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
id: 'task-2',
|
|
85
|
-
name: 'Write tests',
|
|
86
|
-
description: 'Add unit tests for auth',
|
|
87
|
-
requiredRole: 'tester',
|
|
88
|
-
complexity: { overall: 30, factors: { fileCount: 2, codeLines: 150, dependencyDepth: 1, domainKnowledge: 20, riskLevel: 'low' } },
|
|
89
|
-
dependencies: ['task-1'],
|
|
90
|
-
files: { include: ['tests/auth/**'] },
|
|
91
|
-
priority: 'normal',
|
|
92
|
-
status: 'pending'
|
|
93
119
|
}
|
|
94
120
|
]
|
|
95
121
|
})
|
|
@@ -97,149 +123,249 @@ const result = await orchestrator.execute({
|
|
|
97
123
|
console.log(`Completed in ${result.totalDuration}ms, cost: $${result.totalCost}`)
|
|
98
124
|
```
|
|
99
125
|
|
|
100
|
-
|
|
126
|
+
---
|
|
101
127
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
/nexus costs # Show cost breakdown
|
|
106
|
-
/nexus pause # Pause execution
|
|
107
|
-
/nexus resume # Resume execution
|
|
108
|
-
/nexus dashboard # Open web dashboard
|
|
109
|
-
```
|
|
128
|
+
## Features
|
|
129
|
+
|
|
130
|
+
### Real OpenCode Sessions
|
|
110
131
|
|
|
111
|
-
|
|
132
|
+
Each agent runs in its own OpenCode session with the correct model and role-specific system prompt:
|
|
112
133
|
|
|
113
134
|
```typescript
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
topic: 'architecture',
|
|
120
|
-
metadata: { priority: 'high', requiresResponse: false }
|
|
135
|
+
// Creates a real OpenCode session with descriptive title
|
|
136
|
+
const session = await ctx.session.create({
|
|
137
|
+
title: '💻 Coder — anthropic/claude-sonnet-4-6',
|
|
138
|
+
agent: 'build',
|
|
139
|
+
model: { providerID: 'anthropic', id: 'claude-sonnet-4-6' }
|
|
121
140
|
})
|
|
122
141
|
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
from: 'reviewer',
|
|
126
|
-
type: 'review-completed',
|
|
127
|
-
payload: { approved: true, comments: [...] },
|
|
128
|
-
metadata: { priority: 'normal', requiresResponse: true }
|
|
129
|
-
})
|
|
142
|
+
// Sends the task prompt
|
|
143
|
+
await ctx.session.prompt({ sessionID: session.id, text: 'You are a senior software engineer...' })
|
|
130
144
|
```
|
|
131
145
|
|
|
132
|
-
|
|
146
|
+
### Role-Specific System Prompts
|
|
133
147
|
|
|
134
|
-
|
|
148
|
+
Each agent role gets a specialized prompt:
|
|
149
|
+
|
|
150
|
+
| Role | Focus |
|
|
151
|
+
|------|-------|
|
|
152
|
+
| **Architect** | System design, architecture patterns, high-level decisions |
|
|
153
|
+
| **Coder** | Clean, efficient code following best practices |
|
|
154
|
+
| **Reviewer** | Code review for correctness, security, performance |
|
|
155
|
+
| **Tester** | Comprehensive tests, edge cases, quality assurance |
|
|
156
|
+
| **Explorer** | Codebase navigation, architecture analysis |
|
|
157
|
+
| **Documenter** | Clear technical documentation |
|
|
135
158
|
|
|
136
|
-
###
|
|
159
|
+
### Cost-Aware Model Selection
|
|
137
160
|
|
|
138
|
-
|
|
161
|
+
Nexus scores models by quality, cost, and speed — then picks the optimal one per task complexity:
|
|
139
162
|
|
|
140
163
|
```typescript
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
]
|
|
164
|
+
// High-complexity tasks favor quality models
|
|
165
|
+
// Low-complexity tasks favor cheap/fast models
|
|
166
|
+
// Budget remaining filters out unaffordable models
|
|
167
|
+
|
|
168
|
+
const result = orchestrator.selectBestModel('coder', complexityScore)
|
|
169
|
+
// → { provider: 'anthropic', model: 'claude-sonnet-4-6', overallScore: 0.82 }
|
|
148
170
|
```
|
|
149
171
|
|
|
150
|
-
###
|
|
172
|
+
### Self-Healing with Escalation
|
|
173
|
+
|
|
174
|
+
Failed tasks follow a 4-step escalation chain:
|
|
151
175
|
|
|
152
|
-
|
|
176
|
+
1. **Retry** — Exponential backoff (1s, 2s, 4s...)
|
|
177
|
+
2. **Respawn** — Collect context, spawn new agent with transferred state
|
|
178
|
+
3. **Fallback Model** — Try cheaper alternative model
|
|
179
|
+
4. **Alert** — Emit escalation event, mark as failed
|
|
153
180
|
|
|
154
181
|
```typescript
|
|
155
182
|
const orchestrator = new NexusOrchestrator({
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
183
|
+
selfHealing: {
|
|
184
|
+
enabled: true,
|
|
185
|
+
maxRetries: 3,
|
|
186
|
+
contextTransfer: true
|
|
160
187
|
}
|
|
161
188
|
})
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Web Dashboard
|
|
192
|
+
|
|
193
|
+
Real-time monitoring via embedded HTTP + WebSocket server:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Start dashboard
|
|
197
|
+
Use nexus.dashboard.start with port=4747
|
|
162
198
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
// - Remaining budget
|
|
166
|
-
// - Required quality level
|
|
199
|
+
# Open in browser
|
|
200
|
+
open http://localhost:4747
|
|
167
201
|
```
|
|
168
202
|
|
|
169
|
-
|
|
203
|
+
Features: Agent grid, cost tracker, DAG visualization, activity log, config panel.
|
|
170
204
|
|
|
171
|
-
|
|
205
|
+
### Persistent Memory
|
|
206
|
+
|
|
207
|
+
SQLite-backed memory store that survives restarts:
|
|
172
208
|
|
|
173
209
|
```typescript
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
210
|
+
orchestrator.memoryStore.set({
|
|
211
|
+
key: 'api-pattern',
|
|
212
|
+
value: { endpoint: '/users', method: 'GET' },
|
|
213
|
+
scope: 'project',
|
|
214
|
+
author: 'architect',
|
|
215
|
+
confidence: 0.9,
|
|
216
|
+
tags: ['api', 'design']
|
|
179
217
|
})
|
|
180
218
|
|
|
181
|
-
//
|
|
182
|
-
orchestrator.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
219
|
+
// Search across all memory
|
|
220
|
+
const results = orchestrator.memoryStore.search('api pattern')
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Learning Module
|
|
224
|
+
|
|
225
|
+
Records failure patterns and solutions, building confidence over time:
|
|
187
226
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
227
|
+
```typescript
|
|
228
|
+
// Automatically records failures during execution
|
|
229
|
+
// Finds similar past failures and suggests solutions
|
|
230
|
+
// Confidence increases with successful reuse
|
|
231
|
+
|
|
232
|
+
const solutions = orchestrator.learning.findSolutions('TypeScript TS2345 error')
|
|
233
|
+
// → [{ entry: { solution: 'Add type cast', confidence: 0.85 }, similarity: 0.7 }]
|
|
193
234
|
```
|
|
194
235
|
|
|
195
|
-
###
|
|
236
|
+
### JSONC Configuration
|
|
237
|
+
|
|
238
|
+
Read and write config files with comments:
|
|
239
|
+
|
|
240
|
+
```jsonc
|
|
241
|
+
// .opencode/nexus.jsonc (project-level)
|
|
242
|
+
{
|
|
243
|
+
// Agent models for each role
|
|
244
|
+
"models": {
|
|
245
|
+
"architect": "anthropic/claude-sonnet-4-6",
|
|
246
|
+
"coder": "opencode-go/mimo-v2.5"
|
|
247
|
+
},
|
|
248
|
+
"budget": { "maxTotalCost": 10.00 }
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Precedence: project > global > TUI > defaults.
|
|
253
|
+
|
|
254
|
+
### Preset Configurations
|
|
196
255
|
|
|
197
|
-
|
|
256
|
+
Quickly apply predefined configs:
|
|
257
|
+
|
|
258
|
+
| Preset | Models | Budget | Self-Healing |
|
|
259
|
+
|--------|--------|--------|--------------|
|
|
260
|
+
| **minimal** | Gemini Flash | $1 | Off |
|
|
261
|
+
| **balanced** | Claude/GPT mix | $10 | On (3 retries) |
|
|
262
|
+
| **enterprise** | Top-tier | $50 | On (5 retries) |
|
|
263
|
+
| **cost-optimized** | Cheapest | $3 | On (2 retries) |
|
|
264
|
+
|
|
265
|
+
### Composable Modules
|
|
266
|
+
|
|
267
|
+
Extend Nexus with custom modules:
|
|
198
268
|
|
|
199
269
|
```typescript
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
270
|
+
import { NexusPlugin } from '@serkanalgur/opencode-nexus'
|
|
271
|
+
|
|
272
|
+
NexusPlugin.register({
|
|
273
|
+
name: 'my-custom-module',
|
|
274
|
+
description: 'Custom feature',
|
|
275
|
+
version: '1.0.0',
|
|
276
|
+
setup: async (ctx) => { /* ... */ },
|
|
277
|
+
teardown: async () => { /* ... */ }
|
|
208
278
|
})
|
|
209
279
|
```
|
|
210
280
|
|
|
211
|
-
|
|
281
|
+
---
|
|
212
282
|
|
|
213
|
-
|
|
283
|
+
## TUI Commands
|
|
214
284
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
285
|
+
| Command | Alias | Description |
|
|
286
|
+
|---------|-------|-------------|
|
|
287
|
+
| `/nexus` | — | Open full configuration dialog |
|
|
288
|
+
| `/nexus config` | `/nc` | Configure models & budget |
|
|
289
|
+
| `/nexus dashboard` | `/nd` | Show dashboard with models, budget, commands |
|
|
290
|
+
| `/nexus model` | `/nm` | Select model for a role |
|
|
291
|
+
| `/nexus status` | `/ns` | Show config summary |
|
|
292
|
+
| `/nexus reset` | — | Reset all settings to defaults |
|
|
293
|
+
|
|
294
|
+
**Keyboard shortcut:** `Ctrl+N` opens the main configuration dialog.
|
|
295
|
+
|
|
296
|
+
---
|
|
221
297
|
|
|
222
|
-
|
|
223
|
-
|
|
298
|
+
## Tools
|
|
299
|
+
|
|
300
|
+
Register these tools in your agent prompts:
|
|
301
|
+
|
|
302
|
+
| Tool | Description | Input |
|
|
303
|
+
|------|-------------|-------|
|
|
304
|
+
| `nexus.status` | Orchestrator status | `{ detailed?: boolean }` |
|
|
305
|
+
| `nexus.agents` | List spawned agents | `{ filter?: string }` |
|
|
306
|
+
| `nexus.costs` | Cost report & budget | `{}` |
|
|
307
|
+
| `nexus.dashboard` | Full state for dashboard | `{}` |
|
|
308
|
+
| `nexus.spawn` | Spawn a sub-agent | `{ role: string, task: string, model?: string }` |
|
|
309
|
+
| `nexus.queue` | Show task queue with priorities | `{}` |
|
|
310
|
+
| `nexus.config.save` | Save config to disk | `{ level: 'project' \| 'global' }` |
|
|
311
|
+
| `nexus.config.init` | Initialize config files | `{ level: 'project' \| 'global' \| 'both' }` |
|
|
312
|
+
| `nexus.dashboard.start` | Start web dashboard | `{ port?: number, host?: string }` |
|
|
313
|
+
| `nexus.dashboard.stop` | Stop web dashboard | `{}` |
|
|
314
|
+
| `nexus.preset` | Apply preset config | `{ name: string }` |
|
|
315
|
+
| `nexus.template` | List/instantiate templates | `{ name?: string, baseDir?: string }` |
|
|
316
|
+
|
|
317
|
+
### Tool Examples
|
|
224
318
|
|
|
225
|
-
// Search memory
|
|
226
|
-
const results = orchestrator.searchMemory('event sourcing', 'project')
|
|
227
319
|
```
|
|
320
|
+
# Spawn a coder agent with complexity analysis
|
|
321
|
+
Use nexus.spawn with role="coder" and task="Implement JWT auth middleware"
|
|
322
|
+
# → 💻 Coder — anthropic/claude-sonnet-4-6
|
|
323
|
+
# → 📊 Complexity: 45/100 (low risk)
|
|
228
324
|
|
|
229
|
-
|
|
325
|
+
# Check status
|
|
326
|
+
Use nexus.status with detailed=true
|
|
230
327
|
|
|
231
|
-
|
|
328
|
+
# Apply a preset
|
|
329
|
+
Use nexus.preset with name="balanced"
|
|
232
330
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
331
|
+
# Initialize config
|
|
332
|
+
Use nexus.config.init with level="project"
|
|
333
|
+
|
|
334
|
+
# Start web dashboard
|
|
335
|
+
Use nexus.dashboard.start with port=4747
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## Configuration
|
|
341
|
+
|
|
342
|
+
### Agent Models (TUI)
|
|
343
|
+
|
|
344
|
+
Configure via `/nexus` or `Ctrl+N`:
|
|
345
|
+
|
|
346
|
+
```
|
|
347
|
+
🏗️ Architect: anthropic/claude-sonnet-4-6
|
|
348
|
+
💻 Coder: anthropic/claude-sonnet-4-6
|
|
349
|
+
🔍 Reviewer: openai/gpt-5-mini
|
|
350
|
+
🧪 Tester: anthropic/claude-haiku-4-5
|
|
351
|
+
🔬 Explorer: google/gemini-2.5-flash
|
|
352
|
+
📝 Documenter: anthropic/claude-haiku-4-5
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Budget
|
|
356
|
+
|
|
357
|
+
```
|
|
358
|
+
💰 Max Total: $10.00
|
|
359
|
+
Max Per Task: $1.00
|
|
360
|
+
Alert Threshold: 20%
|
|
361
|
+
```
|
|
241
362
|
|
|
242
|
-
|
|
363
|
+
### Self-Healing
|
|
364
|
+
|
|
365
|
+
```
|
|
366
|
+
🛡️ Enabled: ✅
|
|
367
|
+
Max Retries: 3
|
|
368
|
+
Context Transfer: ✅
|
|
243
369
|
```
|
|
244
370
|
|
|
245
371
|
---
|
|
@@ -248,132 +374,70 @@ const orchestrator = new NexusOrchestrator({
|
|
|
248
374
|
|
|
249
375
|
```
|
|
250
376
|
┌─────────────────────────────────────────────────────────────────┐
|
|
251
|
-
│ NEXUS
|
|
377
|
+
│ NEXUS PLUGIN │
|
|
252
378
|
│ │
|
|
253
|
-
│
|
|
254
|
-
│ │
|
|
255
|
-
│ │
|
|
256
|
-
│
|
|
257
|
-
│
|
|
258
|
-
│
|
|
259
|
-
│
|
|
379
|
+
│ ┌──────────────────────────────────────────────────┐ │
|
|
380
|
+
│ │ SERVER PLUGIN (index.ts) │ │
|
|
381
|
+
│ │ • 12 tool registrations (spawn, status, costs, │ │
|
|
382
|
+
│ │ dashboard, config, preset, template, queue) │ │
|
|
383
|
+
│ │ • Session hook for /nexus commands │ │
|
|
384
|
+
│ │ • State persistence to storage │ │
|
|
385
|
+
│ └──────────────────────────────────────────────────┘ │
|
|
386
|
+
│ │
|
|
387
|
+
│ ┌──────────────────────────────────────────────────┐ │
|
|
388
|
+
│ │ ORCHESTRATOR (orchestrator.ts) │ │
|
|
389
|
+
│ │ • Real OpenCode session creation │ │
|
|
390
|
+
│ │ • DAG-based task execution with priority │ │
|
|
391
|
+
│ │ • Cost-aware model routing (scored selection) │ │
|
|
392
|
+
│ │ • Self-healing with escalation policies │ │
|
|
393
|
+
│ │ • Context transfer to respawned agents │ │
|
|
394
|
+
│ │ • Cycle detection for deadlock prevention │ │
|
|
395
|
+
│ │ • Performance: lazy init, debounce, cleanup │ │
|
|
260
396
|
│ └──────────────────────────────────────────────────┘ │
|
|
261
397
|
│ │
|
|
262
398
|
│ ┌──────────────────────────────────────────────────┐ │
|
|
263
|
-
│ │
|
|
399
|
+
│ │ MODULES │ │
|
|
400
|
+
│ │ ┌────────────┐ ┌──────────┐ ┌────────────────┐ │ │
|
|
401
|
+
│ │ │ Health │ │ Learning │ │ Message Store │ │ │
|
|
402
|
+
│ │ │ Monitor │ │ Module │ │ (JSONL+SQLite) │ │ │
|
|
403
|
+
│ │ └────────────┘ └──────────┘ └────────────────┘ │ │
|
|
404
|
+
│ │ ┌────────────┐ ┌──────────┐ ┌────────────────┐ │ │
|
|
405
|
+
│ │ │ Persistent │ │ Fan-Out │ │ Notifications │ │ │
|
|
406
|
+
│ │ │ Memory │ │ Router │ │ (OS native) │ │ │
|
|
407
|
+
│ │ └────────────┘ └──────────┘ └────────────────┘ │ │
|
|
408
|
+
│ │ ┌────────────┐ ┌──────────┐ │ │
|
|
409
|
+
│ │ │ State │ │ Module │ │ │
|
|
410
|
+
│ │ │ Broadcaster│ │ Registry │ │ │
|
|
411
|
+
│ │ └────────────┘ └──────────┘ │ │
|
|
264
412
|
│ └──────────────────────────────────────────────────┘ │
|
|
265
413
|
│ │
|
|
266
414
|
│ ┌──────────────────────────────────────────────────┐ │
|
|
267
|
-
│ │
|
|
415
|
+
│ │ WEB DASHBOARD │ │
|
|
416
|
+
│ │ • Bun.serve() HTTP + WebSocket (port 4747) │ │
|
|
417
|
+
│ │ • REST: /api/state, /api/config, /api/agents │ │
|
|
418
|
+
│ │ • WebSocket: /ws/events (real-time updates) │ │
|
|
419
|
+
│ │ • SPA: Agent grid, DAG viz, cost tracker │ │
|
|
268
420
|
│ └──────────────────────────────────────────────────┘ │
|
|
269
421
|
│ │
|
|
270
422
|
│ ┌──────────────────────────────────────────────────┐ │
|
|
271
|
-
│ │
|
|
423
|
+
│ │ CONFIG │ │
|
|
424
|
+
│ │ • JSONC file loading (project + global) │ │
|
|
425
|
+
│ │ • Config creation and initialization │ │
|
|
426
|
+
│ │ • Preset configurations (4 presets) │ │
|
|
427
|
+
│ │ • Task templates (feature, bugfix, refactor) │ │
|
|
428
|
+
│ └──────────────────────────────────────────────────┘ │
|
|
429
|
+
│ │
|
|
430
|
+
│ ┌──────────────────────────────────────────────────┐ │
|
|
431
|
+
│ │ TUI PLUGIN (tui.tsx) │ │
|
|
432
|
+
│ │ • /nexus slash commands │ │
|
|
433
|
+
│ │ • Configuration dialogs (model selection) │ │
|
|
434
|
+
│ │ • Keyboard shortcut (Ctrl+N) │ │
|
|
272
435
|
│ └──────────────────────────────────────────────────┘ │
|
|
273
436
|
└─────────────────────────────────────────────────────────────────┘
|
|
274
437
|
```
|
|
275
438
|
|
|
276
439
|
---
|
|
277
440
|
|
|
278
|
-
## Configuration
|
|
279
|
-
|
|
280
|
-
### Global Config
|
|
281
|
-
|
|
282
|
-
```jsonc
|
|
283
|
-
// ~/.config/opencode/nexus.jsonc
|
|
284
|
-
{
|
|
285
|
-
"$schema": "https://serkanalgur.com/opencode-nexus/schema.json",
|
|
286
|
-
|
|
287
|
-
"maxConcurrency": 5,
|
|
288
|
-
"budget": {
|
|
289
|
-
"maxTotalCost": 10.00,
|
|
290
|
-
"maxCostPerTask": 1.00,
|
|
291
|
-
"alertThreshold": 0.2
|
|
292
|
-
},
|
|
293
|
-
"selfHealing": {
|
|
294
|
-
"enabled": true,
|
|
295
|
-
"maxRetries": 3,
|
|
296
|
-
"contextTransfer": true
|
|
297
|
-
},
|
|
298
|
-
"communication": {
|
|
299
|
-
"mode": "pubsub",
|
|
300
|
-
"persistence": true
|
|
301
|
-
},
|
|
302
|
-
"dashboard": {
|
|
303
|
-
"enabled": true,
|
|
304
|
-
"port": 4747
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
### Project Config
|
|
310
|
-
|
|
311
|
-
```jsonc
|
|
312
|
-
// .opencode/nexus.jsonc
|
|
313
|
-
{
|
|
314
|
-
"budget": {
|
|
315
|
-
"maxTotalCost": 5.00
|
|
316
|
-
},
|
|
317
|
-
"agentRoles": {
|
|
318
|
-
"security-reviewer": {
|
|
319
|
-
"model": "anthropic/claude-sonnet-4-6",
|
|
320
|
-
"tools": ["read", "grep", "git"]
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
---
|
|
327
|
-
|
|
328
|
-
## API Reference
|
|
329
|
-
|
|
330
|
-
### NexusOrchestrator
|
|
331
|
-
|
|
332
|
-
```typescript
|
|
333
|
-
class NexusOrchestrator {
|
|
334
|
-
// Core
|
|
335
|
-
execute(request: ExecutionRequest): Promise<ExecutionResult>
|
|
336
|
-
spawnAgent(config: SpawnConfig): Promise<Agent>
|
|
337
|
-
terminateAgent(agentId: string): Promise<void>
|
|
338
|
-
|
|
339
|
-
// Communication
|
|
340
|
-
publish(topic: string, message: AgentMessage): void
|
|
341
|
-
subscribe(topic: string, handler: Function): Unsubscribe
|
|
342
|
-
send(agentId: string, message: AgentMessage): void
|
|
343
|
-
|
|
344
|
-
// Memory
|
|
345
|
-
setMemory(scope: MemoryScope, key: string, value: unknown, author: string): void
|
|
346
|
-
getMemory(scope: MemoryScope, key: string): MemoryEntry | undefined
|
|
347
|
-
searchMemory(query: string, scope?: MemoryScope): MemoryEntry[]
|
|
348
|
-
|
|
349
|
-
// Query
|
|
350
|
-
getStatus(detailed?: boolean): string
|
|
351
|
-
listAgents(filter?: string): string
|
|
352
|
-
getCostReport(): string
|
|
353
|
-
|
|
354
|
-
// Control
|
|
355
|
-
pause(): void
|
|
356
|
-
resume(): void
|
|
357
|
-
shutdown(): void
|
|
358
|
-
|
|
359
|
-
// Events
|
|
360
|
-
on(event: string, handler: Function): Unsubscribe
|
|
361
|
-
}
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
### Tools
|
|
365
|
-
|
|
366
|
-
| Tool | Description | Parameters |
|
|
367
|
-
|------|-------------|------------|
|
|
368
|
-
| `nexus_status` | Get orchestrator status | `{ detailed?: boolean }` |
|
|
369
|
-
| `nexus_agents` | List all agents | `{ filter?: string }` |
|
|
370
|
-
| `nexus_costs` | Get cost report | `{}` |
|
|
371
|
-
| `nexus_memory_get` | Get shared memory | `{ scope: string, key: string }` |
|
|
372
|
-
| `nexus_memory_set` | Set shared memory | `{ scope: string, key: string, value: unknown }` |
|
|
373
|
-
| `nexus_send` | Send message to agent | `{ to: string, message: AgentMessage }` |
|
|
374
|
-
|
|
375
|
-
---
|
|
376
|
-
|
|
377
441
|
## Development
|
|
378
442
|
|
|
379
443
|
```bash
|
|
@@ -390,28 +454,12 @@ bun run build
|
|
|
390
454
|
# Run tests
|
|
391
455
|
bun test
|
|
392
456
|
|
|
393
|
-
#
|
|
394
|
-
|
|
457
|
+
# Type check
|
|
458
|
+
npx tsc --noEmit
|
|
395
459
|
```
|
|
396
460
|
|
|
397
461
|
---
|
|
398
462
|
|
|
399
|
-
## Benchmarks
|
|
400
|
-
|
|
401
|
-
| Scenario | Sequential | Swarm | Ensemble | **Nexus** |
|
|
402
|
-
|----------|-----------|-------|----------|-----------|
|
|
403
|
-
| 3 independent tasks | 300s | 120s | 100s | **60s** |
|
|
404
|
-
| Dependent chain (3) | 300s | 150s | 150s | **120s** |
|
|
405
|
-
| Mixed parallel+serial | 300s | 130s | 110s | **70s** |
|
|
406
|
-
|
|
407
|
-
| Metric | Swarm | **Nexus** |
|
|
408
|
-
|--------|-------|-----------|
|
|
409
|
-
| Tokens per task | 15,000 | **8,000** |
|
|
410
|
-
| Agent overhead | 19 fixed | **Dynamic 2-5** |
|
|
411
|
-
| Cost per session | $10 | **$4** |
|
|
412
|
-
|
|
413
|
-
---
|
|
414
|
-
|
|
415
463
|
## Contributing
|
|
416
464
|
|
|
417
465
|
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.
|