Class ResourceManager
java.lang.Object
uno.anahata.asi.agi.event.BasicPropertyChangeSource
uno.anahata.asi.agi.resource.ResourceManager
- All Implemented Interfaces:
ContextProvider, PropertyChangeSource, Rebindable
public class ResourceManager
extends BasicPropertyChangeSource
implements Rebindable, ContextProvider
The next-generation V2 Resource Manager.
This manager is URI-centric and capability-based. It orchestrates V2
Resource instances, providing a reactive and unified context source
for the AI model. It fires property change events to maintain UI synchronization.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AgiThe parent agi session.private booleanWhether this manager is currently providing context augmentation.Registry of V2 resources, keyed by UUID.Fields inherited from class BasicPropertyChangeSource
propertyChangeSupport -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindByPath(@NonNull String path) Finds a managed resource by its physical path.Finds a managed resource by its URI.Finds a managed resource by its uuidGets the list of immediate child context providers.Gets a detailed description of what this context provider does.getId()Gets the unique identifier for this context provider.getName()Gets the human-readable name of this context provider.Gets the parent context provider in the hierarchy, if any.Returns an unmodifiable list of currently managed resources.getUuidByUri(@NonNull String uri) Finds the UUID of a managed resource by its URI.private StringnormalizeUri(String uri) Normalizes a file URI string to the standard triple-slash format (file:///) while preserving UNC paths (file://host).voidpopulateMessage(RagMessage ragMessage) Populates the givenRagMessagewith dynamic, just-in-time context parts.voidrebind()Re-initializes the transientPropertyChangeSupportafter deserialization.voidRegisters a new V2 resource, making it managed by the framework.voidregisterAll(@NonNull Collection<Resource> toRegister, String registeredBy) Registers multiple resources in a single atomic operation.registerHandle(@NonNull ResourceHandle handle, String registeredBy) Registers a pre-created resource handle directly.registerPaths(@NonNull List<Path> paths, String registeredBy) Registers multiple filesystem paths as managed resources.voidResets the cached token counts across all currently registered resources, forcing a lazy recalculation on the next query.unregister(@NonNull String id) Unregisters a resource and cleans up its handle.unregisterAll(@NonNull Collection<String> ids) Unregisters multiple resources in a single operation and fires a single refresh event.Methods inherited from class BasicPropertyChangeSource
addPropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, removePropertyChangeListenerMethods 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, getSystemInstructions, isEffectivelyProviding, isProviding, setParentProvider, setProvidingMethods inherited from interface PropertyChangeSource
getPropertyChangeSupport
-
Field Details
-
agi
The parent agi session. -
resources
-
providing
private boolean providingWhether this manager is currently providing context augmentation.
-
-
Constructor Details
-
ResourceManager
public ResourceManager()
-
-
Method Details
-
register
-
registerAll
Registers multiple resources in a single atomic operation.This method filters out any resources whose URI is already registered to prevent duplicates. It performs the update within a synchronized block and fires exactly ONE property change event to maintain UI performance.
- Parameters:
toRegister- The collection of resources to register. Must not be null.registeredBy- A string describing who registered the resources.
-
unregister
-
unregisterAll
Unregisters multiple resources in a single operation and fires a single refresh event.- Parameters:
ids- The collection of resource UUIDs to unregister.- Returns:
- The list of successfully unregistered resources.
-
getResourcesList
-
findByUri
-
normalizeUri
-
findByPath
-
getUuidByUri
-
get
-
registerPaths
-
registerHandle
Registers a pre-created resource handle directly.Technical Purity: This convenience method avoids redundant handle creation cycles when a host-aware toolkit (like NetBeans) already has an authoritative object (like a FileObject).
- Parameters:
handle- The source handle.registeredBy- A description of the origin.- Returns:
- The created and registered Resource orchestrator.
-
getChildrenProviders
Gets the list of immediate child context providers.- Specified by:
getChildrenProvidersin interfaceContextProvider- Returns:
- The list of children, or an empty list if none.
-
rebind
public void rebind()Re-initializes the transientPropertyChangeSupportafter deserialization.- Specified by:
rebindin interfaceRebindable- Overrides:
rebindin classBasicPropertyChangeSource
-
populateMessage
Populates the givenRagMessagewith dynamic, just-in-time context parts. These parts are appended to the end of the user's prompt (RAG). Injects a summary of disabled V2 resources into the RAG message.- Specified by:
populateMessagein interfaceContextProvider- Parameters:
ragMessage- The message to be augmented with context.- Throws:
Exception- if an error occurs during context generation.
-
getId
Gets the unique identifier for this context provider.- Specified by:
getIdin interfaceContextProvider- Returns:
- The provider's ID.
-
getName
Gets the human-readable name of this context provider.- Specified by:
getNamein interfaceContextProvider- Returns:
- The provider's name.
-
getDescription
Gets a detailed description of what this context provider does.- Specified by:
getDescriptionin interfaceContextProvider- Returns:
- The provider's description.
-
getParentProvider
Gets the parent context provider in the hierarchy, if any.- Specified by:
getParentProviderin interfaceContextProvider- Returns:
- The parent provider, or null if this is a root provider.
-
resetTokenCounts
public void resetTokenCounts()Resets the cached token counts across all currently registered resources, forcing a lazy recalculation on the next query.
-

