mcp-agent-foundry 1.0.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/LICENSE +21 -0
- package/README.md +477 -0
- package/dist/cli/install-skills.d.ts +11 -0
- package/dist/cli/install-skills.d.ts.map +1 -0
- package/dist/cli/install-skills.js +143 -0
- package/dist/cli/install-skills.js.map +1 -0
- package/dist/cli/recovery-commands.d.ts +41 -0
- package/dist/cli/recovery-commands.d.ts.map +1 -0
- package/dist/cli/recovery-commands.js +241 -0
- package/dist/cli/recovery-commands.js.map +1 -0
- package/dist/cli/setup-wizard.d.ts +25 -0
- package/dist/cli/setup-wizard.d.ts.map +1 -0
- package/dist/cli/setup-wizard.js +1417 -0
- package/dist/cli/setup-wizard.js.map +1 -0
- package/dist/cli/test-connection.d.ts +45 -0
- package/dist/cli/test-connection.d.ts.map +1 -0
- package/dist/cli/test-connection.js +317 -0
- package/dist/cli/test-connection.js.map +1 -0
- package/dist/cli.d.ts +75 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +704 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/defaults.d.ts +57 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +99 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/index.d.ts +14 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +22 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/manager.d.ts +184 -0
- package/dist/config/manager.d.ts.map +1 -0
- package/dist/config/manager.js +347 -0
- package/dist/config/manager.js.map +1 -0
- package/dist/config/merger.d.ts +76 -0
- package/dist/config/merger.d.ts.map +1 -0
- package/dist/config/merger.js +189 -0
- package/dist/config/merger.js.map +1 -0
- package/dist/config/schema.d.ts +20 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +20 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/validator.d.ts +254 -0
- package/dist/config/validator.d.ts.map +1 -0
- package/dist/config/validator.js +363 -0
- package/dist/config/validator.js.map +1 -0
- package/dist/config/worktree-defaults.d.ts +23 -0
- package/dist/config/worktree-defaults.d.ts.map +1 -0
- package/dist/config/worktree-defaults.js +78 -0
- package/dist/config/worktree-defaults.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/tools/compare-agents.d.ts +25 -0
- package/dist/mcp/tools/compare-agents.d.ts.map +1 -0
- package/dist/mcp/tools/compare-agents.js +177 -0
- package/dist/mcp/tools/compare-agents.js.map +1 -0
- package/dist/mcp/tools/critique-plan.d.ts +26 -0
- package/dist/mcp/tools/critique-plan.d.ts.map +1 -0
- package/dist/mcp/tools/critique-plan.js +162 -0
- package/dist/mcp/tools/critique-plan.js.map +1 -0
- package/dist/mcp/tools/design-feedback.d.ts +26 -0
- package/dist/mcp/tools/design-feedback.d.ts.map +1 -0
- package/dist/mcp/tools/design-feedback.js +216 -0
- package/dist/mcp/tools/design-feedback.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +50 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +191 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/invoke-agent.d.ts +25 -0
- package/dist/mcp/tools/invoke-agent.d.ts.map +1 -0
- package/dist/mcp/tools/invoke-agent.js +141 -0
- package/dist/mcp/tools/invoke-agent.js.map +1 -0
- package/dist/mcp/tools/review-code.d.ts +25 -0
- package/dist/mcp/tools/review-code.d.ts.map +1 -0
- package/dist/mcp/tools/review-code.js +170 -0
- package/dist/mcp/tools/review-code.js.map +1 -0
- package/dist/mcp/tools/tasks/claim-next-task.d.ts +22 -0
- package/dist/mcp/tools/tasks/claim-next-task.d.ts.map +1 -0
- package/dist/mcp/tools/tasks/claim-next-task.js +203 -0
- package/dist/mcp/tools/tasks/claim-next-task.js.map +1 -0
- package/dist/mcp/tools/tasks/create-routed-task.d.ts +17 -0
- package/dist/mcp/tools/tasks/create-routed-task.d.ts.map +1 -0
- package/dist/mcp/tools/tasks/create-routed-task.js +178 -0
- package/dist/mcp/tools/tasks/create-routed-task.js.map +1 -0
- package/dist/mcp/tools/tasks/execute-pipeline.d.ts +22 -0
- package/dist/mcp/tools/tasks/execute-pipeline.d.ts.map +1 -0
- package/dist/mcp/tools/tasks/execute-pipeline.js +401 -0
- package/dist/mcp/tools/tasks/execute-pipeline.js.map +1 -0
- package/dist/mcp/tools/tasks/execute-task.d.ts +32 -0
- package/dist/mcp/tools/tasks/execute-task.d.ts.map +1 -0
- package/dist/mcp/tools/tasks/execute-task.js +284 -0
- package/dist/mcp/tools/tasks/execute-task.js.map +1 -0
- package/dist/mcp/tools/tasks/get-pipeline-status.d.ts +26 -0
- package/dist/mcp/tools/tasks/get-pipeline-status.d.ts.map +1 -0
- package/dist/mcp/tools/tasks/get-pipeline-status.js +460 -0
- package/dist/mcp/tools/tasks/get-pipeline-status.js.map +1 -0
- package/dist/mcp/tools/tasks/index.d.ts +36 -0
- package/dist/mcp/tools/tasks/index.d.ts.map +1 -0
- package/dist/mcp/tools/tasks/index.js +66 -0
- package/dist/mcp/tools/tasks/index.js.map +1 -0
- package/dist/mcp/tools/worktree/cleanup-worktrees.d.ts +17 -0
- package/dist/mcp/tools/worktree/cleanup-worktrees.d.ts.map +1 -0
- package/dist/mcp/tools/worktree/cleanup-worktrees.js +147 -0
- package/dist/mcp/tools/worktree/cleanup-worktrees.js.map +1 -0
- package/dist/mcp/tools/worktree/get-worktree-status.d.ts +17 -0
- package/dist/mcp/tools/worktree/get-worktree-status.d.ts.map +1 -0
- package/dist/mcp/tools/worktree/get-worktree-status.js +123 -0
- package/dist/mcp/tools/worktree/get-worktree-status.js.map +1 -0
- package/dist/mcp/tools/worktree/index.d.ts +41 -0
- package/dist/mcp/tools/worktree/index.d.ts.map +1 -0
- package/dist/mcp/tools/worktree/index.js +69 -0
- package/dist/mcp/tools/worktree/index.js.map +1 -0
- package/dist/mcp/tools/worktree/list-worktrees.d.ts +17 -0
- package/dist/mcp/tools/worktree/list-worktrees.d.ts.map +1 -0
- package/dist/mcp/tools/worktree/list-worktrees.js +136 -0
- package/dist/mcp/tools/worktree/list-worktrees.js.map +1 -0
- package/dist/mcp/tools/worktree/resolve-conflicts.d.ts +19 -0
- package/dist/mcp/tools/worktree/resolve-conflicts.d.ts.map +1 -0
- package/dist/mcp/tools/worktree/resolve-conflicts.js +228 -0
- package/dist/mcp/tools/worktree/resolve-conflicts.js.map +1 -0
- package/dist/mcp/transport/stdio.d.ts +13 -0
- package/dist/mcp/transport/stdio.d.ts.map +1 -0
- package/dist/mcp/transport/stdio.js +15 -0
- package/dist/mcp/transport/stdio.js.map +1 -0
- package/dist/observability/logger.d.ts +137 -0
- package/dist/observability/logger.d.ts.map +1 -0
- package/dist/observability/logger.js +235 -0
- package/dist/observability/logger.js.map +1 -0
- package/dist/observability/metrics.d.ts +250 -0
- package/dist/observability/metrics.d.ts.map +1 -0
- package/dist/observability/metrics.js +364 -0
- package/dist/observability/metrics.js.map +1 -0
- package/dist/persistence/index.d.ts +9 -0
- package/dist/persistence/index.d.ts.map +1 -0
- package/dist/persistence/index.js +9 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/persistence/state-schema.d.ts +116 -0
- package/dist/persistence/state-schema.d.ts.map +1 -0
- package/dist/persistence/state-schema.js +28 -0
- package/dist/persistence/state-schema.js.map +1 -0
- package/dist/persistence/state-store.d.ts +111 -0
- package/dist/persistence/state-store.d.ts.map +1 -0
- package/dist/persistence/state-store.js +291 -0
- package/dist/persistence/state-store.js.map +1 -0
- package/dist/providers/anthropic.d.ts +164 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +500 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/base.d.ts +151 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/base.js +227 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/gemini.d.ts +85 -0
- package/dist/providers/gemini.d.ts.map +1 -0
- package/dist/providers/gemini.js +414 -0
- package/dist/providers/gemini.js.map +1 -0
- package/dist/providers/kimi.d.ts +19 -0
- package/dist/providers/kimi.d.ts.map +1 -0
- package/dist/providers/kimi.js +20 -0
- package/dist/providers/kimi.js.map +1 -0
- package/dist/providers/manager.d.ts +160 -0
- package/dist/providers/manager.d.ts.map +1 -0
- package/dist/providers/manager.js +264 -0
- package/dist/providers/manager.js.map +1 -0
- package/dist/providers/ollama.d.ts +83 -0
- package/dist/providers/ollama.d.ts.map +1 -0
- package/dist/providers/ollama.js +453 -0
- package/dist/providers/ollama.js.map +1 -0
- package/dist/providers/openai.d.ts +96 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +457 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/zai.d.ts +19 -0
- package/dist/providers/zai.d.ts.map +1 -0
- package/dist/providers/zai.js +20 -0
- package/dist/providers/zai.js.map +1 -0
- package/dist/router/context-manager.d.ts +2 -0
- package/dist/router/context-manager.d.ts.map +1 -0
- package/dist/router/context-manager.js +3 -0
- package/dist/router/context-manager.js.map +1 -0
- package/dist/router/engine.d.ts +169 -0
- package/dist/router/engine.d.ts.map +1 -0
- package/dist/router/engine.js +435 -0
- package/dist/router/engine.js.map +1 -0
- package/dist/router/pattern-executor.d.ts +317 -0
- package/dist/router/pattern-executor.d.ts.map +1 -0
- package/dist/router/pattern-executor.js +571 -0
- package/dist/router/pattern-executor.js.map +1 -0
- package/dist/router/role-resolver.d.ts +59 -0
- package/dist/router/role-resolver.d.ts.map +1 -0
- package/dist/router/role-resolver.js +95 -0
- package/dist/router/role-resolver.js.map +1 -0
- package/dist/server.d.ts +32 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +223 -0
- package/dist/server.js.map +1 -0
- package/dist/startup.d.ts +78 -0
- package/dist/startup.d.ts.map +1 -0
- package/dist/startup.js +107 -0
- package/dist/startup.js.map +1 -0
- package/dist/tasks/coordinator.d.ts +141 -0
- package/dist/tasks/coordinator.d.ts.map +1 -0
- package/dist/tasks/coordinator.js +331 -0
- package/dist/tasks/coordinator.js.map +1 -0
- package/dist/tasks/index.d.ts +13 -0
- package/dist/tasks/index.d.ts.map +1 -0
- package/dist/tasks/index.js +13 -0
- package/dist/tasks/index.js.map +1 -0
- package/dist/tasks/persistent-state-coordinator.d.ts +89 -0
- package/dist/tasks/persistent-state-coordinator.d.ts.map +1 -0
- package/dist/tasks/persistent-state-coordinator.js +371 -0
- package/dist/tasks/persistent-state-coordinator.js.map +1 -0
- package/dist/tasks/pipeline-manager.d.ts +103 -0
- package/dist/tasks/pipeline-manager.d.ts.map +1 -0
- package/dist/tasks/pipeline-manager.js +358 -0
- package/dist/tasks/pipeline-manager.js.map +1 -0
- package/dist/tasks/state-coordinator.d.ts +79 -0
- package/dist/tasks/state-coordinator.d.ts.map +1 -0
- package/dist/tasks/state-coordinator.js +200 -0
- package/dist/tasks/state-coordinator.js.map +1 -0
- package/dist/tasks/worker-mode.d.ts +65 -0
- package/dist/tasks/worker-mode.d.ts.map +1 -0
- package/dist/tasks/worker-mode.js +208 -0
- package/dist/tasks/worker-mode.js.map +1 -0
- package/dist/translation/errors.d.ts +203 -0
- package/dist/translation/errors.d.ts.map +1 -0
- package/dist/translation/errors.js +477 -0
- package/dist/translation/errors.js.map +1 -0
- package/dist/translation/index.d.ts +12 -0
- package/dist/translation/index.d.ts.map +1 -0
- package/dist/translation/index.js +32 -0
- package/dist/translation/index.js.map +1 -0
- package/dist/translation/messages.d.ts +295 -0
- package/dist/translation/messages.d.ts.map +1 -0
- package/dist/translation/messages.js +557 -0
- package/dist/translation/messages.js.map +1 -0
- package/dist/translation/streaming.d.ts +226 -0
- package/dist/translation/streaming.d.ts.map +1 -0
- package/dist/translation/streaming.js +520 -0
- package/dist/translation/streaming.js.map +1 -0
- package/dist/translation/tools.d.ts +209 -0
- package/dist/translation/tools.d.ts.map +1 -0
- package/dist/translation/tools.js +331 -0
- package/dist/translation/tools.js.map +1 -0
- package/dist/types.d.ts +747 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +86 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/circuit-breaker.d.ts +175 -0
- package/dist/utils/circuit-breaker.d.ts.map +1 -0
- package/dist/utils/circuit-breaker.js +315 -0
- package/dist/utils/circuit-breaker.js.map +1 -0
- package/dist/utils/env.d.ts +2 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/env.js +3 -0
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/git.d.ts +58 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +197 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/merge-ordering.d.ts +45 -0
- package/dist/utils/merge-ordering.d.ts.map +1 -0
- package/dist/utils/merge-ordering.js +128 -0
- package/dist/utils/merge-ordering.js.map +1 -0
- package/dist/utils/retry.d.ts +106 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +188 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/worktrees/branch-manager.d.ts +55 -0
- package/dist/worktrees/branch-manager.d.ts.map +1 -0
- package/dist/worktrees/branch-manager.js +129 -0
- package/dist/worktrees/branch-manager.js.map +1 -0
- package/dist/worktrees/conflict-handler.d.ts +72 -0
- package/dist/worktrees/conflict-handler.d.ts.map +1 -0
- package/dist/worktrees/conflict-handler.js +287 -0
- package/dist/worktrees/conflict-handler.js.map +1 -0
- package/dist/worktrees/conflict-parser.d.ts +28 -0
- package/dist/worktrees/conflict-parser.d.ts.map +1 -0
- package/dist/worktrees/conflict-parser.js +140 -0
- package/dist/worktrees/conflict-parser.js.map +1 -0
- package/dist/worktrees/index.d.ts +20 -0
- package/dist/worktrees/index.d.ts.map +1 -0
- package/dist/worktrees/index.js +20 -0
- package/dist/worktrees/index.js.map +1 -0
- package/dist/worktrees/instructions.d.ts +20 -0
- package/dist/worktrees/instructions.d.ts.map +1 -0
- package/dist/worktrees/instructions.js +84 -0
- package/dist/worktrees/instructions.js.map +1 -0
- package/dist/worktrees/manager.d.ts +76 -0
- package/dist/worktrees/manager.d.ts.map +1 -0
- package/dist/worktrees/manager.js +277 -0
- package/dist/worktrees/manager.js.map +1 -0
- package/dist/worktrees/pipeline-merge-orchestrator.d.ts +55 -0
- package/dist/worktrees/pipeline-merge-orchestrator.d.ts.map +1 -0
- package/dist/worktrees/pipeline-merge-orchestrator.js +221 -0
- package/dist/worktrees/pipeline-merge-orchestrator.js.map +1 -0
- package/dist/worktrees/pool.d.ts +95 -0
- package/dist/worktrees/pool.d.ts.map +1 -0
- package/dist/worktrees/pool.js +271 -0
- package/dist/worktrees/pool.js.map +1 -0
- package/dist/worktrees/recovery.d.ts +94 -0
- package/dist/worktrees/recovery.d.ts.map +1 -0
- package/dist/worktrees/recovery.js +371 -0
- package/dist/worktrees/recovery.js.map +1 -0
- package/dist/worktrees/resource-manager.d.ts +74 -0
- package/dist/worktrees/resource-manager.d.ts.map +1 -0
- package/dist/worktrees/resource-manager.js +228 -0
- package/dist/worktrees/resource-manager.js.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pattern Executor
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates multi-agent workflows using various execution patterns.
|
|
5
|
+
* Provides high-level patterns for agent collaboration including:
|
|
6
|
+
* - Sequential pipelines (A → B → C)
|
|
7
|
+
* - Parallel comparison (same task to multiple agents)
|
|
8
|
+
* - Generator-Critic loops (generate → critique → improve)
|
|
9
|
+
* - Consensus building (propose → vote → synthesize)
|
|
10
|
+
*
|
|
11
|
+
* Each pattern leverages the RouterEngine for individual agent invocations
|
|
12
|
+
* while managing the overall workflow state and data flow between agents.
|
|
13
|
+
*/
|
|
14
|
+
import { type Logger } from '../observability/logger.js';
|
|
15
|
+
import type { AgentResponse } from '../types.js';
|
|
16
|
+
import type { RouterEngine } from './engine.js';
|
|
17
|
+
/**
|
|
18
|
+
* Step definition for sequential pipeline execution.
|
|
19
|
+
*/
|
|
20
|
+
export interface SequentialStep {
|
|
21
|
+
/** The role of the agent to invoke for this step */
|
|
22
|
+
role: string;
|
|
23
|
+
/** Task template for this step. Use {{input}} or {{previousOutput}} placeholders */
|
|
24
|
+
taskTemplate: string;
|
|
25
|
+
/** Optional transform function to modify input before sending to agent */
|
|
26
|
+
transform?: (input: string) => string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Result of a sequential pipeline execution.
|
|
30
|
+
*/
|
|
31
|
+
export interface SequentialResult {
|
|
32
|
+
/** Pattern identifier */
|
|
33
|
+
pattern: 'sequential';
|
|
34
|
+
/** All step responses in order */
|
|
35
|
+
steps: AgentResponse[];
|
|
36
|
+
/** Final output text from the last step */
|
|
37
|
+
finalOutput: string;
|
|
38
|
+
/** Total duration in milliseconds */
|
|
39
|
+
totalDurationMs: number;
|
|
40
|
+
/** Trace ID for correlation */
|
|
41
|
+
traceId: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Result of a parallel comparison execution.
|
|
45
|
+
*/
|
|
46
|
+
export interface ParallelResult {
|
|
47
|
+
/** Pattern identifier */
|
|
48
|
+
pattern: 'parallel';
|
|
49
|
+
/** Map of role names to their responses */
|
|
50
|
+
responses: Map<string, AgentResponse>;
|
|
51
|
+
/** Errors for roles that failed */
|
|
52
|
+
errors: Map<string, Error>;
|
|
53
|
+
/** Total duration in milliseconds */
|
|
54
|
+
totalDurationMs: number;
|
|
55
|
+
/** Trace ID for correlation */
|
|
56
|
+
traceId: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Result of a generator-critic loop execution.
|
|
60
|
+
*/
|
|
61
|
+
export interface CriticLoopResult {
|
|
62
|
+
/** Pattern identifier */
|
|
63
|
+
pattern: 'critic-loop';
|
|
64
|
+
/** Number of iterations completed */
|
|
65
|
+
iterations: number;
|
|
66
|
+
/** Final response from the generator */
|
|
67
|
+
finalResponse: AgentResponse;
|
|
68
|
+
/** Complete history of all generation and critique responses */
|
|
69
|
+
history: CriticLoopIteration[];
|
|
70
|
+
/** Whether the critic approved the final result */
|
|
71
|
+
approved: boolean;
|
|
72
|
+
/** Final output text */
|
|
73
|
+
finalOutput: string;
|
|
74
|
+
/** Total duration in milliseconds */
|
|
75
|
+
totalDurationMs: number;
|
|
76
|
+
/** Trace ID for correlation */
|
|
77
|
+
traceId: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Single iteration of a critic loop.
|
|
81
|
+
*/
|
|
82
|
+
export interface CriticLoopIteration {
|
|
83
|
+
/** Iteration number (1-indexed) */
|
|
84
|
+
iteration: number;
|
|
85
|
+
/** Generator's response */
|
|
86
|
+
generation: AgentResponse;
|
|
87
|
+
/** Critic's response */
|
|
88
|
+
critique: AgentResponse;
|
|
89
|
+
/** Whether the critic approved this iteration */
|
|
90
|
+
approved: boolean;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Result of a consensus building execution.
|
|
94
|
+
*/
|
|
95
|
+
export interface ConsensusResult {
|
|
96
|
+
/** Pattern identifier */
|
|
97
|
+
pattern: 'consensus';
|
|
98
|
+
/** Initial proposals from all participating roles */
|
|
99
|
+
proposals: Map<string, AgentResponse>;
|
|
100
|
+
/** Votes/assessments from each role on all proposals */
|
|
101
|
+
votes: Map<string, AgentResponse>;
|
|
102
|
+
/** Final synthesized recommendation */
|
|
103
|
+
synthesis: AgentResponse;
|
|
104
|
+
/** Final output text */
|
|
105
|
+
finalOutput: string;
|
|
106
|
+
/** Total duration in milliseconds */
|
|
107
|
+
totalDurationMs: number;
|
|
108
|
+
/** Trace ID for correlation */
|
|
109
|
+
traceId: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Options for critic loop execution.
|
|
113
|
+
*/
|
|
114
|
+
export interface CriticLoopOptions {
|
|
115
|
+
/** Maximum number of iterations (default: 3) */
|
|
116
|
+
maxIterations?: number;
|
|
117
|
+
/** Custom approval detection function */
|
|
118
|
+
isApproved?: (critique: string) => boolean;
|
|
119
|
+
/** Custom task template for critique requests */
|
|
120
|
+
critiqueTaskTemplate?: string;
|
|
121
|
+
/** Custom task template for improvement requests */
|
|
122
|
+
improvementTaskTemplate?: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Options for consensus building execution.
|
|
126
|
+
*/
|
|
127
|
+
export interface ConsensusOptions {
|
|
128
|
+
/** Role to use for final synthesis (default: first role in list) */
|
|
129
|
+
synthesizeRole?: string;
|
|
130
|
+
/** Custom task template for voting phase */
|
|
131
|
+
voteTaskTemplate?: string;
|
|
132
|
+
/** Custom task template for synthesis phase */
|
|
133
|
+
synthesisTaskTemplate?: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Union type of all orchestration results.
|
|
137
|
+
*/
|
|
138
|
+
export type OrchestrationResult = SequentialResult | ParallelResult | CriticLoopResult | ConsensusResult;
|
|
139
|
+
/**
|
|
140
|
+
* Orchestrates multi-agent workflows using various execution patterns.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const executor = new PatternExecutor(routerEngine, logger);
|
|
145
|
+
*
|
|
146
|
+
* // Sequential pipeline
|
|
147
|
+
* const result = await executor.executeSequential([
|
|
148
|
+
* { role: 'coder', taskTemplate: 'Implement: {{input}}' },
|
|
149
|
+
* { role: 'reviewer', taskTemplate: 'Review this code: {{previousOutput}}' },
|
|
150
|
+
* ], 'Create a sorting function');
|
|
151
|
+
*
|
|
152
|
+
* // Parallel comparison
|
|
153
|
+
* const comparison = await executor.executeParallel(
|
|
154
|
+
* ['coder', 'researcher'],
|
|
155
|
+
* 'What are the best practices for error handling?'
|
|
156
|
+
* );
|
|
157
|
+
*
|
|
158
|
+
* // Critic loop
|
|
159
|
+
* const improved = await executor.executeCriticLoop(
|
|
160
|
+
* 'coder',
|
|
161
|
+
* 'critic',
|
|
162
|
+
* 'Write a REST API endpoint',
|
|
163
|
+
* { maxIterations: 3 }
|
|
164
|
+
* );
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
export declare class PatternExecutor {
|
|
168
|
+
private readonly router;
|
|
169
|
+
private readonly logger;
|
|
170
|
+
constructor(router: RouterEngine, logger: Logger);
|
|
171
|
+
/**
|
|
172
|
+
* Execute a sequential pipeline of agents.
|
|
173
|
+
*
|
|
174
|
+
* Each agent's output becomes input to the next. Task templates can use
|
|
175
|
+
* placeholders:
|
|
176
|
+
* - `{{input}}` - The original input or previous step's output
|
|
177
|
+
* - `{{previousOutput}}` - Alias for input from previous step
|
|
178
|
+
*
|
|
179
|
+
* @param steps - Array of step definitions with roles and task templates
|
|
180
|
+
* @param initialInput - Initial input to the first step
|
|
181
|
+
* @returns Promise resolving to SequentialResult with all step outputs
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```typescript
|
|
185
|
+
* const result = await executor.executeSequential([
|
|
186
|
+
* { role: 'coder', taskTemplate: '{{input}}' },
|
|
187
|
+
* { role: 'reviewer', taskTemplate: 'Review: {{previousOutput}}' },
|
|
188
|
+
* { role: 'coder', taskTemplate: 'Fix issues: {{previousOutput}}' },
|
|
189
|
+
* ], 'Write a function to validate email addresses');
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
executeSequential(steps: SequentialStep[], initialInput: string): Promise<SequentialResult>;
|
|
193
|
+
/**
|
|
194
|
+
* Execute the same task through multiple agents in parallel.
|
|
195
|
+
*
|
|
196
|
+
* All agents receive the same task and run concurrently. Results are
|
|
197
|
+
* collected for comparison. Errors for individual agents don't fail
|
|
198
|
+
* the entire operation.
|
|
199
|
+
*
|
|
200
|
+
* @param roles - Array of role names to invoke
|
|
201
|
+
* @param task - The task to send to all agents
|
|
202
|
+
* @returns Promise resolving to ParallelResult with all agent responses
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* const result = await executor.executeParallel(
|
|
207
|
+
* ['coder', 'researcher', 'critic'],
|
|
208
|
+
* 'What is the best approach to implement caching?'
|
|
209
|
+
* );
|
|
210
|
+
*
|
|
211
|
+
* for (const [role, response] of result.responses) {
|
|
212
|
+
* console.log(`${role}: ${extractText(response)}`);
|
|
213
|
+
* }
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
executeParallel(roles: string[], task: string): Promise<ParallelResult>;
|
|
217
|
+
/**
|
|
218
|
+
* Execute a generator-critic improvement loop.
|
|
219
|
+
*
|
|
220
|
+
* The generator creates an initial response, then the critic reviews it.
|
|
221
|
+
* If the critic identifies issues, the generator improves based on feedback.
|
|
222
|
+
* This continues until the critic approves or max iterations is reached.
|
|
223
|
+
*
|
|
224
|
+
* @param generatorRole - Role for generating content
|
|
225
|
+
* @param criticRole - Role for critiquing content
|
|
226
|
+
* @param task - Initial task for the generator
|
|
227
|
+
* @param options - Optional configuration for the loop
|
|
228
|
+
* @returns Promise resolving to CriticLoopResult with iteration history
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```typescript
|
|
232
|
+
* const result = await executor.executeCriticLoop(
|
|
233
|
+
* 'coder',
|
|
234
|
+
* 'critic',
|
|
235
|
+
* 'Write a function to parse JSON with error handling',
|
|
236
|
+
* { maxIterations: 3 }
|
|
237
|
+
* );
|
|
238
|
+
*
|
|
239
|
+
* if (result.approved) {
|
|
240
|
+
* console.log('Critic approved the final version');
|
|
241
|
+
* }
|
|
242
|
+
* console.log(`Completed in ${result.iterations} iterations`);
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
executeCriticLoop(generatorRole: string, criticRole: string, task: string, options?: CriticLoopOptions): Promise<CriticLoopResult>;
|
|
246
|
+
/**
|
|
247
|
+
* Execute a consensus building workflow.
|
|
248
|
+
*
|
|
249
|
+
* Three phases:
|
|
250
|
+
* 1. Proposals: All roles respond to the initial question
|
|
251
|
+
* 2. Voting: Each role evaluates all proposals
|
|
252
|
+
* 3. Synthesis: A designated role synthesizes a final recommendation
|
|
253
|
+
*
|
|
254
|
+
* @param roles - Array of role names to participate
|
|
255
|
+
* @param question - The question or decision to reach consensus on
|
|
256
|
+
* @param options - Optional configuration for the workflow
|
|
257
|
+
* @returns Promise resolving to ConsensusResult with all phases
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```typescript
|
|
261
|
+
* const result = await executor.executeConsensus(
|
|
262
|
+
* ['coder', 'critic', 'designer'],
|
|
263
|
+
* 'What is the best architecture for a real-time chat application?',
|
|
264
|
+
* { synthesizeRole: 'coder' }
|
|
265
|
+
* );
|
|
266
|
+
*
|
|
267
|
+
* console.log('Final recommendation:', result.finalOutput);
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
executeConsensus(roles: string[], question: string, options?: ConsensusOptions): Promise<ConsensusResult>;
|
|
271
|
+
/**
|
|
272
|
+
* Extract text content from an agent response.
|
|
273
|
+
*
|
|
274
|
+
* @param response - Agent response to extract text from
|
|
275
|
+
* @returns Concatenated text content from all text blocks
|
|
276
|
+
*/
|
|
277
|
+
extractText(response: AgentResponse): string;
|
|
278
|
+
/**
|
|
279
|
+
* Interpolate a template string with variable values.
|
|
280
|
+
*
|
|
281
|
+
* @param template - Template string with {{variable}} placeholders
|
|
282
|
+
* @param variables - Object mapping variable names to values
|
|
283
|
+
* @returns Interpolated string
|
|
284
|
+
*/
|
|
285
|
+
private interpolateTemplate;
|
|
286
|
+
/**
|
|
287
|
+
* Format proposals for display in templates.
|
|
288
|
+
*
|
|
289
|
+
* @param proposals - Map of role names to responses
|
|
290
|
+
* @returns Formatted string with numbered proposals
|
|
291
|
+
*/
|
|
292
|
+
private formatProposals;
|
|
293
|
+
/**
|
|
294
|
+
* Format votes/assessments for display in templates.
|
|
295
|
+
*
|
|
296
|
+
* @param votes - Map of role names to vote responses
|
|
297
|
+
* @returns Formatted string with role assessments
|
|
298
|
+
*/
|
|
299
|
+
private formatVotes;
|
|
300
|
+
/**
|
|
301
|
+
* Truncate a string to a maximum length.
|
|
302
|
+
*
|
|
303
|
+
* @param str - String to truncate
|
|
304
|
+
* @param maxLength - Maximum length before truncation
|
|
305
|
+
* @returns Truncated string with ellipsis if needed
|
|
306
|
+
*/
|
|
307
|
+
private truncate;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Create a PatternExecutor instance.
|
|
311
|
+
*
|
|
312
|
+
* @param router - RouterEngine for agent invocations
|
|
313
|
+
* @param logger - Logger for observability
|
|
314
|
+
* @returns Configured PatternExecutor instance
|
|
315
|
+
*/
|
|
316
|
+
export declare function createPatternExecutor(router: RouterEngine, logger: Logger): PatternExecutor;
|
|
317
|
+
//# sourceMappingURL=pattern-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern-executor.d.ts","sourceRoot":"","sources":["../../src/router/pattern-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAmB,KAAK,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAE1E,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAMhD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,YAAY,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACvC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,yBAAyB;IACzB,OAAO,EAAE,YAAY,CAAC;IACtB,kCAAkC;IAClC,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,2CA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