# `BB.Reactor.Context`
[🔗](https://github.com/beam-bots/bb_reactor/blob/main/lib/bb/reactor/context.ex#L5)

BB context for reactor execution.

This struct is injected into the reactor context by `BB.Reactor.Middleware.Context`
and made available to all steps as `context.private.bb`.

## Fields

- `:robot_module` - The robot module (e.g., `MyRobot`)
- `:robot` - The static `BB.Robot` struct from `robot_module.robot()`
- `:robot_state` - The current robot state (`:disarmed`, `:idle`, `:executing`, etc.)
- `:execution_id` - Unique identifier for this reactor execution

## Usage in Steps

```elixir
def run(arguments, context, options) do
  bb = context.private.bb
  robot = bb.robot_module

  # Use robot module to invoke commands
  apply(robot, :move_to, [goal])
end
```

# `t`

```elixir
@type t() :: %BB.Reactor.Context{
  execution_id: reference(),
  robot: BB.Robot.t(),
  robot_module: module(),
  robot_state: BB.Robot.Runtime.robot_state()
}
```

# `new`

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

Create a new BB context for a reactor execution.

## Arguments

- `robot_module` - The robot module to use for this execution

## Examples

    iex> BB.Reactor.Context.new(MyRobot)
    %BB.Reactor.Context{
      robot_module: MyRobot,
      robot: %BB.Robot{...},
      robot_state: :idle,
      execution_id: #Reference<...>
    }

# `refresh_state`

```elixir
@spec refresh_state(t()) :: t()
```

Refresh the robot state from the runtime.

Call this to get the current robot state if it may have changed.

---

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