Class AgentForgeLoader

java.lang.Object
com.agentforge4j.config.loader.AgentForgeLoader

public final class AgentForgeLoader extends Object
Loads and validates agent and workflow configuration from filesystem and optional classpath bundles.
  • Constructor Details

  • Method Details

    • mergeBundledAgentsStrict

      public static void mergeBundledAgentsStrict(Map<String,AgentDefinition> target, Map<String,AgentDefinition> additions, String additionsDescription)
      Merges additions into target, failing if any agent id in additions is already present in target.
      Parameters:
      target - destination map to update
      additions - agents to merge into target
      additionsDescription - description used in duplicate-id errors
      Throws:
      DuplicateAgentIdException - when any id from additions already exists in target
    • mergeWorkflowsStrict

      public static void mergeWorkflowsStrict(Map<String,WorkflowDefinition> target, Map<String,WorkflowDefinition> additions, String additionsDescription)
      Merges workflow definitions into an existing map while rejecting duplicate workflow ids.
      Parameters:
      target - destination map to update
      additions - workflows to merge into target
      additionsDescription - description used in duplicate-id errors
      Throws:
      DuplicateWorkflowIdException - when any id from additions already exists in target
    • load

      public LoadedConfiguration load(Optional<Path> agentsDir, Optional<Path> workflowsDir, Optional<ClasspathAgentLoader> classpathAgentLoader, Optional<ClasspathWorkflowLoader> classpathWorkflowLoader)
      Loads configured agents and workflows from the provided sources and validates cross-references.
      Parameters:
      agentsDir - presence opts in to filesystem agent loading; the directory is determined by the injected AgentLoader
      workflowsDir - optional filesystem directory containing workflow bundles
      classpathAgentLoader - optional loader for shipped agents
      classpathWorkflowLoader - optional loader for shipped workflows
      Returns:
      loaded and validated configuration snapshot
      Throws:
      RuntimeException - when loading fails, duplicate ids are found, or validation fails
    • validate

      public void validate(Map<String,WorkflowDefinition> workflows, Map<String,AgentDefinition> agents)
      Runs the full workflow validation suite.
      Parameters:
      workflows - workflows to validate
      agents - agents available to workflow steps
      Throws:
      RuntimeException - when any validation rule fails
    • loadAgents

      public Map<String,AgentDefinition> loadAgents()
      Loads agent definitions from a filesystem directory.
      Returns:
      loaded agents keyed by id
    • loadWorkflows

      public Map<String,WorkflowDefinition> loadWorkflows(Path dir)
      Loads workflow definitions from a filesystem directory.
      Parameters:
      dir - directory containing workflow bundles
      Returns:
      loaded workflows keyed by id
    • loadWorkflowDirectory

      public WorkflowDirectoryLoad loadWorkflowDirectory(Path dir)
      Loads workflows and workflow-bundled agents from a filesystem directory.
      Parameters:
      dir - directory containing workflow bundles
      Returns:
      loaded workflows together with bundled agents