Planck.Headless.Widgets (Planck.Headless v0.2.2)

Copy Markdown View Source

RPC dispatch for sidecar-rendered widgets.

Mirrors Planck.Headless.Secrets's dispatch shape, but simpler: unlike secrets (which can be handled locally via EnvFile or remotely via a sidecar module), a widget always lives on the sidecar — there is no local implementation to fall back to. Every call becomes an :rpc.call/5 to Planck.Agent.Sidecar on the connected sidecar node, or the given fallback if there is none.

Every function here is a pass-through: the return value is whatever the widget module on the sidecar produced, untouched. See specs/widgets.md for the full widget design.

Summary

Functions

Return a widget's declared container type by id — see Planck.Agent.Widget.container/0.

Dispatch an action to a widget by id.

List the sidecar's widgets — the modules paired with its tools via their :widget field.

Render a widget by id.

Functions

container(widget_id)

@spec container(String.t()) ::
  {:ok, Planck.Agent.Widget.container()} | {:error, term()}

Return a widget's declared container type by id — see Planck.Agent.Widget.container/0.

dispatch_action(widget_id, action, args)

@spec dispatch_action(String.t(), String.t(), map()) :: :ok | {:error, term()}

Dispatch an action to a widget by id.

list()

@spec list() :: [module()]

List the sidecar's widgets — the modules paired with its tools via their :widget field.

render(widget_id, myself)

@spec render(String.t(), term()) :: {:ok, term()} | {:error, term()}

Render a widget by id.

myself is passed through opaquely — see Planck.Agent.Widget.render/1.