AgentForceWorkflow
AgentForceWorkflow Class Reference
Section titled “AgentForceWorkflow Class Reference”AgentForceWorkflow Workflow Class Multi-Agent
Technical documentation for the AgentForceWorkflow
class structure and API.
Class Documentation Comment
Section titled “Class Documentation Comment”/** * Represents a workflow instance within the AgentForce framework. * This class provides the core functionality for creating and managing workflows. * * @class AgentForceWorkflow */
Imports
Section titled “Imports”import { prompt, dispatcher, registerAgent, sharedStore, sequence, parallel, onSuccess, onFail, iterate, run, loop, debug,} from "./workflow/mod";
import type { WorkflowConfig, AgentForceLogger } from "./types";import type { AgentForceAgent } from "./agent";import { defaultLogger } from "./logger";
Constructor
Section titled “Constructor”constructor(config: WorkflowConfig)
Parameters:
config: WorkflowConfig
- Configuration object containing workflow initialization settings
Description: Constructs the AgentForceWorkflow class with the provided configuration. Initializes the workflow’s name and logger from the config object.
Private Properties
Section titled “Private Properties”private name: string;private logger: AgentForceLogger;
Protected Properties
Section titled “Protected Properties”protected userPrompt: string = "";protected dispatcherAgent: AgentForceAgent | null = null;protected agents: { name: string, agent: AgentForceAgent, outputs: AgentOutput[], tools: string[] }[] = [];protected executionPlan: ExecutionStep[] = [];protected agentToolRegistry: Map<string, string[]> = new Map(); // Maps agent name to tool namesprotected internalSharedStore: Map<string, any> = new Map();
Protected Methods
Section titled “Protected Methods”State Getters
Section titled “State Getters”protected getUserPrompt(): stringprotected getDispatcher(): AgentForceAgent | null
State Setters
Section titled “State Setters”protected setUserPrompt(prompt: string): voidprotected setDispatcher(agent: AgentForceAgent): voidprotected setSharedStoreItem(key: string, value: any): void
Utility Methods
Section titled “Utility Methods”protected pushAgent(name: string, agent: AgentForceAgent, outputs: AgentOutput[], tools: string[]): void
Public Methods
Section titled “Public Methods”State Getters
Section titled “State Getters”public getName(): stringpublic getLogger(): AgentForceLoggerpublic getSharedStoreItem(key: string): any
Chainable Methods
Section titled “Chainable Methods”Returns AgentForceWorkflow
instance for method chaining:
prompt(userPrompt: string): AgentForceWorkflowdispatcher(agent: AgentForceAgent): AgentForceWorkflowregisterAgent(agent: AgentForceAgent): AgentForceWorkflowsharedStore(key: string, value: any): AgentForceWorkflowsequence(agents: AgentForceAgent[]): AgentForceWorkflowparallel(agents: AgentForceAgent[]): AgentForceWorkflowonSuccess(agent: AgentForceAgent): AgentForceWorkflowonFail(agent: AgentForceAgent): AgentForceWorkflowiterate(items: any[] | string, agent: AgentForceAgent): AgentForceWorkflowdebug(): AgentForceWorkflow
Execution Methods
Section titled “Execution Methods”Execute the workflow and return results (ends the chain):
run(): Promise<any>loop(delayInMs?: number): void
Method Binding
Section titled “Method Binding”All public methods are bound to their respective implementations from the ./workflow/mod
module:
// Chainable methodspublic prompt: (userPrompt: string) => AgentForceWorkflow = prompt.bind(this);public dispatcher: (agent: AgentForceAgent) => AgentForceWorkflow = dispatcher.bind(this);public registerAgent: (agent: AgentForceAgent) => AgentForceWorkflow = registerAgent.bind(this);public sharedStore: (key: string, value: any) => AgentForceWorkflow = sharedStore.bind(this);public sequence: (agents: AgentForceAgent[]) => AgentForceWorkflow = sequence.bind(this);public parallel: (agents: AgentForceAgent[]) => AgentForceWorkflow = parallel.bind(this);public onSuccess: (agent: AgentForceAgent) => AgentForceWorkflow = onSuccess.bind(this);public onFail: (agent: AgentForceAgent) => AgentForceWorkflow = onFail.bind(this);public iterate: (items: any[] | string, agent: AgentForceAgent) => AgentForceWorkflow = iterate.bind(this);public debug: () => AgentForceWorkflow = debug.bind(this);
// Execute methodspublic run: () => Promise<any> = run.bind(this);public loop: (delayInMs?: number) => void = loop.bind(this);