Class AgenorRuntime

java.lang.Object
dev.agenor.runtime.AgenorRuntime

public class AgenorRuntime extends Object
Main runtime for the Agenor framework with automatic agent discovery. Manages agent lifecycle, service discovery, and annotation processing.
  • Method Details

    • start

      public CompletableFuture<Void> start()
      Start the runtime and all registered agents
    • stop

      public CompletableFuture<Void> stop()
      Stop the runtime and all agents
    • getAgent

      public Optional<Agent> getAgent(String agentId)
      Get an agent by ID
    • getAgents

      public Collection<Agent> getAgents()
      Get all registered agents
    • registerAgent

      public void registerAgent(Agent agent)
      Register a new agent instance
    • createAgent

      public <T extends Agent> T createAgent(Class<T> agentClass)
      Create an agent from a class using annotation discovery
    • getAgentDirectory

      public AgentDirectory getAgentDirectory()
      Get the agent directory
    • getMessageDispatcher

      public MessageDispatcher getMessageDispatcher()
      Returns the MessageDispatcher for this runtime.
      Returns:
      the message dispatcher; never null
      Since:
      0.20.0
    • getDeadLetterQueue

      public DeadLetterQueue getDeadLetterQueue()
      Returns where this runtime records a message whose delivery it gave up on.

      Defaults to a bounded in-memory window. A dispatcher this runtime did not build itself writes here only if it was given the same queue instance — see AgenorRuntime.Builder.deadLetterQueue(DeadLetterQueue).

      Returns:
      the dead-letter queue; never null
      Since:
      0.32.0
    • getBehaviorScheduler

      public BehaviorScheduler getBehaviorScheduler()
      Get the behavior scheduler
    • getAgentContext

      public AgentContext getAgentContext()
      Returns an AgentContext wrapping the core runtime services.

      Useful when manually instantiating agents that implement Agent directly (without extending BaseAgent) and need all services in a single object:

      
       var agent = new MyDomainAgent(runtime.getAgentContext());
       runtime.registerAgent(agent);
       

      When agents are discovered via package scanning, AgentFactory builds and injects the context automatically — this method is only needed for manually registered agents.

      Returns:
      a new AgentContext built from the current runtime services
      Since:
      0.10.0
    • isRunning

      public boolean isRunning()
      Check if runtime is currently running
    • getLifecycleManager

      public LifecycleManager getLifecycleManager()
      Get the lifecycle manager
    • getConfiguration

      public AgenorConfiguration getConfiguration()
      Get the current configuration
    • getStats

      public AgenorRuntime.RuntimeStats getStats()
      Get runtime statistics
    • getTelemetry

      public AgenorTelemetry getTelemetry()
      Returns the AgenorTelemetry instance wired into this runtime.
      Returns:
      the telemetry instance; never null (falls back to noop)
      Since:
      0.19.0
    • getApprovalService

      public ApprovalHandle getApprovalService()
      Returns the singleton ApprovalHandle for this runtime.

      External systems (HTTP handlers, tests, webhooks) call this handle to submit human approval decisions for pending HumanCheckpointBehavior executions.

      Returns a NoopApprovalHandle when no HITL provider (e.g. agenor-runtime-ext) is on the classpath; its mutating methods throw UnsupportedOperationException.

      Returns:
      the approval handle; never null
      Since:
      0.13.0
    • unregisterAgent

      public CompletableFuture<Void> unregisterAgent(String agentId)
      Unregister an agent from runtime and directory
    • builder

      public static AgenorRuntime.Builder builder()
      Create a new runtime builder