JSPM

opencode-orchestrator

0.8.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1820
  • Score
    100M100P100Q103513F
  • License MIT

Distributed Cognitive Architecture for OpenCode. Turns simple prompts into specialized multi-agent workflows (Planner, Coder, Reviewer).

Package Exports

  • opencode-orchestrator

Readme

Logo

OpenCode Orchestrator

Autonomous multi-agent plugin for OpenCode

MIT License npm Tests


Overview

Multi-agent system that autonomously executes complex tasks. Commander delegates work to specialized agents, manages parallel execution, and maintains shared context.

Capability Detail
Agents 4 consolidated (Commander, Planner, Worker, Reviewer)
Parallel Sessions Up to 50 concurrent Worker Sessions
Context Management .opencode/ with adaptive summarization
Memory Safety Auto GC, disk archiving
Error Handling Pattern-based auto recovery + session recovery
Todo Continuation Auto-continues when todos remain
Smart Notifications TaskToastManager with consolidated views

πŸ›οΈ Master Session Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                           πŸ‘€ USER REQUEST                                   β”‚
β”‚                        "/task Build a REST API"                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                     β”‚
                                     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    🎯 MASTER SESSION (Commander Agent)                      β”‚
β”‚                                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ 1️⃣ THINK     β†’ Analyze request, assess complexity (L1/L2/L3)         β”‚  β”‚
β”‚  β”‚ 2️⃣ PLAN      β†’ Create .opencode/todo.md via Planner                  β”‚  β”‚
β”‚  β”‚ 3️⃣ DELEGATE  β†’ Spawn Worker Sessions via delegate_task              β”‚  β”‚
β”‚  β”‚ 4️⃣ MONITOR   β†’ Watch .opencode/ for progress, handle completions     β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  Session State  β”‚  β”‚               4 CONSOLIDATED AGENTS             β”‚  β”‚
β”‚  β”‚  Map<id,state>  β”‚  β”‚  🎯 Commander  πŸ“‹ Planner                       β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  πŸ”¨ Worker     βœ… Reviewer                       β”‚  β”‚
β”‚                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  β”‚  Plugin Hooks   β”‚                                                       β”‚
β”‚  β”‚  event          β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  chat.message   β”‚  β”‚ πŸ”„ SessionRecovery (auto error handling)        β”‚  β”‚
β”‚  β”‚  tool.execute   β”‚  β”‚ πŸ“‹ TodoContinuation (auto-resume on idle)       β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚ πŸ“£ TaskToastManager (consolidated notifications)β”‚  β”‚
β”‚                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                     β”‚
                        delegate_task (async)
                                     β”‚
           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
           β–Ό                         β–Ό                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  ⚑ Worker Session 1 β”‚  β”‚  ⚑ Worker Session 2 β”‚  β”‚  ⚑ Worker Session N β”‚
β”‚  Agent: Planner     β”‚  β”‚  Agent: Worker      β”‚  β”‚  Agent: Reviewer    β”‚
β”‚                     β”‚  β”‚                     β”‚  β”‚                     β”‚
β”‚  β€’ Independent exec β”‚  β”‚  β€’ Independent exec β”‚  β”‚  β€’ Independent exec β”‚
β”‚  β€’ Read/Write       β”‚  β”‚  β€’ Read/Write       β”‚  β”‚  β€’ Read/Write       β”‚
β”‚    .opencode/       β”‚  β”‚    .opencode/       β”‚  β”‚    .opencode/       β”‚
β”‚  β€’ Notify parent    β”‚  β”‚  β€’ Notify parent    β”‚  β”‚  β€’ Notify parent    β”‚
β”‚    on complete      β”‚  β”‚    on complete      β”‚  β”‚    on complete      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚                         β”‚                         β”‚
           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    πŸ“ SHARED CONTEXT (.opencode/)                           β”‚
β”‚                                                                             β”‚
β”‚  .opencode/todo.md     ← Master TODO (Planner creates, Reviewer updates)  β”‚
β”‚  .opencode/context.md  ← Adaptive context (shrinks as progress increases)  β”‚
β”‚  .opencode/docs/       ← Cached docs (Planner/Worker save, auto-expire)    β”‚
β”‚  .opencode/archive/    ← Old context for reference                         β”‚
β”‚                                                                             β”‚
β”‚  ⚑ All sessions read/write this shared workspace                           β”‚
β”‚  πŸ“Š Progress is tracked via todo.md checkboxes                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Installation

npm install -g opencode-orchestrator

Restart OpenCode after installation.


Usage

πŸš€ Two Modes of Operation

Mode Trigger Behavior
Commander Mode 🎯 /task "mission" Full autonomous execution until sealed
Chat Mode πŸ’¬ Regular conversation Simple Q&A, no autonomous behavior

Use /task when you need the AI to complete a mission autonomously:

/task "Fix the login bug in the docker-compose environment"
/task "Add dark mode support to the entire app"
/task "Refactor the API to use TypeScript"

What Commander Mode Does:

  • ♾️ Runs until sealed β€” Loops until agent outputs <mission_seal>SEALED</mission_seal>
  • 🧠 Anti-Hallucination β€” Researches docs before coding
  • ⚑ Parallel Execution β€” Up to 50 concurrent agents
  • πŸ”„ Auto-Recovery β€” Handles errors automatically
  • πŸ“Š Triage System β€” Adapts strategy to complexity (L1/L2/L3)

πŸŽ–οΈ Mission Seal Loop:

/task "mission" β†’ Agent works β†’ Idle? β†’ Seal found? 
                       ↑              β”‚
                       β”‚      No      β”‚ Yes
                       └──────────────┴──→ βœ… Complete

When the agent finishes ALL work, it outputs:

<mission_seal>SEALED</mission_seal>

Control Commands:

  • /stop or /cancel β€” Stop the loop manually
  • Max 20 iterations (configurable)
Commander TUI

/task "mission" triggers full Commander mode with Mission Seal loop


πŸ’¬ Chat Mode - Regular Conversation (Simple Q&A)

Just type normally without /task for simple questions:

How do I add a loading spinner?
What's the difference between useState and useReducer?

Chat Mode is just regular conversation β€” no autonomous execution, no parallel agents, no mission tracking.


πŸ’‘ Pro Tip: Use /task for anything that requires multiple steps, file changes, or verification. Use Chat Mode for quick questions.


The 7 Agents

Agent Role Responsibility
Commander 🎯 Orchestrator Autonomous mission control
Planner πŸ“‹ Planner + Research Task decomposition, research, caching docs
Worker πŸ”¨ Developer + Docs Full-stack implementation, documentation
Reviewer βœ… Quality + Context Verification, TODO updates, context management

πŸ› οΈ Available Tools

Tool Description
delegate_task Delegate work to subagent (async/sync)
get_task_result Get result from delegated task
list_tasks List all running/completed tasks
cancel_task Cancel a running task
webfetch Fetch URL content as Markdown
websearch Search web (SearXNG β†’ Brave β†’ DuckDuckGo)
codesearch Search open source code patterns
cache_docs Manage cached documentation
run_background Run command in background
check_background / list_background Monitor background jobs
grep_search / glob_search / mgrep Fast file search

πŸ“Š Resource Guarantees

Resource Limit Safety Mechanism
Parallel Sessions 50 Queue overflow protection
Tasks in Memory 1,000 Auto GC + disk archive
Notifications 100/parent FIFO eviction
Event History 100 Ring buffer
Session TTL 60 min Auto cleanup
Poll Interval 1 second Fast completion detection
Max Poll Count 600 Hard limit prevents infinite loops
Sync Timeout 5 min Safe delegate_task timeout
Recovery Attempts 3 Auto session error recovery

πŸ§ͺ Test Coverage

Test Files:  19 passed
Tests:       216 passed
Duration:    ~4.3s

πŸ”„ Reliability Features

Session Recovery

Automatic recovery from common errors:

  • tool_result_missing - Tool crash recovery
  • thinking_block_order - Thinking block issues
  • rate_limit - API rate limiting with backoff
  • Max 3 recovery attempts per session

Todo Continuation

  • Monitors session.idle events
  • 2-second countdown before auto-continuation
  • Cancels on user interaction
  • Skips if background tasks running

noReply Optimization

  • Individual task completion: noReply: true (saves tokens)
  • All tasks complete: noReply: false (AI processes results)

Uninstall

npm uninstall -g opencode-orchestrator

πŸ”§ Debugging

Log file location:

# Find log path (macOS uses /var/folders/...)
npm run log
# or:
tail -f "$(node -e 'console.log(require("os").tmpdir())')/opencode-orchestrator.log"

# Windows
# C:\Users\<username>\AppData\Local\Temp\opencode-orchestrator.log

Documentation


License

MIT License. LICENSE


Enterprise-scale. Memory-safe. Self-healing. Unlimited.