Skip to main content

Module negotiate

Module negotiate 

Source
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§

CatalogRegistry
The catalogs an agent knows about.
ClientCapabilities
What a renderer says it can draw.
RegistryEntry
One catalog in a CatalogRegistry.

Functions§

select_catalog
select_catalog_schema, parsed into a typed Catalog.
select_catalog_schema
Picks the catalog document both sides can speak.