Assembles a structured context tree from multiple sources.
The context tree provides a unified view of session state for AI agents. Different sources contribute subtrees (model projections, widget tree, tools, agents, notifications). Built on demand -- no cached state.
Sources
:model-- TEA model projections from registered resources:widgets-- current widget tree (types, IDs, bounds):tools-- list of available MCP tools:session-- session metadata (id, uptime)
Roles
filter_for_role/2 restricts the tree based on a role atom:
:full-- everything (default):observer-- model + widgets + session (no tools):operator-- model + widgets + tools + session
Summary
Functions
Build a context tree from the given sources.
Build a full context tree with all sources.
Filter a context tree for a given role.
Types
@type context() :: %{ registry: GenServer.server(), session_id: term(), view_tree: map() | list() | nil, model: map() | nil }
@type role() :: :full | :observer | :operator
@type source() :: :model | :widgets | :tools | :session
Functions
Build a context tree from the given sources.
The context map must include :registry and :session_id.
Optional keys: :view_tree, :model.
Build a full context tree with all sources.
Filter a context tree for a given role.