# `Jidoka.Adapter.Jido.AgentServerState`
[🔗](https://github.com/agentjido/jidoka/blob/v0.9.0/lib/jidoka/adapter/jido/agent_server_state.ex#L1)

Formal Jidoka state contract stored inside a process-hosted Jido agent.

This is advanced integration support for applications that inspect or extend
the Jido process-hosting boundary. Direct and session chat do not need it.

`Jido.AgentServer` expects conventional top-level fields like `:status`,
`:last_answer`, and `:error`. Jidoka keeps those fields for Jido
compatibility and stores its typed turn/runtime state under `:jidoka`.

# `t`

```elixir
@type t() :: %Jidoka.Adapter.Jido.AgentServerState{
  agent_state: term(),
  error: nil | nil | any(),
  metadata: map(),
  request_id: nil | nil | binary(),
  result: nil | nil | term(),
  snapshot: nil | nil | term(),
  status: :idle | :running | :completed | :hibernated | :failed
}
```

# `completed`

```elixir
@spec completed(Jidoka.Turn.Result.t(), Jidoka.Turn.Request.t()) :: t()
```

Builds completed agent-server state from a turn result.

# `current_agent_state`

```elixir
@spec current_agent_state(map()) :: Jidoka.Agent.State.t()
```

Returns semantic agent state from a Jido state map.

# `failed`

```elixir
@spec failed(term(), Jidoka.Agent.State.t(), keyword() | map()) :: t()
```

Builds failed agent-server state while preserving semantic state.

# `from_input`

```elixir
@spec from_input(t() | keyword() | map() | nil) :: {:ok, t()} | {:error, term()}
```

Normalizes optional agent-server state input.

# `from_jido_state`

```elixir
@spec from_jido_state(map()) :: {:ok, t()} | {:error, term()}
```

Loads Jidoka state from a Jido agent state map.

# `from_jido_state!`

```elixir
@spec from_jido_state!(map()) :: t()
```

Loads Jidoka state from a Jido state map and raises on invalid data.

# `hibernated`

```elixir
@spec hibernated(Jidoka.Snapshot.t(), Jidoka.Turn.Request.t()) :: t()
```

Builds hibernated agent-server state from a snapshot.

# `new`

```elixir
@spec new(keyword() | map()) :: {:ok, t()} | {:error, term()}
```

Builds agent-server state from keyword or map attributes.

# `new!`

```elixir
@spec new!(keyword() | map()) :: t()
```

Builds agent-server state and raises if the attributes are invalid.

# `schema`

```elixir
@spec schema() :: Zoi.schema()
```

Returns the Zoi schema for Jidoka state stored in a Jido agent.

# `state_key`

```elixir
@spec state_key() :: atom()
```

Returns the key used to store Jidoka state in a Jido agent state map.

# `to_jido_state`

```elixir
@spec to_jido_state(t()) :: map()
```

Projects Jidoka agent-server state into a Jido state map.

# `to_run_result`

```elixir
@spec to_run_result(t()) ::
  {:ok, Jidoka.Turn.Result.t()}
  | {:hibernate, Jidoka.Snapshot.t()}
  | {:error, term()}
```

Converts terminal agent-server state to the public turn result shape.

---

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