Expand description
Agreeing with the renderer on which catalog to speak.
An agent knows several catalogs; a renderer supports some subset, and may
ship its own inline definitions for components only it has. Before the agent
can prompt a model it has to settle which catalog the surface will use, since
createSurface fixes that choice for the surface’s lifetime.
select_catalog is that negotiation. The renderer’s preference order wins
— it is the one that has to draw the result — and inline catalogs are merged
into the selection so a renderer can extend a standard catalog rather than
replace it.
use ag_ui_a2ui::toolkit::negotiate::{select_catalog_schema, ClientCapabilities};
use serde_json::json;
let mine = vec![json!({"catalogId": "basic"}), json!({"catalogId": "fancy"})];
let renderer = ClientCapabilities {
supported_catalog_ids: vec!["fancy".into(), "basic".into()],
inline_catalogs: vec![],
};
let chosen = select_catalog_schema(&mine, &renderer, false).unwrap();
assert_eq!(chosen["catalogId"], "fancy");Structs§
- Catalog
Registry - The catalogs an agent knows about.
- Client
Capabilities - What a renderer says it can draw.
- Registry
Entry - One catalog in a
CatalogRegistry.
Functions§
- select_
catalog select_catalog_schema, parsed into a typedCatalog.- select_
catalog_ schema - Picks the catalog document both sides can speak.