opencode-orchestrator 0.5.4 → 0.5.5
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/dist/agents/definitions.d.ts +1 -1
- package/dist/agents/orchestrator.d.ts +1 -1
- package/dist/agents/subagents/architect.d.ts +1 -1
- package/dist/agents/subagents/builder.d.ts +1 -1
- package/dist/agents/subagents/inspector.d.ts +1 -1
- package/dist/agents/subagents/recorder.d.ts +1 -1
- package/dist/core/agents/concurrency.d.ts +36 -0
- package/dist/core/agents/config.d.ts +9 -0
- package/dist/core/agents/format.d.ts +9 -0
- package/dist/core/agents/index.d.ts +7 -0
- package/dist/core/agents/interfaces/index.d.ts +5 -0
- package/dist/core/agents/interfaces/launch-input.d.ts +9 -0
- package/dist/core/agents/interfaces/parallel-task.d.ts +26 -0
- package/dist/core/agents/logger.d.ts +4 -0
- package/dist/core/agents/manager.d.ts +76 -0
- package/dist/core/agents/task-store.d.ts +28 -0
- package/dist/core/agents/types/index.d.ts +4 -0
- package/dist/core/agents/types/parallel-task-status.d.ts +4 -0
- package/dist/core/commands/index.d.ts +6 -0
- package/dist/core/commands/interfaces/background-task.d.ts +20 -0
- package/dist/core/commands/interfaces/index.d.ts +5 -0
- package/dist/core/commands/interfaces/run-background-options.d.ts +9 -0
- package/dist/core/commands/manager.d.ts +27 -0
- package/dist/core/commands/types/background-task-status.d.ts +4 -0
- package/dist/core/commands/types/index.d.ts +4 -0
- package/dist/core/orchestrator/index.d.ts +7 -0
- package/dist/core/orchestrator/interfaces/index.d.ts +5 -0
- package/dist/core/{state.d.ts → orchestrator/interfaces/session-state.d.ts} +4 -7
- package/dist/core/orchestrator/interfaces/task.d.ts +17 -0
- package/dist/core/orchestrator/state.d.ts +10 -0
- package/dist/core/{tasks.d.ts → orchestrator/task-graph.d.ts} +2 -14
- package/dist/core/orchestrator/types/index.d.ts +5 -0
- package/dist/core/orchestrator/types/task-status.d.ts +4 -0
- package/dist/core/orchestrator/types/task-type.d.ts +4 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +588 -714
- package/dist/shared/{contracts/names.d.ts → agent.d.ts} +12 -0
- package/dist/shared/constants.d.ts +56 -0
- package/dist/tools/background-cmd/check.d.ts +14 -0
- package/dist/tools/background-cmd/index.d.ts +7 -0
- package/dist/tools/background-cmd/kill.d.ts +12 -0
- package/dist/tools/background-cmd/list.d.ts +17 -0
- package/dist/tools/background-cmd/run.d.ts +18 -0
- package/dist/tools/callAgent.d.ts +0 -0
- package/dist/tools/parallel/cancel-task.d.ts +13 -0
- package/dist/tools/parallel/delegate-task.d.ts +21 -0
- package/dist/tools/parallel/get-task-result.d.ts +13 -0
- package/dist/tools/parallel/index.d.ts +7 -0
- package/dist/tools/parallel/list-tasks.d.ts +13 -0
- package/dist/tools/rust.d.ts +0 -0
- package/dist/tools/search.d.ts +2 -9
- package/dist/tools/slashCommand.d.ts +0 -0
- package/dist/utils/binary.d.ts +0 -0
- package/dist/utils/common.d.ts +0 -0
- package/package.json +16 -7
- package/dist/agents/coder.d.ts +0 -2
- package/dist/agents/fixer.d.ts +0 -2
- package/dist/agents/names.d.ts +0 -12
- package/dist/agents/planner.d.ts +0 -2
- package/dist/agents/reviewer.d.ts +0 -2
- package/dist/agents/searcher.d.ts +0 -2
- package/dist/agents/subagents/coder.d.ts +0 -2
- package/dist/agents/subagents/executor.d.ts +0 -2
- package/dist/agents/subagents/fixer.d.ts +0 -2
- package/dist/agents/subagents/frontend-designer.d.ts +0 -2
- package/dist/agents/subagents/memory.d.ts +0 -2
- package/dist/agents/subagents/planner.d.ts +0 -2
- package/dist/agents/subagents/publisher.d.ts +0 -2
- package/dist/agents/subagents/reviewer.d.ts +0 -2
- package/dist/agents/subagents/searcher.d.ts +0 -2
- package/dist/agents/subagents/strategist.d.ts +0 -2
- package/dist/agents/subagents/surgeon.d.ts +0 -2
- package/dist/agents/subagents/types.d.ts +0 -7
- package/dist/agents/subagents/visualist.d.ts +0 -2
- package/dist/agents/types.d.ts +0 -7
- package/dist/cli.d.ts +0 -2
- package/dist/constants/agent.d.ts +0 -8
- package/dist/constants/index.d.ts +0 -7
- package/dist/constants/prompts.d.ts +0 -10
- package/dist/constants/task.d.ts +0 -12
- package/dist/constants/time.d.ts +0 -34
- package/dist/context/enforcer.d.ts +0 -47
- package/dist/core/async-agent.d.ts +0 -100
- package/dist/core/background.d.ts +0 -78
- package/dist/core/batch-processor.d.ts +0 -62
- package/dist/core/config.d.ts +0 -55
- package/dist/core/session-manager.d.ts +0 -39
- package/dist/parallel/optimizer.d.ts +0 -47
- package/dist/profiler/execution.d.ts +0 -40
- package/dist/prompts/shared.d.ts +0 -2
- package/dist/shared/contracts/interfaces.d.ts +0 -7
- package/dist/tasks.d.ts +0 -29
- package/dist/tools/async-agent.d.ts +0 -70
- package/dist/tools/background.d.ts +0 -55
- package/dist/tools/batch.d.ts +0 -53
- package/dist/tools/config.d.ts +0 -60
- package/dist/tools/git.d.ts +0 -48
- package/dist/utils/formatting.d.ts +0 -13
- package/dist/utils/index.d.ts +0 -8
- package/dist/utils/task.d.ts +0 -8
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AgentDefinition } from "../shared/
|
|
1
|
+
import { AgentDefinition } from "../shared/agent.js";
|
|
2
2
|
export declare const AGENTS: Record<string, AgentDefinition>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AgentDefinition } from "../shared/
|
|
1
|
+
import { AgentDefinition } from "../shared/agent.js";
|
|
2
2
|
export declare const orchestrator: AgentDefinition;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AgentDefinition } from "../../shared/
|
|
1
|
+
import { AgentDefinition } from "../../shared/agent.js";
|
|
2
2
|
export declare const architect: AgentDefinition;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AgentDefinition } from "../../shared/
|
|
1
|
+
import { AgentDefinition } from "../../shared/agent.js";
|
|
2
2
|
export declare const builder: AgentDefinition;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AgentDefinition } from "../../shared/
|
|
1
|
+
import { AgentDefinition } from "../../shared/agent.js";
|
|
2
2
|
export declare const inspector: AgentDefinition;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AgentDefinition } from "../../shared/
|
|
1
|
+
import { AgentDefinition } from "../../shared/agent.js";
|
|
2
2
|
export declare const recorder: AgentDefinition;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Concurrency Controller
|
|
3
|
+
*
|
|
4
|
+
* Queue-based rate limiting with support for:
|
|
5
|
+
* - Agent-specific limits
|
|
6
|
+
* - Provider-specific limits (e.g., anthropic/*, openai/*)
|
|
7
|
+
* - Model-specific limits (e.g., anthropic/claude-3-5-sonnet)
|
|
8
|
+
*/
|
|
9
|
+
export interface ConcurrencyConfig {
|
|
10
|
+
defaultConcurrency?: number;
|
|
11
|
+
agentConcurrency?: Record<string, number>;
|
|
12
|
+
providerConcurrency?: Record<string, number>;
|
|
13
|
+
modelConcurrency?: Record<string, number>;
|
|
14
|
+
}
|
|
15
|
+
export declare class ConcurrencyController {
|
|
16
|
+
private counts;
|
|
17
|
+
private queues;
|
|
18
|
+
private limits;
|
|
19
|
+
private config;
|
|
20
|
+
constructor(config?: ConcurrencyConfig);
|
|
21
|
+
setLimit(key: string, limit: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* Get concurrency limit for a key.
|
|
24
|
+
* Priority: explicit limit > model > provider > agent > default
|
|
25
|
+
*/
|
|
26
|
+
getConcurrencyLimit(key: string): number;
|
|
27
|
+
getLimit(key: string): number;
|
|
28
|
+
acquire(key: string): Promise<void>;
|
|
29
|
+
release(key: string): void;
|
|
30
|
+
getQueueLength(key: string): number;
|
|
31
|
+
getActiveCount(key: string): number;
|
|
32
|
+
/**
|
|
33
|
+
* Get formatted concurrency info string (e.g., "2/5 slots")
|
|
34
|
+
*/
|
|
35
|
+
getConcurrencyInfo(key: string): string;
|
|
36
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parallel Module - Agent parallel execution
|
|
3
|
+
*/
|
|
4
|
+
export * from "./types/index.js";
|
|
5
|
+
export * from "./interfaces/index.js";
|
|
6
|
+
export { ConcurrencyController } from "./concurrency.js";
|
|
7
|
+
export { ParallelAgentManager, parallelAgentManager } from "./manager.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ParallelTask - Represents a task running in a parallel session
|
|
3
|
+
*/
|
|
4
|
+
import { ParallelTaskStatus } from "../types/parallel-task-status.js";
|
|
5
|
+
export interface TaskProgress {
|
|
6
|
+
toolCalls: number;
|
|
7
|
+
lastTool?: string;
|
|
8
|
+
lastMessage?: string;
|
|
9
|
+
lastUpdate: Date;
|
|
10
|
+
}
|
|
11
|
+
export interface ParallelTask {
|
|
12
|
+
id: string;
|
|
13
|
+
sessionID: string;
|
|
14
|
+
parentSessionID: string;
|
|
15
|
+
description: string;
|
|
16
|
+
agent: string;
|
|
17
|
+
status: ParallelTaskStatus;
|
|
18
|
+
startedAt: Date;
|
|
19
|
+
completedAt?: Date;
|
|
20
|
+
error?: string;
|
|
21
|
+
result?: string;
|
|
22
|
+
concurrencyKey?: string;
|
|
23
|
+
lastMsgCount?: number;
|
|
24
|
+
stablePolls?: number;
|
|
25
|
+
progress?: TaskProgress;
|
|
26
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
10
|
+
import { formatDuration } from "./format.js";
|
|
11
|
+
import type { ParallelTask } from "./interfaces/parallel-task.js";
|
|
12
|
+
import type { LaunchInput } from "./interfaces/launch-input.js";
|
|
13
|
+
export type { ParallelTask };
|
|
14
|
+
export { formatDuration };
|
|
15
|
+
type OpencodeClient = PluginInput["client"];
|
|
16
|
+
export declare class ParallelAgentManager {
|
|
17
|
+
private static _instance;
|
|
18
|
+
private store;
|
|
19
|
+
private client;
|
|
20
|
+
private directory;
|
|
21
|
+
private concurrency;
|
|
22
|
+
private pollingInterval?;
|
|
23
|
+
private constructor();
|
|
24
|
+
static getInstance(client?: OpencodeClient, directory?: string): ParallelAgentManager;
|
|
25
|
+
launch(input: LaunchInput): Promise<ParallelTask>;
|
|
26
|
+
getTask(id: string): ParallelTask | undefined;
|
|
27
|
+
getRunningTasks(): ParallelTask[];
|
|
28
|
+
getAllTasks(): ParallelTask[];
|
|
29
|
+
getTasksByParent(parentSessionID: string): ParallelTask[];
|
|
30
|
+
cancelTask(taskId: string): Promise<boolean>;
|
|
31
|
+
getResult(taskId: string): Promise<string | null>;
|
|
32
|
+
setConcurrencyLimit(agentType: string, limit: number): void;
|
|
33
|
+
getPendingCount(parentSessionID: string): number;
|
|
34
|
+
cleanup(): void;
|
|
35
|
+
formatDuration: typeof formatDuration;
|
|
36
|
+
/**
|
|
37
|
+
* Handle OpenCode session events for proper resource cleanup.
|
|
38
|
+
* Call this from your plugin's event hook.
|
|
39
|
+
*/
|
|
40
|
+
handleEvent(event: {
|
|
41
|
+
type: string;
|
|
42
|
+
properties?: {
|
|
43
|
+
sessionID?: string;
|
|
44
|
+
info?: {
|
|
45
|
+
id?: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
}): void;
|
|
49
|
+
/**
|
|
50
|
+
* Find task by session ID
|
|
51
|
+
*/
|
|
52
|
+
private findBySession;
|
|
53
|
+
/**
|
|
54
|
+
* Handle session.idle event - validate and complete task
|
|
55
|
+
*/
|
|
56
|
+
private handleSessionIdle;
|
|
57
|
+
private handleTaskError;
|
|
58
|
+
private startPolling;
|
|
59
|
+
private stopPolling;
|
|
60
|
+
private pollRunningTasks;
|
|
61
|
+
/**
|
|
62
|
+
* Update task progress and stability tracking
|
|
63
|
+
*/
|
|
64
|
+
private updateTaskProgress;
|
|
65
|
+
/**
|
|
66
|
+
* Complete a task and cleanup
|
|
67
|
+
*/
|
|
68
|
+
private completeTask;
|
|
69
|
+
private validateSessionHasOutput;
|
|
70
|
+
private pruneExpiredTasks;
|
|
71
|
+
private scheduleCleanup;
|
|
72
|
+
private notifyParentIfAllComplete;
|
|
73
|
+
}
|
|
74
|
+
export declare const parallelAgentManager: {
|
|
75
|
+
getInstance: typeof ParallelAgentManager.getInstance;
|
|
76
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Store - Stores and manages parallel tasks
|
|
3
|
+
*/
|
|
4
|
+
import type { ParallelTask } from "./interfaces/parallel-task.js";
|
|
5
|
+
export declare class TaskStore {
|
|
6
|
+
private tasks;
|
|
7
|
+
private pendingByParent;
|
|
8
|
+
private notifications;
|
|
9
|
+
set(id: string, task: ParallelTask): void;
|
|
10
|
+
get(id: string): ParallelTask | undefined;
|
|
11
|
+
getAll(): ParallelTask[];
|
|
12
|
+
getRunning(): ParallelTask[];
|
|
13
|
+
getByParent(parentSessionID: string): ParallelTask[];
|
|
14
|
+
delete(id: string): boolean;
|
|
15
|
+
clear(): void;
|
|
16
|
+
trackPending(parentSessionID: string, taskId: string): void;
|
|
17
|
+
untrackPending(parentSessionID: string, taskId: string): void;
|
|
18
|
+
getPendingCount(parentSessionID: string): number;
|
|
19
|
+
hasPending(parentSessionID: string): boolean;
|
|
20
|
+
queueNotification(task: ParallelTask): void;
|
|
21
|
+
getNotifications(parentSessionID: string): ParallelTask[];
|
|
22
|
+
clearNotifications(parentSessionID: string): void;
|
|
23
|
+
cleanEmptyNotifications(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Remove a specific task from all notification queues
|
|
26
|
+
*/
|
|
27
|
+
clearNotificationsForTask(taskId: string): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BackgroundTask - Represents a shell command running in background
|
|
3
|
+
*/
|
|
4
|
+
import { ChildProcess } from "child_process";
|
|
5
|
+
import { BackgroundTaskStatus } from "../types/background-task-status.js";
|
|
6
|
+
export interface BackgroundTask {
|
|
7
|
+
id: string;
|
|
8
|
+
command: string;
|
|
9
|
+
args: string[];
|
|
10
|
+
cwd: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
status: BackgroundTaskStatus;
|
|
13
|
+
output: string;
|
|
14
|
+
errorOutput: string;
|
|
15
|
+
exitCode: number | null;
|
|
16
|
+
startTime: number;
|
|
17
|
+
endTime?: number;
|
|
18
|
+
timeout: number;
|
|
19
|
+
process?: ChildProcess;
|
|
20
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background Task Manager
|
|
3
|
+
*
|
|
4
|
+
* Runs shell commands in the background and tracks their output.
|
|
5
|
+
*/
|
|
6
|
+
import type { BackgroundTask } from "./interfaces/background-task.js";
|
|
7
|
+
import type { BackgroundTaskStatus } from "./types/background-task-status.js";
|
|
8
|
+
import type { RunBackgroundOptions } from "./interfaces/run-background-options.js";
|
|
9
|
+
declare class BackgroundTaskManager {
|
|
10
|
+
private static _instance;
|
|
11
|
+
private tasks;
|
|
12
|
+
private debugMode;
|
|
13
|
+
private constructor();
|
|
14
|
+
static get instance(): BackgroundTaskManager;
|
|
15
|
+
private generateId;
|
|
16
|
+
private debug;
|
|
17
|
+
run(options: RunBackgroundOptions): BackgroundTask;
|
|
18
|
+
get(taskId: string): BackgroundTask | undefined;
|
|
19
|
+
getAll(): BackgroundTask[];
|
|
20
|
+
getByStatus(status: BackgroundTaskStatus): BackgroundTask[];
|
|
21
|
+
clearCompleted(): number;
|
|
22
|
+
kill(taskId: string): boolean;
|
|
23
|
+
formatDuration(task: BackgroundTask): string;
|
|
24
|
+
getStatusEmoji(status: BackgroundTaskStatus): string;
|
|
25
|
+
}
|
|
26
|
+
export declare const backgroundTaskManager: BackgroundTaskManager;
|
|
27
|
+
export {};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* SessionState - State for a single orchestration session
|
|
3
|
+
*/
|
|
4
|
+
import type { TaskGraph } from "../task-graph.js";
|
|
2
5
|
export interface SessionState {
|
|
3
6
|
enabled: boolean;
|
|
4
7
|
iterations: number;
|
|
@@ -8,9 +11,3 @@ export interface SessionState {
|
|
|
8
11
|
anomalyCount: number;
|
|
9
12
|
lastHealthyOutput?: string;
|
|
10
13
|
}
|
|
11
|
-
export declare const state: {
|
|
12
|
-
missionActive: boolean;
|
|
13
|
-
maxIterations: number;
|
|
14
|
-
maxRetries: number;
|
|
15
|
-
sessions: Map<string, SessionState>;
|
|
16
|
-
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task - A single task in the orchestration DAG
|
|
3
|
+
*/
|
|
4
|
+
import { TaskStatus } from "../types/task-status.js";
|
|
5
|
+
import { TaskType } from "../types/task-type.js";
|
|
6
|
+
export interface Task {
|
|
7
|
+
id: string;
|
|
8
|
+
description: string;
|
|
9
|
+
action: string;
|
|
10
|
+
file: string;
|
|
11
|
+
dependencies: string[];
|
|
12
|
+
status: TaskStatus;
|
|
13
|
+
result?: string;
|
|
14
|
+
retryCount: number;
|
|
15
|
+
complexity: number;
|
|
16
|
+
type: TaskType;
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global State - Orchestration state manager
|
|
3
|
+
*/
|
|
4
|
+
import { SessionState } from "./interfaces/session-state.js";
|
|
5
|
+
export declare const state: {
|
|
6
|
+
missionActive: boolean;
|
|
7
|
+
maxIterations: number;
|
|
8
|
+
maxRetries: number;
|
|
9
|
+
sessions: Map<string, SessionState>;
|
|
10
|
+
};
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* TaskGraph - DAG for task orchestration
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
export interface Task {
|
|
6
|
-
id: string;
|
|
7
|
-
description: string;
|
|
8
|
-
action: string;
|
|
9
|
-
file: string;
|
|
10
|
-
dependencies: string[];
|
|
11
|
-
status: TaskStatus;
|
|
12
|
-
result?: string;
|
|
13
|
-
retryCount: number;
|
|
14
|
-
complexity: number;
|
|
15
|
-
type: "infrastructure" | "logic" | "integration";
|
|
16
|
-
}
|
|
4
|
+
import { Task } from "./interfaces/task.js";
|
|
17
5
|
export declare class TaskGraph {
|
|
18
6
|
private tasks;
|
|
19
7
|
constructor(tasks?: Task[]);
|
package/dist/index.d.ts
CHANGED
|
@@ -67,12 +67,10 @@ declare const OrchestratorPlugin: (input: PluginInput) => Promise<{
|
|
|
67
67
|
args: {
|
|
68
68
|
patterns: import("zod").ZodArray<import("zod").ZodString>;
|
|
69
69
|
dir: import("zod").ZodOptional<import("zod").ZodString>;
|
|
70
|
-
max_results_per_pattern: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
71
70
|
};
|
|
72
71
|
execute(args: {
|
|
73
72
|
patterns: string[];
|
|
74
73
|
dir?: string | undefined;
|
|
75
|
-
max_results_per_pattern?: number | undefined;
|
|
76
74
|
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
77
75
|
};
|
|
78
76
|
run_background: {
|