# `MingaAgent.Tool.Context`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_agent/tool/context.ex#L1)

Per-session runtime context for building executable agent tools.

This is a narrow capability object. It gives tool builders the project root, routed workspace access, command working directory data, and correlation ids without exposing raw session state.

# `t`

```elixir
@type t() :: %MingaAgent.Tool.Context{
  metadata: map(),
  project_root: String.t(),
  router_context: MingaAgent.ToolRouter.Context.t(),
  session_id: String.t() | nil
}
```

Opaque-ish runtime context passed to source-owned tool builders.

# `command_env`

```elixir
@spec command_env(t()) :: [{String.t(), String.t()}]
```

Returns command environment entries for this context.

# `delete_file`

```elixir
@spec delete_file(t(), String.t()) :: :ok | :passthrough | {:error, term()}
```

Deletes a file through the session router.

# `edit_file`

```elixir
@spec edit_file(t(), String.t(), String.t(), String.t()) ::
  :ok | :passthrough | {:error, term()}
```

Edits a file through the session router.

# `new`

```elixir
@spec new(keyword()) :: t()
```

Builds a tool context from runtime values.

# `read_file`

```elixir
@spec read_file(t(), String.t()) :: {:ok, binary()} | {:error, term()}
```

Reads a file through the session router.

# `tools_opts`

```elixir
@spec tools_opts(t()) :: keyword()
```

Returns opts accepted by `MingaAgent.Tools.all/1`.

# `working_dir`

```elixir
@spec working_dir(t()) :: String.t() | nil
```

Returns the command working directory for this context.

# `write_file`

```elixir
@spec write_file(t(), String.t(), binary()) :: :ok | :passthrough | {:error, term()}
```

Writes a file through the session router.

---

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