Package uno.anahata.ai.context.stateful


package uno.anahata.ai.context.stateful
This package provides a robust framework for managing "stateful resources" local resources, primarily files, whose state can change independently of the chat conversation. It ensures that the AI's view of these resources remains consistent with their real-world state on the disk.

Core Concepts:

The central challenge with using local files in a long-running conversation is that they can be modified or deleted by external processes. This package addresses that by providing a system to track, validate, and automatically manage the lifecycle of these resources within the chat context.

Key Components:

  • StatefulResource: A foundational interface that acts as a contract for any tool response that represents a trackable resource. It standardizes access to a unique ID, last modified timestamp, and size.
  • ResourceTracker: The proactive engine of this package. It scans the chat history for instances of StatefulResource, compares their recorded state against the live state on the file system, and is responsible for the automatic pruning of stale resources when a newer version is loaded into the context.
  • ResourceStatus: A simple yet crucial enum that provides a clear, machine-readable status for each tracked resource (e.g., VALID, STALE, DELETED).
  • StatefulResourceStatus: A data transfer object that aggregates all relevant information about a resource's state, providing a complete snapshot for diagnostics and UI representation.
  • Class
    Description
    Represents the status of a stateful resource in the context, indicating whether the version in memory is valid, stale, or has been deleted from disk.
    Tracks and manages stateful resources within the conversation context.
    An interface for objects that represent a stateful resource in the conversation context.
    A data class that holds the complete status of a stateful resource, comparing its state in the chat context versus its state on the physical disk.