Class DesktopJava
- All Implemented Interfaces:
ContextProvider, PropertyChangeSource, Rebindable
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
-
Nested Class Summary
Nested classes/interfaces inherited from class Java
Java.AnahataClassLoader -
Field Summary
Fields inherited from class Java
agiClassLoader, agiCompiledClasses, classpathPrinter, defaultCompilerClasspath, parentFirstClassessFields inherited from class AnahataToolkit
childrenProviders, propertyChangeSupportFields inherited from class ToolContext
toolkit -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance of the toolkit and adds DesktopAgiTool to the list of parentFirstClasses. -
Method Summary
Modifier and TypeMethodDescriptionprotected Class<? extends ToolContext> The class the model should extend when generating Agi tools.Gets a list of system instruction strings provided by this context provider.voidpopulateMessage(RagMessage ragMessage) Populates the givenRagMessagewith dynamic, just-in-time context parts.Methods inherited from class Java
addParentFirstClasses, clearAllAgiClasses, compile, compile, compileAndExecute, compileAndExecute, compileBytecodes, compileBytecodes, compileInMemory, compileInMemoryBytecodes, compileInMemoryBytecodes, compileWithExternalJavac, createClassPathPrinter, createReloadingClassLoader, escapeArgFileOptions, findClassFallbackBytes, findJavacInJdkHome, formatInternalMethods, getAgiClassSources, getAllAgiCompiledBytecodes, getChildrenProviders, getClasspathPrinter, getDefaultClasspath, getDefaultJavaCompiler, getExtraClassLoaders, getInternalMethods, getKnownJdks, getOrCreateAgiClassLoader, getPrettyPrintedDefaultClasspath, initialize, logClassloading, postActivate, rebind, registerParentFirstClass, removeAgiClasses, removeParentFirstClasses, resetAgiClassLoader, resolveJavacPath, setDefaultClasspath, setProvidingMethods inherited from class AnahataToolkit
getDescription, getId, getName, getParentProvider, getPropertyChangeSupport, isEffectivelyProvidingMethods inherited from class ToolContext
addAttachment, addAttachment, addAttachment, addAttachment, error, error, error, getAgi, getApplicationMap, getAsiContainer, getAsiContainerMap, getCall, getExecutorService, getModelId, getModelMessage, getResourceManager, getResponse, getSessionMap, getThreadSafeLogger, getTool, getToolContext, getToolkit, getToolManager, getTurnMap, isToolExecution, log, peekResponse, runAsyncMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContextProvider
getAgi, getContextPosition, getFlattenedHierarchy, getFullyQualifiedId, getHeader, getIconId, getInstructionsTokenCount, getRagTokenCount, isProviding, setParentProvider, setProviding
-
Constructor Details
-
DesktopJava
public DesktopJava()Constructs a new instance of the toolkit and adds DesktopAgiTool to the list of parentFirstClasses.
-
-
Method Details
-
getSystemInstructions
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
runInEdtandrunInEdtAndWaitfor safe UI interactions.- Specified by:
getSystemInstructionsin interfaceContextProvider- Overrides:
getSystemInstructionsin classJava- Returns:
- the list of system instruction blocks.
- Throws:
Exception- if an error occurs while assembling instructions.
-
populateMessage
Populates the givenRagMessagewith 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:
populateMessagein interfaceContextProvider- Overrides:
populateMessagein classJava- Parameters:
ragMessage- the incoming RAG message to populate.- Throws:
Exception- if an error occurs during message population.
-
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:
getConcreteClassModelShouldExtendin classJava- Returns:
- the base AgiTool class.
-

