# `Wardrik.Workspaces`

Gives agents files: a tree of their own, shared trees, and files read into every turn.

In a definition, `files` in `tools` adds the file tools, `context` lists files to read into
every turn, and `workspace.shared` mounts shared trees:

    tools: [files]
    context: [MEMORY.md]
    workspace:
      shared:
        team: acme
        runbooks: {tree: acme/runbooks, mode: read}

Trees are named `org`, `org/name` or `org/@user/name`. The owner the name starts with can mount
it: acme's agents can mount `acme` and `acme/runbooks`, and jon's can mount `acme/@jon/notes`.

Other agents can only mount a tree that Wardrik's `:workspace` option shares, by resource pattern:

    workspace: [shared: %{"acme/runbooks" => [read: ["acme/*"], write: ["acme/agent/ops", "acme/agent/ops/*"]]}]

An agent's conversations share its tree.

## Context

`context` lists at most 20 files. As a map, it takes `files` and `max_bytes`, from 1024 to
262144. `max_bytes` is `16384` unless set.

# `resolve`

```elixir
@spec resolve(Wardrik.t(), String.t(), map(), boolean()) ::
  {:ok, capabilities: list(), middleware: list()} | {:error, Wardrik.Error.t()}
```

Returns the capabilities and middleware for the agent `id`'s workspace.

Capabilities hold the file tools if `files?` is `true`. Middleware reads `context` into every
turn. Returns an `invalid_request` error if the workspace or `context` is invalid.

# `settings`

```elixir
@spec settings(keyword() | nil) :: %{
  required(String.t()) =&gt; %{read: [String.t()], write: [String.t()]}
}
```

Returns the `:workspace` option as each shared tree's read and write patterns.

# `tree`

```elixir
@spec tree(String.t()) :: String.t()
```

Returns the agent `id`'s own tree. A conversation uses its agent's.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
