Packages

A Fair Source multi-agent runtime with deterministic agent scoring and replayable run history.

Retired package: Deprecated - superseded — operator console moved to the Syntropy app

Current section

Files

Jump to
syntropy lib syntropy_web controllers api history_json.ex
Raw

lib/syntropy_web/controllers/api/history_json.ex

defmodule SyntropyWeb.Api.HistoryJSON do
@moduledoc false
alias SyntropyWeb.RuntimeViewHelpers
@spec snapshot(map()) :: map()
def snapshot(snapshot) do
%{
id: snapshot.id,
node_id: Map.get(snapshot, :node_id, "local"),
trigger_kind: snapshot.trigger_kind,
task_id: snapshot.task_id,
proposal_id: snapshot.proposal_id,
ranked_agent_ids: snapshot.ranked_agent_ids,
inserted_at: DateTime.to_iso8601(snapshot.inserted_at),
agents: Enum.map(snapshot.agents, &agent_snapshot/1)
}
end
defp agent_snapshot(agent) do
%{
id: agent.id,
runtime_id: Map.get(agent, :runtime_id, agent.id),
node_id: Map.get(agent, :node_id, "local"),
name: agent.name,
perspective: agent.perspective,
position: agent.position,
temporary: agent.temporary,
connections: RuntimeViewHelpers.ordered_connections(agent)
}
end
end