opencode-orchestrator 0.5.3 → 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 (77) hide show
  1. package/README.md +10 -67
  2. package/dist/agents/definitions.d.ts +1 -1
  3. package/dist/agents/orchestrator.d.ts +1 -1
  4. package/dist/agents/subagents/architect.d.ts +1 -1
  5. package/dist/agents/subagents/builder.d.ts +1 -1
  6. package/dist/agents/subagents/inspector.d.ts +1 -1
  7. package/dist/agents/subagents/recorder.d.ts +1 -1
  8. package/dist/core/agents/concurrency.d.ts +36 -0
  9. package/dist/core/agents/config.d.ts +9 -0
  10. package/dist/core/agents/format.d.ts +9 -0
  11. package/dist/core/agents/index.d.ts +7 -0
  12. package/dist/core/agents/interfaces/index.d.ts +5 -0
  13. package/dist/core/agents/interfaces/launch-input.d.ts +9 -0
  14. package/dist/core/agents/interfaces/parallel-task.d.ts +26 -0
  15. package/dist/core/agents/logger.d.ts +4 -0
  16. package/dist/core/agents/manager.d.ts +76 -0
  17. package/dist/core/agents/task-store.d.ts +28 -0
  18. package/dist/core/agents/types/index.d.ts +4 -0
  19. package/dist/core/agents/types/parallel-task-status.d.ts +4 -0
  20. package/dist/core/commands/index.d.ts +6 -0
  21. package/dist/core/commands/interfaces/background-task.d.ts +20 -0
  22. package/dist/core/commands/interfaces/index.d.ts +5 -0
  23. package/dist/core/commands/interfaces/run-background-options.d.ts +9 -0
  24. package/dist/core/commands/manager.d.ts +27 -0
  25. package/dist/core/commands/types/background-task-status.d.ts +4 -0
  26. package/dist/core/commands/types/index.d.ts +4 -0
  27. package/dist/core/orchestrator/index.d.ts +7 -0
  28. package/dist/core/orchestrator/interfaces/index.d.ts +5 -0
  29. package/dist/core/{state.d.ts → orchestrator/interfaces/session-state.d.ts} +4 -7
  30. package/dist/core/orchestrator/interfaces/task.d.ts +17 -0
  31. package/dist/core/orchestrator/state.d.ts +10 -0
  32. package/dist/core/orchestrator/task-graph.d.ts +17 -0
  33. package/dist/core/orchestrator/types/index.d.ts +5 -0
  34. package/dist/core/orchestrator/types/task-status.d.ts +4 -0
  35. package/dist/core/orchestrator/types/task-type.d.ts +4 -0
  36. package/dist/index.d.ts +2 -24
  37. package/dist/index.js +871 -2561
  38. package/dist/shared/{contracts/names.d.ts → agent.d.ts} +12 -0
  39. package/dist/shared/constants.d.ts +56 -0
  40. package/dist/tools/background-cmd/check.d.ts +14 -0
  41. package/dist/tools/background-cmd/index.d.ts +7 -0
  42. package/dist/tools/background-cmd/kill.d.ts +12 -0
  43. package/dist/tools/background-cmd/list.d.ts +17 -0
  44. package/dist/tools/background-cmd/run.d.ts +18 -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/search.d.ts +2 -9
  51. package/dist/utils/sanity.d.ts +22 -0
  52. package/package.json +18 -12
  53. package/dist/agents/subagents/frontend-designer.d.ts +0 -2
  54. package/dist/constants/agent.d.ts +0 -8
  55. package/dist/constants/index.d.ts +0 -7
  56. package/dist/constants/prompts.d.ts +0 -10
  57. package/dist/constants/task.d.ts +0 -12
  58. package/dist/constants/time.d.ts +0 -34
  59. package/dist/context/enforcer.d.ts +0 -47
  60. package/dist/core/async-agent.d.ts +0 -112
  61. package/dist/core/background.d.ts +0 -111
  62. package/dist/core/batch-processor.d.ts +0 -62
  63. package/dist/core/config.d.ts +0 -55
  64. package/dist/core/session-manager.d.ts +0 -39
  65. package/dist/core/tasks.d.ts +0 -30
  66. package/dist/parallel/optimizer.d.ts +0 -47
  67. package/dist/profiler/execution.d.ts +0 -40
  68. package/dist/prompts/shared.d.ts +0 -2
  69. package/dist/shared/contracts/interfaces.d.ts +0 -7
  70. package/dist/tools/async-agent.d.ts +0 -70
  71. package/dist/tools/background.d.ts +0 -57
  72. package/dist/tools/batch.d.ts +0 -53
  73. package/dist/tools/config.d.ts +0 -60
  74. package/dist/tools/git.d.ts +0 -48
  75. package/dist/utils/formatting.d.ts +0 -13
  76. package/dist/utils/index.d.ts +0 -8
  77. package/dist/utils/task.d.ts +0 -8
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Agent Definitions
3
+ *
4
+ * Agent names, types, and interfaces.
5
+ */
1
6
  export declare const AGENT_NAMES: {
2
7
  readonly COMMANDER: "commander";
3
8
  readonly ARCHITECT: "architect";
@@ -6,3 +11,10 @@ export declare const AGENT_NAMES: {
6
11
  readonly RECORDER: "recorder";
7
12
  };
8
13
  export type AgentName = (typeof AGENT_NAMES)[keyof typeof AGENT_NAMES];
14
+ export interface AgentDefinition {
15
+ id: string;
16
+ description: string;
17
+ systemPrompt: string;
18
+ canWrite: boolean;
19
+ canBash: boolean;
20
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Centralized Constants
3
+ *
4
+ * All magic numbers, prefixes, and names in one place.
5
+ */
6
+ export declare const TIME: {
7
+ readonly SECOND: 1000;
8
+ readonly MINUTE: number;
9
+ readonly HOUR: number;
10
+ };
11
+ export declare const ID_PREFIX: {
12
+ /** Parallel agent task ID (e.g., task_a1b2c3d4) */
13
+ readonly TASK: "task_";
14
+ /** Background command job ID (e.g., job_a1b2c3d4) */
15
+ readonly JOB: "job_";
16
+ /** Session ID prefix */
17
+ readonly SESSION: "session_";
18
+ };
19
+ export declare const PARALLEL_TASK: {
20
+ readonly TTL_MS: number;
21
+ readonly CLEANUP_DELAY_MS: number;
22
+ readonly MIN_STABILITY_MS: number;
23
+ readonly POLL_INTERVAL_MS: 2000;
24
+ readonly DEFAULT_CONCURRENCY: 3;
25
+ readonly MAX_CONCURRENCY: 10;
26
+ };
27
+ export declare const BACKGROUND_TASK: {
28
+ readonly DEFAULT_TIMEOUT_MS: number;
29
+ readonly MAX_OUTPUT_LENGTH: 10000;
30
+ };
31
+ export declare const TOOL_NAMES: {
32
+ readonly DELEGATE_TASK: "delegate_task";
33
+ readonly GET_TASK_RESULT: "get_task_result";
34
+ readonly LIST_TASKS: "list_tasks";
35
+ readonly CANCEL_TASK: "cancel_task";
36
+ readonly RUN_BACKGROUND: "run_background";
37
+ readonly CHECK_BACKGROUND: "check_background";
38
+ readonly LIST_BACKGROUND: "list_background";
39
+ readonly KILL_BACKGROUND: "kill_background";
40
+ readonly GREP_SEARCH: "grep_search";
41
+ readonly GLOB_SEARCH: "glob_search";
42
+ readonly MGREP: "mgrep";
43
+ readonly CALL_AGENT: "call_agent";
44
+ };
45
+ export { AGENT_NAMES } from "./agent.js";
46
+ export declare const STATUS_EMOJI: {
47
+ readonly pending: "⏳";
48
+ readonly running: "🔄";
49
+ readonly completed: "✅";
50
+ readonly done: "✅";
51
+ readonly error: "❌";
52
+ readonly timeout: "⏰";
53
+ readonly cancelled: "🚫";
54
+ };
55
+ export type TaskStatus = keyof typeof STATUS_EMOJI;
56
+ export declare function getStatusEmoji(status: string): string;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * check_background Tool - Check background task status
3
+ */
4
+ export declare const checkBackgroundTool: {
5
+ description: string;
6
+ args: {
7
+ taskId: import("zod").ZodString;
8
+ tailLines: import("zod").ZodOptional<import("zod").ZodNumber>;
9
+ };
10
+ execute(args: {
11
+ taskId: string;
12
+ tailLines?: number | undefined;
13
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
14
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Background Command Tools
3
+ */
4
+ export { runBackgroundTool } from "./run.js";
5
+ export { checkBackgroundTool } from "./check.js";
6
+ export { listBackgroundTool } from "./list.js";
7
+ export { killBackgroundTool } from "./kill.js";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * kill_background Tool - Kill a running background task
3
+ */
4
+ export declare const killBackgroundTool: {
5
+ description: string;
6
+ args: {
7
+ taskId: import("zod").ZodString;
8
+ };
9
+ execute(args: {
10
+ taskId: string;
11
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
12
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * list_background Tool - List all background tasks
3
+ */
4
+ export declare const listBackgroundTool: {
5
+ description: string;
6
+ args: {
7
+ status: import("zod").ZodOptional<import("zod").ZodEnum<{
8
+ running: "running";
9
+ done: "done";
10
+ error: "error";
11
+ all: "all";
12
+ }>>;
13
+ };
14
+ execute(args: {
15
+ status?: "running" | "done" | "error" | "all" | undefined;
16
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
17
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * run_background Tool - Start a background command
3
+ */
4
+ export declare const runBackgroundTool: {
5
+ description: string;
6
+ args: {
7
+ command: import("zod").ZodString;
8
+ cwd: import("zod").ZodOptional<import("zod").ZodString>;
9
+ timeout: import("zod").ZodOptional<import("zod").ZodNumber>;
10
+ label: import("zod").ZodOptional<import("zod").ZodString>;
11
+ };
12
+ execute(args: {
13
+ command: string;
14
+ cwd?: string | undefined;
15
+ timeout?: number | undefined;
16
+ label?: string | undefined;
17
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
18
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * cancel_task Tool
3
+ */
4
+ import { ParallelAgentManager } from "../../core/agents/index.js";
5
+ export declare const createCancelTaskTool: (manager: ParallelAgentManager) => {
6
+ description: string;
7
+ args: {
8
+ taskId: import("zod").ZodString;
9
+ };
10
+ execute(args: {
11
+ taskId: string;
12
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
13
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * delegate_task Tool
3
+ *
4
+ * Delegate work to an agent (sync or background mode)
5
+ */
6
+ import { ParallelAgentManager } from "../../core/agents/index.js";
7
+ export declare const createDelegateTaskTool: (manager: ParallelAgentManager, client: unknown) => {
8
+ description: string;
9
+ args: {
10
+ agent: import("zod").ZodString;
11
+ description: import("zod").ZodString;
12
+ prompt: import("zod").ZodString;
13
+ background: import("zod").ZodBoolean;
14
+ };
15
+ execute(args: {
16
+ agent: string;
17
+ description: string;
18
+ prompt: string;
19
+ background: boolean;
20
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
21
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * get_task_result Tool
3
+ */
4
+ import { ParallelAgentManager } from "../../core/agents/index.js";
5
+ export declare const createGetTaskResultTool: (manager: ParallelAgentManager) => {
6
+ description: string;
7
+ args: {
8
+ taskId: import("zod").ZodString;
9
+ };
10
+ execute(args: {
11
+ taskId: string;
12
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
13
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Parallel Task Tools
3
+ */
4
+ import type { ToolDefinition } from "@opencode-ai/plugin";
5
+ import { ParallelAgentManager } from "../../core/agents/index.js";
6
+ export { ParallelAgentManager as AsyncAgentManager } from "../../core/agents/index.js";
7
+ export declare function createAsyncAgentTools(manager: ParallelAgentManager, client?: unknown): Record<string, ToolDefinition>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * list_tasks Tool
3
+ */
4
+ import { ParallelAgentManager } from "../../core/agents/index.js";
5
+ export declare const createListTasksTool: (manager: ParallelAgentManager) => {
6
+ description: string;
7
+ args: {
8
+ status: import("zod").ZodOptional<import("zod").ZodString>;
9
+ };
10
+ execute(args: {
11
+ status?: string | undefined;
12
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
13
+ };
@@ -29,24 +29,17 @@ export declare const globSearchTool: (directory: string) => {
29
29
  }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
30
30
  };
31
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
32
+ * Multi-grep (mgrep) tool - search multiple patterns
33
+ * Runs grep for each pattern and combines results
39
34
  */
40
35
  export declare const mgrepTool: (directory: string) => {
41
36
  description: string;
42
37
  args: {
43
38
  patterns: import("zod").ZodArray<import("zod").ZodString>;
44
39
  dir: import("zod").ZodOptional<import("zod").ZodString>;
45
- max_results_per_pattern: import("zod").ZodOptional<import("zod").ZodNumber>;
46
40
  };
47
41
  execute(args: {
48
42
  patterns: string[];
49
43
  dir?: string | undefined;
50
- max_results_per_pattern?: number | undefined;
51
44
  }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
52
45
  };
@@ -1,9 +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
+ */
1
11
  export interface SanityResult {
2
12
  isHealthy: boolean;
3
13
  reason?: string;
4
14
  severity: "ok" | "warning" | "critical";
5
15
  }
16
+ /**
17
+ * Check if LLM output shows signs of degeneration
18
+ */
6
19
  export declare function checkOutputSanity(text: string): SanityResult;
20
+ /**
21
+ * Check if text is completely empty or meaningless
22
+ */
7
23
  export declare function isEmptyOrMeaningless(text: string): boolean;
24
+ /**
25
+ * Recovery prompt for single anomaly
26
+ */
8
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
+ */
9
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.3",
5
+ "version": "0.5.5",
6
6
  "author": "agnusdei1207",
7
7
  "license": "MIT",
8
8
  "repository": {
@@ -38,20 +38,25 @@
38
38
  "LICENSE"
39
39
  ],
40
40
  "scripts": {
41
- "build": "npx esbuild src/index.ts --bundle --outfile=dist/index.js --platform=node --format=esm --external:os --external:path --external:fs --external:child_process --external:util --external:events --external:stream --external:crypto --external:http --external:https --external:url --external:net --external:tls --external:zlib --external:buffer --external:querystring --external:string_decoder && tsc --emitDeclarationOnly && shx mkdir -p dist/scripts && npx esbuild scripts/postinstall.ts --bundle --outfile=dist/scripts/postinstall.js --platform=node --format=esm --packages=external && npx esbuild scripts/preuninstall.ts --bundle --outfile=dist/scripts/preuninstall.js --platform=node --format=esm --packages=external",
41
+ "build": "shx rm -rf dist && npx esbuild src/index.ts --bundle --outfile=dist/index.js --platform=node --format=esm && tsc --emitDeclarationOnly && shx mkdir -p dist/scripts && npx esbuild scripts/postinstall.ts --bundle --outfile=dist/scripts/postinstall.js --platform=node --format=esm && npx esbuild scripts/preuninstall.ts --bundle --outfile=dist/scripts/preuninstall.js --platform=node --format=esm",
42
+ "test": "vitest run --reporter=verbose",
43
+ "test:watch": "vitest",
44
+ "test:coverage": "vitest run --coverage",
45
+ "test:unit": "vitest run tests/unit --reporter=verbose",
46
+ "test:e2e": "vitest run tests/e2e --reporter=verbose",
47
+ "test:all": "vitest run --reporter=verbose && echo '✅ ALL TESTS PASSED'",
42
48
  "postinstall": "node dist/scripts/postinstall.js",
43
49
  "preuninstall": "node dist/scripts/preuninstall.js",
44
50
  "prepublishOnly": "npm run build",
45
- "release:ship": "npx tsx scripts/release.ts",
46
- "release:patch": "npm run build && npm version patch && npm run release:ship",
47
- "release:minor": "npm run build && npm version minor && npm run release:ship",
48
- "release:major": "npm run build && npm version major && npm run release:ship",
49
- "dev:link": "npm run build && npm unlink opencode-orchestrator || shx echo 'Not linked' && shx rm -rf $(npm root -g)/opencode-orchestrator && npm link && echo 'SUCCESS: Re-linked. Restart OpenCode.'",
50
- "dev:unlink": "npm unlink opencode-orchestrator || shx echo 'Not linked' && shx rm -rf $(npm root -g)/opencode-orchestrator && echo 'SUCCESS: Unlinked and Cleaned'",
51
- "dev:status": "echo '=== Global Link Status ===' && shx ls -l $(npm root -g)/opencode-orchestrator || echo 'Not linked'",
51
+ "release:patch": "npm run build && npm version patch && git push --follow-tags && npm publish --access public",
52
+ "release:minor": "npm run build && npm version minor && git push --follow-tags && npm publish --access public",
53
+ "release:major": "npm run build && npm version major && git push --follow-tags && npm publish --access public",
54
+ "dev:clean": "shx rm -rf $(npm root -g)/opencode-orchestrator && npm cache clean --force && echo 'Cleaned global + cache'",
55
+ "dev:link": "npm run dev:clean || true && npm run build && npm link && echo 'SUCCESS: Linked. Restart OpenCode.'",
56
+ "dev:unlink": "npm unlink -g opencode-orchestrator || true && npm run dev:clean && echo 'SUCCESS: Unlinked'",
57
+ "dev:status": "echo '=== Global Link ===' && ls -la $(npm root -g)/opencode-orchestrator 2>/dev/null || echo 'Not linked'",
52
58
  "dev:test": "node dist/scripts/postinstall.js && echo '---' && node dist/scripts/preuninstall.js",
53
- "delete": "brew uninstall opencode && rm -rf ~/.config/opencode && npm uninstall -g opencode-orchestrator",
54
- "install": "brew install opencode && npm install -g opencode-orchestrator"
59
+ "reset": "npm run dev:unlink || true && npm uninstall -g opencode-orchestrator || true && brew uninstall opencode || true && rm -rf ~/.config/opencode ~/.opencode ~/.local/share/opencode && echo '=== Clean done ===' && brew install opencode && npm run dev:link && echo '=== Reset complete ==='"
55
60
  },
56
61
  "dependencies": {
57
62
  "@opencode-ai/plugin": "^1.1.1",
@@ -61,6 +66,7 @@
61
66
  "@types/node": "^22.0.0",
62
67
  "esbuild": "^0.24.0",
63
68
  "shx": "^0.4.0",
64
- "typescript": "^5.7.0"
69
+ "typescript": "^5.7.0",
70
+ "vitest": "^4.0.17"
65
71
  }
66
72
  }
@@ -1,2 +0,0 @@
1
- import { AgentDefinition } from "../../shared/contracts/interfaces.js";
2
- export declare const frontendDesigner: AgentDefinition;
@@ -1,8 +0,0 @@
1
- /**
2
- * Agent-related constants
3
- */
4
- export declare const AGENT_EMOJI: Record<string, string>;
5
- export declare const AGENT_CAPABILITIES: {
6
- readonly canWrite: true;
7
- readonly canBash: true;
8
- };
@@ -1,7 +0,0 @@
1
- /**
2
- * Central constants export
3
- */
4
- export * from "./time.js";
5
- export * from "./task.js";
6
- export * from "./prompts.js";
7
- export * from "./agent.js";
@@ -1,10 +0,0 @@
1
- /**
2
- * Prompt-related constants
3
- */
4
- export declare const REASONING_CONSTRAINTS = "\n<constraints>\n1. Reasoning MUST be in English for maximum stability\n2. If reasoning collapses into gibberish, stop and output: \"ERROR: REASONING_COLLAPSE\"\n3. Never suppress type errors with 'as any', '@ts-ignore', '@ts-expect-error'\n4. Never leave code in broken state\n5. Always verify with evidence before claiming completion\n</constraints>\n";
5
- export declare const LANGUAGE_RULE = "\n<language_rule>\nTHINK and REASON in English for maximum model stability.\n\nFINAL RESPONSE LANGUAGE:\n- Detect user's language from their request\n- Respond in SAME language\n- Korean \u2192 Korean, English \u2192 English, Japanese \u2192 Japanese, Chinese \u2192 Chinese\n- Default to English if unclear\n</language_rule>\n";
6
- export declare const TASK_COMPLETION_CHECK = "\n<completion_criteria>\nA task is COMPLETE when:\n1. \u2705 All planned work done\n2. \u2705 lsp_diagnostics clean on changed files\n3. \u2705 Build passes (if applicable)\n4. \u2705 Tests pass (if applicable)\n5. \u2705 User's original request fully addressed\n</completion_criteria>\n";
7
- export declare const OUTPUT_FORMAT = "\n<output_format>\nReport completion with:\n- What was done (concise)\n- Evidence of success (build/test/audit results)\n- Files changed (with line numbers)\n</output_format>\n";
8
- export declare const ANTI_PATTERNS = "\n<anti_patterns>\n\u274C Delegate without environment/codebase context\n\u274C Leave code broken or with LSP errors\n\u274C Make random changes without understanding root cause\n\u274C Use 'as any', '@ts-ignore', or '@ts-expect-error'\n\u274C Suppress errors instead of fixing them\n</anti_patterns>\n";
9
- export declare const WORKFLOW = "\n<workflow>\n1. THINK - Reason about the task\n2. ACT - Execute the work\n3. OBSERVE - Check the result\n4. ADJUST - Fix if needed\n5. VERIFY - Prove success with evidence\n</workflow>\n";
10
- export declare const BASE_PROMPT = "\n\n<constraints>\n1. Reasoning MUST be in English for maximum stability\n2. If reasoning collapses into gibberish, stop and output: \"ERROR: REASONING_COLLAPSE\"\n3. Never suppress type errors with 'as any', '@ts-ignore', '@ts-expect-error'\n4. Never leave code in broken state\n5. Always verify with evidence before claiming completion\n</constraints>\n\n\n\n<language_rule>\nTHINK and REASON in English for maximum model stability.\n\nFINAL RESPONSE LANGUAGE:\n- Detect user's language from their request\n- Respond in SAME language\n- Korean \u2192 Korean, English \u2192 English, Japanese \u2192 Japanese, Chinese \u2192 Chinese\n- Default to English if unclear\n</language_rule>\n\n\n\n<anti_patterns>\n\u274C Delegate without environment/codebase context\n\u274C Leave code broken or with LSP errors\n\u274C Make random changes without understanding root cause\n\u274C Use 'as any', '@ts-ignore', or '@ts-expect-error'\n\u274C Suppress errors instead of fixing them\n</anti_patterns>\n\n\n\n<workflow>\n1. THINK - Reason about the task\n2. ACT - Execute the work\n3. OBSERVE - Check the result\n4. ADJUST - Fix if needed\n5. VERIFY - Prove success with evidence\n</workflow>\n\n";
@@ -1,12 +0,0 @@
1
- /**
2
- * Task status constants and mappings
3
- */
4
- export type TaskStatus = "pending" | "running" | "completed" | "done" | "error" | "timeout";
5
- export type ParallelTaskStatus = "pending" | "running" | "completed" | "error" | "timeout";
6
- export declare const STATUS_EMOJI: Record<string, string>;
7
- /**
8
- * Get emoji for task status
9
- */
10
- export declare function getStatusEmoji(status: TaskStatus | ParallelTaskStatus | string): string;
11
- export declare const TASK_ID_PREFIX = "task_";
12
- export declare const JOB_ID_PREFIX = "job_";
@@ -1,34 +0,0 @@
1
- /**
2
- * Time-related constants
3
- * Centralized to prevent duplication across the codebase
4
- */
5
- /** Maximum time a task can run before timeout (30 minutes) */
6
- export declare const TASK_TTL_MS: number;
7
- /** Default background task timeout (5 minutes) */
8
- export declare const BACKGROUND_TASK_TIMEOUT_MS: number;
9
- /** Maximum sync task poll time (10 minutes) */
10
- export declare const SYNC_TASK_MAX_POLL_MS: number;
11
- /** Poll interval for parallel agent tasks (2 seconds) */
12
- export declare const PARALLEL_POLL_INTERVAL_MS = 2000;
13
- /** Poll interval for background task monitoring (5 seconds) */
14
- export declare const BACKGROUND_MONITOR_INTERVAL_MS = 5000;
15
- /** Poll interval for sync task completion (500ms) */
16
- export declare const SYNC_POLL_INTERVAL_MS = 500;
17
- /** Minimum time task must run before considered stable (5 seconds) */
18
- export declare const MIN_STABILITY_MS: number;
19
- /** Number of stable polls required to confirm completion (for sync mode) */
20
- export declare const STABILITY_POLLS_REQUIRED = 3;
21
- /** Delay before cleaning up completed tasks (5 minutes) */
22
- export declare const CLEANUP_DELAY_MS: number;
23
- /** Delay before retry after failure (500ms) */
24
- export declare const RETRY_DELAY_MS = 500;
25
- /** Default maximum parallel tasks per agent type */
26
- export declare const DEFAULT_CONCURRENCY = 3;
27
- /** Maximum parallel tasks per agent type (hard limit) */
28
- export declare const MAX_CONCURRENCY = 10;
29
- /** Default maximum steps for auto-continuation */
30
- export declare const DEFAULT_MAX_STEPS = 500;
31
- /** Maximum steps for /task command */
32
- export declare const TASK_COMMAND_MAX_STEPS = 1000;
33
- /** Maximum task retry attempts */
34
- export declare const MAX_TASK_RETRIES = 3;
@@ -1,47 +0,0 @@
1
- /**
2
- * Context Enforcer
3
- *
4
- * Validates context before agent delegation to prevent errors.
5
- * Ensures agents have necessary information to complete tasks.
6
- */
7
- export interface ValidationResult {
8
- valid: boolean;
9
- errors: string[];
10
- warnings: string[];
11
- }
12
- export interface ContextRequirement {
13
- agent: string;
14
- required: string[];
15
- optional: string[];
16
- }
17
- /**
18
- * Context Enforcer validates agent delegation context
19
- */
20
- export declare class ContextEnforcer {
21
- private requirements;
22
- /**
23
- * Validate context for agent delegation
24
- */
25
- validate(agent: string, context: string): ValidationResult;
26
- /**
27
- * Get requirements for an agent
28
- */
29
- getRequirements(agent: string): ContextRequirement | undefined;
30
- /**
31
- * Add or update requirements for an agent
32
- */
33
- setRequirements(agent: string, requirements: ContextRequirement): void;
34
- /**
35
- * Format validation result as user-friendly message
36
- */
37
- formatValidation(result: ValidationResult): string;
38
- /**
39
- * Check if context has minimal required information
40
- */
41
- hasMinimumContext(agent: string, context: string): boolean;
42
- /**
43
- * Suggest missing context based on agent type
44
- */
45
- suggestContext(agent: string, context: string): string[];
46
- }
47
- export declare const contextEnforcer: ContextEnforcer;
@@ -1,112 +0,0 @@
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 concurrency statistics for all agent types
78
- */
79
- getConcurrencyStats(): Record<string, {
80
- running: number;
81
- queued: number;
82
- limit: number;
83
- }>;
84
- /**
85
- * Update concurrency limit dynamically at runtime
86
- */
87
- updateConcurrency(agentType: string, newLimit: number): void;
88
- /**
89
- * Get pending notification count
90
- */
91
- getPendingCount(parentSessionID: string): number;
92
- /**
93
- * Cleanup all state
94
- */
95
- cleanup(): void;
96
- private trackPending;
97
- private untrackPending;
98
- private handleTaskError;
99
- private startPolling;
100
- private stopPolling;
101
- private pollRunningTasks;
102
- private validateSessionHasOutput;
103
- private pruneExpiredTasks;
104
- private scheduleCleanup;
105
- private queueNotification;
106
- private notifyParentIfAllComplete;
107
- formatDuration(start: Date, end?: Date): string;
108
- }
109
- export declare const parallelAgentManager: {
110
- getInstance: typeof ParallelAgentManager.getInstance;
111
- };
112
- export {};