Class AsiContainer

All Implemented Interfaces:
ContextProvider, PropertyChangeSource, Rebindable

public class AsiContainer extends AnahataToolkit
The definitive toolkit for managing and inspecting the ASI container and its active sessions. This toolkit provides deep visibility into the 'Working Memory' and 'Long-Term Context' of the ASI across all sessions.
Author:
anahata
  • Constructor Details

    • AsiContainer

      public AsiContainer()
  • Method Details

    • getSystemInstructions

      public List<String> getSystemInstructions() throws Exception
      Gets a list of system instruction strings provided by this context provider. These are typically prepended to the conversation as high-level guidance.

      Provides core instructions on how to programmatically query the container's AI providers and API keys from within NbJava scripts.

      Returns:
      A list of system instruction strings.
      Throws:
      Exception - if an error occurs during instruction generation.
    • populateMessage

      public void populateMessage(RagMessage ragMessage) throws Exception
      Populates the given RagMessage with dynamic, just-in-time context parts. These parts are appended to the end of the user's prompt (RAG).

      Populates the RAG message with container-level overview metadata, including host application ID, working directory, default template configuration, configured AI providers (summarized model counts), and active AGI sessions.

      Parameters:
      ragMessage - The target RAG message to populate.
      Throws:
      Exception - If an error occurs during message population.
    • listActiveAgis

      public String listActiveAgis()
      Returns a Markdown table of all active AGI sessions in the container.
      Returns:
      A Markdown table listing sessions.
    • listAiProviders

      public String listAiProviders(boolean includeModelIds)
      Returns a Markdown table of all configured AI providers, including their UUIDs, enabled status, class FQNs, endpoints, API key statuses, and model counts or model IDs.
      Parameters:
      includeModelIds - Whether to include the full comma-separated list of model IDs (true) or just the total count (false).
      Returns:
      A Markdown formatted table summarizing the container's AI providers.
    • listAiModels

      public String listAiModels(String providerUuid)
      Returns a Markdown table of available models for a specific AI provider or all providers if providerUuid is null.
      Parameters:
      providerUuid - Optional unique UUID of the AI provider. If null or empty, lists models across all providers.
      Returns:
      A Markdown table of models.
    • getAgiDetails

      public String getAgiDetails(String sessionId)
      Returns detailed metadata for a specific AGI session, including its enabled toolkits, context providers, and managed resources.
      Parameters:
      sessionId - The unique ID of the session.
      Returns:
      A Markdown summary of the session details.
    • createNewAgi

      public String createNewAgi(boolean open, boolean autoReplyTools, String nickName, String aiProviderUUID, String modelID, List<String> toolkitFqns, List<String> resourceURIs, String initialMessage, Map<String, ToolPermission> toolPermissions, ThinkingLevel thinkingLevel)
      Creates a new AGI session with comprehensive configuration options.
      Parameters:
      open - Whether to open the new AGI session in the host UI.
      autoReplyTools - Whether to automatically execute tool calls for the new session without waiting for manual user intervention.
      nickName - the nickname for the new AGI
      aiProviderUUID - Optional UUID of the AI provider to use. Will use container default if null.
      modelID - Optional ID of the AI model to select. Will use container default if null.
      toolkitFqns - Optional list of fully qualified toolkit class names to enable.
      resourceURIs - Optional list of resource URIs to register in the new session.
      initialMessage - Optional message to send to the new AGI immediately after creation.
      toolPermissions - Optional map of tool permission overrides for this session (e.g. tool name -> PROMPT, APPROVE_ALWAYS, DENY).
      thinkingLevel - the startup thinking level for the new AGI
      Returns:
      A confirmation message with the new session ID.
    • closeAgi

      public String closeAgi(String sessionId)
      Closes the UI tab/window of a specific active AGI session without disposing it.
      Parameters:
      sessionId - The unique ID of the session to close.
      Returns:
      A confirmation message.
    • disposeAgi

      public String disposeAgi(String sessionId)
      Permanently disposes of an active AGI session, closing its UI, shutting down its executors, and archiving its session file.
      Parameters:
      sessionId - The unique ID of the session to dispose.
      Returns:
      A confirmation message.
    • dumpHistory

      public String dumpHistory(String sessionId)
      Returns a plain text dump of the entire conversation history for a session.
      Parameters:
      sessionId - Optional session ID. If null, the current session is used.
      Returns:
      A text dump of the history.