agentis
Version:
A TypeScript framework for building sophisticated multi-agent systems
52 lines (51 loc) • 1.62 kB
TypeScript
import { ITool, ToolOutput } from './ITool';
export declare enum ExecutionMode {
SEQUENTIAL = "sequential",
PARALLEL = "parallel",
CONDITIONAL = "conditional"
}
export interface ToolExecutionNode {
id: string;
toolName: string;
input: string | ((context: ExecutionContext) => string);
priority: number;
dependsOn?: string[];
mode?: ExecutionMode;
condition?: (results: Map<string, ToolOutput>) => boolean;
transformOutput?: (output: ToolOutput, context: ExecutionContext) => any;
retryConfig?: {
maxRetries: number;
delayMs: number;
shouldRetry?: (error: Error, attempt: number) => boolean;
};
}
export interface ExecutionContext {
results: Map<string, ToolOutput>;
history: Map<string, ToolOutput[]>;
agentId: string;
getPreviousResult: (nodeId: string) => ToolOutput | undefined;
getAllResults: () => Map<string, ToolOutput>;
}
export interface ExecutionGraph {
nodes: ToolExecutionNode[];
mode: ExecutionMode;
maxConcurrency?: number;
}
export declare class EnhancedToolOrchestrator {
private tools;
private executionHistory;
private executionCache;
private cacheExpiryMs;
constructor(options?: {
defaultTools?: ITool[];
cacheExpiryMs?: number;
});
registerTool(tool: ITool): void;
getTool(name: string): ITool | undefined;
getTools(): ITool[];
private getCacheKey;
private executeSingleNode;
executeGraph(graph: ExecutionGraph, agentId: string): Promise<Map<string, ToolOutput>>;
private topologicalSort;
private groupByDependencyLevel;
}