Raxol.MCP.StructuredScreenshot (Raxol MCP v2.6.0)

Copy Markdown View Source

Converts a view tree into a clean, JSON-friendly widget summary.

Used by the raxol_screenshot MCP tool to return structured content alongside the plain text capture. Strips callbacks and normalizes widget nodes to a consistent shape.

Summary

Functions

Convert a view tree map to a list of widget summaries.

Encode a widget summary list to a JSON string.

Types

widget_summary()

@type widget_summary() :: %{
  :type => atom(),
  :id => String.t() | nil,
  :children => [widget_summary()],
  optional(:content) => String.t(),
  optional(:animation_hints) => [map()],
  optional(:role) => atom(),
  optional(:label) => String.t(),
  optional(:state) => %{optional(atom()) => boolean() | atom()},
  optional(:value) => term(),
  optional(:focused) => boolean(),
  optional(:live) => boolean()
}

Functions

from_view_tree(tree, opts \\ [])

@spec from_view_tree(
  map() | list() | nil,
  keyword()
) :: [widget_summary()]

Convert a view tree map to a list of widget summaries.

Each node retains :type, :id, :content (if text), and recursed :children. All callbacks and style details are stripped. Accessibility fields (:role, :label, :state, :value, :focused, :live) are folded in per node via Raxol.Core.Accessibility.Projection so agents get a machine-readable role/state alongside the structural tree.

Options

  • :focused_id - Element id currently focused; marks that node focused: true in addition to any Component-reported focus.
  • :type_map - override the projection's declaration-type -> Component map.

to_json(summaries)

@spec to_json([widget_summary()]) :: String.t()

Encode a widget summary list to a JSON string.