opencode-orchestrator 1.2.17 → 1.2.23

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.
Files changed (275) hide show
  1. package/README.md +41 -91
  2. package/dist/core/agents/adaptive-concurrency.d.ts +57 -0
  3. package/dist/core/agents/index.d.ts +3 -2
  4. package/dist/core/agents/interfaces/session-pool.interface.d.ts +7 -0
  5. package/dist/core/agents/manager.d.ts +9 -41
  6. package/dist/core/agents/session-pool.d.ts +10 -0
  7. package/dist/core/agents/unified-task-executor.d.ts +27 -0
  8. package/dist/core/mission/mission-controller.d.ts +53 -0
  9. package/dist/core/resource/resource-tracker.d.ts +61 -0
  10. package/dist/index.d.ts +0 -8
  11. package/dist/index.js +6560 -27898
  12. package/dist/scripts/postinstall.js +125 -29
  13. package/dist/shared/constants/system-messages.d.ts +3 -3
  14. package/dist/shared/core/constants/index.d.ts +4 -0
  15. package/dist/shared/core/constants/labels.d.ts +12 -0
  16. package/dist/shared/core/constants/mission.d.ts +8 -0
  17. package/dist/shared/{os/constants/platform.d.ts → core/constants/os.d.ts} +4 -3
  18. package/dist/shared/core/constants/signals.d.ts +22 -0
  19. package/dist/shared/index.d.ts +6 -8
  20. package/dist/shared/prompt/constants/prompts.d.ts +7 -0
  21. package/dist/shared/prompt/constants/tags.d.ts +4 -0
  22. package/dist/shared/prompt/index.d.ts +1 -0
  23. package/dist/shared/session/constants/events/hook-events.d.ts +9 -0
  24. package/dist/shared/session/constants/events/index.d.ts +5 -0
  25. package/dist/shared/session/constants/index.d.ts +2 -0
  26. package/dist/shared/session/constants/message.d.ts +15 -0
  27. package/dist/shared/session/constants/status.d.ts +9 -0
  28. package/dist/shared/session/index.d.ts +1 -0
  29. package/dist/shared/task/constants/parallel-task.d.ts +4 -3
  30. package/dist/tools/parallel/list-agents.d.ts +1 -1
  31. package/dist/utils/common.d.ts +3 -5
  32. package/package.json +3 -3
  33. package/dist/core/agents/agent-registry.d.ts +0 -28
  34. package/dist/core/agents/concurrency.d.ts +0 -38
  35. package/dist/core/agents/config.d.ts +0 -10
  36. package/dist/core/agents/consts/index.d.ts +0 -4
  37. package/dist/core/agents/manager/event-handler.d.ts +0 -35
  38. package/dist/core/agents/manager/index.d.ts +0 -10
  39. package/dist/core/agents/manager/task-cleaner.d.ts +0 -29
  40. package/dist/core/agents/manager/task-launcher.d.ts +0 -35
  41. package/dist/core/agents/manager/task-poller.d.ts +0 -30
  42. package/dist/core/agents/manager/task-resumer.d.ts +0 -18
  43. package/dist/core/agents/persistence/task-wal.d.ts +0 -26
  44. package/dist/core/agents/task-store.d.ts +0 -54
  45. package/dist/core/cleanup/cleanup-scheduler.d.ts +0 -11
  46. package/dist/core/context/context-window-monitor.d.ts +0 -66
  47. package/dist/core/context/index.d.ts +0 -6
  48. package/dist/core/loop/continuation-lock.d.ts +0 -57
  49. package/dist/core/loop/formatters.d.ts +0 -17
  50. package/dist/core/loop/interfaces/index.d.ts +0 -5
  51. package/dist/core/loop/interfaces/todo-stats.d.ts +0 -11
  52. package/dist/core/loop/interfaces/todo.d.ts +0 -13
  53. package/dist/core/loop/interfaces.d.ts +0 -7
  54. package/dist/core/loop/mission-loop-handler.d.ts +0 -25
  55. package/dist/core/loop/mission-loop.d.ts +0 -48
  56. package/dist/core/loop/parser.d.ts +0 -8
  57. package/dist/core/loop/stats.d.ts +0 -24
  58. package/dist/core/loop/todo-continuation.d.ts +0 -39
  59. package/dist/core/loop/todo-enforcer.d.ts +0 -9
  60. package/dist/core/loop/todo-manager.d.ts +0 -22
  61. package/dist/core/loop/types/index.d.ts +0 -5
  62. package/dist/core/loop/types/todo-priority.d.ts +0 -4
  63. package/dist/core/loop/types/todo-status.d.ts +0 -4
  64. package/dist/core/loop/verification.d.ts +0 -27
  65. package/dist/core/memory/interfaces.d.ts +0 -33
  66. package/dist/core/memory/memory-manager.d.ts +0 -40
  67. package/dist/core/metrics/collector.d.ts +0 -27
  68. package/dist/core/notification/os-notify/index.d.ts +0 -7
  69. package/dist/core/notification/os-notify/notifier.d.ts +0 -7
  70. package/dist/core/notification/os-notify/platform-resolver.d.ts +0 -7
  71. package/dist/core/notification/os-notify/platform.d.ts +0 -7
  72. package/dist/core/notification/os-notify/sound-player.d.ts +0 -7
  73. package/dist/core/notification/os-notify/todo-checker.d.ts +0 -5
  74. package/dist/core/notification/task-toast-manager.d.ts +0 -127
  75. package/dist/core/notification/toast-core.d.ts +0 -36
  76. package/dist/core/notification/toast.d.ts +0 -9
  77. package/dist/core/orchestrator/index.d.ts +0 -6
  78. package/dist/core/orchestrator/interfaces/index.d.ts +0 -4
  79. package/dist/core/orchestrator/interfaces/session-state.d.ts +0 -11
  80. package/dist/core/orchestrator/session-manager.d.ts +0 -31
  81. package/dist/core/orchestrator/state.d.ts +0 -10
  82. package/dist/core/orchestrator/types/index.d.ts +0 -4
  83. package/dist/core/orchestrator/types/task-status.d.ts +0 -5
  84. package/dist/core/plugins/interfaces.d.ts +0 -30
  85. package/dist/core/plugins/plugin-manager.d.ts +0 -21
  86. package/dist/core/progress/calculator.d.ts +0 -11
  87. package/dist/core/progress/formatters.d.ts +0 -20
  88. package/dist/core/progress/interfaces/index.d.ts +0 -8
  89. package/dist/core/progress/interfaces/progress-snapshot.d.ts +0 -15
  90. package/dist/core/progress/interfaces/snapshot-input.d.ts +0 -13
  91. package/dist/core/progress/interfaces/step-progress.d.ts +0 -7
  92. package/dist/core/progress/interfaces/task-progress.d.ts +0 -10
  93. package/dist/core/progress/interfaces/todo-progress.d.ts +0 -9
  94. package/dist/core/progress/interfaces.d.ts +0 -6
  95. package/dist/core/progress/progress-notifier.d.ts +0 -14
  96. package/dist/core/progress/state-broadcaster.d.ts +0 -29
  97. package/dist/core/progress/store.d.ts +0 -28
  98. package/dist/core/progress/tracker.d.ts +0 -11
  99. package/dist/core/queue/async-queue.d.ts +0 -46
  100. package/dist/core/queue/async-utils.d.ts +0 -20
  101. package/dist/core/queue/index.d.ts +0 -8
  102. package/dist/core/queue/work-pool.d.ts +0 -19
  103. package/dist/core/recovery/auto-recovery.d.ts +0 -9
  104. package/dist/core/recovery/constants.d.ts +0 -9
  105. package/dist/core/recovery/handler.d.ts +0 -27
  106. package/dist/core/recovery/interfaces/error-context.d.ts +0 -11
  107. package/dist/core/recovery/interfaces/error-pattern.d.ts +0 -10
  108. package/dist/core/recovery/interfaces/index.d.ts +0 -8
  109. package/dist/core/recovery/interfaces/recovery-action.d.ts +0 -25
  110. package/dist/core/recovery/interfaces/recovery-record.d.ts +0 -10
  111. package/dist/core/recovery/interfaces/recovery-stats.d.ts +0 -9
  112. package/dist/core/recovery/interfaces.d.ts +0 -6
  113. package/dist/core/recovery/patterns.d.ts +0 -8
  114. package/dist/core/recovery/retry.d.ts +0 -59
  115. package/dist/core/recovery/session-recovery.d.ts +0 -30
  116. package/dist/core/session/interfaces/context-stats.d.ts +0 -9
  117. package/dist/core/session/interfaces/index.d.ts +0 -8
  118. package/dist/core/session/interfaces/shared-context.d.ts +0 -15
  119. package/dist/core/session/interfaces/shared-decision.d.ts +0 -10
  120. package/dist/core/session/interfaces/shared-document.d.ts +0 -9
  121. package/dist/core/session/interfaces/shared-finding.d.ts +0 -10
  122. package/dist/core/session/interfaces.d.ts +0 -6
  123. package/dist/core/session/session-health.d.ts +0 -93
  124. package/dist/core/session/shared-context.d.ts +0 -8
  125. package/dist/core/session/store.d.ts +0 -44
  126. package/dist/core/session/summary.d.ts +0 -7
  127. package/dist/core/sync/todo-parser.d.ts +0 -5
  128. package/dist/core/sync/todo-sync-service.d.ts +0 -35
  129. package/dist/core/task/interfaces/index.d.ts +0 -8
  130. package/dist/core/task/interfaces/task-hierarchy.d.ts +0 -9
  131. package/dist/core/task/interfaces/task-input.d.ts +0 -11
  132. package/dist/core/task/interfaces/task-node.d.ts +0 -20
  133. package/dist/core/task/interfaces/task-progress.d.ts +0 -11
  134. package/dist/core/task/interfaces.d.ts +0 -6
  135. package/dist/core/task/parser.d.ts +0 -8
  136. package/dist/core/task/scheduler.d.ts +0 -12
  137. package/dist/core/task/store.d.ts +0 -32
  138. package/dist/core/task/summary.d.ts +0 -7
  139. package/dist/core/task/task-decomposer.d.ts +0 -10
  140. package/dist/core/todo/todo-manager.d.ts +0 -36
  141. package/dist/hooks/compatibility/external-plugin.d.ts +0 -10
  142. package/dist/hooks/constants.d.ts +0 -27
  143. package/dist/hooks/custom/agent-ui.d.ts +0 -20
  144. package/dist/hooks/custom/memory-gate.d.ts +0 -21
  145. package/dist/hooks/custom/metrics.d.ts +0 -14
  146. package/dist/hooks/custom/resource-control.d.ts +0 -13
  147. package/dist/hooks/custom/secret-scanner.d.ts +0 -19
  148. package/dist/hooks/custom/strict-role-guard.d.ts +0 -21
  149. package/dist/hooks/custom/user-activity.d.ts +0 -11
  150. package/dist/hooks/features/mission-loop.d.ts +0 -18
  151. package/dist/hooks/features/sanity-check.d.ts +0 -15
  152. package/dist/hooks/index.d.ts +0 -5
  153. package/dist/hooks/registry.d.ts +0 -37
  154. package/dist/hooks/types.d.ts +0 -72
  155. package/dist/plugin-handlers/assistant-done-handler.d.ts +0 -12
  156. package/dist/plugin-handlers/chat-message-handler.d.ts +0 -30
  157. package/dist/plugin-handlers/config-handler.d.ts +0 -9
  158. package/dist/plugin-handlers/event-handler.d.ts +0 -18
  159. package/dist/plugin-handlers/index.d.ts +0 -9
  160. package/dist/plugin-handlers/interfaces/assistant-done-context.d.ts +0 -12
  161. package/dist/plugin-handlers/interfaces/chat-message-context.d.ts +0 -12
  162. package/dist/plugin-handlers/interfaces/event-handler-context.d.ts +0 -14
  163. package/dist/plugin-handlers/interfaces/index.d.ts +0 -12
  164. package/dist/plugin-handlers/interfaces/orchestrator-state.d.ts +0 -14
  165. package/dist/plugin-handlers/interfaces/session-compacting.d.ts +0 -19
  166. package/dist/plugin-handlers/interfaces/session-state.d.ts +0 -15
  167. package/dist/plugin-handlers/interfaces/system-transform.d.ts +0 -17
  168. package/dist/plugin-handlers/interfaces/tool-execute-context.d.ts +0 -8
  169. package/dist/plugin-handlers/interfaces/tool-hook.d.ts +0 -14
  170. package/dist/plugin-handlers/session-compacting-handler.d.ts +0 -14
  171. package/dist/plugin-handlers/system-transform-handler.d.ts +0 -14
  172. package/dist/plugin-handlers/tool-execute-handler.d.ts +0 -14
  173. package/dist/plugin-handlers/tool-execute-pre-handler.d.ts +0 -8
  174. package/dist/shared/errors/constants/error-patterns.d.ts +0 -13
  175. package/dist/shared/errors/constants/error-type.d.ts +0 -13
  176. package/dist/shared/errors/constants/index.d.ts +0 -5
  177. package/dist/shared/errors/detection.d.ts +0 -5
  178. package/dist/shared/errors/index.d.ts +0 -7
  179. package/dist/shared/errors/retry.d.ts +0 -7
  180. package/dist/shared/errors/types/error-pattern-type.d.ts +0 -5
  181. package/dist/shared/errors/types/index.d.ts +0 -4
  182. package/dist/shared/loop/constants/index.d.ts +0 -7
  183. package/dist/shared/loop/constants/labels.d.ts +0 -33
  184. package/dist/shared/loop/constants/loop.d.ts +0 -17
  185. package/dist/shared/loop/constants/mission-control.d.ts +0 -20
  186. package/dist/shared/loop/constants/todo-status.d.ts +0 -9
  187. package/dist/shared/loop/index.d.ts +0 -6
  188. package/dist/shared/loop/interfaces/index.d.ts +0 -6
  189. package/dist/shared/loop/interfaces/mission-loop.d.ts +0 -29
  190. package/dist/shared/loop/interfaces/todo-stats.d.ts +0 -11
  191. package/dist/shared/loop/interfaces/todo.d.ts +0 -13
  192. package/dist/shared/loop/types/index.d.ts +0 -5
  193. package/dist/shared/loop/types/todo-priority.d.ts +0 -4
  194. package/dist/shared/loop/types/todo-status.d.ts +0 -4
  195. package/dist/shared/message/constants/index.d.ts +0 -8
  196. package/dist/shared/message/constants/message-roles.d.ts +0 -23
  197. package/dist/shared/message/constants/part-types.d.ts +0 -13
  198. package/dist/shared/message/constants/plugin-hooks.d.ts +0 -15
  199. package/dist/shared/message/constants/prompts.d.ts +0 -8
  200. package/dist/shared/message/constants/slash-commands.d.ts +0 -21
  201. package/dist/shared/message/index.d.ts +0 -4
  202. package/dist/shared/notification/constants/index.d.ts +0 -3
  203. package/dist/shared/notification/constants/toast-duration.d.ts +0 -19
  204. package/dist/shared/notification/constants/toast-variants.d.ts +0 -10
  205. package/dist/shared/notification/constants/tui.const.d.ts +0 -24
  206. package/dist/shared/notification/index.d.ts +0 -7
  207. package/dist/shared/notification/interfaces/index.d.ts +0 -6
  208. package/dist/shared/notification/interfaces/task-toast.interface.d.ts +0 -18
  209. package/dist/shared/notification/interfaces/toast-message.d.ts +0 -13
  210. package/dist/shared/notification/interfaces/toast-options.d.ts +0 -10
  211. package/dist/shared/notification/os-notify/constants/index.d.ts +0 -6
  212. package/dist/shared/notification/os-notify/constants/notification-command-keys.d.ts +0 -11
  213. package/dist/shared/notification/os-notify/constants/notification-commands.d.ts +0 -11
  214. package/dist/shared/notification/os-notify/constants/notification-defaults.d.ts +0 -5
  215. package/dist/shared/notification/os-notify/index.d.ts +0 -6
  216. package/dist/shared/notification/os-notify/interfaces/index.d.ts +0 -5
  217. package/dist/shared/notification/os-notify/interfaces/notification-config.d.ts +0 -15
  218. package/dist/shared/notification/os-notify/interfaces/notification-state.d.ts +0 -13
  219. package/dist/shared/notification/os-notify/types/index.d.ts +0 -4
  220. package/dist/shared/notification/os-notify/types/notification-commands.d.ts +0 -5
  221. package/dist/shared/notification/presets/index.d.ts +0 -9
  222. package/dist/shared/notification/presets/mission.d.ts +0 -5
  223. package/dist/shared/notification/presets/parallel.d.ts +0 -6
  224. package/dist/shared/notification/presets/session.d.ts +0 -6
  225. package/dist/shared/notification/presets/task-lifecycle.d.ts +0 -7
  226. package/dist/shared/notification/presets/tools.d.ts +0 -6
  227. package/dist/shared/notification/presets/warnings.d.ts +0 -7
  228. package/dist/shared/notification/types/index.d.ts +0 -4
  229. package/dist/shared/notification/types/toast-variant.d.ts +0 -4
  230. package/dist/shared/os/constants/index.d.ts +0 -4
  231. package/dist/shared/os/index.d.ts +0 -5
  232. package/dist/shared/os/types/index.d.ts +0 -4
  233. package/dist/shared/os/types/platform.d.ts +0 -5
  234. package/dist/shared/recovery/constants/history.d.ts +0 -11
  235. package/dist/shared/recovery/constants/index.d.ts +0 -6
  236. package/dist/shared/recovery/constants/recovery-level.d.ts +0 -15
  237. package/dist/shared/recovery/constants/recovery.d.ts +0 -13
  238. package/dist/shared/recovery/index.d.ts +0 -6
  239. package/dist/shared/recovery/interfaces/error-context.d.ts +0 -11
  240. package/dist/shared/recovery/interfaces/index.d.ts +0 -5
  241. package/dist/shared/recovery/interfaces/recovery-record.d.ts +0 -10
  242. package/dist/shared/recovery/types/index.d.ts +0 -4
  243. package/dist/shared/recovery/types/recovery-action.d.ts +0 -4
  244. package/dist/shared/verification/constants/categories.d.ts +0 -95
  245. package/dist/shared/verification/constants/checklist.d.ts +0 -16
  246. package/dist/shared/verification/constants/index.d.ts +0 -7
  247. package/dist/shared/verification/constants/patterns.d.ts +0 -19
  248. package/dist/shared/verification/constants/signals.d.ts +0 -10
  249. package/dist/shared/verification/index.d.ts +0 -8
  250. package/dist/shared/verification/interfaces/checklist-item.d.ts +0 -21
  251. package/dist/shared/verification/interfaces/checklist-verification-result.d.ts +0 -24
  252. package/dist/shared/verification/interfaces/index.d.ts +0 -7
  253. package/dist/shared/verification/interfaces/verification-checklist.d.ts +0 -19
  254. package/dist/shared/verification/interfaces/verification-result.d.ts +0 -29
  255. package/dist/shared/verification/types/checklist-category.d.ts +0 -18
  256. package/dist/shared/verification/types/index.d.ts +0 -4
  257. package/dist/tools/parallel/show-metrics.d.ts +0 -10
  258. package/dist/tools/parallel/update-todo.d.ts +0 -7
  259. package/dist/utils/compatibility/claude.d.ts +0 -9
  260. package/dist/utils/formatting/elapsed-time.d.ts +0 -4
  261. package/dist/utils/formatting/index.d.ts +0 -5
  262. package/dist/utils/formatting/timestamp.d.ts +0 -4
  263. package/dist/utils/parsing/index.d.ts +0 -4
  264. package/dist/utils/parsing/slash-command.d.ts +0 -7
  265. package/dist/utils/sanity/checker.d.ts +0 -8
  266. package/dist/utils/sanity/constants/escalation-prompt.d.ts +0 -4
  267. package/dist/utils/sanity/constants/index.d.ts +0 -6
  268. package/dist/utils/sanity/constants/recovery-prompt.d.ts +0 -4
  269. package/dist/utils/sanity/constants/severity.d.ts +0 -8
  270. package/dist/utils/sanity/index.d.ts +0 -7
  271. package/dist/utils/sanity/interfaces/index.d.ts +0 -4
  272. package/dist/utils/sanity/interfaces/sanity-result.d.ts +0 -9
  273. package/dist/utils/sanity/types/index.d.ts +0 -4
  274. package/dist/utils/sanity/types/severity.d.ts +0 -5
  275. /package/dist/{core/agents/consts/task-status.const.d.ts → shared/task/constants/task-status.d.ts} +0 -0
package/README.md CHANGED
@@ -2,10 +2,9 @@
2
2
  <img src="assets/logo.png" alt="logo" width="200" />
3
3
  <h1>OpenCode Orchestrator</h1>
4
4
 
5
- <p>Autonomous Multi-Agent Orchestration Engine for High-Integrity Software Engineering</p>
5
+ <p>Native-First Autonomous Multi-Agent Engine for High-Integrity Software Engineering</p>
6
6
 
7
7
  [![MIT License](https://img.shields.io/badge/license-MIT-red.svg)](LICENSE)
8
- [![npm](https://img.shields.io/npm/v/opencode-orchestrator.svg)](https://www.npmjs.com/package/opencode-orchestrator)
9
8
  </div>
10
9
 
11
10
  ---
@@ -13,117 +12,68 @@
13
12
  ## ⚡ Quick Start
14
13
 
15
14
  ```bash
16
- npm install -g opencode-orchestrator
15
+ /task "Refactor the authentication module and add unit tests"
17
16
  ```
18
17
 
19
- Inside an OpenCode environment:
20
- ```bash
21
- /task "Implement a new authentication module with JWT and audit logs"
22
- ```
23
-
24
- ---
25
-
26
- ## 🚀 Engine Workflow
18
+ ## 🚀 Engine Architecture (v2)
27
19
 
28
- OpenCode Orchestrator utilizes a **Hub-and-Spoke Topology** to execute complex engineering tasks through parallel, context-isolated sessions.
20
+ OpenCode Orchestrator utilizes a **Native-First Loop** to manage autonomous missions with extreme reliability and resource efficiency.
29
21
 
30
22
  ```text
31
- [ User Task ]
23
+ [ User Mission ]
32
24
 
33
- ┌──────────▼──────────┐
34
- COMMANDER │◄───────────┐ (Loop Phase)
35
- └────────┬────────────┘
36
-
37
- ┌────────▼──────────┐
38
- PLANNER │ (Todo.md)
39
- └────────┬──────────┘
40
- (MVCC Atomic Sync)
41
- ┌─────────────┼──────────────┐
42
- (Isolated Session Pool)
43
- [ Session A ] [ Session B ] [ Session C ]
44
- [ Worker ] [ Worker ] [ Reviewer ]
45
- └─────────────┬──────────────┘
46
-
47
- ┌────────▼──────────┐
48
- │ MSVP MONITOR │──────────────┘
49
- └────────┬──────────┘
50
-
51
- ┌────────▼──────────┐
52
- │ QUALITY ASSURANCE │
53
- └────────┬──────────┘
54
-
55
- [ ✨COMPLETED ]
25
+ ┌─────────▼─────────┐
26
+ MissionController │◄──────────┐ (Idle-Triggered Loop)
27
+ └─────────┬─────────┘
28
+
29
+ ┌─────────▼─────────┐ (Native Todo Sync)
30
+ COMMANDER │ (Native)
31
+ └─────────┬─────────┘
32
+
33
+ ┌─────────────┼──────────────┐
34
+
35
+ [ Planner ] [ Worker ] [ Reviewer ]
36
+ └─────────────┬──────────────┘
37
+
38
+ ┌─────────▼─────────┐
39
+ ResourceTracker │───────────┘
40
+ └─────────┬─────────┘
41
+
42
+ [ ✨MISSION COMPLETE ]
56
43
  ```
57
44
 
58
45
  ---
59
46
 
60
- ## 🛠️ Technical Excellence
61
-
62
- ### ️ Atomic MVCC State Synchronization
63
- The engine solves the "Concurrent TODO Update" problem using **Multi-Version Concurrency Control (MVCC) + Mutex**. Agents can safely mark tasks as complete in parallel without data loss or race conditions. Every state change is kryptographically hashed and logged for a complete audit trail.
64
-
65
- ### 🧩 Advanced Hook Orchestration
66
- Execution flows are governed by a **Priority-Phase Hook Registry**. Hooks (Safety, UI, Protocol) are grouped into phases (`early`, `normal`, `late`) and executed using a **Topological Sort** to handle complex dependencies automatically, ensuring a predictable and stable environment.
67
-
68
- ### ️ Autonomous Recovery
69
- - **Self-healing loops** with adaptive stagnation detection.
70
- - **Proactive Agency**: Smart monitoring that audits logs and plans ahead during background tasks.
71
-
72
- ### ️ State-Level Session Isolation
73
- Reused sessions in the **SessionPool** are explicitly reset using server-side compaction triggered by health monitors. This ensures that previous task context (old error messages, stale file references) never leaks into new tasks, maintaining 100% implementation integrity.
74
-
75
- ### 🚀 Zero-Payload Turbo Mode
76
- Leverages `system.transform` to unshift massive agent instruction sets on the server side. This reduces initial message payloads by **90%+**, slashing latency and preventing context fragmentation during long autonomous loops.
77
-
78
- ---
79
-
80
47
  ## 🛠️ Key Innovations
81
48
 
82
- ### 🧠 Hierarchical Memory System
83
- Maintains focus across thousands of conversation turns using a 4-tier memory structure and **EMA-based Context Gating** to preserve "Architectural Truth" while pruning operational noise.
84
-
85
- ### Dynamic Concurrency Auto-Scaling
86
- Slots for parallel implementation scale up automatically after a **3-success streak** and scale down aggressively upon detection of API instability or implementation failures.
49
+ ### 🏗️ Native-First Orchestration
50
+ Directly integrated with OpenCode's **Native Todo** and **Session API**. By using the host's infrastructure for state management, we've reduced internal code complexity by 70% while drastically increasing reliability and performance.
87
51
 
88
- ### 🛡️ Neuro-Symbolic Safety
89
- Combines LLM reasoning with deterministic **AST/LSP verification**. Every code change is verified by native system tools before being accepted into the master roadmap.
52
+ ### 🧠 Adaptive Concurrency Control
53
+ Execution slots for parallel agents are no longer fixed. Our **Adaptive Controller** dynamically scales slots based on real-time success rates and API latency—scaling up for speed and down for stability.
90
54
 
91
- ### 🔄 Adaptive Intelligence Loop
92
- - **Stagnation Detection**: Automatically senses when no progress is made across multiple iterations.
93
- - **Diagnostic Intervention**: Forces the agent into a "Diagnostic Mode" when stagnation is detected, mandating log audits and strategy pivots.
94
- - **Proactive Agency**: Mandates Speculative Planning and Parallel Thinking during background task execution.
55
+ ### 🛡️ Resource Integrity Protocol
56
+ The **ResourceTracker** ensures that every session, timer, and asynchronous resource is safely reclaimed. No "zombie" sessions or memory leaks, even during complex agent delegation chains.
95
57
 
96
- ### 📊 Native TUI Integration
97
- Seamless integration with OpenCode's native TUI via **TaskToastManager**. Provides non-intrusive, real-time feedback on **Mission Progress**, active **Agent Sub-sessions**, and **Technical Metrics** using protocol-safe Toast notifications.
98
-
99
- ### ⚡ Event-Driven Architecture
100
- Utilizes a hybrid event-driven pipeline (`EventHandler` + `TaskPoller`) to maximize responsiveness while maintaining robust state tracking and resource cleanup.
101
-
102
- ### 🔒 Secure Configuration
103
- Runtime agent configuration is strictly validated using **Zod schemas**, ensuring that custom agent definitions in `agents.json` are type-safe and error-free before execution.
58
+ ### 🔄 Stagnation-Aware Intelligence
59
+ The system doesn't just loop; it **analyzes**. If an agent hasn't made progress on Todos across iterations, the MissionController injects a specialized **Diagnostic Intervention** to force a strategy pivot.
104
60
 
105
61
  ---
106
62
 
107
63
  ## ⚡ Elite Multi-Agent Swarm
108
64
 
109
- | Agent | Expertise | Capability |
65
+ | Agent | Expertise | Role |
110
66
  |:------|:-----|:---|
111
- | **Commander** | Mission Hub | Session pooling, parallel thread control, state rehydration. |
112
- | **Planner** | Architect | Symbolic mapping, dependency research, roadmap generation. |
113
- | **Worker** | Implementer | High-throughput coding, TDD workflow, documentation. |
114
- | **Reviewer** | Auditor | Rigid verification, LSP/Lint authority, final mission seal. |
115
-
116
- ---
117
-
118
- ## 📈 Performance Benchmarks
119
- - **Throughput**: 10+ concurrent agent sessions with adaptive slot scaling.
120
- - **Accuracy**: 99.95% sync reliability via MVCC+Mutex transaction logic.
121
- - **Efficiency**: 40% reduction in token burn via Incremental State & System Transform.
122
- - **Uptime**: 100% mission survival through plugin restarts via S.H.R (Self-Healing Rehydration).
67
+ | **Commander** | Mission Hub | Orchestration, parallel delegation, native loop coordination. |
68
+ | **Planner** | Architect | Roadmap generation, dependency analysis, research. |
69
+ | **Worker** | Implementer | TDD implementation, code generation, refactoring. |
70
+ | **Reviewer** | Auditor | Rigid verification, LSP/Lint authority, quality assurance. |
123
71
 
124
72
  ---
125
73
 
126
- [Internal Architecture Deep-Dive →](docs/SYSTEM_ARCHITECTURE.md) | [Windows Configuration Guide →](docs/WINDOWS_CONFIGURATION.md)
74
+ ## 📊 Technical Excellence
75
+ - **Zero-Leak Policy**: Automated resource cleanup via `ResourceTracker`.
76
+ - **High Throughput**: Adaptive concurrency scaling for maximum parallel efficiency.
77
+ - **Reliable Verification**: Every step is verified using native LSP and AST tools via our high-performance Rust backend.
127
78
 
128
- ## 📄 License
129
- MIT License.
79
+ [Architectural Details →](docs/SYSTEM_ARCHITECTURE.md)
@@ -0,0 +1,57 @@
1
+ export interface AdaptiveConcurrencyConfig {
2
+ /** Global maximum concurrent tasks across all agents */
3
+ globalMax: number;
4
+ /** Minimum slots per agent */
5
+ perAgentMin: number;
6
+ /** Maximum slots per agent */
7
+ perAgentMax: number;
8
+ /** Success rate threshold to scale up slots (0.0 - 1.0) */
9
+ scaleUpThreshold: number;
10
+ /** Success rate threshold to scale down slots (0.0 - 1.0) */
11
+ scaleDownThreshold: number;
12
+ /** How often to adjust limits (ms) */
13
+ adjustmentInterval: number;
14
+ }
15
+ /**
16
+ * Dynamically adjusts agent concurrency limits based on performance metrics.
17
+ * Now acts as a full controller with acquire/release.
18
+ */
19
+ export declare class AdaptiveConcurrencyController {
20
+ private config;
21
+ private currentLimits;
22
+ private activeCount;
23
+ private metrics;
24
+ private adjustmentTimer;
25
+ private waiters;
26
+ constructor(config?: Partial<AdaptiveConcurrencyConfig>);
27
+ /**
28
+ * Acquire a concurrency slot for an agent.
29
+ * Blocks if limit reached.
30
+ */
31
+ acquire(agent: string): Promise<void>;
32
+ /**
33
+ * Release a concurrency slot.
34
+ */
35
+ release(agent: string): void;
36
+ private canAcquire;
37
+ /**
38
+ * Get the current limit for a specific agent.
39
+ */
40
+ getLimit(agent: string): number;
41
+ /**
42
+ * Report task execution result for adaptive calculation.
43
+ */
44
+ reportResult(agent: string, success: boolean, latencyMs?: number): void;
45
+ /**
46
+ * Starts the periodic adjustment cycle.
47
+ */
48
+ private startAdjustmentCycle;
49
+ /**
50
+ * Adjusts agent limits based on accumulated metrics.
51
+ */
52
+ private adjustLimits;
53
+ /**
54
+ * Stops the controller and cleans up.
55
+ */
56
+ cleanup(): void;
57
+ }
@@ -3,6 +3,7 @@
3
3
  */
4
4
  export * from "./types/index.js";
5
5
  export * from "./interfaces/index.js";
6
- export { ConcurrencyController } from "./concurrency.js";
6
+ export { AdaptiveConcurrencyController } from "./adaptive-concurrency.js";
7
7
  export { ParallelAgentManager, parallelAgentManager } from "./manager.js";
8
- export { taskWAL } from "./persistence/task-wal.js";
8
+ export { UnifiedTaskExecutor } from "./unified-task-executor.js";
9
+ export { SessionPool } from "./session-pool.js";
@@ -33,6 +33,8 @@ export interface SessionPoolConfig {
33
33
  maxReuseCount: number;
34
34
  /** Health check interval in milliseconds (default: 60000 = 1 minute) */
35
35
  healthCheckIntervalMs: number;
36
+ /** Global maximum number of sessions across all agents (default: 30) */
37
+ globalMax: number;
36
38
  }
37
39
  export interface SessionPoolStats {
38
40
  /** Total sessions in pool */
@@ -58,6 +60,11 @@ export interface ISessionPool {
58
60
  * Returns a reused session if available, otherwise creates a new one.
59
61
  */
60
62
  acquire(agentName: string, parentSessionID: string, description: string): Promise<PooledSession>;
63
+ /**
64
+ * Acquire a session immediately without waiting.
65
+ * Throws if global limit is reached.
66
+ */
67
+ acquireImmediate(agentName: string, parentSessionID: string, description: string): Promise<PooledSession>;
61
68
  /**
62
69
  * Release a session back to the pool for reuse.
63
70
  * The session will be reset/cleared before being put back.
@@ -1,64 +1,32 @@
1
- /**
2
- * Parallel Agent Manager
3
- *
4
- * Session-based async agent execution with:
5
- * - Concurrency control per agent type
6
- * - Batched notifications
7
- * - Automatic cleanup
8
- *
9
- * This is the main facade that composes the specialized components.
10
- */
11
1
  import type { PluginInput } from "@opencode-ai/plugin";
12
- import { ConcurrencyController } from "./concurrency.js";
2
+ import { AdaptiveConcurrencyController } from "./adaptive-concurrency.js";
13
3
  import { formatDuration } from "./format.js";
14
4
  import type { ParallelTask } from "./interfaces/parallel-task.interface.js";
15
5
  import type { LaunchInput } from "./interfaces/launch-input.interface.js";
16
- import type { ResumeInput } from "./interfaces/resume-input.interface.js";
17
- export type { ParallelTask };
18
- export { formatDuration };
19
6
  type OpencodeClient = PluginInput["client"];
20
7
  export declare class ParallelAgentManager {
21
8
  private static _instance;
22
- private store;
23
9
  private client;
24
10
  private directory;
25
- private concurrency;
11
+ private adaptiveConcurrency;
26
12
  private sessionPool;
27
- private launcher;
28
- private resumer;
29
- private poller;
30
- private cleaner;
31
- private eventHandler;
13
+ private executor;
32
14
  private constructor();
33
15
  static getInstance(client?: OpencodeClient, directory?: string): ParallelAgentManager;
34
16
  launch(inputs: LaunchInput | LaunchInput[]): Promise<ParallelTask | ParallelTask[]>;
35
- resume(input: ResumeInput): Promise<ParallelTask>;
36
17
  getTask(id: string): ParallelTask | undefined;
37
- getRunningTasks(): ParallelTask[];
38
18
  getAllTasks(): ParallelTask[];
39
- getTasksByParent(parentSessionID: string): ParallelTask[];
19
+ getRunningTasks(): ParallelTask[];
20
+ getTasksByParent(parentID: string): ParallelTask[];
40
21
  cancelTask(taskId: string): Promise<boolean>;
41
22
  getResult(taskId: string): Promise<string | null>;
42
- setConcurrencyLimit(agentType: string, limit: number): void;
43
- getPendingCount(parentSessionID: string): number;
44
- getConcurrency(): ConcurrencyController;
45
- cleanup(): void;
23
+ handleEvent(event: any): void;
24
+ getConcurrency(): AdaptiveConcurrencyController;
46
25
  formatDuration: typeof formatDuration;
47
- handleEvent(event: {
48
- type: string;
49
- properties?: {
50
- sessionID?: string;
51
- info?: {
52
- id?: string;
53
- };
54
- };
55
- }): void;
56
- private findBySession;
57
- private handleTaskError;
58
- private handleTaskComplete;
59
- private recoverActiveTasks;
26
+ cleanup(): Promise<void>;
60
27
  }
61
28
  export declare const parallelAgentManager: {
62
29
  getInstance: typeof ParallelAgentManager.getInstance;
63
30
  cleanup: () => void;
64
31
  };
32
+ export {};
@@ -23,8 +23,14 @@ export declare class SessionPool implements ISessionPool {
23
23
  static getInstance(client?: OpencodeClient, directory?: string, config?: Partial<SessionPoolConfig>): SessionPool;
24
24
  /**
25
25
  * Acquire a session from the pool or create a new one.
26
+ * Sessions are validated before reuse to ensure health.
26
27
  */
27
28
  acquire(agentName: string, parentSessionID: string, description: string): Promise<PooledSession>;
29
+ /**
30
+ * Acquire a session immediately without waiting.
31
+ * Throws if global limit is reached.
32
+ */
33
+ acquireImmediate(agentName: string, parentSessionID: string, description: string): Promise<PooledSession>;
28
34
  /**
29
35
  * Release a session back to the pool for reuse.
30
36
  */
@@ -52,6 +58,10 @@ export declare class SessionPool implements ISessionPool {
52
58
  private getPoolKey;
53
59
  private createSession;
54
60
  private deleteSession;
61
+ /**
62
+ * Validate session health by checking if it exists on the server.
63
+ */
64
+ private validateSessionHealth;
55
65
  private startHealthCheck;
56
66
  }
57
67
  export declare const sessionPool: {
@@ -0,0 +1,27 @@
1
+ import type { PluginInput } from "@opencode-ai/plugin";
2
+ import type { ParallelTask } from "./interfaces/parallel-task.interface.js";
3
+ import type { LaunchInput } from "./interfaces/launch-input.interface.js";
4
+ import { AdaptiveConcurrencyController } from "./adaptive-concurrency.js";
5
+ import { SessionPool } from "./session-pool.js";
6
+ type OpencodeClient = PluginInput["client"];
7
+ /**
8
+ * Simplified Unified Task Executor
9
+ * Leveraging AdaptiveConcurrencyController and ResourceTracker
10
+ */
11
+ export declare class UnifiedTaskExecutor {
12
+ private client;
13
+ private sessionPool;
14
+ private adaptiveConcurrency;
15
+ private tasks;
16
+ constructor(client: OpencodeClient, sessionPool: SessionPool, adaptive: AdaptiveConcurrencyController);
17
+ launch(input: LaunchInput): Promise<ParallelTask>;
18
+ /**
19
+ * Handle events for task completion detection
20
+ */
21
+ handleEvent(event: any): Promise<void>;
22
+ private completeTask;
23
+ getTask(taskId: string): ParallelTask | undefined;
24
+ getAllTasks(): ParallelTask[];
25
+ getTasksByParent(parentID: string): ParallelTask[];
26
+ }
27
+ export {};
@@ -0,0 +1,53 @@
1
+ import type { PluginInput } from '@opencode-ai/plugin';
2
+ /**
3
+ * Native Todo interface from OpenCode SDK
4
+ */
5
+ export interface NativeTodo {
6
+ id: string;
7
+ content: string;
8
+ status: 'pending' | 'in_progress' | 'completed' | 'cancelled';
9
+ priority: 'high' | 'medium' | 'low';
10
+ }
11
+ interface MissionState {
12
+ id: string;
13
+ sessionID: string;
14
+ prompt: string;
15
+ status: 'active' | 'completed' | 'failed';
16
+ iteration: number;
17
+ maxIterations: number;
18
+ startedAt: string;
19
+ lastTodoHash?: string;
20
+ stagnationCount: number;
21
+ }
22
+ /**
23
+ * MissionController
24
+ * Handles the main autonomous loop using OpenCode Native APIs.
25
+ */
26
+ export declare class MissionController {
27
+ private state;
28
+ private client;
29
+ constructor(input: PluginInput);
30
+ /**
31
+ * Starts a new mission by creating a session and sending the commander prompt.
32
+ */
33
+ start(prompt: string): Promise<string>;
34
+ /**
35
+ * Fetches native Todos for the current session.
36
+ */
37
+ getTodos(): Promise<NativeTodo[]>;
38
+ /**
39
+ * Moves to the next iteration if needed.
40
+ * Called primarily when session becomes IDLE.
41
+ */
42
+ nextIteration(): Promise<{
43
+ continue: boolean;
44
+ prompt?: string;
45
+ reason?: string;
46
+ }>;
47
+ buildCommanderPrompt(objective: string): string;
48
+ buildContinuationPrompt(pending: NativeTodo[], intervention?: string): string;
49
+ private buildStagnationIntervention;
50
+ private hashTodos;
51
+ getState(): MissionState | null;
52
+ }
53
+ export {};
@@ -0,0 +1,61 @@
1
+ export declare enum ResourceType {
2
+ SESSION = "session",
3
+ TIMER = "timer",
4
+ INTERVAL = "interval",
5
+ FILE_HANDLE = "file_handle",
6
+ MEMORY = "memory"
7
+ }
8
+ interface TrackedResource {
9
+ id: string;
10
+ type: ResourceType;
11
+ sessionID?: string;
12
+ createdAt: number;
13
+ metadata?: Record<string, unknown>;
14
+ cleanup: () => Promise<void> | void;
15
+ }
16
+ /**
17
+ * Centralized tracker for all resources that need explicit cleanup.
18
+ * Ensures that resources tied to a specific session are cleaned up when the session ends.
19
+ */
20
+ export declare class ResourceTracker {
21
+ private static _instance;
22
+ private resources;
23
+ private sessionResources;
24
+ private constructor();
25
+ static getInstance(): ResourceTracker;
26
+ /**
27
+ * Start tracking a resource.
28
+ */
29
+ track(resource: TrackedResource): void;
30
+ /**
31
+ * Release a specific resource by ID.
32
+ */
33
+ release(id: string): Promise<boolean>;
34
+ /**
35
+ * Release all resources associated with a specific sessionID.
36
+ */
37
+ releaseAllForSession(sessionID: string): Promise<number>;
38
+ /**
39
+ * Release all resources of a specific type.
40
+ */
41
+ releaseByType(type: ResourceType): Promise<number>;
42
+ /**
43
+ * Periodic GC for stale resources (e.g. leaked timers).
44
+ */
45
+ cleanupStale(maxAgeMs: number): Promise<number>;
46
+ /**
47
+ * Shutdown the tracker and release all managed resources.
48
+ */
49
+ shutdown(): Promise<void>;
50
+ /**
51
+ * Get current resource statistics.
52
+ */
53
+ getStats(): {
54
+ total: number;
55
+ byType: Record<string, number>;
56
+ bySessions: number;
57
+ };
58
+ }
59
+ export declare function trackTimer(timer: NodeJS.Timeout, sessionID?: string): string;
60
+ export declare function trackInterval(interval: NodeJS.Timeout, sessionID?: string): string;
61
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,11 +1,3 @@
1
- /**
2
- * OpenCode Orchestrator Plugin
3
- *
4
- * This is the main entry point for the 4-Agent consolidated architecture.
5
- * Handlers are modularized in src/plugin-handlers/ for maintainability.
6
- *
7
- * The agents are: Commander, Planner, Worker, Reviewer
8
- */
9
1
  import type { Plugin } from "@opencode-ai/plugin";
10
2
  declare const OrchestratorPlugin: Plugin;
11
3
  export default OrchestratorPlugin;