opencode-orchestrator 0.2.3 → 0.4.1
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 +27 -1
- package/bin/orchestrator-linux-arm64 +0 -0
- package/bin/orchestrator-linux-x64 +0 -0
- package/dist/core/async-agent.d.ts +100 -0
- package/dist/core/background.d.ts +78 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.js +1350 -8
- package/dist/tools/async-agent.d.ts +70 -0
- package/dist/tools/background.d.ts +55 -0
- package/dist/tools/search.d.ts +22 -0
- package/dist/utils/common.d.ts +11 -0
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -28,13 +28,17 @@ A **5-agent autonomous architecture** designed to solve complex engineering task
|
|
|
28
28
|
|
|
29
29
|
**Core Philosophy**: Intelligence is a resource. We orchestrate that resource through **Phase-based Workflows** and **Mandatory Environment Scans** to ensure code always fits the project's infrastructure.
|
|
30
30
|
|
|
31
|
+
> 🦀 **Powered by Rust** — Background tasks and parallel searches run on native Rust binaries for maximum performance.
|
|
32
|
+
|
|
31
33
|
### Key Features
|
|
32
34
|
- **🎯 Autonomous Loop** — Commander runs relentlessly until the mission is complete.
|
|
33
35
|
- **🔍 Environment Scan** — Mandatory analysis of Infra (Docker/OS), Stack, and Domain before any code change.
|
|
34
36
|
- **🔨 Smart Implementation** — Builder matches existing codebase patterns exactly.
|
|
35
37
|
- **🛡️ Rigorous Audit** — Inspector proves success with environment-specific evidence (Builds/Tests/Logs).
|
|
36
38
|
- **💾 Persistent Context** — Recorder saves session state to disk, enabling resume at any time.
|
|
37
|
-
- **🏗️ Parallel
|
|
39
|
+
- **🏗️ Parallel Agents** — Delegated agent execution (`delegate_task`) with sync/async modes.
|
|
40
|
+
- **⏳ Background Tasks** — Run long commands (builds, tests) in background and check results later.
|
|
41
|
+
- **🔎 mgrep** — Multi-pattern parallel search powered by Rust for blazing-fast codebase analysis.
|
|
38
42
|
|
|
39
43
|
---
|
|
40
44
|
|
|
@@ -79,6 +83,26 @@ The Commander will:
|
|
|
79
83
|
> **💡 Tip:** Using the `/task` command makes Commander mode run **2x longer**.
|
|
80
84
|
> Use `/task` for complex tasks that need extended processing!
|
|
81
85
|
|
|
86
|
+
### ⚡ Example: Parallel Execution
|
|
87
|
+
|
|
88
|
+
Trigger parallel agent execution with prompts like:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
"Build and test in parallel"
|
|
92
|
+
"Implement feature X while reviewing module Y"
|
|
93
|
+
"Run linting, tests, and build at the same time"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Commander will automatically use `delegate_task` with `background: true` for independent tasks.
|
|
97
|
+
|
|
98
|
+
Monitor parallel tasks in the terminal:
|
|
99
|
+
```
|
|
100
|
+
[parallel] 🚀 SPAWNED task_a1b2 → builder: Implement feature X
|
|
101
|
+
[parallel] 🚀 SPAWNED task_c3d4 → inspector: Review module Y
|
|
102
|
+
[parallel] ✅ COMPLETED task_c3d4 → inspector: Review module Y (45s)
|
|
103
|
+
[parallel] 🗑️ CLEANED task_c3d4 (session deleted)
|
|
104
|
+
```
|
|
105
|
+
|
|
82
106
|
---
|
|
83
107
|
|
|
84
108
|
## Agents (5-Agent Architecture)
|
|
@@ -123,6 +147,8 @@ npm uninstall -g opencode-orchestrator
|
|
|
123
147
|
|
|
124
148
|
- [Architecture & Design](docs/ARCHITECTURE.md) — Detailed system design and agent protocols
|
|
125
149
|
- [Plugin Troubleshooting](docs/PLUGIN_TROUBLESHOOTING.md) — Setup and common issues
|
|
150
|
+
- [Changelog](CHANGELOG.md) — Version history and updates
|
|
151
|
+
- [Changelogs](changelogs/) — Detailed implementation notes per release
|
|
126
152
|
|
|
127
153
|
---
|
|
128
154
|
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parallel Agent Manager - Session-based async agent execution
|
|
3
|
+
*
|
|
4
|
+
* Key safety features:
|
|
5
|
+
* - Concurrency control per agent type (queue-based)
|
|
6
|
+
* - Batched notifications (notify when ALL complete)
|
|
7
|
+
* - Automatic memory cleanup (5 min after completion)
|
|
8
|
+
* - TTL enforcement (30 min timeout)
|
|
9
|
+
* - Output validation before completion
|
|
10
|
+
* - Process-safe polling (unref)
|
|
11
|
+
*/
|
|
12
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
13
|
+
type OpencodeClient = PluginInput["client"];
|
|
14
|
+
export interface ParallelTask {
|
|
15
|
+
id: string;
|
|
16
|
+
sessionID: string;
|
|
17
|
+
parentSessionID: string;
|
|
18
|
+
description: string;
|
|
19
|
+
agent: string;
|
|
20
|
+
status: "pending" | "running" | "completed" | "error" | "timeout";
|
|
21
|
+
startedAt: Date;
|
|
22
|
+
completedAt?: Date;
|
|
23
|
+
error?: string;
|
|
24
|
+
result?: string;
|
|
25
|
+
concurrencyKey?: string;
|
|
26
|
+
}
|
|
27
|
+
interface LaunchInput {
|
|
28
|
+
description: string;
|
|
29
|
+
prompt: string;
|
|
30
|
+
agent: string;
|
|
31
|
+
parentSessionID: string;
|
|
32
|
+
}
|
|
33
|
+
export declare class ParallelAgentManager {
|
|
34
|
+
private static _instance;
|
|
35
|
+
private tasks;
|
|
36
|
+
private pendingByParent;
|
|
37
|
+
private notifications;
|
|
38
|
+
private client;
|
|
39
|
+
private directory;
|
|
40
|
+
private concurrency;
|
|
41
|
+
private pollingInterval?;
|
|
42
|
+
private constructor();
|
|
43
|
+
static getInstance(client?: OpencodeClient, directory?: string): ParallelAgentManager;
|
|
44
|
+
/**
|
|
45
|
+
* Launch an agent in a new session (async, non-blocking)
|
|
46
|
+
*/
|
|
47
|
+
launch(input: LaunchInput): Promise<ParallelTask>;
|
|
48
|
+
/**
|
|
49
|
+
* Get task by ID
|
|
50
|
+
*/
|
|
51
|
+
getTask(id: string): ParallelTask | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Get all running tasks
|
|
54
|
+
*/
|
|
55
|
+
getRunningTasks(): ParallelTask[];
|
|
56
|
+
/**
|
|
57
|
+
* Get all tasks
|
|
58
|
+
*/
|
|
59
|
+
getAllTasks(): ParallelTask[];
|
|
60
|
+
/**
|
|
61
|
+
* Get tasks by parent session
|
|
62
|
+
*/
|
|
63
|
+
getTasksByParent(parentSessionID: string): ParallelTask[];
|
|
64
|
+
/**
|
|
65
|
+
* Cancel a running task
|
|
66
|
+
*/
|
|
67
|
+
cancelTask(taskId: string): Promise<boolean>;
|
|
68
|
+
/**
|
|
69
|
+
* Get result from completed task
|
|
70
|
+
*/
|
|
71
|
+
getResult(taskId: string): Promise<string | null>;
|
|
72
|
+
/**
|
|
73
|
+
* Set concurrency limit for agent type
|
|
74
|
+
*/
|
|
75
|
+
setConcurrencyLimit(agentType: string, limit: number): void;
|
|
76
|
+
/**
|
|
77
|
+
* Get pending notification count
|
|
78
|
+
*/
|
|
79
|
+
getPendingCount(parentSessionID: string): number;
|
|
80
|
+
/**
|
|
81
|
+
* Cleanup all state
|
|
82
|
+
*/
|
|
83
|
+
cleanup(): void;
|
|
84
|
+
private trackPending;
|
|
85
|
+
private untrackPending;
|
|
86
|
+
private handleTaskError;
|
|
87
|
+
private startPolling;
|
|
88
|
+
private stopPolling;
|
|
89
|
+
private pollRunningTasks;
|
|
90
|
+
private validateSessionHasOutput;
|
|
91
|
+
private pruneExpiredTasks;
|
|
92
|
+
private scheduleCleanup;
|
|
93
|
+
private queueNotification;
|
|
94
|
+
private notifyParentIfAllComplete;
|
|
95
|
+
formatDuration(start: Date, end?: Date): string;
|
|
96
|
+
}
|
|
97
|
+
export declare const parallelAgentManager: {
|
|
98
|
+
getInstance: typeof ParallelAgentManager.getInstance;
|
|
99
|
+
};
|
|
100
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background Task Manager for OpenCode Orchestrator
|
|
3
|
+
*
|
|
4
|
+
* Enables running commands in the background and checking their status later.
|
|
5
|
+
* This allows the AI to continue working while long-running tasks execute.
|
|
6
|
+
*/
|
|
7
|
+
import { ChildProcess } from "child_process";
|
|
8
|
+
export type TaskStatus = "pending" | "running" | "done" | "error" | "timeout";
|
|
9
|
+
export interface BackgroundTask {
|
|
10
|
+
id: string;
|
|
11
|
+
command: string;
|
|
12
|
+
args: string[];
|
|
13
|
+
cwd: string;
|
|
14
|
+
label?: string;
|
|
15
|
+
status: TaskStatus;
|
|
16
|
+
output: string;
|
|
17
|
+
errorOutput: string;
|
|
18
|
+
exitCode: number | null;
|
|
19
|
+
startTime: number;
|
|
20
|
+
endTime?: number;
|
|
21
|
+
timeout: number;
|
|
22
|
+
process?: ChildProcess;
|
|
23
|
+
}
|
|
24
|
+
export interface RunBackgroundOptions {
|
|
25
|
+
command: string;
|
|
26
|
+
cwd?: string;
|
|
27
|
+
timeout?: number;
|
|
28
|
+
label?: string;
|
|
29
|
+
}
|
|
30
|
+
declare class BackgroundTaskManager {
|
|
31
|
+
private static _instance;
|
|
32
|
+
private tasks;
|
|
33
|
+
private debugMode;
|
|
34
|
+
private constructor();
|
|
35
|
+
static get instance(): BackgroundTaskManager;
|
|
36
|
+
/**
|
|
37
|
+
* Generate a unique task ID in the format job_xxxxxxxx
|
|
38
|
+
*/
|
|
39
|
+
private generateId;
|
|
40
|
+
/**
|
|
41
|
+
* Debug logging helper
|
|
42
|
+
*/
|
|
43
|
+
private debug;
|
|
44
|
+
/**
|
|
45
|
+
* Run a command in the background
|
|
46
|
+
*/
|
|
47
|
+
run(options: RunBackgroundOptions): BackgroundTask;
|
|
48
|
+
/**
|
|
49
|
+
* Get task by ID
|
|
50
|
+
*/
|
|
51
|
+
get(taskId: string): BackgroundTask | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Get all tasks
|
|
54
|
+
*/
|
|
55
|
+
getAll(): BackgroundTask[];
|
|
56
|
+
/**
|
|
57
|
+
* Get tasks by status
|
|
58
|
+
*/
|
|
59
|
+
getByStatus(status: TaskStatus): BackgroundTask[];
|
|
60
|
+
/**
|
|
61
|
+
* Clear completed/failed tasks
|
|
62
|
+
*/
|
|
63
|
+
clearCompleted(): number;
|
|
64
|
+
/**
|
|
65
|
+
* Kill a running task
|
|
66
|
+
*/
|
|
67
|
+
kill(taskId: string): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Format duration for display
|
|
70
|
+
*/
|
|
71
|
+
formatDuration(task: BackgroundTask): string;
|
|
72
|
+
/**
|
|
73
|
+
* Get status emoji
|
|
74
|
+
*/
|
|
75
|
+
getStatusEmoji(status: TaskStatus): string;
|
|
76
|
+
}
|
|
77
|
+
export declare const backgroundTaskManager: BackgroundTaskManager;
|
|
78
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -62,6 +62,68 @@ declare const OrchestratorPlugin: (input: PluginInput) => Promise<{
|
|
|
62
62
|
dir?: string | undefined;
|
|
63
63
|
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
64
64
|
};
|
|
65
|
+
mgrep: {
|
|
66
|
+
description: string;
|
|
67
|
+
args: {
|
|
68
|
+
patterns: import("zod").ZodArray<import("zod").ZodString>;
|
|
69
|
+
dir: import("zod").ZodOptional<import("zod").ZodString>;
|
|
70
|
+
max_results_per_pattern: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
71
|
+
};
|
|
72
|
+
execute(args: {
|
|
73
|
+
patterns: string[];
|
|
74
|
+
dir?: string | undefined;
|
|
75
|
+
max_results_per_pattern?: number | undefined;
|
|
76
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
77
|
+
};
|
|
78
|
+
run_background: {
|
|
79
|
+
description: string;
|
|
80
|
+
args: {
|
|
81
|
+
command: import("zod").ZodString;
|
|
82
|
+
cwd: import("zod").ZodOptional<import("zod").ZodString>;
|
|
83
|
+
timeout: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
84
|
+
label: import("zod").ZodOptional<import("zod").ZodString>;
|
|
85
|
+
};
|
|
86
|
+
execute(args: {
|
|
87
|
+
command: string;
|
|
88
|
+
cwd?: string | undefined;
|
|
89
|
+
timeout?: number | undefined;
|
|
90
|
+
label?: string | undefined;
|
|
91
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
92
|
+
};
|
|
93
|
+
check_background: {
|
|
94
|
+
description: string;
|
|
95
|
+
args: {
|
|
96
|
+
taskId: import("zod").ZodString;
|
|
97
|
+
tailLines: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
98
|
+
};
|
|
99
|
+
execute(args: {
|
|
100
|
+
taskId: string;
|
|
101
|
+
tailLines?: number | undefined;
|
|
102
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
103
|
+
};
|
|
104
|
+
list_background: {
|
|
105
|
+
description: string;
|
|
106
|
+
args: {
|
|
107
|
+
status: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
108
|
+
error: "error";
|
|
109
|
+
running: "running";
|
|
110
|
+
done: "done";
|
|
111
|
+
all: "all";
|
|
112
|
+
}>>;
|
|
113
|
+
};
|
|
114
|
+
execute(args: {
|
|
115
|
+
status?: "error" | "running" | "done" | "all" | undefined;
|
|
116
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
117
|
+
};
|
|
118
|
+
kill_background: {
|
|
119
|
+
description: string;
|
|
120
|
+
args: {
|
|
121
|
+
taskId: import("zod").ZodString;
|
|
122
|
+
};
|
|
123
|
+
execute(args: {
|
|
124
|
+
taskId: string;
|
|
125
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
126
|
+
};
|
|
65
127
|
};
|
|
66
128
|
config: (config: Record<string, unknown>) => Promise<void>;
|
|
67
129
|
"chat.message": (msgInput: any, msgOutput: any) => Promise<void>;
|