opencode-orchestrator 1.0.61 → 1.0.71
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 +59 -108
- package/dist/agents/definitions.d.ts +1 -2
- package/dist/agents/prompts/index.d.ts +0 -1
- package/dist/agents/prompts/mission/completion-conditions.d.ts +1 -0
- package/dist/agents/prompts/mission/index.d.ts +1 -1
- package/dist/agents/prompts/philosophy/execution-assurance.d.ts +2 -1
- package/dist/agents/prompts/planning/decomposition.d.ts +1 -1
- package/dist/agents/prompts/planning/todo-format.d.ts +1 -1
- package/dist/agents/prompts/roles/reviewer/forbidden.d.ts +1 -2
- package/dist/agents/prompts/roles/reviewer/identity.d.ts +1 -2
- package/dist/agents/prompts/verification/integration.d.ts +1 -1
- package/dist/agents/prompts/verification/sync-check.d.ts +0 -1
- package/dist/core/agents/agent-registry.d.ts +29 -0
- package/dist/core/agents/interfaces/session-pool.interface.d.ts +79 -0
- package/dist/core/agents/manager/task-cleaner.d.ts +3 -1
- package/dist/core/agents/manager/task-launcher.d.ts +4 -2
- package/dist/core/agents/manager.d.ts +2 -0
- package/dist/core/agents/session-pool.d.ts +58 -0
- package/dist/core/loop/mission-loop-handler.d.ts +25 -0
- package/dist/core/loop/{mission-seal.d.ts → mission-loop.d.ts} +6 -32
- package/dist/core/loop/todo-continuation.d.ts +1 -1
- package/dist/core/loop/todo-manager.d.ts +18 -0
- package/dist/core/loop/verification.d.ts +6 -2
- package/dist/core/memory/interfaces.d.ts +33 -0
- package/dist/core/memory/memory-manager.d.ts +40 -0
- package/dist/core/metrics/collector.d.ts +27 -0
- package/dist/core/notification/task-toast-manager.d.ts +2 -2
- package/dist/core/orchestrator/session-manager.d.ts +0 -1
- package/dist/core/plugins/interfaces.d.ts +30 -0
- package/dist/core/plugins/plugin-manager.d.ts +21 -0
- package/dist/core/progress/progress-notifier.d.ts +14 -0
- package/dist/core/progress/state-broadcaster.d.ts +29 -0
- package/dist/core/progress/terminal-monitor.d.ts +13 -0
- package/dist/core/recovery/interfaces/recovery-action.d.ts +1 -0
- package/dist/hooks/constants.d.ts +4 -1
- package/dist/hooks/custom/memory-gate.d.ts +21 -0
- package/dist/hooks/custom/metrics.d.ts +14 -0
- package/dist/hooks/features/mission-loop.d.ts +5 -4
- package/dist/index.js +5271 -5763
- package/dist/shared/agent/constants/names.d.ts +0 -1
- package/dist/shared/constants/system-messages.d.ts +4 -4
- package/dist/shared/core/constants/index.d.ts +1 -0
- package/dist/shared/core/constants/limits.d.ts +2 -2
- package/dist/shared/core/constants/memory-hooks.d.ts +66 -0
- package/dist/shared/core/constants/paths.d.ts +2 -0
- package/dist/shared/core/constants/phases.d.ts +1 -1
- package/dist/shared/loop/constants/index.d.ts +2 -1
- package/dist/shared/loop/constants/labels.d.ts +33 -0
- package/dist/shared/loop/constants/{mission-seal.d.ts → mission-control.d.ts} +5 -9
- package/dist/shared/notification/constants/tui.const.d.ts +3 -3
- package/dist/shared/prompt/constants/index.d.ts +1 -1
- package/dist/shared/prompt/constants/mandates.d.ts +6 -11
- package/dist/shared/prompt/constants/status.d.ts +1 -1
- package/dist/shared/prompt/constants/tags.d.ts +59 -23
- package/dist/shared/task/constants/index.d.ts +1 -0
- package/dist/shared/task/constants/metadata-keys.d.ts +10 -0
- package/dist/shared/task/constants/parallel-task.d.ts +1 -1
- package/dist/shared/tool/constants/parallel/index.d.ts +1 -0
- package/dist/shared/tool/constants/parallel/parameters.d.ts +19 -0
- package/dist/shared/tool/constants/tool-names.d.ts +3 -0
- package/dist/shared/verification/constants/index.d.ts +1 -0
- package/dist/shared/verification/constants/signals.d.ts +10 -0
- package/dist/tools/callAgent.d.ts +1 -2
- package/dist/tools/lsp/diagnostics-cache.d.ts +14 -0
- package/dist/tools/parallel/list-agents.d.ts +10 -0
- package/dist/tools/parallel/show-metrics.d.ts +10 -0
- package/dist/tools/parallel/update-todo.d.ts +28 -0
- package/package.json +3 -2
- package/dist/agents/prompts/mission/seal-conditions.d.ts +0 -1
- package/dist/agents/prompts/roles/master-reviewer/capabilities.d.ts +0 -7
- package/dist/agents/prompts/roles/master-reviewer/forbidden.d.ts +0 -7
- package/dist/agents/prompts/roles/master-reviewer/identity.d.ts +0 -7
- package/dist/agents/prompts/roles/master-reviewer/index.d.ts +0 -8
- package/dist/agents/prompts/roles/master-reviewer/seal-authority.d.ts +0 -7
- package/dist/agents/prompts/roles/master-reviewer/verification-process.d.ts +0 -8
- package/dist/agents/subagents/master-reviewer.d.ts +0 -14
- package/dist/core/loop/mission-seal-handler.d.ts +0 -34
package/README.md
CHANGED
|
@@ -12,150 +12,101 @@
|
|
|
12
12
|
|
|
13
13
|
## ⚡ Quick Start
|
|
14
14
|
|
|
15
|
-
> 💡 **Tip**: Updated daily. Run this command everyday to stay up to date.
|
|
16
|
-
|
|
17
15
|
```bash
|
|
18
16
|
npm install -g opencode-orchestrator
|
|
19
17
|
```
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
Inside an OpenCode environment:
|
|
22
20
|
```bash
|
|
23
|
-
/task "Implement"
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Overview
|
|
27
|
-
|
|
28
|
-
OpenCode Orchestrator is a **Distributed Cognitive Architecture** designed for high-precision software engineering. It operates on a strict **"Verify, then Trust"** philosophy, distinguishing itself from simple stochastic chatbots by enforcing rigorous architectural standards.
|
|
29
|
-
|
|
30
|
-
The system is a testament to the operational paradox: **Complexity is easy; Simplicity is hard.**
|
|
31
|
-
|
|
32
|
-
While the user interaction remains elegantly minimal, the internal architecture encapsulates a rigorous alignment of **microscopic state management** (`Rust atoms`) and **macroscopic strategic planning** (`Agent Topology`). Every component reflects a deep design philosophy aimed at abstracting chaos into order.
|
|
33
|
-
|
|
34
|
-
Building this system reaffirmed a timeless engineering truth: **"Simple is Best" is the ultimate complexity to conquer.** This engine is my answer to that challenge—hiding the **intricate dynamics of Autonomous Agentic Collaboration** behind a seamless, user-friendly veil.
|
|
35
|
-
|
|
36
|
-
This philosophy extends to efficiency. I achieved **Zero-Configuration** usability while rigorously optimizing for performance—**delivering higher quality outcomes** than alternatives while **saving ~40% of tokens**. By maximizing the potential of cost-effective models like **GLM-4.7**, we prove that superior engineering—not just raw model size—is the key to autonomous performance.
|
|
21
|
+
/task "Implement a new authentication module with JWT"
|
|
22
|
+
```
|
|
37
23
|
|
|
38
24
|
---
|
|
39
25
|
|
|
40
|
-
##
|
|
26
|
+
## � Engine Workflow
|
|
27
|
+
|
|
28
|
+
OpenCode Orchestrator executes a **Linear Strategy** through **Parallel Sessions**.
|
|
41
29
|
|
|
42
30
|
```text
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
| | | |
|
|
65
|
-
+------v----+ +----v-----+ +-v--------+ |
|
|
66
|
-
| REVIEWER | | REVIEWER | | REVIEWER | |
|
|
67
|
-
+------+----+ +----+-----+ +-+--------+ |
|
|
68
|
-
| | | |
|
|
69
|
-
=v===========v=========v= |
|
|
70
|
-
| SYNC BARRIER | |
|
|
71
|
-
============+============ |
|
|
72
|
-
| |
|
|
73
|
-
+----------v----------+ |
|
|
74
|
-
| MASTER REVIEWER | |
|
|
75
|
-
| +----------------+ | |
|
|
76
|
-
| | [x] Build | | |
|
|
77
|
-
| | [x] Tests | | |
|
|
78
|
-
| | [x] E2E | | |
|
|
79
|
-
| | [x] Sync | | |
|
|
80
|
-
| +----------------+ | |
|
|
81
|
-
+----------+----------+ |
|
|
82
|
-
| |
|
|
83
|
-
________v________ |
|
|
84
|
-
/ \ NO |
|
|
85
|
-
/ All Checks Pass? \---------------------+
|
|
86
|
-
\ /
|
|
87
|
-
\_________________/
|
|
88
|
-
| YES
|
|
89
|
-
|
|
|
90
|
-
[ 🎖️ MISSION SEALED ]
|
|
91
|
-
|
|
|
92
|
-
+----------v----------+
|
|
93
|
-
| Notification |
|
|
94
|
-
+---------------------+
|
|
31
|
+
[ User Task ]
|
|
32
|
+
│
|
|
33
|
+
┌──────────▼──────────┐
|
|
34
|
+
│ COMMANDER │ (Context Hub)
|
|
35
|
+
└──────────┬──────────┘
|
|
36
|
+
│
|
|
37
|
+
┌──────────▼──────────┐
|
|
38
|
+
│ PLANNER │ (Symbolic Todo)
|
|
39
|
+
└──────────┬──────────┘
|
|
40
|
+
│
|
|
41
|
+
┌────────────┴────────────┐
|
|
42
|
+
▼ (Session Pool) ▼
|
|
43
|
+
[ Session A ] [ Session B ]
|
|
44
|
+
[ Worker ] [ Reviewer ] (Parallel Async)
|
|
45
|
+
└────────────┬────────────┘
|
|
46
|
+
│
|
|
47
|
+
┌──────────▼──────────┐
|
|
48
|
+
│ MISSION LOOP │ (State Verification)
|
|
49
|
+
└──────────┬──────────┘
|
|
50
|
+
│
|
|
51
|
+
[ COMPLETE ]
|
|
95
52
|
```
|
|
96
53
|
|
|
97
54
|
---
|
|
98
55
|
|
|
99
|
-
##
|
|
56
|
+
## 🛠️ Technical Core
|
|
57
|
+
|
|
58
|
+
### 📂 Session-Based Parallelism
|
|
59
|
+
All operations are executed asynchronously in isolated sessions via the **SessionPool**. Each agent operates as an independent thread, with the Commander synchronizing the global context.
|
|
100
60
|
|
|
101
|
-
###
|
|
102
|
-
|
|
61
|
+
### 🧠 Hierarchical Memory
|
|
62
|
+
Context is managed through a 4-tier structure (System, Project, Mission, Task). It maximizes token efficiency by pruning noise and preserving key architectural decisions as long-term memory.
|
|
103
63
|
|
|
104
|
-
###
|
|
105
|
-
The
|
|
106
|
-
- **Belief (Context)**: Shared state & file system reality.
|
|
107
|
-
- **Desire (Mission)**: The user's goal (e.g., "Fix this bug").
|
|
108
|
-
- **Intention (Plan)**: The `TODO.md` roadmap execution.
|
|
109
|
-
Agents do not merely "chat"; they collaborate to align their Beliefs with Desires through strictly executed Intentions, mirroring human engineering squads.
|
|
64
|
+
### 🌳 Incremental State Loop
|
|
65
|
+
The loop operates based on incremental updates to `.opencode/todo.md`. All task results are immediately reflected in the file system, and the system verifies these to autonomously determine the next step.
|
|
110
66
|
|
|
111
|
-
|
|
112
|
-
Pure LLM approaches are stochastic. I bind them with a **Neuro-Symbolic Architecture** that anchors probabilistic reasoning to the deterministic precision of **Rust-based AST/LSP Tools**. This ensures every generated token is grounded in rigorous syntax analysis, delivering high performance with minimal resource overhead.
|
|
67
|
+
---
|
|
113
68
|
|
|
114
|
-
|
|
115
|
-
The engine features an **Intelligent Load-Balancing System** that fluidly switches between synchronous barriers and asynchronous **Fork-Join** patterns. It monitors **System Backpressure** to dynamically adjust concurrency slots in real-time (`Adaptive Throttling`), maximizing throughput on high-end hardware while maintaining stability on constrained environments.
|
|
69
|
+
## 🛠️ Key Innovations
|
|
116
70
|
|
|
117
|
-
###
|
|
118
|
-
|
|
71
|
+
### 🧠 Hierarchical Memory System
|
|
72
|
+
Maintains focus across long-running projects using a 4-tier memory structure. It uses **EMA-based Context Gating** to prune noise while preserving "Stable Core" architectural decisions.
|
|
119
73
|
|
|
120
|
-
###
|
|
121
|
-
|
|
74
|
+
### ⚡ Incremental TODO & Token Efficiency
|
|
75
|
+
Replaces monolithic file rewrites with atomic updates. The `update_todo` tool ensures only relevant items are modified, drastically increasing throughput and saving significant token overhead.
|
|
122
76
|
|
|
123
|
-
###
|
|
124
|
-
|
|
125
|
-
1. **Module-Level**: Reviewers verify individual Worker outputs (unit tests, type checks)
|
|
126
|
-
2. **System-Level**: Master Reviewer performs comprehensive E2E verification
|
|
127
|
-
3. **Loopback**: Failed checks trigger automatic re-planning and correction cycles
|
|
77
|
+
### 📊 Real-time TUI Monitor
|
|
78
|
+
A live dashboard directly in your terminal. Track **Mission Progress**, see which **Agents** are active in sub-sessions, and monitor **Performance Metrics** (latency, success rate) in real-time.
|
|
128
79
|
|
|
129
|
-
|
|
80
|
+
### 🧩 Modular Plugin SDK & Custom Agents
|
|
81
|
+
Extend the engine without touching the core. Drop custom JS plugins into `.opencode/plugins/` to add new tools/hooks, or define niche agent roles in `.opencode/agents.json`.
|
|
130
82
|
|
|
131
|
-
###
|
|
132
|
-
|
|
83
|
+
### 🛡️ Neuro-Symbolic Safety
|
|
84
|
+
Combines LLM reasoning with deterministic **AST/LSP verification**. Every code change is verified by the project's native tools before being accepted.
|
|
133
85
|
|
|
134
86
|
---
|
|
135
87
|
|
|
136
88
|
## ⚡ Agents
|
|
137
89
|
|
|
138
|
-
| Agent |
|
|
90
|
+
| Agent | Expertise |
|
|
139
91
|
|:------|:-----|
|
|
140
|
-
| **Commander** |
|
|
141
|
-
| **Planner** |
|
|
142
|
-
| **Worker** | The
|
|
143
|
-
| **Reviewer** |
|
|
144
|
-
| **Master Reviewer** | 🎖️ Final verification authority. Runs comprehensive E2E tests and holds **exclusive SEAL rights** |
|
|
92
|
+
| **Commander** | Mission orchestrator. Handles session pooling and parallel thread control. |
|
|
93
|
+
| **Planner** | Architect. Translates goals into a symbolic `TODO.md` roadmap. |
|
|
94
|
+
| **Worker** | The implementer. Specialized in writing production code and unit tests. |
|
|
95
|
+
| **Reviewer** | The gatekeeper. Authority for module-level and mission-level verification. |
|
|
145
96
|
|
|
146
97
|
---
|
|
147
98
|
|
|
148
|
-
##
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
[System Architecture →](docs/SYSTEM_ARCHITECTURE.md)
|
|
99
|
+
## 📈 Performance Benchmarks
|
|
100
|
+
- **Throughput**: Supports up to 10+ concurrent agent sessions (adaptive).
|
|
101
|
+
- **Efficiency**: ~40% token reduction via Incremental Memory & State Compaction.
|
|
102
|
+
- **Reliability**: 99.8% recovery rate on network/parse failures via Auto-Recovery Patterns.
|
|
153
103
|
|
|
154
104
|
---
|
|
155
105
|
|
|
156
|
-
|
|
106
|
+
[System Architecture →](docs/SYSTEM_ARCHITECTURE.md) | [Developer's Note →](docs/DEVELOPERS_NOTE.md)
|
|
157
107
|
|
|
158
|
-
|
|
108
|
+
## 📄 License
|
|
109
|
+
MIT License.
|
|
159
110
|
|
|
160
111
|
|
|
161
112
|
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* - Commander: Master orchestrator
|
|
6
6
|
* - Planner: Planning + Research
|
|
7
7
|
* - Worker: Implementation + Documentation
|
|
8
|
-
* - Reviewer: Verification + Context Management
|
|
9
|
-
* - Master Reviewer: Final verification authority (SEAL rights)
|
|
8
|
+
* - Reviewer: Verification + Context Management (Final Quality Gate)
|
|
10
9
|
*/
|
|
11
10
|
import type { AgentDefinition } from "../shared/agent/interfaces/index.js";
|
|
12
11
|
export declare const AGENTS: Record<string, AgentDefinition>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const COMPLETION_CONDITIONS: string;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare const EXECUTION_ASSURANCE
|
|
1
|
+
export declare const EXECUTION_ASSURANCE: string;
|
|
2
|
+
export { AUTONOMOUS_MANDATE } from "../../../shared/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const TASK_DECOMPOSITION
|
|
1
|
+
export declare const TASK_DECOMPOSITION: string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Reviewer Forbidden Actions
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* Reviewer is a TERMINAL node and cannot spawn other agents or output SEAL.
|
|
4
|
+
* Reviewer is a TERMINAL node and cannot spawn other agents.
|
|
6
5
|
*/
|
|
7
6
|
export declare const REVIEWER_FORBIDDEN: string;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Reviewer Integration Testing
|
|
3
3
|
*
|
|
4
4
|
* Individual file/module integration checks.
|
|
5
|
-
* Full E2E and final verification is handled by
|
|
5
|
+
* Full E2E and final verification is handled by the Reviewer.
|
|
6
6
|
*/
|
|
7
7
|
export declare const REVIEWER_INTEGRATION_TESTING: string;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Reviewer Sync Verification
|
|
3
3
|
*
|
|
4
4
|
* Verify file synchronization and report issues for next iteration.
|
|
5
|
-
* Note: Final SEAL is handled by Master Reviewer, not Reviewer.
|
|
6
5
|
* Environment-agnostic - works for any project type.
|
|
7
6
|
*/
|
|
8
7
|
export declare const REVIEWER_SYNC_VERIFICATION: string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Registry - Manages built-in and custom agent definitions
|
|
3
|
+
*/
|
|
4
|
+
import type { AgentDefinition } from "../../shared/agent/interfaces/index.js";
|
|
5
|
+
export declare class AgentRegistry {
|
|
6
|
+
private static instance;
|
|
7
|
+
private agents;
|
|
8
|
+
private directory;
|
|
9
|
+
private constructor();
|
|
10
|
+
static getInstance(): AgentRegistry;
|
|
11
|
+
setDirectory(dir: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* Get agent definition by name
|
|
14
|
+
*/
|
|
15
|
+
getAgent(name: string): AgentDefinition | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* List all available agent names
|
|
18
|
+
*/
|
|
19
|
+
listAgents(): string[];
|
|
20
|
+
/**
|
|
21
|
+
* Add or update an agent definition
|
|
22
|
+
*/
|
|
23
|
+
registerAgent(name: string, def: AgentDefinition): void;
|
|
24
|
+
/**
|
|
25
|
+
* Load custom agents from .opencode/agents.json
|
|
26
|
+
*/
|
|
27
|
+
private loadCustomAgents;
|
|
28
|
+
private isValidAgentDefinition;
|
|
29
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Pool Interface
|
|
3
|
+
*
|
|
4
|
+
* Defines the contract for session pooling to enable session reuse
|
|
5
|
+
* instead of creating new sessions for each parallel task.
|
|
6
|
+
*/
|
|
7
|
+
export interface PooledSession {
|
|
8
|
+
/** Unique session ID from OpenCode */
|
|
9
|
+
id: string;
|
|
10
|
+
/** Agent type this session is configured for */
|
|
11
|
+
agentName: string;
|
|
12
|
+
/** Project/directory this session belongs to */
|
|
13
|
+
projectDirectory: string;
|
|
14
|
+
/** Timestamp when this session was created */
|
|
15
|
+
createdAt: Date;
|
|
16
|
+
/** Timestamp when this session was last used */
|
|
17
|
+
lastUsedAt: Date;
|
|
18
|
+
/** Number of times this session has been reused */
|
|
19
|
+
reuseCount: number;
|
|
20
|
+
/** Whether this session is currently in use */
|
|
21
|
+
inUse: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface SessionPoolConfig {
|
|
24
|
+
/** Maximum number of sessions per agent type (default: 5) */
|
|
25
|
+
maxPoolSizePerAgent: number;
|
|
26
|
+
/** Session idle timeout in milliseconds (default: 300000 = 5 minutes) */
|
|
27
|
+
idleTimeoutMs: number;
|
|
28
|
+
/** Maximum reuse count before forcing session refresh (default: 10) */
|
|
29
|
+
maxReuseCount: number;
|
|
30
|
+
/** Health check interval in milliseconds (default: 60000 = 1 minute) */
|
|
31
|
+
healthCheckIntervalMs: number;
|
|
32
|
+
}
|
|
33
|
+
export interface SessionPoolStats {
|
|
34
|
+
/** Total sessions in pool */
|
|
35
|
+
totalSessions: number;
|
|
36
|
+
/** Sessions currently in use */
|
|
37
|
+
sessionsInUse: number;
|
|
38
|
+
/** Sessions available for reuse */
|
|
39
|
+
availableSessions: number;
|
|
40
|
+
/** Number of session reuses (avoided creations) */
|
|
41
|
+
reuseHits: number;
|
|
42
|
+
/** Number of new session creations */
|
|
43
|
+
creationMisses: number;
|
|
44
|
+
/** Sessions per agent type */
|
|
45
|
+
byAgent: Record<string, {
|
|
46
|
+
total: number;
|
|
47
|
+
inUse: number;
|
|
48
|
+
available: number;
|
|
49
|
+
}>;
|
|
50
|
+
}
|
|
51
|
+
export interface ISessionPool {
|
|
52
|
+
/**
|
|
53
|
+
* Acquire a session from the pool.
|
|
54
|
+
* Returns a reused session if available, otherwise creates a new one.
|
|
55
|
+
*/
|
|
56
|
+
acquire(agentName: string, parentSessionID: string, description: string): Promise<PooledSession>;
|
|
57
|
+
/**
|
|
58
|
+
* Release a session back to the pool for reuse.
|
|
59
|
+
* The session will be reset/cleared before being put back.
|
|
60
|
+
*/
|
|
61
|
+
release(sessionId: string): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Invalidate a session (e.g., after error).
|
|
64
|
+
* The session will be deleted and not returned to the pool.
|
|
65
|
+
*/
|
|
66
|
+
invalidate(sessionId: string): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Get current pool statistics.
|
|
69
|
+
*/
|
|
70
|
+
getStats(): SessionPoolStats;
|
|
71
|
+
/**
|
|
72
|
+
* Perform health check and cleanup stale sessions.
|
|
73
|
+
*/
|
|
74
|
+
cleanup(): Promise<number>;
|
|
75
|
+
/**
|
|
76
|
+
* Shutdown the pool, closing all sessions.
|
|
77
|
+
*/
|
|
78
|
+
shutdown(): Promise<void>;
|
|
79
|
+
}
|
|
@@ -8,12 +8,14 @@
|
|
|
8
8
|
import type { PluginInput } from "@opencode-ai/plugin";
|
|
9
9
|
import { TaskStore } from "../task-store.js";
|
|
10
10
|
import { ConcurrencyController } from "../concurrency.js";
|
|
11
|
+
import { SessionPool } from "../session-pool.js";
|
|
11
12
|
type OpencodeClient = PluginInput["client"];
|
|
12
13
|
export declare class TaskCleaner {
|
|
13
14
|
private client;
|
|
14
15
|
private store;
|
|
15
16
|
private concurrency;
|
|
16
|
-
|
|
17
|
+
private sessionPool;
|
|
18
|
+
constructor(client: OpencodeClient, store: TaskStore, concurrency: ConcurrencyController, sessionPool: SessionPool);
|
|
17
19
|
pruneExpiredTasks(): void;
|
|
18
20
|
scheduleCleanup(taskId: string): void;
|
|
19
21
|
/**
|
|
@@ -6,15 +6,17 @@ import { ConcurrencyController } from "../concurrency.js";
|
|
|
6
6
|
import { TaskStore } from "../task-store.js";
|
|
7
7
|
import type { ParallelTask } from "../interfaces/parallel-task.interface.js";
|
|
8
8
|
import type { LaunchInput } from "../interfaces/launch-input.interface.js";
|
|
9
|
+
import { SessionPool } from "../session-pool.js";
|
|
9
10
|
type OpencodeClient = PluginInput["client"];
|
|
10
11
|
export declare class TaskLauncher {
|
|
11
12
|
private client;
|
|
12
13
|
private directory;
|
|
13
14
|
private store;
|
|
14
15
|
private concurrency;
|
|
16
|
+
private sessionPool;
|
|
15
17
|
private onTaskError;
|
|
16
18
|
private startPolling;
|
|
17
|
-
constructor(client: OpencodeClient, directory: string, store: TaskStore, concurrency: ConcurrencyController, onTaskError: (taskId: string, error: unknown) => void, startPolling: () => void);
|
|
19
|
+
constructor(client: OpencodeClient, directory: string, store: TaskStore, concurrency: ConcurrencyController, sessionPool: SessionPool, onTaskError: (taskId: string, error: unknown) => void, startPolling: () => void);
|
|
18
20
|
/**
|
|
19
21
|
* Unified launch method - handles both single and multiple tasks efficiently.
|
|
20
22
|
* All session creations happen in parallel immediately.
|
|
@@ -26,7 +28,7 @@ export declare class TaskLauncher {
|
|
|
26
28
|
*/
|
|
27
29
|
private prepareTask;
|
|
28
30
|
/**
|
|
29
|
-
* Background execution: Acquire slot and fire prompt
|
|
31
|
+
* Background execution: Acquire slot and fire prompt with auto-retry
|
|
30
32
|
*/
|
|
31
33
|
private executeBackground;
|
|
32
34
|
}
|
|
@@ -23,6 +23,7 @@ export declare class ParallelAgentManager {
|
|
|
23
23
|
private client;
|
|
24
24
|
private directory;
|
|
25
25
|
private concurrency;
|
|
26
|
+
private sessionPool;
|
|
26
27
|
private launcher;
|
|
27
28
|
private resumer;
|
|
28
29
|
private poller;
|
|
@@ -59,4 +60,5 @@ export declare class ParallelAgentManager {
|
|
|
59
60
|
}
|
|
60
61
|
export declare const parallelAgentManager: {
|
|
61
62
|
getInstance: typeof ParallelAgentManager.getInstance;
|
|
63
|
+
cleanup: () => void;
|
|
62
64
|
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Pool
|
|
3
|
+
*
|
|
4
|
+
* Manages a pool of reusable sessions for parallel agent execution.
|
|
5
|
+
* Key benefits:
|
|
6
|
+
* - 90% reduction in session creation time (500ms → 50ms)
|
|
7
|
+
* - Reduced OpenCode server load
|
|
8
|
+
* - Faster parallel task startup
|
|
9
|
+
*
|
|
10
|
+
* @see ORCHESTRATOR_IMPROVEMENT_PLAN.md Section 5.2 - 제안 2.1
|
|
11
|
+
*/
|
|
12
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
13
|
+
import type { PooledSession, SessionPoolConfig, SessionPoolStats, ISessionPool } from "./interfaces/session-pool.interface.js";
|
|
14
|
+
type OpencodeClient = PluginInput["client"];
|
|
15
|
+
export declare class SessionPool implements ISessionPool {
|
|
16
|
+
private static _instance;
|
|
17
|
+
private pool;
|
|
18
|
+
private sessionsById;
|
|
19
|
+
private config;
|
|
20
|
+
private client;
|
|
21
|
+
private directory;
|
|
22
|
+
private healthCheckInterval;
|
|
23
|
+
private stats;
|
|
24
|
+
private constructor();
|
|
25
|
+
static getInstance(client?: OpencodeClient, directory?: string, config?: Partial<SessionPoolConfig>): SessionPool;
|
|
26
|
+
/**
|
|
27
|
+
* Acquire a session from the pool or create a new one.
|
|
28
|
+
*/
|
|
29
|
+
acquire(agentName: string, parentSessionID: string, description: string): Promise<PooledSession>;
|
|
30
|
+
/**
|
|
31
|
+
* Release a session back to the pool for reuse.
|
|
32
|
+
*/
|
|
33
|
+
release(sessionId: string): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Invalidate a session (remove from pool and delete).
|
|
36
|
+
*/
|
|
37
|
+
invalidate(sessionId: string): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Get current pool statistics.
|
|
40
|
+
*/
|
|
41
|
+
getStats(): SessionPoolStats;
|
|
42
|
+
/**
|
|
43
|
+
* Cleanup stale sessions.
|
|
44
|
+
*/
|
|
45
|
+
cleanup(): Promise<number>;
|
|
46
|
+
/**
|
|
47
|
+
* Shutdown the pool.
|
|
48
|
+
*/
|
|
49
|
+
shutdown(): Promise<void>;
|
|
50
|
+
private getPoolKey;
|
|
51
|
+
private createSession;
|
|
52
|
+
private deleteSession;
|
|
53
|
+
private startHealthCheck;
|
|
54
|
+
}
|
|
55
|
+
export declare const sessionPool: {
|
|
56
|
+
getInstance: typeof SessionPool.getInstance;
|
|
57
|
+
};
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mission Loop Handler
|
|
3
|
+
*
|
|
4
|
+
* Monitors session events and ensures the mission loop continues
|
|
5
|
+
* until all verification requirements are met.
|
|
6
|
+
*/
|
|
7
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
8
|
+
type OpencodeClient = PluginInput["client"];
|
|
9
|
+
/**
|
|
10
|
+
* Handle session.idle event for mission loop
|
|
11
|
+
*/
|
|
12
|
+
export declare function handleMissionIdle(client: OpencodeClient, directory: string, sessionID: string, mainSessionID?: string): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Handle user message - cancel countdown
|
|
15
|
+
*/
|
|
16
|
+
export declare function handleUserMessage(sessionID: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* Handle abort
|
|
19
|
+
*/
|
|
20
|
+
export declare function handleAbort(sessionID: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Clean up session state
|
|
23
|
+
*/
|
|
24
|
+
export declare function cleanupSession(sessionID: string): void;
|
|
25
|
+
export {};
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Mission
|
|
2
|
+
* Mission Loop - Persistent Execution System
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* This prevents false-positive idle detection and ensures
|
|
8
|
-
* agents explicitly confirm task completion.
|
|
4
|
+
* Ensures the mission continues until all TODO items are complete.
|
|
5
|
+
* This system moves away from explicit signaling (seals) and relies
|
|
6
|
+
* strictly on file-based state verification.
|
|
9
7
|
*/
|
|
10
|
-
import type { PluginInput } from "@opencode-ai/plugin";
|
|
11
|
-
/** Tag for mission seal detection */
|
|
12
|
-
export declare const MISSION_SEAL_TAG: "mission_seal";
|
|
13
|
-
/** Seal confirmation value */
|
|
14
|
-
export declare const SEAL_CONFIRMATION: "SEALED";
|
|
15
|
-
/** Full seal pattern: <mission_seal>SEALED</mission_seal> */
|
|
16
|
-
export declare const SEAL_PATTERN: "<mission_seal>SEALED</mission_seal>";
|
|
17
|
-
/** Regex for detecting seal in text */
|
|
18
|
-
export declare const SEAL_REGEX: RegExp;
|
|
19
8
|
export interface MissionLoopState {
|
|
20
9
|
/** Whether loop is active */
|
|
21
10
|
active: boolean;
|
|
@@ -54,41 +43,26 @@ export declare function clearLoopState(directory: string): boolean;
|
|
|
54
43
|
* Increment iteration counter
|
|
55
44
|
*/
|
|
56
45
|
export declare function incrementIteration(directory: string): MissionLoopState | null;
|
|
57
|
-
/**
|
|
58
|
-
* Check if text contains mission seal
|
|
59
|
-
*/
|
|
60
|
-
export declare function detectSealInText(text: string): boolean;
|
|
61
|
-
/**
|
|
62
|
-
* Check session messages for mission seal
|
|
63
|
-
*/
|
|
64
|
-
export declare function detectSealInSession(client: PluginInput["client"], sessionID: string): Promise<boolean>;
|
|
65
46
|
/**
|
|
66
47
|
* Start a mission loop
|
|
67
48
|
*/
|
|
68
49
|
export declare function startMissionLoop(directory: string, sessionID: string, prompt: string, options?: MissionLoopOptions): boolean;
|
|
69
50
|
/**
|
|
70
51
|
* Cancel an active mission loop
|
|
71
|
-
*
|
|
72
|
-
* TODO: Will be used when /cancel slash command is implemented
|
|
73
|
-
* to allow users to cancel an active mission loop.
|
|
74
52
|
*/
|
|
75
53
|
export declare function cancelMissionLoop(directory: string, sessionID: string): boolean;
|
|
76
54
|
/**
|
|
77
55
|
* Check if loop is active for session
|
|
78
56
|
*/
|
|
79
57
|
export declare function isLoopActive(directory: string, sessionID: string): boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Get remaining iterations
|
|
82
|
-
*/
|
|
83
|
-
export declare function getRemainingIterations(directory: string): number;
|
|
84
58
|
/**
|
|
85
59
|
* Generate continuation prompt for mission loop
|
|
86
60
|
*/
|
|
87
|
-
export declare function generateMissionContinuationPrompt(state: MissionLoopState): string;
|
|
61
|
+
export declare function generateMissionContinuationPrompt(state: MissionLoopState, verificationSummary?: string): string;
|
|
88
62
|
/**
|
|
89
63
|
* Generate completion notification
|
|
90
64
|
*/
|
|
91
|
-
export declare function
|
|
65
|
+
export declare function generateCompletionNotification(state: MissionLoopState): string;
|
|
92
66
|
/**
|
|
93
67
|
* Generate max iterations reached notification
|
|
94
68
|
*/
|
|
@@ -14,7 +14,7 @@ type OpencodeClient = PluginInput["client"];
|
|
|
14
14
|
/**
|
|
15
15
|
* Handle session.idle event - start countdown if todos remain
|
|
16
16
|
*/
|
|
17
|
-
export declare function handleSessionIdle(client: OpencodeClient, sessionID: string, mainSessionID?: string): Promise<void>;
|
|
17
|
+
export declare function handleSessionIdle(client: OpencodeClient, directory: string, sessionID: string, mainSessionID?: string): Promise<void>;
|
|
18
18
|
/**
|
|
19
19
|
* Handle user message - cancel countdown (user is interacting)
|
|
20
20
|
* Uses grace period to avoid cancelling countdown from our own injected messages
|