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.
Files changed (100) hide show
  1. package/dist/agents/definitions.d.ts +1 -1
  2. package/dist/agents/orchestrator.d.ts +1 -1
  3. package/dist/agents/subagents/architect.d.ts +1 -1
  4. package/dist/agents/subagents/builder.d.ts +1 -1
  5. package/dist/agents/subagents/inspector.d.ts +1 -1
  6. package/dist/agents/subagents/recorder.d.ts +1 -1
  7. package/dist/core/agents/concurrency.d.ts +36 -0
  8. package/dist/core/agents/config.d.ts +9 -0
  9. package/dist/core/agents/format.d.ts +9 -0
  10. package/dist/core/agents/index.d.ts +7 -0
  11. package/dist/core/agents/interfaces/index.d.ts +5 -0
  12. package/dist/core/agents/interfaces/launch-input.d.ts +9 -0
  13. package/dist/core/agents/interfaces/parallel-task.d.ts +26 -0
  14. package/dist/core/agents/logger.d.ts +4 -0
  15. package/dist/core/agents/manager.d.ts +76 -0
  16. package/dist/core/agents/task-store.d.ts +28 -0
  17. package/dist/core/agents/types/index.d.ts +4 -0
  18. package/dist/core/agents/types/parallel-task-status.d.ts +4 -0
  19. package/dist/core/commands/index.d.ts +6 -0
  20. package/dist/core/commands/interfaces/background-task.d.ts +20 -0
  21. package/dist/core/commands/interfaces/index.d.ts +5 -0
  22. package/dist/core/commands/interfaces/run-background-options.d.ts +9 -0
  23. package/dist/core/commands/manager.d.ts +27 -0
  24. package/dist/core/commands/types/background-task-status.d.ts +4 -0
  25. package/dist/core/commands/types/index.d.ts +4 -0
  26. package/dist/core/orchestrator/index.d.ts +7 -0
  27. package/dist/core/orchestrator/interfaces/index.d.ts +5 -0
  28. package/dist/core/{state.d.ts → orchestrator/interfaces/session-state.d.ts} +4 -7
  29. package/dist/core/orchestrator/interfaces/task.d.ts +17 -0
  30. package/dist/core/orchestrator/state.d.ts +10 -0
  31. package/dist/core/{tasks.d.ts → orchestrator/task-graph.d.ts} +2 -14
  32. package/dist/core/orchestrator/types/index.d.ts +5 -0
  33. package/dist/core/orchestrator/types/task-status.d.ts +4 -0
  34. package/dist/core/orchestrator/types/task-type.d.ts +4 -0
  35. package/dist/index.d.ts +0 -2
  36. package/dist/index.js +588 -714
  37. package/dist/shared/{contracts/names.d.ts → agent.d.ts} +12 -0
  38. package/dist/shared/constants.d.ts +56 -0
  39. package/dist/tools/background-cmd/check.d.ts +14 -0
  40. package/dist/tools/background-cmd/index.d.ts +7 -0
  41. package/dist/tools/background-cmd/kill.d.ts +12 -0
  42. package/dist/tools/background-cmd/list.d.ts +17 -0
  43. package/dist/tools/background-cmd/run.d.ts +18 -0
  44. package/dist/tools/callAgent.d.ts +0 -0
  45. package/dist/tools/parallel/cancel-task.d.ts +13 -0
  46. package/dist/tools/parallel/delegate-task.d.ts +21 -0
  47. package/dist/tools/parallel/get-task-result.d.ts +13 -0
  48. package/dist/tools/parallel/index.d.ts +7 -0
  49. package/dist/tools/parallel/list-tasks.d.ts +13 -0
  50. package/dist/tools/rust.d.ts +0 -0
  51. package/dist/tools/search.d.ts +2 -9
  52. package/dist/tools/slashCommand.d.ts +0 -0
  53. package/dist/utils/binary.d.ts +0 -0
  54. package/dist/utils/common.d.ts +0 -0
  55. package/package.json +16 -7
  56. package/dist/agents/coder.d.ts +0 -2
  57. package/dist/agents/fixer.d.ts +0 -2
  58. package/dist/agents/names.d.ts +0 -12
  59. package/dist/agents/planner.d.ts +0 -2
  60. package/dist/agents/reviewer.d.ts +0 -2
  61. package/dist/agents/searcher.d.ts +0 -2
  62. package/dist/agents/subagents/coder.d.ts +0 -2
  63. package/dist/agents/subagents/executor.d.ts +0 -2
  64. package/dist/agents/subagents/fixer.d.ts +0 -2
  65. package/dist/agents/subagents/frontend-designer.d.ts +0 -2
  66. package/dist/agents/subagents/memory.d.ts +0 -2
  67. package/dist/agents/subagents/planner.d.ts +0 -2
  68. package/dist/agents/subagents/publisher.d.ts +0 -2
  69. package/dist/agents/subagents/reviewer.d.ts +0 -2
  70. package/dist/agents/subagents/searcher.d.ts +0 -2
  71. package/dist/agents/subagents/strategist.d.ts +0 -2
  72. package/dist/agents/subagents/surgeon.d.ts +0 -2
  73. package/dist/agents/subagents/types.d.ts +0 -7
  74. package/dist/agents/subagents/visualist.d.ts +0 -2
  75. package/dist/agents/types.d.ts +0 -7
  76. package/dist/cli.d.ts +0 -2
  77. package/dist/constants/agent.d.ts +0 -8
  78. package/dist/constants/index.d.ts +0 -7
  79. package/dist/constants/prompts.d.ts +0 -10
  80. package/dist/constants/task.d.ts +0 -12
  81. package/dist/constants/time.d.ts +0 -34
  82. package/dist/context/enforcer.d.ts +0 -47
  83. package/dist/core/async-agent.d.ts +0 -100
  84. package/dist/core/background.d.ts +0 -78
  85. package/dist/core/batch-processor.d.ts +0 -62
  86. package/dist/core/config.d.ts +0 -55
  87. package/dist/core/session-manager.d.ts +0 -39
  88. package/dist/parallel/optimizer.d.ts +0 -47
  89. package/dist/profiler/execution.d.ts +0 -40
  90. package/dist/prompts/shared.d.ts +0 -2
  91. package/dist/shared/contracts/interfaces.d.ts +0 -7
  92. package/dist/tasks.d.ts +0 -29
  93. package/dist/tools/async-agent.d.ts +0 -70
  94. package/dist/tools/background.d.ts +0 -55
  95. package/dist/tools/batch.d.ts +0 -53
  96. package/dist/tools/config.d.ts +0 -60
  97. package/dist/tools/git.d.ts +0 -48
  98. package/dist/utils/formatting.d.ts +0 -13
  99. package/dist/utils/index.d.ts +0 -8
  100. package/dist/utils/task.d.ts +0 -8
@@ -1,2 +1,2 @@
1
- import { AgentDefinition } from "../shared/contracts/interfaces.js";
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/contracts/interfaces.js";
1
+ import { AgentDefinition } from "../shared/agent.js";
2
2
  export declare const orchestrator: AgentDefinition;
@@ -1,2 +1,2 @@
1
- import { AgentDefinition } from "../../shared/contracts/interfaces.js";
1
+ import { AgentDefinition } from "../../shared/agent.js";
2
2
  export declare const architect: AgentDefinition;
@@ -1,2 +1,2 @@
1
- import { AgentDefinition } from "../../shared/contracts/interfaces.js";
1
+ import { AgentDefinition } from "../../shared/agent.js";
2
2
  export declare const builder: AgentDefinition;
@@ -1,2 +1,2 @@
1
- import { AgentDefinition } from "../../shared/contracts/interfaces.js";
1
+ import { AgentDefinition } from "../../shared/agent.js";
2
2
  export declare const inspector: AgentDefinition;
@@ -1,2 +1,2 @@
1
- import { AgentDefinition } from "../../shared/contracts/interfaces.js";
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,9 @@
1
+ /**
2
+ * Parallel Manager Configuration
3
+ */
4
+ export declare const CONFIG: {
5
+ readonly TASK_TTL_MS: number;
6
+ readonly CLEANUP_DELAY_MS: number;
7
+ readonly MIN_STABILITY_MS: number;
8
+ readonly POLL_INTERVAL_MS: 2000;
9
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Format utilities for parallel tasks
3
+ */
4
+ export declare function formatDuration(start: Date, end?: Date): string;
5
+ export declare function buildNotificationMessage(tasks: Array<{
6
+ id: string;
7
+ description: string;
8
+ status: string;
9
+ }>): string;
@@ -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,5 @@
1
+ /**
2
+ * Parallel Module Interfaces Index
3
+ */
4
+ export { ParallelTask } from "./parallel-task.js";
5
+ export { LaunchInput } from "./launch-input.js";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * LaunchInput - Input for launching a parallel task
3
+ */
4
+ export interface LaunchInput {
5
+ description: string;
6
+ prompt: string;
7
+ agent: string;
8
+ parentSessionID: string;
9
+ }
@@ -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,4 @@
1
+ /**
2
+ * Debug logger for parallel agent
3
+ */
4
+ export declare function log(...args: unknown[]): void;
@@ -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,4 @@
1
+ /**
2
+ * Parallel Module Types Index
3
+ */
4
+ export { ParallelTaskStatus } from "./parallel-task-status.js";
@@ -0,0 +1,4 @@
1
+ /**
2
+ * ParallelTaskStatus - Task status union type
3
+ */
4
+ export type ParallelTaskStatus = "pending" | "running" | "completed" | "error" | "timeout";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Background Task Module
3
+ */
4
+ export * from "./types/index.js";
5
+ export * from "./interfaces/index.js";
6
+ export { backgroundTaskManager } from "./manager.js";
@@ -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,5 @@
1
+ /**
2
+ * Background Task Interfaces Index
3
+ */
4
+ export { BackgroundTask } from "./background-task.js";
5
+ export { RunBackgroundOptions } from "./run-background-options.js";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * RunBackgroundOptions - Options for running a background task
3
+ */
4
+ export interface RunBackgroundOptions {
5
+ command: string;
6
+ cwd?: string;
7
+ timeout?: number;
8
+ label?: string;
9
+ }
@@ -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 {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * BackgroundTaskStatus - Task status union type
3
+ */
4
+ export type BackgroundTaskStatus = "pending" | "running" | "done" | "error" | "timeout";
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Background Task Types Index
3
+ */
4
+ export { BackgroundTaskStatus } from "./background-task-status.js";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Session Module - State and Task management
3
+ */
4
+ export * from "./types/index.js";
5
+ export * from "./interfaces/index.js";
6
+ export { TaskGraph } from "./task-graph.js";
7
+ export { state } from "./state.js";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Session Interfaces Index
3
+ */
4
+ export { Task } from "./task.js";
5
+ export { SessionState } from "./session-state.js";
@@ -1,4 +1,7 @@
1
- import { TaskGraph } from "./tasks.js";
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
- * Task management for DAG-based orchestration
2
+ * TaskGraph - DAG for task orchestration
3
3
  */
4
- export type TaskStatus = "pending" | "running" | "completed" | "failed";
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[]);
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Orchestrator Types Index
3
+ */
4
+ export { TaskStatus } from "./task-status.js";
5
+ export { TaskType } from "./task-type.js";
@@ -0,0 +1,4 @@
1
+ /**
2
+ * TaskStatus - Status of a task in the DAG
3
+ */
4
+ export type TaskStatus = "pending" | "running" | "completed" | "failed";
@@ -0,0 +1,4 @@
1
+ /**
2
+ * TaskType - Type of task in the orchestration DAG
3
+ */
4
+ export type TaskType = "infrastructure" | "logic" | "integration";
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: {