opencode-orchestrator 1.0.65 β 1.0.72
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 +60 -104
- 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/todo-manager.d.ts +18 -0
- 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/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/index.js +1621 -469
- package/dist/shared/core/constants/index.d.ts +1 -0
- package/dist/shared/core/constants/memory-hooks.d.ts +66 -0
- package/dist/shared/core/constants/paths.d.ts +2 -0
- package/dist/shared/tool/constants/tool-names.d.ts +3 -0
- 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 +1 -1
package/README.md
CHANGED
|
@@ -12,145 +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 our 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. We 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
|
-
ββββββββΌββββ βββββββΌβββββ ββββββΌββββββ β
|
|
66
|
-
βπREVIEWERβ βπREVIEWERβ βπREVIEWERβ (Module-level Verification) β
|
|
67
|
-
ββββββββ¬ββββ βββββββ¬βββββ ββββββ¬ββββββ β
|
|
68
|
-
β β β β
|
|
69
|
-
ββΌββββββββββββΌββββββββββββΌβ β
|
|
70
|
-
β π³ TODO ROLL-UP β β
|
|
71
|
-
ββββββββββββββ€βββββββββββββ β
|
|
72
|
-
β β
|
|
73
|
-
βββββββββββββΌββββββββββββ β
|
|
74
|
-
β π REVIEWER β (Final Quality Gate) β
|
|
75
|
-
β βββββββββββββββββββ β β
|
|
76
|
-
β β [x] TODO 100% β β β
|
|
77
|
-
β β [x] Build Pass β β β
|
|
78
|
-
β β [x] Tests Pass β β β
|
|
79
|
-
β β [x] E2E Pass β β β
|
|
80
|
-
β β [x] Sync OK β β β
|
|
81
|
-
β βββββββββββββββββββ β β
|
|
82
|
-
βββββββββββββ¬ββββββββββββ β
|
|
83
|
-
β β
|
|
84
|
-
_________βΌ__________ β
|
|
85
|
-
β± β² NO (Failure Summary β Commander) β
|
|
86
|
-
β± β
All Checks Pass β² βββββββββββββββββββββββββββββββββββββββββββ
|
|
87
|
-
β² π‘οΈ Sync Issues 0? β± (Autonomous Loopback via File State)
|
|
88
|
-
β²____________________β±
|
|
89
|
-
β YES
|
|
90
|
-
β
|
|
91
|
-
[ ποΈ MISSION COMPLETE ]
|
|
92
|
-
β
|
|
93
|
-
βββββββββββββΌββββββββββββ
|
|
94
|
-
β π Notification β
|
|
95
|
-
βββββββββββββββββββββββββ
|
|
31
|
+
[ User Task ]
|
|
32
|
+
β
|
|
33
|
+
ββββββββββββΌβββββββββββ
|
|
34
|
+
β COMMANDER β (Context Hub)
|
|
35
|
+
ββββββββββββ¬βββββββββββ
|
|
36
|
+
β
|
|
37
|
+
ββββββββββββΌβββββββββββ
|
|
38
|
+
β PLANNER β (Symbolic Todo)
|
|
39
|
+
ββββββββββββ¬βββββββββββ
|
|
40
|
+
β
|
|
41
|
+
ββββββββββββββββΌβββββββββββββββ
|
|
42
|
+
βΌ (Async Session Pool) βΌ
|
|
43
|
+
[ Session A ] [ Session B ] [ Session C ]
|
|
44
|
+
[ Worker ] [ Worker ] [ Reviewer ]
|
|
45
|
+
ββββββββββββββββ¬βββββββββββββββ
|
|
46
|
+
β
|
|
47
|
+
ββββββββββββΌβββββββββββ
|
|
48
|
+
β MISSION LOOP β (State Verification)
|
|
49
|
+
ββββββββββββ¬βββββββββββ
|
|
50
|
+
β
|
|
51
|
+
[ COMPLETE ]
|
|
96
52
|
```
|
|
97
53
|
|
|
98
54
|
---
|
|
99
55
|
|
|
100
|
-
##
|
|
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.
|
|
101
60
|
|
|
102
|
-
###
|
|
103
|
-
|
|
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.
|
|
104
63
|
|
|
105
|
-
###
|
|
106
|
-
The
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
- **Intention (Plan)**: The `TODO.md` roadmap execution.
|
|
110
|
-
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.
|
|
66
|
+
|
|
67
|
+
---
|
|
111
68
|
|
|
112
|
-
|
|
113
|
-
Pure LLM approaches are stochastic. We 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.
|
|
69
|
+
## π οΈ Key Innovations
|
|
114
70
|
|
|
115
|
-
###
|
|
116
|
-
|
|
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.
|
|
117
73
|
|
|
118
|
-
###
|
|
119
|
-
|
|
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.
|
|
120
76
|
|
|
121
|
-
###
|
|
122
|
-
|
|
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.
|
|
123
79
|
|
|
124
|
-
###
|
|
125
|
-
|
|
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`.
|
|
126
82
|
|
|
127
|
-
###
|
|
128
|
-
|
|
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.
|
|
129
85
|
|
|
130
86
|
---
|
|
131
87
|
|
|
132
88
|
## β‘ Agents
|
|
133
89
|
|
|
134
|
-
| Agent |
|
|
90
|
+
| Agent | Expertise |
|
|
135
91
|
|:------|:-----|
|
|
136
|
-
| **Commander** |
|
|
137
|
-
| **Planner** |
|
|
138
|
-
| **Worker** | The
|
|
139
|
-
| **Reviewer** |
|
|
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. |
|
|
140
96
|
|
|
141
97
|
---
|
|
142
98
|
|
|
143
|
-
##
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
[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.
|
|
148
103
|
|
|
149
104
|
---
|
|
150
105
|
|
|
151
|
-
|
|
106
|
+
[System Architecture β](docs/SYSTEM_ARCHITECTURE.md) | [Developer's Note β](docs/DEVELOPERS_NOTE.md)
|
|
152
107
|
|
|
153
|
-
|
|
108
|
+
## π License
|
|
109
|
+
MIT License.
|
|
154
110
|
|
|
155
111
|
|
|
156
112
|
|
|
@@ -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,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TodoManager - Intelligent Incremental TODO Updates
|
|
3
|
+
*/
|
|
4
|
+
export declare class TodoManager {
|
|
5
|
+
private static instance;
|
|
6
|
+
private directory;
|
|
7
|
+
private constructor();
|
|
8
|
+
static getInstance(): TodoManager;
|
|
9
|
+
setDirectory(dir: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* Update a specific TODO item by its text content
|
|
12
|
+
*/
|
|
13
|
+
updateItem(searchText: string, newStatus: string): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Add a new sub-task under a parent task
|
|
16
|
+
*/
|
|
17
|
+
addSubTask(parentText: string, subTaskText: string): boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hierarchical Memory System Interfaces
|
|
3
|
+
*/
|
|
4
|
+
export declare enum MemoryLevel {
|
|
5
|
+
/** Core rules, identity, and system instructions (Highest permanence) */
|
|
6
|
+
SYSTEM = "system",
|
|
7
|
+
/** Project architecture, tech stack, and long-term findings (High permanence) */
|
|
8
|
+
PROJECT = "project",
|
|
9
|
+
/** Mission goals, TODO progress, and mid-term decisions (Medium permanence) */
|
|
10
|
+
MISSION = "mission",
|
|
11
|
+
/** Current task details, short-term findings, and tool outputs (Low permanence) */
|
|
12
|
+
TASK = "task"
|
|
13
|
+
}
|
|
14
|
+
export interface MemoryEntry {
|
|
15
|
+
id: string;
|
|
16
|
+
level: MemoryLevel;
|
|
17
|
+
content: string;
|
|
18
|
+
timestamp: number;
|
|
19
|
+
metadata?: Record<string, any>;
|
|
20
|
+
importance: number;
|
|
21
|
+
}
|
|
22
|
+
export interface MemorySnapshot {
|
|
23
|
+
[MemoryLevel.SYSTEM]: MemoryEntry[];
|
|
24
|
+
[MemoryLevel.PROJECT]: MemoryEntry[];
|
|
25
|
+
[MemoryLevel.MISSION]: MemoryEntry[];
|
|
26
|
+
[MemoryLevel.TASK]: MemoryEntry[];
|
|
27
|
+
}
|
|
28
|
+
export interface MemoryConfig {
|
|
29
|
+
/** Token budget per level (approximate or percentage) */
|
|
30
|
+
tokenBudgets: Record<MemoryLevel, number>;
|
|
31
|
+
/** Enable dynamic relevance filtering */
|
|
32
|
+
enableRelevanceFiltering: boolean;
|
|
33
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MemoryManager - Core component of the Hierarchical Memory System
|
|
3
|
+
*/
|
|
4
|
+
import { MemoryLevel, MemorySnapshot } from "./interfaces.js";
|
|
5
|
+
export declare class MemoryManager {
|
|
6
|
+
private static instance;
|
|
7
|
+
private memories;
|
|
8
|
+
private storage;
|
|
9
|
+
private config;
|
|
10
|
+
private constructor();
|
|
11
|
+
static getInstance(): MemoryManager;
|
|
12
|
+
/**
|
|
13
|
+
* Add a memory entry
|
|
14
|
+
*/
|
|
15
|
+
add(level: MemoryLevel, content: string, importance?: number, metadata?: Record<string, any>): string;
|
|
16
|
+
/**
|
|
17
|
+
* Retrieve memory for prompt construction
|
|
18
|
+
*/
|
|
19
|
+
getContext(query?: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Simple keyword-based relevance check
|
|
22
|
+
*/
|
|
23
|
+
private isRelevant;
|
|
24
|
+
/**
|
|
25
|
+
* Prune memory based on token budget (simplified)
|
|
26
|
+
*/
|
|
27
|
+
prune(level: MemoryLevel): void;
|
|
28
|
+
/**
|
|
29
|
+
* Clear task memory (Short-term)
|
|
30
|
+
*/
|
|
31
|
+
clearTaskMemory(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Export full memory state (for persistence)
|
|
34
|
+
*/
|
|
35
|
+
export(): MemorySnapshot;
|
|
36
|
+
/**
|
|
37
|
+
* Import memory state
|
|
38
|
+
*/
|
|
39
|
+
import(snapshot: MemorySnapshot): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MetricsCollector - Tracks system performance and token usage
|
|
3
|
+
*/
|
|
4
|
+
export interface PerformanceStats {
|
|
5
|
+
avgAgentLatency: Record<string, number>;
|
|
6
|
+
avgToolLatency: Record<string, number>;
|
|
7
|
+
tokenUsage: number;
|
|
8
|
+
efficiency: number;
|
|
9
|
+
totalTasks: number;
|
|
10
|
+
successRate: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class MetricsCollector {
|
|
13
|
+
private static instance;
|
|
14
|
+
private agentLatencies;
|
|
15
|
+
private toolLatencies;
|
|
16
|
+
private tokenUsage;
|
|
17
|
+
private lineCount;
|
|
18
|
+
private tasks;
|
|
19
|
+
private constructor();
|
|
20
|
+
static getInstance(): MetricsCollector;
|
|
21
|
+
recordAgentExecution(agent: string, duration: number): void;
|
|
22
|
+
recordToolExecution(tool: string, duration: number): void;
|
|
23
|
+
recordTokenUsage(tokens: number): void;
|
|
24
|
+
recordTaskResult(id: string, success: boolean): void;
|
|
25
|
+
recordLinesProduced(lines: number): void;
|
|
26
|
+
getStats(): PerformanceStats;
|
|
27
|
+
}
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
export declare function ensureSessionInitialized(sessions: Map<string, any>, sessionID: string): any;
|
|
12
12
|
/**
|
|
13
13
|
* Activates the global mission state for a specific session.
|
|
14
|
-
* This is "Session State 2" (Global Orchestrator State).
|
|
15
14
|
*/
|
|
16
15
|
export declare function activateMissionState(sessionID: string): void;
|
|
17
16
|
/**
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin System Interfaces
|
|
3
|
+
*/
|
|
4
|
+
import type { ToolDefinition } from "@opencode-ai/plugin";
|
|
5
|
+
import type { PreToolUseHook, PostToolUseHook, ChatMessageHook, AssistantDoneHook } from "../../hooks/types.js";
|
|
6
|
+
export interface CustomPlugin {
|
|
7
|
+
name: string;
|
|
8
|
+
version: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Tools to register
|
|
12
|
+
*/
|
|
13
|
+
tools?: Record<string, ToolDefinition>;
|
|
14
|
+
/**
|
|
15
|
+
* Hooks to register
|
|
16
|
+
*/
|
|
17
|
+
hooks?: {
|
|
18
|
+
preTool?: PreToolUseHook;
|
|
19
|
+
postTool?: PostToolUseHook;
|
|
20
|
+
chat?: ChatMessageHook;
|
|
21
|
+
done?: AssistantDoneHook;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Initialization logic
|
|
25
|
+
*/
|
|
26
|
+
init?: (context: PluginContext) => Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
export interface PluginContext {
|
|
29
|
+
directory: string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PluginManager - Manages dynamic loading of orchestrator plugins
|
|
3
|
+
*/
|
|
4
|
+
export declare class PluginManager {
|
|
5
|
+
private static instance;
|
|
6
|
+
private plugins;
|
|
7
|
+
private directory;
|
|
8
|
+
private dynamicTools;
|
|
9
|
+
private constructor();
|
|
10
|
+
static getInstance(): PluginManager;
|
|
11
|
+
initialize(directory: string): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Load plugins from .opencode/plugins/*.js
|
|
14
|
+
*/
|
|
15
|
+
private loadPlugins;
|
|
16
|
+
private loadPlugin;
|
|
17
|
+
/**
|
|
18
|
+
* Get all dynamically registered tools
|
|
19
|
+
*/
|
|
20
|
+
getDynamicTools(): Record<string, any>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ParallelAgentManager } from "../agents/manager.js";
|
|
2
|
+
export declare class ProgressNotifier {
|
|
3
|
+
private static _instance;
|
|
4
|
+
private manager;
|
|
5
|
+
private constructor();
|
|
6
|
+
static getInstance(): ProgressNotifier;
|
|
7
|
+
setManager(manager: ParallelAgentManager): void;
|
|
8
|
+
/**
|
|
9
|
+
* Poll current status from ParallelAgentManager and broadcast it
|
|
10
|
+
*/
|
|
11
|
+
update(): void;
|
|
12
|
+
private handleStateChange;
|
|
13
|
+
}
|
|
14
|
+
export declare const progressNotifier: ProgressNotifier;
|