Class StatusManager

All Implemented Interfaces:
PropertyChangeSource, Rebindable

public class StatusManager extends BasicPropertyChangeSource
Manages and broadcasts the real-time operational status of an Agi session.

This manager acts as the 'Voice of Anahata', utilizing a PropertyChangeSource to provide reactive updates to the UI layer. It tracks state transitions, performance metrics, and coordinates the retry logic for API failures.

Author:
anahata
  • Field Details

    • agi

      private final Agi agi
      The orchestrator session instance managed by this status tracker.
    • apiErrors

      private final List<ApiErrorRecord> apiErrors
      List of all recorded API errors captured during this session.
    • currentStatus

      private AgiStatus currentStatus
      The current real-time operational status of the AGI session.
    • statusChangeTime

      private long statusChangeTime
      The epoch timestamp of the most recent status transition.
    • lastOperationDuration

      private long lastOperationDuration
      The duration of the last completed execution phase, in milliseconds.
    • currentBackoffAmount

      private long currentBackoffAmount
      The current active backoff duration in milliseconds for transient API retries.
  • Constructor Details

    • StatusManager

      public StatusManager(@NonNull @NonNull Agi agi)
      Constructs a new StatusManager bound to an active Agi session.
      Parameters:
      agi - The active Agi orchestrator.
  • Method Details

    • fireStatusChanged

      public void fireStatusChanged(AgiStatus newStatus)
      Fires a status change event.
      Parameters:
      newStatus - The new status.
    • fireStatusChanged

      public void fireStatusChanged(AgiStatus newStatus, String detailMessage)
      Fires a status change event, optionally with a detail message.
      Parameters:
      newStatus - The new status.
      detailMessage - A detail message (e.g., for tool execution).
    • fireApiError

      public void fireApiError(ApiErrorRecord errorRecord, AgiStatus status, String detailMessage)
      Records an API error and sets the agi status.
      Parameters:
      errorRecord - The ApiErrorRecord to record.
      status - The new agi status to set.
      detailMessage - A detail message for the status change.
    • getApiErrors

      public List<ApiErrorRecord> getApiErrors()
      Gets an unmodifiable list of all recorded API errors.
      Returns:
      The list of errors.
    • clearApiErrors

      public void clearApiErrors()
      Clears all recorded API errors. This should be called upon a successful API response.
    • reset

      public void reset()
      Resets the status manager to its initial state.