A2UICore.Message.RendererToAgent (A2UICore v0.1.1)

Copy Markdown View Source

Builders for the messages a renderer sends to the agent (renderer_to_agent.json):

Every builder returns the wire map, version included (:version, "v1.0" unless given), ready to be encoded by a transport.

iex> A2UICore.Message.RendererToAgent.function_response("call-1", {:ok, 42})
%{
  "version" => "v1.0",
  "rendererFunctionResponse" => %{"functionCallId" => "call-1", "value" => 42}
}

Summary

Functions

An action message carrying event, the map A2UICore.State.Surface.dispatch_action/4 returns.

A callAgentFunction message: the renderer asks the agent to run call (a function call object, "@call"/"catalogId"/"args").

An error message. Options: :surface_id, :function_call_id and :path, each included when present, and :version.

A rendererFunctionResponse message: {:ok, value} for a result (value is always present, nil for a void function) or {:error, code, message}.

Functions

action(event, options \\ [])

(since 0.1.0)
@spec action(map(), keyword()) :: map()

An action message carrying event, the map A2UICore.State.Surface.dispatch_action/4 returns.

call_agent_function(surface_id, function_call_id, call, options \\ [])

(since 0.1.0)
@spec call_agent_function(String.t(), String.t(), map(), keyword()) :: map()

A callAgentFunction message: the renderer asks the agent to run call (a function call object, "@call"/"catalogId"/"args").

error(code, message, options \\ [])

(since 0.1.0)
@spec error(String.t(), String.t(), keyword()) :: map()

An error message. Options: :surface_id, :function_call_id and :path, each included when present, and :version.

The schema requires a validation error (VALIDATION_FAILED, UNALLOWED_PARENT, UNALLOWED_CHILD) to carry surfaceId and path, and any other error to carry exactly one of surfaceId and functionCallId.

function_response(function_call_id, outcome, options \\ [])

(since 0.1.0)
@spec function_response(
  String.t(),
  {:ok, term()} | {:error, String.t(), String.t()},
  keyword()
) ::
  map()

A rendererFunctionResponse message: {:ok, value} for a result (value is always present, nil for a void function) or {:error, code, message}.