opencode-orchestrator 0.4.13 → 0.4.17

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 (62) hide show
  1. package/README.md +61 -3
  2. package/dist/agents/definitions.d.ts +0 -0
  3. package/dist/agents/orchestrator.d.ts +0 -0
  4. package/dist/agents/subagents/architect.d.ts +0 -0
  5. package/dist/agents/subagents/builder.d.ts +0 -0
  6. package/dist/agents/subagents/{coder.d.ts → frontend-designer.d.ts} +1 -1
  7. package/dist/agents/subagents/inspector.d.ts +0 -0
  8. package/dist/agents/subagents/recorder.d.ts +0 -0
  9. package/dist/constants/agent.d.ts +8 -0
  10. package/dist/constants/index.d.ts +7 -0
  11. package/dist/constants/prompts.d.ts +10 -0
  12. package/dist/constants/task.d.ts +12 -0
  13. package/dist/constants/time.d.ts +34 -0
  14. package/dist/context/enforcer.d.ts +47 -0
  15. package/dist/core/async-agent.d.ts +14 -2
  16. package/dist/core/batch-processor.d.ts +62 -0
  17. package/dist/core/config.d.ts +55 -0
  18. package/dist/core/session-manager.d.ts +39 -0
  19. package/dist/core/state.d.ts +0 -0
  20. package/dist/core/tasks.d.ts +1 -0
  21. package/dist/index.d.ts +20 -2
  22. package/dist/index.js +1497 -164
  23. package/dist/parallel/optimizer.d.ts +47 -0
  24. package/dist/profiler/execution.d.ts +40 -0
  25. package/dist/prompts/shared.d.ts +2 -0
  26. package/dist/shared/contracts/interfaces.d.ts +0 -0
  27. package/dist/shared/contracts/names.d.ts +0 -0
  28. package/dist/tools/background.d.ts +2 -2
  29. package/dist/tools/batch.d.ts +53 -0
  30. package/dist/tools/callAgent.d.ts +0 -0
  31. package/dist/tools/config.d.ts +60 -0
  32. package/dist/tools/git.d.ts +48 -0
  33. package/dist/tools/rust.d.ts +0 -0
  34. package/dist/tools/search.d.ts +0 -0
  35. package/dist/tools/slashCommand.d.ts +0 -0
  36. package/dist/utils/binary.d.ts +0 -0
  37. package/dist/utils/common.d.ts +0 -0
  38. package/dist/utils/formatting.d.ts +13 -0
  39. package/dist/utils/index.d.ts +8 -0
  40. package/dist/utils/sanity.d.ts +0 -22
  41. package/dist/utils/task.d.ts +8 -0
  42. package/package.json +1 -1
  43. package/dist/agents/coder.d.ts +0 -2
  44. package/dist/agents/fixer.d.ts +0 -2
  45. package/dist/agents/names.d.ts +0 -12
  46. package/dist/agents/planner.d.ts +0 -2
  47. package/dist/agents/reviewer.d.ts +0 -2
  48. package/dist/agents/searcher.d.ts +0 -2
  49. package/dist/agents/subagents/executor.d.ts +0 -2
  50. package/dist/agents/subagents/fixer.d.ts +0 -2
  51. package/dist/agents/subagents/memory.d.ts +0 -2
  52. package/dist/agents/subagents/planner.d.ts +0 -2
  53. package/dist/agents/subagents/publisher.d.ts +0 -2
  54. package/dist/agents/subagents/reviewer.d.ts +0 -2
  55. package/dist/agents/subagents/searcher.d.ts +0 -2
  56. package/dist/agents/subagents/strategist.d.ts +0 -2
  57. package/dist/agents/subagents/surgeon.d.ts +0 -2
  58. package/dist/agents/subagents/types.d.ts +0 -7
  59. package/dist/agents/subagents/visualist.d.ts +0 -2
  60. package/dist/agents/types.d.ts +0 -7
  61. package/dist/cli.d.ts +0 -2
  62. package/dist/tasks.d.ts +0 -29
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Auto-Parallel Optimizer
3
+ *
4
+ * Optimizes task parallelization by analyzing dependencies and conflicts.
5
+ * Maximizes parallel execution while preventing conflicts.
6
+ */
7
+ import type { Task } from "../core/tasks.js";
8
+ export interface OptimizationResult {
9
+ tasks: Task[];
10
+ groups: Map<number, string[]>;
11
+ efficiency: number;
12
+ optimizationNotes: string[];
13
+ }
14
+ /**
15
+ * Auto-Parallel Optimizer analyzes tasks and creates optimal parallel groups
16
+ */
17
+ export declare class ParallelOptimizer {
18
+ /**
19
+ * Optimize tasks for parallel execution
20
+ */
21
+ optimize(tasks: Task[]): OptimizationResult;
22
+ /**
23
+ * Check if task dependencies are satisfied
24
+ */
25
+ private areDependenciesSatisfied;
26
+ /**
27
+ * Format optimization result for display
28
+ */
29
+ formatResult(result: OptimizationResult): string;
30
+ /**
31
+ * Get conflict analysis
32
+ */
33
+ analyzeConflicts(tasks: Task[]): Map<string, string[]>;
34
+ /**
35
+ * Suggest task reordering for better parallelism
36
+ */
37
+ suggestReordering(tasks: Task[]): Task[];
38
+ /**
39
+ * Calculate parallelization potential
40
+ */
41
+ calculateParallelizationPotential(tasks: Task[]): {
42
+ current: number;
43
+ optimal: number;
44
+ improvement: number;
45
+ };
46
+ }
47
+ export declare const parallelOptimizer: ParallelOptimizer;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Execution Profiler
3
+ *
4
+ * Tracks and analyzes agent performance metrics.
5
+ * Provides data-driven optimization insights.
6
+ */
7
+ export interface Metric {
8
+ operation: string;
9
+ duration: number;
10
+ timestamp: number;
11
+ agent: string;
12
+ success: boolean;
13
+ }
14
+ export interface PerformanceMetrics {
15
+ agent: string;
16
+ operations: Metric[];
17
+ averageDuration: number;
18
+ medianDuration: number;
19
+ totalDuration: number;
20
+ operationCount: number;
21
+ successRate: number;
22
+ }
23
+ export interface Analysis {
24
+ performance: Record<string, PerformanceMetrics>;
25
+ outliers: Metric[];
26
+ suggestions: string[];
27
+ bottlenecks: string[];
28
+ }
29
+ export declare class ExecutionProfiler {
30
+ private metrics;
31
+ record(agent: string, operation: string, duration: number, success?: boolean): void;
32
+ getMetrics(agent: string): Metric[];
33
+ analyze(agent: string): PerformanceMetrics;
34
+ analyzeAll(): Analysis;
35
+ formatAnalysis(analysis: Analysis): string;
36
+ clear(): void;
37
+ toJSON(): string;
38
+ static fromJSON(json: string): ExecutionProfiler;
39
+ }
40
+ export declare const executionProfiler: ExecutionProfiler;
@@ -0,0 +1,2 @@
1
+ export { REASONING_CONSTRAINTS, LANGUAGE_RULE, TASK_COMPLETION_CHECK, OUTPUT_FORMAT, ANTI_PATTERNS, WORKFLOW, BASE_PROMPT, } from "../constants/prompts.js";
2
+ export { RECOVERY_PROMPT, ESCALATION_PROMPT } from "../utils/sanity.js";
File without changes
File without changes
@@ -37,13 +37,13 @@ export declare const listBackgroundTool: {
37
37
  args: {
38
38
  status: import("zod").ZodOptional<import("zod").ZodEnum<{
39
39
  running: "running";
40
+ all: "all";
40
41
  done: "done";
41
42
  error: "error";
42
- all: "all";
43
43
  }>>;
44
44
  };
45
45
  execute(args: {
46
- status?: "running" | "done" | "error" | "all" | undefined;
46
+ status?: "running" | "all" | "done" | "error" | undefined;
47
47
  }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
48
48
  };
49
49
  export declare const killBackgroundTool: {
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Smart Batch Tool - Centralized validation and retry
3
+ *
4
+ * Execute many tasks with intelligent batching, validation, and retry.
5
+ */
6
+ import { tool } from "@opencode-ai/plugin";
7
+ import { ParallelAgentManager } from "../core/async-agent.js";
8
+ /**
9
+ * process_batch - Execute multiple tasks with smart validation
10
+ */
11
+ export declare const createProcessBatchTool: (parallelAgentManager: ParallelAgentManager, client: unknown) => {
12
+ description: string;
13
+ args: {
14
+ concurrency: import("zod").ZodString;
15
+ maxRetries: import("zod").ZodOptional<import("zod").ZodString>;
16
+ validateAfterEach: import("zod").ZodOptional<import("zod").ZodBoolean>;
17
+ tasks: import("zod").ZodString;
18
+ };
19
+ execute(args: {
20
+ concurrency: string;
21
+ tasks: string;
22
+ maxRetries?: string | undefined;
23
+ validateAfterEach?: boolean | undefined;
24
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
25
+ };
26
+ /**
27
+ * export_failed_tasks - Export failed tasks for manual review
28
+ */
29
+ export declare const createExportFailedTasksTool: (parallelAgentManager: ParallelAgentManager) => {
30
+ description: string;
31
+ args: {};
32
+ execute(args: Record<string, never>, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
33
+ };
34
+ /**
35
+ * compare_strategies - Compare performance of different strategies
36
+ */
37
+ export declare const createCompareStrategiesTool: (parallelAgentManager: ParallelAgentManager) => {
38
+ description: string;
39
+ args: {
40
+ taskCount: import("zod").ZodString;
41
+ concurrency1: import("zod").ZodOptional<import("zod").ZodString>;
42
+ concurrency2: import("zod").ZodOptional<import("zod").ZodString>;
43
+ };
44
+ execute(args: {
45
+ taskCount: string;
46
+ concurrency1?: string | undefined;
47
+ concurrency2?: string | undefined;
48
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
49
+ };
50
+ /**
51
+ * Factory to create all batch tools
52
+ */
53
+ export declare function createBatchTools(parallelAgentManager: ParallelAgentManager, client?: unknown): Record<string, ReturnType<typeof tool>>;
File without changes
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Configuration Management Tool
3
+ *
4
+ * Tools for viewing and modifying configuration at runtime.
5
+ */
6
+ import { tool } from "@opencode-ai/plugin";
7
+ /**
8
+ * show_config - Display current configuration
9
+ */
10
+ export declare const createShowConfigTool: () => {
11
+ description: string;
12
+ args: {};
13
+ execute(args: Record<string, never>, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
14
+ };
15
+ /**
16
+ * set_concurrency - Update agent concurrency limits at runtime
17
+ */
18
+ export declare const createSetConcurrencyTool: (client: unknown) => {
19
+ description: string;
20
+ args: {
21
+ agent: import("zod").ZodString;
22
+ limit: import("zod").ZodString;
23
+ };
24
+ execute(args: {
25
+ agent: string;
26
+ limit: string;
27
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
28
+ };
29
+ /**
30
+ * set_timeout - Update task timeout settings
31
+ */
32
+ export declare const createSetTimeoutTool: () => {
33
+ description: string;
34
+ args: {
35
+ taskTtlMinutes: import("zod").ZodOptional<import("zod").ZodString>;
36
+ cleanupDelayMinutes: import("zod").ZodOptional<import("zod").ZodString>;
37
+ };
38
+ execute(args: {
39
+ taskTtlMinutes?: string | undefined;
40
+ cleanupDelayMinutes?: string | undefined;
41
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
42
+ };
43
+ /**
44
+ * set_debug - Toggle debug logging
45
+ */
46
+ export declare const createSetDebugTool: () => {
47
+ description: string;
48
+ args: {
49
+ component: import("zod").ZodString;
50
+ enable: import("zod").ZodBoolean;
51
+ };
52
+ execute(args: {
53
+ component: string;
54
+ enable: boolean;
55
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
56
+ };
57
+ /**
58
+ * Factory to create all configuration tools
59
+ */
60
+ export declare function createConfigTools(client?: unknown): Record<string, ReturnType<typeof tool>>;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Git Branch Parser Tool
3
+ *
4
+ * Provides comprehensive Git branch information and parsing capabilities.
5
+ * Useful for understanding current workspace context before making changes.
6
+ */
7
+ export interface BranchInfo {
8
+ name: string;
9
+ current: boolean;
10
+ isRemote: boolean;
11
+ upstream?: string;
12
+ ahead?: number;
13
+ behind?: number;
14
+ }
15
+ export interface GitStatus {
16
+ branch: string;
17
+ staged: string[];
18
+ unstaged: string[];
19
+ untracked: string[];
20
+ conflicted: string[];
21
+ ahead?: number;
22
+ behind?: number;
23
+ }
24
+ export interface CommitInfo {
25
+ hash: string;
26
+ message: string;
27
+ author: string;
28
+ date: string;
29
+ files: string[];
30
+ }
31
+ export declare const gitBranchTool: (directory: string) => {
32
+ description: string;
33
+ args: {
34
+ action: import("zod").ZodEnum<{
35
+ status: "status";
36
+ diff: "diff";
37
+ current: "current";
38
+ list: "list";
39
+ recent: "recent";
40
+ all: "all";
41
+ }>;
42
+ baseBranch: import("zod").ZodOptional<import("zod").ZodString>;
43
+ };
44
+ execute(args: {
45
+ action: "status" | "diff" | "current" | "list" | "recent" | "all";
46
+ baseBranch?: string | undefined;
47
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
48
+ };
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,13 @@
1
+ import { getStatusEmoji } from "../constants/task.js";
2
+ /**
3
+ * Format duration between two timestamps
4
+ */
5
+ export declare function formatDuration(start: Date, end?: Date): string;
6
+ /**
7
+ * Format duration from milliseconds to human-readable string
8
+ */
9
+ export declare function formatDurationMs(ms: number): string;
10
+ /**
11
+ * Get emoji for task status
12
+ */
13
+ export { getStatusEmoji };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Utility exports
3
+ */
4
+ export * from "./common.js";
5
+ export * from "./sanity.js";
6
+ export * from "./task.js";
7
+ export * from "./formatting.js";
8
+ export * from "./binary.js";
@@ -1,31 +1,9 @@
1
- /**
2
- * Output Sanity Check - LLM degeneration/gibberish detection
3
- *
4
- * Detects common LLM failure modes:
5
- * - Single character repetition (SSSSSS...)
6
- * - Pattern loops (茅茅茅茅...)
7
- * - Low information density
8
- * - Visual gibberish (box drawing characters)
9
- * - Line repetition
10
- */
11
1
  export interface SanityResult {
12
2
  isHealthy: boolean;
13
3
  reason?: string;
14
4
  severity: "ok" | "warning" | "critical";
15
5
  }
16
- /**
17
- * Check if LLM output shows signs of degeneration
18
- */
19
6
  export declare function checkOutputSanity(text: string): SanityResult;
20
- /**
21
- * Check if text is completely empty or meaningless
22
- */
23
7
  export declare function isEmptyOrMeaningless(text: string): boolean;
24
- /**
25
- * Recovery prompt for single anomaly
26
- */
27
8
  export declare const RECOVERY_PROMPT = "<anomaly_recovery>\n\u26A0\uFE0F SYSTEM NOTICE: Previous output was malformed (gibberish/loop detected).\n\n<recovery_protocol>\n1. DISCARD the corrupted output completely - do not reference it\n2. RECALL the original mission objective\n3. IDENTIFY the last confirmed successful step\n4. RESTART with a simpler, more focused approach\n</recovery_protocol>\n\n<instructions>\n- If a sub-agent produced bad output: try a different agent or simpler task\n- If stuck in a loop: break down the task into smaller pieces\n- If context seems corrupted: call recorder to restore context\n- THINK in English for maximum stability\n</instructions>\n\nWhat was the original task? Proceed from the last known good state.\n</anomaly_recovery>";
28
- /**
29
- * Escalation prompt for multiple consecutive anomalies
30
- */
31
9
  export declare const ESCALATION_PROMPT = "<critical_anomaly>\n\uD83D\uDEA8 CRITICAL: Multiple consecutive malformed outputs detected.\n\n<emergency_protocol>\n1. STOP current execution path immediately\n2. DO NOT continue with the same approach - it is failing\n3. CALL architect for a completely new strategy\n4. If architect also fails: report status to user and await guidance\n</emergency_protocol>\n\n<diagnosis>\nThe current approach is producing corrupted output.\nThis may indicate: context overload, model instability, or task complexity.\n</diagnosis>\n\nRequest a fresh plan from architect with reduced scope.\n</critical_anomaly>";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Generate a unique task ID in format task_xxxxxxxx
3
+ */
4
+ export declare function generateTaskId(): string;
5
+ /**
6
+ * Generate a unique job ID in format job_xxxxxxxx
7
+ */
8
+ export declare function generateJobId(): string;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "opencode-orchestrator",
3
3
  "displayName": "OpenCode Orchestrator",
4
4
  "description": "Distributed Cognitive Architecture for OpenCode. Turns simple prompts into specialized multi-agent workflows (Planner, Coder, Reviewer).",
5
- "version": "0.4.13",
5
+ "version": "0.4.17",
6
6
  "author": "agnusdei1207",
7
7
  "license": "MIT",
8
8
  "repository": {
@@ -1,2 +0,0 @@
1
- import { AgentDefinition } from "./types.js";
2
- export declare const coder: AgentDefinition;
@@ -1,2 +0,0 @@
1
- import { AgentDefinition } from "./types.js";
2
- export declare const fixer: AgentDefinition;
@@ -1,12 +0,0 @@
1
- export declare const AGENT_NAMES: {
2
- readonly ORCHESTRATOR: "orchestrator";
3
- readonly PLANNER: "planner";
4
- readonly CODER: "coder";
5
- readonly REVIEWER: "reviewer";
6
- readonly SEARCHER: "searcher";
7
- readonly SURGEON: "surgeon";
8
- readonly EXECUTOR: "executor";
9
- readonly VISUALIST: "visualist";
10
- readonly PUBLISHER: "publisher";
11
- };
12
- export type AgentName = typeof AGENT_NAMES[keyof typeof AGENT_NAMES];
@@ -1,2 +0,0 @@
1
- import { AgentDefinition } from "./types.js";
2
- export declare const planner: AgentDefinition;
@@ -1,2 +0,0 @@
1
- import { AgentDefinition } from "./types.js";
2
- export declare const reviewer: AgentDefinition;
@@ -1,2 +0,0 @@
1
- import { AgentDefinition } from "./types.js";
2
- export declare const searcher: AgentDefinition;
@@ -1,2 +0,0 @@
1
- import { AgentDefinition } from "../../shared/contracts/interfaces.js";
2
- export declare const executor: AgentDefinition;
@@ -1,2 +0,0 @@
1
- import { AgentDefinition } from "../../shared/contracts/interfaces.js";
2
- export declare const fixer: AgentDefinition;
@@ -1,2 +0,0 @@
1
- import { AgentDefinition } from "../../shared/contracts/interfaces.js";
2
- export declare const memory: AgentDefinition;
@@ -1,2 +0,0 @@
1
- import { AgentDefinition } from "../../shared/contracts/interfaces.js";
2
- export declare const planner: AgentDefinition;
@@ -1,2 +0,0 @@
1
- import { AgentDefinition } from "../../shared/contracts/interfaces.js";
2
- export declare const publisher: AgentDefinition;
@@ -1,2 +0,0 @@
1
- import { AgentDefinition } from "../../shared/contracts/interfaces.js";
2
- export declare const reviewer: AgentDefinition;
@@ -1,2 +0,0 @@
1
- import { AgentDefinition } from "../../shared/contracts/interfaces.js";
2
- export declare const searcher: AgentDefinition;
@@ -1,2 +0,0 @@
1
- import { AgentDefinition } from "../../shared/contracts/interfaces.js";
2
- export declare const strategist: AgentDefinition;
@@ -1,2 +0,0 @@
1
- import { AgentDefinition } from "../../shared/contracts/interfaces.js";
2
- export declare const surgeon: AgentDefinition;
@@ -1,7 +0,0 @@
1
- export interface AgentDefinition {
2
- id: string;
3
- description: string;
4
- systemPrompt: string;
5
- canWrite: boolean;
6
- canBash: boolean;
7
- }
@@ -1,2 +0,0 @@
1
- import { AgentDefinition } from "../../shared/contracts/interfaces.js";
2
- export declare const visualist: AgentDefinition;
@@ -1,7 +0,0 @@
1
- export interface AgentDefinition {
2
- id: string;
3
- description: string;
4
- systemPrompt: string;
5
- canWrite: boolean;
6
- canBash: boolean;
7
- }
package/dist/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/dist/tasks.d.ts DELETED
@@ -1,29 +0,0 @@
1
- /**
2
- * Task management for DAG-based orchestration
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
- }
17
- export declare class TaskGraph {
18
- private tasks;
19
- constructor(tasks?: Task[]);
20
- addTask(task: Task): void;
21
- getTask(id: string): Task | undefined;
22
- updateTask(id: string, updates: Partial<Task>): void;
23
- getReadyTasks(): Task[];
24
- isCompleted(): boolean;
25
- hasFailed(): boolean;
26
- getTaskSummary(): string;
27
- toJSON(): string;
28
- static fromJSON(json: string): TaskGraph;
29
- }