Jidoka.Adapter.Jido.AgentServerState (Jidoka v0.9.0)

Copy Markdown View Source

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.

Summary

Functions

Builds completed agent-server state from a turn result.

Returns semantic agent state from a Jido state map.

Builds failed agent-server state while preserving semantic state.

Normalizes optional agent-server state input.

Loads Jidoka state from a Jido agent state map.

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

Builds hibernated agent-server state from a snapshot.

Builds agent-server state from keyword or map attributes.

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

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

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

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

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

Types

t()

@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
}

Functions

completed(result, request)

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

Builds completed agent-server state from a turn result.

current_agent_state(jido_state)

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

Returns semantic agent state from a Jido state map.

failed(reason, agent_state \\ Agent.State.new!(), context \\ %{})

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

Builds failed agent-server state while preserving semantic state.

from_input(state)

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

Normalizes optional agent-server state input.

from_jido_state(jido_state)

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

Loads Jidoka state from a Jido agent state map.

from_jido_state!(jido_state)

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

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

hibernated(snapshot, request)

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

Builds hibernated agent-server state from a snapshot.

new(attrs \\ [])

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

Builds agent-server state from keyword or map attributes.

new!(attrs \\ [])

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

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

schema()

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

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

state_key()

@spec state_key() :: atom()

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

to_jido_state(state)

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

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

to_run_result(state)

@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.