opencode-orchestrator 1.0.7 → 1.0.10

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 CHANGED
@@ -2,13 +2,21 @@
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
  [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
9
  [![npm](https://img.shields.io/npm/v/opencode-orchestrator.svg)](https://www.npmjs.com/package/opencode-orchestrator)
7
10
  [![Tests](https://img.shields.io/badge/tests-216%20passed-brightgreen.svg)]()
8
11
  </div>
9
12
 
10
- > **Multi-Agent Orchestration Plugin for [OpenCode](https://opencode.ai)**
13
+ ---
14
+
15
+ ### 🌌 **The End of Sequential Limits. The Era of Fractal Mastery.**
11
16
 
17
+ 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.
18
+
19
+ 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.
12
20
 
13
21
  ## ⚡ Quick Start
14
22
 
@@ -16,20 +24,21 @@
16
24
  npm install -g opencode-orchestrator
17
25
  ```
18
26
 
19
- Then in OpenCode:
27
+ Then in OpenCode, launch your mission:
20
28
  ```bash
21
- /extreme-mission "Implement a Diablo2 Online Game for Web"
29
+ /extreme-mission "Architect and Build a Diablo-like Web Engine"
22
30
  ```
23
31
 
24
- ## 🏔️ Extreme Resilience & Performance
32
+ ## 💎 The Four Pillars of Excellence
25
33
 
26
- Built for "Infinite Missions," the OpenCode Orchestrator is engineered to handle massive codebases and long-running tasks where absolute stability is non-negotiable.
34
+ We’ve combined industrial-grade reliability with cutting-edge parallel intelligence to redefine what’s possible in AI coding.
27
35
 
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.
36
+ * **⚡ Velocity**: Parallelize up to 50 concurrent sessions. What takes hours for others is finished in minutes through **Cognitive Elasticity**.
37
+ * **🧬 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.
38
+ * **🛡️ Safety**: Our **MSVP (Multi-Stage Verification Pipeline)** reviews every line of code in parallel "Shadow Sessions" before it ever touches your build.
39
+ * **♾️ Trust**: **Iron-Clad Reliability** via Write-Ahead Logging (WAL). Even after a crash, the system replays its history to resume exactly where it was.
32
40
 
41
+ ---
33
42
 
34
43
  ## ⭐ Core Philosophy
35
44
 
@@ -63,73 +72,90 @@ Built for "Infinite Missions," the OpenCode Orchestrator is engineered to handle
63
72
  | 🤝 **Specialized Roles** | Each agent has a clear, focused responsibility |
64
73
 
65
74
 
66
- ## 🏛️ Workflow Architecture
75
+ ## 🏛️ Hyper-Parallel Architecture: HPFA & MSVP
76
+
77
+ The orchestrator eliminates the linear bottleneck of AI development through two breakthrough technologies:
78
+
79
+ ### 🧬 **HPFA (Hyper-Parallel Fractal Architecture)**
80
+ Imagine an agent that doesn't just work, but **thinks like a Hive Mind**.
81
+ * **Fractal Delegation**: Workers are no longer just "doers." They are mini-planners that can recursively spawn their own sub-agents to handle complexity at every level.
82
+ * **Speculative Racing**: Ambiguous tasks are solved using multiple strategies in parallel. The fastest, most accurate path wins, while others are pruned—minimizing latency and maximizing quality.
83
+
84
+ ### 🛡️ **MSVP (Multi-Stage Verification Pipeline)**
85
+ Speed is nothing without accuracy. MSVP ensures your code is production-ready at every second.
86
+ * **Shadow Parallel Review**: As soon as a file is written, a parallel reviewer session is already validating it before the main task even finishes.
87
+ * **Barrier-Sync Integration**: A 4-stage verification gate that prevents "architectural drift" by forcing a global synchronization barrier before final sealing.
67
88
 
68
89
  ```
69
- /extreme-mission "Build REST API"
70
-
71
- ╔═══════════════════════════════════════╗
72
- ║ 🎯 COMMANDER — Orchestrator ║
73
- ║ (Main Session - Single) ║
74
- ╚═══════════════════╤═══════════════════╝
75
-
76
- ┌───────────────────▼───────────────────┐
77
- │ 📋 PLANNER — Create Plan │
78
- (Single, Sync Call)
79
- │ → Outputs: .opencode/todo.md │
80
- └───────────────────┬───────────────────┘
81
-
90
+ /extreme-mission "Build Complex System"
91
+
92
+ ╔═══════════════════════════════════════╗
93
+ ║ 🎯 COMMANDER — Orchestrator ║
94
+ ║ (Main Session - Single) ║
95
+ ╚═══════════════════╤═══════════════════╝
96
+
97
+ ┌───────────────────▼───────────────────┐
98
+ │ 📋 PLANNER — Create Plan │
99
+ Outputs: Architectural Grid
100
+ └───────────────────┬───────────────────┘
101
+
82
102
  ══════════════════════════╧══════════════════════════
83
- 🔥 PARALLEL ZONE
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
- │ │ │
103
+ 🔥 HPFA PARALLEL GRID (MSVP)
93
104
  ══════════════════════════════════════════════════════
94
- ║ ⏳ SYNC BARRIER ║
105
+ │ │ │ │
106
+ ▼ ▼ ▼ ▼
107
+ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
108
+ │🔨 WORKER │ │🔨 WORKER │ │🔨 WORKER │ │🔨 WORKER │ <-- Fractal Spawning
109
+ │ Module A │ │ Module B │ │ Module C │ │ Module D │
110
+ └────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘
111
+ │ ⚡ Instant │ ⚡ Instant │ ⚡ Instant │ ⚡ Instant
112
+ ▼ Review ▼ Review ▼ Review ▼ Review
113
+ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
114
+ │✅ REVIEWR│ │✅ REVIEWR│ │✅ REVIEWR│ │✅ REVIEWR│ <-- Stage 1: Unit
115
+ │ (Unit-A) │ │ (Unit-B) │ │ (Unit-C) │ │ (Unit-D) │ Verification
116
+ └────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘
117
+ │ │ │ │
118
+ ═▼═══════════════▼═══════════════▼═══════════════▼════
119
+ ║ ⏳ SYNC BARRIER ║
95
120
  ══════════════════════════════════════════════════════
96
-
97
- ┌───────────────────▼───────────────────┐
98
- │ ✅ REVIEWER — Verify All
99
- │ (Single, Sync Call)
100
- │ → Tests, Lint, Integration
101
- └───────────────────┬───────────────────┘
102
-
103
- ┌─────────┴─────────┐
104
- All Complete?
105
- Issues = 0?
106
- └─────────┬─────────┘
107
- No ↙ ↘ Yes
108
- ♻️ LOOP 🎖️ MISSION
109
- (back to SEALED
110
- Commander)
121
+
122
+ ┌───────────────────▼───────────────────┐
123
+ │ ✅ MASTER REVIEWER — Final Pass
124
+ │ (Cross-module Integration)
125
+ │ → Stage 2: E2E & System Integrity
126
+ └───────────────────┬───────────────────┘
127
+
128
+ ┌─────────┴─────────┐
129
+ Seal Conditions
130
+ Verified?
131
+ └─────────┬─────────┘
132
+ No ↙ ↘ Yes
133
+ ♻️ LOOP 🎖️ MISSION
134
+ (Adaptive) SEALED
111
135
  ```
112
136
 
113
- ### Execution Model
137
+ ### Execution Model (MSVP)
114
138
 
115
- | Phase | Agent | Parallelism | Blocking |
116
- |:------|:------|:------------|:---------|
117
- | 1️⃣ Plan | Planner | **Single** | Sync (waits) |
118
- | 2️⃣ Execute | Workers | **Parallel** (up to 50) | Async (background) |
119
- | 3️⃣ Verify | Reviewer | **Single** | Sync (waits) |
120
- | 4️⃣ Loop | Commander | **Single** | Coordinates |
139
+ | Phase | Agent | Parallelism | Verification Level |
140
+ |:------|:------|:------------|:-------------------|
141
+ | 1️⃣ Plan | Planner | **Single** | Static Analysis |
142
+ | 2️⃣ Implement | Workers | **HPFA Parallel** | Direct Coding |
143
+ | 3️⃣ Unit Pass | Reviewers | **Shadow Parallel** | **1차 리뷰**: Unit Tests (Async) |
144
+ | 4️⃣ Final Sync | Barrier | **Blocking** | All Units Verified |
145
+ | 5️⃣ Integration | Master Reviewer | **Single** | **2차 리뷰**: Full E2E & Sync |
121
146
 
122
147
  ## Features
123
148
 
124
149
  | Feature | What It Does |
125
150
  |:---------|:-------------|
126
- | 🚀 **60-80% Optimization**| Smart polling & output caching for massive speed gains |
127
- | **50 Parallel Tasks** | Run up to 50 agents simultaneously |
151
+ | 🚀 **MSVP Pipeline** | Parallel unit reviews triggered immediately after worker tasks |
152
+ | 🧬 **Fractal Spawning** | Workers can recursively spawn sub-missions for complex tasks |
153
+ | ⚡ **20+ Parallel Tasks** | High-intensity execution with safety concurrency limits |
128
154
  | 🔄 **Non-Stop Recovery** | WAL-based persistence (resumes tasks after crashes) |
129
155
  | 🔥 **Multi-File Ops** | Work on different files at the same time |
130
156
  | 🛡️ **Self-Scaling** | Dynamic concurrency limits based on success/failure |
131
157
  | 🩹 **Memory Integrity** | Strict resource cleanup prevents leaks in long sessions |
132
- | 🧬 **Adaptive AI** | Agents learn and adapt based on the project |
158
+ | 🏗️ **Architectural Modularity**| Enforces language-agnostic clean code principles |
133
159
 
134
160
  ---
135
161
 
@@ -145,14 +171,13 @@ Built for "Infinite Missions," the OpenCode Orchestrator is engineered to handle
145
171
  | 🔨 Build failure | Fix the issue and retry |
146
172
 
147
173
 
148
- ## 📚 Documentation
149
-
150
- - **[System Architecture](docs/SYSTEM_ARCHITECTURE.md)** — Full technical deep-dive
151
-
174
+ ---
152
175
 
153
176
  ## 🎹 Developer's Words
154
177
 
155
- > [Read the full note →](docs/DEVELOPERS_NOTE.md)
178
+ > "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."
179
+ >
180
+ > [Read the full Developer's Note →](docs/DEVELOPERS_NOTE.md)
156
181
 
157
182
 
158
183
  ## 📄 License
@@ -0,0 +1,4 @@
1
+ /**
2
+ * HPFA (Hyper-Parallel Fractal Architecture) Guidelines
3
+ */
4
+ export declare const HYPER_PARALLEL_ENFORCEMENT: string;
@@ -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";
@@ -7,4 +7,6 @@ export interface LaunchInput {
7
7
  agent: string;
8
8
  parentSessionID: string;
9
9
  depth?: number;
10
+ mode?: "normal" | "race" | "fractal";
11
+ groupID?: string;
10
12
  }
@@ -17,6 +17,8 @@ export interface ParallelTask {
17
17
  result?: string;
18
18
  concurrencyKey?: string;
19
19
  depth: number;
20
+ mode?: "normal" | "race" | "fractal";
21
+ groupID?: string;
20
22
  lastMsgCount?: number;
21
23
  stablePolls?: number;
22
24
  progress?: TaskProgress;
@@ -14,7 +14,8 @@ export declare class EventHandler {
14
14
  private notifyParentIfAllComplete;
15
15
  private scheduleCleanup;
16
16
  private validateSessionHasOutput;
17
- 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>);
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;
@@ -54,6 +54,7 @@ export declare class ParallelAgentManager {
54
54
  }): void;
55
55
  private findBySession;
56
56
  private handleTaskError;
57
+ private handleTaskComplete;
57
58
  private recoverActiveTasks;
58
59
  }
59
60
  export declare const parallelAgentManager: {
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: 3,
292
- // Concurrency limits (safe for most APIs)
293
- DEFAULT_CONCURRENCY: 3,
294
- MAX_CONCURRENCY: 10,
291
+ MAX_DEPTH: 5,
292
+ // Increased for fractal recursion
293
+ // Concurrency limits (Aggressive for intense processing)
294
+ DEFAULT_CONCURRENCY: 5,
295
+ MAX_CONCURRENCY: 20,
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,
@@ -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,
@@ -17043,7 +17083,9 @@ var TaskLauncher = class {
17043
17083
  // Start as PENDING
17044
17084
  startedAt: /* @__PURE__ */ new Date(),
17045
17085
  concurrencyKey: input.agent,
17046
- depth: (input.depth ?? 0) + 1
17086
+ depth: (input.depth ?? 0) + 1,
17087
+ mode: input.mode || "normal",
17088
+ groupID: input.groupID
17047
17089
  };
17048
17090
  this.store.set(taskId, task);
17049
17091
  this.store.trackPending(input.parentSessionID, taskId);
@@ -17079,10 +17121,11 @@ var TaskLauncher = class {
17079
17121
  body: {
17080
17122
  agent: task.agent,
17081
17123
  tools: {
17082
- delegate_task: false,
17083
- get_task_result: false,
17084
- list_tasks: false,
17085
- cancel_task: false
17124
+ // HPFA: Allow agents to delegate sub-tasks (Fractal Spawning)
17125
+ delegate_task: true,
17126
+ get_task_result: true,
17127
+ list_tasks: true,
17128
+ cancel_task: true
17086
17129
  },
17087
17130
  parts: [{ type: PART_TYPES.TEXT, text: task.prompt }]
17088
17131
  }
@@ -17153,13 +17196,14 @@ var CONFIG = {
17153
17196
 
17154
17197
  // src/core/agents/manager/task-poller.ts
17155
17198
  var TaskPoller = class {
17156
- constructor(client, store, concurrency, notifyParentIfAllComplete, scheduleCleanup, pruneExpiredTasks) {
17199
+ constructor(client, store, concurrency, notifyParentIfAllComplete, scheduleCleanup, pruneExpiredTasks, onTaskComplete) {
17157
17200
  this.client = client;
17158
17201
  this.store = store;
17159
17202
  this.concurrency = concurrency;
17160
17203
  this.notifyParentIfAllComplete = notifyParentIfAllComplete;
17161
17204
  this.scheduleCleanup = scheduleCleanup;
17162
17205
  this.pruneExpiredTasks = pruneExpiredTasks;
17206
+ this.onTaskComplete = onTaskComplete;
17163
17207
  }
17164
17208
  pollingInterval;
17165
17209
  start() {
@@ -17243,6 +17287,9 @@ var TaskPoller = class {
17243
17287
  this.scheduleCleanup(task.id);
17244
17288
  taskWAL.log(WAL_ACTIONS.COMPLETE, task).catch(() => {
17245
17289
  });
17290
+ if (this.onTaskComplete) {
17291
+ Promise.resolve(this.onTaskComplete(task)).catch((err) => log("Error in onTaskComplete callback:", err));
17292
+ }
17246
17293
  const duration3 = formatDuration(task.startedAt, task.completedAt);
17247
17294
  presets.sessionCompleted(task.sessionID, duration3);
17248
17295
  log(`Completed ${task.id} (${duration3})`);
@@ -17399,7 +17446,7 @@ You will be notified when ALL tasks complete. Continue productive work.`;
17399
17446
 
17400
17447
  // src/core/agents/manager/event-handler.ts
17401
17448
  var EventHandler = class {
17402
- constructor(client, store, concurrency, findBySession, notifyParentIfAllComplete, scheduleCleanup, validateSessionHasOutput2) {
17449
+ constructor(client, store, concurrency, findBySession, notifyParentIfAllComplete, scheduleCleanup, validateSessionHasOutput2, onTaskComplete) {
17403
17450
  this.client = client;
17404
17451
  this.store = store;
17405
17452
  this.concurrency = concurrency;
@@ -17407,6 +17454,7 @@ var EventHandler = class {
17407
17454
  this.notifyParentIfAllComplete = notifyParentIfAllComplete;
17408
17455
  this.scheduleCleanup = scheduleCleanup;
17409
17456
  this.validateSessionHasOutput = validateSessionHasOutput2;
17457
+ this.onTaskComplete = onTaskComplete;
17410
17458
  }
17411
17459
  /**
17412
17460
  * Handle OpenCode session events for proper resource cleanup.
@@ -17455,6 +17503,9 @@ var EventHandler = class {
17455
17503
  this.scheduleCleanup(task.id);
17456
17504
  taskWAL.log(WAL_ACTIONS.COMPLETE, task).catch(() => {
17457
17505
  });
17506
+ if (this.onTaskComplete) {
17507
+ Promise.resolve(this.onTaskComplete(task)).catch((err) => log("Error in onTaskComplete callback:", err));
17508
+ }
17458
17509
  log(`Task ${task.id} completed via session.idle event (${formatDuration(task.startedAt, task.completedAt)})`);
17459
17510
  }
17460
17511
  handleSessionDeleted(task) {
@@ -17501,7 +17552,8 @@ var ParallelAgentManager = class _ParallelAgentManager {
17501
17552
  this.concurrency,
17502
17553
  (parentSessionID) => this.cleaner.notifyParentIfAllComplete(parentSessionID),
17503
17554
  (taskId) => this.cleaner.scheduleCleanup(taskId),
17504
- () => this.cleaner.pruneExpiredTasks()
17555
+ () => this.cleaner.pruneExpiredTasks(),
17556
+ (task) => this.handleTaskComplete(task)
17505
17557
  );
17506
17558
  this.launcher = new TaskLauncher(
17507
17559
  client,
@@ -17525,7 +17577,8 @@ var ParallelAgentManager = class _ParallelAgentManager {
17525
17577
  (sessionID) => this.findBySession(sessionID),
17526
17578
  (parentSessionID) => this.cleaner.notifyParentIfAllComplete(parentSessionID),
17527
17579
  (taskId) => this.cleaner.scheduleCleanup(taskId),
17528
- (sessionID) => this.poller.validateSessionHasOutput(sessionID)
17580
+ (sessionID) => this.poller.validateSessionHasOutput(sessionID),
17581
+ (task) => this.handleTaskComplete(task)
17529
17582
  );
17530
17583
  this.recoverActiveTasks().catch((err) => {
17531
17584
  log("Recovery error:", err);
@@ -17645,6 +17698,30 @@ var ParallelAgentManager = class _ParallelAgentManager {
17645
17698
  taskWAL.log(WAL_ACTIONS.UPDATE, task).catch(() => {
17646
17699
  });
17647
17700
  }
17701
+ async handleTaskComplete(task) {
17702
+ if (task.agent === AGENT_NAMES.WORKER && task.mode !== "race") {
17703
+ log(`[MSVP] Triggering 1\uCC28 \uB9AC\uBDF0 (Unit Review) for task ${task.id}`);
17704
+ try {
17705
+ await this.launch({
17706
+ agent: AGENT_NAMES.REVIEWER,
17707
+ description: `1\uCC28 \uB9AC\uBDF0: ${task.description}`,
17708
+ 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.
17709
+ \uC8FC\uC694 \uC810\uAC80 \uC0AC\uD56D:
17710
+ 1. \uD574\uB2F9 \uBAA8\uB4C8\uC758 \uC720\uB2DB \uD14C\uC2A4\uD2B8 \uCF54\uB4DC \uC791\uC131 \uC5EC\uBD80 \uBC0F \uD1B5\uACFC \uD655\uC778
17711
+ 2. \uCF54\uB4DC \uD488\uC9C8 \uBC0F \uBAA8\uB4C8\uC131 \uC900\uC218 \uC5EC\uBD80
17712
+ 3. \uBC1C\uACAC\uB41C \uACB0\uD568 \uC989\uC2DC \uC218\uC815 \uC9C0\uC2DC \uB610\uB294 \uB9AC\uD3EC\uD2B8
17713
+
17714
+ \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.`,
17715
+ parentSessionID: task.parentSessionID,
17716
+ depth: task.depth,
17717
+ groupID: task.groupID || task.id
17718
+ // Group reviews with their origins
17719
+ });
17720
+ } catch (error45) {
17721
+ log(`[MSVP] Failed to trigger review for ${task.id}:`, error45);
17722
+ }
17723
+ }
17724
+ }
17648
17725
  async recoverActiveTasks() {
17649
17726
  const tasks = await taskWAL.readAll();
17650
17727
  if (tasks.size === 0) return;
@@ -17824,12 +17901,14 @@ var createDelegateTaskTool = (manager, client) => tool({
17824
17901
  description: tool.schema.string().describe("Task description"),
17825
17902
  prompt: tool.schema.string().describe("Prompt for the agent"),
17826
17903
  background: tool.schema.boolean().describe("true=async, false=sync"),
17827
- resume: tool.schema.string().optional().describe("Session ID to resume (from previous task.sessionID)")
17904
+ resume: tool.schema.string().optional().describe("Session ID to resume (from previous task.sessionID)"),
17905
+ mode: tool.schema.enum(["normal", "race", "fractal"]).optional().describe("Task mode (race=first wins, fractal=recursive)"),
17906
+ groupID: tool.schema.string().optional().describe("Group ID for racing or tracking recursive families")
17828
17907
  },
17829
17908
  async execute(args, context) {
17830
- const { agent, description, prompt, background, resume } = args;
17909
+ const { agent, description, prompt, background, resume, mode, groupID } = args;
17831
17910
  const ctx = context;
17832
- log(`${PARALLEL_LOG.DELEGATE_TASK} execute() called`, { agent, description, background, resume, parentSession: ctx.sessionID });
17911
+ log(`${PARALLEL_LOG.DELEGATE_TASK} execute() called`, { agent, description, background, resume, mode, groupID, parentSession: ctx.sessionID });
17833
17912
  const sessionClient = client;
17834
17913
  if (background === void 0) {
17835
17914
  return `${OUTPUT_LABEL.ERROR} 'background' parameter is REQUIRED.`;
@@ -17842,8 +17921,10 @@ var createDelegateTaskTool = (manager, client) => tool({
17842
17921
  parentSessionID: ctx.sessionID,
17843
17922
  agent,
17844
17923
  // Assuming agent is needed for resume context
17845
- description
17924
+ description,
17846
17925
  // Assuming description is needed for resume context
17926
+ mode,
17927
+ groupID
17847
17928
  };
17848
17929
  const launchResult = await manager.launch(input);
17849
17930
  const task = Array.isArray(launchResult) ? launchResult[0] : launchResult;
@@ -17881,7 +17962,9 @@ ${text || "(No output)"}`;
17881
17962
  agent,
17882
17963
  description,
17883
17964
  prompt,
17884
- parentSessionID: ctx.sessionID
17965
+ parentSessionID: ctx.sessionID,
17966
+ mode,
17967
+ groupID
17885
17968
  });
17886
17969
  const task = Array.isArray(launchResult) ? launchResult[0] : launchResult;
17887
17970
  presets.taskStarted(task.id, agent);
@@ -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: 3;
8
- readonly DEFAULT_CONCURRENCY: 3;
9
- readonly MAX_CONCURRENCY: 10;
12
+ readonly MAX_DEPTH: 5;
13
+ readonly DEFAULT_CONCURRENCY: 5;
14
+ readonly MAX_CONCURRENCY: 20;
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.7",
5
+ "version": "1.0.10",
6
6
  "author": "agnusdei1207",
7
7
  "license": "MIT",
8
8
  "repository": {