StoreFileBackend

org.llm4s.agent.harness.StoreFileBackend
See theStoreFileBackend companion object
@Experimental
final class StoreFileBackend extends FileBackend

A LongTermStore namespace as files, for /memories/: what the agent writes there outlives the thread. Each run uses Namespace(<the run's tenant>, path), so no run can reach another tenant's files, whatever the application configures (rule 8).

A file is an item keyed by its path, with value {"content": ...}; directories are implicit, as in StateFileBackend. Mutations lock files/store/<path>/<file> and run through ReplayGuard.transactional under ctx.effectKey("file.write" | "file.edit" | "file.delete", file), each as one store.modify, so an edit decides "old was not found", and a write the tree's shape, inside the store's transaction, and a replay whose first attempt landed returns the first outcome. The store's bounds hold, and an over-limit write is a tool error. Listings read at most the store's maxItems entries.

Attributes

Companion
object
Source
StoreFileBackend.scala
Graph
Supertypes
trait FileBackend
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

Removes the item at target, whatever it holds: the namespace is not validated, so an item a refusal names as corrupt can be deleted. A directory (items beneath) or nothing is refused.

Removes the item at target, whatever it holds: the namespace is not validated, so an item a refusal names as corrupt can be deleted. A directory (items beneath) or nothing is refused.

Attributes

Source
StoreFileBackend.scala
def edit(target: VPath, old: String, replacement: String, replaceAll: Boolean, ctx: FileContext): Result[(FileEdited, StateUpdate)]

Replaces old with replacement in the file path: the one occurrence, or every occurrence when replaceAll. Refused when old is empty or absent, or occurs more than once and not replaceAll.

Replaces old with replacement in the file path: the one occurrence, or every occurrence when replaceAll. Refused when old is empty or absent, or occurs more than once and not replaceAll.

Attributes

Source
StoreFileBackend.scala
def find(under: VPath, accept: VPath => Boolean, limit: Int, ctx: FileContext): Result[Listing[VPath]]

The files within under that accept takes, in path order, at most limit: accept is applied before the limit, so a file it refuses never takes a place (a composite passes a predicate that refuses the paths a mount shadows, and relies on this to fill its limit with visible files). search likewise.

The files within under that accept takes, in path order, at most limit: accept is applied before the limit, so a file it refuses never takes a place (a composite passes a predicate that refuses the paths a mount shadows, and relies on this to fill its limit with visible files). search likewise.

Attributes

Source
StoreFileBackend.scala
def locks(file: VPath): Set[LockKey]

The locks a mutation of path holds.

The locks a mutation of path holds.

Attributes

Source
StoreFileBackend.scala
def ls(dir: VPath, limit: Int, ctx: FileContext): Result[Listing[FileInfo]]

The entries directly beneath the directory path, in path order, at most limit.

The entries directly beneath the directory path, in path order, at most limit.

Attributes

Source
StoreFileBackend.scala
def read(file: VPath, offset: Int, limit: Int, ctx: FileContext): Result[FileLines]

At most limit lines of the file path, from the 0-based line offset.

At most limit lines of the file path, from the 0-based line offset.

Attributes

Source
StoreFileBackend.scala
override def readText(file: VPath, ctx: FileContext): Result[String]

The whole text of the file path exactly as it is stored, line endings and final newline included, for a caller that must write it back byte for byte: the harness puts back the standing files a sandboxed command changed with it (#3327). A missing file, or a directory, is a BackendRefused, as read refuses it. The default is a Left that is not a refusal - the backend cannot give the exact text - so the harness refuses to run a command whose changes to the standing files it could not put back; every llm4s backend overrides it.

The whole text of the file path exactly as it is stored, line endings and final newline included, for a caller that must write it back byte for byte: the harness puts back the standing files a sandboxed command changed with it (#3327). A missing file, or a directory, is a BackendRefused, as read refuses it. The default is a Left that is not a refusal - the backend cannot give the exact text - so the harness refuses to run a command whose changes to the standing files it could not put back; every llm4s backend overrides it.

Attributes

Definition Classes
Source
StoreFileBackend.scala
def search(under: VPath, regex: Pattern, accept: VPath => Boolean, limit: Int, ctx: FileContext): Result[Listing[GrepMatch]]

The lines matching regex of the files within under that accept takes, in path then line order. regex is the model's: match it with org.llm4s.security.RegexSafetyManager.safeFind, never a bare matcher, so a catastrophic pattern is bounded and cannot overflow the stack.

The lines matching regex of the files within under that accept takes, in path then line order. regex is the model's: match it with org.llm4s.security.RegexSafetyManager.safeFind, never a bare matcher, so a catastrophic pattern is bounded and cannot overflow the stack.

Attributes

Source
StoreFileBackend.scala
def write(target: VPath, text: String, ctx: FileContext): Result[(FileWritten, StateUpdate)]

Writes the file path, creating it or replacing it.

Writes the file path, creating it or replacing it.

Attributes

Source
StoreFileBackend.scala

Inherited methods

final def glob(pattern: Glob, under: VPath, limit: Int, ctx: FileContext): Result[Listing[VPath]]

The files within under whose path relative to under matches pattern.

The files within under whose path relative to under matches pattern.

Attributes

Inherited from:
FileBackend
Source
FileBackend.scala
final def grep(regex: String, under: VPath, include: Option[Glob], limit: Int, ctx: FileContext): Result[Listing[GrepMatch]]

The lines matching regex in the files within under. include filters the files: a pattern with no / matches a file's name, one with a / its path relative to under (as ripgrep's --glob).

The lines matching regex in the files within under. include filters the files: a pattern with no / matches a file's name, one with a / its path relative to under (as ripgrep's --glob).

Attributes

Inherited from:
FileBackend
Source
FileBackend.scala

Concrete fields

Attributes

Source
StoreFileBackend.scala

Attributes

Source
StoreFileBackend.scala
val writes: Set[StateKey[_, _]]

The state keys the StateUpdates of this backend's mutations touch; a tool declares them in writes.

The state keys the StateUpdates of this backend's mutations touch; a tool declares them in writes.

Attributes

Source
StoreFileBackend.scala