ExAgent.Workspace.Backend behaviour (ExAgent v3.0.0)

View Source

Backend of an ExAgent.Workspace mount. Paths are validated relative paths with no leading slash. The mount root is the empty string. Text is UTF-8.

Stability — Candidate.

entries/4 returns a bounded recursive inventory under the requested directory, including directories. Reject an incomplete scan with {:error, :scan_limit}. Enforce the budgets before allocating backend data where the storage API permits. put/6 atomically compares existing text for edits. A whole-file write passes :any. A rejected write guarantees no change. Return {:unknown, :result_unconfirmed} when a write may have happened. The runtime journals writes under the ordinary tool protocol.

Summary

Types

config()

@type config() :: term()

entry()

@type entry() :: {String.t(), :file | :directory}

limits()

@type limits() :: %{
  file_bytes: pos_integer(),
  total_bytes: pos_integer(),
  entries: pos_integer()
}

reason()

@type reason() ::
  :invalid_path
  | :not_found
  | :not_directory
  | :not_file
  | :read_only
  | :file_limit
  | :scan_limit
  | :conflict
  | :unavailable
  | :unlisted

Callbacks

entries(config, t, t, limits)

@callback entries(config(), ExAgent.RunContext.t(), String.t(), limits()) ::
  {:ok, [entry()]} | {:error, reason()}

put(config, t, t, arg4, t, limits)

@callback put(
  config(),
  ExAgent.RunContext.t(),
  String.t(),
  :any | String.t(),
  String.t(),
  limits()
) ::
  :ok | {:error, reason()} | {:unknown, :result_unconfirmed}

read(config, t, t, limits)

@callback read(config(), ExAgent.RunContext.t(), String.t(), limits()) ::
  {:ok, String.t()} | {:error, reason()}