JSPM

opencode-orchestrator

0.8.15
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2599
  • Score
    100M100P100Q105800F
  • 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

πŸ›οΈ Architecture Overview

πŸš€ User Flow: Real Scenario

Example: /task "Build a REST API with user authentication"

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  πŸ‘€ USER: /task "Build a REST API with user authentication"                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β”‚
                                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          🎯 COMMANDER (Master Session)                          β”‚
β”‚                                                                                 β”‚
β”‚  "I'll break this into parallel tasks and delegate to specialized agents"      β”‚
β”‚                                                                                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚  πŸ“‹ Creates TODO.md:                                                    β”‚    β”‚
β”‚  β”‚  - [ ] Research: Express.js + JWT best practices                        β”‚    β”‚
β”‚  β”‚  - [ ] Setup: Project structure + dependencies                          β”‚    β”‚
β”‚  β”‚  - [ ] Implement: User model + auth routes                              β”‚    β”‚
β”‚  β”‚  - [ ] Test: API endpoints verification                                 β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                        β”‚                        β”‚
              β–Ό                        β–Ό                        β–Ό

    ╔═══════════════════╗   ╔═══════════════════╗   ╔═══════════════════╗
    β•‘ πŸ” PLANNER        β•‘   β•‘ πŸ”¨ WORKER #1      β•‘   β•‘ πŸ”¨ WORKER #2      β•‘
    β•‘ Session: ses_001  β•‘   β•‘ Session: ses_002  β•‘   β•‘ Session: ses_003  β•‘
    ╠═══════════════════╣   ╠═══════════════════╣   ╠═══════════════════╣
    β•‘ Research Express  β•‘   β•‘ Create src/       β•‘   β•‘ Write auth.ts     β•‘
    β•‘ + JWT docs        β•‘   β•‘ Setup package.jsonβ•‘   β•‘ + user.model.ts   β•‘
    β•‘                   β•‘   β•‘                   β•‘   β•‘                   β•‘
    β•‘ πŸ“₯ websearch()    β•‘   β•‘ πŸ“₯ write files    β•‘   β•‘ πŸ“₯ write files    β•‘
    β•‘ ⏳ cache_docs()   β•‘   β•‘ ⏳ run_background β•‘   β•‘                   β•‘
    β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•   β•‘    β†’ npm install  β•‘   β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
              β”‚             β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•             β”‚
              β”‚                        β”‚                      β”‚
              β”‚    ⚑ ALL RUN IN PARALLEL (async: true)       β”‚
              β”‚    ⏱️ Commander monitors, doesn't wait        β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         πŸ”„ BACKGROUND PROCESSES                                 β”‚
β”‚                                                                                 β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                β”‚
β”‚   β”‚ npm install     β”‚  β”‚ npm run build   β”‚  β”‚ npm test        β”‚                β”‚
β”‚   β”‚ (bg_cmd_001)    β”‚  β”‚ (bg_cmd_002)    β”‚  β”‚ (bg_cmd_003)    β”‚                β”‚
β”‚   β”‚ ⏳ running...   β”‚  β”‚ ⏳ running...   β”‚  β”‚ ⏳ pending...   β”‚                β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β”‚
β”‚                                                                                 β”‚
β”‚   β€’ Check with: check_background / list_background                              β”‚
β”‚   β€’ Non-blocking: Commander continues other work                                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β”‚
                                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         πŸ“Š ASYNC RESULT COLLECTION                              β”‚
β”‚                                                                                 β”‚
β”‚   get_task_result("ses_001") ──▢ βœ… Planner done: "Found JWT patterns..."      β”‚
β”‚   get_task_result("ses_002") ──▢ βœ… Worker #1 done: "Project setup complete"   β”‚
β”‚   get_task_result("ses_003") ──▢ ⏳ Still running...                            β”‚
β”‚                                                                                 β”‚
β”‚   Commander: "Worker #2 still working, I'll delegate review task meanwhile"    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β”‚
                                       β–Ό
    ╔═══════════════════╗
    β•‘ βœ… REVIEWER       β•‘
    β•‘ Session: ses_004  β•‘
    ╠═══════════════════╣
    β•‘ Verify endpoints  β•‘
    β•‘ Update TODO.md:   β•‘
    β•‘  - [x] Research βœ“ β•‘
    β•‘  - [x] Setup βœ“    β•‘
    β•‘  - [x] Implement βœ“β•‘
    β•‘  - [x] Test βœ“     β•‘
    β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
              β”‚
              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          πŸŽ–οΈ MISSION COMPLETE                                    β”‚
β”‚                                                                                 β”‚
β”‚   Commander: "All TODOs checked. Mission complete."                             β”‚
β”‚                                                                                 β”‚
β”‚   Output: <mission_seal>SEALED</mission_seal>                                   β”‚
β”‚                                                                                 β”‚
β”‚   βœ… Session cleanup β†’ Resources freed β†’ Ready for next mission                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Concepts Visualized:

Concept How It Works
Session Each agent runs in isolated session (ses_001, ses_002...)
Parallel Agents Multiple Workers execute simultaneously, not sequentially
Background Commands Long-running commands (npm install) don't block agents
Async Collection Commander polls results, continues work while waiting
Auto-Continue If TODOs remain, loop continues until all [x] checked

πŸ“Š Project Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         OpenCode Orchestrator Plugin                            β”‚
β”‚                              src/index.ts                                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β–Ό                           β–Ό                           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Plugin Hooks      β”‚  β”‚   Core Systems      β”‚  β”‚         Tools               β”‚
β”‚   plugin-handlers/  β”‚  β”‚   src/core/         β”‚  β”‚       src/tools/            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β€’ chat.message      β”‚  β”‚ β€’ agents/           β”‚  β”‚ β€’ parallel/                 β”‚
β”‚ β€’ event             β”‚  β”‚   ParallelManager   β”‚  β”‚   delegate_task             β”‚
β”‚ β€’ tool.execute      β”‚  β”‚   TaskStore         β”‚  β”‚   get_task_result           β”‚
β”‚ β€’ assistant.done    β”‚  β”‚   Concurrency       β”‚  β”‚ β€’ web/                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚ β€’ loop/             β”‚  β”‚   webfetch, websearch       β”‚
                         β”‚   MissionSeal       β”‚  β”‚ β€’ background-cmd/           β”‚
                         β”‚   TodoContinuation  β”‚  β”‚   run_background            β”‚
                         β”‚ β€’ recovery/         β”‚  β”‚ β€’ search                    β”‚
                         β”‚   SessionRecovery   β”‚  β”‚   grep, glob, mgrep         β”‚
                         β”‚ β€’ notification/     β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚   Toast, Manager    β”‚
                         β”‚ β€’ session/          β”‚
                         β”‚   SharedContext     β”‚
                         β”‚ β€’ cache/            β”‚
                         β”‚   DocumentCache     β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β–Ό                           β–Ό                           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   🎯 Commander       β”‚  β”‚   πŸ“‹ Planner        β”‚  β”‚   πŸ”¨ Worker          β”‚
β”‚   Orchestrator      β”‚  β”‚   Research+Plan     β”‚  β”‚   Implementation    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β€’ Mission control   β”‚  β”‚ β€’ Task decompose    β”‚  β”‚ β€’ Code writing      β”‚
β”‚ β€’ Parallel delegate β”‚  β”‚ β€’ Doc research      β”‚  β”‚ β€’ File operations   β”‚
β”‚ β€’ TODO monitoring   β”‚  β”‚ β€’ TODO creation     β”‚  β”‚ β€’ Command execution β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                           β”‚                           β”‚
          β”‚                           β”‚                           β”‚
          β”‚                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”                  β”‚
          β”‚                  β–Ό                 β”‚                  β”‚
          β”‚       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”‚                  β”‚
          β”‚       β”‚   βœ… Reviewer        β”‚      β”‚                  β”‚
          β”‚       β”‚   Quality+Context   β”‚      β”‚                  β”‚
          β”‚       β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€      β”‚                  β”‚
          β”‚       β”‚ β€’ Verification      β”‚      β”‚                  β”‚
          β”‚       β”‚ β€’ TODO updates      β”‚      β”‚                  β”‚
          β”‚       β”‚ β€’ Context manage    β”‚      β”‚                  β”‚
          β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β”‚                  β”‚
          β”‚                  β”‚                 β”‚                  β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        πŸ“ Shared Workspace (.opencode/)                         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  todo.md          β”‚ Hierarchical task list (Epic β†’ Task β†’ Subtask)             β”‚
β”‚  context.md       β”‚ Adaptive context (shrinks with progress)                   β”‚
β”‚  loop-state.json  β”‚ Mission loop iteration state                               β”‚
β”‚  docs/            β”‚ Cached documentation (auto-expire)                         β”‚
β”‚  archive/         β”‚ Old context snapshots                                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“‚ Directory Structure

src/
β”œβ”€β”€ index.ts                      # Plugin main entry point
β”œβ”€β”€ agents/
β”‚   β”œβ”€β”€ commander.ts              # Commander agent definition
β”‚   β”œβ”€β”€ definitions.ts            # Agent exports
β”‚   β”œβ”€β”€ prompts/                  # Prompt fragments (commander/, planner/, worker/, reviewer/)
β”‚   └── subagents/                # Subagent definitions (planner.ts, worker.ts, reviewer.ts)
β”œβ”€β”€ core/
β”‚   β”œβ”€β”€ agents/                   # ParallelAgentManager, TaskStore, ConcurrencyController
β”‚   β”œβ”€β”€ cache/                    # DocumentCache
β”‚   β”œβ”€β”€ loop/                     # MissionSeal, TodoContinuation, TodoEnforcer
β”‚   β”œβ”€β”€ notification/             # Toast, TaskToastManager
β”‚   β”œβ”€β”€ recovery/                 # SessionRecovery, ErrorPatterns
β”‚   β”œβ”€β”€ session/                  # SharedContext
β”‚   └── task/                     # TaskScheduler, TaskParser
β”œβ”€β”€ plugin-handlers/
β”‚   β”œβ”€β”€ chat-message-handler.ts   # /task detection, mission start
β”‚   β”œβ”€β”€ event-handler.ts          # session.idle, session.error handling
β”‚   β”œβ”€β”€ tool-execute-handler.ts   # Tool completion tracking
β”‚   └── assistant-done-handler.ts # Response completion
β”œβ”€β”€ shared/
β”‚   β”œβ”€β”€ constants/                # PATHS, TOOL_NAMES, MISSION_SEAL, etc.
β”‚   β”œβ”€β”€ agent/                    # Agent definitions, names
β”‚   └── errors/                   # Error types
β”œβ”€β”€ tools/
β”‚   β”œβ”€β”€ parallel/                 # delegate_task, get_task_result, list_tasks, cancel_task
β”‚   β”œβ”€β”€ web/                      # webfetch, websearch, codesearch, cache_docs
β”‚   β”œβ”€β”€ background-cmd/           # run_background, check_background, list_background
β”‚   └── search.ts                 # grep_search, glob_search, mgrep
└── utils/                        # Utility functions

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 Worker Sessions
  • πŸ”„ Auto-Recovery β€” Handles errors automatically with pattern matching
  • πŸ“Š Progress Tracking β€” Monitors TODO completion and shows progress

Concurrency Limits (per agent type):

Agent Max Concurrent Purpose
Commander 1 Single orchestrator per mission
Planner 3 Research and TODO planning
Worker 10 Implementation tasks
Reviewer 5 Verification and testing

πŸŽ–οΈ 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.


πŸ”„ Mission Loop Mechanism

The Commander uses an event-driven mission loop to autonomously complete missions:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  MISSION LOOP LIFECYCLE                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

1️⃣ User sends "/task 'mission'"
    ↓
2️⃣ chat.message handler detects /task
    ↓
3️⃣ Create session + startMissionLoop()
    ↓
    Write .opencode/loop-state.json:
    {
      "active": true,
      "sessionID": "ses_abc",
      "iteration": 1,
      "maxIterations": 20
    }
    ↓
4️⃣ Commander receives prompt β†’ delegates work
    ↓
5️⃣ Worker sessions execute β†’ results collected
    ↓
6️⃣ session.idle event triggers
    ↓
    Check for <mission_seal>SEALED</mission_seal>
    β”œβ”€ Seal found? β†’ Clear loop state β†’ Complete βœ…
    └─ Not found? β†’ Increment iteration β†’ Continue loop
         ↓
         Show countdown toast (3 seconds)
         ↓
         Inject continuation prompt
         ↓
         [Loop back to step 4]

Key Loop Components:

Component File Purpose
Loop State src/core/loop/mission-seal.ts State management (.opencode/loop-state.json)
Seal Detection src/core/loop/mission-seal-handler.ts Detect <mission_seal> in responses
Continuation src/core/loop/mission-seal-handler.ts Inject prompts to continue work
Countdown src/core/loop/mission-seal-handler.ts 3-second countdown toast
Idle Handler src/plugin-handlers/assistant-done-handler.ts Monitor session.idle events

Why Event-Driven?

  • No fixed iteration limits - loop continues until sealed
  • Resilient to network delays
  • Can be interrupted by user at any time
  • Efficient polling (500ms interval with backoff)

The 4 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 500ms 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
  • 3-second countdown toast before auto-continuation
  • Cancels on user interaction
  • Skips if background tasks running or session is recovering

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.