Class DesktopJava

All Implemented Interfaces:
ContextProvider, PropertyChangeSource, Rebindable

public class DesktopJava extends Java
An extension of the Java toolkit that provides Desktop java-specific execution utilities, such as EDT synchronization with context propagation.

This toolkit ensures that code running on the Event Dispatch Thread (EDT) can still access the tool execution context (logs, errors, attachments) by capturing and re-applying the thread-local state.

Author:
anahata
  • Constructor Details

    • DesktopJava

      public DesktopJava()
      Constructs a new instance of the toolkit and adds DesktopAgiTool to the list of parentFirstClasses.
  • 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 system instructions for runtime Java code compilation, detailing available methods, multi-threading patterns, memory safety, and JVM properties.

      Injects Desktop java specific execution helpers into the system instructions, enabling the model to use runInEdt and runInEdtAndWait for safe UI interactions.

      Specified by:
      getSystemInstructions in interface ContextProvider
      Overrides:
      getSystemInstructions in class Java
      Returns:
      the list of system instruction blocks.
      Throws:
      Exception - if an error occurs while assembling instructions.
    • 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).

      Adds session/container map keys, the abbreviated classpath manifest, in-memory compiled classes held by AgiClassLoader, and available Java compilers and JDKs to the RAG message.

      Augments the RAG message with the active JavaFX runtime status if available.

      Specified by:
      populateMessage in interface ContextProvider
      Overrides:
      populateMessage in class Java
      Parameters:
      ragMessage - the incoming RAG message to populate.
      Throws:
      Exception - if an error occurs during message population.
    • getConcreteClassModelShouldExtend

      protected Class<? extends ToolContext> getConcreteClassModelShouldExtend()
      The class the model should extend when generating Agi tools.

      In this base implementation, it returns OnTheFlyAgiTool, which provides the necessary context anchors (log, error, etc.) for the script.

      Configures the code generator to produce classes extending DesktopAgiTool, which provides the necessary plumbing for EDT-aware context propagation.

      Overrides:
      getConcreteClassModelShouldExtend in class Java
      Returns:
      the base AgiTool class.