Prunes the protocol schemas a prompt shows the model.
Catalogs are pruned with A2UIAgent.CatalogTransformer; the
agent-to-renderer and common types schemas belong to the protocol, so
they are pruned here.
Summary
Functions
Keeps only the common type definitions in use: those the
referencing schemas refer to (as common_types.json#/$defs/<name> or
#/$defs/<name>) and those a definition in use refers to.
Keeps only the allowed messages of an agent-to-renderer schema.
Functions
Keeps only the common type definitions in use: those the
referencing schemas refer to (as common_types.json#/$defs/<name> or
#/$defs/<name>) and those a definition in use refers to.
Keeps only the allowed messages of an agent-to-renderer schema.
allowed names message actions ("createSurface") or message
definitions ("CreateSurfaceMessage"). The allowlist is read
literally: an empty one admits no message and unknown names are
ignored. Definitions only the removed messages use are removed too.
iex> schema = %{
...> "oneOf" => [%{"$ref" => "#/$defs/A"}, %{"$ref" => "#/$defs/B"}],
...> "$defs" => %{
...> "A" => %{"properties" => %{"createSurface" => %{"$ref" => "#/$defs/Shared"}}},
...> "B" => %{"properties" => %{"deleteSurface" => %{}}},
...> "Shared" => %{}
...> }
...> }
iex> pruned = A2UIAgent.SchemaPruning.prune_messages(schema, ["createSurface"])
iex> {pruned["oneOf"], Map.keys(pruned["$defs"])}
{[%{"$ref" => "#/$defs/A"}], ["A", "Shared"]}