opencode-orchestrator 1.0.7 → 1.0.11
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 +95 -69
- package/dist/agents/prompts/common/hyper-parallel.d.ts +4 -0
- package/dist/agents/prompts/common/index.d.ts +1 -0
- package/dist/core/agents/interfaces/launch-input.interface.d.ts +2 -0
- package/dist/core/agents/interfaces/parallel-task.interface.d.ts +2 -0
- package/dist/core/agents/manager/event-handler.d.ts +2 -1
- package/dist/core/agents/manager/task-poller.d.ts +2 -1
- package/dist/core/agents/manager.d.ts +1 -0
- package/dist/index.js +116 -22
- package/dist/shared/message/constants/slash-commands.d.ts +2 -2
- package/dist/shared/task/constants/parallel-task.d.ts +8 -3
- package/dist/tools/parallel/delegate-task.d.ts +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
<img src="assets/logo.png" alt="logo" width="280" />
|
|
3
3
|
<h1>OpenCode Orchestrator</h1>
|
|
4
4
|
|
|
5
|
+
<p><b>Next-Gen Autonomous Mastery: Powered by HPFA™ & MSVP™</b></p>
|
|
6
|
+
<p><i>Redefining Scalability with Fractal Swarm Intelligence and Multi-Stage Integrity</i></p>
|
|
7
|
+
|
|
5
8
|
[](LICENSE)
|
|
6
9
|
[](https://www.npmjs.com/package/opencode-orchestrator)
|
|
7
10
|
[]()
|
|
8
11
|
</div>
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
---
|
|
12
14
|
|
|
13
15
|
## ⚡ Quick Start
|
|
14
16
|
|
|
@@ -16,20 +18,28 @@
|
|
|
16
18
|
npm install -g opencode-orchestrator
|
|
17
19
|
```
|
|
18
20
|
|
|
19
|
-
Then in OpenCode:
|
|
21
|
+
Then in OpenCode, launch your mission:
|
|
20
22
|
```bash
|
|
21
|
-
/
|
|
23
|
+
/swarm "Architect and Build a Diablo-like Web Game"
|
|
22
24
|
```
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
### 🌌 **The End of Sequential Limits. The Era of Fractal Mastery.**
|
|
27
|
+
|
|
28
|
+
Where traditional agents hit a sequential wall, we deploy a fractal swarm. OpenCode Orchestrator is the world's most advanced autonomous engineering platform—a **Titan-Class Execution Engine** designed to conquer missions that break conventional AI.
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
By fusing **Fractal Swarm Intelligence (HPFA™)** with **Continuous Multi-Stage Verification Pipeline (MSVP™)**, it delivers a level of scale, velocity, and architectural absolute previously considered impossible. Welcome to the final form of autonomous development. No bottlenecks. No limits. Only pure execution.
|
|
27
31
|
|
|
28
|
-
- **🔄 Continuous Operation (WAL)**: Mission continuity is guaranteed via Write-Ahead Logging. Even after a system crash, the orchestrator "replays" its history from disk to resume complex tasks exactly where they left off.
|
|
29
|
-
- **⚡ 80% Resource Efficiency**: Smart intent-based polling and output caching reduce API overhead by 60-80%. The system intelligently filters redundant traffic, ensuring extreme agility even under heavy multi-agent load.
|
|
30
|
-
- **🧬 Self-Scaling Intelligence**: Real-time success/failure feedback dynamic concurrency. The system learns model reliability and rate limits on the fly, autonomously balancing execution speed with fail-safe stability.
|
|
31
|
-
- **💎 Zero-Leak Architecture**: Rigorous, lifecycle-based resource management ensures 100% memory reclamation. Engineered for sessions lasting 10,000+ iterations without a single byte of memory drift.
|
|
32
32
|
|
|
33
|
+
## 💎 The Four Pillars of Excellence
|
|
34
|
+
|
|
35
|
+
We’ve combined industrial-grade reliability with cutting-edge parallel intelligence to redefine what’s possible in AI coding.
|
|
36
|
+
|
|
37
|
+
* **⚡ Velocity**: Parallelize up to 50 concurrent sessions. What takes hours for others is finished in minutes through **Cognitive Elasticity**.
|
|
38
|
+
* **🧬 Scale**: **Fractal Delegation** allows workers to recursively spawn their own sub-agents. No task is too big for a system that can replicate its own intelligence.
|
|
39
|
+
* **🛡️ Safety**: Our **MSVP (Multi-Stage Verification Pipeline)** reviews every line of code in parallel "Shadow Sessions" before it ever touches your build.
|
|
40
|
+
* **♾️ Trust**: **Iron-Clad Reliability** via Write-Ahead Logging (WAL). Even after a crash, the system replays its history to resume exactly where it was.
|
|
41
|
+
|
|
42
|
+
---
|
|
33
43
|
|
|
34
44
|
## ⭐ Core Philosophy
|
|
35
45
|
|
|
@@ -63,73 +73,90 @@ Built for "Infinite Missions," the OpenCode Orchestrator is engineered to handle
|
|
|
63
73
|
| 🤝 **Specialized Roles** | Each agent has a clear, focused responsibility |
|
|
64
74
|
|
|
65
75
|
|
|
66
|
-
## 🏛️
|
|
76
|
+
## 🏛️ Hyper-Parallel Architecture: HPFA & MSVP
|
|
77
|
+
|
|
78
|
+
The orchestrator eliminates the linear reasoning bottleneck of conventional AI agents by shifting from sequential execution to a **Distributed Runtime Unit** paradigm.
|
|
79
|
+
|
|
80
|
+
### 🧬 **HPFA™ (Hyper-Parallel Fractal Architecture)**
|
|
81
|
+
HPFA defines a recursive problem-solving model that decomposes massive codebases into atomic task units through a fractal hierarchy.
|
|
82
|
+
* **Fractal Delegation**: Workers are instantiated as autonomous controllers with localized `TaskLauncher` contexts. This enables recursive spawning of sub-agents up to 8 levels deep, mapping complex architectural hierarchies into a parallel execution grid.
|
|
83
|
+
* **Cognitive Concurrency Control**: A dedicated state-machine manages up to 50 concurrent sessions. It monitors success/failure trajectories to dynamically scale concurrency slots, ensuring maximum throughput while maintaining strict rate-limit compliance.
|
|
84
|
+
|
|
85
|
+
### 🛡️ **MSVP™ (Multi-Stage Verification Pipeline)**
|
|
86
|
+
MSVP ensures continuous integration integrity by decoupling verification from the implementation lifecycle, treating code review as a parallel background-thread.
|
|
87
|
+
* **Shadow Review Pipeline**: Upon every file-write operation, a parallel reviewer session is instantly snapshotted (Unit-level Verification). This zero-latency audit identifies defects the millisecond they are introduced, without blocking the primary implementation thread.
|
|
88
|
+
* **Global Barrier-Sync Protocol**: Implements a synchronized verification gate. The system enforces a blocking "Barrier" that requires consistency across all distributed units before transitioning to the final Master Review (E2E Integration) and Mission Sealing.
|
|
67
89
|
|
|
68
90
|
```
|
|
69
|
-
/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
│
|
|
91
|
+
/swarm "Build Complex System"
|
|
92
|
+
│
|
|
93
|
+
╔═══════════════════════════════════════╗
|
|
94
|
+
║ 🎯 COMMANDER — Orchestrator ║
|
|
95
|
+
║ (Main Session - Single) ║
|
|
96
|
+
╚═══════════════════╤═══════════════════╝
|
|
97
|
+
│
|
|
98
|
+
┌───────────────────▼───────────────────┐
|
|
99
|
+
│ 📋 PLANNER — Create Plan │
|
|
100
|
+
│ → Outputs: Architectural Grid │
|
|
101
|
+
└───────────────────┬───────────────────┘
|
|
102
|
+
│
|
|
82
103
|
══════════════════════════╧══════════════════════════
|
|
83
|
-
║
|
|
84
|
-
══════════════════════════════════════════════════════
|
|
85
|
-
│ │ │
|
|
86
|
-
▼ ▼ ▼
|
|
87
|
-
┌──────────┐ ┌──────────┐ ┌──────────┐
|
|
88
|
-
│ 🔨 WORKER│ │ 🔨 WORKER│ │ 🔨 WORKER│ ← Up to 50
|
|
89
|
-
│ Task 1 │ │ Task 2 │ │ Task 3 │ concurrent
|
|
90
|
-
│ auth.ts │ │ api.ts │ │ db.ts │ sessions
|
|
91
|
-
└────┬─────┘ └────┬─────┘ └────┬─────┘
|
|
92
|
-
│ │ │
|
|
104
|
+
║ 🔥 HPFA PARALLEL GRID (MSVP) ║
|
|
93
105
|
══════════════════════════════════════════════════════
|
|
94
|
-
|
|
106
|
+
│ │ │ │
|
|
107
|
+
▼ ▼ ▼ ▼
|
|
108
|
+
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
|
|
109
|
+
│🔨 WORKER │ │🔨 WORKER │ │🔨 WORKER │ │🔨 WORKER │ <-- Fractal Spawning
|
|
110
|
+
│ Module A │ │ Module B │ │ Module C │ │ Module D │
|
|
111
|
+
└────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘
|
|
112
|
+
│ ⚡ Instant │ ⚡ Instant │ ⚡ Instant │ ⚡ Instant
|
|
113
|
+
▼ Review ▼ Review ▼ Review ▼ Review
|
|
114
|
+
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
|
|
115
|
+
│✅ REVIEWR│ │✅ REVIEWR│ │✅ REVIEWR│ │✅ REVIEWR│ <-- Stage 1: Unit
|
|
116
|
+
│ (Unit-A) │ │ (Unit-B) │ │ (Unit-C) │ │ (Unit-D) │ Verification
|
|
117
|
+
└────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘
|
|
118
|
+
│ │ │ │
|
|
119
|
+
═▼═══════════════▼═══════════════▼═══════════════▼════
|
|
120
|
+
║ ⏳ SYNC BARRIER ║
|
|
95
121
|
══════════════════════════════════════════════════════
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
Commander)
|
|
122
|
+
│
|
|
123
|
+
┌───────────────────▼───────────────────┐
|
|
124
|
+
│ ✅ MASTER REVIEWER — Final Pass │
|
|
125
|
+
│ (Cross-module Integration) │
|
|
126
|
+
│ → Stage 2: E2E & System Integrity │
|
|
127
|
+
└───────────────────┬───────────────────┘
|
|
128
|
+
│
|
|
129
|
+
┌─────────┴─────────┐
|
|
130
|
+
│ Seal Conditions │
|
|
131
|
+
│ Verified? │
|
|
132
|
+
└─────────┬─────────┘
|
|
133
|
+
No ↙ ↘ Yes
|
|
134
|
+
♻️ LOOP 🎖️ MISSION
|
|
135
|
+
(Adaptive) SEALED
|
|
111
136
|
```
|
|
112
137
|
|
|
113
|
-
### Execution Model
|
|
138
|
+
### Execution Model (MSVP)
|
|
114
139
|
|
|
115
|
-
| Phase | Agent | Parallelism |
|
|
116
|
-
|
|
117
|
-
| 1️⃣ Plan | Planner | **Single** |
|
|
118
|
-
| 2️⃣
|
|
119
|
-
| 3️⃣
|
|
120
|
-
| 4️⃣
|
|
140
|
+
| Phase | Agent | Parallelism | Verification Level |
|
|
141
|
+
|:------|:------|:------------|:-------------------|
|
|
142
|
+
| 1️⃣ Plan | Planner | **Single** | Static Analysis |
|
|
143
|
+
| 2️⃣ Implement | Workers | **HPFA Parallel** | Direct Coding |
|
|
144
|
+
| 3️⃣ Unit Pass | Reviewers | **Shadow Parallel** | **1차 리뷰**: Unit Tests (Async) |
|
|
145
|
+
| 4️⃣ Final Sync | Barrier | **Blocking** | All Units Verified |
|
|
146
|
+
| 5️⃣ Integration | Master Reviewer | **Single** | **2차 리뷰**: Full E2E & Sync |
|
|
121
147
|
|
|
122
148
|
## Features
|
|
123
149
|
|
|
124
150
|
| Feature | What It Does |
|
|
125
151
|
|:---------|:-------------|
|
|
126
|
-
| 🚀 **
|
|
127
|
-
|
|
|
128
|
-
|
|
|
129
|
-
|
|
|
130
|
-
|
|
|
131
|
-
|
|
|
132
|
-
|
|
|
152
|
+
| 🚀 **MSVP™ Pipeline** | Zero-latency unit reviews triggered the millisecond code is written |
|
|
153
|
+
| 🧬 **Fractal Spawning** | Workers recursively spawn sub-agents for infinite structural depth |
|
|
154
|
+
| ⚡ **50 Parallel Tasks** | Titan-class density—run massive swarms without breaking a sweat |
|
|
155
|
+
| 🔄 **Non-Stop Recovery** | WAL-powered cognitive persistence; resumes instantly after any crash |
|
|
156
|
+
| 🔥 **Multi-File Ops** | Massive parallel edits with cross-file context integrity |
|
|
157
|
+
| 🛡️ **Self-Scaling** | Dynamic AI-driven concurrency management based on success velocity |
|
|
158
|
+
| 🩹 **Memory Integrity** | 100% reclamation; engineered for sessions with 10k+ iterations |
|
|
159
|
+
| 🏗️ **Clean-Code Engine**| Enforces industrial modularity and clean architectural patterns |
|
|
133
160
|
|
|
134
161
|
---
|
|
135
162
|
|
|
@@ -145,14 +172,13 @@ Built for "Infinite Missions," the OpenCode Orchestrator is engineered to handle
|
|
|
145
172
|
| 🔨 Build failure | Fix the issue and retry |
|
|
146
173
|
|
|
147
174
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
- **[System Architecture](docs/SYSTEM_ARCHITECTURE.md)** — Full technical deep-dive
|
|
151
|
-
|
|
175
|
+
---
|
|
152
176
|
|
|
153
177
|
## 🎹 Developer's Words
|
|
154
178
|
|
|
155
|
-
>
|
|
179
|
+
> "We are not just building a tool; we are building an autonomous engineer that can evolve with the project. HPFA and MSVP are the heart of this evolution—turning AI from a chatbot into a high-performance execution engine."
|
|
180
|
+
>
|
|
181
|
+
> [Read the full Developer's Note →](docs/DEVELOPERS_NOTE.md)
|
|
156
182
|
|
|
157
183
|
|
|
158
184
|
## 📄 License
|
|
@@ -13,3 +13,4 @@ export { CORE_PHILOSOPHY } from "./core-philosophy.js";
|
|
|
13
13
|
export { SHARED_LSP_TOOLS } from "./lsp.js";
|
|
14
14
|
export { SHARED_AST_TOOLS } from "./ast.js";
|
|
15
15
|
export { MODULARITY_ENFORCEMENT } from "./modularity.js";
|
|
16
|
+
export { HYPER_PARALLEL_ENFORCEMENT } from "./hyper-parallel.js";
|
|
@@ -14,7 +14,8 @@ export declare class EventHandler {
|
|
|
14
14
|
private notifyParentIfAllComplete;
|
|
15
15
|
private scheduleCleanup;
|
|
16
16
|
private validateSessionHasOutput;
|
|
17
|
-
|
|
17
|
+
private onTaskComplete?;
|
|
18
|
+
constructor(client: OpencodeClient, store: TaskStore, concurrency: ConcurrencyController, findBySession: (sessionID: string) => ParallelTask | undefined, notifyParentIfAllComplete: (parentSessionID: string) => Promise<void>, scheduleCleanup: (taskId: string) => void, validateSessionHasOutput: (sessionID: string) => Promise<boolean>, onTaskComplete?: ((task: ParallelTask) => void | Promise<void>) | undefined);
|
|
18
19
|
/**
|
|
19
20
|
* Handle OpenCode session events for proper resource cleanup.
|
|
20
21
|
* Call this from your plugin's event hook.
|
|
@@ -13,8 +13,9 @@ export declare class TaskPoller {
|
|
|
13
13
|
private notifyParentIfAllComplete;
|
|
14
14
|
private scheduleCleanup;
|
|
15
15
|
private pruneExpiredTasks;
|
|
16
|
+
private onTaskComplete?;
|
|
16
17
|
private pollingInterval?;
|
|
17
|
-
constructor(client: OpencodeClient, store: TaskStore, concurrency: ConcurrencyController, notifyParentIfAllComplete: (parentSessionID: string) => Promise<void>, scheduleCleanup: (taskId: string) => void, pruneExpiredTasks: () => void);
|
|
18
|
+
constructor(client: OpencodeClient, store: TaskStore, concurrency: ConcurrencyController, notifyParentIfAllComplete: (parentSessionID: string) => Promise<void>, scheduleCleanup: (taskId: string) => void, pruneExpiredTasks: () => void, onTaskComplete?: ((task: ParallelTask) => void | Promise<void>) | undefined);
|
|
18
19
|
start(): void;
|
|
19
20
|
stop(): void;
|
|
20
21
|
isRunning(): boolean;
|
package/dist/index.js
CHANGED
|
@@ -288,10 +288,11 @@ var PARALLEL_TASK = {
|
|
|
288
288
|
// Task lifecycle (24 hours for long tasks)
|
|
289
289
|
TTL_MS: 24 * TIME.HOUR,
|
|
290
290
|
CLEANUP_DELAY_MS: 10 * TIME.MINUTE,
|
|
291
|
-
MAX_DEPTH:
|
|
292
|
-
//
|
|
293
|
-
|
|
294
|
-
|
|
291
|
+
MAX_DEPTH: 8,
|
|
292
|
+
// Titan-Class depth for complex fractal missions
|
|
293
|
+
// Concurrency limits (Aggressive for intense processing)
|
|
294
|
+
DEFAULT_CONCURRENCY: 10,
|
|
295
|
+
MAX_CONCURRENCY: 50,
|
|
295
296
|
// Sync polling (for delegate_task sync mode)
|
|
296
297
|
// Optimized: Reduced polling frequency while relying more on events
|
|
297
298
|
SYNC_TIMEOUT_MS: 5 * TIME.MINUTE,
|
|
@@ -630,7 +631,7 @@ var PROMPTS = {
|
|
|
630
631
|
|
|
631
632
|
// src/shared/message/constants/slash-commands.ts
|
|
632
633
|
var COMMAND_NAMES = {
|
|
633
|
-
TASK: "
|
|
634
|
+
TASK: "swarm",
|
|
634
635
|
PLAN: "plan",
|
|
635
636
|
STATUS: "status",
|
|
636
637
|
STOP: "stop",
|
|
@@ -13713,6 +13714,42 @@ If a single unit of code (file or module) starts to handle multiple distinct con
|
|
|
13713
13714
|
- If you have to scroll through "screens of code" to find a different type of logic, it belongs in a new file or sub-folder.
|
|
13714
13715
|
${PROMPT_TAGS.QUALITY_CHECKLIST.close}`;
|
|
13715
13716
|
|
|
13717
|
+
// src/agents/prompts/common/hyper-parallel.ts
|
|
13718
|
+
var HYPER_PARALLEL_ENFORCEMENT = `${PROMPT_TAGS.QUALITY_CHECKLIST.open}
|
|
13719
|
+
\u{1F680} HYPER-PARALLEL COGNITIVE ARCHITECTURE (HPFA)
|
|
13720
|
+
|
|
13721
|
+
To achieve maximum velocity, you MUST leverage these advanced parallel execution patterns:
|
|
13722
|
+
|
|
13723
|
+
### 1. Fractal Self-Delegation (Recursive Scaling)
|
|
13724
|
+
If you are a Worker and your assigned task is complex (e.g., implementing multiple endpoints, refactoring several files), **do not do it sequentially**.
|
|
13725
|
+
- **Spawn Sub-Workers**: Use \`delegate_task\` to launch sub-agents for independent sub-components.
|
|
13726
|
+
- **Fractal Depth**: You can scale down to any depth. Each worker acts as a local coordinator for its sub-workers.
|
|
13727
|
+
- **Context Sharding**: Give each sub-worker a focused, atomic prompt and relevant file context.
|
|
13728
|
+
|
|
13729
|
+
### 2. Speculative Racing (Competitive Implementation)
|
|
13730
|
+
When faced with a high-uncertainty problem (bug fixing, complex refactoring with multiple possible approaches):
|
|
13731
|
+
- **Launch a Race**: Spawn multiple Workers (\`mode: "race"\`) with slightly different prompts or strategies.
|
|
13732
|
+
- **Winning Criteria**: The first agent to produce a solution that passes unit tests "wins".
|
|
13733
|
+
- **Efficiency**: This eliminates the "try-fail-repeat" loop by trying all likely solutions simultaneously.
|
|
13734
|
+
|
|
13735
|
+
### 3. Asynchronous Batching
|
|
13736
|
+
When you need to perform many independent reads or metadata checks:
|
|
13737
|
+
- **Batch Operations**: Group your tool calls to trigger massive parallel execution host-side.
|
|
13738
|
+
- **Avoid Serial Bottlenecks**: Never wait for a tool result if you have other independent tasks you could be launching in parallel.
|
|
13739
|
+
|
|
13740
|
+
### 4. Barrier-Sync Integrated Pipeline (BSIP)
|
|
13741
|
+
Don't wait for all workers to finish before starting reviews:
|
|
13742
|
+
- **Pipelined Verification**: Immediately spawn a Reviewer task as soon as a Worker finishes its individual sub-task. The review of Module A happens while Module B is still being built.
|
|
13743
|
+
- **Synchronization Point**: Use the "Final Sync Barrier" to wait for all parallel implementation AND individual reviews to complete.
|
|
13744
|
+
- **Global Integration**: The final master Reviewer only acts once all individual units have been verified by their respective sub-reviewers.
|
|
13745
|
+
|
|
13746
|
+
### 5. Real-time Brain Sync
|
|
13747
|
+
As you work in a parallel session, log your critical findings or discovered interface changes to the shared task log.
|
|
13748
|
+
Assume that:
|
|
13749
|
+
- **Global Awareness**: Other workers are aware of your public findings.
|
|
13750
|
+
- **Consistency**: You must check for "Global Context Updates" to ensure your parallel work aligns with the latest state of the system.
|
|
13751
|
+
${PROMPT_TAGS.QUALITY_CHECKLIST.close}`;
|
|
13752
|
+
|
|
13716
13753
|
// src/agents/prompts/commander/role.ts
|
|
13717
13754
|
var COMMANDER_ROLE = `${PROMPT_TAGS.ROLE.open}
|
|
13718
13755
|
You are ${AGENT_NAMES.COMMANDER}. Autonomous mission controller.
|
|
@@ -15330,6 +15367,7 @@ var commander = {
|
|
|
15330
15367
|
var systemPrompt2 = [
|
|
15331
15368
|
PLANNER_ROLE,
|
|
15332
15369
|
MODULARITY_ENFORCEMENT,
|
|
15370
|
+
HYPER_PARALLEL_ENFORCEMENT,
|
|
15333
15371
|
PLANNER_FORBIDDEN,
|
|
15334
15372
|
PLANNER_REQUIRED,
|
|
15335
15373
|
ENVIRONMENT_DISCOVERY,
|
|
@@ -15356,6 +15394,7 @@ var planner = {
|
|
|
15356
15394
|
var systemPrompt3 = [
|
|
15357
15395
|
WORKER_ROLE,
|
|
15358
15396
|
MODULARITY_ENFORCEMENT,
|
|
15397
|
+
HYPER_PARALLEL_ENFORCEMENT,
|
|
15359
15398
|
WORKER_FORBIDDEN,
|
|
15360
15399
|
WORKER_REQUIRED,
|
|
15361
15400
|
ANTI_HALLUCINATION_CORE,
|
|
@@ -15384,6 +15423,7 @@ var worker = {
|
|
|
15384
15423
|
var systemPrompt4 = [
|
|
15385
15424
|
REVIEWER_ROLE,
|
|
15386
15425
|
MODULARITY_ENFORCEMENT,
|
|
15426
|
+
HYPER_PARALLEL_ENFORCEMENT,
|
|
15387
15427
|
REVIEWER_FORBIDDEN,
|
|
15388
15428
|
REVIEWER_REQUIRED,
|
|
15389
15429
|
REVIEWER_VERIFICATION,
|
|
@@ -15492,7 +15532,7 @@ $ARGUMENTS
|
|
|
15492
15532
|
</execution_rules>
|
|
15493
15533
|
</mission>`;
|
|
15494
15534
|
var COMMANDS = {
|
|
15495
|
-
"
|
|
15535
|
+
"swarm": {
|
|
15496
15536
|
description: "MISSION MODE - Execute task autonomously until complete",
|
|
15497
15537
|
template: MISSION_MODE_TEMPLATE,
|
|
15498
15538
|
argumentHint: '"mission goal"'
|
|
@@ -15553,7 +15593,7 @@ THINK \u2192 PLAN \u2192 DELEGATE \u2192 EXECUTE \u2192 VERIFY \u2192 COMPLETE
|
|
|
15553
15593
|
|
|
15554
15594
|
## Usage
|
|
15555
15595
|
- Select **${AGENT_NAMES.COMMANDER}** and type your request
|
|
15556
|
-
- Or use \`/
|
|
15596
|
+
- Or use \`/swarm "your mission"\` explicitly
|
|
15557
15597
|
- ${AGENT_NAMES.COMMANDER} automatically coordinates all agents`
|
|
15558
15598
|
}
|
|
15559
15599
|
};
|
|
@@ -16209,7 +16249,7 @@ var ConcurrencyController = class {
|
|
|
16209
16249
|
this.failureCount.set(key, 0);
|
|
16210
16250
|
if (streak % 5 === 0) {
|
|
16211
16251
|
const currentLimit = this.getConcurrencyLimit(key);
|
|
16212
|
-
if (currentLimit <
|
|
16252
|
+
if (currentLimit < PARALLEL_TASK.MAX_CONCURRENCY) {
|
|
16213
16253
|
this.setLimit(key, currentLimit + 1);
|
|
16214
16254
|
log(`[concurrency] Auto-scaling UP for ${key}: ${currentLimit + 1}`);
|
|
16215
16255
|
}
|
|
@@ -17020,6 +17060,11 @@ var TaskLauncher = class {
|
|
|
17020
17060
|
* Prepare task: Create session and registration without blocking on concurrency
|
|
17021
17061
|
*/
|
|
17022
17062
|
async prepareTask(input) {
|
|
17063
|
+
const currentDepth = input.depth ?? 0;
|
|
17064
|
+
if (currentDepth >= PARALLEL_TASK.MAX_DEPTH) {
|
|
17065
|
+
log(`[task-launcher.ts] Task depth limit reached (${currentDepth}/${PARALLEL_TASK.MAX_DEPTH}). Generation blocked.`);
|
|
17066
|
+
throw new Error(`Maximum task depth (${PARALLEL_TASK.MAX_DEPTH}) reached. To prevent infinite recursion, no further sub-tasks can be spawned.`);
|
|
17067
|
+
}
|
|
17023
17068
|
const createResult = await this.client.session.create({
|
|
17024
17069
|
body: {
|
|
17025
17070
|
parentID: input.parentSessionID,
|
|
@@ -17043,7 +17088,9 @@ var TaskLauncher = class {
|
|
|
17043
17088
|
// Start as PENDING
|
|
17044
17089
|
startedAt: /* @__PURE__ */ new Date(),
|
|
17045
17090
|
concurrencyKey: input.agent,
|
|
17046
|
-
depth: (input.depth ?? 0) + 1
|
|
17091
|
+
depth: (input.depth ?? 0) + 1,
|
|
17092
|
+
mode: input.mode || "normal",
|
|
17093
|
+
groupID: input.groupID
|
|
17047
17094
|
};
|
|
17048
17095
|
this.store.set(taskId, task);
|
|
17049
17096
|
this.store.trackPending(input.parentSessionID, taskId);
|
|
@@ -17079,10 +17126,11 @@ var TaskLauncher = class {
|
|
|
17079
17126
|
body: {
|
|
17080
17127
|
agent: task.agent,
|
|
17081
17128
|
tools: {
|
|
17082
|
-
|
|
17083
|
-
|
|
17084
|
-
|
|
17085
|
-
|
|
17129
|
+
// HPFA: Allow agents to delegate sub-tasks (Fractal Spawning)
|
|
17130
|
+
delegate_task: true,
|
|
17131
|
+
get_task_result: true,
|
|
17132
|
+
list_tasks: true,
|
|
17133
|
+
cancel_task: true
|
|
17086
17134
|
},
|
|
17087
17135
|
parts: [{ type: PART_TYPES.TEXT, text: task.prompt }]
|
|
17088
17136
|
}
|
|
@@ -17153,13 +17201,14 @@ var CONFIG = {
|
|
|
17153
17201
|
|
|
17154
17202
|
// src/core/agents/manager/task-poller.ts
|
|
17155
17203
|
var TaskPoller = class {
|
|
17156
|
-
constructor(client, store, concurrency, notifyParentIfAllComplete, scheduleCleanup, pruneExpiredTasks) {
|
|
17204
|
+
constructor(client, store, concurrency, notifyParentIfAllComplete, scheduleCleanup, pruneExpiredTasks, onTaskComplete) {
|
|
17157
17205
|
this.client = client;
|
|
17158
17206
|
this.store = store;
|
|
17159
17207
|
this.concurrency = concurrency;
|
|
17160
17208
|
this.notifyParentIfAllComplete = notifyParentIfAllComplete;
|
|
17161
17209
|
this.scheduleCleanup = scheduleCleanup;
|
|
17162
17210
|
this.pruneExpiredTasks = pruneExpiredTasks;
|
|
17211
|
+
this.onTaskComplete = onTaskComplete;
|
|
17163
17212
|
}
|
|
17164
17213
|
pollingInterval;
|
|
17165
17214
|
start() {
|
|
@@ -17243,6 +17292,9 @@ var TaskPoller = class {
|
|
|
17243
17292
|
this.scheduleCleanup(task.id);
|
|
17244
17293
|
taskWAL.log(WAL_ACTIONS.COMPLETE, task).catch(() => {
|
|
17245
17294
|
});
|
|
17295
|
+
if (this.onTaskComplete) {
|
|
17296
|
+
Promise.resolve(this.onTaskComplete(task)).catch((err) => log("Error in onTaskComplete callback:", err));
|
|
17297
|
+
}
|
|
17246
17298
|
const duration3 = formatDuration(task.startedAt, task.completedAt);
|
|
17247
17299
|
presets.sessionCompleted(task.sessionID, duration3);
|
|
17248
17300
|
log(`Completed ${task.id} (${duration3})`);
|
|
@@ -17399,7 +17451,7 @@ You will be notified when ALL tasks complete. Continue productive work.`;
|
|
|
17399
17451
|
|
|
17400
17452
|
// src/core/agents/manager/event-handler.ts
|
|
17401
17453
|
var EventHandler = class {
|
|
17402
|
-
constructor(client, store, concurrency, findBySession, notifyParentIfAllComplete, scheduleCleanup, validateSessionHasOutput2) {
|
|
17454
|
+
constructor(client, store, concurrency, findBySession, notifyParentIfAllComplete, scheduleCleanup, validateSessionHasOutput2, onTaskComplete) {
|
|
17403
17455
|
this.client = client;
|
|
17404
17456
|
this.store = store;
|
|
17405
17457
|
this.concurrency = concurrency;
|
|
@@ -17407,6 +17459,7 @@ var EventHandler = class {
|
|
|
17407
17459
|
this.notifyParentIfAllComplete = notifyParentIfAllComplete;
|
|
17408
17460
|
this.scheduleCleanup = scheduleCleanup;
|
|
17409
17461
|
this.validateSessionHasOutput = validateSessionHasOutput2;
|
|
17462
|
+
this.onTaskComplete = onTaskComplete;
|
|
17410
17463
|
}
|
|
17411
17464
|
/**
|
|
17412
17465
|
* Handle OpenCode session events for proper resource cleanup.
|
|
@@ -17455,6 +17508,9 @@ var EventHandler = class {
|
|
|
17455
17508
|
this.scheduleCleanup(task.id);
|
|
17456
17509
|
taskWAL.log(WAL_ACTIONS.COMPLETE, task).catch(() => {
|
|
17457
17510
|
});
|
|
17511
|
+
if (this.onTaskComplete) {
|
|
17512
|
+
Promise.resolve(this.onTaskComplete(task)).catch((err) => log("Error in onTaskComplete callback:", err));
|
|
17513
|
+
}
|
|
17458
17514
|
log(`Task ${task.id} completed via session.idle event (${formatDuration(task.startedAt, task.completedAt)})`);
|
|
17459
17515
|
}
|
|
17460
17516
|
handleSessionDeleted(task) {
|
|
@@ -17501,7 +17557,8 @@ var ParallelAgentManager = class _ParallelAgentManager {
|
|
|
17501
17557
|
this.concurrency,
|
|
17502
17558
|
(parentSessionID) => this.cleaner.notifyParentIfAllComplete(parentSessionID),
|
|
17503
17559
|
(taskId) => this.cleaner.scheduleCleanup(taskId),
|
|
17504
|
-
() => this.cleaner.pruneExpiredTasks()
|
|
17560
|
+
() => this.cleaner.pruneExpiredTasks(),
|
|
17561
|
+
(task) => this.handleTaskComplete(task)
|
|
17505
17562
|
);
|
|
17506
17563
|
this.launcher = new TaskLauncher(
|
|
17507
17564
|
client,
|
|
@@ -17525,7 +17582,8 @@ var ParallelAgentManager = class _ParallelAgentManager {
|
|
|
17525
17582
|
(sessionID) => this.findBySession(sessionID),
|
|
17526
17583
|
(parentSessionID) => this.cleaner.notifyParentIfAllComplete(parentSessionID),
|
|
17527
17584
|
(taskId) => this.cleaner.scheduleCleanup(taskId),
|
|
17528
|
-
(sessionID) => this.poller.validateSessionHasOutput(sessionID)
|
|
17585
|
+
(sessionID) => this.poller.validateSessionHasOutput(sessionID),
|
|
17586
|
+
(task) => this.handleTaskComplete(task)
|
|
17529
17587
|
);
|
|
17530
17588
|
this.recoverActiveTasks().catch((err) => {
|
|
17531
17589
|
log("Recovery error:", err);
|
|
@@ -17645,6 +17703,30 @@ var ParallelAgentManager = class _ParallelAgentManager {
|
|
|
17645
17703
|
taskWAL.log(WAL_ACTIONS.UPDATE, task).catch(() => {
|
|
17646
17704
|
});
|
|
17647
17705
|
}
|
|
17706
|
+
async handleTaskComplete(task) {
|
|
17707
|
+
if (task.agent === AGENT_NAMES.WORKER && task.mode !== "race") {
|
|
17708
|
+
log(`[MSVP] Triggering 1\uCC28 \uB9AC\uBDF0 (Unit Review) for task ${task.id}`);
|
|
17709
|
+
try {
|
|
17710
|
+
await this.launch({
|
|
17711
|
+
agent: AGENT_NAMES.REVIEWER,
|
|
17712
|
+
description: `1\uCC28 \uB9AC\uBDF0: ${task.description}`,
|
|
17713
|
+
prompt: `\uC9C4\uD589\uB41C \uC791\uC5C5(\`${task.description}\`)\uC5D0 \uB300\uD574 1\uCC28 \uB9AC\uBDF0(\uC720\uB2DB \uAC80\uC99D)\uB97C \uC218\uD589\uD558\uC138\uC694.
|
|
17714
|
+
\uC8FC\uC694 \uC810\uAC80 \uC0AC\uD56D:
|
|
17715
|
+
1. \uD574\uB2F9 \uBAA8\uB4C8\uC758 \uC720\uB2DB \uD14C\uC2A4\uD2B8 \uCF54\uB4DC \uC791\uC131 \uC5EC\uBD80 \uBC0F \uD1B5\uACFC \uD655\uC778
|
|
17716
|
+
2. \uCF54\uB4DC \uD488\uC9C8 \uBC0F \uBAA8\uB4C8\uC131 \uC900\uC218 \uC5EC\uBD80
|
|
17717
|
+
3. \uBC1C\uACAC\uB41C \uACB0\uD568 \uC989\uC2DC \uC218\uC815 \uC9C0\uC2DC \uB610\uB294 \uB9AC\uD3EC\uD2B8
|
|
17718
|
+
|
|
17719
|
+
\uC774 \uC791\uC5C5\uC740 \uC804\uCCB4 \uD1B5\uD569 \uC804 \uBD80\uD488 \uB2E8\uC704\uC758 \uC644\uACB0\uC131\uC744 \uBCF4\uC7A5\uD558\uAE30 \uC704\uD568\uC785\uB2C8\uB2E4.`,
|
|
17720
|
+
parentSessionID: task.parentSessionID,
|
|
17721
|
+
depth: task.depth,
|
|
17722
|
+
groupID: task.groupID || task.id
|
|
17723
|
+
// Group reviews with their origins
|
|
17724
|
+
});
|
|
17725
|
+
} catch (error45) {
|
|
17726
|
+
log(`[MSVP] Failed to trigger review for ${task.id}:`, error45);
|
|
17727
|
+
}
|
|
17728
|
+
}
|
|
17729
|
+
}
|
|
17648
17730
|
async recoverActiveTasks() {
|
|
17649
17731
|
const tasks = await taskWAL.readAll();
|
|
17650
17732
|
if (tasks.size === 0) return;
|
|
@@ -17824,12 +17906,17 @@ var createDelegateTaskTool = (manager, client) => tool({
|
|
|
17824
17906
|
description: tool.schema.string().describe("Task description"),
|
|
17825
17907
|
prompt: tool.schema.string().describe("Prompt for the agent"),
|
|
17826
17908
|
background: tool.schema.boolean().describe("true=async, false=sync"),
|
|
17827
|
-
resume: tool.schema.string().optional().describe("Session ID to resume (from previous task.sessionID)")
|
|
17909
|
+
resume: tool.schema.string().optional().describe("Session ID to resume (from previous task.sessionID)"),
|
|
17910
|
+
mode: tool.schema.enum(["normal", "race", "fractal"]).optional().describe("Task mode (race=first wins, fractal=recursive)"),
|
|
17911
|
+
groupID: tool.schema.string().optional().describe("Group ID for racing or tracking recursive families")
|
|
17828
17912
|
},
|
|
17829
17913
|
async execute(args, context) {
|
|
17830
|
-
const { agent, description, prompt, background, resume } = args;
|
|
17914
|
+
const { agent, description, prompt, background, resume, mode, groupID } = args;
|
|
17831
17915
|
const ctx = context;
|
|
17832
|
-
|
|
17916
|
+
const allTasks = manager.getAllTasks();
|
|
17917
|
+
const parentTask = allTasks.find((t) => t.sessionID === ctx.sessionID);
|
|
17918
|
+
const parentDepth = parentTask?.depth ?? 0;
|
|
17919
|
+
log(`${PARALLEL_LOG.DELEGATE_TASK} execute() called`, { agent, description, background, resume, mode, groupID, parentSession: ctx.sessionID, depth: parentDepth });
|
|
17833
17920
|
const sessionClient = client;
|
|
17834
17921
|
if (background === void 0) {
|
|
17835
17922
|
return `${OUTPUT_LABEL.ERROR} 'background' parameter is REQUIRED.`;
|
|
@@ -17842,8 +17929,12 @@ var createDelegateTaskTool = (manager, client) => tool({
|
|
|
17842
17929
|
parentSessionID: ctx.sessionID,
|
|
17843
17930
|
agent,
|
|
17844
17931
|
// Assuming agent is needed for resume context
|
|
17845
|
-
description
|
|
17932
|
+
description,
|
|
17846
17933
|
// Assuming description is needed for resume context
|
|
17934
|
+
mode,
|
|
17935
|
+
groupID,
|
|
17936
|
+
depth: parentDepth
|
|
17937
|
+
// Preserve depth on resume
|
|
17847
17938
|
};
|
|
17848
17939
|
const launchResult = await manager.launch(input);
|
|
17849
17940
|
const task = Array.isArray(launchResult) ? launchResult[0] : launchResult;
|
|
@@ -17881,7 +17972,10 @@ ${text || "(No output)"}`;
|
|
|
17881
17972
|
agent,
|
|
17882
17973
|
description,
|
|
17883
17974
|
prompt,
|
|
17884
|
-
parentSessionID: ctx.sessionID
|
|
17975
|
+
parentSessionID: ctx.sessionID,
|
|
17976
|
+
mode,
|
|
17977
|
+
groupID,
|
|
17978
|
+
depth: parentDepth
|
|
17885
17979
|
});
|
|
17886
17980
|
const task = Array.isArray(launchResult) ? launchResult[0] : launchResult;
|
|
17887
17981
|
presets.taskStarted(task.id, agent);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Slash Commands (with slash prefix)
|
|
3
3
|
*/
|
|
4
4
|
export declare const SLASH_COMMANDS: {
|
|
5
|
-
readonly TASK: "/
|
|
5
|
+
readonly TASK: "/swarm";
|
|
6
6
|
readonly PLAN: "/plan";
|
|
7
7
|
readonly STATUS: "/status";
|
|
8
8
|
readonly STOP: "/stop";
|
|
@@ -12,7 +12,7 @@ export declare const SLASH_COMMANDS: {
|
|
|
12
12
|
* Command Names (without slash prefix, for comparison after parsing)
|
|
13
13
|
*/
|
|
14
14
|
export declare const COMMAND_NAMES: {
|
|
15
|
-
readonly TASK: "
|
|
15
|
+
readonly TASK: "swarm";
|
|
16
16
|
readonly PLAN: "plan";
|
|
17
17
|
readonly STATUS: "status";
|
|
18
18
|
readonly STOP: "stop";
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Parallel Task Configuration
|
|
3
3
|
*/
|
|
4
|
+
export declare const TASK_MODE: {
|
|
5
|
+
readonly NORMAL: "normal";
|
|
6
|
+
readonly RACE: "race";
|
|
7
|
+
readonly FRACTAL: "fractal";
|
|
8
|
+
};
|
|
4
9
|
export declare const PARALLEL_TASK: {
|
|
5
10
|
readonly TTL_MS: number;
|
|
6
11
|
readonly CLEANUP_DELAY_MS: number;
|
|
7
|
-
readonly MAX_DEPTH:
|
|
8
|
-
readonly DEFAULT_CONCURRENCY:
|
|
9
|
-
readonly MAX_CONCURRENCY:
|
|
12
|
+
readonly MAX_DEPTH: 8;
|
|
13
|
+
readonly DEFAULT_CONCURRENCY: 10;
|
|
14
|
+
readonly MAX_CONCURRENCY: 50;
|
|
10
15
|
readonly SYNC_TIMEOUT_MS: number;
|
|
11
16
|
readonly POLL_INTERVAL_MS: 2000;
|
|
12
17
|
readonly MIN_IDLE_TIME_MS: number;
|
|
@@ -18,6 +18,12 @@ export declare const createDelegateTaskTool: (manager: ParallelAgentManager, cli
|
|
|
18
18
|
prompt: import("zod").ZodString;
|
|
19
19
|
background: import("zod").ZodBoolean;
|
|
20
20
|
resume: import("zod").ZodOptional<import("zod").ZodString>;
|
|
21
|
+
mode: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
22
|
+
normal: "normal";
|
|
23
|
+
race: "race";
|
|
24
|
+
fractal: "fractal";
|
|
25
|
+
}>>;
|
|
26
|
+
groupID: import("zod").ZodOptional<import("zod").ZodString>;
|
|
21
27
|
};
|
|
22
28
|
execute(args: {
|
|
23
29
|
agent: string;
|
|
@@ -25,5 +31,7 @@ export declare const createDelegateTaskTool: (manager: ParallelAgentManager, cli
|
|
|
25
31
|
prompt: string;
|
|
26
32
|
background: boolean;
|
|
27
33
|
resume?: string | undefined;
|
|
34
|
+
mode?: "normal" | "race" | "fractal" | undefined;
|
|
35
|
+
groupID?: string | undefined;
|
|
28
36
|
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
29
37
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "opencode-orchestrator",
|
|
3
3
|
"displayName": "OpenCode Orchestrator",
|
|
4
4
|
"description": "Distributed Cognitive Architecture for OpenCode. Turns simple prompts into specialized multi-agent workflows (Planner, Coder, Reviewer).",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.11",
|
|
6
6
|
"author": "agnusdei1207",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|