Class Resources
- All Implemented Interfaces:
ContextProvider, PropertyChangeSource, Rebindable
This toolkit provides a unified interface for RAG-based context augmentation and persistent, surgical mutations of text-based resources. It abstracts the complexities of different storage protocols (File, URL, String) while enforcing optimistic locking and context integrity.
- Author:
- anahata
-
Field Summary
Fields inherited from class AnahataToolkit
childrenProviders, propertyChangeSupportFields inherited from class ToolContext
toolkit -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateTextFile(FullTextFileCreate create) Creates a new text file on the host filesystem and automatically registers it as a resource.Performs a set of semantic line edits (insertions, replacements, deletions) in an existing file.findAndReplaceInTextResource(TextResourceReplacements replacements, String reason) Performs surgical text replacements in an existing file.private StringgetActor()Intelligently resolves the actor string for registration heritage.Gets a list of system instruction strings provided by this context provider.loadResources(List<String> uriStrings, TextViewportSettings initialSettings) Loads multiple resources into the agi context in a single turn.voidsetFullView(List<String> resourceIds, boolean fullView) Enables or disables Full View mode for one or more text resources.voidsetProviding(List<String> resourceIds, boolean providing) Sets the 'providing' flag of various resources by their UUID.voidunloadResources(List<String> resourceIds) Unloads multiple resources from the context.voidunloadResourcesByUri(List<String> uris) Unloads resources by their URIs.Updates an existing text file using full content replacement.voidupdateViewport(String resourceId, TextViewportSettings settings) Updates the viewport configuration for an existing text resource.Methods inherited from class AnahataToolkit
getChildrenProviders, getDescription, getId, getName, getParentProvider, getPropertyChangeSupport, initialize, isEffectivelyProviding, postActivate, rebindMethods 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, populateMessage, setParentProvider, setProviding
-
Constructor Details
-
Resources
public Resources()
-
-
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.Injects critical surgical precision rules into the model's system prompt, ensuring environmental awareness during file mutations.
- Returns:
- A list of system instruction strings.
- Throws:
Exception- if an error occurs during instruction generation.
-
getActor
Intelligently resolves the actor string for registration heritage.Technical Purity: Inspects the current tool execution context to identify the model and tool responsible for the registration.
- Returns:
- The actor description string.
-
loadResources
public List<String> loadResources(List<String> uriStrings, TextViewportSettings initialSettings) throws Exception Loads multiple resources into the agi context in a single turn.- Parameters:
uriStrings- The URIs to load.initialSettings- Optional initial viewport configuration.- Returns:
- The list of unique resource identifiers.
- Throws:
Exception- if loading fails.
-
updateViewport
Updates the viewport configuration for an existing text resource.- Parameters:
resourceId- The UUID of the resource.settings- The new settings.- Throws:
Exception- if the resource is not found.
-
setFullView
Enables or disables Full View mode for one or more text resources.When Full View is enabled, the entire file content up to EOF is loaded into the prompt without character pagination or horizontal column truncation, while preserving line numbers.
- Parameters:
resourceIds- The list of unique resource identifiers.fullView- True to enable full view mode, false to revert to viewport settings.
-
unloadResources
-
unloadResourcesByUri
-
setProviding
-
createTextFile
Creates a new text file on the host filesystem and automatically registers it as a resource.- Parameters:
create- The creation DTO.- Returns:
- The new resource UUID.
- Throws:
Exception- if creation fails.
-
updateTextResource
Updates an existing text file using full content replacement.- Parameters:
update- The update DTO.- Returns:
- A standard unified diff of the changes applied.
- Throws:
Exception- if the update fails.
-
findAndReplaceInTextResource
public String findAndReplaceInTextResource(TextResourceReplacements replacements, String reason) throws Exception Performs surgical text replacements in an existing file.- Parameters:
replacements- The replacements DTO.reason- the overall reason for the update- Returns:
- A standard unified diff of the changes applied.
- Throws:
Exception- if replacements fail.
-
editTextResource
Performs a set of semantic line edits (insertions, replacements, deletions) in an existing file.This is the next-generation surgical editor that targets absolute coordinates from the RAG message without requiring mental arithmetic.
- Parameters:
edits- The semantic line edits DTO.- Returns:
- A standard unified diff of the changes applied.
- Throws:
Exception- if application fails.
-

