opencode-orchestrator 0.2.2 → 0.4.0
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/core/state.d.ts +2 -0
- package/dist/index.d.ts +67 -6
- package/dist/index.js +1535 -10
- 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/dist/utils/sanity.d.ts +31 -0
- package/package.json +8 -5
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Delegation Tools
|
|
3
|
+
*
|
|
4
|
+
* Tools for delegating work to agents:
|
|
5
|
+
* - delegate_task: Delegate work to an agent (sync or background)
|
|
6
|
+
* - get_task_result: Retrieve completed task result
|
|
7
|
+
* - list_tasks: View all parallel tasks
|
|
8
|
+
* - cancel_task: Stop a running task
|
|
9
|
+
*/
|
|
10
|
+
import { type ToolDefinition } from "@opencode-ai/plugin";
|
|
11
|
+
import { ParallelAgentManager } from "../core/async-agent.js";
|
|
12
|
+
export { ParallelAgentManager as AsyncAgentManager } from "../core/async-agent.js";
|
|
13
|
+
/**
|
|
14
|
+
* delegate_task - Delegate work to an agent (sync or background)
|
|
15
|
+
*/
|
|
16
|
+
export declare const createDelegateTaskTool: (manager: ParallelAgentManager, client: unknown) => {
|
|
17
|
+
description: string;
|
|
18
|
+
args: {
|
|
19
|
+
agent: import("zod").ZodString;
|
|
20
|
+
description: import("zod").ZodString;
|
|
21
|
+
prompt: import("zod").ZodString;
|
|
22
|
+
background: import("zod").ZodBoolean;
|
|
23
|
+
};
|
|
24
|
+
execute(args: {
|
|
25
|
+
agent: string;
|
|
26
|
+
description: string;
|
|
27
|
+
prompt: string;
|
|
28
|
+
background: boolean;
|
|
29
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* get_task_result - Get result from a completed background task
|
|
33
|
+
*/
|
|
34
|
+
export declare const createGetTaskResultTool: (manager: ParallelAgentManager) => {
|
|
35
|
+
description: string;
|
|
36
|
+
args: {
|
|
37
|
+
taskId: import("zod").ZodString;
|
|
38
|
+
};
|
|
39
|
+
execute(args: {
|
|
40
|
+
taskId: string;
|
|
41
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* list_tasks - List all background tasks
|
|
45
|
+
*/
|
|
46
|
+
export declare const createListTasksTool: (manager: ParallelAgentManager) => {
|
|
47
|
+
description: string;
|
|
48
|
+
args: {
|
|
49
|
+
status: import("zod").ZodOptional<import("zod").ZodString>;
|
|
50
|
+
};
|
|
51
|
+
execute(args: {
|
|
52
|
+
status?: string | undefined;
|
|
53
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* cancel_task - Cancel a running background task
|
|
57
|
+
*/
|
|
58
|
+
export declare const createCancelTaskTool: (manager: ParallelAgentManager) => {
|
|
59
|
+
description: string;
|
|
60
|
+
args: {
|
|
61
|
+
taskId: import("zod").ZodString;
|
|
62
|
+
};
|
|
63
|
+
execute(args: {
|
|
64
|
+
taskId: string;
|
|
65
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Factory function to create all task delegation tools
|
|
69
|
+
*/
|
|
70
|
+
export declare function createAsyncAgentTools(manager: ParallelAgentManager, client?: unknown): Record<string, ToolDefinition>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background Task Tools for OpenCode Orchestrator
|
|
3
|
+
*
|
|
4
|
+
* These tools allow the AI to run commands in the background and check their results later.
|
|
5
|
+
* This is useful for long-running builds, tests, or other operations.
|
|
6
|
+
*/
|
|
7
|
+
export declare const runBackgroundTool: {
|
|
8
|
+
description: string;
|
|
9
|
+
args: {
|
|
10
|
+
command: import("zod").ZodString;
|
|
11
|
+
cwd: import("zod").ZodOptional<import("zod").ZodString>;
|
|
12
|
+
timeout: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
13
|
+
label: import("zod").ZodOptional<import("zod").ZodString>;
|
|
14
|
+
};
|
|
15
|
+
execute(args: {
|
|
16
|
+
command: string;
|
|
17
|
+
cwd?: string | undefined;
|
|
18
|
+
timeout?: number | undefined;
|
|
19
|
+
label?: string | undefined;
|
|
20
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
21
|
+
};
|
|
22
|
+
export declare const checkBackgroundTool: {
|
|
23
|
+
description: string;
|
|
24
|
+
args: {
|
|
25
|
+
taskId: import("zod").ZodString;
|
|
26
|
+
tailLines: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
27
|
+
};
|
|
28
|
+
execute(args: {
|
|
29
|
+
taskId: string;
|
|
30
|
+
tailLines?: number | undefined;
|
|
31
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
32
|
+
};
|
|
33
|
+
export declare const listBackgroundTool: {
|
|
34
|
+
description: string;
|
|
35
|
+
args: {
|
|
36
|
+
status: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
37
|
+
error: "error";
|
|
38
|
+
running: "running";
|
|
39
|
+
done: "done";
|
|
40
|
+
all: "all";
|
|
41
|
+
}>>;
|
|
42
|
+
};
|
|
43
|
+
execute(args: {
|
|
44
|
+
status?: "error" | "running" | "done" | "all" | undefined;
|
|
45
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
46
|
+
};
|
|
47
|
+
export declare const killBackgroundTool: {
|
|
48
|
+
description: string;
|
|
49
|
+
args: {
|
|
50
|
+
taskId: import("zod").ZodString;
|
|
51
|
+
};
|
|
52
|
+
execute(args: {
|
|
53
|
+
taskId: string;
|
|
54
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
55
|
+
};
|
package/dist/tools/search.d.ts
CHANGED
|
@@ -28,3 +28,25 @@ export declare const globSearchTool: (directory: string) => {
|
|
|
28
28
|
dir?: string | undefined;
|
|
29
29
|
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Multi-grep (mgrep) tool - search multiple patterns in parallel
|
|
33
|
+
* High-performance parallel search powered by Rust
|
|
34
|
+
*
|
|
35
|
+
* Use cases:
|
|
36
|
+
* - Find all usages of multiple functions at once
|
|
37
|
+
* - Search for related patterns (imports, exports, usages)
|
|
38
|
+
* - Codebase-wide refactoring analysis
|
|
39
|
+
*/
|
|
40
|
+
export declare const mgrepTool: (directory: string) => {
|
|
41
|
+
description: string;
|
|
42
|
+
args: {
|
|
43
|
+
patterns: import("zod").ZodArray<import("zod").ZodString>;
|
|
44
|
+
dir: import("zod").ZodOptional<import("zod").ZodString>;
|
|
45
|
+
max_results_per_pattern: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
46
|
+
};
|
|
47
|
+
execute(args: {
|
|
48
|
+
patterns: string[];
|
|
49
|
+
dir?: string | undefined;
|
|
50
|
+
max_results_per_pattern?: number | undefined;
|
|
51
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
52
|
+
};
|
package/dist/utils/common.d.ts
CHANGED
|
@@ -2,3 +2,14 @@ export declare function detectSlashCommand(text: string): {
|
|
|
2
2
|
command: string;
|
|
3
3
|
args: string;
|
|
4
4
|
} | null;
|
|
5
|
+
/**
|
|
6
|
+
* Format a timestamp in human-readable format: YYYY-MM-DD HH:mm:ss
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatTimestamp(date?: Date): string;
|
|
9
|
+
/**
|
|
10
|
+
* Calculate and format elapsed time between two timestamps in human-readable format
|
|
11
|
+
* @param startMs Start timestamp in milliseconds
|
|
12
|
+
* @param endMs End timestamp in milliseconds (defaults to now)
|
|
13
|
+
* @returns Formatted string like "2h 30m 15s" or "45s"
|
|
14
|
+
*/
|
|
15
|
+
export declare function formatElapsedTime(startMs: number, endMs?: number): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
export interface SanityResult {
|
|
12
|
+
isHealthy: boolean;
|
|
13
|
+
reason?: string;
|
|
14
|
+
severity: "ok" | "warning" | "critical";
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Check if LLM output shows signs of degeneration
|
|
18
|
+
*/
|
|
19
|
+
export declare function checkOutputSanity(text: string): SanityResult;
|
|
20
|
+
/**
|
|
21
|
+
* Check if text is completely empty or meaningless
|
|
22
|
+
*/
|
|
23
|
+
export declare function isEmptyOrMeaningless(text: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Recovery prompt for single anomaly
|
|
26
|
+
*/
|
|
27
|
+
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
|
+
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>";
|
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.
|
|
5
|
+
"version": "0.4.0",
|
|
6
6
|
"author": "agnusdei1207",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
@@ -55,10 +55,13 @@
|
|
|
55
55
|
"postinstall": "node dist/scripts/postinstall.js 2>/dev/null || true",
|
|
56
56
|
"preuninstall": "node dist/scripts/preuninstall.js 2>/dev/null || true",
|
|
57
57
|
"prepublishOnly": "npm run build:js",
|
|
58
|
-
"dev:install": "npm run build:js && npm install -g .",
|
|
59
|
-
"dev:uninstall": "npm uninstall -g opencode-orchestrator",
|
|
60
|
-
"dev:link": "npm run build:js && npm link",
|
|
61
|
-
"dev:unlink": "npm unlink -g opencode-orchestrator",
|
|
58
|
+
"dev:install": "npm run build:js && npm uninstall -g opencode-orchestrator >/dev/null 2>&1 || true && npm install -g . && echo '✅ Installed globally'",
|
|
59
|
+
"dev:uninstall": "npm unlink -g opencode-orchestrator >/dev/null 2>&1 || true && npm uninstall -g opencode-orchestrator >/dev/null 2>&1 || true && rm -rf $(npm root -g)/opencode-orchestrator && echo '✅ Forcefully Uninstalled'",
|
|
60
|
+
"dev:link": "npm run build:js && npm unlink -g opencode-orchestrator >/dev/null 2>&1 || true && npm unlink >/dev/null 2>&1 || true && rm -rf $(npm root -g)/opencode-orchestrator && npm link && echo '✅ Re-linked. Restart OpenCode.'",
|
|
61
|
+
"dev:unlink": "npm unlink -g opencode-orchestrator >/dev/null 2>&1 || true && npm unlink >/dev/null 2>&1 || true && rm -rf $(npm root -g)/opencode-orchestrator && echo '✅ Unlinked and Cleaned'",
|
|
62
|
+
"dev:reload": "npm run dev:link",
|
|
63
|
+
"dev:build": "npm run build:js && echo '✅ Built (no link change)'",
|
|
64
|
+
"dev:status": "echo '=== Global Link Status ===' && ls -l $(npm root -g)/opencode-orchestrator 2>/dev/null || echo 'Not found'",
|
|
62
65
|
"util:stars": "gh api repos/agnusdei1207/opencode-orchestrator/stargazers --jq '.[].login'"
|
|
63
66
|
},
|
|
64
67
|
"dependencies": {
|